/src/libreoffice/include/svx/sdr/properties/defaultproperties.hxx
Line | Count | Source |
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 | | #include <span> |
27 | | |
28 | | #include <svx/sdr/properties/properties.hxx> |
29 | | #include <svx/svxdllapi.h> |
30 | | #include <svl/itemset.hxx> |
31 | | |
32 | | struct _xmlTextWriter; |
33 | | typedef struct _xmlTextWriter* xmlTextWriterPtr; |
34 | | |
35 | | namespace sdr::properties |
36 | | { |
37 | | class SVXCORE_DLLPUBLIC DefaultProperties : public BaseProperties |
38 | | { |
39 | | protected: |
40 | | // the to be used ItemSet |
41 | | mutable std::optional<SfxItemSet> moItemSet; |
42 | | |
43 | | // create a new object specific itemset with object specific ranges. |
44 | | SAL_DLLPRIVATE virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) override; |
45 | | |
46 | | // Test changeability for a single item. If an implementation wants to prevent |
47 | | // changing an item it should override this method. |
48 | | SAL_DLLPRIVATE virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const; |
49 | | |
50 | | // Do the internal ItemChange. If only nWhich is given, the item needs to be cleared. |
51 | | // Also needs to handle if nWhich and pNewItem is 0, which means to clear all items. |
52 | | SAL_DLLPRIVATE virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr); |
53 | | |
54 | | // Called after ItemChange() is done for all items. Allows local reactions on |
55 | | // specific item changes |
56 | | SAL_DLLPRIVATE virtual void PostItemChange(const sal_uInt16 nWhich); |
57 | | |
58 | | // Internally react on ItemSet changes. The given span contains changed items. |
59 | | // If nDeletedWhich is not 0, it indicates a deleted item. |
60 | | // @param bAdjustTextFrameWidthAndHeight pass false if you know it is safe to avoid the cost of doing |
61 | | // text layout right now. |
62 | | SAL_DLLPRIVATE virtual void ItemSetChanged(std::span< const SfxPoolItem* const > aChangedItems, sal_uInt16 nDeletedWhich, bool bAdjustTextFrameWidthAndHeight = true); |
63 | | |
64 | | // check if SfxItemSet exists |
65 | 77.2M | bool HasSfxItemSet() const { return bool(moItemSet); } |
66 | | |
67 | | public: |
68 | | // basic constructor |
69 | | explicit DefaultProperties(SdrObject& rObj); |
70 | | |
71 | | // constructor for copying, but using new object |
72 | | SAL_DLLPRIVATE DefaultProperties(const DefaultProperties& rProps, SdrObject& rObj); |
73 | | |
74 | | // destructor |
75 | | SAL_DLLPRIVATE virtual ~DefaultProperties() override; |
76 | | |
77 | | SAL_DLLPRIVATE void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
78 | | |
79 | | // Clone() operator, normally just calls the local copy constructor |
80 | | SAL_DLLPRIVATE virtual std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const override; |
81 | | |
82 | | // get itemset |
83 | | SAL_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet() const override; |
84 | | |
85 | | // set single item |
86 | | SAL_DLLPRIVATE virtual void SetObjectItem(const SfxPoolItem& rItem) override; |
87 | | |
88 | | // set single item direct, do not do any notifies or things like that |
89 | | SAL_DLLPRIVATE virtual void SetObjectItemDirect(const SfxPoolItem& rItem) override; |
90 | | |
91 | | // clear single item |
92 | | SAL_DLLPRIVATE 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 | | SAL_DLLPRIVATE virtual void ClearObjectItemDirect(const sal_uInt16 nWhich) override; |
97 | | |
98 | | // set complete item set |
99 | | SAL_DLLPRIVATE virtual void SetObjectItemSet(const SfxItemSet& rSet, bool bAdjustTextFrameWidthAndHeight = true) override; |
100 | | |
101 | | // set a new StyleSheet and broadcast |
102 | | SAL_DLLPRIVATE virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, |
103 | | bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; |
104 | | |
105 | | // get the installed StyleSheet |
106 | | SAL_DLLPRIVATE 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 | | SAL_DLLPRIVATE 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: */ |