xref: /AOO41X/main/sd/source/ui/view/drviewsi.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "DrawViewShell.hxx"
32*cdf0e10cSrcweir #include <svx/xtable.hxx>
33*cdf0e10cSrcweir #include "sdattr.hxx"
34*cdf0e10cSrcweir #include <svl/aeitem.hxx>
35*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
36*cdf0e10cSrcweir #include <sfx2/request.hxx>
37*cdf0e10cSrcweir #include <svx/svditer.hxx>
38*cdf0e10cSrcweir #include <editeng/colritem.hxx>
39*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
40*cdf0e10cSrcweir #ifndef _SVXIDS_HRC
41*cdf0e10cSrcweir #include <svx/svxids.hrc>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #include <svx/svdundo.hxx>
44*cdf0e10cSrcweir #include <svx/view3d.hxx>
45*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46*cdf0e10cSrcweir #include <svx/float3d.hxx>
47*cdf0e10cSrcweir #include <svx/f3dchild.hxx>
48*cdf0e10cSrcweir #ifndef _SVX_DIALOGS_HRC //autogen
49*cdf0e10cSrcweir #include <svx/dialogs.hrc>
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include "app.hrc"
55*cdf0e10cSrcweir #include "strings.hrc"
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include "drawdoc.hxx"
58*cdf0e10cSrcweir #include "DrawDocShell.hxx"
59*cdf0e10cSrcweir #include "anminfo.hxx"
60*cdf0e10cSrcweir #include "unoaprms.hxx"                 // Undo-Action
61*cdf0e10cSrcweir #include "sdundogr.hxx"                 // Undo Gruppe
62*cdf0e10cSrcweir #include "drawview.hxx"
63*cdf0e10cSrcweir #include "Window.hxx"
64*cdf0e10cSrcweir #include "sdresid.hxx"
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir using namespace ::com::sun::star;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir namespace sd {
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #define ATTR_MISSING    0       // Attribut nicht verfuegbar
71*cdf0e10cSrcweir #define ATTR_MIXED      1       // Attribut uneindeutig (bei Mehrfachselektion)
72*cdf0e10cSrcweir #define ATTR_SET        2       // Attribut eindeutig
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir #define ITEMVALUE(ItemSet,Id,Cast)	((const Cast&)(ItemSet).Get(Id)).GetValue()
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir /*************************************************************************
77*cdf0e10cSrcweir |*
78*cdf0e10cSrcweir |* SfxRequests fuer EffekteWindow bearbeiten
79*cdf0e10cSrcweir |*
80*cdf0e10cSrcweir \************************************************************************/
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir 	CheckLineTo (rReq);
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	sal_uInt16 nSId = rReq.GetSlot();
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	switch( nSId )
89*cdf0e10cSrcweir 	{
90*cdf0e10cSrcweir 		case SID_3D_INIT:
91*cdf0e10cSrcweir 		{
92*cdf0e10cSrcweir 			sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
93*cdf0e10cSrcweir 			SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
94*cdf0e10cSrcweir 			if( pWindow )
95*cdf0e10cSrcweir 			{
96*cdf0e10cSrcweir 				Svx3DWin* p3DWin = (Svx3DWin*)( pWindow->GetWindow() );
97*cdf0e10cSrcweir 				if( p3DWin )
98*cdf0e10cSrcweir 					p3DWin->InitColorLB( GetDoc() );
99*cdf0e10cSrcweir 			}
100*cdf0e10cSrcweir 		}
101*cdf0e10cSrcweir 		break;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 		case SID_3D_STATE:
104*cdf0e10cSrcweir 		{
105*cdf0e10cSrcweir 			Update3DWindow();
106*cdf0e10cSrcweir 		}
107*cdf0e10cSrcweir 		break;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 		case SID_3D_ASSIGN:
110*cdf0e10cSrcweir 		{
111*cdf0e10cSrcweir 			AssignFrom3DWindow();
112*cdf0e10cSrcweir 		}
113*cdf0e10cSrcweir 		break;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	}
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir /*************************************************************************
119*cdf0e10cSrcweir |*
120*cdf0e10cSrcweir |* 3D - Assign / Update
121*cdf0e10cSrcweir |*
122*cdf0e10cSrcweir \************************************************************************/
123*cdf0e10cSrcweir void DrawViewShell::Update3DWindow()
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
126*cdf0e10cSrcweir 	SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
127*cdf0e10cSrcweir 	if( pWindow )
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		Svx3DWin* p3DWin = (Svx3DWin*) pWindow->GetWindow();
130*cdf0e10cSrcweir 		if( p3DWin && p3DWin->IsUpdateMode() )
131*cdf0e10cSrcweir 		{
132*cdf0e10cSrcweir 			SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
133*cdf0e10cSrcweir 			p3DWin->Update( aTmpItemSet );
134*cdf0e10cSrcweir 		}
135*cdf0e10cSrcweir 	}
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir /*----------------------------------------------------------------------------*/
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir void DrawViewShell::AssignFrom3DWindow()
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
143*cdf0e10cSrcweir 	SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
144*cdf0e10cSrcweir 	if( pWin )
145*cdf0e10cSrcweir 	{
146*cdf0e10cSrcweir 		Svx3DWin* p3DWin = (Svx3DWin*) pWin->GetWindow();
147*cdf0e10cSrcweir 		if( p3DWin && GetView() )
148*cdf0e10cSrcweir 		{
149*cdf0e10cSrcweir 			if(!GetView()->IsPresObjSelected())
150*cdf0e10cSrcweir 			{
151*cdf0e10cSrcweir 				SfxItemSet aSet( GetDoc()->GetPool(),
152*cdf0e10cSrcweir 					SDRATTR_START,	SDRATTR_END,
153*cdf0e10cSrcweir 					0, 0);
154*cdf0e10cSrcweir 				p3DWin->GetAttr( aSet );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 				// Eigene UNDO-Klammerung auch um die Wandlung in 3D
157*cdf0e10cSrcweir 				GetView()->BegUndo(String(SdResId(STR_UNDO_APPLY_3D_FAVOURITE)));
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 				if(GetView()->IsConvertTo3DObjPossible())
160*cdf0e10cSrcweir 				{
161*cdf0e10cSrcweir 					// Nur TextAttribute zuweisen
162*cdf0e10cSrcweir 					SfxItemSet aTextSet( GetDoc()->GetPool(),
163*cdf0e10cSrcweir 						EE_ITEMS_START,	EE_ITEMS_END, 0 );
164*cdf0e10cSrcweir 					aTextSet.Put( aSet, sal_False );
165*cdf0e10cSrcweir 					GetView()->SetAttributes( aTextSet );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 					// Text in 3D umwandeln
168*cdf0e10cSrcweir 					sal_uInt16 nSId = SID_CONVERT_TO_3D;
169*cdf0e10cSrcweir 					SfxBoolItem aItem( nSId, sal_True );
170*cdf0e10cSrcweir 					GetViewFrame()->GetDispatcher()->Execute(
171*cdf0e10cSrcweir 						nSId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 					// Feststellen, ob ein FILL_Attribut gesetzt ist.
174*cdf0e10cSrcweir 					// Falls nicht, Fuellattribut hart setzen
175*cdf0e10cSrcweir 					XFillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem );
176*cdf0e10cSrcweir 					if(eFillStyle == XFILL_NONE)
177*cdf0e10cSrcweir 						aSet.Put(XFillStyleItem (XFILL_SOLID));
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 					// remove some 3DSCENE attributes since these were
180*cdf0e10cSrcweir 					// created by convert to 3D and may not be changed
181*cdf0e10cSrcweir 					// to the defaults again.
182*cdf0e10cSrcweir 					aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
183*cdf0e10cSrcweir 					aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
184*cdf0e10cSrcweir 					aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
185*cdf0e10cSrcweir 				}
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 				// Attribute zuweisen
188*cdf0e10cSrcweir 				GetView()->Set3DAttributes( aSet );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 				// Ende UNDO
191*cdf0e10cSrcweir 				GetView()->EndUndo();
192*cdf0e10cSrcweir 			}
193*cdf0e10cSrcweir 			else
194*cdf0e10cSrcweir 			{
195*cdf0e10cSrcweir                 InfoBox aInfoBox (
196*cdf0e10cSrcweir                     GetActiveWindow(),
197*cdf0e10cSrcweir                     String(SdResId(STR_ACTION_NOTPOSSIBLE)));
198*cdf0e10cSrcweir 				aInfoBox.Execute();
199*cdf0e10cSrcweir 			}
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 			// Focus zurueckholen
202*cdf0e10cSrcweir 			GetActiveWindow()->GrabFocus();
203*cdf0e10cSrcweir 		}
204*cdf0e10cSrcweir 	}
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir }
208