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