1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <tools/shl.hxx> 32 #include "svx/svditer.hxx" 33 #include <svx/svdpool.hxx> 34 #include <svx/svdmodel.hxx> 35 #include <svx/svxids.hrc> 36 #include <svx/xtable.hxx> 37 #include <svx/fmview.hxx> 38 #include <svx/dialogs.hrc> 39 #include <svx/dialmgr.hxx> 40 #include "svx/globl3d.hxx" 41 #include <svx/obj3d.hxx> 42 #include <svx/polysc3d.hxx> 43 #include <svx/e3ditem.hxx> 44 #include <editeng/colritem.hxx> 45 #include <svx/lathe3d.hxx> 46 #include <svx/sphere3d.hxx> 47 #include <svx/extrud3d.hxx> 48 #include <svx/e3dundo.hxx> 49 #include <svx/view3d.hxx> 50 #include <svx/cube3d.hxx> 51 #include <svx/xflclit.hxx> 52 #include <svx/svdogrp.hxx> 53 #include <svx/e3dsceneupdater.hxx> 54 55 /************************************************************************* 56 |* 57 |* Konvertierung in Polygone 58 |* 59 \************************************************************************/ 60 61 void E3dView::ConvertMarkedToPolyObj(sal_Bool bLineToArea) 62 { 63 SdrObject* pNewObj = NULL; 64 65 if (GetMarkedObjectCount() == 1) 66 { 67 SdrObject* pObj = GetMarkedObjectByIndex(0); 68 69 if (pObj && pObj->ISA(E3dPolyScene)) 70 { 71 sal_Bool bBezier = sal_False; 72 pNewObj = ((E3dPolyScene*) pObj)->ConvertToPolyObj(bBezier, bLineToArea); 73 74 if (pNewObj) 75 { 76 BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE)); 77 ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj); 78 EndUndo(); 79 } 80 } 81 } 82 83 if (!pNewObj) 84 { 85 SdrView::ConvertMarkedToPolyObj(bLineToArea); 86 } 87 } 88 89 /************************************************************************* 90 |* 91 |* Get3DAttributes 92 |* 93 \************************************************************************/ 94 95 void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask) 96 { 97 if(pObj->ISA(E3dLatheObj)) 98 { 99 rMask |= 0x0001; 100 } 101 else if(pObj->ISA(E3dExtrudeObj)) 102 { 103 rMask |= 0x0002; 104 } 105 else if(pObj->ISA(E3dSphereObj)) 106 { 107 rMask |= 0x0004; 108 } 109 else if(pObj->ISA(E3dCubeObj)) 110 { 111 rMask |= 0x0008; 112 } 113 else if(pObj->IsGroupObject()) 114 { 115 SdrObjList* pList = pObj->GetSubList(); 116 for(sal_uInt32 a(0); a < pList->GetObjCount(); a++) 117 Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask); 118 } 119 } 120 121 SfxItemSet E3dView::Get3DAttributes(E3dScene* pInScene, sal_Bool /*bOnly3DAttr*/) const 122 { 123 // ItemSet mit entspr. Bereich anlegen 124 SfxItemSet aSet( 125 pMod->GetItemPool(), 126 SDRATTR_START, SDRATTR_END, 127 SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN, 128 0, 0); 129 130 sal_uInt32 nSelectedItems(0L); 131 132 if(pInScene) 133 { 134 // special scene 135 aSet.Put(pInScene->GetMergedItemSet()); 136 } 137 else 138 { 139 // get attributes from all selected objects 140 MergeAttrFromMarked(aSet, sal_False); 141 142 // calc flags for SID_ATTR_3D_INTERN 143 const SdrMarkList& rMarkList = GetMarkedObjectList(); 144 sal_uInt32 nMarkCnt(rMarkList.GetMarkCount()); 145 146 for(sal_uInt32 a(0); a < nMarkCnt; a++) 147 { 148 SdrObject* pObj = GetMarkedObjectByIndex(a); 149 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems); 150 } 151 } 152 153 // setze SID_ATTR_3D_INTERN auf den Status der selektierten Objekte 154 aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems)); 155 156 // DefaultValues pflegen 157 if(!nSelectedItems && !pInScene) 158 { 159 // Defaults holen und hinzufuegen 160 SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST); 161 GetAttributes(aDefaultSet); 162 aSet.Put(aDefaultSet); 163 164 // ... aber keine Linien fuer 3D 165 aSet.Put(XLineStyleItem (XLINE_NONE)); 166 167 // #84061# new defaults for distance and focal length 168 aSet.Put(Svx3DDistanceItem(100)); 169 aSet.Put(Svx3DFocalLengthItem(10000)); 170 } 171 172 // ItemSet zurueckgeben 173 return(aSet); 174 } 175 176 /************************************************************************* 177 |* 178 |* Set3DAttributes: 179 |* 180 \************************************************************************/ 181 182 void E3dView::Set3DAttributes( const SfxItemSet& rAttr, E3dScene* pInScene, sal_Bool bReplaceAll) 183 { 184 sal_uInt32 nSelectedItems(0L); 185 186 if(pInScene) 187 { 188 //pInScene->SetItemSetAndBroadcast(rAttr, bReplaceAll); 189 pInScene->SetMergedItemSetAndBroadcast(rAttr, bReplaceAll); 190 } 191 else 192 { 193 // #i94832# removed usage of E3DModifySceneSnapRectUpdater here. 194 // They are not needed here, they are already handled in SetAttrToMarked 195 196 // set at selected objects 197 SetAttrToMarked(rAttr, bReplaceAll); 198 199 // old run 200 const SdrMarkList& rMarkList = GetMarkedObjectList(); 201 const sal_uInt32 nMarkCnt(rMarkList.GetMarkCount()); 202 203 for(sal_uInt32 a(0); a < nMarkCnt; a++) 204 { 205 SdrObject* pObj = GetMarkedObjectByIndex(a); 206 Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems); 207 } 208 } 209 210 // DefaultValues pflegen 211 if(!nSelectedItems && !pInScene) 212 { 213 // Defaults setzen 214 SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST); 215 aDefaultSet.Put(rAttr); 216 SetAttributes(aDefaultSet); 217 218 } 219 } 220 221 double E3dView::GetDefaultCamPosZ() 222 { 223 return (double)((const SfxUInt32Item&)pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE)).GetValue(); 224 } 225 226 double E3dView::GetDefaultCamFocal() 227 { 228 return (double)((const SfxUInt32Item&)pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); 229 } 230 231