bump product version to 4.1.6.2
[LibreOffice.git] / include / svx / sdr / properties / properties.hxx
blob287cd5b93ef24654dd3bb06ffbab4c2a4f03ee9c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SDR_PROPERTIES_PROPERTIES_HXX
21 #define _SDR_PROPERTIES_PROPERTIES_HXX
23 #include <sal/types.h>
24 #include "svx/svxdllapi.h"
26 //////////////////////////////////////////////////////////////////////////////
27 // predeclarations
29 class SdrObject;
30 class SfxItemSet;
31 class SfxPoolItem;
32 class SfxStyleSheet;
33 class Fraction;
34 class SfxItemPool;
35 class SdrModel;
37 namespace sdr
39 namespace properties
41 class ItemChangeBroadcaster;
42 } // end of namespace properties
43 } // end of namespace sdr
45 //////////////////////////////////////////////////////////////////////////////
47 namespace sdr
49 namespace properties
51 class SVX_DLLPUBLIC BaseProperties
53 protected:
54 // the owner of this Properties. Set from constructor and not
55 // to be changed in any way.
56 SdrObject& mrObject;
58 // create a new object specific itemset with object specific ranges.
59 virtual SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0;
61 // internal access to SdrObject
62 SdrObject& GetSdrObject() const
64 return mrObject;
67 // Test changeability for a single item. If a implementation wants to prevent
68 // changing an item this method may be overloaded.
69 virtual sal_Bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0) const = 0;
71 // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared.
72 // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items.
73 virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0) = 0;
75 // Called after ItemChange() is done for all items. Allows local reactions on
76 // specific item changes
77 virtual void PostItemChange(const sal_uInt16 nWhich) = 0;
79 // Internally react on ItemSet changes. The given ItemSet contains all changed items, the new ones.
80 virtual void ItemSetChanged(const SfxItemSet& rSet) = 0;
82 public:
83 // basic constructor, used from SdrObject.
84 explicit BaseProperties(SdrObject& rObj);
86 // constructor for copying, but using new object. Used from the Clone()
87 // method.
88 BaseProperties(const BaseProperties& rProps, SdrObject& rObj);
90 // destructor
91 virtual ~BaseProperties();
93 // Clone() operator, normally just calls the local copy constructor,
94 // see above.
95 virtual BaseProperties& Clone(SdrObject& rObj) const = 0;
97 // Get the local ItemSet. This directly returns the local ItemSet of the object. No
98 // merging of ItemSets is done for e.g. Group objects.
99 virtual const SfxItemSet& GetObjectItemSet() const = 0;
101 // get merged ItemSet. Normappl, this maps directly to GetObjectItemSet(), but may
102 // be overloaded e.g for group objects to return a merged ItemSet of the object.
103 // When using this method the returned ItemSet may contain items in the state
104 // SFX_ITEM_DONTCARE which means there were several such items with different
105 // values.
106 virtual const SfxItemSet& GetMergedItemSet() const;
108 // Sets all items which are on state SFX_ITEM_SET in rSet at the local ItemSet.
109 // Uses AllowItemChange(), ItemChange(), PostItemChange() and ItemSetChanged() calls.
110 virtual void SetObjectItemSet(const SfxItemSet& rSet) = 0;
112 // Set merged ItemSet. Normally, this maps to SetObjectItemSet().
113 virtual void SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems = sal_False);
115 // Set single item at the local ItemSet. Uses AllowItemChange(),
116 // ItemChange(), PostItemChange() and ItemSetChanged() calls.
117 virtual void SetObjectItem(const SfxPoolItem& rItem) = 0;
119 // Set a single item direct. Only uses AllowItemChange() and ItemChange(),
120 // but not PostItemChange() and ItemSetChanged() calls.
121 virtual void SetObjectItemDirect(const SfxPoolItem& rItem) = 0;
123 // Clear a single local item. Uses AllowItemChange(),
124 // ItemChange(), PostItemChange() and ItemSetChanged() calls.
125 virtual void ClearObjectItem(const sal_uInt16 nWhich = 0) = 0;
127 // Set a single item, iterate over hierarchies if necessary. Default
128 // Implementation falls back to ClearObjectItem().
129 virtual void SetMergedItem(const SfxPoolItem& rItem);
131 // Clear a single item, iterate over hierarchies if necessary. Default
132 // Implementation falls back to ClearObjectItem().
133 virtual void ClearMergedItem(const sal_uInt16 nWhich = 0);
135 // Clear single item direct. Only uses AllowItemChange() and ItemChange(),
136 // but not PostItemChange() and ItemSetChanged() calls.
137 // Also supports complete deletion of items when default parameter 0 is used.
138 virtual void ClearObjectItemDirect(const sal_uInt16 nWhich = 0) = 0;
140 // Set a new StyleSheet. Registers as listener at the StyleSheet to get knowledge
141 // of StyleSheet changes.
142 virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) = 0;
144 // Get the installed StyleSheet.
145 virtual SfxStyleSheet* GetStyleSheet() const = 0;
147 // Scale the local ItemSet as far as it contains metric items. This needs to be
148 // overloaded to do it for hierarchical objects like e.g. groups.
149 virtual void Scale(const Fraction& rScale);
151 // Move local items to a new ItemPool. This needs to be
152 // overloaded to do it for hierarchical objects like e.g. groups.
153 virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel = 0L);
155 // Set new model.
156 virtual void SetModel(SdrModel* pOldModel, SdrModel* pNewModel);
158 // force all attributes which come from styles to hard attributes
159 // to be able to live without the style.
160 virtual void ForceStyleToHardAttributes();
162 // syntactical sugar for ItemSet accesses. Broadcasts before and after the changes
163 // to invalidate views in old and new BoundRects. As soon as the repaint mechanism
164 // will be changed these broadcasts will no longer be needed.
165 //void SetItemAndBroadcast(const SfxPoolItem& rItem);
166 //void ClearItemAndBroadcast(const sal_uInt16 nWhich = 0);
167 void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems = sal_False);
169 // Just a convenient shortcut for GetObjectItemSet().Get(nWhich).
170 const SfxPoolItem& GetItem(const sal_uInt16 nWhich) const;
172 // support for convenient broadcasting. Used from SetMergedItemAndBroadcast(),
173 // ClearItemAndBroadcast() and SetItemSetAndBroadcast(), see above.
174 // But also from inside SdrObjects.
175 void BroadcastItemChange(const ItemChangeBroadcaster& rChange);
177 // #i101556# add versioning mechanism; used from e.g. text attribute set to
178 // allow detection of e.g. style sheet or single text attribute changes. The
179 // default implementation returns 0 (zero)
180 virtual sal_uInt32 getVersion() const;
183 // checks the FillStyle item and removes unneeded Gradient, FillBitmap and Hatch items
184 void SVX_DLLPUBLIC CleanupFillProperties( SfxItemSet& rItemSet );
186 } // end of namespace properties
187 } // end of namespace sdr
189 //////////////////////////////////////////////////////////////////////////////
191 #endif //_SDR_PROPERTIES_PROPERTIES_HXX
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */