1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <ReportUndoFactory.hxx>
20 #include <RptObject.hxx>
21 #include <UndoActions.hxx>
22 #include <strings.hrc>
23 #include <o3tl/make_unique.hxx>
27 using namespace ::com::sun::star
;
29 static std::unique_ptr
<SdrUndoAction
> lcl_createUndo(SdrObject
& rObject
, Action _eAction
, const char* pCommentId
)
31 OObjectBase
* pObj
= dynamic_cast<OObjectBase
*>(&rObject
);
34 uno::Reference
< report::XReportComponent
> xReportComponent
= pObj
->getReportComponent();
35 uno::Reference
< report::XSection
> xSection
= pObj
->getSection();
36 uno::Reference
< report::XGroup
> xGroup
= xSection
->getGroup();
38 return o3tl::make_unique
<OUndoGroupSectionAction
>(rObject
.getSdrModelFromSdrObject(),_eAction
,OGroupHelper::getMemberFunction(xSection
),xGroup
,xReportComponent
,pCommentId
);
40 return o3tl::make_unique
<OUndoReportSectionAction
>(rObject
.getSdrModelFromSdrObject(),_eAction
,OReportHelper::getMemberFunction(xSection
),xSection
->getReportDefinition(),xReportComponent
,pCommentId
);
44 OReportUndoFactory::OReportUndoFactory() : m_pUndoFactory(new SdrUndoFactory
)
48 OReportUndoFactory::~OReportUndoFactory()
52 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoMoveObject( SdrObject
& rObject
, const Size
& rDist
)
54 return m_pUndoFactory
->CreateUndoMoveObject( rObject
, rDist
);
57 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoGeoObject( SdrObject
& rObject
)
59 return m_pUndoFactory
->CreateUndoGeoObject( rObject
);
62 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoAttrObject( SdrObject
& rObject
, bool bStyleSheet1
, bool bSaveText
)
64 return m_pUndoFactory
->CreateUndoAttrObject( rObject
, bStyleSheet1
, bSaveText
);
67 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoRemoveObject( SdrObject
& rObject
, bool bOrdNumDirect
)
69 return m_pUndoFactory
->CreateUndoRemoveObject( rObject
, bOrdNumDirect
);
72 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoInsertObject( SdrObject
& rObject
, bool /*bOrdNumDirect*/ )
74 return lcl_createUndo(rObject
,rptui::Inserted
,RID_STR_UNDO_INSERT_CONTROL
);
77 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoDeleteObject( SdrObject
& rObject
, bool /*bOrdNumDirect*/ )
79 return lcl_createUndo(rObject
,rptui::Removed
,RID_STR_UNDO_DELETE_CONTROL
);
82 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoNewObject( SdrObject
& rObject
, bool /*bOrdNumDirect*/ )
84 return lcl_createUndo(rObject
,rptui::Inserted
,RID_STR_UNDO_INSERT_CONTROL
);
87 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoCopyObject( SdrObject
& rObject
, bool bOrdNumDirect
)
89 return m_pUndoFactory
->CreateUndoCopyObject( rObject
, bOrdNumDirect
);
92 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject
& rObject
, sal_uInt32 nOldOrdNum1
, sal_uInt32 nNewOrdNum1
)
94 return m_pUndoFactory
->CreateUndoObjectOrdNum( rObject
, nOldOrdNum1
, nNewOrdNum1
);
97 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoReplaceObject( SdrObject
& rOldObject
, SdrObject
& rNewObject
, bool bOrdNumDirect
)
99 return m_pUndoFactory
->CreateUndoReplaceObject( rOldObject
, rNewObject
, bOrdNumDirect
);
102 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject
& rObject
, SdrLayerID aOldLayer
, SdrLayerID aNewLayer
)
104 return m_pUndoFactory
->CreateUndoObjectLayerChange( rObject
, aOldLayer
, aNewLayer
);
107 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoObjectSetText( SdrObject
& rNewObj
, sal_Int32 nText
)
109 return m_pUndoFactory
->CreateUndoObjectSetText( rNewObj
, nText
);
113 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum
, SdrLayerAdmin
& rNewLayerAdmin
, SdrModel
& rNewModel
)
115 return m_pUndoFactory
->CreateUndoNewLayer( nLayerNum
, rNewLayerAdmin
, rNewModel
);
118 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum
, SdrLayerAdmin
& rNewLayerAdmin
, SdrModel
& rNewModel
)
120 return m_pUndoFactory
->CreateUndoDeleteLayer( nLayerNum
, rNewLayerAdmin
, rNewModel
);
124 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoDeletePage(SdrPage
& rPage
)
126 return m_pUndoFactory
->CreateUndoDeletePage(rPage
);
129 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoNewPage(SdrPage
& rPage
)
131 return m_pUndoFactory
->CreateUndoNewPage( rPage
);
134 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoCopyPage(SdrPage
& rPage
)
136 return m_pUndoFactory
->CreateUndoCopyPage( rPage
);
139 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoSetPageNum(SdrPage
& rNewPg
, sal_uInt16 nOldPageNum1
, sal_uInt16 nNewPageNum1
)
141 return m_pUndoFactory
->CreateUndoSetPageNum( rNewPg
, nOldPageNum1
, nNewPageNum1
);
144 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage
& rChangedPage
)
146 return m_pUndoFactory
->CreateUndoPageRemoveMasterPage( rChangedPage
);
149 std::unique_ptr
<SdrUndoAction
> OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage
& rChangedPage
)
151 return m_pUndoFactory
->CreateUndoPageChangeMasterPage(rChangedPage
);
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */