LibreOffice Module svx (master) 1
customshapeproperties.cxx
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#include <sal/config.h>
21
23#include <svl/itemset.hxx>
24#include <svl/style.hxx>
25#include <svx/svdoashp.hxx>
26#include <svx/sdooitm.hxx>
27#include <editeng/eeitem.hxx>
28#include <svl/whiter.hxx>
29#include <svl/hint.hxx>
30
31
32namespace sdr::properties
33{
34 void CustomShapeProperties::UpdateTextFrameStatus(bool bInvalidateRenderGeometry)
35 {
36 SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& >(GetSdrObject());
37 const bool bOld(rObj.mbTextFrame);
38
39 // change TextFrame flag when bResizeShapeToFitText changes (which is mapped
40 // on the item SDRATTR_TEXT_AUTOGROWHEIGHT for custom shapes, argh)
42
43 // check if it did change
44 if(rObj.mbTextFrame != bOld)
45 {
46 // on change also invalidate render geometry
47 bInvalidateRenderGeometry = true;
48
49 // #115391# Potential recursion, since it calls SetObjectItemSet again, but rObj.bTextFrame
50 // will not change again. Thus it will be only one level and terminate safely
51 rObj.AdaptTextMinSize();
52 }
53
54 if(bInvalidateRenderGeometry)
55 {
56 // if asked for or bResizeShapeToFitText changed, make sure that
57 // the render geometry is reconstructed using changed parameters
59 }
60 }
61
63 {
64 return SfxItemSet(
65 rPool,
67 // Ranges from SdrAttrObj:
71 // Graphic attributes, 3D properties, CustomShape
72 // properties:
77 // Range from SdrTextObj:
79 }
80
81 bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const
82 {
83 bool bAllowItemChange = true;
84 if ( !pNewItem )
85 {
86 if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) )
87 bAllowItemChange = false;
88 }
89 if ( bAllowItemChange )
90 bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem );
91 return bAllowItemChange;
92 }
93
94 void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich)
95 {
96 if ( !nWhich )
97 {
98 SfxWhichIter aIter( *mxItemSet );
99 sal_uInt16 nWhich2 = aIter.FirstWhich();
100 while( nWhich2 )
101 {
103 nWhich2 = aIter.NextWhich();
104 }
105 ItemSetChanged({}, 0);
106 }
107 else
109 }
110
112 {
113 if ( !nWhich )
114 {
115 SfxWhichIter aIter( *mxItemSet );
116 sal_uInt16 nWhich2 = aIter.FirstWhich();
117 while( nWhich2 )
118 {
120 nWhich2 = aIter.NextWhich();
121 }
122 }
123 else
125 }
126
128 {
129 // call parent
130 TextProperties::ItemSetChanged(aChangedItems, nDeletedWhich);
131
132 // update bTextFrame and RenderGeometry
134 }
135
136 void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich)
137 {
138 switch(nWhich)
139 {
141 {
142 // #115391# update bTextFrame and RenderGeometry using AdaptTextMinSize()
144 break;
145 }
146 default:
147 {
148 break;
149 }
150 }
151
152 // call parent
154 }
155
156 void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
157 {
158 // call parent
159 TextProperties::ItemChange( nWhich, pNewItem );
160
161 // update bTextFrame and RenderGeometry
163 }
164
165 void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr,
166 bool bBroadcast)
167 {
168 // call parent (always first thing to do, may create the SfxItemSet)
169 TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr, bBroadcast );
170
171 // update bTextFrame and RenderGeometry
173 }
174
176 {
177 // update bTextFrame and RenderGeometry
179
180 // SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml
181 // This means: Do *not* call parent here is by purpose...
182 }
183
185 : TextProperties(rObj)
186 {
187 }
188
190 : TextProperties(rProps, rObj)
191 {
192 }
193
195 {
196 }
197
198 std::unique_ptr<BaseProperties> CustomShapeProperties::Clone(SdrObject& rObj) const
199 {
200 return std::unique_ptr<BaseProperties>(new CustomShapeProperties(*this, rObj));
201 }
202
204 {
205 TextProperties::Notify( rBC, rHint );
206
207 bool bRemoveRenderGeometry = false;
208 const SfxStyleSheetHint* pStyleHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint);
209
210 if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() )
211 {
212 switch( pStyleHint->GetId() )
213 {
214 case SfxHintId::StyleSheetModified :
215 case SfxHintId::StyleSheetChanged :
216 bRemoveRenderGeometry = true;
217 break;
218 default: break;
219 }
220 }
221 else if ( rHint.GetId() == SfxHintId::DataChanged )
222 {
223 bRemoveRenderGeometry = true;
224 }
225
226 // update bTextFrame and RenderGeometry
227 UpdateTextFrameStatus(bRemoveRenderGeometry);
228 }
229} // end of namespace
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InvalidateRenderGeometry()
Definition: svdoashp.cxx:3236
virtual void AdaptTextMinSize() override
Definition: svdoashp.cxx:1395
Abstract DrawObject.
Definition: svdobj.hxx:260
bool mbTextFrame
Definition: svdotext.hxx:242
SfxHintId GetId() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SfxStyleSheetBase * GetStyleSheet() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
virtual const SfxItemSet & GetObjectItemSet() const override
virtual SfxStyleSheet * GetStyleSheet() const override
const SdrObject & GetSdrObject() const
Definition: properties.cxx:43
virtual void ClearObjectItemDirect(const sal_uInt16 nWhich) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem *pNewItem=nullptr) override
void UpdateTextFrameStatus(bool bInvalidateRenderGeometry)
virtual void ClearObjectItem(const sal_uInt16 nWhich=0) override
virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool &rPool) override
virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem *pNewItem=nullptr) const override
virtual void PostItemChange(const sal_uInt16 nWhich) override
virtual void ItemSetChanged(o3tl::span< const SfxPoolItem *const > aChangedItems, sal_uInt16 nDeletedWhich) override
virtual void SetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast) override
virtual std::unique_ptr< BaseProperties > Clone(SdrObject &rObj) const override
virtual void ClearObjectItemDirect(const sal_uInt16 nWhich) override
virtual void ClearObjectItem(const sal_uInt16 nWhich=0) override
virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem *pNewItem=nullptr) const
std::optional< SfxItemSet > mxItemSet
virtual void PostItemChange(const sal_uInt16 nWhich)
virtual void SetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem *pNewItem=nullptr) override
virtual void ItemSetChanged(o3tl::span< const SfxPoolItem *const > aChangedItems, sal_uInt16 nDeletedWhich) override
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
static constexpr auto Items
constexpr sal_uInt16 SDRATTR_CUSTOMSHAPE_FIRST(SDRATTR_3D_LAST+1)
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr sal_uInt16 SDRATTR_TEXTCOLUMNS_FIRST(SDRATTR_SOFTEDGE_LAST+1)
constexpr sal_uInt16 SDRATTR_CUSTOMSHAPE_LAST(SDRATTR_CUSTOMSHAPE_GEOMETRY)
constexpr sal_uInt16 SDRATTR_MISC_LAST(SDRATTR_TEXT_CLIPVERTOVERFLOW)
constexpr sal_uInt16 SDRATTR_GLOW_FIRST(SDRATTR_TABLE_LAST+1)
constexpr sal_uInt16 SDRATTR_SOFTEDGE_LAST(SDRATTR_SOFTEDGE_RADIUS)
constexpr sal_uInt16 SDRATTR_MISC_FIRST(SDRATTR_CAPTION_LAST+1)
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_AUTOGROWHEIGHT(SDRATTR_MISC_FIRST+2)
constexpr sal_uInt16 SDRATTR_TEXTCOLUMNS_LAST(SDRATTR_TEXTCOLUMNS_SPACING)
constexpr sal_uInt16 SDRATTR_GRAF_FIRST(SDRATTR_NOTPERSIST_LAST+1)
constexpr sal_uInt16 SDRATTR_SHADOW_LAST(SDRATTR_SHADOWALIGNMENT)
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
constexpr TypedWhichId< SvxFrameDirectionItem > SDRATTR_WRITINGMODE2(SDRATTR_WRITINGMODE2_FIRST+0)