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/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/xlineit0.hxx>
42 #include <svx/svdogrp.hxx>
43 #include <svx/e3dsceneupdater.hxx>
44 #include <com/sun/star/drawing/LineStyle.hpp>
45 
47 {
48  SdrObject* pNewObj = nullptr;
49 
50  if (GetMarkedObjectCount() == 1)
51  {
53 
54  if (pObj)
55  {
56  auto pScene = dynamic_cast< const E3dScene* >(pObj);
57  if (pScene)
58  {
59  pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/).release();
60  if (pNewObj)
61  {
62  BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE));
63  ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
64  EndUndo();
65  }
66  }
67  }
68  }
69 
70  if (!pNewObj)
71  {
73  }
74 }
75 
76 static void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
77 {
78  if(dynamic_cast< const E3dLatheObj* >(pObj) != nullptr)
79  {
80  rMask |= 0x0001;
81  }
82  else if(dynamic_cast< const E3dExtrudeObj* >(pObj) != nullptr)
83  {
84  rMask |= 0x0002;
85  }
86  else if(dynamic_cast< const E3dSphereObj* >(pObj) != nullptr)
87  {
88  rMask |= 0x0004;
89  }
90  else if(dynamic_cast< const E3dCubeObj* >(pObj) != nullptr)
91  {
92  rMask |= 0x0008;
93  }
94  else if(pObj->IsGroupObject())
95  {
96  SdrObjList* pList = pObj->GetSubList();
97  for(size_t a = 0; a < pList->GetObjCount(); ++a)
99  }
100 }
101 
103 {
104  // Creating itemset with corresponding field
105  SfxItemSet aSet(
106  mpModel->GetItemPool(),
108  SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN>{});
109 
110  sal_uInt32 nSelectedItems(0);
111 
112  // get attributes from all selected objects
113  MergeAttrFromMarked(aSet, false);
114 
115  // calc flags for SID_ATTR_3D_INTERN
116  const SdrMarkList& rMarkList = GetMarkedObjectList();
117  const size_t nMarkCnt(rMarkList.GetMarkCount());
118 
119  for(size_t a = 0; a < nMarkCnt; ++a)
120  {
122  Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
123  }
124 
125  // Set SID_ATTR_3D_INTERN on the status of the selected objects
126  aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems));
127 
128  // maintain default values
129  if(!nSelectedItems)
130  {
131  // Get defaults and apply
133  GetAttributes(aDefaultSet);
134  aSet.Put(aDefaultSet);
135 
136  // ... but no lines for 3D
137  aSet.Put(XLineStyleItem (css::drawing::LineStyle_NONE));
138 
139  // new defaults for distance and focal length
140  aSet.Put(makeSvx3DDistanceItem(100));
141  aSet.Put(makeSvx3DFocalLengthItem(10000));
142  }
143 
144  // return ItemSet
145  return aSet;
146 }
147 
149 {
150  sal_uInt32 nSelectedItems(0);
151 
152  // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
153  // They are not needed here, they are already handled in SetAttrToMarked
154 
155  // set at selected objects
156  SetAttrToMarked(rAttr, false/*bReplaceAll*/);
157 
158  // old run
159  const SdrMarkList& rMarkList = GetMarkedObjectList();
160  const size_t nMarkCnt(rMarkList.GetMarkCount());
161 
162  for(size_t a = 0; a < nMarkCnt; ++a)
163  {
165  Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
166  }
167 
168  // Maintain default values
169  if(!nSelectedItems)
170  {
171  // Set defaults
173  aDefaultSet.Put(rAttr);
174  SetAttributes(aDefaultSet);
175  }
176 }
177 
179 {
180  return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE).GetValue());
181 }
182 
184 {
185  return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue());
186 }
187 
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t GetMarkCount() const
Definition: svdmark.hxx:179
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
Definition: svdedtv.cxx:990
static void Imp_E3dView_InorderRun3DObjects(const SdrObject *pObj, sal_uInt32 &rMask)
Definition: view3d1.cxx:76
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:773
size_t GetObjCount() const
Definition: svdpage.cxx:767
void BegUndo()
Definition: svdedtv.hxx:179
void Set3DAttributes(const SfxItemSet &rAttr)
Definition: view3d1.cxx:148
#define SDRATTR_END
Definition: svddef.hxx:407
void MergeAttrFromMarked(SfxItemSet &rAttr, bool bOnlyHardAttr) const
Definition: svdedtv1.cxx:917
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:674
SdrModel * mpModel
Definition: svdpntv.hxx:132
SfxItemSet Get3DAttributes() const
Definition: view3d1.cxx:102
void SetAttrToMarked(const SfxItemSet &rAttr, bool bReplaceAll)
Definition: svdedtv1.cxx:1055
double GetDefaultCamPosZ()
Definition: view3d1.cxx:178
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
void ConvertMarkedToPolyObj()
Definition: svdedtv2.cxx:2052
#define SDRATTR_3DSCENE_FOCAL_LENGTH
Definition: svddef.hxx:360
void EndUndo()
Definition: svdedtv.cxx:278
SfxUInt32Item makeSvx3DFocalLengthItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:158
uno_Any a
size_t GetMarkedObjectCount() const
Definition: svdmrkv.hxx:249
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:243
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
Definition: svdview.hxx:193
double GetDefaultCamFocal()
Definition: view3d1.cxx:183
SfxUInt32Item makeSvx3DDistanceItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:154
bool IsGroupObject() const
Definition: svdobj.cxx:669
#define SDRATTR_START
Definition: svddef.hxx:168
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
Abstract DrawObject.
Definition: svdobj.hxx:312
#define SDRATTR_3DSCENE_DISTANCE
Definition: svddef.hxx:359
SdrObjectUniquePtr ConvertToPolyObj(bool bBezier, bool bLineToArea) const
Definition: svdobj.cxx:2532
void ConvertMarkedToPolyObj()
Definition: view3d1.cxx:46
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
Definition: svdview.cxx:251
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
Definition: svdmrkv.hxx:248
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:310
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:314