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