xref: /trunk/main/svx/source/engine3d/cube3d.cxx (revision 61dff127b6698e0bae836c8aedd6ec62111483d1)
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 
31 #include "svx/svdstr.hrc"
32 #include "svx/svdglob.hxx"
33 #include <svx/cube3d.hxx>
34 #include "svx/globl3d.hxx"
35 #include <basegfx/point/b3dpoint.hxx>
36 #include <basegfx/polygon/b3dpolygon.hxx>
37 #include <svx/sdr/contact/viewcontactofe3dcube.hxx>
38 
39 //////////////////////////////////////////////////////////////////////////////
40 // #110094# DrawContact section
41 
42 sdr::contact::ViewContact* E3dCubeObj::CreateObjectSpecificViewContact()
43 {
44     return new sdr::contact::ViewContactOfE3dCube(*this);
45 }
46 
47 TYPEINIT1(E3dCubeObj, E3dCompoundObject);
48 
49 /*************************************************************************
50 |*
51 |* Konstruktor:                                                 |
52 |* 3D-Quader erzeugen; aPos: Zentrum oder links, unten, hinten  |__
53 |*                           (abhaengig von bPosIsCenter)      /
54 |*
55 \************************************************************************/
56 
57 E3dCubeObj::E3dCubeObj(E3dDefaultAttributes& rDefault, basegfx::B3DPoint aPos, const basegfx::B3DVector& r3DSize)
58 :   E3dCompoundObject(rDefault)
59 {
60     // Defaults setzen
61     SetDefaultAttributes(rDefault);
62 
63     // uebergebene drueberbuegeln
64     aCubePos = aPos;
65     aCubeSize = r3DSize;
66 }
67 
68 E3dCubeObj::E3dCubeObj()
69 :   E3dCompoundObject()
70 {
71     // Defaults setzen
72     E3dDefaultAttributes aDefault;
73     SetDefaultAttributes(aDefault);
74 }
75 
76 void E3dCubeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
77 {
78     aCubePos = rDefault.GetDefaultCubePos();
79     aCubeSize = rDefault.GetDefaultCubeSize();
80     nSideFlags = rDefault.GetDefaultCubeSideFlags();
81     bPosIsCenter = rDefault.GetDefaultCubePosIsCenter();
82 }
83 
84 /*************************************************************************
85 |*
86 |* Identifier zurueckgeben
87 |*
88 \************************************************************************/
89 
90 sal_uInt16 E3dCubeObj::GetObjIdentifier() const
91 {
92     return E3D_CUBEOBJ_ID;
93 }
94 
95 /*************************************************************************
96 |*
97 |* Wandle das Objekt in ein Gruppenobjekt bestehend aus 6 Polygonen
98 |*
99 \************************************************************************/
100 
101 SdrObject *E3dCubeObj::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const
102 {
103     return NULL;
104 }
105 
106 /*************************************************************************
107 |*
108 |* Zuweisungsoperator
109 |*
110 \************************************************************************/
111 
112 void E3dCubeObj::operator=(const SdrObject& rObj)
113 {
114     // erstmal alle Childs kopieren
115     E3dCompoundObject::operator=(rObj);
116 
117     // weitere Parameter kopieren
118     const E3dCubeObj& r3DObj = (const E3dCubeObj&)rObj;
119 
120     aCubePos = r3DObj.aCubePos;
121     aCubeSize = r3DObj.aCubeSize;
122     bPosIsCenter = r3DObj.bPosIsCenter;
123     nSideFlags = r3DObj.nSideFlags;
124 }
125 
126 /*************************************************************************
127 |*
128 |* Lokale Parameter setzen mit Geometrieneuerzeugung
129 |*
130 \************************************************************************/
131 
132 void E3dCubeObj::SetCubePos(const basegfx::B3DPoint& rNew)
133 {
134     if(aCubePos != rNew)
135     {
136         aCubePos = rNew;
137         ActionChanged();
138     }
139 }
140 
141 void E3dCubeObj::SetCubeSize(const basegfx::B3DVector& rNew)
142 {
143     if(aCubeSize != rNew)
144     {
145         aCubeSize = rNew;
146         ActionChanged();
147     }
148 }
149 
150 void E3dCubeObj::SetPosIsCenter(sal_Bool bNew)
151 {
152     if(bPosIsCenter != bNew)
153     {
154         bPosIsCenter = bNew;
155         ActionChanged();
156     }
157 }
158 
159 void E3dCubeObj::SetSideFlags(sal_uInt16 nNew)
160 {
161     if(nSideFlags != nNew)
162     {
163         nSideFlags = nNew;
164         ActionChanged();
165     }
166 }
167 
168 /*************************************************************************
169 |*
170 |* Get the name of the object (singular)
171 |*
172 \************************************************************************/
173 
174 void E3dCubeObj::TakeObjNameSingul(XubString& rName) const
175 {
176     rName=ImpGetResStr(STR_ObjNameSingulCube3d);
177 
178     String aName( GetName() );
179     if(aName.Len())
180     {
181         rName += sal_Unicode(' ');
182         rName += sal_Unicode('\'');
183         rName += aName;
184         rName += sal_Unicode('\'');
185     }
186 }
187 
188 /*************************************************************************
189 |*
190 |* Get the name of the object (plural)
191 |*
192 \************************************************************************/
193 
194 void E3dCubeObj::TakeObjNamePlural(XubString& rName) const
195 {
196     rName=ImpGetResStr(STR_ObjNamePluralCube3d);
197 }
198 
199 // eof
200