2004-08-02 14:09:11 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* $RCSfile: databasedocument.cxx,v $
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-12-21 12:34:54 +00:00
|
|
|
* $Revision: 1.23 $
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-12-21 12:34:54 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2005-12-21 13:34:54 $
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* This library 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 for more details.
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
2005-09-08 11:02:43 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-08-02 14:09:11 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _DBA_COREDATAACCESS_DATASOURCE_HXX_
|
|
|
|
#include "datasource.hxx"
|
|
|
|
#endif
|
2005-03-10 15:33:50 +00:00
|
|
|
#ifndef _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
|
|
|
|
#include "databasedocument.hxx"
|
|
|
|
#endif
|
2004-08-02 14:09:11 +00:00
|
|
|
#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
|
|
|
|
#include "dbastrings.hrc"
|
|
|
|
#endif
|
2005-05-13 14:43:10 +00:00
|
|
|
#include <comphelper/documentconstants.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
|
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
|
2005-03-10 15:33:50 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.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
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
namespace css = ::com::sun::star;
|
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;
|
|
|
|
using namespace ::cppu;
|
|
|
|
using namespace ::osl;
|
2005-03-04 08:44:36 +00:00
|
|
|
namespace css = ::com::sun::star;
|
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
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
static OMultiInstanceAutoRegistration< ODatabaseDocument > aAutoRegistration;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > ODatabaseDocument_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
ODatabaseContext* pContext = NULL;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<XUnoTunnel> xUnoTunnel(_rxFactory->createInstance(SERVICE_SDB_DATABASECONTEXT),UNO_QUERY);
|
|
|
|
if ( xUnoTunnel.is() )
|
|
|
|
pContext = reinterpret_cast<ODatabaseContext*>(xUnoTunnel->getSomething(ODatabaseContext::getUnoTunnelImplementationId()));
|
|
|
|
}
|
|
|
|
catch(Exception)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
::rtl::Reference<ODatabaseModelImpl> pImpl(new ODatabaseModelImpl(_rxFactory));
|
|
|
|
pImpl->m_pDBContext = pContext;
|
2005-07-08 09:36:11 +00:00
|
|
|
Reference< XModel > xModel( pImpl->createNewModel_deliverOwnership() );
|
|
|
|
return xModel.get();
|
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() )
|
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
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
// adjust our readonly flag
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_xDocEventBroadcaster.set(m_pImpl->m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.GlobalEventBroadcaster"))),
|
|
|
|
UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch(Exception)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Could not create GlobalEventBroadcaster!");
|
|
|
|
}
|
2005-05-06 08:18:46 +00:00
|
|
|
Reference<XChild> xChild(m_pImpl->m_xForms.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(static_cast<OWeakObject*>(this));
|
|
|
|
|
|
|
|
xChild.set(m_pImpl->m_xReports.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(static_cast<OWeakObject*>(this));
|
|
|
|
xChild.set(m_pImpl->m_xTableDefinitions.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(static_cast<OWeakObject*>(this));
|
|
|
|
xChild.set(m_pImpl->m_xCommandDefinitions.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(static_cast<OWeakObject*>(this));
|
2004-08-02 14:09:11 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// local functions
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-30 10:55:24 +00:00
|
|
|
void lcl_stripLoadArguments( ::comphelper::MediaDescriptor& _rDescriptor, Sequence< PropertyValue >& _rArgs )
|
2005-03-10 15:33:50 +00:00
|
|
|
{
|
2005-03-30 10:55:24 +00:00
|
|
|
_rDescriptor.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) ) );
|
|
|
|
_rDescriptor.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) ) );
|
|
|
|
_rDescriptor.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ) );
|
|
|
|
_rDescriptor >> _rArgs;
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
2005-03-30 10:55:24 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void lcl_extractAndStartStatusIndicator( const ::comphelper::MediaDescriptor& _rDescriptor, Reference< XStatusIndicator >& _rxStatusIndicator,
|
|
|
|
Sequence< Any >& _rCallArgs )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_rxStatusIndicator = _rDescriptor.getUnpackedValueOrDefault( _rDescriptor.PROP_STATUSINDICATOR(), _rxStatusIndicator );
|
|
|
|
if ( _rxStatusIndicator.is() )
|
|
|
|
{
|
|
|
|
_rxStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
|
|
|
|
|
|
|
|
sal_Int32 nLength = _rCallArgs.getLength();
|
|
|
|
_rCallArgs.realloc( nLength + 1 );
|
|
|
|
_rCallArgs[ nLength ] <<= _rxStatusIndicator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "lcl_extractAndStartStatusIndicator: caught an exception!" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XModel
|
2004-11-17 13:43:36 +00:00
|
|
|
// ATTENTION: The Application controller attaches the same resource to force a reload.
|
2005-03-30 10:55:24 +00:00
|
|
|
sal_Bool SAL_CALL ODatabaseDocument::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _aArguments ) 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
|
|
|
|
2004-11-17 13:43:36 +00:00
|
|
|
try
|
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->clearConnections();
|
|
|
|
m_pImpl->disposeStorages();
|
2004-12-03 13:34:06 +00:00
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
if ( m_pImpl->m_bOwnStorage )
|
|
|
|
::comphelper::disposeComponent(m_pImpl->m_xStorage);
|
|
|
|
Reference< XNameAccess > xContainer = m_pImpl->m_xForms;
|
2004-11-17 13:43:36 +00:00
|
|
|
::comphelper::disposeComponent(xContainer);
|
2005-03-10 15:33:50 +00:00
|
|
|
xContainer = m_pImpl->m_xReports;
|
2004-11-17 13:43:36 +00:00
|
|
|
::comphelper::disposeComponent(xContainer);
|
2005-03-10 15:33:50 +00:00
|
|
|
xContainer = m_pImpl->m_xTableDefinitions;
|
2004-11-17 13:43:36 +00:00
|
|
|
::comphelper::disposeComponent(xContainer);
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
xContainer = m_pImpl->m_xCommandDefinitions;
|
2004-11-17 13:43:36 +00:00
|
|
|
::comphelper::disposeComponent(xContainer);
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_aContainer.clear();
|
|
|
|
m_pImpl->lateInit();
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_xStorage = NULL;
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_bDocumentReadOnly = sal_False;
|
2004-11-17 13:43:36 +00:00
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
::comphelper::MediaDescriptor aDescriptor( _aArguments );
|
|
|
|
lcl_stripLoadArguments( aDescriptor, m_pImpl->m_aArgs );
|
|
|
|
|
|
|
|
m_pImpl->m_sFileURL = _rURL;
|
|
|
|
m_pImpl->m_sRealFileURL = aDescriptor.getUnpackedValueOrDefault(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SalvagedFile" ) ), _rURL );
|
|
|
|
if ( !m_pImpl->m_sRealFileURL.getLength() )
|
|
|
|
m_pImpl->m_sRealFileURL = m_pImpl->m_sFileURL;
|
2005-03-10 15:33:50 +00:00
|
|
|
|
|
|
|
if ( !m_pImpl->m_sName.getLength() )
|
2005-03-30 10:55:24 +00:00
|
|
|
m_pImpl->m_sName = m_pImpl->m_sRealFileURL;
|
2005-03-10 15:33:50 +00:00
|
|
|
|
|
|
|
m_pImpl->getStorage();
|
|
|
|
|
2004-11-17 13:43:36 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Sequence<Any> aFilterArgs;
|
2005-02-02 13:01:30 +00:00
|
|
|
Reference<XStatusIndicator> xStatusIndicator;
|
2005-03-30 10:55:24 +00:00
|
|
|
lcl_extractAndStartStatusIndicator( aDescriptor, xStatusIndicator, aFilterArgs );
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
Reference<XImporter> xImporter(
|
|
|
|
m_pImpl->m_xServiceFactory->createInstanceWithArguments(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sdb.DBFilter" ) ),
|
|
|
|
aFilterArgs
|
|
|
|
),
|
|
|
|
UNO_QUERY
|
|
|
|
);
|
2004-11-17 13:43:36 +00:00
|
|
|
|
|
|
|
if ( xImporter.is() )
|
|
|
|
{
|
|
|
|
Reference<XComponent> xComponent(*this,UNO_QUERY);
|
|
|
|
xImporter->setTargetDocument(xComponent);
|
|
|
|
Reference<XFilter> xFilter(xImporter,UNO_QUERY);
|
|
|
|
|
2005-02-02 13:01:30 +00:00
|
|
|
xFilter->filter(_aArguments);
|
|
|
|
if ( xStatusIndicator.is() )
|
|
|
|
xStatusIndicator->end();
|
2004-11-17 13:43:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
catch(const RuntimeException& e)
|
|
|
|
{
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
if ( m_pImpl->m_pDBContext )
|
|
|
|
{
|
2005-03-30 10:55:24 +00:00
|
|
|
m_pImpl->m_pDBContext->registerPrivate(m_pImpl->m_sRealFileURL,m_pImpl);
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->setModified(sal_False);
|
|
|
|
}
|
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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
2005-03-30 10:55:24 +00:00
|
|
|
|
|
|
|
return m_pImpl->m_sRealFileURL;
|
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
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
2005-03-30 10:55:24 +00:00
|
|
|
|
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 );
|
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_aControllers.push_back(_xController);
|
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
|
|
|
|
|
|
|
m_pImpl->m_aControllers.erase(::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController));
|
|
|
|
if ( m_pImpl->m_xCurrentController == _xController )
|
|
|
|
m_pImpl->m_xCurrentController = NULL;
|
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");
|
|
|
|
|
|
|
|
return m_pImpl->m_xCurrentController.is() ? m_pImpl->m_xCurrentController : ( m_pImpl->m_aControllers.empty() ? Reference< XController >() : *m_pImpl->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");
|
|
|
|
|
|
|
|
m_pImpl->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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
return m_pImpl->m_sRealFileURL.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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
return m_pImpl->m_sRealFileURL;
|
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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
if ( m_pImpl->m_sFileURL == m_pImpl->m_sRealFileURL )
|
|
|
|
store( m_pImpl->m_sFileURL, m_pImpl->m_aArgs );
|
|
|
|
else
|
|
|
|
storeAsURL( m_pImpl->m_sRealFileURL, m_pImpl->m_aArgs );
|
2005-02-02 13:01:30 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
impl_notifyEvent( "OnSaveDone", aGuard );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-30 10:55:24 +00:00
|
|
|
void ODatabaseDocument::store(const ::rtl::OUString& _rURL
|
|
|
|
,const Sequence< PropertyValue >& _rArguments)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
if ( m_pImpl->m_bDocumentReadOnly )
|
2004-08-02 14:09:11 +00:00
|
|
|
throw IOException();
|
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
m_bCommitMasterStorage = sal_False;
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->commitStorages();
|
2005-07-08 09:36:11 +00:00
|
|
|
m_bCommitMasterStorage = sal_True;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
writeStorage(_rURL,_rArguments,m_pImpl->getStorage());
|
|
|
|
|
|
|
|
m_pImpl->commitRootStorage();
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-03-23 08:46:04 +00:00
|
|
|
setModified(sal_False);
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-30 10:55:24 +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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory() );
|
2005-12-21 12:34:54 +00:00
|
|
|
if ( !xStorageFactory.is() )
|
|
|
|
throw RuntimeException();
|
2005-03-30 10:55:24 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
// don't use _rURL - we might be recovering/salvaging a file currently ...
|
|
|
|
// #i45314# / 2005-03-21 / frank.schoenheit@sun.com
|
|
|
|
::comphelper::MediaDescriptor aDescriptor( _rArguments );
|
|
|
|
|
|
|
|
sal_Bool bLocationChanged = ( _rURL != m_pImpl->m_sFileURL );
|
|
|
|
if ( bLocationChanged )
|
|
|
|
{
|
|
|
|
Sequence<Any> aParam(2);
|
|
|
|
aParam[0] <<= _rURL;
|
|
|
|
aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE;
|
|
|
|
Reference<XStorage> xStorage;
|
|
|
|
try
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
xStorage.set(xStorageFactory->createInstanceWithArguments( aParam ),UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
if ( !xStorage.is() )
|
|
|
|
throw IOException();
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
if ( m_pImpl->isEmbeddedDatabase() )
|
|
|
|
m_pImpl->clearConnections();
|
|
|
|
m_pImpl->commitEmbeddedStorage();
|
2005-02-16 15:07:41 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
Reference<XStorage> xMyStorage = m_pImpl->getStorage();
|
|
|
|
if ( xMyStorage.is() )
|
|
|
|
{
|
|
|
|
m_pImpl->commitStorages();
|
|
|
|
xMyStorage->copyToStorage( xStorage );
|
|
|
|
}
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
m_pImpl->disposeStorages();
|
2004-12-03 13:34:06 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
m_pImpl->m_xStorage = xStorage;
|
|
|
|
if ( m_pImpl->m_bOwnStorage )
|
|
|
|
::comphelper::disposeComponent(xMyStorage);
|
|
|
|
else
|
|
|
|
m_pImpl->m_bOwnStorage = sal_True;
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
m_pImpl->m_bDocumentReadOnly = sal_False;
|
|
|
|
if ( _rURL != m_pImpl->m_sRealFileURL )
|
|
|
|
{
|
|
|
|
if ( m_pImpl->m_pDBContext )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
if ( m_pImpl->m_sRealFileURL.getLength() )
|
|
|
|
m_pImpl->m_pDBContext->nameChangePrivate(m_pImpl->m_sRealFileURL,_rURL);
|
|
|
|
else
|
|
|
|
m_pImpl->m_pDBContext->registerPrivate(_rURL,m_pImpl);
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
|
|
|
INetURLObject aURL( _rURL );
|
|
|
|
if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
|
|
|
|
m_pImpl->m_sName = _rURL;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
m_pImpl->m_sRealFileURL = m_pImpl->m_sFileURL = _rURL;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
lcl_stripLoadArguments( aDescriptor, m_pImpl->m_aArgs );
|
|
|
|
store(m_pImpl->m_sFileURL,_rArguments);
|
|
|
|
|
|
|
|
impl_notifyEvent( "OnSaveAsDone", aGuard );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-30 10:55:24 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::storeToURL( 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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
|
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory() );
|
|
|
|
Sequence<Any> aParam(2);
|
|
|
|
aParam[0] <<= _rURL;
|
|
|
|
aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE;
|
|
|
|
Reference<XStorage> xStorage;
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( xStorageFactory.is() )
|
2005-03-30 10:55:24 +00:00
|
|
|
xStorage = xStorage.query( xStorageFactory->createInstanceWithArguments( aParam ) );
|
|
|
|
OSL_ENSURE( xStorage.is(), "ODatabaseDocument::storeToURL: no storage factory!" );
|
|
|
|
if ( !xStorage.is() )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-30 10:55:24 +00:00
|
|
|
IOException aError;
|
|
|
|
aError.Message = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create a target storage." ) );
|
|
|
|
aError.Context = *this;
|
|
|
|
throw IOException( aError );
|
|
|
|
}
|
2004-08-02 14:09:11 +00:00
|
|
|
|
2005-03-30 10:55:24 +00:00
|
|
|
Reference<XStorage> xMyStorage = m_pImpl->getStorage();
|
|
|
|
OSL_ENSURE( xMyStorage.is(), "ODatabaseDocument::storeToURL: no own storage?" );
|
|
|
|
if ( !xMyStorage.is() )
|
|
|
|
{
|
|
|
|
IOException aError;
|
|
|
|
aError.Message = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error: no source storage available." ) );
|
|
|
|
aError.Context = *this;
|
|
|
|
throw IOException( aError );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pImpl->commitEmbeddedStorage();
|
|
|
|
xMyStorage->copyToStorage( xStorage );
|
|
|
|
writeStorage(_rURL,_rArguments,xStorage);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<XTransactedObject> xTransact(xStorage,UNO_QUERY);
|
|
|
|
if ( xTransact.is() )
|
|
|
|
xTransact->commit();
|
|
|
|
}
|
|
|
|
catch(Exception)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Exception Caught: Could not store database!");
|
|
|
|
throw IOException();
|
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);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
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);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
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 );
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2005-12-21 12:34:54 +00:00
|
|
|
if ( m_pImpl->m_bModified == _bModified )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_pImpl->m_bModified = _bModified;
|
|
|
|
lang::EventObject aEvt( *this );
|
|
|
|
|
|
|
|
aGuard.clear();
|
|
|
|
m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
|
|
|
|
|
|
|
|
aGuard.reset();
|
|
|
|
impl_notifyEvent( "OnModifyChanged", aGuard );
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
2005-03-04 08:44:36 +00:00
|
|
|
// ::com::sun::star::document::XEventBroadcaster
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::addEventListener(const css::uno::Reference< css::document::XEventListener >& _xListener ) throw (css::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);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::removeEventListener( const css::uno::Reference< css::document::XEventListener >& _xListener ) throw (css::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);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// ::com::sun::star::document::XEventListener
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::notifyEvent( const css::document::EventObject& aEvent ) throw (css::uno::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.
|
2005-12-21 12:34:54 +00:00
|
|
|
impl_notifyEvent( aEvent.EventName, aGuard );
|
2005-03-04 08:44:36 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2004-08-02 14:09:11 +00:00
|
|
|
// ::com::sun::star::view::XPrintable
|
2005-03-10 15:33:50 +00:00
|
|
|
Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getPrinter( ) throw (RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
return Sequence< PropertyValue >();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::setPrinter( const Sequence< PropertyValue >& aPrinter ) throw (IllegalArgumentException, RuntimeException)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
void SAL_CALL ODatabaseDocument::print( const Sequence< PropertyValue >& xOptions ) throw (IllegalArgumentException, RuntimeException)
|
2004-08-02 14:09:11 +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
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
::std::vector< Reference< XController> > aCopy = m_pImpl->m_aControllers;
|
2005-09-23 11:04:55 +00:00
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
::std::vector< Reference< XController> >::iterator aIter = aCopy.begin();
|
|
|
|
::std::vector< Reference< XController> >::iterator aEnd = aCopy.end();
|
2005-09-23 11:04:55 +00:00
|
|
|
for ( ;aIter != aEnd ; ++aIter )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
if ( aIter->is() )
|
|
|
|
{
|
2005-09-23 11:04:55 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XCloseable> xFrame( (*aIter)->getFrame(), UNO_QUERY );
|
|
|
|
if ( xFrame.is() )
|
|
|
|
xFrame->close( _bDeliverOwnership );
|
|
|
|
}
|
|
|
|
catch( const CloseVetoException& ) { throw; }
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "ODatabaseDocument::impl_closeControllerFrames: caught an unexpected exception!" );
|
|
|
|
}
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
}
|
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 );
|
|
|
|
|
|
|
|
lang::EventObject aEvent( *this );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
DBG_ASSERT( m_pImpl->m_aControllers.empty(), "ODatabaseDocument::close: aren't controllers expected to veto the closing?" );
|
|
|
|
impl_closeControllerFrames( _bDeliverOwnership );
|
|
|
|
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
aGuard.clear();
|
|
|
|
m_aCloseListener.notifyEach( &XCloseListener::notifyClosing, aEvent );
|
|
|
|
aGuard.reset();
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
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
|
|
|
{
|
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");
|
|
|
|
|
|
|
|
Reference< XNameAccess > xContainer = m_pImpl->m_xForms;
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( !xContainer.is() )
|
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
if ( !m_pImpl->m_aContainer[ODatabaseModelImpl::E_FORM].get() )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("forms"));
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_aContainer[ODatabaseModelImpl::E_FORM] = TContentPtr(new ODefinitionContainer_Impl);
|
|
|
|
m_pImpl->m_aContainer[ODatabaseModelImpl::E_FORM]->m_pDataSource = m_pImpl.get();
|
|
|
|
m_pImpl->m_aContainer[ODatabaseModelImpl::E_FORM]->m_aProps.aTitle = sName;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
xContainer = new ODocumentContainer(m_pImpl->m_xServiceFactory,*this,m_pImpl->m_aContainer[ODatabaseModelImpl::E_FORM],sal_True);
|
|
|
|
m_pImpl->m_xForms = xContainer;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
return xContainer;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) 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");
|
|
|
|
|
|
|
|
Reference< XNameAccess > xContainer = m_pImpl->m_xReports;
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( !xContainer.is() )
|
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
if ( !m_pImpl->m_aContainer[ODatabaseModelImpl::E_REPORT].get() )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_aContainer[ODatabaseModelImpl::E_REPORT] = TContentPtr(new ODefinitionContainer_Impl);
|
2004-08-02 14:09:11 +00:00
|
|
|
::rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("reports"));
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_aContainer[ODatabaseModelImpl::E_REPORT]->m_pDataSource = m_pImpl.get();
|
|
|
|
m_pImpl->m_aContainer[ODatabaseModelImpl::E_REPORT]->m_aProps.aTitle = sName;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
xContainer = new ODocumentContainer(m_pImpl->m_xServiceFactory,*this,m_pImpl->m_aContainer[ODatabaseModelImpl::E_REPORT],sal_False);
|
|
|
|
m_pImpl->m_xReports = xContainer;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
return xContainer;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
sal_Bool ODatabaseDocument::WriteThroughComponent(
|
2004-08-02 14:09:11 +00:00
|
|
|
const Reference<XComponent> & xComponent,
|
|
|
|
const sal_Char* pStreamName,
|
|
|
|
const sal_Char* pServiceName,
|
|
|
|
const Sequence<Any> & rArguments,
|
|
|
|
const Sequence<PropertyValue> & rMediaDesc,
|
2005-03-23 08:46:04 +00:00
|
|
|
sal_Bool bPlainStream
|
|
|
|
,const Reference<XStorage>& _xStorageToSaveTo)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE( NULL != pStreamName, "Need stream name!" );
|
|
|
|
OSL_ENSURE( NULL != pServiceName, "Need service name!" );
|
|
|
|
|
2005-03-23 08:46:04 +00:00
|
|
|
Reference<XStorage> xMyStorage = _xStorageToSaveTo;
|
2004-08-02 14:09:11 +00:00
|
|
|
// open stream
|
|
|
|
::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii( pStreamName );
|
|
|
|
Reference<XStream> xStream = xMyStorage->openStreamElement( sStreamName,ElementModes::READWRITE | ElementModes::TRUNCATE );
|
|
|
|
if ( !xStream.is() )
|
|
|
|
return sal_False;
|
|
|
|
Reference<XOutputStream> xOutputStream = xStream->getOutputStream();
|
|
|
|
OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!");
|
|
|
|
if ( ! xOutputStream.is() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
Reference<XPropertySet> xStreamProp(xOutputStream,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xStreamProp.is(),"No valid preoperty set for the output stream!");
|
|
|
|
|
|
|
|
Reference<XSeekable> xSeek(xStreamProp,UNO_QUERY);
|
|
|
|
if ( xSeek.is() )
|
|
|
|
{
|
2005-03-30 10:55:24 +00:00
|
|
|
OSL_TRACE("Length of stream %i",(int)xSeek->getPosition());
|
2004-08-02 14:09:11 +00:00
|
|
|
xSeek->seek(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
|
|
|
|
::rtl::OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
|
|
|
|
Any aAny;
|
|
|
|
aAny <<= aMime;
|
|
|
|
xStreamProp->setPropertyValue( aPropName, aAny );
|
|
|
|
|
|
|
|
if( bPlainStream )
|
|
|
|
{
|
|
|
|
::rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Compressed") );
|
|
|
|
sal_Bool bFalse = sal_False;
|
|
|
|
aAny.setValue( &bFalse, ::getBooleanCppuType() );
|
|
|
|
xStreamProp->setPropertyValue( aPropName, aAny );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Encrypted") );
|
|
|
|
sal_Bool bTrue = sal_True;
|
|
|
|
aAny.setValue( &bTrue, ::getBooleanCppuType() );
|
|
|
|
xStreamProp->setPropertyValue( aPropName, aAny );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// set buffer and create outputstream
|
|
|
|
|
|
|
|
// write the stuff
|
|
|
|
sal_Bool bRet = WriteThroughComponent(
|
|
|
|
xOutputStream, xComponent,
|
|
|
|
pServiceName, rArguments, rMediaDesc );
|
|
|
|
|
|
|
|
// finally, commit stream.
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
sal_Bool ODatabaseDocument::WriteThroughComponent(
|
2004-08-02 14:09:11 +00:00
|
|
|
const Reference<XOutputStream> & xOutputStream,
|
|
|
|
const Reference<XComponent> & xComponent,
|
|
|
|
const sal_Char* pServiceName,
|
|
|
|
const Sequence<Any> & rArguments,
|
2005-03-23 08:46:04 +00:00
|
|
|
const Sequence<PropertyValue> & rMediaDesc)
|
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
|
|
|
|
Reference< XActiveDataSource > xSaxWriter(
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer"))),
|
2004-08-02 14:09:11 +00:00
|
|
|
UNO_QUERY );
|
|
|
|
OSL_ENSURE( xSaxWriter.is(), "can't instantiate XML com.sun.star.xml.sax.Writer" );
|
|
|
|
if(!xSaxWriter.is())
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
// connect XML writer to output stream
|
|
|
|
xSaxWriter->setOutputStream( xOutputStream );
|
|
|
|
|
|
|
|
// prepare arguments (prepend doc handler to given arguments)
|
|
|
|
Reference<XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
|
|
|
|
Sequence<Any> aArgs( 1 + rArguments.getLength() );
|
|
|
|
aArgs[0] <<= xDocHandler;
|
|
|
|
for(sal_Int32 i = 0; i < rArguments.getLength(); i++)
|
|
|
|
aArgs[i+1] = rArguments[i];
|
|
|
|
|
|
|
|
// get filter component
|
|
|
|
Reference< XExporter > xExporter(
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_xServiceFactory->createInstanceWithArguments(
|
2004-08-02 14:09:11 +00:00
|
|
|
::rtl::OUString::createFromAscii(pServiceName), aArgs), UNO_QUERY);
|
|
|
|
OSL_ENSURE( xExporter.is(),
|
|
|
|
"can't instantiate export filter component" );
|
|
|
|
if( !xExporter.is() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
|
|
|
|
// connect model and filter
|
|
|
|
xExporter->setSourceDocument( xComponent );
|
|
|
|
|
|
|
|
// filter!
|
|
|
|
Reference<XFilter> xFilter( xExporter, UNO_QUERY );
|
|
|
|
return xFilter->filter( rMediaDesc );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-30 10:55:24 +00:00
|
|
|
void ODatabaseDocument::writeStorage(const ::rtl::OUString& _rURL
|
|
|
|
,const Sequence< PropertyValue >& _rArguments
|
2005-03-23 08:46:04 +00:00
|
|
|
,const Reference<XStorage>& _xStorageToSaveTo)
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
// create XStatusIndicator
|
|
|
|
Reference<XStatusIndicator> xStatusIndicator;
|
2005-03-30 10:55:24 +00:00
|
|
|
Sequence< Any > aDelegatorArguments;
|
|
|
|
::comphelper::MediaDescriptor aDescriptor( _rArguments );
|
|
|
|
lcl_extractAndStartStatusIndicator( aDescriptor, xStatusIndicator, aDelegatorArguments );
|
2004-08-02 14:09:11 +00:00
|
|
|
|
|
|
|
// properties
|
2005-03-30 10:55:24 +00:00
|
|
|
Sequence < PropertyValue > aProps( _rURL.getLength() ? 1 : 0 );
|
|
|
|
if( _rURL.getLength() )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
PropertyValue *pProps = aProps.getArray();
|
|
|
|
pProps->Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FileName") );
|
2005-03-30 10:55:24 +00:00
|
|
|
(pProps++)->Value <<= _rURL;
|
2004-08-02 14:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// export sub streams for package, else full stream into a file
|
|
|
|
sal_Bool bWarn = sal_False, bErr = sal_False;
|
|
|
|
String sWarnFile, sErrFile;
|
|
|
|
|
2005-03-23 08:46:04 +00:00
|
|
|
Reference<XPropertySet> xProp(_xStorageToSaveTo,UNO_QUERY);
|
2004-08-02 14:09:11 +00:00
|
|
|
if ( xProp.is() )
|
|
|
|
{
|
|
|
|
static const ::rtl::OUString sPropName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType"));
|
|
|
|
Any aAny;
|
2005-05-13 14:43:10 +00:00
|
|
|
aAny <<= MIMETYPE_OASIS_OPENDOCUMENT_DATABASE;
|
2004-08-02 14:09:11 +00:00
|
|
|
xProp->setPropertyValue( sPropName, aAny );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference<XComponent> xCom(static_cast<OWeakObject*>(this),UNO_QUERY);
|
|
|
|
if( !bErr )
|
|
|
|
{
|
|
|
|
if( !WriteThroughComponent(
|
|
|
|
xCom, "settings.xml",
|
|
|
|
"com.sun.star.comp.sdb.XMLSettingsExporter",
|
2005-03-30 10:55:24 +00:00
|
|
|
aDelegatorArguments, aProps, sal_True,_xStorageToSaveTo ) )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
if( !bWarn )
|
|
|
|
{
|
|
|
|
bWarn = sal_True;
|
|
|
|
sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("settings.xml"),
|
|
|
|
RTL_TEXTENCODING_ASCII_US );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bErr )
|
|
|
|
{
|
|
|
|
if( !WriteThroughComponent(
|
|
|
|
xCom, "content.xml",
|
|
|
|
"com.sun.star.comp.sdb.DBExportFilter",
|
2005-03-30 10:55:24 +00:00
|
|
|
aDelegatorArguments, aProps, sal_True,_xStorageToSaveTo ) )
|
2004-08-02 14:09:11 +00:00
|
|
|
{
|
|
|
|
bErr = sal_True;
|
|
|
|
sErrFile = String( RTL_CONSTASCII_STRINGPARAM("content.xml"),
|
|
|
|
RTL_TEXTENCODING_ASCII_US );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( xStatusIndicator.is() )
|
|
|
|
xStatusIndicator->end();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-03-10 15:33:50 +00:00
|
|
|
Reference< ::com::sun::star::ui::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() )
|
|
|
|
{
|
2005-03-01 18:13:53 +00:00
|
|
|
m_xUIConfigurationManager = Reference< ::com::sun::star::ui::XUIConfigurationManager >(
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl->m_xServiceFactory->createInstance(
|
2005-03-01 18:13:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "com.sun.star.ui.UIConfigurationManager" )),
|
2004-08-02 14:09:11 +00:00
|
|
|
UNO_QUERY );
|
|
|
|
|
2005-03-01 18:13:53 +00:00
|
|
|
Reference< ::com::sun::star::ui::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 aMediaTypeProp( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ));
|
|
|
|
rtl::OUString aUIConfigMediaType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.ui.configuration" ));
|
|
|
|
rtl::OUString aMediaType;
|
|
|
|
Reference< XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
|
|
|
|
Any a = xPropSet->getPropertyValue( aMediaTypeProp );
|
|
|
|
if ( !( a >>= aMediaType ) || ( aMediaType.getLength() == 0 ))
|
|
|
|
{
|
|
|
|
a <<= aUIConfigMediaType;
|
|
|
|
xPropSet->setPropertyValue( aMediaTypeProp, a );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-12-21 12:34:54 +00:00
|
|
|
void ODatabaseDocument::impl_notifyEvent( const ::rtl::OUString& _sEventName, ::osl::ClearableMutexGuard& _rGuard )
|
2005-02-02 13:01:30 +00:00
|
|
|
{
|
2005-03-04 08:44:36 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
css::document::EventObject aEvt(*this, _sEventName);
|
2005-12-21 12:34:54 +00:00
|
|
|
Reference< XEventListener > xDocEventBroadcaster;
|
|
|
|
/// TODO: this code has to be deleted after AS' cws will be integrated
|
2005-03-10 15:33:50 +00:00
|
|
|
try
|
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
xDocEventBroadcaster = xDocEventBroadcaster.query( m_pImpl->m_xServiceFactory->createInstance(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.GlobalEventBroadcaster" ) ) ) );
|
2005-03-10 15:33:50 +00:00
|
|
|
}
|
|
|
|
catch(Exception)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Could not create GlobalEventBroadcaster!");
|
|
|
|
}
|
2005-12-21 12:34:54 +00:00
|
|
|
|
|
|
|
_rGuard.clear();
|
|
|
|
if ( xDocEventBroadcaster.is() )
|
|
|
|
xDocEventBroadcaster->notifyEvent(aEvt);
|
|
|
|
m_aDocEventListeners.notifyEach( &css::document::XEventListener::notifyEvent, aEvt );
|
2005-03-04 08:44:36 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
2005-02-02 13:01:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2005-09-23 11:04:55 +00:00
|
|
|
DBG_ASSERT( m_pImpl->m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" );
|
|
|
|
// normally, nobody should explicitly dispose, but only XCloseable::close the document. And controllers
|
|
|
|
// are expected to veto the closing, so when we're here, there shouldn't be any controllers anymore.
|
2005-12-21 12:34:54 +00:00
|
|
|
m_pImpl->m_aControllers.clear();
|
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
|
|
|
{
|
2005-12-21 12:34:54 +00:00
|
|
|
{
|
|
|
|
::osl::ClearableMutexGuard aGuard( getMutex() );
|
|
|
|
impl_notifyEvent( "OnUnload", aGuard );
|
|
|
|
}
|
2005-07-08 09:36:11 +00:00
|
|
|
|
2005-03-10 15:33:50 +00:00
|
|
|
css::lang::EventObject aDisposeEvent(static_cast<XWeak*>(this));
|
|
|
|
m_aModifyListeners.disposeAndClear( aDisposeEvent );
|
|
|
|
m_aCloseListener.disposeAndClear( aDisposeEvent );
|
|
|
|
m_aDocEventListeners.disposeAndClear( aDisposeEvent );
|
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
m_xDocEventBroadcaster = NULL;
|
|
|
|
m_xUIConfigurationManager = NULL;
|
2005-03-10 15:33:50 +00:00
|
|
|
|
2005-05-06 08:18:46 +00:00
|
|
|
Reference<XChild> xChild(m_pImpl->m_xForms.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(NULL);
|
|
|
|
|
|
|
|
xChild.set(m_pImpl->m_xReports.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(NULL);
|
|
|
|
xChild.set(m_pImpl->m_xTableDefinitions.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(NULL);
|
|
|
|
xChild.set(m_pImpl->m_xCommandDefinitions.get(),UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent(NULL);
|
|
|
|
|
2005-07-08 09:36:11 +00:00
|
|
|
m_pImpl->modelIsDisposing( ODatabaseModelImpl::ResetModelAccess() );
|
2005-01-21 16:03:37 +00:00
|
|
|
}
|
2005-03-10 15:33:50 +00:00
|
|
|
m_pImpl.clear();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XComponent
|
|
|
|
void SAL_CALL ODatabaseDocument::dispose( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::cppu::WeakComponentImplHelperBase::dispose();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::addEventListener( const Reference< css::lang::XEventListener >& _xListener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::cppu::WeakComponentImplHelperBase::addEventListener(_xListener);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ODatabaseDocument::removeEventListener( const Reference< css::lang::XEventListener >& _xListener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::cppu::WeakComponentImplHelperBase::removeEventListener(_xListener);
|
|
|
|
}
|
|
|
|
// XServiceInfo
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
rtl::OUString ODatabaseDocument::getImplementationName( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getImplementationName_Static();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
rtl::OUString ODatabaseDocument::getImplementationName_Static( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ODatabaseDocument");
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return getSupportedServiceNames_Static();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > ODatabaseDocument::Create(const Reference< XMultiServiceFactory >& _rxFactory)
|
|
|
|
{
|
|
|
|
return ODatabaseDocument_CreateInstance(_rxFactory);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames_Static( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
Reference< XInterface > ODatabaseDocument::getThis()
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|