LibreOffice Module svx (master) 1
view3d1.cxx
Go to the documentation of this file.
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 <svl/itempool.hxx>
22#include <svx/svdmodel.hxx>
23#include <svx/svxids.hrc>
24#include <svx/strings.hrc>
25#include <svx/dialmgr.hxx>
26#include <svx/lathe3d.hxx>
27#include <svx/scene3d.hxx>
28#include <svx/sphere3d.hxx>
29#include <extrud3d.hxx>
30#include <svx/view3d.hxx>
31#include <svx/cube3d.hxx>
32#include <svx/xlineit0.hxx>
33#include <com/sun/star/drawing/LineStyle.hpp>
34
36{
38
39 if (GetMarkedObjectCount() == 1)
40 {
42
43 if (pObj)
44 {
45 const E3dScene* pScene = DynCastE3dScene(pObj);
46 if (pScene)
47 {
48 pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/);
49 if (pNewObj)
50 {
51 BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE));
52 ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj.get());
53 EndUndo();
54 }
55 }
56 }
57 }
58
59 if (!pNewObj)
60 {
62 }
63}
64
65static void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
66{
67 if(dynamic_cast< const E3dLatheObj* >(pObj) != nullptr)
68 {
69 rMask |= 0x0001;
70 }
71 else if(dynamic_cast< const E3dExtrudeObj* >(pObj) != nullptr)
72 {
73 rMask |= 0x0002;
74 }
75 else if(dynamic_cast< const E3dSphereObj* >(pObj) != nullptr)
76 {
77 rMask |= 0x0004;
78 }
79 else if(dynamic_cast< const E3dCubeObj* >(pObj) != nullptr)
80 {
81 rMask |= 0x0008;
82 }
83 else if(pObj->IsGroupObject())
84 {
85 SdrObjList* pList = pObj->GetSubList();
86 for(size_t a = 0; a < pList->GetObjCount(); ++a)
88 }
89}
90
92{
93 // Creating itemset with corresponding field
94 SfxItemPool& rPool = GetModel().GetItemPool();
95 SfxItemSet aSet(
96 rPool,
97 svl::Items<SDRATTR_START, SDRATTR_END, SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN>);
98
99 sal_uInt32 nSelectedItems(0);
100
101 // get attributes from all selected objects
102 MergeAttrFromMarked(aSet, false);
103
104 // calc flags for SID_ATTR_3D_INTERN
105 const SdrMarkList& rMarkList = GetMarkedObjectList();
106 const size_t nMarkCnt(rMarkList.GetMarkCount());
107
108 for(size_t a = 0; a < nMarkCnt; ++a)
109 {
111 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
112 }
113
114 // Set SID_ATTR_3D_INTERN on the status of the selected objects
115 aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems));
116
117 // maintain default values
118 if(!nSelectedItems)
119 {
120 // Get defaults and apply
122 GetAttributes(aDefaultSet);
123 aSet.Put(aDefaultSet);
124
125 // ... but no lines for 3D
126 aSet.Put(XLineStyleItem (css::drawing::LineStyle_NONE));
127
128 // new defaults for distance and focal length
129 aSet.Put(makeSvx3DDistanceItem(100));
130 aSet.Put(makeSvx3DFocalLengthItem(10000));
131 }
132
133 // return ItemSet
134 return aSet;
135}
136
138{
139 sal_uInt32 nSelectedItems(0);
140
141 // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
142 // They are not needed here, they are already handled in SetAttrToMarked
143
144 // set at selected objects
145 SetAttrToMarked(rAttr, false/*bReplaceAll*/);
146
147 // old run
148 const SdrMarkList& rMarkList = GetMarkedObjectList();
149 const size_t nMarkCnt(rMarkList.GetMarkCount());
150
151 for(size_t a = 0; a < nMarkCnt; ++a)
152 {
154 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
155 }
156
157 // Maintain default values
158 if(!nSelectedItems)
159 {
160 // Set defaults
162 aDefaultSet.Put(rAttr);
163 SetAttributes(aDefaultSet);
164 }
165}
166
168{
169 return static_cast<double>(GetModel().GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE).GetValue());
170}
171
173{
174 return static_cast<double>(GetModel().GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue());
175}
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SphereObject with diameter r3DSize.
Definition: sphere3d.hxx:36
void ConvertMarkedToPolyObj()
Definition: view3d1.cxx:35
SfxItemSet Get3DAttributes() const
Definition: view3d1.cxx:91
double GetDefaultCamFocal()
Definition: view3d1.cxx:172
void Set3DAttributes(const SfxItemSet &rAttr)
Definition: view3d1.cxx:137
double GetDefaultCamPosZ()
Definition: view3d1.cxx:167
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
Definition: svdedtv.cxx:1020
void SetAttrToMarked(const SfxItemSet &rAttr, bool bReplaceAll)
Definition: svdedtv1.cxx:1063
void BegUndo()
Definition: svdedtv.hxx:178
void MergeAttrFromMarked(SfxItemSet &rAttr, bool bOnlyHardAttr) const
Definition: svdedtv1.cxx:907
void ConvertMarkedToPolyObj()
Definition: svdedtv2.cxx:2090
void EndUndo()
Definition: svdedtv.cxx:295
size_t GetMarkCount() const
Definition: svdmark.hxx:178
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:258
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
Definition: svdmrkv.hxx:263
size_t GetMarkedObjectCount() const
Definition: svdmrkv.hxx:264
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:318
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:785
size_t GetObjCount() const
Definition: svdpage.cxx:779
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:717
rtl::Reference< SdrObject > ConvertToPolyObj(bool bBezier, bool bLineToArea) const
Definition: svdobj.cxx:2620
bool IsGroupObject() const
Definition: svdobj.cxx:712
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:323
SdrModel & GetModel() const
Definition: svdpntv.hxx:282
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
Definition: svdview.hxx:193
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
Definition: svdview.cxx:244
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
uno_Any a
constexpr TypedWhichId< SfxUInt32Item > SDRATTR_3DSCENE_FOCAL_LENGTH(SDRATTR_3DSCENE_FIRST+2)
constexpr TypedWhichId< SfxUInt32Item > SDRATTR_3DSCENE_DISTANCE(SDRATTR_3DSCENE_FIRST+1)
E3dScene * DynCastE3dScene(SdrObject *pObj)
Definition: svdobj.cxx:3198
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) Svx3DPerspectiveItem final SfxUInt32Item makeSvx3DDistanceItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:155
SfxUInt32Item makeSvx3DFocalLengthItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:159
static void Imp_E3dView_InorderRun3DObjects(const SdrObject *pObj, sal_uInt32 &rMask)
Definition: view3d1.cxx:65