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