bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / engine3d / view3d1.cxx
blobd3414bdb3e18ffab6ad78187f80b12b8e83bff30
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/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 #include <com/sun/star/drawing/LineStyle.hpp>
45 void E3dView::ConvertMarkedToPolyObj(bool bLineToArea)
47 SdrObject* pNewObj = NULL;
49 if (GetMarkedObjectCount() == 1)
51 SdrObject* pObj = GetMarkedObjectByIndex(0);
53 if (pObj && pObj->ISA(E3dPolyScene))
55 bool bBezier = false;
56 pNewObj = static_cast<E3dPolyScene*>(pObj)->ConvertToPolyObj(bBezier, bLineToArea);
58 if (pNewObj)
60 BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE));
61 ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
62 EndUndo();
67 if (!pNewObj)
69 SdrView::ConvertMarkedToPolyObj(bLineToArea);
73 void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
75 if(pObj->ISA(E3dLatheObj))
77 rMask |= 0x0001;
79 else if(pObj->ISA(E3dExtrudeObj))
81 rMask |= 0x0002;
83 else if(pObj->ISA(E3dSphereObj))
85 rMask |= 0x0004;
87 else if(pObj->ISA(E3dCubeObj))
89 rMask |= 0x0008;
91 else if(pObj->IsGroupObject())
93 SdrObjList* pList = pObj->GetSubList();
94 for(size_t a = 0; a < pList->GetObjCount(); ++a)
95 Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask);
99 SfxItemSet E3dView::Get3DAttributes(E3dScene* pInScene, bool /*bOnly3DAttr*/) const
101 // Creating itemset with corresponding field
102 SfxItemSet aSet(
103 pMod->GetItemPool(),
104 SDRATTR_START, SDRATTR_END,
105 SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN,
106 0, 0);
108 sal_uInt32 nSelectedItems(0L);
110 if(pInScene)
112 // special scene
113 aSet.Put(pInScene->GetMergedItemSet());
115 else
117 // get attributes from all selected objects
118 MergeAttrFromMarked(aSet, false);
120 // calc flags for SID_ATTR_3D_INTERN
121 const SdrMarkList& rMarkList = GetMarkedObjectList();
122 const size_t nMarkCnt(rMarkList.GetMarkCount());
124 for(size_t a = 0; a < nMarkCnt; ++a)
126 SdrObject* pObj = GetMarkedObjectByIndex(a);
127 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
131 // Set SID_ATTR_3D_INTERN on the status of the selected objects
132 aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems));
134 // maintain default values
135 if(!nSelectedItems && !pInScene)
137 // Get defaults and apply
138 SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST);
139 GetAttributes(aDefaultSet);
140 aSet.Put(aDefaultSet);
142 // ... but no lines for 3D
143 aSet.Put(XLineStyleItem (com::sun::star::drawing::LineStyle_NONE));
145 // new defaults for distance and focal length
146 aSet.Put(makeSvx3DDistanceItem(100));
147 aSet.Put(makeSvx3DFocalLengthItem(10000));
150 // return ItemSet
151 return aSet;
154 void E3dView::Set3DAttributes( const SfxItemSet& rAttr, E3dScene* pInScene, bool bReplaceAll)
156 sal_uInt32 nSelectedItems(0L);
158 if(pInScene)
160 pInScene->SetMergedItemSetAndBroadcast(rAttr, bReplaceAll);
162 else
164 // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
165 // They are not needed here, they are already handled in SetAttrToMarked
167 // set at selected objects
168 SetAttrToMarked(rAttr, bReplaceAll);
170 // old run
171 const SdrMarkList& rMarkList = GetMarkedObjectList();
172 const size_t nMarkCnt(rMarkList.GetMarkCount());
174 for(size_t a = 0; a < nMarkCnt; ++a)
176 SdrObject* pObj = GetMarkedObjectByIndex(a);
177 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
181 // Maintain default values
182 if(!nSelectedItems && !pInScene)
184 // Set defaults
185 SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST);
186 aDefaultSet.Put(rAttr);
187 SetAttributes(aDefaultSet);
192 double E3dView::GetDefaultCamPosZ()
194 return (double) static_cast<const SfxUInt32Item&>(pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE)).GetValue();
197 double E3dView::GetDefaultCamFocal()
199 return (double) static_cast<const SfxUInt32Item&>(pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue();
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */