xref: /AOO41X/main/sd/source/ui/view/drviews4.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "DrawViewShell.hxx"
34*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35*cdf0e10cSrcweir #include <svl/urlbmk.hxx>
36*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
37*cdf0e10cSrcweir #include <svx/svdundo.hxx>
38*cdf0e10cSrcweir #include <svx/fmglob.hxx>
39*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
40*cdf0e10cSrcweir #ifndef _FLDITEM_HXX
41*cdf0e10cSrcweir #include <editeng/flditem.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #ifndef _SVXIDS_HRC
44*cdf0e10cSrcweir #include <svx/svxids.hrc>
45*cdf0e10cSrcweir #endif
46*cdf0e10cSrcweir #include <svx/ruler.hxx>
47*cdf0e10cSrcweir #ifndef _GLOBL3D_HXX
48*cdf0e10cSrcweir #include <svx/globl3d.hxx>
49*cdf0e10cSrcweir #endif
50*cdf0e10cSrcweir #include <editeng/outliner.hxx>
51*cdf0e10cSrcweir #ifndef _SFX_CLIENTSH_HXX
52*cdf0e10cSrcweir #include <sfx2/ipclient.hxx>
53*cdf0e10cSrcweir #endif
54*cdf0e10cSrcweir #include <sfx2/request.hxx>
55*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
56*cdf0e10cSrcweir #include <svx/svdopath.hxx>
57*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
58*cdf0e10cSrcweir #include <editeng/editview.hxx>
59*cdf0e10cSrcweir #include <vcl/cursor.hxx>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir #include "app.hrc"
63*cdf0e10cSrcweir #include "glob.hrc"
64*cdf0e10cSrcweir #include "strings.hrc"
65*cdf0e10cSrcweir #include "res_bmp.hrc"
66*cdf0e10cSrcweir #include "DrawDocShell.hxx"
67*cdf0e10cSrcweir #include "drawdoc.hxx"
68*cdf0e10cSrcweir #include "Window.hxx"
69*cdf0e10cSrcweir #include "fupoor.hxx"
70*cdf0e10cSrcweir #include "fusnapln.hxx"
71*cdf0e10cSrcweir #include "app.hxx"
72*cdf0e10cSrcweir #include "Ruler.hxx"
73*cdf0e10cSrcweir #include "sdresid.hxx"
74*cdf0e10cSrcweir #include "GraphicViewShell.hxx"
75*cdf0e10cSrcweir #include "sdpage.hxx"
76*cdf0e10cSrcweir #include "slideshow.hxx"
77*cdf0e10cSrcweir #include "anminfo.hxx"
78*cdf0e10cSrcweir #include "sdpopup.hxx"
79*cdf0e10cSrcweir #include "drawview.hxx"
80*cdf0e10cSrcweir #include <svx/bmpmask.hxx>
81*cdf0e10cSrcweir #include "LayerTabBar.hxx"
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir // #97016# IV
84*cdf0e10cSrcweir #include <svx/svditer.hxx>
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir namespace sd {
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir #define PIPETTE_RANGE 0
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir #ifdef _MSC_VER
91*cdf0e10cSrcweir #pragma optimize ( "", off )
92*cdf0e10cSrcweir #endif
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
95*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir /*************************************************************************
98*cdf0e10cSrcweir |*
99*cdf0e10cSrcweir |* aktuelle Seite loeschen
100*cdf0e10cSrcweir |*
101*cdf0e10cSrcweir \************************************************************************/
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir void DrawViewShell::DeleteActualPage()
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	sal_uInt16			nPage = maTabControl.GetCurPageId() - 1;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	mpDrawView->SdrEndTextEdit();
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	try
110*cdf0e10cSrcweir 	{
111*cdf0e10cSrcweir 	    Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
112*cdf0e10cSrcweir 	    Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
113*cdf0e10cSrcweir 		Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
114*cdf0e10cSrcweir 		xPages->remove( xPage );
115*cdf0e10cSrcweir 	}
116*cdf0e10cSrcweir 	catch( Exception& )
117*cdf0e10cSrcweir 	{
118*cdf0e10cSrcweir 		DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir /*************************************************************************
123*cdf0e10cSrcweir |*
124*cdf0e10cSrcweir |* aktuelle Ebene loeschen
125*cdf0e10cSrcweir |*
126*cdf0e10cSrcweir \************************************************************************/
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir void DrawViewShell::DeleteActualLayer()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
131*cdf0e10cSrcweir 	const String&  rName  = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
132*cdf0e10cSrcweir 	String         aString(SdResId(STR_ASK_DELETE_LAYER));
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	// Platzhalter ersetzen
135*cdf0e10cSrcweir 	sal_uInt16 nPos = aString.Search(sal_Unicode('$'));
136*cdf0e10cSrcweir 	aString.Erase(nPos, 1);
137*cdf0e10cSrcweir 	aString.Insert(rName, nPos);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 	if (QueryBox(GetActiveWindow(), WB_YES_NO, aString).Execute() == RET_YES)
140*cdf0e10cSrcweir 	{
141*cdf0e10cSrcweir 		const SdrLayer* pLayer = rAdmin.GetLayer(rName, sal_False);
142*cdf0e10cSrcweir 		mpDrawView->DeleteLayer( pLayer->GetName() );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 		// damit TabBar und Window neu gezeichnet werden;
145*cdf0e10cSrcweir 		// sollte spaeter wie beim Aendern der Layerfolge durch einen
146*cdf0e10cSrcweir 		// Hint von Joe angestossen werden
147*cdf0e10cSrcweir 		// ( View::Notify() --> ViewShell::ResetActualLayer() )
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         mbIsLayerModeActive = false; 	// damit ChangeEditMode() ueberhaupt was tut
150*cdf0e10cSrcweir 		ChangeEditMode(GetEditMode(), true);
151*cdf0e10cSrcweir 	}
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir /*************************************************************************
156*cdf0e10cSrcweir |*
157*cdf0e10cSrcweir |* Keyboard event
158*cdf0e10cSrcweir |*
159*cdf0e10cSrcweir \************************************************************************/
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir sal_Bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
166*cdf0e10cSrcweir 	{
167*cdf0e10cSrcweir 		// #97016# IV
168*cdf0e10cSrcweir 		if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
169*cdf0e10cSrcweir 			&& rKEvt.GetKeyCode().IsMod1()
170*cdf0e10cSrcweir 			&& GetView()->IsTextEdit())
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			// this should be used for cursor travelling.
173*cdf0e10cSrcweir 			SdPage* pActualPage = GetActualPage();
174*cdf0e10cSrcweir 			const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
175*cdf0e10cSrcweir 			SdrTextObj* pCandidate = 0L;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 			if(pActualPage && 1 == rMarkList.GetMarkCount())
178*cdf0e10cSrcweir 			{
179*cdf0e10cSrcweir 				SdrMark* pMark = rMarkList.GetMark(0);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 				// remember which object was the text in edit mode
182*cdf0e10cSrcweir 				SdrObject* pOldObj = pMark->GetMarkedSdrObj();
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 				// end text edit now
185*cdf0e10cSrcweir 				GetView()->SdrEndTextEdit();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 				// look for a new candidate, a successor of pOldObj
188*cdf0e10cSrcweir 				SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
189*cdf0e10cSrcweir 				sal_Bool bDidVisitOldObject(sal_False);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 				while(aIter.IsMore() && !pCandidate)
192*cdf0e10cSrcweir 				{
193*cdf0e10cSrcweir 					SdrObject* pObj = aIter.Next();
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 					if(pObj && pObj->ISA(SdrTextObj))
196*cdf0e10cSrcweir 					{
197*cdf0e10cSrcweir 						sal_uInt32 nInv(pObj->GetObjInventor());
198*cdf0e10cSrcweir 						sal_uInt16 nKnd(pObj->GetObjIdentifier());
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 						if(SdrInventor == nInv &&
201*cdf0e10cSrcweir 							(OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd)
202*cdf0e10cSrcweir 							&& bDidVisitOldObject)
203*cdf0e10cSrcweir 						{
204*cdf0e10cSrcweir 							pCandidate = (SdrTextObj*)pObj;
205*cdf0e10cSrcweir 						}
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 						if(pObj == pOldObj)
208*cdf0e10cSrcweir 						{
209*cdf0e10cSrcweir 							bDidVisitOldObject = sal_True;
210*cdf0e10cSrcweir 						}
211*cdf0e10cSrcweir 					}
212*cdf0e10cSrcweir 				}
213*cdf0e10cSrcweir 			}
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 			if(pCandidate)
216*cdf0e10cSrcweir 			{
217*cdf0e10cSrcweir 				// set the new candidate to text edit mode
218*cdf0e10cSrcweir 				GetView()->UnMarkAll();
219*cdf0e10cSrcweir 				GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 				GetViewFrame()->GetDispatcher()->Execute(
222*cdf0e10cSrcweir 					SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON);
223*cdf0e10cSrcweir 			}
224*cdf0e10cSrcweir 			else
225*cdf0e10cSrcweir 			{
226*cdf0e10cSrcweir 				// insert a new page with the same page layout
227*cdf0e10cSrcweir 				GetViewFrame()->GetDispatcher()->Execute(
228*cdf0e10cSrcweir 					SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON);
229*cdf0e10cSrcweir 			}
230*cdf0e10cSrcweir 		}
231*cdf0e10cSrcweir 		else
232*cdf0e10cSrcweir 		{
233*cdf0e10cSrcweir 			bRet = ViewShell::KeyInput(rKEvt, pWin);
234*cdf0e10cSrcweir 		}
235*cdf0e10cSrcweir 	}
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	return bRet;
238*cdf0e10cSrcweir }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir /*************************************************************************
241*cdf0e10cSrcweir |*
242*cdf0e10cSrcweir |* Vom Lineal ausgehenden Drag (Hilflinien, Ursprung) beginnen
243*cdf0e10cSrcweir |*
244*cdf0e10cSrcweir \************************************************************************/
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir void DrawViewShell::StartRulerDrag (
247*cdf0e10cSrcweir     const Ruler& rRuler,
248*cdf0e10cSrcweir     const MouseEvent& rMEvt)
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir     GetActiveWindow()->CaptureMouse();
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) )
255*cdf0e10cSrcweir 	{
256*cdf0e10cSrcweir 		mpDrawView->BegSetPageOrg(aWPos);
257*cdf0e10cSrcweir         mbIsRulerDrag = sal_True;
258*cdf0e10cSrcweir 	}
259*cdf0e10cSrcweir 	else
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir         // #i34536# if no guide-lines are visible yet, that show them
262*cdf0e10cSrcweir         if( ! mpDrawView->IsHlplVisible())
263*cdf0e10cSrcweir             mpDrawView->SetHlplVisible( sal_True );
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir         SdrHelpLineKind eKind;
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir         if ( rMEvt.IsMod1() )
268*cdf0e10cSrcweir             eKind = SDRHELPLINE_POINT;
269*cdf0e10cSrcweir         else if ( rRuler.IsHorizontal() )
270*cdf0e10cSrcweir             eKind = SDRHELPLINE_HORIZONTAL;
271*cdf0e10cSrcweir         else
272*cdf0e10cSrcweir             eKind = SDRHELPLINE_VERTICAL;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         mpDrawView->BegDragHelpLine(aWPos, eKind);
275*cdf0e10cSrcweir         mbIsRulerDrag = sal_True;
276*cdf0e10cSrcweir 	}
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir /*************************************************************************
280*cdf0e10cSrcweir |*
281*cdf0e10cSrcweir |* MouseButtonDown event
282*cdf0e10cSrcweir |*
283*cdf0e10cSrcweir \************************************************************************/
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt,
286*cdf0e10cSrcweir     ::sd::Window* pWin)
287*cdf0e10cSrcweir {
288*cdf0e10cSrcweir     // We have to check if a context menu is shown and we have an UI
289*cdf0e10cSrcweir     // active inplace client. In that case we have to ignore the mouse
290*cdf0e10cSrcweir     // button down event. Otherwise we would crash (context menu has been
291*cdf0e10cSrcweir     // opened by inplace client and we would deactivate the inplace client,
292*cdf0e10cSrcweir     // the contex menu is closed by VCL asynchronously which in the end
293*cdf0e10cSrcweir     // would work on deleted objects or the context menu has no parent anymore)
294*cdf0e10cSrcweir     // See #126086# and #128122#
295*cdf0e10cSrcweir     SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
296*cdf0e10cSrcweir     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     if ( bIsOleActive && PopupMenu::IsInExecute() )
299*cdf0e10cSrcweir         return;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 	if ( !IsInputLocked() )
302*cdf0e10cSrcweir 	{
303*cdf0e10cSrcweir 		ViewShell::MouseButtonDown(rMEvt, pWin);
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 		if ( mbPipette )
306*cdf0e10cSrcweir 			( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->PipetteClicked();
307*cdf0e10cSrcweir 	}
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir /*************************************************************************
311*cdf0e10cSrcweir |*
312*cdf0e10cSrcweir |* MouseMove event
313*cdf0e10cSrcweir |*
314*cdf0e10cSrcweir \************************************************************************/
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir 	if ( !IsInputLocked() )
320*cdf0e10cSrcweir 	{
321*cdf0e10cSrcweir 		if ( mpDrawView->IsAction() )
322*cdf0e10cSrcweir 		{
323*cdf0e10cSrcweir 			Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 			if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
326*cdf0e10cSrcweir 			{
327*cdf0e10cSrcweir 				sal_Bool bInsideOtherWindow = sal_False;
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir                 if (mpContentWindow.get() != NULL)
330*cdf0e10cSrcweir                 {
331*cdf0e10cSrcweir                     aOutputArea = Rectangle(Point(0,0),
332*cdf0e10cSrcweir                         mpContentWindow->GetOutputSizePixel());
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir                     Point aPos = mpContentWindow->GetPointerPosPixel();
335*cdf0e10cSrcweir                     if ( aOutputArea.IsInside(aPos) )
336*cdf0e10cSrcweir                         bInsideOtherWindow = sal_True;
337*cdf0e10cSrcweir                 }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 				if (! GetActiveWindow()->HasFocus ())
340*cdf0e10cSrcweir 				{
341*cdf0e10cSrcweir 					GetActiveWindow()->ReleaseMouse ();
342*cdf0e10cSrcweir 					mpDrawView->BrkAction ();
343*cdf0e10cSrcweir 					return;
344*cdf0e10cSrcweir 				}
345*cdf0e10cSrcweir 				else if ( bInsideOtherWindow )
346*cdf0e10cSrcweir 				{
347*cdf0e10cSrcweir 					GetActiveWindow()->ReleaseMouse();
348*cdf0e10cSrcweir 					pWin->CaptureMouse ();
349*cdf0e10cSrcweir 				}
350*cdf0e10cSrcweir 			}
351*cdf0e10cSrcweir 			else if ( pWin != GetActiveWindow() )
352*cdf0e10cSrcweir 				 pWin->CaptureMouse();
353*cdf0e10cSrcweir 		}
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 		// #109585#
356*cdf0e10cSrcweir 		// Since the next MouseMove may execute a IsSolidDraggingNow() in
357*cdf0e10cSrcweir 		// SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
358*cdf0e10cSrcweir 		// is needed it is necessary to set it here.
359*cdf0e10cSrcweir 		if(mpDrawView!=NULL && GetDoc()!=NULL)
360*cdf0e10cSrcweir 		{
361*cdf0e10cSrcweir 			svtools::ColorConfig aColorConfig;
362*cdf0e10cSrcweir 			Color aFillColor;
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 			if(DOCUMENT_TYPE_IMPRESS == GetDoc()->GetDocumentType())
365*cdf0e10cSrcweir 			{
366*cdf0e10cSrcweir 				aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
367*cdf0e10cSrcweir 			}
368*cdf0e10cSrcweir 			else
369*cdf0e10cSrcweir 			{
370*cdf0e10cSrcweir 				aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
371*cdf0e10cSrcweir 			}
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 			mpDrawView->SetApplicationBackgroundColor(aFillColor);
374*cdf0e10cSrcweir 		}
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 		ViewShell::MouseMove(rMEvt, pWin);
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 		if( !mbMousePosFreezed )
379*cdf0e10cSrcweir 			maMousePos = rMEvt.GetPosPixel();
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 		Rectangle aRect;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 		if ( mbIsRulerDrag )
384*cdf0e10cSrcweir 		{
385*cdf0e10cSrcweir 			Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
386*cdf0e10cSrcweir 			mpDrawView->MovAction(aLogPos);
387*cdf0e10cSrcweir 		}
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 		if ( mpDrawView->IsAction() )
390*cdf0e10cSrcweir 		{
391*cdf0e10cSrcweir 			mpDrawView->TakeActionRect(aRect);
392*cdf0e10cSrcweir 			aRect = GetActiveWindow()->LogicToPixel(aRect);
393*cdf0e10cSrcweir 		}
394*cdf0e10cSrcweir 		else
395*cdf0e10cSrcweir 		{
396*cdf0e10cSrcweir 			aRect = Rectangle(maMousePos, maMousePos);
397*cdf0e10cSrcweir 		}
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 		ShowMousePosInfo(aRect, pWin);
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 		if ( mbPipette && GetViewFrame()->HasChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ) )
402*cdf0e10cSrcweir 		{
403*cdf0e10cSrcweir 			const long		nStartX = maMousePos.X() - PIPETTE_RANGE;
404*cdf0e10cSrcweir 			const long		nEndX = maMousePos.X() + PIPETTE_RANGE;
405*cdf0e10cSrcweir 			const long		nStartY = maMousePos.Y() - PIPETTE_RANGE;
406*cdf0e10cSrcweir 			const long		nEndY = maMousePos.Y() + PIPETTE_RANGE;
407*cdf0e10cSrcweir 			long			nRed = 0;
408*cdf0e10cSrcweir 			long			nGreen = 0;
409*cdf0e10cSrcweir 			long			nBlue = 0;
410*cdf0e10cSrcweir 			const double	fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 			for ( long nY = nStartY; nY <= nEndY; nY++ )
413*cdf0e10cSrcweir 			{
414*cdf0e10cSrcweir 				for( long nX = nStartX; nX <= nEndX; nX++ )
415*cdf0e10cSrcweir 				{
416*cdf0e10cSrcweir 					const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 					nRed += aCol.GetRed();
419*cdf0e10cSrcweir 					nGreen += aCol.GetGreen();
420*cdf0e10cSrcweir 					nBlue += aCol.GetBlue();
421*cdf0e10cSrcweir 				}
422*cdf0e10cSrcweir 			}
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 			( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
425*cdf0e10cSrcweir 				SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ),
426*cdf0e10cSrcweir 								 (sal_uInt8) ( nGreen / fDiv + .5 ),
427*cdf0e10cSrcweir 								 (sal_uInt8) ( nBlue / fDiv + .5 ) ) );
428*cdf0e10cSrcweir 		}
429*cdf0e10cSrcweir 	}
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir /*************************************************************************
434*cdf0e10cSrcweir |*
435*cdf0e10cSrcweir |* MouseButtonUp event
436*cdf0e10cSrcweir |*
437*cdf0e10cSrcweir \************************************************************************/
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
440*cdf0e10cSrcweir {
441*cdf0e10cSrcweir 	if ( !IsInputLocked() )
442*cdf0e10cSrcweir 	{
443*cdf0e10cSrcweir 		FASTBOOL bIsSetPageOrg = mpDrawView->IsSetPageOrg();
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 		if (mbIsRulerDrag)
446*cdf0e10cSrcweir 		{
447*cdf0e10cSrcweir 			Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 			if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
450*cdf0e10cSrcweir 			{
451*cdf0e10cSrcweir 				mpDrawView->EndAction();
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 				if (bIsSetPageOrg)
454*cdf0e10cSrcweir 					GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
455*cdf0e10cSrcweir 			}
456*cdf0e10cSrcweir 			else if (rMEvt.IsLeft() && bIsSetPageOrg)
457*cdf0e10cSrcweir 			{
458*cdf0e10cSrcweir 				mpDrawView->BrkAction();
459*cdf0e10cSrcweir 				SdPage* pPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
460*cdf0e10cSrcweir 				Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
461*cdf0e10cSrcweir 				mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
462*cdf0e10cSrcweir 				GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
463*cdf0e10cSrcweir 			}
464*cdf0e10cSrcweir 			else
465*cdf0e10cSrcweir 			{
466*cdf0e10cSrcweir 				mpDrawView->BrkAction();
467*cdf0e10cSrcweir 			}
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir 			GetActiveWindow()->ReleaseMouse();
470*cdf0e10cSrcweir 			mbIsRulerDrag = sal_False;
471*cdf0e10cSrcweir 		}
472*cdf0e10cSrcweir 		else
473*cdf0e10cSrcweir     		ViewShell::MouseButtonUp(rMEvt, pWin);
474*cdf0e10cSrcweir 	}
475*cdf0e10cSrcweir }
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir /*************************************************************************
478*cdf0e10cSrcweir |*
479*cdf0e10cSrcweir |* Command event
480*cdf0e10cSrcweir |*
481*cdf0e10cSrcweir \************************************************************************/
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir     // The command event is send to the window after a possible context
486*cdf0e10cSrcweir     // menu from an inplace client is closed. Now we have the chance to
487*cdf0e10cSrcweir     // deactivate the inplace client without any problem regarding parent
488*cdf0e10cSrcweir     // windows and code on the stack.
489*cdf0e10cSrcweir     // For more information, see #126086# and #128122#
490*cdf0e10cSrcweir     SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
491*cdf0e10cSrcweir     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
492*cdf0e10cSrcweir     if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
493*cdf0e10cSrcweir     {
494*cdf0e10cSrcweir         // Deactivate OLE object
495*cdf0e10cSrcweir         mpDrawView->UnmarkAll();
496*cdf0e10cSrcweir         SelectionHasChanged();
497*cdf0e10cSrcweir         return;
498*cdf0e10cSrcweir     }
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir     if ( !IsInputLocked() )
501*cdf0e10cSrcweir 	{
502*cdf0e10cSrcweir 	    if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
503*cdf0e10cSrcweir 	        return;
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 		const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir         if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow )
508*cdf0e10cSrcweir         {
509*cdf0e10cSrcweir 			TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 			if( aDataHelper.GetTransferable().is() )
512*cdf0e10cSrcweir 			{
513*cdf0e10cSrcweir             	Point       aPos;
514*cdf0e10cSrcweir                 sal_Int8    nDnDAction = DND_ACTION_COPY;
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir 		        if( GetActiveWindow() )
517*cdf0e10cSrcweir 			        aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir 				if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, sal_False ) )
520*cdf0e10cSrcweir 				{
521*cdf0e10cSrcweir 					INetBookmark	aINetBookmark( aEmptyStr, aEmptyStr );
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 					if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
524*cdf0e10cSrcweir 						  aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
525*cdf0e10cSrcweir 						( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
526*cdf0e10cSrcweir 						  aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
527*cdf0e10cSrcweir 						( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
528*cdf0e10cSrcweir 						  aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
529*cdf0e10cSrcweir 					{
530*cdf0e10cSrcweir 						InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
531*cdf0e10cSrcweir 					}
532*cdf0e10cSrcweir 				}
533*cdf0e10cSrcweir 			}
534*cdf0e10cSrcweir         }
535*cdf0e10cSrcweir         else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow &&
536*cdf0e10cSrcweir 			     pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
537*cdf0e10cSrcweir 		{
538*cdf0e10cSrcweir 			sal_uInt16 nSdResId = 0;          // ResourceID fuer Popup-Menue
539*cdf0e10cSrcweir 			sal_Bool bGraphicShell = this->ISA(GraphicViewShell);
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 			// Ist ein Fangobjekt unter dem Mauszeiger?
542*cdf0e10cSrcweir 			SdrPageView* pPV;
543*cdf0e10cSrcweir 			Point	aMPos = pWin->PixelToLogic( maMousePos );
544*cdf0e10cSrcweir 			sal_uInt16	nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
545*cdf0e10cSrcweir                 Size(FuPoor::HITPIX, 0 ) ).Width();
546*cdf0e10cSrcweir 			sal_uInt16	nHelpLine;
547*cdf0e10cSrcweir 			// fuer Klebepunkt
548*cdf0e10cSrcweir 			SdrObject*	pObj = NULL;
549*cdf0e10cSrcweir 			sal_uInt16		nPickId = 0;
550*cdf0e10cSrcweir 			// fuer Feldbefehl
551*cdf0e10cSrcweir 			OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
552*cdf0e10cSrcweir 			const SvxFieldItem* pFldItem = NULL;
553*cdf0e10cSrcweir 			if( pOLV )
554*cdf0e10cSrcweir 				pFldItem = pOLV->GetFieldAtSelection();
555*cdf0e10cSrcweir 				//pFldItem = pOLV->GetFieldUnderMousePointer();
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 			// Hilfslinie
558*cdf0e10cSrcweir 			if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
559*cdf0e10cSrcweir 			{
560*cdf0e10cSrcweir 				nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
561*cdf0e10cSrcweir                 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
562*cdf0e10cSrcweir                 return;
563*cdf0e10cSrcweir 			}
564*cdf0e10cSrcweir 			// Klebepunkt unter dem Mauszeiger markiert?
565*cdf0e10cSrcweir 			else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
566*cdf0e10cSrcweir 					 mpDrawView->IsGluePointMarked( pObj, nPickId ) )
567*cdf0e10cSrcweir 			{
568*cdf0e10cSrcweir 				nSdResId = RID_DRAW_GLUEPOINT_POPUP;
569*cdf0e10cSrcweir 			}
570*cdf0e10cSrcweir 			// Feldbefehl ?
571*cdf0e10cSrcweir 			else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
572*cdf0e10cSrcweir 								 pFldItem->GetField()->ISA( SvxExtTimeField ) ||
573*cdf0e10cSrcweir 								 pFldItem->GetField()->ISA( SvxExtFileField ) ||
574*cdf0e10cSrcweir 								 pFldItem->GetField()->ISA( SvxAuthorField ) ) )
575*cdf0e10cSrcweir 			{
576*cdf0e10cSrcweir                 LanguageType eLanguage( LANGUAGE_SYSTEM );
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir                 // #101743# Format popup with outliner language, if possible
579*cdf0e10cSrcweir                 if( pOLV->GetOutliner() )
580*cdf0e10cSrcweir                 {
581*cdf0e10cSrcweir                     ESelection aSelection( pOLV->GetSelection() );
582*cdf0e10cSrcweir                     eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
583*cdf0e10cSrcweir                 }
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir                 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 				if ( rCEvt.IsMouseEvent() )
588*cdf0e10cSrcweir 					aMPos = rCEvt.GetMousePosPixel();
589*cdf0e10cSrcweir 				else
590*cdf0e10cSrcweir 					aMPos = Point( 20, 20 );
591*cdf0e10cSrcweir 				aFieldPopup.Execute( pWin, aMPos );
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir 				SvxFieldData* pField = aFieldPopup.GetField();
594*cdf0e10cSrcweir 				if( pField )
595*cdf0e10cSrcweir 				{
596*cdf0e10cSrcweir                     SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
597*cdf0e10cSrcweir 					//pOLV->DeleteSelected(); <-- fehlt leider !
598*cdf0e10cSrcweir 					// Feld selektieren, so dass es beim Insert geloescht wird
599*cdf0e10cSrcweir 					ESelection aSel = pOLV->GetSelection();
600*cdf0e10cSrcweir 					sal_Bool bSel = sal_True;
601*cdf0e10cSrcweir 					if( aSel.nStartPos == aSel.nEndPos )
602*cdf0e10cSrcweir 					{
603*cdf0e10cSrcweir 						bSel = sal_False;
604*cdf0e10cSrcweir 						aSel.nEndPos++;
605*cdf0e10cSrcweir 					}
606*cdf0e10cSrcweir 					pOLV->SetSelection( aSel );
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 					pOLV->InsertField( aFieldItem );
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir 					// Selektion wird wieder in den Ursprungszustand gebracht
611*cdf0e10cSrcweir 					if( !bSel )
612*cdf0e10cSrcweir 						aSel.nEndPos--;
613*cdf0e10cSrcweir 					pOLV->SetSelection( aSel );
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 					delete pField;
616*cdf0e10cSrcweir 				}
617*cdf0e10cSrcweir 			}
618*cdf0e10cSrcweir 			else
619*cdf0e10cSrcweir 			{
620*cdf0e10cSrcweir 				// ist etwas selektiert?
621*cdf0e10cSrcweir 				if (mpDrawView->AreObjectsMarked() &&
622*cdf0e10cSrcweir 					mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
623*cdf0e10cSrcweir 				{
624*cdf0e10cSrcweir 					pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
625*cdf0e10cSrcweir 					if( HasCurrentFunction(SID_BEZIER_EDIT)	&& (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
626*cdf0e10cSrcweir 					{
627*cdf0e10cSrcweir 						nSdResId = RID_BEZIER_POPUP;
628*cdf0e10cSrcweir 					}
629*cdf0e10cSrcweir 					else
630*cdf0e10cSrcweir 					{
631*cdf0e10cSrcweir 						if( mpDrawView->GetTextEditObject() )
632*cdf0e10cSrcweir 						{
633*cdf0e10cSrcweir 							OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
634*cdf0e10cSrcweir 							Point aPos(rCEvt.GetMousePosPixel());
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir 							if ( pOutlinerView )
637*cdf0e10cSrcweir 							{
638*cdf0e10cSrcweir 								if( (  rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
639*cdf0e10cSrcweir 								    ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
640*cdf0e10cSrcweir 								{
641*cdf0e10cSrcweir 									// #91457# Popup for Online-Spelling now handled by DrawDocShell
642*cdf0e10cSrcweir 									// Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
643*cdf0e10cSrcweir 									Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 									if( !rCEvt.IsMouseEvent() )
646*cdf0e10cSrcweir 									{
647*cdf0e10cSrcweir 										aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
648*cdf0e10cSrcweir 									}
649*cdf0e10cSrcweir                                     // While showing the spell context menu
650*cdf0e10cSrcweir                                     // we lock the input so that another
651*cdf0e10cSrcweir                                     // context menu can not be opened during
652*cdf0e10cSrcweir                                     // that time (crash #i43235#).  In order
653*cdf0e10cSrcweir                                     // to not lock the UI completely we
654*cdf0e10cSrcweir                                     // first release the mouse.
655*cdf0e10cSrcweir                                     GetActiveWindow()->ReleaseMouse();
656*cdf0e10cSrcweir                                     LockInput();
657*cdf0e10cSrcweir 									pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
658*cdf0e10cSrcweir                                     UnlockInput();
659*cdf0e10cSrcweir 								}
660*cdf0e10cSrcweir 								else
661*cdf0e10cSrcweir 								{
662*cdf0e10cSrcweir 								    if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
663*cdf0e10cSrcweir 								    {
664*cdf0e10cSrcweir 								        nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
665*cdf0e10cSrcweir 								    }
666*cdf0e10cSrcweir 								    else
667*cdf0e10cSrcweir 								    {
668*cdf0e10cSrcweir 								        nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
669*cdf0e10cSrcweir 								    }
670*cdf0e10cSrcweir 								}
671*cdf0e10cSrcweir 							}
672*cdf0e10cSrcweir 						}
673*cdf0e10cSrcweir 						else
674*cdf0e10cSrcweir 						{
675*cdf0e10cSrcweir 							sal_uInt32 nInv = pObj->GetObjInventor();
676*cdf0e10cSrcweir 							sal_uInt16 nId = pObj->GetObjIdentifier();
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir 							if (nInv == SdrInventor)
679*cdf0e10cSrcweir 							{
680*cdf0e10cSrcweir 								switch ( nId )
681*cdf0e10cSrcweir 								{
682*cdf0e10cSrcweir 									case OBJ_CAPTION:
683*cdf0e10cSrcweir 									case OBJ_TITLETEXT:
684*cdf0e10cSrcweir 									case OBJ_OUTLINETEXT:
685*cdf0e10cSrcweir 									case OBJ_TEXT:
686*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
687*cdf0e10cSrcweir 																	RID_DRAW_TEXTOBJ_POPUP;
688*cdf0e10cSrcweir 										break;
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 									case OBJ_PATHLINE:
691*cdf0e10cSrcweir 									case OBJ_PLIN:
692*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
693*cdf0e10cSrcweir 																	RID_DRAW_POLYLINEOBJ_POPUP;
694*cdf0e10cSrcweir 										break;
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir 									case OBJ_FREELINE:
697*cdf0e10cSrcweir 									case OBJ_EDGE:		// Connector
698*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
699*cdf0e10cSrcweir 																	RID_DRAW_EDGEOBJ_POPUP;
700*cdf0e10cSrcweir 										break;
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 									case OBJ_LINE:
703*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
704*cdf0e10cSrcweir 																	RID_DRAW_LINEOBJ_POPUP;
705*cdf0e10cSrcweir 										break;
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 									case OBJ_MEASURE:
708*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
709*cdf0e10cSrcweir 																	RID_DRAW_MEASUREOBJ_POPUP;
710*cdf0e10cSrcweir 										break;
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 									case OBJ_RECT:
713*cdf0e10cSrcweir 									case OBJ_CIRC:
714*cdf0e10cSrcweir 									case OBJ_FREEFILL:
715*cdf0e10cSrcweir 									case OBJ_PATHFILL:
716*cdf0e10cSrcweir 									case OBJ_POLY:
717*cdf0e10cSrcweir 									case OBJ_SECT:
718*cdf0e10cSrcweir 									case OBJ_CARC:
719*cdf0e10cSrcweir 									case OBJ_CCUT:
720*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
721*cdf0e10cSrcweir 																	RID_DRAW_GEOMOBJ_POPUP;
722*cdf0e10cSrcweir 										break;
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir 									case OBJ_CUSTOMSHAPE:
725*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
726*cdf0e10cSrcweir 																	RID_DRAW_CUSTOMSHAPE_POPUP;
727*cdf0e10cSrcweir 										break;
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir 									case OBJ_GRUP:
730*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
731*cdf0e10cSrcweir 																	RID_DRAW_GROUPOBJ_POPUP;
732*cdf0e10cSrcweir 										break;
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir 									case OBJ_GRAF:
735*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
736*cdf0e10cSrcweir 																	RID_DRAW_GRAPHIC_POPUP;
737*cdf0e10cSrcweir 										break;
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir 									case OBJ_OLE2:
740*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
741*cdf0e10cSrcweir 																	RID_DRAW_OLE2_POPUP;
742*cdf0e10cSrcweir 										break;
743*cdf0e10cSrcweir 									case OBJ_MEDIA:
744*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
745*cdf0e10cSrcweir 																	RID_DRAW_MEDIA_POPUP;
746*cdf0e10cSrcweir 										break;
747*cdf0e10cSrcweir 									case OBJ_TABLE:
748*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
749*cdf0e10cSrcweir 																	RID_DRAW_TABLE_POPUP;
750*cdf0e10cSrcweir 										break;
751*cdf0e10cSrcweir 								}
752*cdf0e10cSrcweir 							}
753*cdf0e10cSrcweir 							else if( nInv == E3dInventor /*&& nId == E3D_POLYSCENE_ID*/)
754*cdf0e10cSrcweir 							{
755*cdf0e10cSrcweir 								if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
756*cdf0e10cSrcweir 								{
757*cdf0e10cSrcweir 									if( !mpDrawView->IsGroupEntered() )
758*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
759*cdf0e10cSrcweir 																RID_DRAW_3DSCENE_POPUP;
760*cdf0e10cSrcweir 									else
761*cdf0e10cSrcweir 										nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
762*cdf0e10cSrcweir 																RID_DRAW_3DSCENE2_POPUP;
763*cdf0e10cSrcweir 								}
764*cdf0e10cSrcweir 								else
765*cdf0e10cSrcweir 									nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
766*cdf0e10cSrcweir 																RID_DRAW_3DOBJ_POPUP;
767*cdf0e10cSrcweir 							}
768*cdf0e10cSrcweir 							else if( nInv == FmFormInventor )
769*cdf0e10cSrcweir 							{
770*cdf0e10cSrcweir 								nSdResId = RID_FORM_CONTROL_POPUP;
771*cdf0e10cSrcweir 							}
772*cdf0e10cSrcweir 						}
773*cdf0e10cSrcweir 					}
774*cdf0e10cSrcweir 				}
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 				// Mehrfachselektion
777*cdf0e10cSrcweir 				else if (mpDrawView->AreObjectsMarked() &&
778*cdf0e10cSrcweir 					mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
779*cdf0e10cSrcweir 				{
780*cdf0e10cSrcweir 					nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
781*cdf0e10cSrcweir 												RID_DRAW_MULTISELECTION_POPUP;
782*cdf0e10cSrcweir 				}
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 				// nichts selektiert
785*cdf0e10cSrcweir 				else
786*cdf0e10cSrcweir 				{
787*cdf0e10cSrcweir 					nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
788*cdf0e10cSrcweir 												RID_DRAW_NOSEL_POPUP;
789*cdf0e10cSrcweir 				}
790*cdf0e10cSrcweir 			}
791*cdf0e10cSrcweir 			// Popup-Menue anzeigen
792*cdf0e10cSrcweir 			if (nSdResId)
793*cdf0e10cSrcweir 			{
794*cdf0e10cSrcweir 				GetActiveWindow()->ReleaseMouse();
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir                 if(rCEvt.IsMouseEvent())
797*cdf0e10cSrcweir 				    GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
798*cdf0e10cSrcweir                 else
799*cdf0e10cSrcweir                 {
800*cdf0e10cSrcweir                     //#106326# don't open contextmenu at mouse position if not opened via mouse
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir                     //middle of the window if nothing is marked
803*cdf0e10cSrcweir                     Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
804*cdf0e10cSrcweir                             ,GetActiveWindow()->GetSizePixel().Height()/2);
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir                     //middle of the bounding rect if something is marked
807*cdf0e10cSrcweir                     if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
808*cdf0e10cSrcweir                     {
809*cdf0e10cSrcweir                         Rectangle aMarkRect;
810*cdf0e10cSrcweir                         mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
811*cdf0e10cSrcweir                         aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir                         //move the point into the visible window area
814*cdf0e10cSrcweir                         if( aMenuPos.X() < 0 )
815*cdf0e10cSrcweir                             aMenuPos.X() = 0;
816*cdf0e10cSrcweir                         if( aMenuPos.Y() < 0 )
817*cdf0e10cSrcweir                             aMenuPos.Y() = 0;
818*cdf0e10cSrcweir                         if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
819*cdf0e10cSrcweir                             aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
820*cdf0e10cSrcweir                         if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
821*cdf0e10cSrcweir                             aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
822*cdf0e10cSrcweir                     }
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir                     //open context menu at that point
825*cdf0e10cSrcweir                     GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
826*cdf0e10cSrcweir                 }
827*cdf0e10cSrcweir 				mbMousePosFreezed = sal_False;
828*cdf0e10cSrcweir 			}
829*cdf0e10cSrcweir 		}
830*cdf0e10cSrcweir 		else
831*cdf0e10cSrcweir 		{
832*cdf0e10cSrcweir 			ViewShell::Command(rCEvt, pWin);
833*cdf0e10cSrcweir 		}
834*cdf0e10cSrcweir 	}
835*cdf0e10cSrcweir }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir /*************************************************************************
838*cdf0e10cSrcweir |*
839*cdf0e10cSrcweir |* Linealmarkierungen anzeigen
840*cdf0e10cSrcweir |*
841*cdf0e10cSrcweir \************************************************************************/
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
844*cdf0e10cSrcweir     ::sd::Window* pWin)
845*cdf0e10cSrcweir {
846*cdf0e10cSrcweir 	if (mbHasRulers && pWin )
847*cdf0e10cSrcweir 	{
848*cdf0e10cSrcweir 		RulerLine	pHLines[2];
849*cdf0e10cSrcweir 		RulerLine	pVLines[2];
850*cdf0e10cSrcweir 		long        nHOffs = 0L;
851*cdf0e10cSrcweir 		long        nVOffs = 0L;
852*cdf0e10cSrcweir 		sal_uInt16		nCnt;
853*cdf0e10cSrcweir 
854*cdf0e10cSrcweir         if (mpHorizontalRuler.get() != NULL)
855*cdf0e10cSrcweir             mpHorizontalRuler->SetLines();
856*cdf0e10cSrcweir 
857*cdf0e10cSrcweir         if (mpVerticalRuler.get() != NULL)
858*cdf0e10cSrcweir             mpVerticalRuler->SetLines();
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir 		if (mpHorizontalRuler.get() != NULL)
861*cdf0e10cSrcweir 		{
862*cdf0e10cSrcweir 			nHOffs = mpHorizontalRuler->GetNullOffset() +
863*cdf0e10cSrcweir 					 mpHorizontalRuler->GetPageOffset();
864*cdf0e10cSrcweir 		}
865*cdf0e10cSrcweir 
866*cdf0e10cSrcweir 		if (mpVerticalRuler.get() != NULL)
867*cdf0e10cSrcweir 		{
868*cdf0e10cSrcweir 			nVOffs = mpVerticalRuler->GetNullOffset() +
869*cdf0e10cSrcweir 					 mpVerticalRuler->GetPageOffset();
870*cdf0e10cSrcweir 		}
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 		nCnt = 1;
873*cdf0e10cSrcweir 		pHLines[0].nPos = rRect.Left() - nHOffs;
874*cdf0e10cSrcweir 		pVLines[0].nPos = rRect.Top()  - nVOffs;
875*cdf0e10cSrcweir 		pHLines[0].nStyle = 0;
876*cdf0e10cSrcweir 		pVLines[0].nStyle = 0;
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir 		if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
879*cdf0e10cSrcweir 		{
880*cdf0e10cSrcweir 			pHLines[1].nPos = rRect.Right()  - nHOffs;
881*cdf0e10cSrcweir 			pVLines[1].nPos = rRect.Bottom() - nVOffs;
882*cdf0e10cSrcweir 			pHLines[1].nStyle = 0;
883*cdf0e10cSrcweir 			pVLines[1].nStyle = 0;
884*cdf0e10cSrcweir 			nCnt++;
885*cdf0e10cSrcweir 		}
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir 		if (mpHorizontalRuler.get() != NULL)
888*cdf0e10cSrcweir 			mpHorizontalRuler->SetLines(nCnt, pHLines);
889*cdf0e10cSrcweir 		if (mpVerticalRuler.get() != NULL)
890*cdf0e10cSrcweir 			mpVerticalRuler->SetLines(nCnt, pVLines);
891*cdf0e10cSrcweir 	}
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir 	// StatusBar Koordinatenanzeige
894*cdf0e10cSrcweir     OSL_ASSERT (GetViewShell()!=NULL);
895*cdf0e10cSrcweir     if ( !GetViewShell()->GetUIActiveClient() )
896*cdf0e10cSrcweir 	{
897*cdf0e10cSrcweir 		SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
898*cdf0e10cSrcweir 								   SID_ATTR_POSITION, SID_ATTR_POSITION,
899*cdf0e10cSrcweir 								   SID_ATTR_SIZE, SID_ATTR_SIZE,
900*cdf0e10cSrcweir 								   0L);
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir //		  GetStatusBarState(aSet);	nicht performant bei gedrueckter Modifiertaste!!
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir 		aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir 		SfxBindings& rBindings = GetViewFrame()->GetBindings();
907*cdf0e10cSrcweir 		rBindings.SetState(aSet);
908*cdf0e10cSrcweir 		rBindings.Invalidate(SID_CONTEXT);
909*cdf0e10cSrcweir 		rBindings.Invalidate(SID_ATTR_POSITION);
910*cdf0e10cSrcweir 		rBindings.Invalidate(SID_ATTR_SIZE);
911*cdf0e10cSrcweir     }
912*cdf0e10cSrcweir }
913*cdf0e10cSrcweir 
914*cdf0e10cSrcweir /*************************************************************************
915*cdf0e10cSrcweir |*
916*cdf0e10cSrcweir |*
917*cdf0e10cSrcweir |*
918*cdf0e10cSrcweir \************************************************************************/
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir void DrawViewShell::LockInput()
921*cdf0e10cSrcweir {
922*cdf0e10cSrcweir 	mnLockCount++;
923*cdf0e10cSrcweir }
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir /*************************************************************************
926*cdf0e10cSrcweir |*
927*cdf0e10cSrcweir |*
928*cdf0e10cSrcweir |*
929*cdf0e10cSrcweir \************************************************************************/
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir void DrawViewShell::UnlockInput()
932*cdf0e10cSrcweir {
933*cdf0e10cSrcweir 	DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
934*cdf0e10cSrcweir 	if ( mnLockCount )
935*cdf0e10cSrcweir 		mnLockCount--;
936*cdf0e10cSrcweir }
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir void DrawViewShell::ShowSnapLineContextMenu (
942*cdf0e10cSrcweir     SdrPageView& rPageView,
943*cdf0e10cSrcweir     const sal_uInt16 nSnapLineIndex,
944*cdf0e10cSrcweir     const Point& rMouseLocation)
945*cdf0e10cSrcweir {
946*cdf0e10cSrcweir     const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
947*cdf0e10cSrcweir     ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir     if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
950*cdf0e10cSrcweir     {
951*cdf0e10cSrcweir         pMenu->InsertItem(
952*cdf0e10cSrcweir             SID_SET_SNAPITEM,
953*cdf0e10cSrcweir             String(SdResId(STR_POPUP_EDIT_SNAPPOINT)));
954*cdf0e10cSrcweir         pMenu->InsertSeparator();
955*cdf0e10cSrcweir         pMenu->InsertItem(
956*cdf0e10cSrcweir             SID_DELETE_SNAPITEM,
957*cdf0e10cSrcweir             String(SdResId(STR_POPUP_DELETE_SNAPPOINT)));
958*cdf0e10cSrcweir     }
959*cdf0e10cSrcweir     else
960*cdf0e10cSrcweir     {
961*cdf0e10cSrcweir         pMenu->InsertItem(
962*cdf0e10cSrcweir             SID_SET_SNAPITEM,
963*cdf0e10cSrcweir             String(SdResId(STR_POPUP_EDIT_SNAPLINE)));
964*cdf0e10cSrcweir         pMenu->InsertSeparator();
965*cdf0e10cSrcweir         pMenu->InsertItem(
966*cdf0e10cSrcweir             SID_DELETE_SNAPITEM,
967*cdf0e10cSrcweir             String(SdResId(STR_POPUP_DELETE_SNAPLINE)));
968*cdf0e10cSrcweir     }
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir     pMenu->RemoveDisabledEntries(sal_False, sal_False);
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir     const sal_uInt16 nResult = pMenu->Execute(
973*cdf0e10cSrcweir         GetActiveWindow(),
974*cdf0e10cSrcweir         Rectangle(rMouseLocation, Size(10,10)),
975*cdf0e10cSrcweir         POPUPMENU_EXECUTE_DOWN);
976*cdf0e10cSrcweir     switch (nResult)
977*cdf0e10cSrcweir     {
978*cdf0e10cSrcweir         case SID_SET_SNAPITEM:
979*cdf0e10cSrcweir         {
980*cdf0e10cSrcweir             SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
981*cdf0e10cSrcweir             const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
982*cdf0e10cSrcweir             GetViewFrame()->GetDispatcher()->Execute(
983*cdf0e10cSrcweir                 SID_SET_SNAPITEM,
984*cdf0e10cSrcweir                 SFX_CALLMODE_SLOT,
985*cdf0e10cSrcweir                 aArguments);
986*cdf0e10cSrcweir         }
987*cdf0e10cSrcweir         break;
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir         case SID_DELETE_SNAPITEM:
990*cdf0e10cSrcweir         {
991*cdf0e10cSrcweir             rPageView.DeleteHelpLine(nSnapLineIndex);
992*cdf0e10cSrcweir         }
993*cdf0e10cSrcweir         break;
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir         default:
996*cdf0e10cSrcweir             break;
997*cdf0e10cSrcweir     }
998*cdf0e10cSrcweir }
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir #ifdef _MSC_VER
1004*cdf0e10cSrcweir #pragma optimize ( "", on )
1005*cdf0e10cSrcweir #endif
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir } // end of namespace sd
1008