xref: /AOO41X/main/svx/source/sdr/properties/circleproperties.cxx (revision ff0525f24f03981d56b7579b645949f111420994)
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/circleproperties.hxx>
27 #include <svl/itemset.hxx>
28 #include <svl/style.hxx>
29 #include <svx/svddef.hxx>
30 #include <editeng/eeitem.hxx>
31 #include <svx/svdocirc.hxx>
32 #include <svx/sxcikitm.hxx>
33 #include <svx/sxciaitm.hxx>
34 #include <svx/sxciaitm.hxx>
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 namespace sdr
39 {
40     namespace properties
41     {
42         // create a new itemset
43         SfxItemSet& CircleProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
44         {
45             return *(new SfxItemSet(rPool,
46 
47                 // range from SdrAttrObj
48                 SDRATTR_START, SDRATTR_SHADOW_LAST,
49                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
50                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
51 
52                 // range from SdrCircObj
53                 SDRATTR_CIRC_FIRST, SDRATTR_CIRC_LAST,
54 
55                 // range from SdrTextObj
56                 EE_ITEMS_START, EE_ITEMS_END,
57 
58                 // end
59                 0, 0));
60         }
61 
62         CircleProperties::CircleProperties(SdrObject& rObj)
63         :   RectangleProperties(rObj)
64         {
65         }
66 
67         CircleProperties::CircleProperties(const CircleProperties& rProps, SdrObject& rObj)
68         :   RectangleProperties(rProps, rObj)
69         {
70         }
71 
72         CircleProperties::~CircleProperties()
73         {
74         }
75 
76         BaseProperties& CircleProperties::Clone(SdrObject& rObj) const
77         {
78             return *(new CircleProperties(*this, rObj));
79         }
80 
81         void CircleProperties::ItemSetChanged(const SfxItemSet& rSet)
82         {
83             SdrCircObj& rObj = (SdrCircObj&)GetSdrObject();
84 
85             // call parent
86             RectangleProperties::ItemSetChanged(rSet);
87 
88             // local changes
89             rObj.ImpSetAttrToCircInfo();
90         }
91 
92         void CircleProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
93         {
94             SdrCircObj& rObj = (SdrCircObj&)GetSdrObject();
95 
96             // local changes
97             rObj.SetXPolyDirty();
98 
99             // call parent
100             RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
101 
102             // local changes
103             rObj.ImpSetAttrToCircInfo();
104         }
105 
106         void CircleProperties::ForceDefaultAttributes()
107         {
108             SdrCircObj& rObj = (SdrCircObj&)GetSdrObject();
109             SdrCircKind eKindA = SDRCIRC_FULL;
110             SdrObjKind eKind = rObj.GetCircleKind();
111 
112             if(eKind == OBJ_SECT)
113             {
114                 eKindA = SDRCIRC_SECT;
115             }
116             else if(eKind == OBJ_CARC)
117             {
118                 eKindA = SDRCIRC_ARC;
119             }
120             else if(eKind == OBJ_CCUT)
121             {
122                 eKindA = SDRCIRC_CUT;
123             }
124 
125             if(eKindA != SDRCIRC_FULL)
126             {
127                 // force ItemSet
128                 GetObjectItemSet();
129 
130                 mpItemSet->Put(SdrCircKindItem(eKindA));
131 
132                 if(rObj.GetStartWink())
133                 {
134                     mpItemSet->Put(SdrCircStartAngleItem(rObj.GetStartWink()));
135                 }
136 
137                 if(rObj.GetEndWink() != 36000)
138                 {
139                     mpItemSet->Put(SdrCircEndAngleItem(rObj.GetEndWink()));
140                 }
141             }
142 
143             // call parent after SetObjectItem(SdrCircKindItem())
144             // because ForceDefaultAttr() will call
145             // ImpSetAttrToCircInfo() which needs a correct
146             // SdrCircKindItem
147             RectangleProperties::ForceDefaultAttributes();
148         }
149     } // end of namespace properties
150 } // end of namespace sdr
151 
152 //////////////////////////////////////////////////////////////////////////////
153 // eof
154