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_sd.hxx" 30 31 #include "DrawViewShell.hxx" 32 #include <svx/xtable.hxx> 33 #include "sdattr.hxx" 34 #include <svl/aeitem.hxx> 35 #include <editeng/eeitem.hxx> 36 #include <sfx2/request.hxx> 37 #include <svx/svditer.hxx> 38 #include <editeng/colritem.hxx> 39 #include <sfx2/viewfrm.hxx> 40 #ifndef _SVXIDS_HRC 41 #include <svx/svxids.hrc> 42 #endif 43 #include <svx/svdundo.hxx> 44 #include <svx/view3d.hxx> 45 #include <sfx2/dispatch.hxx> 46 #include <svx/float3d.hxx> 47 #include <svx/f3dchild.hxx> 48 #ifndef _SVX_DIALOGS_HRC //autogen 49 #include <svx/dialogs.hrc> 50 #endif 51 #include <vcl/msgbox.hxx> 52 53 54 #include "app.hrc" 55 #include "strings.hrc" 56 57 #include "drawdoc.hxx" 58 #include "DrawDocShell.hxx" 59 #include "anminfo.hxx" 60 #include "unoaprms.hxx" // Undo-Action 61 #include "sdundogr.hxx" // Undo Gruppe 62 #include "drawview.hxx" 63 #include "Window.hxx" 64 #include "sdresid.hxx" 65 66 using namespace ::com::sun::star; 67 68 namespace sd { 69 70 #define ATTR_MISSING 0 // Attribut nicht verfuegbar 71 #define ATTR_MIXED 1 // Attribut uneindeutig (bei Mehrfachselektion) 72 #define ATTR_SET 2 // Attribut eindeutig 73 74 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() 75 76 /************************************************************************* 77 |* 78 |* SfxRequests fuer EffekteWindow bearbeiten 79 |* 80 \************************************************************************/ 81 82 void DrawViewShell::ExecEffectWin( SfxRequest& rReq ) 83 { 84 CheckLineTo (rReq); 85 86 sal_uInt16 nSId = rReq.GetSlot(); 87 88 switch( nSId ) 89 { 90 case SID_3D_INIT: 91 { 92 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId(); 93 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId ); 94 if( pWindow ) 95 { 96 Svx3DWin* p3DWin = (Svx3DWin*)( pWindow->GetWindow() ); 97 if( p3DWin ) 98 p3DWin->InitColorLB( GetDoc() ); 99 } 100 } 101 break; 102 103 case SID_3D_STATE: 104 { 105 Update3DWindow(); 106 } 107 break; 108 109 case SID_3D_ASSIGN: 110 { 111 AssignFrom3DWindow(); 112 } 113 break; 114 115 } 116 } 117 118 /************************************************************************* 119 |* 120 |* 3D - Assign / Update 121 |* 122 \************************************************************************/ 123 void DrawViewShell::Update3DWindow() 124 { 125 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId(); 126 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId ); 127 if( pWindow ) 128 { 129 Svx3DWin* p3DWin = (Svx3DWin*) pWindow->GetWindow(); 130 if( p3DWin && p3DWin->IsUpdateMode() ) 131 { 132 SfxItemSet aTmpItemSet = GetView()->Get3DAttributes(); 133 p3DWin->Update( aTmpItemSet ); 134 } 135 } 136 } 137 138 /*----------------------------------------------------------------------------*/ 139 140 void DrawViewShell::AssignFrom3DWindow() 141 { 142 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId(); 143 SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId ); 144 if( pWin ) 145 { 146 Svx3DWin* p3DWin = (Svx3DWin*) pWin->GetWindow(); 147 if( p3DWin && GetView() ) 148 { 149 if(!GetView()->IsPresObjSelected()) 150 { 151 SfxItemSet aSet( GetDoc()->GetPool(), 152 SDRATTR_START, SDRATTR_END, 153 0, 0); 154 p3DWin->GetAttr( aSet ); 155 156 // Eigene UNDO-Klammerung auch um die Wandlung in 3D 157 GetView()->BegUndo(String(SdResId(STR_UNDO_APPLY_3D_FAVOURITE))); 158 159 if(GetView()->IsConvertTo3DObjPossible()) 160 { 161 // Nur TextAttribute zuweisen 162 SfxItemSet aTextSet( GetDoc()->GetPool(), 163 EE_ITEMS_START, EE_ITEMS_END, 0 ); 164 aTextSet.Put( aSet, sal_False ); 165 GetView()->SetAttributes( aTextSet ); 166 167 // Text in 3D umwandeln 168 sal_uInt16 nSId = SID_CONVERT_TO_3D; 169 SfxBoolItem aItem( nSId, sal_True ); 170 GetViewFrame()->GetDispatcher()->Execute( 171 nSId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); 172 173 // Feststellen, ob ein FILL_Attribut gesetzt ist. 174 // Falls nicht, Fuellattribut hart setzen 175 XFillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem ); 176 if(eFillStyle == XFILL_NONE) 177 aSet.Put(XFillStyleItem (XFILL_SOLID)); 178 179 // remove some 3DSCENE attributes since these were 180 // created by convert to 3D and may not be changed 181 // to the defaults again. 182 aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE); 183 aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH); 184 aSet.ClearItem(SDRATTR_3DOBJ_DEPTH); 185 } 186 187 // Attribute zuweisen 188 GetView()->Set3DAttributes( aSet ); 189 190 // Ende UNDO 191 GetView()->EndUndo(); 192 } 193 else 194 { 195 InfoBox aInfoBox ( 196 GetActiveWindow(), 197 String(SdResId(STR_ACTION_NOTPOSSIBLE))); 198 aInfoBox.Execute(); 199 } 200 201 // Focus zurueckholen 202 GetActiveWindow()->GrabFocus(); 203 } 204 } 205 } 206 207 } 208