1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #include "precompiled_reportdesign.hxx"
24 #include "ReportUndoFactory.hxx"
25 #include "RptObject.hxx"
26 #include "UndoActions.hxx"
27 #include "RptResId.hrc"
28
29 namespace rptui
30 {
31 using namespace ::com::sun::star;
32 // -----------------------------------------------------------------------------
lcl_createUndo(SdrObject & rObject,Action _eAction,sal_uInt16 _nCommentId)33 SdrUndoAction* lcl_createUndo(SdrObject& rObject,Action _eAction,sal_uInt16 _nCommentId)
34 {
35 OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject);
36 if ( !pObj )
37 return NULL;
38 uno::Reference< report::XReportComponent> xReportComponent = pObj->getReportComponent();
39 uno::Reference< report::XSection> xSection = pObj->getSection();
40 uno::Reference< report::XGroup> xGroup = xSection->getGroup();
41 SdrUndoAction* pUndo = NULL;
42 if ( xGroup.is() )
43 pUndo = new OUndoGroupSectionAction(*rObject.GetModel(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,_nCommentId);
44 else
45 pUndo = new OUndoReportSectionAction(*rObject.GetModel(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,_nCommentId);
46 return pUndo;
47 }
48 // -----------------------------------------------------------------------------
DBG_NAME(rpt_OReportUndoFactory)49 DBG_NAME( rpt_OReportUndoFactory )
50 // -----------------------------------------------------------------------------
51 OReportUndoFactory::OReportUndoFactory() : m_pUndoFactory(new SdrUndoFactory)
52 {
53 DBG_CTOR( rpt_OReportUndoFactory,NULL);
54 }
55 // -----------------------------------------------------------------------------
~OReportUndoFactory()56 OReportUndoFactory::~OReportUndoFactory()
57 {
58 DBG_DTOR( rpt_OReportUndoFactory,NULL);
59 }
60 ///////////////////////////////////////////////////////////////////////
61 // shapes
CreateUndoMoveObject(SdrObject & rObject)62 SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject )
63 {
64 return m_pUndoFactory->CreateUndoMoveObject( rObject );
65 }
66
CreateUndoMoveObject(SdrObject & rObject,const Size & rDist)67 SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
68 {
69 return m_pUndoFactory->CreateUndoMoveObject( rObject, rDist );
70 }
71
CreateUndoGeoObject(SdrObject & rObject)72 SdrUndoAction* OReportUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
73 {
74 return m_pUndoFactory->CreateUndoGeoObject( rObject );
75 }
76
CreateUndoAttrObject(SdrObject & rObject,bool bStyleSheet1,bool bSaveText)77 SdrUndoAction* OReportUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
78 {
79 return m_pUndoFactory->CreateUndoAttrObject( rObject, bStyleSheet1 ? sal_True : sal_False, bSaveText ? sal_True : sal_False );
80 }
81
CreateUndoRemoveObject(SdrObject & rObject,bool bOrdNumDirect)82 SdrUndoAction* OReportUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
83 {
84 return m_pUndoFactory->CreateUndoRemoveObject( rObject, bOrdNumDirect ? sal_True : sal_False );
85 }
86
CreateUndoInsertObject(SdrObject & rObject,bool)87 SdrUndoAction* OReportUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
88 {
89 return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
90 }
91
CreateUndoDeleteObject(SdrObject & rObject,bool)92 SdrUndoAction* OReportUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
93 {
94 return lcl_createUndo(rObject,rptui::Removed,RID_STR_UNDO_DELETE_CONTROL);
95 //return m_pUndoFactory->CreateUndoDeleteObject( rObject, bOrdNumDirect ? sal_True : sal_False );
96 }
97
CreateUndoNewObject(SdrObject & rObject,bool)98 SdrUndoAction* OReportUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
99 {
100 return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
101 }
102
CreateUndoCopyObject(SdrObject & rObject,bool bOrdNumDirect)103 SdrUndoAction* OReportUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
104 {
105 return m_pUndoFactory->CreateUndoCopyObject( rObject, bOrdNumDirect ? sal_True : sal_False );
106 }
107
CreateUndoObjectOrdNum(SdrObject & rObject,sal_uInt32 nOldOrdNum1,sal_uInt32 nNewOrdNum1)108 SdrUndoAction* OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
109 {
110 return m_pUndoFactory->CreateUndoObjectOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 );
111 }
112
CreateUndoReplaceObject(SdrObject & rOldObject,SdrObject & rNewObject,bool bOrdNumDirect)113 SdrUndoAction* OReportUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
114 {
115 return m_pUndoFactory->CreateUndoReplaceObject( rOldObject, rNewObject, bOrdNumDirect ? sal_True : sal_False );
116 }
117
CreateUndoObjectLayerChange(SdrObject & rObject,SdrLayerID aOldLayer,SdrLayerID aNewLayer)118 SdrUndoAction* OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
119 {
120 return m_pUndoFactory->CreateUndoObjectLayerChange( rObject, aOldLayer, aNewLayer );
121 }
122
CreateUndoObjectSetText(SdrObject & rNewObj,sal_Int32 nText)123 SdrUndoAction* OReportUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
124 {
125 return m_pUndoFactory->CreateUndoObjectSetText( rNewObj, nText );
126 }
127
128 // layer
CreateUndoNewLayer(sal_uInt16 nLayerNum,SdrLayerAdmin & rNewLayerAdmin,SdrModel & rNewModel)129 SdrUndoAction* OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
130 {
131 return m_pUndoFactory->CreateUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel );
132 }
133
CreateUndoDeleteLayer(sal_uInt16 nLayerNum,SdrLayerAdmin & rNewLayerAdmin,SdrModel & rNewModel)134 SdrUndoAction* OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
135 {
136 return m_pUndoFactory->CreateUndoDeleteLayer( nLayerNum, rNewLayerAdmin, rNewModel );
137 }
138
CreateUndoMoveLayer(sal_uInt16 nLayerNum,SdrLayerAdmin & rNewLayerAdmin,SdrModel & rNewModel,sal_uInt16 nNeuPos1)139 SdrUndoAction* OReportUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1)
140 {
141 return m_pUndoFactory->CreateUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 );
142 }
143
144 // page
CreateUndoDeletePage(SdrPage & rPage)145 SdrUndoAction* OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
146 {
147 return m_pUndoFactory->CreateUndoDeletePage( rPage );
148 }
149
CreateUndoNewPage(SdrPage & rPage)150 SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)
151 {
152 return m_pUndoFactory->CreateUndoNewPage( rPage );
153 }
154
CreateUndoCopyPage(SdrPage & rPage)155 SdrUndoAction* OReportUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
156 {
157 return m_pUndoFactory->CreateUndoCopyPage( rPage );
158 }
159
CreateUndoSetPageNum(SdrPage & rNewPg,sal_uInt16 nOldPageNum1,sal_uInt16 nNewPageNum1)160 SdrUndoAction* OReportUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
161 {
162 return m_pUndoFactory->CreateUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 );
163 }
164 // master page
CreateUndoPageRemoveMasterPage(SdrPage & rChangedPage)165 SdrUndoAction* OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
166 {
167 return m_pUndoFactory->CreateUndoPageRemoveMasterPage( rChangedPage );
168 }
169
CreateUndoPageChangeMasterPage(SdrPage & rChangedPage)170 SdrUndoAction* OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
171 {
172 return m_pUndoFactory->CreateUndoPageChangeMasterPage(rChangedPage);
173 }
174
175 //==================================================================
176 } //rptui
177 //==================================================================
178
179