LibreOffice Module svx (master)  1
properties.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_SVX_SDR_PROPERTIES_PROPERTIES_HXX
21 #define INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
22 
23 #include <sal/config.h>
24 
25 #include <memory>
26 
27 #include <sal/types.h>
28 #include <svx/svxdllapi.h>
29 #include <svl/typedwhich.hxx>
30 
31 struct _xmlTextWriter;
32 typedef struct _xmlTextWriter* xmlTextWriterPtr;
33 class SdrObject;
34 class SfxItemSet;
35 class SfxPoolItem;
36 class SfxStyleSheet;
37 class Fraction;
38 class SfxItemPool;
39 class SdrModel;
40 
41 namespace sdr::properties
42 {
43  class ItemChangeBroadcaster;
44 }
45 
46 
48 //
49 // BaseProperties
50 // DefaultProperties ->SfxItemSet
51 // AttributeProperties ->SfxStyleSheet
52 // E3dProperties
53 // E3dCompoundProperties
54 // E3dExtrudeProperties
55 // E3dLatheProperties
56 // E3dSphereProperties
57 // E3dSceneProperties
58 // TextProperties ->maVersion
59 // ConnectorProperties
60 // CustomShapeProperties
61 // MeasureProperties
62 // RectangleProperties
63 // CaptionProperties
64 // CircleProperties
65 // GraphicProperties
66 // OleProperties
67 // CellProperties
68 // TableProperties
69 // GroupProperties
70 // EmptyProperties
71 // PageProperties
72 
73 namespace sdr::properties
74  {
76  {
77  private:
78  // the owner of this Properties. Set from constructor and not
79  // to be changed in any way.
81 
82  protected:
83  // apply the correct SfyStyleSheet from SdrObject's SdrModel
84  virtual void applyDefaultStyleSheetFromSdrModel();
85 
86  // create a new object specific itemset with object specific ranges.
87  virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0;
88 
89  // internal access to SdrObject
90  const SdrObject& GetSdrObject() const;
91 
92  SdrObject& GetSdrObject();
93 
94  // Test changeability for a single item. If an implementation wants to prevent
95  // changing an item it should override this method.
96  virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const = 0;
97 
98  // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared.
99  // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items.
100  virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) = 0;
101 
102  // Called after ItemChange() is done for all items. Allows local reactions on
103  // specific item changes
104  virtual void PostItemChange(const sal_uInt16 nWhich) = 0;
105 
106  // Internally react on ItemSet changes. The given ItemSet contains all changed items, the new ones.
107  virtual void ItemSetChanged(const SfxItemSet*) = 0;
108  // Subclasses need to return true if they want the ItemSetChanged() callback to actually have a non-zero pointer.
109  // We do this because creating the temporary item set is expensive and seldom used.
110  virtual bool WantItemSetInItemSetChanged() const { return false; }
111 
112  public:
113  // basic constructor, used from SdrObject.
114  explicit BaseProperties(SdrObject& rObj);
115 
116  // destructor
117  virtual ~BaseProperties();
118 
119  // Clone() operator, normally just calls the local copy constructor,
120  // see above.
121  virtual std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const = 0;
122 
123  // Get the local ItemSet. This directly returns the local ItemSet of the object. No
124  // merging of ItemSets is done for e.g. Group objects.
125  virtual const SfxItemSet& GetObjectItemSet() const = 0;
126 
127  // get merged ItemSet. Normally, this maps directly to GetObjectItemSet(), but may
128  // be overridden e.g for group objects to return a merged ItemSet of the object.
129  // When using this method the returned ItemSet may contain items in the state
130  // SfxItemState::DONTCARE which means there were several such items with different
131  // values.
132  virtual const SfxItemSet& GetMergedItemSet() const;
133 
134  // Sets all items which are on state SfxItemState::SET in rSet at the local ItemSet.
135  // Uses AllowItemChange(), ItemChange(), PostItemChange() and ItemSetChanged() calls.
136  virtual void SetObjectItemSet(const SfxItemSet& rSet) = 0;
137 
138  // Set merged ItemSet. Normally, this maps to SetObjectItemSet().
139  virtual void SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems = false);
140 
141  // Set single item at the local ItemSet. Uses AllowItemChange(),
142  // ItemChange(), PostItemChange() and ItemSetChanged() calls.
143  virtual void SetObjectItem(const SfxPoolItem& rItem) = 0;
144 
145  // Set a single item direct. Only uses AllowItemChange() and ItemChange(),
146  // but not PostItemChange() and ItemSetChanged() calls.
147  virtual void SetObjectItemDirect(const SfxPoolItem& rItem) = 0;
148 
149  // Clear a single local item. Uses AllowItemChange(),
150  // ItemChange(), PostItemChange() and ItemSetChanged() calls.
151  virtual void ClearObjectItem(const sal_uInt16 nWhich = 0) = 0;
152 
153  // Set a single item, iterate over hierarchies if necessary. Default
154  // Implementation falls back to ClearObjectItem().
155  virtual void SetMergedItem(const SfxPoolItem& rItem);
156 
157  // Clear a single item, iterate over hierarchies if necessary. Default
158  // Implementation falls back to ClearObjectItem().
159  virtual void ClearMergedItem(const sal_uInt16 nWhich);
160 
161  // Clear single item direct. Only uses AllowItemChange() and ItemChange(),
162  // but not PostItemChange() and ItemSetChanged() calls.
163  // Also supports complete deletion of items when default parameter 0 is used.
164  virtual void ClearObjectItemDirect(const sal_uInt16 nWhich) = 0;
165 
166  // Set a new StyleSheet. Registers as listener at the StyleSheet to get knowledge
167  // of StyleSheet changes.
168  virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) = 0;
169 
170  // Get the installed StyleSheet.
171  virtual SfxStyleSheet* GetStyleSheet() const = 0;
172 
173  // force all attributes which come from styles to hard attributes
174  // to be able to live without the style.
175  virtual void ForceStyleToHardAttributes();
176 
177  // syntactical sugar for ItemSet accesses. Broadcasts before and after the changes
178  // to invalidate views in old and new BoundRects. As soon as the repaint mechanism
179  // will be changed these broadcasts will no longer be needed.
180  //void SetItemAndBroadcast(const SfxPoolItem& rItem);
181  //void ClearItemAndBroadcast(const sal_uInt16 nWhich = 0);
182  void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems = false);
183 
184  // Just a convenient shortcut for GetObjectItemSet().Get(nWhich).
185  const SfxPoolItem& GetItem(const sal_uInt16 nWhich) const;
186  template<class T> const T& GetItem(TypedWhichId<T> nWhich) const
187  {
188  return static_cast<const T&>(GetItem(sal_uInt16(nWhich)));
189  }
190 
191  // support for convenient broadcasting. Used from SetMergedItemAndBroadcast(),
192  // ClearItemAndBroadcast() and SetItemSetAndBroadcast(), see above.
193  // But also from inside SdrObjects.
194  void BroadcastItemChange(const ItemChangeBroadcaster& rChange);
195 
196  // #i101556# add versioning mechanism; used from e.g. text attribute set to
197  // allow detection of e.g. style sheet or single text attribute changes. The
198  // default implementation returns 0 (zero)
199  virtual sal_uInt32 getVersion() const;
200 
201  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
202  };
203 
204  // checks the FillStyle item and removes unneeded Gradient, FillBitmap and Hatch items
206 
207 } // end of namespace sdr::properties
208 
209 #endif // INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
210 
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
struct _xmlTextWriter * xmlTextWriterPtr
Definition: properties.hxx:32
void CleanupFillProperties(SfxItemSet &rItemSet)
Definition: properties.cxx:162
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
virtual bool WantItemSetInItemSetChanged() const
Definition: properties.hxx:110
Abstract DrawObject.
Definition: svdobj.hxx:259
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
const T & GetItem(TypedWhichId< T > nWhich) const
Definition: properties.hxx:186