LibreOffice Module svx (master)  1
svdogrp.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 #pragma once
21 
22 #include <memory>
23 #include <svx/svdobj.hxx>
24 #include <svx/svxdllapi.h>
25 #include <svx/svdpage.hxx>
26 
27 // Forward declarations
28 class SfxItemSet;
29 class SdrObjGroup;
30 namespace svx
31 {
32 namespace diagram
33 {
34 class DiagramDataState;
35 }
36 }
37 
38 // Helper class to allow administer advanced Diagram related
39 // data and functionality
41 {
42 private:
43  // These values define behaviour to where take data from at re-creation time.
44  // Different definitions will have different consequences for re-creation
45  // of Diagram visualization (if needed/triggered).
46  // The style attributes per shape e.g. can be re-stored frm either an
47  // existing Theme, or the preserved key/value list of properties per XShape.
48  // With the current default settings the re-creation uses the preserved
49  // key/value pairs, but re-creation from Theme may also be desirable. It
50  // is also good to preserve both data packages at initial import to allow
51  // alternatively one of these two methods for re-construction
52 
53  // If true, the oox::Theme data from ::DiagramData get/set/ThemeDocument()
54  // aka mxThemeDocument - if it exists - will be used to create the style
55  // attributes for the to-be-created XShapes (theoretically allows re-creation
56  // with other Theme)
57  bool mbUseDiagramThemeData; // false
58 
59  // If true, the UNO API form of attributes per Point as Key/value list
60  // that was secured after initial XShape creation is used to create the
61  // style attributes for the to-be-created XShapes
62  bool mbUseDiagramModelData; // true
63 
64  // If true and mxThemeDocument exists it will be re-imported to
65  // a newly created oox::drawingml::Theme object
67 
68 protected:
69  void anchorToSdrObjGroup(SdrObjGroup& rTarget);
70 
71 public:
73  virtual ~IDiagramHelper();
74 
75  // re-create XShapes
76  virtual void reLayout(SdrObjGroup& rTarget) = 0;
77 
78  // get text representation of data tree
79  virtual OUString getString() const = 0;
80 
81  // get children of provided data node
82  // use empty string for top-level nodes
83  // returns vector of (id, text)
84  virtual std::vector<std::pair<OUString, OUString>>
85  getChildren(const OUString& rParentId) const = 0;
86 
87  // add/remove new top-level node to data model, returns its id
88  virtual OUString addNode(const OUString& rText) = 0;
89  virtual bool removeNode(const OUString& rNodeId) = 0;
90 
91  // Undo/Redo helpers for extracting/restoring Diagram-defining data
92  virtual std::shared_ptr<svx::diagram::DiagramDataState> extractDiagramDataState() const = 0;
93  virtual void
94  applyDiagramDataState(const std::shared_ptr<svx::diagram::DiagramDataState>& rState)
95  = 0;
96 
97  bool UseDiagramThemeData() const { return mbUseDiagramThemeData; }
98  bool UseDiagramModelData() const { return mbUseDiagramModelData; }
99  bool ForceThemePtrRecreation() const { return mbForceThemePtrRecreation; };
100 };
101 
102 // SdrObjGroup
103 class SVXCORE_DLLPUBLIC SdrObjGroup final : public SdrObject, public SdrObjList
104 {
105 private:
106  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
107  virtual std::unique_ptr<sdr::properties::BaseProperties>
109 
110  Point maRefPoint; // Reference point inside the object group
111 
112  // Allow *only* DiagramHelper itself to set this internal reference to
113  // tightly control usage
114  friend class IDiagramHelper;
115  std::shared_ptr<IDiagramHelper> mp_DiagramHelper;
116 
117 public:
118  bool isDiagram() const { return bool(mp_DiagramHelper); }
119  const std::shared_ptr<IDiagramHelper>& getDiagramHelper() { return mp_DiagramHelper; }
120 
121 private:
122  // protected destructor - due to final, make private
123  virtual ~SdrObjGroup() override;
124 
125 public:
126  SdrObjGroup(SdrModel& rSdrModel);
127  // Copy constructor
128  SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const& rSource);
129 
130  // derived from SdrObjList
131  virtual SdrPage* getSdrPageFromSdrObjList() const override;
132  virtual SdrObject* getSdrObjectFromSdrObjList() const override;
133 
134  // derived from SdrObject
135  virtual SdrObjList* getChildrenOfSdrObject() const override;
136 
137  virtual void SetBoundRectDirty() override;
138  virtual SdrObjKind GetObjIdentifier() const override;
139  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
140  virtual SdrLayerID GetLayer() const override;
141  virtual void NbcSetLayer(SdrLayerID nLayer) override;
142 
143  // react on model/page change
144  virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
145 
146  virtual SdrObjList* GetSubList() const override;
147  virtual void SetGrabBagItem(const css::uno::Any& rVal) override;
148 
149  virtual const tools::Rectangle& GetCurrentBoundRect() const override;
150  virtual const tools::Rectangle& GetSnapRect() const override;
151 
152  virtual SdrObjGroup* CloneSdrObject(SdrModel& rTargetModel) const override;
153 
154  virtual OUString TakeObjNameSingul() const override;
155  virtual OUString TakeObjNamePlural() const override;
156 
157  virtual void RecalcSnapRect() override;
158  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
159 
160  // special drag methods
161  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
162 
163  virtual bool BegCreate(SdrDragStat& rStat) override;
164 
165  virtual Degree100 GetRotateAngle() const override;
166  virtual Degree100 GetShearAngle(bool bVertical = false) const override;
167 
168  virtual void Move(const Size& rSiz) override;
169  virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact,
170  bool bUnsetRelative = true) override;
171  virtual void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
172  virtual void Mirror(const Point& rRef1, const Point& rRef2) override;
173  virtual void Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
174  virtual void SetAnchorPos(const Point& rPnt) override;
175  virtual void SetRelativePos(const Point& rPnt) override;
176  virtual void SetSnapRect(const tools::Rectangle& rRect) override;
177  virtual void SetLogicRect(const tools::Rectangle& rRect) override;
178 
179  virtual void NbcMove(const Size& rSiz) override;
180  virtual void NbcResize(const Point& rRef, const Fraction& xFact,
181  const Fraction& yFact) override;
182  virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
183  virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
184  virtual void NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
185  virtual void NbcSetAnchorPos(const Point& rPnt) override;
186  virtual void NbcSetRelativePos(const Point& rPnt) override;
187  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
188  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
189 
190  virtual void NbcReformatText() override;
191 
192  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
193 
194  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
195 };
196 
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
The Xor-Polygon is required by the View to drag the object.
Definition: svdobj.cxx:1119
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const
Definition: svdobj.cxx:654
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:949
virtual bool BegCreate(SdrDragStat &rStat)
Every object must be able to create itself interactively.
Definition: svdobj.cxx:1374
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true)
Definition: svdobj.cxx:1546
struct _xmlTextWriter * xmlTextWriterPtr
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage)
Definition: svdobj.cxx:524
virtual SdrObjList * getChildrenOfSdrObject() const
Definition: svdobj.cxx:310
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
Definition: svdobj.cxx:1433
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:1463
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties()
Definition: svdobj.cxx:205
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const
Definition: svdobj.cxx:2638
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1522
virtual void SetBoundRectDirty()
Definition: svdobj.cxx:316
virtual OUString TakeObjNameSingul() const
Definition: svdobj.cxx:1075
virtual SdrObjKind GetObjIdentifier() const
Definition: svdobj.cxx:649
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:738
virtual void SetGrabBagItem(const css::uno::Any &rVal)
Definition: svdobj.cxx:917
virtual const tools::Rectangle & GetSnapRect() const
Definition: svdobj.cxx:1660
SdrObjKind
Definition: svdobjkind.hxx:24
Provides information about various ZObject properties.
Definition: svdobj.hxx:195
virtual void SetAnchorPos(const Point &rPnt)
Definition: svdobj.cxx:1640
const std::shared_ptr< IDiagramHelper > & getDiagramHelper()
Definition: svdogrp.hxx:119
virtual void RecalcSnapRect()
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdobj.cxx:1656
Point maRefPoint
Definition: svdogrp.hxx:110
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdpage.cxx:1099
virtual void NbcMirror(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:1491
virtual Degree100 GetShearAngle(bool bVertical=false) const
Definition: svdobj.cxx:1708
bool isDiagram() const
Definition: svdogrp.hxx:118
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1694
virtual void Move(const Size &rSiz)
Definition: svdobj.cxx:1529
virtual void SetRelativePos(const Point &rPnt)
Definition: svdobj.cxx:1612
Abstract DrawObject.
Definition: svdobj.hxx:259
virtual void Mirror(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:1585
virtual SdrLayerID GetLayer() const
Definition: svdobj.cxx:668
bool mbUseDiagramModelData
Definition: svdogrp.hxx:62
bool mbForceThemePtrRecreation
Definition: svdogrp.hxx:66
virtual void NbcReformatText()
Definition: svdobj.cxx:1836
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact()
Definition: svdobj.cxx:246
virtual void NbcSetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1665
bool UseDiagramThemeData() const
Definition: svdogrp.hxx:97
virtual void NbcSetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1675
virtual void NbcMove(const Size &rSiz)
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdobj.cxx:1427
bool mbUseDiagramThemeData
Definition: svdogrp.hxx:57
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
Definition: svdobj.cxx:1070
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:117
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:97
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1338
virtual OUString TakeObjNamePlural() const
Definition: svdobj.cxx:1085
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:1574
virtual void SetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1685
bool UseDiagramModelData() const
Definition: svdogrp.hxx:98
virtual void NbcSetAnchorPos(const Point &rPnt)
Definition: svdobj.cxx:1633
virtual Degree100 GetRotateAngle() const
Definition: svdobj.cxx:1703
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:373
OUString getString(const Any &_rAny)
virtual void NbcSetRelativePos(const Point &rPnt)
The relative position of a SdrObject is the distance of the upper left corner of the logic bounding r...
Definition: svdobj.cxx:1605
std::shared_ptr< IDiagramHelper > mp_DiagramHelper
Definition: svdogrp.hxx:115
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:123
virtual void NbcSetLayer(SdrLayerID nLayer)
Definition: svdobj.cxx:685
bool ForceThemePtrRecreation() const
Definition: svdogrp.hxx:99