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 #include <svx/sdr/properties/measureproperties.hxx>
27 #include <svl/itemset.hxx>
28 #include <svl/style.hxx>
29 #include <svx/svddef.hxx>
30 #include <editeng/eeitem.hxx>
31 #include <svx/svdomeas.hxx>
32 #include <svx/sxmsuitm.hxx>
33 #include <svx/xlnstit.hxx>
34 #include <svx/xlnstwit.hxx>
35 #include <svx/xlnedit.hxx>
36 #include <svx/xlnedwit.hxx>
37 #include <basegfx/point/b2dpoint.hxx>
38 #include <basegfx/polygon/b2dpolygon.hxx>
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 namespace sdr
43 {
44 	namespace properties
45 	{
46 		// create a new itemset
CreateObjectSpecificItemSet(SfxItemPool & rPool)47 		SfxItemSet& MeasureProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
48 		{
49 			return *(new SfxItemSet(rPool,
50 
51 				// range from SdrAttrObj
52 				SDRATTR_START, SDRATTR_SHADOW_LAST,
53 				SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
54 				SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
55 
56 				// range from SdrMeasureObj
57 				SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
58 
59 				// range from SdrTextObj
60 				EE_ITEMS_START, EE_ITEMS_END,
61 
62 				// end
63 				0, 0));
64 		}
65 
MeasureProperties(SdrObject & rObj)66 		MeasureProperties::MeasureProperties(SdrObject& rObj)
67 		:	TextProperties(rObj)
68 		{
69 		}
70 
MeasureProperties(const MeasureProperties & rProps,SdrObject & rObj)71 		MeasureProperties::MeasureProperties(const MeasureProperties& rProps, SdrObject& rObj)
72 		:	TextProperties(rProps, rObj)
73 		{
74 		}
75 
~MeasureProperties()76 		MeasureProperties::~MeasureProperties()
77 		{
78 		}
79 
Clone(SdrObject & rObj) const80 		BaseProperties& MeasureProperties::Clone(SdrObject& rObj) const
81 		{
82 			return *(new MeasureProperties(*this, rObj));
83 		}
84 
ItemSetChanged(const SfxItemSet & rSet)85 		void MeasureProperties::ItemSetChanged(const SfxItemSet& rSet)
86 		{
87 			SdrMeasureObj& rObj = (SdrMeasureObj&)GetSdrObject();
88 
89 			// call parent
90 			TextProperties::ItemSetChanged(rSet);
91 
92 			// local changes
93 			rObj.SetTextDirty();
94 		}
95 
SetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)96 		void MeasureProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
97 		{
98 			SdrMeasureObj& rObj = (SdrMeasureObj&)GetSdrObject();
99 
100 			// local changes
101 			rObj.SetTextDirty();
102 
103 			// call parent
104 			TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
105 		}
106 
ForceDefaultAttributes()107 		void MeasureProperties::ForceDefaultAttributes()
108 		{
109 			// call parent
110 			TextProperties::ForceDefaultAttributes();
111 
112 			// force ItemSet
113 			GetObjectItemSet();
114 
115 			//#71958# by default, the show units Bool-Item is set as hard
116 			// attribute to sal_True to avoid confusion when copying SdrMeasureObj's
117 			// from one application to another
118 			mpItemSet->Put(SdrMeasureShowUnitItem(sal_True));
119 
120 			basegfx::B2DPolygon aNewPolygon;
121 			aNewPolygon.append(basegfx::B2DPoint(100.0, 0.0));
122 			aNewPolygon.append(basegfx::B2DPoint(200.0, 400.0));
123 			aNewPolygon.append(basegfx::B2DPoint(0.0, 400.0));
124 			aNewPolygon.setClosed(true);
125 
126 			mpItemSet->Put(XLineStartItem(String(), basegfx::B2DPolyPolygon(aNewPolygon)));
127 			mpItemSet->Put(XLineStartWidthItem(200));
128 			mpItemSet->Put(XLineEndItem(String(), basegfx::B2DPolyPolygon(aNewPolygon)));
129 			mpItemSet->Put(XLineEndWidthItem(200));
130 			mpItemSet->Put(XLineStyleItem(XLINE_SOLID));
131 		}
132 	} // end of namespace properties
133 } // end of namespace sdr
134 
135 //////////////////////////////////////////////////////////////////////////////
136 
137 // eof
138