summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-25 14:28:03 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-25 14:28:03 +0100
commit5cf47c0008eb4126cfc41c59fbeeb4d73c8e22b1 (patch)
tree60f31eb9322b9d31bb95ec4300ae587bf47ceffd /dbaccess
parent4c4bdf1aaa3645bd15644f983c8f4f8a6307d444 (diff)
undoapi: split OSingleDocumentController into DBSubComponentController (which the report design's controller will
be derived from) and the still-so-named OSingleDocumentController. Module reportdesign does not compile with this change, this is yet to come.
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/inc/dataview.hxx17
-rw-r--r--dbaccess/inc/dbsubcomponentcontroller.hxx (renamed from dbaccess/inc/singledoccontroller.hxx)50
-rw-r--r--dbaccess/source/ui/app/AppController.cxx4
-rw-r--r--dbaccess/source/ui/browser/dataview.cxx39
-rw-r--r--dbaccess/source/ui/inc/JoinController.hxx12
-rw-r--r--dbaccess/source/ui/inc/TableController.hxx20
-rwxr-xr-xdbaccess/source/ui/inc/singledoccontroller.hxx93
-rw-r--r--dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx672
-rw-r--r--dbaccess/source/ui/misc/makefile.mk1
-rwxr-xr-x[-rw-r--r--]dbaccess/source/ui/misc/singledoccontroller.cxx703
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx4
-rw-r--r--dbaccess/source/ui/querydesign/QueryViewSwitch.cxx2
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx4
-rw-r--r--dbaccess/source/ui/relationdesign/RelationController.cxx2
-rw-r--r--dbaccess/source/ui/relationdesign/RelationTableView.cxx29
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx6
16 files changed, 874 insertions, 784 deletions
diff --git a/dbaccess/inc/dataview.hxx b/dbaccess/inc/dataview.hxx
index ae93fa1d3284..fdb99014433a 100644
--- a/dbaccess/inc/dataview.hxx
+++ b/dbaccess/inc/dataview.hxx
@@ -27,17 +27,13 @@
#ifndef DBAUI_DATAVIEW_HXX
#define DBAUI_DATAVIEW_HXX
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include "dbaccessdllapi.h"
+
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#endif
-#ifndef INCLUDED_SVTOOLS_ACCELERATOREXECUTE_HXX
#include <svtools/acceleratorexecute.hxx>
-#endif
+#include <vcl/fixed.hxx>
+
#include <memory>
-#include "dbaccessdllapi.h"
class FixedLine;
class SvtMiscOptions;
@@ -50,7 +46,7 @@ namespace dbaui
protected:
IController& m_rController; // the controller in where we resides in
- FixedLine* m_pSeparator; // our separator above the toolbox (may be NULL)
+ FixedLine m_aSeparator;
::std::auto_ptr< ::svt::AcceleratorExecute> m_pAccel;
public:
@@ -75,9 +71,6 @@ namespace dbaui
*/
virtual void resizeControls(const Size& /*_rDiff*/) { Resize(); }
- void enableSeparator( const sal_Bool _bEnable = sal_True );
- sal_Bool isSeparatorEnabled() const { return NULL != m_pSeparator; }
-
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() { return m_xServiceFactory;}
// the default implementation simply calls resizeAll( GetSizePixel() )
diff --git a/dbaccess/inc/singledoccontroller.hxx b/dbaccess/inc/dbsubcomponentcontroller.hxx
index 8e11446ad8d9..cd93a29df321 100644
--- a/dbaccess/inc/singledoccontroller.hxx
+++ b/dbaccess/inc/dbsubcomponentcontroller.hxx
@@ -25,8 +25,8 @@
*
************************************************************************/
-#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
-#define DBAUI_SINGLEDOCCONTROLLER_HXX
+#ifndef DBAUI_SUBCOMPONENTCONTROLLER_HXX
+#define DBAUI_SUBCOMPONENTCONTROLLER_HXX
#include "genericcontroller.hxx"
@@ -37,15 +37,13 @@
#include <com/sun/star/sdbc/XDataSource.hpp>
#include <com/sun/star/util/XNumberFormatter.hpp>
#include <com/sun/star/util/XModifiable.hpp>
-#include <com/sun/star/document/XUndoManagerSupplier.hpp>
/** === end UNO includes === **/
#include <comphelper/broadcasthelper.hxx>
#include <comphelper/proparrhlp.hxx>
#include <comphelper/propertycontainer.hxx>
#include <connectivity/dbmetadata.hxx>
-#include <cppuhelper/implbase3.hxx>
-#include <svl/undo.hxx>
+#include <cppuhelper/implbase2.hxx>
#include <memory>
@@ -55,22 +53,20 @@ namespace dbaui
//........................................................................
//====================================================================
- //= OSingleDocumentController
+ //= DBSubComponentController
//====================================================================
- class OSingleDocumentController;
+ class DBSubComponentController;
- typedef ::cppu::ImplInheritanceHelper3 < OGenericUnoController
+ typedef ::cppu::ImplInheritanceHelper2 < OGenericUnoController
, ::com::sun::star::document::XScriptInvocationContext
, ::com::sun::star::util::XModifiable
- , ::com::sun::star::document::XUndoManagerSupplier
- > OSingleDocumentController_Base;
+ > DBSubComponentController_Base;
- struct OSingleDocumentControllerImpl;
- class DBACCESS_DLLPUBLIC OSingleDocumentController
- :public OSingleDocumentController_Base
+ struct DBSubComponentController_Impl;
+ class DBACCESS_DLLPUBLIC DBSubComponentController : public DBSubComponentController_Base
{
private:
- ::std::auto_ptr<OSingleDocumentControllerImpl> m_pImpl;
+ ::std::auto_ptr<DBSubComponentController_Impl> m_pImpl;
private:
/** forces usage of a connection which we do not own
@@ -82,9 +78,7 @@ namespace dbaui
// OGenericUnoController - initialization
virtual void impl_initialize();
- // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
- virtual FeatureState GetState(sal_uInt16 nId) const;
- // execute a feature
+ // OGenericUnoController
virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getPrivateModel() const;
@@ -98,14 +92,6 @@ namespace dbaui
sal_Bool isEditable() const;
void setEditable(sal_Bool _bEditable);
- // need for undo's and redo's
- SfxUndoManager& GetUndoManager() const;
-
- /** addUndoActionAndInvalidate adds an undo action to the undoManager,
- additionally invalidates the UNDO and REDO slot
- @param pAction the undo action to add
- */
- void addUndoActionAndInvalidate(SfxUndoAction *pAction);
// ----------------------------------------------------------------
// asking for connection-related stuff
@@ -186,12 +172,9 @@ namespace dbaui
// XTitle
virtual ::rtl::OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException);
- // XUndoManagerSupplier
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL getUndoManager( ) throw (::com::sun::star::uno::RuntimeException);
-
protected:
- OSingleDocumentController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxORB);
- virtual ~OSingleDocumentController();
+ DBSubComponentController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxORB);
+ virtual ~DBSubComponentController();
virtual void disconnect();
virtual void reconnect( sal_Bool _bUI );
@@ -202,9 +185,6 @@ namespace dbaui
*/
virtual void losingConnection( );
- // late construction
- virtual sal_Bool Construct(Window* pParent);
-
protected:
// XEventListener
virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
@@ -222,12 +202,12 @@ namespace dbaui
sal_Int32 getCurrentStartNumber() const;
private:
- OSingleDocumentController(); // never implemented
+ DBSubComponentController(); // never implemented
};
//........................................................................
} // namespace dbaui
//........................................................................
-#endif // DBAUI_SINGLEDOCCONTROLLER_HXX
+#endif // DBAUI_SUBCOMPONENTCONTROLLER_HXX
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 595d9b412851..f624853c8852 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -482,10 +482,6 @@ sal_Bool OApplicationController::Construct(Window* _pParent)
return sal_False;
}
- DBG_ASSERT( getView(), "OApplicationController::Construct: have no view!" );
- if ( getView() )
- getView()->enableSeparator( );
-
// now that we have a view we can create the clipboard listener
m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
m_aSystemClipboard.StartClipboardListening( );
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx
index 382aac477727..8112250ad23e 100644
--- a/dbaccess/source/ui/browser/dataview.cxx
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -44,9 +44,6 @@
#ifndef _SFXIMGMGR_HXX
#include <sfx2/imgmgr.hxx>
#endif
-#ifndef _SV_FIXED_HXX
-#include <vcl/fixed.hxx>
-#endif
#ifndef DBAUI_ICONTROLLER_HXX
#include "IController.hxx"
#endif
@@ -103,11 +100,12 @@ namespace dbaui
:Window(pParent,nStyle)
,m_xServiceFactory(_rFactory)
,m_rController( _rController )
- ,m_pSeparator( NULL )
+ ,m_aSeparator( this )
{
DBG_CTOR(ODataView,NULL);
m_rController.acquire();
m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
+ m_aSeparator.Show();
}
// -------------------------------------------------------------------------
@@ -120,30 +118,10 @@ namespace dbaui
{
DBG_DTOR(ODataView,NULL);
- enableSeparator( sal_False );
m_rController.release();
}
// -------------------------------------------------------------------------
- void ODataView::enableSeparator( const sal_Bool _bEnable )
- {
- if ( _bEnable == isSeparatorEnabled() )
- // nothing to do
- return;
-
- if ( _bEnable )
- {
- m_pSeparator = new FixedLine( this );
- m_pSeparator->Show( );
- }
- else
- {
- ::std::auto_ptr<FixedLine> aTemp(m_pSeparator);
- m_pSeparator = NULL;
- }
- Resize();
- }
- // -------------------------------------------------------------------------
void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
{
}
@@ -167,15 +145,10 @@ namespace dbaui
{
Rectangle aPlayground( _rPlayground );
- // position thew separator
- if ( m_pSeparator )
- {
- Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
-
- m_pSeparator->SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
-
- aPlayground.Top() += aSeparatorSize.Height() + 1;
- }
+ // position the separator
+ const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
+ m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
+ aPlayground.Top() += aSeparatorSize.Height() + 1;
// position the controls of the document's view
resizeDocumentView( aPlayground );
diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx
index 41ee2458fa2f..8ff5fe99b727 100644
--- a/dbaccess/source/ui/inc/JoinController.hxx
+++ b/dbaccess/source/ui/inc/JoinController.hxx
@@ -27,26 +27,14 @@
#ifndef DBAUI_JOINCONTROLLER_HXX
#define DBAUI_JOINCONTROLLER_HXX
-#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
#include "singledoccontroller.hxx"
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
-#endif
-#ifndef DBAUI_JOINTABLEVIEW_HXX
#include "JoinTableView.hxx"
-#endif
-#ifndef DBAUI_JOINDESIGNVIEW_HXX
#include "JoinDesignView.hxx"
-#endif
#include "TableConnectionData.hxx"
#include "TableWindowData.hxx"
-#ifndef _MEMORY_
#include <memory>
-#endif
#include <boost/shared_ptr.hpp>
namespace comphelper
diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx
index b64fba13bbea..a1f1b8158c65 100644
--- a/dbaccess/source/ui/inc/TableController.hxx
+++ b/dbaccess/source/ui/inc/TableController.hxx
@@ -27,36 +27,16 @@
#ifndef DBUI_TABLECONTROLLER_HXX
#define DBUI_TABLECONTROLLER_HXX
-#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
#include "singledoccontroller.hxx"
-#endif
-#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
-#endif
-#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
#include <com/sun/star/sdbc/XConnection.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectOutputStream.hpp>
-#endif
-#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectInputStream.hpp>
-#endif
-#ifndef DBAUI_TYPEINFO_HXX
#include "TypeInfo.hxx"
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
-#endif
class FixedText;
namespace dbaui
diff --git a/dbaccess/source/ui/inc/singledoccontroller.hxx b/dbaccess/source/ui/inc/singledoccontroller.hxx
new file mode 100755
index 000000000000..c738bd94e81c
--- /dev/null
+++ b/dbaccess/source/ui/inc/singledoccontroller.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
+#define DBAUI_SINGLEDOCCONTROLLER_HXX
+
+#include "dbsubcomponentcontroller.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+class SfxUndoAction;
+class SfxUndoManager;
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= OSingleDocumentController
+ //==================================================================================================================
+ struct OSingleDocumentController_Data;
+ typedef ::cppu::ImplInheritanceHelper1 < DBSubComponentController
+ , ::com::sun::star::document::XUndoManagerSupplier
+ > OSingleDocumentController_Base;
+ class OSingleDocumentController : public OSingleDocumentController_Base
+ {
+ protected:
+ OSingleDocumentController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxORB );
+ virtual ~OSingleDocumentController();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ public:
+ /// need for undo's and redo's
+ SfxUndoManager& GetUndoManager() const;
+
+ /// complete clears the Undo/Redo stacks
+ void ClearUndoManager();
+
+ /** addUndoActionAndInvalidate adds an undo action to the undoManager,
+ additionally invalidates the UNDO and REDO slot
+ @param pAction the undo action to add
+ */
+ void addUndoActionAndInvalidate( SfxUndoAction* pAction );
+
+ // OGenericUnoController
+ virtual FeatureState GetState( sal_uInt16 nId ) const;
+ virtual void Execute( sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs );
+
+ // XUndoManagerSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL getUndoManager( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ private:
+ ::std::auto_ptr< OSingleDocumentController_Data > m_pData;
+ };
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
+
+#endif // DBAUI_SINGLEDOCCONTROLLER_HXX
diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
new file mode 100644
index 000000000000..eb1b34710ff8
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
@@ -0,0 +1,672 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "browserids.hxx"
+#include "commontypes.hxx"
+#include "dataview.hxx"
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "dbsubcomponentcontroller.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::sdbc::XDataSource;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdb::XDocumentDataSource;
+ using ::com::sun::star::document::XEmbeddedScripts;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::frame::XUntitledNumbers;
+ using ::com::sun::star::beans::PropertyVetoException;
+ /** === end UNO using === **/
+
+ class DataSourceHolder
+ {
+ public:
+ DataSourceHolder()
+ {
+ }
+
+ DataSourceHolder( const Reference< XDataSource >& _rxDataSource )
+ {
+ m_xDataSource = _rxDataSource;
+ Reference< XDocumentDataSource > xDocDS( m_xDataSource, UNO_QUERY );
+ if ( xDocDS.is() )
+ m_xDocument = xDocDS->getDatabaseDocument();
+
+ m_xDataSourceProps.set( m_xDataSource, UNO_QUERY );
+ }
+
+ const Reference< XDataSource >& getDataSource() const { return m_xDataSource; }
+ const Reference< XPropertySet >& getDataSourceProps() const { return m_xDataSourceProps; }
+ const Reference< XOfficeDatabaseDocument > getDatabaseDocument() const { return m_xDocument; }
+
+ bool is() const { return m_xDataSource.is(); }
+
+ void clear()
+ {
+ m_xDataSource.clear();
+ m_xDocument.clear();
+ }
+
+ private:
+ Reference< XDataSource > m_xDataSource;
+ Reference< XPropertySet > m_xDataSourceProps;
+ Reference< XOfficeDatabaseDocument > m_xDocument;
+ };
+
+ struct DBSubComponentController_Impl
+ {
+ private:
+ ::boost::optional< bool > m_aDocScriptSupport;
+
+ public:
+ OModuleClient m_aModuleClient;
+ ::dbtools::SQLExceptionInfo m_aCurrentError;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aModifyListeners;
+
+ // <properties>
+ SharedConnection m_xConnection;
+ ::dbtools::DatabaseMetaData m_aSdbMetaData;
+ // </properties>
+ ::rtl::OUString m_sDataSourceName; // the data source we're working for
+ DataSourceHolder m_aDataSource;
+ Reference< XModel > m_xDocument;
+ Reference< XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+ sal_Int32 m_nDocStartNumber;
+ sal_Bool m_bSuspended; // is true when the controller was already suspended
+ sal_Bool m_bEditable; // is the control readonly or not
+ sal_Bool m_bModified; // is the data modified
+ bool m_bNotAttached;
+
+ DBSubComponentController_Impl( ::osl::Mutex& i_rMutex )
+ :m_aDocScriptSupport()
+ ,m_aModifyListeners( i_rMutex )
+ ,m_nDocStartNumber(0)
+ ,m_bSuspended( sal_False )
+ ,m_bEditable(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bNotAttached(true)
+ {
+ }
+
+ bool documentHasScriptSupport() const
+ {
+ OSL_PRECOND( !!m_aDocScriptSupport,
+ "DBSubComponentController_Impl::documentHasScriptSupport: not completely initialized, yet - don't know!?" );
+ return !!m_aDocScriptSupport && *m_aDocScriptSupport;
+ }
+
+ void setDocumentScriptSupport( const bool _bSupport )
+ {
+ OSL_PRECOND( !m_aDocScriptSupport,
+ "DBSubComponentController_Impl::setDocumentScriptSupport: already initialized!" );
+ m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
+ }
+ };
+
+ //====================================================================
+ //= DBSubComponentController
+ //====================================================================
+ //--------------------------------------------------------------------
+ DBSubComponentController::DBSubComponentController(const Reference< XMultiServiceFactory >& _rxORB)
+ :DBSubComponentController_Base( _rxORB )
+ ,m_pImpl( new DBSubComponentController_Impl( getMutex() ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DBSubComponentController::~DBSubComponentController()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::impl_initialize()
+ {
+ OGenericUnoController::impl_initialize();
+
+ const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
+
+ Reference< XConnection > xConnection;
+ xConnection = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection );
+
+ if ( !xConnection.is() )
+ ::dbtools::isEmbeddedInDatabase( getModel(), xConnection );
+
+ if ( xConnection.is() )
+ initializeConnection( xConnection );
+
+ bool bShowError = true;
+ if ( !isConnected() )
+ {
+ reconnect( sal_False );
+ bShowError = false;
+ }
+ if ( !isConnected() )
+ {
+ if ( bShowError )
+ connectionLostMessage();
+ throw IllegalArgumentException();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL DBSubComponentController::queryInterface(const Type& _rType) throw (RuntimeException)
+ {
+ if ( _rType.equals( XScriptInvocationContext::static_type() ) )
+ {
+ if ( m_pImpl->documentHasScriptSupport() )
+ return makeAny( Reference< XScriptInvocationContext >( this ) );
+ return Any();
+ }
+
+ return DBSubComponentController_Base::queryInterface( _rType );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Type > SAL_CALL DBSubComponentController::getTypes( ) throw (RuntimeException)
+ {
+ Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ {
+ Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 );
+ ::std::remove_copy_if(
+ aTypes.getConstArray(),
+ aTypes.getConstArray() + aTypes.getLength(),
+ aStrippedTypes.getArray(),
+ ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
+ );
+ aTypes = aStrippedTypes;
+ }
+ return aTypes;
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::initializeConnection( const Reference< XConnection >& _rxForeignConn )
+ {
+ DBG_ASSERT( !isConnected(), "DBSubComponentController::initializeConnection: not to be called when already connected!" );
+ // usually this gets called from within initialize of derived classes ...
+ if ( isConnected() )
+ disconnect();
+
+ m_pImpl->m_xConnection.reset( _rxForeignConn, SharedConnection::NoTakeOwnership );
+ m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
+ startConnectionListening( m_pImpl->m_xConnection );
+
+ // get the data source the connection belongs to
+ try
+ {
+ // determine our data source
+ OSL_PRECOND( !m_pImpl->m_aDataSource.is(), "DBSubComponentController::initializeConnection: already a data source in this phase?" );
+ {
+ Reference< XChild > xConnAsChild( m_pImpl->m_xConnection, UNO_QUERY );
+ Reference< XDataSource > xDS;
+ if ( xConnAsChild.is() )
+ xDS = Reference< XDataSource >( xConnAsChild->getParent(), UNO_QUERY );
+
+ // (take the indirection through XDataSource to ensure we have a correct object ....)
+ m_pImpl->m_aDataSource = xDS;
+ }
+ OSL_POSTCOND( m_pImpl->m_aDataSource.is(), "DBSubComponentController::initializeConnection: unable to obtain the data source object!" );
+
+ if ( m_pImpl->m_bNotAttached )
+ {
+ Reference< XUntitledNumbers > xUntitledProvider( getDatabaseDocument(), UNO_QUERY );
+ m_pImpl->m_nDocStartNumber = 1;
+ if ( xUntitledProvider.is() )
+ m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
+ }
+
+ // determine the availability of script support in our document. Our own XScriptInvocationContext
+ // interface depends on this
+ m_pImpl->setDocumentScriptSupport( Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY ).is() );
+
+ // get a number formatter
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps(), UNO_SET_THROW );
+ xDataSourceProps->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->m_sDataSourceName;
+ DBG_ASSERT( m_pImpl->m_sDataSourceName.getLength(), "DBSubComponentController::initializeConnection: invalid data source name!" );
+ Reference< XNumberFormatsSupplier> xSupplier = ::dbtools::getNumberFormats(m_pImpl->m_xConnection);
+ if(xSupplier.is())
+ {
+ m_pImpl->m_xFormatter = Reference< XNumberFormatter >(getORB()
+ ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
+ m_pImpl->m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ OSL_ENSURE(m_pImpl->m_xFormatter.is(),"No NumberFormatter!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::reconnect( sal_Bool _bUI )
+ {
+ OSL_ENSURE(!m_pImpl->m_bSuspended, "Cannot reconnect while suspended!");
+
+ stopConnectionListening( m_pImpl->m_xConnection );
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ // reconnect
+ sal_Bool bReConnect = sal_True;
+ if ( _bUI )
+ {
+ QueryBox aQuery( getView(), ModuleRes(QUERY_CONNECTION_LOST) );
+ bReConnect = ( RET_YES == aQuery.Execute() );
+ }
+
+ // now really reconnect ...
+ if ( bReConnect )
+ {
+ m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), NULL ), SharedConnection::TakeOwnership );
+ m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
+ }
+
+ // invalidate all slots
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::disconnect()
+ {
+ stopConnectionListening(m_pImpl->m_xConnection);
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::losingConnection()
+ {
+ // our connection was disposed so we need a new one
+ reconnect( sal_True );
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::disposing()
+ {
+ DBSubComponentController_Base::disposing();
+
+ disconnect();
+
+ attachFrame( Reference < XFrame >() );
+
+ m_pImpl->m_aDataSource.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::disposing(const EventObject& _rSource) throw( RuntimeException )
+ {
+ if ( _rSource.Source == getConnection() )
+ {
+ if ( !m_pImpl->m_bSuspended // when already suspended then we don't have to reconnect
+ && !getBroadcastHelper().bInDispose
+ && !getBroadcastHelper().bDisposed
+ && isConnected()
+ )
+ {
+ losingConnection();
+ }
+ else
+ {
+ m_pImpl->m_xConnection.reset( m_pImpl->m_xConnection, SharedConnection::NoTakeOwnership );
+ // this prevents the "disposeComponent" call in disconnect
+ disconnect();
+ }
+ }
+ else
+ DBSubComponentController_Base::disposing( _rSource );
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::appendError( const ::rtl::OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState,
+ const sal_Int32 _nErrorCode )
+ {
+ m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLStateAscii( _eSQLState ),
+ _nErrorCode );
+ }
+ //--------------------------------------------------------------------
+ void DBSubComponentController::clearError()
+ {
+ m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool DBSubComponentController::hasError() const
+ {
+ return m_pImpl->m_aCurrentError.isValid();
+ }
+
+ //--------------------------------------------------------------------
+ const ::dbtools::SQLExceptionInfo& DBSubComponentController::getError() const
+ {
+ return m_pImpl->m_aCurrentError;
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::displayError()
+ {
+ showError( m_pImpl->m_aCurrentError );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL DBSubComponentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
+ {
+ m_pImpl->m_bSuspended = bSuspend;
+ if ( !bSuspend && !isConnected() )
+ reconnect(sal_True);
+
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL DBSubComponentController::attachModel( const Reference< XModel > & _rxModel) throw( RuntimeException )
+ {
+ if ( !_rxModel.is() )
+ return sal_False;
+ if ( !DBSubComponentController_Base::attachModel( _rxModel ) )
+ return sal_False;
+
+ m_pImpl->m_bNotAttached = false;
+ if ( m_pImpl->m_nDocStartNumber == 1 )
+ releaseNumberForComponent();
+
+ Reference< XUntitledNumbers > xUntitledProvider( _rxModel, UNO_QUERY );
+ m_pImpl->m_nDocStartNumber = 1;
+ if ( xUntitledProvider.is() )
+ m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs)
+ {
+ if ( _nId == ID_BROWSER_CLOSE )
+ {
+ closeTask();
+ return;
+ }
+
+ DBSubComponentController_Base::Execute( _nId, _rArgs );
+ InvalidateFeature( _nId );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString DBSubComponentController::getDataSourceName() const
+ {
+ ::rtl::OUString sName;
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps() );
+ if ( xDataSourceProps.is() )
+ xDataSourceProps->getPropertyValue(PROPERTY_NAME) >>= sName;
+ return sName;
+ }
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::connectionLostMessage() const
+ {
+ String aMessage(ModuleRes(RID_STR_CONNECTION_LOST));
+ Reference< XWindow > xWindow = getTopMostContainerWindow();
+ Window* pWin = NULL;
+ if ( xWindow.is() )
+ pWin = VCLUnoHelper::GetWindow(xWindow);
+ if ( !pWin )
+ pWin = getView()->Window::GetParent();
+
+ InfoBox(pWin, aMessage).Execute();
+ }
+ // -----------------------------------------------------------------------------
+ const Reference< XConnection >& DBSubComponentController::getConnection() const
+ {
+ return m_pImpl->m_xConnection;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isReadOnly() const
+ {
+ return !m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isEditable() const
+ {
+ return m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::setEditable(sal_Bool _bEditable)
+ {
+ m_pImpl->m_bEditable = _bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ const ::dbtools::DatabaseMetaData& DBSubComponentController::getSdbMetaData() const
+ {
+ return m_pImpl->m_aSdbMetaData;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isConnected() const
+ {
+ return m_pImpl->m_xConnection.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XDatabaseMetaData > DBSubComponentController::getMetaData( ) const
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ try
+ {
+ if ( isConnected() )
+ xMeta.set( m_pImpl->m_xConnection->getMetaData(), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xMeta;
+ }
+
+ // -----------------------------------------------------------------------------
+ const Reference< XPropertySet >& DBSubComponentController::getDataSource() const
+ {
+ return m_pImpl->m_aDataSource.getDataSourceProps();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::haveDataSource() const
+ {
+ return m_pImpl->m_aDataSource.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > DBSubComponentController::getDatabaseDocument() const
+ {
+ return Reference< XModel >( m_pImpl->m_aDataSource.getDatabaseDocument(), UNO_QUERY );
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XNumberFormatter > DBSubComponentController::getNumberFormatter() const
+ {
+ return m_pImpl->m_xFormatter;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > DBSubComponentController::getPrivateModel() const
+ {
+ return getDatabaseDocument();
+ }
+ // -----------------------------------------------------------------------------
+ // XTitle
+ ::rtl::OUString SAL_CALL DBSubComponentController::getTitle()
+ throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( m_bExternalTitle )
+ return impl_getTitleHelper_throw()->getTitle ();
+
+ ::rtl::OUStringBuffer sTitle;
+ Reference< XTitle > xTitle(getPrivateModel(),UNO_QUERY);
+ if ( xTitle.is() )
+ {
+ sTitle.append( xTitle->getTitle() );
+ sTitle.appendAscii(" : ");
+ }
+ sTitle.append( getPrivateTitle() );
+ return sTitle.makeStringAndClear();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Int32 DBSubComponentController::getCurrentStartNumber() const
+ {
+ return m_pImpl->m_nDocStartNumber;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XEmbeddedScripts > SAL_CALL DBSubComponentController::getScriptContainer() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ return NULL;
+
+ return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::addModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.addInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::removeModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.removeInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DBSubComponentController::isModified( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ return impl_isModified();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::setModified( ::sal_Bool i_bModified ) throw (PropertyVetoException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( getMutex() );
+
+ if ( m_pImpl->m_bModified == i_bModified )
+ return;
+
+ m_pImpl->m_bModified = i_bModified;
+ impl_onModifyChanged();
+
+ EventObject aEvent( *this );
+ aGuard.clear();
+ m_pImpl->m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::impl_isModified() const
+ {
+ return m_pImpl->m_bModified;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::impl_onModifyChanged()
+ {
+ InvalidateFeature( ID_BROWSER_SAVEDOC );
+ if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) )
+ InvalidateFeature( ID_BROWSER_SAVEASDOC );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/makefile.mk b/dbaccess/source/ui/misc/makefile.mk
index 62276292224e..534d90e3995c 100644
--- a/dbaccess/source/ui/misc/makefile.mk
+++ b/dbaccess/source/ui/misc/makefile.mk
@@ -52,6 +52,7 @@ SLOFILES= \
$(SLO)/asyncmodaldialog.obj \
$(SLO)/imageprovider.obj \
$(SLO)/singledoccontroller.obj \
+ $(SLO)/dbsubcomponentcontroller.obj \
$(SLO)/datasourceconnector.obj \
$(SLO)/linkeddocuments.obj \
$(SLO)/indexcollection.obj \
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
index a382f245347a..2e8c002a2097 100644..100755
--- a/dbaccess/source/ui/misc/singledoccontroller.cxx
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -1,5 +1,4 @@
/*************************************************************************
- *
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
@@ -25,472 +24,128 @@
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
+#include "dbaundomanager.hxx"
+#include "singledoccontroller.hxx"
#include "browserids.hxx"
-#include "commontypes.hxx"
-#include "dataview.hxx"
#include "dbu_misc.hrc"
#include "dbustrings.hrc"
#include "moduledbu.hxx"
-#include "singledoccontroller.hxx"
-#include "dbaundomanager.hxx"
/** === begin UNO includes === **/
-#include <com/sun/star/frame/XUntitledNumbers.hpp>
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <com/sun/star/container/XChild.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/sdb/XDocumentDataSource.hpp>
-#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
-#include <com/sun/star/sdbc/XDataSource.hpp>
-#include <com/sun/star/lang/IllegalArgumentException.hpp>
-#include <com/sun/star/frame/XUntitledNumbers.hpp>
/** === end UNO includes === **/
-#include <comphelper/sequence.hxx>
-#include <comphelper/types.hxx>
-#include <connectivity/dbexception.hxx>
-#include <connectivity/dbtools.hxx>
-#include <cppuhelper/typeprovider.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <toolkit/unohlp.hxx>
-#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
-#include <vcl/msgbox.hxx>
+#include <svl/undo.hxx>
-//........................................................................
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
namespace dbaui
{
-//........................................................................
+//......................................................................................................................
/** === begin UNO using === **/
- using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
- using ::com::sun::star::beans::XPropertySet;
- using ::com::sun::star::util::XNumberFormatter;
- using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Type;
- using ::com::sun::star::sdbc::XConnection;
- using ::com::sun::star::uno::UNO_QUERY;
- using ::com::sun::star::container::XChild;
- using ::com::sun::star::sdbc::XDataSource;
- using ::com::sun::star::util::XNumberFormatter;
- using ::com::sun::star::util::XNumberFormatsSupplier;
- using ::com::sun::star::frame::XFrame;
- using ::com::sun::star::uno::Exception;
- using ::com::sun::star::sdbc::SQLException;
- using ::com::sun::star::lang::EventObject;
- using ::com::sun::star::beans::PropertyValue;
- using ::com::sun::star::frame::XModel;
- using ::com::sun::star::sdb::XOfficeDatabaseDocument;
- using ::com::sun::star::awt::XWindow;
- using ::com::sun::star::sdbc::XDatabaseMetaData;
- using ::com::sun::star::sdb::XDocumentDataSource;
- using ::com::sun::star::document::XEmbeddedScripts;
- using ::com::sun::star::lang::IllegalArgumentException;
- using ::com::sun::star::uno::UNO_SET_THROW;
- using ::com::sun::star::uno::UNO_QUERY_THROW;
- using ::com::sun::star::frame::XUntitledNumbers;
- using ::com::sun::star::beans::PropertyVetoException;
using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::lang::EventObject;
/** === end UNO using === **/
- class DataSourceHolder
+ //==================================================================================================================
+ //= OSingleDocumentController_Data
+ //==================================================================================================================
+ struct OSingleDocumentController_Data
{
- public:
- DataSourceHolder()
- {
- }
-
- DataSourceHolder( const Reference< XDataSource >& _rxDataSource )
- {
- m_xDataSource = _rxDataSource;
- Reference< XDocumentDataSource > xDocDS( m_xDataSource, UNO_QUERY );
- if ( xDocDS.is() )
- m_xDocument = xDocDS->getDatabaseDocument();
-
- m_xDataSourceProps.set( m_xDataSource, UNO_QUERY );
- }
-
- const Reference< XDataSource >& getDataSource() const { return m_xDataSource; }
- const Reference< XPropertySet >& getDataSourceProps() const { return m_xDataSourceProps; }
- const Reference< XOfficeDatabaseDocument > getDatabaseDocument() const { return m_xDocument; }
+ ::boost::scoped_ptr< UndoManager > m_pUndoManager;
- bool is() const { return m_xDataSource.is(); }
-
- void clear()
+ OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pUndoManager( new UndoManager( i_parent, i_mutex ) )
{
- m_xDataSource.clear();
- m_xDocument.clear();
}
-
- private:
- Reference< XDataSource > m_xDataSource;
- Reference< XPropertySet > m_xDataSourceProps;
- Reference< XOfficeDatabaseDocument > m_xDocument;
};
- struct OSingleDocumentControllerImpl
- {
- private:
- ::boost::optional< bool > m_aDocScriptSupport;
-
- public:
- OModuleClient m_aModuleClient;
- ::dbtools::SQLExceptionInfo m_aCurrentError;
-
- ::cppu::OInterfaceContainerHelper
- m_aModifyListeners;
-
- // <properties>
- SharedConnection m_xConnection;
- ::dbtools::DatabaseMetaData m_aSdbMetaData;
- // </properties>
- ::boost::scoped_ptr< UndoManager >
- m_pUndoManager;
- ::rtl::OUString m_sDataSourceName; // the data source we're working for
- DataSourceHolder m_aDataSource;
- Reference< XModel > m_xDocument;
- Reference< XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
- sal_Int32 m_nDocStartNumber;
- sal_Bool m_bSuspended; // is true when the controller was already suspended
- sal_Bool m_bEditable; // is the control readonly or not
- sal_Bool m_bModified; // is the data modified
- bool m_bNotAttached;
-
- OSingleDocumentControllerImpl( OSingleDocumentController& i_antiImpl, ::osl::Mutex& i_rMutex )
- :m_aDocScriptSupport()
- ,m_aModifyListeners( i_rMutex )
- ,m_pUndoManager( new UndoManager( i_antiImpl, i_rMutex ) )
- ,m_nDocStartNumber(0)
- ,m_bSuspended( sal_False )
- ,m_bEditable(sal_True)
- ,m_bModified(sal_False)
- ,m_bNotAttached(true)
- {
- }
-
- bool documentHasScriptSupport() const
- {
- OSL_PRECOND( !!m_aDocScriptSupport,
- "OSingleDocumentControllerImpl::documentHasScriptSupport: not completely initialized, yet - don't know!?" );
- return !!m_aDocScriptSupport && *m_aDocScriptSupport;
- }
-
- void setDocumentScriptSupport( const bool _bSupport )
- {
- OSL_PRECOND( !m_aDocScriptSupport,
- "OSingleDocumentControllerImpl::setDocumentScriptSupport: already initialized!" );
- m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
- }
- };
-
- //====================================================================
+ //==================================================================================================================
//= OSingleDocumentController
- //====================================================================
- //--------------------------------------------------------------------
- OSingleDocumentController::OSingleDocumentController(const Reference< XMultiServiceFactory >& _rxORB)
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ OSingleDocumentController::OSingleDocumentController( const Reference< XMultiServiceFactory >& _rxORB )
:OSingleDocumentController_Base( _rxORB )
- ,m_pImpl( new OSingleDocumentControllerImpl( *this, getMutex() ) )
+ ,m_pData( new OSingleDocumentController_Data( *this, getMutex() ) )
{
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
OSingleDocumentController::~OSingleDocumentController()
{
}
- //--------------------------------------------------------------------
- void OSingleDocumentController::impl_initialize()
- {
- OGenericUnoController::impl_initialize();
-
- const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
-
- Reference< XConnection > xConnection;
- xConnection = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection );
-
- if ( !xConnection.is() )
- ::dbtools::isEmbeddedInDatabase( getModel(), xConnection );
-
- if ( xConnection.is() )
- initializeConnection( xConnection );
-
- bool bShowError = true;
- if ( !isConnected() )
- {
- reconnect( sal_False );
- bShowError = false;
- }
- if ( !isConnected() )
- {
- if ( bShowError )
- connectionLostMessage();
- throw IllegalArgumentException();
- }
- }
-
- //--------------------------------------------------------------------
- Any SAL_CALL OSingleDocumentController::queryInterface(const Type& _rType) throw (RuntimeException)
- {
- if ( _rType.equals( XScriptInvocationContext::static_type() ) )
- {
- if ( m_pImpl->documentHasScriptSupport() )
- return makeAny( Reference< XScriptInvocationContext >( this ) );
- return Any();
- }
-
- return OSingleDocumentController_Base::queryInterface( _rType );
- }
-
- //--------------------------------------------------------------------
- Sequence< Type > SAL_CALL OSingleDocumentController::getTypes( ) throw (RuntimeException)
- {
- Sequence< Type > aTypes( OSingleDocumentController_Base::getTypes() );
- if ( !m_pImpl->documentHasScriptSupport() )
- {
- Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 );
- ::std::remove_copy_if(
- aTypes.getConstArray(),
- aTypes.getConstArray() + aTypes.getLength(),
- aStrippedTypes.getArray(),
- ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
- );
- aTypes = aStrippedTypes;
- }
- return aTypes;
- }
-
- //--------------------------------------------------------------------
- void OSingleDocumentController::initializeConnection( const Reference< XConnection >& _rxForeignConn )
- {
- DBG_ASSERT( !isConnected(), "OSingleDocumentController::initializeConnection: not to be called when already connected!" );
- // usually this gets called from within initialize of derived classes ...
- if ( isConnected() )
- disconnect();
-
- m_pImpl->m_xConnection.reset( _rxForeignConn, SharedConnection::NoTakeOwnership );
- m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
- startConnectionListening( m_pImpl->m_xConnection );
-
- // get the data source the connection belongs to
- try
- {
- // determine our data source
- OSL_PRECOND( !m_pImpl->m_aDataSource.is(), "OSingleDocumentController::initializeConnection: already a data source in this phase?" );
- {
- Reference< XChild > xConnAsChild( m_pImpl->m_xConnection, UNO_QUERY );
- Reference< XDataSource > xDS;
- if ( xConnAsChild.is() )
- xDS = Reference< XDataSource >( xConnAsChild->getParent(), UNO_QUERY );
-
- // (take the indirection through XDataSource to ensure we have a correct object ....)
- m_pImpl->m_aDataSource = xDS;
- }
- OSL_POSTCOND( m_pImpl->m_aDataSource.is(), "OSingleDocumentController::initializeConnection: unable to obtain the data source object!" );
-
- if ( m_pImpl->m_bNotAttached )
- {
- Reference< XUntitledNumbers > xUntitledProvider( getDatabaseDocument(), UNO_QUERY );
- m_pImpl->m_nDocStartNumber = 1;
- if ( xUntitledProvider.is() )
- m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
- }
-
- // determine the availability of script support in our document. Our own XScriptInvocationContext
- // interface depends on this
- m_pImpl->setDocumentScriptSupport( Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY ).is() );
-
- // get a number formatter
- Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps(), UNO_SET_THROW );
- xDataSourceProps->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->m_sDataSourceName;
- DBG_ASSERT( m_pImpl->m_sDataSourceName.getLength(), "OSingleDocumentController::initializeConnection: invalid data source name!" );
- Reference< XNumberFormatsSupplier> xSupplier = ::dbtools::getNumberFormats(m_pImpl->m_xConnection);
- if(xSupplier.is())
- {
- m_pImpl->m_xFormatter = Reference< XNumberFormatter >(getORB()
- ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
- m_pImpl->m_xFormatter->attachNumberFormatsSupplier(xSupplier);
- }
- OSL_ENSURE(m_pImpl->m_xFormatter.is(),"No NumberFormatter!");
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
-
- //--------------------------------------------------------------------
- void OSingleDocumentController::reconnect( sal_Bool _bUI )
- {
- OSL_ENSURE(!m_pImpl->m_bSuspended, "Cannot reconnect while suspended!");
-
- stopConnectionListening( m_pImpl->m_xConnection );
- m_pImpl->m_aSdbMetaData.reset( NULL );
- m_pImpl->m_xConnection.clear();
-
- // reconnect
- sal_Bool bReConnect = sal_True;
- if ( _bUI )
- {
- QueryBox aQuery( getView(), ModuleRes(QUERY_CONNECTION_LOST) );
- bReConnect = ( RET_YES == aQuery.Execute() );
- }
-
- // now really reconnect ...
- if ( bReConnect )
- {
- m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), NULL ), SharedConnection::TakeOwnership );
- m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
- }
-
- // invalidate all slots
- InvalidateAll();
- }
-
- //--------------------------------------------------------------------
- void OSingleDocumentController::disconnect()
- {
- stopConnectionListening(m_pImpl->m_xConnection);
- m_pImpl->m_aSdbMetaData.reset( NULL );
- m_pImpl->m_xConnection.clear();
-
- InvalidateAll();
- }
-
- //--------------------------------------------------------------------
- void OSingleDocumentController::losingConnection()
- {
- // our connection was disposed so we need a new one
- reconnect( sal_True );
- InvalidateAll();
- }
-
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------
void SAL_CALL OSingleDocumentController::disposing()
{
OSingleDocumentController_Base::disposing();
- GetUndoManager().Clear();
-
- disconnect();
-
- attachFrame( Reference < XFrame >() );
-
- m_pImpl->m_pUndoManager->disposing();
- m_pImpl->m_aDataSource.clear();
- }
-
- //--------------------------------------------------------------------
- sal_Bool OSingleDocumentController::Construct(Window* _pParent)
- {
- DBG_ASSERT( getView(), "OSingleDocumentController::Construct: have no view!" );
- if ( getView() )
- getView()->enableSeparator( );
-
- return OSingleDocumentController_Base::Construct( _pParent );
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL OSingleDocumentController::disposing(const EventObject& _rSource) throw( RuntimeException )
- {
- if ( _rSource.Source == getConnection() )
- {
- if ( !m_pImpl->m_bSuspended // when already suspended then we don't have to reconnect
- && !getBroadcastHelper().bInDispose
- && !getBroadcastHelper().bDisposed
- && isConnected()
- )
- {
- losingConnection();
- }
- else
- {
- m_pImpl->m_xConnection.reset( m_pImpl->m_xConnection, SharedConnection::NoTakeOwnership );
- // this prevents the "disposeComponent" call in disconnect
- disconnect();
- }
- }
- else
- OSingleDocumentController_Base::disposing( _rSource );
- }
-
- //--------------------------------------------------------------------
- void OSingleDocumentController::appendError( const ::rtl::OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState,
- const sal_Int32 _nErrorCode )
- {
- m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLStateAscii( _eSQLState ),
- _nErrorCode );
- }
- //--------------------------------------------------------------------
- void OSingleDocumentController::clearError()
- {
- m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
+ ClearUndoManager();
+ m_pData->m_pUndoManager->disposing();
}
- //--------------------------------------------------------------------
- sal_Bool OSingleDocumentController::hasError() const
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::disposing( const EventObject& i_event ) throw( RuntimeException )
{
- return m_pImpl->m_aCurrentError.isValid();
+ // simply disambiguate
+ OSingleDocumentController_Base::disposing( i_event );
}
- //--------------------------------------------------------------------
- const ::dbtools::SQLExceptionInfo& OSingleDocumentController::getError() const
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::ClearUndoManager()
{
- return m_pImpl->m_aCurrentError;
+ GetUndoManager().Clear();
}
- //--------------------------------------------------------------------
- void OSingleDocumentController::displayError()
+ // -----------------------------------------------------------------------------
+ SfxUndoManager& OSingleDocumentController::GetUndoManager() const
{
- showError( m_pImpl->m_aCurrentError );
+ return m_pData->m_pUndoManager->GetSfxUndoManager();
}
- //--------------------------------------------------------------------
- sal_Bool SAL_CALL OSingleDocumentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
{
- m_pImpl->m_bSuspended = bSuspend;
- if ( !bSuspend && !isConnected() )
- reconnect(sal_True);
+ // add undo action
+ GetUndoManager().AddUndoAction( _pAction );
+ // when we add an undo action the controller was modified
+ setModified( sal_True );
- return sal_True;
+ // now inform me that or states changed
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
}
// -----------------------------------------------------------------------------
- sal_Bool SAL_CALL OSingleDocumentController::attachModel( const Reference< XModel > & _rxModel) throw( RuntimeException )
+ Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( ) throw (RuntimeException)
{
- if ( !_rxModel.is() )
- return sal_False;
- if ( !OSingleDocumentController_Base::attachModel( _rxModel ) )
- return sal_False;
-
- m_pImpl->m_bNotAttached = false;
- if ( m_pImpl->m_nDocStartNumber == 1 )
- releaseNumberForComponent();
-
- Reference< XUntitledNumbers > xUntitledProvider( _rxModel, UNO_QUERY );
- m_pImpl->m_nDocStartNumber = 1;
- if ( xUntitledProvider.is() )
- m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
-
- return sal_True;
+ return m_pData->m_pUndoManager.get();
}
// -----------------------------------------------------------------------------
FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
{
FeatureState aReturn;
- // (disabled automatically)
- aReturn.bEnabled = sal_True;
-
- switch (_nId)
+ switch ( _nId )
{
case ID_BROWSER_UNDO:
- aReturn.bEnabled = m_pImpl->m_bEditable && GetUndoManager().GetUndoActionCount() != 0;
+ aReturn.bEnabled = isEditable() && GetUndoManager().GetUndoActionCount() != 0;
if ( aReturn.bEnabled )
{
String sUndo(ModuleRes(STR_UNDO_COLON));
@@ -499,8 +154,9 @@ namespace dbaui
aReturn.sTitle = sUndo;
}
break;
+
case ID_BROWSER_REDO:
- aReturn.bEnabled = m_pImpl->m_bEditable && GetUndoManager().GetRedoActionCount() != 0;
+ aReturn.bEnabled = isEditable() && GetUndoManager().GetRedoActionCount() != 0;
if ( aReturn.bEnabled )
{
String sRedo(ModuleRes(STR_REDO_COLON));
@@ -509,255 +165,36 @@ namespace dbaui
aReturn.sTitle = sRedo;
}
break;
+
default:
aReturn = OSingleDocumentController_Base::GetState(_nId);
}
return aReturn;
}
// -----------------------------------------------------------------------------
- void OSingleDocumentController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs)
+ void OSingleDocumentController::Execute( sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs )
{
- switch(_nId)
+ switch ( _nId )
{
- case ID_BROWSER_CLOSE:
- closeTask();
- return;
case ID_BROWSER_UNDO:
GetUndoManager().Undo();
- InvalidateFeature(ID_BROWSER_REDO);
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
break;
+
case ID_BROWSER_REDO:
GetUndoManager().Redo();
- InvalidateFeature(ID_BROWSER_UNDO);
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
break;
+
default:
OSingleDocumentController_Base::Execute( _nId, _rArgs );
break;
}
InvalidateFeature(_nId);
}
- // -----------------------------------------------------------------------------
- SfxUndoManager& OSingleDocumentController::GetUndoManager() const
- {
- return m_pImpl->m_pUndoManager->GetSfxUndoManager();
- }
- // -----------------------------------------------------------------------------
- void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
- {
- // add undo action
- GetUndoManager().AddUndoAction(_pAction);
- // when we add an undo action the controller was modified
- setModified(sal_True);
- // now inform me that or states changed
- InvalidateFeature(ID_BROWSER_UNDO);
- InvalidateFeature(ID_BROWSER_REDO);
- }
-
- // -----------------------------------------------------------------------------
- ::rtl::OUString OSingleDocumentController::getDataSourceName() const
- {
- ::rtl::OUString sName;
- Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps() );
- if ( xDataSourceProps.is() )
- xDataSourceProps->getPropertyValue(PROPERTY_NAME) >>= sName;
- return sName;
- }
- // -----------------------------------------------------------------------------
- void OSingleDocumentController::connectionLostMessage() const
- {
- String aMessage(ModuleRes(RID_STR_CONNECTION_LOST));
- Reference< XWindow > xWindow = getTopMostContainerWindow();
- Window* pWin = NULL;
- if ( xWindow.is() )
- pWin = VCLUnoHelper::GetWindow(xWindow);
- if ( !pWin )
- pWin = getView()->Window::GetParent();
-
- InfoBox(pWin, aMessage).Execute();
- }
- // -----------------------------------------------------------------------------
- const Reference< XConnection >& OSingleDocumentController::getConnection() const
- {
- return m_pImpl->m_xConnection;
- }
-
- // -----------------------------------------------------------------------------
- sal_Bool OSingleDocumentController::isReadOnly() const
- {
- return !m_pImpl->m_bEditable;
- }
-
- // -----------------------------------------------------------------------------
- sal_Bool OSingleDocumentController::isEditable() const
- {
- return m_pImpl->m_bEditable;
- }
-
- // -----------------------------------------------------------------------------
- void OSingleDocumentController::setEditable(sal_Bool _bEditable)
- {
- m_pImpl->m_bEditable = _bEditable;
- }
-
- // -----------------------------------------------------------------------------
- const ::dbtools::DatabaseMetaData& OSingleDocumentController::getSdbMetaData() const
- {
- return m_pImpl->m_aSdbMetaData;
- }
-
- // -----------------------------------------------------------------------------
- sal_Bool OSingleDocumentController::isConnected() const
- {
- return m_pImpl->m_xConnection.is();
- }
-
- // -----------------------------------------------------------------------------
- Reference< XDatabaseMetaData > OSingleDocumentController::getMetaData( ) const
- {
- Reference< XDatabaseMetaData > xMeta;
- try
- {
- if ( isConnected() )
- xMeta.set( m_pImpl->m_xConnection->getMetaData(), UNO_SET_THROW );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return xMeta;
- }
-
- // -----------------------------------------------------------------------------
- const Reference< XPropertySet >& OSingleDocumentController::getDataSource() const
- {
- return m_pImpl->m_aDataSource.getDataSourceProps();
- }
-
- // -----------------------------------------------------------------------------
- sal_Bool OSingleDocumentController::haveDataSource() const
- {
- return m_pImpl->m_aDataSource.is();
- }
-
- // -----------------------------------------------------------------------------
- Reference< XModel > OSingleDocumentController::getDatabaseDocument() const
- {
- return Reference< XModel >( m_pImpl->m_aDataSource.getDatabaseDocument(), UNO_QUERY );
- }
-
- // -----------------------------------------------------------------------------
- Reference< XNumberFormatter > OSingleDocumentController::getNumberFormatter() const
- {
- return m_pImpl->m_xFormatter;
- }
-
- // -----------------------------------------------------------------------------
- Reference< XModel > OSingleDocumentController::getPrivateModel() const
- {
- return getDatabaseDocument();
- }
- // -----------------------------------------------------------------------------
- // XTitle
- ::rtl::OUString SAL_CALL OSingleDocumentController::getTitle()
- throw (RuntimeException)
- {
- ::osl::MutexGuard aGuard( getMutex() );
- if ( m_bExternalTitle )
- return impl_getTitleHelper_throw()->getTitle ();
-
- ::rtl::OUStringBuffer sTitle;
- Reference< XTitle > xTitle(getPrivateModel(),UNO_QUERY);
- if ( xTitle.is() )
- {
- sTitle.append( xTitle->getTitle() );
- sTitle.appendAscii(" : ");
- }
- sTitle.append( getPrivateTitle() );
- // There can be only one view with the same object
- //const sal_Int32 nCurrentView = getCurrentStartNumber();
- //if ( nCurrentView > 1 )
- //{
- // sTitle.appendAscii(" : ");
- // sTitle.append(nCurrentView);
- //}
-
- return sTitle.makeStringAndClear();
- }
-
- // -----------------------------------------------------------------------------
- Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( ) throw (RuntimeException)
- {
- return m_pImpl->m_pUndoManager.get();
- }
-
- // -----------------------------------------------------------------------------
- sal_Int32 OSingleDocumentController::getCurrentStartNumber() const
- {
- return m_pImpl->m_nDocStartNumber;
- }
-
- // -----------------------------------------------------------------------------
- Reference< XEmbeddedScripts > SAL_CALL OSingleDocumentController::getScriptContainer() throw (RuntimeException)
- {
- ::osl::MutexGuard aGuard( getMutex() );
- if ( !m_pImpl->documentHasScriptSupport() )
- return NULL;
-
- return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW );
- }
-
- // -----------------------------------------------------------------------------
- void SAL_CALL OSingleDocumentController::addModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
- {
- ::osl::MutexGuard aGuard( getMutex() );
- m_pImpl->m_aModifyListeners.addInterface( i_Listener );
- }
-
- // -----------------------------------------------------------------------------
- void SAL_CALL OSingleDocumentController::removeModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
- {
- ::osl::MutexGuard aGuard( getMutex() );
- m_pImpl->m_aModifyListeners.removeInterface( i_Listener );
- }
-
- // -----------------------------------------------------------------------------
- ::sal_Bool SAL_CALL OSingleDocumentController::isModified( ) throw (RuntimeException)
- {
- ::osl::MutexGuard aGuard( getMutex() );
- return impl_isModified();
- }
-
- // -----------------------------------------------------------------------------
- void SAL_CALL OSingleDocumentController::setModified( ::sal_Bool i_bModified ) throw (PropertyVetoException, RuntimeException)
- {
- ::osl::ClearableMutexGuard aGuard( getMutex() );
-
- if ( m_pImpl->m_bModified == i_bModified )
- return;
-
- m_pImpl->m_bModified = i_bModified;
- impl_onModifyChanged();
-
- EventObject aEvent( *this );
- aGuard.clear();
- m_pImpl->m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
- }
-
- // -----------------------------------------------------------------------------
- sal_Bool OSingleDocumentController::impl_isModified() const
- {
- return m_pImpl->m_bModified;
- }
-
- // -----------------------------------------------------------------------------
- void OSingleDocumentController::impl_onModifyChanged()
- {
- InvalidateFeature( ID_BROWSER_SAVEDOC );
- if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) )
- InvalidateFeature( ID_BROWSER_SAVEASDOC );
- }
-
-//........................................................................
-} // namespace dbaui
-//........................................................................
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index b8598f26f825..28238ea27e03 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -2177,7 +2177,7 @@ namespace
while ( false );
// Durch das Neuerzeugen wurden wieder Undo-Actions in den Manager gestellt
- rController.GetUndoManager().Clear();
+ rController.ClearUndoManager();
_pSelectionBrw->Invalidate();
return eErrorCode;
}
@@ -3234,7 +3234,7 @@ void OQueryDesignView::initByFieldDescriptions( const Sequence< PropertyValue >&
InsertField( pField, sal_True, sal_False );
}
- rController.GetUndoManager().Clear();
+ rController.ClearUndoManager();
m_pSelectionBox->Invalidate();
}
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
index d60621f7b414..5943485a7bb5 100644
--- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
+++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
@@ -299,7 +299,7 @@ bool OQueryViewSwitch::impl_postViewSwitch( const bool i_bGraphicalDesign, const
if ( pContainer )
pContainer->Resize();
- m_pDesignView->getController().GetUndoManager().Clear();
+ m_pDesignView->getController().ClearUndoManager();
m_pDesignView->getController().InvalidateAll();
return i_bSuccess;
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index c39191ac8cc9..2659580a91b4 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -1037,7 +1037,7 @@ void OQueryController::impl_initialize()
}
}
- GetUndoManager().Clear();
+ ClearUndoManager();
if ( ( m_bGraphicalDesign )
&& ( ( !m_sName.getLength() && !editingCommand() )
@@ -1789,7 +1789,7 @@ void OQueryController::reset()
{
impl_reset();
getContainer()->reset( NULL );
- GetUndoManager().Clear();
+ ClearUndoManager();
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx
index 642d22d1af8e..66dbc066324c 100644
--- a/dbaccess/source/ui/relationdesign/RelationController.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationController.cxx
@@ -494,7 +494,7 @@ IMPL_LINK( ORelationController, OnThreadFinished, void*, /*NOTINTERESTEDIN*/ )
{
getView()->initialize(); // show the windows and fill with our informations
getView()->Invalidate(INVALIDATE_NOERASE);
- GetUndoManager().Clear(); // clear all undo redo things
+ ClearUndoManager();
setModified(sal_False); // and we are not modified yet
if(m_vTableData.empty())
diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
index 505738ef5cf0..dfbc022d4f7d 100644
--- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
@@ -375,7 +375,7 @@ void ORelationTableView::RemoveTabWin( OTableWindow* pTabWin )
OSQLWarningBox aDlg( this, ModuleRes( STR_QUERY_REL_DELETE_WINDOW ), WB_YES_NO | WB_DEF_YES );
if ( m_bInRemove || aDlg.Execute() == RET_YES )
{
- m_pView->getController().GetUndoManager().Clear();
+ m_pView->getController().ClearUndoManager();
OJoinTableView::RemoveTabWin( pTabWin );
m_pView->getController().InvalidateFeature(SID_RELATION_ADD_RELATION);
@@ -383,30 +383,7 @@ void ORelationTableView::RemoveTabWin( OTableWindow* pTabWin )
m_pView->getController().InvalidateFeature(ID_BROWSER_REDO);
}
}
-// -----------------------------------------------------------------------------
-//namespace
-//{
-// class OReleationAskDialog : public ButtonDialog
-// {
-// FixedImage m_aInfoImage;
-// FixedText m_aTitle;
-// FixedText m_aMessage;
-// public:
-// OReleationDialog(Window* _pParent) : ButtonDialog(_pParent,WB_HORZ | WB_STDDIALOG)
-// ,m_aInfoImage(this)
-// ,m_aTitle(this,WB_WORDBREAK | WB_LEFT)
-// ,m_aMessage(this,WB_WORDBREAK | WB_LEFT)
-// {
-// m_aMessage.SetText(ModuleRes(STR_QUERY_REL_EDIT_RELATION));
-// m_aMessage.Show();
-//
-// // Changed as per BugID 79541 Branding/Configuration
-// String sDialogTitle( lcl_getProductName() );
-// SetText( sDialogTitle.AppendAscii( " Base" ) );
-// m_aTitle.Show();
-// }
-// };
-//}
+
// -----------------------------------------------------------------------------
void ORelationTableView::lookForUiActivities()
{
@@ -469,7 +446,7 @@ void ORelationTableView::_elementRemoved( const container::ContainerEvent& _rEve
OTableWindow* pTableWindow = GetTabWindow(sName);
if ( pTableWindow )
{
- m_pView->getController().GetUndoManager().Clear();
+ m_pView->getController().ClearUndoManager();
OJoinTableView::RemoveTabWin( pTableWindow );
m_pView->getController().InvalidateFeature(SID_RELATION_ADD_RELATION);
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 1cc02fb45d8b..fa8d1809b595 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -568,7 +568,7 @@ void OTableController::impl_initialize()
{
loadData(); // fill the column information form the table
getView()->initialize(); // show the windows and fill with our informations
- GetUndoManager().Clear(); // clear all undo redo things
+ ClearUndoManager();
setModified(sal_False); // and we are not modified yet
}
catch( const Exception& )
@@ -1516,7 +1516,7 @@ void OTableController::reSyncRows()
}
static_cast<OTableDesignView*>(getView())->reSync(); // show the windows and fill with our informations
- GetUndoManager().Clear(); // clear all undo redo things
+ ClearUndoManager();
setModified(sal_False); // and we are not modified yet
}
// -----------------------------------------------------------------------------
@@ -1572,7 +1572,7 @@ void OTableController::reload()
{
loadData(); // fill the column information form the table
static_cast<OTableDesignView*>(getView())->reSync(); // show the windows and fill with our informations
- GetUndoManager().Clear(); // clear all undo redo things
+ ClearUndoManager();
setModified(sal_False); // and we are not modified yet
static_cast<OTableDesignView*>(getView())->Invalidate();
}