bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svx / source / engine3d / view3d1.cxx
blob4a20e3821e9a50d1950d025437582f855c859732
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/strings.hrc>
28 #include <svx/dialmgr.hxx>
29 #include <svx/globl3d.hxx>
30 #include <svx/obj3d.hxx>
31 #include <svx/e3ditem.hxx>
32 #include <editeng/colritem.hxx>
33 #include <svx/lathe3d.hxx>
34 #include <svx/scene3d.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()
47 SdrObject* pNewObj = nullptr;
49 if (GetMarkedObjectCount() == 1)
51 SdrObject* pObj = GetMarkedObjectByIndex(0);
53 if (pObj)
55 auto pScene = dynamic_cast< const E3dScene* >(pObj);
56 if (pScene)
58 pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/);
59 if (pNewObj)
61 BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE));
62 ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
63 EndUndo();
69 if (!pNewObj)
71 SdrView::ConvertMarkedToPolyObj();
75 static void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
77 if(dynamic_cast< const E3dLatheObj* >(pObj) != nullptr)
79 rMask |= 0x0001;
81 else if(dynamic_cast< const E3dExtrudeObj* >(pObj) != nullptr)
83 rMask |= 0x0002;
85 else if(dynamic_cast< const E3dSphereObj* >(pObj) != nullptr)
87 rMask |= 0x0004;
89 else if(dynamic_cast< const E3dCubeObj* >(pObj) != nullptr)
91 rMask |= 0x0008;
93 else if(pObj->IsGroupObject())
95 SdrObjList* pList = pObj->GetSubList();
96 for(size_t a = 0; a < pList->GetObjCount(); ++a)
97 Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask);
101 SfxItemSet E3dView::Get3DAttributes() const
103 // Creating itemset with corresponding field
104 SfxItemSet aSet(
105 mpModel->GetItemPool(),
106 svl::Items<SDRATTR_START, SDRATTR_END,
107 SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN>{});
109 sal_uInt32 nSelectedItems(0);
111 // get attributes from all selected objects
112 MergeAttrFromMarked(aSet, false);
114 // calc flags for SID_ATTR_3D_INTERN
115 const SdrMarkList& rMarkList = GetMarkedObjectList();
116 const size_t nMarkCnt(rMarkList.GetMarkCount());
118 for(size_t a = 0; a < nMarkCnt; ++a)
120 SdrObject* pObj = GetMarkedObjectByIndex(a);
121 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
124 // Set SID_ATTR_3D_INTERN on the status of the selected objects
125 aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems));
127 // maintain default values
128 if(!nSelectedItems)
130 // Get defaults and apply
131 SfxItemSet aDefaultSet(mpModel->GetItemPool(), svl::Items<SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{});
132 GetAttributes(aDefaultSet);
133 aSet.Put(aDefaultSet);
135 // ... but no lines for 3D
136 aSet.Put(XLineStyleItem (css::drawing::LineStyle_NONE));
138 // new defaults for distance and focal length
139 aSet.Put(makeSvx3DDistanceItem(100));
140 aSet.Put(makeSvx3DFocalLengthItem(10000));
143 // return ItemSet
144 return aSet;
147 void E3dView::Set3DAttributes( const SfxItemSet& rAttr)
149 sal_uInt32 nSelectedItems(0);
151 // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
152 // They are not needed here, they are already handled in SetAttrToMarked
154 // set at selected objects
155 SetAttrToMarked(rAttr, false/*bReplaceAll*/);
157 // old run
158 const SdrMarkList& rMarkList = GetMarkedObjectList();
159 const size_t nMarkCnt(rMarkList.GetMarkCount());
161 for(size_t a = 0; a < nMarkCnt; ++a)
163 SdrObject* pObj = GetMarkedObjectByIndex(a);
164 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
167 // Maintain default values
168 if(!nSelectedItems)
170 // Set defaults
171 SfxItemSet aDefaultSet(mpModel->GetItemPool(), svl::Items<SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{});
172 aDefaultSet.Put(rAttr);
173 SetAttributes(aDefaultSet);
177 double E3dView::GetDefaultCamPosZ()
179 return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE).GetValue());
182 double E3dView::GetDefaultCamFocal()
184 return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue());
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */