Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SDR_PROPERTIES_PROPERTIES_HXX
30 : : #define _SDR_PROPERTIES_PROPERTIES_HXX
31 : :
32 : : #include <sal/types.h>
33 : : #include "svx/svxdllapi.h"
34 : :
35 : : //////////////////////////////////////////////////////////////////////////////
36 : : // predeclarations
37 : :
38 : : class SdrObject;
39 : : class SfxItemSet;
40 : : class SfxPoolItem;
41 : : class SfxStyleSheet;
42 : : class Fraction;
43 : : class SfxItemPool;
44 : : class SdrModel;
45 : :
46 : : namespace sdr
47 : : {
48 : : namespace properties
49 : : {
50 : : class ItemChangeBroadcaster;
51 : : } // end of namespace properties
52 : : } // end of namespace sdr
53 : :
54 : : //////////////////////////////////////////////////////////////////////////////
55 : :
56 : : namespace sdr
57 : : {
58 : : namespace properties
59 : : {
60 : : class SVX_DLLPUBLIC BaseProperties
61 : : {
62 : : protected:
63 : : // the owner of this Properties. Set from constructor and not
64 : : // to be changed in any way.
65 : : SdrObject& mrObject;
66 : :
67 : : // create a new object specific itemset with object specific ranges.
68 : : virtual SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0;
69 : :
70 : : // internal access to SdrObject
71 : 4185965 : SdrObject& GetSdrObject() const
72 : : {
73 : 4185965 : return mrObject;
74 : : }
75 : :
76 : : // Test changeability for a single item. If a implementation wants to prevent
77 : : // changing an item this method may be overloaded.
78 : : virtual sal_Bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0) const = 0;
79 : :
80 : : // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared.
81 : : // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items.
82 : : virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0) = 0;
83 : :
84 : : // Called after ItemChange() is done for all items. Allows local reactions on
85 : : // specific item changes
86 : : virtual void PostItemChange(const sal_uInt16 nWhich) = 0;
87 : :
88 : : // Internally react on ItemSet changes. The given ItemSet contains all changed items, the new ones.
89 : : virtual void ItemSetChanged(const SfxItemSet& rSet) = 0;
90 : :
91 : : public:
92 : : // basic constructor, used from SdrObject.
93 : : explicit BaseProperties(SdrObject& rObj);
94 : :
95 : : // constructor for copying, but using new object. Used from the Clone()
96 : : // method.
97 : : BaseProperties(const BaseProperties& rProps, SdrObject& rObj);
98 : :
99 : : // destructor
100 : : virtual ~BaseProperties();
101 : :
102 : : // Clone() operator, normally just calls the local copy constructor,
103 : : // see above.
104 : : virtual BaseProperties& Clone(SdrObject& rObj) const = 0;
105 : :
106 : : // Get the local ItemSet. This directly returns the local ItemSet of the object. No
107 : : // merging of ItemSets is done for e.g. Group objects.
108 : : virtual const SfxItemSet& GetObjectItemSet() const = 0;
109 : :
110 : : // get merged ItemSet. Normappl, this maps directly to GetObjectItemSet(), but may
111 : : // be overloaded e.g for group objects to return a merged ItemSet of the object.
112 : : // When using this method the returned ItemSet may contain items in the state
113 : : // SFX_ITEM_DONTCARE which means there were several such items with different
114 : : // values.
115 : : virtual const SfxItemSet& GetMergedItemSet() const;
116 : :
117 : : // Sets all items which are on state SFX_ITEM_SET in rSet at the local ItemSet.
118 : : // Uses AllowItemChange(), ItemChange(), PostItemChange() and ItemSetChanged() calls.
119 : : virtual void SetObjectItemSet(const SfxItemSet& rSet) = 0;
120 : :
121 : : // Set merged ItemSet. Normally, this maps to SetObjectItemSet().
122 : : virtual void SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems = sal_False);
123 : :
124 : : // Set single item at the local ItemSet. Uses AllowItemChange(),
125 : : // ItemChange(), PostItemChange() and ItemSetChanged() calls.
126 : : virtual void SetObjectItem(const SfxPoolItem& rItem) = 0;
127 : :
128 : : // Set a single item direct. Only uses AllowItemChange() and ItemChange(),
129 : : // but not PostItemChange() and ItemSetChanged() calls.
130 : : virtual void SetObjectItemDirect(const SfxPoolItem& rItem) = 0;
131 : :
132 : : // Clear a single local item. Uses AllowItemChange(),
133 : : // ItemChange(), PostItemChange() and ItemSetChanged() calls.
134 : : virtual void ClearObjectItem(const sal_uInt16 nWhich = 0) = 0;
135 : :
136 : : // Set a single item, iterate over hierarchies if necessary. Default
137 : : // Implementation falls back to ClearObjectItem().
138 : : virtual void SetMergedItem(const SfxPoolItem& rItem);
139 : :
140 : : // Clear a single item, iterate over hierarchies if necessary. Default
141 : : // Implementation falls back to ClearObjectItem().
142 : : virtual void ClearMergedItem(const sal_uInt16 nWhich = 0);
143 : :
144 : : // Clear single item direct. Only uses AllowItemChange() and ItemChange(),
145 : : // but not PostItemChange() and ItemSetChanged() calls.
146 : : // Also supports complete deletion of items when default parameter 0 is used.
147 : : virtual void ClearObjectItemDirect(const sal_uInt16 nWhich = 0) = 0;
148 : :
149 : : // Set a new StyleSheet. Registers as listener at the StyleSheet to get knowledge
150 : : // of StyleSheet changes.
151 : : virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) = 0;
152 : :
153 : : // Get the installed StyleSheet.
154 : : virtual SfxStyleSheet* GetStyleSheet() const = 0;
155 : :
156 : : // Scale the local ItemSet as far as it contains metric items. This needs to be
157 : : // overloaded to do it for hierarchical objects like e.g. groups.
158 : : virtual void Scale(const Fraction& rScale);
159 : :
160 : : // Move local items to a new ItemPool. This needs to be
161 : : // overloaded to do it for hierarchical objects like e.g. groups.
162 : : virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel = 0L);
163 : :
164 : : // Set new model.
165 : : virtual void SetModel(SdrModel* pOldModel, SdrModel* pNewModel);
166 : :
167 : : // force all attributes which come from styles to hard attributes
168 : : // to be able to live without the style.
169 : : virtual void ForceStyleToHardAttributes();
170 : :
171 : : // syntactical sugar for ItemSet accesses. Broadcasts before and after the changes
172 : : // to invalidate views in old and new BoundRects. As soon as the repaint mechanism
173 : : // will be changed these broadcasts will no longer be needed.
174 : : //void SetItemAndBroadcast(const SfxPoolItem& rItem);
175 : : //void ClearItemAndBroadcast(const sal_uInt16 nWhich = 0);
176 : : void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems = sal_False);
177 : :
178 : : // Just a convenient shortcut for GetObjectItemSet().Get(nWhich).
179 : : const SfxPoolItem& GetItem(const sal_uInt16 nWhich) const;
180 : :
181 : : // support for convenient broadcasting. Used from SetMergedItemAndBroadcast(),
182 : : // ClearItemAndBroadcast() and SetItemSetAndBroadcast(), see above.
183 : : // But also from inside SdrObjects.
184 : : void BroadcastItemChange(const ItemChangeBroadcaster& rChange);
185 : :
186 : : // #i101556# add versioning mechanism; used from e.g. text attribute set to
187 : : // allow detection of e.g. style sheet or single text attribute changes. The
188 : : // default implementation returns 0 (zero)
189 : : virtual sal_uInt32 getVersion() const;
190 : : };
191 : :
192 : : // checks the FillStyle item and removes unneeded Gradient, FillBitmap and Hatch items
193 : : void SVX_DLLPUBLIC CleanupFillProperties( SfxItemSet& rItemSet );
194 : :
195 : : } // end of namespace properties
196 : : } // end of namespace sdr
197 : :
198 : : //////////////////////////////////////////////////////////////////////////////
199 : :
200 : : #endif //_SDR_PROPERTIES_PROPERTIES_HXX
201 : :
202 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|