LCOV - code coverage report
Current view: top level - svx/source/engine3d - lathe3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 74 1.4 %
Date: 2012-08-25 Functions: 1 18 5.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 144 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "svx/svdstr.hrc"
      31                 :            : #include "svx/svdglob.hxx"
      32                 :            : #include <tools/poly.hxx>
      33                 :            : #include <svx/svdpage.hxx>
      34                 :            : #include "svx/globl3d.hxx"
      35                 :            : #include <svx/lathe3d.hxx>
      36                 :            : #include <svx/xpoly.hxx>
      37                 :            : #include <svx/svxids.hrc>
      38                 :            : #include <svx/svdopath.hxx>
      39                 :            : #include <svx/svdmodel.hxx>
      40                 :            : #include <svx/svx3ditems.hxx>
      41                 :            : #include <svx/sdr/properties/e3dlatheproperties.hxx>
      42                 :            : #include <svx/sdr/contact/viewcontactofe3dlathe.hxx>
      43                 :            : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      44                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      45                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      46                 :            : 
      47                 :            : //////////////////////////////////////////////////////////////////////////////
      48                 :            : // DrawContact section
      49                 :            : 
      50                 :          0 : sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact()
      51                 :            : {
      52         [ #  # ]:          0 :     return new sdr::contact::ViewContactOfE3dLathe(*this);
      53                 :            : }
      54                 :            : 
      55                 :            : //////////////////////////////////////////////////////////////////////////////
      56                 :            : 
      57                 :          0 : sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties()
      58                 :            : {
      59         [ #  # ]:          0 :     return new sdr::properties::E3dLatheProperties(*this);
      60                 :            : }
      61                 :            : 
      62                 :            : //////////////////////////////////////////////////////////////////////////////
      63                 :            : 
      64 [ #  # ][ #  # ]:      87233 : TYPEINIT1(E3dLatheObj, E3dCompoundObject);
      65                 :            : 
      66                 :            : // Constructor from 3D polygon, scale is the conversion factor for the coordinates
      67                 :            : 
      68                 :          0 : E3dLatheObj::E3dLatheObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon rPoly2D)
      69                 :            : :   E3dCompoundObject(rDefault),
      70         [ #  # ]:          0 :     maPolyPoly2D(rPoly2D)
      71                 :            : {
      72                 :            :     // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
      73         [ #  # ]:          0 :     basegfx::B2DHomMatrix aMirrorY;
      74         [ #  # ]:          0 :     aMirrorY.scale(1.0, -1.0);
      75         [ #  # ]:          0 :     maPolyPoly2D.transform(aMirrorY);
      76                 :            : 
      77                 :            :     // Set Defaults
      78         [ #  # ]:          0 :     SetDefaultAttributes(rDefault);
      79                 :            : 
      80                 :            :     // Superfluous items removed, in particular to prevent duplicate
      81                 :            :     // start and end points
      82         [ #  # ]:          0 :     maPolyPoly2D.removeDoublePoints();
      83                 :            : 
      84 [ #  # ][ #  # ]:          0 :     if(maPolyPoly2D.count())
      85                 :            :     {
      86         [ #  # ]:          0 :         const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
      87         [ #  # ]:          0 :         sal_uInt32 nSegCnt(rPoly.count());
      88                 :            : 
      89 [ #  # ][ #  # ]:          0 :         if(nSegCnt && !rPoly.isClosed())
         [ #  # ][ #  # ]
      90                 :            :         {
      91                 :          0 :             nSegCnt -= 1;
      92                 :            :         }
      93                 :            : 
      94 [ #  # ][ #  # ]:          0 :         GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt));
         [ #  # ][ #  # ]
                 [ #  # ]
      95         [ #  # ]:          0 :     }
      96                 :          0 : }
      97                 :            : 
      98                 :          0 : E3dLatheObj::E3dLatheObj()
      99         [ #  # ]:          0 : :    E3dCompoundObject()
     100                 :            : {
     101                 :            :     // Set Defaults
     102         [ #  # ]:          0 :     E3dDefaultAttributes aDefault;
     103 [ #  # ][ #  # ]:          0 :     SetDefaultAttributes(aDefault);
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
     107                 :            : {
     108         [ #  # ]:          0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
     109         [ #  # ]:          0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack()));
     110         [ #  # ]:          0 :     GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode()));
     111         [ #  # ]:          0 :     GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront()));
     112         [ #  # ]:          0 :     GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack()));
     113                 :          0 : }
     114                 :            : 
     115                 :          0 : sal_uInt16 E3dLatheObj::GetObjIdentifier() const
     116                 :            : {
     117                 :          0 :     return E3D_LATHEOBJ_ID;
     118                 :            : }
     119                 :            : 
     120                 :          0 : E3dLatheObj* E3dLatheObj::Clone() const
     121                 :            : {
     122                 :          0 :     return CloneHelper< E3dLatheObj >();
     123                 :            : }
     124                 :            : 
     125                 :            : // Convert the object to group object consisting of n polygons
     126                 :            : 
     127                 :          0 : SdrObject *E3dLatheObj::DoConvertToPolyObj(sal_Bool /*bBezier*/) const
     128                 :            : {
     129                 :          0 :     return NULL;
     130                 :            : }
     131                 :            : 
     132                 :            : // Set Local parameters set to re-create geometry
     133                 :            : 
     134                 :          0 : void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew)
     135                 :            : {
     136         [ #  # ]:          0 :     if(maPolyPoly2D != rNew)
     137                 :            :     {
     138                 :          0 :         maPolyPoly2D = rNew;
     139                 :          0 :         maPolyPoly2D.removeDoublePoints();
     140                 :            : 
     141         [ #  # ]:          0 :         if(maPolyPoly2D.count())
     142                 :            :         {
     143         [ #  # ]:          0 :             const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
     144         [ #  # ]:          0 :             sal_uInt32 nSegCnt(rPoly.count());
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 :             if(nSegCnt && !rPoly.isClosed())
         [ #  # ][ #  # ]
     147                 :            :             {
     148                 :          0 :                 nSegCnt -= 1;
     149                 :            :             }
     150                 :            : 
     151 [ #  # ][ #  # ]:          0 :             GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt));
         [ #  # ][ #  # ]
                 [ #  # ]
     152                 :            :         }
     153                 :            : 
     154                 :          0 :         ActionChanged();
     155                 :            :     }
     156                 :          0 : }
     157                 :            : 
     158                 :            : // Get the name of the object (singular)
     159                 :            : 
     160                 :          0 : void E3dLatheObj::TakeObjNameSingul(XubString& rName) const
     161                 :            : {
     162 [ #  # ][ #  # ]:          0 :     rName=ImpGetResStr(STR_ObjNameSingulLathe3d);
                 [ #  # ]
     163                 :            : 
     164 [ #  # ][ #  # ]:          0 :     String aName( GetName() );
     165         [ #  # ]:          0 :     if(aName.Len())
     166                 :            :     {
     167         [ #  # ]:          0 :         rName += sal_Unicode(' ');
     168         [ #  # ]:          0 :         rName += sal_Unicode('\'');
     169         [ #  # ]:          0 :         rName += aName;
     170         [ #  # ]:          0 :         rName += sal_Unicode('\'');
     171         [ #  # ]:          0 :     }
     172                 :          0 : }
     173                 :            : 
     174                 :            : // Get the name of the object (plural)
     175                 :            : 
     176                 :          0 : void E3dLatheObj::TakeObjNamePlural(XubString& rName) const
     177                 :            : {
     178         [ #  # ]:          0 :     rName=ImpGetResStr(STR_ObjNamePluralLathe3d);
     179                 :          0 : }
     180                 :            : 
     181                 :          0 : sal_Bool E3dLatheObj::IsBreakObjPossible()
     182                 :            : {
     183                 :          0 :     return sal_True;
     184                 :            : }
     185                 :            : 
     186                 :          0 : SdrAttrObj* E3dLatheObj::GetBreakObj()
     187                 :            : {
     188                 :            :     // create PathObj
     189         [ #  # ]:          0 :     basegfx::B3DPolyPolygon aLathePoly3D(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D));
     190         [ #  # ]:          0 :     basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
     191 [ #  # ][ #  # ]:          0 :     SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly);
     192                 :            : 
     193         [ #  # ]:          0 :     if(pPathObj)
     194                 :            :     {
     195                 :            :         // Set Attribute
     196 [ #  # ][ #  # ]:          0 :         SfxItemSet aSet(GetObjectItemSet());
     197                 :            : 
     198                 :            :         // Enable lines to guarantee that the object becomes visible
     199 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineStyleItem(XLINE_SOLID));
                 [ #  # ]
     200                 :            : 
     201 [ #  # ][ #  # ]:          0 :         pPathObj->SetMergedItemSet(aSet);
     202                 :            :     }
     203                 :            : 
     204 [ #  # ][ #  # ]:          0 :     return pPathObj;
     205                 :            : }
     206                 :            : 
     207                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10