diff options
author | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
commit | 84a2bad767682ba670a1bd4a8bf7e43dd21eb9b6 (patch) | |
tree | c54f93749b887848637a16ca08fa10f8c932a121 /reportdesign | |
parent | 2fffd98e29c9178c87e523454021c427e0aa4ed3 (diff) | |
parent | b98b964dc2735ca4c42a3905ef5eddcddba411c1 (diff) |
removetooltypes01: Rebase to DEV300m99
Diffstat (limited to 'reportdesign')
20 files changed, 423 insertions, 324 deletions
diff --git a/reportdesign/inc/ReportDefinition.hxx b/reportdesign/inc/ReportDefinition.hxx index d932110bc5f3..68a16e609b77 100644..100755 --- a/reportdesign/inc/ReportDefinition.hxx +++ b/reportdesign/inc/ReportDefinition.hxx @@ -29,25 +29,36 @@ #define REPORTDESIGN_API_REPORTDEFINITION_HXX #include "dllapi.h" -#include <com/sun/star/report/XReportDefinition.hpp> -#include <cppuhelper/compbase12.hxx> -#include <cppuhelper/basemutex.hxx> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <com/sun/star/lang/XTypeProvider.hpp> + +#include "ReportHelperDefines.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XUndoManagerSupplier.hpp> +#include <com/sun/star/frame/XModule.hpp> #include <com/sun/star/frame/XTitle.hpp> #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> #include <com/sun/star/frame/XUntitledNumbers.hpp> -#include <com/sun/star/frame/XModule.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/report/XReportDefinition.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <com/sun/star/datatransfer/XTransferable.hpp> -#include <cppuhelper/propertysetmixin.hxx> -#include <comphelper/uno3.hxx> +/** === end UNO includes === **/ + #include <comphelper/embeddedobjectcontainer.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propertysetmixin.hxx> #include <svx/unomod.hxx> -#include "ReportHelperDefines.hxx" +#if !defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 13 +#include <comphelper/implbase_var.hxx> +#endif + #include <boost/shared_ptr.hpp> @@ -62,32 +73,37 @@ namespace comphelper namespace reportdesign { class OReportComponentProperties; - typedef ::cppu::WeakComponentImplHelper12< com::sun::star::report::XReportDefinition - ,com::sun::star::document::XEventBroadcaster - ,com::sun::star::lang::XServiceInfo - ,com::sun::star::frame::XModule - ,com::sun::star::lang::XUnoTunnel - ,com::sun::star::util::XNumberFormatsSupplier - ,::com::sun::star::frame::XTitle - ,::com::sun::star::frame::XTitleChangeBroadcaster - ,::com::sun::star::frame::XUntitledNumbers - ,::com::sun::star::document::XDocumentPropertiesSupplier - ,::com::sun::star::datatransfer::XTransferable - ,SvxUnoDrawMSFactory> ReportDefinitionBase; - typedef ::cppu::PropertySetMixin<com::sun::star::report::XReportDefinition> ReportDefinitionPropertySet; + typedef ::comphelper::WeakComponentImplHelper13 < ::com::sun::star::report::XReportDefinition + , ::com::sun::star::document::XEventBroadcaster + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::frame::XModule + , ::com::sun::star::lang::XUnoTunnel + , ::com::sun::star::util::XNumberFormatsSupplier + , ::com::sun::star::frame::XTitle + , ::com::sun::star::frame::XTitleChangeBroadcaster + , ::com::sun::star::frame::XUntitledNumbers + , ::com::sun::star::document::XDocumentPropertiesSupplier + , ::com::sun::star::datatransfer::XTransferable + , ::com::sun::star::document::XUndoManagerSupplier + , SvxUnoDrawMSFactory + > ReportDefinitionBase; + + typedef ::cppu::PropertySetMixin< ::com::sun::star::report::XReportDefinition > ReportDefinitionPropertySet; struct OReportDefinitionImpl; /** \class OReportDefinition Defines the implementation of a \interface com:::sun::star::report::XReportDefinition * \ingroup reportdesign_api * */ - class REPORTDESIGN_DLLPUBLIC OReportDefinition : public ::cppu::BaseMutex, - public ReportDefinitionBase, - public ReportDefinitionPropertySet, - public ::comphelper::IEmbeddedHelper + class REPORTDESIGN_DLLPUBLIC OReportDefinition :public ::cppu::BaseMutex + ,public ReportDefinitionBase + ,public ReportDefinitionPropertySet + ,public ::comphelper::IEmbeddedHelper { + private: ::boost::shared_ptr<OReportComponentProperties> m_aProps; ::boost::shared_ptr<OReportDefinitionImpl> m_pImpl; + private: OReportDefinition(const OReportDefinition&); OReportDefinition& operator=(const OReportDefinition&); @@ -380,6 +396,9 @@ namespace reportdesign virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) 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); + // comphelper::IEmbeddedHelper virtual com::sun::star::uno::Reference < com::sun::star::embed::XStorage > getStorage() const; virtual ::comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const; diff --git a/reportdesign/inc/RptModel.hxx b/reportdesign/inc/RptModel.hxx index c4fcbdc2da34..a9f400d92c4b 100644 --- a/reportdesign/inc/RptModel.hxx +++ b/reportdesign/inc/RptModel.hxx @@ -35,7 +35,7 @@ class Window; namespace dbaui { - class OSingleDocumentController; + class DBSubComponentController; } namespace reportdesign { @@ -56,7 +56,7 @@ class REPORTDESIGN_DLLPUBLIC OReportModel : public SdrModel private: OXUndoEnvironment* m_pUndoEnv; - ::dbaui::OSingleDocumentController* m_pController; + ::dbaui::DBSubComponentController* m_pController; ::reportdesign::OReportDefinition* m_pReportDefinition; virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel(); @@ -79,8 +79,8 @@ public: OXUndoEnvironment& GetUndoEnv(); void SetModified(sal_Bool _bModified); - inline dbaui::OSingleDocumentController* getController() const { return m_pController; } - inline void attachController( dbaui::OSingleDocumentController& _rController ) { m_pController = &_rController; } + inline dbaui::DBSubComponentController* getController() const { return m_pController; } + inline void attachController( dbaui::DBSubComponentController& _rController ) { m_pController = &_rController; } void detachController(); OReportPage* createNewPage(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection); diff --git a/reportdesign/inc/UndoActions.hxx b/reportdesign/inc/UndoActions.hxx index b7b09292cfbe..2a7df2d6c9cb 100644 --- a/reportdesign/inc/UndoActions.hxx +++ b/reportdesign/inc/UndoActions.hxx @@ -28,8 +28,9 @@ #define RPTUI_UNDOACTIONS_HXX #include "dllapi.h" -#include <svx/svdundo.hxx> -#include <tools/string.hxx> + +#include "RptModel.hxx" + /** === begin UNO includes === **/ #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -43,13 +44,16 @@ #include <com/sun/star/report/XReportComponent.hpp> #include <com/sun/star/report/XReportDefinition.hpp> #include <com/sun/star/report/XGroup.hpp> +#include <com/sun/star/document/XUndoManager.hpp> /** === end UNO includes === **/ + #include <cppuhelper/implbase3.hxx> #include <comphelper/uno3.hxx> #include <comphelper/sequence.hxx> #include <svl/lstner.hxx> #include <svx/svdouno.hxx> -#include "RptModel.hxx" +#include <svx/svdundo.hxx> +#include <tools/string.hxx> #include <functional> #include <memory> @@ -119,23 +123,51 @@ namespace rptui static ::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> , OReportHelper> getMemberFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection); }; - class REPORTDESIGN_DLLPUBLIC UndoManagerListAction + //================================================================================================================== + //= UndoContext + //================================================================================================================== + class UndoContext { + public: + UndoContext( SfxUndoManager& i_undoManager, const ::rtl::OUString& i_undoTitle ) + :m_rUndoManager( i_undoManager ) + { + m_rUndoManager.EnterListAction( i_undoTitle, String() ); + } + + ~UndoContext() + { + m_rUndoManager.LeaveListAction(); + } + private: - SfxUndoManager& m_rManager; + SfxUndoManager& m_rUndoManager; + }; + //================================================================================================================== + //= UndoSuppressor + //================================================================================================================== + class UndoSuppressor + { public: - UndoManagerListAction( SfxUndoManager& _rManager, const String& _rListActionComment ) - :m_rManager( _rManager ) + UndoSuppressor( SfxUndoManager& i_undoManager ) + :m_rUndoManager( i_undoManager ) { - m_rManager.EnterListAction( _rListActionComment, String() ); + m_rUndoManager.EnableUndo( false ); } - ~UndoManagerListAction() + + ~UndoSuppressor() { - m_rManager.LeaveListAction(); + m_rUndoManager.EnableUndo( true ); } + + private: + SfxUndoManager& m_rUndoManager; }; + //================================================================================================================== + //= OCommentUndoAction + //================================================================================================================== class REPORTDESIGN_DLLPUBLIC OCommentUndoAction : public SdrUndoAction { protected: diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 2cf848dc0c84..6b8414ad60a3 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -24,18 +24,66 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "ReportDefinition.hxx" + +#include "FixedLine.hxx" +#include "FixedText.hxx" +#include "FormattedField.hxx" +#include "Functions.hxx" +#include "Groups.hxx" +#include "ImageControl.hxx" +#include "ReportComponent.hxx" +#include "ReportHelperImpl.hxx" +#include "RptDef.hxx" +#include "RptModel.hxx" +#include "Section.hxx" +#include "Shape.hxx" +#include "Tools.hxx" +#include "UndoEnv.hxx" +#include "core_resource.hrc" +#include "core_resource.hxx" +#include "corestrings.hrc" + +/** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp> +#include <com/sun/star/document/EventObject.hpp> +#include <com/sun/star/document/XEventListener.hpp> +#include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/EmbedMapUnits.hpp> +#include <com/sun/star/embed/EntryInitModes.hpp> +#include <com/sun/star/embed/XEmbedPersist.hpp> +#include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/report/GroupKeepTogether.hpp> #include <com/sun/star/report/ReportPrintOption.hpp> #include <com/sun/star/report/XFunction.hpp> #include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> +#include <com/sun/star/style/GraphicLocation.hpp> +#include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/style/PageStyleLayout.hpp> +#include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/table/BorderLine.hpp> #include <com/sun/star/table/ShadowFormat.hpp> -#include <com/sun/star/style/PageStyleLayout.hpp> -#include <com/sun/star/style/GraphicLocation.hpp> +#include <com/sun/star/task/ErrorCodeIOException.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/ui/XUIConfigurationStorage.hpp> #include <com/sun/star/xml/AttributeData.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +/** === end UNO includes === **/ + #include <comphelper/broadcasthelper.hxx> #include <comphelper/documentconstants.hxx> #include <comphelper/genericpropertyset.hxx> @@ -44,83 +92,41 @@ #include <comphelper/namecontainer.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/numberedcollection.hxx> -#include <comphelper/propertystatecontainer.hxx> #include <comphelper/proparrhlp.hxx> #include <comphelper/property.hxx> #include <comphelper/propertysetinfo.hxx> -#include <comphelper/sequence.hxx> +#include <comphelper/propertystatecontainer.hxx> #include <comphelper/seqstream.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/uno3.hxx> -#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp> -#include <vcl/svapp.hxx> -#include <vcl/virdev.hxx> -#include <vos/mutex.hxx> -#include <com/sun/star/beans/XMultiPropertyStates.hpp> -#include <com/sun/star/document/EventObject.hpp> -#include <com/sun/star/document/XEventListener.hpp> -#include <com/sun/star/style/XStyle.hpp> -#include <com/sun/star/embed/XTransactedObject.hpp> -#include <com/sun/star/embed/ElementModes.hpp> -#include <com/sun/star/embed/EmbedMapUnits.hpp> -#include <com/sun/star/embed/EntryInitModes.hpp> -#include <com/sun/star/embed/Aspects.hpp> -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/embed/ElementModes.hpp> -#include <com/sun/star/io/XSeekable.hpp> -#include <com/sun/star/embed/XEmbedPersist.hpp> -#include <com/sun/star/task/XStatusIndicator.hpp> -#include <com/sun/star/task/XStatusIndicatorFactory.hpp> -#include <com/sun/star/ui/XUIConfigurationStorage.hpp> -#include <com/sun/star/document/XExporter.hpp> -#include <com/sun/star/document/XImporter.hpp> -#include <com/sun/star/document/XFilter.hpp> -#include <com/sun/star/task/ErrorCodeIOException.hpp> -#include <com/sun/star/xml/sax/XDocumentHandler.hpp> -#include <com/sun/star/frame/XComponentLoader.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include "corestrings.hrc" -#include "Groups.hxx" -#include "RptDef.hxx" -#include "Section.hxx" -#include "FixedLine.hxx" -#include "core_resource.hrc" -#include "core_resource.hxx" -#include "Tools.hxx" -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <unotools/streamwrap.hxx> #include <connectivity/CommonTools.hxx> #include <connectivity/dbconversion.hxx> -#include <framework/titlehelper.hxx> #include <connectivity/dbtools.hxx> -#include <com/sun/star/task/XStatusIndicator.hpp> -#include "Functions.hxx" -#include <boost/mem_fn.hpp> -#include <boost/bind.hpp> -#include <boost/utility.hpp> -#include <unotools/saveopt.hxx> -#include "RptModel.hxx" -#include "UndoEnv.hxx" -#include "FormattedField.hxx" -#include "FixedText.hxx" -#include "ImageControl.hxx" -#include "Shape.hxx" -#include "ReportHelperImpl.hxx" -#include <svl/itempool.hxx> -#include <unotools/moduleoptions.hxx> -#include <osl/thread.hxx> - +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <dbaccess/dbaundomanager.hxx> #include <editeng/paperinf.hxx> +#include <framework/titlehelper.hxx> +#include <osl/thread.hxx> +#include <svl/itempool.hxx> +#include <svl/undo.hxx> #include <svx/svdlayer.hxx> +#include <svx/unofill.hxx> #include <svx/xmleohlp.hxx> #include <svx/xmlgrhlp.hxx> -#include <svx/unofill.hxx> -#include <cppuhelper/interfacecontainer.h> -#include <cppuhelper/exc_hlp.hxx> -#include "ReportComponent.hxx" -#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> -#include <com/sun/star/style/NumberingType.hpp> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/moduleoptions.hxx> +#include <unotools/saveopt.hxx> +#include <unotools/streamwrap.hxx> +#include <vcl/svapp.hxx> +#include <vcl/virdev.hxx> +#include <vos/mutex.hxx> + +#include <boost/bind.hpp> +#include <boost/mem_fn.hpp> +#include <boost/utility.hpp> #define MAP_LEN(x) x, sizeof(x) - 1 #define MAP_CHAR_LEN(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) @@ -607,6 +613,7 @@ struct OReportDefinitionImpl ::boost::shared_ptr< ::comphelper::EmbeddedObjectContainer> m_pObjectContainer; ::boost::shared_ptr<rptui::OReportModel> m_pReportModel; + ::rtl::Reference< ::dbaui::UndoManager > m_pUndoManager; ::rtl::OUString m_sCaption; ::rtl::OUString m_sCommand; ::rtl::OUString m_sFilter; @@ -623,6 +630,7 @@ struct OReportDefinitionImpl sal_Bool m_bModified; sal_Bool m_bEscapeProcessing; sal_Bool m_bSetModifiedEnabled; + OReportDefinitionImpl(::osl::Mutex& _aMutex) :m_aStorageChangeListeners(_aMutex) ,m_aCloseListener(_aMutex) @@ -746,7 +754,6 @@ OReportDefinition::~OReportDefinition() } // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition, ReportDefinitionBase ) -//IMPLEMENT_FORWARD_XINTERFACE2(OReportDefinition,ReportDefinitionBase,ReportDefinitionPropertySet) void OReportDefinition::init() { try @@ -764,7 +771,7 @@ void OReportDefinition::init() pCreatorThread->createSuspended(); pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal); pCreatorThread->resume(); - } // for ( ; pIter != pEnd; ++pIter ) + } } m_pImpl->m_pReportModel.reset(new OReportModel(this)); @@ -775,6 +782,9 @@ void OReportDefinition::init() rAdmin.NewLayer(UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "back" ) ), RPT_LAYER_BACK ); rAdmin.NewLayer( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "HiddenLayer" ) ), RPT_LAYER_HIDDEN ); + m_pImpl->m_pUndoManager = new ::dbaui::UndoManager( *this, m_aMutex ); + m_pImpl->m_pReportModel->SetSdrUndoManager( &m_pImpl->m_pUndoManager->GetSfxUndoManager() ); + m_pImpl->m_xFunctions = new OFunctions(this,m_aProps->m_xContext); if ( !m_pImpl->m_xStorage.is() ) m_pImpl->m_xStorage = ::comphelper::OStorageHelper::GetTemporaryStorage(); @@ -789,9 +799,9 @@ void OReportDefinition::init() } m_pImpl->m_pObjectContainer.reset( new comphelper::EmbeddedObjectContainer(m_pImpl->m_xStorage , static_cast<cppu::OWeakObject*>(this) ) ); } - catch(uno::Exception) + catch ( const uno::Exception& ) { - OSL_ENSURE(0,"Error!"); + DBG_UNHANDLED_EXCEPTION(); } } // ----------------------------------------------------------------------------- @@ -1296,10 +1306,21 @@ void SAL_CALL OReportDefinition::close( ::sal_Bool _bDeliverOwnership ) throw (u ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed ); ::comphelper::MediaDescriptor aDescriptor( _aArguments ); - fillArgs(aDescriptor); - m_pImpl->m_pReportModel->SetModified(sal_False); + + m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( false ); + try + { + fillArgs(aDescriptor); + m_pImpl->m_pReportModel->SetModified(sal_False); + } + catch ( ... ) + { + m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( true ); + throw; + } + m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( true ); return sal_True; } // ----------------------------------------------------------------------------- @@ -1842,7 +1863,6 @@ void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue else if ( sURL.getLength() ) aStorageSource <<= sURL; else - // TODO: error message throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No input source (URL or InputStream) found." ) ), // TODO: resource @@ -2931,8 +2951,15 @@ uno::Sequence< datatransfer::DataFlavor > SAL_CALL OReportDefinition::getTransfe { return aFlavor.MimeType.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/png"))); } + // ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- +uno::Reference< document::XUndoManager > SAL_CALL OReportDefinition::getUndoManager( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return m_pImpl->m_pUndoManager.get(); +} + + // ============================================================================= }// namespace reportdesign // ============================================================================= diff --git a/reportdesign/source/core/sdr/RptModel.cxx b/reportdesign/source/core/sdr/RptModel.cxx index 816873cbc6c5..8e4ebad7712a 100644 --- a/reportdesign/source/core/sdr/RptModel.cxx +++ b/reportdesign/source/core/sdr/RptModel.cxx @@ -28,7 +28,7 @@ #include "RptModel.hxx" #include "RptPage.hxx" -#include <dbaccess/singledoccontroller.hxx> +#include <dbaccess/dbsubcomponentcontroller.hxx> #include <tools/debug.hxx> #include <unotools/pathoptions.hxx> diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index 7d73977b03bb..bfe079ff7d31 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -37,7 +37,7 @@ #include <toolkit/helper/convert.hxx> #include "RptPage.hxx" #include "corestrings.hrc" -#include <dbaccess/singledoccontroller.hxx> +#include <dbaccess/dbsubcomponentcontroller.hxx> #include "ModuleHelper.hxx" #include <RptResId.hrc> diff --git a/reportdesign/source/core/sdr/UndoActions.cxx b/reportdesign/source/core/sdr/UndoActions.cxx index 3b8ba713e888..24ce8a9e1710 100644 --- a/reportdesign/source/core/sdr/UndoActions.cxx +++ b/reportdesign/source/core/sdr/UndoActions.cxx @@ -52,7 +52,7 @@ #include <tools/diagnose_ex.h> #include <comphelper/stl_types.hxx> #include <vcl/svapp.hxx> -#include <dbaccess/singledoccontroller.hxx> +#include <dbaccess/dbsubcomponentcontroller.hxx> #include <svx/unoshape.hxx> #include <vos/mutex.hxx> diff --git a/reportdesign/source/core/sdr/UndoEnv.cxx b/reportdesign/source/core/sdr/UndoEnv.cxx index aa9f6523e357..8db61ffe5583 100644 --- a/reportdesign/source/core/sdr/UndoEnv.cxx +++ b/reportdesign/source/core/sdr/UndoEnv.cxx @@ -54,7 +54,7 @@ #include <comphelper/stl_types.hxx> #include <comphelper/componentcontext.hxx> #include <vcl/svapp.hxx> -#include <dbaccess/singledoccontroller.hxx> +#include <dbaccess/dbsubcomponentcontroller.hxx> #include <svx/unoshape.hxx> #include <vos/mutex.hxx> @@ -262,7 +262,7 @@ void SAL_CALL OXUndoEnvironment::propertyChange( const PropertyChangeEvent& _rEv if (!xSet.is()) return; - dbaui::OSingleDocumentController* pController = m_pImpl->m_rModel.getController(); + dbaui::DBSubComponentController* pController = m_pImpl->m_rModel.getController(); if ( !pController ) return; @@ -380,7 +380,7 @@ void SAL_CALL OXUndoEnvironment::propertyChange( const PropertyChangeEvent& _rEv if ( pUndo == NULL ) pUndo = new ORptUndoPropertyAction( m_pImpl->m_rModel, _rEvent ); - pController->addUndoActionAndInvalidate(pUndo); + m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( pUndo ); pController->InvalidateAll(); } // ----------------------------------------------------------------------------- @@ -439,12 +439,9 @@ void SAL_CALL OXUndoEnvironment::elementInserted(const ContainerEvent& evt) thro uno::Reference< report::XFunctions> xContainer(evt.Source,uno::UNO_QUERY); if ( xContainer.is() ) { - dbaui::OSingleDocumentController* pController = m_pImpl->m_rModel.getController(); - pController->addUndoActionAndInvalidate(new OUndoContainerAction(m_pImpl->m_rModel - ,rptui::Inserted - ,xContainer.get() - ,xIface - ,RID_STR_UNDO_ADDFUNCTION)); + m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( + new OUndoContainerAction( m_pImpl->m_rModel, rptui::Inserted, xContainer.get(), + xIface, RID_STR_UNDO_ADDFUNCTION ) ); } } } @@ -510,12 +507,8 @@ void SAL_CALL OXUndoEnvironment::elementRemoved(const ContainerEvent& evt) throw uno::Reference< report::XFunctions> xFunctions(evt.Source,uno::UNO_QUERY); if ( xFunctions.is() ) { - dbaui::OSingleDocumentController* pController = m_pImpl->m_rModel.getController(); - pController->addUndoActionAndInvalidate(new OUndoContainerAction(m_pImpl->m_rModel - ,rptui::Removed - ,xFunctions.get() - ,xIface - ,RID_STR_UNDO_ADDFUNCTION)); + m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( new OUndoContainerAction( + m_pImpl->m_rModel, rptui::Removed, xFunctions.get(), xIface, RID_STR_UNDO_ADDFUNCTION ) ); } } } diff --git a/reportdesign/source/core/sdr/formatnormalizer.cxx b/reportdesign/source/core/sdr/formatnormalizer.cxx index e4817bbe9f44..f5fba8129d54 100644 --- a/reportdesign/source/core/sdr/formatnormalizer.cxx +++ b/reportdesign/source/core/sdr/formatnormalizer.cxx @@ -35,7 +35,7 @@ #include <com/sun/star/util/XNumberFormatTypes.hpp> /** === end UNO includes === **/ -#include <dbaccess/singledoccontroller.hxx> +#include <dbaccess/dbsubcomponentcontroller.hxx> #include <unotools/syslocale.hxx> #include <connectivity/statementcomposer.hxx> #include <connectivity/dbtools.hxx> @@ -186,7 +186,7 @@ namespace rptui if ( !m_xReportDefinition.is() ) return false; - ::dbaui::OSingleDocumentController* pController( m_rModel.getController() ); + ::dbaui::DBSubComponentController* pController( m_rModel.getController() ); OSL_ENSURE( pController, "FormatNormalizer::impl_ensureUpToDateFieldList_nothrow: no controller? how can *this* happen?!" ); if ( !pController ) return false; diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index b4f9fc54b410..1e428b081c0d 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -465,8 +465,8 @@ namespace rptui short nRet = ModalDialog::Execute(); if ( nRet == RET_OK ) { - String sUndoAction( ModuleRes( RID_STR_UNDO_CONDITIONAL_FORMATTING ) ); - UndoManagerListAction aListAction(*m_rController.getUndoMgr(),sUndoAction); + const String sUndoAction( ModuleRes( RID_STR_UNDO_CONDITIONAL_FORMATTING ) ); + const UndoContext aUndoContext( m_rController.getUndoManager(), sUndoAction ); try { sal_Int32 j(0), i(0);; diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index 3d9de51c227b..2a93c374ca15 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -316,8 +316,8 @@ void OFieldExpressionControl::moveGroups(const uno::Sequence<uno::Any>& _aGroups m_bIgnoreEvent = true; { sal_Int32 nRow = _nRow; - String sUndoAction(ModuleRes(RID_STR_UNDO_MOVE_GROUP)); - UndoManagerListAction aListAction(*m_pParent->m_pController->getUndoMgr(),sUndoAction); + const String sUndoAction(ModuleRes(RID_STR_UNDO_MOVE_GROUP)); + const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction ); uno::Reference< report::XGroups> xGroups = m_pParent->getGroups(); const uno::Any* pIter = _aGroups.getConstArray(); @@ -455,7 +455,7 @@ sal_Bool OFieldExpressionControl::SaveModified(bool _bAppendRow) { bAppend = sal_True; String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP)); - m_pParent->m_pController->getUndoMgr()->EnterListAction( sUndoAction, String() ); + m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, String() ); xGroup = m_pParent->getGroups()->createGroup(); xGroup->setHeaderOn(sal_True); @@ -499,7 +499,7 @@ sal_Bool OFieldExpressionControl::SaveModified(bool _bAppendRow) ::rptui::adjustSectionName(xGroup,nPos); if ( bAppend ) - m_pParent->m_pController->getUndoMgr()->LeaveListAction(); + m_pParent->m_pController->getUndoManager().LeaveListAction(); } if ( Controller() ) @@ -824,7 +824,7 @@ void OFieldExpressionControl::DeleteRows() { bFirstTime = false; String sUndoAction(ModuleRes(RID_STR_UNDO_REMOVE_SELECTION)); - m_pParent->m_pController->getUndoMgr()->EnterListAction( sUndoAction, String() ); + m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, String() ); } sal_Int32 nGroupPos = m_aGroupPositions[nIndex]; @@ -844,7 +844,7 @@ void OFieldExpressionControl::DeleteRows() } // while( nIndex >= 0 ) if ( !bFirstTime ) - m_pParent->m_pController->getUndoMgr()->LeaveListAction(); + m_pParent->m_pController->getUndoManager().LeaveListAction(); m_nDataPos = GetCurRow(); InvalidateStatusCell( nOldDataPos ); @@ -930,8 +930,8 @@ void OFieldExpressionControl::InsertRows( long nRow ) { m_bIgnoreEvent = false; { - String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP)); - UndoManagerListAction aListAction(*m_pParent->m_pController->getUndoMgr(),sUndoAction); + const String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP)); + const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction ); uno::Reference<report::XGroups> xGroups = m_pParent->getGroups(); sal_Int32 nGroupPos = 0; diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx index aad664d4bb22..215e5145889f 100644 --- a/reportdesign/source/ui/dlg/Navigator.cxx +++ b/reportdesign/source/ui/dlg/Navigator.cxx @@ -31,7 +31,7 @@ #include "uistrings.hrc" #include "ReportController.hxx" #include "UITools.hxx" -#include "Undo.hxx" +#include "RptUndo.hxx" #include "reportformula.hxx" #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/report/XReportDefinition.hpp> diff --git a/reportdesign/source/ui/inc/ReportController.hxx b/reportdesign/source/ui/inc/ReportController.hxx index 2eba90b13192..b25f49770f5b 100644 --- a/reportdesign/source/ui/inc/ReportController.hxx +++ b/reportdesign/source/ui/inc/ReportController.hxx @@ -27,48 +27,52 @@ #ifndef RPTUI_REPORTCONTROLLER_HXX #define RPTUI_REPORTCONTROLLER_HXX -#include <dbaccess/singledoccontroller.hxx> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/sdbc/XConnection.hpp> -#include <com/sun/star/sdbc/XRowSet.hpp> +#include "DesignView.hxx" +#include "ModuleHelper.hxx" +#include "ReportControllerObserver.hxx" +#include "RptDef.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/util/XNumberFormatter.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/embed/XVisualObject.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/report/XReportDefinition.hpp> +#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/io/XObjectOutputStream.hpp> #include <com/sun/star/report/XReportControlModel.hpp> +#include <com/sun/star/report/XReportDefinition.hpp> #include <com/sun/star/report/XReportEngine.hpp> #include <com/sun/star/report/XSection.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/XModeSelector.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/embed/XVisualObject.hpp> -#include <cppuhelper/implbase5.hxx> -#include <svtools/transfer.hxx> -#include <svl/lstner.hxx> -#include <svx/svdedtv.hxx> -#include <svx/zoomitem.hxx> -#include "ModuleHelper.hxx" +/** === end UNO includes === **/ -#include <comphelper/uno3.hxx> #include <comphelper/implementationreference.hxx> #include <comphelper/proparrhlp.hxx> #include <comphelper/propertystatecontainer.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase5.hxx> +#include <dbaccess/dbsubcomponentcontroller.hxx> +#include <svl/lstner.hxx> +#include <svtools/transfer.hxx> +#include <svx/svdedtv.hxx> +#include <svx/zoomitem.hxx> -#include "RptDef.hxx" -#include "DesignView.hxx" -#include <functional> +#include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> -#include <com/sun/star/util/XModeSelector.hpp> -#include "ReportControllerObserver.hxx" +#include <functional> class TransferableHelper; class TransferableClipboardListener; class VclWindowEvent; +class SfxUndoManager; namespace rptui { class OGroupsSortingDialog; @@ -78,7 +82,7 @@ namespace rptui class OAddFieldWindow; class OSectionWindow; - typedef ::dbaui::OSingleDocumentController OReportController_BASE; + typedef ::dbaui::DBSubComponentController OReportController_BASE; typedef ::cppu::ImplHelper5 < ::com::sun::star::container::XContainerListener , ::com::sun::star::beans::XPropertyChangeListener , ::com::sun::star::view::XSelectionSupplier @@ -91,6 +95,7 @@ namespace rptui ,public SfxListener ,public ::comphelper::OPropertyStateContainer ,public ::comphelper::OPropertyArrayUsageHelper < OReportController_BASE > + ,public ::boost::noncopyable { private: OModuleClient m_aModuleClient; @@ -107,9 +112,9 @@ namespace rptui ODesignView* getDesignView() const { return static_cast< ODesignView* >( getView() ); } - ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition> m_xReportDefinition; - ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportEngine> m_xReportEngine; - ::com::sun::star::uno::Reference < ::com::sun::star::frame::XComponentLoader> m_xFrameLoader; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReportDefinition; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportEngine > m_xReportEngine; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XComponentLoader > m_xFrameLoader; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > m_xRowSetMediator; @@ -215,15 +220,20 @@ namespace rptui void executeMethodWithUndo(sal_uInt16 _nUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun); void alignControlsWithUndo(sal_uInt16 _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection = false); + + // open the help agent of report designer at start time + void doOpenHelpAgent(); + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getXFrame(); + /** shrink a section @param _nUndoStrId the string id of the string which is shown in undo menu @param _nShrinkId ID of what you would like to shrink. */ - protected: void shrinkSectionBottom(::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > _xSection); void shrinkSectionTop(::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > _xSection); - public: + public: void shrinkSection(sal_uInt16 _nUndoStrId, ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > _xSection, sal_Int32 _nShrinkId); /** opens the file open dialog to allow the user to select a image which will be @@ -292,14 +302,11 @@ namespace rptui */ void impl_zoom_nothrow(); - private: - OReportController(OReportController const&); - OReportController& operator =(OReportController const&); - public: - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getXFrame(); + virtual void impl_onModifyChanged(); - // open the help agent of report designer at start time - void doOpenHelpAgent(); + virtual void onLoadedMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager ); + virtual void impl_initialize( ); + bool isUiVisible() const; /** creates a new default control for the currently set type when the modifier KEY_MOD1 was pressed * \param _aArgs must contain a properyvalue with name "KeyModifier" and value KEY_MOD1 when control should be created. @@ -333,16 +340,15 @@ namespace rptui // execute a feature virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); - virtual void losingConnection( ); - virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const; virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); + private: virtual ~OReportController(); + public: OReportController(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & the_context); - DECL_LINK( NotifyUndoActionHdl, SfxUndoAction* ); DECL_LINK( EventLstHdl, VclWindowEvent* ); DECL_LINK( OnCreateHdl, OAddFieldWindow*); @@ -352,12 +358,6 @@ namespace rptui // SfxListener virtual void Notify(SfxBroadcaster & rBc, SfxHint const & rHint); - virtual void impl_onModifyChanged(); - - // const ::connectivity::OSQLParseNode* getParseTree() const { return m_aSqlIterator.getParseTree();} - // need for undo's and redo's - SfxUndoManager* getUndoMgr(); - /** returns <TRUE/> when the command is enbaled @param _nCommand the command id @param _xControlFormat the report control format @@ -455,7 +455,7 @@ namespace rptui * * \return */ - ::boost::shared_ptr<rptui::OReportModel> getSdrModel(); + ::boost::shared_ptr<rptui::OReportModel> getSdrModel() const; inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } inline sal_Int16 getZoomValue() const { return m_nZoomValue; } @@ -477,10 +477,9 @@ namespace rptui ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getColumns() const; ::rtl::OUString getColumnLabel_throw(const ::rtl::OUString& i_sColumnName) const; - private: - virtual void onLoadedMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager ); - virtual void impl_initialize( ); - bool isUiVisible() const; + SfxUndoManager& getUndoManager() const; + void clearUndoManager() const; + void addUndoAction( SfxUndoAction* i_pAction ); }; } #endif // RPTUI_REPORTCONTROLLER_HXX diff --git a/reportdesign/source/ui/inc/Undo.hxx b/reportdesign/source/ui/inc/RptUndo.hxx index bd3b9606a8e3..bd3b9606a8e3 100644 --- a/reportdesign/source/ui/inc/Undo.hxx +++ b/reportdesign/source/ui/inc/RptUndo.hxx diff --git a/reportdesign/source/ui/misc/Undo.cxx b/reportdesign/source/ui/misc/RptUndo.cxx index a29613ae4426..4244987b717a 100644 --- a/reportdesign/source/ui/misc/Undo.cxx +++ b/reportdesign/source/ui/misc/RptUndo.cxx @@ -26,21 +26,16 @@ ************************************************************************/ #include "precompiled_reportdesign.hxx" -#include "Undo.hxx" -#ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC +#include "RptUndo.hxx" #include "uistrings.hrc" -#endif -#ifndef _RPTUI_SLOTID_HRC_ #include "rptui_slotid.hrc" -#endif -#ifndef RPTUI_TOOLS_HXX #include "UITools.hxx" -#endif +#include "UndoEnv.hxx" + #include <dbaccess/IController.hxx> #include <com/sun/star/report/XSection.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include "UndoEnv.hxx" #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> #include <svx/unoshape.hxx> diff --git a/reportdesign/source/ui/misc/makefile.mk b/reportdesign/source/ui/misc/makefile.mk index b12bafdc7760..494b68023d62 100644 --- a/reportdesign/source/ui/misc/makefile.mk +++ b/reportdesign/source/ui/misc/makefile.mk @@ -44,7 +44,7 @@ VISIBILITY_HIDDEN=TRUE # ... object files ............................ EXCEPTIONSFILES= \ - $(SLO)$/Undo.obj \ + $(SLO)$/RptUndo.obj \ $(SLO)$/ColorListener.obj \ $(SLO)$/UITools.obj \ $(SLO)$/rptuiservices.obj \ diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index d74a5d943d5a..1e0557a4edcc 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -248,7 +248,12 @@ long ODesignView::PreNotify( NotifyEvent& rNEvt ) switch(rNEvt.GetType()) { case EVENT_KEYINPUT: - //if ( nRet != 1L ) + if ( (m_pPropWin && m_pPropWin->HasChildPathFocus()) ) + return 0L; + if ( (m_pAddField && m_pAddField->HasChildPathFocus()) ) + return 0L; + if ( (m_pReportExplorer && m_pReportExplorer->HasChildPathFocus()) ) + return 0L; { const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); if ( handleKeyEvent(*pKeyEvent) ) diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index b67b12213e0d..5967bbb199f8 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -99,6 +99,7 @@ #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdbc/SQLWarning.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/document/XUndoManagerSupplier.hpp> #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> @@ -117,7 +118,7 @@ #include <svx/zoomitem.hxx> #include <svx/zoomslideritem.hxx> #include <editeng/brshitem.hxx> -#include <svx/flagsdef.hxx> //CHINA001 +#include <svx/flagsdef.hxx> #include <svx/svdpagv.hxx> #include <svx/svxdlg.hxx> #include <svx/zoom_def.hxx> @@ -126,7 +127,7 @@ #include "DesignView.hxx" #include "ModuleHelper.hxx" #include "RptObject.hxx" -#include "Undo.hxx" +#include "RptUndo.hxx" #include "uistrings.hrc" #include "RptDef.hxx" #include "ReportSection.hxx" @@ -137,7 +138,7 @@ #include <svl/itempool.hxx> #include <svl/itemset.hxx> -#include <svl/aeitem.hxx> //CHINA001 +#include <svl/aeitem.hxx> #include <svtools/cliplistener.hxx> #include <unotools/syslocale.hxx> #include <unotools/viewoptions.hxx> @@ -152,10 +153,12 @@ #include <toolkit/helper/vclunohelper.hxx> #include "UndoEnv.hxx" #include "InsertFunctions.hxx" +#include "ReportControllerObserver.hxx" #include <boost/mem_fn.hpp> #include <boost/bind.hpp> #include <boost/utility.hpp> +#include <boost/scoped_ptr.hpp> #include <cppuhelper/exc_hlp.hxx> #include <unotools/confignode.hxx> @@ -163,7 +166,7 @@ #include <ReportControllerObserver.hxx> -#define MAX_ROWS_FOR_PREVIEW 50 +#define MAX_ROWS_FOR_PREVIEW 20 using namespace ::com::sun::star; using namespace uno; @@ -245,14 +248,16 @@ void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs, SequenceAsHashMap aMap(aArgs); xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>()); _xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>()); - } // if ( aArgs.getLength() ) + } + if ( !xReportControlFormat.is() ) { _pView->fillControlModelSelection(_rControlsFormats); - //xReportControlFormat.set( _pView->getCurrentControlModel(),uno::UNO_QUERY); - } // if ( !xReportControlFormat.is() ) + } else + { _rControlsFormats.push_back(xReportControlFormat); + } if ( !_xWindow.is() ) _xWindow = VCLUnoHelper::GetInterface(_pView); @@ -372,14 +377,15 @@ void OReportController::disposing() pSectionWindow = getDesignView()->getMarkedSection(); if ( pSectionWindow ) pSectionWindow->getReportSection().deactivateOle(); - getUndoMgr()->Clear(); // clear all undo redo things + clearUndoManager(); if ( m_aReportModel ) listen(false); m_pReportControllerObserver->Clear(); m_pReportControllerObserver->release(); } - catch(uno::Exception&) + catch ( const uno::Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } @@ -391,7 +397,6 @@ void OReportController::disposing() OReportController_BASE::disposing(); - // disconnect(); try { m_xReportDefinition.clear(); @@ -457,8 +462,20 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const break; case SID_REDO: case SID_UNDO: - aReturn = OReportController_BASE::GetState(_nId); - aReturn.bEnabled = aReturn.bEnabled; + { + size_t ( SfxUndoManager::*retrieveCount )( bool const ) const = + ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionCount : &SfxUndoManager::GetRedoActionCount; + + SfxUndoManager& rUndoManager( getUndoManager() ); + aReturn.bEnabled = ( rUndoManager.*retrieveCount )( ::svl::IUndoManager::TopLevel ) > 0; + if ( aReturn.bEnabled ) + { + // TODO: add "Undo/Redo: prefix" + String ( SfxUndoManager::*retrieveComment )( size_t, bool const ) const = + ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionComment : &SfxUndoManager::GetRedoActionComment; + aReturn.sTitle = (rUndoManager.*retrieveComment)( 0, ::svl::IUndoManager::TopLevel ); + } + } break; case SID_OBJECT_RESIZING: case SID_OBJECT_SMALLESTWIDTH: @@ -563,7 +580,7 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const case SID_EXPAND_SECTION: case SID_NEXT_MARK: case SID_PREV_MARK: - aReturn.bEnabled = isEditable(); + aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent(_nId); break; case SID_SELECT: case SID_SELECT_REPORT: @@ -1024,10 +1041,12 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > case SID_REDO: case SID_UNDO: { - // const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); - // We would like to know if we are in undo mode const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() ); - OReportController_BASE::Execute( _nId, aArgs ); + BOOL ( SfxUndoManager::*doXDo )() = + ( _nId == SID_UNDO ) ? &SfxUndoManager::Undo : &SfxUndoManager::Redo; + + SfxUndoManager& rUndoManager( getUndoManager() ); + (rUndoManager.*doXDo)(); InvalidateAll(); updateFloater(); } @@ -1165,7 +1184,7 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW); sal_Int32 nIndex = getPositionInIndexAccess(xFunctions.get(),xFunction); const String sUndoAction = String((ModuleRes(RID_STR_UNDO_REMOVE_FUNCTION))); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); xFunctions->removeByIndex(nIndex); select(uno::makeAny(xFunctions->getParent())); InvalidateFeature( SID_SAVEDOC ); @@ -1192,14 +1211,6 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > InvalidateAll(); break; case SID_INSERT_DIAGRAM: - /*{ - OSectionView* pView = getCurrentSectionView(); - if ( pView ) - { - Reference< awt::XWindow> xWindow = VCLUnoHelper::GetInterface(getView()->Window::GetParent()); - InsertChart(m_xContext,m_xReportDefinition.get(),xWindow,pView,getSdrModel().get()); - } - }*/ getDesignView()->SetMode( RPTUI_INSERT ); getDesignView()->SetInsertObj( OBJ_OLE2); createDefaultControl(aArgs); @@ -1452,19 +1463,16 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > case SID_ATTR_CHAR_POSTURE: case SID_ATTR_CHAR_UNDERLINE: { - ::std::auto_ptr<UndoManagerListAction> pListAction; uno::Reference< awt::XWindow> xWindow; ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats; lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats ); - bool bMulti = aControlsFormats.size() > 1; + + const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT)); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin(); for(; aIter != aControlsFormats.end();++aIter) { - if ( !pListAction.get() && bMulti) - { - const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT)); - pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction)); - } // if ( !pListAction.get() ) uno::Reference< report::XReportControlFormat> xReportControlFormat(*aIter,uno::UNO_QUERY); lcl_setFontWPU_nothrow(xReportControlFormat,_nId); } @@ -1528,32 +1536,37 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > break; case SID_CHAR_DLG: { - ::std::auto_ptr<UndoManagerListAction> pListAction; uno::Sequence< beans::NamedValue > aSettings; uno::Reference< awt::XWindow> xWindow; ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats; lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats ); - ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin(); - for(; aIter != aControlsFormats.end();++aIter) + + if ( !aControlsFormats.empty() ) { - uno::Reference< report::XReportControlFormat > xFormat(*aIter,uno::UNO_QUERY); - if ( xFormat.is() ) + const String sUndoAction( ModuleRes( RID_STR_UNDO_CHANGEFONT ) ); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); + + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin(); + for(; aIter != aControlsFormats.end();++aIter) { - if ( !pListAction.get() ) + uno::Reference< report::XReportControlFormat > xFormat( *aIter, uno::UNO_QUERY ); + if ( !xFormat.is() ) + continue; + + if ( aSettings.getLength() == 0 ) { - const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT)); - pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction)); - rptui::openCharDialog(xFormat,xWindow,aSettings); - } // if ( !pListAction.get() ) + ::rptui::openCharDialog( xFormat, xWindow, aSettings ); + if ( aSettings.getLength() == 0 ) + break; + } + applyCharacterSettings( xFormat, aSettings ); } - } // for(; aIter != aControlsFormats.end();++aIter) - if ( !aControlsFormats.empty() ) + InvalidateAll(); + } } break; - //case SID_FM_DESIGN_MODE: - // break; case SID_INSERT_GRAPHIC: insertGraphic(); break; @@ -1674,10 +1687,14 @@ void OReportController::impl_initialize( ) { //m_sName = m_xReportDefinition->getName(); getView()->initialize(); // show the windows and fill with our informations - getUndoMgr()->Clear(); // clear all undo redo things - getSdrModel(); + + m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition); if ( !m_aReportModel ) - throw Exception(); + throw RuntimeException(); + m_aReportModel->attachController( *this ); + + clearUndoManager(); + UndoSuppressor aSuppressUndo( getUndoManager() ); ::comphelper::NamedValueCollection aArgs(getModel()->getArgs()); setMode(aArgs.getOrDefault("Mode", rtl::OUString::createFromAscii("normal"))); @@ -1829,7 +1846,7 @@ sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/) throw( Runt // ----------------------------------------------------------------------------- void OReportController::describeSupportedFeatures() { - OSingleDocumentController::describeSupportedFeatures(); + DBSubComponentController::describeSupportedFeatures(); implDescribeSupportedFeature( ".uno:TextDocument", SID_RPT_TEXTDOCUMENT, CommandGroup::APPLICATION ); implDescribeSupportedFeature( ".uno:Spreadsheet", SID_RPT_SPREADSHEET, CommandGroup::APPLICATION ); @@ -2092,18 +2109,13 @@ void OReportController::describeSupportedFeatures() implDescribeSupportedFeature( ".uno:ExpandSection", SID_EXPAND_SECTION); } // ----------------------------------------------------------------------------- -SfxUndoManager* OReportController::getUndoMgr() -{ - return &m_aUndoManager; -} -// ----------------------------------------------------------------------------- void OReportController::impl_onModifyChanged() { try { if ( m_xReportDefinition.is() ) m_xReportDefinition->setModified( impl_isModified() ); - OSingleDocumentController::impl_onModifyChanged(); + DBSubComponentController::impl_onModifyChanged(); } catch(uno::Exception) { @@ -2111,14 +2123,6 @@ void OReportController::impl_onModifyChanged() } } // ----------------------------------------------------------------------------- -void OReportController::losingConnection( ) -{ - // let the base class do it's reconnect - OReportController_BASE::losingConnection( ); - - InvalidateAll(); -} -// ----------------------------------------------------------------------------- void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager) { if ( _xLayoutManager.is() ) @@ -2305,6 +2309,7 @@ void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEven // ----------------------------------------------------------------------------- void SAL_CALL OReportController::disposing( const lang::EventObject& Source ) throw(uno::RuntimeException) { + // simply disambiguate OReportController_BASE::disposing(Source); } @@ -2376,13 +2381,6 @@ IMPL_LINK( OReportController, OnClipboardChanged, void*, EMPTYARG ) return OnInvalidateClipboard( NULL ); } //------------------------------------------------------------------------------ -IMPL_LINK( OReportController, NotifyUndoActionHdl, SfxUndoAction*, _pUndoAction ) -{ - OSL_ENSURE(_pUndoAction,"UndoAction is NULL!"); - addUndoActionAndInvalidate(_pUndoAction); - return 0L; -} -//------------------------------------------------------------------------------ IMPL_LINK(OReportController, OnInvalidateClipboard, void*, EMPTYARG) { InvalidateFeature(SID_CUT); @@ -2483,7 +2481,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ { uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW); const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEPAGE)); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); const SfxPoolItem* pItem = NULL; if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_SIZE,sal_True,&pItem)) { @@ -2534,13 +2532,24 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ delete pDefaults[i]; } + // ----------------------------------------------------------------------------- sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel) throw( uno::RuntimeException ) { ::osl::MutexGuard aGuard( getMutex() ); - m_xReportDefinition.set(xModel,uno::UNO_QUERY); - return m_xReportDefinition.is(); + + uno::Reference< report::XReportDefinition > xReportDefinition( xModel, UNO_QUERY ); + if ( !xReportDefinition.is() ) + return sal_False; + + uno::Reference< document::XUndoManagerSupplier > xTestSuppUndo( xModel, UNO_QUERY ); + if ( !xTestSuppUndo.is() ) + return sal_False; + + m_xReportDefinition = xReportDefinition; + return sal_True; } + // ----------------------------------------------------------------------------- void OReportController::openSortingAndGroupingDialog() { @@ -2597,7 +2606,7 @@ void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHi void OReportController::executeMethodWithUndo(sal_uInt16 _nUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun) { const String sUndoAction = String((ModuleRes(_nUndoStrId))); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); _pMemfun( getDesignView() ); InvalidateFeature( SID_SAVEDOC ); InvalidateFeature( SID_UNDO ); @@ -2606,7 +2615,7 @@ void OReportController::executeMethodWithUndo(sal_uInt16 _nUndoStrId,const ::std void OReportController::alignControlsWithUndo(sal_uInt16 _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection) { const String sUndoAction = String((ModuleRes(_nUndoStrId))); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); getDesignView()->alignMarkedObjects(_nControlModification,_bAlignAtSection); InvalidateFeature( SID_SAVEDOC ); InvalidateFeature( SID_UNDO ); @@ -2691,7 +2700,7 @@ void OReportController::shrinkSection(sal_uInt16 _nUndoStrId, uno::Reference<rep if ( _xSection.is() ) { const String sUndoAction = String((ModuleRes(_nUndoStrId))); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); if (_nSid == SID_SECTION_SHRINK) { @@ -3051,17 +3060,8 @@ void OReportController::insertGraphic() } } // ----------------------------------------------------------------------------- -::boost::shared_ptr<rptui::OReportModel> OReportController::getSdrModel() +::boost::shared_ptr<rptui::OReportModel> OReportController::getSdrModel() const { - if ( !m_aReportModel ) - { - m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition); - if ( m_aReportModel ) - { - m_aReportModel->attachController( *this ); - m_aReportModel->SetNotifyUndoActionHdl(LINK( this, OReportController, NotifyUndoActionHdl )); - } - } return m_aReportModel; } // ----------------------------------------------------------------------------- @@ -3265,7 +3265,7 @@ void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs) getDesignView()->unmarkAllObjects(NULL); const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL)); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); SequenceAsHashMap aMap(_aArgs); aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0))); @@ -3293,7 +3293,7 @@ void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs getDesignView()->unmarkAllObjects(NULL); const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL)); - UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); if ( !m_xReportDefinition->getPageHeaderOn() ) { @@ -3337,7 +3337,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) } uno::Reference<report::XSection> xCurrentSection = getDesignView()->getCurrentSection(); - UndoManagerListAction aUndo( *getUndoMgr(), String( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) ); + UndoContext aUndoContext( getUndoManager(), String( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) ); try { @@ -3805,19 +3805,21 @@ void OReportController::switchReportSection(const sal_Int16 _nId) { const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn(); + + ::boost::scoped_ptr< UndoContext > pUndoContext; if ( SID_REPORTHEADERFOOTER == _nId ) { const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); - getUndoMgr()->EnterListAction( sUndoAction, String() ); + pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); - addUndoActionAndInvalidate(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO + addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO ,::std::mem_fun(&OReportHelper::getReportHeader) ,m_xReportDefinition ,bSwitchOn ? Inserted : Removed ,0 )); - addUndoActionAndInvalidate(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO + addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO ,::std::mem_fun(&OReportHelper::getReportFooter) ,m_xReportDefinition ,bSwitchOn ? Inserted : Removed @@ -3840,7 +3842,7 @@ void OReportController::switchReportSection(const sal_Int16 _nId) } if ( SID_REPORTHEADERFOOTER == _nId ) - getUndoMgr()->LeaveListAction(); + pUndoContext.reset(); getView()->Resize(); } } @@ -3853,12 +3855,13 @@ void OReportController::switchPageSection(const sal_Int16 _nId) const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn(); + ::boost::scoped_ptr< UndoContext > pUndoContext; if ( SID_PAGEHEADERFOOTER == _nId ) { const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); - getUndoMgr()->EnterListAction( sUndoAction, String() ); + pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); - addUndoActionAndInvalidate(new OReportSectionUndo(*m_aReportModel + addUndoAction(new OReportSectionUndo(*m_aReportModel ,SID_PAGEHEADER_WITHOUT_UNDO ,::std::mem_fun(&OReportHelper::getPageHeader) ,m_xReportDefinition @@ -3866,7 +3869,7 @@ void OReportController::switchPageSection(const sal_Int16 _nId) ,0 )); - addUndoActionAndInvalidate(new OReportSectionUndo(*m_aReportModel + addUndoAction(new OReportSectionUndo(*m_aReportModel ,SID_PAGEFOOTER_WITHOUT_UNDO ,::std::mem_fun(&OReportHelper::getPageFooter) ,m_xReportDefinition @@ -3888,7 +3891,7 @@ void OReportController::switchPageSection(const sal_Int16 _nId) break; } if ( SID_PAGEHEADERFOOTER == _nId ) - getUndoMgr()->LeaveListAction(); + pUndoContext.reset(); getView()->Resize(); } } @@ -3914,7 +3917,7 @@ void OReportController::modifyGroup(const bool _bAppend, const Sequence< Propert rUndoEnv.AddElement( xGroup->getFunctions() ); } - addUndoActionAndInvalidate( new OGroupUndo( + addUndoAction( new OGroupUndo( *m_aReportModel, _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP, _bAppend ? Inserted : Removed, @@ -3948,7 +3951,7 @@ void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader { const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv()); if ( _bUndo ) - addUndoActionAndInvalidate(new OGroupSectionUndo(*m_aReportModel + addUndoAction(new OGroupSectionUndo(*m_aReportModel ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO ,_bHeader ? ::std::mem_fun(&OGroupHelper::getHeader) : ::std::mem_fun(&OGroupHelper::getFooter) ,xGroup @@ -4203,23 +4206,21 @@ sal_Bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const un // ----------------------------------------------------------------------------- bool OReportController::impl_setPropertyAtControls_throw(const sal_uInt16 _nUndoResId,const ::rtl::OUString& _sProperty,const uno::Any& _aValue,const Sequence< PropertyValue >& _aArgs) { - ::std::auto_ptr<UndoManagerListAction> pListAction; ::std::vector< uno::Reference< uno::XInterface > > aSelection; uno::Reference< awt::XWindow> xWindow; lcl_getReportControlFormat( _aArgs, getDesignView(), xWindow, aSelection ); - const bool bMultiSet = aSelection.size() > 1; ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin(); + + const String sUndoAction = String( ModuleRes( _nUndoResId ) ); + UndoContext aUndoContext( getUndoManager(), sUndoAction ); + for(; aIter != aSelection.end();++aIter) { - if ( !pListAction.get() && _nUndoResId && bMultiSet ) - { - const String sUndoAction = String(ModuleRes(_nUndoResId)); - pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction)); - } // if ( !pListAction.get() ) const uno::Reference< beans::XPropertySet > xControlModel(*aIter,uno::UNO_QUERY); if ( xControlModel.is() ) xControlModel->setPropertyValue(_sProperty,_aValue); - } // for(; aIter != aSelection.end();++aIter) + } + return !aSelection.empty(); } // ----------------------------------------------------------------------------- @@ -4388,4 +4389,33 @@ uno::Reference< container::XNameAccess > OReportController::getColumns() const } return sLabel; } + +// ----------------------------------------------------------------------------- +SfxUndoManager& OReportController::getUndoManager() const +{ + DBG_TESTSOLARMUTEX(); + // this is expected to be called during UI actions, so the SM is assumed to be locked + + ::boost::shared_ptr< OReportModel > pReportModel( getSdrModel() ); + ENSURE_OR_THROW( !!pReportModel, "no access to our model" ); + + SfxUndoManager* pUndoManager( pReportModel->GetSdrUndoManager() ); + ENSURE_OR_THROW( pUndoManager != NULL, "no access to our model's UndoManager" ); + + return *pUndoManager; +} + +// ----------------------------------------------------------------------------- +void OReportController::clearUndoManager() const +{ + getUndoManager().Clear(); +} + // ----------------------------------------------------------------------------- +void OReportController::addUndoAction( SfxUndoAction* i_pAction ) +{ + getUndoManager().AddUndoAction( i_pAction ); + + InvalidateFeature( SID_UNDO ); + InvalidateFeature( SID_REDO ); +} diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx index 67dfb0f9753f..2b39503b4375 100644 --- a/reportdesign/source/ui/report/SectionWindow.cxx +++ b/reportdesign/source/ui/report/SectionWindow.cxx @@ -329,15 +329,14 @@ void OSectionWindow::zoom(const Fraction& _aZoom) //----------------------------------------------------------------------------- IMPL_LINK( OSectionWindow, StartSplitHdl, Splitter*, ) { - const String sEmpty(ModuleRes(RID_STR_UNDO_CHANGE_SIZE)); - getViewsWindow()->getView()->getReportView()->getController().getUndoMgr()->EnterListAction(sEmpty,String()); + const String sUndoAction( ModuleRes( RID_STR_UNDO_CHANGE_SIZE ) ); + getViewsWindow()->getView()->getReportView()->getController().getUndoManager().EnterListAction( sUndoAction, String() ); return 0L; } //------------------------------------------------------------------------------ IMPL_LINK( OSectionWindow, EndSplitHdl, Splitter*, ) { - getViewsWindow()->getView()->getReportView()->getController().getUndoMgr()->LeaveListAction(); - /*getViewsWindow()->Resize();*/ + getViewsWindow()->getView()->getReportView()->getController().getUndoManager().LeaveListAction(); return 0L; } //----------------------------------------------------------------------------- diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index 49f67a6e5195..4271f52ec6a8 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -1329,7 +1329,7 @@ void OViewsWindow::EndDragObj_removeInvisibleObjects() void OViewsWindow::EndDragObj(sal_Bool _bControlKeyPressed, const OSectionView* _pSection,const Point& _aPnt) { const String sUndoAction = String((ModuleRes(RID_STR_UNDO_CHANGEPOSITION))); - UndoManagerListAction aListAction(*getView()->getReportView()->getController().getUndoMgr(),sUndoAction); + const UndoContext aUndoContext( getView()->getReportView()->getController().getUndoManager(), sUndoAction ); Point aNewPos = _aPnt; OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aNewPos); |