xref: /aoo41x/main/sc/source/ui/view/tabvwshb.cxx (revision a5258243)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29cdf0e10cSrcweir #include "precompiled_sc.hxx"
30cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
31cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataReceiver.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //------------------------------------------------------------------
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #ifdef _MSC_VER
38cdf0e10cSrcweir #pragma optimize ("", off)
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMisc.hpp>
44cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
45cdf0e10cSrcweir #include <sfx2/app.hxx>
46cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
47cdf0e10cSrcweir #include <svx/svxdlg.hxx>
48cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx>
49cdf0e10cSrcweir #include <svx/pfiledlg.hxx>
50cdf0e10cSrcweir #include <svx/svditer.hxx>
51cdf0e10cSrcweir #include <svx/svdmark.hxx>
52cdf0e10cSrcweir #include <svx/svdograf.hxx>
53cdf0e10cSrcweir #include <svx/svdogrp.hxx>
54cdf0e10cSrcweir #include <svx/svdoole2.hxx>
55cdf0e10cSrcweir #include <svx/svdouno.hxx>
56cdf0e10cSrcweir #include <svx/svdview.hxx>
57cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
58cdf0e10cSrcweir #include <svx/fontworkbar.hxx>
59cdf0e10cSrcweir #include <sfx2/bindings.hxx>
60cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
61cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
62cdf0e10cSrcweir #include <svtools/soerr.hxx>
63cdf0e10cSrcweir #include <svl/rectitem.hxx>
64cdf0e10cSrcweir #include <svl/slstitm.hxx>
65cdf0e10cSrcweir #include <svl/whiter.hxx>
66cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
67cdf0e10cSrcweir #include <sot/exchange.hxx>
68cdf0e10cSrcweir #include <tools/diagnose_ex.h>
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #include "tabvwsh.hxx"
71cdf0e10cSrcweir #include "globstr.hrc"
72cdf0e10cSrcweir #include "scmod.hxx"
73cdf0e10cSrcweir #include "document.hxx"
74cdf0e10cSrcweir #include "sc.hrc"
75cdf0e10cSrcweir #include "client.hxx"
76cdf0e10cSrcweir #include "fuinsert.hxx"
77cdf0e10cSrcweir #include "docsh.hxx"
78cdf0e10cSrcweir #include "chartarr.hxx"
79cdf0e10cSrcweir #include "drawview.hxx"
80cdf0e10cSrcweir #include "ChartRangeSelectionListener.hxx"
81cdf0e10cSrcweir 
82cdf0e10cSrcweir using namespace com::sun::star;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
85cdf0e10cSrcweir 
86cdf0e10cSrcweir void ScTabViewShell::ConnectObject( SdrOle2Obj* pObj )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	//	wird aus dem Paint gerufen
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
91cdf0e10cSrcweir 	Window* pWin = GetActiveWin();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	//	#41412# wenn schon connected ist, nicht nochmal SetObjArea/SetSizeScale
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
96cdf0e10cSrcweir     if ( !pClient )
97cdf0e10cSrcweir 	{
98cdf0e10cSrcweir         pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
99cdf0e10cSrcweir 		Rectangle aRect = pObj->GetLogicRect();
100cdf0e10cSrcweir 		Size aDrawSize = aRect.GetSize();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 		Size aOleSize = pObj->GetOrigObjSize();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 		Fraction aScaleWidth (aDrawSize.Width(),  aOleSize.Width() );
105cdf0e10cSrcweir 		Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
106cdf0e10cSrcweir 		aScaleWidth.ReduceInaccurate(10);		// kompatibel zum SdrOle2Obj
107cdf0e10cSrcweir 		aScaleHeight.ReduceInaccurate(10);
108cdf0e10cSrcweir         pClient->SetSizeScale(aScaleWidth,aScaleHeight);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         // sichtbarer Ausschnitt wird nur inplace veraendert!
111cdf0e10cSrcweir 		// the object area must be set after the scaling since it triggers the resizing
112cdf0e10cSrcweir 		aRect.SetSize( aOleSize );
113cdf0e10cSrcweir         pClient->SetObjArea( aRect );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         ((ScClient*)pClient)->SetGrafEdit( NULL );
116cdf0e10cSrcweir 	}
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir sal_Bool ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, long nVerb )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	// #41081# Gueltigkeits-Hinweisfenster nicht ueber dem Objekt stehenlassen
122cdf0e10cSrcweir 	RemoveHintWindow();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
125cdf0e10cSrcweir 	Window* pWin = GetActiveWin();
126cdf0e10cSrcweir 	ErrCode nErr = ERRCODE_NONE;
127cdf0e10cSrcweir 	sal_Bool bErrorShown = sal_False;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	// linked objects aren't supported
130cdf0e10cSrcweir //	if ( xIPObj->IsLink() )
131cdf0e10cSrcweir //		nErr = xIPObj->DoVerb(nVerb);			// gelinkt -> ohne Client etc.
132cdf0e10cSrcweir //	else
133cdf0e10cSrcweir 	{
134cdf0e10cSrcweir         SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
135cdf0e10cSrcweir         if ( !pClient )
136cdf0e10cSrcweir             pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         if ( !(nErr & ERRCODE_ERROR_MASK) && xObj.is() )
139cdf0e10cSrcweir 		{
140cdf0e10cSrcweir 			Rectangle aRect = pObj->GetLogicRect();
141*a5258243SPedro Giffuni 
142*a5258243SPedro Giffuni             {
143*a5258243SPedro Giffuni                 // #i118485# center on BoundRect for activation,
144*a5258243SPedro Giffuni                 // OLE may be sheared/rotated now
145*a5258243SPedro Giffuni         	    const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
146*a5258243SPedro Giffuni                 const Point aDelta(rBoundRect.Center() - aRect.Center());
147*a5258243SPedro Giffuni                 aRect.Move(aDelta.X(), aDelta.Y());
148*a5258243SPedro Giffuni             }
149*a5258243SPedro Giffuni 
150*a5258243SPedro Giffuni             Size aDrawSize = aRect.GetSize();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 			MapMode aMapMode( MAP_100TH_MM );
153cdf0e10cSrcweir 			Size aOleSize = pObj->GetOrigObjSize( &aMapMode );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir             if ( pClient->GetAspect() != embed::Aspects::MSOLE_ICON
156cdf0e10cSrcweir 			  && ( xObj->getStatus( pClient->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
157cdf0e10cSrcweir 			{
158cdf0e10cSrcweir 				//	scale must always be 1 - change VisArea if different from client size
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 				if ( aDrawSize != aOleSize )
161cdf0e10cSrcweir 				{
162cdf0e10cSrcweir             		MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pClient->GetAspect() ) );
163cdf0e10cSrcweir                     aOleSize = OutputDevice::LogicToLogic( aDrawSize,
164cdf0e10cSrcweir                                             MAP_100TH_MM, aUnit );
165cdf0e10cSrcweir             		awt::Size aSz( aOleSize.Width(), aOleSize.Height() );
166cdf0e10cSrcweir                     xObj->setVisualAreaSize( pClient->GetAspect(), aSz );
167cdf0e10cSrcweir 				}
168cdf0e10cSrcweir 				Fraction aOne( 1, 1 );
169cdf0e10cSrcweir                 pClient->SetSizeScale( aOne, aOne );
170cdf0e10cSrcweir 			}
171cdf0e10cSrcweir 			else
172cdf0e10cSrcweir 			{
173cdf0e10cSrcweir 				//	calculate scale from client and VisArea size
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 				Fraction aScaleWidth (aDrawSize.Width(),  aOleSize.Width() );
176cdf0e10cSrcweir 				Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
177cdf0e10cSrcweir 				aScaleWidth.ReduceInaccurate(10);		// kompatibel zum SdrOle2Obj
178cdf0e10cSrcweir 				aScaleHeight.ReduceInaccurate(10);
179cdf0e10cSrcweir                 pClient->SetSizeScale(aScaleWidth,aScaleHeight);
180cdf0e10cSrcweir 			}
181cdf0e10cSrcweir 
182cdf0e10cSrcweir             // sichtbarer Ausschnitt wird nur inplace veraendert!
183cdf0e10cSrcweir 			// the object area must be set after the scaling since it triggers the resizing
184cdf0e10cSrcweir 			aRect.SetSize( aOleSize );
185cdf0e10cSrcweir             pClient->SetObjArea( aRect );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir             ((ScClient*)pClient)->SetGrafEdit( NULL );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir             nErr = pClient->DoVerb( nVerb );
190cdf0e10cSrcweir 			bErrorShown = sal_True;
191cdf0e10cSrcweir 			// SfxViewShell::DoVerb zeigt seine Fehlermeldungen selber an
192cdf0e10cSrcweir 
193cdf0e10cSrcweir             SetNewVisArea();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 			// attach listener to selection changes in chart that affect cell
196cdf0e10cSrcweir 			// ranges, so those can be highlighted
197cdf0e10cSrcweir             // note: do that after DoVerb, so that the chart controller exists
198cdf0e10cSrcweir 			if ( SvtModuleOptions().IsChart() )
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir                 SvGlobalName aObjClsId ( xObj->getClassID() );
201cdf0e10cSrcweir 				if (SotExchange::IsChart( aObjClsId ))
202cdf0e10cSrcweir 				{
203cdf0e10cSrcweir                     try
204cdf0e10cSrcweir                     {
205cdf0e10cSrcweir                         uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY_THROW );
206cdf0e10cSrcweir                         uno::Reference< chart2::data::XDataReceiver > xDataReceiver(
207cdf0e10cSrcweir                             xSup->getComponent(), uno::UNO_QUERY_THROW );
208cdf0e10cSrcweir                         uno::Reference< chart2::data::XRangeHighlighter > xRangeHightlighter(
209cdf0e10cSrcweir                             xDataReceiver->getRangeHighlighter());
210cdf0e10cSrcweir                         if( xRangeHightlighter.is())
211cdf0e10cSrcweir                         {
212cdf0e10cSrcweir                             uno::Reference< view::XSelectionChangeListener > xListener(
213cdf0e10cSrcweir                                 new ScChartRangeSelectionListener( this ));
214cdf0e10cSrcweir                             xRangeHightlighter->addSelectionChangeListener( xListener );
215cdf0e10cSrcweir                         }
216cdf0e10cSrcweir                     }
217cdf0e10cSrcweir                     catch( const uno::Exception & )
218cdf0e10cSrcweir                     {
219cdf0e10cSrcweir                         DBG_ERROR( "Exception caught while querying chart" );
220cdf0e10cSrcweir                     }
221cdf0e10cSrcweir                 }
222cdf0e10cSrcweir 			}
223cdf0e10cSrcweir 		}
224cdf0e10cSrcweir 	}
225cdf0e10cSrcweir 	if (nErr != ERRCODE_NONE && !bErrorShown)
226cdf0e10cSrcweir 		ErrorHandler::HandleError(nErr);
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	//!	SetDocumentName sollte schon im Sfx passieren ???
229cdf0e10cSrcweir     //TODO/LATER: how "SetDocumentName"?
230cdf0e10cSrcweir     //xIPObj->SetDocumentName( GetViewData()->GetDocShell()->GetTitle() );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	return ( !(nErr & ERRCODE_ERROR_MASK) );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir ErrCode __EXPORT ScTabViewShell::DoVerb(long nVerb)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	SdrView* pView = GetSdrView();
238cdf0e10cSrcweir 	if (!pView)
239cdf0e10cSrcweir 		return ERRCODE_SO_NOTIMPL;			// soll nicht sein
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	SdrOle2Obj* pOle2Obj = NULL;
242cdf0e10cSrcweir 	SdrGrafObj* pGrafObj = NULL;
243cdf0e10cSrcweir 	SdrObject* pObj = NULL;
244cdf0e10cSrcweir 	ErrCode nErr = ERRCODE_NONE;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
247cdf0e10cSrcweir 	if (rMarkList.GetMarkCount() == 1)
248cdf0e10cSrcweir 	{
249cdf0e10cSrcweir 		pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
250cdf0e10cSrcweir 		if (pObj->GetObjIdentifier() == OBJ_OLE2)
251cdf0e10cSrcweir 			pOle2Obj = (SdrOle2Obj*) pObj;
252cdf0e10cSrcweir 		else if (pObj->GetObjIdentifier() == OBJ_GRAF)
253cdf0e10cSrcweir 		{
254cdf0e10cSrcweir 			pGrafObj = (SdrGrafObj*) pObj;
255cdf0e10cSrcweir 		}
256cdf0e10cSrcweir 	}
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	if (pOle2Obj)
259cdf0e10cSrcweir 	{
260cdf0e10cSrcweir 		ActivateObject( pOle2Obj, nVerb );
261cdf0e10cSrcweir 	}
262cdf0e10cSrcweir 	else
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 		DBG_ERROR("kein Objekt fuer Verb gefunden");
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	return nErr;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir void ScTabViewShell::DeactivateOle()
271cdf0e10cSrcweir {
272cdf0e10cSrcweir     // deactivate inplace editing if currently active
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
275cdf0e10cSrcweir     bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     ScClient* pClient = (ScClient*) GetIPClient();
278cdf0e10cSrcweir     if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
279cdf0e10cSrcweir         pClient->DeactivateObject();
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
285cdf0e10cSrcweir 	if (nSlot != SID_OBJECTRESIZE )
286cdf0e10cSrcweir 	{
287cdf0e10cSrcweir 		SC_MOD()->InputEnterHandler();
288cdf0e10cSrcweir 		UpdateInputHandler();
289cdf0e10cSrcweir 	}
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 	//	Rahmen fuer Chart einfuegen wird abgebrochen:
292cdf0e10cSrcweir 	FuPoor* pPoor = GetDrawFuncPtr();
293cdf0e10cSrcweir 	if ( pPoor && pPoor->GetSlotID() == SID_DRAW_CHART )
294cdf0e10cSrcweir 		GetViewData()->GetDispatcher().Execute(SID_DRAW_CHART, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	MakeDrawLayer();
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	SfxBindings& rBindings = GetViewFrame()->GetBindings();
299cdf0e10cSrcweir 	ScTabView*	 pTabView  = GetViewData()->GetView();
300cdf0e10cSrcweir 	Window* 	 pWin	   = pTabView->GetActiveWin();
301cdf0e10cSrcweir 	ScDrawView*	 pView	   = pTabView->GetScDrawView();
302cdf0e10cSrcweir 	ScDocShell*	 pDocSh	   = GetViewData()->GetDocShell();
303cdf0e10cSrcweir 	ScDocument*	 pDoc	   = pDocSh->GetDocument();
304cdf0e10cSrcweir //	SdrModel*	 pDrModel  = pDocSh->MakeDrawLayer();
305cdf0e10cSrcweir 	SdrModel*	 pDrModel  = pView->GetModel();
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 	switch ( nSlot )
308cdf0e10cSrcweir 	{
309cdf0e10cSrcweir 		case SID_INSERT_GRAPHIC:
310cdf0e10cSrcweir 			FuInsertGraphic(this, pWin, pView, pDrModel, rReq);
311cdf0e10cSrcweir 			// shell is set in MarkListHasChanged
312cdf0e10cSrcweir 			break;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 		case SID_INSERT_AVMEDIA:
315cdf0e10cSrcweir 			FuInsertMedia(this, pWin, pView, pDrModel, rReq);
316cdf0e10cSrcweir 			// shell is set in MarkListHasChanged
317cdf0e10cSrcweir 			break;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 		case SID_INSERT_DIAGRAM:
320cdf0e10cSrcweir 			FuInsertChart(this, pWin, pView, pDrModel, rReq);
321cdf0e10cSrcweir //?			SC_MOD()->SetFunctionDlg( NULL );//XXX
322cdf0e10cSrcweir 			break;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 		case SID_INSERT_OBJECT:
325cdf0e10cSrcweir 		case SID_INSERT_PLUGIN:
326cdf0e10cSrcweir 		case SID_INSERT_SOUND:
327cdf0e10cSrcweir 		case SID_INSERT_VIDEO:
328cdf0e10cSrcweir 		case SID_INSERT_SMATH:
329cdf0e10cSrcweir 		case SID_INSERT_FLOATINGFRAME:
330cdf0e10cSrcweir 			FuInsertOLE(this, pWin, pView, pDrModel, rReq);
331cdf0e10cSrcweir 			break;
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 		case SID_OBJECTRESIZE:
334cdf0e10cSrcweir 			{
335cdf0e10cSrcweir 				//			Der Server moechte die Clientgrosse verandern
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 				SfxInPlaceClient* pClient = GetIPClient();
338cdf0e10cSrcweir 
339cdf0e10cSrcweir                 if ( pClient && pClient->IsObjectInPlaceActive() )
340cdf0e10cSrcweir 				{
341cdf0e10cSrcweir 					const SfxRectangleItem& rRect =
342cdf0e10cSrcweir 						(SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE);
343cdf0e10cSrcweir 					Rectangle aRect( pWin->PixelToLogic( rRect.GetValue() ) );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 					if ( pView->AreObjectsMarked() )
346cdf0e10cSrcweir 					{
347cdf0e10cSrcweir 						const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 						if (rMarkList.GetMarkCount() == 1)
350cdf0e10cSrcweir 						{
351cdf0e10cSrcweir 							SdrMark* pMark = rMarkList.GetMark(0);
352cdf0e10cSrcweir 							SdrObject* pObj = pMark->GetMarkedSdrObj();
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 							sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 							if (nSdrObjKind == OBJ_OLE2)
357cdf0e10cSrcweir 							{
358cdf0e10cSrcweir                                 if ( ( (SdrOle2Obj*) pObj)->GetObjRef().is() )
359cdf0e10cSrcweir 								{
360cdf0e10cSrcweir 									pObj->SetLogicRect(aRect);
361cdf0e10cSrcweir 								}
362cdf0e10cSrcweir 							}
363cdf0e10cSrcweir 						}
364cdf0e10cSrcweir 					}
365cdf0e10cSrcweir 				}
366cdf0e10cSrcweir 			}
367cdf0e10cSrcweir 			break;
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 		case SID_LINKS:
370cdf0e10cSrcweir 			{
371cdf0e10cSrcweir                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
372cdf0e10cSrcweir                 SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pWin, pDoc->GetLinkManager() );
373cdf0e10cSrcweir                 if ( pDlg )
374cdf0e10cSrcweir                 {
375cdf0e10cSrcweir                     pDlg->Execute();
376cdf0e10cSrcweir                     rBindings.Invalidate( nSlot );
377cdf0e10cSrcweir                     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );     // Navigator
378cdf0e10cSrcweir                     rReq.Done();
379cdf0e10cSrcweir                 }
380cdf0e10cSrcweir 			}
381cdf0e10cSrcweir 			break;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 		// #98721#
384cdf0e10cSrcweir 		case SID_FM_CREATE_FIELDCONTROL:
385cdf0e10cSrcweir 			{
386cdf0e10cSrcweir 				SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
387cdf0e10cSrcweir 				DBG_ASSERT( pDescriptorItem, "SID_FM_CREATE_FIELDCONTROL: invalid request args!" );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 				if(pDescriptorItem)
390cdf0e10cSrcweir 				{
391cdf0e10cSrcweir 					//!	merge with ScViewFunc::PasteDataFormat (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE)?
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 					ScDrawView* pDrView = GetScDrawView();
394cdf0e10cSrcweir 					SdrPageView* pPageView = pDrView ? pDrView->GetSdrPageView() : NULL;
395cdf0e10cSrcweir 					if(pPageView)
396cdf0e10cSrcweir 					{
397cdf0e10cSrcweir                         ::svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
398cdf0e10cSrcweir 						SdrObject* pNewDBField = pDrView->CreateFieldControl(aDescriptor);
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 						if(pNewDBField)
401cdf0e10cSrcweir 						{
402cdf0e10cSrcweir 							Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
403cdf0e10cSrcweir 							Point aObjPos(aVisArea.Center());
404cdf0e10cSrcweir 							Size aObjSize(pNewDBField->GetLogicRect().GetSize());
405cdf0e10cSrcweir 							aObjPos.X() -= aObjSize.Width() / 2;
406cdf0e10cSrcweir 							aObjPos.Y() -= aObjSize.Height() / 2;
407cdf0e10cSrcweir 							Rectangle aNewObjectRectangle(aObjPos, aObjSize);
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 							pNewDBField->SetLogicRect(aNewObjectRectangle);
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 							// controls must be on control layer, groups on front layer
412cdf0e10cSrcweir 							if ( pNewDBField->ISA(SdrUnoObj) )
413cdf0e10cSrcweir 								pNewDBField->NbcSetLayer(SC_LAYER_CONTROLS);
414cdf0e10cSrcweir 							else
415cdf0e10cSrcweir 								pNewDBField->NbcSetLayer(SC_LAYER_FRONT);
416cdf0e10cSrcweir 							if (pNewDBField->ISA(SdrObjGroup))
417cdf0e10cSrcweir 							{
418cdf0e10cSrcweir 								SdrObjListIter aIter( *pNewDBField, IM_DEEPWITHGROUPS );
419cdf0e10cSrcweir 								SdrObject* pSubObj = aIter.Next();
420cdf0e10cSrcweir 								while (pSubObj)
421cdf0e10cSrcweir 								{
422cdf0e10cSrcweir 									if ( pSubObj->ISA(SdrUnoObj) )
423cdf0e10cSrcweir 										pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
424cdf0e10cSrcweir 									else
425cdf0e10cSrcweir 										pSubObj->NbcSetLayer(SC_LAYER_FRONT);
426cdf0e10cSrcweir 									pSubObj = aIter.Next();
427cdf0e10cSrcweir 								}
428cdf0e10cSrcweir 							}
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 							pView->InsertObjectAtView(pNewDBField, *pPageView);
431cdf0e10cSrcweir 						}
432cdf0e10cSrcweir 					}
433cdf0e10cSrcweir 				}
434cdf0e10cSrcweir 				rReq.Done();
435cdf0e10cSrcweir 			}
436cdf0e10cSrcweir 			break;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir         case SID_FONTWORK_GALLERY_FLOATER:
439cdf0e10cSrcweir             svx::FontworkBar::execute( pView, rReq, GetViewFrame()->GetBindings() );
440cdf0e10cSrcweir             rReq.Ignore();
441cdf0e10cSrcweir             break;
442cdf0e10cSrcweir 	}
443cdf0e10cSrcweir }
444cdf0e10cSrcweir 
445cdf0e10cSrcweir void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
446cdf0e10cSrcweir {
447cdf0e10cSrcweir     sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
448cdf0e10cSrcweir 	sal_Bool bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
449cdf0e10cSrcweir     ScDocShell* pDocShell = ( GetViewData() ? GetViewData()->GetDocShell() : NULL );
450cdf0e10cSrcweir     bool bShared = ( pDocShell ? pDocShell->IsDocShared() : false );
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
453cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
454cdf0e10cSrcweir 	while ( nWhich )
455cdf0e10cSrcweir 	{
456cdf0e10cSrcweir 		switch ( nWhich )
457cdf0e10cSrcweir 		{
458cdf0e10cSrcweir 			case SID_INSERT_DIAGRAM:
459cdf0e10cSrcweir 				if ( bOle || bTabProt || !SvtModuleOptions().IsChart() || bShared )
460cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
461cdf0e10cSrcweir 				break;
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 			case SID_INSERT_SMATH:
464cdf0e10cSrcweir 				if ( bOle || bTabProt || !SvtModuleOptions().IsMath() || bShared )
465cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
466cdf0e10cSrcweir 				break;
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 			case SID_INSERT_OBJECT:
469cdf0e10cSrcweir 			case SID_INSERT_PLUGIN:
470cdf0e10cSrcweir 			case SID_INSERT_FLOATINGFRAME:
471cdf0e10cSrcweir                 if ( bOle || bTabProt || bShared )
472cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
473cdf0e10cSrcweir 				break;
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 			case SID_INSERT_SOUND:
476cdf0e10cSrcweir 			case SID_INSERT_VIDEO:
477cdf0e10cSrcweir                  /* #i102735# discussed with NN: removed for performance reasons
478cdf0e10cSrcweir                  || !SvxPluginFileDlg::IsAvailable(nWhich)
479cdf0e10cSrcweir                  */
480cdf0e10cSrcweir                 if ( bOle || bTabProt || bShared )
481cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
482cdf0e10cSrcweir 				break;
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 			case SID_INSERT_GRAPHIC:
485cdf0e10cSrcweir 			case SID_INSERT_AVMEDIA:
486cdf0e10cSrcweir             case SID_FONTWORK_GALLERY_FLOATER:
487cdf0e10cSrcweir                 if ( bTabProt || bShared )
488cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
489cdf0e10cSrcweir 				break;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 			case SID_LINKS:
492cdf0e10cSrcweir 				{
493cdf0e10cSrcweir 					if (GetViewData()->GetDocument()->GetLinkManager()->GetLinks().Count() == 0 )
494cdf0e10cSrcweir 						rSet.DisableItem( SID_LINKS );
495cdf0e10cSrcweir 				}
496cdf0e10cSrcweir 				break;
497cdf0e10cSrcweir 		}
498cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
499cdf0e10cSrcweir 	}
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 
503cdf0e10cSrcweir //------------------------------------------------------------------
504cdf0e10cSrcweir 
505cdf0e10cSrcweir void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir     SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
508cdf0e10cSrcweir     ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager();
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 	const SfxItemSet* pReqArgs = rReq.GetArgs();
511cdf0e10cSrcweir 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
514cdf0e10cSrcweir 	switch ( nSlot )
515cdf0e10cSrcweir 	{
516cdf0e10cSrcweir 		case SID_UNDO:
517cdf0e10cSrcweir 		case SID_REDO:
518cdf0e10cSrcweir 			if ( pUndoManager )
519cdf0e10cSrcweir 			{
520cdf0e10cSrcweir 				sal_Bool bIsUndo = ( nSlot == SID_UNDO );
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 				sal_uInt16 nCount = 1;
523cdf0e10cSrcweir 				const SfxPoolItem* pItem;
524cdf0e10cSrcweir 				if ( pReqArgs && pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
525cdf0e10cSrcweir 					nCount = ((const SfxUInt16Item*)pItem)->GetValue();
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 				// lock paint for more than one cell undo action (not for editing within a cell)
528cdf0e10cSrcweir 				sal_Bool bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() );
529cdf0e10cSrcweir 				if ( bLockPaint )
530cdf0e10cSrcweir 					pDocSh->LockPaint();
531cdf0e10cSrcweir 
532cdf0e10cSrcweir                 try
533cdf0e10cSrcweir                 {
534cdf0e10cSrcweir 				    for (sal_uInt16 i=0; i<nCount; i++)
535cdf0e10cSrcweir 				    {
536cdf0e10cSrcweir 					    if ( bIsUndo )
537cdf0e10cSrcweir 						    pUndoManager->Undo();
538cdf0e10cSrcweir 					    else
539cdf0e10cSrcweir 						    pUndoManager->Redo();
540cdf0e10cSrcweir 				    }
541cdf0e10cSrcweir                 }
542cdf0e10cSrcweir                 catch ( const uno::Exception& )
543cdf0e10cSrcweir                 {
544cdf0e10cSrcweir                     // no need to handle. By definition, the UndoManager handled this by clearing the
545cdf0e10cSrcweir                     // Undo/Redo stacks
546cdf0e10cSrcweir                 }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 				if ( bLockPaint )
549cdf0e10cSrcweir 					pDocSh->UnlockPaint();
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 				GetViewFrame()->GetBindings().InvalidateAll(sal_False);
552cdf0e10cSrcweir 			}
553cdf0e10cSrcweir 			break;
554cdf0e10cSrcweir //		default:
555cdf0e10cSrcweir //			GetViewFrame()->ExecuteSlot( rReq );
556cdf0e10cSrcweir 	}
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir void ScTabViewShell::GetUndoState(SfxItemSet &rSet)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
562cdf0e10cSrcweir     ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager();
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
565cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
566cdf0e10cSrcweir 	while ( nWhich )
567cdf0e10cSrcweir 	{
568cdf0e10cSrcweir 		switch (nWhich)
569cdf0e10cSrcweir 		{
570cdf0e10cSrcweir 			case SID_GETUNDOSTRINGS:
571cdf0e10cSrcweir 			case SID_GETREDOSTRINGS:
572cdf0e10cSrcweir 				{
573cdf0e10cSrcweir 					SfxStringListItem aStrLst( nWhich );
574cdf0e10cSrcweir 					if ( pUndoManager )
575cdf0e10cSrcweir 					{
576cdf0e10cSrcweir 						List* pList = aStrLst.GetList();
577cdf0e10cSrcweir 						sal_Bool bIsUndo = ( nWhich == SID_GETUNDOSTRINGS );
578cdf0e10cSrcweir 						size_t nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount();
579cdf0e10cSrcweir 						for (size_t i=0; i<nCount; i++)
580cdf0e10cSrcweir 							pList->Insert( new String( bIsUndo ? pUndoManager->GetUndoActionComment(i) :
581cdf0e10cSrcweir 															     pUndoManager->GetRedoActionComment(i) ),
582cdf0e10cSrcweir 										   LIST_APPEND );
583cdf0e10cSrcweir 					}
584cdf0e10cSrcweir 					rSet.Put( aStrLst );
585cdf0e10cSrcweir 				}
586cdf0e10cSrcweir 				break;
587cdf0e10cSrcweir 			default:
588cdf0e10cSrcweir 				// get state from sfx view frame
589cdf0e10cSrcweir 				GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
590cdf0e10cSrcweir 		}
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
593cdf0e10cSrcweir 	}
594cdf0e10cSrcweir }
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 
598