xref: /AOO41X/main/sc/source/ui/drawfunc/fusel.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_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
36*cdf0e10cSrcweir #include <editeng/flditem.hxx>
37*cdf0e10cSrcweir #include <svx/svdoole2.hxx>
38*cdf0e10cSrcweir #include <svx/svdotext.hxx>
39*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
40*cdf0e10cSrcweir #include <svtools/imapobj.hxx>
41*cdf0e10cSrcweir #include <svx/svdouno.hxx>
42*cdf0e10cSrcweir #include <svx/svdomedia.hxx>
43*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
44*cdf0e10cSrcweir #include <editeng/outlobj.hxx>
45*cdf0e10cSrcweir #include <svx/svdocapt.hxx>
46*cdf0e10cSrcweir #include <sfx2/app.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include "fusel.hxx"
49*cdf0e10cSrcweir #include "sc.hrc"
50*cdf0e10cSrcweir #include "fudraw.hxx"
51*cdf0e10cSrcweir #include "futext.hxx"
52*cdf0e10cSrcweir #include "drawview.hxx"
53*cdf0e10cSrcweir #include "tabvwsh.hxx"
54*cdf0e10cSrcweir #include "drawpage.hxx"
55*cdf0e10cSrcweir #include "globstr.hrc"
56*cdf0e10cSrcweir #include "drwlayer.hxx"
57*cdf0e10cSrcweir #include "userdat.hxx"
58*cdf0e10cSrcweir #include "scmod.hxx"
59*cdf0e10cSrcweir #include "client.hxx"
60*cdf0e10cSrcweir #include "charthelper.hxx"
61*cdf0e10cSrcweir #include "docuno.hxx"
62*cdf0e10cSrcweir #include "docsh.hxx"
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir // -----------------------------------------------------------------------
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir //	Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
67*cdf0e10cSrcweir //!	fusel,fuconstr,futext - zusammenfassen!
68*cdf0e10cSrcweir #define SC_MAXDRAGMOVE	3
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir // -----------------------------------------------------------------------
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir #ifdef _MSC_VER
73*cdf0e10cSrcweir #pragma optimize ( "", off )
74*cdf0e10cSrcweir #endif
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir using namespace com::sun::star;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir /*************************************************************************
79*cdf0e10cSrcweir |*
80*cdf0e10cSrcweir |* Konstruktor
81*cdf0e10cSrcweir |*
82*cdf0e10cSrcweir \************************************************************************/
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir FuSelection::FuSelection(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
85*cdf0e10cSrcweir 			   SdrModel* pDoc, SfxRequest& rReq ) :
86*cdf0e10cSrcweir     FuDraw(pViewSh, pWin, pViewP, pDoc, rReq),
87*cdf0e10cSrcweir 	bVCAction(sal_False)
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir /*************************************************************************
92*cdf0e10cSrcweir |*
93*cdf0e10cSrcweir |* Destruktor
94*cdf0e10cSrcweir |*
95*cdf0e10cSrcweir \************************************************************************/
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir FuSelection::~FuSelection()
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir sal_uInt8 FuSelection::Command(const CommandEvent& rCEvt)
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	//	special code for non-VCL OS2/UNX removed
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	return FuDraw::Command( rCEvt );
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir /*************************************************************************
109*cdf0e10cSrcweir |*
110*cdf0e10cSrcweir |* MouseButtonDown-event
111*cdf0e10cSrcweir |*
112*cdf0e10cSrcweir \************************************************************************/
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir sal_Bool __EXPORT FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
117*cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
118*cdf0e10cSrcweir 	const bool bSelectionOnly = rMEvt.IsRight();
119*cdf0e10cSrcweir 	if ( pView->IsAction() )
120*cdf0e10cSrcweir 	{
121*cdf0e10cSrcweir         if ( bSelectionOnly )
122*cdf0e10cSrcweir 			pView->BckAction();
123*cdf0e10cSrcweir 		return sal_True;
124*cdf0e10cSrcweir 	}
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	bVCAction = sal_False;
127*cdf0e10cSrcweir 	bIsInDragMode = sal_False;		//	irgendwo muss es ja zurueckgesetzt werden (#50033#)
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	if ( rMEvt.IsLeft() )
134*cdf0e10cSrcweir 	{
135*cdf0e10cSrcweir 		SdrHdl* pHdl = pView->PickHandle(aMDPos);
136*cdf0e10cSrcweir 		SdrObject* pObj;
137*cdf0e10cSrcweir 		SdrPageView* pPV;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		if ( pHdl!=NULL || pView->IsMarkedHit(aMDPos) )
140*cdf0e10cSrcweir 		{
141*cdf0e10cSrcweir 		    // Determine if this is the tail of a SdrCaptionObj i.e.
142*cdf0e10cSrcweir 		    // we need to disable the drag option on the tail of a note
143*cdf0e10cSrcweir 		    // object. Also, disable the ability to use the circular
144*cdf0e10cSrcweir 		    // drag of a note object.
145*cdf0e10cSrcweir             bool bDrag = false;
146*cdf0e10cSrcweir 		    const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
147*cdf0e10cSrcweir 		    if( rMarkList.GetMarkCount() == 1 )
148*cdf0e10cSrcweir 		    {
149*cdf0e10cSrcweir                 SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
150*cdf0e10cSrcweir                 if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
151*cdf0e10cSrcweir 			    {
152*cdf0e10cSrcweir 			        // move using the valid caption handles for note text box.
153*cdf0e10cSrcweir 			        if(pHdl && (pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC))
154*cdf0e10cSrcweir                         bDrag = true;
155*cdf0e10cSrcweir 			        // move the complete note box.
156*cdf0e10cSrcweir 			        else if(!pHdl)
157*cdf0e10cSrcweir                         bDrag = true;
158*cdf0e10cSrcweir 			    }
159*cdf0e10cSrcweir 			    else
160*cdf0e10cSrcweir                     bDrag = true;   // different object
161*cdf0e10cSrcweir 		    }
162*cdf0e10cSrcweir             else
163*cdf0e10cSrcweir                 bDrag = true;       // several objects
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir             if ( bDrag )
166*cdf0e10cSrcweir             {
167*cdf0e10cSrcweir                 aDragTimer.Start();
168*cdf0e10cSrcweir                 pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
169*cdf0e10cSrcweir                 bReturn = sal_True;
170*cdf0e10cSrcweir             }
171*cdf0e10cSrcweir 		}
172*cdf0e10cSrcweir 		else
173*cdf0e10cSrcweir 		{
174*cdf0e10cSrcweir 			sal_Bool bAlt = rMEvt.IsMod2();
175*cdf0e10cSrcweir 			if ( !bAlt && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
176*cdf0e10cSrcweir 			{
177*cdf0e10cSrcweir 				pView->BegMacroObj(aMDPos, pObj, pPV, pWindow);
178*cdf0e10cSrcweir 				bReturn = sal_True;
179*cdf0e10cSrcweir 			}
180*cdf0e10cSrcweir 			else
181*cdf0e10cSrcweir 			{
182*cdf0e10cSrcweir                 String sURL, sTarget;
183*cdf0e10cSrcweir                 if ( !bAlt && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER))
184*cdf0e10cSrcweir                 {
185*cdf0e10cSrcweir                    // Support for imported Excel docs
186*cdf0e10cSrcweir                    // Excel is of course not consistent and allows
187*cdf0e10cSrcweir                    // a hyperlink to be assigned for an object group
188*cdf0e10cSrcweir                    // and even though the hyperlink is exported in the Escher layer
189*cdf0e10cSrcweir                    // its never used, when dealing with a group object the link
190*cdf0e10cSrcweir                    // associated with the clicked object is used only
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir                    // additionally you can also select a macro in Excel for a grouped
193*cdf0e10cSrcweir                    // objects and this results in the macro being set for the elements
194*cdf0e10cSrcweir                    // in the group and no macro is exported for the group
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir                    // if a macro and hlink are defined favour the hlink
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir                    // If a group object has no hyperlink use the hyperlink of the
199*cdf0e10cSrcweir                    // object clicked
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir                    if ( pObj->IsGroupObject() )
202*cdf0e10cSrcweir                    {
203*cdf0e10cSrcweir                        SdrObject* pHit = NULL;
204*cdf0e10cSrcweir                        if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
205*cdf0e10cSrcweir                            pObj = pHit;
206*cdf0e10cSrcweir                    }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir                    ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, sal_True );
209*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES
210*cdf0e10cSrcweir                    // For interoperability favour links over macros if both are defined
211*cdf0e10cSrcweir                    if ( pInfo->GetHlink().getLength() > 0 )
212*cdf0e10cSrcweir                    {
213*cdf0e10cSrcweir                        OSL_TRACE("** Got URL");
214*cdf0e10cSrcweir                        sURL = pInfo->GetHlink();
215*cdf0e10cSrcweir                    }
216*cdf0e10cSrcweir                    else if ( pInfo->GetMacro().getLength() > 0 )
217*cdf0e10cSrcweir #else
218*cdf0e10cSrcweir                    if ( pInfo->GetMacro().getLength() > 0 )
219*cdf0e10cSrcweir #endif
220*cdf0e10cSrcweir                    {
221*cdf0e10cSrcweir                        SfxObjectShell* pObjSh = SfxObjectShell::Current();
222*cdf0e10cSrcweir                        if ( pObjSh && SfxApplication::IsXScriptURL( pInfo->GetMacro() ) )
223*cdf0e10cSrcweir                        {
224*cdf0e10cSrcweir                            uno::Any aRet;
225*cdf0e10cSrcweir                            uno::Sequence< sal_Int16 > aOutArgsIndex;
226*cdf0e10cSrcweir                            uno::Sequence< uno::Any > aOutArgs;
227*cdf0e10cSrcweir                            uno::Sequence< uno::Any >* pInArgs =
228*cdf0e10cSrcweir                                new uno::Sequence< uno::Any >(0);
229*cdf0e10cSrcweir                            pObjSh->CallXScript( pInfo->GetMacro(),
230*cdf0e10cSrcweir                                *pInArgs, aRet, aOutArgsIndex, aOutArgs);
231*cdf0e10cSrcweir                            pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() );
232*cdf0e10cSrcweir                            return sal_True;        // kein CaptureMouse etc.
233*cdf0e10cSrcweir                        }
234*cdf0e10cSrcweir                    }
235*cdf0e10cSrcweir                 }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 				//	URL / ImageMap
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 				SdrViewEvent aVEvt;
240*cdf0e10cSrcweir 				if ( !bAlt &&
241*cdf0e10cSrcweir 					pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt ) != SDRHIT_NONE &&
242*cdf0e10cSrcweir 					aVEvt.pObj != NULL )
243*cdf0e10cSrcweir 				{
244*cdf0e10cSrcweir 					if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) )		// ImageMap
245*cdf0e10cSrcweir 					{
246*cdf0e10cSrcweir 						const IMapObject* pIMapObj =
247*cdf0e10cSrcweir 								ScDrawLayer::GetHitIMapObject( aVEvt.pObj, aMDPos, *pWindow );
248*cdf0e10cSrcweir 						if ( pIMapObj && pIMapObj->GetURL().Len() )
249*cdf0e10cSrcweir 						{
250*cdf0e10cSrcweir                             sURL = pIMapObj->GetURL();
251*cdf0e10cSrcweir                             sTarget = pIMapObj->GetTarget();
252*cdf0e10cSrcweir 						}
253*cdf0e10cSrcweir 					}
254*cdf0e10cSrcweir 					if ( aVEvt.eEvent == SDREVENT_EXECUTEURL && aVEvt.pURLField )	// URL
255*cdf0e10cSrcweir                     {
256*cdf0e10cSrcweir                         sURL = aVEvt.pURLField->GetURL();
257*cdf0e10cSrcweir                         sTarget = aVEvt.pURLField->GetTargetFrame();
258*cdf0e10cSrcweir                     }
259*cdf0e10cSrcweir 				}
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir                 // open hyperlink, if found at object or in object's text
262*cdf0e10cSrcweir                 if ( sURL.Len() > 0 )
263*cdf0e10cSrcweir                 {
264*cdf0e10cSrcweir                     ScGlobal::OpenURL( sURL, sTarget );
265*cdf0e10cSrcweir                     pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() );
266*cdf0e10cSrcweir                     return sal_True;        // kein CaptureMouse etc.
267*cdf0e10cSrcweir                 }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 				//	Is another object being edited in this view?
270*cdf0e10cSrcweir 				//	(Editing is ended in MarkListHasChanged - test before UnmarkAll)
271*cdf0e10cSrcweir 				SfxInPlaceClient* pClient = pViewShell->GetIPClient();
272*cdf0e10cSrcweir                 sal_Bool bWasOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 				//	Markieren
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir                 // do not allow multiselection with note caption
277*cdf0e10cSrcweir 				bool bCaptionClicked = IsNoteCaptionClicked( aMDPos );
278*cdf0e10cSrcweir 				if ( !rMEvt.IsShift() || bCaptionClicked || IsNoteCaptionMarked() )
279*cdf0e10cSrcweir 					pView->UnmarkAll();
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir                 /*  Unlock internal layer, if a note caption is clicked. The
282*cdf0e10cSrcweir                     layer will be relocked in ScDrawView::MarkListHasChanged(). */
283*cdf0e10cSrcweir 				if( bCaptionClicked )
284*cdf0e10cSrcweir                     pView->UnlockInternalLayer();
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir                 // try to select the clicked object
287*cdf0e10cSrcweir 				if ( pView->MarkObj( aMDPos, -2, sal_False, rMEvt.IsMod1() ) )
288*cdf0e10cSrcweir 				{
289*cdf0e10cSrcweir 					//*********************************************************
290*cdf0e10cSrcweir 					//Objekt verschieben
291*cdf0e10cSrcweir 					//********************************************************
292*cdf0e10cSrcweir 					if (pView->IsMarkedHit(aMDPos))
293*cdf0e10cSrcweir 					{
294*cdf0e10cSrcweir 						//	#95834# Don't start drag timer if inplace editing of an OLE object
295*cdf0e10cSrcweir 						//	was just ended with this mouse click - the view will be moved
296*cdf0e10cSrcweir 						//	(different tool bars) and the object that was clicked on would
297*cdf0e10cSrcweir 						//	be moved unintentionally.
298*cdf0e10cSrcweir 						if ( !bWasOleActive )
299*cdf0e10cSrcweir 							aDragTimer.Start();
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 						pHdl=pView->PickHandle(aMDPos);
302*cdf0e10cSrcweir 						pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
303*cdf0e10cSrcweir 						bReturn = sal_True;
304*cdf0e10cSrcweir 					}
305*cdf0e10cSrcweir 					else									// Objekt am Rand getroffen
306*cdf0e10cSrcweir 						if (pViewShell->IsDrawSelMode())
307*cdf0e10cSrcweir 							bReturn = sal_True;
308*cdf0e10cSrcweir 				}
309*cdf0e10cSrcweir 				else
310*cdf0e10cSrcweir 				{
311*cdf0e10cSrcweir 					//		nichts getroffen
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 					if (pViewShell->IsDrawSelMode())
314*cdf0e10cSrcweir 					{
315*cdf0e10cSrcweir 						//*********************************************************
316*cdf0e10cSrcweir 						//Objekt selektieren
317*cdf0e10cSrcweir 						//********************************************************
318*cdf0e10cSrcweir 						pView->BegMarkObj(aMDPos);
319*cdf0e10cSrcweir 						bReturn = sal_True;
320*cdf0e10cSrcweir 					}
321*cdf0e10cSrcweir 				}
322*cdf0e10cSrcweir 			}
323*cdf0e10cSrcweir 		}
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	}
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 	if (!bIsInDragMode)
328*cdf0e10cSrcweir 	{
329*cdf0e10cSrcweir 		if (!bVCAction)					// VC rufen selber CaptureMouse
330*cdf0e10cSrcweir 			pWindow->CaptureMouse();
331*cdf0e10cSrcweir 		ForcePointer(&rMEvt);
332*cdf0e10cSrcweir 	}
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 	return bReturn;
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir /*************************************************************************
338*cdf0e10cSrcweir |*
339*cdf0e10cSrcweir |* MouseMove-event
340*cdf0e10cSrcweir |*
341*cdf0e10cSrcweir \************************************************************************/
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir sal_Bool __EXPORT FuSelection::MouseMove(const MouseEvent& rMEvt)
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir 	sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	if (aDragTimer.IsActive() )
348*cdf0e10cSrcweir 	{
349*cdf0e10cSrcweir 		Point aOldPixel = pWindow->LogicToPixel( aMDPos );
350*cdf0e10cSrcweir 		Point aNewPixel = rMEvt.GetPosPixel();
351*cdf0e10cSrcweir 		if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
352*cdf0e10cSrcweir 			 Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
353*cdf0e10cSrcweir 			aDragTimer.Stop();
354*cdf0e10cSrcweir 	}
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	if ( pView->IsAction() )
357*cdf0e10cSrcweir 	{
358*cdf0e10cSrcweir 		Point aPix(rMEvt.GetPosPixel());
359*cdf0e10cSrcweir 		Point aPnt(pWindow->PixelToLogic(aPix));
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 		ForceScroll(aPix);
362*cdf0e10cSrcweir 		pView->MovAction(aPnt);
363*cdf0e10cSrcweir 		bReturn = sal_True;
364*cdf0e10cSrcweir 	}
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 	// Ein VCControl ist aktiv
367*cdf0e10cSrcweir 	// Event an den Manager weiterleiten
368*cdf0e10cSrcweir 	if( bVCAction )
369*cdf0e10cSrcweir 	{
370*cdf0e10cSrcweir 		//	GetSbxForm gibts nicht mehr - Basic-Controls sind tot
371*cdf0e10cSrcweir 		//SdrPageView* pPgView = pView->GetPageViewByIndex(0);
372*cdf0e10cSrcweir 		//ScDrawPage*  pPage	 = (ScDrawPage*)pPgView->GetPage();
373*cdf0e10cSrcweir 		//VCSbxForm* pForm = (VCSbxForm*)(SbxObject*)(pPage->GetSbxForm());
374*cdf0e10cSrcweir 		//((VCManager*)(pForm->GetVCContainer()))->
375*cdf0e10cSrcweir 		//    MouseMove( pWindow, rMEvt );
376*cdf0e10cSrcweir 		bReturn = sal_True;
377*cdf0e10cSrcweir 	}
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 	ForcePointer(&rMEvt);
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	return (bReturn);
382*cdf0e10cSrcweir }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir /*************************************************************************
385*cdf0e10cSrcweir |*
386*cdf0e10cSrcweir |* MouseButtonUp-event
387*cdf0e10cSrcweir |*
388*cdf0e10cSrcweir \************************************************************************/
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir sal_Bool __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
391*cdf0e10cSrcweir {
392*cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
393*cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 	sal_Bool bReturn = FuDraw::MouseButtonUp(rMEvt);
396*cdf0e10cSrcweir //	sal_Bool bOle	 = pViewShell->GetViewData()->IsOle();
397*cdf0e10cSrcweir     sal_Bool bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 	if (aDragTimer.IsActive() )
400*cdf0e10cSrcweir 	{
401*cdf0e10cSrcweir 		aDragTimer.Stop();
402*cdf0e10cSrcweir 	}
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 	Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     bool bCopy = false;
407*cdf0e10cSrcweir     ScViewData* pViewData = ( pViewShell ? pViewShell->GetViewData() : NULL );
408*cdf0e10cSrcweir     ScDocument* pDocument = ( pViewData ? pViewData->GetDocument() : NULL );
409*cdf0e10cSrcweir     SdrPageView* pPageView = ( pView ? pView->GetSdrPageView() : NULL );
410*cdf0e10cSrcweir     SdrPage* pPage = ( pPageView ? pPageView->GetPage() : NULL );
411*cdf0e10cSrcweir     ::std::vector< ::rtl::OUString > aExcludedChartNames;
412*cdf0e10cSrcweir     ScRangeListVector aProtectedChartRangesVector;
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 	if ( rMEvt.IsLeft() )
415*cdf0e10cSrcweir 	{
416*cdf0e10cSrcweir 		if ( pView->IsDragObj() )
417*cdf0e10cSrcweir 		{
418*cdf0e10cSrcweir 			/******************************************************************
419*cdf0e10cSrcweir 			* Objekt wurde verschoben
420*cdf0e10cSrcweir 			******************************************************************/
421*cdf0e10cSrcweir             if ( rMEvt.IsMod1() )
422*cdf0e10cSrcweir             {
423*cdf0e10cSrcweir                 if ( pPage )
424*cdf0e10cSrcweir                 {
425*cdf0e10cSrcweir                     ScChartHelper::GetChartNames( aExcludedChartNames, pPage );
426*cdf0e10cSrcweir                 }
427*cdf0e10cSrcweir                 if ( pView && pDocument )
428*cdf0e10cSrcweir                 {
429*cdf0e10cSrcweir                     const SdrMarkList& rSdrMarkList = pView->GetMarkedObjectList();
430*cdf0e10cSrcweir                     sal_uLong nMarkCount = rSdrMarkList.GetMarkCount();
431*cdf0e10cSrcweir                     for ( sal_uLong i = 0; i < nMarkCount; ++i )
432*cdf0e10cSrcweir                     {
433*cdf0e10cSrcweir                         SdrMark* pMark = rSdrMarkList.GetMark( i );
434*cdf0e10cSrcweir                         SdrObject* pObj = ( pMark ? pMark->GetMarkedSdrObj() : NULL );
435*cdf0e10cSrcweir                         if ( pObj )
436*cdf0e10cSrcweir                         {
437*cdf0e10cSrcweir                             ScChartHelper::AddRangesIfProtectedChart( aProtectedChartRangesVector, pDocument, pObj );
438*cdf0e10cSrcweir                         }
439*cdf0e10cSrcweir                     }
440*cdf0e10cSrcweir                 }
441*cdf0e10cSrcweir                 bCopy = true;
442*cdf0e10cSrcweir             }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 			pView->EndDragObj( rMEvt.IsMod1() );
445*cdf0e10cSrcweir 			pView->ForceMarkedToAnotherPage();
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 			const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
448*cdf0e10cSrcweir 			if (rMarkList.GetMarkCount() == 1)
449*cdf0e10cSrcweir 			{
450*cdf0e10cSrcweir 		  	    SdrMark* pMark = rMarkList.GetMark(0);
451*cdf0e10cSrcweir 		  	    SdrObject* pObj = pMark->GetMarkedSdrObj();
452*cdf0e10cSrcweir 		  	    FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
453*cdf0e10cSrcweir 		  	    FuText* pText = static_cast<FuText*>(pPoor);
454*cdf0e10cSrcweir 			    pText->StopDragMode(pObj );
455*cdf0e10cSrcweir 			}
456*cdf0e10cSrcweir 			bReturn = sal_True;
457*cdf0e10cSrcweir 		}
458*cdf0e10cSrcweir 		else if (pView->IsAction() )
459*cdf0e10cSrcweir 		{
460*cdf0e10cSrcweir             // unlock internal layer to include note captions
461*cdf0e10cSrcweir             pView->UnlockInternalLayer();
462*cdf0e10cSrcweir 			pView->EndAction();
463*cdf0e10cSrcweir 			if ( pView->AreObjectsMarked() )
464*cdf0e10cSrcweir             {
465*cdf0e10cSrcweir 				bReturn = sal_True;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir                 /*  if multi-selection contains a note caption object, remove
468*cdf0e10cSrcweir                     all other objects from selection. */
469*cdf0e10cSrcweir                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
470*cdf0e10cSrcweir                 sal_uLong nCount = rMarkList.GetMarkCount();
471*cdf0e10cSrcweir                 if( nCount > 1 )
472*cdf0e10cSrcweir                 {
473*cdf0e10cSrcweir                     bool bFound = false;
474*cdf0e10cSrcweir                     for( sal_uLong nIdx = 0; !bFound && (nIdx < nCount); ++nIdx )
475*cdf0e10cSrcweir                     {
476*cdf0e10cSrcweir                         SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj();
477*cdf0e10cSrcweir                         bFound = ScDrawLayer::IsNoteCaption( pObj );
478*cdf0e10cSrcweir                         if( bFound )
479*cdf0e10cSrcweir                         {
480*cdf0e10cSrcweir                             pView->UnMarkAll();
481*cdf0e10cSrcweir                             pView->MarkObj( pObj, pView->GetSdrPageView() );
482*cdf0e10cSrcweir                         }
483*cdf0e10cSrcweir                     }
484*cdf0e10cSrcweir                 }
485*cdf0e10cSrcweir             }
486*cdf0e10cSrcweir 		}
487*cdf0e10cSrcweir 	}
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir /*
490*cdf0e10cSrcweir 	if ( pView->IsObjEdit() )
491*cdf0e10cSrcweir 	{
492*cdf0e10cSrcweir 		sal_Bool bShowCursor = sal_True;
493*cdf0e10cSrcweir //! 	pOutlinerView = pView->GetOutlinerView(pWindow, bShowCursor);
494*cdf0e10cSrcweir 		bReturn = sal_True;
495*cdf0e10cSrcweir 	}
496*cdf0e10cSrcweir */
497*cdf0e10cSrcweir 	/**************************************************************************
498*cdf0e10cSrcweir 	* Ggf. OLE-Objekt beruecksichtigen
499*cdf0e10cSrcweir 	**************************************************************************/
500*cdf0e10cSrcweir 	SfxInPlaceClient* pIPClient = pViewShell->GetIPClient();
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir 	if (pIPClient)
503*cdf0e10cSrcweir 	{
504*cdf0e10cSrcweir         ScModule* pScMod = SC_MOD();
505*cdf0e10cSrcweir         bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir         if ( pIPClient->IsObjectInPlaceActive() && !bUnoRefDialog )
508*cdf0e10cSrcweir             pIPClient->DeactivateObject();
509*cdf0e10cSrcweir 	}
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 	sal_uInt16 nClicks = rMEvt.GetClicks();
512*cdf0e10cSrcweir 	if ( nClicks == 2 && rMEvt.IsLeft() )
513*cdf0e10cSrcweir 	{
514*cdf0e10cSrcweir 		if ( pView->AreObjectsMarked() )
515*cdf0e10cSrcweir 		{
516*cdf0e10cSrcweir 			const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
517*cdf0e10cSrcweir 			if (rMarkList.GetMarkCount() == 1)
518*cdf0e10cSrcweir 			{
519*cdf0e10cSrcweir 				SdrMark* pMark = rMarkList.GetMark(0);
520*cdf0e10cSrcweir 				SdrObject* pObj = pMark->GetMarkedSdrObj();
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 				//	#43984# aktivieren nur, wenn die Maus auch (noch) ueber dem
523*cdf0e10cSrcweir 				//	selektierten Objekt steht
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 				SdrViewEvent aVEvt;
526*cdf0e10cSrcweir 				SdrHitKind eHit = pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
527*cdf0e10cSrcweir 				if ( eHit != SDRHIT_NONE && aVEvt.pObj == pObj )
528*cdf0e10cSrcweir 				{
529*cdf0e10cSrcweir 					sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 					//
532*cdf0e10cSrcweir 					//	OLE: aktivieren
533*cdf0e10cSrcweir 					//
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 					if (nSdrObjKind == OBJ_OLE2)
536*cdf0e10cSrcweir 					{
537*cdf0e10cSrcweir 						if (!bOle)
538*cdf0e10cSrcweir 						{
539*cdf0e10cSrcweir                             if (((SdrOle2Obj*) pObj)->GetObjRef().is())
540*cdf0e10cSrcweir 							{
541*cdf0e10cSrcweir 								//HMHpView->HideMarkHdl();
542*cdf0e10cSrcweir 								pViewShell->ActivateObject( (SdrOle2Obj*) pObj, 0 );
543*cdf0e10cSrcweir 							}
544*cdf0e10cSrcweir 						}
545*cdf0e10cSrcweir 					}
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir 					//
548*cdf0e10cSrcweir                     //  Edit text
549*cdf0e10cSrcweir                     //  #49458# not in UNO controls
550*cdf0e10cSrcweir                     //  #i32352# not in media objects
551*cdf0e10cSrcweir 					//
552*cdf0e10cSrcweir                     else if ( pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) && !pObj->ISA(SdrMediaObj) )
553*cdf0e10cSrcweir 					{
554*cdf0e10cSrcweir 						OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
555*cdf0e10cSrcweir 						sal_Bool bVertical = ( pOPO && pOPO->IsVertical() );
556*cdf0e10cSrcweir 						sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir 						pViewShell->GetViewData()->GetDispatcher().
559*cdf0e10cSrcweir 							Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 						// jetzt den erzeugten FuText holen und in den EditModus setzen
562*cdf0e10cSrcweir 						FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
563*cdf0e10cSrcweir 						if ( pPoor && pPoor->GetSlotID() == nTextSlotId )	 //	hat keine RTTI
564*cdf0e10cSrcweir 						{
565*cdf0e10cSrcweir 							FuText* pText = (FuText*)pPoor;
566*cdf0e10cSrcweir 							Point aMousePixel = rMEvt.GetPosPixel();
567*cdf0e10cSrcweir 							pText->SetInEditMode( pObj, &aMousePixel );
568*cdf0e10cSrcweir 						}
569*cdf0e10cSrcweir 						bReturn = sal_True;
570*cdf0e10cSrcweir 					}
571*cdf0e10cSrcweir 				}
572*cdf0e10cSrcweir 			}
573*cdf0e10cSrcweir 		}
574*cdf0e10cSrcweir 		else if ( TestDetective( pView->GetSdrPageView(), aPnt ) )
575*cdf0e10cSrcweir 			bReturn = sal_True;
576*cdf0e10cSrcweir 	}
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 	// Ein VCControl ist aktiv
579*cdf0e10cSrcweir 	// Event an den Manager weiterleiten
580*cdf0e10cSrcweir 	if( bVCAction )
581*cdf0e10cSrcweir 	{
582*cdf0e10cSrcweir 		//	GetSbxForm gibts nicht mehr - Basic-Controls sind tot
583*cdf0e10cSrcweir 		//SdrPageView* pPgView = pView->GetPageViewByIndex(0);
584*cdf0e10cSrcweir 		//ScDrawPage*  pPage	 = (ScDrawPage*)pPgView->GetPage();
585*cdf0e10cSrcweir 		//VCSbxForm* pForm = (VCSbxForm*)(SbxObject*)(pPage->GetSbxForm());
586*cdf0e10cSrcweir 		//((VCManager*)(pForm->GetVCContainer()))->
587*cdf0e10cSrcweir 		//    MouseButtonUp( pWindow, rMEvt );
588*cdf0e10cSrcweir 		//HMHpView->ShowMarkHdl();
589*cdf0e10cSrcweir 		bVCAction = sal_False;
590*cdf0e10cSrcweir 		bReturn = sal_True;
591*cdf0e10cSrcweir 	}
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir 	ForcePointer(&rMEvt);
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 	pWindow->ReleaseMouse();
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir 	//	Command-Handler fuer Kontext-Menue kommt erst nach MouseButtonUp,
598*cdf0e10cSrcweir 	//	darum hier die harte IsLeft-Abfrage
599*cdf0e10cSrcweir 	if ( !bReturn && rMEvt.IsLeft() )
600*cdf0e10cSrcweir 		if (pViewShell->IsDrawSelMode())
601*cdf0e10cSrcweir 			pViewShell->GetViewData()->GetDispatcher().
602*cdf0e10cSrcweir 				Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir     if ( bCopy && pViewData && pDocument && pPage )
605*cdf0e10cSrcweir     {
606*cdf0e10cSrcweir         ScDocShell* pDocShell = pViewData->GetDocShell();
607*cdf0e10cSrcweir         ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : NULL );
608*cdf0e10cSrcweir         if ( pModelObj )
609*cdf0e10cSrcweir         {
610*cdf0e10cSrcweir             SCTAB nTab = pViewData->GetTabNo();
611*cdf0e10cSrcweir             ScChartHelper::CreateProtectedChartListenersAndNotify( pDocument, pPage, pModelObj, nTab,
612*cdf0e10cSrcweir                 aProtectedChartRangesVector, aExcludedChartNames );
613*cdf0e10cSrcweir         }
614*cdf0e10cSrcweir     }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 	return (bReturn);
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir /*************************************************************************
620*cdf0e10cSrcweir |*
621*cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
622*cdf0e10cSrcweir |*
623*cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
624*cdf0e10cSrcweir |* FALSE.
625*cdf0e10cSrcweir |*
626*cdf0e10cSrcweir \************************************************************************/
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir sal_Bool FuSelection::KeyInput(const KeyEvent& rKEvt)
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir 	if (!bReturn)
633*cdf0e10cSrcweir 	{
634*cdf0e10cSrcweir 		bReturn = FuDraw::KeyInput(rKEvt);
635*cdf0e10cSrcweir 	}
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 	return(bReturn);
638*cdf0e10cSrcweir }
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir /*************************************************************************
642*cdf0e10cSrcweir |*
643*cdf0e10cSrcweir |* Function aktivieren
644*cdf0e10cSrcweir |*
645*cdf0e10cSrcweir \************************************************************************/
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir void FuSelection::Activate()
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir /*
650*cdf0e10cSrcweir 	SdrDragMode eMode;
651*cdf0e10cSrcweir 	switch (aSfxRequest.GetSlot() )
652*cdf0e10cSrcweir 	{
653*cdf0e10cSrcweir 		case SID_OBJECT_SELECT:
654*cdf0e10cSrcweir 			eMode = SDRDRAG_MOVE;
655*cdf0e10cSrcweir 			break;
656*cdf0e10cSrcweir 		case SID_OBJECT_ROTATE:
657*cdf0e10cSrcweir 			eMode = SDRDRAG_ROTATE;
658*cdf0e10cSrcweir 			break;
659*cdf0e10cSrcweir 		case SID_OBJECT_MIRROR:
660*cdf0e10cSrcweir 			eMode = SDRDRAG_MIRROR;
661*cdf0e10cSrcweir 			break;
662*cdf0e10cSrcweir 	}
663*cdf0e10cSrcweir 	pView->SetDragMode(eMode);
664*cdf0e10cSrcweir */
665*cdf0e10cSrcweir 	FuDraw::Activate();
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir /*************************************************************************
671*cdf0e10cSrcweir |*
672*cdf0e10cSrcweir |* Function deaktivieren
673*cdf0e10cSrcweir |*
674*cdf0e10cSrcweir \************************************************************************/
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir void FuSelection::Deactivate()
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir 	/**************************************************************************
679*cdf0e10cSrcweir 	* Hide Cursor
680*cdf0e10cSrcweir 	**************************************************************************/
681*cdf0e10cSrcweir //    sal_Bool bShowCursor = sal_False;
682*cdf0e10cSrcweir //! pOutlinerView = pView->GetOutlinerView(pWindow, bShowCursor);
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir //	pView->SetDragMode(SDRDRAG_MOVE);
685*cdf0e10cSrcweir 	FuDraw::Deactivate();
686*cdf0e10cSrcweir }
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir #ifdef _MSC_VER
690*cdf0e10cSrcweir #pragma optimize ( "", on )
691*cdf0e10cSrcweir #endif
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir 
697