2004-08-02 14:09:11 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* $RCSfile: databasedocument.cxx,v $
|
2008-06-06 13:02:08 +00:00
|
|
|
* $Revision: 1.45 $
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2008-04-10 11:44:35 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 05:39:27 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
2008-01-30 07:33:34 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
#include "datasource.hxx"
|
2005-03-10 15:33:50 +00:00
|
|
|
#include "databasedocument.hxx"
|
2004-08-02 14:09:11 +00:00
|
|
|
#include "dbastrings.hrc"
|
2008-01-30 07:33:34 +00:00
|
|
|
#include "module_dba.hxx"
|
|
|
|
|
2005-05-13 14:43:10 +00:00
|
|
|
#include <comphelper/documentconstants.hxx>
|
2007-11-21 14:37:45 +00:00
|
|
|
#include <comphelper/namedvaluecollection.hxx>
|
2007-04-16 15:23:47 +00:00
|
|
|
#include <comphelper/enumhelper.hxx>
|
2008-04-04 13:32:17 +00:00
|
|
|
#include <comphelper/numberedcollection.hxx>
|
|
|
|
#include <framework/titlehelper.hxx>
|
2004-08-02 14:09:11 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_XTRANSACTEDOBJECT_HPP_
|
|
|
|
#include <com/sun/star/embed/XTransactedObject.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
|
|
|
|
#include <com/sun/star/io/XActiveDataSource.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
|
|
|
|
#include <com/sun/star/io/XSeekable.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATOR_HPP_
|
|
|
|
#include <com/sun/star/task/XStatusIndicator.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATORFACTORY_HPP_
|
|
|
|
#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
|
|
|
|
#include <com/sun/star/document/XExporter.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
|
|
|
|
#include <com/sun/star/document/XFilter.hpp>
|
|
|
|
#endif
|
2005-03-10 15:33:50 +00:00
|
|
|
#ifndef _COM_SUN_STAR_TASK_ERRORCODEIOEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/task/ErrorCodeIOException.hpp>
|
|
|
|
#endif
|
2004-08-02 14:09:11 +00:00
|
|
|
#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
|
|
|
|
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREDATAACCESS_DOCUMENTCONTAINER_HXX_
|
|
|
|
#include "documentcontainer.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_
|
|
|
|
#include "databasecontext.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _URLOBJ_HXX
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
2007-07-24 11:04:32 +00:00
|
|
|
#ifndef TOOLS_DIAGNOSE_EX_H
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#endif
|
2005-03-10 15:33:50 +00:00
|
|
|
#ifndef _ERRCODE_HXX
|
|
|
|
#include <tools/errcode.hxx>
|
|
|
|
#endif
|
2005-02-02 13:01:30 +00:00
|
|
|
#ifndef _COMPHELPER_MEDIADESCRIPTOR_HXX_
|
|
|
|
#include <comphelper/mediadescriptor.hxx>
|
|
|
|
#endif
|
2005-03-01 18:13:53 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONSTORAGE_HPP_
|
|
|
|
#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
|
2004-08-02 14:09:11 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONBROADCASTER_HPP_
|
|
|
|
#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
|
|
|
|
#endif
|
2005-03-10 15:33:50 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_XEMBEDPERSIST_HPP_
|
|
|
|
#include <com/sun/star/embed/XEmbedPersist.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_EMBED_ENTRYINITMODES_HPP_
|
|
|
|
#include <com/sun/star/embed/EntryInitModes.hpp>
|
|
|
|
#endif
|
2004-08-02 14:09:11 +00:00
|
|
|
#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/view/XSelectionSupplier.hpp>
|
|
|
|
#endif
|
2004-11-17 13:43:36 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
|
|
|
|
#include <com/sun/star/document/XImporter.hpp>
|
|
|
|
#endif
|
2008-03-06 16:58:17 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SCRIPT_PROVIDER_XSCRIPTPROVIDERFACTORY_HPP_
|
|
|
|
#include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
|
|
|
|
#endif
|
2005-03-10 15:33:50 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2006-03-29 11:33:47 +00:00
|
|
|
#ifndef _CPPUHELPER_EXC_HLP_HXX_
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
|
|
|
#endif
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
#ifndef BOOST_BIND_HPP_INCLUDED
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
#endif
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::frame;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::document;
|
|
|
|
using namespace ::com::sun::star::io;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::embed;
|
|
|
|
using namespace ::com::sun::star::task;
|
|
|
|
using namespace ::com::sun::star::view;
|
2005-03-10 15:33:50 +00:00
|
|
|
using namespace ::com::sun::star::sdbc;
|
2004-08-02 14:09:11 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::xml::sax;
|
2008-03-06 16:58:17 +00:00
|
|
|
using namespace ::com::sun::star::script;
|
|
|
|
using namespace ::com::sun::star::script::provider;
|
|
|
|
using namespace ::com::sun::star::ui;
|
2004-08-02 14:09:11 +00:00
|
|
|
using namespace ::cppu;
|
|
|
|
using namespace ::osl;
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2008-06-06 13:02:08 +00:00
|
|
|
using ::com::sun::star::awt::XWindow;
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
//........................................................................
|
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
//........................................................................
|
2005-03-10 15:33:50 +00:00
|
|
|
|
|
|
|
//============================================================
|
|
|
|
//= ODatabaseContext
|
|
|
|
//============================================================
|
|
|
|
DBG_NAME(ODatabaseDocument)
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument()
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2008-01-30 07:33:34 +00:00
|
|
|
static ::dba::OAutoRegistration< ODatabaseDocument > aAutoRegistration;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl )
|
2005-12-21 12:34:54 +00:00
|
|
|
:ModelDependentComponent( _pImpl )
|
|
|
|
,ODatabaseDocument_OfficeDocument( getMutex() )
|
|
|
|
,m_aModifyListeners( getMutex() )
|
|
|
|
,m_aCloseListener( getMutex() )
|
|
|
|
,m_aDocEventListeners( getMutex() )
|
2008-03-06 16:58:17 +00:00
|
|
|
,m_aStorageListeners( getMutex() )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
DBG_CTOR(ODatabaseDocument,NULL);
|
2005-07-08 09:36:11 +00:00
|
|
|
|
2006-02-07 09:18:42 +00:00
|
|
|
osl_incrementInterlockedCount( &m_refCount );
|
|
|
|
{
|
|
|
|
impl_reparent_nothrow( m_xForms );
|
|
|
|
impl_reparent_nothrow( m_xReports );
|
|
|
|
impl_reparent_nothrow( m_pImpl->m_xTableDefinitions );
|
|
|
|
impl_reparent_nothrow( m_pImpl->m_xCommandDefinitions );
|
|
|
|
}
|
|
|
|
osl_decrementInterlockedCount( &m_refCount );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
ODatabaseDocument::~ODatabaseDocument()
|
2004-12-03 13:34:06 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
DBG_DTOR(ODatabaseDocument,NULL);
|
|
|
|
if ( !ODatabaseDocument_OfficeDocument::rBHelper.bInDispose && !ODatabaseDocument_OfficeDocument::rBHelper.bDisposed )
|
2004-12-03 13:34:06 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
acquire();
|
|
|
|
dispose();
|
2004-12-03 13:34:06 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-06 13:02:08 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL ODatabaseDocument::queryInterface( const Type& _rType ) throw (RuntimeException)
|
2008-04-04 13:32:17 +00:00
|
|
|
{
|
2008-04-08 11:46:07 +00:00
|
|
|
// strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
|
|
|
|
// which already contains macros. In this case, the database document itself is not
|
|
|
|
// allowed to contain macros, too.
|
|
|
|
if ( impl_shouldDisallowScripting_nolck_nothrow()
|
|
|
|
&& ( _rType.equals( XEmbeddedScripts::static_type() )
|
|
|
|
|| _rType.equals( XScriptInvocationContext::static_type() )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return Any();
|
|
|
|
|
2008-04-04 13:32:17 +00:00
|
|
|
Any aReturn = ODatabaseDocument_OfficeDocument::queryInterface(_rType);
|
|
|
|
if (!aReturn.hasValue())
|
|
|
|
aReturn = ODatabaseDocument_Title::queryInterface(_rType);
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::acquire( ) throw ()
|
|
|
|
{
|
|
|
|
ODatabaseDocument_OfficeDocument::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::release( ) throw ()
|
|
|
|
{
|
|
|
|
ODatabaseDocument_OfficeDocument::release();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) throw (RuntimeException)
|
|
|
|
{
|
2008-04-08 11:46:07 +00:00
|
|
|
Sequence< Type > aTypes = ::comphelper::concatSequences(
|
2008-04-04 13:32:17 +00:00
|
|
|
ODatabaseDocument_OfficeDocument::getTypes(),
|
|
|
|
ODatabaseDocument_Title::getTypes()
|
|
|
|
);
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
// strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
|
|
|
|
// which already contains macros. In this case, the database document itself is not
|
|
|
|
// allowed to contain macros, too.
|
|
|
|
if ( impl_shouldDisallowScripting_nolck_nothrow() )
|
2005-03-30 10:55:24 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
Sequence< Type > aStrippedTypes( aTypes.getLength() );
|
|
|
|
Type* pStripTo( aStrippedTypes.getArray() );
|
|
|
|
|
|
|
|
// strip XEmbeddedScripts, and immediately re-assign to aTypes
|
|
|
|
aTypes = Sequence< Type >(
|
|
|
|
pStripTo,
|
|
|
|
::std::remove_copy_if(
|
|
|
|
aTypes.getConstArray(),
|
|
|
|
aTypes.getConstArray() + aTypes.getLength(),
|
|
|
|
pStripTo,
|
|
|
|
::std::bind2nd( ::std::equal_to< Type >(), XEmbeddedScripts::static_type() )
|
|
|
|
) - pStripTo
|
|
|
|
);
|
|
|
|
|
|
|
|
// strip XScriptInvocationContext, and immediately re-assign to aTypes
|
|
|
|
aTypes = Sequence< Type >(
|
|
|
|
pStripTo,
|
|
|
|
::std::remove_copy_if(
|
|
|
|
aTypes.getConstArray(),
|
|
|
|
aTypes.getConstArray() + aTypes.getLength(),
|
|
|
|
pStripTo,
|
|
|
|
::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
|
|
|
|
) - pStripTo
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return aTypes;
|
|
|
|
}
|
2008-04-08 11:46:07 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< sal_Int8 > SAL_CALL ODatabaseDocument::getImplementationId( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
static ::cppu::OImplementationId * pId = 0;
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
static ::cppu::OImplementationId aId;
|
|
|
|
pId = &aId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pId->getImplementationId();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
bool ODatabaseDocument::impl_shouldDisallowScripting_nolck_nothrow() const
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( getMutex() );
|
|
|
|
// TODO: revert to the disabled code. The current version is just to be able
|
|
|
|
// to integrate an intermediate version of the CWS, which should behave as
|
|
|
|
// if no macros in DB docs are allowed
|
|
|
|
// if ( m_pImpl.is() && m_pImpl->hasAnyObjectWithMacros() )
|
|
|
|
return true;
|
|
|
|
// return false;
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// local functions
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static void lcl_stripLoadArguments( ::comphelper::NamedValueCollection& _rArguments, Sequence< PropertyValue >& _rArgs )
|
|
|
|
{
|
2008-06-06 13:02:08 +00:00
|
|
|
OSL_ENSURE( !_rArguments.has( "Model" ), "lcl_stripLoadArguments: this is suspicious (1)!" );
|
|
|
|
OSL_ENSURE( !_rArguments.has( "ViewName" ), "lcl_stripLoadArguments: this is suspicious (2)!" );
|
2008-03-06 16:58:17 +00:00
|
|
|
_rArguments.remove( "Model" );
|
2008-06-06 13:02:08 +00:00
|
|
|
_rArguments.remove( "ViewName" );
|
2008-03-06 16:58:17 +00:00
|
|
|
_rArguments >>= _rArgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static void lcl_extractAndStartStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Reference< XStatusIndicator >& _rxStatusIndicator,
|
|
|
|
Sequence< Any >& _rCallArgs )
|
|
|
|
{
|
|
|
|
try
|
2005-03-30 10:55:24 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
_rxStatusIndicator = _rArguments.getOrDefault( "StatusIndicator", _rxStatusIndicator );
|
|
|
|
if ( _rxStatusIndicator.is() )
|
|
|
|
{
|
|
|
|
_rxStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
|
2005-03-30 10:55:24 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
sal_Int32 nLength = _rCallArgs.getLength();
|
|
|
|
_rCallArgs.realloc( nLength + 1 );
|
|
|
|
_rCallArgs[ nLength ] <<= _rxStatusIndicator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2005-03-30 10:55:24 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
static Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const Sequence< PropertyValue >& _rDescriptor, const ::rtl::OUString _rURL )
|
2005-03-30 10:55:24 +00:00
|
|
|
{
|
2008-06-06 13:02:08 +00:00
|
|
|
::comphelper::NamedValueCollection aMediaDescriptor( _rDescriptor );
|
2008-03-06 16:58:17 +00:00
|
|
|
if ( _rURL.getLength() )
|
|
|
|
{
|
2008-06-06 13:02:08 +00:00
|
|
|
aMediaDescriptor.put( "FileName", _rURL );
|
|
|
|
aMediaDescriptor.put( "URL", _rURL );
|
2008-03-06 16:58:17 +00:00
|
|
|
}
|
2008-06-06 13:02:08 +00:00
|
|
|
return aMediaDescriptor.getPropertyValues();
|
2005-03-30 10:55:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::impl_reset_nothrow()
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2004-11-17 13:43:36 +00:00
|
|
|
try
|
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->clearConnections();
|
|
|
|
m_pImpl->disposeStorages();
|
2008-03-06 16:58:17 +00:00
|
|
|
m_pImpl->resetRootStroage();
|
2004-12-03 13:34:06 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
clearObjectContainer( m_xForms );
|
|
|
|
clearObjectContainer( m_xReports );
|
|
|
|
clearObjectContainer( m_pImpl->m_xTableDefinitions );
|
|
|
|
clearObjectContainer( m_pImpl->m_xCommandDefinitions );
|
2004-11-17 13:43:36 +00:00
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
m_pImpl->reset();
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
2007-11-21 14:37:45 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_bDocumentReadOnly = sal_False;
|
2008-03-06 16:58:17 +00:00
|
|
|
}
|
2004-11-17 13:43:36 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
bool ODatabaseDocument::impl_import_throw( const ::comphelper::NamedValueCollection& _rResource )
|
|
|
|
{
|
2004-11-17 13:43:36 +00:00
|
|
|
try
|
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
Sequence< Any > aFilterArgs;
|
|
|
|
Reference< XStatusIndicator > xStatusIndicator;
|
|
|
|
lcl_extractAndStartStatusIndicator( _rResource, xStatusIndicator, aFilterArgs );
|
2004-11-17 13:43:36 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XImporter > xImporter(
|
|
|
|
m_pImpl->m_aContext.createComponentWithArguments( "com.sun.star.comp.sdb.DBFilter", aFilterArgs ),
|
|
|
|
UNO_QUERY_THROW );
|
2004-11-17 13:43:36 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XComponent > xComponent( *this, UNO_QUERY_THROW );
|
|
|
|
xImporter->setTargetDocument( xComponent );
|
|
|
|
|
|
|
|
Reference< XFilter > xFilter( xImporter, UNO_QUERY_THROW );
|
|
|
|
xFilter->filter( m_pImpl->m_aArgs );
|
|
|
|
|
|
|
|
if ( xStatusIndicator.is() )
|
|
|
|
xStatusIndicator->end();
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
catch( const RuntimeException& e )
|
2004-11-17 13:43:36 +00:00
|
|
|
{
|
|
|
|
throw e;
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
catch( const Exception& )
|
2004-11-17 13:43:36 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
return false;
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XModel
|
|
|
|
// ATTENTION: The Application controller attaches the same resource to force a reload.
|
|
|
|
// TODO: this is a bug. By (API) definition, attachResource is only for notifying the document
|
|
|
|
// of its resource, *not* for loading it. We should implement an XLoadable, and move all the
|
|
|
|
// load logic therein.
|
|
|
|
sal_Bool SAL_CALL ODatabaseDocument::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _aArguments ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
|
|
|
impl_reset_nothrow();
|
|
|
|
|
|
|
|
::comphelper::NamedValueCollection aResource( _aArguments );
|
|
|
|
lcl_stripLoadArguments( aResource, m_pImpl->m_aArgs );
|
|
|
|
|
2008-05-05 14:50:07 +00:00
|
|
|
// now that somebody (perhaps) told us an macro execution mode, remember it as
|
|
|
|
// ImposedMacroExecMode
|
|
|
|
m_pImpl->setImposedMacroExecMode(
|
2008-06-06 13:02:08 +00:00
|
|
|
aResource.getOrDefault( "MacroExecutionMode", m_pImpl->getImposedMacroExecMode() ) );
|
2008-05-05 14:50:07 +00:00
|
|
|
|
2008-06-06 13:02:08 +00:00
|
|
|
::rtl::OUString sDocumentLocation( aResource.getOrDefault( "SalvagedFile", _rURL ) );
|
|
|
|
if ( !sDocumentLocation.getLength() )
|
2008-03-06 16:58:17 +00:00
|
|
|
// this indicates "the document is being recovered, but _rURL already is the real document URL,
|
|
|
|
// not the temporary document location"
|
2008-06-06 13:02:08 +00:00
|
|
|
sDocumentLocation = _rURL;
|
|
|
|
m_pImpl->switchToURL( sDocumentLocation, _rURL );
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
bool bSuccess =
|
|
|
|
( m_pImpl->getOrCreateRootStorage().is()
|
|
|
|
&& impl_import_throw( aResource ) // TODO: this doesn't belong here, but into an (externally called) XLoadable::load implementation
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( !bSuccess )
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
m_pImpl->revokeDataSource();
|
|
|
|
return sal_False;
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
impl_setModified_throw( sal_False, aGuard );
|
2004-08-02 14:09:11 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
::rtl::OUString SAL_CALL ODatabaseDocument::getURL( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2008-03-06 16:58:17 +00:00
|
|
|
return m_pImpl->getURL();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
return m_pImpl->m_aArgs;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::connectController( const Reference< XController >& _xController ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2007-11-21 14:37:45 +00:00
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
m_aControllers.push_back( _xController );
|
2007-11-21 14:37:45 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
if ( m_aControllers.size() != 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// it's the first controller
|
|
|
|
|
|
|
|
// check/adjust our macro mode. Note: This is only temporary. When we fully support the
|
|
|
|
// XEmbeddedScripts interface, plus related functionality, then the controller is able
|
|
|
|
// to do this itself, since we'll then have a UNO method for this.
|
|
|
|
//
|
|
|
|
// Also, the same has to happen in the loader then, since the checks must be made
|
|
|
|
// *before* OnLoad events are triggered - finally, the user can bind events to OnLoad ...
|
|
|
|
// (This, at the latest, implies we need a UNO equivalent for checkMacrosOnLoading, else
|
|
|
|
// the loader can't call it.)
|
|
|
|
//
|
|
|
|
// For now, as long as we do not have own macros, but only those in the embedded
|
|
|
|
// forms/reports, it's sufficient to do the check here.
|
|
|
|
//
|
|
|
|
m_pImpl->checkMacrosOnLoading();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::disconnectController( const Reference< XController >& _xController ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
2005-03-30 10:55:24 +00:00
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
Controllers::iterator pos = ::std::find( m_aControllers.begin(), m_aControllers.end(), _xController );
|
|
|
|
OSL_ENSURE( pos != m_aControllers.end(), "ODatabaseDocument::disconnectController: don't know this controller!" );
|
|
|
|
if ( pos != m_aControllers.end() )
|
|
|
|
m_aControllers.erase( pos );
|
2006-12-01 16:29:18 +00:00
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
if ( m_xCurrentController == _xController )
|
|
|
|
m_xCurrentController = NULL;
|
2006-03-29 11:33:47 +00:00
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
if ( m_aControllers.empty() )
|
2006-03-29 11:33:47 +00:00
|
|
|
{
|
2007-11-21 14:37:45 +00:00
|
|
|
// reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource
|
|
|
|
// object still exists), and somebody subsequently re-opens the document, we want to have
|
|
|
|
// the security warning, again.
|
|
|
|
m_pImpl->resetMacroExecutionMode();
|
|
|
|
|
2006-03-29 11:33:47 +00:00
|
|
|
// if this was the last view, close the document as a whole
|
|
|
|
// #i51157# / 2006-03-16 / frank.schoenheit@sun.com
|
|
|
|
try
|
|
|
|
{
|
|
|
|
close( sal_True );
|
|
|
|
}
|
|
|
|
catch( const CloseVetoException& )
|
|
|
|
{
|
|
|
|
// okay, somebody vetoed and took ownership
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::lockControllers( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
2005-03-30 10:55:24 +00:00
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
++m_pImpl->m_nControllerLockCount;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::unlockControllers( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
|
|
|
--m_pImpl->m_nControllerLockCount;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
sal_Bool SAL_CALL ODatabaseDocument::hasControllersLocked( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
|
|
|
return m_pImpl->m_nControllerLockCount != 0;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< XController > SAL_CALL ODatabaseDocument::getCurrentController() throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
return m_xCurrentController.is() ? m_xCurrentController : ( m_aControllers.empty() ? Reference< XController >() : *m_aControllers.begin() );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::setCurrentController( const Reference< XController >& _xController ) throw (NoSuchElementException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
m_xCurrentController = _xController;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< XInterface > SAL_CALL ODatabaseDocument::getCurrentSelection( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
Reference< XInterface > xRet;
|
|
|
|
Reference< XSelectionSupplier > xDocView( getCurrentController(), UNO_QUERY );
|
|
|
|
if ( xDocView.is() )
|
|
|
|
xRet.set(xDocView->getSelection(),UNO_QUERY);
|
|
|
|
|
|
|
|
return xRet;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// XStorable
|
2005-03-10 15:33:50 +00:00
|
|
|
sal_Bool SAL_CALL ODatabaseDocument::hasLocation( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2008-03-06 16:58:17 +00:00
|
|
|
return m_pImpl->getLocation().getLength() > 0;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
::rtl::OUString SAL_CALL ODatabaseDocument::getLocation( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2008-03-06 16:58:17 +00:00
|
|
|
return m_pImpl->getLocation();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
sal_Bool SAL_CALL ODatabaseDocument::isReadonly( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
|
|
|
return m_pImpl->m_bDocumentReadOnly;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::store( ) throw (IOException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2008-03-06 16:58:17 +00:00
|
|
|
//ModifyLock aLock( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
if ( m_pImpl->getLocation() == m_pImpl->getURL() )
|
|
|
|
if ( m_pImpl->m_bDocumentReadOnly )
|
|
|
|
throw IOException();
|
2005-02-02 13:01:30 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
impl_storeAs_throw( m_pImpl->getURL(), m_pImpl->m_aArgs, "OnSaveDone", aGuard );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::impl_storeAs_throw( const ::rtl::OUString& _rURL, const Sequence< PropertyValue>& _rArguments,
|
|
|
|
const sal_Char* _pAsciiDocumentEventName, ModelMethodGuard& _rGuard )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XStorage > xNewRootStorage;
|
|
|
|
// will be non-NULL if our storage changed
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
sal_Bool bLocationChanged = ( _rURL != m_pImpl->getLocation() );
|
|
|
|
if ( bLocationChanged )
|
2006-01-03 15:14:40 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
// create storage for target URL
|
2008-06-06 13:02:08 +00:00
|
|
|
Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( _rURL ) );
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
if ( m_pImpl->isEmbeddedDatabase() )
|
|
|
|
m_pImpl->clearConnections();
|
|
|
|
|
|
|
|
// commit everything
|
|
|
|
m_pImpl->commitEmbeddedStorage();
|
|
|
|
m_pImpl->commitStorages();
|
|
|
|
|
|
|
|
// copy own storage to target storage
|
|
|
|
Reference< XStorage > xCurrentStorage( m_pImpl->getRootStorage() );
|
|
|
|
if ( xCurrentStorage.is() )
|
|
|
|
xCurrentStorage->copyToStorage( xTargetStorage );
|
|
|
|
|
|
|
|
m_pImpl->disposeStorages();
|
|
|
|
|
|
|
|
xNewRootStorage = m_pImpl->switchToStorage( xTargetStorage );
|
|
|
|
|
|
|
|
m_pImpl->m_bDocumentReadOnly = sal_False;
|
2006-01-03 15:14:40 +00:00
|
|
|
}
|
2005-03-30 10:55:24 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
// adjust arguments
|
|
|
|
::comphelper::NamedValueCollection aResource( _rArguments );
|
|
|
|
lcl_stripLoadArguments( aResource, m_pImpl->m_aArgs );
|
|
|
|
Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( m_pImpl->m_aArgs, _rURL ) );
|
|
|
|
|
|
|
|
// store to current storage
|
|
|
|
Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW );
|
|
|
|
impl_storeToStorage_throw( xCurrentStorage, aMediaDescriptor );
|
|
|
|
|
|
|
|
// success - tell our impl the new URL
|
|
|
|
m_pImpl->switchToURL( _rURL, _rURL );
|
|
|
|
|
|
|
|
// create a document event (mutex still locked)
|
|
|
|
document::EventObject aEvent( *this, ::rtl::OUString::createFromAscii( _pAsciiDocumentEventName ) );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
// reset our "modified" flag, and clear the guard
|
|
|
|
impl_setModified_throw( sal_False, _rGuard );
|
|
|
|
|
|
|
|
// notify the document event
|
|
|
|
impl_notifyEvent_nolck_nothrow( aEvent );
|
|
|
|
|
|
|
|
// notify storage listeners
|
|
|
|
impl_notifyStorageChange_nolck_nothrow( xNewRootStorage );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-06 13:02:08 +00:00
|
|
|
Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const ::rtl::OUString& _rURL ) const
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
Sequence<Any> aParam(2);
|
|
|
|
aParam[0] <<= _rURL;
|
|
|
|
aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE;
|
|
|
|
|
2008-06-06 13:02:08 +00:00
|
|
|
Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory(), UNO_SET_THROW );
|
|
|
|
return Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::storeAsURL( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (IOException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2008-03-06 16:58:17 +00:00
|
|
|
//ModifyLock aLock( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
impl_storeAs_throw( _rURL, _rArguments, "OnSaveAsDone", aGuard );
|
|
|
|
}
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ODatabaseDocument::impl_storeToStorage_throw( const Reference< XStorage >& _rxTargetStorage, const Sequence< PropertyValue >& _rMediaDescriptor ) const
|
|
|
|
{
|
|
|
|
if ( !_rxTargetStorage.is() )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *const_cast< ODatabaseDocument* >( this ), 1 );
|
|
|
|
|
|
|
|
if ( !m_pImpl.is() )
|
|
|
|
throw DisposedException( ::rtl::OUString(), *const_cast< ODatabaseDocument* >( this ) );
|
2005-03-30 10:55:24 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
// commit everything
|
|
|
|
m_pImpl->commitEmbeddedStorage();
|
|
|
|
m_pImpl->commitStorages();
|
|
|
|
|
|
|
|
// copy own storage to target storage
|
|
|
|
Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW );
|
|
|
|
if ( xCurrentStorage != _rxTargetStorage )
|
|
|
|
xCurrentStorage->copyToStorage( _rxTargetStorage );
|
|
|
|
|
|
|
|
// write into target storage
|
2008-03-11 08:43:41 +00:00
|
|
|
::comphelper::NamedValueCollection aWriteArgs( _rMediaDescriptor );
|
|
|
|
writeStorage( _rxTargetStorage, aWriteArgs );
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
// commit target storage
|
|
|
|
OSL_VERIFY( m_pImpl->commitStorageIfWriteable_ignoreErrors( _rxTargetStorage ) );
|
2005-03-30 10:55:24 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
catch( const IOException& ) { throw; }
|
|
|
|
catch( const RuntimeException& ) { throw; }
|
|
|
|
catch ( const Exception& e )
|
2005-03-30 10:55:24 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
throw IOException( e.Message, *const_cast< ODatabaseDocument* >( this ) );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::storeToURL( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (IOException, RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
ModifyLock aLock( *this );
|
|
|
|
|
|
|
|
// create storage for target URL
|
2008-06-06 13:02:08 +00:00
|
|
|
Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( _rURL ) );
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
// extend media descriptor with URL
|
|
|
|
Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
|
|
|
|
|
|
|
|
// store to this storage
|
|
|
|
impl_storeToStorage_throw( xTargetStorage, aMediaDescriptor );
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XModifyBroadcaster
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::addModifyListener( const Reference< XModifyListener >& _xListener ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
|
2004-08-02 14:09:11 +00:00
|
|
|
m_aModifyListeners.addInterface(_xListener);
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::removeModifyListener( const Reference< XModifyListener >& _xListener ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
|
2004-08-02 14:09:11 +00:00
|
|
|
m_aModifyListeners.removeInterface(_xListener);
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XModifiable
|
2005-03-10 15:33:50 +00:00
|
|
|
sal_Bool SAL_CALL ODatabaseDocument::isModified( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
|
|
|
return m_pImpl->m_bModified;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::setModified( sal_Bool _bModified ) throw (PropertyVetoException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2008-03-06 16:58:17 +00:00
|
|
|
impl_setModified_throw( _bModified, aGuard );
|
2007-09-26 13:39:51 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2007-09-26 13:39:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::impl_setModified_throw( sal_Bool _bModified, ModelMethodGuard& _rGuard )
|
2007-09-26 13:39:51 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
if ( m_pImpl->m_bModified == _bModified )
|
|
|
|
return;
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
if ( m_pImpl->isModifyLocked() )
|
|
|
|
return;
|
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
m_pImpl->m_bModified = _bModified;
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
document::EventObject aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnModifyChanged" ) ) );
|
2007-09-26 13:39:51 +00:00
|
|
|
_rGuard.clear();
|
2005-12-21 12:34:54 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
m_aModifyListeners.notifyEach( &XModifyListener::modified, (const lang::EventObject&)aEvent );
|
|
|
|
impl_notifyEvent_nolck_nothrow( aEvent );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:32:17 +00:00
|
|
|
// ::com::sun::star::document::XEventBroadcaster
|
|
|
|
void SAL_CALL ODatabaseDocument::addEventListener(const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException)
|
2005-03-04 08:44:36 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
|
2005-03-04 08:44:36 +00:00
|
|
|
m_aDocEventListeners.addInterface(_xListener);
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2005-03-04 08:44:36 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:32:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::removeEventListener( const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException)
|
2005-03-04 08:44:36 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
|
2005-03-04 08:44:36 +00:00
|
|
|
m_aDocEventListeners.removeInterface(_xListener);
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2005-03-04 08:44:36 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::notifyEvent( const document::EventObject& _rEvent ) throw (RuntimeException)
|
2005-03-04 08:44:36 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-04 08:44:36 +00:00
|
|
|
// used only to forward external events (e.g. for doc creation) from the frame loader
|
|
|
|
// to the global event broadcaster and all other interested doc event listener.
|
2008-03-06 16:58:17 +00:00
|
|
|
document::EventObject aEvent( *this, _rEvent.EventName );
|
|
|
|
aGuard.clear();
|
|
|
|
impl_notifyEvent_nolck_nothrow( aEvent );
|
2005-03-04 08:44:36 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2005-03-04 08:44:36 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getPrinter( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2006-06-20 01:44:17 +00:00
|
|
|
DBG_ERROR( "ODatabaseDocument::getPrinter: not supported!" );
|
2004-08-02 14:09:11 +00:00
|
|
|
return Sequence< PropertyValue >();
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:44:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::setPrinter( const Sequence< PropertyValue >& /*aPrinter*/ ) throw (IllegalArgumentException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2006-06-20 01:44:17 +00:00
|
|
|
DBG_ERROR( "ODatabaseDocument::setPrinter: not supported!" );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:44:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::print( const Sequence< PropertyValue >& /*xOptions*/ ) throw (IllegalArgumentException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2006-06-20 01:44:17 +00:00
|
|
|
DBG_ERROR( "ODatabaseDocument::print: not supported!" );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-02-07 09:18:42 +00:00
|
|
|
void ODatabaseDocument::impl_reparent_nothrow( const WeakReference< XNameAccess >& _rxContainer )
|
|
|
|
{
|
|
|
|
Reference< XChild > xChild( _rxContainer.get(), UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( *this );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-04-19 12:18:41 +00:00
|
|
|
void ODatabaseDocument::clearObjectContainer( WeakReference< XNameAccess >& _rxContainer)
|
2006-02-07 09:18:42 +00:00
|
|
|
{
|
|
|
|
Reference< XNameAccess > xContainer = _rxContainer;
|
|
|
|
::comphelper::disposeComponent( xContainer );
|
|
|
|
|
2006-04-19 12:18:41 +00:00
|
|
|
Reference< XChild > xChild( _rxContainer.get(),UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( NULL );
|
|
|
|
_rxContainer = Reference< XNameAccess >();
|
2006-02-07 09:18:42 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType )
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
OSL_POSTCOND( m_pImpl.is(), "ODatabaseDocument::impl_getDocumentContainer_throw: Impl is NULL" );
|
|
|
|
|
|
|
|
if ( ( _eType != ODatabaseModelImpl::E_FORM ) && ( _eType != ODatabaseModelImpl::E_REPORT ) )
|
|
|
|
throw IllegalArgumentException();
|
|
|
|
|
|
|
|
bool bFormsContainer = _eType == ODatabaseModelImpl::E_FORM;
|
|
|
|
|
|
|
|
WeakReference< XNameAccess >& rContainerRef( bFormsContainer ? m_xForms : m_xReports );
|
|
|
|
Reference< XNameAccess > xContainer = rContainerRef;
|
|
|
|
if ( !xContainer.is() )
|
|
|
|
{
|
2007-11-21 14:37:45 +00:00
|
|
|
TContentPtr& rContainerData( m_pImpl->getObjectContainer( _eType ) );
|
2008-03-06 16:58:17 +00:00
|
|
|
rContainerRef = xContainer = new ODocumentContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, bFormsContainer );
|
2006-02-07 09:18:42 +00:00
|
|
|
impl_reparent_nothrow( xContainer );
|
|
|
|
}
|
|
|
|
return xContainer;
|
|
|
|
}
|
2007-07-24 11:04:32 +00:00
|
|
|
|
2006-02-07 09:18:42 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-09-23 11:04:55 +00:00
|
|
|
void ODatabaseDocument::impl_closeControllerFrames( sal_Bool _bDeliverOwnership )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2007-07-24 11:04:32 +00:00
|
|
|
Controllers aCopy = m_aControllers;
|
2005-09-23 11:04:55 +00:00
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
for ( Controllers::iterator aIter = aCopy.begin(); aIter != aCopy.end() ; ++aIter )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2007-07-24 11:04:32 +00:00
|
|
|
if ( !aIter->is() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
try
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2007-07-24 11:04:32 +00:00
|
|
|
Reference< XCloseable> xFrame( (*aIter)->getFrame(), UNO_QUERY );
|
|
|
|
if ( xFrame.is() )
|
|
|
|
xFrame->close( _bDeliverOwnership );
|
|
|
|
}
|
|
|
|
catch( const CloseVetoException& ) { throw; }
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-23 11:04:55 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
struct DisposeControllerFrame : public ::std::unary_function< Reference< XController >, void >
|
|
|
|
{
|
|
|
|
void operator()( const Reference< XController >& _rxController ) const
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( !_rxController.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Reference< XFrame > xFrame( _rxController->getFrame() );
|
|
|
|
::comphelper::disposeComponent( xFrame );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ODatabaseDocument::impl_disposeControllerFrames_nothrow()
|
|
|
|
{
|
|
|
|
Controllers aCopy;
|
|
|
|
aCopy.swap( m_aControllers ); // ensure m_aControllers is empty afterwards
|
|
|
|
::std::for_each( aCopy.begin(), aCopy.end(), DisposeControllerFrame() );
|
|
|
|
}
|
|
|
|
|
2005-09-23 11:04:55 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::close( sal_Bool _bDeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, RuntimeException)
|
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
document::EventObject aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnUnload" ) ) );
|
2005-09-23 11:04:55 +00:00
|
|
|
|
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
aGuard.clear();
|
|
|
|
m_aCloseListener.forEach< XCloseListener >(
|
|
|
|
boost::bind( &XCloseListener::queryClosing, _1, boost::cref( aEvent ), boost::cref( _bDeliverOwnership ) ) );
|
|
|
|
aGuard.reset();
|
2005-09-23 11:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl_closeControllerFrames( _bDeliverOwnership );
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
aGuard.clear();
|
|
|
|
|
|
|
|
m_aCloseListener.notifyEach( &XCloseListener::notifyClosing, (const lang::EventObject&)aEvent );
|
|
|
|
|
|
|
|
// notify the OnUnload at the earliest possibility - which is here and now
|
|
|
|
impl_notifyEvent_nolck_nothrow( aEvent );
|
2005-09-23 11:04:55 +00:00
|
|
|
|
|
|
|
dispose();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::addCloseListener( const Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
|
2004-10-22 07:58:51 +00:00
|
|
|
m_aCloseListener.addInterface(Listener);
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::removeCloseListener( const Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
|
|
|
|
m_aCloseListener.removeInterface(Listener);
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< XNameAccess > SAL_CALL ODatabaseDocument::getFormDocuments( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2006-02-07 09:18:42 +00:00
|
|
|
return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_FORM );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2006-02-07 09:18:42 +00:00
|
|
|
return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_REPORT );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const sal_Char* pStreamName,
|
|
|
|
const sal_Char* pServiceName, const Sequence< Any >& _rArguments, const Sequence< PropertyValue >& rMediaDesc,
|
|
|
|
const Reference<XStorage>& _xStorageToSaveTo ) const
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
OSL_ENSURE( pStreamName, "Need stream name!" );
|
|
|
|
OSL_ENSURE( pServiceName, "Need service name!" );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
// open stream
|
|
|
|
::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii( pStreamName );
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XStream > xStream = _xStorageToSaveTo->openStreamElement( sStreamName, ElementModes::READWRITE | ElementModes::TRUNCATE );
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( !xStream.is() )
|
2008-03-06 16:58:17 +00:00
|
|
|
return;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
|
|
|
|
OSL_ENSURE( xOutputStream.is(), "Can't create output stream in package!" );
|
|
|
|
if ( !xOutputStream.is() )
|
|
|
|
return;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XSeekable > xSeek( xOutputStream, UNO_QUERY );
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( xSeek.is() )
|
|
|
|
xSeek->seek(0);
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XPropertySet > xStreamProp( xOutputStream, UNO_QUERY_THROW );
|
|
|
|
xStreamProp->setPropertyValue( INFO_MEDIATYPE, makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/xml" ) ) ) );
|
|
|
|
xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) ), makeAny( (sal_Bool)sal_True ) );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
// write the stuff
|
2008-03-06 16:58:17 +00:00
|
|
|
WriteThroughComponent( xOutputStream, xComponent, pServiceName, _rArguments, rMediaDesc );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >& xOutputStream,
|
|
|
|
const Reference< XComponent >& xComponent, const sal_Char* pServiceName, const Sequence< Any >& _rArguments,
|
|
|
|
const Sequence< PropertyValue >& rMediaDesc ) const
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
|
|
|
|
OSL_ENSURE( xComponent.is(), "Need component!" );
|
|
|
|
OSL_ENSURE( NULL != pServiceName, "Need component name!" );
|
|
|
|
|
|
|
|
// get component
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XActiveDataSource > xSaxWriter;
|
|
|
|
OSL_VERIFY( m_pImpl->m_aContext.createComponent( "com.sun.star.xml.sax.Writer", xSaxWriter ) );
|
|
|
|
if ( !xSaxWriter.is() )
|
|
|
|
return;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
// connect XML writer to output stream
|
|
|
|
xSaxWriter->setOutputStream( xOutputStream );
|
|
|
|
|
|
|
|
// prepare arguments (prepend doc handler to given arguments)
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XDocumentHandler > xDocHandler( xSaxWriter,UNO_QUERY);
|
|
|
|
Sequence<Any> aArgs( 1 + _rArguments.getLength() );
|
2004-08-02 14:09:11 +00:00
|
|
|
aArgs[0] <<= xDocHandler;
|
2008-03-06 16:58:17 +00:00
|
|
|
for ( sal_Int32 i = 0; i < _rArguments.getLength(); ++i )
|
|
|
|
aArgs[ i+1 ] = _rArguments[i];
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
// get filter component
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XExporter > xExporter;
|
|
|
|
OSL_VERIFY( m_pImpl->m_aContext.createComponentWithArguments( pServiceName, aArgs, xExporter ) );
|
|
|
|
if ( !xExporter.is() )
|
|
|
|
return;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
// connect model and filter
|
|
|
|
xExporter->setSourceDocument( xComponent );
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
// filter
|
|
|
|
Reference< XFilter > xFilter( xExporter, UNO_QUERY_THROW );
|
|
|
|
xFilter->filter( rMediaDesc );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::writeStorage( const Reference< XStorage >& _rxTargetStorage, const ::comphelper::NamedValueCollection& _rMediaDescriptor ) const
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
// extract status indicator
|
2005-03-30 10:55:24 +00:00
|
|
|
Sequence< Any > aDelegatorArguments;
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XStatusIndicator > xStatusIndicator;
|
|
|
|
lcl_extractAndStartStatusIndicator( _rMediaDescriptor, xStatusIndicator, aDelegatorArguments );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XPropertySet > xProp( _rxTargetStorage, UNO_QUERY_THROW );
|
|
|
|
xProp->setPropertyValue( INFO_MEDIATYPE, makeAny( (rtl::OUString)MIMETYPE_OASIS_OPENDOCUMENT_DATABASE ) );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XComponent > xComponent( *const_cast< ODatabaseDocument* >( this ), UNO_QUERY_THROW );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
Sequence< PropertyValue > aMediaDescriptor;
|
|
|
|
_rMediaDescriptor >>= aMediaDescriptor;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
WriteThroughComponent( xComponent, "settings.xml", "com.sun.star.comp.sdb.XMLSettingsExporter",
|
|
|
|
aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
WriteThroughComponent( xComponent, "content.xml", "com.sun.star.comp.sdb.DBExportFilter",
|
|
|
|
aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
m_pImpl->storeLibraryContainersTo( _rxTargetStorage );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
if ( xStatusIndicator.is() )
|
|
|
|
xStatusIndicator->end();
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XUIConfigurationManager > SAL_CALL ODatabaseDocument::getUIConfigurationManager( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( !m_xUIConfigurationManager.is() )
|
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
m_pImpl->m_aContext.createComponent( "com.sun.star.ui.UIConfigurationManager", m_xUIConfigurationManager );
|
|
|
|
Reference< XUIConfigurationStorage > xUIConfigStorage( m_xUIConfigurationManager, UNO_QUERY );
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( xUIConfigStorage.is() )
|
|
|
|
{
|
|
|
|
rtl::OUString aUIConfigFolderName( RTL_CONSTASCII_USTRINGPARAM( "Configurations2" ));
|
|
|
|
Reference< XStorage > xConfigStorage;
|
|
|
|
|
|
|
|
// First try to open with READWRITE and then READ
|
|
|
|
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, ElementModes::READWRITE );
|
|
|
|
if ( xConfigStorage.is() )
|
|
|
|
{
|
|
|
|
rtl::OUString aUIConfigMediaType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.ui.configuration" ));
|
|
|
|
rtl::OUString aMediaType;
|
|
|
|
Reference< XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
|
2007-11-09 07:11:44 +00:00
|
|
|
Any a = xPropSet->getPropertyValue( INFO_MEDIATYPE );
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( !( a >>= aMediaType ) || ( aMediaType.getLength() == 0 ))
|
|
|
|
{
|
|
|
|
a <<= aUIConfigMediaType;
|
2007-11-09 07:11:44 +00:00
|
|
|
xPropSet->setPropertyValue( INFO_MEDIATYPE, a );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, ElementModes::READ );
|
|
|
|
|
|
|
|
// initialize ui configuration manager with document substorage
|
|
|
|
xUIConfigStorage->setStorage( xConfigStorage );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_xUIConfigurationManager;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< XStorage > SAL_CALL ODatabaseDocument::getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
Reference< XDocumentSubStorageSupplier > xStorageAccess( m_pImpl->getDocumentSubStorageSupplier() );
|
|
|
|
return xStorageAccess->getDocumentSubStorage( aStorageName, nMode );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Sequence< ::rtl::OUString > SAL_CALL ODatabaseDocument::getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-07-08 09:36:11 +00:00
|
|
|
Reference< XDocumentSubStorageSupplier > xStorageAccess( m_pImpl->getDocumentSubStorageSupplier() );
|
|
|
|
return xStorageAccess->getDocumentSubStoragesNames();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void ODatabaseDocument::impl_notifyEvent_nolck_nothrow( const document::EventObject& _rEvent )
|
2005-02-02 13:01:30 +00:00
|
|
|
{
|
2005-03-04 08:44:36 +00:00
|
|
|
try
|
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
m_aDocEventListeners.notifyEach( &XEventListener::notifyEvent, _rEvent );
|
2005-03-04 08:44:36 +00:00
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
catch(const Exception&)
|
2005-02-02 13:01:30 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2005-02-02 13:01:30 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void ODatabaseDocument::impl_notifyStorageChange_nolck_nothrow( const Reference< XStorage >& _rxNewRootStorage )
|
|
|
|
{
|
|
|
|
Reference< XInterface > xMe( *const_cast< ODatabaseDocument* >( this ) );
|
|
|
|
|
|
|
|
m_aStorageListeners.forEach< XStorageChangeListener >(
|
|
|
|
boost::bind( &XStorageChangeListener::notifyStorageChange, _1, boost::cref( xMe ), boost::cref( _rxNewRootStorage ) ) );
|
|
|
|
}
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void ODatabaseDocument::disposing()
|
2005-01-21 16:03:37 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
if ( !m_pImpl.is() )
|
|
|
|
{
|
|
|
|
// this means that we're already disposed
|
|
|
|
DBG_ASSERT( ODatabaseDocument_OfficeDocument::rBHelper.bDisposed, "ODatabaseDocument::disposing: no impl anymore, but not yet disposed!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-24 11:04:32 +00:00
|
|
|
DBG_ASSERT( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" );
|
2006-12-01 16:29:18 +00:00
|
|
|
// normally, nobody should explicitly dispose, but only XCloseable::close the document. And upon
|
2006-03-29 11:33:47 +00:00
|
|
|
// closing, our controllers are closed, too
|
2005-09-23 11:04:55 +00:00
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
Reference< XModel > xHoldAlive( this );
|
2005-01-21 16:03:37 +00:00
|
|
|
{
|
2008-04-04 13:32:17 +00:00
|
|
|
{
|
2008-04-08 11:46:07 +00:00
|
|
|
document::EventObject aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnLoad" ) ) );
|
|
|
|
impl_notifyEvent_nolck_nothrow( aEvent );
|
2008-04-04 13:32:17 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
lang::EventObject aDisposeEvent(static_cast<XWeak*>(this));
|
2005-03-10 15:33:50 +00:00
|
|
|
m_aModifyListeners.disposeAndClear( aDisposeEvent );
|
|
|
|
m_aCloseListener.disposeAndClear( aDisposeEvent );
|
|
|
|
m_aDocEventListeners.disposeAndClear( aDisposeEvent );
|
2008-03-06 16:58:17 +00:00
|
|
|
m_aStorageListeners.disposeAndClear( aDisposeEvent );
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
m_xUIConfigurationManager = NULL;
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2008-03-06 16:58:17 +00:00
|
|
|
clearObjectContainer( m_xForms );
|
|
|
|
clearObjectContainer( m_xReports );
|
2005-05-06 08:18:46 +00:00
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
m_pImpl->modelIsDisposing( ODatabaseModelImpl::ResetModelAccess() );
|
2006-12-01 16:29:18 +00:00
|
|
|
|
|
|
|
// now, at the latest, the controller array should be empty. Controllers are
|
|
|
|
// expected to listen for our disposal, and disconnect then
|
2007-07-24 11:04:32 +00:00
|
|
|
DBG_ASSERT( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" );
|
|
|
|
impl_disposeControllerFrames_nothrow();
|
2008-04-04 13:32:17 +00:00
|
|
|
m_xModuleManager.clear();
|
|
|
|
m_xTitleHelper.clear();
|
2005-01-21 16:03:37 +00:00
|
|
|
}
|
2006-12-01 16:29:18 +00:00
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl.clear();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XComponent
|
|
|
|
void SAL_CALL ODatabaseDocument::dispose( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::cppu::WeakComponentImplHelperBase::dispose();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::addEventListener( const Reference< lang::XEventListener >& _xListener ) throw (RuntimeException)
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
::cppu::WeakComponentImplHelperBase::addEventListener( _xListener );
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::removeEventListener( const Reference< lang::XEventListener >& _xListener ) throw (RuntimeException)
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
::cppu::WeakComponentImplHelperBase::removeEventListener( _xListener );
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
|
|
|
// XServiceInfo
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
rtl::OUString ODatabaseDocument::getImplementationName( ) throw(RuntimeException)
|
|
|
|
{
|
2008-01-30 07:33:34 +00:00
|
|
|
return getImplementationName_static();
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2008-01-30 07:33:34 +00:00
|
|
|
rtl::OUString ODatabaseDocument::getImplementationName_static( ) throw(RuntimeException)
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
|
|
|
return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ODatabaseDocument");
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames( ) throw (RuntimeException)
|
|
|
|
{
|
2008-01-30 07:33:34 +00:00
|
|
|
return getSupportedServiceNames_static();
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2008-01-30 07:33:34 +00:00
|
|
|
Reference< XInterface > ODatabaseDocument::Create( const Reference< XComponentContext >& _rxContext )
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
2008-01-30 07:33:34 +00:00
|
|
|
::comphelper::ComponentContext aContext( _rxContext );
|
|
|
|
Reference< XUnoTunnel > xDBContextTunnel( aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), UNO_QUERY_THROW );
|
|
|
|
ODatabaseContext* pContext = reinterpret_cast< ODatabaseContext* >( xDBContextTunnel->getSomething( ODatabaseContext::getUnoTunnelImplementationId() ) );
|
|
|
|
|
|
|
|
::rtl::Reference<ODatabaseModelImpl> pImpl( new ODatabaseModelImpl( aContext.getLegacyServiceFactory() ) );
|
|
|
|
pImpl->m_pDBContext = pContext;
|
|
|
|
Reference< XModel > xModel( pImpl->createNewModel_deliverOwnership() );
|
|
|
|
return xModel.get();
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2008-01-30 07:33:34 +00:00
|
|
|
Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames_static( ) throw (RuntimeException)
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aSNS( 2 );
|
|
|
|
aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument"));
|
|
|
|
aSNS[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.OfficeDocument"));
|
|
|
|
return aSNS;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool ODatabaseDocument::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XDataSource > SAL_CALL ODatabaseDocument::getDataSource() throw (RuntimeException)
|
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
ModelMethodGuard aGuard( *this );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
return m_pImpl->getDataSource();
|
|
|
|
}
|
2008-03-06 16:58:17 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::loadFromStorage( const Reference< XStorage >& /*xStorage*/, const Sequence< PropertyValue >& /*aMediaDescriptor*/ ) throw (IllegalArgumentException, DoubleInitializationException, IOException, Exception, RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
throw Exception(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Embedding of database documents is not supported." ) ),
|
|
|
|
// TODO: resource
|
|
|
|
*this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::storeToStorage( const Reference< XStorage >& _rxStorage, const Sequence< PropertyValue >& _rMediaDescriptor ) throw (IllegalArgumentException, IOException, Exception, RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
//ModifyLock aLock( *this );
|
|
|
|
|
|
|
|
impl_storeToStorage_throw( _rxStorage, _rMediaDescriptor );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::switchToStorage( const Reference< XStorage >& _rxNewRootStorage ) throw (IllegalArgumentException, IOException, Exception, RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
Reference< XStorage > xNewRootStorage( m_pImpl->switchToStorage( _rxNewRootStorage ) );
|
|
|
|
|
|
|
|
aGuard.clear();
|
|
|
|
impl_notifyStorageChange_nolck_nothrow( xNewRootStorage );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XStorage > SAL_CALL ODatabaseDocument::getDocumentStorage( ) throw (IOException, Exception, RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
return m_pImpl->getRootStorage();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::addStorageChangeListener( const Reference< XStorageChangeListener >& _Listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
m_aStorageListeners.addInterface( _Listener );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::removeStorageChangeListener( const Reference< XStorageChangeListener >& _Listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
m_aStorageListeners.addInterface( _Listener );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XStorageBasedLibraryContainer > SAL_CALL ODatabaseDocument::getBasicLibraries() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
return m_pImpl->getLibraryContainer( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XStorageBasedLibraryContainer > SAL_CALL ODatabaseDocument::getDialogLibraries() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
return m_pImpl->getLibraryContainer( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::sal_Bool SAL_CALL ODatabaseDocument::getAllowMacroExecution() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
return m_pImpl->adjustMacroMode_AutoReject();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XEmbeddedScripts > SAL_CALL ODatabaseDocument::getScriptContainer() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< provider::XScriptProvider > SAL_CALL ODatabaseDocument::getScriptProvider( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
Reference< XScriptProvider > xScriptProvider( m_xScriptProvider );
|
|
|
|
if ( !xScriptProvider.is() )
|
|
|
|
{
|
|
|
|
Reference < XScriptProviderFactory > xFactory(
|
|
|
|
m_pImpl->m_aContext.getSingleton( "com.sun.star.script.provider.theMasterScriptProviderFactory" ), UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
Any aScriptProviderContext;
|
|
|
|
if ( !impl_shouldDisallowScripting_nolck_nothrow() )
|
|
|
|
aScriptProviderContext <<= Reference< XModel >( this );
|
|
|
|
|
|
|
|
xScriptProvider.set( xFactory->createScriptProvider( aScriptProviderContext ), UNO_SET_THROW );
|
|
|
|
m_xScriptProvider = xScriptProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xScriptProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
if ( m_pImpl.is() )
|
|
|
|
m_pImpl->disposing(Source);
|
2005-01-21 16:03:37 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2008-03-06 16:58:17 +00:00
|
|
|
Reference< XInterface > ODatabaseDocument::getThis() const
|
2005-12-21 12:34:54 +00:00
|
|
|
{
|
2008-03-06 16:58:17 +00:00
|
|
|
return *const_cast< ODatabaseDocument* >( this );
|
2005-12-21 12:34:54 +00:00
|
|
|
}
|
2007-04-16 15:23:47 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
struct CreateAny : public ::std::unary_function< Reference<XController>, Any>
|
2007-07-24 11:04:32 +00:00
|
|
|
{
|
|
|
|
Any operator() (const Reference<XController>& lhs) const
|
|
|
|
{
|
|
|
|
return makeAny(lhs);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-04-16 15:23:47 +00:00
|
|
|
// XModel2
|
|
|
|
Reference< XEnumeration > SAL_CALL ODatabaseDocument::getControllers( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
2007-07-24 11:04:32 +00:00
|
|
|
uno::Sequence< Any> aController( m_aControllers.size() );
|
|
|
|
::std::transform( m_aControllers.begin(), m_aControllers.end(), aController.getArray(), CreateAny() );
|
2007-04-16 15:23:47 +00:00
|
|
|
return new ::comphelper::OAnyEnumeration(aController);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > SAL_CALL ODatabaseDocument::getAvailableViewControllerNames( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aNames(1);
|
|
|
|
aNames[0] = SERVICE_SDB_APPLICATIONCONTROLLER;
|
|
|
|
return aNames;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-06 13:02:08 +00:00
|
|
|
Reference< XController2 > SAL_CALL ODatabaseDocument::createDefaultViewController( const Reference< XFrame >& _Frame ) throw (IllegalArgumentException, Exception, RuntimeException)
|
2007-04-16 15:23:47 +00:00
|
|
|
{
|
2008-06-06 13:02:08 +00:00
|
|
|
return createViewController(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ),
|
|
|
|
Sequence< PropertyValue >(),
|
|
|
|
_Frame
|
|
|
|
);
|
2007-04-16 15:23:47 +00:00
|
|
|
}
|
2008-06-06 13:02:08 +00:00
|
|
|
|
2007-04-16 15:23:47 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-06 13:02:08 +00:00
|
|
|
Reference< XController2 > SAL_CALL ODatabaseDocument::createViewController( const ::rtl::OUString& _ViewName, const Sequence< PropertyValue >& _Arguments, const Reference< XFrame >& _Frame ) throw (IllegalArgumentException, Exception, RuntimeException)
|
2007-04-16 15:23:47 +00:00
|
|
|
{
|
2008-06-06 13:02:08 +00:00
|
|
|
if ( !_ViewName.equalsAscii( "Default" ) && !_ViewName.equalsAscii( "Preview" ) )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
|
|
|
|
if ( !_Frame.is() )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *this, 3 );
|
|
|
|
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
::comphelper::ComponentContext aContext( m_pImpl->m_aContext );
|
|
|
|
aGuard.clear();
|
|
|
|
|
|
|
|
Reference< XController2 > xController;
|
|
|
|
aContext.createComponent( "org.openoffice.comp.dbu.OApplicationController", xController );
|
|
|
|
|
|
|
|
::comphelper::NamedValueCollection aInitArgs( _Arguments );
|
|
|
|
aInitArgs.put( "Frame", _Frame );
|
|
|
|
if ( _ViewName.equalsAscii( "Preview" ) )
|
|
|
|
aInitArgs.put( "Preview", sal_Bool( sal_True ) );
|
|
|
|
Reference< XInitialization > xInitController( xController, UNO_QUERY_THROW );
|
|
|
|
xInitController->initialize( aInitArgs.getWrappedPropertyValues() );
|
|
|
|
|
|
|
|
return xController;
|
2007-04-16 15:23:47 +00:00
|
|
|
}
|
2008-06-06 13:02:08 +00:00
|
|
|
|
2007-04-16 15:23:47 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:32:17 +00:00
|
|
|
//=============================================================================
|
2008-04-08 11:46:07 +00:00
|
|
|
Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw()
|
2008-04-04 13:32:17 +00:00
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
if ( ! m_xTitleHelper.is ())
|
|
|
|
{
|
2008-04-08 11:46:07 +00:00
|
|
|
Reference< XUntitledNumbers > xDesktop(
|
|
|
|
m_pImpl->m_aContext.createComponent( "com.sun.star.frame.Desktop" ),
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
uno::Reference< frame::XModel > xThis (getThis(), uno::UNO_QUERY_THROW);
|
2008-04-04 13:32:17 +00:00
|
|
|
|
2008-04-08 11:46:07 +00:00
|
|
|
::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_pImpl->m_aContext.getLegacyServiceFactory());
|
2008-04-04 13:32:17 +00:00
|
|
|
m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
|
|
|
|
pHelper->setOwner (xThis );
|
|
|
|
pHelper->connectWithUntitledNumbers (xDesktop);
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_xTitleHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHelper_throw(const uno::Reference< uno::XInterface >& _xComponent)
|
|
|
|
{
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
if ( !m_xModuleManager.is() )
|
2008-04-08 11:46:07 +00:00
|
|
|
m_xModuleManager.set( m_pImpl->m_aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
|
2008-04-04 13:32:17 +00:00
|
|
|
|
|
|
|
::rtl::OUString sModuleId = m_xModuleManager->identify( _xComponent );
|
|
|
|
|
|
|
|
uno::Reference< frame::XUntitledNumbers > xNumberedControllers;
|
|
|
|
|
|
|
|
TNumberedController::iterator aFind = m_aNumberedControllers.find(sModuleId);
|
|
|
|
if ( aFind == m_aNumberedControllers.end() )
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
|
|
|
|
::comphelper::NumberedCollection* pHelper = new ::comphelper::NumberedCollection();
|
|
|
|
xNumberedControllers.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
|
|
|
|
|
|
|
|
pHelper->setOwner (xThis);
|
|
|
|
//pHelper->setUntitledPrefix (::rtl::OUString::createFromAscii(" : "));
|
|
|
|
|
|
|
|
m_aNumberedControllers.insert(TNumberedController::value_type(sModuleId,xNumberedControllers));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xNumberedControllers = aFind->second;
|
|
|
|
|
|
|
|
return xNumberedControllers;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XTitle
|
|
|
|
::rtl::OUString SAL_CALL ODatabaseDocument::getTitle()
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// SYNCHRONIZED ->
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
return impl_getTitleHelper_throw()->getTitle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XTitle
|
|
|
|
void SAL_CALL ODatabaseDocument::setTitle( const ::rtl::OUString& sTitle )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// SYNCHRONIZED ->
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
impl_getTitleHelper_throw()->setTitle (sTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XTitleChangeBroadcaster
|
|
|
|
void SAL_CALL ODatabaseDocument::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// SYNCHRONIZED ->
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
|
|
|
|
if (xBroadcaster.is ())
|
|
|
|
xBroadcaster->addTitleChangeListener (xListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XTitleChangeBroadcaster
|
|
|
|
void SAL_CALL ODatabaseDocument::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// SYNCHRONIZED ->
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
|
|
|
|
if (xBroadcaster.is ())
|
|
|
|
xBroadcaster->removeTitleChangeListener (xListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XUntitledNumbers
|
|
|
|
::sal_Int32 SAL_CALL ODatabaseDocument::leaseNumber( const uno::Reference< uno::XInterface >& xComponent )
|
|
|
|
throw (lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// object already disposed?
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
return impl_getUntitledHelper_throw(xComponent)->leaseNumber (xComponent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XUntitledNumbers
|
|
|
|
void SAL_CALL ODatabaseDocument::releaseNumber( ::sal_Int32 nNumber )
|
|
|
|
throw (lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// object already disposed?
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
|
|
|
|
impl_getUntitledHelper_throw()->releaseNumber (nNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XUntitledNumbers
|
|
|
|
void SAL_CALL ODatabaseDocument::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent )
|
|
|
|
throw (lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// object already disposed?
|
|
|
|
ModelMethodGuard aGuard( *this );
|
|
|
|
impl_getUntitledHelper_throw(xComponent)->releaseNumberForComponent (xComponent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// css.frame.XUntitledNumbers
|
|
|
|
::rtl::OUString SAL_CALL ODatabaseDocument::getUntitledPrefix() throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString();/*RTL_CONSTASCII_USTRINGPARAM(" : "));*/
|
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
2005-02-16 15:07:41 +00:00
|
|
|
//------------------------------------------------------------------
|
2004-08-02 14:09:11 +00:00
|
|
|
//........................................................................
|
|
|
|
} // namespace dbaccess
|
|
|
|
//........................................................................
|
2005-02-16 15:07:41 +00:00
|
|
|
|
2005-03-04 08:44:36 +00:00
|
|
|
|