1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
21 #define INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
23 #include <sal/types.h>
24 #include <svx/svxdllapi.h>
38 class ItemChangeBroadcaster
;
46 class SVX_DLLPUBLIC BaseProperties
49 // the owner of this Properties. Set from constructor and not
50 // to be changed in any way.
55 // create a new object specific itemset with object specific ranges.
56 virtual SfxItemSet
* CreateObjectSpecificItemSet(SfxItemPool
& pPool
) = 0;
58 // internal access to SdrObject
59 const SdrObject
& GetSdrObject() const;
61 SdrObject
& GetSdrObject();
63 // Test changeability for a single item. If a implementation wants to prevent
64 // changing an item it should override this method.
65 virtual bool AllowItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
= 0) const = 0;
67 // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared.
68 // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items.
69 virtual void ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
= 0) = 0;
71 // Called after ItemChange() is done for all items. Allows local reactions on
72 // specific item changes
73 virtual void PostItemChange(const sal_uInt16 nWhich
) = 0;
75 // Internally react on ItemSet changes. The given ItemSet contains all changed items, the new ones.
76 virtual void ItemSetChanged(const SfxItemSet
& rSet
) = 0;
79 // basic constructor, used from SdrObject.
80 explicit BaseProperties(SdrObject
& rObj
);
82 // constructor for copying, but using new object. Used from the Clone()
84 BaseProperties(const BaseProperties
& rProps
, SdrObject
& rObj
);
87 virtual ~BaseProperties();
89 // Clone() operator, normally just calls the local copy constructor,
91 virtual BaseProperties
& Clone(SdrObject
& rObj
) const = 0;
93 // Get the local ItemSet. This directly returns the local ItemSet of the object. No
94 // merging of ItemSets is done for e.g. Group objects.
95 virtual const SfxItemSet
& GetObjectItemSet() const = 0;
97 // get merged ItemSet. Normally, this maps directly to GetObjectItemSet(), but may
98 // be overridden e.g for group objects to return a merged ItemSet of the object.
99 // When using this method the returned ItemSet may contain items in the state
100 // SfxItemState::DONTCARE which means there were several such items with different
102 virtual const SfxItemSet
& GetMergedItemSet() const;
104 // Sets all items which are on state SfxItemState::SET in rSet at the local ItemSet.
105 // Uses AllowItemChange(), ItemChange(), PostItemChange() and ItemSetChanged() calls.
106 virtual void SetObjectItemSet(const SfxItemSet
& rSet
) = 0;
108 // Set merged ItemSet. Normally, this maps to SetObjectItemSet().
109 virtual void SetMergedItemSet(const SfxItemSet
& rSet
, bool bClearAllItems
= false);
111 // Set single item at the local ItemSet. Uses AllowItemChange(),
112 // ItemChange(), PostItemChange() and ItemSetChanged() calls.
113 virtual void SetObjectItem(const SfxPoolItem
& rItem
) = 0;
115 // Set a single item direct. Only uses AllowItemChange() and ItemChange(),
116 // but not PostItemChange() and ItemSetChanged() calls.
117 virtual void SetObjectItemDirect(const SfxPoolItem
& rItem
) = 0;
119 // Clear a single local item. Uses AllowItemChange(),
120 // ItemChange(), PostItemChange() and ItemSetChanged() calls.
121 virtual void ClearObjectItem(const sal_uInt16 nWhich
= 0) = 0;
123 // Set a single item, iterate over hierarchies if necessary. Default
124 // Implementation falls back to ClearObjectItem().
125 virtual void SetMergedItem(const SfxPoolItem
& rItem
);
127 // Clear a single item, iterate over hierarchies if necessary. Default
128 // Implementation falls back to ClearObjectItem().
129 virtual void ClearMergedItem(const sal_uInt16 nWhich
= 0);
131 // Clear single item direct. Only uses AllowItemChange() and ItemChange(),
132 // but not PostItemChange() and ItemSetChanged() calls.
133 // Also supports complete deletion of items when default parameter 0 is used.
134 virtual void ClearObjectItemDirect(const sal_uInt16 nWhich
= 0) = 0;
136 // Set a new StyleSheet. Registers as listener at the StyleSheet to get knowledge
137 // of StyleSheet changes.
138 virtual void SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, bool bDontRemoveHardAttr
) = 0;
140 // Get the installed StyleSheet.
141 virtual SfxStyleSheet
* GetStyleSheet() const = 0;
143 // Scale the local ItemSet as far as it contains metric items.
144 // Override this to do it for hierarchical objects like e.g. groups.
145 virtual void Scale(const Fraction
& rScale
);
147 // Move local items to a new ItemPool.
148 // Override this to do it for hierarchical objects like e.g. groups.
149 virtual void MoveToItemPool(SfxItemPool
* pSrcPool
, SfxItemPool
* pDestPool
, SdrModel
* pNewModel
= 0L);
152 virtual void SetModel(SdrModel
* pOldModel
, SdrModel
* pNewModel
);
154 // force all attributes which come from styles to hard attributes
155 // to be able to live without the style.
156 virtual void ForceStyleToHardAttributes();
158 // syntactical sugar for ItemSet accesses. Broadcasts before and after the changes
159 // to invalidate views in old and new BoundRects. As soon as the repaint mechanism
160 // will be changed these broadcasts will no longer be needed.
161 //void SetItemAndBroadcast(const SfxPoolItem& rItem);
162 //void ClearItemAndBroadcast(const sal_uInt16 nWhich = 0);
163 void SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, bool bClearAllItems
= false);
165 // Just a convenient shortcut for GetObjectItemSet().Get(nWhich).
166 const SfxPoolItem
& GetItem(const sal_uInt16 nWhich
) const;
168 // support for convenient broadcasting. Used from SetMergedItemAndBroadcast(),
169 // ClearItemAndBroadcast() and SetItemSetAndBroadcast(), see above.
170 // But also from inside SdrObjects.
171 void BroadcastItemChange(const ItemChangeBroadcaster
& rChange
);
173 // #i101556# add versioning mechanism; used from e.g. text attribute set to
174 // allow detection of e.g. style sheet or single text attribute changes. The
175 // default implementation returns 0 (zero)
176 virtual sal_uInt32
getVersion() const;
179 // checks the FillStyle item and removes unneeded Gradient, FillBitmap and Hatch items
180 void SVX_DLLPUBLIC
CleanupFillProperties( SfxItemSet
& rItemSet
);
182 } // end of namespace properties
183 } // end of namespace sdr
185 #endif // INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */