xref: /aoo41x/main/sc/source/ui/view/tabvwsh2.cxx (revision cdf0e10c)
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_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifdef _MSC_VER
36*cdf0e10cSrcweir #pragma optimize ("", off)
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
40*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
41*cdf0e10cSrcweir #include <svl/aeitem.hxx>
42*cdf0e10cSrcweir #include <svl/whiter.hxx>
43*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
44*cdf0e10cSrcweir #include <svl/languageoptions.hxx>
45*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include "tabvwsh.hxx"
48*cdf0e10cSrcweir #include "drawattr.hxx"
49*cdf0e10cSrcweir #include "drawsh.hxx"
50*cdf0e10cSrcweir #include "drawview.hxx"
51*cdf0e10cSrcweir #include "fupoor.hxx"
52*cdf0e10cSrcweir #include "fuconrec.hxx"
53*cdf0e10cSrcweir #include "fuconpol.hxx"
54*cdf0e10cSrcweir #include "fuconarc.hxx"
55*cdf0e10cSrcweir #include "fuconuno.hxx"
56*cdf0e10cSrcweir #include "fusel.hxx"
57*cdf0e10cSrcweir #include "futext.hxx"
58*cdf0e10cSrcweir #include "fumark.hxx"
59*cdf0e10cSrcweir #include "fuinsert.hxx"
60*cdf0e10cSrcweir #include "global.hxx"
61*cdf0e10cSrcweir #include "sc.hrc"
62*cdf0e10cSrcweir #include "scmod.hxx"
63*cdf0e10cSrcweir #include "appoptio.hxx"
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir // #98185# Create default drawing objects via keyboard
66*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
67*cdf0e10cSrcweir #include <svl/stritem.hxx>
68*cdf0e10cSrcweir #include <svx/svdpage.hxx>
69*cdf0e10cSrcweir #include <fuconcustomshape.hxx>
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir // -----------------------------------------------------------------------
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir SdrView* __EXPORT ScTabViewShell::GetDrawView() const
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir 	return ((ScTabViewShell*)this)->GetScDrawView();	// GetScDrawView ist nicht-const
76*cdf0e10cSrcweir }
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir void ScTabViewShell::WindowChanged()
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	Window* pWin = GetActiveWin();
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	ScDrawView* pDrView = GetScDrawView();
83*cdf0e10cSrcweir 	if (pDrView)
84*cdf0e10cSrcweir 		pDrView->SetActualWin(pWin);
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	FuPoor*	pFunc = GetDrawFuncPtr();
87*cdf0e10cSrcweir 	if (pFunc)
88*cdf0e10cSrcweir 		pFunc->SetWindow(pWin);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	//	when font from InputContext is used,
91*cdf0e10cSrcweir 	//	this must be moved to change of cursor position:
92*cdf0e10cSrcweir 	UpdateInputContext();
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir void ScTabViewShell::ExecDraw(SfxRequest& rReq)
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	SC_MOD()->InputEnterHandler();
98*cdf0e10cSrcweir 	UpdateInputHandler();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	MakeDrawLayer();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	ScTabView* pTabView = GetViewData()->GetView();
103*cdf0e10cSrcweir 	SfxBindings& rBindings = GetViewFrame()->GetBindings();
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	Window* 	pWin	= pTabView->GetActiveWin();
106*cdf0e10cSrcweir 	ScDrawView*	pView	= pTabView->GetScDrawView();
107*cdf0e10cSrcweir 	SdrModel*	pDoc	= pView->GetModel();
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	const SfxItemSet *pArgs = rReq.GetArgs();
110*cdf0e10cSrcweir 	sal_uInt16 nNewId = rReq.GetSlot();
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     if ( nNewId == SID_DRAW_CHART )
113*cdf0e10cSrcweir     {
114*cdf0e10cSrcweir         // #i71254# directly insert a chart instead of drawing its output rectangle
115*cdf0e10cSrcweir         FuInsertChart(this, pWin, pView, pDoc, rReq);
116*cdf0e10cSrcweir         return;
117*cdf0e10cSrcweir     }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	//
120*cdf0e10cSrcweir 	//	Pseudo-Slots von Draw-Toolbox auswerten
121*cdf0e10cSrcweir 	//!	wird das ueberhaupt noch gebraucht ?????
122*cdf0e10cSrcweir 	//
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     if (nNewId == SID_INSERT_DRAW && pArgs)
125*cdf0e10cSrcweir 	{
126*cdf0e10cSrcweir 		const SfxPoolItem* pItem;
127*cdf0e10cSrcweir 		if ( pArgs->GetItemState( SID_INSERT_DRAW, sal_True, &pItem ) == SFX_ITEM_SET &&
128*cdf0e10cSrcweir 			 pItem->ISA( SvxDrawToolItem ) )
129*cdf0e10cSrcweir 		{
130*cdf0e10cSrcweir 			SvxDrawToolEnum eSel = (SvxDrawToolEnum)((const SvxDrawToolItem*)pItem)->GetValue();
131*cdf0e10cSrcweir 			switch (eSel)
132*cdf0e10cSrcweir 			{
133*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_SELECT:			nNewId = SID_OBJECT_SELECT; 		break;
134*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_LINE:			nNewId = SID_DRAW_LINE; 			break;
135*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_RECT:			nNewId = SID_DRAW_RECT; 			break;
136*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_ELLIPSE: 		nNewId = SID_DRAW_ELLIPSE;			break;
137*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_POLYGON_NOFILL:	nNewId = SID_DRAW_POLYGON_NOFILL;	break;
138*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_BEZIER_NOFILL:	nNewId = SID_DRAW_BEZIER_NOFILL;	break;
139*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_FREELINE_NOFILL:	nNewId = SID_DRAW_FREELINE_NOFILL;	break;
140*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_ARC: 			nNewId = SID_DRAW_ARC;				break;
141*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_PIE: 			nNewId = SID_DRAW_PIE;				break;
142*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_CIRCLECUT:		nNewId = SID_DRAW_CIRCLECUT;		break;
143*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_TEXT:			nNewId = SID_DRAW_TEXT; 			break;
144*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_TEXT_VERTICAL:	nNewId = SID_DRAW_TEXT_VERTICAL;	break;
145*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_TEXT_MARQUEE:	nNewId = SID_DRAW_TEXT_MARQUEE;		break;
146*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_CAPTION: 		nNewId = SID_DRAW_CAPTION;			break;
147*cdf0e10cSrcweir 				case SVX_SNAP_DRAW_CAPTION_VERTICAL: nNewId = SID_DRAW_CAPTION_VERTICAL; break;
148*cdf0e10cSrcweir 			}
149*cdf0e10cSrcweir 		}
150*cdf0e10cSrcweir         else                    // sal_uInt16-Item vom Controller
151*cdf0e10cSrcweir         {
152*cdf0e10cSrcweir             rReq.Done();
153*cdf0e10cSrcweir             return;
154*cdf0e10cSrcweir         }
155*cdf0e10cSrcweir 	}
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     if ( nNewId == SID_DRAW_SELECT )
158*cdf0e10cSrcweir 		nNewId = SID_OBJECT_SELECT;
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	sal_uInt16 nNewFormId = 0;
161*cdf0e10cSrcweir 	if ( nNewId == SID_FM_CREATE_CONTROL && pArgs )
162*cdf0e10cSrcweir 	{
163*cdf0e10cSrcweir 		const SfxPoolItem* pItem;
164*cdf0e10cSrcweir 		if ( pArgs->GetItemState( SID_FM_CONTROL_IDENTIFIER, sal_True, &pItem ) == SFX_ITEM_SET &&
165*cdf0e10cSrcweir 			 pItem->ISA( SfxUInt16Item ) )
166*cdf0e10cSrcweir 			nNewFormId = ((const SfxUInt16Item*)pItem)->GetValue();
167*cdf0e10cSrcweir 	}
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     String sStringItemValue;
170*cdf0e10cSrcweir     if ( pArgs )
171*cdf0e10cSrcweir     {
172*cdf0e10cSrcweir         const SfxPoolItem* pItem;
173*cdf0e10cSrcweir         if ( pArgs->GetItemState( nNewId, sal_True, &pItem ) == SFX_ITEM_SET && pItem->ISA( SfxStringItem ) )
174*cdf0e10cSrcweir             sStringItemValue = static_cast<const SfxStringItem*>(pItem)->GetValue();
175*cdf0e10cSrcweir     }
176*cdf0e10cSrcweir     bool bSwitchCustom = ( sStringItemValue.Len() && sDrawCustom.Len() && sStringItemValue != sDrawCustom );
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	if (nNewId == SID_INSERT_FRAME)						// vom Tbx-Button
179*cdf0e10cSrcweir 		nNewId = SID_DRAW_TEXT;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	//	#97016# CTRL-SID_OBJECT_SELECT is used to select the first object,
182*cdf0e10cSrcweir 	//	but not if SID_OBJECT_SELECT is the result of clicking a create function again,
183*cdf0e10cSrcweir 	//	so this must be tested before changing nNewId below.
184*cdf0e10cSrcweir 	sal_Bool bSelectFirst = ( nNewId == SID_OBJECT_SELECT && (rReq.GetModifier() & KEY_MOD1) );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 	sal_Bool bEx = IsDrawSelMode();
187*cdf0e10cSrcweir 	if ( rReq.GetModifier() & KEY_MOD1 )
188*cdf0e10cSrcweir 	{
189*cdf0e10cSrcweir 		//	#97016# always allow keyboard selection also on background layer
190*cdf0e10cSrcweir 		//	#98185# also allow creation of default objects if the same object type
191*cdf0e10cSrcweir 		//	was already active
192*cdf0e10cSrcweir 		bEx = sal_True;
193*cdf0e10cSrcweir 	}
194*cdf0e10cSrcweir 	else if ( nNewId == nDrawSfxId && ( nNewId != SID_FM_CREATE_CONTROL ||
195*cdf0e10cSrcweir                                     nNewFormId == nFormSfxId || nNewFormId == 0 ) && !bSwitchCustom )
196*cdf0e10cSrcweir 	{
197*cdf0e10cSrcweir         //  #i52871# if a different custom shape is selected, the slot id can be the same,
198*cdf0e10cSrcweir         //  so the custom shape type string has to be compared, too.
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 		//	SID_FM_CREATE_CONTROL mit nNewFormId==0 (ohne Parameter) kommt beim Deaktivieren
201*cdf0e10cSrcweir 		//	aus FuConstruct::SimpleMouseButtonUp
202*cdf0e10cSrcweir 		//	#59280# Execute fuer die Form-Shell, um im Controller zu deselektieren
203*cdf0e10cSrcweir 		if ( nNewId == SID_FM_CREATE_CONTROL )
204*cdf0e10cSrcweir 		{
205*cdf0e10cSrcweir 			GetViewData()->GetDispatcher().Execute(SID_FM_LEAVE_CREATE);
206*cdf0e10cSrcweir 			GetViewFrame()->GetBindings().InvalidateAll(sal_False);
207*cdf0e10cSrcweir 			//!	was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen????
208*cdf0e10cSrcweir 		}
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 		bEx = !bEx;
211*cdf0e10cSrcweir 		nNewId = SID_OBJECT_SELECT;
212*cdf0e10cSrcweir 	}
213*cdf0e10cSrcweir 	else
214*cdf0e10cSrcweir 		bEx = sal_True;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	if ( nDrawSfxId == SID_FM_CREATE_CONTROL && nNewId != nDrawSfxId )
217*cdf0e10cSrcweir 	{
218*cdf0e10cSrcweir 		//	Wechsel von Control- zu Zeichenfunktion -> im Control-Controller deselektieren
219*cdf0e10cSrcweir 		GetViewData()->GetDispatcher().Execute(SID_FM_LEAVE_CREATE);
220*cdf0e10cSrcweir 		GetViewFrame()->GetBindings().InvalidateAll(sal_False);
221*cdf0e10cSrcweir 		//!	was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen????
222*cdf0e10cSrcweir 	}
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	SetDrawSelMode(bEx);
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 	pView->LockBackgroundLayer( !bEx );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	if ( bSelectFirst )
229*cdf0e10cSrcweir 	{
230*cdf0e10cSrcweir 		//	#97016# select first draw object if none is selected yet
231*cdf0e10cSrcweir 		if(!pView->AreObjectsMarked())
232*cdf0e10cSrcweir 		{
233*cdf0e10cSrcweir 			// select first object
234*cdf0e10cSrcweir 			pView->UnmarkAllObj();
235*cdf0e10cSrcweir 			pView->MarkNextObj(sal_True);
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 			// ...and make it visible
238*cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
239*cdf0e10cSrcweir 				pView->MakeVisible(pView->GetAllMarkedRect(), *pWin);
240*cdf0e10cSrcweir 		}
241*cdf0e10cSrcweir 	}
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	nDrawSfxId = nNewId;
244*cdf0e10cSrcweir     sDrawCustom.Erase();    // value is set below for custom shapes
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 	if ( nNewId != SID_DRAW_CHART )				// Chart nicht mit DrawShell
247*cdf0e10cSrcweir 	{
248*cdf0e10cSrcweir 		if ( nNewId == SID_DRAW_TEXT || nNewId == SID_DRAW_TEXT_VERTICAL ||
249*cdf0e10cSrcweir 				nNewId == SID_DRAW_TEXT_MARQUEE || nNewId == SID_DRAW_NOTEEDIT )
250*cdf0e10cSrcweir 			SetDrawTextShell( sal_True );
251*cdf0e10cSrcweir 		else
252*cdf0e10cSrcweir 		{
253*cdf0e10cSrcweir 			if ( bEx || pView->GetMarkedObjectList().GetMarkCount() != 0 )
254*cdf0e10cSrcweir 				SetDrawShellOrSub();
255*cdf0e10cSrcweir 			else
256*cdf0e10cSrcweir 				SetDrawShell( sal_False );
257*cdf0e10cSrcweir 		}
258*cdf0e10cSrcweir 	}
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 	if (pTabView->GetDrawFuncPtr())
261*cdf0e10cSrcweir 	{
262*cdf0e10cSrcweir 		if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr())
263*cdf0e10cSrcweir 			delete pTabView->GetDrawFuncOldPtr();
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 		pTabView->GetDrawFuncPtr()->Deactivate();
266*cdf0e10cSrcweir 		pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr());
267*cdf0e10cSrcweir 		pTabView->SetDrawFuncPtr(NULL);
268*cdf0e10cSrcweir 	}
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 	SfxRequest aNewReq(rReq);
271*cdf0e10cSrcweir 	aNewReq.SetSlot(nDrawSfxId);
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 	switch (nNewId)
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		case SID_OBJECT_SELECT:
276*cdf0e10cSrcweir 			//@#70206# Nicht immer zurueckschalten
277*cdf0e10cSrcweir 			if(pView->GetMarkedObjectList().GetMarkCount() == 0) SetDrawShell(bEx);
278*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuSelection(this, pWin, pView, pDoc, aNewReq));
279*cdf0e10cSrcweir 			break;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 		case SID_DRAW_LINE:
282*cdf0e10cSrcweir 		case SID_DRAW_RECT:
283*cdf0e10cSrcweir 		case SID_DRAW_ELLIPSE:
284*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq));
285*cdf0e10cSrcweir 			break;
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 		case SID_DRAW_CAPTION:
288*cdf0e10cSrcweir 		case SID_DRAW_CAPTION_VERTICAL:
289*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq));
290*cdf0e10cSrcweir 			pView->SetFrameDragSingles( sal_False );
291*cdf0e10cSrcweir 			rBindings.Invalidate( SID_BEZIER_EDIT );
292*cdf0e10cSrcweir 			break;
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 		case SID_DRAW_POLYGON:
295*cdf0e10cSrcweir 		case SID_DRAW_POLYGON_NOFILL:
296*cdf0e10cSrcweir 		case SID_DRAW_BEZIER_NOFILL:
297*cdf0e10cSrcweir 		case SID_DRAW_FREELINE_NOFILL:
298*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuConstPolygon(this, pWin, pView, pDoc, aNewReq));
299*cdf0e10cSrcweir 			break;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 		case SID_DRAW_ARC:
302*cdf0e10cSrcweir 		case SID_DRAW_PIE:
303*cdf0e10cSrcweir 		case SID_DRAW_CIRCLECUT:
304*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuConstArc(this, pWin, pView, pDoc, aNewReq));
305*cdf0e10cSrcweir 			break;
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 		case SID_DRAW_TEXT:
308*cdf0e10cSrcweir 		case SID_DRAW_TEXT_VERTICAL:
309*cdf0e10cSrcweir 		case SID_DRAW_TEXT_MARQUEE:
310*cdf0e10cSrcweir 		case SID_DRAW_NOTEEDIT:
311*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuText(this, pWin, pView, pDoc, aNewReq));
312*cdf0e10cSrcweir 			break;
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir 		case SID_FM_CREATE_CONTROL:
315*cdf0e10cSrcweir 			SetDrawFormShell(sal_True);
316*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuConstUnoControl(this, pWin, pView, pDoc, aNewReq));
317*cdf0e10cSrcweir 			nFormSfxId = nNewFormId;
318*cdf0e10cSrcweir 			break;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 		case SID_DRAW_CHART:
321*cdf0e10cSrcweir //UNUSED2008-05  bChartDlgIsEdit = sal_False;
322*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr(new FuMarkRect(this, pWin, pView, pDoc, aNewReq));
323*cdf0e10cSrcweir 			break;
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 		case SID_DRAWTBX_CS_BASIC :
326*cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL :
327*cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW :
328*cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART :
329*cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT :
330*cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR :
331*cdf0e10cSrcweir 		case SID_DRAW_CS_ID :
332*cdf0e10cSrcweir 		{
333*cdf0e10cSrcweir 			pTabView->SetDrawFuncPtr( new FuConstCustomShape( this, pWin, pView, pDoc, aNewReq ));
334*cdf0e10cSrcweir             if ( nNewId != SID_DRAW_CS_ID )
335*cdf0e10cSrcweir             {
336*cdf0e10cSrcweir                 SFX_REQUEST_ARG( rReq, pEnumCommand, SfxStringItem, nNewId, sal_False );
337*cdf0e10cSrcweir                 if ( pEnumCommand )
338*cdf0e10cSrcweir                 {
339*cdf0e10cSrcweir                     aCurrShapeEnumCommand[ nNewId - SID_DRAWTBX_CS_BASIC ] = pEnumCommand->GetValue();
340*cdf0e10cSrcweir 		            SfxBindings& rBind = GetViewFrame()->GetBindings();
341*cdf0e10cSrcweir 		            rBind.Invalidate( nNewId );
342*cdf0e10cSrcweir 		            rBind.Update( nNewId );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir                     sDrawCustom = pEnumCommand->GetValue();  // to detect when a different shape type is selected
345*cdf0e10cSrcweir                 }
346*cdf0e10cSrcweir             }
347*cdf0e10cSrcweir 		}
348*cdf0e10cSrcweir 		break;
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir         default:
351*cdf0e10cSrcweir 			break;
352*cdf0e10cSrcweir 	}
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir 	if (pTabView->GetDrawFuncPtr())
355*cdf0e10cSrcweir 		pTabView->GetDrawFuncPtr()->Activate();
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 	rReq.Done();
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	rBindings.Invalidate( SID_INSERT_DRAW );
360*cdf0e10cSrcweir 	rBindings.Update( SID_INSERT_DRAW );
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	// #98185# Create default drawing objects via keyboard
363*cdf0e10cSrcweir 	// with qualifier construct directly
364*cdf0e10cSrcweir 	FuPoor*	pFuActual = GetDrawFuncPtr();
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 	if(pFuActual && (rReq.GetModifier() & KEY_MOD1))
367*cdf0e10cSrcweir 	{
368*cdf0e10cSrcweir 		// #98185# Create default drawing objects via keyboard
369*cdf0e10cSrcweir 		const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
370*cdf0e10cSrcweir 		sal_uInt32 nDefaultObjectSizeWidth = rAppOpt.GetDefaultObjectSizeWidth();
371*cdf0e10cSrcweir 		sal_uInt32 nDefaultObjectSizeHeight = rAppOpt.GetDefaultObjectSizeHeight();
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 		// calc position and size
374*cdf0e10cSrcweir 		Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
375*cdf0e10cSrcweir 		Point aPagePos = aVisArea.Center();
376*cdf0e10cSrcweir 		aPagePos.X() -= nDefaultObjectSizeWidth / 2;
377*cdf0e10cSrcweir 		aPagePos.Y() -= nDefaultObjectSizeHeight / 2;
378*cdf0e10cSrcweir 		Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 		ScDrawView* pDrView = GetScDrawView();
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 		if(pDrView)
383*cdf0e10cSrcweir 		{
384*cdf0e10cSrcweir 			SdrPageView* pPageView = pDrView->GetSdrPageView();
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 			if(pPageView)
387*cdf0e10cSrcweir 			{
388*cdf0e10cSrcweir 				// create the default object
389*cdf0e10cSrcweir 				SdrObject* pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle);
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir 				if(pObj)
392*cdf0e10cSrcweir 				{
393*cdf0e10cSrcweir 					// insert into page
394*cdf0e10cSrcweir 					pView->InsertObjectAtView(pObj, *pPageView);
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 					if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL )
397*cdf0e10cSrcweir 					{
398*cdf0e10cSrcweir 						//	#105815# use KeyInput to start edit mode (FuText is created).
399*cdf0e10cSrcweir 						//	For FuText objects, edit mode is handled within CreateDefaultObject.
400*cdf0e10cSrcweir 						//	KEY_F2 is handled in FuDraw::KeyInput.
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 						pFuActual->KeyInput( KeyEvent( 0, KeyCode( KEY_F2 ) ) );
403*cdf0e10cSrcweir 					}
404*cdf0e10cSrcweir 				}
405*cdf0e10cSrcweir 			}
406*cdf0e10cSrcweir 		}
407*cdf0e10cSrcweir 	}
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir void ScTabViewShell::GetDrawState(SfxItemSet &rSet)
411*cdf0e10cSrcweir {
412*cdf0e10cSrcweir 	SfxWhichIter	aIter(rSet);
413*cdf0e10cSrcweir 	sal_uInt16			nWhich = aIter.FirstWhich();
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	while ( nWhich )
416*cdf0e10cSrcweir 	{
417*cdf0e10cSrcweir 		switch ( nWhich )
418*cdf0e10cSrcweir 		{
419*cdf0e10cSrcweir 			case SID_INSERT_DRAW:
420*cdf0e10cSrcweir 				{
421*cdf0e10cSrcweir 					//	SID_OBJECT_SELECT nur, wenn "harter" Selektionsmodus
422*cdf0e10cSrcweir 					sal_uInt16 nPutId = nDrawSfxId;
423*cdf0e10cSrcweir 					if ( nPutId == SID_OBJECT_SELECT && !IsDrawSelMode() )
424*cdf0e10cSrcweir 						nPutId = USHRT_MAX;
425*cdf0e10cSrcweir 					// nur die Images, die auch auf dem Controller liegen
426*cdf0e10cSrcweir 					if ( nPutId != SID_OBJECT_SELECT &&
427*cdf0e10cSrcweir 						 nPutId != SID_DRAW_LINE &&
428*cdf0e10cSrcweir 						 nPutId != SID_DRAW_RECT &&
429*cdf0e10cSrcweir 						 nPutId != SID_DRAW_ELLIPSE &&
430*cdf0e10cSrcweir 						 nPutId != SID_DRAW_POLYGON_NOFILL &&
431*cdf0e10cSrcweir 						 nPutId != SID_DRAW_BEZIER_NOFILL &&
432*cdf0e10cSrcweir 						 nPutId != SID_DRAW_FREELINE_NOFILL &&
433*cdf0e10cSrcweir 						 nPutId != SID_DRAW_ARC &&
434*cdf0e10cSrcweir 						 nPutId != SID_DRAW_PIE &&
435*cdf0e10cSrcweir 						 nPutId != SID_DRAW_CIRCLECUT &&
436*cdf0e10cSrcweir 						 nPutId != SID_DRAW_TEXT &&
437*cdf0e10cSrcweir 						 nPutId != SID_DRAW_TEXT_VERTICAL &&
438*cdf0e10cSrcweir 						 nPutId != SID_DRAW_TEXT_MARQUEE &&
439*cdf0e10cSrcweir 						 nPutId != SID_DRAW_CAPTION &&
440*cdf0e10cSrcweir 						 nPutId != SID_DRAW_CAPTION_VERTICAL )
441*cdf0e10cSrcweir 						nPutId = USHRT_MAX;
442*cdf0e10cSrcweir 					SfxAllEnumItem aItem( nWhich, nPutId );
443*cdf0e10cSrcweir 					if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
444*cdf0e10cSrcweir 					{
445*cdf0e10cSrcweir 						aItem.DisableValue( SID_DRAW_TEXT_VERTICAL );
446*cdf0e10cSrcweir 						aItem.DisableValue( SID_DRAW_CAPTION_VERTICAL );
447*cdf0e10cSrcweir 					}
448*cdf0e10cSrcweir 					rSet.Put( aItem );
449*cdf0e10cSrcweir 				}
450*cdf0e10cSrcweir 				break;
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 			case SID_DRAW_CHART:
453*cdf0e10cSrcweir 				{
454*cdf0e10cSrcweir                     sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
455*cdf0e10cSrcweir 					if ( bOle || !SvtModuleOptions().IsChart() )
456*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
457*cdf0e10cSrcweir 				}
458*cdf0e10cSrcweir 				break;
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 			case SID_OBJECT_SELECT:		// wichtig fuer den ollen Control-Controller
461*cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, nDrawSfxId == SID_OBJECT_SELECT && IsDrawSelMode() ) );
462*cdf0e10cSrcweir 				break;
463*cdf0e10cSrcweir 		}
464*cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
465*cdf0e10cSrcweir 	}
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir sal_Bool ScTabViewShell::SelectObject( const String& rName )
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir 	ScDrawView* pView = GetViewData()->GetScDrawView();
471*cdf0e10cSrcweir 	if (!pView)
472*cdf0e10cSrcweir 		return sal_False;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	sal_Bool bFound = pView->SelectObject( rName );
475*cdf0e10cSrcweir 	// DrawShell etc. is handled in MarkListHasChanged
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	return bFound;
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir 
482