1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view3d1.cxx,v $
10 * $Revision: 1.15.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <tools/shl.hxx>
35 #include "svditer.hxx"
36 #include <svx/svdpool.hxx>
37 #include <svx/svdmodel.hxx>
38 #include <svx/svxids.hrc>
39 #include <svx/xtable.hxx>
40 #include <svx/fmview.hxx>
41 #include <svx/dialogs.hrc>
42 #include <svx/dialmgr.hxx>
43 #include "globl3d.hxx"
44 #include <svx/obj3d.hxx>
45 #include <svx/polysc3d.hxx>
46 #include <svx/e3ditem.hxx>
47 #include <svx/colritem.hxx>
48 #include <svx/lathe3d.hxx>
49 #include <svx/sphere3d.hxx>
50 #include <svx/extrud3d.hxx>
51 #include <svx/e3dundo.hxx>
52 #include <svx/view3d.hxx>
53 #include <svx/cube3d.hxx>
54 #include <svx/xflclit.hxx>
55 #include <svx/svdogrp.hxx>
56 #include <svx/e3dsceneupdater.hxx>
58 /*************************************************************************
60 |* Konvertierung in Polygone
62 \************************************************************************/
64 void E3dView::ConvertMarkedToPolyObj(BOOL bLineToArea
)
66 SdrObject
* pNewObj
= NULL
;
68 if (GetMarkedObjectCount() == 1)
70 SdrObject
* pObj
= GetMarkedObjectByIndex(0);
72 if (pObj
&& pObj
->ISA(E3dPolyScene
))
75 pNewObj
= ((E3dPolyScene
*) pObj
)->ConvertToPolyObj(bBezier
, bLineToArea
);
79 BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE
));
80 ReplaceObjectAtView(pObj
, *GetSdrPageView(), pNewObj
);
88 SdrView::ConvertMarkedToPolyObj(bLineToArea
);
92 /*************************************************************************
96 \************************************************************************/
98 void Imp_E3dView_InorderRun3DObjects(const SdrObject
* pObj
, sal_uInt32
& rMask
)
100 if(pObj
->ISA(E3dLatheObj
))
104 else if(pObj
->ISA(E3dExtrudeObj
))
108 else if(pObj
->ISA(E3dSphereObj
))
112 else if(pObj
->ISA(E3dCubeObj
))
116 else if(pObj
->IsGroupObject())
118 SdrObjList
* pList
= pObj
->GetSubList();
119 for(sal_uInt32
a(0); a
< pList
->GetObjCount(); a
++)
120 Imp_E3dView_InorderRun3DObjects(pList
->GetObj(a
), rMask
);
124 SfxItemSet
E3dView::Get3DAttributes(E3dScene
* pInScene
, BOOL
/*bOnly3DAttr*/) const
126 // ItemSet mit entspr. Bereich anlegen
129 SDRATTR_START
, SDRATTR_END
,
130 SID_ATTR_3D_INTERN
, SID_ATTR_3D_INTERN
,
133 sal_uInt32
nSelectedItems(0L);
138 aSet
.Put(pInScene
->GetMergedItemSet());
142 // get attributes from all selected objects
143 MergeAttrFromMarked(aSet
, FALSE
);
145 // calc flags for SID_ATTR_3D_INTERN
146 const SdrMarkList
& rMarkList
= GetMarkedObjectList();
147 sal_uInt32
nMarkCnt(rMarkList
.GetMarkCount());
149 for(sal_uInt32
a(0); a
< nMarkCnt
; a
++)
151 SdrObject
* pObj
= GetMarkedObjectByIndex(a
);
152 Imp_E3dView_InorderRun3DObjects(pObj
, nSelectedItems
);
156 // setze SID_ATTR_3D_INTERN auf den Status der selektierten Objekte
157 aSet
.Put(SfxUInt32Item(SID_ATTR_3D_INTERN
, nSelectedItems
));
159 // DefaultValues pflegen
160 if(!nSelectedItems
&& !pInScene
)
162 // Defaults holen und hinzufuegen
163 SfxItemSet
aDefaultSet(pMod
->GetItemPool(), SDRATTR_3D_FIRST
, SDRATTR_3D_LAST
);
164 GetAttributes(aDefaultSet
);
165 aSet
.Put(aDefaultSet
);
167 // ... aber keine Linien fuer 3D
168 aSet
.Put(XLineStyleItem (XLINE_NONE
));
170 // #84061# new defaults for distance and focal length
171 aSet
.Put(Svx3DDistanceItem(100));
172 aSet
.Put(Svx3DFocalLengthItem(10000));
175 // ItemSet zurueckgeben
179 /*************************************************************************
183 \************************************************************************/
185 void E3dView::Set3DAttributes( const SfxItemSet
& rAttr
, E3dScene
* pInScene
, BOOL bReplaceAll
)
187 sal_uInt32
nSelectedItems(0L);
191 //pInScene->SetItemSetAndBroadcast(rAttr, bReplaceAll);
192 pInScene
->SetMergedItemSetAndBroadcast(rAttr
, bReplaceAll
);
196 // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
197 // They are not needed here, they are already handled in SetAttrToMarked
199 // set at selected objects
200 SetAttrToMarked(rAttr
, bReplaceAll
);
203 const SdrMarkList
& rMarkList
= GetMarkedObjectList();
204 const sal_uInt32
nMarkCnt(rMarkList
.GetMarkCount());
206 for(sal_uInt32
a(0); a
< nMarkCnt
; a
++)
208 SdrObject
* pObj
= GetMarkedObjectByIndex(a
);
209 Imp_E3dView_InorderRun3DObjects(pObj
, nSelectedItems
);
213 // DefaultValues pflegen
214 if(!nSelectedItems
&& !pInScene
)
217 SfxItemSet
aDefaultSet(pMod
->GetItemPool(), SDRATTR_3D_FIRST
, SDRATTR_3D_LAST
);
218 aDefaultSet
.Put(rAttr
);
219 SetAttributes(aDefaultSet
);
224 double E3dView::GetDefaultCamPosZ()
226 return (double)((const SfxUInt32Item
&)pMod
->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE
)).GetValue();
229 double E3dView::GetDefaultCamFocal()
231 return (double)((const SfxUInt32Item
&)pMod
->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH
)).GetValue();