LCOV - code coverage report
Current view: top level - svx/source/engine3d - view3d1.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 69 1.4 %
Date: 2014-11-03 Functions: 2 8 25.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/svditer.hxx"
      22             : #include <svx/svdpool.hxx>
      23             : #include <svx/svdmodel.hxx>
      24             : #include <svx/svxids.hrc>
      25             : #include <svx/xtable.hxx>
      26             : #include <svx/fmview.hxx>
      27             : #include <svx/dialogs.hrc>
      28             : #include <svx/dialmgr.hxx>
      29             : #include "svx/globl3d.hxx"
      30             : #include <svx/obj3d.hxx>
      31             : #include <svx/polysc3d.hxx>
      32             : #include <svx/e3ditem.hxx>
      33             : #include <editeng/colritem.hxx>
      34             : #include <svx/lathe3d.hxx>
      35             : #include <svx/sphere3d.hxx>
      36             : #include <svx/extrud3d.hxx>
      37             : #include <svx/e3dundo.hxx>
      38             : #include <svx/view3d.hxx>
      39             : #include <svx/cube3d.hxx>
      40             : #include <svx/xflclit.hxx>
      41             : #include <svx/svdogrp.hxx>
      42             : #include <svx/e3dsceneupdater.hxx>
      43             : 
      44           0 : void E3dView::ConvertMarkedToPolyObj(bool bLineToArea)
      45             : {
      46           0 :     SdrObject* pNewObj = NULL;
      47             : 
      48           0 :     if (GetMarkedObjectCount() == 1)
      49             :     {
      50           0 :         SdrObject* pObj = GetMarkedObjectByIndex(0);
      51             : 
      52           0 :         if (pObj && pObj->ISA(E3dPolyScene))
      53             :         {
      54           0 :             bool bBezier = false;
      55           0 :             pNewObj = static_cast<E3dPolyScene*>(pObj)->ConvertToPolyObj(bBezier, bLineToArea);
      56             : 
      57           0 :             if (pNewObj)
      58             :             {
      59           0 :                 BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE));
      60           0 :                 ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
      61           0 :                 EndUndo();
      62             :             }
      63             :         }
      64             :     }
      65             : 
      66           0 :     if (!pNewObj)
      67             :     {
      68           0 :         SdrView::ConvertMarkedToPolyObj(bLineToArea);
      69             :     }
      70           0 : }
      71             : 
      72           0 : void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
      73             : {
      74           0 :     if(pObj->ISA(E3dLatheObj))
      75             :     {
      76           0 :         rMask |= 0x0001;
      77             :     }
      78           0 :     else if(pObj->ISA(E3dExtrudeObj))
      79             :     {
      80           0 :         rMask |= 0x0002;
      81             :     }
      82           0 :     else if(pObj->ISA(E3dSphereObj))
      83             :     {
      84           0 :         rMask |= 0x0004;
      85             :     }
      86           0 :     else if(pObj->ISA(E3dCubeObj))
      87             :     {
      88           0 :         rMask |= 0x0008;
      89             :     }
      90           0 :     else if(pObj->IsGroupObject())
      91             :     {
      92           0 :         SdrObjList* pList = pObj->GetSubList();
      93           0 :         for(size_t a = 0; a < pList->GetObjCount(); ++a)
      94           0 :             Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask);
      95             :     }
      96           0 : }
      97             : 
      98           0 : SfxItemSet E3dView::Get3DAttributes(E3dScene* pInScene, bool /*bOnly3DAttr*/) const
      99             : {
     100             :     // Creating itemset with corresponding field
     101             :     SfxItemSet aSet(
     102           0 :         pMod->GetItemPool(),
     103             :         SDRATTR_START,      SDRATTR_END,
     104             :         SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN,
     105           0 :         0, 0);
     106             : 
     107           0 :     sal_uInt32 nSelectedItems(0L);
     108             : 
     109           0 :     if(pInScene)
     110             :     {
     111             :         // special scene
     112           0 :         aSet.Put(pInScene->GetMergedItemSet());
     113             :     }
     114             :     else
     115             :     {
     116             :         // get attributes from all selected objects
     117           0 :         MergeAttrFromMarked(aSet, false);
     118             : 
     119             :         // calc flags for SID_ATTR_3D_INTERN
     120           0 :         const SdrMarkList& rMarkList = GetMarkedObjectList();
     121           0 :         const size_t nMarkCnt(rMarkList.GetMarkCount());
     122             : 
     123           0 :         for(size_t a = 0; a < nMarkCnt; ++a)
     124             :         {
     125           0 :             SdrObject* pObj = GetMarkedObjectByIndex(a);
     126           0 :             Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
     127             :         }
     128             :     }
     129             : 
     130             :     // Set SID_ATTR_3D_INTERN on the status of the selected objects
     131           0 :     aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems));
     132             : 
     133             :     // maintain default values
     134           0 :     if(!nSelectedItems  && !pInScene)
     135             :     {
     136             :         // Get defaults and apply
     137           0 :         SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST);
     138           0 :         GetAttributes(aDefaultSet);
     139           0 :         aSet.Put(aDefaultSet);
     140             : 
     141             :         // ... but no lines for 3D
     142           0 :         aSet.Put(XLineStyleItem (XLINE_NONE));
     143             : 
     144             :         // new defaults for distance and focal length
     145           0 :         aSet.Put(makeSvx3DDistanceItem(100));
     146           0 :         aSet.Put(makeSvx3DFocalLengthItem(10000));
     147             :     }
     148             : 
     149             :     // return ItemSet
     150           0 :     return(aSet);
     151             : }
     152             : 
     153           0 : void E3dView::Set3DAttributes( const SfxItemSet& rAttr, E3dScene* pInScene, bool bReplaceAll)
     154             : {
     155           0 :     sal_uInt32 nSelectedItems(0L);
     156             : 
     157           0 :     if(pInScene)
     158             :     {
     159           0 :         pInScene->SetMergedItemSetAndBroadcast(rAttr, bReplaceAll);
     160             :     }
     161             :     else
     162             :     {
     163             :         // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
     164             :         // They are not needed here, they are already handled in SetAttrToMarked
     165             : 
     166             :         // set at selected objects
     167           0 :         SetAttrToMarked(rAttr, bReplaceAll);
     168             : 
     169             :         // old run
     170           0 :         const SdrMarkList& rMarkList = GetMarkedObjectList();
     171           0 :         const size_t nMarkCnt(rMarkList.GetMarkCount());
     172             : 
     173           0 :         for(size_t a = 0; a < nMarkCnt; ++a)
     174             :         {
     175           0 :             SdrObject* pObj = GetMarkedObjectByIndex(a);
     176           0 :             Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
     177             :         }
     178             :     }
     179             : 
     180             :     // Maintain default values
     181           0 :     if(!nSelectedItems && !pInScene)
     182             :     {
     183             :         // Set defaults
     184           0 :         SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST);
     185           0 :         aDefaultSet.Put(rAttr);
     186           0 :         SetAttributes(aDefaultSet);
     187             : 
     188             :     }
     189           0 : }
     190             : 
     191           0 : double E3dView::GetDefaultCamPosZ()
     192             : {
     193           0 :     return (double) static_cast<const SfxUInt32Item&>(pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE)).GetValue();
     194             : }
     195             : 
     196           0 : double E3dView::GetDefaultCamFocal()
     197             : {
     198           0 :     return (double) static_cast<const SfxUInt32Item&>(pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue();
     199         651 : }
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10