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 "ReportUndoFactory.hxx"
24 #include "RptObject.hxx"
25 #include "UndoActions.hxx"
26 #include "RptResId.hrc"
27 
28 namespace rptui
29 {
30     using namespace ::com::sun::star;
31 // -----------------------------------------------------------------------------
lcl_createUndo(SdrObject & rObject,Action _eAction,sal_uInt16 _nCommentId)32 SdrUndoAction* lcl_createUndo(SdrObject& rObject,Action _eAction,sal_uInt16 _nCommentId)
33 {
34     OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject);
35     if ( !pObj )
36         return NULL;
37     uno::Reference< report::XReportComponent> xReportComponent = pObj->getReportComponent();
38     uno::Reference< report::XSection> xSection = pObj->getSection();
39     uno::Reference< report::XGroup> xGroup = xSection->getGroup();
40     SdrUndoAction* pUndo = NULL;
41     if ( xGroup.is() )
42         pUndo = new OUndoGroupSectionAction(*rObject.GetModel(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,_nCommentId);
43     else
44         pUndo = new OUndoReportSectionAction(*rObject.GetModel(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,_nCommentId);
45     return pUndo;
46 }
47 // -----------------------------------------------------------------------------
DBG_NAME(rpt_OReportUndoFactory)48 DBG_NAME( rpt_OReportUndoFactory )
49 // -----------------------------------------------------------------------------
50 OReportUndoFactory::OReportUndoFactory() : m_pUndoFactory(new SdrUndoFactory)
51 {
52     DBG_CTOR( rpt_OReportUndoFactory,NULL);
53 }
54 // -----------------------------------------------------------------------------
~OReportUndoFactory()55 OReportUndoFactory::~OReportUndoFactory()
56 {
57     DBG_DTOR( rpt_OReportUndoFactory,NULL);
58 }
59 ///////////////////////////////////////////////////////////////////////
60 // shapes
CreateUndoMoveObject(SdrObject & rObject)61 SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject )
62 {
63 	return m_pUndoFactory->CreateUndoMoveObject( rObject );
64 }
65 
CreateUndoMoveObject(SdrObject & rObject,const Size & rDist)66 SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
67 {
68 	return m_pUndoFactory->CreateUndoMoveObject( rObject, rDist );
69 }
70 
CreateUndoGeoObject(SdrObject & rObject)71 SdrUndoAction* OReportUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
72 {
73 	return m_pUndoFactory->CreateUndoGeoObject( rObject );
74 }
75 
CreateUndoAttrObject(SdrObject & rObject,bool bStyleSheet1,bool bSaveText)76 SdrUndoAction* OReportUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
77 {
78 	return m_pUndoFactory->CreateUndoAttrObject( rObject, bStyleSheet1 ? sal_True : sal_False, bSaveText ? sal_True : sal_False );
79 }
80 
CreateUndoRemoveObject(SdrObject & rObject,bool bOrdNumDirect)81 SdrUndoAction* OReportUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
82 {
83 	return m_pUndoFactory->CreateUndoRemoveObject( rObject, bOrdNumDirect ? sal_True : sal_False );
84 }
85 
CreateUndoInsertObject(SdrObject & rObject,bool)86 SdrUndoAction* OReportUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
87 {
88     return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
89 }
90 
CreateUndoDeleteObject(SdrObject & rObject,bool)91 SdrUndoAction* OReportUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
92 {
93     return lcl_createUndo(rObject,rptui::Removed,RID_STR_UNDO_DELETE_CONTROL);
94 	//return m_pUndoFactory->CreateUndoDeleteObject( rObject, bOrdNumDirect ? sal_True : sal_False );
95 }
96 
CreateUndoNewObject(SdrObject & rObject,bool)97 SdrUndoAction* OReportUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
98 {
99 	return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
100 }
101 
CreateUndoCopyObject(SdrObject & rObject,bool bOrdNumDirect)102 SdrUndoAction* OReportUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
103 {
104 	return m_pUndoFactory->CreateUndoCopyObject( rObject, bOrdNumDirect ? sal_True : sal_False );
105 }
106 
CreateUndoObjectOrdNum(SdrObject & rObject,sal_uInt32 nOldOrdNum1,sal_uInt32 nNewOrdNum1)107 SdrUndoAction* OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
108 {
109 	return m_pUndoFactory->CreateUndoObjectOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 );
110 }
111 
CreateUndoReplaceObject(SdrObject & rOldObject,SdrObject & rNewObject,bool bOrdNumDirect)112 SdrUndoAction* OReportUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
113 {
114 	return m_pUndoFactory->CreateUndoReplaceObject( rOldObject, rNewObject, bOrdNumDirect ? sal_True : sal_False );
115 }
116 
CreateUndoObjectLayerChange(SdrObject & rObject,SdrLayerID aOldLayer,SdrLayerID aNewLayer)117 SdrUndoAction* OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
118 {
119 	return m_pUndoFactory->CreateUndoObjectLayerChange( rObject, aOldLayer, aNewLayer );
120 }
121 
CreateUndoObjectSetText(SdrObject & rNewObj,sal_Int32 nText)122 SdrUndoAction* OReportUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
123 {
124 	return m_pUndoFactory->CreateUndoObjectSetText( rNewObj, nText );
125 }
126 
127 // layer
CreateUndoNewLayer(sal_uInt16 nLayerNum,SdrLayerAdmin & rNewLayerAdmin,SdrModel & rNewModel)128 SdrUndoAction* OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
129 {
130 	return m_pUndoFactory->CreateUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel );
131 }
132 
CreateUndoDeleteLayer(sal_uInt16 nLayerNum,SdrLayerAdmin & rNewLayerAdmin,SdrModel & rNewModel)133 SdrUndoAction* OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
134 {
135 	return m_pUndoFactory->CreateUndoDeleteLayer( nLayerNum, rNewLayerAdmin, rNewModel );
136 }
137 
CreateUndoMoveLayer(sal_uInt16 nLayerNum,SdrLayerAdmin & rNewLayerAdmin,SdrModel & rNewModel,sal_uInt16 nNeuPos1)138 SdrUndoAction* OReportUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1)
139 {
140 	return m_pUndoFactory->CreateUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 );
141 }
142 
143 // page
CreateUndoDeletePage(SdrPage & rPage)144 SdrUndoAction*	OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
145 {
146 	return m_pUndoFactory->CreateUndoDeletePage( rPage );
147 }
148 
CreateUndoNewPage(SdrPage & rPage)149 SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)
150 {
151 	return m_pUndoFactory->CreateUndoNewPage( rPage );
152 }
153 
CreateUndoCopyPage(SdrPage & rPage)154 SdrUndoAction* OReportUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
155 {
156 	return m_pUndoFactory->CreateUndoCopyPage( rPage );
157 }
158 
CreateUndoSetPageNum(SdrPage & rNewPg,sal_uInt16 nOldPageNum1,sal_uInt16 nNewPageNum1)159 SdrUndoAction* OReportUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
160 {
161 	return m_pUndoFactory->CreateUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 );
162 }
163 	// master page
CreateUndoPageRemoveMasterPage(SdrPage & rChangedPage)164 SdrUndoAction* OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
165 {
166 	return m_pUndoFactory->CreateUndoPageRemoveMasterPage( rChangedPage );
167 }
168 
CreateUndoPageChangeMasterPage(SdrPage & rChangedPage)169 SdrUndoAction* OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
170 {
171 	return m_pUndoFactory->CreateUndoPageChangeMasterPage(rChangedPage);
172 }
173 
174 //==================================================================
175 }	//rptui
176 //==================================================================
177 
178