1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SDR_PROPERTIES_PROPERTIES_HXX 25 #define _SDR_PROPERTIES_PROPERTIES_HXX 26 27 #include <sal/types.h> 28 #include "svx/svxdllapi.h" 29 30 ////////////////////////////////////////////////////////////////////////////// 31 // predeclarations 32 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 } // end of namespace properties 47 } // end of namespace sdr 48 49 ////////////////////////////////////////////////////////////////////////////// 50 51 namespace sdr 52 { 53 namespace properties 54 { 55 class SVX_DLLPUBLIC BaseProperties 56 { 57 protected: 58 // the owner of this Properties. Set from constructor and not 59 // to be changed in any way. 60 SdrObject& mrObject; 61 62 // create a new object specific itemset with object specific ranges. 63 virtual SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0; 64 65 // internal access to SdrObject GetSdrObject() const66 SdrObject& GetSdrObject() const 67 { 68 return mrObject; 69 } 70 71 // Test changeability for a single item. If a implementation wants to prevent 72 // changing an item this method may be overloaded. 73 virtual sal_Bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0) const = 0; 74 75 // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared. 76 // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items. 77 virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0) = 0; 78 79 // Called after ItemChange() is done for all items. Allows local reactions on 80 // specific item changes 81 virtual void PostItemChange(const sal_uInt16 nWhich) = 0; 82 83 // Internally react on ItemSet changes. The given ItemSet contains all changed items, the new ones. 84 virtual void ItemSetChanged(const SfxItemSet& rSet) = 0; 85 86 public: 87 // basic constructor, used from SdrObject. 88 BaseProperties(SdrObject& rObj); 89 90 // constructor for copying, but using new object. Used from the Clone() 91 // method. 92 BaseProperties(const BaseProperties& rProps, SdrObject& rObj); 93 94 // destructor 95 virtual ~BaseProperties(); 96 97 // Clone() operator, normally just calls the local copy constructor, 98 // see above. 99 virtual BaseProperties& Clone(SdrObject& rObj) const = 0; 100 101 // Get the local ItemSet. This directly returns the local ItemSet of the object. No 102 // merging of ItemSets is done for e.g. Group objects. 103 virtual const SfxItemSet& GetObjectItemSet() const = 0; 104 105 // get merged ItemSet. Normappl, this maps directly to GetObjectItemSet(), but may 106 // be overloaded e.g for group objects to return a merged ItemSet of the object. 107 // When using this method the returned ItemSet may contain items in the state 108 // SFX_ITEM_DONTCARE which means there were several such items with different 109 // values. 110 virtual const SfxItemSet& GetMergedItemSet() const; 111 112 // Sets all items which are on state SFX_ITEM_SET in rSet at the local ItemSet. 113 // Uses AllowItemChange(), ItemChange(), PostItemChange() and ItemSetChanged() calls. 114 virtual void SetObjectItemSet(const SfxItemSet& rSet) = 0; 115 116 // Set merged ItemSet. Normally, this maps to SetObjectItemSet(). 117 virtual void SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems = sal_False); 118 119 // Set single item at the local ItemSet. Uses AllowItemChange(), 120 // ItemChange(), PostItemChange() and ItemSetChanged() calls. 121 virtual void SetObjectItem(const SfxPoolItem& rItem) = 0; 122 123 // Set a single item direct. Only uses AllowItemChange() and ItemChange(), 124 // but not PostItemChange() and ItemSetChanged() calls. 125 virtual void SetObjectItemDirect(const SfxPoolItem& rItem) = 0; 126 127 // Clear a single local item. Uses AllowItemChange(), 128 // ItemChange(), PostItemChange() and ItemSetChanged() calls. 129 virtual void ClearObjectItem(const sal_uInt16 nWhich = 0) = 0; 130 131 // Set a single item, iterate over hierarchies if necessary. Default 132 // Implementation falls back to ClearObjectItem(). 133 virtual void SetMergedItem(const SfxPoolItem& rItem); 134 135 // Clear a single item, iterate over hierarchies if necessary. Default 136 // Implementation falls back to ClearObjectItem(). 137 virtual void ClearMergedItem(const sal_uInt16 nWhich = 0); 138 139 // Clear single item direct. Only uses AllowItemChange() and ItemChange(), 140 // but not PostItemChange() and ItemSetChanged() calls. 141 // Also supports complete deletion of items when default parameter 0 is used. 142 virtual void ClearObjectItemDirect(const sal_uInt16 nWhich = 0) = 0; 143 144 // Set a new StyleSheet. Registers as listener at the StyleSheet to get knowledge 145 // of StyleSheet changes. 146 virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) = 0; 147 148 // Get the installed StyleSheet. 149 virtual SfxStyleSheet* GetStyleSheet() const = 0; 150 151 // Scale the local ItemSet as far as it contains metric items. This needs to be 152 // overloaded to do it for hierarchical objects like e.g. groups. 153 virtual void Scale(const Fraction& rScale); 154 155 // Move local items to a new ItemPool. This needs to be 156 // overloaded to do it for hierarchical objects like e.g. groups. 157 virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel = 0L); 158 159 // Set new model. 160 virtual void SetModel(SdrModel* pOldModel, SdrModel* pNewModel); 161 162 // force all attributes which come from styles to hard attributes 163 // to be able to live without the style. 164 virtual void ForceStyleToHardAttributes(); 165 166 // syntactical sugar for ItemSet accesses. Broadcasts before and after the changes 167 // to invalidate views in old and new BoundRects. As soon as the repaint mechanism 168 // will be changed these broadcasts will no longer be needed. 169 //void SetItemAndBroadcast(const SfxPoolItem& rItem); 170 //void ClearItemAndBroadcast(const sal_uInt16 nWhich = 0); 171 void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems = sal_False); 172 173 // Just a convenient shortcut for GetObjectItemSet().Get(nWhich). 174 const SfxPoolItem& GetItem(const sal_uInt16 nWhich) const; 175 176 // support for convenient broadcasting. Used from SetMergedItemAndBroadcast(), 177 // ClearItemAndBroadcast() and SetItemSetAndBroadcast(), see above. 178 // But also from inside SdrObjects. 179 void BroadcastItemChange(const ItemChangeBroadcaster& rChange); 180 181 // #i101556# add versioning mechanism; used from e.g. text attribute set to 182 // allow detection of e.g. style sheet or single text attribute changes. The 183 // default implementation returns 0 (zero) 184 virtual sal_uInt32 getVersion() const; 185 }; 186 187 // checks the FillStyle item and removes unneeded Gradient, FillBitmap and Hatch items 188 void SVX_DLLPUBLIC CleanupFillProperties( SfxItemSet& rItemSet ); 189 190 } // end of namespace properties 191 } // end of namespace sdr 192 193 ////////////////////////////////////////////////////////////////////////////// 194 195 #endif //_SDR_PROPERTIES_PROPERTIES_HXX 196 197 // eof 198