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