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 : :
32 : : #include <memory> //auto_ptr
33 : : #include <editeng/adjitem.hxx>
34 : : #include <svx/algitem.hxx>
35 : : #include <editeng/editview.hxx>
36 : : #include <editeng/editstat.hxx>
37 : : #include <editeng/flditem.hxx>
38 : : #include <editeng/justifyitem.hxx>
39 : : #include <svx/svdetc.hxx>
40 : : #include <editeng/editobj.hxx>
41 : : #include <sfx2/dispatch.hxx>
42 : : #include <sfx2/viewfrm.hxx>
43 : : #include <sfx2/docfile.hxx>
44 : : #include <svl/stritem.hxx>
45 : : #include <svtools/svlbox.hxx>
46 : : #include <svtools/svtabbx.hxx>
47 : : #include <svl/urlbmk.hxx>
48 : : #include <vcl/cursor.hxx>
49 : : #include <vcl/graph.hxx>
50 : : #include <vcl/hatch.hxx>
51 : : #include <sot/formats.hxx>
52 : : #include <sot/clsids.hxx>
53 : : #include <sal/macros.h>
54 : :
55 : : #include <svx/svdview.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT)
56 : : #include <editeng/outliner.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT)
57 : : #include <svx/svditer.hxx>
58 : : #include <svx/svdocapt.hxx>
59 : : #include <svx/svdpagv.hxx>
60 : :
61 : : #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
62 : : #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
63 : : #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
64 : : #include <com/sun/star/sheet/DataPilotTableResultData.hpp>
65 : : #include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
66 : : #include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
67 : : #include <com/sun/star/sheet/MemberResultFlags.hpp>
68 : : #include <com/sun/star/awt/KeyModifier.hpp>
69 : : #include <com/sun/star/awt/MouseButton.hpp>
70 : : #include <com/sun/star/script/vba/VBAEventId.hpp>
71 : : #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
72 : :
73 : : #include "gridwin.hxx"
74 : : #include "tabvwsh.hxx"
75 : : #include "docsh.hxx"
76 : : #include "viewdata.hxx"
77 : : #include "tabview.hxx"
78 : : #include "select.hxx"
79 : : #include "scmod.hxx"
80 : : #include "document.hxx"
81 : : #include "attrib.hxx"
82 : : #include "dbdata.hxx"
83 : : #include "stlpool.hxx"
84 : : #include "printfun.hxx"
85 : : #include "cbutton.hxx"
86 : : #include "sc.hrc"
87 : : #include "globstr.hrc"
88 : : #include "editutil.hxx"
89 : : #include "scresid.hxx"
90 : : #include "inputhdl.hxx"
91 : : #include "uiitems.hxx" // Filter-Dialog - auslagern !!!
92 : : #include "filtdlg.hxx"
93 : : #include "impex.hxx" // Sylk-ID fuer CB
94 : : #include "cell.hxx" // fuer Edit-Felder
95 : : #include "patattr.hxx"
96 : : #include "notemark.hxx"
97 : : #include "rfindlst.hxx"
98 : : #include "docpool.hxx"
99 : : #include "output.hxx"
100 : : #include "docfunc.hxx"
101 : : #include "dbdocfun.hxx"
102 : : #include "dpobject.hxx"
103 : : #include "dpoutput.hxx"
104 : : #include "transobj.hxx"
105 : : #include "drwtrans.hxx"
106 : : #include "seltrans.hxx"
107 : : #include "sizedev.hxx"
108 : : #include "AccessibilityHints.hxx"
109 : : #include "dpsave.hxx"
110 : : #include "viewuno.hxx"
111 : : #include "compiler.hxx"
112 : : #include "editable.hxx"
113 : : #include "fillinfo.hxx"
114 : : #include "userdat.hxx"
115 : : #include "drwlayer.hxx"
116 : : #include "validat.hxx"
117 : : #include "tabprotection.hxx"
118 : : #include "postit.hxx"
119 : : #include "dpcontrol.hxx"
120 : : #include "checklistmenu.hxx"
121 : : #include "clipparam.hxx"
122 : : #include "cellsh.hxx"
123 : : #include "overlayobject.hxx"
124 : : #include "cellsuno.hxx"
125 : : #include "drawview.hxx"
126 : : #include "dragdata.hxx"
127 : : #include "cliputil.hxx"
128 : : #include "queryentry.hxx"
129 : : #include "markdata.hxx"
130 : : #include "checklistmenu.hrc"
131 : : #include "strload.hxx"
132 : :
133 : : #include <svx/sdrpagewindow.hxx>
134 : : #include <svx/sdr/overlay/overlaymanager.hxx>
135 : : #include <vcl/svapp.hxx>
136 : : #include <svx/sdr/overlay/overlayselection.hxx>
137 : :
138 : : #include <vector>
139 : :
140 : : using namespace com::sun::star;
141 : : using ::com::sun::star::uno::Sequence;
142 : : using ::com::sun::star::uno::Any;
143 : : using ::rtl::OUString;
144 : :
145 : : const sal_uInt8 SC_NESTEDBUTTON_NONE = 0;
146 : : const sal_uInt8 SC_NESTEDBUTTON_DOWN = 1;
147 : : const sal_uInt8 SC_NESTEDBUTTON_UP = 2;
148 : :
149 : : #define SC_AUTOFILTER_ALL 0
150 : : #define SC_AUTOFILTER_TOP10 1
151 : : #define SC_AUTOFILTER_CUSTOM 2
152 : : #define SC_AUTOFILTER_EMPTY 3
153 : : #define SC_AUTOFILTER_NOTEMPTY 4
154 : :
155 : : // Modi fuer die FilterListBox
156 : : enum ScFilterBoxMode
157 : : {
158 : : SC_FILTERBOX_FILTER,
159 : : SC_FILTERBOX_DATASELECT,
160 : : SC_FILTERBOX_SCENARIO,
161 : : SC_FILTERBOX_PAGEFIELD
162 : : };
163 : :
164 : : extern SfxViewShell* pScActiveViewShell; // global.cxx
165 : : extern sal_uInt16 nScClickMouseModifier; // global.cxx
166 : : extern sal_uInt16 nScFillModeMouseModifier; // global.cxx
167 : :
168 : : #define SC_FILTERLISTBOX_LINES 12
169 : :
170 : : // ============================================================================
171 : :
172 : 229 : ScGridWindow::VisibleRange::VisibleRange() :
173 : 229 : mnCol1(0), mnCol2(MAXCOL), mnRow1(0), mnRow2(MAXROW)
174 : : {
175 : 229 : }
176 : :
177 : 2844 : bool ScGridWindow::VisibleRange::isInside(SCCOL nCol, SCROW nRow) const
178 : : {
179 [ + - ][ + + ]: 2844 : return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2;
[ + - ][ + + ]
180 : : }
181 : :
182 : : // ============================================================================
183 : :
184 : : class ScFilterListBox : public ListBox
185 : : {
186 : : private:
187 : : ScGridWindow* pGridWin;
188 : : SCCOL nCol;
189 : : SCROW nRow;
190 : : sal_Bool bButtonDown;
191 : : sal_Bool bInit;
192 : : sal_Bool bCancelled;
193 : : sal_Bool bInSelect;
194 : : bool mbListHasDates;
195 : : sal_uLong nSel;
196 : : ScFilterBoxMode eMode;
197 : :
198 : : protected:
199 : : virtual void LoseFocus();
200 : : void SelectHdl();
201 : :
202 : : public:
203 : : ScFilterListBox( Window* pParent, ScGridWindow* pGrid,
204 : : SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode );
205 : : ~ScFilterListBox();
206 : :
207 : : virtual long PreNotify( NotifyEvent& rNEvt );
208 : : virtual void Select();
209 : :
210 : 0 : SCCOL GetCol() const { return nCol; }
211 : 0 : SCROW GetRow() const { return nRow; }
212 : 0 : ScFilterBoxMode GetMode() const { return eMode; }
213 : : sal_Bool IsDataSelect() const { return (eMode == SC_FILTERBOX_DATASELECT); }
214 : : void EndInit();
215 : 0 : sal_Bool IsInInit() const { return bInit; }
216 : 0 : void SetCancelled() { bCancelled = sal_True; }
217 : 0 : sal_Bool IsInSelect() const { return bInSelect; }
218 : 0 : void SetListHasDates(bool b) { mbListHasDates = b; }
219 : 0 : bool HasDates() const { return mbListHasDates; }
220 : : };
221 : :
222 : : //-------------------------------------------------------------------
223 : :
224 : : // ListBox in einem FloatingWindow (pParent)
225 : 0 : ScFilterListBox::ScFilterListBox( Window* pParent, ScGridWindow* pGrid,
226 : : SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode ) :
227 : : ListBox( pParent, WB_AUTOHSCROLL ),
228 : : pGridWin( pGrid ),
229 : : nCol( nNewCol ),
230 : : nRow( nNewRow ),
231 : : bButtonDown( false ),
232 : : bInit( sal_True ),
233 : : bCancelled( false ),
234 : : bInSelect( false ),
235 : : mbListHasDates(false),
236 : : nSel( 0 ),
237 : 0 : eMode( eNewMode )
238 : : {
239 : 0 : }
240 : :
241 : 0 : ScFilterListBox::~ScFilterListBox()
242 : : {
243 [ # # ][ # # ]: 0 : if (IsMouseCaptured())
244 [ # # ]: 0 : ReleaseMouse();
245 [ # # ]: 0 : }
246 : :
247 : 0 : void ScFilterListBox::EndInit()
248 : : {
249 : 0 : sal_uInt16 nPos = GetSelectEntryPos();
250 [ # # ]: 0 : if ( LISTBOX_ENTRY_NOTFOUND == nPos )
251 : 0 : nSel = 0;
252 : : else
253 : 0 : nSel = nPos;
254 : :
255 : 0 : bInit = false;
256 : 0 : }
257 : :
258 : 0 : void ScFilterListBox::LoseFocus()
259 : : {
260 : : #ifndef UNX
261 : : Hide();
262 : : #endif
263 : 0 : }
264 : :
265 : : // -----------------------------------------------------------------------
266 : :
267 : 0 : long ScFilterListBox::PreNotify( NotifyEvent& rNEvt )
268 : : {
269 : 0 : long nDone = 0;
270 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
271 : : {
272 [ # # ][ # # ]: 0 : KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
273 : 0 : KeyCode aCode = aKeyEvt.GetKeyCode();
274 [ # # ]: 0 : if ( !aCode.GetModifier() ) // ohne alle Modifiers
275 : : {
276 : 0 : sal_uInt16 nKey = aCode.GetCode();
277 [ # # ]: 0 : if ( nKey == KEY_RETURN )
278 : : {
279 [ # # ]: 0 : SelectHdl(); // auswaehlen
280 : 0 : nDone = 1;
281 : : }
282 [ # # ]: 0 : else if ( nKey == KEY_ESCAPE )
283 : : {
284 [ # # ]: 0 : pGridWin->ClickExtern(); // loescht die List-Box !!!
285 : 0 : nDone = 1;
286 : : }
287 : : }
288 : : }
289 : :
290 [ # # ]: 0 : return nDone ? nDone : ListBox::PreNotify( rNEvt );
291 : : }
292 : :
293 : 0 : void ScFilterListBox::Select()
294 : : {
295 : 0 : ListBox::Select();
296 : 0 : SelectHdl();
297 : 0 : }
298 : :
299 : 0 : void ScFilterListBox::SelectHdl()
300 : : {
301 [ # # ][ # # ]: 0 : if ( !IsTravelSelect() && !bInit && !bCancelled )
[ # # ][ # # ]
302 : : {
303 : 0 : sal_uInt16 nPos = GetSelectEntryPos();
304 [ # # ]: 0 : if ( LISTBOX_ENTRY_NOTFOUND != nPos )
305 : : {
306 : 0 : nSel = nPos;
307 [ # # ]: 0 : if (!bButtonDown)
308 : : {
309 : : // #i81298# set bInSelect flag, so the box isn't deleted from modifications within FilterSelect
310 : 0 : bInSelect = sal_True;
311 : 0 : pGridWin->FilterSelect( nSel );
312 : 0 : bInSelect = false;
313 : : }
314 : : }
315 : : }
316 : 0 : }
317 : :
318 : : // ============================================================================
319 : :
320 : : // use a System floating window for the above filter listbox
321 : : class ScFilterFloatingWindow : public FloatingWindow
322 : : {
323 : : public:
324 : : ScFilterFloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
325 : : virtual ~ScFilterFloatingWindow();
326 : : // required for System FloatingWindows that will not process KeyInput by themselves
327 : : virtual Window* GetPreferredKeyInputWindow();
328 : : };
329 : :
330 : 0 : ScFilterFloatingWindow::ScFilterFloatingWindow( Window* pParent, WinBits nStyle ) :
331 : 0 : FloatingWindow( pParent, nStyle|WB_SYSTEMWINDOW ) // make it a system floater
332 : 0 : {}
333 : :
334 : 0 : ScFilterFloatingWindow::~ScFilterFloatingWindow()
335 : : {
336 [ # # ]: 0 : EndPopupMode();
337 [ # # ]: 0 : }
338 : :
339 : 0 : Window* ScFilterFloatingWindow::GetPreferredKeyInputWindow()
340 : : {
341 : : // redirect keyinput in the child window
342 [ # # ]: 0 : return GetWindow(WINDOW_FIRSTCHILD) ? GetWindow(WINDOW_FIRSTCHILD)->GetPreferredKeyInputWindow() : NULL; // will be the FilterBox
343 : : }
344 : :
345 : : // ============================================================================
346 : :
347 : 0 : sal_Bool lcl_IsEditableMatrix( ScDocument* pDoc, const ScRange& rRange )
348 : : {
349 : : // wenn es ein editierbarer Bereich ist, und rechts unten eine Matrix-Zelle
350 : : // mit Origin links oben liegt, enthaelt der Bereich genau die Matrix.
351 : : //! Direkt die MatrixEdges Funktionen von der Column herausreichen ???
352 : :
353 [ # # ]: 0 : if ( !pDoc->IsBlockEditable( rRange.aStart.Tab(), rRange.aStart.Col(),rRange.aStart.Row(),
354 [ # # ]: 0 : rRange.aEnd.Col(),rRange.aEnd.Row() ) )
355 : 0 : return false;
356 : :
357 : 0 : ScAddress aPos;
358 [ # # ]: 0 : const ScBaseCell* pCell = pDoc->GetCell( rRange.aEnd );
359 : 0 : return ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA &&
360 [ # # # # ]: 0 : ((ScFormulaCell*)pCell)->GetMatrixOrigin(aPos) && aPos == rRange.aStart );
[ # # ][ # # ]
[ # # ][ # # ]
361 : :
362 : : }
363 : :
364 : 0 : void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pDrDoc, const Point& rPos, ScViewData* pViewData )
365 : : {
366 [ # # ][ # # ]: 0 : if (!pView && !pPV && !pDrDoc && !pViewData)
[ # # ][ # # ]
367 : 0 : return;
368 : :
369 [ # # ]: 0 : ScDocument& rDoc = *pViewData->GetDocument();
370 : 0 : ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
371 [ # # ][ # # ]: 0 : ScPostIt* pNote = rDoc.GetNotes( aCellPos.Tab() )->findByAddress( aCellPos );
372 [ # # ]: 0 : SdrObject* pObj = pNote ? pNote->GetCaption() : 0;
373 [ # # ][ # # ]: 0 : if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
374 : : {
375 [ # # ]: 0 : const ScProtectionAttr* pProtAttr = static_cast< const ScProtectionAttr* > (rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_PROTECTION ) );
376 [ # # ][ # # ]: 0 : bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell() ;
377 [ # # ][ # # ]: 0 : bool bProtectDoc = rDoc.IsTabProtected( aCellPos.Tab() ) || pViewData->GetSfxDocShell()->IsReadOnly() ;
[ # # ][ # # ]
[ # # ]
378 : : // unlock internal layer (if not protected), will be relocked in ScDrawView::MarkListHasChanged()
379 [ # # ][ # # ]: 0 : pView->LockInternalLayer( bProtectDoc && bProtectAttr );
[ # # ]
380 : : }
381 : : }
382 : :
383 : 0 : sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell )
384 : : {
385 : 0 : sal_Bool bFound = false;
386 [ # # ]: 0 : do
387 : : {
388 : 0 : pDoc->GetCell( rPosX, rPosY, nTab, rpCell );
389 [ # # ][ # # ]: 0 : if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE )
[ # # ]
390 : : {
391 [ # # ]: 0 : if ( rPosX <= 0 )
392 : 0 : return false; // alles leer bis links
393 : : else
394 : 0 : --rPosX; // weitersuchen
395 : : }
396 [ # # ]: 0 : else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
397 : 0 : bFound = sal_True;
398 [ # # # # ]: 0 : else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
[ # # ]
399 [ # # ]: 0 : static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
400 : 0 : bFound = sal_True;
401 : : else
402 : 0 : return false; // andere Zelle
403 : : }
404 : 0 : while ( !bFound );
405 : :
406 : 0 : return bFound;
407 : : }
408 : :
409 : : // ---------------------------------------------------------------------------
410 : : // WB_DIALOGCONTROL noetig fuer UNO-Controls
411 : 229 : ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos )
412 : : : Window( pParent, WB_CLIPCHILDREN | WB_DIALOGCONTROL ),
413 : : DropTargetHelper( this ),
414 : : DragSourceHelper( this ),
415 : : mpOOCursors( NULL ),
416 : : mpOOSelection( NULL ),
417 : : mpOOSelectionBorder( NULL ),
418 : : mpOOAutoFill( NULL ),
419 : : mpOODragRect( NULL ),
420 : : mpOOHeader( NULL ),
421 : : mpOOShrink( NULL ),
422 : : mpAutoFillRect(static_cast<Rectangle*>(NULL)),
423 : : pViewData( pData ),
424 : : eWhich( eWhichPos ),
425 : : pNoteMarker( NULL ),
426 : : pFilterBox( NULL ),
427 : : pFilterFloat( NULL ),
428 : : mpAutoFilterPopup(NULL),
429 : : mpDPFieldPopup(NULL),
430 : : mpFilterButton(NULL),
431 : : nCursorHideCount( 0 ),
432 : : nButtonDown( 0 ),
433 : : nMouseStatus( SC_GM_NONE ),
434 : : nNestedButtonState( SC_NESTEDBUTTON_NONE ),
435 : : nPagebreakMouse( SC_PD_NONE ),
436 : : nPageScript( 0 ),
437 : : nDragStartX( -1 ),
438 : : nDragStartY( -1 ),
439 : : nDragEndX( -1 ),
440 : : nDragEndY( -1 ),
441 : : meDragInsertMode( INS_NONE ),
442 : : nCurrentPointer( 0 ),
443 : : aComboButton( this ),
444 : : aCurMousePos( 0,0 ),
445 : : nPaintCount( 0 ),
446 : : bEEMouse( false ),
447 : : bDPMouse( false ),
448 : : bRFMouse( false ),
449 : : bRFSize( false ),
450 : : bPagebreakDrawn( false ),
451 : : bDragRect( false ),
452 : : bIsInScroll( false ),
453 : : bIsInPaint( false ),
454 : : bNeedsRepaint( false ),
455 : : bAutoMarkVisible( false ),
456 [ + - ][ + - ]: 229 : bListValButton( false )
[ + - ][ + - ]
[ + - ]
457 : : {
458 [ - - + - : 229 : switch(eWhich)
- ]
459 : : {
460 : : case SC_SPLIT_TOPLEFT:
461 : 0 : eHWhich = SC_SPLIT_LEFT;
462 : 0 : eVWhich = SC_SPLIT_TOP;
463 : 0 : break;
464 : : case SC_SPLIT_TOPRIGHT:
465 : 0 : eHWhich = SC_SPLIT_RIGHT;
466 : 0 : eVWhich = SC_SPLIT_TOP;
467 : 0 : break;
468 : : case SC_SPLIT_BOTTOMLEFT:
469 : 229 : eHWhich = SC_SPLIT_LEFT;
470 : 229 : eVWhich = SC_SPLIT_BOTTOM;
471 : 229 : break;
472 : : case SC_SPLIT_BOTTOMRIGHT:
473 : 0 : eHWhich = SC_SPLIT_RIGHT;
474 : 0 : eVWhich = SC_SPLIT_BOTTOM;
475 : 0 : break;
476 : : default:
477 : : OSL_FAIL("GridWindow: falsche Position");
478 : : }
479 : :
480 [ + - ]: 229 : SetBackground();
481 : :
482 [ + - ][ + - ]: 229 : SetMapMode(pViewData->GetLogicMode(eWhich));
483 [ + - ]: 229 : EnableChildTransparentMode();
484 [ + - ]: 229 : SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
485 : :
486 [ + - ]: 229 : SetHelpId( HID_SC_WIN_GRIDWIN );
487 [ + - ]: 229 : SetUniqueId( HID_SC_WIN_GRIDWIN );
488 : :
489 [ + - ][ + - ]: 229 : SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
[ + - ]
490 [ + - ]: 229 : EnableRTL( false );
491 : 229 : }
492 : :
493 [ + - ][ + - ]: 225 : ScGridWindow::~ScGridWindow()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
494 : : {
495 : : // #114409#
496 [ + - ]: 225 : ImpDestroyOverlayObjects();
497 : :
498 [ - + ][ # # ]: 225 : delete pFilterBox;
499 [ - + ][ # # ]: 225 : delete pFilterFloat;
500 [ - + ][ # # ]: 225 : delete pNoteMarker;
501 [ - + ]: 450 : }
502 : :
503 : 0 : void ScGridWindow::Resize( const Size& )
504 : : {
505 : : // gar nix
506 : 0 : }
507 : :
508 : 1317 : void ScGridWindow::ClickExtern()
509 : : {
510 : : do
511 : : {
512 : : // #i81298# don't delete the filter box when called from its select handler
513 : : // (possible through row header size update)
514 : : // #i84277# when initializing the filter box, a Basic error can deactivate the view
515 [ - + ][ # # ]: 1317 : if ( pFilterBox && ( pFilterBox->IsInSelect() || pFilterBox->IsInInit() ) )
[ # # ][ - + ]
516 : : {
517 : 0 : break;
518 : : }
519 : :
520 [ - + ]: 1317 : DELETEZ(pFilterBox);
521 [ - + ]: 1317 : DELETEZ(pFilterFloat);
522 : : }
523 : : while (false);
524 : :
525 [ - + ]: 1317 : if (mpDPFieldPopup)
526 : : {
527 : 0 : mpDPFieldPopup->close(false);
528 : 0 : mpDPFieldPopup.reset();
529 : : }
530 : 1317 : }
531 : :
532 : 0 : IMPL_LINK_NOARG(ScGridWindow, PopupModeEndHdl)
533 : : {
534 [ # # ]: 0 : if (pFilterBox)
535 : 0 : pFilterBox->SetCancelled(); // nicht mehr auswaehlen
536 : 0 : GrabFocus();
537 : 0 : return 0;
538 : : }
539 : :
540 : 0 : IMPL_LINK( ScGridWindow, PopupSpellingHdl, SpellCallbackInfo*, pInfo )
541 : : {
542 [ # # ]: 0 : if( pInfo->nCommand == SPELLCMD_STARTSPELLDLG )
543 : 0 : pViewData->GetDispatcher().Execute( SID_SPELL_DIALOG, SFX_CALLMODE_ASYNCHRON );
544 : 0 : return 0;
545 : : }
546 : :
547 : 0 : void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSelection, const String& rStr )
548 : : {
549 : : //! gridwin2 ?
550 : :
551 : 0 : ScDocument* pDoc = pViewData->GetDocument();
552 : 0 : SCTAB nTab = pViewData->GetTabNo();
553 : 0 : ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
554 [ # # ][ # # ]: 0 : if ( pDPObj && nCol > 0 )
555 : : {
556 : : // look for the dimension header left of the drop-down arrow
557 : 0 : sal_uInt16 nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
558 [ # # ]: 0 : long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient );
559 [ # # ][ # # ]: 0 : if ( nField >= 0 && nOrient == sheet::DataPilotFieldOrientation_PAGE )
560 : : {
561 [ # # ]: 0 : ScDPSaveData aSaveData( *pDPObj->GetSaveData() );
562 : :
563 : : bool bIsDataLayout;
564 [ # # ]: 0 : OUString aDimName = pDPObj->GetDimName( nField, bIsDataLayout );
565 [ # # ]: 0 : if ( !bIsDataLayout )
566 : : {
567 [ # # ]: 0 : ScDPSaveDimension* pDim = aSaveData.GetDimensionByName(aDimName);
568 : :
569 [ # # ]: 0 : if ( bHasSelection )
570 : : {
571 [ # # ]: 0 : const ::rtl::OUString aName = rStr;
572 [ # # ]: 0 : pDim->SetCurrentPage( &aName );
573 : : }
574 : : else
575 [ # # ]: 0 : pDim->SetCurrentPage( NULL );
576 : :
577 [ # # ]: 0 : ScDPObject aNewObj( *pDPObj );
578 [ # # ]: 0 : aNewObj.SetSaveData( aSaveData );
579 : 0 : ScDBDocFunc aFunc( *pViewData->GetDocShell() );
580 [ # # ]: 0 : aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, false );
581 [ # # ][ # # ]: 0 : pViewData->GetView()->CursorPosChanged(); // shells may be switched
582 [ # # ]: 0 : }
583 : : }
584 : : }
585 : 0 : }
586 : :
587 : : namespace {
588 : :
589 : 0 : struct AutoFilterData : public ScCheckListMenuWindow::ExtendedData
590 : : {
591 : : ScAddress maPos;
592 : : ScDBData* mpData;
593 : : };
594 : :
595 [ # # ]: 0 : class AutoFilterAction : public ScMenuFloatingWindow::Action
596 : : {
597 : : ScGridWindow* mpWindow;
598 : : ScGridWindow::AutoFilterMode meMode;
599 : : public:
600 : 0 : AutoFilterAction(ScGridWindow* p, ScGridWindow::AutoFilterMode eMode) :
601 : 0 : mpWindow(p), meMode(eMode) {}
602 : 0 : virtual void execute()
603 : : {
604 : 0 : mpWindow->UpdateAutoFilterFromMenu(meMode);
605 : 0 : }
606 : : };
607 : :
608 [ # # ]: 0 : class AutoFilterPopupEndAction : public ScMenuFloatingWindow::Action
609 : : {
610 : : ScGridWindow* mpWindow;
611 : : ScAddress maPos;
612 : : public:
613 : 0 : AutoFilterPopupEndAction(ScGridWindow* p, const ScAddress& rPos) :
614 : 0 : mpWindow(p), maPos(rPos) {}
615 : 0 : virtual void execute()
616 : : {
617 : 0 : mpWindow->RefreshAutoFilterButton(maPos);
618 : 0 : }
619 : : };
620 : :
621 : : class AddItemToEntry : public std::unary_function<rtl::OUString, void>
622 : : {
623 : : ScQueryEntry::QueryItemsType& mrItems;
624 : : public:
625 : 0 : AddItemToEntry(ScQueryEntry::QueryItemsType& rItems) : mrItems(rItems) {}
626 : 0 : void operator() (const rtl::OUString& rSelected)
627 : : {
628 : 0 : ScQueryEntry::Item aNew;
629 : 0 : aNew.maString = rSelected;
630 : 0 : aNew.meType = ScQueryEntry::ByString;
631 : 0 : aNew.mfVal = 0.0;
632 [ # # ][ # # ]: 0 : mrItems.push_back(aNew);
633 : 0 : }
634 : : };
635 : :
636 : : class AddSelectedItemString : public std::unary_function<ScQueryEntry::Item, void>
637 : : {
638 : : boost::unordered_set<rtl::OUString, rtl::OUStringHash>& mrSet;
639 : : public:
640 : 0 : AddSelectedItemString(boost::unordered_set<rtl::OUString, rtl::OUStringHash>& r) :
641 : 0 : mrSet(r) {}
642 : :
643 : 0 : void operator() (const ScQueryEntry::Item& rItem)
644 : : {
645 : 0 : mrSet.insert(rItem.maString);
646 : 0 : }
647 : : };
648 : :
649 : : }
650 : :
651 : 0 : void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
652 : : {
653 : 0 : SCTAB nTab = pViewData->GetTabNo();
654 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
655 : :
656 [ # # ][ # # ]: 0 : mpAutoFilterPopup.reset(new ScCheckListMenuWindow(this, pDoc));
[ # # ]
657 [ # # ][ # # ]: 0 : mpAutoFilterPopup->setOKAction(new AutoFilterAction(this, Normal));
658 : : mpAutoFilterPopup->setPopupEndAction(
659 [ # # ][ # # ]: 0 : new AutoFilterPopupEndAction(this, ScAddress(nCol, nRow, nTab)));
660 [ # # ]: 0 : std::auto_ptr<AutoFilterData> pData(new AutoFilterData);
661 : 0 : pData->maPos = ScAddress(nCol, nRow, nTab);
662 : :
663 [ # # ]: 0 : Point aPos = pViewData->GetScrPos(nCol, nRow, eWhich);
664 : 0 : long nSizeX = 0;
665 : 0 : long nSizeY = 0;
666 [ # # ]: 0 : pViewData->GetMergeSizePixel(nCol, nRow, nSizeX, nSizeY);
667 [ # # ][ # # ]: 0 : Rectangle aCellRect(OutputToScreenPixel(aPos), Size(nSizeX, nSizeY));
668 : :
669 [ # # ]: 0 : ScDBData* pDBData = pDoc->GetDBAtCursor(nCol, nRow, nTab);
670 [ # # ]: 0 : if (!pDBData)
671 : 0 : return;
672 : :
673 : 0 : pData->mpData = pDBData;
674 [ # # ]: 0 : mpAutoFilterPopup->setExtendedData(pData.release());
675 : :
676 [ # # ]: 0 : ScQueryParam aParam;
677 [ # # ]: 0 : pDBData->GetQueryParam(aParam);
678 [ # # ]: 0 : ScQueryEntry* pEntry = aParam.FindEntryByField(nCol, false);
679 [ # # ]: 0 : boost::unordered_set<rtl::OUString, rtl::OUStringHash> aSelected;
680 [ # # ][ # # ]: 0 : if (pEntry && pEntry->bDoQuery)
681 : : {
682 [ # # ]: 0 : if (pEntry->eOp == SC_EQUAL)
683 : : {
684 [ # # ]: 0 : ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
685 [ # # ]: 0 : std::for_each(rItems.begin(), rItems.end(), AddSelectedItemString(aSelected));
686 : : }
687 : : }
688 : :
689 : : // Populate the check box list.
690 : 0 : bool bHasDates = false;
691 [ # # ]: 0 : std::vector<ScTypedStrData> aStrings;
692 [ # # ]: 0 : pDoc->GetFilterEntries(nCol, nRow, nTab, true, aStrings, bHasDates);
693 : :
694 [ # # ]: 0 : mpAutoFilterPopup->setMemberSize(aStrings.size());
695 [ # # ][ # # ]: 0 : std::vector<ScTypedStrData>::const_iterator it = aStrings.begin(), itEnd = aStrings.end();
696 [ # # ][ # # ]: 0 : for (; it != itEnd; ++it)
697 : : {
698 [ # # ]: 0 : const rtl::OUString& aVal = it->GetString();
699 : 0 : bool bSelected = true;
700 [ # # ]: 0 : if (!aSelected.empty())
701 [ # # ]: 0 : bSelected = aSelected.count(aVal) > 0;
702 [ # # ]: 0 : mpAutoFilterPopup->addMember(aVal, bSelected);
703 : : }
704 [ # # ]: 0 : mpAutoFilterPopup->initMembers();
705 : :
706 : : // Populate the menu.
707 : 0 : mpAutoFilterPopup->addMenuItem(
708 [ # # ][ # # ]: 0 : ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_ASC).GetString(),
709 [ # # ]: 0 : true, new AutoFilterAction(this, SortAscending));
[ # # # # ]
710 : 0 : mpAutoFilterPopup->addMenuItem(
711 [ # # ][ # # ]: 0 : ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_DESC).GetString(),
712 [ # # ]: 0 : true, new AutoFilterAction(this, SortDescending));
[ # # # # ]
713 [ # # ]: 0 : mpAutoFilterPopup->addSeparator();
714 : 0 : mpAutoFilterPopup->addMenuItem(
715 [ # # ][ # # ]: 0 : SC_RESSTR(SCSTR_TOP10FILTER), true, new AutoFilterAction(this, Top10));
[ # # # # ]
716 : 0 : mpAutoFilterPopup->addMenuItem(
717 [ # # ]: 0 : SC_RESSTR(SCSTR_FILTER_EMPTY), true, new AutoFilterAction(this, Empty));
[ # # # # ]
[ # # ]
718 : 0 : mpAutoFilterPopup->addMenuItem(
719 [ # # ]: 0 : SC_RESSTR(SCSTR_FILTER_NOTEMPTY), true, new AutoFilterAction(this, NonEmpty));
[ # # # # ]
[ # # ]
720 [ # # ]: 0 : mpAutoFilterPopup->addSeparator();
721 : 0 : mpAutoFilterPopup->addMenuItem(
722 [ # # ][ # # ]: 0 : SC_RESSTR(SCSTR_STDFILTER), true, new AutoFilterAction(this, Custom));
[ # # # # ]
723 : :
724 [ # # ]: 0 : ScCheckListMenuWindow::Config aConfig;
725 : 0 : aConfig.mbAllowEmptySet = false;
726 [ # # ]: 0 : mpAutoFilterPopup->setConfig(aConfig);
727 [ # # ][ # # ]: 0 : mpAutoFilterPopup->launch(aCellRect);
[ # # ][ # # ]
728 : : }
729 : :
730 : 0 : void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos)
731 : : {
732 [ # # ]: 0 : if (mpFilterButton)
733 : : {
734 : 0 : bool bFilterActive = IsAutoFilterActive(rPos.Col(), rPos.Row(), rPos.Tab());
735 : 0 : mpFilterButton->setHasHiddenMember(bFilterActive);
736 : 0 : mpFilterButton->setPopupPressed(false);
737 : 0 : mpFilterButton->draw();
738 : : }
739 : 0 : }
740 : :
741 : 0 : void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
742 : : {
743 : : const AutoFilterData* pData =
744 [ # # ]: 0 : static_cast<const AutoFilterData*>(mpAutoFilterPopup->getExtendedData());
745 : :
746 [ # # ]: 0 : if (!pData)
747 : : return;
748 : :
749 : 0 : const ScAddress& rPos = pData->maPos;
750 : 0 : ScDBData* pDBData = pData->mpData;
751 [ # # ]: 0 : if (!pDBData)
752 : : return;
753 : :
754 [ # # ]: 0 : switch (eMode)
755 : : {
756 : : case SortAscending:
757 : : case SortDescending:
758 : : {
759 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
760 : 0 : SCTAB nTab = pViewData->GetTabNo();
761 : 0 : SCCOL nCol = rPos.Col();
762 [ # # ]: 0 : ScSortParam aSortParam;
763 [ # # ]: 0 : pDBData->GetSortParam(aSortParam);
764 [ # # ][ # # ]: 0 : if (nCol < aSortParam.nCol1 || nCol > aSortParam.nCol2)
765 : : // out of bound
766 : : return;
767 : :
768 : : bool bHasHeader = pDoc->HasColHeader(
769 [ # # ]: 0 : aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab);
770 : :
771 : 0 : aSortParam.bHasHeader = bHasHeader;
772 : 0 : aSortParam.bByRow = true;
773 : 0 : aSortParam.bCaseSens = false;
774 : 0 : aSortParam.bNaturalSort = false;
775 : 0 : aSortParam.bIncludePattern = true;
776 : 0 : aSortParam.bInplace = true;
777 : 0 : aSortParam.maKeyState[0].bDoSort = true;
778 : 0 : aSortParam.maKeyState[0].nField = nCol;
779 : 0 : aSortParam.maKeyState[0].bAscending = (eMode == SortAscending);
780 : :
781 [ # # ]: 0 : for (size_t i = 1; i < aSortParam.GetSortKeyCount(); ++i)
782 : 0 : aSortParam.maKeyState[i].bDoSort = false;
783 : :
784 [ # # ]: 0 : pViewData->GetViewShell()->UISort(aSortParam);
785 [ # # ]: 0 : return;
786 : : }
787 : : default:
788 : : ;
789 : : }
790 : :
791 [ # # ]: 0 : if (eMode == Custom)
792 : : {
793 : 0 : ScRange aRange;
794 [ # # ]: 0 : pDBData->GetArea(aRange);
795 [ # # ]: 0 : pViewData->GetView()->MarkRange(aRange);
796 [ # # ]: 0 : pViewData->GetView()->SetCursor(rPos.Col(), rPos.Row());
797 [ # # ][ # # ]: 0 : pViewData->GetDispatcher().Execute(SID_FILTER, SFX_CALLMODE_SLOT|SFX_CALLMODE_RECORD);
798 : : return;
799 : : }
800 : :
801 [ # # ]: 0 : ScQueryParam aParam;
802 [ # # ]: 0 : pDBData->GetQueryParam(aParam);
803 : :
804 [ # # ][ # # ]: 0 : if (eMode == Normal && mpAutoFilterPopup->isAllSelected())
[ # # ][ # # ]
805 : : {
806 : : // Remove this entry.
807 [ # # ]: 0 : aParam.RemoveEntryByField(rPos.Col());
808 : : }
809 : : else
810 : : {
811 : : // Try to use the existing entry for the column (if one exists).
812 [ # # ]: 0 : ScQueryEntry* pEntry = aParam.FindEntryByField(rPos.Col(), true);
813 : :
814 [ # # ]: 0 : if (!pEntry)
815 : : // Something went terribly wrong!
816 : : return;
817 : :
818 : 0 : pEntry->bDoQuery = true;
819 : 0 : pEntry->nField = rPos.Col();
820 : 0 : pEntry->eConnect = SC_AND;
821 : :
822 [ # # # # : 0 : switch (eMode)
# ]
823 : : {
824 : : case Normal:
825 : : {
826 : 0 : pEntry->eOp = SC_EQUAL;
827 : :
828 [ # # ]: 0 : ScCheckListMenuWindow::ResultType aResult;
829 [ # # ]: 0 : mpAutoFilterPopup->getResult(aResult);
830 [ # # ]: 0 : std::vector<rtl::OUString> aSelected;
831 [ # # ][ # # ]: 0 : ScCheckListMenuWindow::ResultType::const_iterator itr = aResult.begin(), itrEnd = aResult.end();
832 [ # # ]: 0 : for (; itr != itrEnd; ++itr)
833 : : {
834 [ # # ][ # # ]: 0 : if (itr->second)
835 [ # # ][ # # ]: 0 : aSelected.push_back(itr->first);
836 : : }
837 : :
838 [ # # ]: 0 : ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
839 : 0 : rItems.clear();
840 [ # # ][ # # ]: 0 : std::for_each(aSelected.begin(), aSelected.end(), AddItemToEntry(rItems));
841 : : }
842 : 0 : break;
843 : : case Top10:
844 : 0 : pEntry->eOp = SC_TOPVAL;
845 [ # # ]: 0 : pEntry->GetQueryItem().meType = ScQueryEntry::ByString;
846 [ # # ][ # # ]: 0 : pEntry->GetQueryItem().maString = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10"));
847 : 0 : break;
848 : : case Empty:
849 [ # # ]: 0 : pEntry->SetQueryByEmpty();
850 : 0 : break;
851 : : case NonEmpty:
852 [ # # ]: 0 : pEntry->SetQueryByNonEmpty();
853 : 0 : break;
854 : : default:
855 : : // We don't know how to handle this!
856 : : return;
857 : : }
858 : : }
859 : :
860 [ # # ]: 0 : pViewData->GetView()->Query(aParam, NULL, true);
861 [ # # ][ # # ]: 0 : pDBData->SetQueryParam(aParam);
[ # # ]
862 : : }
863 : :
864 : 0 : void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
865 : : {
866 : : //! merge position/size handling with DoAutoFilterMenue
867 : :
868 [ # # ][ # # ]: 0 : delete pFilterBox;
869 [ # # ][ # # ]: 0 : delete pFilterFloat;
870 : :
871 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
872 : 0 : SCTAB nTab = pViewData->GetTabNo();
873 [ # # ]: 0 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
874 : :
875 : 0 : long nSizeX = 0;
876 : 0 : long nSizeY = 0;
877 : 0 : long nHeight = 0;
878 [ # # ]: 0 : pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
879 [ # # ]: 0 : Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
880 [ # # ]: 0 : if ( bLayoutRTL )
881 : 0 : aPos.X() -= nSizeX;
882 : :
883 [ # # ][ # # ]: 0 : Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
884 : :
885 : 0 : aPos.X() -= 1;
886 : 0 : aPos.Y() += nSizeY - 1;
887 : :
888 [ # # ][ # # ]: 0 : pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // not resizable etc.
889 [ # # ]: 0 : pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) );
890 [ # # ][ # # ]: 0 : pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_PAGEFIELD );
891 [ # # ]: 0 : if ( bLayoutRTL )
892 [ # # ]: 0 : pFilterBox->EnableMirroring();
893 : :
894 : 0 : nSizeX += 1;
895 : :
896 : : {
897 [ # # ][ # # ]: 0 : Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() );
898 [ # # ][ # # ]: 0 : MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL );
[ # # ][ # # ]
899 : :
900 [ # # ]: 0 : nHeight = GetTextHeight();
901 : 0 : nHeight *= SC_FILTERLISTBOX_LINES;
902 : :
903 [ # # ]: 0 : SetMapMode( aOldMode );
904 [ # # ][ # # ]: 0 : SetFont( aOldFont );
[ # # ]
905 : : }
906 : :
907 : : // SetSize comes later
908 : :
909 [ # # ]: 0 : std::vector<rtl::OUString> aStrings;
910 : :
911 : : // get list box entries and selection
912 : 0 : sal_Bool bHasCurrentPage = false;
913 [ # # ]: 0 : String aCurrentPage;
914 [ # # ]: 0 : ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
915 [ # # ][ # # ]: 0 : if ( pDPObj && nCol > 0 )
916 : : {
917 : : // look for the dimension header left of the drop-down arrow
918 : 0 : sal_uInt16 nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
919 [ # # ]: 0 : long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient );
920 [ # # ][ # # ]: 0 : if ( nField >= 0 && nOrient == sheet::DataPilotFieldOrientation_PAGE )
921 : : {
922 [ # # ]: 0 : pDPObj->FillPageList( aStrings, nField );
923 : :
924 : : // get current page from SaveData
925 : :
926 : 0 : ScDPSaveData* pSaveData = pDPObj->GetSaveData();
927 : : bool bIsDataLayout;
928 [ # # ]: 0 : OUString aDimName = pDPObj->GetDimName( nField, bIsDataLayout );
929 [ # # ][ # # ]: 0 : if ( pSaveData && !bIsDataLayout )
930 : : {
931 [ # # ]: 0 : ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(aDimName);
932 [ # # ][ # # ]: 0 : if ( pDim && pDim->HasCurrentPage() )
[ # # ][ # # ]
933 : : {
934 [ # # ][ # # ]: 0 : aCurrentPage = pDim->GetCurrentPage();
935 : 0 : bHasCurrentPage = sal_True;
936 : : }
937 : 0 : }
938 : : }
939 : : }
940 : :
941 : : // include all entry widths for the size of the drop-down
942 : 0 : long nMaxText = 0;
943 : : {
944 [ # # ][ # # ]: 0 : std::vector<rtl::OUString>::const_iterator it = aStrings.begin(), itEnd = aStrings.end();
945 [ # # ][ # # ]: 0 : for (; it != itEnd; ++it)
946 : : {
947 [ # # ][ # # ]: 0 : long nTextWidth = pFilterBox->GetTextWidth(*it);
[ # # ]
948 [ # # ]: 0 : if ( nTextWidth > nMaxText )
949 : 0 : nMaxText = nTextWidth;
950 : : }
951 : : }
952 : :
953 : : // add scrollbar width if needed (string entries are counted here)
954 : : // (scrollbar is shown if the box is exactly full?)
955 [ # # ]: 0 : if (aStrings.size() >= SC_FILTERLISTBOX_LINES)
956 : 0 : nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize();
957 : :
958 : 0 : nMaxText += 4; // for borders
959 : :
960 [ # # ]: 0 : if ( nMaxText > nSizeX )
961 : 0 : nSizeX = nMaxText; // just modify width - starting position is unchanged
962 : :
963 : : // adjust position and size to window
964 : :
965 [ # # ]: 0 : Size aParentSize = GetParent()->GetOutputSizePixel();
966 : 0 : Size aSize( nSizeX, nHeight );
967 : :
968 [ # # ]: 0 : if ( aSize.Height() > aParentSize.Height() )
969 : 0 : aSize.Height() = aParentSize.Height();
970 [ # # ]: 0 : if ( aPos.Y() + aSize.Height() > aParentSize.Height() )
971 : 0 : aPos.Y() = aParentSize.Height() - aSize.Height();
972 : :
973 [ # # ]: 0 : pFilterBox->SetSizePixel( aSize );
974 [ # # ]: 0 : pFilterBox->Show(); // Show must be called before SetUpdateMode
975 [ # # ]: 0 : pFilterBox->SetUpdateMode(false);
976 : :
977 [ # # ]: 0 : pFilterFloat->SetOutputSizePixel( aSize );
978 [ # # ]: 0 : pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS);
979 : :
980 : : // fill the list box
981 : 0 : bool bWait = aStrings.size() > 100;
982 : :
983 [ # # ]: 0 : if (bWait)
984 [ # # ]: 0 : EnterWait();
985 : :
986 : : {
987 [ # # ][ # # ]: 0 : std::vector<rtl::OUString>::const_iterator it = aStrings.begin(), itEnd = aStrings.end();
988 [ # # ][ # # ]: 0 : for (; it != itEnd; ++it)
989 [ # # ][ # # ]: 0 : pFilterBox->InsertEntry(*it);
[ # # ]
990 : : }
991 : :
992 [ # # ]: 0 : pFilterBox->SetSeparatorPos( 0 );
993 : :
994 [ # # ]: 0 : if (bWait)
995 [ # # ]: 0 : LeaveWait();
996 : :
997 [ # # ]: 0 : pFilterBox->SetUpdateMode(true);
998 : :
999 : 0 : sal_uInt16 nSelPos = LISTBOX_ENTRY_NOTFOUND;
1000 [ # # ]: 0 : if (bHasCurrentPage)
1001 [ # # ]: 0 : nSelPos = pFilterBox->GetEntryPos( aCurrentPage );
1002 : :
1003 [ # # ]: 0 : if ( nSelPos == LISTBOX_ENTRY_NOTFOUND )
1004 : 0 : nSelPos = 0; // first entry
1005 : :
1006 [ # # ]: 0 : pFilterBox->GrabFocus();
1007 : :
1008 : : // call Select after GrabFocus, so the focus rectangle ends up in the right position
1009 [ # # ]: 0 : if ( nSelPos != LISTBOX_ENTRY_NOTFOUND )
1010 [ # # ]: 0 : pFilterBox->SelectEntryPos( nSelPos );
1011 : :
1012 [ # # ]: 0 : pFilterBox->EndInit();
1013 : :
1014 : 0 : nMouseStatus = SC_GM_FILTER;
1015 [ # # ][ # # ]: 0 : CaptureMouse();
1016 : 0 : }
1017 : :
1018 : 0 : void ScGridWindow::LaunchDPFieldMenu( SCCOL nCol, SCROW nRow )
1019 : : {
1020 : 0 : SCTAB nTab = pViewData->GetTabNo();
1021 [ # # ][ # # ]: 0 : ScDPObject* pDPObj = pViewData->GetDocument()->GetDPAtCursor(nCol, nRow, nTab);
1022 [ # # ]: 0 : if (!pDPObj)
1023 : 0 : return;
1024 : :
1025 : : // Get the geometry of the cell.
1026 [ # # ]: 0 : Point aScrPos = pViewData->GetScrPos(nCol, nRow, eWhich);
1027 : : long nSizeX, nSizeY;
1028 [ # # ]: 0 : pViewData->GetMergeSizePixel(nCol, nRow, nSizeX, nSizeY);
1029 : 0 : Size aScrSize(nSizeX-1, nSizeY-1);
1030 : :
1031 [ # # ][ # # ]: 0 : DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, ScAddress(nCol, nRow, nTab), pDPObj);
1032 : : }
1033 : :
1034 : 0 : void ScGridWindow::DoScenarioMenue( const ScRange& rScenRange )
1035 : : {
1036 [ # # ][ # # ]: 0 : delete pFilterBox;
1037 [ # # ][ # # ]: 0 : delete pFilterFloat;
1038 : :
1039 : 0 : SCCOL nCol = rScenRange.aEnd.Col(); // Zelle unterhalb des Buttons
1040 : 0 : SCROW nRow = rScenRange.aStart.Row();
1041 [ # # ]: 0 : if (nRow == 0)
1042 : : {
1043 : 0 : nRow = rScenRange.aEnd.Row() + 1; // Bereich ganz oben -> Button unterhalb
1044 [ # # ]: 0 : if (nRow>MAXROW) nRow = MAXROW;
1045 : : //! Texthoehe addieren (wenn sie an der View gespeichert ist...)
1046 : : }
1047 : :
1048 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
1049 : 0 : SCTAB nTab = pViewData->GetTabNo();
1050 [ # # ]: 0 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
1051 : :
1052 : 0 : long nSizeX = 0;
1053 : 0 : long nSizeY = 0;
1054 : 0 : long nHeight = 0;
1055 [ # # ]: 0 : pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
1056 [ # # ]: 0 : Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
1057 [ # # ]: 0 : if ( bLayoutRTL )
1058 : 0 : aPos.X() -= nSizeX;
1059 [ # # ][ # # ]: 0 : Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
1060 : 0 : aCellRect.Top() -= nSizeY;
1061 : 0 : aCellRect.Bottom() -= nSizeY - 1;
1062 : : // Die ListBox direkt unter der schwarzen Linie auf dem Zellgitter
1063 : : // (wenn die Linie verdeckt wird, sieht es komisch aus...)
1064 : :
1065 [ # # ][ # # ]: 0 : pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc.
1066 [ # # ]: 0 : pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) );
1067 [ # # ][ # # ]: 0 : pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_SCENARIO );
1068 [ # # ]: 0 : if ( bLayoutRTL )
1069 [ # # ]: 0 : pFilterBox->EnableMirroring();
1070 : :
1071 : 0 : nSizeX += 1;
1072 : :
1073 : : {
1074 [ # # ][ # # ]: 0 : Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() );
1075 [ # # ][ # # ]: 0 : MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL );
[ # # ][ # # ]
1076 : :
1077 [ # # ]: 0 : nHeight = GetTextHeight();
1078 : 0 : nHeight *= SC_FILTERLISTBOX_LINES;
1079 : :
1080 [ # # ]: 0 : SetMapMode( aOldMode );
1081 [ # # ][ # # ]: 0 : SetFont( aOldFont );
[ # # ]
1082 : : }
1083 : :
1084 : : // SetSize spaeter
1085 : :
1086 : : // ParentSize Abfrage fehlt
1087 : 0 : Size aSize( nSizeX, nHeight );
1088 [ # # ]: 0 : pFilterBox->SetSizePixel( aSize );
1089 [ # # ]: 0 : pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!!
1090 [ # # ]: 0 : pFilterBox->SetUpdateMode(false);
1091 : :
1092 : : // SetOutputSizePixel/StartPopupMode erst unten, wenn die Groesse feststeht
1093 : :
1094 : : // Listbox fuellen
1095 : :
1096 : 0 : long nMaxText = 0;
1097 : 0 : rtl::OUString aCurrent;
1098 : 0 : rtl::OUString aTabName;
1099 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
1100 : 0 : SCTAB nEntryCount = 0;
1101 [ # # ][ # # ]: 0 : for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
[ # # ][ # # ]
1102 : : {
1103 [ # # ][ # # ]: 0 : if (pDoc->HasScenarioRange( i, rScenRange ))
1104 [ # # ][ # # ]: 0 : if (pDoc->GetName( i, aTabName ))
1105 : : {
1106 [ # # ][ # # ]: 0 : pFilterBox->InsertEntry( aTabName );
[ # # ]
1107 [ # # ][ # # ]: 0 : if (pDoc->IsActiveScenario(i))
1108 : 0 : aCurrent = aTabName;
1109 [ # # ][ # # ]: 0 : long nTextWidth = pFilterBox->GetTextWidth( aTabName );
[ # # ]
1110 [ # # ]: 0 : if ( nTextWidth > nMaxText )
1111 : 0 : nMaxText = nTextWidth;
1112 : 0 : ++nEntryCount;
1113 : : }
1114 : : }
1115 [ # # ]: 0 : if (nEntryCount > SC_FILTERLISTBOX_LINES)
1116 : 0 : nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize();
1117 : 0 : nMaxText += 4; // fuer Rand
1118 [ # # ]: 0 : if ( nMaxText > 300 )
1119 : 0 : nMaxText = 300; // auch nicht uebertreiben (Pixel)
1120 : :
1121 [ # # ]: 0 : if (nMaxText > nSizeX) // Groesse auf benoetigte Groesse anpassen
1122 : : {
1123 : 0 : long nDiff = nMaxText - nSizeX;
1124 : 0 : aSize = Size( nMaxText, nHeight );
1125 [ # # ]: 0 : pFilterBox->SetSizePixel( aSize );
1126 [ # # ]: 0 : pFilterFloat->SetOutputSizePixel( aSize );
1127 : :
1128 [ # # ]: 0 : if ( !bLayoutRTL )
1129 : : {
1130 : : // also move popup position
1131 : 0 : long nNewX = aCellRect.Left() - nDiff;
1132 [ # # ]: 0 : if ( nNewX < 0 )
1133 : 0 : nNewX = 0;
1134 : 0 : aCellRect.Left() = nNewX;
1135 : : }
1136 : : }
1137 : :
1138 [ # # ]: 0 : pFilterFloat->SetOutputSizePixel( aSize );
1139 [ # # ]: 0 : pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS );
1140 : :
1141 [ # # ]: 0 : pFilterBox->SetUpdateMode(sal_True);
1142 [ # # ]: 0 : pFilterBox->GrabFocus();
1143 : :
1144 : 0 : sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
1145 [ # # ]: 0 : if (!aCurrent.isEmpty())
1146 : : {
1147 [ # # ][ # # ]: 0 : nPos = pFilterBox->GetEntryPos(String(aCurrent));
[ # # ]
1148 : : }
1149 [ # # ][ # # ]: 0 : if (LISTBOX_ENTRY_NOTFOUND == nPos && pFilterBox->GetEntryCount() > 0 )
[ # # ][ # # ]
1150 : 0 : nPos = 0;
1151 [ # # ]: 0 : if (LISTBOX_ENTRY_NOTFOUND != nPos )
1152 [ # # ]: 0 : pFilterBox->SelectEntryPos(nPos);
1153 : :
1154 [ # # ]: 0 : pFilterBox->EndInit();
1155 : :
1156 : : // Szenario-Auswahl kommt aus MouseButtonDown:
1157 : : // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown
1158 : :
1159 : 0 : nMouseStatus = SC_GM_FILTER;
1160 [ # # ]: 0 : CaptureMouse();
1161 : 0 : }
1162 : :
1163 : 0 : void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect )
1164 : : {
1165 [ # # ][ # # ]: 0 : delete pFilterBox;
1166 [ # # ][ # # ]: 0 : delete pFilterFloat;
1167 : :
1168 : : sal_uInt16 i;
1169 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
1170 : 0 : SCTAB nTab = pViewData->GetTabNo();
1171 [ # # ]: 0 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
1172 : :
1173 : 0 : long nSizeX = 0;
1174 : 0 : long nSizeY = 0;
1175 : 0 : long nHeight = 0;
1176 [ # # ]: 0 : pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
1177 [ # # ]: 0 : Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
1178 [ # # ]: 0 : if ( bLayoutRTL )
1179 : 0 : aPos.X() -= nSizeX;
1180 : :
1181 [ # # ][ # # ]: 0 : Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
1182 : :
1183 : 0 : aPos.X() -= 1;
1184 : 0 : aPos.Y() += nSizeY - 1;
1185 : :
1186 [ # # ][ # # ]: 0 : pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc.
1187 [ # # ]: 0 : pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) );
1188 : : pFilterBox = new ScFilterListBox(
1189 [ # # ][ # # ]: 0 : pFilterFloat, this, nCol, nRow, bDataSelect ? SC_FILTERBOX_DATASELECT : SC_FILTERBOX_FILTER );
[ # # ]
1190 [ # # ]: 0 : if ( bLayoutRTL )
1191 [ # # ]: 0 : pFilterBox->EnableMirroring();
1192 : :
1193 : 0 : nSizeX += 1;
1194 : :
1195 : : {
1196 [ # # ][ # # ]: 0 : Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() );
1197 [ # # ][ # # ]: 0 : MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL );
[ # # ][ # # ]
1198 : :
1199 [ # # ]: 0 : nHeight = GetTextHeight();
1200 : 0 : nHeight *= SC_FILTERLISTBOX_LINES;
1201 : :
1202 [ # # ]: 0 : SetMapMode( aOldMode );
1203 [ # # ][ # # ]: 0 : SetFont( aOldFont );
[ # # ]
1204 : : }
1205 : :
1206 : : // SetSize spaeter
1207 : :
1208 : 0 : bool bEmpty = false;
1209 [ # # ]: 0 : std::vector<ScTypedStrData> aStrings; // case sensitive
1210 [ # # ]: 0 : if ( bDataSelect ) // Auswahl-Liste
1211 : : {
1212 : : // Liste fuellen
1213 [ # # ]: 0 : pDoc->GetDataEntries(nCol, nRow, nTab, true, aStrings);
1214 [ # # ]: 0 : if (aStrings.empty())
1215 : 0 : bEmpty = true;
1216 : : }
1217 : : else // AutoFilter
1218 : : {
1219 : : //! wird der Titel ueberhaupt ausgewertet ???
1220 [ # # ]: 0 : String aString;
1221 [ # # ]: 0 : pDoc->GetString( nCol, nRow, nTab, aString );
1222 [ # # ]: 0 : pFilterBox->SetText( aString );
1223 : :
1224 : 0 : long nMaxText = 0;
1225 : :
1226 : : // default entries
1227 : : static const sal_uInt16 nDefIDs[] = { SCSTR_TOP10FILTER, SCSTR_STDFILTER, SCSTR_FILTER_EMPTY, SCSTR_FILTER_NOTEMPTY };
1228 : 0 : const size_t nDefCount = SAL_N_ELEMENTS(nDefIDs);
1229 [ # # ]: 0 : for (i=0; i<nDefCount; i++)
1230 : : {
1231 [ # # ][ # # ]: 0 : String aEntry( (ScResId) nDefIDs[i] );
1232 [ # # ]: 0 : pFilterBox->InsertEntry( aEntry );
1233 [ # # ]: 0 : long nTextWidth = pFilterBox->GetTextWidth( aEntry );
1234 [ # # ]: 0 : if ( nTextWidth > nMaxText )
1235 : 0 : nMaxText = nTextWidth;
1236 [ # # ]: 0 : }
1237 [ # # ]: 0 : pFilterBox->SetSeparatorPos( nDefCount - 1 );
1238 : :
1239 : : // get list entries
1240 : 0 : bool bHasDates = false;
1241 [ # # ]: 0 : pDoc->GetFilterEntries( nCol, nRow, nTab, true, aStrings, bHasDates);
1242 : 0 : pFilterBox->SetListHasDates(bHasDates);
1243 : :
1244 : : // check widths of numerical entries (string entries are not included)
1245 : : // so all numbers are completely visible
1246 [ # # ][ # # ]: 0 : std::vector<ScTypedStrData>::const_iterator it = aStrings.begin(), itEnd = aStrings.end();
1247 [ # # ][ # # ]: 0 : for (; it != itEnd; ++it)
1248 : : {
1249 [ # # ][ # # ]: 0 : if (!it->IsStrData()) // only numerical entries
1250 : : {
1251 [ # # ][ # # ]: 0 : long nTextWidth = pFilterBox->GetTextWidth(it->GetString());
[ # # ][ # # ]
1252 [ # # ]: 0 : if ( nTextWidth > nMaxText )
1253 : 0 : nMaxText = nTextWidth;
1254 : : }
1255 : : }
1256 : :
1257 : : // add scrollbar width if needed (string entries are counted here)
1258 : : // (scrollbar is shown if the box is exactly full?)
1259 [ # # ]: 0 : if (aStrings.size() + nDefCount >= SC_FILTERLISTBOX_LINES)
1260 : 0 : nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize();
1261 : :
1262 : 0 : nMaxText += 4; // for borders
1263 : :
1264 [ # # ]: 0 : if ( nMaxText > nSizeX )
1265 [ # # ]: 0 : nSizeX = nMaxText; // just modify width - starting position is unchanged
1266 : : }
1267 : :
1268 [ # # ]: 0 : if (!bEmpty)
1269 : : {
1270 : : // Position und Groesse an Fenster anpassen
1271 : : //! vorher Abfrage, ob die Eintraege hineinpassen (Breite)
1272 : :
1273 [ # # ]: 0 : Size aParentSize = GetParent()->GetOutputSizePixel();
1274 : 0 : Size aSize( nSizeX, nHeight );
1275 : :
1276 [ # # ]: 0 : if ( aSize.Height() > aParentSize.Height() )
1277 : 0 : aSize.Height() = aParentSize.Height();
1278 [ # # ]: 0 : if ( aPos.Y() + aSize.Height() > aParentSize.Height() )
1279 : 0 : aPos.Y() = aParentSize.Height() - aSize.Height();
1280 : :
1281 [ # # ]: 0 : pFilterBox->SetSizePixel( aSize );
1282 [ # # ]: 0 : pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!!
1283 [ # # ]: 0 : pFilterBox->SetUpdateMode(false);
1284 : :
1285 [ # # ]: 0 : pFilterFloat->SetOutputSizePixel( aSize );
1286 [ # # ]: 0 : pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS);
1287 : :
1288 : : // Listbox fuellen
1289 : 0 : bool bWait = aStrings.size() > 100;
1290 : :
1291 [ # # ]: 0 : if (bWait)
1292 [ # # ]: 0 : EnterWait();
1293 : :
1294 [ # # ][ # # ]: 0 : std::vector<ScTypedStrData>::const_iterator it = aStrings.begin(), itEnd = aStrings.end();
1295 [ # # ][ # # ]: 0 : for (; it != itEnd; ++it)
1296 [ # # ][ # # ]: 0 : pFilterBox->InsertEntry(it->GetString());
[ # # ][ # # ]
1297 : :
1298 [ # # ]: 0 : if (bWait)
1299 [ # # ]: 0 : LeaveWait();
1300 : :
1301 [ # # ]: 0 : pFilterBox->SetUpdateMode(true);
1302 : : }
1303 : :
1304 : 0 : sal_uInt16 nSelPos = LISTBOX_ENTRY_NOTFOUND;
1305 : :
1306 [ # # ]: 0 : if (!bDataSelect) // AutoFilter: aktiven Eintrag selektieren
1307 : : {
1308 [ # # ]: 0 : ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
1309 [ # # ]: 0 : if (pDBData)
1310 : : {
1311 [ # # ]: 0 : ScQueryParam aParam;
1312 [ # # ]: 0 : pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben
1313 : :
1314 : 0 : sal_Bool bValid = sal_True;
1315 [ # # ]: 0 : SCSIZE nCount = aParam.GetEntryCount();
1316 [ # # ][ # # ]: 0 : for (SCSIZE j = 0; j < nCount && bValid; ++j) // bisherige Filter-Einstellungen
[ # # ]
1317 [ # # ][ # # ]: 0 : if (aParam.GetEntry(j).bDoQuery)
1318 : : {
1319 : : //! Abfrage mit DrawButtons zusammenfassen!
1320 : :
1321 [ # # ]: 0 : ScQueryEntry& rEntry = aParam.GetEntry(j);
1322 [ # # ]: 0 : if (j>0)
1323 [ # # ]: 0 : if (rEntry.eConnect != SC_AND)
1324 : 0 : bValid = false;
1325 [ # # ]: 0 : if (rEntry.nField == nCol)
1326 : : {
1327 [ # # ]: 0 : const rtl::OUString& rQueryStr = rEntry.GetQueryItem().maString;
1328 [ # # ]: 0 : if (rEntry.eOp == SC_EQUAL)
1329 : : {
1330 [ # # ]: 0 : if (!rQueryStr.isEmpty())
1331 : : {
1332 [ # # ][ # # ]: 0 : nSelPos = pFilterBox->GetEntryPos(rQueryStr);
[ # # ]
1333 : : }
1334 : : }
1335 [ # # ][ # # ]: 0 : else if ( rEntry.eOp == SC_TOPVAL && rQueryStr == "10" )
[ # # ]
1336 : 0 : nSelPos = SC_AUTOFILTER_TOP10;
1337 : : else
1338 : 0 : nSelPos = SC_AUTOFILTER_CUSTOM;
1339 : : }
1340 : : }
1341 : :
1342 [ # # ]: 0 : if (!bValid)
1343 [ # # ]: 0 : nSelPos = SC_AUTOFILTER_CUSTOM;
1344 : : }
1345 : : }
1346 : : else
1347 : : {
1348 : :
1349 : : sal_uLong nIndex = ((SfxUInt32Item*)pDoc->GetAttr(
1350 [ # # ]: 0 : nCol, nRow, nTab, ATTR_VALIDDATA ))->GetValue();
1351 [ # # ]: 0 : if ( nIndex )
1352 : : {
1353 [ # # ]: 0 : const ScValidationData* pData = pDoc->GetValidationEntry( nIndex );
1354 [ # # ]: 0 : if (pData)
1355 : : {
1356 : 0 : ScTypedStrData* pNew = NULL;
1357 : 0 : rtl::OUString aDocStr;
1358 [ # # ]: 0 : pDoc->GetString( nCol, nRow, nTab, aDocStr );
1359 [ # # ][ # # ]: 0 : if ( pDoc->HasValueData( nCol, nRow, nTab ) )
1360 : : {
1361 [ # # ]: 0 : double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nTab));
1362 [ # # ][ # # ]: 0 : pNew = new ScTypedStrData(aDocStr, fVal, ScTypedStrData::Value);
1363 : : }
1364 : : else
1365 [ # # ][ # # ]: 0 : pNew = new ScTypedStrData(aDocStr, 0.0, ScTypedStrData::Standard);
1366 : :
1367 : 0 : bool bSortList = ( pData->GetListType() == ValidListType::SORTEDASCENDING);
1368 [ # # ]: 0 : if ( bSortList )
1369 : : {
1370 [ # # ][ # # ]: 0 : std::vector<ScTypedStrData>::const_iterator itBeg = aStrings.begin(), itEnd = aStrings.end();
1371 : : std::vector<ScTypedStrData>::const_iterator it =
1372 [ # # ][ # # ]: 0 : std::find_if(itBeg, itEnd, FindTypedStrData(*pNew, true));
1373 [ # # ][ # # ]: 0 : if (it != itEnd)
1374 : : // Found!
1375 [ # # ]: 0 : nSelPos = std::distance(itBeg, it);
1376 : : }
1377 : : else
1378 : : {
1379 : : ScTypedStrData::EqualCaseSensitive aHdl;
1380 [ # # ][ # # ]: 0 : std::vector<ScTypedStrData>::const_iterator itBeg = aStrings.begin(), itEnd = aStrings.end();
1381 : 0 : std::vector<ScTypedStrData>::const_iterator it = itBeg;
1382 [ # # ][ # # ]: 0 : for (; it != itEnd && LISTBOX_ENTRY_NOTFOUND == nSelPos; ++it)
[ # # ][ # # ]
1383 : : {
1384 [ # # ][ # # ]: 0 : if (aHdl(*it, *pNew))
1385 [ # # ]: 0 : nSelPos = std::distance(itBeg, it);
1386 : : }
1387 : : }
1388 [ # # ]: 0 : delete pNew;
1389 : : }
1390 : : }
1391 : : }
1392 : :
1393 : : // neu (309): irgendwas muss immer selektiert sein:
1394 [ # # ][ # # ]: 0 : if ( LISTBOX_ENTRY_NOTFOUND == nSelPos && pFilterBox->GetEntryCount() > 0 && !bDataSelect)
[ # # ][ # # ]
[ # # ]
1395 : 0 : nSelPos = 0;
1396 : :
1397 : : // keine leere Auswahl-Liste anzeigen:
1398 : :
1399 [ # # ]: 0 : if ( bEmpty )
1400 : : {
1401 [ # # ][ # # ]: 0 : DELETEZ(pFilterBox); // war nix
1402 [ # # ][ # # ]: 0 : DELETEZ(pFilterFloat);
1403 : : }
1404 : : else
1405 : : {
1406 [ # # ]: 0 : pFilterBox->GrabFocus();
1407 : :
1408 : : // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet
1409 [ # # ]: 0 : if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
1410 [ # # ]: 0 : pFilterBox->SelectEntryPos( nSelPos );
1411 : : else
1412 : : {
1413 [ # # ]: 0 : if (bDataSelect)
1414 [ # # ]: 0 : pFilterBox->SetNoSelection();
1415 : : }
1416 : :
1417 [ # # ]: 0 : pFilterBox->EndInit();
1418 : :
1419 [ # # ]: 0 : if (!bDataSelect)
1420 : : {
1421 : : // AutoFilter (aus MouseButtonDown):
1422 : : // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown
1423 : :
1424 : 0 : nMouseStatus = SC_GM_FILTER;
1425 [ # # ]: 0 : CaptureMouse();
1426 : : }
1427 : 0 : }
1428 : 0 : }
1429 : :
1430 : 0 : void ScGridWindow::FilterSelect( sal_uLong nSel )
1431 : : {
1432 [ # # ]: 0 : String aString = pFilterBox->GetEntry( static_cast< sal_uInt16 >( nSel ) );
1433 : :
1434 : 0 : SCCOL nCol = pFilterBox->GetCol();
1435 : 0 : SCROW nRow = pFilterBox->GetRow();
1436 [ # # # # : 0 : switch ( pFilterBox->GetMode() )
# ]
1437 : : {
1438 : : case SC_FILTERBOX_DATASELECT:
1439 [ # # ]: 0 : ExecDataSelect( nCol, nRow, aString );
1440 : 0 : break;
1441 : : case SC_FILTERBOX_FILTER:
1442 [ # # ]: 0 : ExecFilter( nSel, nCol, nRow, aString, pFilterBox->HasDates() );
1443 : 0 : break;
1444 : : case SC_FILTERBOX_SCENARIO:
1445 [ # # ]: 0 : pViewData->GetView()->UseScenario( aString );
1446 : 0 : break;
1447 : : case SC_FILTERBOX_PAGEFIELD:
1448 : : // first entry is "all"
1449 [ # # ]: 0 : ExecPageFieldSelect( nCol, nRow, (nSel != 0), aString );
1450 : 0 : break;
1451 : : }
1452 : :
1453 [ # # ]: 0 : if (pFilterFloat)
1454 [ # # ]: 0 : pFilterFloat->EndPopupMode();
1455 : :
1456 [ # # ][ # # ]: 0 : GrabFocus(); // unter OS/2 stimmt der Focus sonst nicht
1457 : 0 : }
1458 : :
1459 : 0 : void ScGridWindow::ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr )
1460 : : {
1461 [ # # ]: 0 : if ( rStr.Len() )
1462 : : {
1463 : 0 : SCTAB nTab = pViewData->GetTabNo();
1464 [ # # ]: 0 : ScViewFunc* pView = pViewData->GetView();
1465 : 0 : pView->EnterData( nCol, nRow, nTab, rStr );
1466 : :
1467 : : // #i52307# CellContentChanged is not in EnterData so it isn't called twice
1468 : : // if the cursor is moved afterwards.
1469 : 0 : pView->CellContentChanged();
1470 : : }
1471 : 0 : }
1472 : :
1473 : 0 : void ScGridWindow::ExecFilter( sal_uLong nSel,
1474 : : SCCOL nCol, SCROW nRow,
1475 : : const String& aValue, bool bCheckForDates )
1476 : : {
1477 : 0 : SCTAB nTab = pViewData->GetTabNo();
1478 : 0 : ScDocument* pDoc = pViewData->GetDocument();
1479 : :
1480 : 0 : ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
1481 [ # # ]: 0 : if (pDBData)
1482 : : {
1483 [ # # ]: 0 : ScQueryParam aParam;
1484 [ # # ]: 0 : pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben
1485 : :
1486 [ # # ]: 0 : if (SC_AUTOFILTER_CUSTOM == nSel)
1487 : : {
1488 : : SCTAB nAreaTab;
1489 : : SCCOL nStartCol;
1490 : : SCROW nStartRow;
1491 : : SCCOL nEndCol;
1492 : : SCROW nEndRow;
1493 [ # # ]: 0 : pDBData->GetArea( nAreaTab, nStartCol,nStartRow,nEndCol,nEndRow );
1494 [ # # ]: 0 : pViewData->GetView()->MarkRange( ScRange( nStartCol,nStartRow,nAreaTab,nEndCol,nEndRow,nAreaTab));
1495 [ # # ]: 0 : pViewData->GetView()->SetCursor(nCol,nRow); //! auch ueber Slot ??
1496 [ # # ][ # # ]: 0 : pViewData->GetDispatcher().Execute( SID_FILTER, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1497 : : }
1498 : : else
1499 : : {
1500 : 0 : sal_Bool bDeleteOld = false;
1501 : 0 : SCSIZE nQueryPos = 0;
1502 : 0 : sal_Bool bFound = false;
1503 [ # # ]: 0 : if (!aParam.bInplace)
1504 : 0 : bDeleteOld = sal_True;
1505 [ # # ]: 0 : if (aParam.bRegExp)
1506 : 0 : bDeleteOld = sal_True;
1507 [ # # ]: 0 : SCSIZE nCount = aParam.GetEntryCount();
1508 [ # # ][ # # ]: 0 : for (SCSIZE i = 0; i < nCount && !bDeleteOld; ++i) // bisherige Filter-Einstellungen
[ # # ]
1509 [ # # ][ # # ]: 0 : if (aParam.GetEntry(i).bDoQuery)
1510 : : {
1511 : : //! Abfrage mit DrawButtons zusammenfassen!
1512 : :
1513 [ # # ]: 0 : ScQueryEntry& rEntry = aParam.GetEntry(i);
1514 [ # # ]: 0 : if (i>0)
1515 [ # # ]: 0 : if (rEntry.eConnect != SC_AND)
1516 : 0 : bDeleteOld = sal_True;
1517 : :
1518 [ # # ]: 0 : if (rEntry.nField == nCol)
1519 : : {
1520 [ # # ]: 0 : if (bFound) // diese Spalte zweimal?
1521 : 0 : bDeleteOld = sal_True;
1522 : 0 : nQueryPos = i;
1523 : 0 : bFound = sal_True;
1524 : : }
1525 [ # # ]: 0 : if (!bFound)
1526 : 0 : nQueryPos = i + 1;
1527 : : }
1528 : :
1529 [ # # ]: 0 : if (bDeleteOld)
1530 : : {
1531 [ # # ]: 0 : SCSIZE nEC = aParam.GetEntryCount();
1532 [ # # ]: 0 : for (SCSIZE i=0; i<nEC; i++)
1533 [ # # ][ # # ]: 0 : aParam.GetEntry(i).Clear();
1534 : 0 : nQueryPos = 0;
1535 : 0 : aParam.bInplace = sal_True;
1536 : 0 : aParam.bRegExp = false;
1537 : : }
1538 : :
1539 [ # # ][ # # ]: 0 : if ( nQueryPos < nCount || SC_AUTOFILTER_ALL == nSel ) // loeschen geht immer
1540 : : {
1541 [ # # ]: 0 : if (nSel)
1542 : : {
1543 [ # # ]: 0 : ScQueryEntry& rNewEntry = aParam.GetEntry(nQueryPos);
1544 [ # # ]: 0 : ScQueryEntry::Item& rItem = rNewEntry.GetQueryItem();
1545 : 0 : rNewEntry.bDoQuery = true;
1546 : 0 : rNewEntry.nField = nCol;
1547 [ # # ]: 0 : rItem.meType = bCheckForDates ? ScQueryEntry::ByDate : ScQueryEntry::ByString;
1548 : :
1549 [ # # ]: 0 : if ( nSel == SC_AUTOFILTER_TOP10 )
1550 : : {
1551 : 0 : rNewEntry.eOp = SC_TOPVAL;
1552 [ # # ]: 0 : rItem.maString = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10"));
1553 : : }
1554 [ # # ]: 0 : else if (nSel == SC_AUTOFILTER_EMPTY)
1555 : : {
1556 [ # # ]: 0 : rNewEntry.SetQueryByEmpty();
1557 : : }
1558 [ # # ]: 0 : else if (nSel == SC_AUTOFILTER_NOTEMPTY)
1559 : : {
1560 [ # # ]: 0 : rNewEntry.SetQueryByNonEmpty();
1561 : : }
1562 : : else
1563 : : {
1564 : 0 : rNewEntry.eOp = SC_EQUAL;
1565 [ # # ]: 0 : rItem.maString = aValue;
1566 : : }
1567 [ # # ]: 0 : if (nQueryPos > 0)
1568 : 0 : rNewEntry.eConnect = SC_AND;
1569 : : }
1570 : : else
1571 : : {
1572 [ # # ]: 0 : if (bFound)
1573 [ # # ]: 0 : aParam.RemoveEntryByField(nCol);
1574 : : }
1575 : :
1576 : : // end edit mode - like in ScCellShell::ExecuteDB
1577 [ # # ]: 0 : if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
1578 : : {
1579 [ # # ][ # # ]: 0 : SC_MOD()->InputEnterHandler();
1580 [ # # ]: 0 : pViewData->GetViewShell()->UpdateInputHandler();
1581 : : }
1582 : :
1583 [ # # ]: 0 : pViewData->GetView()->Query( aParam, NULL, true );
1584 [ # # ]: 0 : pDBData->SetQueryParam( aParam ); // speichern
1585 : : }
1586 : : else // "Zuviele Bedingungen"
1587 [ # # ]: 0 : pViewData->GetView()->ErrorMessage( STR_FILTER_TOOMANY );
1588 [ # # ]: 0 : }
1589 : : }
1590 : : else
1591 : : {
1592 : : OSL_FAIL("Wo ist der Datenbankbereich?");
1593 : : }
1594 : 0 : }
1595 : :
1596 : 0 : void ScGridWindow::SetPointer( const Pointer& rPointer )
1597 : : {
1598 : 0 : nCurrentPointer = 0;
1599 : 0 : Window::SetPointer( rPointer );
1600 : 0 : }
1601 : :
1602 : 0 : void ScGridWindow::MoveMouseStatus( ScGridWindow& rDestWin )
1603 : : {
1604 [ # # ]: 0 : if (nButtonDown)
1605 : : {
1606 : 0 : rDestWin.nButtonDown = nButtonDown;
1607 : 0 : rDestWin.nMouseStatus = nMouseStatus;
1608 : : }
1609 : :
1610 [ # # ]: 0 : if (bRFMouse)
1611 : : {
1612 : 0 : rDestWin.bRFMouse = bRFMouse;
1613 : 0 : rDestWin.bRFSize = bRFSize;
1614 : 0 : rDestWin.nRFIndex = nRFIndex;
1615 : 0 : rDestWin.nRFAddX = nRFAddX;
1616 : 0 : rDestWin.nRFAddY = nRFAddY;
1617 : 0 : bRFMouse = false;
1618 : : }
1619 : :
1620 [ # # ]: 0 : if (nPagebreakMouse)
1621 : : {
1622 : 0 : rDestWin.nPagebreakMouse = nPagebreakMouse;
1623 : 0 : rDestWin.nPagebreakBreak = nPagebreakBreak;
1624 : 0 : rDestWin.nPagebreakPrev = nPagebreakPrev;
1625 : 0 : rDestWin.aPagebreakSource = aPagebreakSource;
1626 : 0 : rDestWin.aPagebreakDrag = aPagebreakDrag;
1627 : 0 : nPagebreakMouse = SC_PD_NONE;
1628 : : }
1629 : 0 : }
1630 : :
1631 : 0 : bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, bool bAction )
1632 : : {
1633 : : // MouseEvent buttons must only be checked if bAction==TRUE
1634 : : // to allow changing the mouse pointer in MouseMove,
1635 : : // but not start AutoFill with right button (#74229#).
1636 : : // with bAction==sal_True, SetFillMode / SetDragMode is called
1637 : :
1638 [ # # ][ # # ]: 0 : if ( bAction && !rMEvt.IsLeft() )
[ # # ]
1639 : 0 : return false;
1640 : :
1641 : 0 : bool bNewPointer = false;
1642 : :
1643 : 0 : SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
1644 [ # # ][ # # ]: 0 : bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
1645 : :
1646 [ # # ][ # # ]: 0 : if ( pViewData->IsActive() && !bOleActive )
[ # # ]
1647 : : {
1648 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
1649 : 0 : SCTAB nTab = pViewData->GetTabNo();
1650 [ # # ]: 0 : bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
1651 : :
1652 : : // Auto-Fill
1653 : :
1654 : 0 : ScRange aMarkRange;
1655 [ # # ][ # # ]: 0 : if (pViewData->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE)
1656 : : {
1657 [ # # ][ # # ]: 0 : if (aMarkRange.aStart.Tab() == pViewData->GetTabNo() && mpAutoFillRect)
[ # # ]
1658 : : {
1659 : 0 : Point aMousePos = rMEvt.GetPosPixel();
1660 [ # # ][ # # ]: 0 : if (mpAutoFillRect->IsInside(aMousePos))
1661 : : {
1662 [ # # ]: 0 : SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ?
1663 [ # # ]: 0 : if (bAction)
1664 : : {
1665 : 0 : SCCOL nX = aMarkRange.aEnd.Col();
1666 : 0 : SCROW nY = aMarkRange.aEnd.Row();
1667 : :
1668 [ # # ][ # # ]: 0 : if ( lcl_IsEditableMatrix( pViewData->GetDocument(), aMarkRange ) )
[ # # ]
1669 : : pViewData->SetDragMode(
1670 [ # # ]: 0 : aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY, SC_FILL_MATRIX );
1671 : : else
1672 : : pViewData->SetFillMode(
1673 [ # # ]: 0 : aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY );
1674 : :
1675 : : // The simple selection must also be recognized when dragging,
1676 : : // where the Marking flag is set and MarkToSimple won't work anymore.
1677 [ # # ][ # # ]: 0 : pViewData->GetMarkData().MarkToSimple();
1678 : : }
1679 : 0 : bNewPointer = true;
1680 : : }
1681 : : }
1682 : : }
1683 : :
1684 : : // Embedded-Rechteck
1685 : :
1686 [ # # ][ # # ]: 0 : if (pDoc->IsEmbedded())
1687 : : {
1688 : 0 : ScRange aRange;
1689 [ # # ]: 0 : pDoc->GetEmbedded( aRange );
1690 [ # # ]: 0 : if ( pViewData->GetTabNo() == aRange.aStart.Tab() )
1691 : : {
1692 [ # # ]: 0 : Point aStartPos = pViewData->GetScrPos( aRange.aStart.Col(), aRange.aStart.Row(), eWhich );
1693 [ # # ]: 0 : Point aEndPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich );
1694 : 0 : Point aMousePos = rMEvt.GetPosPixel();
1695 [ # # ]: 0 : if ( bLayoutRTL )
1696 : : {
1697 : 0 : aStartPos.X() += 2;
1698 : 0 : aEndPos.X() += 2;
1699 : : }
1700 : 0 : bool bTop = ( aMousePos.X() >= aStartPos.X()-3 && aMousePos.X() <= aStartPos.X()+1 &&
1701 [ # # ][ # # ]: 0 : aMousePos.Y() >= aStartPos.Y()-3 && aMousePos.Y() <= aStartPos.Y()+1 );
[ # # # # ]
1702 : 0 : bool bBottom = ( aMousePos.X() >= aEndPos.X()-3 && aMousePos.X() <= aEndPos.X()+1 &&
1703 [ # # ][ # # ]: 0 : aMousePos.Y() >= aEndPos.Y()-3 && aMousePos.Y() <= aEndPos.Y()+1 );
[ # # # # ]
1704 [ # # ][ # # ]: 0 : if ( bTop || bBottom )
1705 : : {
1706 [ # # ]: 0 : SetPointer( Pointer( POINTER_CROSS ) );
1707 [ # # ]: 0 : if (bAction)
1708 : : {
1709 [ # # ]: 0 : sal_uInt8 nMode = bTop ? SC_FILL_EMBED_LT : SC_FILL_EMBED_RB;
1710 : : pViewData->SetDragMode(
1711 : 0 : aRange.aStart.Col(), aRange.aStart.Row(),
1712 [ # # ]: 0 : aRange.aEnd.Col(), aRange.aEnd.Row(), nMode );
1713 : : }
1714 : 0 : bNewPointer = true;
1715 : : }
1716 : : }
1717 : : }
1718 : : }
1719 : :
1720 [ # # ][ # # ]: 0 : if (!bNewPointer && bAction)
1721 : : {
1722 : 0 : pViewData->ResetFillMode();
1723 : : }
1724 : :
1725 : 0 : return bNewPointer;
1726 : : }
1727 : :
1728 : 0 : void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
1729 : : {
1730 : 0 : nNestedButtonState = SC_NESTEDBUTTON_DOWN;
1731 : :
1732 : 0 : HandleMouseButtonDown( rMEvt );
1733 : :
1734 [ # # ]: 0 : if ( nNestedButtonState == SC_NESTEDBUTTON_UP )
1735 : : {
1736 : : // #i41690# If an object is deactivated from MouseButtonDown, it might reschedule,
1737 : : // so MouseButtonUp comes before the MouseButtonDown call is finished. In this case,
1738 : : // simulate another MouseButtonUp call, so the selection state is consistent.
1739 : :
1740 : 0 : nButtonDown = rMEvt.GetButtons();
1741 : 0 : FakeButtonUp();
1742 : :
1743 [ # # ]: 0 : if ( IsTracking() )
1744 : 0 : EndTracking(); // normally done in VCL as part of MouseButtonUp handling
1745 : : }
1746 : 0 : nNestedButtonState = SC_NESTEDBUTTON_NONE;
1747 : 0 : }
1748 : :
1749 : 0 : void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
1750 : : {
1751 : : // We have to check if a context menu is shown and we have an UI
1752 : : // active inplace client. In that case we have to ignore the event.
1753 : : // Otherwise we would crash (context menu has been
1754 : : // opened by inplace client and we would deactivate the inplace client,
1755 : : // the contex menu is closed by VCL asynchronously which in the end
1756 : : // would work on deleted objects or the context menu has no parent anymore)
1757 : 0 : SfxViewShell* pViewSh = pViewData->GetViewShell();
1758 [ # # ]: 0 : SfxInPlaceClient* pClient = pViewSh->GetIPClient();
1759 [ # # ][ # # ]: 0 : if ( pClient &&
[ # # ][ # # ]
1760 [ # # ]: 0 : pClient->IsObjectInPlaceActive() &&
1761 [ # # ]: 0 : PopupMenu::IsInExecute() )
1762 : : return;
1763 : :
1764 : 0 : aCurMousePos = rMEvt.GetPosPixel();
1765 : :
1766 : : // Filter-Popup beendet sich mit eigenem Mausklick, nicht erst beim Klick
1767 : : // in das GridWindow, darum ist die folgende Abfrage nicht mehr noetig:
1768 [ # # ]: 0 : ClickExtern(); // loescht FilterBox, wenn vorhanden
1769 : :
1770 [ # # ]: 0 : HideNoteMarker(); // Notiz-Anzeige
1771 : :
1772 : 0 : bEEMouse = false;
1773 : :
1774 [ # # ]: 0 : ScModule* pScMod = SC_MOD();
1775 [ # # ][ # # ]: 0 : if (pScMod->IsModalMode(pViewData->GetSfxDocShell()))
[ # # ]
1776 : : return;
1777 : :
1778 : 0 : pScActiveViewShell = pViewData->GetViewShell(); // falls auf Link geklickt wird
1779 : 0 : nScClickMouseModifier = rMEvt.GetModifier(); // um Control-Klick immer zu erkennen
1780 : :
1781 [ # # ]: 0 : sal_Bool bDetective = pViewData->GetViewShell()->IsAuditShell();
1782 : 0 : sal_Bool bRefMode = pViewData->IsRefMode(); // Referenz angefangen
1783 [ # # ]: 0 : sal_Bool bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz
1784 : 0 : sal_Bool bEditMode = pViewData->HasEditView(eWhich); // auch bei Mode==SC_INPUT_TYPE
1785 : 0 : sal_Bool bDouble = (rMEvt.GetClicks() == 2);
1786 : :
1787 : : // DeactivateIP passiert nur noch bei MarkListHasChanged
1788 : :
1789 : : // im GrabFocus Aufruf kann eine Fehlermeldung hochkommen
1790 : : // (z.B. beim Umbenennen von Tabellen per Tab-Reiter)
1791 : :
1792 [ # # ][ # # ]: 0 : if ( !nButtonDown || !bDouble ) // single (first) click is always valid
1793 : 0 : nButtonDown = rMEvt.GetButtons(); // set nButtonDown first, so StopMarking works
1794 : :
1795 [ # # ][ # # ]: 0 : if ( ( bEditMode && pViewData->GetActivePart() == eWhich ) || !bFormulaMode )
[ # # ][ # # ]
1796 [ # # ]: 0 : GrabFocus();
1797 : :
1798 : : // #i31846# need to cancel a double click if the first click has set the "ignore" state,
1799 : : // but a single (first) click is always valid
1800 [ # # ][ # # ]: 0 : if ( nMouseStatus == SC_GM_IGNORE && bDouble )
1801 : : {
1802 : 0 : nButtonDown = 0;
1803 : 0 : nMouseStatus = SC_GM_NONE;
1804 : : return;
1805 : : }
1806 : :
1807 [ # # ]: 0 : if ( bDetective ) // Detektiv-Fuell-Modus
1808 : : {
1809 [ # # ][ # # ]: 0 : if ( rMEvt.IsLeft() && !rMEvt.GetModifier() )
[ # # ]
1810 : : {
1811 : 0 : Point aPos = rMEvt.GetPosPixel();
1812 : : SCsCOL nPosX;
1813 : : SCsROW nPosY;
1814 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
1815 : :
1816 [ # # ]: 0 : SfxInt16Item aPosXItem( SID_RANGE_COL, nPosX );
1817 [ # # ]: 0 : SfxInt32Item aPosYItem( SID_RANGE_ROW, nPosY );
1818 [ # # ]: 0 : pViewData->GetDispatcher().Execute( SID_FILL_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
1819 [ # # ][ # # ]: 0 : &aPosXItem, &aPosYItem, (void*)0L );
[ # # ]
1820 : :
1821 : : }
1822 : 0 : nButtonDown = 0;
1823 : 0 : nMouseStatus = SC_GM_NONE;
1824 : : return;
1825 : : }
1826 : :
1827 [ # # ]: 0 : if (!bDouble)
1828 : 0 : nMouseStatus = SC_GM_NONE;
1829 : :
1830 [ # # ]: 0 : if (!bFormulaMode)
1831 : : {
1832 [ # # ]: 0 : if ( pViewData->GetActivePart() != eWhich )
1833 [ # # ]: 0 : pViewData->GetView()->ActivatePart( eWhich );
1834 : : }
1835 : : else
1836 : : {
1837 : 0 : ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine();
1838 [ # # ]: 0 : pSelEng->SetWindow(this);
1839 : 0 : pSelEng->SetWhich(eWhich);
1840 [ # # ]: 0 : pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) );
1841 : : }
1842 : :
1843 [ # # ][ # # ]: 0 : if (bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()))
[ # # ]
1844 : : {
1845 : 0 : Point aPos = rMEvt.GetPosPixel();
1846 : : SCsCOL nPosX;
1847 : : SCsROW nPosY;
1848 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
1849 : :
1850 : : EditView* pEditView;
1851 : : SCCOL nEditCol;
1852 : : SCROW nEditRow;
1853 [ # # ]: 0 : pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
1854 : 0 : SCCOL nEndCol = pViewData->GetEditEndCol();
1855 : 0 : SCROW nEndRow = pViewData->GetEditEndRow();
1856 : :
1857 [ # # ][ # # ]: 0 : if ( nPosX >= (SCsCOL) nEditCol && nPosX <= (SCsCOL) nEndCol &&
[ # # ][ # # ]
1858 : : nPosY >= (SCsROW) nEditRow && nPosY <= (SCsROW) nEndRow )
1859 : : {
1860 : : // beim Klick in die Tabellen-EditView immer den Focus umsetzen
1861 [ # # ]: 0 : if (bFormulaMode) // sonst ist es oben schon passiert
1862 [ # # ]: 0 : GrabFocus();
1863 : :
1864 [ # # ]: 0 : pScMod->SetInputMode( SC_INPUT_TABLE );
1865 : 0 : bEEMouse = true;
1866 [ # # ]: 0 : bEditMode = pEditView->MouseButtonDown( rMEvt );
1867 : : return;
1868 : : }
1869 : : }
1870 : :
1871 [ # # ]: 0 : if (pScMod->GetIsWaterCan())
1872 : : {
1873 : : //! was is mit'm Mac ???
1874 [ # # ]: 0 : if ( rMEvt.GetModifier() + rMEvt.GetButtons() == MOUSE_RIGHT )
1875 : : {
1876 : 0 : nMouseStatus = SC_GM_WATERUNDO;
1877 : : return;
1878 : : }
1879 : : }
1880 : :
1881 : : // Reihenfolge passend zum angezeigten Cursor:
1882 : : // RangeFinder, AutoFill, PageBreak, Drawing
1883 : :
1884 : : bool bCorner;
1885 [ # # ]: 0 : bool bFound = HitRangeFinder(rMEvt.GetPosPixel(), bCorner, &nRFIndex, &nRFAddX, &nRFAddY);
1886 : 0 : bRFSize = bCorner;
1887 [ # # ]: 0 : if (bFound)
1888 : : {
1889 : 0 : bRFMouse = true; // die anderen Variablen sind oben initialisiert
1890 : :
1891 [ # # ]: 0 : if ( pViewData->GetActivePart() != eWhich )
1892 [ # # ]: 0 : pViewData->GetView()->ActivatePart( eWhich ); //! schon oben immer ???
1893 : :
1894 [ # # ]: 0 : StartTracking();
1895 : : return;
1896 : : }
1897 : :
1898 [ # # ]: 0 : sal_Bool bCrossPointer = TestMouse( rMEvt, sal_True );
1899 [ # # ]: 0 : if ( bCrossPointer )
1900 : : {
1901 [ # # ]: 0 : if ( bDouble )
1902 [ # # ]: 0 : pViewData->GetView()->FillCrossDblClick();
1903 : : else
1904 [ # # ]: 0 : pScMod->InputEnterHandler(); // Autofill etc.
1905 : : }
1906 : :
1907 [ # # ]: 0 : if ( !bCrossPointer )
1908 : : {
1909 : 0 : nPagebreakMouse = HitPageBreak( rMEvt.GetPosPixel(), &aPagebreakSource,
1910 [ # # ]: 0 : &nPagebreakBreak, &nPagebreakPrev );
1911 [ # # ]: 0 : if (nPagebreakMouse)
1912 : : {
1913 : 0 : bPagebreakDrawn = false;
1914 [ # # ]: 0 : StartTracking();
1915 [ # # ]: 0 : PagebreakMove( rMEvt, false );
1916 : : return;
1917 : : }
1918 : : }
1919 : :
1920 [ # # ][ # # ]: 0 : if (!bFormulaMode && !bEditMode && rMEvt.IsLeft())
[ # # ][ # # ]
1921 : : {
1922 [ # # ][ # # ]: 0 : if ( !bCrossPointer && DrawMouseButtonDown(rMEvt) )
[ # # ][ # # ]
1923 : : {
1924 : : return;
1925 : : }
1926 : :
1927 [ # # ]: 0 : pViewData->GetViewShell()->SetDrawShell( false ); // kein Draw-Objekt selektiert
1928 : :
1929 : : // TestMouse schon oben passiert
1930 : : }
1931 : :
1932 : 0 : Point aPos = rMEvt.GetPosPixel();
1933 : : SCsCOL nPosX;
1934 : : SCsROW nPosY;
1935 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
1936 : 0 : SCTAB nTab = pViewData->GetTabNo();
1937 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
1938 : :
1939 : :
1940 : : //
1941 : : // AutoFilter buttons
1942 : : //
1943 : :
1944 [ # # ][ # # ]: 0 : if ( !bDouble && !bFormulaMode && rMEvt.IsLeft() )
[ # # ][ # # ]
1945 : : {
1946 : : ScMergeFlagAttr* pAttr = (ScMergeFlagAttr*)
1947 [ # # ]: 0 : pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG );
1948 [ # # ]: 0 : if (pAttr->HasAutoFilter())
1949 : : {
1950 [ # # ][ # # ]: 0 : if (DoAutoFilterButton(nPosX, nPosY, rMEvt))
1951 : : return;
1952 : : }
1953 [ # # ]: 0 : if (pAttr->HasButton())
1954 : : {
1955 [ # # ]: 0 : DoPushButton( nPosX, nPosY, rMEvt ); // setzt evtl. bPivotMouse / bDPMouse
1956 : : return;
1957 : : }
1958 : :
1959 : : // List Validity drop-down button
1960 : :
1961 [ # # ]: 0 : if ( bListValButton )
1962 : : {
1963 [ # # ]: 0 : Rectangle aButtonRect = GetListValButtonRect( aListValPos );
1964 [ # # ][ # # ]: 0 : if ( aButtonRect.IsInside( aPos ) )
1965 : : {
1966 [ # # ]: 0 : LaunchDataSelectMenu( aListValPos.Col(), aListValPos.Row(), true );
1967 : :
1968 : 0 : nMouseStatus = SC_GM_FILTER; // not set in DoAutoFilterMenue for bDataSelect
1969 [ # # ]: 0 : CaptureMouse();
1970 : : return;
1971 : : }
1972 : : }
1973 : : }
1974 : :
1975 : : //
1976 : : // scenario selection
1977 : : //
1978 : :
1979 : 0 : ScRange aScenRange;
1980 [ # # ][ # # ]: 0 : if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) )
[ # # ][ # # ]
1981 : : {
1982 [ # # ]: 0 : DoScenarioMenue( aScenRange );
1983 : : return;
1984 : : }
1985 : :
1986 : : //
1987 : : // Doppelklick angefangen ?
1988 : : //
1989 : :
1990 : : // StopMarking kann aus DrawMouseButtonDown gerufen werden
1991 : :
1992 [ # # ][ # # ]: 0 : if ( nMouseStatus != SC_GM_IGNORE && !bRefMode )
1993 : : {
1994 [ # # ][ # # ]: 0 : if ( bDouble && !bCrossPointer )
1995 : : {
1996 [ # # ]: 0 : if (nMouseStatus == SC_GM_TABDOWN)
1997 : 0 : nMouseStatus = SC_GM_DBLDOWN;
1998 : : }
1999 : : else
2000 : 0 : nMouseStatus = SC_GM_TABDOWN;
2001 : : }
2002 : :
2003 : : //
2004 : : // Links in Edit-Zellen
2005 : : //
2006 : :
2007 : 0 : sal_Bool bAlt = rMEvt.IsMod2();
2008 [ # # ][ # # ]: 0 : if ( !bAlt && rMEvt.IsLeft() &&
[ # # ][ # # ]
2009 [ # # ]: 0 : GetEditUrl(rMEvt.GetPosPixel()) ) // Klick auf Link: Cursor nicht bewegen
2010 : : {
2011 [ # # ]: 0 : SetPointer( Pointer( POINTER_REFHAND ) );
2012 : 0 : nMouseStatus = SC_GM_URLDOWN; // auch nur dann beim ButtonUp ausfuehren
2013 : : return;
2014 : : }
2015 : :
2016 : : //
2017 : : // Gridwin - SelectionEngine
2018 : : //
2019 : :
2020 [ # # ]: 0 : if ( rMEvt.IsLeft() )
2021 : : {
2022 : 0 : ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine();
2023 [ # # ]: 0 : pSelEng->SetWindow(this);
2024 : 0 : pSelEng->SetWhich(eWhich);
2025 [ # # ]: 0 : pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) );
2026 : :
2027 : : // SelMouseButtonDown an der View setzt noch das bMoveIsShift Flag
2028 [ # # ][ # # ]: 0 : if ( pViewData->GetView()->SelMouseButtonDown( rMEvt ) )
2029 : : {
2030 [ # # ][ # # ]: 0 : if (IsMouseCaptured())
2031 : : {
2032 : : // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
2033 : : //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
2034 [ # # ]: 0 : ReleaseMouse();
2035 [ # # ]: 0 : StartTracking();
2036 : : }
2037 [ # # ]: 0 : pViewData->GetMarkData().SetMarking(sal_True);
2038 : : return;
2039 : : }
2040 : : }
2041 : : }
2042 : :
2043 : 0 : void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
2044 : : {
2045 : 0 : aCurMousePos = rMEvt.GetPosPixel();
2046 : 0 : ScDocument* pDoc = pViewData->GetDocument();
2047 : 0 : ScMarkData& rMark = pViewData->GetMarkData();
2048 : :
2049 : : // #i41690# detect a MouseButtonUp call from within MouseButtonDown
2050 : : // (possible through Reschedule from storing an OLE object that is deselected)
2051 : :
2052 [ # # ]: 0 : if ( nNestedButtonState == SC_NESTEDBUTTON_DOWN )
2053 : 0 : nNestedButtonState = SC_NESTEDBUTTON_UP;
2054 : :
2055 [ # # ]: 0 : if (nButtonDown != rMEvt.GetButtons())
2056 : 0 : nMouseStatus = SC_GM_IGNORE; // reset und return
2057 : :
2058 : 0 : nButtonDown = 0;
2059 : :
2060 [ # # ]: 0 : if (nMouseStatus == SC_GM_IGNORE)
2061 : : {
2062 : 0 : nMouseStatus = SC_GM_NONE;
2063 : : // Selection-Engine: Markieren abbrechen
2064 : 0 : pViewData->GetView()->GetSelEngine()->Reset();
2065 : 0 : rMark.SetMarking(false);
2066 [ # # ]: 0 : if (pViewData->IsAnyFillMode())
2067 : : {
2068 : 0 : pViewData->GetView()->StopRefMode();
2069 : 0 : pViewData->ResetFillMode();
2070 : : }
2071 : 0 : StopMarking();
2072 : 0 : DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen
2073 : 0 : ReleaseMouse();
2074 : 0 : return;
2075 : : }
2076 : :
2077 [ # # ]: 0 : if (nMouseStatus == SC_GM_FILTER)
2078 : : {
2079 : 0 : nMouseStatus = SC_GM_NONE;
2080 : 0 : ReleaseMouse();
2081 : 0 : return; // da muss nix mehr passieren
2082 : : }
2083 : :
2084 : 0 : ScModule* pScMod = SC_MOD();
2085 [ # # ]: 0 : if (pScMod->IsModalMode(pViewData->GetSfxDocShell()))
2086 : 0 : return;
2087 : :
2088 : 0 : SfxBindings& rBindings = pViewData->GetBindings();
2089 [ # # ][ # # ]: 0 : if (bEEMouse && pViewData->HasEditView( eWhich ))
[ # # ]
2090 : : {
2091 : : EditView* pEditView;
2092 : : SCCOL nEditCol;
2093 : : SCROW nEditRow;
2094 [ # # ]: 0 : pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
2095 [ # # ]: 0 : pEditView->MouseButtonUp( rMEvt );
2096 : :
2097 [ # # # # ]: 0 : if ( rMEvt.IsMiddle() &&
[ # # ]
2098 : 0 : GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION )
2099 : : {
2100 : : // EditView may have pasted from selection
2101 [ # # ]: 0 : pScMod->InputChanged( pEditView );
2102 : : }
2103 : : else
2104 [ # # ]: 0 : pScMod->InputSelection( pEditView ); // parentheses etc.
2105 : :
2106 [ # # ]: 0 : pViewData->GetView()->InvalidateAttribs();
2107 [ # # ]: 0 : rBindings.Invalidate( SID_HYPERLINK_GETLINK );
2108 : 0 : bEEMouse = false;
2109 : : return;
2110 : : }
2111 : :
2112 [ # # ]: 0 : if (bDPMouse)
2113 : : {
2114 : 0 : DPMouseButtonUp( rMEvt ); // resets bDPMouse
2115 : 0 : return;
2116 : : }
2117 : :
2118 [ # # ]: 0 : if (bRFMouse)
2119 : : {
2120 : 0 : RFMouseMove( rMEvt, sal_True ); // Range wieder richtigherum
2121 : 0 : bRFMouse = false;
2122 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
2123 : 0 : ReleaseMouse();
2124 : 0 : return;
2125 : : }
2126 : :
2127 [ # # ]: 0 : if (nPagebreakMouse)
2128 : : {
2129 : 0 : PagebreakMove( rMEvt, sal_True );
2130 : 0 : nPagebreakMouse = SC_PD_NONE;
2131 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
2132 : 0 : ReleaseMouse();
2133 : 0 : return;
2134 : : }
2135 : :
2136 [ # # ]: 0 : if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus
2137 : : {
2138 : 0 : ::svl::IUndoManager* pMgr = pViewData->GetDocShell()->GetUndoManager();
2139 [ # # ][ # # ]: 0 : if ( pMgr->GetUndoActionCount() && pMgr->GetUndoActionId() == STR_UNDO_APPLYCELLSTYLE )
[ # # ]
2140 : 0 : pMgr->Undo();
2141 : 0 : return;
2142 : : }
2143 : :
2144 [ # # ]: 0 : if (DrawMouseButtonUp(rMEvt)) // includes format paint brush handling for drawing objects
2145 : 0 : return;
2146 : :
2147 : 0 : rMark.SetMarking(false);
2148 : :
2149 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
2150 : :
2151 [ # # # # : 0 : if (pViewData->IsFillMode() ||
# # ][ # # ]
2152 : 0 : ( pViewData->GetFillMode() == SC_FILL_MATRIX && rMEvt.IsMod1() ))
2153 : : {
2154 : 0 : nScFillModeMouseModifier = rMEvt.GetModifier();
2155 : : SCCOL nStartCol;
2156 : : SCROW nStartRow;
2157 : : SCCOL nEndCol;
2158 : : SCROW nEndRow;
2159 [ # # ]: 0 : pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
2160 : 0 : ScRange aDelRange;
2161 : 0 : sal_Bool bIsDel = pViewData->GetDelMark( aDelRange );
2162 : :
2163 [ # # ]: 0 : ScViewFunc* pView = pViewData->GetView();
2164 [ # # ]: 0 : pView->StopRefMode();
2165 [ # # ]: 0 : pViewData->ResetFillMode();
2166 [ # # ]: 0 : pView->GetFunctionSet()->SetAnchorFlag( false ); // #i5819# don't use AutoFill anchor flag for selection
2167 : :
2168 [ # # ]: 0 : if ( bIsDel )
2169 : : {
2170 [ # # ]: 0 : pView->MarkRange( aDelRange, false );
2171 [ # # ]: 0 : pView->DeleteContents( IDF_CONTENTS );
2172 : 0 : SCTAB nTab = pViewData->GetTabNo();
2173 : 0 : ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2174 [ # # ]: 0 : if ( aBlockRange != aDelRange )
2175 : : {
2176 [ # # ]: 0 : if ( aDelRange.aStart.Row() == nStartRow )
2177 : 0 : aBlockRange.aEnd.SetCol( aDelRange.aStart.Col() - 1 );
2178 : : else
2179 : 0 : aBlockRange.aEnd.SetRow( aDelRange.aStart.Row() - 1 );
2180 [ # # ]: 0 : pView->MarkRange( aBlockRange, false );
2181 : : }
2182 : : }
2183 : : else
2184 [ # # ][ # # ]: 0 : pViewData->GetDispatcher().Execute( FID_FILL_AUTO, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
2185 : : }
2186 [ # # ]: 0 : else if (pViewData->GetFillMode() == SC_FILL_MATRIX)
2187 : : {
2188 : 0 : SCTAB nTab = pViewData->GetTabNo();
2189 : : SCCOL nStartCol;
2190 : : SCROW nStartRow;
2191 : : SCCOL nEndCol;
2192 : : SCROW nEndRow;
2193 [ # # ]: 0 : pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
2194 : 0 : ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2195 : 0 : SCCOL nFillCol = pViewData->GetRefEndX();
2196 : 0 : SCROW nFillRow = pViewData->GetRefEndY();
2197 : 0 : ScAddress aEndPos( nFillCol, nFillRow, nTab );
2198 : :
2199 [ # # ]: 0 : ScTabView* pView = pViewData->GetView();
2200 [ # # ]: 0 : pView->StopRefMode();
2201 [ # # ]: 0 : pViewData->ResetFillMode();
2202 [ # # ]: 0 : pView->GetFunctionSet()->SetAnchorFlag( false );
2203 : :
2204 [ # # ]: 0 : if ( aEndPos != aBlockRange.aEnd )
2205 : : {
2206 [ # # ]: 0 : pViewData->GetDocShell()->GetDocFunc().ResizeMatrix( aBlockRange, aEndPos, false );
2207 [ # # ]: 0 : pViewData->GetView()->MarkRange( ScRange( aBlockRange.aStart, aEndPos ) );
2208 : : }
2209 : : }
2210 [ # # ]: 0 : else if (pViewData->IsAnyFillMode())
2211 : : {
2212 : : // Embedded-Area has been changed
2213 [ # # ]: 0 : ScTabView* pView = pViewData->GetView();
2214 : 0 : pView->StopRefMode();
2215 : 0 : pViewData->ResetFillMode();
2216 : 0 : pView->GetFunctionSet()->SetAnchorFlag( false );
2217 : 0 : pViewData->GetDocShell()->UpdateOle(pViewData);
2218 : : }
2219 : :
2220 : 0 : sal_Bool bRefMode = pViewData->IsRefMode();
2221 [ # # ]: 0 : if (bRefMode)
2222 : 0 : pScMod->EndReference();
2223 : :
2224 : : //
2225 : : // Giesskannen-Modus (Gestalter)
2226 : : //
2227 : :
2228 [ # # ]: 0 : if (pScMod->GetIsWaterCan())
2229 : : {
2230 : : // Abfrage auf Undo schon oben
2231 : :
2232 : : ScStyleSheetPool* pStylePool = (ScStyleSheetPool*)
2233 : : (pViewData->GetDocument()->
2234 : 0 : GetStyleSheetPool());
2235 [ # # ]: 0 : if ( pStylePool )
2236 : : {
2237 : : SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)
2238 : 0 : pStylePool->GetActualStyleSheet();
2239 : :
2240 [ # # ]: 0 : if ( pStyleSheet )
2241 : : {
2242 : 0 : SfxStyleFamily eFamily = pStyleSheet->GetFamily();
2243 : :
2244 [ # # # ]: 0 : switch ( eFamily )
2245 : : {
2246 : : case SFX_STYLE_FAMILY_PARA:
2247 : 0 : pViewData->GetView()->SetStyleSheetToMarked( pStyleSheet );
2248 : 0 : pViewData->GetView()->DoneBlockMode();
2249 : 0 : break;
2250 : :
2251 : : case SFX_STYLE_FAMILY_PAGE:
2252 : 0 : pViewData->GetDocument()->SetPageStyle( pViewData->GetTabNo(),
2253 [ # # ][ # # ]: 0 : pStyleSheet->GetName() );
2254 : :
2255 : : ScPrintFunc( pViewData->GetDocShell(),
2256 : 0 : pViewData->GetViewShell()->GetPrinter(sal_True),
2257 [ # # ]: 0 : pViewData->GetTabNo() ).UpdatePages();
2258 : :
2259 : 0 : rBindings.Invalidate( SID_STATUS_PAGESTYLE );
2260 : 0 : break;
2261 : :
2262 : : default:
2263 : 0 : break;
2264 : : }
2265 : : }
2266 : : }
2267 : : }
2268 : :
2269 : 0 : ScDBFunc* pView = pViewData->GetView();
2270 : 0 : ScDocument* pBrushDoc = pView->GetBrushDocument();
2271 [ # # ]: 0 : if ( pBrushDoc )
2272 : : {
2273 : 0 : pView->PasteFromClip( IDF_ATTRIB, pBrushDoc );
2274 [ # # ]: 0 : if ( !pView->IsPaintBrushLocked() )
2275 : 0 : pView->ResetBrushDocument(); // invalidates pBrushDoc pointer
2276 : : }
2277 : :
2278 : : //
2279 : : // double click (only left button)
2280 : : //
2281 : :
2282 [ # # ][ # # ]: 0 : sal_Bool bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() );
2283 [ # # ][ # # ]: 0 : if ( bDouble && !bRefMode && nMouseStatus == SC_GM_DBLDOWN && !pScMod->IsRefDialogOpen() )
[ # # ][ # # ]
[ # # ]
2284 : : {
2285 : : // data pilot table
2286 : 0 : Point aPos = rMEvt.GetPosPixel();
2287 : : SCsCOL nPosX;
2288 : : SCsROW nPosY;
2289 : 0 : SCTAB nTab = pViewData->GetTabNo();
2290 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
2291 [ # # ]: 0 : ScDPObject* pDPObj = pDoc->GetDPAtCursor( nPosX, nPosY, nTab );
2292 [ # # ][ # # ]: 0 : if ( pDPObj && pDPObj->GetSaveData()->GetDrillDown() )
[ # # ]
2293 : : {
2294 : 0 : ScAddress aCellPos( nPosX, nPosY, pViewData->GetTabNo() );
2295 : :
2296 : : // Check for header drill-down first.
2297 : 0 : sheet::DataPilotTableHeaderData aData;
2298 [ # # ]: 0 : pDPObj->GetHeaderPositionData(aCellPos, aData);
2299 : :
2300 [ # # ][ # # ]: 0 : if ( ( aData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
2301 : 0 : ! ( aData.Flags & sheet::MemberResultFlags::SUBTOTAL ) )
2302 : : {
2303 : : sal_uInt16 nDummy;
2304 [ # # ][ # # ]: 0 : if ( pView->HasSelectionForDrillDown( nDummy ) )
2305 : : {
2306 : : // execute slot to show dialog
2307 [ # # ][ # # ]: 0 : pViewData->GetDispatcher().Execute( SID_OUTLINE_SHOW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
2308 : : }
2309 : : else
2310 : : {
2311 : : // toggle single entry
2312 [ # # ]: 0 : ScDPObject aNewObj( *pDPObj );
2313 [ # # ]: 0 : pDPObj->ToggleDetails( aData, &aNewObj );
2314 : 0 : ScDBDocFunc aFunc( *pViewData->GetDocShell() );
2315 [ # # ]: 0 : aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, false );
2316 [ # # ][ # # ]: 0 : pViewData->GetView()->CursorPosChanged(); // shells may be switched
2317 : 0 : }
2318 : : }
2319 : : else
2320 : : {
2321 : : // Check if the data area is double-clicked.
2322 : :
2323 [ # # ]: 0 : Sequence<sheet::DataPilotFieldFilter> aFilters;
2324 [ # # ][ # # ]: 0 : if ( pDPObj->GetDataFieldPositionData(aCellPos, aFilters) )
2325 [ # # ][ # # ]: 0 : pViewData->GetView()->ShowDataPilotSourceData( *pDPObj, aFilters );
2326 : : }
2327 : :
2328 : 0 : return;
2329 : : }
2330 : :
2331 : : // Check for cell protection attribute.
2332 [ # # ]: 0 : ScTableProtection* pProtect = pDoc->GetTabProtection( nTab );
2333 : 0 : bool bEditAllowed = true;
2334 [ # # ][ # # ]: 0 : if ( pProtect && pProtect->isProtected() )
[ # # ][ # # ]
2335 : : {
2336 [ # # ]: 0 : bool bCellProtected = pDoc->HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HASATTR_PROTECTED);
2337 [ # # ]: 0 : bool bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
2338 [ # # ]: 0 : bool bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
2339 : :
2340 [ # # ][ # # ]: 0 : if ( bSkipProtected && bSkipUnprotected )
2341 : 0 : bEditAllowed = false;
2342 [ # # ][ # # ]: 0 : else if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) )
[ # # ][ # # ]
2343 : 0 : bEditAllowed = false;
2344 : : }
2345 : :
2346 [ # # ]: 0 : if ( bEditAllowed )
2347 : : {
2348 : : // edit cell contents
2349 [ # # ]: 0 : pViewData->GetViewShell()->UpdateInputHandler();
2350 [ # # ]: 0 : pScMod->SetInputMode( SC_INPUT_TABLE );
2351 [ # # ]: 0 : if (pViewData->HasEditView(eWhich))
2352 : : {
2353 : : // Text-Cursor gleich an die geklickte Stelle setzen
2354 : 0 : EditView* pEditView = pViewData->GetEditView( eWhich );
2355 [ # # ]: 0 : MouseEvent aEditEvt( rMEvt.GetPosPixel(), 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
2356 [ # # ]: 0 : pEditView->MouseButtonDown( aEditEvt );
2357 [ # # ]: 0 : pEditView->MouseButtonUp( aEditEvt );
2358 : : }
2359 : : }
2360 : : return;
2361 : : }
2362 : :
2363 : : //
2364 : : // Links in edit cells
2365 : : //
2366 : :
2367 : 0 : sal_Bool bAlt = rMEvt.IsMod2();
2368 [ # # ][ # # ]: 0 : if ( !bAlt && !bRefMode && !bDouble && nMouseStatus == SC_GM_URLDOWN )
[ # # ][ # # ]
2369 : : {
2370 : : // beim ButtonUp nur ausfuehren, wenn ButtonDown auch ueber einer URL war
2371 : :
2372 [ # # ][ # # ]: 0 : String aName, aUrl, aTarget;
[ # # ]
2373 [ # # ][ # # ]: 0 : if ( GetEditUrl( rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget ) )
2374 : : {
2375 : 0 : nMouseStatus = SC_GM_NONE; // keinen Doppelklick anfangen
2376 [ # # ]: 0 : ScGlobal::OpenURL( aUrl, aTarget );
2377 : :
2378 : : // fire worksheet_followhyperlink event
2379 [ # # ]: 0 : uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();
2380 [ # # ]: 0 : if( xVbaEvents.is() ) try
2381 : : {
2382 : 0 : Point aPos = rMEvt.GetPosPixel();
2383 : : SCsCOL nPosX;
2384 : : SCsROW nPosY;
2385 : 0 : SCTAB nTab = pViewData->GetTabNo();
2386 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
2387 : 0 : ScBaseCell* pCell = NULL;
2388 [ # # ][ # # ]: 0 : if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ) )
2389 : : {
2390 : 0 : ScAddress aCellPos( nPosX, nPosY, nTab );
2391 [ # # ][ # # ]: 0 : uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) );
[ # # ]
2392 [ # # ]: 0 : uno::Sequence< uno::Any > aArgs(1);
2393 [ # # ][ # # ]: 0 : aArgs[0] <<= xCell;
2394 [ # # ][ # # ]: 0 : xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs );
[ # # ][ # # ]
2395 : : }
2396 : : }
2397 [ # # ]: 0 : catch( uno::Exception& )
2398 : : {
2399 : : }
2400 : :
2401 : 0 : return;
2402 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
2403 : : }
2404 : :
2405 : : //
2406 : : // Gridwin - SelectionEngine
2407 : : //
2408 : :
2409 : : // SelMouseButtonDown is called only for left button, but SelMouseButtonUp would return
2410 : : // sal_True for any call, so IsLeft must be checked here, too.
2411 : :
2412 [ # # ][ # # ]: 0 : if ( rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) )
[ # # ]
2413 : : {
2414 : 0 : pViewData->GetView()->SelectionChanged();
2415 : :
2416 : 0 : SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher();
2417 : 0 : sal_Bool bFormulaMode = pScMod->IsFormulaMode();
2418 : : OSL_ENSURE( pDisp || bFormulaMode, "Cursor auf nicht aktiver View bewegen ?" );
2419 : :
2420 : : // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no
2421 : : // multiple selection, so the argument string completely describes the selection,
2422 : : // and executing the slot won't change the existing selection (executing the slot
2423 : : // here and from a recorded macro is treated equally)
2424 : :
2425 [ # # ][ # # ]: 0 : if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() )
[ # # ][ # # ]
2426 : : {
2427 [ # # ]: 0 : String aAddr; // CurrentCell
2428 [ # # ]: 0 : if( rMark.IsMarked() )
2429 : : {
2430 : 0 : ScRange aScRange;
2431 [ # # ]: 0 : rMark.GetMarkArea( aScRange );
2432 [ # # ]: 0 : aScRange.Format( aAddr, SCR_ABS );
2433 [ # # ]: 0 : if ( aScRange.aStart == aScRange.aEnd )
2434 : : {
2435 : : // make sure there is a range selection string even for a single cell
2436 [ # # ]: 0 : String aSingle = aAddr;
2437 [ # # ]: 0 : aAddr.Append( (sal_Char) ':' );
2438 [ # # ][ # # ]: 0 : aAddr.Append( aSingle );
2439 : : }
2440 : :
2441 : : //! SID_MARKAREA gibts nicht mehr ???
2442 : : //! was passiert beim Markieren mit dem Cursor ???
2443 : : }
2444 : : else // nur Cursor bewegen
2445 : : {
2446 : 0 : ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 );
2447 [ # # ]: 0 : aScAddress.Format( aAddr, SCA_ABS );
2448 : : }
2449 : :
2450 [ # # ]: 0 : SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
2451 : : // We don't want to align to the cursor position because if the
2452 : : // cell cursor isn't visible after making selection, it would jump
2453 : : // back to the origin of the selection where the cell cursor is.
2454 [ # # ]: 0 : SfxBoolItem aAlignCursorItem( FN_PARAM_2, false );
2455 : : pDisp->Execute( SID_CURRENTCELL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
2456 [ # # ]: 0 : &aPosItem, &aAlignCursorItem, (void*)0L );
2457 : :
2458 [ # # ][ # # ]: 0 : pViewData->GetView()->InvalidateAttribs();
[ # # ][ # # ]
2459 : : }
2460 : 0 : return;
2461 : : }
2462 : : }
2463 : :
2464 : 0 : void ScGridWindow::FakeButtonUp()
2465 : : {
2466 [ # # ]: 0 : if ( nButtonDown )
2467 : : {
2468 [ # # ]: 0 : MouseEvent aEvent( aCurMousePos ); // nButtons = 0 -> ignore
2469 [ # # ]: 0 : MouseButtonUp( aEvent );
2470 : : }
2471 : 0 : }
2472 : :
2473 : 0 : void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
2474 : : {
2475 : 0 : aCurMousePos = rMEvt.GetPosPixel();
2476 : :
2477 [ # # ][ # # ]: 0 : if ( rMEvt.IsLeaveWindow() && pNoteMarker && !pNoteMarker->IsByKeyboard() )
[ # # ][ # # ]
2478 : 0 : HideNoteMarker();
2479 : :
2480 : 0 : ScModule* pScMod = SC_MOD();
2481 [ # # ]: 0 : if (pScMod->IsModalMode(pViewData->GetSfxDocShell()))
2482 : 0 : return;
2483 : :
2484 : : // Ob aus dem Edit-Modus Drag&Drop gestartet wurde, bekommt man leider
2485 : : // nicht anders mit:
2486 : :
2487 [ # # ][ # # ]: 0 : if (bEEMouse && nButtonDown && !rMEvt.GetButtons())
[ # # ][ # # ]
2488 : : {
2489 : 0 : bEEMouse = false;
2490 : 0 : nButtonDown = 0;
2491 : 0 : nMouseStatus = SC_GM_NONE;
2492 : 0 : return;
2493 : : }
2494 : :
2495 [ # # ]: 0 : if (nMouseStatus == SC_GM_IGNORE)
2496 : 0 : return;
2497 : :
2498 [ # # ]: 0 : if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus -> nur auf Up warten
2499 : 0 : return;
2500 : :
2501 [ # # ]: 0 : if ( pViewData->GetViewShell()->IsAuditShell() ) // Detektiv-Fuell-Modus
2502 : : {
2503 [ # # ]: 0 : SetPointer( Pointer( POINTER_FILL ) );
2504 : 0 : return;
2505 : : }
2506 : :
2507 [ # # ][ # # ]: 0 : if (nMouseStatus == SC_GM_FILTER && pFilterBox)
2508 : : {
2509 [ # # ][ # # ]: 0 : Point aRelPos = pFilterBox->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
2510 [ # # ][ # # ]: 0 : if ( Rectangle(Point(),pFilterBox->GetOutputSizePixel()).IsInside(aRelPos) )
[ # # ]
2511 : : {
2512 : 0 : nButtonDown = 0;
2513 : 0 : nMouseStatus = SC_GM_NONE;
2514 [ # # ]: 0 : ReleaseMouse();
2515 [ # # ][ # # ]: 0 : pFilterBox->MouseButtonDown( MouseEvent( aRelPos, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT ) );
2516 : : return;
2517 : : }
2518 : : }
2519 : :
2520 : 0 : sal_Bool bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz
2521 : :
2522 [ # # ][ # # ]: 0 : if (bEEMouse && pViewData->HasEditView( eWhich ))
[ # # ]
2523 : : {
2524 : : EditView* pEditView;
2525 : : SCCOL nEditCol;
2526 : : SCROW nEditRow;
2527 [ # # ]: 0 : pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
2528 [ # # ]: 0 : pEditView->MouseMove( rMEvt );
2529 : : return;
2530 : : }
2531 : :
2532 [ # # ]: 0 : if (bDPMouse)
2533 : : {
2534 : 0 : DPMouseMove( rMEvt );
2535 : 0 : return;
2536 : : }
2537 : :
2538 [ # # ]: 0 : if (bRFMouse)
2539 : : {
2540 : 0 : RFMouseMove( rMEvt, false );
2541 : 0 : return;
2542 : : }
2543 : :
2544 [ # # ]: 0 : if (nPagebreakMouse)
2545 : : {
2546 : 0 : PagebreakMove( rMEvt, false );
2547 : 0 : return;
2548 : : }
2549 : :
2550 : : // anderen Mauszeiger anzeigen?
2551 : :
2552 : 0 : sal_Bool bEditMode = pViewData->HasEditView(eWhich);
2553 : :
2554 : : //! Testen ob RefMode-Dragging !!!
2555 [ # # ][ # # ]: 0 : if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) )
[ # # ]
2556 : : {
2557 : 0 : Point aPos = rMEvt.GetPosPixel();
2558 : : SCsCOL nPosX;
2559 : : SCsROW nPosY;
2560 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
2561 : :
2562 : : EditView* pEditView;
2563 : : SCCOL nEditCol;
2564 : : SCROW nEditRow;
2565 [ # # ]: 0 : pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
2566 : 0 : SCCOL nEndCol = pViewData->GetEditEndCol();
2567 : 0 : SCROW nEndRow = pViewData->GetEditEndRow();
2568 : :
2569 [ # # ][ # # ]: 0 : if ( nPosX >= (SCsCOL) nEditCol && nPosX <= (SCsCOL) nEndCol &&
[ # # ][ # # ]
2570 : : nPosY >= (SCsROW) nEditRow && nPosY <= (SCsROW) nEndRow )
2571 : : {
2572 : : // Field can only be URL field
2573 : 0 : sal_Bool bAlt = rMEvt.IsMod2();
2574 [ # # ][ # # ]: 0 : if ( !bAlt && !nButtonDown && pEditView && pEditView->GetFieldUnderMousePointer() )
[ # # ][ # # ]
[ # # ][ # # ]
2575 [ # # ]: 0 : SetPointer( Pointer( POINTER_REFHAND ) );
2576 [ # # ][ # # ]: 0 : else if ( pEditView && pEditView->GetEditEngine()->IsVertical() )
[ # # ][ # # ]
[ # # ]
2577 [ # # ]: 0 : SetPointer( Pointer( POINTER_TEXT_VERTICAL ) );
2578 : : else
2579 [ # # ]: 0 : SetPointer( Pointer( POINTER_TEXT ) );
2580 : : return;
2581 : : }
2582 : : }
2583 : :
2584 [ # # ][ # # ]: 0 : sal_Bool bWater = SC_MOD()->GetIsWaterCan() || pViewData->GetView()->HasPaintBrush();
2585 [ # # ]: 0 : if (bWater)
2586 [ # # ]: 0 : SetPointer( Pointer(POINTER_FILL) );
2587 : :
2588 [ # # ]: 0 : if (!bWater)
2589 : : {
2590 : 0 : sal_Bool bCross = false;
2591 : :
2592 : : // Range-Finder
2593 : :
2594 : : bool bCorner;
2595 [ # # ][ # # ]: 0 : if ( HitRangeFinder( rMEvt.GetPosPixel(), bCorner ) )
2596 : : {
2597 [ # # ]: 0 : if (bCorner)
2598 [ # # ]: 0 : SetPointer( Pointer( POINTER_CROSS ) );
2599 : : else
2600 [ # # ]: 0 : SetPointer( Pointer( POINTER_HAND ) );
2601 : 0 : bCross = sal_True;
2602 : : }
2603 : :
2604 : : // Page-Break-Modus
2605 : :
2606 : : sal_uInt16 nBreakType;
2607 [ # # ]: 0 : if ( !nButtonDown && pViewData->IsPagebreakMode() &&
[ # # # # ]
[ # # ][ # # ]
2608 : 0 : ( nBreakType = HitPageBreak( rMEvt.GetPosPixel() ) ) != 0 )
2609 : : {
2610 : 0 : PointerStyle eNew = POINTER_ARROW;
2611 [ # # # # : 0 : switch ( nBreakType )
# ]
2612 : : {
2613 : : case SC_PD_RANGE_L:
2614 : : case SC_PD_RANGE_R:
2615 : : case SC_PD_BREAK_H:
2616 : 0 : eNew = POINTER_ESIZE;
2617 : 0 : break;
2618 : : case SC_PD_RANGE_T:
2619 : : case SC_PD_RANGE_B:
2620 : : case SC_PD_BREAK_V:
2621 : 0 : eNew = POINTER_SSIZE;
2622 : 0 : break;
2623 : : case SC_PD_RANGE_TL:
2624 : : case SC_PD_RANGE_BR:
2625 : 0 : eNew = POINTER_SESIZE;
2626 : 0 : break;
2627 : : case SC_PD_RANGE_TR:
2628 : : case SC_PD_RANGE_BL:
2629 : 0 : eNew = POINTER_NESIZE;
2630 : 0 : break;
2631 : : }
2632 [ # # ]: 0 : SetPointer( Pointer( eNew ) );
2633 : 0 : bCross = sal_True;
2634 : : }
2635 : :
2636 : : // Fill-Cursor anzeigen ?
2637 : :
2638 [ # # ][ # # ]: 0 : if ( !bFormulaMode && !nButtonDown )
2639 [ # # ][ # # ]: 0 : if (TestMouse( rMEvt, false ))
2640 : 0 : bCross = sal_True;
2641 : :
2642 [ # # ][ # # ]: 0 : if ( nButtonDown && pViewData->IsAnyFillMode() )
[ # # ]
2643 : : {
2644 [ # # ]: 0 : SetPointer( Pointer( POINTER_CROSS ) );
2645 : 0 : bCross = sal_True;
2646 : 0 : nScFillModeMouseModifier = rMEvt.GetModifier(); // ausgewertet bei AutoFill und Matrix
2647 : : }
2648 : :
2649 [ # # ]: 0 : if (!bCross)
2650 : : {
2651 : 0 : sal_Bool bAlt = rMEvt.IsMod2();
2652 : :
2653 [ # # ]: 0 : if (bEditMode) // Edit-Mode muss zuerst kommen!
2654 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
2655 [ # # ][ # # ]: 0 : else if ( !bAlt && !nButtonDown &&
[ # # ][ # # ]
2656 [ # # ]: 0 : GetEditUrl(rMEvt.GetPosPixel()) )
2657 [ # # ]: 0 : SetPointer( Pointer( POINTER_REFHAND ) );
2658 [ # # ][ # # ]: 0 : else if ( DrawMouseMove(rMEvt) ) // setzt Pointer um
2659 : : return;
2660 : : }
2661 : : }
2662 : :
2663 [ # # ]: 0 : if ( pViewData->GetView()->GetSelEngine()->SelMouseMove( rMEvt ) )
2664 : 0 : return;
2665 : : }
2666 : :
2667 : 0 : void lcl_InitMouseEvent( ::com::sun::star::awt::MouseEvent& rEvent, const MouseEvent& rEvt )
2668 : : {
2669 : 0 : rEvent.Modifiers = 0;
2670 [ # # ]: 0 : if ( rEvt.IsShift() )
2671 : 0 : rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT;
2672 [ # # ]: 0 : if ( rEvt.IsMod1() )
2673 : 0 : rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1;
2674 [ # # ]: 0 : if ( rEvt.IsMod2() )
2675 : 0 : rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2;
2676 [ # # ]: 0 : if ( rEvt.IsMod3() )
2677 : 0 : rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3;
2678 : :
2679 : 0 : rEvent.Buttons = 0;
2680 [ # # ]: 0 : if ( rEvt.IsLeft() )
2681 : 0 : rEvent.Buttons |= ::com::sun::star::awt::MouseButton::LEFT;
2682 [ # # ]: 0 : if ( rEvt.IsRight() )
2683 : 0 : rEvent.Buttons |= ::com::sun::star::awt::MouseButton::RIGHT;
2684 [ # # ]: 0 : if ( rEvt.IsMiddle() )
2685 : 0 : rEvent.Buttons |= ::com::sun::star::awt::MouseButton::MIDDLE;
2686 : :
2687 : 0 : rEvent.X = rEvt.GetPosPixel().X();
2688 : 0 : rEvent.Y = rEvt.GetPosPixel().Y();
2689 : 0 : rEvent.ClickCount = rEvt.GetClicks();
2690 : 0 : rEvent.PopupTrigger = false;
2691 : 0 : }
2692 : :
2693 : 442 : long ScGridWindow::PreNotify( NotifyEvent& rNEvt )
2694 : : {
2695 : 442 : bool bDone = false;
2696 : 442 : sal_uInt16 nType = rNEvt.GetType();
2697 [ - + ][ + - ]: 442 : if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN )
2698 : : {
2699 : 0 : Window* pWindow = rNEvt.GetWindow();
2700 [ # # ][ # # ]: 0 : if (pWindow == this && pViewData)
2701 : : {
2702 : 0 : SfxViewFrame* pViewFrame = pViewData->GetViewShell()->GetViewFrame();
2703 [ # # ]: 0 : if (pViewFrame)
2704 : : {
2705 [ # # ][ # # ]: 0 : com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = pViewFrame->GetFrame().GetController();
2706 [ # # ]: 0 : if (xController.is())
2707 : : {
2708 [ # # ]: 0 : ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
2709 [ # # ][ # # ]: 0 : if (pImp && pImp->IsMouseListening())
[ # # ][ # # ]
2710 : : {
2711 [ # # ]: 0 : ::com::sun::star::awt::MouseEvent aEvent;
2712 [ # # ]: 0 : lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() );
2713 [ # # ]: 0 : if ( rNEvt.GetWindow() )
2714 [ # # ][ # # ]: 0 : aEvent.Source = rNEvt.GetWindow()->GetComponentInterface();
2715 [ # # ]: 0 : if ( nType == EVENT_MOUSEBUTTONDOWN)
2716 [ # # ]: 0 : bDone = pImp->MousePressed( aEvent );
2717 : : else
2718 [ # # ][ # # ]: 0 : bDone = pImp->MouseReleased( aEvent );
2719 : : }
2720 : 0 : }
2721 : : }
2722 : : }
2723 : : }
2724 [ - + ]: 442 : if (bDone) // event consumed by a listener
2725 : : {
2726 [ # # ]: 0 : if ( nType == EVENT_MOUSEBUTTONDOWN )
2727 : : {
2728 : 0 : const MouseEvent* pMouseEvent = rNEvt.GetMouseEvent();
2729 [ # # ][ # # ]: 0 : if ( pMouseEvent->IsRight() && pMouseEvent->GetClicks() == 1 )
[ # # ]
2730 : : {
2731 : : // If a listener returned true for a right-click call, also prevent opening the context menu
2732 : : // (this works only if the context menu is opened on mouse-down)
2733 : 0 : nMouseStatus = SC_GM_IGNORE;
2734 : : }
2735 : : }
2736 : :
2737 : 0 : return 1;
2738 : : }
2739 : : else
2740 : 442 : return Window::PreNotify( rNEvt );
2741 : : }
2742 : :
2743 : 0 : void ScGridWindow::Tracking( const TrackingEvent& rTEvt )
2744 : : {
2745 : : // Weil die SelectionEngine kein Tracking kennt, die Events nur auf
2746 : : // die verschiedenen MouseHandler verteilen...
2747 : :
2748 : 0 : const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
2749 : :
2750 [ # # ]: 0 : if ( rTEvt.IsTrackingCanceled() ) // alles abbrechen...
2751 : : {
2752 [ # # ]: 0 : if (!pViewData->GetView()->IsInActivatePart())
2753 : : {
2754 [ # # ]: 0 : if (bDPMouse)
2755 : 0 : bDPMouse = false; // gezeichnet wird per bDragRect
2756 [ # # ]: 0 : if (bDragRect)
2757 : : {
2758 : : // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
2759 : 0 : bDragRect = false;
2760 : 0 : UpdateDragRectOverlay();
2761 : : }
2762 [ # # ]: 0 : if (bRFMouse)
2763 : : {
2764 : 0 : RFMouseMove( rMEvt, true ); // richtig abbrechen geht dabei nicht...
2765 : 0 : bRFMouse = false;
2766 : : }
2767 [ # # ]: 0 : if (nPagebreakMouse)
2768 : : {
2769 : : // if (bPagebreakDrawn)
2770 : : // DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(),
2771 : : // aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), sal_False );
2772 : 0 : bPagebreakDrawn = false;
2773 : 0 : UpdateDragRectOverlay();
2774 : 0 : nPagebreakMouse = SC_PD_NONE;
2775 : : }
2776 : :
2777 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
2778 : 0 : StopMarking();
2779 : 0 : MouseButtonUp( rMEvt ); // mit Status SC_GM_IGNORE aus StopMarking
2780 : :
2781 : 0 : sal_Bool bRefMode = pViewData->IsRefMode();
2782 [ # # ]: 0 : if (bRefMode)
2783 : 0 : SC_MOD()->EndReference(); // Dialog nicht verkleinert lassen
2784 : : }
2785 : : }
2786 [ # # ]: 0 : else if ( rTEvt.IsTrackingEnded() )
2787 : : {
2788 : : // MouseButtonUp immer mit passenden Buttons (z.B. wegen Testtool, #63148#)
2789 : : // Schliesslich behauptet der Tracking-Event ja, dass normal beendet und nicht
2790 : : // abgebrochen wurde.
2791 : :
2792 : 0 : MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(),
2793 [ # # ]: 0 : rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() );
2794 [ # # ]: 0 : MouseButtonUp( aUpEvt );
2795 : : }
2796 : : else
2797 : 0 : MouseMove( rMEvt );
2798 : 0 : }
2799 : :
2800 : 0 : void ScGridWindow::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
2801 : : {
2802 [ # # ][ # # ]: 0 : if ( pFilterBox || nPagebreakMouse )
2803 : 0 : return;
2804 : :
2805 [ # # ]: 0 : HideNoteMarker();
2806 : :
2807 [ # # ]: 0 : CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, sal_True );
2808 : :
2809 [ # # ][ # # ]: 0 : if (bEEMouse && pViewData->HasEditView( eWhich ))
[ # # ]
2810 : : {
2811 : : EditView* pEditView;
2812 : : SCCOL nEditCol;
2813 : : SCROW nEditRow;
2814 [ # # ]: 0 : pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
2815 : :
2816 : : // don't remove the edit view while switching views
2817 [ # # ]: 0 : ScModule* pScMod = SC_MOD();
2818 : 0 : pScMod->SetInEditCommand( sal_True );
2819 : :
2820 [ # # ]: 0 : pEditView->Command( aDragEvent );
2821 : :
2822 [ # # ]: 0 : ScInputHandler* pHdl = pScMod->GetInputHdl();
2823 [ # # ]: 0 : if (pHdl)
2824 [ # # ]: 0 : pHdl->DataChanged();
2825 : :
2826 : 0 : pScMod->SetInEditCommand( false );
2827 [ # # ]: 0 : if (!pViewData->IsActive()) // dropped to different view?
2828 : : {
2829 [ # # ]: 0 : ScInputHandler* pViewHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
2830 [ # # ][ # # ]: 0 : if ( pViewHdl && pViewData->HasEditView( eWhich ) )
[ # # ]
2831 : : {
2832 [ # # ]: 0 : pViewHdl->CancelHandler();
2833 : 0 : ShowCursor(); // missing from KillEditView
2834 : : }
2835 : : }
2836 : : }
2837 : : else
2838 [ # # ][ # # ]: 0 : if ( !DrawCommand(aDragEvent) )
2839 [ # # ]: 0 : pViewData->GetView()->GetSelEngine()->Command( aDragEvent );
2840 : : }
2841 : :
2842 : 0 : void lcl_SetTextCursorPos( ScViewData* pViewData, ScSplitPos eWhich, Window* pWin )
2843 : : {
2844 : 0 : SCCOL nCol = pViewData->GetCurX();
2845 : 0 : SCROW nRow = pViewData->GetCurY();
2846 [ # # ]: 0 : Rectangle aEditArea = pViewData->GetEditArea( eWhich, nCol, nRow, pWin, NULL, sal_True );
2847 : 0 : aEditArea.Right() = aEditArea.Left();
2848 [ # # ]: 0 : aEditArea = pWin->PixelToLogic( aEditArea );
2849 [ # # ]: 0 : pWin->SetCursorRect( &aEditArea );
2850 : 0 : }
2851 : :
2852 : 0 : void ScGridWindow::Command( const CommandEvent& rCEvt )
2853 : : {
2854 : : // The command event is send to the window after a possible context
2855 : : // menu from an inplace client is closed. Now we have the chance to
2856 : : // deactivate the inplace client without any problem regarding parent
2857 : : // windows and code on the stack.
2858 : 0 : sal_uInt16 nCmd = rCEvt.GetCommand();
2859 : 0 : ScTabViewShell* pTabViewSh = pViewData->GetViewShell();
2860 : 0 : SfxInPlaceClient* pClient = pTabViewSh->GetIPClient();
2861 [ # # ][ # # ]: 0 : if ( pClient &&
[ # # # # ]
2862 : 0 : pClient->IsObjectInPlaceActive() &&
2863 : : nCmd == COMMAND_CONTEXTMENU )
2864 : : {
2865 : 0 : pTabViewSh->DeactivateOle();
2866 : 0 : return;
2867 : : }
2868 : :
2869 : 0 : ScModule* pScMod = SC_MOD();
2870 : : OSL_ENSURE( nCmd != COMMAND_STARTDRAG, "ScGridWindow::Command called with COMMAND_STARTDRAG" );
2871 : :
2872 [ # # ][ # # ]: 0 : if ( nCmd == COMMAND_STARTEXTTEXTINPUT ||
[ # # ][ # # ]
2873 : : nCmd == COMMAND_ENDEXTTEXTINPUT ||
2874 : : nCmd == COMMAND_EXTTEXTINPUT ||
2875 : : nCmd == COMMAND_CURSORPOS )
2876 : : {
2877 : 0 : sal_Bool bEditView = pViewData->HasEditView( eWhich );
2878 [ # # ]: 0 : if (!bEditView)
2879 : : {
2880 : : // only if no cell editview is active, look at drawview
2881 : 0 : SdrView* pSdrView = pViewData->GetView()->GetSdrView();
2882 [ # # ]: 0 : if ( pSdrView )
2883 : : {
2884 : 0 : OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
2885 [ # # ][ # # ]: 0 : if ( pOlView && pOlView->GetWindow() == this )
[ # # ]
2886 : : {
2887 : 0 : pOlView->Command( rCEvt );
2888 : 0 : return; // done
2889 : : }
2890 : : }
2891 : : }
2892 : :
2893 [ # # ][ # # ]: 0 : if ( nCmd == COMMAND_CURSORPOS && !bEditView )
2894 : : {
2895 : : // CURSORPOS may be called without following text input,
2896 : : // to set the input method window position
2897 : : // -> input mode must not be started,
2898 : : // manually calculate text insert position if not in input mode
2899 : :
2900 : 0 : lcl_SetTextCursorPos( pViewData, eWhich, this );
2901 : 0 : return;
2902 : : }
2903 : :
2904 : 0 : ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
2905 [ # # ]: 0 : if ( pHdl )
2906 : : {
2907 : 0 : pHdl->InputCommand( rCEvt, sal_True );
2908 : 0 : return; // done
2909 : : }
2910 : :
2911 : 0 : Window::Command( rCEvt );
2912 : 0 : return;
2913 : : }
2914 : :
2915 [ # # ]: 0 : if ( nCmd == COMMAND_VOICE )
2916 : : {
2917 : : // Der Handler wird nur gerufen, wenn ein Text-Cursor aktiv ist,
2918 : : // also muss es eine EditView oder ein editiertes Zeichenobjekt geben
2919 : :
2920 : 0 : ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
2921 [ # # ][ # # ]: 0 : if ( pHdl && pViewData->HasEditView( eWhich ) )
[ # # ]
2922 : : {
2923 : 0 : EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0
2924 : 0 : pHdl->DataChanging();
2925 : 0 : pEditView->Command( rCEvt );
2926 : 0 : pHdl->DataChanged();
2927 : 0 : return; // erledigt
2928 : : }
2929 : 0 : SdrView* pSdrView = pViewData->GetView()->GetSdrView();
2930 [ # # ]: 0 : if ( pSdrView )
2931 : : {
2932 : 0 : OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
2933 [ # # ][ # # ]: 0 : if ( pOlView && pOlView->GetWindow() == this )
[ # # ]
2934 : : {
2935 : 0 : pOlView->Command( rCEvt );
2936 : 0 : return; // erledigt
2937 : : }
2938 : : }
2939 : 0 : Window::Command(rCEvt); // sonst soll sich die Basisklasse drum kuemmern...
2940 : 0 : return;
2941 : : }
2942 : :
2943 [ # # ]: 0 : if ( nCmd == COMMAND_PASTESELECTION )
2944 : : {
2945 [ # # ]: 0 : if ( bEEMouse )
2946 : : {
2947 : : // EditEngine handles selection in MouseButtonUp - no action
2948 : : // needed in command handler
2949 : : }
2950 : : else
2951 : : {
2952 : 0 : PasteSelection( rCEvt.GetMousePosPixel() );
2953 : : }
2954 : 0 : return;
2955 : : }
2956 : :
2957 [ # # ]: 0 : if ( nCmd == COMMAND_INPUTLANGUAGECHANGE )
2958 : : {
2959 : : // #i55929# Font and font size state depends on input language if nothing is selected,
2960 : : // so the slots have to be invalidated when the input language is changed.
2961 : :
2962 : 0 : SfxBindings& rBindings = pViewData->GetBindings();
2963 : 0 : rBindings.Invalidate( SID_ATTR_CHAR_FONT );
2964 : 0 : rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
2965 : 0 : return;
2966 : : }
2967 : :
2968 [ # # ][ # # ]: 0 : if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL )
[ # # ]
2969 : : {
2970 : 0 : sal_Bool bDone = pViewData->GetView()->ScrollCommand( rCEvt, eWhich );
2971 [ # # ]: 0 : if (!bDone)
2972 : 0 : Window::Command(rCEvt);
2973 : 0 : return;
2974 : : }
2975 : : // #i7560# FormulaMode check is below scrolling - scrolling is allowed during formula input
2976 : 0 : sal_Bool bDisable = pScMod->IsFormulaMode() ||
2977 [ # # ][ # # ]: 0 : pScMod->IsModalMode(pViewData->GetSfxDocShell());
2978 [ # # ]: 0 : if (bDisable)
2979 : 0 : return;
2980 : :
2981 [ # # ][ # # ]: 0 : if ( nCmd == COMMAND_CONTEXTMENU && !SC_MOD()->GetIsWaterCan() )
[ # # ]
2982 : : {
2983 : 0 : sal_Bool bMouse = rCEvt.IsMouseEvent();
2984 [ # # ][ # # ]: 0 : if ( bMouse && nMouseStatus == SC_GM_IGNORE )
2985 : : return;
2986 : :
2987 [ # # ]: 0 : if (pViewData->IsAnyFillMode())
2988 : : {
2989 [ # # ]: 0 : pViewData->GetView()->StopRefMode();
2990 [ # # ]: 0 : pViewData->ResetFillMode();
2991 : : }
2992 [ # # ]: 0 : ReleaseMouse();
2993 [ # # ]: 0 : StopMarking();
2994 : :
2995 : 0 : Point aPosPixel = rCEvt.GetMousePosPixel();
2996 : 0 : Point aMenuPos = aPosPixel;
2997 : :
2998 [ # # ]: 0 : if ( bMouse )
2999 : : {
3000 : 0 : SCsCOL nCellX = -1;
3001 : 0 : SCsROW nCellY = -1;
3002 [ # # ]: 0 : pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY);
3003 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
3004 : 0 : SCTAB nTab = pViewData->GetTabNo();
3005 [ # # ]: 0 : const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
3006 : 0 : bool bSelectAllowed = true;
3007 [ # # ][ # # ]: 0 : if ( pProtect && pProtect->isProtected() )
[ # # ][ # # ]
3008 : : {
3009 : : // This sheet is protected. Check if a context menu is allowed on this cell.
3010 [ # # ]: 0 : bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HASATTR_PROTECTED);
3011 [ # # ]: 0 : bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
3012 [ # # ]: 0 : bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
3013 : :
3014 [ # # ]: 0 : if (bCellProtected)
3015 : 0 : bSelectAllowed = bSelProtected;
3016 : : else
3017 : 0 : bSelectAllowed = bSelUnprotected;
3018 : : }
3019 [ # # ]: 0 : if (!bSelectAllowed)
3020 : : // Selecting this cell is not allowed, neither is context menu.
3021 : : return;
3022 : :
3023 : : // #i18735# First select the item under the mouse pointer.
3024 : : // This can change the selection, and the view state (edit mode, etc).
3025 [ # # ]: 0 : SelectForContextMenu( aPosPixel, nCellX, nCellY );
3026 : : }
3027 : :
3028 : 0 : sal_Bool bDone = false;
3029 : 0 : sal_Bool bEdit = pViewData->HasEditView(eWhich);
3030 [ # # ]: 0 : if ( !bEdit )
3031 : : {
3032 : : // Edit-Zelle mit Spelling-Errors ?
3033 [ # # ][ # # ]: 0 : if ( bMouse && GetEditUrlOrError( sal_True, aPosPixel ) )
[ # # ][ # # ]
3034 : : {
3035 : : // GetEditUrlOrError hat den Cursor schon bewegt
3036 : :
3037 [ # # ]: 0 : pScMod->SetInputMode( SC_INPUT_TABLE );
3038 : 0 : bEdit = pViewData->HasEditView(eWhich); // hat's geklappt ?
3039 : :
3040 : : OSL_ENSURE( bEdit, "kann nicht in Edit-Modus schalten" );
3041 : : }
3042 : : }
3043 [ # # ]: 0 : if ( bEdit )
3044 : : {
3045 : 0 : EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0
3046 : :
3047 [ # # ]: 0 : if ( !bMouse )
3048 : : {
3049 [ # # ]: 0 : Cursor* pCur = pEditView->GetCursor();
3050 [ # # ]: 0 : if ( pCur )
3051 : : {
3052 : 0 : Point aLogicPos = pCur->GetPos();
3053 : : // use the position right of the cursor (spell popup is opened if
3054 : : // the cursor is before the word, but not if behind it)
3055 : 0 : aLogicPos.X() += pCur->GetWidth();
3056 : 0 : aLogicPos.Y() += pCur->GetHeight() / 2; // center vertically
3057 [ # # ]: 0 : aMenuPos = LogicToPixel( aLogicPos );
3058 : : }
3059 : : }
3060 : :
3061 : : // if edit mode was just started above, online spelling may be incomplete
3062 [ # # ][ # # ]: 0 : pEditView->GetEditEngine()->CompleteOnlineSpelling();
3063 : :
3064 : : // IsCursorAtWrongSpelledWord could be used for !bMouse
3065 : : // if there was a corresponding ExecuteSpellPopup call
3066 : :
3067 [ # # ][ # # ]: 0 : if( pEditView->IsWrongSpelledWordAtPos( aMenuPos ) )
3068 : : {
3069 : : // Wenn man unter OS/2 neben das Popupmenue klickt, kommt MouseButtonDown
3070 : : // vor dem Ende des Menue-Execute, darum muss SetModified vorher kommen
3071 : : // (Bug #40968#)
3072 [ # # ]: 0 : ScInputHandler* pHdl = pScMod->GetInputHdl();
3073 [ # # ]: 0 : if (pHdl)
3074 : 0 : pHdl->SetModified();
3075 : :
3076 [ # # ]: 0 : Link aLink = LINK( this, ScGridWindow, PopupSpellingHdl );
3077 [ # # ]: 0 : pEditView->ExecuteSpellPopup( aMenuPos, &aLink );
3078 : :
3079 : 0 : bDone = sal_True;
3080 : : }
3081 : : }
3082 [ # # ]: 0 : else if ( !bMouse )
3083 : : {
3084 : : // non-edit menu by keyboard -> use lower right of cell cursor position
3085 : :
3086 : 0 : SCCOL nCurX = pViewData->GetCurX();
3087 : 0 : SCROW nCurY = pViewData->GetCurY();
3088 [ # # ]: 0 : aMenuPos = pViewData->GetScrPos( nCurX, nCurY, eWhich, sal_True );
3089 : : long nSizeXPix;
3090 : : long nSizeYPix;
3091 [ # # ]: 0 : pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix );
3092 : 0 : aMenuPos.X() += nSizeXPix;
3093 : 0 : aMenuPos.Y() += nSizeYPix;
3094 : :
3095 [ # # ]: 0 : if (pViewData)
3096 : : {
3097 : 0 : ScTabViewShell* pViewSh = pViewData->GetViewShell();
3098 [ # # ]: 0 : if (pViewSh)
3099 : : {
3100 : : // Is a draw object selected?
3101 : :
3102 [ # # ]: 0 : SdrView* pDrawView = pViewSh->GetSdrView();
3103 [ # # ][ # # ]: 0 : if (pDrawView && pDrawView->AreObjectsMarked())
[ # # ]
3104 : : {
3105 : : // #100442#; the conext menu should open in the middle of the selected objects
3106 [ # # ][ # # ]: 0 : Rectangle aSelectRect(LogicToPixel(pDrawView->GetAllMarkedBoundRect()));
3107 [ # # ]: 0 : aMenuPos = aSelectRect.Center();
3108 : : }
3109 : : }
3110 : : }
3111 : : }
3112 : :
3113 [ # # ]: 0 : if (!bDone)
3114 : : {
3115 [ # # ]: 0 : SfxDispatcher::ExecutePopup( 0, this, &aMenuPos );
3116 : : }
3117 : : }
3118 : : }
3119 : :
3120 : 0 : void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY )
3121 : : {
3122 : : // #i18735# if the click was outside of the current selection,
3123 : : // the cursor is moved or an object at the click position selected.
3124 : : // (see SwEditWin::SelectMenuPosition in Writer)
3125 : :
3126 [ # # ]: 0 : ScTabView* pView = pViewData->GetView();
3127 : 0 : ScDrawView* pDrawView = pView->GetScDrawView();
3128 : :
3129 : : // check cell edit mode
3130 : :
3131 [ # # ]: 0 : if ( pViewData->HasEditView(eWhich) )
3132 : : {
3133 [ # # ]: 0 : ScModule* pScMod = SC_MOD();
3134 : 0 : SCCOL nEditStartCol = pViewData->GetEditViewCol(); //! change to GetEditStartCol after calcrtl is integrated
3135 : 0 : SCROW nEditStartRow = pViewData->GetEditViewRow();
3136 : 0 : SCCOL nEditEndCol = pViewData->GetEditEndCol();
3137 : 0 : SCROW nEditEndRow = pViewData->GetEditEndRow();
3138 : :
3139 [ # # ][ # # ]: 0 : if ( nCellX >= (SCsCOL) nEditStartCol && nCellX <= (SCsCOL) nEditEndCol &&
[ # # ][ # # ]
3140 : : nCellY >= (SCsROW) nEditStartRow && nCellY <= (SCsROW) nEditEndRow )
3141 : : {
3142 : : // handle selection within the EditView
3143 : :
3144 : 0 : EditView* pEditView = pViewData->GetEditView( eWhich ); // not NULL (HasEditView)
3145 [ # # ]: 0 : EditEngine* pEditEngine = pEditView->GetEditEngine();
3146 [ # # ]: 0 : Rectangle aOutputArea = pEditView->GetOutputArea();
3147 [ # # ]: 0 : Rectangle aVisArea = pEditView->GetVisArea();
3148 : :
3149 [ # # ]: 0 : Point aTextPos = PixelToLogic( rPosPixel );
3150 [ # # ][ # # ]: 0 : if ( pEditEngine->IsVertical() ) // have to manually transform position
3151 : : {
3152 [ # # ]: 0 : aTextPos -= aOutputArea.TopRight();
3153 : 0 : long nTemp = -aTextPos.X();
3154 : 0 : aTextPos.X() = aTextPos.Y();
3155 : 0 : aTextPos.Y() = nTemp;
3156 : : }
3157 : : else
3158 : 0 : aTextPos -= aOutputArea.TopLeft();
3159 : 0 : aTextPos += aVisArea.TopLeft(); // position in the edit document
3160 : :
3161 [ # # ]: 0 : EPosition aDocPosition = pEditEngine->FindDocPosition(aTextPos);
3162 : 0 : ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
3163 [ # # ]: 0 : ESelection aSelection = pEditView->GetSelection();
3164 : 0 : aSelection.Adjust(); // needed for IsLess/IsGreater
3165 [ # # ][ # # ]: 0 : if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) )
[ # # ]
3166 : : {
3167 : : // clicked outside the selected text - deselect and move text cursor
3168 [ # # ]: 0 : MouseEvent aEvent( rPosPixel );
3169 [ # # ]: 0 : pEditView->MouseButtonDown( aEvent );
3170 [ # # ]: 0 : pEditView->MouseButtonUp( aEvent );
3171 [ # # ]: 0 : pScMod->InputSelection( pEditView );
3172 : : }
3173 : :
3174 : : return; // clicked within the edit view - keep edit mode
3175 : : }
3176 : : else
3177 : : {
3178 : : // outside of the edit view - end edit mode, regardless of cell selection, then continue
3179 [ # # ]: 0 : pScMod->InputEnterHandler();
3180 : : }
3181 : : }
3182 : :
3183 : : // check draw text edit mode
3184 : :
3185 [ # # ]: 0 : Point aLogicPos = PixelToLogic( rPosPixel ); // after cell edit mode is ended
3186 [ # # ][ # # ]: 0 : if ( pDrawView && pDrawView->GetTextEditObject() && pDrawView->GetTextEditOutlinerView() )
[ # # ][ # # ]
[ # # ]
3187 : : {
3188 : 0 : OutlinerView* pOlView = pDrawView->GetTextEditOutlinerView();
3189 [ # # ]: 0 : Rectangle aOutputArea = pOlView->GetOutputArea();
3190 [ # # ][ # # ]: 0 : if ( aOutputArea.IsInside( aLogicPos ) )
3191 : : {
3192 : : // handle selection within the OutlinerView
3193 : :
3194 : 0 : Outliner* pOutliner = pOlView->GetOutliner();
3195 : 0 : const EditEngine& rEditEngine = pOutliner->GetEditEngine();
3196 [ # # ]: 0 : Rectangle aVisArea = pOlView->GetVisArea();
3197 : :
3198 : 0 : Point aTextPos = aLogicPos;
3199 [ # # ][ # # ]: 0 : if ( pOutliner->IsVertical() ) // have to manually transform position
3200 : : {
3201 [ # # ]: 0 : aTextPos -= aOutputArea.TopRight();
3202 : 0 : long nTemp = -aTextPos.X();
3203 : 0 : aTextPos.X() = aTextPos.Y();
3204 : 0 : aTextPos.Y() = nTemp;
3205 : : }
3206 : : else
3207 : 0 : aTextPos -= aOutputArea.TopLeft();
3208 : 0 : aTextPos += aVisArea.TopLeft(); // position in the edit document
3209 : :
3210 [ # # ]: 0 : EPosition aDocPosition = rEditEngine.FindDocPosition(aTextPos);
3211 : 0 : ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
3212 [ # # ]: 0 : ESelection aSelection = pOlView->GetSelection();
3213 : 0 : aSelection.Adjust(); // needed for IsLess/IsGreater
3214 [ # # ][ # # ]: 0 : if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) )
[ # # ]
3215 : : {
3216 : : // clicked outside the selected text - deselect and move text cursor
3217 : : // use DrawView to allow extra handling there (none currently)
3218 [ # # ]: 0 : MouseEvent aEvent( rPosPixel );
3219 [ # # ]: 0 : pDrawView->MouseButtonDown( aEvent, this );
3220 [ # # ]: 0 : pDrawView->MouseButtonUp( aEvent, this );
3221 : : }
3222 : :
3223 : : return; // clicked within the edit area - keep edit mode
3224 : : }
3225 : : else
3226 : : {
3227 : : // Outside of the edit area - end text edit mode, then continue.
3228 : : // DrawDeselectAll also ends text edit mode and updates the shells.
3229 : : // If the click was on the edited object, it will be selected again below.
3230 [ # # ]: 0 : pView->DrawDeselectAll();
3231 : : }
3232 : : }
3233 : :
3234 : : // look for existing selection
3235 : :
3236 : 0 : sal_Bool bHitSelected = false;
3237 [ # # ][ # # ]: 0 : if ( pDrawView && pDrawView->IsMarkedObjHit( aLogicPos ) )
[ # # ][ # # ]
3238 : : {
3239 : : // clicked on selected object -> don't change anything
3240 : 0 : bHitSelected = sal_True;
3241 : : }
3242 [ # # ][ # # ]: 0 : else if ( pViewData->GetMarkData().IsCellMarked(nCellX, nCellY) )
[ # # ]
3243 : : {
3244 : : // clicked on selected cell -> don't change anything
3245 : 0 : bHitSelected = sal_True;
3246 : : }
3247 : :
3248 : : // select drawing object or move cell cursor
3249 : :
3250 [ # # ]: 0 : if ( !bHitSelected )
3251 : : {
3252 [ # # ][ # # ]: 0 : sal_Bool bWasDraw = ( pDrawView && pDrawView->AreObjectsMarked() );
3253 : 0 : sal_Bool bHitDraw = false;
3254 [ # # ]: 0 : if ( pDrawView )
3255 : : {
3256 [ # # ]: 0 : pDrawView->UnmarkAllObj();
3257 : : // Unlock the Internal Layer in order to activate the context menu.
3258 : : // re-lock in ScDrawView::MarkListHasChanged()
3259 [ # # ]: 0 : lcl_UnLockComment( pDrawView, pDrawView->GetSdrPageView(), pDrawView->GetModel(), aLogicPos ,pViewData);
3260 [ # # ]: 0 : bHitDraw = pDrawView->MarkObj( aLogicPos );
3261 : : // draw shell is activated in MarkListHasChanged
3262 : : }
3263 [ # # ]: 0 : if ( !bHitDraw )
3264 : : {
3265 [ # # ]: 0 : pView->Unmark();
3266 [ # # ]: 0 : pView->SetCursor(nCellX, nCellY);
3267 [ # # ]: 0 : if ( bWasDraw )
3268 [ # # ]: 0 : pViewData->GetViewShell()->SetDrawShell( false ); // switch shells
3269 : : }
3270 : : }
3271 : : }
3272 : :
3273 : 0 : void ScGridWindow::KeyInput(const KeyEvent& rKEvt)
3274 : : {
3275 : : // Cursor control for ref input dialog
3276 : 0 : const KeyCode& rKeyCode = rKEvt.GetKeyCode();
3277 [ # # ]: 0 : if( SC_MOD()->IsRefDialogOpen() )
3278 : : {
3279 [ # # ][ # # ]: 0 : if( !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
[ # # ]
3280 : : {
3281 : 0 : SC_MOD()->EndReference();
3282 : 0 : return;
3283 : : }
3284 [ # # ]: 0 : else if( pViewData->GetViewShell()->MoveCursorKeyInput( rKEvt ) )
3285 : : {
3286 : : ScRange aRef(
3287 : 0 : pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(),
3288 : 0 : pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() );
3289 [ # # ][ # # ]: 0 : SC_MOD()->SetReference( aRef, pViewData->GetDocument() );
[ # # ]
3290 : : return;
3291 : : }
3292 : : }
3293 [ # # ][ # # ]: 0 : else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() )
[ # # ]
3294 : : {
3295 : 0 : ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
3296 [ # # ]: 0 : ScClipUtil::PasteFromClipboard( pViewData, pTabViewShell, false );
3297 : :
3298 : : // Clear clipboard content.
3299 : : uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
3300 [ # # ]: 0 : TransferableHelper::GetSystemClipboard();
3301 [ # # ]: 0 : if (xSystemClipboard.is())
3302 : : {
3303 [ # # ]: 0 : xSystemClipboard->setContents(
3304 : : uno::Reference<datatransfer::XTransferable>(),
3305 [ # # ]: 0 : uno::Reference<datatransfer::clipboard::XClipboardOwner>());
3306 : : }
3307 : :
3308 : : // hide the border around the copy source
3309 : 0 : pViewData->SetPasteMode( SC_PASTE_NONE );
3310 [ # # ]: 0 : UpdateCopySourceOverlay();
3311 : 0 : return;
3312 : : }
3313 : : // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs:
3314 [ # # ]: 0 : else if( !pViewData->IsAnyFillMode() )
3315 : : {
3316 [ # # ]: 0 : if (rKeyCode.GetCode() == KEY_ESCAPE)
3317 : : {
3318 : 0 : pViewData->SetPasteMode( SC_PASTE_NONE );
3319 [ # # ]: 0 : UpdateCopySourceOverlay();
3320 : : }
3321 : : // query for existing note marker before calling ViewShell's keyboard handling
3322 : : // which may remove the marker
3323 [ # # ][ # # ]: 0 : sal_Bool bHadKeyMarker = ( pNoteMarker && pNoteMarker->IsByKeyboard() );
3324 : 0 : ScTabViewShell* pViewSh = pViewData->GetViewShell();
3325 : :
3326 [ # # ][ # # ]: 0 : if (pViewData->GetDocShell()->GetProgress())
3327 : : return;
3328 : :
3329 [ # # ][ # # ]: 0 : if (DrawKeyInput(rKEvt))
3330 : : return;
3331 : :
3332 [ # # ][ # # ]: 0 : if (!pViewData->GetView()->IsDrawSelMode() && !DrawHasMarkedObj()) // keine Eingaben im Zeichenmodus
[ # # ][ # # ]
3333 : : { //! DrawShell abfragen !!!
3334 [ # # ][ # # ]: 0 : if (pViewSh->TabKeyInput(rKEvt))
3335 : : return;
3336 : : }
3337 : : else
3338 [ # # ][ # # ]: 0 : if (pViewSh->SfxViewShell::KeyInput(rKEvt)) // von SfxViewShell
3339 : : return;
3340 : :
3341 : 0 : KeyCode aCode = rKEvt.GetKeyCode();
3342 [ # # ][ # # ]: 0 : if ( aCode.GetCode() == KEY_ESCAPE && aCode.GetModifier() == 0 )
[ # # ]
3343 : : {
3344 [ # # ]: 0 : if ( bHadKeyMarker )
3345 [ # # ]: 0 : HideNoteMarker();
3346 : : else
3347 [ # # ]: 0 : pViewSh->Escape();
3348 : : return;
3349 : : }
3350 [ # # ][ # # ]: 0 : if ( aCode.GetCode() == KEY_F1 && aCode.GetModifier() == KEY_MOD1 )
[ # # ]
3351 : : {
3352 : : // ctrl-F1 shows or hides the note or redlining info for the cursor position
3353 : : // (hard-coded because F1 can't be configured)
3354 : :
3355 [ # # ]: 0 : if ( bHadKeyMarker )
3356 [ # # ]: 0 : HideNoteMarker(); // hide when previously visible
3357 : : else
3358 [ # # ]: 0 : ShowNoteMarker( pViewData->GetCurX(), pViewData->GetCurY(), sal_True );
3359 : : return;
3360 : : }
3361 [ # # ][ # # ]: 0 : if (aCode.GetCode() == KEY_BRACKETLEFT && aCode.GetModifier() == KEY_MOD1)
[ # # ]
3362 : : {
3363 [ # # ]: 0 : pViewSh->DetectiveMarkPred();
3364 : : return;
3365 : : }
3366 [ # # ][ # # ]: 0 : if (aCode.GetCode() == KEY_BRACKETRIGHT && aCode.GetModifier() == KEY_MOD1)
[ # # ]
3367 : : {
3368 [ # # ]: 0 : pViewSh->DetectiveMarkSucc();
3369 : : return;
3370 : : }
3371 : :
3372 : : }
3373 : :
3374 : 0 : Window::KeyInput(rKEvt);
3375 : : }
3376 : :
3377 : 458 : void ScGridWindow::StopMarking()
3378 : : {
3379 : 458 : DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen
3380 : :
3381 [ - + ]: 458 : if (nButtonDown)
3382 : : {
3383 : 0 : pViewData->GetMarkData().SetMarking(false);
3384 : 0 : nMouseStatus = SC_GM_IGNORE;
3385 : : }
3386 : 458 : }
3387 : :
3388 : 532 : void ScGridWindow::UpdateInputContext()
3389 : : {
3390 [ + - ]: 532 : sal_Bool bReadOnly = pViewData->GetDocShell()->IsReadOnly();
3391 [ - + ]: 532 : sal_uLong nOptions = bReadOnly ? 0 : ( INPUTCONTEXT_TEXT | INPUTCONTEXT_EXTTEXTINPUT );
3392 : :
3393 : : // when font from InputContext is used,
3394 : : // it must be taken from the cursor position's cell attributes
3395 : :
3396 [ + - ]: 532 : InputContext aContext;
3397 : 532 : aContext.SetOptions( nOptions );
3398 [ + - ][ + - ]: 532 : SetInputContext( aContext );
3399 : 532 : }
3400 : :
3401 : : //--------------------------------------------------------
3402 : :
3403 : : // sensitiver Bereich (Pixel)
3404 : : #define SCROLL_SENSITIVE 20
3405 : :
3406 : 0 : bool ScGridWindow::DropScroll( const Point& rMousePos )
3407 : : {
3408 : 0 : SCsCOL nDx = 0;
3409 : 0 : SCsROW nDy = 0;
3410 : 0 : Size aSize = GetOutputSizePixel();
3411 : :
3412 [ # # ]: 0 : if (aSize.Width() > SCROLL_SENSITIVE * 3)
3413 : : {
3414 [ # # ][ # # ]: 0 : if ( rMousePos.X() < SCROLL_SENSITIVE && pViewData->GetPosX(WhichH(eWhich)) > 0 )
[ # # ]
3415 : 0 : nDx = -1;
3416 [ # # # # ]: 0 : if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE
[ # # ]
3417 : 0 : && pViewData->GetPosX(WhichH(eWhich)) < MAXCOL )
3418 : 0 : nDx = 1;
3419 : : }
3420 [ # # ]: 0 : if (aSize.Height() > SCROLL_SENSITIVE * 3)
3421 : : {
3422 [ # # ][ # # ]: 0 : if ( rMousePos.Y() < SCROLL_SENSITIVE && pViewData->GetPosY(WhichV(eWhich)) > 0 )
[ # # ]
3423 : 0 : nDy = -1;
3424 [ # # # # ]: 0 : if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE
[ # # ]
3425 : 0 : && pViewData->GetPosY(WhichV(eWhich)) < MAXROW )
3426 : 0 : nDy = 1;
3427 : : }
3428 : :
3429 [ # # ][ # # ]: 0 : if ( nDx != 0 || nDy != 0 )
3430 : : {
3431 [ # # ]: 0 : if ( nDx != 0 )
3432 [ # # ]: 0 : pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
3433 [ # # ]: 0 : if ( nDy != 0 )
3434 [ # # ]: 0 : pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
3435 : : }
3436 : :
3437 : 0 : return false;
3438 : : }
3439 : :
3440 : 0 : sal_Bool lcl_TestScenarioRedliningDrop( ScDocument* pDoc, const ScRange& aDragRange)
3441 : : {
3442 : : // Testet, ob bei eingeschalteten RedLining,
3443 : : // bei einem Drop ein Scenario betroffen ist.
3444 : :
3445 : 0 : sal_Bool bReturn = false;
3446 : 0 : SCTAB nTab = aDragRange.aStart.Tab();
3447 : 0 : SCTAB nTabCount = pDoc->GetTableCount();
3448 : :
3449 [ # # ]: 0 : if(pDoc->GetChangeTrack()!=NULL)
3450 : : {
3451 [ # # ][ # # ]: 0 : if( pDoc->IsScenario(nTab) && pDoc->HasScenarioRange(nTab, aDragRange))
[ # # ]
3452 : : {
3453 : 0 : bReturn = sal_True;
3454 : : }
3455 : : else
3456 : : {
3457 [ # # ][ # # ]: 0 : for(SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
[ # # ]
3458 : : {
3459 [ # # ]: 0 : if(pDoc->HasScenarioRange(i, aDragRange))
3460 : : {
3461 : 0 : bReturn = sal_True;
3462 : 0 : break;
3463 : : }
3464 : : }
3465 : : }
3466 : : }
3467 : 0 : return bReturn;
3468 : : }
3469 : :
3470 : 0 : ScRange lcl_MakeDropRange( SCCOL nPosX, SCROW nPosY, SCTAB nTab, const ScRange& rSource )
3471 : : {
3472 : 0 : SCCOL nCol1 = nPosX;
3473 : 0 : SCCOL nCol2 = nCol1 + ( rSource.aEnd.Col() - rSource.aStart.Col() );
3474 [ # # ]: 0 : if ( nCol2 > MAXCOL )
3475 : : {
3476 : 0 : nCol1 -= nCol2 - MAXCOL;
3477 : 0 : nCol2 = MAXCOL;
3478 : : }
3479 : 0 : SCROW nRow1 = nPosY;
3480 : 0 : SCROW nRow2 = nRow1 + ( rSource.aEnd.Row() - rSource.aStart.Row() );
3481 [ # # ]: 0 : if ( nRow2 > MAXROW )
3482 : : {
3483 : 0 : nRow1 -= nRow2 - MAXROW;
3484 : 0 : nRow2 = MAXROW;
3485 : : }
3486 : :
3487 : 0 : return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
3488 : : }
3489 : :
3490 : : //--------------------------------------------------------
3491 : :
3492 : : extern sal_Bool bPasteIsDrop; // viewfun4 -> move to header
3493 : : extern sal_Bool bPasteIsMove; // viewfun7 -> move to header
3494 : :
3495 : : //--------------------------------------------------------
3496 : :
3497 : 0 : sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt )
3498 : : {
3499 [ # # ]: 0 : if ( rEvt.mbLeaving )
3500 : : {
3501 : 0 : bDragRect = false;
3502 : 0 : UpdateDragRectOverlay();
3503 : 0 : return rEvt.mnAction;
3504 : : }
3505 : :
3506 : 0 : const ScDragData& rData = SC_MOD()->GetDragData();
3507 [ # # ]: 0 : if ( rData.pCellTransfer )
3508 : : {
3509 : : // Don't move source that would include filtered rows.
3510 [ # # ][ # # ]: 0 : if ((rEvt.mnAction & DND_ACTION_MOVE) && rData.pCellTransfer->HasFilteredRows())
[ # # ]
3511 : : {
3512 [ # # ]: 0 : if (bDragRect)
3513 : : {
3514 : 0 : bDragRect = false;
3515 [ # # ]: 0 : UpdateDragRectOverlay();
3516 : : }
3517 : 0 : return DND_ACTION_NONE;
3518 : : }
3519 : :
3520 : 0 : Point aPos = rEvt.maPosPixel;
3521 : :
3522 [ # # ]: 0 : ScDocument* pSourceDoc = rData.pCellTransfer->GetSourceDocument();
3523 [ # # ]: 0 : ScDocument* pThisDoc = pViewData->GetDocument();
3524 [ # # ]: 0 : if (pSourceDoc == pThisDoc)
3525 : : {
3526 : 0 : rtl::OUString aName;
3527 [ # # ][ # # ]: 0 : if ( pThisDoc->HasChartAtPoint(pViewData->GetTabNo(), PixelToLogic(aPos), aName ))
[ # # ]
3528 : : {
3529 [ # # ]: 0 : if (bDragRect) // Rechteck loeschen
3530 : : {
3531 : 0 : bDragRect = false;
3532 [ # # ]: 0 : UpdateDragRectOverlay();
3533 : : }
3534 : :
3535 : : //! highlight chart? (selection border?)
3536 : :
3537 : 0 : sal_Int8 nRet = rEvt.mnAction;
3538 : 0 : return nRet;
3539 [ # # ]: 0 : }
3540 : : }
3541 : :
3542 [ # # ]: 0 : if ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) // whole sheet?
3543 : : {
3544 [ # # ]: 0 : sal_Bool bOk = pThisDoc->IsDocEditable();
3545 [ # # ]: 0 : return bOk ? rEvt.mnAction : 0; // don't draw selection frame
3546 : : }
3547 : :
3548 : : SCsCOL nPosX;
3549 : : SCsROW nPosY;
3550 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
3551 : :
3552 : 0 : ScRange aSourceRange = rData.pCellTransfer->GetRange();
3553 : 0 : SCCOL nSourceStartX = aSourceRange.aStart.Col();
3554 : 0 : SCROW nSourceStartY = aSourceRange.aStart.Row();
3555 : 0 : SCCOL nSourceEndX = aSourceRange.aEnd.Col();
3556 : 0 : SCROW nSourceEndY = aSourceRange.aEnd.Row();
3557 : 0 : SCCOL nSizeX = nSourceEndX - nSourceStartX + 1;
3558 : 0 : SCROW nSizeY = nSourceEndY - nSourceStartY + 1;
3559 : :
3560 [ # # ]: 0 : if ( rEvt.mnAction != DND_ACTION_MOVE )
3561 : 0 : nSizeY = rData.pCellTransfer->GetNonFilteredRows(); // copy/link: no filtered rows
3562 : :
3563 : 0 : SCsCOL nNewDragX = nPosX - rData.pCellTransfer->GetDragHandleX();
3564 [ # # ]: 0 : if (nNewDragX<0) nNewDragX=0;
3565 [ # # ]: 0 : if (nNewDragX+(nSizeX-1) > MAXCOL)
3566 : 0 : nNewDragX = MAXCOL-(nSizeX-1);
3567 : 0 : SCsROW nNewDragY = nPosY - rData.pCellTransfer->GetDragHandleY();
3568 [ # # ]: 0 : if (nNewDragY<0) nNewDragY=0;
3569 [ # # ]: 0 : if (nNewDragY+(nSizeY-1) > MAXROW)
3570 : 0 : nNewDragY = MAXROW-(nSizeY-1);
3571 : :
3572 : : // don't break scenario ranges, don't drop on filtered
3573 : 0 : SCTAB nTab = pViewData->GetTabNo();
3574 : 0 : ScRange aDropRange = lcl_MakeDropRange( nNewDragX, nNewDragY, nTab, aSourceRange );
3575 [ # # ][ # # ]: 0 : if ( lcl_TestScenarioRedliningDrop( pThisDoc, aDropRange ) ||
[ # # ][ # # ]
[ # # ]
3576 [ # # ]: 0 : lcl_TestScenarioRedliningDrop( pSourceDoc, aSourceRange ) ||
3577 [ # # ]: 0 : ScViewUtil::HasFiltered( aDropRange, pThisDoc) )
3578 : : {
3579 [ # # ]: 0 : if (bDragRect)
3580 : : {
3581 : 0 : bDragRect = false;
3582 [ # # ]: 0 : UpdateDragRectOverlay();
3583 : : }
3584 : 0 : return DND_ACTION_NONE;
3585 : : }
3586 : :
3587 : 0 : InsCellCmd eDragInsertMode = INS_NONE;
3588 [ # # ]: 0 : Window::PointerState aState = GetPointerState();
3589 : :
3590 : : // check for datapilot item sorting
3591 : 0 : ScDPObject* pDPObj = NULL;
3592 [ # # ][ # # ]: 0 : if ( pThisDoc == pSourceDoc && ( pDPObj = pThisDoc->GetDPAtCursor( nNewDragX, nNewDragY, nTab ) ) != NULL )
[ # # ][ # # ]
3593 : : {
3594 : : // drop on DataPilot table: sort or nothing
3595 : :
3596 : 0 : bool bDPSort = false;
3597 [ # # ][ # # ]: 0 : if ( pThisDoc->GetDPAtCursor( nSourceStartX, nSourceStartY, aSourceRange.aStart.Tab() ) == pDPObj )
3598 : : {
3599 : 0 : sheet::DataPilotTableHeaderData aDestData;
3600 [ # # ]: 0 : pDPObj->GetHeaderPositionData( ScAddress(nNewDragX, nNewDragY, nTab), aDestData );
3601 : 0 : bool bValid = ( aDestData.Dimension >= 0 ); // dropping onto a field
3602 : :
3603 : : // look through the source range
3604 [ # # ][ # # ]: 0 : for (SCROW nRow = aSourceRange.aStart.Row(); bValid && nRow <= aSourceRange.aEnd.Row(); ++nRow )
[ # # ]
3605 [ # # ][ # # ]: 0 : for (SCCOL nCol = aSourceRange.aStart.Col(); bValid && nCol <= aSourceRange.aEnd.Col(); ++nCol )
[ # # ]
3606 : : {
3607 : 0 : sheet::DataPilotTableHeaderData aSourceData;
3608 [ # # ]: 0 : pDPObj->GetHeaderPositionData( ScAddress( nCol, nRow, aSourceRange.aStart.Tab() ), aSourceData );
3609 [ # # ][ # # ]: 0 : if ( aSourceData.Dimension != aDestData.Dimension || aSourceData.MemberName.isEmpty() )
[ # # ]
3610 : 0 : bValid = false; // empty (subtotal) or different field
3611 : 0 : }
3612 : :
3613 [ # # ]: 0 : if ( bValid )
3614 : : {
3615 : : bool bIsDataLayout;
3616 [ # # ]: 0 : OUString aDimName = pDPObj->GetDimName( aDestData.Dimension, bIsDataLayout );
3617 [ # # ]: 0 : const ScDPSaveDimension* pDim = pDPObj->GetSaveData()->GetExistingDimensionByName( aDimName );
3618 [ # # ]: 0 : if ( pDim )
3619 : : {
3620 : 0 : ScRange aOutRange = pDPObj->GetOutRange();
3621 : :
3622 : 0 : sal_uInt16 nOrient = pDim->GetOrientation();
3623 [ # # ]: 0 : if ( nOrient == sheet::DataPilotFieldOrientation_COLUMN )
3624 : : {
3625 : 0 : eDragInsertMode = INS_CELLSRIGHT;
3626 : 0 : nSizeY = aOutRange.aEnd.Row() - nNewDragY + 1;
3627 : 0 : bDPSort = true;
3628 : : }
3629 [ # # ]: 0 : else if ( nOrient == sheet::DataPilotFieldOrientation_ROW )
3630 : : {
3631 : 0 : eDragInsertMode = INS_CELLSDOWN;
3632 : 0 : nSizeX = aOutRange.aEnd.Col() - nNewDragX + 1;
3633 : 0 : bDPSort = true;
3634 : : }
3635 : 0 : }
3636 : 0 : }
3637 : : }
3638 : :
3639 [ # # ]: 0 : if ( !bDPSort )
3640 : : {
3641 : : // no valid sorting in a DataPilot table -> disallow
3642 [ # # ]: 0 : if ( bDragRect )
3643 : : {
3644 : 0 : bDragRect = false;
3645 [ # # ]: 0 : UpdateDragRectOverlay();
3646 : : }
3647 : 0 : return DND_ACTION_NONE;
3648 : : }
3649 : : }
3650 [ # # ]: 0 : else if ( aState.mnState & KEY_MOD2 )
3651 : : {
3652 [ # # ][ # # ]: 0 : if ( pThisDoc == pSourceDoc && nTab == aSourceRange.aStart.Tab() )
[ # # ]
3653 : : {
3654 : 0 : long nDeltaX = labs( static_cast< long >( nNewDragX - nSourceStartX ) );
3655 : 0 : long nDeltaY = labs( static_cast< long >( nNewDragY - nSourceStartY ) );
3656 [ # # ]: 0 : if ( nDeltaX <= nDeltaY )
3657 : : {
3658 : 0 : eDragInsertMode = INS_CELLSDOWN;
3659 : : }
3660 : : else
3661 : : {
3662 : 0 : eDragInsertMode = INS_CELLSRIGHT;
3663 : : }
3664 : :
3665 [ # # ][ # # ]: 0 : if ( ( eDragInsertMode == INS_CELLSDOWN && nNewDragY <= nSourceEndY &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
3666 : : ( nNewDragX + nSizeX - 1 ) >= nSourceStartX && nNewDragX <= nSourceEndX &&
3667 : : ( nNewDragX != nSourceStartX || nNewDragY >= nSourceStartY ) ) ||
3668 : : ( eDragInsertMode == INS_CELLSRIGHT && nNewDragX <= nSourceEndX &&
3669 : : ( nNewDragY + nSizeY - 1 ) >= nSourceStartY && nNewDragY <= nSourceEndY &&
3670 : : ( nNewDragY != nSourceStartY || nNewDragX >= nSourceStartX ) ) )
3671 : : {
3672 [ # # ]: 0 : if ( bDragRect )
3673 : : {
3674 : 0 : bDragRect = false;
3675 [ # # ]: 0 : UpdateDragRectOverlay();
3676 : : }
3677 : 0 : return DND_ACTION_NONE;
3678 : : }
3679 : : }
3680 : : else
3681 : : {
3682 [ # # ]: 0 : if ( static_cast< long >( nSizeX ) >= static_cast< long >( nSizeY ) )
3683 : : {
3684 : 0 : eDragInsertMode = INS_CELLSDOWN;
3685 : :
3686 : : }
3687 : : else
3688 : : {
3689 : 0 : eDragInsertMode = INS_CELLSRIGHT;
3690 : : }
3691 : : }
3692 : : }
3693 : :
3694 [ # # ][ # # ]: 0 : if ( nNewDragX != (SCsCOL) nDragStartX || nNewDragY != (SCsROW) nDragStartY ||
[ # # ][ # # ]
[ # # ][ # # ]
3695 : : nDragStartX+nSizeX-1 != nDragEndX || nDragStartY+nSizeY-1 != nDragEndY ||
3696 : 0 : !bDragRect || eDragInsertMode != meDragInsertMode )
3697 : : {
3698 : 0 : nDragStartX = nNewDragX;
3699 : 0 : nDragStartY = nNewDragY;
3700 : 0 : nDragEndX = nDragStartX+nSizeX-1;
3701 : 0 : nDragEndY = nDragStartY+nSizeY-1;
3702 : 0 : bDragRect = true;
3703 : 0 : meDragInsertMode = eDragInsertMode;
3704 : :
3705 [ # # ]: 0 : UpdateDragRectOverlay();
3706 : : }
3707 : : }
3708 : :
3709 : 0 : return rEvt.mnAction;
3710 : : }
3711 : :
3712 : 0 : sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt )
3713 : : {
3714 : 0 : const ScDragData& rData = SC_MOD()->GetDragData();
3715 [ # # ]: 0 : if ( rEvt.mbLeaving )
3716 : : {
3717 : 0 : DrawMarkDropObj( NULL );
3718 [ # # ]: 0 : if ( rData.pCellTransfer )
3719 : 0 : return AcceptPrivateDrop( rEvt ); // hide drop marker for internal D&D
3720 : : else
3721 : 0 : return rEvt.mnAction;
3722 : : }
3723 : :
3724 [ # # ]: 0 : if ( pViewData->GetDocShell()->IsReadOnly() )
3725 : 0 : return DND_ACTION_NONE;
3726 : :
3727 : :
3728 : 0 : sal_Int8 nRet = DND_ACTION_NONE;
3729 : :
3730 [ # # ]: 0 : if (rData.pCellTransfer)
3731 : : {
3732 : 0 : ScRange aSource = rData.pCellTransfer->GetRange();
3733 [ # # # # : 0 : if ( aSource.aStart.Col() != 0 || aSource.aEnd.Col() != MAXCOL ||
# # ][ # # ]
[ # # ]
3734 : 0 : aSource.aStart.Row() != 0 || aSource.aEnd.Row() != MAXROW )
3735 [ # # ]: 0 : DropScroll( rEvt.maPosPixel );
3736 : :
3737 [ # # ]: 0 : nRet = AcceptPrivateDrop( rEvt );
3738 : : }
3739 : : else
3740 : : {
3741 [ # # ]: 0 : if ( !rData.aLinkDoc.isEmpty() )
3742 : : {
3743 : 0 : rtl::OUString aThisName;
3744 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
3745 [ # # ][ # # ]: 0 : if (pDocSh && pDocSh->HasName())
[ # # ]
3746 [ # # ]: 0 : aThisName = pDocSh->GetMedium()->GetName();
3747 : :
3748 [ # # ]: 0 : if ( !rData.aLinkDoc.equals(aThisName) )
3749 : 0 : nRet = rEvt.mnAction;
3750 : : }
3751 [ # # ]: 0 : else if (!rData.aJumpTarget.isEmpty())
3752 : : {
3753 : : // internal bookmarks (from Navigator)
3754 : : // local jumps from an unnamed document are possible only within a document
3755 : :
3756 [ # # ][ # # ]: 0 : if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() )
[ # # ]
3757 : 0 : nRet = rEvt.mnAction;
3758 : : }
3759 : : else
3760 : : {
3761 : 0 : sal_Int8 nMyAction = rEvt.mnAction;
3762 : :
3763 [ # # # # ]: 0 : if ( !rData.pDrawTransfer ||
[ # # ]
3764 : 0 : !IsMyModel(rData.pDrawTransfer->GetDragSourceView()) ) // drawing within the document
3765 [ # # ][ # # ]: 0 : if ( rEvt.mbDefault && nMyAction == DND_ACTION_MOVE )
3766 : 0 : nMyAction = DND_ACTION_COPY;
3767 : :
3768 : 0 : ScDocument* pThisDoc = pViewData->GetDocument();
3769 : : SdrObject* pHitObj = pThisDoc->GetObjectAtPoint(
3770 [ # # ]: 0 : pViewData->GetTabNo(), PixelToLogic(rEvt.maPosPixel) );
3771 [ # # ][ # # ]: 0 : if ( pHitObj && nMyAction == DND_ACTION_LINK && !rData.pDrawTransfer )
[ # # ]
3772 : : {
3773 [ # # # # : 0 : if ( IsDropFormatSupported(SOT_FORMATSTR_ID_SVXB)
# # ][ # # ]
3774 : 0 : || IsDropFormatSupported(SOT_FORMAT_GDIMETAFILE)
3775 : 0 : || IsDropFormatSupported(SOT_FORMAT_BITMAP) )
3776 : : {
3777 : : // graphic dragged onto drawing object
3778 : 0 : DrawMarkDropObj( pHitObj );
3779 : 0 : nRet = nMyAction;
3780 : : }
3781 : : }
3782 [ # # ]: 0 : if (!nRet)
3783 : 0 : DrawMarkDropObj( NULL );
3784 : :
3785 [ # # ]: 0 : if (!nRet)
3786 : : {
3787 [ # # # ]: 0 : switch ( nMyAction )
3788 : : {
3789 : : case DND_ACTION_COPY:
3790 : : case DND_ACTION_MOVE:
3791 : : case DND_ACTION_COPYMOVE:
3792 : : {
3793 : 0 : sal_Bool bMove = ( nMyAction == DND_ACTION_MOVE );
3794 [ # # # # : 0 : if ( IsDropFormatSupported( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ][ # #
# # # # #
# # # # #
# # ][ # # ]
3795 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
3796 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ||
3797 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
3798 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
3799 : 0 : IsDropFormatSupported( SOT_FORMAT_STRING ) ||
3800 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_SYLK ) ||
3801 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) ||
3802 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_HTML ) ||
3803 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_HTML_SIMPLE ) ||
3804 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_DIF ) ||
3805 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING ) ||
3806 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB ) ||
3807 : 0 : IsDropFormatSupported( SOT_FORMAT_RTF ) ||
3808 : 0 : IsDropFormatSupported( SOT_FORMAT_GDIMETAFILE ) ||
3809 : 0 : IsDropFormatSupported( SOT_FORMAT_BITMAP ) ||
3810 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) ||
3811 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) ||
3812 : : ( !bMove && (
3813 : 0 : IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) ||
3814 : 0 : IsDropFormatSupported( SOT_FORMAT_FILE ) ||
3815 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
3816 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
3817 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) ||
3818 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ) ) )
3819 : : {
3820 : 0 : nRet = nMyAction;
3821 : : }
3822 : : }
3823 : 0 : break;
3824 : : case DND_ACTION_LINK:
3825 [ # # # # : 0 : if ( IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
# # # # #
# # # # #
# # # # ]
[ # # ]
3826 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
3827 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) ||
3828 : 0 : IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) ||
3829 : 0 : IsDropFormatSupported( SOT_FORMAT_FILE ) ||
3830 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
3831 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
3832 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) ||
3833 : 0 : IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) )
3834 : : {
3835 : 0 : nRet = nMyAction;
3836 : : }
3837 : 0 : break;
3838 : : }
3839 : :
3840 [ # # ]: 0 : if ( nRet )
3841 : : {
3842 : : // Simple check for protection: It's not known here if the drop will result
3843 : : // in cells or drawing objects (some formats can be both) and how many cells
3844 : : // the result will be. But if IsFormatEditable for the drop cell position
3845 : : // is sal_False (ignores matrix formulas), nothing can be pasted, so the drop
3846 : : // can already be rejected here.
3847 : :
3848 : 0 : Point aPos = rEvt.maPosPixel;
3849 : : SCsCOL nPosX;
3850 : : SCsROW nPosY;
3851 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
3852 : 0 : SCTAB nTab = pViewData->GetTabNo();
3853 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
3854 : :
3855 [ # # ]: 0 : ScEditableTester aTester( pDoc, nTab, nPosX,nPosY, nPosX,nPosY );
3856 [ # # ]: 0 : if ( !aTester.IsFormatEditable() )
3857 : 0 : nRet = DND_ACTION_NONE; // forbidden
3858 : : }
3859 : : }
3860 : : }
3861 : :
3862 : : // scroll only for accepted formats
3863 [ # # ]: 0 : if (nRet)
3864 : 0 : DropScroll( rEvt.maPosPixel );
3865 : : }
3866 : :
3867 : 0 : return nRet;
3868 : : }
3869 : :
3870 : 0 : sal_uLong lcl_GetDropFormatId( const uno::Reference<datatransfer::XTransferable>& xTransfer, bool bPreferText = false )
3871 : : {
3872 [ # # ]: 0 : TransferableDataHelper aDataHelper( xTransfer );
3873 : :
3874 [ # # ][ # # ]: 0 : if ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) )
3875 : : {
3876 : : // use bookmark formats if no sba is present
3877 : :
3878 [ # # ][ # # ]: 0 : if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) )
3879 : 0 : return SOT_FORMATSTR_ID_SOLK;
3880 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) )
3881 : 0 : return SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR;
3882 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) )
3883 : 0 : return SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
3884 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) )
3885 : 0 : return SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR;
3886 : : }
3887 : :
3888 : 0 : sal_uLong nFormatId = 0;
3889 [ # # ][ # # ]: 0 : if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
3890 : 0 : nFormatId = SOT_FORMATSTR_ID_DRAWING;
3891 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
3892 : 0 : nFormatId = SOT_FORMATSTR_ID_SVXB;
3893 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) )
3894 : : {
3895 : : // If it's a Writer object, insert RTF instead of OLE
3896 : :
3897 : 0 : sal_Bool bDoRtf = false;
3898 : 0 : SotStorageStreamRef xStm;
3899 [ # # ]: 0 : TransferableObjectDescriptor aObjDesc;
3900 [ # # ][ # # ]: 0 : if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
[ # # ][ # # ]
3901 [ # # ]: 0 : aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) )
3902 : : {
3903 [ # # ][ # # ]: 0 : SotStorageRef xStore( new SotStorage( *xStm ) );
3904 [ # # ][ # # ]: 0 : bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) ||
[ # # ][ # # ]
[ # # ]
3905 [ # # ][ # # ]: 0 : aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) )
[ # # ][ # # ]
[ # # ]
3906 [ # # ][ # # ]: 0 : && aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
[ # # ][ # # ]
[ # # ]
3907 : : }
3908 [ # # ]: 0 : if ( bDoRtf )
3909 : 0 : nFormatId = FORMAT_RTF;
3910 : : else
3911 [ # # ][ # # ]: 0 : nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE;
3912 : : }
3913 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) )
3914 : 0 : nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE;
3915 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) )
3916 : 0 : nFormatId = SOT_FORMATSTR_ID_SBA_DATAEXCHANGE;
3917 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) )
3918 : 0 : nFormatId = SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE;
3919 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_BIFF_8 ) )
3920 : 0 : nFormatId = SOT_FORMATSTR_ID_BIFF_8;
3921 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_BIFF_5 ) )
3922 : 0 : nFormatId = SOT_FORMATSTR_ID_BIFF_5;
3923 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) )
3924 : 0 : nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE;
3925 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) )
3926 : 0 : nFormatId = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE;
3927 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) )
3928 : 0 : nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE;
3929 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
3930 : 0 : nFormatId = SOT_FORMAT_RTF;
3931 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML ) )
3932 : 0 : nFormatId = SOT_FORMATSTR_ID_HTML;
3933 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) )
3934 : 0 : nFormatId = SOT_FORMATSTR_ID_HTML_SIMPLE;
3935 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SYLK ) )
3936 : 0 : nFormatId = SOT_FORMATSTR_ID_SYLK;
3937 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK ) )
3938 : 0 : nFormatId = SOT_FORMATSTR_ID_LINK;
3939 [ # # ][ # # ]: 0 : else if ( bPreferText && aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) // #i86734# the behaviour introduced in #i62773# is wrong when pasting
[ # # ][ # # ]
3940 : 0 : nFormatId = SOT_FORMAT_STRING;
3941 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) )
3942 : 0 : nFormatId = SOT_FORMAT_FILE_LIST;
3943 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE ) ) // #i62773# FILE_LIST/FILE before STRING (Unix file managers)
3944 : 0 : nFormatId = SOT_FORMAT_FILE;
3945 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
3946 : 0 : nFormatId = SOT_FORMAT_STRING;
3947 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) )
3948 : 0 : nFormatId = SOT_FORMAT_GDIMETAFILE;
3949 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) )
3950 : 0 : nFormatId = SOT_FORMAT_BITMAP;
3951 : :
3952 [ # # ]: 0 : return nFormatId;
3953 : : }
3954 : :
3955 : 0 : sal_uLong lcl_GetDropLinkId( const uno::Reference<datatransfer::XTransferable>& xTransfer )
3956 : : {
3957 [ # # ]: 0 : TransferableDataHelper aDataHelper( xTransfer );
3958 : :
3959 : 0 : sal_uLong nFormatId = 0;
3960 [ # # ][ # # ]: 0 : if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) )
3961 : 0 : nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE;
3962 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) )
3963 : 0 : nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE;
3964 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK ) )
3965 : 0 : nFormatId = SOT_FORMATSTR_ID_LINK;
3966 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) )
3967 : 0 : nFormatId = SOT_FORMAT_FILE_LIST;
3968 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE ) )
3969 : 0 : nFormatId = SOT_FORMAT_FILE;
3970 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) )
3971 : 0 : nFormatId = SOT_FORMATSTR_ID_SOLK;
3972 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) )
3973 : 0 : nFormatId = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR;
3974 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) )
3975 : 0 : nFormatId = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
3976 [ # # ][ # # ]: 0 : else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) )
3977 : 0 : nFormatId = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR;
3978 : :
3979 [ # # ]: 0 : return nFormatId;
3980 : : }
3981 : :
3982 : :
3983 : 0 : sal_Int8 ScGridWindow::ExecutePrivateDrop( const ExecuteDropEvent& rEvt )
3984 : : {
3985 : : // hide drop marker
3986 : 0 : bDragRect = false;
3987 : 0 : UpdateDragRectOverlay();
3988 : :
3989 : 0 : ScModule* pScMod = SC_MOD();
3990 : 0 : const ScDragData& rData = pScMod->GetDragData();
3991 : :
3992 : : return DropTransferObj( rData.pCellTransfer, nDragStartX, nDragStartY,
3993 [ # # ]: 0 : PixelToLogic(rEvt.maPosPixel), rEvt.mnAction );
3994 : : }
3995 : :
3996 : 0 : sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
3997 : : const Point& rLogicPos, sal_Int8 nDndAction )
3998 : : {
3999 [ # # ]: 0 : if ( !pTransObj )
4000 : 0 : return 0;
4001 : :
4002 [ # # ]: 0 : ScDocument* pSourceDoc = pTransObj->GetSourceDocument();
4003 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
4004 [ # # ]: 0 : ScDocument* pThisDoc = pViewData->GetDocument();
4005 [ # # ]: 0 : ScViewFunc* pView = pViewData->GetView();
4006 : 0 : SCTAB nThisTab = pViewData->GetTabNo();
4007 : 0 : sal_uInt16 nFlags = pTransObj->GetDragSourceFlags();
4008 : :
4009 : 0 : sal_Bool bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0;
4010 [ # # ][ # # ]: 0 : sal_Bool bIsMove = ( nDndAction == DND_ACTION_MOVE && !bIsNavi );
4011 : :
4012 : : // workaround for wrong nDndAction on Windows when pressing solely
4013 : : // the Alt key during drag and drop;
4014 : : // can be removed after #i79215# has been fixed
4015 [ # # ]: 0 : if ( meDragInsertMode != INS_NONE )
4016 : : {
4017 [ # # ][ # # ]: 0 : bIsMove = ( nDndAction & DND_ACTION_MOVE && !bIsNavi );
4018 : : }
4019 : :
4020 : 0 : sal_Bool bIsLink = ( nDndAction == DND_ACTION_LINK );
4021 : :
4022 : 0 : ScRange aSource = pTransObj->GetRange();
4023 : :
4024 : : // only use visible tab from source range - when dragging within one table,
4025 : : // all selected tables at the time of dropping are used (handled in MoveBlockTo)
4026 : 0 : SCTAB nSourceTab = pTransObj->GetVisibleTab();
4027 : 0 : aSource.aStart.SetTab( nSourceTab );
4028 : 0 : aSource.aEnd.SetTab( nSourceTab );
4029 : :
4030 : 0 : SCCOL nSizeX = aSource.aEnd.Col() - aSource.aStart.Col() + 1;
4031 : 0 : SCROW nSizeY = (bIsMove ? (aSource.aEnd.Row() - aSource.aStart.Row() + 1) :
4032 [ # # ]: 0 : pTransObj->GetNonFilteredRows()); // copy/link: no filtered rows
4033 : : ScRange aDest( nDestPosX, nDestPosY, nThisTab,
4034 : 0 : nDestPosX + nSizeX - 1, nDestPosY + nSizeY - 1, nThisTab );
4035 : :
4036 : :
4037 : : /* NOTE: AcceptPrivateDrop() already checked for filtered conditions during
4038 : : * dragging and adapted drawing of the selection frame. We check here
4039 : : * (again) because this may actually also be called from PasteSelection(),
4040 : : * we would have to duplicate determination of flags and destination range
4041 : : * and would lose the context of the "filtered destination is OK" cases
4042 : : * below, which is already awkward enough as is. */
4043 : :
4044 : : // Don't move filtered source.
4045 [ # # ][ # # ]: 0 : bool bFiltered = (bIsMove && pTransObj->HasFilteredRows());
4046 [ # # ]: 0 : if (!bFiltered)
4047 : : {
4048 [ # # ][ # # ]: 0 : if (pSourceDoc != pThisDoc && ((nFlags & SC_DROP_TABLE) ||
[ # # ][ # # ]
4049 : : (!bIsLink && meDragInsertMode == INS_NONE)))
4050 : : {
4051 : : // Nothing. Either entire sheet to be dropped, or the one case
4052 : : // where PasteFromClip() is to be called that handles a filtered
4053 : : // destination itself. Drag-copy from another document without
4054 : : // inserting cells.
4055 : : }
4056 : : else
4057 : : // Don't copy or move to filtered destination.
4058 [ # # ]: 0 : bFiltered = ScViewUtil::HasFiltered( aDest, pThisDoc);
4059 : : }
4060 : :
4061 : 0 : sal_Bool bDone = false;
4062 : :
4063 [ # # ][ # # ]: 0 : if (!bFiltered && pSourceDoc == pThisDoc)
4064 : : {
4065 [ # # ]: 0 : if ( nFlags & SC_DROP_TABLE ) // whole sheet?
4066 : : {
4067 [ # # ][ # # ]: 0 : if ( pThisDoc->IsDocEditable() )
4068 : : {
4069 : 0 : SCTAB nSrcTab = aSource.aStart.Tab();
4070 [ # # ]: 0 : pViewData->GetDocShell()->MoveTable( nSrcTab, nThisTab, !bIsMove, sal_True ); // with Undo
4071 [ # # ]: 0 : pView->SetTabNo( nThisTab, sal_True );
4072 : 0 : bDone = sal_True;
4073 : : }
4074 : : }
4075 : : else // move/copy block
4076 : : {
4077 : 0 : rtl::OUString aChartName;
4078 [ # # ][ # # ]: 0 : if (pThisDoc->HasChartAtPoint( nThisTab, rLogicPos, aChartName ))
4079 : : {
4080 [ # # ]: 0 : String aRangeName;
4081 [ # # ]: 0 : aSource.Format( aRangeName, SCR_ABS_3D, pThisDoc );
4082 [ # # ][ # # ]: 0 : SfxStringItem aNameItem( SID_CHART_NAME, aChartName );
[ # # ]
4083 [ # # ]: 0 : SfxStringItem aRangeItem( SID_CHART_SOURCE, aRangeName );
4084 [ # # ]: 0 : sal_uInt16 nId = bIsMove ? SID_CHART_SOURCE : SID_CHART_ADDSOURCE;
4085 [ # # ]: 0 : pViewData->GetDispatcher().Execute( nId, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
4086 [ # # ]: 0 : &aRangeItem, &aNameItem, (void*) NULL );
4087 [ # # ][ # # ]: 0 : bDone = sal_True;
[ # # ]
4088 : : }
4089 [ # # ][ # # ]: 0 : else if ( pThisDoc->GetDPAtCursor( nDestPosX, nDestPosY, nThisTab ) )
4090 : : {
4091 : : // drop on DataPilot table: try to sort, fail if that isn't possible
4092 : :
4093 : 0 : ScAddress aDestPos( nDestPosX, nDestPosY, nThisTab );
4094 [ # # ]: 0 : if ( aDestPos != aSource.aStart )
4095 [ # # ]: 0 : bDone = pViewData->GetView()->DataPilotMove( aSource, aDestPos );
4096 : : else
4097 : 0 : bDone = sal_True; // same position: nothing
4098 : : }
4099 [ # # ][ # # ]: 0 : else if ( nDestPosX != aSource.aStart.Col() || nDestPosY != aSource.aStart.Row() ||
[ # # ][ # # ]
4100 : : nSourceTab != nThisTab )
4101 : : {
4102 [ # # ][ # # ]: 0 : String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
[ # # ]
4103 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
4104 : :
4105 : 0 : SCsCOL nCorrectCursorPosCol = 0;
4106 : 0 : SCsROW nCorrectCursorPosRow = 0;
4107 : :
4108 : 0 : bDone = sal_True;
4109 [ # # ]: 0 : if ( meDragInsertMode != INS_NONE )
4110 : : {
4111 : : // call with bApi = sal_True to avoid error messages in drop handler
4112 [ # # ]: 0 : bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, sal_True /*bRecord*/, sal_True /*bApi*/, sal_True /*bPartOfPaste*/ );
4113 [ # # ]: 0 : if ( bDone )
4114 : : {
4115 [ # # ]: 0 : if ( nThisTab == nSourceTab )
4116 : : {
4117 [ # # # # : 0 : if ( meDragInsertMode == INS_CELLSDOWN &&
# # ][ # # ]
4118 : 0 : nDestPosX == aSource.aStart.Col() && nDestPosY < aSource.aStart.Row() )
4119 : : {
4120 [ # # ]: 0 : bDone = aSource.Move( 0, nSizeY, 0, pSourceDoc );
4121 : 0 : nCorrectCursorPosRow = nSizeY;
4122 : : }
4123 [ # # # # : 0 : else if ( meDragInsertMode == INS_CELLSRIGHT &&
# # ][ # # ]
4124 : 0 : nDestPosY == aSource.aStart.Row() && nDestPosX < aSource.aStart.Col() )
4125 : : {
4126 [ # # ]: 0 : bDone = aSource.Move( nSizeX, 0, 0, pSourceDoc );
4127 : 0 : nCorrectCursorPosCol = nSizeX;
4128 : : }
4129 : : }
4130 [ # # ]: 0 : pDocSh->UpdateOle( pViewData );
4131 [ # # ]: 0 : pView->CellContentChanged();
4132 : : }
4133 : : }
4134 : :
4135 [ # # ]: 0 : if ( bDone )
4136 : : {
4137 [ # # ]: 0 : if ( bIsLink )
4138 : : {
4139 : : // call with bApi = sal_True to avoid error messages in drop handler
4140 [ # # ]: 0 : bDone = pView->LinkBlock( aSource, aDest.aStart, sal_True /*bApi*/ );
4141 : : }
4142 : : else
4143 : : {
4144 : : // call with bApi = sal_True to avoid error messages in drop handler
4145 [ # # ]: 0 : bDone = pView->MoveBlockTo( aSource, aDest.aStart, bIsMove, sal_True /*bRecord*/, sal_True /*bPaint*/, sal_True /*bApi*/ );
4146 : : }
4147 : : }
4148 : :
4149 [ # # ][ # # ]: 0 : if ( bDone && meDragInsertMode != INS_NONE && bIsMove && nThisTab == nSourceTab )
[ # # ][ # # ]
4150 : : {
4151 : 0 : DelCellCmd eCmd = DEL_NONE;
4152 [ # # ]: 0 : if ( meDragInsertMode == INS_CELLSDOWN )
4153 : : {
4154 : 0 : eCmd = DEL_CELLSUP;
4155 : : }
4156 [ # # ]: 0 : else if ( meDragInsertMode == INS_CELLSRIGHT )
4157 : : {
4158 : 0 : eCmd = DEL_CELLSLEFT;
4159 : : }
4160 : :
4161 [ # # ][ # # ]: 0 : if ( ( eCmd == DEL_CELLSUP && nDestPosX == aSource.aStart.Col() ) ||
[ # # # # ]
[ # # ]
4162 : 0 : ( eCmd == DEL_CELLSLEFT && nDestPosY == aSource.aStart.Row() ) )
4163 : : {
4164 : : // call with bApi = sal_True to avoid error messages in drop handler
4165 [ # # ]: 0 : bDone = pDocSh->GetDocFunc().DeleteCells( aSource, NULL, eCmd, sal_True /*bRecord*/, sal_True /*bApi*/ );
4166 [ # # ]: 0 : if ( bDone )
4167 : : {
4168 [ # # ][ # # ]: 0 : if ( eCmd == DEL_CELLSUP && nDestPosY > aSource.aEnd.Row() )
[ # # ]
4169 : : {
4170 [ # # ]: 0 : bDone = aDest.Move( 0, -nSizeY, 0, pThisDoc );
4171 : : }
4172 [ # # ][ # # ]: 0 : else if ( eCmd == DEL_CELLSLEFT && nDestPosX > aSource.aEnd.Col() )
[ # # ]
4173 : : {
4174 [ # # ]: 0 : bDone = aDest.Move( -nSizeX, 0, 0, pThisDoc );
4175 : : }
4176 [ # # ]: 0 : pDocSh->UpdateOle( pViewData );
4177 [ # # ]: 0 : pView->CellContentChanged();
4178 : : }
4179 : : }
4180 : : }
4181 : :
4182 [ # # ]: 0 : if ( bDone )
4183 : : {
4184 [ # # ]: 0 : pView->MarkRange( aDest, false, false );
4185 : :
4186 : 0 : SCCOL nDCol = pViewData->GetCurX() - aSource.aStart.Col() + nCorrectCursorPosCol;
4187 : 0 : SCROW nDRow = pViewData->GetCurY() - aSource.aStart.Row() + nCorrectCursorPosRow;
4188 [ # # ]: 0 : pView->SetCursor( aDest.aStart.Col() + nDCol, aDest.aStart.Row() + nDRow );
4189 : : }
4190 : :
4191 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->LeaveListAction();
[ # # ]
4192 : :
4193 : : }
4194 : : else
4195 : 0 : bDone = sal_True; // nothing to do
4196 : : }
4197 : :
4198 [ # # ]: 0 : if (bDone)
4199 [ # # ]: 0 : pTransObj->SetDragWasInternal(); // don't delete source in DragFinished
4200 : : }
4201 [ # # ][ # # ]: 0 : else if ( !bFiltered && pSourceDoc ) // between documents
4202 : : {
4203 [ # # ]: 0 : if ( nFlags & SC_DROP_TABLE ) // copy/link sheets between documents
4204 : : {
4205 [ # # ][ # # ]: 0 : if ( pThisDoc->IsDocEditable() )
4206 : : {
4207 [ # # ]: 0 : ScDocShell* pSrcShell = pTransObj->GetSourceDocShell();
4208 : :
4209 [ # # ]: 0 : std::vector<SCTAB> nTabs;
4210 : :
4211 [ # # ]: 0 : ScMarkData aMark = pTransObj->GetSourceMarkData();
4212 [ # # ]: 0 : SCTAB nTabCount = pSourceDoc->GetTableCount();
4213 : :
4214 [ # # ]: 0 : for(SCTAB i=0; i<nTabCount; i++)
4215 : : {
4216 [ # # ][ # # ]: 0 : if(aMark.GetTableSelect(i))
4217 : : {
4218 [ # # ]: 0 : nTabs.push_back(i);
4219 [ # # ]: 0 : for(SCTAB j=i+1;j<nTabCount;j++)
4220 : : {
4221 [ # # ][ # # ]: 0 : if((!pSourceDoc->IsVisible(j))&&(pSourceDoc->IsScenario(j)))
[ # # ][ # # ]
[ # # ]
4222 : : {
4223 [ # # ]: 0 : nTabs.push_back( j );
4224 : 0 : i=j;
4225 : : }
4226 : 0 : else break;
4227 : : }
4228 : : }
4229 : : }
4230 : :
4231 [ # # ][ # # ]: 0 : pView->ImportTables( pSrcShell,static_cast<SCTAB>(nTabs.size()), &nTabs[0], bIsLink, nThisTab );
4232 [ # # ]: 0 : bDone = sal_True;
4233 : : }
4234 : : }
4235 [ # # ]: 0 : else if ( bIsLink )
4236 : : {
4237 : : // as in PasteDDE
4238 : : // (external references might be used instead?)
4239 : :
4240 : 0 : SfxObjectShell* pSourceSh = pSourceDoc->GetDocumentShell();
4241 : : OSL_ENSURE(pSourceSh, "drag document has no shell");
4242 [ # # ]: 0 : if (pSourceSh)
4243 : : {
4244 [ # # ][ # # ]: 0 : String aUndo = ScGlobal::GetRscString( STR_UNDO_COPY );
4245 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
4246 : :
4247 : 0 : bDone = sal_True;
4248 [ # # ]: 0 : if ( meDragInsertMode != INS_NONE )
4249 : : {
4250 : : // call with bApi = sal_True to avoid error messages in drop handler
4251 [ # # ]: 0 : bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, sal_True /*bRecord*/, sal_True /*bApi*/, sal_True /*bPartOfPaste*/ );
4252 [ # # ]: 0 : if ( bDone )
4253 : : {
4254 [ # # ]: 0 : pDocSh->UpdateOle( pViewData );
4255 [ # # ]: 0 : pView->CellContentChanged();
4256 : : }
4257 : : }
4258 : :
4259 [ # # ]: 0 : if ( bDone )
4260 : : {
4261 [ # # ]: 0 : String aApp = Application::GetAppName();
4262 [ # # ]: 0 : String aTopic = pSourceSh->GetTitle( SFX_TITLE_FULLNAME );
4263 [ # # ]: 0 : String aItem;
4264 [ # # ]: 0 : aSource.Format( aItem, SCA_VALID | SCA_TAB_3D, pSourceDoc );
4265 : :
4266 : : // TODO: we could define ocQuote for "
4267 : 0 : const rtl::OUString aQuote('"');
4268 [ # # ]: 0 : const String& sSep = ScCompiler::GetNativeSymbol( ocSep);
4269 : 0 : rtl::OUStringBuffer aFormula;
4270 [ # # ]: 0 : aFormula.append('=');
4271 [ # # ][ # # ]: 0 : aFormula.append(ScCompiler::GetNativeSymbol(ocDde));
[ # # ]
4272 [ # # ][ # # ]: 0 : aFormula.append(ScCompiler::GetNativeSymbol(ocOpen));
[ # # ]
4273 [ # # ]: 0 : aFormula.append(aQuote);
4274 [ # # ][ # # ]: 0 : aFormula.append(aApp);
4275 [ # # ]: 0 : aFormula.append(aQuote);
4276 [ # # ][ # # ]: 0 : aFormula.append(sSep);
4277 [ # # ]: 0 : aFormula.append(aQuote);
4278 [ # # ][ # # ]: 0 : aFormula.append(aTopic);
4279 [ # # ]: 0 : aFormula.append(aQuote);
4280 [ # # ][ # # ]: 0 : aFormula.append(sSep);
4281 [ # # ]: 0 : aFormula.append(aQuote);
4282 [ # # ][ # # ]: 0 : aFormula.append(aItem);
4283 [ # # ]: 0 : aFormula.append(aQuote);
4284 [ # # ][ # # ]: 0 : aFormula.append(ScCompiler::GetNativeSymbol(ocClose));
[ # # ]
4285 : :
4286 [ # # ]: 0 : pView->DoneBlockMode();
4287 [ # # ]: 0 : pView->InitBlockMode( nDestPosX, nDestPosY, nThisTab );
4288 : : pView->MarkCursor( nDestPosX + nSizeX - 1,
4289 [ # # ]: 0 : nDestPosY + nSizeY - 1, nThisTab );
4290 : :
4291 [ # # ][ # # ]: 0 : pView->EnterMatrix( aFormula.makeStringAndClear(), ::formula::FormulaGrammar::GRAM_NATIVE );
[ # # ][ # # ]
4292 : :
4293 [ # # ]: 0 : pView->MarkRange( aDest, false, false );
4294 [ # # ][ # # ]: 0 : pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
[ # # ][ # # ]
4295 : : }
4296 : :
4297 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->LeaveListAction();
[ # # ]
4298 : : }
4299 : : }
4300 : : else
4301 : : {
4302 : : //! HasSelectedBlockMatrixFragment without selected sheet?
4303 : : //! or don't start dragging on a part of a matrix
4304 : :
4305 [ # # ][ # # ]: 0 : String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
[ # # ]
4306 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
4307 : :
4308 : 0 : bDone = sal_True;
4309 [ # # ]: 0 : if ( meDragInsertMode != INS_NONE )
4310 : : {
4311 : : // call with bApi = sal_True to avoid error messages in drop handler
4312 [ # # ]: 0 : bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, sal_True /*bRecord*/, sal_True /*bApi*/, sal_True /*bPartOfPaste*/ );
4313 [ # # ]: 0 : if ( bDone )
4314 : : {
4315 [ # # ]: 0 : pDocSh->UpdateOle( pViewData );
4316 [ # # ]: 0 : pView->CellContentChanged();
4317 : : }
4318 : : }
4319 : :
4320 [ # # ]: 0 : if ( bDone )
4321 : : {
4322 [ # # ]: 0 : pView->Unmark(); // before SetCursor, so CheckSelectionTransfer isn't called with a selection
4323 [ # # ]: 0 : pView->SetCursor( nDestPosX, nDestPosY );
4324 [ # # ]: 0 : bDone = pView->PasteFromClip( IDF_ALL, pTransObj->GetDocument() ); // clip-doc
4325 [ # # ]: 0 : if ( bDone )
4326 : : {
4327 [ # # ]: 0 : pView->MarkRange( aDest, false, false );
4328 [ # # ]: 0 : pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
4329 : : }
4330 : : }
4331 : :
4332 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->LeaveListAction();
[ # # ]
4333 : :
4334 : : // no longer call ResetMark here - the inserted block has been selected
4335 : : // and may have been copied to primary selection
4336 : : }
4337 : : }
4338 : :
4339 [ # # ]: 0 : sal_Int8 nRet = bDone ? nDndAction : DND_ACTION_NONE;
4340 : 0 : return nRet;
4341 : : }
4342 : :
4343 : 0 : sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
4344 : : {
4345 [ # # ]: 0 : DrawMarkDropObj( NULL ); // drawing layer
4346 : :
4347 [ # # ]: 0 : ScModule* pScMod = SC_MOD();
4348 [ # # ]: 0 : const ScDragData& rData = pScMod->GetDragData();
4349 [ # # ]: 0 : if (rData.pCellTransfer)
4350 [ # # ]: 0 : return ExecutePrivateDrop( rEvt );
4351 : :
4352 : 0 : Point aPos = rEvt.maPosPixel;
4353 : :
4354 [ # # ]: 0 : if ( !rData.aLinkDoc.isEmpty() )
4355 : : {
4356 : : // try to insert a link
4357 : :
4358 : 0 : bool bOk = true;
4359 : 0 : rtl::OUString aThisName;
4360 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
4361 [ # # ][ # # ]: 0 : if (pDocSh && pDocSh->HasName())
[ # # ]
4362 [ # # ]: 0 : aThisName = pDocSh->GetMedium()->GetName();
4363 : :
4364 [ # # ]: 0 : if ( rData.aLinkDoc.equals(aThisName) ) // error - no link within a document
4365 : 0 : bOk = false;
4366 : : else
4367 : : {
4368 [ # # ]: 0 : ScViewFunc* pView = pViewData->GetView();
4369 [ # # ]: 0 : if ( !rData.aLinkTable.isEmpty() )
4370 [ # # ][ # # ]: 0 : pView->InsertTableLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING,
4371 [ # # ][ # # ]: 0 : rData.aLinkTable );
[ # # ][ # # ]
[ # # ]
4372 [ # # ]: 0 : else if ( !rData.aLinkArea.isEmpty() )
4373 : : {
4374 : : SCsCOL nPosX;
4375 : : SCsROW nPosY;
4376 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
4377 [ # # ]: 0 : pView->MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, false, false );
4378 : :
4379 [ # # ][ # # ]: 0 : pView->InsertAreaLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING,
4380 [ # # ][ # # ]: 0 : rData.aLinkArea, 0 );
[ # # ][ # # ]
[ # # ]
4381 : : }
4382 : : else
4383 : : {
4384 : : OSL_FAIL("drop with link: no sheet nor area");
4385 : 0 : bOk = false;
4386 : : }
4387 : : }
4388 : :
4389 [ # # ]: 0 : return bOk ? rEvt.mnAction : DND_ACTION_NONE; // don't try anything else
4390 : : }
4391 : :
4392 [ # # ]: 0 : Point aLogicPos = PixelToLogic(aPos);
4393 : :
4394 [ # # ]: 0 : if (rData.pDrawTransfer)
4395 : : {
4396 : 0 : sal_uInt16 nFlags = rData.pDrawTransfer->GetDragSourceFlags();
4397 : :
4398 : 0 : sal_Bool bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0;
4399 [ # # ][ # # ]: 0 : sal_Bool bIsMove = ( rEvt.mnAction == DND_ACTION_MOVE && !bIsNavi );
4400 : :
4401 : 0 : bPasteIsMove = bIsMove;
4402 : :
4403 [ # # ]: 0 : pViewData->GetView()->PasteDraw( aLogicPos, rData.pDrawTransfer->GetModel() );
4404 : :
4405 [ # # ]: 0 : if (bPasteIsMove)
4406 [ # # ]: 0 : rData.pDrawTransfer->SetDragWasInternal();
4407 : 0 : bPasteIsMove = false;
4408 : :
4409 : 0 : return rEvt.mnAction;
4410 : : }
4411 : :
4412 : :
4413 : : SCsCOL nPosX;
4414 : : SCsROW nPosY;
4415 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
4416 : :
4417 [ # # ]: 0 : if (!rData.aJumpTarget.isEmpty())
4418 : : {
4419 : : // internal bookmark (from Navigator)
4420 : : // bookmark clipboard formats are in PasteScDataObject
4421 : :
4422 [ # # ][ # # ]: 0 : if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() )
[ # # ][ # # ]
4423 : : {
4424 : 0 : pViewData->GetViewShell()->InsertBookmark( rData.aJumpText, rData.aJumpTarget,
4425 [ # # ]: 0 : nPosX, nPosY );
[ # # # # ]
[ # # ][ # # ]
4426 : 0 : return rEvt.mnAction;
4427 : : }
4428 : : }
4429 : :
4430 : 0 : sal_Bool bIsLink = ( rEvt.mnAction == DND_ACTION_LINK );
4431 : :
4432 [ # # ]: 0 : ScDocument* pThisDoc = pViewData->GetDocument();
4433 [ # # ][ # # ]: 0 : SdrObject* pHitObj = pThisDoc->GetObjectAtPoint( pViewData->GetTabNo(), PixelToLogic(aPos) );
4434 [ # # ][ # # ]: 0 : if ( pHitObj && bIsLink )
4435 : : {
4436 : : // dropped on drawing object
4437 : : // PasteOnDrawObject checks for valid formats
4438 [ # # ][ # # ]: 0 : if ( pViewData->GetView()->PasteOnDrawObject( rEvt.maDropEvent.Transferable, pHitObj, sal_True ) )
4439 : 0 : return rEvt.mnAction;
4440 : : }
4441 : :
4442 : 0 : sal_Bool bDone = false;
4443 : :
4444 : : sal_uLong nFormatId = bIsLink ?
4445 : 0 : lcl_GetDropLinkId( rEvt.maDropEvent.Transferable ) :
4446 [ # # ][ # # ]: 0 : lcl_GetDropFormatId( rEvt.maDropEvent.Transferable );
[ # # ]
4447 [ # # ]: 0 : if ( nFormatId )
4448 : : {
4449 : 0 : pScMod->SetInExecuteDrop( sal_True ); // #i28468# prevent error messages from PasteDataFormat
4450 : 0 : bPasteIsDrop = sal_True;
4451 : 0 : bDone = pViewData->GetView()->PasteDataFormat(
4452 [ # # ]: 0 : nFormatId, rEvt.maDropEvent.Transferable, nPosX, nPosY, &aLogicPos, bIsLink );
4453 : 0 : bPasteIsDrop = false;
4454 : 0 : pScMod->SetInExecuteDrop( false );
4455 : : }
4456 : :
4457 [ # # ]: 0 : sal_Int8 nRet = bDone ? rEvt.mnAction : DND_ACTION_NONE;
4458 : 0 : return nRet;
4459 : : }
4460 : :
4461 : : //--------------------------------------------------------
4462 : :
4463 : 0 : void ScGridWindow::PasteSelection( const Point& rPosPixel )
4464 : : {
4465 [ # # ]: 0 : Point aLogicPos = PixelToLogic( rPosPixel );
4466 : :
4467 : : SCsCOL nPosX;
4468 : : SCsROW nPosY;
4469 [ # # ]: 0 : pViewData->GetPosFromPixel( rPosPixel.X(), rPosPixel.Y(), eWhich, nPosX, nPosY );
4470 : :
4471 : : // If the mouse down was inside a visible note window, ignore it and
4472 : : // leave it up to the ScPostIt to handle it
4473 [ # # ]: 0 : SdrView* pDrawView = pViewData->GetViewShell()->GetSdrView();
4474 [ # # ]: 0 : if (pDrawView)
4475 : : {
4476 : 0 : sal_uLong nCount = pDrawView->GetMarkedObjectCount();
4477 [ # # ]: 0 : for (sal_uLong i = 0; i < nCount; ++i)
4478 : : {
4479 [ # # ]: 0 : SdrObject* pObj = pDrawView->GetMarkedObjectByIndex(i);
4480 [ # # ][ # # ]: 0 : if (pObj && pObj->GetLogicRect().IsInside(aLogicPos))
[ # # ][ # # ]
[ # # ]
4481 : : {
4482 : : // Inside an active drawing object. Bail out.
4483 : 0 : return;
4484 : : }
4485 : : }
4486 : : }
4487 : :
4488 [ # # ]: 0 : ScSelectionTransferObj* pOwnSelection = SC_MOD()->GetSelectionTransfer();
4489 [ # # ]: 0 : if ( pOwnSelection )
4490 : : {
4491 : : // within Calc
4492 : :
4493 [ # # ]: 0 : ScTransferObj* pCellTransfer = pOwnSelection->GetCellData();
4494 [ # # ]: 0 : if ( pCellTransfer )
4495 : : {
4496 : : // keep a reference to the data in case the selection is changed during paste
4497 [ # # ][ # # ]: 0 : uno::Reference<datatransfer::XTransferable> xRef( pCellTransfer );
4498 [ # # ]: 0 : DropTransferObj( pCellTransfer, nPosX, nPosY, aLogicPos, DND_ACTION_COPY );
4499 : : }
4500 : : else
4501 : : {
4502 [ # # ]: 0 : ScDrawTransferObj* pDrawTransfer = pOwnSelection->GetDrawData();
4503 [ # # ]: 0 : if ( pDrawTransfer )
4504 : : {
4505 : : // keep a reference to the data in case the selection is changed during paste
4506 [ # # ][ # # ]: 0 : uno::Reference<datatransfer::XTransferable> xRef( pDrawTransfer );
4507 : :
4508 : : // bSameDocClipboard argument for PasteDraw is needed
4509 : : // because only DragData is checked directly inside PasteDraw
4510 : 0 : pViewData->GetView()->PasteDraw( aLogicPos, pDrawTransfer->GetModel(), false,
4511 [ # # ][ # # ]: 0 : pDrawTransfer->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() );
[ # # ]
4512 : : }
4513 : : }
4514 : : }
4515 : : else
4516 : : {
4517 : : // get selection from system
4518 : :
4519 [ # # ]: 0 : TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( this ) );
4520 : 0 : uno::Reference<datatransfer::XTransferable> xTransferable = aDataHelper.GetTransferable();
4521 [ # # ]: 0 : if ( xTransferable.is() )
4522 : : {
4523 [ # # ]: 0 : sal_uLong nFormatId = lcl_GetDropFormatId( xTransferable, true );
4524 [ # # ]: 0 : if ( nFormatId )
4525 : : {
4526 : 0 : bPasteIsDrop = sal_True;
4527 [ # # ]: 0 : pViewData->GetView()->PasteDataFormat( nFormatId, xTransferable, nPosX, nPosY, &aLogicPos );
4528 : 0 : bPasteIsDrop = false;
4529 : : }
4530 [ # # ]: 0 : }
4531 : : }
4532 : : }
4533 : :
4534 : : //--------------------------------------------------------
4535 : :
4536 : 0 : void ScGridWindow::UpdateEditViewPos()
4537 : : {
4538 [ # # ]: 0 : if (pViewData->HasEditView(eWhich))
4539 : : {
4540 : : EditView* pView;
4541 : : SCCOL nCol;
4542 : : SCROW nRow;
4543 [ # # ]: 0 : pViewData->GetEditView( eWhich, pView, nCol, nRow );
4544 : 0 : SCCOL nEndCol = pViewData->GetEditEndCol();
4545 : 0 : SCROW nEndRow = pViewData->GetEditEndRow();
4546 : :
4547 : : // hide EditView?
4548 : :
4549 [ # # ][ # # ]: 0 : sal_Bool bHide = ( nEndCol<pViewData->GetPosX(eHWhich) || nEndRow<pViewData->GetPosY(eVWhich) );
4550 [ # # ][ # # ]: 0 : if ( SC_MOD()->IsFormulaMode() )
[ # # ]
4551 [ # # ]: 0 : if ( pViewData->GetTabNo() != pViewData->GetRefTabNo() )
4552 : 0 : bHide = sal_True;
4553 : :
4554 [ # # ]: 0 : if (bHide)
4555 : : {
4556 [ # # ]: 0 : Rectangle aRect = pView->GetOutputArea();
4557 : 0 : long nHeight = aRect.Bottom() - aRect.Top();
4558 [ # # ]: 0 : aRect.Top() = PixelToLogic(GetOutputSizePixel(), pViewData->GetLogicMode()).
4559 [ # # ]: 0 : Height() * 2;
4560 : 0 : aRect.Bottom() = aRect.Top() + nHeight;
4561 [ # # ]: 0 : pView->SetOutputArea( aRect );
4562 [ # # ]: 0 : pView->HideCursor();
4563 : : }
4564 : : else
4565 : : {
4566 : : // bForceToTop = sal_True for editing
4567 [ # # ]: 0 : Rectangle aPixRect = pViewData->GetEditArea( eWhich, nCol, nRow, this, NULL, sal_True );
4568 [ # # ][ # # ]: 0 : Point aScrPos = PixelToLogic( aPixRect.TopLeft(), pViewData->GetLogicMode() );
4569 : :
4570 [ # # ]: 0 : Rectangle aRect = pView->GetOutputArea();
4571 : 0 : aRect.SetPos( aScrPos );
4572 [ # # ]: 0 : pView->SetOutputArea( aRect );
4573 [ # # ]: 0 : pView->ShowCursor();
4574 : : }
4575 : : }
4576 : 0 : }
4577 : :
4578 : 0 : void ScGridWindow::ScrollPixel( long nDifX, long nDifY )
4579 : : {
4580 : 0 : ClickExtern();
4581 : 0 : HideNoteMarker();
4582 : :
4583 : 0 : bIsInScroll = true;
4584 : :
4585 [ # # ]: 0 : SetMapMode(MAP_PIXEL);
4586 : 0 : Scroll( nDifX, nDifY, SCROLL_CHILDREN );
4587 [ # # ]: 0 : SetMapMode( GetDrawMapMode() ); // verschobenen MapMode erzeugen
4588 : :
4589 : 0 : UpdateEditViewPos();
4590 : :
4591 : 0 : DrawAfterScroll();
4592 : 0 : bIsInScroll = false;
4593 : 0 : }
4594 : :
4595 : : // Formeln neu zeichnen -------------------------------------------------
4596 : :
4597 : 3825 : void ScGridWindow::UpdateFormulas()
4598 : : {
4599 [ + - ]: 3825 : if (pViewData->GetView()->IsMinimized())
4600 : : return;
4601 : :
4602 [ - + ]: 3825 : if ( nPaintCount )
4603 : : {
4604 : : // nicht anfangen, verschachtelt zu painten
4605 : : // (dann wuerde zumindest der MapMode nicht mehr stimmen)
4606 : :
4607 : 0 : bNeedsRepaint = true; // -> am Ende vom Paint nochmal Invalidate auf alles
4608 [ # # ]: 0 : aRepaintPixel = Rectangle(); // alles
4609 : : return;
4610 : : }
4611 : :
4612 : 3825 : SCCOL nX1 = pViewData->GetPosX( eHWhich );
4613 : 3825 : SCROW nY1 = pViewData->GetPosY( eVWhich );
4614 [ + - ]: 3825 : SCCOL nX2 = nX1 + pViewData->VisibleCellsX( eHWhich );
4615 [ + - ]: 3825 : SCROW nY2 = nY1 + pViewData->VisibleCellsY( eVWhich );
4616 : :
4617 [ - + ]: 3825 : if (nX2 > MAXCOL) nX2 = MAXCOL;
4618 [ - + ]: 3825 : if (nY2 > MAXROW) nY2 = MAXROW;
4619 : :
4620 : : // Draw( nX1, nY1, nX2, nY2, SC_UPDATE_CHANGED );
4621 : :
4622 : : // don't draw directly - instead use OutputData to find changed area and invalidate
4623 : :
4624 : 3825 : SCROW nPosY = nY1;
4625 : :
4626 : 3825 : ScDocShell* pDocSh = pViewData->GetDocShell();
4627 : 3825 : ScDocument* pDoc = pDocSh->GetDocument();
4628 : 3825 : SCTAB nTab = pViewData->GetTabNo();
4629 : :
4630 [ + - ]: 3825 : pDoc->ExtendHidden( nX1, nY1, nX2, nY2, nTab );
4631 : :
4632 [ + - ]: 3825 : Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
4633 [ + - ]: 3825 : long nMirrorWidth = GetSizePixel().Width();
4634 [ + - ]: 3825 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
4635 [ + + ]: 3825 : if ( bLayoutRTL )
4636 : : {
4637 [ + - ]: 2 : long nEndPixel = pViewData->GetScrPos( nX2+1, nPosY, eWhich ).X();
4638 : 2 : nMirrorWidth = aScrPos.X() - nEndPixel;
4639 : 2 : aScrPos.X() = nEndPixel + 1;
4640 : : }
4641 : :
4642 : 3825 : long nScrX = aScrPos.X();
4643 : 3825 : long nScrY = aScrPos.Y();
4644 : :
4645 : 3825 : double nPPTX = pViewData->GetPPTX();
4646 : 3825 : double nPPTY = pViewData->GetPPTY();
4647 : :
4648 [ + - ]: 3825 : ScTableInfo aTabInfo;
4649 [ + - ]: 3825 : pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, false );
4650 : :
4651 [ + - ]: 3825 : Fraction aZoomX = pViewData->GetZoomX();
4652 [ + - ]: 3825 : Fraction aZoomY = pViewData->GetZoomY();
4653 : : ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
4654 : : nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
4655 [ + - ]: 3825 : &aZoomX, &aZoomY );
4656 [ + - ]: 3825 : aOutputData.SetMirrorWidth( nMirrorWidth );
4657 : :
4658 [ + - ]: 3825 : aOutputData.FindChanged();
4659 : :
4660 [ + - ]: 3825 : PolyPolygon aChangedPoly( aOutputData.GetChangedArea() ); // logic (PixelToLogic)
4661 [ + - ][ + + ]: 3825 : if ( aChangedPoly.Count() )
4662 : : {
4663 [ + - ][ + - ]: 100 : Invalidate( aChangedPoly );
[ + - ]
4664 : : }
4665 : :
4666 [ + - ][ + - ]: 3825 : CheckNeedsRepaint(); // #i90362# used to be called via Draw() - still needed here
[ + - ][ + - ]
4667 : : }
4668 : :
4669 : 1267 : void ScGridWindow::UpdateAutoFillMark(bool bMarked, const ScRange& rMarkRange)
4670 : : {
4671 [ + + ][ + - ]: 1267 : if ( bMarked != bAutoMarkVisible || ( bMarked && rMarkRange.aEnd != aAutoMarkPos ) )
[ + + ][ + + ]
4672 : : {
4673 : 338 : bAutoMarkVisible = bMarked;
4674 [ + - ]: 338 : if ( bMarked )
4675 : 338 : aAutoMarkPos = rMarkRange.aEnd;
4676 : :
4677 : 338 : UpdateAutoFillOverlay();
4678 : : }
4679 : 1267 : }
4680 : :
4681 : 231 : void ScGridWindow::UpdateListValPos( bool bVisible, const ScAddress& rPos )
4682 : : {
4683 : 231 : bool bOldButton = bListValButton;
4684 : 231 : ScAddress aOldPos = aListValPos;
4685 : :
4686 : 231 : bListValButton = bVisible;
4687 : 231 : aListValPos = rPos;
4688 : :
4689 [ - + ]: 231 : if ( bListValButton )
4690 : : {
4691 [ # # ][ # # ]: 0 : if ( !bOldButton || aListValPos != aOldPos )
[ # # ]
4692 : : {
4693 : : // paint area of new button
4694 [ # # ][ # # ]: 0 : Invalidate( PixelToLogic( GetListValButtonRect( aListValPos ) ) );
[ # # ]
4695 : : }
4696 : : }
4697 [ - + ]: 231 : if ( bOldButton )
4698 : : {
4699 [ # # ][ # # ]: 0 : if ( !bListValButton || aListValPos != aOldPos )
[ # # ]
4700 : : {
4701 : : // paint area of old button
4702 [ # # ][ # # ]: 0 : Invalidate( PixelToLogic( GetListValButtonRect( aOldPos ) ) );
[ # # ]
4703 : : }
4704 : : }
4705 : 231 : }
4706 : :
4707 : 556 : void ScGridWindow::HideCursor()
4708 : : {
4709 : 556 : ++nCursorHideCount;
4710 : 556 : }
4711 : :
4712 : 331 : void ScGridWindow::ShowCursor()
4713 : : {
4714 : 331 : --nCursorHideCount;
4715 : 331 : }
4716 : :
4717 : 223 : void ScGridWindow::GetFocus()
4718 : : {
4719 : 223 : ScTabViewShell* pViewShell = pViewData->GetViewShell();
4720 : 223 : pViewShell->GotFocus();
4721 : 223 : pViewShell->SetFormShellAtTop( false ); // focus in GridWindow -> FormShell no longer on top
4722 : :
4723 [ - + ]: 223 : if (pViewShell->HasAccessibilityObjects())
4724 [ # # ][ # # ]: 0 : pViewShell->BroadcastAccessibility(ScAccGridWinFocusGotHint(eWhich, GetAccessible()));
[ # # ]
4725 : :
4726 : :
4727 [ + - ]: 223 : if ( !SC_MOD()->IsFormulaMode() )
4728 : : {
4729 : 223 : pViewShell->UpdateInputHandler();
4730 : : // StopMarking(); // falls Dialog (Fehler), weil dann kein ButtonUp
4731 : : // MO: nur wenn nicht im RefInput-Modus
4732 : : // -> GetFocus/MouseButtonDown-Reihenfolge
4733 : : // auf dem Mac
4734 : : }
4735 : :
4736 : 223 : pViewData->GetDocShell()->CheckConfigOptions();
4737 : 223 : Window::GetFocus();
4738 : 223 : }
4739 : :
4740 : 219 : void ScGridWindow::LoseFocus()
4741 : : {
4742 : 219 : ScTabViewShell* pViewShell = pViewData->GetViewShell();
4743 : 219 : pViewShell->LostFocus();
4744 : :
4745 [ + + ]: 219 : if (pViewShell->HasAccessibilityObjects())
4746 [ + - ][ + - ]: 5 : pViewShell->BroadcastAccessibility(ScAccGridWinFocusLostHint(eWhich, GetAccessible()));
[ + - ]
4747 : :
4748 : 219 : Window::LoseFocus();
4749 : 219 : }
4750 : :
4751 : 0 : Point ScGridWindow::GetMousePosPixel() const { return aCurMousePos; }
4752 : :
4753 : : //------------------------------------------------------------------------
4754 : :
4755 : 0 : bool ScGridWindow::HitRangeFinder( const Point& rMouse, bool& rCorner,
4756 : : sal_uInt16* pIndex, SCsCOL* pAddX, SCsROW* pAddY )
4757 : : {
4758 : 0 : bool bFound = false;
4759 : 0 : ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
4760 [ # # ]: 0 : if (pHdl)
4761 : : {
4762 : 0 : ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
4763 [ # # ][ # # ]: 0 : if ( pRangeFinder && !pRangeFinder->IsHidden() &&
[ # # ][ # # ]
4764 [ # # ][ # # ]: 0 : pRangeFinder->GetDocName() == pViewData->GetDocShell()->GetTitle() )
[ # # ][ # # ]
4765 : : {
4766 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
4767 : 0 : SCTAB nTab = pViewData->GetTabNo();
4768 [ # # ]: 0 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
4769 [ # # ]: 0 : long nLayoutSign = bLayoutRTL ? -1 : 1;
4770 : :
4771 : : SCsCOL nPosX;
4772 : : SCsROW nPosY;
4773 [ # # ]: 0 : pViewData->GetPosFromPixel( rMouse.X(), rMouse.Y(), eWhich, nPosX, nPosY );
4774 : : // zusammengefasste (einzeln/Bereich) ???
4775 : 0 : ScAddress aAddr( nPosX, nPosY, nTab );
4776 : :
4777 [ # # ]: 0 : Point aNext = pViewData->GetScrPos( nPosX, nPosY, eWhich, true );
4778 : : long nSizeXPix;
4779 : : long nSizeYPix;
4780 [ # # ]: 0 : pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeXPix, nSizeYPix );
4781 : 0 : aNext.X() += nSizeXPix * nLayoutSign;
4782 : 0 : aNext.Y() += nSizeYPix;
4783 : :
4784 : : bool bCornerHor;
4785 [ # # ]: 0 : if ( bLayoutRTL )
4786 [ # # ][ # # ]: 0 : bCornerHor = ( rMouse.X() >= aNext.X() && rMouse.X() <= aNext.X() + 8 );
4787 : : else
4788 [ # # ][ # # ]: 0 : bCornerHor = ( rMouse.X() >= aNext.X() - 8 && rMouse.X() <= aNext.X() );
4789 : :
4790 : : bool bCellCorner = ( bCornerHor &&
4791 [ # # ][ # # ]: 0 : rMouse.Y() >= aNext.Y() - 8 && rMouse.Y() <= aNext.Y() );
[ # # ]
4792 : : // corner is hit only if the mouse is within the cell
4793 : :
4794 : 0 : sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count();
4795 [ # # ]: 0 : for (sal_uInt16 i=nCount; i;)
4796 : : {
4797 : : // rueckwaerts suchen, damit der zuletzt gepaintete Rahmen gefunden wird
4798 : 0 : --i;
4799 [ # # ]: 0 : ScRangeFindData* pData = pRangeFinder->GetObject(i);
4800 [ # # ]: 0 : if ( pData->aRef.In(aAddr) )
4801 : : {
4802 [ # # ]: 0 : if (pIndex) *pIndex = i;
4803 [ # # ]: 0 : if (pAddX) *pAddX = nPosX - pData->aRef.aStart.Col();
4804 [ # # ]: 0 : if (pAddY) *pAddY = nPosY - pData->aRef.aStart.Row();
4805 : 0 : bFound = sal_True;
4806 [ # # ][ # # ]: 0 : rCorner = ( bCellCorner && aAddr == pData->aRef.aEnd );
4807 : 0 : break;
4808 : : }
4809 : : }
4810 : : }
4811 : : }
4812 : 0 : return bFound;
4813 : : }
4814 : :
4815 : : #define SCE_TOP 1
4816 : : #define SCE_BOTTOM 2
4817 : : #define SCE_LEFT 4
4818 : : #define SCE_RIGHT 8
4819 : : #define SCE_ALL 15
4820 : :
4821 : 0 : void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, sal_uInt16 nEdges )
4822 : : {
4823 : : // der Range ist immer richtigherum
4824 : :
4825 : 0 : SCCOL nCol1 = rRange.aStart.Col();
4826 : 0 : SCROW nRow1 = rRange.aStart.Row();
4827 : 0 : SCTAB nTab1 = rRange.aStart.Tab();
4828 : 0 : SCCOL nCol2 = rRange.aEnd.Col();
4829 : 0 : SCROW nRow2 = rRange.aEnd.Row();
4830 : 0 : SCTAB nTab2 = rRange.aEnd.Tab();
4831 : 0 : sal_Bool bHiddenEdge = false;
4832 : : SCROW nTmp;
4833 : :
4834 : 0 : ScDocument* pDoc = pDocSh->GetDocument();
4835 [ # # ][ # # ]: 0 : while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab1) )
[ # # ]
4836 : : {
4837 : 0 : --nCol1;
4838 : 0 : bHiddenEdge = sal_True;
4839 : : }
4840 [ # # ][ # # ]: 0 : while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab1) )
[ # # ]
4841 : : {
4842 : 0 : ++nCol2;
4843 : 0 : bHiddenEdge = sal_True;
4844 : : }
4845 : 0 : nTmp = pDoc->FirstVisibleRow(0, nRow1, nTab1);
4846 [ # # ]: 0 : if (!ValidRow(nTmp))
4847 : 0 : nTmp = 0;
4848 [ # # ]: 0 : if (nTmp < nRow1)
4849 : : {
4850 : 0 : nRow1 = nTmp;
4851 : 0 : bHiddenEdge = sal_True;
4852 : : }
4853 : 0 : nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab1);
4854 [ # # ]: 0 : if (!ValidRow(nTmp))
4855 : 0 : nTmp = MAXROW;
4856 [ # # ]: 0 : if (nTmp > nRow2)
4857 : : {
4858 : 0 : nRow2 = nTmp;
4859 : 0 : bHiddenEdge = sal_True;
4860 : : }
4861 : :
4862 [ # # ][ # # ]: 0 : if ( nCol2 > nCol1 + 1 && nRow2 > nRow1 + 1 && !bHiddenEdge )
[ # # ]
4863 : : {
4864 : : // nur an den Raendern entlang
4865 : : // (die Ecken werden evtl. zweimal getroffen)
4866 : :
4867 [ # # ]: 0 : if ( nEdges & SCE_TOP )
4868 : 0 : pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow1, nTab2, PAINT_MARKS );
4869 [ # # ]: 0 : if ( nEdges & SCE_LEFT )
4870 : 0 : pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol1, nRow2, nTab2, PAINT_MARKS );
4871 [ # # ]: 0 : if ( nEdges & SCE_RIGHT )
4872 : 0 : pDocSh->PostPaint( nCol2, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS );
4873 [ # # ]: 0 : if ( nEdges & SCE_BOTTOM )
4874 : 0 : pDocSh->PostPaint( nCol1, nRow2, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS );
4875 : : }
4876 : : else // everything in one call
4877 : 0 : pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS );
4878 : 0 : }
4879 : :
4880 : 0 : void lcl_PaintRefChanged( ScDocShell* pDocSh, const ScRange& rOldUn, const ScRange& rNewUn )
4881 : : {
4882 : : // Repaint fuer die Teile des Rahmens in Old, die bei New nicht mehr da sind
4883 : :
4884 : 0 : ScRange aOld = rOldUn;
4885 : 0 : ScRange aNew = rNewUn;
4886 [ # # ]: 0 : aOld.Justify();
4887 [ # # ]: 0 : aNew.Justify();
4888 : :
4889 [ # # ]: 0 : if ( aOld.aStart == aOld.aEnd ) //! Tab ignorieren?
4890 [ # # ]: 0 : pDocSh->GetDocument()->ExtendMerge(aOld);
4891 [ # # ]: 0 : if ( aNew.aStart == aNew.aEnd ) //! Tab ignorieren?
4892 [ # # ]: 0 : pDocSh->GetDocument()->ExtendMerge(aNew);
4893 : :
4894 : 0 : SCCOL nOldCol1 = aOld.aStart.Col();
4895 : 0 : SCROW nOldRow1 = aOld.aStart.Row();
4896 : 0 : SCCOL nOldCol2 = aOld.aEnd.Col();
4897 : 0 : SCROW nOldRow2 = aOld.aEnd.Row();
4898 : 0 : SCCOL nNewCol1 = aNew.aStart.Col();
4899 : 0 : SCROW nNewRow1 = aNew.aStart.Row();
4900 : 0 : SCCOL nNewCol2 = aNew.aEnd.Col();
4901 : 0 : SCROW nNewRow2 = aNew.aEnd.Row();
4902 : 0 : SCTAB nTab1 = aOld.aStart.Tab(); // Tab aendert sich nicht
4903 : 0 : SCTAB nTab2 = aOld.aEnd.Tab();
4904 : :
4905 [ # # ][ # # ]: 0 : if ( nNewRow2 < nOldRow1 || nNewRow1 > nOldRow2 ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
4906 : : nNewCol2 < nOldCol1 || nNewCol1 > nOldCol2 ||
4907 : : ( nNewCol1 != nOldCol1 && nNewRow1 != nOldRow1 &&
4908 : : nNewCol2 != nOldCol2 && nNewRow2 != nOldRow2 ) )
4909 : : {
4910 : : // komplett weggeschoben oder alle Seiten veraendert
4911 : : // (Abfrage <= statt < geht schief bei einzelnen Zeilen/Spalten)
4912 : :
4913 [ # # ]: 0 : lcl_PaintOneRange( pDocSh, aOld, SCE_ALL );
4914 : : }
4915 : : else // alle vier Kanten einzeln testen
4916 : : {
4917 : : // oberer Teil
4918 [ # # ]: 0 : if ( nNewRow1 < nOldRow1 ) // nur obere Linie loeschen
4919 : : lcl_PaintOneRange( pDocSh, ScRange(
4920 [ # # ]: 0 : nOldCol1, nOldRow1, nTab1, nOldCol2, nOldRow1, nTab2 ), SCE_ALL );
4921 [ # # ]: 0 : else if ( nNewRow1 > nOldRow1 ) // den Teil, der oben wegkommt
4922 : : lcl_PaintOneRange( pDocSh, ScRange(
4923 : : nOldCol1, nOldRow1, nTab1, nOldCol2, nNewRow1-1, nTab2 ),
4924 [ # # ]: 0 : SCE_ALL &~ SCE_BOTTOM );
4925 : :
4926 : : // unterer Teil
4927 [ # # ]: 0 : if ( nNewRow2 > nOldRow2 ) // nur untere Linie loeschen
4928 : : lcl_PaintOneRange( pDocSh, ScRange(
4929 [ # # ]: 0 : nOldCol1, nOldRow2, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL );
4930 [ # # ]: 0 : else if ( nNewRow2 < nOldRow2 ) // den Teil, der unten wegkommt
4931 : : lcl_PaintOneRange( pDocSh, ScRange(
4932 : : nOldCol1, nNewRow2+1, nTab1, nOldCol2, nOldRow2, nTab2 ),
4933 [ # # ]: 0 : SCE_ALL &~ SCE_TOP );
4934 : :
4935 : : // linker Teil
4936 [ # # ]: 0 : if ( nNewCol1 < nOldCol1 ) // nur linke Linie loeschen
4937 : : lcl_PaintOneRange( pDocSh, ScRange(
4938 [ # # ]: 0 : nOldCol1, nOldRow1, nTab1, nOldCol1, nOldRow2, nTab2 ), SCE_ALL );
4939 [ # # ]: 0 : else if ( nNewCol1 > nOldCol1 ) // den Teil, der links wegkommt
4940 : : lcl_PaintOneRange( pDocSh, ScRange(
4941 : : nOldCol1, nOldRow1, nTab1, nNewCol1-1, nOldRow2, nTab2 ),
4942 [ # # ]: 0 : SCE_ALL &~ SCE_RIGHT );
4943 : :
4944 : : // rechter Teil
4945 [ # # ]: 0 : if ( nNewCol2 > nOldCol2 ) // nur rechte Linie loeschen
4946 : : lcl_PaintOneRange( pDocSh, ScRange(
4947 [ # # ]: 0 : nOldCol2, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL );
4948 [ # # ]: 0 : else if ( nNewCol2 < nOldCol2 ) // den Teil, der rechts wegkommt
4949 : : lcl_PaintOneRange( pDocSh, ScRange(
4950 : : nNewCol2+1, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ),
4951 [ # # ]: 0 : SCE_ALL &~ SCE_LEFT );
4952 : : }
4953 : 0 : }
4954 : :
4955 : 0 : void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp )
4956 : : {
4957 [ # # ][ # # ]: 0 : ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
4958 [ # # ]: 0 : if (!pHdl)
4959 : : return;
4960 : 0 : ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
4961 [ # # ][ # # ]: 0 : if (!pRangeFinder || nRFIndex >= pRangeFinder->Count())
[ # # ]
4962 : : return;
4963 [ # # ]: 0 : ScRangeFindData* pData = pRangeFinder->GetObject( nRFIndex );
4964 : :
4965 : : // Mauszeiger
4966 : :
4967 [ # # ]: 0 : if (bRFSize)
4968 [ # # ]: 0 : SetPointer( Pointer( POINTER_CROSS ) );
4969 : : else
4970 [ # # ]: 0 : SetPointer( Pointer( POINTER_HAND ) );
4971 : :
4972 : : // Scrolling
4973 : :
4974 : 0 : sal_Bool bTimer = false;
4975 : 0 : Point aPos = rMEvt.GetPosPixel();
4976 : 0 : SCsCOL nDx = 0;
4977 : 0 : SCsROW nDy = 0;
4978 [ # # ]: 0 : if ( aPos.X() < 0 ) nDx = -1;
4979 [ # # ]: 0 : if ( aPos.Y() < 0 ) nDy = -1;
4980 : 0 : Size aSize = GetOutputSizePixel();
4981 [ # # ]: 0 : if ( aPos.X() >= aSize.Width() )
4982 : 0 : nDx = 1;
4983 [ # # ]: 0 : if ( aPos.Y() >= aSize.Height() )
4984 : 0 : nDy = 1;
4985 [ # # ][ # # ]: 0 : if ( nDx != 0 || nDy != 0 )
4986 : : {
4987 [ # # ][ # # ]: 0 : if ( nDx != 0) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
4988 [ # # ][ # # ]: 0 : if ( nDy != 0 ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
4989 : 0 : bTimer = sal_True;
4990 : : }
4991 : :
4992 : : // Umschalten bei Fixierung (damit Scrolling funktioniert)
4993 : :
4994 [ # # ]: 0 : if ( eWhich == pViewData->GetActivePart() ) //??
4995 : : {
4996 [ # # ]: 0 : if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX )
4997 [ # # ]: 0 : if ( nDx > 0 )
4998 : : {
4999 [ # # ]: 0 : if ( eWhich == SC_SPLIT_TOPLEFT )
5000 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT );
5001 [ # # ]: 0 : else if ( eWhich == SC_SPLIT_BOTTOMLEFT )
5002 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
5003 : : }
5004 : :
5005 [ # # ]: 0 : if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX )
5006 [ # # ]: 0 : if ( nDy > 0 )
5007 : : {
5008 [ # # ]: 0 : if ( eWhich == SC_SPLIT_TOPLEFT )
5009 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT );
5010 [ # # ]: 0 : else if ( eWhich == SC_SPLIT_TOPRIGHT )
5011 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
5012 : : }
5013 : : }
5014 : :
5015 : : // Verschieben
5016 : :
5017 : : SCsCOL nPosX;
5018 : : SCsROW nPosY;
5019 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
5020 : :
5021 : 0 : ScRange aOld = pData->aRef;
5022 : 0 : ScRange aNew = aOld;
5023 [ # # ]: 0 : if ( bRFSize )
5024 : : {
5025 : 0 : aNew.aEnd.SetCol((SCCOL)nPosX);
5026 : 0 : aNew.aEnd.SetRow((SCROW)nPosY);
5027 : : }
5028 : : else
5029 : : {
5030 : 0 : long nStartX = nPosX - nRFAddX;
5031 [ # # ]: 0 : if ( nStartX < 0 ) nStartX = 0;
5032 : 0 : long nStartY = nPosY - nRFAddY;
5033 [ # # ]: 0 : if ( nStartY < 0 ) nStartY = 0;
5034 : 0 : long nEndX = nStartX + aOld.aEnd.Col() - aOld.aStart.Col();
5035 [ # # ]: 0 : if ( nEndX > MAXCOL )
5036 : : {
5037 : 0 : nStartX -= ( nEndX - MAXROW );
5038 : 0 : nEndX = MAXCOL;
5039 : : }
5040 : 0 : long nEndY = nStartY + aOld.aEnd.Row() - aOld.aStart.Row();
5041 [ # # ]: 0 : if ( nEndY > MAXROW )
5042 : : {
5043 : 0 : nStartY -= ( nEndY - MAXROW );
5044 : 0 : nEndY = MAXROW;
5045 : : }
5046 : :
5047 : 0 : aNew.aStart.SetCol((SCCOL)nStartX);
5048 : 0 : aNew.aStart.SetRow((SCROW)nStartY);
5049 : 0 : aNew.aEnd.SetCol((SCCOL)nEndX);
5050 : 0 : aNew.aEnd.SetRow((SCROW)nEndY);
5051 : : }
5052 : :
5053 [ # # ]: 0 : if ( bUp )
5054 [ # # ]: 0 : aNew.Justify(); // beim ButtonUp wieder richtigherum
5055 : :
5056 [ # # ]: 0 : if ( aNew != aOld )
5057 : : {
5058 [ # # ]: 0 : pHdl->UpdateRange( nRFIndex, aNew );
5059 : :
5060 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
5061 : :
5062 : : // nur das neuzeichnen, was sich veraendert hat...
5063 [ # # ]: 0 : lcl_PaintRefChanged( pDocSh, aOld, aNew );
5064 : :
5065 : : // neuen Rahmen nur drueberzeichnen (synchron)
5066 [ # # ][ # # ]: 0 : pDocSh->Broadcast( ScIndexHint( SC_HINT_SHOWRANGEFINDER, nRFIndex ) );
[ # # ]
5067 : :
5068 [ # # ]: 0 : Update(); // was man bewegt, will man auch sofort sehen
5069 : : }
5070 : :
5071 : : // Timer fuer Scrolling
5072 : :
5073 [ # # ]: 0 : if (bTimer)
5074 [ # # ]: 0 : pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen
5075 : : else
5076 [ # # ]: 0 : pViewData->GetView()->ResetTimer();
5077 : : }
5078 : :
5079 : : //------------------------------------------------------------------------
5080 : :
5081 : 0 : bool ScGridWindow::GetEditUrl( const Point& rPos,
5082 : : String* pName, String* pUrl, String* pTarget )
5083 : : {
5084 : 0 : return GetEditUrlOrError( false, rPos, pName, pUrl, pTarget );
5085 : : }
5086 : :
5087 : 0 : bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
5088 : : String* pName, String* pUrl, String* pTarget )
5089 : : {
5090 : : //! nPosX/Y mit uebergeben?
5091 : : SCsCOL nPosX;
5092 : : SCsROW nPosY;
5093 [ # # ]: 0 : pViewData->GetPosFromPixel( rPos.X(), rPos.Y(), eWhich, nPosX, nPosY );
5094 : :
5095 : 0 : SCTAB nTab = pViewData->GetTabNo();
5096 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
5097 : 0 : ScDocument* pDoc = pDocSh->GetDocument();
5098 : 0 : ScBaseCell* pCell = NULL;
5099 : :
5100 [ # # ]: 0 : sal_Bool bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
5101 [ # # ]: 0 : if( !bFound )
5102 : 0 : return false;
5103 : :
5104 [ # # ]: 0 : const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab );
5105 : : // bForceToTop = sal_False, use the cell's real position
5106 [ # # ]: 0 : Rectangle aEditRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern, false );
5107 [ # # ]: 0 : if (rPos.Y() < aEditRect.Top())
5108 : 0 : return false;
5109 : :
5110 : : // vertikal kann (noch) nicht angeklickt werden:
5111 : :
5112 [ # # ][ # # ]: 0 : if (pPattern->GetCellOrientation() != SVX_ORIENTATION_STANDARD)
5113 : 0 : return false;
5114 : :
5115 [ # # ]: 0 : sal_Bool bBreak = ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue() ||
5116 : : ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
5117 [ # # ][ # # ]: 0 : GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK);
[ # # ]
5118 : : SvxCellHorJustify eHorJust = (SvxCellHorJustify)((SvxHorJustifyItem&)pPattern->
5119 [ # # ]: 0 : GetItem(ATTR_HOR_JUSTIFY)).GetValue();
5120 : :
5121 : : // EditEngine
5122 : :
5123 [ # # ][ # # ]: 0 : ScFieldEditEngine aEngine(pDoc, pDoc->GetEditPool());
5124 [ # # ]: 0 : ScSizeDeviceProvider aProv(pDocSh);
5125 [ # # ]: 0 : aEngine.SetRefDevice( aProv.GetDevice() );
5126 [ # # ][ # # ]: 0 : aEngine.SetRefMapMode( MAP_100TH_MM );
[ # # ]
5127 [ # # ][ # # ]: 0 : SfxItemSet aDefault( aEngine.GetEmptyItemSet() );
5128 [ # # ]: 0 : pPattern->FillEditItemSet( &aDefault );
5129 : 0 : SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT;
5130 [ # # # # : 0 : switch (eHorJust)
# ]
5131 : : {
5132 : : case SVX_HOR_JUSTIFY_LEFT:
5133 : : case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert
5134 : : case SVX_HOR_JUSTIFY_STANDARD: // always Text if an EditCell type
5135 : 0 : eSvxAdjust = SVX_ADJUST_LEFT;
5136 : 0 : break;
5137 : : case SVX_HOR_JUSTIFY_RIGHT:
5138 : 0 : eSvxAdjust = SVX_ADJUST_RIGHT;
5139 : 0 : break;
5140 : : case SVX_HOR_JUSTIFY_CENTER:
5141 : 0 : eSvxAdjust = SVX_ADJUST_CENTER;
5142 : 0 : break;
5143 : : case SVX_HOR_JUSTIFY_BLOCK:
5144 : 0 : eSvxAdjust = SVX_ADJUST_BLOCK;
5145 : 0 : break;
5146 : : }
5147 [ # # ][ # # ]: 0 : aDefault.Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
[ # # ]
5148 [ # # ]: 0 : aEngine.SetDefaults( aDefault );
5149 [ # # ]: 0 : if (bSpellErr)
5150 [ # # ][ # # ]: 0 : aEngine.SetControlWord( aEngine.GetControlWord() | EE_CNTRL_ONLINESPELLING );
5151 : :
5152 [ # # ][ # # ]: 0 : MapMode aEditMode = pViewData->GetLogicMode(eWhich); // ohne Drawing-Skalierung
5153 [ # # ]: 0 : Rectangle aLogicEdit = PixelToLogic( aEditRect, aEditMode );
5154 : 0 : long nThisColLogic = aLogicEdit.Right() - aLogicEdit.Left() + 1;
5155 : 0 : Size aPaperSize = Size( 1000000, 1000000 );
5156 [ # # ]: 0 : if(pCell->GetCellType() == CELLTYPE_FORMULA)
5157 : : {
5158 : 0 : long nSizeX = 0;
5159 : 0 : long nSizeY = 0;
5160 [ # # ]: 0 : pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
5161 : 0 : aPaperSize = Size(nSizeX, nSizeY );
5162 [ # # ]: 0 : aPaperSize = PixelToLogic(aPaperSize);
5163 : : }
5164 : :
5165 [ # # ]: 0 : if (bBreak)
5166 : 0 : aPaperSize.Width() = nThisColLogic;
5167 [ # # ]: 0 : aEngine.SetPaperSize( aPaperSize );
5168 : :
5169 : 0 : ::std::auto_ptr< EditTextObject > pTextObj;
5170 : : const EditTextObject* pData;
5171 [ # # ]: 0 : if(pCell->GetCellType() == CELLTYPE_EDIT)
5172 : : {
5173 [ # # ]: 0 : ((ScEditCell*)pCell)->GetData(pData);
5174 [ # # ]: 0 : if (pData)
5175 [ # # ]: 0 : aEngine.SetText(*pData);
5176 : : }
5177 : : else // HyperLink Formula cell
5178 : : {
5179 [ # # ][ # # ]: 0 : pTextObj.reset((static_cast<ScFormulaCell*>(pCell))->CreateURLObject());
5180 [ # # ]: 0 : if (pTextObj.get())
5181 [ # # ]: 0 : aEngine.SetText(*pTextObj);
5182 : : }
5183 : :
5184 : 0 : long nStartX = aLogicEdit.Left();
5185 : :
5186 [ # # ]: 0 : long nTextWidth = aEngine.CalcTextWidth();
5187 [ # # ]: 0 : long nTextHeight = aEngine.GetTextHeight();
5188 [ # # ]: 0 : if ( nTextWidth < nThisColLogic )
5189 : : {
5190 [ # # ]: 0 : if (eHorJust == SVX_HOR_JUSTIFY_RIGHT)
5191 : 0 : nStartX += nThisColLogic - nTextWidth;
5192 [ # # ]: 0 : else if (eHorJust == SVX_HOR_JUSTIFY_CENTER)
5193 : 0 : nStartX += (nThisColLogic - nTextWidth) / 2;
5194 : : }
5195 : :
5196 : 0 : aLogicEdit.Left() = nStartX;
5197 [ # # ]: 0 : if (!bBreak)
5198 : 0 : aLogicEdit.Right() = nStartX + nTextWidth;
5199 : :
5200 : : // There is one glitch when dealing with a hyperlink cell and
5201 : : // the cell content is NUMERIC. This defaults to right aligned and
5202 : : // we need to adjust accordingly.
5203 [ # # ][ # # ]: 0 : if(pCell->GetCellType() == CELLTYPE_FORMULA &&
[ # # ][ # # ]
5204 [ # # ][ # # ]: 0 : static_cast<ScFormulaCell*>(pCell)->IsValue() &&
5205 : : eHorJust == SVX_HOR_JUSTIFY_STANDARD)
5206 : : {
5207 : 0 : aLogicEdit.Right() = aLogicEdit.Left() + nThisColLogic - 1;
5208 : 0 : aLogicEdit.Left() = aLogicEdit.Right() - nTextWidth;
5209 : : }
5210 : 0 : aLogicEdit.Bottom() = aLogicEdit.Top() + nTextHeight;
5211 : :
5212 : :
5213 [ # # ]: 0 : Point aLogicClick = PixelToLogic(rPos,aEditMode);
5214 [ # # ][ # # ]: 0 : if ( aLogicEdit.IsInside(aLogicClick) )
5215 : : {
5216 [ # # ]: 0 : EditView aTempView( &aEngine, this );
5217 [ # # ]: 0 : aTempView.SetOutputArea( aLogicEdit );
5218 : :
5219 : 0 : sal_Bool bRet = false;
5220 [ # # ]: 0 : MapMode aOld = GetMapMode();
5221 [ # # ]: 0 : SetMapMode(aEditMode); // kein return mehr
5222 : :
5223 [ # # ]: 0 : if (bSpellErr) // Spelling-Fehler suchen
5224 : : {
5225 [ # # ]: 0 : bRet = aTempView.IsWrongSpelledWordAtPos( rPos );
5226 [ # # ]: 0 : if ( bRet )
5227 [ # # ]: 0 : pViewData->GetView()->SetCursor( nPosX, nPosY ); // Cursor setzen
5228 : : }
5229 : : else // URL suchen
5230 : : {
5231 [ # # ]: 0 : const SvxFieldItem* pFieldItem = aTempView.GetFieldUnderMousePointer();
5232 : :
5233 [ # # ]: 0 : if (pFieldItem)
5234 : : {
5235 : 0 : const SvxFieldData* pField = pFieldItem->GetField();
5236 [ # # ][ # # ]: 0 : if ( pField && pField->ISA(SvxURLField) )
[ # # ][ # # ]
[ # # ]
5237 : : {
5238 [ # # ][ # # ]: 0 : if ( pName || pUrl || pTarget )
[ # # ]
5239 : : {
5240 : 0 : const SvxURLField* pURLField = (const SvxURLField*)pField;
5241 [ # # ]: 0 : if (pName)
5242 [ # # ]: 0 : *pName = pURLField->GetRepresentation();
5243 [ # # ]: 0 : if (pUrl)
5244 [ # # ]: 0 : *pUrl = pURLField->GetURL();
5245 [ # # ]: 0 : if (pTarget)
5246 [ # # ]: 0 : *pTarget = pURLField->GetTargetFrame();
5247 : : }
5248 : 0 : bRet = sal_True;
5249 : : }
5250 : : }
5251 : : }
5252 : :
5253 [ # # ]: 0 : SetMapMode(aOld);
5254 : :
5255 [ # # ][ # # ]: 0 : return bRet;
5256 : : }
5257 [ # # ][ # # ]: 0 : return false;
[ # # ][ # # ]
[ # # ]
5258 : : }
5259 : :
5260 : 0 : bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange )
5261 : : {
5262 : 0 : ScDocument* pDoc = pViewData->GetDocument();
5263 : 0 : SCTAB nTab = pViewData->GetTabNo();
5264 : 0 : SCTAB nTabCount = pDoc->GetTableCount();
5265 [ # # ][ # # ]: 0 : if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) )
[ # # ][ # # ]
5266 : : {
5267 [ # # ]: 0 : bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
5268 : :
5269 : 0 : Size aButSize = pViewData->GetScenButSize();
5270 : 0 : long nBWidth = aButSize.Width();
5271 [ # # ]: 0 : if (!nBWidth)
5272 : 0 : return false; // noch kein Button gezeichnet -> da ist auch keiner
5273 : 0 : long nBHeight = aButSize.Height();
5274 : 0 : long nHSpace = (long)( SC_SCENARIO_HSPACE * pViewData->GetPPTX() );
5275 : :
5276 : : //! Ranges an der Table cachen!!!!
5277 : :
5278 [ # # ]: 0 : ScMarkData aMarks;
5279 [ # # ][ # # ]: 0 : for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
[ # # ][ # # ]
5280 [ # # ]: 0 : pDoc->MarkScenario( i, nTab, aMarks, false, SC_SCENARIO_SHOWFRAME );
5281 [ # # ]: 0 : ScRangeList aRanges;
5282 [ # # ]: 0 : aMarks.FillRangeListWithMarks( &aRanges, false );
5283 : :
5284 : :
5285 [ # # ]: 0 : size_t nRangeCount = aRanges.size();
5286 [ # # ]: 0 : for (size_t j=0; j< nRangeCount; ++j)
5287 : : {
5288 [ # # ]: 0 : ScRange aRange = *aRanges[j];
5289 : : // Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn
5290 : : // dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden
5291 [ # # ]: 0 : pDoc->ExtendTotalMerge( aRange );
5292 : :
5293 : 0 : bool bTextBelow = ( aRange.aStart.Row() == 0 );
5294 : :
5295 : 0 : Point aButtonPos;
5296 [ # # ]: 0 : if ( bTextBelow )
5297 : : {
5298 : 0 : aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1,
5299 [ # # ]: 0 : eWhich, sal_True );
5300 : : }
5301 : : else
5302 : : {
5303 : 0 : aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(),
5304 [ # # ]: 0 : eWhich, sal_True );
5305 : 0 : aButtonPos.Y() -= nBHeight;
5306 : : }
5307 [ # # ]: 0 : if ( bLayoutRTL )
5308 : 0 : aButtonPos.X() -= nHSpace - 1;
5309 : : else
5310 : 0 : aButtonPos.X() -= nBWidth - nHSpace; // same for top or bottom
5311 : :
5312 [ # # ]: 0 : Rectangle aButRect( aButtonPos, Size(nBWidth,nBHeight) );
5313 [ # # ][ # # ]: 0 : if ( aButRect.IsInside( rPosPixel ) )
5314 : : {
5315 : 0 : rScenRange = aRange;
5316 : 0 : return true;
5317 : : }
5318 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
5319 : : }
5320 : :
5321 : 0 : return false;
5322 : : }
5323 : :
5324 : : // #114409#
5325 : 210 : void ScGridWindow::DrawLayerCreated()
5326 : : {
5327 [ + - ]: 210 : SetMapMode( GetDrawMapMode() );
5328 : :
5329 : : // initially create overlay objects
5330 : 210 : ImpCreateOverlayObjects();
5331 : 210 : }
5332 : :
5333 : : // #114409#
5334 : 331 : void ScGridWindow::CursorChanged()
5335 : : {
5336 : : // here the created OverlayObjects may be transformed in later versions. For
5337 : : // now, just re-create them
5338 : :
5339 : 331 : UpdateCursorOverlay();
5340 : 331 : }
5341 : :
5342 : : // #114409#
5343 : 1196 : void ScGridWindow::ImpCreateOverlayObjects()
5344 : : {
5345 : 1196 : UpdateCursorOverlay();
5346 : 1196 : UpdateCopySourceOverlay();
5347 : 1196 : UpdateSelectionOverlay();
5348 : 1196 : UpdateAutoFillOverlay();
5349 : 1196 : UpdateDragRectOverlay();
5350 : 1196 : UpdateHeaderOverlay();
5351 : 1196 : UpdateShrinkOverlay();
5352 : 1196 : }
5353 : :
5354 : : // #114409#
5355 : 1211 : void ScGridWindow::ImpDestroyOverlayObjects()
5356 : : {
5357 : 1211 : DeleteCursorOverlay();
5358 : 1211 : DeleteCopySourceOverlay();
5359 : 1211 : DeleteSelectionOverlay();
5360 : 1211 : DeleteAutoFillOverlay();
5361 : 1211 : DeleteDragRectOverlay();
5362 : 1211 : DeleteHeaderOverlay();
5363 : 1211 : DeleteShrinkOverlay();
5364 : 1211 : }
5365 : :
5366 : 986 : void ScGridWindow::UpdateAllOverlays()
5367 : : {
5368 : : // delete and re-allocate all overlay objects
5369 : :
5370 : 986 : ImpDestroyOverlayObjects();
5371 : 986 : ImpCreateOverlayObjects();
5372 : 986 : }
5373 : :
5374 : 2738 : void ScGridWindow::DeleteCursorOverlay()
5375 : : {
5376 [ + + ]: 2738 : DELETEZ( mpOOCursors );
5377 : 2738 : }
5378 : :
5379 : 2407 : void ScGridWindow::DeleteCopySourceOverlay()
5380 : : {
5381 [ - + ]: 2407 : DELETEZ( mpOOSelectionBorder );
5382 : 2407 : }
5383 : :
5384 : 1196 : void ScGridWindow::UpdateCopySourceOverlay()
5385 : : {
5386 [ + - ]: 1196 : MapMode aDrawMode = GetDrawMapMode();
5387 [ + - ]: 1196 : MapMode aOldMode = GetMapMode();
5388 [ + - ][ + + ]: 1196 : if ( aOldMode != aDrawMode )
5389 [ + - ]: 4 : SetMapMode( aDrawMode );
5390 : :
5391 [ + - ]: 1196 : DeleteCopySourceOverlay();
5392 : :
5393 [ + - ]: 1196 : if (!pViewData->ShowPasteSource())
5394 : : return;
5395 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5396 [ # # ]: 0 : if (!xOverlayManager.is())
5397 : : return;
5398 [ # # ][ # # ]: 0 : ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard( pViewData->GetActiveWin() );
5399 [ # # ]: 0 : if (!pTransObj)
5400 : : return;
5401 : 0 : ScDocument* pClipDoc = pTransObj->GetDocument();
5402 [ # # ]: 0 : if (!pClipDoc)
5403 : : return;
5404 : :
5405 [ # # ]: 0 : SCTAB nCurTab = pViewData->GetCurPos().Tab();
5406 : :
5407 [ # # ]: 0 : ScClipParam& rClipParam = pClipDoc->GetClipParam();
5408 [ # # ][ # # ]: 0 : mpOOSelectionBorder = new ::sdr::overlay::OverlayObjectList;
5409 [ # # ][ # # ]: 0 : for ( size_t i = 0; i < rClipParam.maRanges.size(); ++i )
5410 : : {
5411 [ # # ]: 0 : ScRange* p = rClipParam.maRanges[i];
5412 [ # # ]: 0 : if (p->aStart.Tab() != nCurTab)
5413 : 0 : continue;
5414 : :
5415 : 0 : SCCOL nClipStartX = p->aStart.Col();
5416 : 0 : SCROW nClipStartY = p->aStart.Row();
5417 : 0 : SCCOL nClipEndX = p->aEnd.Col();
5418 : 0 : SCROW nClipEndY = p->aEnd.Row();
5419 : :
5420 [ # # ]: 0 : Point aClipStartScrPos = pViewData->GetScrPos( nClipStartX, nClipStartY, eWhich );
5421 [ # # ]: 0 : Point aClipEndScrPos = pViewData->GetScrPos( nClipEndX + 1, nClipEndY + 1, eWhich );
5422 : 0 : aClipStartScrPos -= Point(1, 1);
5423 : 0 : long nSizeXPix = aClipEndScrPos.X() - aClipStartScrPos.X();
5424 : 0 : long nSizeYPix = aClipEndScrPos.Y() - aClipStartScrPos.Y();
5425 : :
5426 [ # # ]: 0 : Rectangle aRect( aClipStartScrPos, Size(nSizeXPix, nSizeYPix) );
5427 : :
5428 : :
5429 : 0 : Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
5430 : :
5431 [ # # ]: 0 : Rectangle aLogic = PixelToLogic(aRect, aDrawMode);
5432 [ # # ]: 0 : ::basegfx::B2DRange aRange(aLogic.Left(), aLogic.Top(), aLogic.Right(), aLogic.Bottom());
5433 [ # # ][ # # ]: 0 : ScOverlayDashedBorder* pDashedBorder = new ScOverlayDashedBorder(aRange, aHighlight, this);
5434 [ # # ]: 0 : xOverlayManager->add(*pDashedBorder);
5435 [ # # ]: 0 : mpOOSelectionBorder->append(*pDashedBorder);
5436 : : }
5437 : :
5438 [ # # ][ # # ]: 0 : if ( aOldMode != aDrawMode )
5439 [ # # ][ # # ]: 1196 : SetMapMode( aOldMode );
[ # # ][ + - ]
[ + - ][ + - ]
[ - + ]
5440 : : }
5441 : :
5442 : 1527 : void ScGridWindow::UpdateCursorOverlay()
5443 : : {
5444 [ + - ]: 1527 : MapMode aDrawMode = GetDrawMapMode();
5445 [ + - ]: 1527 : MapMode aOldMode = GetMapMode();
5446 [ + - ][ + + ]: 1527 : if ( aOldMode != aDrawMode )
5447 [ + - ]: 6 : SetMapMode( aDrawMode );
5448 : :
5449 : : // Existing OverlayObjects may be transformed in later versions.
5450 : : // For now, just re-create them.
5451 : :
5452 [ + - ]: 1527 : DeleteCursorOverlay();
5453 : :
5454 [ + - ]: 1527 : std::vector<Rectangle> aPixelRects;
5455 : :
5456 : : //
5457 : : // determine the cursor rectangles in pixels (moved from ScGridWindow::DrawCursor)
5458 : : //
5459 : :
5460 : 1527 : SCTAB nTab = pViewData->GetTabNo();
5461 : 1527 : SCCOL nX = pViewData->GetCurX();
5462 : 1527 : SCROW nY = pViewData->GetCurY();
5463 : :
5464 [ + + ]: 1527 : if (!maVisibleRange.isInside(nX, nY))
5465 : 1527 : return;
5466 : :
5467 : : // don't show the cursor in overlapped cells
5468 : :
5469 [ + - ]: 1515 : ScDocument* pDoc = pViewData->GetDocument();
5470 [ + - ]: 1515 : const ScPatternAttr* pPattern = pDoc->GetPattern(nX,nY,nTab);
5471 [ + - ]: 1515 : const ScMergeFlagAttr& rMergeFlag = (const ScMergeFlagAttr&) pPattern->GetItem(ATTR_MERGE_FLAG);
5472 : 1515 : sal_Bool bOverlapped = rMergeFlag.IsOverlapped();
5473 : :
5474 : : // left or above of the screen?
5475 : :
5476 [ + - ][ + - ]: 1515 : sal_Bool bVis = ( nX>=pViewData->GetPosX(eHWhich) && nY>=pViewData->GetPosY(eVWhich) );
5477 [ - + ]: 1515 : if (!bVis)
5478 : : {
5479 : 0 : SCCOL nEndX = nX;
5480 : 0 : SCROW nEndY = nY;
5481 [ # # ]: 0 : const ScMergeAttr& rMerge = (const ScMergeAttr&) pPattern->GetItem(ATTR_MERGE);
5482 [ # # ]: 0 : if (rMerge.GetColMerge() > 1)
5483 : 0 : nEndX += rMerge.GetColMerge()-1;
5484 [ # # ]: 0 : if (rMerge.GetRowMerge() > 1)
5485 : 0 : nEndY += rMerge.GetRowMerge()-1;
5486 [ # # ][ # # ]: 0 : bVis = ( nEndX>=pViewData->GetPosX(eHWhich) && nEndY>=pViewData->GetPosY(eVWhich) );
5487 : : }
5488 : :
5489 [ + - ][ + - ]: 1515 : if ( bVis && !bOverlapped && !pViewData->HasEditView(eWhich) && pViewData->IsActive() )
[ + - ][ + + ]
[ + + ]
5490 : : {
5491 [ + - ]: 1505 : Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, sal_True );
5492 [ + - ]: 1505 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
5493 : :
5494 : : // completely right of/below the screen?
5495 : : // (test with logical start position in aScrPos)
5496 : : sal_Bool bMaybeVisible;
5497 [ + + ]: 1505 : if ( bLayoutRTL )
5498 [ + - ][ + - ]: 2 : bMaybeVisible = ( aScrPos.X() >= -2 && aScrPos.Y() >= -2 );
5499 : : else
5500 : : {
5501 : 1503 : Size aOutSize = GetOutputSizePixel();
5502 [ + + ][ + + ]: 1503 : bMaybeVisible = ( aScrPos.X() <= aOutSize.Width() + 2 && aScrPos.Y() <= aOutSize.Height() + 2 );
5503 : : }
5504 [ + + ]: 1505 : if ( bMaybeVisible )
5505 : : {
5506 : : long nSizeXPix;
5507 : : long nSizeYPix;
5508 [ + - ]: 1497 : pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
5509 : :
5510 [ + + ]: 1497 : if ( bLayoutRTL )
5511 : 2 : aScrPos.X() -= nSizeXPix - 2; // move instead of mirroring
5512 : :
5513 : : // Now, draw the cursor.
5514 : :
5515 : 1497 : aScrPos.X() -= 2;
5516 : 1497 : aScrPos.Y() -= 2;
5517 [ + - ]: 1497 : Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) );
5518 : :
5519 [ + - ][ + - ]: 1497 : aPixelRects.push_back(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() ));
5520 [ + - ][ + - ]: 1497 : aPixelRects.push_back(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() ));
5521 [ + - ][ + - ]: 1497 : aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 ));
5522 [ + - ][ + - ]: 1505 : aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() ));
5523 : : }
5524 : : }
5525 : :
5526 [ + + ]: 1515 : if ( !aPixelRects.empty() )
5527 : : {
5528 : : // #i70788# get the OverlayManager safely
5529 [ + - ]: 1497 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5530 : :
5531 [ + + ]: 1497 : if (xOverlayManager.is())
5532 : : {
5533 [ + - ][ + - ]: 1449 : Color aCursorColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
[ + - ]
5534 [ - + ]: 1449 : if (pViewData->GetActivePart() != eWhich)
5535 : : // non-active pane uses a different color.
5536 [ # # ][ # # ]: 0 : aCursorColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
[ # # ]
5537 [ + - ]: 1449 : std::vector< basegfx::B2DRange > aRanges;
5538 [ + - ]: 1449 : const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
5539 : :
5540 [ + + ]: 7245 : for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
5541 : : {
5542 [ + - ]: 5796 : const Rectangle aRA(aPixelRects[a]);
5543 [ + - ]: 5796 : basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
5544 [ + - ]: 5796 : aRB.transform(aTransform);
5545 [ + - ]: 5796 : aRanges.push_back(aRB);
5546 : : }
5547 : :
5548 : : sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
5549 : : sdr::overlay::OVERLAY_SOLID,
5550 : : aCursorColor,
5551 : : aRanges,
5552 [ + - ][ + - ]: 1449 : false);
5553 : :
5554 [ + - ]: 1449 : xOverlayManager->add(*pOverlay);
5555 [ + - ][ + - ]: 1449 : mpOOCursors = new ::sdr::overlay::OverlayObjectList;
5556 [ + - ][ + - ]: 1449 : mpOOCursors->append(*pOverlay);
5557 [ + - ]: 1497 : }
5558 : : }
5559 : :
5560 [ + - ][ + + ]: 1515 : if ( aOldMode != aDrawMode )
5561 [ + - ][ + + ]: 1527 : SetMapMode( aOldMode );
[ + - ][ + + ]
[ + - ][ + + ]
5562 : : }
5563 : :
5564 : 2448 : void ScGridWindow::DeleteSelectionOverlay()
5565 : : {
5566 [ + + ]: 2448 : DELETEZ( mpOOSelection );
5567 : 2448 : }
5568 : :
5569 : 1237 : void ScGridWindow::UpdateSelectionOverlay()
5570 : : {
5571 [ + - ]: 1237 : MapMode aDrawMode = GetDrawMapMode();
5572 [ + - ]: 1237 : MapMode aOldMode = GetMapMode();
5573 [ + - ][ - + ]: 1237 : if ( aOldMode != aDrawMode )
5574 [ # # ]: 0 : SetMapMode( aDrawMode );
5575 : :
5576 [ + - ]: 1237 : DeleteSelectionOverlay();
5577 [ + - ]: 1237 : std::vector<Rectangle> aPixelRects;
5578 [ + - ]: 1237 : GetSelectionRects( aPixelRects );
5579 : :
5580 [ + + ][ + + ]: 1237 : if ( aPixelRects.size() && pViewData->IsActive() )
[ + + ]
5581 : : {
5582 : : // #i70788# get the OverlayManager safely
5583 [ + - ]: 38 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5584 : :
5585 [ + - ]: 38 : if (xOverlayManager.is())
5586 : : {
5587 [ + - ]: 38 : std::vector< basegfx::B2DRange > aRanges;
5588 [ + - ]: 38 : const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
5589 : :
5590 [ + + ]: 76 : for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
5591 : : {
5592 [ + - ]: 38 : const Rectangle aRA(aPixelRects[a]);
5593 [ + - ]: 38 : basegfx::B2DRange aRB(aRA.Left() - 1, aRA.Top() - 1, aRA.Right(), aRA.Bottom());
5594 [ + - ]: 38 : aRB.transform(aTransform);
5595 [ + - ]: 38 : aRanges.push_back(aRB);
5596 : : }
5597 : :
5598 : : // #i97672# get the system's hilight color and limit it to the maximum
5599 : : // allowed luminance. This is needed to react on too bright hilight colors
5600 : : // which would otherwise vive a bad visualisation
5601 : 38 : Color aHighlight(GetSettings().GetStyleSettings().GetHighlightColor());
5602 [ + - ]: 38 : const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
5603 : 38 : const basegfx::BColor aSelection(aHighlight.getBColor());
5604 : 38 : const double fLuminance(aSelection.luminance());
5605 [ + - ]: 38 : const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0);
5606 : :
5607 [ - + ]: 38 : if(fLuminance > fMaxLum)
5608 : : {
5609 : 0 : const double fFactor(fMaxLum / fLuminance);
5610 : : const basegfx::BColor aNewSelection(
5611 : 0 : aSelection.getRed() * fFactor,
5612 : 0 : aSelection.getGreen() * fFactor,
5613 : 0 : aSelection.getBlue() * fFactor);
5614 : :
5615 : 0 : aHighlight = Color(aNewSelection);
5616 : : }
5617 : :
5618 : : sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
5619 : : sdr::overlay::OVERLAY_TRANSPARENT,
5620 : : aHighlight,
5621 : : aRanges,
5622 [ + - ][ + - ]: 38 : true);
5623 : :
5624 [ + - ]: 38 : xOverlayManager->add(*pOverlay);
5625 [ + - ][ + - ]: 38 : mpOOSelection = new ::sdr::overlay::OverlayObjectList;
5626 [ + - ][ + - ]: 38 : mpOOSelection->append(*pOverlay);
[ + - ]
5627 [ + - ]: 38 : }
5628 : : }
5629 : :
5630 [ + - ][ - + ]: 1237 : if ( aOldMode != aDrawMode )
5631 [ # # ][ + - ]: 1237 : SetMapMode( aOldMode );
[ + - ]
5632 : 1237 : }
5633 : :
5634 : 2745 : void ScGridWindow::DeleteAutoFillOverlay()
5635 : : {
5636 [ + + ]: 2745 : DELETEZ( mpOOAutoFill );
5637 : 2745 : mpAutoFillRect.reset();
5638 : 2745 : }
5639 : :
5640 : 1534 : void ScGridWindow::UpdateAutoFillOverlay()
5641 : : {
5642 [ + - ]: 1534 : MapMode aDrawMode = GetDrawMapMode();
5643 [ + - ]: 1534 : MapMode aOldMode = GetMapMode();
5644 [ + - ][ + + ]: 1534 : if ( aOldMode != aDrawMode )
5645 [ + - ]: 2 : SetMapMode( aDrawMode );
5646 : :
5647 [ + - ]: 1534 : DeleteAutoFillOverlay();
5648 : :
5649 : : //
5650 : : // get the AutoFill handle rectangle in pixels
5651 : : //
5652 : :
5653 [ + + ][ + - : 4182 : if ( bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() &&
+ - + + ]
[ + + ]
5654 : 2648 : !pViewData->HasEditView(eWhich) && pViewData->IsActive() )
5655 : : {
5656 : 1317 : SCCOL nX = aAutoMarkPos.Col();
5657 : 1317 : SCROW nY = aAutoMarkPos.Row();
5658 : :
5659 [ + + ]: 1317 : if (!maVisibleRange.isInside(nX, nY))
5660 : : // Autofill mark is not visible. Bail out.
5661 : 1534 : return;
5662 : :
5663 : 1301 : SCTAB nTab = pViewData->GetTabNo();
5664 [ + - ]: 1301 : ScDocument* pDoc = pViewData->GetDocument();
5665 [ + - ]: 1301 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
5666 : :
5667 [ + - ]: 1301 : Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, sal_True );
5668 : : long nSizeXPix;
5669 : : long nSizeYPix;
5670 [ + - ]: 1301 : pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
5671 [ + + ]: 1301 : if ( bLayoutRTL )
5672 : 2 : aFillPos.X() -= nSizeXPix + 3;
5673 : : else
5674 : 1299 : aFillPos.X() += nSizeXPix - 2;
5675 : :
5676 : 1301 : aFillPos.Y() += nSizeYPix;
5677 : 1301 : aFillPos.Y() -= 2;
5678 [ + - ][ + - ]: 1301 : mpAutoFillRect.reset(new Rectangle(aFillPos, Size(6, 6)));
[ + - ]
5679 : :
5680 : : // #i70788# get the OverlayManager safely
5681 [ + - ]: 1301 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5682 : :
5683 [ + + ]: 1301 : if (xOverlayManager.is())
5684 : : {
5685 [ + - ][ + - ]: 1269 : Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
[ + - ]
5686 [ - + ]: 1269 : if (pViewData->GetActivePart() != eWhich)
5687 : : // non-active pane uses a different color.
5688 [ # # ][ # # ]: 0 : aHandleColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
[ # # ]
5689 [ + - ]: 1269 : std::vector< basegfx::B2DRange > aRanges;
5690 [ + - ]: 1269 : const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
5691 [ + - ]: 1269 : basegfx::B2DRange aRB(mpAutoFillRect->Left(), mpAutoFillRect->Top(), mpAutoFillRect->Right() + 1, mpAutoFillRect->Bottom() + 1);
5692 : :
5693 [ + - ]: 1269 : aRB.transform(aTransform);
5694 [ + - ]: 1269 : aRanges.push_back(aRB);
5695 : :
5696 : : sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
5697 : : sdr::overlay::OVERLAY_SOLID,
5698 : : aHandleColor,
5699 : : aRanges,
5700 [ + - ][ + - ]: 1269 : false);
5701 : :
5702 [ + - ]: 1269 : xOverlayManager->add(*pOverlay);
5703 [ + - ][ + - ]: 1269 : mpOOAutoFill = new ::sdr::overlay::OverlayObjectList;
5704 [ + - ][ + - ]: 1269 : mpOOAutoFill->append(*pOverlay);
5705 : : }
5706 : :
5707 [ + - ][ + + ]: 1301 : if ( aOldMode != aDrawMode )
5708 [ + - ][ + - ]: 1534 : SetMapMode( aOldMode );
5709 [ + - ][ + + ]: 1534 : }
[ + - ][ + + ]
5710 : : }
5711 : :
5712 : 2407 : void ScGridWindow::DeleteDragRectOverlay()
5713 : : {
5714 [ - + ]: 2407 : DELETEZ( mpOODragRect );
5715 : 2407 : }
5716 : :
5717 : 1196 : void ScGridWindow::UpdateDragRectOverlay()
5718 : : {
5719 [ + - ]: 1196 : MapMode aDrawMode = GetDrawMapMode();
5720 [ + - ]: 1196 : MapMode aOldMode = GetMapMode();
5721 [ + - ][ - + ]: 1196 : if ( aOldMode != aDrawMode )
5722 [ # # ]: 0 : SetMapMode( aDrawMode );
5723 : :
5724 [ + - ]: 1196 : DeleteDragRectOverlay();
5725 : :
5726 : : //
5727 : : // get the rectangles in pixels (moved from DrawDragRect)
5728 : : //
5729 : :
5730 [ + - ][ - + ]: 1196 : if ( bDragRect || bPagebreakDrawn )
5731 : : {
5732 [ # # ]: 0 : std::vector<Rectangle> aPixelRects;
5733 : :
5734 [ # # ]: 0 : SCCOL nX1 = bDragRect ? nDragStartX : aPagebreakDrag.aStart.Col();
5735 [ # # ]: 0 : SCROW nY1 = bDragRect ? nDragStartY : aPagebreakDrag.aStart.Row();
5736 [ # # ]: 0 : SCCOL nX2 = bDragRect ? nDragEndX : aPagebreakDrag.aEnd.Col();
5737 [ # # ]: 0 : SCROW nY2 = bDragRect ? nDragEndY : aPagebreakDrag.aEnd.Row();
5738 : :
5739 : 0 : SCTAB nTab = pViewData->GetTabNo();
5740 : :
5741 : 0 : SCCOL nPosX = pViewData->GetPosX(WhichH(eWhich));
5742 : 0 : SCROW nPosY = pViewData->GetPosY(WhichV(eWhich));
5743 [ # # ]: 0 : if (nX1 < nPosX) nX1 = nPosX;
5744 [ # # ]: 0 : if (nX2 < nPosX) nX2 = nPosX;
5745 [ # # ]: 0 : if (nY1 < nPosY) nY1 = nPosY;
5746 [ # # ]: 0 : if (nY2 < nPosY) nY2 = nPosY;
5747 : :
5748 [ # # ]: 0 : Point aScrPos( pViewData->GetScrPos( nX1, nY1, eWhich ) );
5749 : :
5750 : 0 : long nSizeXPix=0;
5751 : 0 : long nSizeYPix=0;
5752 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
5753 : 0 : double nPPTX = pViewData->GetPPTX();
5754 : 0 : double nPPTY = pViewData->GetPPTY();
5755 : : SCCOLROW i;
5756 : :
5757 [ # # ]: 0 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
5758 [ # # ]: 0 : long nLayoutSign = bLayoutRTL ? -1 : 1;
5759 : :
5760 [ # # ][ # # ]: 0 : if (ValidCol(nX2) && nX2>=nX1)
[ # # ]
5761 [ # # ]: 0 : for (i=nX1; i<=nX2; i++)
5762 [ # # ]: 0 : nSizeXPix += ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(i), nTab ), nPPTX );
5763 : : else
5764 : : {
5765 : 0 : aScrPos.X() -= nLayoutSign;
5766 : 0 : nSizeXPix += 2;
5767 : : }
5768 : :
5769 [ # # ][ # # ]: 0 : if (ValidRow(nY2) && nY2>=nY1)
[ # # ]
5770 [ # # ]: 0 : for (i=nY1; i<=nY2; i++)
5771 [ # # ]: 0 : nSizeYPix += ScViewData::ToPixel( pDoc->GetRowHeight( i, nTab ), nPPTY );
5772 : : else
5773 : : {
5774 : 0 : aScrPos.Y() -= 1;
5775 : 0 : nSizeYPix += 2;
5776 : : }
5777 : :
5778 : 0 : aScrPos.X() -= 2 * nLayoutSign;
5779 : 0 : aScrPos.Y() -= 2;
5780 : 0 : Rectangle aRect( aScrPos.X(), aScrPos.Y(),
5781 [ # # ]: 0 : aScrPos.X() + ( nSizeXPix + 2 ) * nLayoutSign, aScrPos.Y() + nSizeYPix + 2 );
5782 [ # # ]: 0 : if ( bLayoutRTL )
5783 : : {
5784 : 0 : aRect.Left() = aRect.Right(); // end position is left
5785 : 0 : aRect.Right() = aScrPos.X();
5786 : : }
5787 : :
5788 [ # # ]: 0 : if ( meDragInsertMode == INS_CELLSDOWN )
5789 : : {
5790 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Top()+3, aRect.Left()+1, aRect.Bottom()-2 ) );
5791 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Right()-1, aRect.Top()+3, aRect.Right()-1, aRect.Bottom()-2 ) );
5792 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Top(), aRect.Right()-1, aRect.Top()+2 ) );
5793 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Bottom()-1, aRect.Right()-1, aRect.Bottom()-1 ) );
5794 : : }
5795 [ # # ]: 0 : else if ( meDragInsertMode == INS_CELLSRIGHT )
5796 : : {
5797 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left(), aRect.Top()+1, aRect.Left()+2, aRect.Bottom()-1 ) );
5798 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Right()-1, aRect.Top()+1, aRect.Right()-1, aRect.Bottom()-1 ) );
5799 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Top()+1, aRect.Right()-2, aRect.Top()+1 ) );
5800 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Bottom()-1, aRect.Right()-2, aRect.Bottom()-1 ) );
5801 : : }
5802 : : else
5803 : : {
5804 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() ) );
5805 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() ) );
5806 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 ) );
5807 [ # # ][ # # ]: 0 : aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() ) );
5808 : : }
5809 : :
5810 : : // #i70788# get the OverlayManager safely
5811 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5812 : :
5813 [ # # ]: 0 : if (xOverlayManager.is())
5814 : : {
5815 [ # # ]: 0 : std::vector< basegfx::B2DRange > aRanges;
5816 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
5817 : :
5818 [ # # ]: 0 : for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
5819 : : {
5820 [ # # ]: 0 : const Rectangle aRA(aPixelRects[a]);
5821 [ # # ]: 0 : basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
5822 [ # # ]: 0 : aRB.transform(aTransform);
5823 [ # # ]: 0 : aRanges.push_back(aRB);
5824 : : }
5825 : :
5826 : : sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
5827 : : sdr::overlay::OVERLAY_INVERT,
5828 : : Color(COL_BLACK),
5829 : : aRanges,
5830 [ # # ][ # # ]: 0 : false);
5831 : :
5832 [ # # ]: 0 : xOverlayManager->add(*pOverlay);
5833 [ # # ][ # # ]: 0 : mpOODragRect = new ::sdr::overlay::OverlayObjectList;
5834 [ # # ][ # # ]: 0 : mpOODragRect->append(*pOverlay);
5835 [ # # ]: 0 : }
5836 : : }
5837 : :
5838 [ + - ][ - + ]: 1196 : if ( aOldMode != aDrawMode )
5839 [ # # ][ + - ]: 1196 : SetMapMode( aOldMode );
[ + - ]
5840 : 1196 : }
5841 : :
5842 : 2407 : void ScGridWindow::DeleteHeaderOverlay()
5843 : : {
5844 [ - + ]: 2407 : DELETEZ( mpOOHeader );
5845 : 2407 : }
5846 : :
5847 : 1196 : void ScGridWindow::UpdateHeaderOverlay()
5848 : : {
5849 [ + - ]: 1196 : MapMode aDrawMode = GetDrawMapMode();
5850 [ + - ]: 1196 : MapMode aOldMode = GetMapMode();
5851 [ + - ][ - + ]: 1196 : if ( aOldMode != aDrawMode )
5852 [ # # ]: 0 : SetMapMode( aDrawMode );
5853 : :
5854 [ + - ]: 1196 : DeleteHeaderOverlay();
5855 : :
5856 : : // Pixel rectangle is in aInvertRect
5857 [ + - ][ - + ]: 1196 : if ( !aInvertRect.IsEmpty() )
5858 : : {
5859 : : // #i70788# get the OverlayManager safely
5860 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5861 : :
5862 [ # # ]: 0 : if (xOverlayManager.is())
5863 : : {
5864 : : // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
5865 [ # # ]: 0 : std::vector< basegfx::B2DRange > aRanges;
5866 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
5867 [ # # ]: 0 : basegfx::B2DRange aRB(aInvertRect.Left(), aInvertRect.Top(), aInvertRect.Right() + 1, aInvertRect.Bottom() + 1);
5868 : :
5869 [ # # ]: 0 : aRB.transform(aTransform);
5870 [ # # ]: 0 : aRanges.push_back(aRB);
5871 : :
5872 : : sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
5873 : : sdr::overlay::OVERLAY_INVERT,
5874 : : Color(COL_BLACK),
5875 : : aRanges,
5876 [ # # ][ # # ]: 0 : false);
5877 : :
5878 [ # # ]: 0 : xOverlayManager->add(*pOverlay);
5879 [ # # ][ # # ]: 0 : mpOOHeader = new ::sdr::overlay::OverlayObjectList;
5880 [ # # ][ # # ]: 0 : mpOOHeader->append(*pOverlay);
5881 [ # # ]: 0 : }
5882 : : }
5883 : :
5884 [ + - ][ - + ]: 1196 : if ( aOldMode != aDrawMode )
5885 [ # # ][ + - ]: 1196 : SetMapMode( aOldMode );
[ + - ]
5886 : 1196 : }
5887 : :
5888 : 2407 : void ScGridWindow::DeleteShrinkOverlay()
5889 : : {
5890 [ - + ]: 2407 : DELETEZ( mpOOShrink );
5891 : 2407 : }
5892 : :
5893 : 1196 : void ScGridWindow::UpdateShrinkOverlay()
5894 : : {
5895 [ + - ]: 1196 : MapMode aDrawMode = GetDrawMapMode();
5896 [ + - ]: 1196 : MapMode aOldMode = GetMapMode();
5897 [ + - ][ - + ]: 1196 : if ( aOldMode != aDrawMode )
5898 [ # # ]: 0 : SetMapMode( aDrawMode );
5899 : :
5900 [ + - ]: 1196 : DeleteShrinkOverlay();
5901 : :
5902 : : //
5903 : : // get the rectangle in pixels
5904 : : //
5905 : :
5906 [ + - ]: 1196 : Rectangle aPixRect;
5907 : 1196 : ScRange aRange;
5908 : 1196 : SCTAB nTab = pViewData->GetTabNo();
5909 [ # # ]: 1196 : if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() &&
[ # # # # ]
[ - + ][ - + ]
5910 : 0 : pViewData->GetDelMark( aRange ) )
5911 : : {
5912 : : //! limit to visible area
5913 [ # # # # ]: 0 : if ( aRange.aStart.Col() <= aRange.aEnd.Col() &&
[ # # ]
5914 : 0 : aRange.aStart.Row() <= aRange.aEnd.Row() )
5915 : : {
5916 : 0 : Point aStart = pViewData->GetScrPos( aRange.aStart.Col(),
5917 [ # # ]: 0 : aRange.aStart.Row(), eWhich );
5918 : 0 : Point aEnd = pViewData->GetScrPos( aRange.aEnd.Col()+1,
5919 [ # # ]: 0 : aRange.aEnd.Row()+1, eWhich );
5920 : 0 : aEnd.X() -= 1;
5921 : 0 : aEnd.Y() -= 1;
5922 : :
5923 [ # # ]: 0 : aPixRect = Rectangle( aStart,aEnd );
5924 : : }
5925 : : }
5926 : :
5927 [ + - ][ - + ]: 1196 : if ( !aPixRect.IsEmpty() )
5928 : : {
5929 : : // #i70788# get the OverlayManager safely
5930 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5931 : :
5932 [ # # ]: 0 : if (xOverlayManager.is())
5933 : : {
5934 [ # # ]: 0 : std::vector< basegfx::B2DRange > aRanges;
5935 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
5936 [ # # ]: 0 : basegfx::B2DRange aRB(aPixRect.Left(), aPixRect.Top(), aPixRect.Right() + 1, aPixRect.Bottom() + 1);
5937 : :
5938 [ # # ]: 0 : aRB.transform(aTransform);
5939 [ # # ]: 0 : aRanges.push_back(aRB);
5940 : :
5941 : : sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
5942 : : sdr::overlay::OVERLAY_INVERT,
5943 : : Color(COL_BLACK),
5944 : : aRanges,
5945 [ # # ][ # # ]: 0 : false);
5946 : :
5947 [ # # ]: 0 : xOverlayManager->add(*pOverlay);
5948 [ # # ][ # # ]: 0 : mpOOShrink = new ::sdr::overlay::OverlayObjectList;
5949 [ # # ][ # # ]: 0 : mpOOShrink->append(*pOverlay);
5950 [ # # ]: 0 : }
5951 : : }
5952 : :
5953 [ + - ][ - + ]: 1196 : if ( aOldMode != aDrawMode )
5954 [ # # ][ + - ]: 1196 : SetMapMode( aOldMode );
[ + - ]
5955 : 1196 : }
5956 : :
5957 : : // #i70788# central method to get the OverlayManager safely
5958 : 2836 : rtl::Reference<sdr::overlay::OverlayManager> ScGridWindow::getOverlayManager()
5959 : : {
5960 : 2836 : SdrPageView* pPV = pViewData->GetView()->GetScDrawView()->GetSdrPageView();
5961 : :
5962 [ + + ]: 2836 : if(pPV)
5963 : : {
5964 : 2756 : SdrPageWindow* pPageWin = pPV->FindPageWindow( *this );
5965 : :
5966 [ + - ]: 2756 : if ( pPageWin )
5967 : : {
5968 : 2756 : return (pPageWin->GetOverlayManager());
5969 : : }
5970 : : }
5971 : :
5972 : 2836 : return rtl::Reference<sdr::overlay::OverlayManager>();
5973 : : }
5974 : :
5975 : 0 : void ScGridWindow::flushOverlayManager()
5976 : : {
5977 : : // #i70788# get the OverlayManager safely
5978 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
5979 : :
5980 [ # # ]: 0 : if (xOverlayManager.is())
5981 [ # # ][ # # ]: 0 : xOverlayManager->flush();
5982 : 0 : }
5983 : :
5984 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|