Update ooo320-m1
[ooovba.git] / reportdesign / source / core / sdr / ReportUndoFactory.cxx
blob85e174c54f21b51e631b0c2280a4efcc3e8f13a3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ReportUndoFactory.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "ReportUndoFactory.hxx"
31 #include "RptObject.hxx"
32 #include "UndoActions.hxx"
33 #include "RptResId.hrc"
35 namespace rptui
37 using namespace ::com::sun::star;
38 // -----------------------------------------------------------------------------
39 SdrUndoAction* lcl_createUndo(SdrObject& rObject,Action _eAction,USHORT _nCommentId)
41 OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject);
42 if ( !pObj )
43 return NULL;
44 uno::Reference< report::XReportComponent> xReportComponent = pObj->getReportComponent();
45 uno::Reference< report::XSection> xSection = pObj->getSection();
46 uno::Reference< report::XGroup> xGroup = xSection->getGroup();
47 SdrUndoAction* pUndo = NULL;
48 if ( xGroup.is() )
49 pUndo = new OUndoGroupSectionAction(*rObject.GetModel(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,_nCommentId);
50 else
51 pUndo = new OUndoReportSectionAction(*rObject.GetModel(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,_nCommentId);
52 return pUndo;
54 // -----------------------------------------------------------------------------
55 DBG_NAME( rpt_OReportUndoFactory )
56 // -----------------------------------------------------------------------------
57 OReportUndoFactory::OReportUndoFactory() : m_pUndoFactory(new SdrUndoFactory)
59 DBG_CTOR( rpt_OReportUndoFactory,NULL);
61 // -----------------------------------------------------------------------------
62 OReportUndoFactory::~OReportUndoFactory()
64 DBG_DTOR( rpt_OReportUndoFactory,NULL);
66 ///////////////////////////////////////////////////////////////////////
67 // shapes
68 SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject )
70 return m_pUndoFactory->CreateUndoMoveObject( rObject );
73 SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
75 return m_pUndoFactory->CreateUndoMoveObject( rObject, rDist );
78 SdrUndoAction* OReportUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
80 return m_pUndoFactory->CreateUndoGeoObject( rObject );
83 SdrUndoAction* OReportUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
85 return m_pUndoFactory->CreateUndoAttrObject( rObject, bStyleSheet1 ? TRUE : FALSE, bSaveText ? TRUE : FALSE );
88 SdrUndoAction* OReportUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
90 return m_pUndoFactory->CreateUndoRemoveObject( rObject, bOrdNumDirect ? TRUE : FALSE );
93 SdrUndoAction* OReportUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
95 return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
98 SdrUndoAction* OReportUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
100 return lcl_createUndo(rObject,rptui::Removed,RID_STR_UNDO_DELETE_CONTROL);
101 //return m_pUndoFactory->CreateUndoDeleteObject( rObject, bOrdNumDirect ? TRUE : FALSE );
104 SdrUndoAction* OReportUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
106 return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
109 SdrUndoAction* OReportUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
111 return m_pUndoFactory->CreateUndoCopyObject( rObject, bOrdNumDirect ? TRUE : FALSE );
114 SdrUndoAction* OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
116 return m_pUndoFactory->CreateUndoObjectOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 );
119 SdrUndoAction* OReportUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
121 return m_pUndoFactory->CreateUndoReplaceObject( rOldObject, rNewObject, bOrdNumDirect ? TRUE : FALSE );
124 SdrUndoAction* OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
126 return m_pUndoFactory->CreateUndoObjectLayerChange( rObject, aOldLayer, aNewLayer );
129 SdrUndoAction* OReportUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
131 return m_pUndoFactory->CreateUndoObjectSetText( rNewObj, nText );
134 // layer
135 SdrUndoAction* OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
137 return m_pUndoFactory->CreateUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel );
140 SdrUndoAction* OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
142 return m_pUndoFactory->CreateUndoDeleteLayer( nLayerNum, rNewLayerAdmin, rNewModel );
145 SdrUndoAction* OReportUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1)
147 return m_pUndoFactory->CreateUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 );
150 // page
151 SdrUndoAction* OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
153 return m_pUndoFactory->CreateUndoDeletePage( rPage );
156 SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)
158 return m_pUndoFactory->CreateUndoNewPage( rPage );
161 SdrUndoAction* OReportUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
163 return m_pUndoFactory->CreateUndoCopyPage( rPage );
166 SdrUndoAction* OReportUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
168 return m_pUndoFactory->CreateUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 );
170 // master page
171 SdrUndoAction* OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
173 return m_pUndoFactory->CreateUndoPageRemoveMasterPage( rChangedPage );
176 SdrUndoAction* OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
178 return m_pUndoFactory->CreateUndoPageChangeMasterPage(rChangedPage);
181 //==================================================================
182 } //rptui
183 //==================================================================