merge the formfield patch from ooo-build
[ooovba.git] / svx / source / engine3d / sphere3d.cxx
blobb6910274f4aff07407b1aa0a655986479bc2bb8e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sphere3d.cxx,v $
10 * $Revision: 1.20.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "svdstr.hrc"
35 #include "svdglob.hxx"
36 #include <svx/svdmodel.hxx>
37 #include <svx/svdpage.hxx>
38 #include "globl3d.hxx"
39 #include <svx/sphere3d.hxx>
41 #include <svx/svxids.hrc>
42 #include <svx/svx3ditems.hxx>
43 #include <svx/sdr/properties/e3dsphereproperties.hxx>
44 #include <basegfx/vector/b3dvector.hxx>
45 #include <basegfx/point/b3dpoint.hxx>
46 #include <svx/sdr/contact/viewcontactofe3dsphere.hxx>
47 #include <basegfx/polygon/b3dpolygon.hxx>
49 //////////////////////////////////////////////////////////////////////////////
50 // #110094# DrawContact section
52 sdr::contact::ViewContact* E3dSphereObj::CreateObjectSpecificViewContact()
54 return new sdr::contact::ViewContactOfE3dSphere(*this);
57 //////////////////////////////////////////////////////////////////////////////
59 sdr::properties::BaseProperties* E3dSphereObj::CreateObjectSpecificProperties()
61 return new sdr::properties::E3dSphereProperties(*this);
64 //////////////////////////////////////////////////////////////////////////////
66 TYPEINIT1(E3dSphereObj, E3dCompoundObject);
68 /*************************************************************************
70 |* Kugel aus Polygonfacetten nach Laengen und Breitengrad aufbauen
72 \************************************************************************/
74 E3dSphereObj::E3dSphereObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& rCenter, const basegfx::B3DVector& r3DSize)
75 : E3dCompoundObject(rDefault)
77 // Defaults setzen
78 SetDefaultAttributes(rDefault);
80 // Uebergebene drueberbuegeln
81 aCenter = rCenter;
82 aSize = r3DSize;
85 E3dSphereObj::E3dSphereObj()
86 : E3dCompoundObject()
88 // Defaults setzen
89 E3dDefaultAttributes aDefault;
90 SetDefaultAttributes(aDefault);
93 /*************************************************************************
95 |* Kugel erzeugen ohne die Polygone darin zu erzeugen
97 \************************************************************************/
99 // FG: Dieser Aufruf erfolgt von der 3D-Object Factory (objfac3d.cxx) und zwar ausschliesslich beim
100 // laden von Dokumenten. Hier braucht man keinen CreateSphere-Aufruf, denn die wirkliche
101 // Anzahl Segmente ist ja noch nicht bekannt. Dies war bis zum 10.2.97 ein (kleines)
102 // Speicherleck.
103 E3dSphereObj::E3dSphereObj(int /*dummy*/) // den Parameter braucht es um unterscheiden zu koennen, welcher
104 { // der beiden Konstruktoren gemeint ist. Der obige halt per Default
105 // Defaults setzen
106 E3dDefaultAttributes aDefault;
107 SetDefaultAttributes(aDefault);
110 void E3dSphereObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
112 // Defaults setzen
113 aCenter = rDefault.GetDefaultSphereCenter();
114 aSize = rDefault.GetDefaultSphereSize();
117 /*************************************************************************
119 |* Identifier zurueckgeben
121 \************************************************************************/
123 UINT16 E3dSphereObj::GetObjIdentifier() const
125 return E3D_SPHEREOBJ_ID;
128 /*************************************************************************
130 |* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen
132 \************************************************************************/
134 SdrObject *E3dSphereObj::DoConvertToPolyObj(BOOL /*bBezier*/) const
136 return NULL;
139 /*************************************************************************
141 |* Leer-Konstruktor
143 \************************************************************************/
145 void E3dSphereObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs)
147 if((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) && (nHSegs != 0 || nVSegs != 0))
149 GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs));
150 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs));
152 ActionChanged();
156 /*************************************************************************
158 |* Zuweisungsoperator
160 \************************************************************************/
162 void E3dSphereObj::operator=(const SdrObject& rObj)
164 // erstmal alle Childs kopieren
165 E3dCompoundObject::operator=(rObj);
167 // weitere Parameter kopieren
168 const E3dSphereObj& r3DObj = (const E3dSphereObj&) rObj;
170 aCenter = r3DObj.aCenter;
171 aSize = r3DObj.aSize;
174 /*************************************************************************
176 |* Lokale Parameter setzen mit Geometrieneuerzeugung
178 \************************************************************************/
180 void E3dSphereObj::SetCenter(const basegfx::B3DPoint& rNew)
182 if(aCenter != rNew)
184 aCenter = rNew;
185 ActionChanged();
189 void E3dSphereObj::SetSize(const basegfx::B3DVector& rNew)
191 if(aSize != rNew)
193 aSize = rNew;
194 ActionChanged();
198 /*************************************************************************
200 |* Get the name of the object (singular)
202 \************************************************************************/
204 void E3dSphereObj::TakeObjNameSingul(XubString& rName) const
206 rName=ImpGetResStr(STR_ObjNameSingulSphere3d);
208 String aName( GetName() );
209 if(aName.Len())
211 rName += sal_Unicode(' ');
212 rName += sal_Unicode('\'');
213 rName += aName;
214 rName += sal_Unicode('\'');
218 /*************************************************************************
220 |* Get the name of the object (plural)
222 \************************************************************************/
224 void E3dSphereObj::TakeObjNamePlural(XubString& rName) const
226 rName=ImpGetResStr(STR_ObjNamePluralSphere3d);
229 // eof