LibreOffice Module sw (master)  1
UndoDraw.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX
22 
23 #include <undobj.hxx>
24 #include <memory>
25 
26 struct SwUndoGroupObjImpl;
27 class SdrMark;
28 class SdrMarkList;
29 class SdrObject;
30 class SdrObjGroup;
31 class SdrUndoAction;
32 class SwDrawFrameFormat;
33 class SwDoc;
34 
35 // Undo for Draw Objects
36 class SwSdrUndo final : public SwUndo
37 {
38  std::unique_ptr<SdrUndoAction> m_pSdrUndo;
39  std::unique_ptr<SdrMarkList> m_pMarkList; // MarkList for all selected SdrObjects
40 
41 public:
42  SwSdrUndo(std::unique_ptr<SdrUndoAction>, const SdrMarkList* pMarkList, const SwDoc& rDoc);
43 
44  virtual ~SwSdrUndo() override;
45 
46  virtual void UndoImpl(::sw::UndoRedoContext&) override;
47  virtual void RedoImpl(::sw::UndoRedoContext&) override;
48 
49  virtual OUString GetComment() const override;
50 };
51 
52 class SwUndoDrawGroup final : public SwUndo
53 {
54  std::unique_ptr<SwUndoGroupObjImpl[]> m_pObjArray;
55  sal_uInt16 m_nSize;
57 
58 public:
59  SwUndoDrawGroup(sal_uInt16 nCnt, const SwDoc& rDoc);
60 
61  virtual ~SwUndoDrawGroup() override;
62 
63  virtual void UndoImpl(::sw::UndoRedoContext&) override;
64  virtual void RedoImpl(::sw::UndoRedoContext&) override;
65 
66  void AddObj(sal_uInt16 nPos, SwDrawFrameFormat*, SdrObject*);
68 };
69 
70 // Action "ungroup drawing object" is now split into three parts - see
71 // method <SwDoc::UnGroupSelection(..)>:
72 // - creation for <SwDrawFrameFormat> instances for the group members of the
73 // selected group objects
74 // - intrinsic ungroup of the selected group objects
75 // - creation of <SwDrawContact> instances for the former group members and
76 // connection to the Writer layout.
77 // Thus, two undo actions (instances of <SwUndo>) are needed:
78 // - Existing class <SwUndoDrawUnGroup> takes over the part for the formats.
79 // - New class <SwUndoDrawUnGroupConnectToLayout> takes over the part for
80 // contact object.
81 class SwUndoDrawUnGroup final : public SwUndo
82 {
83  std::unique_ptr<SwUndoGroupObjImpl[]> m_pObjArray;
84  sal_uInt16 m_nSize;
86 
87 public:
88  SwUndoDrawUnGroup(SdrObjGroup*, const SwDoc& rDoc);
89 
90  virtual ~SwUndoDrawUnGroup() override;
91 
92  virtual void UndoImpl(::sw::UndoRedoContext&) override;
93  virtual void RedoImpl(::sw::UndoRedoContext&) override;
94 
95  void AddObj(sal_uInt16 nPos, SwDrawFrameFormat*);
96 };
97 
99 {
100 private:
101  std::vector<std::pair<SwDrawFrameFormat*, SdrObject*>> m_aDrawFormatsAndObjs;
102 
103 public:
105 
106  virtual ~SwUndoDrawUnGroupConnectToLayout() override;
107 
108  virtual void UndoImpl(::sw::UndoRedoContext&) override;
109  virtual void RedoImpl(::sw::UndoRedoContext&) override;
110 
111  void AddFormatAndObj(SwDrawFrameFormat* pDrawFrameFormat, SdrObject* pDrawObject);
112 };
113 
114 class SwUndoDrawDelete final : public SwUndo
115 {
116  std::unique_ptr<SwUndoGroupObjImpl[]> m_pObjArray;
117  std::unique_ptr<SdrMarkList> m_pMarkList; // MarkList for all selected SdrObjects
119 
120 public:
121  SwUndoDrawDelete(sal_uInt16 nCnt, const SwDoc& rDoc);
122 
123  virtual ~SwUndoDrawDelete() override;
124 
125  virtual void UndoImpl(::sw::UndoRedoContext&) override;
126  virtual void RedoImpl(::sw::UndoRedoContext&) override;
127 
128  void AddObj(SwDrawFrameFormat*, const SdrMark&);
129  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
130 };
131 
132 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX
133 
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< SdrMarkList > m_pMarkList
Definition: UndoDraw.hxx:39
virtual ~SwUndoDrawUnGroupConnectToLayout() override
Definition: undraw.cxx:529
std::unique_ptr< SdrMarkList > m_pMarkList
Definition: UndoDraw.hxx:117
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *, SdrObject *)
Definition: undraw.cxx:329
Definition: doc.hxx:188
void AddFormatAndObj(SwDrawFrameFormat *pDrawFrameFormat, SdrObject *pDrawObject)
Definition: undraw.cxx:565
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: undraw.cxx:654
bool m_bDeleteFormat
Definition: UndoDraw.hxx:56
std::unique_ptr< SwUndoGroupObjImpl[]> m_pObjArray
Definition: UndoDraw.hxx:83
void SetGroupFormat(SwDrawFrameFormat *)
Definition: undraw.cxx:343
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:588
sal_uInt16 m_nSize
Definition: UndoDraw.hxx:84
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:88
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:534
SwUndoDrawGroup(sal_uInt16 nCnt, const SwDoc &rDoc)
Definition: undraw.cxx:171
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:189
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:553
std::vector< std::pair< SwDrawFrameFormat *, SdrObject * > > m_aDrawFormatsAndObjs
Definition: UndoDraw.hxx:101
void AddObj(SwDrawFrameFormat *, const SdrMark &)
Definition: undraw.cxx:636
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:614
virtual ~SwUndoDrawUnGroup() override
Definition: undraw.cxx:374
std::unique_ptr< SwUndoGroupObjImpl[]> m_pObjArray
Definition: UndoDraw.hxx:54
virtual ~SwUndoDrawDelete() override
Definition: undraw.cxx:578
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:261
virtual ~SwUndoDrawGroup() override
Definition: undraw.cxx:177
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *)
Definition: undraw.cxx:517
SwUndoDrawUnGroupConnectToLayout(const SwDoc &rDoc)
Definition: undraw.cxx:524
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undraw.cxx:94
std::unique_ptr< SwUndoGroupObjImpl[]> m_pObjArray
Definition: UndoDraw.hxx:116
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:82
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:386
virtual ~SwSdrUndo() override
Definition: undraw.cxx:76
struct _xmlTextWriter * xmlTextWriterPtr
sal_uInt16 m_nSize
Definition: UndoDraw.hxx:55
std::unique_ptr< SdrUndoAction > m_pSdrUndo
Definition: UndoDraw.hxx:38
SwUndoDrawDelete(sal_uInt16 nCnt, const SwDoc &rDoc)
Definition: undraw.cxx:571
SwUndoDrawUnGroup(SdrObjGroup *, const SwDoc &rDoc)
Definition: undraw.cxx:349
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:456
SwSdrUndo(std::unique_ptr< SdrUndoAction >, const SdrMarkList *pMarkList, const SwDoc &rDoc)
Definition: undraw.cxx:69