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 : public SwUndo
37 {
38  std::unique_ptr<SdrUndoAction> pSdrUndo;
39  std::unique_ptr<SdrMarkList> pMarkList; // MarkList for all selected SdrObjects
40 
41 public:
42  SwSdrUndo( std::unique_ptr<SdrUndoAction> , const SdrMarkList* pMarkList, const SwDoc* pDoc );
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 : public SwUndo
53 {
54  std::unique_ptr<SwUndoGroupObjImpl[]> pObjArr;
55  sal_uInt16 const nSize;
56  bool bDelFormat;
57 
58 public:
59  SwUndoDrawGroup( sal_uInt16 nCnt, const SwDoc* pDoc );
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 : public SwUndo
82 {
83  std::unique_ptr<SwUndoGroupObjImpl[]> pObjArr;
84  sal_uInt16 nSize;
85  bool bDelFormat;
86 
87 public:
88  SwUndoDrawUnGroup( SdrObjGroup*, const SwDoc* pDoc );
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* > > 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,
112  SdrObject* pDrawObject );
113 };
114 
115 class SwUndoDrawDelete : public SwUndo
116 {
117  std::unique_ptr<SwUndoGroupObjImpl[]> pObjArr;
118  std::unique_ptr<SdrMarkList> pMarkLst; // MarkList for all selected SdrObjects
120 
121 public:
122  SwUndoDrawDelete( sal_uInt16 nCnt, const SwDoc* pDoc );
123 
124  virtual ~SwUndoDrawDelete() override;
125 
126  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
127  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
128 
129  void AddObj( SwDrawFrameFormat*, const SdrMark& );
130 };
131 
132 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDODRAW_HXX
133 
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwUndoDrawUnGroupConnectToLayout(const SwDoc *pDoc)
Definition: undraw.cxx:429
virtual ~SwUndoDrawUnGroupConnectToLayout() override
Definition: undraw.cxx:434
std::unique_ptr< SdrMarkList > pMarkList
Definition: UndoDraw.hxx:39
std::unique_ptr< SwUndoGroupObjImpl[]> pObjArr
Definition: UndoDraw.hxx:83
std::vector< std::pair< SwDrawFrameFormat *, SdrObject * > > aDrawFormatsAndObjs
Definition: UndoDraw.hxx:101
std::unique_ptr< SdrUndoAction > pSdrUndo
Definition: UndoDraw.hxx:38
std::unique_ptr< SdrMarkList > pMarkLst
Definition: UndoDraw.hxx:118
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *, SdrObject *)
Definition: undraw.cxx:289
Definition: doc.hxx:185
void AddFormatAndObj(SwDrawFrameFormat *pDrawFrameFormat, SdrObject *pDrawObject)
Definition: undraw.cxx:470
void SetGroupFormat(SwDrawFrameFormat *)
Definition: undraw.cxx:304
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:493
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:91
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:439
SwUndoDrawGroup(sal_uInt16 nCnt, const SwDoc *pDoc)
Definition: undraw.cxx:179
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:197
sal_uInt16 nSize
Definition: UndoDraw.hxx:84
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:458
void AddObj(SwDrawFrameFormat *, const SdrMark &)
Definition: undraw.cxx:542
SwUndoDrawDelete(sal_uInt16 nCnt, const SwDoc *pDoc)
Definition: undraw.cxx:476
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:519
virtual ~SwUndoDrawUnGroup() override
Definition: undraw.cxx:336
virtual ~SwUndoDrawDelete() override
Definition: undraw.cxx:483
std::unique_ptr< SwUndoGroupObjImpl[]> pObjArr
Definition: UndoDraw.hxx:54
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:242
virtual ~SwUndoDrawGroup() override
Definition: undraw.cxx:185
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *)
Definition: undraw.cxx:422
SwUndoDrawUnGroup(SdrObjGroup *, const SwDoc *pDoc)
Definition: undraw.cxx:310
std::unique_ptr< SwUndoGroupObjImpl[]> pObjArr
Definition: UndoDraw.hxx:117
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undraw.cxx:97
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:85
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:348
virtual ~SwSdrUndo() override
Definition: undraw.cxx:79
SwSdrUndo(std::unique_ptr< SdrUndoAction >, const SdrMarkList *pMarkList, const SwDoc *pDoc)
Definition: undraw.cxx:72
sal_uInt16 const nSize
Definition: UndoDraw.hxx:55
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undraw.cxx:386