xref: /aoo42x/main/sc/source/ui/view/gridwin3.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "scitems.hxx"
28cdf0e10cSrcweir #include <editeng/eeitem.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <svx/svdoutl.hxx>
31cdf0e10cSrcweir #include <svx/svdotext.hxx>
32cdf0e10cSrcweir #include <svx/svdpagv.hxx>
33cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
34cdf0e10cSrcweir #include <sfx2/bindings.hxx>
35cdf0e10cSrcweir #include <svl/ptitem.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "tabvwsh.hxx"
38cdf0e10cSrcweir #include "gridwin.hxx"
39cdf0e10cSrcweir #include "dbfunc.hxx"
40cdf0e10cSrcweir #include "viewdata.hxx"
41cdf0e10cSrcweir #include "output.hxx"
42cdf0e10cSrcweir #include "drawview.hxx"
43cdf0e10cSrcweir #include "fupoor.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "drawutil.hxx"
46cdf0e10cSrcweir #include "document.hxx"
47cdf0e10cSrcweir #include "drwlayer.hxx"
48cdf0e10cSrcweir #include <vcl/svapp.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // -----------------------------------------------------------------------
51cdf0e10cSrcweir 
52cdf0e10cSrcweir sal_Bool ScGridWindow::DrawMouseButtonDown(const MouseEvent& rMEvt)
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
55cdf0e10cSrcweir 	FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
56cdf0e10cSrcweir 	if (pDraw && !pViewData->IsRefMode())
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		pDraw->SetWindow( this );
59cdf0e10cSrcweir 		Point aLogicPos = PixelToLogic(rMEvt.GetPosPixel());
60cdf0e10cSrcweir 		if ( pDraw->IsDetectiveHit( aLogicPos ) )
61cdf0e10cSrcweir 		{
62cdf0e10cSrcweir 			//	auf Detektiv-Pfeilen gar nichts (Doppelklick wird bei ButtonUp ausgewertet)
63cdf0e10cSrcweir 			bRet = sal_True;
64cdf0e10cSrcweir 		}
65cdf0e10cSrcweir 		else
66cdf0e10cSrcweir 		{
67cdf0e10cSrcweir 			bRet = pDraw->MouseButtonDown( rMEvt );
68cdf0e10cSrcweir 			if ( bRet )
69cdf0e10cSrcweir 				UpdateStatusPosSize();
70cdf0e10cSrcweir 		}
71cdf0e10cSrcweir 	}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	//	bei rechter Taste Draw-Aktion abbrechen
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetScDrawView();
76cdf0e10cSrcweir 	if ( pDrView && !rMEvt.IsLeft() && !bRet )
77cdf0e10cSrcweir 	{
78cdf0e10cSrcweir 		pDrView->BrkAction();
79cdf0e10cSrcweir 		bRet = sal_True;
80cdf0e10cSrcweir 	}
81cdf0e10cSrcweir 	return bRet;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir sal_Bool ScGridWindow::DrawMouseButtonUp(const MouseEvent& rMEvt)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     ScViewFunc* pView = pViewData->GetView();
87cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
88cdf0e10cSrcweir 	FuPoor* pDraw = pView->GetDrawFuncPtr();
89cdf0e10cSrcweir 	if (pDraw && !pViewData->IsRefMode())
90cdf0e10cSrcweir 	{
91cdf0e10cSrcweir 		pDraw->SetWindow( this );
92cdf0e10cSrcweir 		bRet = pDraw->MouseButtonUp( rMEvt );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         // execute "format paint brush" for drawing objects
95cdf0e10cSrcweir         SfxItemSet* pDrawBrush = pView->GetDrawBrushSet();
96cdf0e10cSrcweir         if ( pDrawBrush )
97cdf0e10cSrcweir         {
98cdf0e10cSrcweir             ScDrawView* pDrView = pViewData->GetScDrawView();
99cdf0e10cSrcweir             if ( pDrView )
100cdf0e10cSrcweir             {
101cdf0e10cSrcweir                 sal_Bool bReplaceAll = sal_True;
102cdf0e10cSrcweir 	            pDrView->SetAttrToMarked(*pDrawBrush, bReplaceAll);
103cdf0e10cSrcweir             }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir             if ( !pView->IsPaintBrushLocked() )
106cdf0e10cSrcweir                 pView->ResetBrushDocument();        // end paint brush mode if not locked
107cdf0e10cSrcweir         }
108cdf0e10cSrcweir 	}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	return bRet;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir sal_Bool ScGridWindow::DrawMouseMove(const MouseEvent& rMEvt)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
116cdf0e10cSrcweir 	if (pDraw && !pViewData->IsRefMode())
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 		pDraw->SetWindow( this );
119cdf0e10cSrcweir 		sal_Bool bRet = pDraw->MouseMove( rMEvt );
120cdf0e10cSrcweir 		if ( bRet )
121cdf0e10cSrcweir 			UpdateStatusPosSize();
122cdf0e10cSrcweir 		return bRet;
123cdf0e10cSrcweir 	}
124cdf0e10cSrcweir 	else
125cdf0e10cSrcweir 	{
126cdf0e10cSrcweir 		SetPointer( Pointer( POINTER_ARROW ) );
127cdf0e10cSrcweir 		return sal_False;
128cdf0e10cSrcweir 	}
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir void ScGridWindow::DrawEndAction()
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetScDrawView();
134cdf0e10cSrcweir 	if ( pDrView && pDrView->IsAction() )
135cdf0e10cSrcweir 		pDrView->BrkAction();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
138cdf0e10cSrcweir 	if (pDraw)
139cdf0e10cSrcweir 		pDraw->StopDragTimer();
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	//	ReleaseMouse beim Aufruf
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir sal_Bool ScGridWindow::DrawCommand(const CommandEvent& rCEvt)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetScDrawView();
147cdf0e10cSrcweir 	FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
148cdf0e10cSrcweir 	if (pDrView && pDraw && !pViewData->IsRefMode())
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		pDraw->SetWindow( this );
151cdf0e10cSrcweir 		sal_uInt8 nUsed = pDraw->Command( rCEvt );
152cdf0e10cSrcweir 		if( nUsed == SC_CMD_USED )
153cdf0e10cSrcweir 			nButtonDown = 0;					// MouseButtonUp wird verschluckt...
154cdf0e10cSrcweir 		if( nUsed || pDrView->IsAction() )
155cdf0e10cSrcweir 			return sal_True;
156cdf0e10cSrcweir 	}
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	return sal_False;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir sal_Bool ScGridWindow::DrawKeyInput(const KeyEvent& rKEvt)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetScDrawView();
164cdf0e10cSrcweir 	FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
165cdf0e10cSrcweir 	if (pDrView && pDraw && !pViewData->IsRefMode())
166cdf0e10cSrcweir 	{
167cdf0e10cSrcweir 		pDraw->SetWindow( this );
168cdf0e10cSrcweir 		sal_Bool bOldMarked = pDrView->AreObjectsMarked();
169cdf0e10cSrcweir 		if (pDraw->KeyInput( rKEvt ))
170cdf0e10cSrcweir 		{
171cdf0e10cSrcweir 			sal_Bool bLeaveDraw = sal_False;
172cdf0e10cSrcweir 			sal_Bool bUsed = sal_True;
173cdf0e10cSrcweir 			sal_Bool bNewMarked = pDrView->AreObjectsMarked();
174cdf0e10cSrcweir 			if ( !pViewData->GetView()->IsDrawSelMode() )
175cdf0e10cSrcweir 				if ( !bNewMarked )
176cdf0e10cSrcweir 				{
177cdf0e10cSrcweir 					pViewData->GetViewShell()->SetDrawShell( sal_False );
178cdf0e10cSrcweir 					bLeaveDraw = sal_True;
179cdf0e10cSrcweir 					if ( !bOldMarked &&
180cdf0e10cSrcweir 						rKEvt.GetKeyCode().GetCode() == KEY_DELETE )
181cdf0e10cSrcweir 						bUsed = sal_False;					// nichts geloescht
182cdf0e10cSrcweir 				}
183cdf0e10cSrcweir 			if (!bLeaveDraw)
184cdf0e10cSrcweir 				UpdateStatusPosSize();		// #108137# for moving/resizing etc. by keyboard
185cdf0e10cSrcweir 			return bUsed;
186cdf0e10cSrcweir 		}
187cdf0e10cSrcweir 	}
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	return sal_False;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	// #109985#
195cdf0e10cSrcweir 	const ScViewOptions& rOpts = pViewData->GetOptions();
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     // use new flags at SdrPaintView for hiding objects
198cdf0e10cSrcweir     const bool bDrawOle(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_OLE));
199cdf0e10cSrcweir     const bool bDrawChart(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_CHART));
200cdf0e10cSrcweir     const bool bDrawDraw(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_DRAW));
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     if(bDrawOle || bDrawChart || bDrawDraw)
203cdf0e10cSrcweir     {
204cdf0e10cSrcweir         ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
205cdf0e10cSrcweir 
206cdf0e10cSrcweir         if(pDrView)
207cdf0e10cSrcweir         {
208cdf0e10cSrcweir             pDrView->setHideOle(!bDrawOle);
209cdf0e10cSrcweir             pDrView->setHideChart(!bDrawChart);
210cdf0e10cSrcweir             pDrView->setHideDraw(!bDrawDraw);
211cdf0e10cSrcweir             pDrView->setHideFormControl(!bDrawDraw);
212cdf0e10cSrcweir         }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		if(SC_UPDATE_CHANGED == eMode)
215cdf0e10cSrcweir 		{
216cdf0e10cSrcweir 			rOutputData.DrawingSingle((sal_uInt16)nLayer);
217cdf0e10cSrcweir 		}
218cdf0e10cSrcweir 		else
219cdf0e10cSrcweir 		{
220cdf0e10cSrcweir 			rOutputData.DrawSelectiveObjects((sal_uInt16)nLayer);
221cdf0e10cSrcweir 		}
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir void ScGridWindow::DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir 	//	Draw-Gitterlinien
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
230cdf0e10cSrcweir 	if ( pDrView && pDrView->IsGridVisible() )
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir 		SdrPageView* pPV = pDrView->GetSdrPageView();
233cdf0e10cSrcweir 		DBG_ASSERT(pPV, "keine PageView");
234cdf0e10cSrcweir 		if (pPV)
235cdf0e10cSrcweir 		{
236cdf0e10cSrcweir             pContentDev->SetLineColor(COL_GRAY);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir             pPV->DrawPageViewGrid( *pContentDev, rDrawingRect );
239cdf0e10cSrcweir 		}
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir MapMode ScGridWindow::GetDrawMapMode( sal_Bool bForce )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	ScDocument* pDoc = pViewData->GetDocument();
246cdf0e10cSrcweir     SCTAB nTab = pViewData->GetTabNo();
247cdf0e10cSrcweir 	sal_Bool bNegativePage = pDoc->IsNegativePage( nTab );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	MapMode aDrawMode = pViewData->GetLogicMode();
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
252cdf0e10cSrcweir 	if ( pDrView || bForce )
253cdf0e10cSrcweir 	{
254cdf0e10cSrcweir 		Fraction aScaleX;
255cdf0e10cSrcweir 		Fraction aScaleY;
256cdf0e10cSrcweir 		if (pDrView)
257cdf0e10cSrcweir 			pDrView->GetScale( aScaleX, aScaleY );
258cdf0e10cSrcweir 		else
259cdf0e10cSrcweir 		{
260cdf0e10cSrcweir 			SCCOL nEndCol = 0;
261cdf0e10cSrcweir 			SCROW nEndRow = 0;
262cdf0e10cSrcweir 			pDoc->GetTableArea( nTab, nEndCol, nEndRow );
263cdf0e10cSrcweir 			if (nEndCol<20) nEndCol = 20;
264cdf0e10cSrcweir             if (nEndRow<20) nEndRow = 20;
265cdf0e10cSrcweir 			ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, this,
266cdf0e10cSrcweir 									pViewData->GetZoomX(),pViewData->GetZoomY(),
267cdf0e10cSrcweir 									pViewData->GetPPTX(),pViewData->GetPPTY(),
268cdf0e10cSrcweir 									aScaleX,aScaleY );
269cdf0e10cSrcweir 		}
270cdf0e10cSrcweir 		aDrawMode.SetScaleX(aScaleX);
271cdf0e10cSrcweir 		aDrawMode.SetScaleY(aScaleY);
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir 	aDrawMode.SetOrigin(Point());
274cdf0e10cSrcweir 	Point aStartPos = pViewData->GetPixPos(eWhich);
275cdf0e10cSrcweir 	if ( bNegativePage )
276cdf0e10cSrcweir 	{
277cdf0e10cSrcweir 		//	RTL uses negative positions for drawing objects
278cdf0e10cSrcweir 		aStartPos.X() = -aStartPos.X() + GetOutputSizePixel().Width() - 1;
279cdf0e10cSrcweir 	}
280cdf0e10cSrcweir 	aDrawMode.SetOrigin( PixelToLogic( aStartPos, aDrawMode ) );
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	return aDrawMode;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir //sal_Bool ScGridWindow::DrawBeforeScroll()
286cdf0e10cSrcweir //{
287cdf0e10cSrcweir //	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
288cdf0e10cSrcweir //
289cdf0e10cSrcweir //	sal_Bool bXor = sal_False;
290cdf0e10cSrcweir //	if (pDrView)
291cdf0e10cSrcweir //	{
292cdf0e10cSrcweir //	    bXor=pDrView->IsShownXorVisible(this);
293cdf0e10cSrcweir //	    if (bXor) pDrView->HideShownXor(this);
294cdf0e10cSrcweir //	}
295cdf0e10cSrcweir //	return bXor;
296cdf0e10cSrcweir //}
297cdf0e10cSrcweir 
298cdf0e10cSrcweir void ScGridWindow::DrawAfterScroll(/*sal_Bool bVal*/)
299cdf0e10cSrcweir {
300cdf0e10cSrcweir 	Update();		// immer, damit das Verhalten mit/ohne DrawingLayer gleich ist
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
303cdf0e10cSrcweir 	if (pDrView)
304cdf0e10cSrcweir 	{
305cdf0e10cSrcweir 	    //if (bVal)
306cdf0e10cSrcweir     	//	pDrView->ShowShownXor(this);
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 		OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
309cdf0e10cSrcweir 		if (pOlView && pOlView->GetWindow() == this)
310cdf0e10cSrcweir 			pOlView->ShowCursor(sal_False);					// ist beim Scrollen weggekommen
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir //void ScGridWindow::DrawMarks()
315cdf0e10cSrcweir //{
316cdf0e10cSrcweir //	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
317cdf0e10cSrcweir //	if (pDrView)
318cdf0e10cSrcweir //		pDrView->DrawMarks(this);
319cdf0e10cSrcweir //}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir //sal_Bool ScGridWindow::NeedDrawMarks()
322cdf0e10cSrcweir //{
323cdf0e10cSrcweir //	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
324cdf0e10cSrcweir //	return pDrView && pDrView->IsMarkHdlShown() && pDrView->AreObjectsMarked();
325cdf0e10cSrcweir //}
326cdf0e10cSrcweir 
327cdf0e10cSrcweir void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress)
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
330cdf0e10cSrcweir 	if (pDrView)
331cdf0e10cSrcweir 	{
332cdf0e10cSrcweir 		const ScViewOptions& rOpts = pViewData->GetOptions();
333cdf0e10cSrcweir 		if(rOpts.GetOption( VOPT_ANCHOR ))
334cdf0e10cSrcweir 		{
335cdf0e10cSrcweir 			sal_Bool bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
336cdf0e10cSrcweir 			Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, sal_True );
337cdf0e10cSrcweir 			aPos = PixelToLogic(aPos);
338cdf0e10cSrcweir 			rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? HDL_ANCHOR_TR : HDL_ANCHOR));
339cdf0e10cSrcweir 		}
340cdf0e10cSrcweir 	}
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir SdrObject* ScGridWindow::GetEditObject()
344cdf0e10cSrcweir {
345cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
346cdf0e10cSrcweir 	if (pDrView)
347cdf0e10cSrcweir 	{
348cdf0e10cSrcweir 		OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
349cdf0e10cSrcweir 		if (pOlView && pOlView->GetWindow() == this)
350cdf0e10cSrcweir 			return pDrView->GetTextEditObject();
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	return NULL;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir void ScGridWindow::UpdateStatusPosSize()
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
359cdf0e10cSrcweir 	if (!pDrView)
360cdf0e10cSrcweir 		return;			// shouldn't be called in that case
361cdf0e10cSrcweir 
362cdf0e10cSrcweir     SdrPageView* pPV = pDrView->GetSdrPageView();
363cdf0e10cSrcweir     if (!pPV)
364cdf0e10cSrcweir         return;         // shouldn't be called in that case either
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	SfxItemSet aSet(pViewData->GetViewShell()->GetPool(), SID_ATTR_POSITION, SID_ATTR_SIZE);
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	//	Fill items for position and size:
369cdf0e10cSrcweir 	//	#108137# show action rectangle during action,
370cdf0e10cSrcweir 	//	position and size of selected object(s) if something is selected,
371cdf0e10cSrcweir 	//	mouse position otherwise
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	sal_Bool bActionItem = sal_False;
374cdf0e10cSrcweir 	if ( pDrView->IsAction() )				// action rectangle
375cdf0e10cSrcweir 	{
376cdf0e10cSrcweir 		Rectangle aRect;
377cdf0e10cSrcweir 		pDrView->TakeActionRect( aRect );
378cdf0e10cSrcweir 		if ( !aRect.IsEmpty() )
379cdf0e10cSrcweir 		{
380cdf0e10cSrcweir 			pPV->LogicToPagePos(aRect);
381cdf0e10cSrcweir 			aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
382cdf0e10cSrcweir 			aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
383cdf0e10cSrcweir 					Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
384cdf0e10cSrcweir 			bActionItem = sal_True;
385cdf0e10cSrcweir 		}
386cdf0e10cSrcweir 	}
387cdf0e10cSrcweir 	if ( !bActionItem )
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		if ( pDrView->AreObjectsMarked() )		// selected objects
390cdf0e10cSrcweir 		{
391cdf0e10cSrcweir 			Rectangle aRect = pDrView->GetAllMarkedRect();
392cdf0e10cSrcweir 			pPV->LogicToPagePos(aRect);
393cdf0e10cSrcweir 			aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
394cdf0e10cSrcweir 			aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
395cdf0e10cSrcweir 					Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
396cdf0e10cSrcweir 		}
397cdf0e10cSrcweir 		else								// mouse position
398cdf0e10cSrcweir 		{
399cdf0e10cSrcweir 			Point aPos = PixelToLogic(aCurMousePos);
400cdf0e10cSrcweir 			pPV->LogicToPagePos(aPos);
401cdf0e10cSrcweir 			aSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) );
402cdf0e10cSrcweir 			aSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
403cdf0e10cSrcweir 		}
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	pViewData->GetBindings().SetState(aSet);
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir sal_Bool ScGridWindow::DrawHasMarkedObj()
410cdf0e10cSrcweir {
411cdf0e10cSrcweir 	ScDrawView* p = pViewData->GetScDrawView();
412cdf0e10cSrcweir 	return p ? p->AreObjectsMarked() : sal_False;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir //void ScGridWindow::DrawStartTimer()
416cdf0e10cSrcweir //{
417cdf0e10cSrcweir 	//ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
418cdf0e10cSrcweir 	//if (pDrView)
419cdf0e10cSrcweir 	//{
420cdf0e10cSrcweir 		/* jetzt in DrawMarks
421cdf0e10cSrcweir 		sal_uInt16 nWinNum = pDrView->FindWin(this);
422cdf0e10cSrcweir 	    if (nWinNum!=SDRVIEWWIN_NOTFOUND)
423cdf0e10cSrcweir 	        pDrView->AfterInitRedraw(nWinNum);
424cdf0e10cSrcweir         */
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 		// pDrView->PostPaint();
427cdf0e10cSrcweir 		// pDrView->RestartAfterPaintTimer();
428cdf0e10cSrcweir 	//}
429cdf0e10cSrcweir //}
430cdf0e10cSrcweir 
431cdf0e10cSrcweir void ScGridWindow::DrawMarkDropObj( SdrObject* pObj )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
434cdf0e10cSrcweir 	if (pDrView)
435cdf0e10cSrcweir 		pDrView->MarkDropObj(pObj);
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 
440