LibreOffice Module svx (master)  1
defaultproperties.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SDR_PROPERTIES_DEFAULTPROPERTIES_HXX
21 #define INCLUDED_SVX_SDR_PROPERTIES_DEFAULTPROPERTIES_HXX
22 
23 #include <sal/config.h>
24 
25 #include <optional>
26 
28 #include <svx/svxdllapi.h>
29 #include <svl/itemset.hxx>
30 
31 struct _xmlTextWriter;
32 typedef struct _xmlTextWriter* xmlTextWriterPtr;
33 
34 namespace sdr::properties
35  {
37  {
38  protected:
39  // the to be used ItemSet
40  mutable std::optional<SfxItemSet> mxItemSet;
41 
42  // create a new object specific itemset with object specific ranges.
43  virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool);
44 
45  // Test changeability for a single item. If an implementation wants to prevent
46  // changing an item it should override this method.
47  virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const;
48 
49  // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared.
50  // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items.
51  virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr);
52 
53  // Called after ItemChange() is done for all items. Allows local reactions on
54  // specific item changes
55  virtual void PostItemChange(const sal_uInt16 nWhich);
56 
57  // Internally react on ItemSet changes. The given ItemSet contains all changed items, the new ones.
58  virtual void ItemSetChanged(const SfxItemSet*);
59 
60  // Subclasses need to return true if they want the ItemSetChanged() callback to actually have a non-zero pointer.
61  // We do this because creating the temporary item set is expensive and seldom used.
62  virtual bool WantItemSetInItemSetChanged() const { return false; }
63 
64  // check if SfxItemSet exists
65  bool HasSfxItemSet() const { return bool(mxItemSet); }
66 
67  public:
68  // basic constructor
69  explicit DefaultProperties(SdrObject& rObj);
70 
71  // constructor for copying, but using new object
72  DefaultProperties(const DefaultProperties& rProps, SdrObject& rObj);
73 
74  // destructor
75  virtual ~DefaultProperties() override;
76 
77  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
78 
79  // Clone() operator, normally just calls the local copy constructor
80  virtual std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const override;
81 
82  // get itemset
83  virtual const SfxItemSet& GetObjectItemSet() const override;
84 
85  // set single item
86  virtual void SetObjectItem(const SfxPoolItem& rItem) override;
87 
88  // set single item direct, do not do any notifies or things like that
89  virtual void SetObjectItemDirect(const SfxPoolItem& rItem) override;
90 
91  // clear single item
92  virtual void ClearObjectItem(const sal_uInt16 nWhich = 0) override;
93 
94  // clear single item direct, do not do any notifies or things like that.
95  // Also supports complete deletion of items when default parameter 0 is used.
96  virtual void ClearObjectItemDirect(const sal_uInt16 nWhich) override;
97 
98  // set complete item set
99  virtual void SetObjectItemSet(const SfxItemSet& rSet) override;
100 
101  // set a new StyleSheet and broadcast
102  virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr,
103  bool bBroadcast) override;
104 
105  // get the installed StyleSheet
106  virtual SfxStyleSheet* GetStyleSheet() const override;
107 
108  // force default attributes for a specific object type, called from
109  // DefaultProperties::GetObjectItemSet() if a new ItemSet is created.
110  // Default implementation does nothing.
111  virtual void ForceDefaultAttributes();
112  };
113 
114 } // end of namespace sdr::properties
115 
116 #endif // INCLUDED_SVX_SDR_PROPERTIES_DEFAULTPROPERTIES_HXX
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
struct _xmlTextWriter * xmlTextWriterPtr
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
virtual bool WantItemSetInItemSetChanged() const
Abstract DrawObject.
Definition: svdobj.hxx:260
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
std::optional< SfxItemSet > mxItemSet