xref: /trunk/main/svx/source/sdr/properties/measureproperties.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/sdr/properties/measureproperties.hxx>
31 #include <svl/itemset.hxx>
32 #include <svl/style.hxx>
33 #include <svx/svddef.hxx>
34 #include <editeng/eeitem.hxx>
35 #include <svx/svdomeas.hxx>
36 #include <svx/sxmsuitm.hxx>
37 #include <svx/xlnstit.hxx>
38 #include <svx/xlnstwit.hxx>
39 #include <svx/xlnedit.hxx>
40 #include <svx/xlnedwit.hxx>
41 #include <basegfx/point/b2dpoint.hxx>
42 #include <basegfx/polygon/b2dpolygon.hxx>
43 
44 //////////////////////////////////////////////////////////////////////////////
45 
46 namespace sdr
47 {
48     namespace properties
49     {
50         // create a new itemset
51         SfxItemSet& MeasureProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
52         {
53             return *(new SfxItemSet(rPool,
54 
55                 // range from SdrAttrObj
56                 SDRATTR_START, SDRATTR_SHADOW_LAST,
57                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
58                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
59 
60                 // range from SdrMeasureObj
61                 SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
62 
63                 // range from SdrTextObj
64                 EE_ITEMS_START, EE_ITEMS_END,
65 
66                 // end
67                 0, 0));
68         }
69 
70         MeasureProperties::MeasureProperties(SdrObject& rObj)
71         :   TextProperties(rObj)
72         {
73         }
74 
75         MeasureProperties::MeasureProperties(const MeasureProperties& rProps, SdrObject& rObj)
76         :   TextProperties(rProps, rObj)
77         {
78         }
79 
80         MeasureProperties::~MeasureProperties()
81         {
82         }
83 
84         BaseProperties& MeasureProperties::Clone(SdrObject& rObj) const
85         {
86             return *(new MeasureProperties(*this, rObj));
87         }
88 
89         void MeasureProperties::ItemSetChanged(const SfxItemSet& rSet)
90         {
91             SdrMeasureObj& rObj = (SdrMeasureObj&)GetSdrObject();
92 
93             // call parent
94             TextProperties::ItemSetChanged(rSet);
95 
96             // local changes
97             rObj.SetTextDirty();
98         }
99 
100         void MeasureProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
101         {
102             SdrMeasureObj& rObj = (SdrMeasureObj&)GetSdrObject();
103 
104             // local changes
105             rObj.SetTextDirty();
106 
107             // call parent
108             TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
109         }
110 
111         void MeasureProperties::ForceDefaultAttributes()
112         {
113             // call parent
114             TextProperties::ForceDefaultAttributes();
115 
116             // force ItemSet
117             GetObjectItemSet();
118 
119             //#71958# by default, the show units Bool-Item is set as hard
120             // attribute to sal_True to aviod confusion when copying SdrMeasureObj's
121             // from one application to another
122             mpItemSet->Put(SdrMeasureShowUnitItem(sal_True));
123 
124             basegfx::B2DPolygon aNewPolygon;
125             aNewPolygon.append(basegfx::B2DPoint(100.0, 0.0));
126             aNewPolygon.append(basegfx::B2DPoint(200.0, 400.0));
127             aNewPolygon.append(basegfx::B2DPoint(0.0, 400.0));
128             aNewPolygon.setClosed(true);
129 
130             mpItemSet->Put(XLineStartItem(String(), basegfx::B2DPolyPolygon(aNewPolygon)));
131             mpItemSet->Put(XLineStartWidthItem(200));
132             mpItemSet->Put(XLineEndItem(String(), basegfx::B2DPolyPolygon(aNewPolygon)));
133             mpItemSet->Put(XLineEndWidthItem(200));
134             mpItemSet->Put(XLineStyleItem(XLINE_SOLID));
135         }
136     } // end of namespace properties
137 } // end of namespace sdr
138 
139 //////////////////////////////////////////////////////////////////////////////
140 
141 // eof
142