Update ooo320-m1
[ooovba.git] / sd / source / ui / view / drviewsi.cxx
blob30f1f6b623e86162025b753d0f77b515b0cc18c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviewsi.cxx,v $
10 * $Revision: 1.22 $
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_sd.hxx"
34 #include "DrawViewShell.hxx"
35 #include <svx/xtable.hxx>
36 #include "sdattr.hxx"
37 #include <svtools/aeitem.hxx>
38 #include <svx/eeitem.hxx>
39 #include <sfx2/request.hxx>
40 #include <svx/svditer.hxx>
41 #include <svx/colritem.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #ifndef _SVXIDS_HRC
44 #include <svx/svxids.hrc>
45 #endif
46 #include <svx/svdundo.hxx>
47 #include <svx/view3d.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <svx/float3d.hxx>
50 #include <svx/f3dchild.hxx>
51 #ifndef _SVX_DIALOGS_HRC //autogen
52 #include <svx/dialogs.hrc>
53 #endif
54 #include <vcl/msgbox.hxx>
57 #include "app.hrc"
58 #include "strings.hrc"
60 #include "drawdoc.hxx"
61 #include "DrawDocShell.hxx"
62 #include "anminfo.hxx"
63 #include "unoaprms.hxx" // Undo-Action
64 #include "sdundogr.hxx" // Undo Gruppe
65 #include "drawview.hxx"
66 #include "Window.hxx"
67 #include "sdresid.hxx"
69 using namespace ::com::sun::star;
71 namespace sd {
73 #define ATTR_MISSING 0 // Attribut nicht verfuegbar
74 #define ATTR_MIXED 1 // Attribut uneindeutig (bei Mehrfachselektion)
75 #define ATTR_SET 2 // Attribut eindeutig
77 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
79 /*************************************************************************
81 |* SfxRequests fuer EffekteWindow bearbeiten
83 \************************************************************************/
85 void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
87 CheckLineTo (rReq);
89 USHORT nSId = rReq.GetSlot();
91 switch( nSId )
93 case SID_3D_INIT:
95 USHORT nId = Svx3DChildWindow::GetChildWindowId();
96 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
97 if( pWindow )
99 Svx3DWin* p3DWin = (Svx3DWin*)( pWindow->GetWindow() );
100 if( p3DWin )
101 p3DWin->InitColorLB( GetDoc() );
104 break;
106 case SID_3D_STATE:
108 Update3DWindow();
110 break;
112 case SID_3D_ASSIGN:
114 AssignFrom3DWindow();
116 break;
121 /*************************************************************************
123 |* 3D - Assign / Update
125 \************************************************************************/
126 void DrawViewShell::Update3DWindow()
128 USHORT nId = Svx3DChildWindow::GetChildWindowId();
129 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
130 if( pWindow )
132 Svx3DWin* p3DWin = (Svx3DWin*) pWindow->GetWindow();
133 if( p3DWin && p3DWin->IsUpdateMode() )
135 SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
136 p3DWin->Update( aTmpItemSet );
141 /*----------------------------------------------------------------------------*/
143 void DrawViewShell::AssignFrom3DWindow()
145 USHORT nId = Svx3DChildWindow::GetChildWindowId();
146 SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
147 if( pWin )
149 Svx3DWin* p3DWin = (Svx3DWin*) pWin->GetWindow();
150 if( p3DWin && GetView() )
152 if(!GetView()->IsPresObjSelected())
154 SfxItemSet aSet( GetDoc()->GetPool(),
155 SDRATTR_START, SDRATTR_END,
156 0, 0);
157 p3DWin->GetAttr( aSet );
159 // Eigene UNDO-Klammerung auch um die Wandlung in 3D
160 GetView()->BegUndo(String(SdResId(STR_UNDO_APPLY_3D_FAVOURITE)));
162 if(GetView()->IsConvertTo3DObjPossible())
164 // Nur TextAttribute zuweisen
165 SfxItemSet aTextSet( GetDoc()->GetPool(),
166 EE_ITEMS_START, EE_ITEMS_END, 0 );
167 aTextSet.Put( aSet, FALSE );
168 GetView()->SetAttributes( aTextSet );
170 // Text in 3D umwandeln
171 USHORT nSId = SID_CONVERT_TO_3D;
172 SfxBoolItem aItem( nSId, TRUE );
173 GetViewFrame()->GetDispatcher()->Execute(
174 nSId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
176 // Feststellen, ob ein FILL_Attribut gesetzt ist.
177 // Falls nicht, Fuellattribut hart setzen
178 XFillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem );
179 if(eFillStyle == XFILL_NONE)
180 aSet.Put(XFillStyleItem (XFILL_SOLID));
182 // remove some 3DSCENE attributes since these were
183 // created by convert to 3D and may not be changed
184 // to the defaults again.
185 aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
186 aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
187 aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
190 // Attribute zuweisen
191 GetView()->Set3DAttributes( aSet );
193 // Ende UNDO
194 GetView()->EndUndo();
196 else
198 InfoBox aInfoBox (
199 GetActiveWindow(),
200 String(SdResId(STR_ACTION_NOTPOSSIBLE)));
201 aInfoBox.Execute();
204 // Focus zurueckholen
205 GetActiveWindow()->GrabFocus();