diff options
Diffstat (limited to 'reportdesign/source/ui/report/ReportController.cxx')
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 246 |
1 files changed, 138 insertions, 108 deletions
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 ); +} |