LCOV - code coverage report
Current view: top level - svx/source/engine3d - lathe3d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 32 72 44.4 %
Date: 2015-06-13 12:38:46 Functions: 11 20 55.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 "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 <sdr/properties/e3dlatheproperties.hxx>
      33             : #include <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         252 : sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact()
      42             : {
      43         252 :     return new sdr::contact::ViewContactOfE3dLathe(*this);
      44             : }
      45             : 
      46             : 
      47             : 
      48         252 : sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties()
      49             : {
      50         252 :     return new sdr::properties::E3dLatheProperties(*this);
      51             : }
      52             : 
      53             : 
      54             : 
      55      126820 : 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(makeSvx3DVerticalSegmentsItem(nSegCnt));
      86           0 :     }
      87           0 : }
      88             : 
      89         252 : E3dLatheObj::E3dLatheObj()
      90         252 : :    E3dCompoundObject()
      91             : {
      92             :     // Set Defaults
      93         252 :     E3dDefaultAttributes aDefault;
      94         252 :     SetDefaultAttributes(aDefault);
      95         252 : }
      96             : 
      97         252 : void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
      98             : {
      99         252 :     GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
     100         252 :     GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack()));
     101         252 :     GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode()));
     102         252 :     GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront()));
     103         252 :     GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack()));
     104         252 : }
     105             : 
     106         252 : sal_uInt16 E3dLatheObj::GetObjIdentifier() const
     107             : {
     108         252 :     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         504 : void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew)
     126             : {
     127         504 :     if(maPolyPoly2D != rNew)
     128             :     {
     129         504 :         maPolyPoly2D = rNew;
     130         504 :         maPolyPoly2D.removeDoublePoints();
     131             : 
     132         504 :         if(maPolyPoly2D.count())
     133             :         {
     134         504 :             const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
     135         504 :             sal_uInt32 nSegCnt(rPoly.count());
     136             : 
     137         504 :             if(nSegCnt && !rPoly.isClosed())
     138             :             {
     139         252 :                 nSegCnt -= 1;
     140             :             }
     141             : 
     142         504 :             GetProperties().SetObjectItemDirect(makeSvx3DVerticalSegmentsItem(nSegCnt));
     143             :         }
     144             : 
     145         504 :         ActionChanged();
     146             :     }
     147         504 : }
     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             :     // Set Attribute
     186           0 :     SfxItemSet aSet(GetObjectItemSet());
     187             : 
     188             :     // Enable lines to guarantee that the object becomes visible
     189           0 :     aSet.Put(XLineStyleItem(com::sun::star::drawing::LineStyle_SOLID));
     190             : 
     191           0 :     pPathObj->SetMergedItemSet(aSet);
     192             : 
     193           0 :     return pPathObj;
     194         435 : }
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11