xref: /aoo42x/main/svx/source/svdraw/svdoattr.cxx (revision f6e50924)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <svx/svdoattr.hxx>
28 #include <svx/xpool.hxx>
29 #include "svx/svditext.hxx"
30 #include <svx/svdmodel.hxx>
31 #include <svx/svdpage.hxx>
32 #include <svx/svdattr.hxx>
33 #include <svx/svdattrx.hxx>
34 #include <svx/svdpool.hxx>
35 #include <svx/svdotext.hxx>
36 #include <svx/svdocapt.hxx>
37 #include <svx/svdograf.hxx>
38 #include <svx/svdoole2.hxx>
39 #include <svx/svdorect.hxx>
40 #include <svx/svdocirc.hxx>
41 #include <svx/svdomeas.hxx>
42 #include <svl/smplhint.hxx>
43 #include <svl/itemiter.hxx>
44 #include <svx/xenum.hxx>
45 #include <svx/xlineit0.hxx>
46 #include <svx/xlnstwit.hxx>
47 #include <svx/xlnedwit.hxx>
48 #include <svx/xfillit0.hxx>
49 #include <svx/xflbmtit.hxx>
50 #include <svx/xtextit0.hxx>
51 #include <svx/xflbstit.hxx>
52 #include <svx/xflbtoxy.hxx>
53 #include <svx/xftshit.hxx>
54 
55 
56 #include <editeng/colritem.hxx>
57 #include "editeng/fontitem.hxx"
58 #include <editeng/fhgtitem.hxx>
59 
60 //#include <editeng/charscaleitem.hxx>
61 #include <svx/xlnstcit.hxx>
62 #include <svx/xlnwtit.hxx>
63 #include <svl/style.hxx>
64 #include <svl/style.hxx>
65 #include <svl/whiter.hxx>
66 #include <svx/xlnclit.hxx>
67 #include <svx/xflclit.hxx>
68 #include <svx/xlntrit.hxx>
69 #include <svx/xfltrit.hxx>
70 #include <svx/xlnedcit.hxx>
71 #include <editeng/adjitem.hxx>
72 #include <svx/xflbckit.hxx>
73 #include <svx/xtable.hxx>
74 #include <svx/xbtmpit.hxx>
75 #include <svx/xlndsit.hxx>
76 #include <svx/xlnedit.hxx>
77 #include <svx/xflgrit.hxx>
78 #include <svx/xflftrit.hxx>
79 #include <svx/xflhtit.hxx>
80 #include <svx/xlnstit.hxx>
81 #include <svx/sdr/properties/attributeproperties.hxx>
82 #include <basegfx/polygon/b2dpolygon.hxx>
83 #include "svx/xlinjoit.hxx"
84 #include <svdoimp.hxx>
85 
86 //////////////////////////////////////////////////////////////////////////////
87 
CreateObjectSpecificProperties()88 sdr::properties::BaseProperties* SdrAttrObj::CreateObjectSpecificProperties()
89 {
90 	return new sdr::properties::AttributeProperties(*this);
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////////////////////////
94 
95 TYPEINIT1(SdrAttrObj,SdrObject);
96 
SdrAttrObj()97 SdrAttrObj::SdrAttrObj()
98 {
99 }
100 
~SdrAttrObj()101 SdrAttrObj::~SdrAttrObj()
102 {
103 }
104 
GetSnapRect() const105 const Rectangle& SdrAttrObj::GetSnapRect() const
106 {
107 	if(bSnapRectDirty)
108 	{
109 		((SdrAttrObj*)this)->RecalcSnapRect();
110 		((SdrAttrObj*)this)->bSnapRectDirty = false;
111 	}
112 
113 	return maSnapRect;
114 }
115 
SetModel(SdrModel * pNewModel)116 void SdrAttrObj::SetModel(SdrModel* pNewModel)
117 {
118 	SdrModel* pOldModel = pModel;
119 
120 	// test for correct pool in ItemSet; move to new pool if necessary
121 	if(pNewModel && GetObjectItemPool() && GetObjectItemPool() != &pNewModel->GetItemPool())
122 	{
123 		MigrateItemPool(GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
124 	}
125 
126 	// call parent
127 	SdrObject::SetModel(pNewModel);
128 
129 	// modify properties
130 	GetProperties().SetModel(pOldModel, pNewModel);
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////////////////////////
134 // syntactical sugar for ItemSet accesses
135 
Notify(SfxBroadcaster &,const SfxHint & rHint)136 void __EXPORT SdrAttrObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
137 {
138 	SfxSimpleHint *pSimple = PTR_CAST(SfxSimpleHint, &rHint);
139 	sal_Bool bDataChg(pSimple && SFX_HINT_DATACHANGED == pSimple->GetId());
140 
141 	if(bDataChg)
142 	{
143 		Rectangle aBoundRect = GetLastBoundRect();
144 		SetBoundRectDirty();
145 		SetRectsDirty(sal_True);
146 
147 		// This may have lead to object change
148 		SetChanged();
149 		BroadcastObjectChange();
150 		SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect);
151 	}
152 }
153 
ImpGetLineWdt() const154 sal_Int32 SdrAttrObj::ImpGetLineWdt() const
155 {
156 	sal_Int32 nRetval(0);
157 
158 	if(XLINE_NONE != ((XLineStyleItem&)(GetObjectItem(XATTR_LINESTYLE))).GetValue())
159 	{
160 		nRetval = ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
161 	}
162 
163 	return nRetval;
164 }
165 
HasFill() const166 sal_Bool SdrAttrObj::HasFill() const
167 {
168 	return bClosedObj && ((XFillStyleItem&)(GetProperties().GetObjectItemSet().Get(XATTR_FILLSTYLE))).GetValue()!=XFILL_NONE;
169 }
170 
HasLine() const171 sal_Bool SdrAttrObj::HasLine() const
172 {
173 	return ((XLineStyleItem&)(GetProperties().GetObjectItemSet().Get(XATTR_LINESTYLE))).GetValue()!=XLINE_NONE;
174 }
175 
176 // eof
177