Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "scitems.hxx"
31 : : #include <editeng/eeitem.hxx>
32 : :
33 : : #include <svx/svdoutl.hxx>
34 : : #include <svx/svdotext.hxx>
35 : : #include <svx/svdpagv.hxx>
36 : : #include <editeng/sizeitem.hxx>
37 : : #include <sfx2/bindings.hxx>
38 : : #include <svl/ptitem.hxx>
39 : :
40 : : #include "tabvwsh.hxx"
41 : : #include "gridwin.hxx"
42 : : #include "dbfunc.hxx"
43 : : #include "viewdata.hxx"
44 : : #include "output.hxx"
45 : : #include "drawview.hxx"
46 : : #include "fupoor.hxx"
47 : :
48 : : #include "drawutil.hxx"
49 : : #include "document.hxx"
50 : : #include "drwlayer.hxx"
51 : : #include <vcl/svapp.hxx>
52 : :
53 : : // -----------------------------------------------------------------------
54 : :
55 : 0 : bool ScGridWindow::DrawMouseButtonDown(const MouseEvent& rMEvt)
56 : : {
57 : 0 : bool bRet = false;
58 : 0 : FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
59 [ # # ][ # # ]: 0 : if (pDraw && !pViewData->IsRefMode())
[ # # ]
60 : : {
61 : 0 : pDraw->SetWindow( this );
62 [ # # ]: 0 : Point aLogicPos = PixelToLogic(rMEvt.GetPosPixel());
63 [ # # ][ # # ]: 0 : if ( pDraw->IsDetectiveHit( aLogicPos ) )
64 : : {
65 : : // auf Detektiv-Pfeilen gar nichts (Doppelklick wird bei ButtonUp ausgewertet)
66 : 0 : bRet = true;
67 : : }
68 : : else
69 : : {
70 [ # # ]: 0 : bRet = pDraw->MouseButtonDown( rMEvt );
71 [ # # ]: 0 : if ( bRet )
72 [ # # ]: 0 : UpdateStatusPosSize();
73 : : }
74 : : }
75 : :
76 : : // bei rechter Taste Draw-Aktion abbrechen
77 : :
78 : 0 : ScDrawView* pDrView = pViewData->GetScDrawView();
79 [ # # ][ # # ]: 0 : if ( pDrView && !rMEvt.IsLeft() && !bRet )
[ # # ][ # # ]
80 : : {
81 : 0 : pDrView->BrkAction();
82 : 0 : bRet = true;
83 : : }
84 : 0 : return bRet;
85 : : }
86 : :
87 : 0 : bool ScGridWindow::DrawMouseButtonUp(const MouseEvent& rMEvt)
88 : : {
89 [ # # ]: 0 : ScViewFunc* pView = pViewData->GetView();
90 : 0 : bool bRet = false;
91 : 0 : FuPoor* pDraw = pView->GetDrawFuncPtr();
92 [ # # ][ # # ]: 0 : if (pDraw && !pViewData->IsRefMode())
[ # # ]
93 : : {
94 : 0 : pDraw->SetWindow( this );
95 : 0 : bRet = pDraw->MouseButtonUp( rMEvt );
96 : :
97 : : // execute "format paint brush" for drawing objects
98 : 0 : SfxItemSet* pDrawBrush = pView->GetDrawBrushSet();
99 [ # # ]: 0 : if ( pDrawBrush )
100 : : {
101 : 0 : ScDrawView* pDrView = pViewData->GetScDrawView();
102 [ # # ]: 0 : if ( pDrView )
103 : : {
104 : 0 : bool bReplaceAll = true;
105 : 0 : pDrView->SetAttrToMarked(*pDrawBrush, bReplaceAll);
106 : : }
107 : :
108 [ # # ]: 0 : if ( !pView->IsPaintBrushLocked() )
109 : 0 : pView->ResetBrushDocument(); // end paint brush mode if not locked
110 : : }
111 : : }
112 : :
113 : 0 : return bRet;
114 : : }
115 : :
116 : 0 : bool ScGridWindow::DrawMouseMove(const MouseEvent& rMEvt)
117 : : {
118 : 0 : FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
119 [ # # ][ # # ]: 0 : if (pDraw && !pViewData->IsRefMode())
[ # # ]
120 : : {
121 : 0 : pDraw->SetWindow( this );
122 : 0 : bool bRet = pDraw->MouseMove( rMEvt );
123 [ # # ]: 0 : if ( bRet )
124 : 0 : UpdateStatusPosSize();
125 : 0 : return bRet;
126 : : }
127 : : else
128 : : {
129 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
130 : 0 : return false;
131 : : }
132 : : }
133 : :
134 : 458 : void ScGridWindow::DrawEndAction()
135 : : {
136 : 458 : ScDrawView* pDrView = pViewData->GetScDrawView();
137 [ - + ][ - + ]: 458 : if ( pDrView && pDrView->IsAction() )
[ + - ]
138 : 0 : pDrView->BrkAction();
139 : :
140 : 458 : FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
141 [ + - ]: 458 : if (pDraw)
142 : 458 : pDraw->StopDragTimer();
143 : :
144 : : // ReleaseMouse beim Aufruf
145 : 458 : }
146 : :
147 : 0 : bool ScGridWindow::DrawCommand(const CommandEvent& rCEvt)
148 : : {
149 : 0 : ScDrawView* pDrView = pViewData->GetScDrawView();
150 : 0 : FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
151 [ # # ][ # # ]: 0 : if (pDrView && pDraw && !pViewData->IsRefMode())
[ # # ][ # # ]
152 : : {
153 : 0 : pDraw->SetWindow( this );
154 : 0 : sal_uInt8 nUsed = pDraw->Command( rCEvt );
155 [ # # ]: 0 : if( nUsed == SC_CMD_USED )
156 : 0 : nButtonDown = 0; // MouseButtonUp wird verschluckt...
157 [ # # ][ # # ]: 0 : if( nUsed || pDrView->IsAction() )
[ # # ]
158 : 0 : return true;
159 : : }
160 : :
161 : 0 : return false;
162 : : }
163 : :
164 : 0 : bool ScGridWindow::DrawKeyInput(const KeyEvent& rKEvt)
165 : : {
166 : 0 : ScDrawView* pDrView = pViewData->GetScDrawView();
167 : 0 : FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
168 [ # # ][ # # ]: 0 : if (pDrView && pDraw && !pViewData->IsRefMode())
[ # # ][ # # ]
169 : : {
170 : 0 : pDraw->SetWindow( this );
171 : 0 : bool bOldMarked = pDrView->AreObjectsMarked();
172 [ # # ]: 0 : if (pDraw->KeyInput( rKEvt ))
173 : : {
174 : 0 : bool bLeaveDraw = false;
175 : 0 : bool bUsed = true;
176 : 0 : bool bNewMarked = pDrView->AreObjectsMarked();
177 [ # # ]: 0 : if ( !pViewData->GetView()->IsDrawSelMode() )
178 [ # # ]: 0 : if ( !bNewMarked )
179 : : {
180 : 0 : pViewData->GetViewShell()->SetDrawShell( false );
181 : 0 : bLeaveDraw = true;
182 [ # # ]: 0 : if ( !bOldMarked &&
[ # # # # ]
183 : 0 : rKEvt.GetKeyCode().GetCode() == KEY_DELETE )
184 : 0 : bUsed = false; // nichts geloescht
185 : : }
186 [ # # ]: 0 : if (!bLeaveDraw)
187 : 0 : UpdateStatusPosSize(); // for moving/resizing etc. by keyboard
188 : 0 : return bUsed;
189 : : }
190 : : }
191 : :
192 : 0 : return false;
193 : : }
194 : :
195 : 2556 : void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer )
196 : : {
197 : : // #109985#
198 : 2556 : const ScViewOptions& rOpts = pViewData->GetOptions();
199 : :
200 : : // use new flags at SdrPaintView for hiding objects
201 : 2556 : const bool bDrawOle(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_OLE));
202 : 2556 : const bool bDrawChart(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_CHART));
203 : 2556 : const bool bDrawDraw(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_DRAW));
204 : :
205 [ # # ][ # # ]: 2556 : if(bDrawOle || bDrawChart || bDrawDraw)
[ - + ]
206 : : {
207 : 2556 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
208 : :
209 [ + - ]: 2556 : if(pDrView)
210 : : {
211 : 2556 : pDrView->setHideOle(!bDrawOle);
212 : 2556 : pDrView->setHideChart(!bDrawChart);
213 : 2556 : pDrView->setHideDraw(!bDrawDraw);
214 : 2556 : pDrView->setHideFormControl(!bDrawDraw);
215 : : }
216 : :
217 [ - + ]: 2556 : if(SC_UPDATE_CHANGED == eMode)
218 : : {
219 : 0 : rOutputData.DrawingSingle((sal_uInt16)nLayer);
220 : : }
221 : : else
222 : : {
223 : 2556 : rOutputData.DrawSelectiveObjects((sal_uInt16)nLayer);
224 : : }
225 : : }
226 : 2556 : }
227 : :
228 : 1278 : void ScGridWindow::DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev )
229 : : {
230 : : // Draw-Gitterlinien
231 : :
232 : 1278 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
233 [ - + ][ - + ]: 1278 : if ( pDrView && pDrView->IsGridVisible() )
[ + - ]
234 : : {
235 : 0 : SdrPageView* pPV = pDrView->GetSdrPageView();
236 : : OSL_ENSURE(pPV, "keine PageView");
237 [ # # ]: 0 : if (pPV)
238 : : {
239 [ # # ]: 0 : pContentDev->SetLineColor(COL_GRAY);
240 : :
241 [ # # ]: 0 : pPV->DrawPageViewGrid( *pContentDev, rDrawingRect );
242 : : }
243 : : }
244 : 1278 : }
245 : :
246 : 12936 : MapMode ScGridWindow::GetDrawMapMode( bool bForce )
247 : : {
248 [ + - ]: 12936 : ScDocument* pDoc = pViewData->GetDocument();
249 : 12936 : SCTAB nTab = pViewData->GetTabNo();
250 [ + - ]: 12936 : sal_Bool bNegativePage = pDoc->IsNegativePage( nTab );
251 : :
252 [ + - ][ + - ]: 12936 : MapMode aDrawMode = pViewData->GetLogicMode();
253 : :
254 : 12936 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
255 [ - + ][ + + ]: 12936 : if ( pDrView || bForce )
256 : : {
257 : 12516 : Fraction aScaleX;
258 : 12516 : Fraction aScaleY;
259 [ + - ]: 12516 : if (pDrView)
260 [ + - ]: 12516 : pDrView->GetScale( aScaleX, aScaleY );
261 : : else
262 : : {
263 : 0 : SCCOL nEndCol = 0;
264 : 0 : SCROW nEndRow = 0;
265 [ # # ]: 0 : pDoc->GetTableArea( nTab, nEndCol, nEndRow );
266 [ # # ]: 0 : if (nEndCol<20) nEndCol = 20;
267 [ # # ]: 0 : if (nEndRow<20) nEndRow = 1000;
268 : : ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, this,
269 : 0 : pViewData->GetZoomX(),pViewData->GetZoomY(),
270 : : pViewData->GetPPTX(),pViewData->GetPPTY(),
271 [ # # ]: 0 : aScaleX,aScaleY );
272 : : }
273 [ + - ]: 12516 : aDrawMode.SetScaleX(aScaleX);
274 [ + - ]: 12516 : aDrawMode.SetScaleY(aScaleY);
275 : : }
276 [ + - ]: 12936 : aDrawMode.SetOrigin(Point());
277 [ + - ]: 12936 : Point aStartPos = pViewData->GetPixPos(eWhich);
278 [ + + ]: 12936 : if ( bNegativePage )
279 : : {
280 : : // RTL uses negative positions for drawing objects
281 : 16 : aStartPos.X() = -aStartPos.X() + GetOutputSizePixel().Width() - 1;
282 : : }
283 [ + - ][ + - ]: 12936 : aDrawMode.SetOrigin( PixelToLogic( aStartPos, aDrawMode ) );
284 : :
285 : 12936 : return aDrawMode;
286 : : }
287 : :
288 : 0 : void ScGridWindow::DrawAfterScroll(/*BOOL bVal*/)
289 : : {
290 : 0 : Update(); // immer, damit das Verhalten mit/ohne DrawingLayer gleich ist
291 : :
292 : 0 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
293 [ # # ]: 0 : if (pDrView)
294 : : {
295 : 0 : OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
296 [ # # ][ # # ]: 0 : if (pOlView && pOlView->GetWindow() == this)
[ # # ]
297 : 0 : pOlView->ShowCursor(false); // ist beim Scrollen weggekommen
298 : : }
299 : 0 : }
300 : :
301 : 0 : void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress)
302 : : {
303 : 0 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
304 [ # # ]: 0 : if (pDrView)
305 : : {
306 : 0 : const ScViewOptions& rOpts = pViewData->GetOptions();
307 [ # # ]: 0 : if(rOpts.GetOption( VOPT_ANCHOR ))
308 : : {
309 [ # # ][ # # ]: 0 : sal_Bool bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
310 [ # # ]: 0 : Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, sal_True );
311 [ # # ]: 0 : aPos = PixelToLogic(aPos);
312 [ # # ][ # # ]: 0 : rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? HDL_ANCHOR_TR : HDL_ANCHOR));
[ # # ][ # # ]
313 : : }
314 : : }
315 : 0 : }
316 : :
317 : 1278 : SdrObject* ScGridWindow::GetEditObject()
318 : : {
319 : 1278 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
320 [ + - ]: 1278 : if (pDrView)
321 : : {
322 : 1278 : OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
323 [ # # ][ - + ]: 1278 : if (pOlView && pOlView->GetWindow() == this)
[ - + ]
324 : 0 : return pDrView->GetTextEditObject();
325 : : }
326 : :
327 : 1278 : return NULL;
328 : : }
329 : :
330 : 0 : void ScGridWindow::UpdateStatusPosSize()
331 : : {
332 : 0 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
333 [ # # ]: 0 : if (!pDrView)
334 : : return; // shouldn't be called in that case
335 : :
336 : 0 : SdrPageView* pPV = pDrView->GetSdrPageView();
337 [ # # ]: 0 : if (!pPV)
338 : : return; // shouldn't be called in that case either
339 : :
340 [ # # ]: 0 : SfxItemSet aSet(pViewData->GetViewShell()->GetPool(), SID_ATTR_POSITION, SID_ATTR_SIZE);
341 : :
342 : : // Fill items for position and size:
343 : : // show action rectangle during action,
344 : : // position and size of selected object(s) if something is selected,
345 : : // mouse position otherwise
346 : :
347 : 0 : sal_Bool bActionItem = false;
348 [ # # ][ # # ]: 0 : if ( pDrView->IsAction() ) // action rectangle
349 : : {
350 [ # # ]: 0 : Rectangle aRect;
351 [ # # ]: 0 : pDrView->TakeActionRect( aRect );
352 [ # # ][ # # ]: 0 : if ( !aRect.IsEmpty() )
353 : : {
354 [ # # ]: 0 : pPV->LogicToPagePos(aRect);
355 [ # # ][ # # ]: 0 : aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
[ # # ]
356 : : aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
357 [ # # ][ # # ]: 0 : Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
[ # # ]
358 : 0 : bActionItem = sal_True;
359 : : }
360 : : }
361 [ # # ]: 0 : if ( !bActionItem )
362 : : {
363 [ # # ]: 0 : if ( pDrView->AreObjectsMarked() ) // selected objects
364 : : {
365 [ # # ]: 0 : Rectangle aRect = pDrView->GetAllMarkedRect();
366 [ # # ]: 0 : pPV->LogicToPagePos(aRect);
367 [ # # ][ # # ]: 0 : aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
[ # # ]
368 : : aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
369 [ # # ][ # # ]: 0 : Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
[ # # ]
370 : : }
371 : : else // mouse position
372 : : {
373 [ # # ]: 0 : Point aPos = PixelToLogic(aCurMousePos);
374 : 0 : pPV->LogicToPagePos(aPos);
375 [ # # ][ # # ]: 0 : aSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) );
[ # # ]
376 [ # # ][ # # ]: 0 : aSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
[ # # ]
377 : : }
378 : : }
379 : :
380 [ # # ][ # # ]: 0 : pViewData->GetBindings().SetState(aSet);
[ # # ]
381 : : }
382 : :
383 : 0 : bool ScGridWindow::DrawHasMarkedObj()
384 : : {
385 : 0 : ScDrawView* p = pViewData->GetScDrawView();
386 [ # # ][ # # ]: 0 : return p ? p->AreObjectsMarked() : false;
387 : : }
388 : :
389 : 0 : void ScGridWindow::DrawMarkDropObj( SdrObject* pObj )
390 : : {
391 : 0 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
392 [ # # ]: 0 : if (pDrView)
393 : 0 : pDrView->MarkDropObj(pObj);
394 : 0 : }
395 : :
396 : :
397 : :
398 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|