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