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 <svx/svdpool.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 {
37  SdrObject* pNewObj = nullptr;
38 
39  if (GetMarkedObjectCount() == 1)
40  {
42 
43  if (pObj)
44  {
45  auto pScene = dynamic_cast< const E3dScene* >(pObj);
46  if (pScene)
47  {
48  pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/).release();
49  if (pNewObj)
50  {
51  BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE));
52  ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
53  EndUndo();
54  }
55  }
56  }
57  }
58 
59  if (!pNewObj)
60  {
62  }
63 }
64 
65 static 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  SfxItemSet aSet(
97  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>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE).GetValue());
170 }
171 
173 {
174  return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue());
175 }
176 
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t GetMarkCount() const
Definition: svdmark.hxx:180
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
Definition: svdedtv.cxx:986
static void Imp_E3dView_InorderRun3DObjects(const SdrObject *pObj, sal_uInt32 &rMask)
Definition: view3d1.cxx:65
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:758
size_t GetObjCount() const
Definition: svdpage.cxx:752
void BegUndo()
Definition: svdedtv.hxx:179
void Set3DAttributes(const SfxItemSet &rAttr)
Definition: view3d1.cxx:137
void MergeAttrFromMarked(SfxItemSet &rAttr, bool bOnlyHardAttr) const
Definition: svdedtv1.cxx:894
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:647
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
SdrModel * mpModel
Definition: svdpntv.hxx:126
SfxItemSet Get3DAttributes() const
Definition: view3d1.cxx:91
constexpr TypedWhichId< SfxUInt32Item > SDRATTR_3DSCENE_DISTANCE(SDRATTR_3DSCENE_FIRST+1)
void SetAttrToMarked(const SfxItemSet &rAttr, bool bReplaceAll)
Definition: svdedtv1.cxx:1032
double GetDefaultCamPosZ()
Definition: view3d1.cxx:167
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
void ConvertMarkedToPolyObj()
Definition: svdedtv2.cxx:2053
void EndUndo()
Definition: svdedtv.cxx:275
SfxUInt32Item makeSvx3DFocalLengthItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:159
uno_Any a
size_t GetMarkedObjectCount() const
Definition: svdmrkv.hxx:258
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) Svx3DPerspectiveItem SfxUInt32Item makeSvx3DDistanceItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:155
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:252
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
Definition: svdview.hxx:193
double GetDefaultCamFocal()
Definition: view3d1.cxx:172
bool IsGroupObject() const
Definition: svdobj.cxx:642
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
Abstract DrawObject.
Definition: svdobj.hxx:312
constexpr sal_uInt16 SDRATTR_END(SDRATTR_SOFTEDGE_LAST)
SdrObjectUniquePtr ConvertToPolyObj(bool bBezier, bool bLineToArea) const
Definition: svdobj.cxx:2511
constexpr TypedWhichId< SfxUInt32Item > SDRATTR_3DSCENE_FOCAL_LENGTH(SDRATTR_3DSCENE_FIRST+2)
void ConvertMarkedToPolyObj()
Definition: view3d1.cxx:35
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
Definition: svdview.cxx:245
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
Definition: svdmrkv.hxx:257
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:304
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:313