fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / engine3d / extrud3d.cxx
blob724f45d3f8b4c98a0c5bfe97e2406ca503bc4cb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "svx/svdstr.hrc"
22 #include "svx/svdglob.hxx"
23 #include <svx/svdpage.hxx>
24 #include "svx/globl3d.hxx"
25 #include <svx/extrud3d.hxx>
26 #include <svx/scene3d.hxx>
28 #include <svx/svxids.hrc>
29 #include <svx/xpoly.hxx>
30 #include <svx/svdopath.hxx>
31 #include <svx/svdmodel.hxx>
32 #include <svx/svx3ditems.hxx>
33 #include <svx/sdr/properties/e3dextrudeproperties.hxx>
34 #include <svx/sdr/contact/viewcontactofe3dextrude.hxx>
35 #include <basegfx/polygon/b2dpolypolygontools.hxx>
36 #include <basegfx/polygon/b2dpolygontools.hxx>
37 #include <basegfx/polygon/b3dpolygontools.hxx>
38 #include <basegfx/polygon/b3dpolypolygontools.hxx>
40 //////////////////////////////////////////////////////////////////////////////
41 // DrawContact section
43 sdr::contact::ViewContact* E3dExtrudeObj::CreateObjectSpecificViewContact()
45 return new sdr::contact::ViewContactOfE3dExtrude(*this);
48 //////////////////////////////////////////////////////////////////////////////
50 sdr::properties::BaseProperties* E3dExtrudeObj::CreateObjectSpecificProperties()
52 return new sdr::properties::E3dExtrudeProperties(*this);
55 //////////////////////////////////////////////////////////////////////////////
57 TYPEINIT1(E3dExtrudeObj, E3dCompoundObject);
59 // Constructor creates a two cover surface PolyPolygon and (point-count 1) side
60 // surfaces rectangles from the passed PolyPolygon
62 E3dExtrudeObj::E3dExtrudeObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth)
63 : E3dCompoundObject(rDefault),
64 maExtrudePolygon(rPP)
66 // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
67 basegfx::B2DHomMatrix aMirrorY;
68 aMirrorY.scale(1.0, -1.0);
69 maExtrudePolygon.transform(aMirrorY);
71 // Set Defaults
72 SetDefaultAttributes(rDefault);
74 // set extrude depth
75 GetProperties().SetObjectItemDirect(Svx3DDepthItem((sal_uInt32)(fDepth + 0.5)));
78 E3dExtrudeObj::E3dExtrudeObj()
79 : E3dCompoundObject()
81 // Set Defaults
82 E3dDefaultAttributes aDefault;
83 SetDefaultAttributes(aDefault);
86 void E3dExtrudeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
88 GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
89 GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultExtrudeSmoothFrontBack()));
90 GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultExtrudeCharacterMode()));
91 GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultExtrudeCloseFront()));
92 GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultExtrudeCloseBack()));
94 // For extrudes use StdTexture in X and Y by default
95 GetProperties().SetObjectItemDirect(Svx3DTextureProjectionXItem(1));
96 GetProperties().SetObjectItemDirect(Svx3DTextureProjectionYItem(1));
99 sal_uInt16 E3dExtrudeObj::GetObjIdentifier() const
101 return E3D_EXTRUDEOBJ_ID;
104 E3dExtrudeObj* E3dExtrudeObj::Clone() const
106 return CloneHelper< E3dExtrudeObj >();
110 // Set local parameters with geometry re-creating
112 void E3dExtrudeObj::SetExtrudePolygon(const basegfx::B2DPolyPolygon &rNew)
114 if(maExtrudePolygon != rNew)
116 maExtrudePolygon = rNew;
117 ActionChanged();
121 // Get the name of the object (singular)
123 void E3dExtrudeObj::TakeObjNameSingul(XubString& rName) const
125 rName=ImpGetResStr(STR_ObjNameSingulExtrude3d);
127 String aName( GetName() );
128 if(aName.Len())
130 rName += sal_Unicode(' ');
131 rName += sal_Unicode('\'');
132 rName += aName;
133 rName += sal_Unicode('\'');
137 // Get the name of the object (plural)
139 void E3dExtrudeObj::TakeObjNamePlural(XubString& rName) const
141 rName=ImpGetResStr(STR_ObjNamePluralExtrude3d);
144 bool E3dExtrudeObj::IsBreakObjPossible()
146 return true;
149 SdrAttrObj* E3dExtrudeObj::GetBreakObj()
151 basegfx::B3DPolyPolygon aFrontSide;
152 basegfx::B3DPolyPolygon aBackSide;
154 if(maExtrudePolygon.count())
156 basegfx::B2DPolyPolygon aTemp(maExtrudePolygon);
157 aTemp.removeDoublePoints();
158 aTemp = basegfx::tools::correctOrientations(aTemp);
159 const basegfx::B2VectorOrientation aOrient = basegfx::tools::getOrientation(aTemp.getB2DPolygon(0L));
161 if(basegfx::ORIENTATION_POSITIVE == aOrient)
163 aTemp.flip();
166 aFrontSide = basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(aTemp);
169 if(aFrontSide.count())
171 aBackSide = aFrontSide;
173 if(GetExtrudeDepth())
175 basegfx::B3DHomMatrix aTransform;
177 if(100 != GetPercentBackScale())
179 // scale polygon from center
180 const double fScaleFactor(GetPercentBackScale() / 100.0);
181 const basegfx::B3DRange aPolyPolyRange(basegfx::tools::getRange(aBackSide));
182 const basegfx::B3DPoint aCenter(aPolyPolyRange.getCenter());
184 aTransform.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ());
185 aTransform.scale(fScaleFactor, fScaleFactor, fScaleFactor);
186 aTransform.translate(aCenter.getX(), aCenter.getY(), aCenter.getZ());
189 // translate by extrude depth
190 aTransform.translate(0.0, 0.0, (double)GetExtrudeDepth());
192 aBackSide.transform(aTransform);
196 if(aBackSide.count())
198 // create PathObj
199 basegfx::B2DPolyPolygon aPoly = TransformToScreenCoor(aBackSide);
200 SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aPoly);
202 if(pPathObj)
204 SfxItemSet aSet(GetObjectItemSet());
205 aSet.Put(XLineStyleItem(XLINE_SOLID));
206 pPathObj->SetMergedItemSet(aSet);
209 return pPathObj;
212 return 0;
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */