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
10*9e0e4191SAndrew Rist *
11*9e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9e0e4191SAndrew Rist *
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.
19*9e0e4191SAndrew Rist *
20*9e0e4191SAndrew Rist *************************************************************/
21*9e0e4191SAndrew Rist
22*9e0e4191SAndrew Rist
23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include "RptUndo.hxx"
26cdf0e10cSrcweir #include "uistrings.hrc"
27cdf0e10cSrcweir #include "rptui_slotid.hrc"
28cdf0e10cSrcweir #include "UITools.hxx"
29cdf0e10cSrcweir #include "UndoEnv.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <dbaccess/IController.hxx>
32cdf0e10cSrcweir #include <com/sun/star/report/XSection.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
37cdf0e10cSrcweir #include <svx/unoshape.hxx>
38cdf0e10cSrcweir #include <boost/bind.hpp>
39cdf0e10cSrcweir #include <functional>
40cdf0e10cSrcweir
41cdf0e10cSrcweir namespace rptui
42cdf0e10cSrcweir {
43cdf0e10cSrcweir using namespace ::com::sun::star;
44cdf0e10cSrcweir using namespace uno;
45cdf0e10cSrcweir using namespace lang;
46cdf0e10cSrcweir using namespace script;
47cdf0e10cSrcweir using namespace beans;
48cdf0e10cSrcweir using namespace awt;
49cdf0e10cSrcweir using namespace util;
50cdf0e10cSrcweir using namespace container;
51cdf0e10cSrcweir using namespace report;
52cdf0e10cSrcweir
53cdf0e10cSrcweir //----------------------------------------------------------------------------
54cdf0e10cSrcweir namespace
55cdf0e10cSrcweir {
lcl_collectElements(const uno::Reference<report::XSection> & _xSection,::std::vector<uno::Reference<drawing::XShape>> & _rControls)56cdf0e10cSrcweir void lcl_collectElements(const uno::Reference< report::XSection >& _xSection,::std::vector< uno::Reference< drawing::XShape> >& _rControls)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir if ( _xSection.is() )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir sal_Int32 nCount = _xSection->getCount();
61cdf0e10cSrcweir _rControls.reserve(nCount);
62cdf0e10cSrcweir while ( nCount )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir uno::Reference< drawing::XShape> xShape(_xSection->getByIndex(nCount-1),uno::UNO_QUERY);
65cdf0e10cSrcweir _rControls.push_back(xShape);
66cdf0e10cSrcweir _xSection->remove(xShape);
67cdf0e10cSrcweir --nCount;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir } // if ( _xSection.is() )
70cdf0e10cSrcweir }
71cdf0e10cSrcweir //----------------------------------------------------------------------------
lcl_insertElements(const uno::Reference<report::XSection> & _xSection,const::std::vector<uno::Reference<drawing::XShape>> & _aControls)72cdf0e10cSrcweir void lcl_insertElements(const uno::Reference< report::XSection >& _xSection,const ::std::vector< uno::Reference< drawing::XShape> >& _aControls)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir if ( _xSection.is() )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir ::std::vector< uno::Reference< drawing::XShape> >::const_reverse_iterator aIter = _aControls.rbegin();
77cdf0e10cSrcweir ::std::vector< uno::Reference< drawing::XShape> >::const_reverse_iterator aEnd = _aControls.rend();
78cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir try
81cdf0e10cSrcweir {
82cdf0e10cSrcweir const awt::Point aPos = (*aIter)->getPosition();
83cdf0e10cSrcweir const awt::Size aSize = (*aIter)->getSize();
84cdf0e10cSrcweir _xSection->add(*aIter);
85cdf0e10cSrcweir (*aIter)->setPosition( aPos );
86cdf0e10cSrcweir (*aIter)->setSize( aSize );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir catch(const uno::Exception&)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir OSL_ENSURE(0,"lcl_insertElements:Exception caught!");
91cdf0e10cSrcweir }
92cdf0e10cSrcweir }
93cdf0e10cSrcweir }
94cdf0e10cSrcweir }
95cdf0e10cSrcweir //----------------------------------------------------------------------------
lcl_setValues(const uno::Reference<report::XSection> & _xSection,const::std::vector<::std::pair<::rtl::OUString,uno::Any>> & _aValues)96cdf0e10cSrcweir void lcl_setValues(const uno::Reference< report::XSection >& _xSection,const ::std::vector< ::std::pair< ::rtl::OUString ,uno::Any> >& _aValues)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir if ( _xSection.is() )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir ::std::vector< ::std::pair< ::rtl::OUString ,uno::Any> >::const_iterator aIter = _aValues.begin();
101cdf0e10cSrcweir ::std::vector< ::std::pair< ::rtl::OUString ,uno::Any> >::const_iterator aEnd = _aValues.end();
102cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir try
105cdf0e10cSrcweir {
106cdf0e10cSrcweir _xSection->setPropertyValue(aIter->first,aIter->second);
107cdf0e10cSrcweir }
108cdf0e10cSrcweir catch(const uno::Exception&)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir OSL_ENSURE(0,"lcl_setValues:Exception caught!");
111cdf0e10cSrcweir }
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir }
115cdf0e10cSrcweir }
116cdf0e10cSrcweir //----------------------------------------------------------------------------
117cdf0e10cSrcweir TYPEINIT1( OSectionUndo, OCommentUndoAction );
DBG_NAME(rpt_OSectionUndo)118cdf0e10cSrcweir DBG_NAME(rpt_OSectionUndo)
119cdf0e10cSrcweir //----------------------------------------------------------------------------
120cdf0e10cSrcweir OSectionUndo::OSectionUndo(OReportModel& _rMod
121cdf0e10cSrcweir ,sal_uInt16 _nSlot
122cdf0e10cSrcweir ,Action _eAction
123cdf0e10cSrcweir ,sal_uInt16 nCommentID)
124cdf0e10cSrcweir : OCommentUndoAction(_rMod,nCommentID)
125cdf0e10cSrcweir ,m_eAction(_eAction)
126cdf0e10cSrcweir ,m_nSlot(_nSlot)
127cdf0e10cSrcweir ,m_bInserted(false)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir DBG_CTOR(rpt_OSectionUndo,NULL);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OSectionUndo()132cdf0e10cSrcweir OSectionUndo::~OSectionUndo()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir if ( !m_bInserted )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
137cdf0e10cSrcweir ::std::vector< uno::Reference< drawing::XShape> >::iterator aEnd = m_aControls.end();
138cdf0e10cSrcweir for (::std::vector< uno::Reference< drawing::XShape> >::iterator aIter = m_aControls.begin(); aIter != aEnd; ++aIter)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir uno::Reference< drawing::XShape> xShape = *aIter;
141cdf0e10cSrcweir rEnv.RemoveElement(xShape);
142cdf0e10cSrcweir
143cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
144cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( xShape );
145cdf0e10cSrcweir SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
146cdf0e10cSrcweir OSL_ENSURE( pShape && pShape->HasSdrObjectOwnership() && pObject && !pObject->IsInserted(),
147cdf0e10cSrcweir "OSectionUndo::~OSectionUndo: inconsistency in the shape/object ownership!" );
148cdf0e10cSrcweir #endif
149cdf0e10cSrcweir try
150cdf0e10cSrcweir {
151cdf0e10cSrcweir comphelper::disposeComponent(xShape);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir catch(uno::Exception)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir OSL_ENSURE(0,"Exception caught!");
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir DBG_DTOR(rpt_OSectionUndo,NULL);
160cdf0e10cSrcweir }
161cdf0e10cSrcweir // -----------------------------------------------------------------------------
collectControls(const uno::Reference<report::XSection> & _xSection)162cdf0e10cSrcweir void OSectionUndo::collectControls(const uno::Reference< report::XSection >& _xSection)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir m_aControls.clear();
165cdf0e10cSrcweir try
166cdf0e10cSrcweir {
167cdf0e10cSrcweir // copy all properties for restoring
168cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo> xInfo = _xSection->getPropertySetInfo();
169cdf0e10cSrcweir uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
170cdf0e10cSrcweir const beans::Property* pIter = aSeq.getConstArray();
171cdf0e10cSrcweir const beans::Property* pEnd = pIter + aSeq.getLength();
172cdf0e10cSrcweir for(;pIter != pEnd;++pIter)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir if ( 0 == (pIter->Attributes & beans::PropertyAttribute::READONLY) )
175cdf0e10cSrcweir m_aValues.push_back(::std::pair< ::rtl::OUString ,uno::Any>(pIter->Name,_xSection->getPropertyValue(pIter->Name)));
176cdf0e10cSrcweir }
177cdf0e10cSrcweir lcl_collectElements(_xSection,m_aControls);
178cdf0e10cSrcweir }
179cdf0e10cSrcweir catch(uno::Exception&)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir }
182cdf0e10cSrcweir }
183cdf0e10cSrcweir //----------------------------------------------------------------------------
Undo()184cdf0e10cSrcweir void OSectionUndo::Undo()
185cdf0e10cSrcweir {
186cdf0e10cSrcweir try
187cdf0e10cSrcweir {
188cdf0e10cSrcweir switch ( m_eAction )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir case Inserted:
191cdf0e10cSrcweir implReRemove();
192cdf0e10cSrcweir break;
193cdf0e10cSrcweir
194cdf0e10cSrcweir case Removed:
195cdf0e10cSrcweir implReInsert();
196cdf0e10cSrcweir break;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir }
199cdf0e10cSrcweir catch( const Exception& )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir OSL_ENSURE( sal_False, "OSectionUndo::Undo: caught an exception!" );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir }
204cdf0e10cSrcweir //----------------------------------------------------------------------------
Redo()205cdf0e10cSrcweir void OSectionUndo::Redo()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir try
208cdf0e10cSrcweir {
209cdf0e10cSrcweir switch ( m_eAction )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir case Inserted:
212cdf0e10cSrcweir implReInsert();
213cdf0e10cSrcweir break;
214cdf0e10cSrcweir
215cdf0e10cSrcweir case Removed:
216cdf0e10cSrcweir implReRemove();
217cdf0e10cSrcweir break;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir catch( const Exception& )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir OSL_ENSURE( sal_False, "OSectionUndo::Redo: caught an exception!" );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir }
225cdf0e10cSrcweir //----------------------------------------------------------------------------
226cdf0e10cSrcweir TYPEINIT1( OReportSectionUndo, OSectionUndo );
227cdf0e10cSrcweir //----------------------------------------------------------------------------
OReportSectionUndo(OReportModel & _rMod,sal_uInt16 _nSlot,::std::mem_fun_t<uno::Reference<report::XSection>,OReportHelper> _pMemberFunction,const uno::Reference<report::XReportDefinition> & _xReport,Action _eAction,sal_uInt16 nCommentID)228cdf0e10cSrcweir OReportSectionUndo::OReportSectionUndo(OReportModel& _rMod,sal_uInt16 _nSlot
229cdf0e10cSrcweir ,::std::mem_fun_t< uno::Reference< report::XSection >
230cdf0e10cSrcweir ,OReportHelper> _pMemberFunction
231cdf0e10cSrcweir ,const uno::Reference< report::XReportDefinition >& _xReport
232cdf0e10cSrcweir ,Action _eAction
233cdf0e10cSrcweir ,sal_uInt16 nCommentID)
234cdf0e10cSrcweir : OSectionUndo(_rMod,_nSlot,_eAction,nCommentID)
235cdf0e10cSrcweir ,m_aReportHelper(_xReport)
236cdf0e10cSrcweir ,m_pMemberFunction(_pMemberFunction)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir if( m_eAction == Removed )
239cdf0e10cSrcweir collectControls(m_pMemberFunction(&m_aReportHelper));
240cdf0e10cSrcweir }
241cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OReportSectionUndo()242cdf0e10cSrcweir OReportSectionUndo::~OReportSectionUndo()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir }
245cdf0e10cSrcweir //----------------------------------------------------------------------------
implReInsert()246cdf0e10cSrcweir void OReportSectionUndo::implReInsert( )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aArgs;
249cdf0e10cSrcweir m_pController->executeChecked(m_nSlot,aArgs);
250cdf0e10cSrcweir uno::Reference< report::XSection > xSection = m_pMemberFunction(&m_aReportHelper);
251cdf0e10cSrcweir lcl_insertElements(xSection,m_aControls);
252cdf0e10cSrcweir lcl_setValues(xSection,m_aValues);
253cdf0e10cSrcweir m_bInserted = true;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir //----------------------------------------------------------------------------
implReRemove()256cdf0e10cSrcweir void OReportSectionUndo::implReRemove( )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir if( m_eAction == Removed )
259cdf0e10cSrcweir collectControls(m_pMemberFunction(&m_aReportHelper));
260cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aArgs;
261cdf0e10cSrcweir m_pController->executeChecked(m_nSlot,aArgs);
262cdf0e10cSrcweir m_bInserted = false;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir //----------------------------------------------------------------------------
265cdf0e10cSrcweir TYPEINIT1( OGroupSectionUndo, OSectionUndo );
266cdf0e10cSrcweir //----------------------------------------------------------------------------
OGroupSectionUndo(OReportModel & _rMod,sal_uInt16 _nSlot,::std::mem_fun_t<uno::Reference<report::XSection>,OGroupHelper> _pMemberFunction,const uno::Reference<report::XGroup> & _xGroup,Action _eAction,sal_uInt16 nCommentID)267cdf0e10cSrcweir OGroupSectionUndo::OGroupSectionUndo(OReportModel& _rMod,sal_uInt16 _nSlot
268cdf0e10cSrcweir ,::std::mem_fun_t< uno::Reference< report::XSection >
269cdf0e10cSrcweir ,OGroupHelper> _pMemberFunction
270cdf0e10cSrcweir ,const uno::Reference< report::XGroup >& _xGroup
271cdf0e10cSrcweir ,Action _eAction
272cdf0e10cSrcweir ,sal_uInt16 nCommentID)
273cdf0e10cSrcweir : OSectionUndo(_rMod,_nSlot,_eAction,nCommentID)
274cdf0e10cSrcweir ,m_aGroupHelper(_xGroup)
275cdf0e10cSrcweir ,m_pMemberFunction(_pMemberFunction)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir if( m_eAction == Removed )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir uno::Reference< report::XSection > xSection = m_pMemberFunction(&m_aGroupHelper);
280cdf0e10cSrcweir if ( xSection.is() )
281cdf0e10cSrcweir m_sName = xSection->getName();
282cdf0e10cSrcweir collectControls(xSection);
283cdf0e10cSrcweir }
284cdf0e10cSrcweir }
285cdf0e10cSrcweir //----------------------------------------------------------------------------
GetComment() const286cdf0e10cSrcweir String OGroupSectionUndo::GetComment() const
287cdf0e10cSrcweir {
288cdf0e10cSrcweir if ( !m_sName.getLength() )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir try
291cdf0e10cSrcweir {
292cdf0e10cSrcweir uno::Reference< report::XSection > xSection = const_cast<OGroupSectionUndo*>(this)->m_pMemberFunction(&const_cast<OGroupSectionUndo*>(this)->m_aGroupHelper);
293cdf0e10cSrcweir
294cdf0e10cSrcweir if ( xSection.is() )
295cdf0e10cSrcweir m_sName = xSection->getName();
296cdf0e10cSrcweir }
297cdf0e10cSrcweir catch(uno::Exception&)
298cdf0e10cSrcweir {}
299cdf0e10cSrcweir }
300cdf0e10cSrcweir return m_strComment + m_sName;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir //----------------------------------------------------------------------------
implReInsert()303cdf0e10cSrcweir void OGroupSectionUndo::implReInsert( )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs(2);
306cdf0e10cSrcweir
307cdf0e10cSrcweir aArgs[0].Name = SID_GROUPHEADER_WITHOUT_UNDO == m_nSlot? PROPERTY_HEADERON : PROPERTY_FOOTERON;
308cdf0e10cSrcweir aArgs[0].Value <<= sal_True;
309cdf0e10cSrcweir aArgs[1].Name = PROPERTY_GROUP;
310cdf0e10cSrcweir aArgs[1].Value <<= m_aGroupHelper.getGroup();
311cdf0e10cSrcweir m_pController->executeChecked(m_nSlot,aArgs);
312cdf0e10cSrcweir
313cdf0e10cSrcweir uno::Reference< report::XSection > xSection = m_pMemberFunction(&m_aGroupHelper);
314cdf0e10cSrcweir lcl_insertElements(xSection,m_aControls);
315cdf0e10cSrcweir lcl_setValues(xSection,m_aValues);
316cdf0e10cSrcweir m_bInserted = true;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir //----------------------------------------------------------------------------
implReRemove()319cdf0e10cSrcweir void OGroupSectionUndo::implReRemove( )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir if( m_eAction == Removed )
322cdf0e10cSrcweir collectControls(m_pMemberFunction(&m_aGroupHelper));
323cdf0e10cSrcweir
324cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs(2);
325cdf0e10cSrcweir
326cdf0e10cSrcweir aArgs[0].Name = SID_GROUPHEADER_WITHOUT_UNDO == m_nSlot? PROPERTY_HEADERON : PROPERTY_FOOTERON;
327cdf0e10cSrcweir aArgs[0].Value <<= sal_False;
328cdf0e10cSrcweir aArgs[1].Name = PROPERTY_GROUP;
329cdf0e10cSrcweir aArgs[1].Value <<= m_aGroupHelper.getGroup();
330cdf0e10cSrcweir
331cdf0e10cSrcweir m_pController->executeChecked(m_nSlot,aArgs);
332cdf0e10cSrcweir m_bInserted = false;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir //----------------------------------------------------------------------------
335cdf0e10cSrcweir TYPEINIT1( OGroupUndo, OCommentUndoAction );
336cdf0e10cSrcweir //----------------------------------------------------------------------------
OGroupUndo(OReportModel & _rMod,sal_uInt16 nCommentID,Action _eAction,const uno::Reference<report::XGroup> & _xGroup,const uno::Reference<report::XReportDefinition> & _xReportDefinition)337cdf0e10cSrcweir OGroupUndo::OGroupUndo(OReportModel& _rMod
338cdf0e10cSrcweir ,sal_uInt16 nCommentID
339cdf0e10cSrcweir ,Action _eAction
340cdf0e10cSrcweir ,const uno::Reference< report::XGroup>& _xGroup
341cdf0e10cSrcweir ,const uno::Reference< report::XReportDefinition >& _xReportDefinition)
342cdf0e10cSrcweir : OCommentUndoAction(_rMod,nCommentID)
343cdf0e10cSrcweir ,m_xGroup(_xGroup)
344cdf0e10cSrcweir ,m_xReportDefinition(_xReportDefinition)
345cdf0e10cSrcweir ,m_eAction(_eAction)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir m_nLastPosition = getPositionInIndexAccess(m_xReportDefinition->getGroups().get(),m_xGroup);
348cdf0e10cSrcweir }
349cdf0e10cSrcweir //----------------------------------------------------------------------------
implReInsert()350cdf0e10cSrcweir void OGroupUndo::implReInsert( )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir try
353cdf0e10cSrcweir {
354cdf0e10cSrcweir m_xReportDefinition->getGroups()->insertByIndex(m_nLastPosition,uno::makeAny(m_xGroup));
355cdf0e10cSrcweir }
356cdf0e10cSrcweir catch(uno::Exception&)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir OSL_ENSURE(0,"Exception catched while undoing remove group");
359cdf0e10cSrcweir }
360cdf0e10cSrcweir }
361cdf0e10cSrcweir //----------------------------------------------------------------------------
implReRemove()362cdf0e10cSrcweir void OGroupUndo::implReRemove( )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir try
365cdf0e10cSrcweir {
366cdf0e10cSrcweir m_xReportDefinition->getGroups()->removeByIndex(m_nLastPosition);
367cdf0e10cSrcweir }
368cdf0e10cSrcweir catch(uno::Exception&)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir OSL_ENSURE(0,"Exception catched while redoing remove group");
371cdf0e10cSrcweir }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir //----------------------------------------------------------------------------
Undo()374cdf0e10cSrcweir void OGroupUndo::Undo()
375cdf0e10cSrcweir {
376cdf0e10cSrcweir switch ( m_eAction )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir case Inserted:
379cdf0e10cSrcweir implReRemove();
380cdf0e10cSrcweir break;
381cdf0e10cSrcweir
382cdf0e10cSrcweir case Removed:
383cdf0e10cSrcweir implReInsert();
384cdf0e10cSrcweir break;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir
387cdf0e10cSrcweir }
388cdf0e10cSrcweir //----------------------------------------------------------------------------
Redo()389cdf0e10cSrcweir void OGroupUndo::Redo()
390cdf0e10cSrcweir {
391cdf0e10cSrcweir switch ( m_eAction )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir case Inserted:
394cdf0e10cSrcweir implReInsert();
395cdf0e10cSrcweir break;
396cdf0e10cSrcweir
397cdf0e10cSrcweir case Removed:
398cdf0e10cSrcweir implReRemove();
399cdf0e10cSrcweir break;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir //----------------------------------------------------------------------------
403cdf0e10cSrcweir //============================================================================
404cdf0e10cSrcweir } // rptui
405cdf0e10cSrcweir //============================================================================
406cdf0e10cSrcweir
407cdf0e10cSrcweir
408