1cdf0e10cSrcweir /************************************************************************* 2cdf0e10cSrcweir * 3cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir * 5cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir * 7cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir * 9cdf0e10cSrcweir * This file is part of OpenOffice.org. 10cdf0e10cSrcweir * 11cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14cdf0e10cSrcweir * 15cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir * 21cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25cdf0e10cSrcweir * 26cdf0e10cSrcweir ************************************************************************/ 27cdf0e10cSrcweir 28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29cdf0e10cSrcweir #include "precompiled_svx.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "svx/svdstr.hrc" 32cdf0e10cSrcweir #include "svx/svdglob.hxx" 33cdf0e10cSrcweir #include <tools/poly.hxx> 34cdf0e10cSrcweir #include <svx/svdpage.hxx> 35cdf0e10cSrcweir #include "svx/globl3d.hxx" 36cdf0e10cSrcweir #include <svx/lathe3d.hxx> 37cdf0e10cSrcweir #include <svx/xpoly.hxx> 38cdf0e10cSrcweir #include <svx/svxids.hrc> 39cdf0e10cSrcweir #include <svx/svdopath.hxx> 40cdf0e10cSrcweir #include <svx/svdmodel.hxx> 41cdf0e10cSrcweir #include <svx/svx3ditems.hxx> 42cdf0e10cSrcweir #include <svx/sdr/properties/e3dlatheproperties.hxx> 43cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3dlathe.hxx> 44cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 45cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 46cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 49cdf0e10cSrcweir // #110094# DrawContact section 50cdf0e10cSrcweir 51cdf0e10cSrcweir sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact() 52cdf0e10cSrcweir { 53cdf0e10cSrcweir return new sdr::contact::ViewContactOfE3dLathe(*this); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 57cdf0e10cSrcweir 58cdf0e10cSrcweir sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir return new sdr::properties::E3dLatheProperties(*this); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 64cdf0e10cSrcweir 65cdf0e10cSrcweir TYPEINIT1(E3dLatheObj, E3dCompoundObject); 66cdf0e10cSrcweir 67cdf0e10cSrcweir /************************************************************************* 68cdf0e10cSrcweir |* 69cdf0e10cSrcweir |* Konstruktor aus 3D-Polygon, Scale gibt den Umrechnungsfaktor fuer 70cdf0e10cSrcweir |* die Koordinaten an 71cdf0e10cSrcweir |* 72cdf0e10cSrcweir \************************************************************************/ 73cdf0e10cSrcweir 74cdf0e10cSrcweir E3dLatheObj::E3dLatheObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon rPoly2D) 75cdf0e10cSrcweir : E3dCompoundObject(rDefault), 76cdf0e10cSrcweir maPolyPoly2D(rPoly2D) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here 79cdf0e10cSrcweir basegfx::B2DHomMatrix aMirrorY; 80cdf0e10cSrcweir aMirrorY.scale(1.0, -1.0); 81cdf0e10cSrcweir maPolyPoly2D.transform(aMirrorY); 82cdf0e10cSrcweir 83cdf0e10cSrcweir // Defaults setzen 84cdf0e10cSrcweir SetDefaultAttributes(rDefault); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // Ueberfluessige Punkte entfernen, insbesondere doppelte 87cdf0e10cSrcweir // Start- und Endpunkte verhindern 88cdf0e10cSrcweir maPolyPoly2D.removeDoublePoints(); 89cdf0e10cSrcweir 90cdf0e10cSrcweir if(maPolyPoly2D.count()) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L)); 93cdf0e10cSrcweir sal_uInt32 nSegCnt(rPoly.count()); 94cdf0e10cSrcweir 95cdf0e10cSrcweir if(nSegCnt && !rPoly.isClosed()) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir nSegCnt -= 1; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt)); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir /************************************************************************* 105cdf0e10cSrcweir |* 106cdf0e10cSrcweir |* Leer-Konstruktor 107cdf0e10cSrcweir |* 108cdf0e10cSrcweir \************************************************************************/ 109cdf0e10cSrcweir 110cdf0e10cSrcweir E3dLatheObj::E3dLatheObj() 111cdf0e10cSrcweir : E3dCompoundObject() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir // Defaults setzen 114cdf0e10cSrcweir E3dDefaultAttributes aDefault; 115cdf0e10cSrcweir SetDefaultAttributes(aDefault); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed())); 121cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack())); 122cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode())); 123cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront())); 124cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack())); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir /************************************************************************* 128cdf0e10cSrcweir |* 129cdf0e10cSrcweir |* Identifier zurueckgeben 130cdf0e10cSrcweir |* 131cdf0e10cSrcweir \************************************************************************/ 132cdf0e10cSrcweir 133cdf0e10cSrcweir sal_uInt16 E3dLatheObj::GetObjIdentifier() const 134cdf0e10cSrcweir { 135cdf0e10cSrcweir return E3D_LATHEOBJ_ID; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir /************************************************************************* 139cdf0e10cSrcweir |* 140cdf0e10cSrcweir |* Zuweisungsoperator 141cdf0e10cSrcweir |* 142cdf0e10cSrcweir \************************************************************************/ 143cdf0e10cSrcweir 144cdf0e10cSrcweir void E3dLatheObj::operator=(const SdrObject& rObj) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir // erstmal alle Childs kopieren 147cdf0e10cSrcweir E3dCompoundObject::operator=(rObj); 148cdf0e10cSrcweir 149cdf0e10cSrcweir // weitere Parameter kopieren 150cdf0e10cSrcweir const E3dLatheObj& r3DObj = (const E3dLatheObj&)rObj; 151cdf0e10cSrcweir 152cdf0e10cSrcweir maPolyPoly2D = r3DObj.maPolyPoly2D; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir /************************************************************************* 156cdf0e10cSrcweir |* 157cdf0e10cSrcweir |* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen 158cdf0e10cSrcweir |* 159cdf0e10cSrcweir \************************************************************************/ 160cdf0e10cSrcweir 161*a5258243SPedro Giffuni SdrObject *E3dLatheObj::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const 162cdf0e10cSrcweir { 163cdf0e10cSrcweir return NULL; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir /************************************************************************* 167cdf0e10cSrcweir |* 168cdf0e10cSrcweir |* Neue Segmentierung (Beschreibung siehe Header-File) 169cdf0e10cSrcweir |* 170cdf0e10cSrcweir \************************************************************************/ 171cdf0e10cSrcweir 172cdf0e10cSrcweir void E3dLatheObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir if ((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) && 175cdf0e10cSrcweir (nHSegs != 0 || nVSegs != 0)) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs)); 178cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs)); 179cdf0e10cSrcweir 180cdf0e10cSrcweir ActionChanged(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir /************************************************************************* 185cdf0e10cSrcweir |* 186cdf0e10cSrcweir |* Lokale Parameter setzen mit Geometrieneuerzeugung 187cdf0e10cSrcweir |* 188cdf0e10cSrcweir \************************************************************************/ 189cdf0e10cSrcweir 190cdf0e10cSrcweir void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir if(maPolyPoly2D != rNew) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir maPolyPoly2D = rNew; 195cdf0e10cSrcweir maPolyPoly2D.removeDoublePoints(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir if(maPolyPoly2D.count()) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L)); 200cdf0e10cSrcweir sal_uInt32 nSegCnt(rPoly.count()); 201cdf0e10cSrcweir 202cdf0e10cSrcweir if(nSegCnt && !rPoly.isClosed()) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir nSegCnt -= 1; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt)); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir ActionChanged(); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir /************************************************************************* 215cdf0e10cSrcweir |* 216cdf0e10cSrcweir |* Get the name of the object (singular) 217cdf0e10cSrcweir |* 218cdf0e10cSrcweir \************************************************************************/ 219cdf0e10cSrcweir 220cdf0e10cSrcweir void E3dLatheObj::TakeObjNameSingul(XubString& rName) const 221cdf0e10cSrcweir { 222cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNameSingulLathe3d); 223cdf0e10cSrcweir 224cdf0e10cSrcweir String aName( GetName() ); 225cdf0e10cSrcweir if(aName.Len()) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir rName += sal_Unicode(' '); 228cdf0e10cSrcweir rName += sal_Unicode('\''); 229cdf0e10cSrcweir rName += aName; 230cdf0e10cSrcweir rName += sal_Unicode('\''); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir /************************************************************************* 235cdf0e10cSrcweir |* 236cdf0e10cSrcweir |* Get the name of the object (plural) 237cdf0e10cSrcweir |* 238cdf0e10cSrcweir \************************************************************************/ 239cdf0e10cSrcweir 240cdf0e10cSrcweir void E3dLatheObj::TakeObjNamePlural(XubString& rName) const 241cdf0e10cSrcweir { 242cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralLathe3d); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir /************************************************************************* 246cdf0e10cSrcweir |* 247cdf0e10cSrcweir |* Aufbrechen 248cdf0e10cSrcweir |* 249cdf0e10cSrcweir \************************************************************************/ 250cdf0e10cSrcweir 251cdf0e10cSrcweir sal_Bool E3dLatheObj::IsBreakObjPossible() 252cdf0e10cSrcweir { 253cdf0e10cSrcweir return sal_True; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir SdrAttrObj* E3dLatheObj::GetBreakObj() 257cdf0e10cSrcweir { 258cdf0e10cSrcweir // create PathObj 259cdf0e10cSrcweir basegfx::B3DPolyPolygon aLathePoly3D(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D)); 260cdf0e10cSrcweir basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D)); 261cdf0e10cSrcweir SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly); 262cdf0e10cSrcweir 263cdf0e10cSrcweir if(pPathObj) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir // Attribute setzen 266cdf0e10cSrcweir SfxItemSet aSet(GetObjectItemSet()); 267cdf0e10cSrcweir 268cdf0e10cSrcweir // Linien aktivieren, um Objekt garantiert sichtbar zu machen 269cdf0e10cSrcweir aSet.Put(XLineStyleItem(XLINE_SOLID)); 270cdf0e10cSrcweir 271cdf0e10cSrcweir pPathObj->SetMergedItemSet(aSet); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir return pPathObj; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir // eof 278