File: | home/maarten/src/libreoffice/core/svx/source/engine3d/view3d1.cxx |
Warning: | line 83, column 13 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | ||||
35 | void E3dView::ConvertMarkedToPolyObj() | |||
36 | { | |||
37 | SdrObject* pNewObj = nullptr; | |||
38 | ||||
39 | if (GetMarkedObjectCount() == 1) | |||
40 | { | |||
41 | SdrObject* pObj = GetMarkedObjectByIndex(0); | |||
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_EXTRUDEreinterpret_cast<char const *>("RID_SVX_3D_UNDO_EXTRUDE" "\004" u8"Create extrusion object"))); | |||
52 | ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj); | |||
53 | EndUndo(); | |||
54 | } | |||
55 | } | |||
56 | } | |||
57 | } | |||
58 | ||||
59 | if (!pNewObj) | |||
60 | { | |||
61 | SdrView::ConvertMarkedToPolyObj(); | |||
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) | |||
87 | Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask); | |||
88 | } | |||
89 | } | |||
90 | ||||
91 | SfxItemSet E3dView::Get3DAttributes() const | |||
92 | { | |||
93 | // Creating itemset with corresponding field | |||
94 | SfxItemSet aSet( | |||
95 | mpModel->GetItemPool(), | |||
96 | svl::Items<SDRATTR_START, SDRATTR_END, | |||
97 | SID_ATTR_3D_INTERN( 10000 + 422 ), SID_ATTR_3D_INTERN( 10000 + 422 )>{}); | |||
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 | { | |||
110 | SdrObject* pObj = GetMarkedObjectByIndex(a); | |||
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( 10000 + 422 ), nSelectedItems)); | |||
116 | ||||
117 | // maintain default values | |||
118 | if(!nSelectedItems) | |||
119 | { | |||
120 | // Get defaults and apply | |||
121 | SfxItemSet aDefaultSet(mpModel->GetItemPool(), svl::Items<SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{}); | |||
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 | ||||
137 | void E3dView::Set3DAttributes( const SfxItemSet& rAttr) | |||
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 | { | |||
153 | SdrObject* pObj = GetMarkedObjectByIndex(a); | |||
154 | Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems); | |||
155 | } | |||
156 | ||||
157 | // Maintain default values | |||
158 | if(!nSelectedItems) | |||
159 | { | |||
160 | // Set defaults | |||
161 | SfxItemSet aDefaultSet(mpModel->GetItemPool(), svl::Items<SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{}); | |||
162 | aDefaultSet.Put(rAttr); | |||
163 | SetAttributes(aDefaultSet); | |||
164 | } | |||
165 | } | |||
166 | ||||
167 | double E3dView::GetDefaultCamPosZ() | |||
168 | { | |||
169 | return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE).GetValue()); | |||
170 | } | |||
171 | ||||
172 | double E3dView::GetDefaultCamFocal() | |||
173 | { | |||
174 | return static_cast<double>(mpModel->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue()); | |||
175 | } | |||
176 | ||||
177 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |