LCOV - code coverage report
Current view: top level - svx/source/engine3d - lathe3d.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 72 0.0 %
Date: 2014-04-14 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "svx/svdstr.hrc"
      22             : #include "svx/svdglob.hxx"
      23             : #include <tools/poly.hxx>
      24             : #include <svx/svdpage.hxx>
      25             : #include "svx/globl3d.hxx"
      26             : #include <svx/lathe3d.hxx>
      27             : #include <svx/xpoly.hxx>
      28             : #include <svx/svxids.hrc>
      29             : #include <svx/svdopath.hxx>
      30             : #include <svx/svdmodel.hxx>
      31             : #include <svx/svx3ditems.hxx>
      32             : #include <svx/sdr/properties/e3dlatheproperties.hxx>
      33             : #include <svx/sdr/contact/viewcontactofe3dlathe.hxx>
      34             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      35             : #include <basegfx/polygon/b2dpolygontools.hxx>
      36             : #include <basegfx/matrix/b2dhommatrix.hxx>
      37             : 
      38             : 
      39             : // DrawContact section
      40             : 
      41           0 : sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact()
      42             : {
      43           0 :     return new sdr::contact::ViewContactOfE3dLathe(*this);
      44             : }
      45             : 
      46             : 
      47             : 
      48           0 : sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties()
      49             : {
      50           0 :     return new sdr::properties::E3dLatheProperties(*this);
      51             : }
      52             : 
      53             : 
      54             : 
      55           0 : TYPEINIT1(E3dLatheObj, E3dCompoundObject);
      56             : 
      57             : // Constructor from 3D polygon, scale is the conversion factor for the coordinates
      58             : 
      59           0 : E3dLatheObj::E3dLatheObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon rPoly2D)
      60             : :   E3dCompoundObject(rDefault),
      61           0 :     maPolyPoly2D(rPoly2D)
      62             : {
      63             :     // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
      64           0 :     basegfx::B2DHomMatrix aMirrorY;
      65           0 :     aMirrorY.scale(1.0, -1.0);
      66           0 :     maPolyPoly2D.transform(aMirrorY);
      67             : 
      68             :     // Set Defaults
      69           0 :     SetDefaultAttributes(rDefault);
      70             : 
      71             :     // Superfluous items removed, in particular to prevent duplicate
      72             :     // start and end points
      73           0 :     maPolyPoly2D.removeDoublePoints();
      74             : 
      75           0 :     if(maPolyPoly2D.count())
      76             :     {
      77           0 :         const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
      78           0 :         sal_uInt32 nSegCnt(rPoly.count());
      79             : 
      80           0 :         if(nSegCnt && !rPoly.isClosed())
      81             :         {
      82           0 :             nSegCnt -= 1;
      83             :         }
      84             : 
      85           0 :         GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt));
      86           0 :     }
      87           0 : }
      88             : 
      89           0 : E3dLatheObj::E3dLatheObj()
      90           0 : :    E3dCompoundObject()
      91             : {
      92             :     // Set Defaults
      93           0 :     E3dDefaultAttributes aDefault;
      94           0 :     SetDefaultAttributes(aDefault);
      95           0 : }
      96             : 
      97           0 : void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
      98             : {
      99           0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
     100           0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack()));
     101           0 :     GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode()));
     102           0 :     GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront()));
     103           0 :     GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack()));
     104           0 : }
     105             : 
     106           0 : sal_uInt16 E3dLatheObj::GetObjIdentifier() const
     107             : {
     108           0 :     return E3D_LATHEOBJ_ID;
     109             : }
     110             : 
     111           0 : E3dLatheObj* E3dLatheObj::Clone() const
     112             : {
     113           0 :     return CloneHelper< E3dLatheObj >();
     114             : }
     115             : 
     116             : // Convert the object to group object consisting of n polygons
     117             : 
     118           0 : SdrObject *E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
     119             : {
     120           0 :     return NULL;
     121             : }
     122             : 
     123             : // Set Local parameters set to re-create geometry
     124             : 
     125           0 : void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew)
     126             : {
     127           0 :     if(maPolyPoly2D != rNew)
     128             :     {
     129           0 :         maPolyPoly2D = rNew;
     130           0 :         maPolyPoly2D.removeDoublePoints();
     131             : 
     132           0 :         if(maPolyPoly2D.count())
     133             :         {
     134           0 :             const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
     135           0 :             sal_uInt32 nSegCnt(rPoly.count());
     136             : 
     137           0 :             if(nSegCnt && !rPoly.isClosed())
     138             :             {
     139           0 :                 nSegCnt -= 1;
     140             :             }
     141             : 
     142           0 :             GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt));
     143             :         }
     144             : 
     145           0 :         ActionChanged();
     146             :     }
     147           0 : }
     148             : 
     149             : // Get the name of the object (singular)
     150             : 
     151           0 : OUString E3dLatheObj::TakeObjNameSingul() const
     152             : {
     153           0 :     OUStringBuffer sName(ImpGetResStr(STR_ObjNameSingulLathe3d));
     154             : 
     155           0 :     OUString aName(GetName());
     156           0 :     if (!aName.isEmpty())
     157             :     {
     158           0 :         sName.append(' ');
     159           0 :         sName.append('\'');
     160           0 :         sName.append(aName);
     161           0 :         sName.append('\'');
     162             :     }
     163           0 :     return sName.makeStringAndClear();
     164             : }
     165             : 
     166             : // Get the name of the object (plural)
     167             : 
     168           0 : OUString E3dLatheObj::TakeObjNamePlural() const
     169             : {
     170           0 :     return ImpGetResStr(STR_ObjNamePluralLathe3d);
     171             : }
     172             : 
     173           0 : bool E3dLatheObj::IsBreakObjPossible()
     174             : {
     175           0 :     return true;
     176             : }
     177             : 
     178           0 : SdrAttrObj* E3dLatheObj::GetBreakObj()
     179             : {
     180             :     // create PathObj
     181           0 :     basegfx::B3DPolyPolygon aLathePoly3D(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D));
     182           0 :     basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
     183           0 :     SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly);
     184             : 
     185           0 :     if(pPathObj)
     186             :     {
     187             :         // Set Attribute
     188           0 :         SfxItemSet aSet(GetObjectItemSet());
     189             : 
     190             :         // Enable lines to guarantee that the object becomes visible
     191           0 :         aSet.Put(XLineStyleItem(XLINE_SOLID));
     192             : 
     193           0 :         pPathObj->SetMergedItemSet(aSet);
     194             :     }
     195             : 
     196           0 :     return pPathObj;
     197             : }
     198             : 
     199             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10