xref: /AOO41X/main/reportdesign/source/core/sdr/UndoActions.cxx (revision 9e0e41911c53968aad5ad356e2b2126da667034f)
1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9e0e4191SAndrew Rist  * distributed with this work for additional information
6*9e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist  * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9e0e4191SAndrew Rist  * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9e0e4191SAndrew Rist  *************************************************************/
21*9e0e4191SAndrew Rist 
22*9e0e4191SAndrew Rist 
23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include "UndoActions.hxx"
26cdf0e10cSrcweir #include "UndoEnv.hxx"
27cdf0e10cSrcweir #include "formatnormalizer.hxx"
28cdf0e10cSrcweir #include "conditionupdater.hxx"
29cdf0e10cSrcweir #include "corestrings.hrc"
30cdf0e10cSrcweir #include "rptui_slotid.hrc"
31cdf0e10cSrcweir #include "RptDef.hxx"
32cdf0e10cSrcweir #include "ModuleHelper.hxx"
33cdf0e10cSrcweir #include "RptObject.hxx"
34cdf0e10cSrcweir #include "RptPage.hxx"
35cdf0e10cSrcweir #include "RptResId.hrc"
36cdf0e10cSrcweir #include "RptModel.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir /** === begin UNO includes === **/
39cdf0e10cSrcweir #include <com/sun/star/script/XEventAttacherManager.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
41cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
43cdf0e10cSrcweir #include <com/sun/star/util/XModifyBroadcaster.hpp>
44cdf0e10cSrcweir /** === end UNO includes === **/
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
47cdf0e10cSrcweir #include <svl/smplhint.hxx>
48cdf0e10cSrcweir #include <tools/diagnose_ex.h>
49cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
50cdf0e10cSrcweir #include <vcl/svapp.hxx>
51cdf0e10cSrcweir #include <dbaccess/dbsubcomponentcontroller.hxx>
52cdf0e10cSrcweir #include <svx/unoshape.hxx>
53cdf0e10cSrcweir #include <vos/mutex.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace rptui
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     using namespace ::com::sun::star;
58cdf0e10cSrcweir     using namespace uno;
59cdf0e10cSrcweir     using namespace lang;
60cdf0e10cSrcweir     using namespace script;
61cdf0e10cSrcweir     using namespace beans;
62cdf0e10cSrcweir     using namespace awt;
63cdf0e10cSrcweir     using namespace util;
64cdf0e10cSrcweir     using namespace container;
65cdf0e10cSrcweir     using namespace report;
66cdf0e10cSrcweir //----------------------------------------------------------------------------
getMemberFunction(const Reference<XSection> & _xSection)67cdf0e10cSrcweir ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> OGroupHelper::getMemberFunction(const Reference< XSection >& _xSection)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter);
70cdf0e10cSrcweir     uno::Reference< report::XGroup> xGroup = _xSection->getGroup();
71cdf0e10cSrcweir     if ( xGroup->getHeaderOn() && xGroup->getHeader() == _xSection )
72cdf0e10cSrcweir         pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader);
73cdf0e10cSrcweir     return pMemFunSection;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir // -----------------------------------------------------------------------------
getMemberFunction(const Reference<XSection> & _xSection)76cdf0e10cSrcweir ::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> OReportHelper::getMemberFunction(const Reference< XSection >& _xSection)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     uno::Reference< report::XReportDefinition> xReportDefinition(_xSection->getReportDefinition());
79cdf0e10cSrcweir     ::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> pMemFunSection = ::std::mem_fun(&OReportHelper::getReportFooter);
80cdf0e10cSrcweir     if ( xReportDefinition->getReportHeaderOn() && xReportDefinition->getReportHeader() == _xSection )
81cdf0e10cSrcweir         pMemFunSection = ::std::mem_fun(&OReportHelper::getReportHeader);
82cdf0e10cSrcweir     else if ( xReportDefinition->getPageHeaderOn() && xReportDefinition->getPageHeader() == _xSection )
83cdf0e10cSrcweir         pMemFunSection = ::std::mem_fun(&OReportHelper::getPageHeader);
84cdf0e10cSrcweir     else if ( xReportDefinition->getPageFooterOn() && xReportDefinition->getPageFooter() == _xSection )
85cdf0e10cSrcweir         pMemFunSection = ::std::mem_fun(&OReportHelper::getPageFooter);
86cdf0e10cSrcweir     else if ( xReportDefinition->getDetail() == _xSection )
87cdf0e10cSrcweir         pMemFunSection = ::std::mem_fun(&OReportHelper::getDetail);
88cdf0e10cSrcweir     return pMemFunSection;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //------------------------------------------------------------------------------
92cdf0e10cSrcweir TYPEINIT1( OCommentUndoAction,          SdrUndoAction );
DBG_NAME(rpt_OCommentUndoAction)93cdf0e10cSrcweir DBG_NAME(rpt_OCommentUndoAction)
94cdf0e10cSrcweir //----------------------------------------------------------------------------
95cdf0e10cSrcweir OCommentUndoAction::OCommentUndoAction(SdrModel& _rMod,sal_uInt16 nCommentID)
96cdf0e10cSrcweir     :SdrUndoAction(_rMod)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     DBG_CTOR(rpt_OCommentUndoAction,NULL);
99cdf0e10cSrcweir     m_pController = static_cast< OReportModel& >( _rMod ).getController();
100cdf0e10cSrcweir     if ( nCommentID )
101cdf0e10cSrcweir         m_strComment = String(ModuleRes(nCommentID));
102cdf0e10cSrcweir }
~OCommentUndoAction()103cdf0e10cSrcweir OCommentUndoAction::~OCommentUndoAction()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     DBG_DTOR(rpt_OCommentUndoAction,NULL);
106cdf0e10cSrcweir }
107cdf0e10cSrcweir //----------------------------------------------------------------------------
Undo()108cdf0e10cSrcweir void OCommentUndoAction::Undo()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir }
111cdf0e10cSrcweir //----------------------------------------------------------------------------
Redo()112cdf0e10cSrcweir void OCommentUndoAction::Redo()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir DBG_NAME( rpt_OUndoContainerAction );
116cdf0e10cSrcweir //------------------------------------------------------------------------------
OUndoContainerAction(SdrModel & _rMod,Action _eAction,const uno::Reference<container::XIndexContainer> _xContainer,const Reference<XInterface> & xElem,sal_uInt16 _nCommentId)117cdf0e10cSrcweir OUndoContainerAction::OUndoContainerAction(SdrModel& _rMod
118cdf0e10cSrcweir                                              ,Action _eAction
119cdf0e10cSrcweir                                              ,const uno::Reference< container::XIndexContainer > _xContainer
120cdf0e10cSrcweir                                              ,const Reference< XInterface > & xElem
121cdf0e10cSrcweir                                              ,sal_uInt16 _nCommentId)
122cdf0e10cSrcweir                       :OCommentUndoAction(_rMod,_nCommentId)
123cdf0e10cSrcweir                       ,m_xElement(xElem)
124cdf0e10cSrcweir                       ,m_xContainer(_xContainer)
125cdf0e10cSrcweir                       ,m_eAction( _eAction )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     DBG_CTOR( rpt_OUndoContainerAction,NULL);
128cdf0e10cSrcweir     // normalize
129cdf0e10cSrcweir     if ( m_eAction == Removed )
130cdf0e10cSrcweir         // we now own the element
131cdf0e10cSrcweir         m_xOwnElement = m_xElement;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir //------------------------------------------------------------------------------
~OUndoContainerAction()134cdf0e10cSrcweir OUndoContainerAction::~OUndoContainerAction()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     // if we own the object ....
137cdf0e10cSrcweir     Reference< XComponent > xComp( m_xOwnElement, UNO_QUERY );
138cdf0e10cSrcweir     if ( xComp.is() )
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         // and the object does not have a parent
141cdf0e10cSrcweir         Reference< XChild >  xChild( m_xOwnElement, UNO_QUERY );
142cdf0e10cSrcweir         if ( xChild.is() && !xChild->getParent().is() )
143cdf0e10cSrcweir         {
144cdf0e10cSrcweir             OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
145cdf0e10cSrcweir             rEnv.RemoveElement( m_xOwnElement );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
148cdf0e10cSrcweir             SvxShape* pShape = SvxShape::getImplementation( xChild );
149cdf0e10cSrcweir             SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
150cdf0e10cSrcweir             OSL_ENSURE( pObject ? pShape->HasSdrObjectOwnership() && !pObject->IsInserted() : true ,
151cdf0e10cSrcweir                 "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" );
152cdf0e10cSrcweir #endif
153cdf0e10cSrcweir             // -> dispose it
154cdf0e10cSrcweir             try
155cdf0e10cSrcweir             {
156cdf0e10cSrcweir                 comphelper::disposeComponent( xComp );
157cdf0e10cSrcweir             }
158cdf0e10cSrcweir             catch ( const uno::Exception& )
159cdf0e10cSrcweir             {
160cdf0e10cSrcweir                 DBG_UNHANDLED_EXCEPTION();
161cdf0e10cSrcweir             }
162cdf0e10cSrcweir         }
163cdf0e10cSrcweir     }
164cdf0e10cSrcweir     DBG_DTOR( rpt_OUndoContainerAction,NULL);
165cdf0e10cSrcweir }
166cdf0e10cSrcweir //------------------------------------------------------------------------------
implReInsert()167cdf0e10cSrcweir void OUndoContainerAction::implReInsert( ) SAL_THROW( ( Exception ) )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     if ( m_xContainer.is() )
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         // insert the element
172cdf0e10cSrcweir         m_xContainer->insertByIndex( m_xContainer->getCount(),uno::makeAny(m_xElement) );
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir     // we don't own the object anymore
175cdf0e10cSrcweir     m_xOwnElement = NULL;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir //------------------------------------------------------------------------------
implReRemove()179cdf0e10cSrcweir void OUndoContainerAction::implReRemove( ) SAL_THROW( ( Exception ) )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
182cdf0e10cSrcweir     try
183cdf0e10cSrcweir     {
184cdf0e10cSrcweir         OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
185cdf0e10cSrcweir         if ( m_xContainer.is() )
186cdf0e10cSrcweir         {
187cdf0e10cSrcweir             const sal_Int32 nCount = m_xContainer->getCount();
188cdf0e10cSrcweir             for (sal_Int32 i = 0; i < nCount; ++i)
189cdf0e10cSrcweir             {
190cdf0e10cSrcweir                 uno::Reference< uno::XInterface> xObj(m_xContainer->getByIndex(i),uno::UNO_QUERY);
191cdf0e10cSrcweir                 if ( xObj == m_xElement )
192cdf0e10cSrcweir                 {
193cdf0e10cSrcweir                     m_xContainer->removeByIndex( i );
194cdf0e10cSrcweir                     break;
195cdf0e10cSrcweir                 }
196cdf0e10cSrcweir             }
197cdf0e10cSrcweir         }
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir     catch(uno::Exception&){}
200cdf0e10cSrcweir     // from now on, we own this object
201cdf0e10cSrcweir     m_xOwnElement = m_xElement;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir //------------------------------------------------------------------------------
Undo()205cdf0e10cSrcweir void OUndoContainerAction::Undo()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     if ( m_xElement.is() )
208cdf0e10cSrcweir     {
209cdf0e10cSrcweir         // prevents that an undo action will be created for elementInserted
210cdf0e10cSrcweir         try
211cdf0e10cSrcweir         {
212cdf0e10cSrcweir             switch ( m_eAction )
213cdf0e10cSrcweir             {
214cdf0e10cSrcweir             case Inserted:
215cdf0e10cSrcweir                 implReRemove();
216cdf0e10cSrcweir                 break;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir             case Removed:
219cdf0e10cSrcweir                 implReInsert();
220cdf0e10cSrcweir                 break;
221cdf0e10cSrcweir             default:
222cdf0e10cSrcweir                 OSL_ENSURE(0,"Illegal case value");
223cdf0e10cSrcweir                 break;
224cdf0e10cSrcweir             }
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir         catch( const Exception& )
227cdf0e10cSrcweir         {
228cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OUndoContainerAction::Undo: caught an exception!" );
229cdf0e10cSrcweir         }
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir //------------------------------------------------------------------------------
Redo()234cdf0e10cSrcweir void OUndoContainerAction::Redo()
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     if ( m_xElement.is() )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         try
239cdf0e10cSrcweir         {
240cdf0e10cSrcweir             switch ( m_eAction )
241cdf0e10cSrcweir             {
242cdf0e10cSrcweir             case Inserted:
243cdf0e10cSrcweir                 implReInsert();
244cdf0e10cSrcweir                 break;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir             case Removed:
247cdf0e10cSrcweir                 implReRemove();
248cdf0e10cSrcweir                 break;
249cdf0e10cSrcweir             default:
250cdf0e10cSrcweir                 OSL_ENSURE(0,"Illegal case value");
251cdf0e10cSrcweir                 break;
252cdf0e10cSrcweir             }
253cdf0e10cSrcweir         }
254cdf0e10cSrcweir         catch( const Exception& )
255cdf0e10cSrcweir         {
256cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OUndoContainerAction::Redo: caught an exception!" );
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir }
260cdf0e10cSrcweir // -----------------------------------------------------------------------------
OUndoGroupSectionAction(SdrModel & _rMod,Action _eAction,::std::mem_fun_t<uno::Reference<report::XSection>,OGroupHelper> _pMemberFunction,const uno::Reference<report::XGroup> & _xGroup,const Reference<XInterface> & xElem,sal_uInt16 _nCommentId)261cdf0e10cSrcweir OUndoGroupSectionAction::OUndoGroupSectionAction(SdrModel& _rMod
262cdf0e10cSrcweir                                              ,Action _eAction
263cdf0e10cSrcweir                                              ,::std::mem_fun_t< uno::Reference< report::XSection >
264cdf0e10cSrcweir                                                     ,OGroupHelper> _pMemberFunction
265cdf0e10cSrcweir                                              ,const uno::Reference< report::XGroup >& _xGroup
266cdf0e10cSrcweir                                              ,const Reference< XInterface > & xElem
267cdf0e10cSrcweir                                              ,sal_uInt16 _nCommentId)
268cdf0e10cSrcweir :OUndoContainerAction(_rMod,_eAction,NULL,xElem,_nCommentId)
269cdf0e10cSrcweir ,m_aGroupHelper(_xGroup)
270cdf0e10cSrcweir ,m_pMemberFunction(_pMemberFunction)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir }
273cdf0e10cSrcweir //------------------------------------------------------------------------------
implReInsert()274cdf0e10cSrcweir void OUndoGroupSectionAction::implReInsert( ) SAL_THROW( ( Exception ) )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
277cdf0e10cSrcweir     try
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
280cdf0e10cSrcweir         uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aGroupHelper);
281cdf0e10cSrcweir         if ( xSection.is() )
282cdf0e10cSrcweir             xSection->add(uno::Reference< drawing::XShape>(m_xElement,uno::UNO_QUERY));
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir     catch(uno::Exception&){}
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     // we don't own the object anymore
287cdf0e10cSrcweir     m_xOwnElement = NULL;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir //------------------------------------------------------------------------------
implReRemove()291cdf0e10cSrcweir void OUndoGroupSectionAction::implReRemove( ) SAL_THROW( ( Exception ) )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir         OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
294cdf0e10cSrcweir     try
295cdf0e10cSrcweir     {
296cdf0e10cSrcweir         OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
297cdf0e10cSrcweir         uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aGroupHelper);
298cdf0e10cSrcweir         if ( xSection.is() )
299cdf0e10cSrcweir             xSection->remove(uno::Reference< drawing::XShape>(m_xElement,uno::UNO_QUERY));
300cdf0e10cSrcweir     }
301cdf0e10cSrcweir     catch(uno::Exception&){}
302cdf0e10cSrcweir 
303cdf0e10cSrcweir     // from now on, we own this object
304cdf0e10cSrcweir     m_xOwnElement = m_xElement;
305cdf0e10cSrcweir }
306cdf0e10cSrcweir //----------------------------------------------------------------------------
OUndoReportSectionAction(SdrModel & _rMod,Action _eAction,::std::mem_fun_t<uno::Reference<report::XSection>,OReportHelper> _pMemberFunction,const uno::Reference<report::XReportDefinition> & _xReport,const Reference<XInterface> & xElem,sal_uInt16 _nCommentId)307cdf0e10cSrcweir OUndoReportSectionAction::OUndoReportSectionAction(SdrModel& _rMod
308cdf0e10cSrcweir                                              ,Action _eAction
309cdf0e10cSrcweir                                              ,::std::mem_fun_t< uno::Reference< report::XSection >
310cdf0e10cSrcweir                                                 ,OReportHelper> _pMemberFunction
311cdf0e10cSrcweir                                              ,const uno::Reference< report::XReportDefinition >& _xReport
312cdf0e10cSrcweir                                              ,const Reference< XInterface > & xElem
313cdf0e10cSrcweir                                              ,sal_uInt16 _nCommentId)
314cdf0e10cSrcweir :OUndoContainerAction(_rMod,_eAction,NULL,xElem,_nCommentId)
315cdf0e10cSrcweir ,m_aReportHelper(_xReport)
316cdf0e10cSrcweir ,m_pMemberFunction(_pMemberFunction)
317cdf0e10cSrcweir {
318cdf0e10cSrcweir }
319cdf0e10cSrcweir //------------------------------------------------------------------------------
implReInsert()320cdf0e10cSrcweir void OUndoReportSectionAction::implReInsert( ) SAL_THROW( ( Exception ) )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir     OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
323cdf0e10cSrcweir     try
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
326cdf0e10cSrcweir         uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aReportHelper);
327cdf0e10cSrcweir         if ( xSection.is() )
328cdf0e10cSrcweir         {
329cdf0e10cSrcweir             uno::Reference< drawing::XShape> xShape(m_xElement,uno::UNO_QUERY_THROW);
330cdf0e10cSrcweir             awt::Point aPos = xShape->getPosition();
331cdf0e10cSrcweir             awt::Size aSize = xShape->getSize();
332cdf0e10cSrcweir             xSection->add(xShape);
333cdf0e10cSrcweir             xShape->setPosition( aPos );
334cdf0e10cSrcweir             xShape->setSize( aSize );
335cdf0e10cSrcweir         }
336cdf0e10cSrcweir     }
337cdf0e10cSrcweir     catch(uno::Exception&){}
338cdf0e10cSrcweir     // we don't own the object anymore
339cdf0e10cSrcweir     m_xOwnElement = NULL;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir //------------------------------------------------------------------------------
implReRemove()343cdf0e10cSrcweir void OUndoReportSectionAction::implReRemove( ) SAL_THROW( ( Exception ) )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir     OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
346cdf0e10cSrcweir     try
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
349cdf0e10cSrcweir         uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aReportHelper);
350cdf0e10cSrcweir         if ( xSection.is() )
351cdf0e10cSrcweir             xSection->remove(uno::Reference< drawing::XShape>(m_xElement,uno::UNO_QUERY));
352cdf0e10cSrcweir     }
353cdf0e10cSrcweir     catch(uno::Exception&){}
354cdf0e10cSrcweir     // from now on, we own this object
355cdf0e10cSrcweir     m_xOwnElement = m_xElement;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir //------------------------------------------------------------------------------
ORptUndoPropertyAction(SdrModel & rNewMod,const PropertyChangeEvent & evt)358cdf0e10cSrcweir ORptUndoPropertyAction::ORptUndoPropertyAction(SdrModel& rNewMod, const PropertyChangeEvent& evt)
359cdf0e10cSrcweir                      :OCommentUndoAction(rNewMod,0)
360cdf0e10cSrcweir                      ,m_xObj(evt.Source, UNO_QUERY)
361cdf0e10cSrcweir                      ,m_aPropertyName(evt.PropertyName)
362cdf0e10cSrcweir                      ,m_aNewValue(evt.NewValue)
363cdf0e10cSrcweir                      ,m_aOldValue(evt.OldValue)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir }
366cdf0e10cSrcweir //------------------------------------------------------------------------------
Undo()367cdf0e10cSrcweir void ORptUndoPropertyAction::Undo()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir     setProperty(sal_True);
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir //------------------------------------------------------------------------------
Redo()373cdf0e10cSrcweir void ORptUndoPropertyAction::Redo()
374cdf0e10cSrcweir {
375cdf0e10cSrcweir     setProperty(sal_False);
376cdf0e10cSrcweir }
377cdf0e10cSrcweir // -----------------------------------------------------------------------------
getObject()378cdf0e10cSrcweir Reference< XPropertySet> ORptUndoPropertyAction::getObject()
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     return m_xObj;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir // -----------------------------------------------------------------------------
setProperty(sal_Bool _bOld)383cdf0e10cSrcweir void ORptUndoPropertyAction::setProperty(sal_Bool _bOld)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir     Reference< XPropertySet> xObj = getObject();
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     if (xObj.is() )
388cdf0e10cSrcweir     {
389cdf0e10cSrcweir         try
390cdf0e10cSrcweir         {
391cdf0e10cSrcweir             xObj->setPropertyValue( m_aPropertyName, _bOld ? m_aOldValue : m_aNewValue );
392cdf0e10cSrcweir         }
393cdf0e10cSrcweir         catch( const Exception& )
394cdf0e10cSrcweir         {
395cdf0e10cSrcweir             OSL_ENSURE( sal_False, "ORptUndoPropertyAction::Redo: caught an exception!" );
396cdf0e10cSrcweir         }
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir //------------------------------------------------------------------------------
GetComment() const401cdf0e10cSrcweir String ORptUndoPropertyAction::GetComment() const
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     String aStr(ModuleRes(RID_STR_UNDO_PROPERTY));
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     aStr.SearchAndReplace( '#', m_aPropertyName );
406cdf0e10cSrcweir     return aStr;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir // -----------------------------------------------------------------------------
OUndoPropertyGroupSectionAction(SdrModel & _rMod,const PropertyChangeEvent & evt,::std::mem_fun_t<uno::Reference<report::XSection>,OGroupHelper> _pMemberFunction,const uno::Reference<report::XGroup> & _xGroup)409cdf0e10cSrcweir OUndoPropertyGroupSectionAction::OUndoPropertyGroupSectionAction(SdrModel& _rMod
410cdf0e10cSrcweir                                              ,const PropertyChangeEvent& evt
411cdf0e10cSrcweir                                              ,::std::mem_fun_t< uno::Reference< report::XSection >
412cdf0e10cSrcweir                                                     ,OGroupHelper> _pMemberFunction
413cdf0e10cSrcweir                                              ,const uno::Reference< report::XGroup >& _xGroup
414cdf0e10cSrcweir                                              )
415cdf0e10cSrcweir :ORptUndoPropertyAction(_rMod,evt)
416cdf0e10cSrcweir ,m_aGroupHelper(_xGroup)
417cdf0e10cSrcweir ,m_pMemberFunction(_pMemberFunction)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir }
420cdf0e10cSrcweir // -----------------------------------------------------------------------------
getObject()421cdf0e10cSrcweir Reference< XPropertySet> OUndoPropertyGroupSectionAction::getObject()
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     return m_pMemberFunction(&m_aGroupHelper).get();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir // -----------------------------------------------------------------------------
OUndoPropertyReportSectionAction(SdrModel & _rMod,const PropertyChangeEvent & evt,::std::mem_fun_t<uno::Reference<report::XSection>,OReportHelper> _pMemberFunction,const uno::Reference<report::XReportDefinition> & _xReport)426cdf0e10cSrcweir OUndoPropertyReportSectionAction::OUndoPropertyReportSectionAction(SdrModel& _rMod
427cdf0e10cSrcweir                                              ,const PropertyChangeEvent& evt
428cdf0e10cSrcweir                                              ,::std::mem_fun_t< uno::Reference< report::XSection >
429cdf0e10cSrcweir                                                 ,OReportHelper> _pMemberFunction
430cdf0e10cSrcweir                                              ,const uno::Reference< report::XReportDefinition >& _xReport
431cdf0e10cSrcweir                                              )
432cdf0e10cSrcweir :ORptUndoPropertyAction(_rMod,evt)
433cdf0e10cSrcweir ,m_aReportHelper(_xReport)
434cdf0e10cSrcweir ,m_pMemberFunction(_pMemberFunction)
435cdf0e10cSrcweir {
436cdf0e10cSrcweir }
437cdf0e10cSrcweir // -----------------------------------------------------------------------------
getObject()438cdf0e10cSrcweir Reference< XPropertySet> OUndoPropertyReportSectionAction::getObject()
439cdf0e10cSrcweir {
440cdf0e10cSrcweir     return m_pMemberFunction(&m_aReportHelper).get();
441cdf0e10cSrcweir }
442cdf0e10cSrcweir //============================================================================
443cdf0e10cSrcweir } // rptui
444cdf0e10cSrcweir //============================================================================
445cdf0e10cSrcweir 
446