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 : : #include "scitems.hxx"
30 : : #include <vcl/msgbox.hxx>
31 : :
32 : : #include "gridwin.hxx"
33 : : #include "tabvwsh.hxx"
34 : : #include "docsh.hxx"
35 : : #include "viewdata.hxx"
36 : : #include "pivot.hxx"
37 : : #include "uiitems.hxx"
38 : : #include "scresid.hxx"
39 : : #include "sc.hrc"
40 : : #include "globstr.hrc"
41 : : #include "pagedata.hxx"
42 : : #include "dpobject.hxx"
43 : : #include "dpsave.hxx"
44 : : #include "dpoutput.hxx" // ScDPPositionData
45 : : #include "dpshttab.hxx"
46 : : #include "dbdocfun.hxx"
47 : : #include "checklistmenu.hxx"
48 : : #include "dpcontrol.hxx"
49 : : #include "checklistmenu.hrc"
50 : : #include "strload.hxx"
51 : : #include "userlist.hxx"
52 : :
53 : : #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
54 : : #include "scabstdlg.hxx"
55 : :
56 : : #include <vector>
57 : : #include <boost/unordered_map.hpp>
58 : :
59 : : using namespace com::sun::star;
60 : : using ::com::sun::star::sheet::DataPilotFieldOrientation;
61 : : using ::std::vector;
62 : : using ::std::auto_ptr;
63 : : using ::boost::unordered_map;
64 : : using ::rtl::OUString;
65 : : using ::rtl::OUStringHash;
66 : :
67 : : // STATIC DATA -----------------------------------------------------------
68 : :
69 : : // -----------------------------------------------------------------------
70 : :
71 : 0 : DataPilotFieldOrientation ScGridWindow::GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const
72 : : {
73 : : using namespace ::com::sun::star::sheet;
74 : :
75 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
76 : 0 : SCTAB nTab = pViewData->GetTabNo();
77 [ # # ]: 0 : ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
78 [ # # ]: 0 : if (!pDPObj)
79 : 0 : return DataPilotFieldOrientation_HIDDEN;
80 : :
81 : 0 : sal_uInt16 nOrient = DataPilotFieldOrientation_HIDDEN;
82 : :
83 : : // Check for page field first.
84 [ # # ]: 0 : if (nCol > 0)
85 : : {
86 : : // look for the dimension header left of the drop-down arrow
87 [ # # ]: 0 : long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient );
88 [ # # ][ # # ]: 0 : if ( nField >= 0 && nOrient == DataPilotFieldOrientation_PAGE )
89 : : {
90 : 0 : bool bIsDataLayout = false;
91 [ # # ]: 0 : OUString aFieldName = pDPObj->GetDimName( nField, bIsDataLayout );
92 [ # # ][ # # ]: 0 : if ( !aFieldName.isEmpty() && !bIsDataLayout )
[ # # ]
93 [ # # ]: 0 : return DataPilotFieldOrientation_PAGE;
94 : : }
95 : : }
96 : :
97 : 0 : nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
98 : :
99 : : // Now, check for row/column field.
100 [ # # ]: 0 : long nField = pDPObj->GetHeaderDim(ScAddress(nCol, nRow, nTab), nOrient);
101 [ # # ][ # # ]: 0 : if (nField >= 0 && (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW) )
[ # # ]
102 : : {
103 : 0 : bool bIsDataLayout = false;
104 [ # # ]: 0 : OUString aFieldName = pDPObj->GetDimName(nField, bIsDataLayout);
105 [ # # ][ # # ]: 0 : if (!aFieldName.isEmpty() && !bIsDataLayout)
[ # # ]
106 [ # # ]: 0 : return static_cast<DataPilotFieldOrientation>(nOrient);
107 : : }
108 : :
109 : 0 : return DataPilotFieldOrientation_HIDDEN;
110 : : }
111 : :
112 : : // private method for mouse button handling
113 : 0 : bool ScGridWindow::DoPageFieldSelection( SCCOL nCol, SCROW nRow )
114 : : {
115 [ # # ]: 0 : if (GetDPFieldOrientation( nCol, nRow ) == sheet::DataPilotFieldOrientation_PAGE)
116 : : {
117 : 0 : LaunchPageFieldMenu( nCol, nRow );
118 : 0 : return true;
119 : : }
120 : 0 : return false;
121 : : }
122 : :
123 : 0 : bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt )
124 : : {
125 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
126 : 0 : SCTAB nTab = pViewData->GetTabNo();
127 [ # # ]: 0 : Point aScrPos = pViewData->GetScrPos(nCol, nRow, eWhich);
128 : 0 : Point aDiffPix = rMEvt.GetPosPixel();
129 : :
130 : 0 : aDiffPix -= aScrPos;
131 [ # # ]: 0 : sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
132 [ # # ]: 0 : if ( bLayoutRTL )
133 : 0 : aDiffPix.X() = -aDiffPix.X();
134 : :
135 : : long nSizeX, nSizeY;
136 [ # # ]: 0 : pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
137 : 0 : Size aScrSize(nSizeX-1, nSizeY-1);
138 : :
139 : : // Check if the mouse cursor is clicking on the popup arrow box.
140 [ # # ][ # # ]: 0 : mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc));
[ # # ]
141 [ # # ]: 0 : mpFilterButton->setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
142 [ # # ]: 0 : mpFilterButton->setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL
143 : 0 : Point aPopupPos;
144 : 0 : Size aPopupSize;
145 [ # # ]: 0 : mpFilterButton->getPopupBoundingBox(aPopupPos, aPopupSize);
146 [ # # ]: 0 : Rectangle aRec(aPopupPos, aPopupSize);
147 [ # # ][ # # ]: 0 : if (aRec.IsInside(rMEvt.GetPosPixel()))
148 : : {
149 [ # # ][ # # ]: 0 : if ( DoPageFieldSelection( nCol, nRow ) )
150 : 0 : return true;
151 : :
152 [ # # ]: 0 : bool bFilterActive = IsAutoFilterActive(nCol, nRow, nTab);
153 [ # # ]: 0 : mpFilterButton->setHasHiddenMember(bFilterActive);
154 [ # # ]: 0 : mpFilterButton->setDrawBaseButton(false);
155 [ # # ]: 0 : mpFilterButton->setDrawPopupButton(true);
156 [ # # ]: 0 : mpFilterButton->setPopupPressed(true);
157 [ # # ]: 0 : mpFilterButton->draw();
158 [ # # ]: 0 : LaunchAutoFilterMenu(nCol, nRow);
159 : 0 : return true;
160 : : }
161 : :
162 : 0 : return false;
163 : : }
164 : :
165 : 0 : void ScGridWindow::DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt )
166 : : {
167 : 0 : ScDocument* pDoc = pViewData->GetDocument();
168 : 0 : SCTAB nTab = pViewData->GetTabNo();
169 : :
170 : 0 : ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
171 : :
172 [ # # ]: 0 : if (pDPObj)
173 : : {
174 : 0 : sal_uInt16 nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
175 : 0 : ScAddress aPos( nCol, nRow, nTab );
176 [ # # ]: 0 : long nField = pDPObj->GetHeaderDim( aPos, nOrient );
177 [ # # ]: 0 : if ( nField >= 0 )
178 : : {
179 : 0 : bDPMouse = true;
180 : 0 : nDPField = nField;
181 : 0 : pDragDPObj = pDPObj;
182 : :
183 [ # # ][ # # ]: 0 : if (DPTestFieldPopupArrow(rMEvt, aPos, pDPObj))
184 : : {
185 : : // field name pop up menu has been launched. Don't activate
186 : : // field move.
187 : 0 : bDPMouse = false;
188 : 0 : return;
189 : : }
190 : :
191 [ # # ]: 0 : DPTestMouse( rMEvt, sal_True );
192 [ # # ]: 0 : StartTracking();
193 : : }
194 [ # # ][ # # ]: 0 : else if ( pDPObj->IsFilterButton(aPos) )
195 : : {
196 [ # # ]: 0 : ReleaseMouse(); // may have been captured in ButtonDown
197 : :
198 [ # # ]: 0 : ScQueryParam aQueryParam;
199 : 0 : SCTAB nSrcTab = 0;
200 : 0 : const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
201 : : OSL_ENSURE(pDesc, "no sheet source for filter button");
202 [ # # ]: 0 : if (pDesc)
203 : : {
204 [ # # ][ # # ]: 0 : aQueryParam = pDesc->GetQueryParam();
205 [ # # ]: 0 : nSrcTab = pDesc->GetSourceRange().aStart.Tab();
206 : : }
207 : :
208 : 0 : SfxItemSet aArgSet( pViewData->GetViewShell()->GetPool(),
209 [ # # ]: 0 : SCITEM_QUERYDATA, SCITEM_QUERYDATA );
210 [ # # ][ # # ]: 0 : aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
[ # # ]
211 : :
212 [ # # ]: 0 : ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
213 : : OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
214 : :
215 : : AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg( pViewData->GetViewShell()->GetDialogParent(),
216 : : aArgSet, nSrcTab,
217 [ # # ][ # # ]: 0 : RID_SCDLG_PIVOTFILTER);
218 : : OSL_ENSURE(pDlg, "Dialog create fail!");
219 [ # # ][ # # ]: 0 : if ( pDlg->Execute() == RET_OK )
220 : : {
221 [ # # ]: 0 : ScSheetSourceDesc aNewDesc(pDoc);
222 [ # # ]: 0 : if (pDesc)
223 [ # # ]: 0 : aNewDesc = *pDesc;
224 : :
225 [ # # ]: 0 : const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
226 [ # # ][ # # ]: 0 : aNewDesc.SetQueryParam(rQueryItem.GetQueryData());
227 : :
228 [ # # ]: 0 : ScDPObject aNewObj( *pDPObj );
229 [ # # ]: 0 : aNewObj.SetSheetDesc( aNewDesc );
230 : 0 : ScDBDocFunc aFunc( *pViewData->GetDocShell() );
231 [ # # ]: 0 : aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, false );
232 [ # # ][ # # ]: 0 : pViewData->GetView()->CursorPosChanged(); // shells may be switched
[ # # ]
233 : : }
234 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
235 : : }
236 : : }
237 : : else
238 : : {
239 : : OSL_FAIL("Da is ja garnix");
240 : : }
241 : : }
242 : :
243 : : // -----------------------------------------------------------------------
244 : : //
245 : : // Data Pilot interaction
246 : : //
247 : :
248 : 0 : void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, sal_Bool bMove )
249 : : {
250 : : OSL_ENSURE(pDragDPObj, "pDragDPObj missing");
251 : :
252 : : // scroll window if at edges
253 : : //! move this to separate method
254 : :
255 : 0 : sal_Bool bTimer = false;
256 : 0 : Point aPixel = rMEvt.GetPosPixel();
257 : :
258 : 0 : SCsCOL nDx = 0;
259 : 0 : SCsROW nDy = 0;
260 [ # # ]: 0 : if ( aPixel.X() < 0 )
261 : 0 : nDx = -1;
262 [ # # ]: 0 : if ( aPixel.Y() < 0 )
263 : 0 : nDy = -1;
264 : 0 : Size aSize = GetOutputSizePixel();
265 [ # # ]: 0 : if ( aPixel.X() >= aSize.Width() )
266 : 0 : nDx = 1;
267 [ # # ]: 0 : if ( aPixel.Y() >= aSize.Height() )
268 : 0 : nDy = 1;
269 [ # # ][ # # ]: 0 : if ( nDx != 0 || nDy != 0 )
270 : : {
271 [ # # ][ # # ]: 0 : UpdateDragRect( false, Rectangle() );
272 : :
273 [ # # ]: 0 : if ( nDx != 0)
274 [ # # ]: 0 : pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
275 [ # # ]: 0 : if ( nDy != 0 )
276 [ # # ]: 0 : pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
277 : :
278 : 0 : bTimer = sal_True;
279 : : }
280 : :
281 : : // ---
282 : :
283 : : SCsCOL nPosX;
284 : : SCsROW nPosY;
285 [ # # ]: 0 : pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), eWhich, nPosX, nPosY );
286 : : sal_Bool bMouseLeft;
287 : : sal_Bool bMouseTop;
288 [ # # ]: 0 : pViewData->GetMouseQuadrant( aPixel, eWhich, nPosX, nPosY, bMouseLeft, bMouseTop );
289 : :
290 : 0 : ScAddress aPos( nPosX, nPosY, pViewData->GetTabNo() );
291 : :
292 [ # # ]: 0 : Rectangle aPosRect;
293 : : sal_uInt16 nOrient;
294 : : long nDimPos;
295 : : sal_Bool bHasRange = pDragDPObj->GetHeaderDrag( aPos, bMouseLeft, bMouseTop, nDPField,
296 [ # # ]: 0 : aPosRect, nOrient, nDimPos );
297 [ # # ][ # # ]: 0 : UpdateDragRect( bHasRange && bMove, aPosRect );
[ # # ]
298 : :
299 : : bool bIsDataLayout;
300 : 0 : sal_Int32 nDimFlags = 0;
301 [ # # ]: 0 : OUString aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout, &nDimFlags );
302 [ # # ][ # # ]: 0 : bool bAllowed = !bHasRange || ScDPObject::IsOrientationAllowed( nOrient, nDimFlags );
[ # # ]
303 : :
304 [ # # ]: 0 : if (bMove) // set mouse pointer
305 : : {
306 : 0 : PointerStyle ePointer = POINTER_PIVOT_DELETE;
307 [ # # ]: 0 : if ( !bAllowed )
308 : 0 : ePointer = POINTER_NOTALLOWED;
309 [ # # ]: 0 : else if ( bHasRange )
310 [ # # # # ]: 0 : switch (nOrient)
311 : : {
312 : 0 : case sheet::DataPilotFieldOrientation_COLUMN: ePointer = POINTER_PIVOT_COL; break;
313 : 0 : case sheet::DataPilotFieldOrientation_ROW: ePointer = POINTER_PIVOT_ROW; break;
314 : : case sheet::DataPilotFieldOrientation_PAGE:
315 : 0 : case sheet::DataPilotFieldOrientation_DATA: ePointer = POINTER_PIVOT_FIELD; break;
316 : : }
317 [ # # ]: 0 : SetPointer( ePointer );
318 : : }
319 : : else // execute change
320 : : {
321 [ # # ]: 0 : if (!bHasRange)
322 : 0 : nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
323 : :
324 [ # # ][ # # ]: 0 : if ( bIsDataLayout && ( nOrient != sheet::DataPilotFieldOrientation_COLUMN &&
[ # # ]
325 : : nOrient != sheet::DataPilotFieldOrientation_ROW ) )
326 : : {
327 : : // removing data layout is not allowed
328 [ # # ]: 0 : pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED);
329 : : }
330 [ # # ]: 0 : else if ( bAllowed )
331 : : {
332 [ # # ]: 0 : ScDPSaveData aSaveData( *pDragDPObj->GetSaveData() );
333 : :
334 : : ScDPSaveDimension* pDim;
335 [ # # ]: 0 : if ( bIsDataLayout )
336 [ # # ]: 0 : pDim = aSaveData.GetDataLayoutDimension();
337 : : else
338 [ # # ]: 0 : pDim = aSaveData.GetDimensionByName(aDimName);
339 [ # # ]: 0 : pDim->SetOrientation( nOrient );
340 [ # # ]: 0 : aSaveData.SetPosition( pDim, nDimPos );
341 : :
342 : : //! docfunc method with ScDPSaveData as argument?
343 : :
344 [ # # ]: 0 : ScDPObject aNewObj( *pDragDPObj );
345 [ # # ]: 0 : aNewObj.SetSaveData( aSaveData );
346 : 0 : ScDBDocFunc aFunc( *pViewData->GetDocShell() );
347 : : // when dragging fields, allow re-positioning (bAllowMove)
348 [ # # ]: 0 : aFunc.DataPilotUpdate( pDragDPObj, &aNewObj, sal_True, false, sal_True );
349 [ # # ][ # # ]: 0 : pViewData->GetView()->CursorPosChanged(); // shells may be switched
[ # # ]
350 : : }
351 : : }
352 : :
353 [ # # ][ # # ]: 0 : if (bTimer && bMove)
354 [ # # ]: 0 : pViewData->GetView()->SetTimer( this, rMEvt ); // repeat event
355 : : else
356 [ # # ]: 0 : pViewData->GetView()->ResetTimer();
357 : 0 : }
358 : :
359 : 0 : bool ScGridWindow::DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj)
360 : : {
361 [ # # ][ # # ]: 0 : sal_Bool bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
362 : :
363 : : // Get the geometry of the cell.
364 [ # # ]: 0 : Point aScrPos = pViewData->GetScrPos(rPos.Col(), rPos.Row(), eWhich);
365 : : long nSizeX, nSizeY;
366 [ # # ]: 0 : pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
367 : 0 : Size aScrSize(nSizeX-1, nSizeY-1);
368 : :
369 : : // Check if the mouse cursor is clicking on the popup arrow box.
370 [ # # ]: 0 : ScDPFieldButton aBtn(this, &GetSettings().GetStyleSettings());
371 [ # # ]: 0 : aBtn.setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
372 [ # # ]: 0 : aBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now
373 : 0 : Point aPopupPos;
374 : 0 : Size aPopupSize;
375 [ # # ]: 0 : aBtn.getPopupBoundingBox(aPopupPos, aPopupSize);
376 [ # # ]: 0 : Rectangle aRec(aPopupPos, aPopupSize);
377 [ # # ][ # # ]: 0 : if (aRec.IsInside(rMEvt.GetPosPixel()))
378 : : {
379 : : // Mouse cursor inside the popup arrow box. Launch the field menu.
380 [ # # ][ # # ]: 0 : DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, rPos, pDPObj);
381 : 0 : return true;
382 : : }
383 : :
384 [ # # ]: 0 : return false;
385 : : }
386 : :
387 : : namespace {
388 : :
389 : 0 : struct DPFieldPopupData : public ScCheckListMenuWindow::ExtendedData
390 : : {
391 : : ScDPLabelData maLabels;
392 : : ScDPObject* mpDPObj;
393 : : long mnDim;
394 : : };
395 : :
396 [ # # ]: 0 : class DPFieldPopupOKAction : public ScMenuFloatingWindow::Action
397 : : {
398 : : public:
399 : 0 : explicit DPFieldPopupOKAction(ScGridWindow* p) :
400 : 0 : mpGridWindow(p) {}
401 : :
402 : 0 : virtual void execute()
403 : : {
404 : 0 : mpGridWindow->UpdateDPFromFieldPopupMenu();
405 : 0 : }
406 : : private:
407 : : ScGridWindow* mpGridWindow;
408 : : };
409 : :
410 [ # # ]: 0 : class PopupSortAction : public ScMenuFloatingWindow::Action
411 : : {
412 : : public:
413 : : enum SortType { ASCENDING, DESCENDING, CUSTOM };
414 : :
415 : 0 : explicit PopupSortAction(const ScAddress& rPos, SortType eType, sal_uInt16 nUserListIndex, ScTabViewShell* pViewShell) :
416 : 0 : maPos(rPos), meType(eType), mnUserListIndex(nUserListIndex), mpViewShell(pViewShell) {}
417 : :
418 : 0 : virtual void execute()
419 : : {
420 [ # # # # ]: 0 : switch (meType)
421 : : {
422 : : case ASCENDING:
423 : 0 : mpViewShell->DataPilotSort(maPos, true);
424 : 0 : break;
425 : : case DESCENDING:
426 : 0 : mpViewShell->DataPilotSort(maPos, false);
427 : 0 : break;
428 : : case CUSTOM:
429 : 0 : mpViewShell->DataPilotSort(maPos, true, &mnUserListIndex);
430 : 0 : break;
431 : : default:
432 : : ;
433 : : }
434 : 0 : }
435 : :
436 : : private:
437 : : ScAddress maPos;
438 : : SortType meType;
439 : : sal_uInt16 mnUserListIndex;
440 : : ScTabViewShell* mpViewShell;
441 : : };
442 : :
443 : : }
444 : :
445 : 0 : void ScGridWindow::DPLaunchFieldPopupMenu(
446 : : const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj)
447 : : {
448 : : // We need to get the list of field members.
449 [ # # ][ # # ]: 0 : auto_ptr<DPFieldPopupData> pDPData(new DPFieldPopupData);
450 : : sal_uInt16 nOrient;
451 [ # # ]: 0 : pDPData->mnDim = pDPObj->GetHeaderDim(rPos, nOrient);
452 [ # # ]: 0 : pDPObj->FillLabelData(pDPData->mnDim, pDPData->maLabels);
453 : 0 : pDPData->mpDPObj = pDPObj;
454 : :
455 : 0 : const ScDPLabelData& rLabelData = pDPData->maLabels;
456 : :
457 [ # # ][ # # ]: 0 : mpDPFieldPopup.reset(new ScCheckListMenuWindow(this, pViewData->GetDocument()));
[ # # ][ # # ]
458 [ # # ]: 0 : mpDPFieldPopup->setName(OUString("DataPilot field member popup"));
459 [ # # ]: 0 : mpDPFieldPopup->setExtendedData(pDPData.release());
460 [ # # ][ # # ]: 0 : mpDPFieldPopup->setOKAction(new DPFieldPopupOKAction(this));
461 : : {
462 : : // Populate field members.
463 : 0 : size_t n = rLabelData.maMembers.size();
464 [ # # ]: 0 : mpDPFieldPopup->setMemberSize(n);
465 [ # # ]: 0 : for (size_t i = 0; i < n; ++i)
466 : : {
467 : 0 : const ScDPLabelData::Member& rMem = rLabelData.maMembers[i];
468 [ # # ]: 0 : rtl::OUString aName = rMem.getDisplayName();
469 [ # # ]: 0 : if (aName.isEmpty())
470 : : // Use special string for an empty name.
471 [ # # ][ # # ]: 0 : mpDPFieldPopup->addMember(ScGlobal::GetRscString(STR_EMPTYDATA), rMem.mbVisible);
[ # # ]
472 : : else
473 [ # # ][ # # ]: 0 : mpDPFieldPopup->addMember(rMem.getDisplayName(), rMem.mbVisible);
474 : 0 : }
475 [ # # ]: 0 : mpDPFieldPopup->initMembers();
476 : : }
477 : :
478 [ # # ]: 0 : vector<OUString> aUserSortNames;
479 [ # # ]: 0 : ScUserList* pUserList = ScGlobal::GetUserList();
480 [ # # ]: 0 : if (pUserList)
481 : : {
482 [ # # ]: 0 : size_t n = pUserList->size();
483 [ # # ]: 0 : aUserSortNames.reserve(n);
484 [ # # ]: 0 : for (size_t i = 0; i < n; ++i)
485 : : {
486 [ # # ]: 0 : const ScUserListData* pData = (*pUserList)[i];
487 [ # # ]: 0 : aUserSortNames.push_back(pData->GetString());
488 : : }
489 : : }
490 : :
491 : : // Populate the menus.
492 : 0 : ScTabViewShell* pViewShell = pViewData->GetViewShell();
493 : 0 : mpDPFieldPopup->addMenuItem(
494 [ # # ][ # # ]: 0 : ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_ASC).GetString(), true,
495 [ # # # # ]: 0 : new PopupSortAction(rPos, PopupSortAction::ASCENDING, 0, pViewShell));
[ # # ]
496 : 0 : mpDPFieldPopup->addMenuItem(
497 [ # # ][ # # ]: 0 : ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_DESC).GetString(), true,
498 [ # # ]: 0 : new PopupSortAction(rPos, PopupSortAction::DESCENDING, 0, pViewShell));
[ # # # # ]
499 : 0 : ScMenuFloatingWindow* pSubMenu = mpDPFieldPopup->addSubMenuItem(
500 [ # # ]: 0 : ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_CUSTOM).GetString(), !aUserSortNames.empty());
[ # # # # ]
[ # # ]
501 : :
502 [ # # ][ # # ]: 0 : if (pSubMenu && !aUserSortNames.empty())
[ # # ]
503 : : {
504 : 0 : size_t n = aUserSortNames.size();
505 [ # # ]: 0 : for (size_t i = 0; i < n; ++i)
506 : : {
507 : : pSubMenu->addMenuItem(
508 : 0 : aUserSortNames[i], true,
509 [ # # ][ # # ]: 0 : new PopupSortAction(rPos, PopupSortAction::CUSTOM, static_cast<sal_uInt16>(i), pViewShell));
510 : : }
511 : : }
512 : :
513 [ # # ][ # # ]: 0 : bool bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL(pViewData->GetTabNo());
514 : :
515 [ # # ]: 0 : Rectangle aCellRect(rScrPos, rScrSize);
516 [ # # ]: 0 : const Size& rPopupSize = mpDPFieldPopup->getWindowSize();
517 [ # # ]: 0 : if (bLayoutRTL)
518 : : {
519 : : // RTL: rScrPos is logical-left (visual right) position, always right-align with that
520 : 0 : aCellRect.SetPos(Point(rScrPos.X() - rPopupSize.Width() + 1, rScrPos.Y()));
521 : : }
522 [ # # ]: 0 : else if (rScrSize.getWidth() > rPopupSize.getWidth())
523 : : {
524 : : // If the cell width is larger than the popup window width, launch it
525 : : // right-aligned with the cell.
526 : 0 : long nXOffset = rScrSize.getWidth() - rPopupSize.getWidth();
527 : 0 : aCellRect.SetPos(Point(rScrPos.X() + nXOffset, rScrPos.Y()));
528 : : }
529 [ # # ]: 0 : mpDPFieldPopup->SetPopupModeEndHdl( LINK(this, ScGridWindow, PopupModeEndHdl) );
530 [ # # ][ # # ]: 0 : mpDPFieldPopup->launch(aCellRect);
531 : 0 : }
532 : :
533 : 0 : void ScGridWindow::UpdateDPFromFieldPopupMenu()
534 : : {
535 : : typedef boost::unordered_map<OUString, OUString, OUStringHash> MemNameMapType;
536 : :
537 [ # # ]: 0 : if (!mpDPFieldPopup)
538 : : return;
539 : :
540 [ # # ]: 0 : DPFieldPopupData* pDPData = static_cast<DPFieldPopupData*>(mpDPFieldPopup->getExtendedData());
541 [ # # ]: 0 : if (!pDPData)
542 : : return;
543 : :
544 : 0 : ScDPObject* pDPObj = pDPData->mpDPObj;
545 [ # # ]: 0 : pDPObj->BuildAllDimensionMembers();
546 : 0 : ScDPSaveData* pSaveData = pDPObj->GetSaveData();
547 : :
548 : : bool bIsDataLayout;
549 [ # # ]: 0 : OUString aDimName = pDPObj->GetDimName(pDPData->mnDim, bIsDataLayout);
550 [ # # ]: 0 : ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(aDimName);
551 [ # # ]: 0 : if (!pDim)
552 : : return;
553 : :
554 : : // Build a map of layout names to original names.
555 : 0 : const ScDPLabelData& rLabelData = pDPData->maLabels;
556 [ # # ]: 0 : MemNameMapType aMemNameMap;
557 [ # # ][ # # ]: 0 : for (vector<ScDPLabelData::Member>::const_iterator itr = rLabelData.maMembers.begin(), itrEnd = rLabelData.maMembers.end();
558 : : itr != itrEnd; ++itr)
559 [ # # ]: 0 : aMemNameMap.insert(MemNameMapType::value_type(itr->maLayoutName, itr->maName));
560 : :
561 : : // The raw result may contain a mixture of layout names and original names.
562 [ # # ]: 0 : ScCheckListMenuWindow::ResultType aRawResult;
563 [ # # ]: 0 : mpDPFieldPopup->getResult(aRawResult);
564 : :
565 [ # # ]: 0 : ScCheckListMenuWindow::ResultType aResult;
566 [ # # ][ # # ]: 0 : ScCheckListMenuWindow::ResultType::const_iterator itr = aRawResult.begin(), itrEnd = aRawResult.end();
567 [ # # ]: 0 : for (; itr != itrEnd; ++itr)
568 : : {
569 [ # # ][ # # ]: 0 : MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(itr->first);
570 [ # # ][ # # ]: 0 : if (itrNameMap == aMemNameMap.end())
571 : : {
572 : : // This is an original member name. Use it as-is.
573 [ # # ]: 0 : rtl::OUString aName = itr->first;
574 [ # # ][ # # ]: 0 : if (aName.equals(ScGlobal::GetRscString(STR_EMPTYDATA)))
[ # # ]
575 : : // Translate the special empty name into an empty string.
576 : 0 : aName = rtl::OUString();
577 : :
578 : : aResult.insert(
579 : : ScCheckListMenuWindow::ResultType::value_type(
580 [ # # ][ # # ]: 0 : aName, itr->second));
581 : : }
582 : : else
583 : : {
584 : : // This is a layout name. Get the original member name and use it.
585 : : aResult.insert(
586 : : ScCheckListMenuWindow::ResultType::value_type(
587 [ # # ][ # # ]: 0 : itrNameMap->second, itr->second));
[ # # ]
588 : : }
589 : : }
590 [ # # ]: 0 : pDim->UpdateMemberVisibility(aResult);
591 : :
592 : 0 : ScDBDocFunc aFunc(*pViewData->GetDocShell());
593 [ # # ][ # # ]: 0 : aFunc.DataPilotUpdate(pDPObj, pDPObj, true, false);
[ # # ][ # # ]
[ # # ]
594 : : }
595 : :
596 : 1581 : void ScGridWindow::UpdateVisibleRange()
597 : : {
598 : 1581 : SCCOL nPosX = pViewData->GetPosX(eHWhich);
599 : 1581 : SCROW nPosY = pViewData->GetPosY(eVWhich);
600 : 1581 : SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
601 [ - + ]: 1581 : if (nXRight > MAXCOL) nXRight = MAXCOL;
602 : 1581 : SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
603 [ - + ]: 1581 : if (nYBottom > MAXROW) nYBottom = MAXROW;
604 : :
605 : : // Store the current visible range.
606 : 1581 : maVisibleRange.mnCol1 = nPosX;
607 : 1581 : maVisibleRange.mnCol2 = nXRight;
608 : 1581 : maVisibleRange.mnRow1 = nPosY;
609 : 1581 : maVisibleRange.mnRow2 = nYBottom;
610 : 1581 : }
611 : :
612 : 0 : void ScGridWindow::DPMouseMove( const MouseEvent& rMEvt )
613 : : {
614 : 0 : DPTestMouse( rMEvt, sal_True );
615 : 0 : }
616 : :
617 : 0 : void ScGridWindow::DPMouseButtonUp( const MouseEvent& rMEvt )
618 : : {
619 : 0 : bDPMouse = false;
620 : 0 : ReleaseMouse();
621 : :
622 : 0 : DPTestMouse( rMEvt, false );
623 [ # # ]: 0 : SetPointer( Pointer( POINTER_ARROW ) );
624 : 0 : }
625 : :
626 : : // -----------------------------------------------------------------------
627 : :
628 : 0 : void ScGridWindow::UpdateDragRect( bool bShowRange, const Rectangle& rPosRect )
629 : : {
630 [ # # ]: 0 : SCCOL nStartX = ( rPosRect.Left() >= 0 ) ? static_cast<SCCOL>(rPosRect.Left()) : SCCOL_MAX;
631 [ # # ]: 0 : SCROW nStartY = ( rPosRect.Top() >= 0 ) ? static_cast<SCROW>(rPosRect.Top()) : SCROW_MAX;
632 [ # # ]: 0 : SCCOL nEndX = ( rPosRect.Right() >= 0 ) ? static_cast<SCCOL>(rPosRect.Right()) : SCCOL_MAX;
633 [ # # ]: 0 : SCROW nEndY = ( rPosRect.Bottom() >= 0 ) ? static_cast<SCROW>(rPosRect.Bottom()) : SCROW_MAX;
634 : :
635 [ # # ][ # # ]: 0 : if ( bShowRange == bDragRect && nDragStartX == nStartX && nDragEndX == nEndX &&
[ # # ][ # # ]
[ # # ]
636 : : nDragStartY == nStartY && nDragEndY == nEndY )
637 : : {
638 : 0 : return; // everything unchanged
639 : : }
640 : :
641 [ # # ]: 0 : if ( bShowRange )
642 : : {
643 : 0 : nDragStartX = nStartX;
644 : 0 : nDragStartY = nStartY;
645 : 0 : nDragEndX = nEndX;
646 : 0 : nDragEndY = nEndY;
647 : 0 : bDragRect = true;
648 : : }
649 : : else
650 : 0 : bDragRect = false;
651 : :
652 : 0 : UpdateDragRectOverlay();
653 : : }
654 : :
655 : : // -----------------------------------------------------------------------
656 : :
657 : : // Page-Break-Modus
658 : :
659 : 0 : sal_uInt16 ScGridWindow::HitPageBreak( const Point& rMouse, ScRange* pSource,
660 : : SCCOLROW* pBreak, SCCOLROW* pPrev )
661 : : {
662 : 0 : sal_uInt16 nFound = SC_PD_NONE; // 0
663 : 0 : ScRange aSource;
664 : 0 : SCCOLROW nBreak = 0;
665 : 0 : SCCOLROW nPrev = 0;
666 : :
667 : 0 : ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData();
668 [ # # ]: 0 : if ( pPageData )
669 : : {
670 : 0 : sal_Bool bHori = false;
671 : 0 : sal_Bool bVert = false;
672 : 0 : SCCOL nHitX = 0;
673 : 0 : SCROW nHitY = 0;
674 : :
675 : 0 : long nMouseX = rMouse.X();
676 : 0 : long nMouseY = rMouse.Y();
677 : : SCsCOL nPosX;
678 : : SCsROW nPosY;
679 [ # # ]: 0 : pViewData->GetPosFromPixel( nMouseX, nMouseY, eWhich, nPosX, nPosY );
680 [ # # ]: 0 : Point aTL = pViewData->GetScrPos( nPosX, nPosY, eWhich );
681 [ # # ]: 0 : Point aBR = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich );
682 : :
683 : : // Horizontal mehr Toleranz als vertikal, weil mehr Platz ist
684 [ # # ]: 0 : if ( nMouseX <= aTL.X() + 4 )
685 : : {
686 : 0 : bHori = sal_True;
687 : 0 : nHitX = nPosX;
688 : : }
689 [ # # ]: 0 : else if ( nMouseX >= aBR.X() - 6 )
690 : : {
691 : 0 : bHori = sal_True;
692 : 0 : nHitX = nPosX+1; // linker Rand der naechsten Zelle
693 : : }
694 [ # # ]: 0 : if ( nMouseY <= aTL.Y() + 2 )
695 : : {
696 : 0 : bVert = sal_True;
697 : 0 : nHitY = nPosY;
698 : : }
699 [ # # ]: 0 : else if ( nMouseY >= aBR.Y() - 4 )
700 : : {
701 : 0 : bVert = sal_True;
702 : 0 : nHitY = nPosY+1; // oberer Rand der naechsten Zelle
703 : : }
704 : :
705 [ # # ][ # # ]: 0 : if ( bHori || bVert )
706 : : {
707 : 0 : sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
708 [ # # ][ # # ]: 0 : for (sal_uInt16 nPos=0; nPos<nCount && !nFound; nPos++)
[ # # ]
709 : : {
710 [ # # ]: 0 : ScPrintRangeData& rData = pPageData->GetData(nPos);
711 : 0 : ScRange aRange = rData.GetPrintRange();
712 [ # # ][ # # ]: 0 : sal_Bool bLHit = ( bHori && nHitX == aRange.aStart.Col() );
713 [ # # ][ # # ]: 0 : sal_Bool bRHit = ( bHori && nHitX == aRange.aEnd.Col() + 1 );
714 [ # # ][ # # ]: 0 : sal_Bool bTHit = ( bVert && nHitY == aRange.aStart.Row() );
715 [ # # ][ # # ]: 0 : sal_Bool bBHit = ( bVert && nHitY == aRange.aEnd.Row() + 1 );
716 [ # # ][ # # ]: 0 : sal_Bool bInsideH = ( nPosX >= aRange.aStart.Col() && nPosX <= aRange.aEnd.Col() );
717 [ # # ][ # # ]: 0 : sal_Bool bInsideV = ( nPosY >= aRange.aStart.Row() && nPosY <= aRange.aEnd.Row() );
718 : :
719 [ # # ]: 0 : if ( bLHit )
720 : : {
721 [ # # ]: 0 : if ( bTHit )
722 : 0 : nFound = SC_PD_RANGE_TL;
723 [ # # ]: 0 : else if ( bBHit )
724 : 0 : nFound = SC_PD_RANGE_BL;
725 [ # # ]: 0 : else if ( bInsideV )
726 : 0 : nFound = SC_PD_RANGE_L;
727 : : }
728 [ # # ]: 0 : else if ( bRHit )
729 : : {
730 [ # # ]: 0 : if ( bTHit )
731 : 0 : nFound = SC_PD_RANGE_TR;
732 [ # # ]: 0 : else if ( bBHit )
733 : 0 : nFound = SC_PD_RANGE_BR;
734 [ # # ]: 0 : else if ( bInsideV )
735 : 0 : nFound = SC_PD_RANGE_R;
736 : : }
737 [ # # ][ # # ]: 0 : else if ( bTHit && bInsideH )
738 : 0 : nFound = SC_PD_RANGE_T;
739 [ # # ][ # # ]: 0 : else if ( bBHit && bInsideH )
740 : 0 : nFound = SC_PD_RANGE_B;
741 [ # # ]: 0 : if (nFound)
742 : 0 : aSource = aRange;
743 : :
744 : : // Umbrueche
745 : :
746 [ # # ][ # # ]: 0 : if ( bVert && bInsideH && !nFound )
[ # # ]
747 : : {
748 : 0 : size_t nRowCount = rData.GetPagesY();
749 : 0 : const SCROW* pRowEnd = rData.GetPageEndY();
750 [ # # ]: 0 : for (size_t nRowPos=0; nRowPos+1<nRowCount; nRowPos++)
751 [ # # ]: 0 : if ( pRowEnd[nRowPos]+1 == nHitY )
752 : : {
753 : 0 : nFound = SC_PD_BREAK_V;
754 : 0 : aSource = aRange;
755 : 0 : nBreak = nHitY;
756 [ # # ]: 0 : if ( nRowPos )
757 : 0 : nPrev = pRowEnd[nRowPos-1]+1;
758 : : else
759 : 0 : nPrev = aRange.aStart.Row();
760 : : }
761 : : }
762 [ # # ][ # # ]: 0 : if ( bHori && bInsideV && !nFound )
[ # # ]
763 : : {
764 : 0 : size_t nColCount = rData.GetPagesX();
765 : 0 : const SCCOL* pColEnd = rData.GetPageEndX();
766 [ # # ]: 0 : for (size_t nColPos=0; nColPos+1<nColCount; nColPos++)
767 [ # # ]: 0 : if ( pColEnd[nColPos]+1 == nHitX )
768 : : {
769 : 0 : nFound = SC_PD_BREAK_H;
770 : 0 : aSource = aRange;
771 : 0 : nBreak = nHitX;
772 [ # # ]: 0 : if ( nColPos )
773 : 0 : nPrev = pColEnd[nColPos-1]+1;
774 : : else
775 : 0 : nPrev = aRange.aStart.Col();
776 : : }
777 : : }
778 : : }
779 : : }
780 : : }
781 : :
782 [ # # ]: 0 : if (pSource)
783 : 0 : *pSource = aSource; // Druckbereich
784 [ # # ]: 0 : if (pBreak)
785 : 0 : *pBreak = nBreak; // X/Y Position des verchobenen Seitenumbruchs
786 [ # # ]: 0 : if (pPrev)
787 : 0 : *pPrev = nPrev; // X/Y Anfang der Seite, die am Umbruch zuende ist
788 : 0 : return nFound;
789 : : }
790 : :
791 : 0 : void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, sal_Bool bUp )
792 : : {
793 : : //! Scrolling und Umschalten mit RFMouseMove zusammenfassen !
794 : : //! (Weginvertieren vor dem Scrolling ist anders)
795 : :
796 : : // Scrolling
797 : :
798 : 0 : sal_Bool bTimer = false;
799 : 0 : Point aPos = rMEvt.GetPosPixel();
800 : 0 : SCsCOL nDx = 0;
801 : 0 : SCsROW nDy = 0;
802 [ # # ]: 0 : if ( aPos.X() < 0 ) nDx = -1;
803 [ # # ]: 0 : if ( aPos.Y() < 0 ) nDy = -1;
804 : 0 : Size aSize = GetOutputSizePixel();
805 [ # # ]: 0 : if ( aPos.X() >= aSize.Width() )
806 : 0 : nDx = 1;
807 [ # # ]: 0 : if ( aPos.Y() >= aSize.Height() )
808 : 0 : nDy = 1;
809 [ # # ][ # # ]: 0 : if ( nDx != 0 || nDy != 0 )
810 : : {
811 [ # # ]: 0 : if ( bPagebreakDrawn ) // weginvertieren
812 : : {
813 : 0 : bPagebreakDrawn = false;
814 [ # # ]: 0 : UpdateDragRectOverlay();
815 : : }
816 : :
817 [ # # ][ # # ]: 0 : if ( nDx != 0 ) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
818 [ # # ][ # # ]: 0 : if ( nDy != 0 ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
819 : 0 : bTimer = sal_True;
820 : : }
821 : :
822 : : // Umschalten bei Fixierung (damit Scrolling funktioniert)
823 : :
824 [ # # ]: 0 : if ( eWhich == pViewData->GetActivePart() ) //??
825 : : {
826 [ # # ]: 0 : if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX )
827 [ # # ]: 0 : if ( nDx > 0 )
828 : : {
829 [ # # ]: 0 : if ( eWhich == SC_SPLIT_TOPLEFT )
830 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT );
831 [ # # ]: 0 : else if ( eWhich == SC_SPLIT_BOTTOMLEFT )
832 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
833 : : }
834 : :
835 [ # # ]: 0 : if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX )
836 [ # # ]: 0 : if ( nDy > 0 )
837 : : {
838 [ # # ]: 0 : if ( eWhich == SC_SPLIT_TOPLEFT )
839 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT );
840 [ # # ]: 0 : else if ( eWhich == SC_SPLIT_TOPRIGHT )
841 [ # # ]: 0 : pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
842 : : }
843 : : }
844 : :
845 : : // ab hier neu
846 : :
847 : : // gesucht wird eine Position zwischen den Zellen (vor nPosX / nPosY)
848 : : SCsCOL nPosX;
849 : : SCsROW nPosY;
850 [ # # ]: 0 : pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
851 : : sal_Bool bLeft, bTop;
852 [ # # ]: 0 : pViewData->GetMouseQuadrant( aPos, eWhich, nPosX, nPosY, bLeft, bTop );
853 [ # # ]: 0 : if ( !bLeft ) ++nPosX;
854 [ # # ]: 0 : if ( !bTop ) ++nPosY;
855 : :
856 [ # # ][ # # ]: 0 : sal_Bool bBreak = ( nPagebreakMouse == SC_PD_BREAK_H || nPagebreakMouse == SC_PD_BREAK_V );
857 : 0 : sal_Bool bHide = false;
858 : 0 : sal_Bool bToEnd = false;
859 : 0 : ScRange aDrawRange = aPagebreakSource;
860 [ # # ]: 0 : if ( bBreak )
861 : : {
862 [ # # ]: 0 : if ( nPagebreakMouse == SC_PD_BREAK_H )
863 : : {
864 [ # # # # ]: 0 : if ( nPosX > aPagebreakSource.aStart.Col() &&
[ # # ]
865 : 0 : nPosX <= aPagebreakSource.aEnd.Col() + 1 ) // ans Ende ist auch erlaubt
866 : : {
867 : 0 : bToEnd = ( nPosX == aPagebreakSource.aEnd.Col() + 1 );
868 : 0 : aDrawRange.aStart.SetCol( nPosX );
869 : 0 : aDrawRange.aEnd.SetCol( nPosX - 1 );
870 : : }
871 : : else
872 : 0 : bHide = sal_True;
873 : : }
874 : : else
875 : : {
876 [ # # # # ]: 0 : if ( nPosY > aPagebreakSource.aStart.Row() &&
[ # # ]
877 : 0 : nPosY <= aPagebreakSource.aEnd.Row() + 1 ) // ans Ende ist auch erlaubt
878 : : {
879 : 0 : bToEnd = ( nPosY == aPagebreakSource.aEnd.Row() + 1 );
880 : 0 : aDrawRange.aStart.SetRow( nPosY );
881 : 0 : aDrawRange.aEnd.SetRow( nPosY - 1 );
882 : : }
883 : : else
884 : 0 : bHide = sal_True;
885 : : }
886 : : }
887 : : else
888 : : {
889 [ # # ]: 0 : if ( nPagebreakMouse & SC_PD_RANGE_L )
890 : 0 : aDrawRange.aStart.SetCol( nPosX );
891 [ # # ]: 0 : if ( nPagebreakMouse & SC_PD_RANGE_T )
892 : 0 : aDrawRange.aStart.SetRow( nPosY );
893 [ # # ]: 0 : if ( nPagebreakMouse & SC_PD_RANGE_R )
894 : : {
895 [ # # ]: 0 : if ( nPosX > 0 )
896 : 0 : aDrawRange.aEnd.SetCol( nPosX-1 );
897 : : else
898 : 0 : bHide = sal_True;
899 : : }
900 [ # # ]: 0 : if ( nPagebreakMouse & SC_PD_RANGE_B )
901 : : {
902 [ # # ]: 0 : if ( nPosY > 0 )
903 : 0 : aDrawRange.aEnd.SetRow( nPosY-1 );
904 : : else
905 : 0 : bHide = sal_True;
906 : : }
907 [ # # # # ]: 0 : if ( aDrawRange.aStart.Col() > aDrawRange.aEnd.Col() ||
[ # # ]
908 : 0 : aDrawRange.aStart.Row() > aDrawRange.aEnd.Row() )
909 : 0 : bHide = sal_True;
910 : : }
911 : :
912 [ # # ][ # # ]: 0 : if ( !bPagebreakDrawn || bUp || aDrawRange != aPagebreakDrag )
[ # # ][ # # ]
913 : : {
914 : : // zeichnen...
915 : :
916 [ # # ]: 0 : if ( bPagebreakDrawn )
917 : : {
918 : : // weginvertieren
919 : 0 : bPagebreakDrawn = false;
920 : : }
921 : 0 : aPagebreakDrag = aDrawRange;
922 [ # # ][ # # ]: 0 : if ( !bUp && !bHide )
923 : : {
924 : : // hininvertieren
925 : 0 : bPagebreakDrawn = true;
926 : : }
927 [ # # ]: 0 : UpdateDragRectOverlay();
928 : : }
929 : :
930 : : // bei ButtonUp die Aenderung ausfuehren
931 : :
932 [ # # ]: 0 : if ( bUp )
933 : : {
934 [ # # ]: 0 : ScViewFunc* pViewFunc = pViewData->GetView();
935 : 0 : ScDocShell* pDocSh = pViewData->GetDocShell();
936 : 0 : ScDocument* pDoc = pDocSh->GetDocument();
937 : 0 : SCTAB nTab = pViewData->GetTabNo();
938 : 0 : sal_Bool bUndo (pDoc->IsUndoEnabled());
939 : :
940 [ # # ]: 0 : if ( bBreak )
941 : : {
942 : 0 : sal_Bool bColumn = ( nPagebreakMouse == SC_PD_BREAK_H );
943 [ # # ]: 0 : SCCOLROW nNew = bColumn ? static_cast<SCCOLROW>(nPosX) : static_cast<SCCOLROW>(nPosY);
944 [ # # ]: 0 : if ( nNew != nPagebreakBreak )
945 : : {
946 [ # # ]: 0 : if (bUndo)
947 : : {
948 [ # # ][ # # ]: 0 : String aUndo = ScGlobal::GetRscString( STR_UNDO_DRAG_BREAK );
949 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
[ # # ]
950 : : }
951 : :
952 [ # # ][ # # ]: 0 : sal_Bool bGrow = !bHide && nNew > nPagebreakBreak;
953 [ # # ]: 0 : if ( bColumn )
954 : : {
955 [ # # ][ # # ]: 0 : if (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakBreak), nTab) & BREAK_MANUAL)
956 : : {
957 : 0 : ScAddress aOldAddr( static_cast<SCCOL>(nPagebreakBreak), nPosY, nTab );
958 [ # # ]: 0 : pViewFunc->DeletePageBreak( sal_True, sal_True, &aOldAddr, false );
959 : : }
960 [ # # ][ # # ]: 0 : if ( !bHide && !bToEnd ) // am Ende nicht
961 : : {
962 : 0 : ScAddress aNewAddr( static_cast<SCCOL>(nNew), nPosY, nTab );
963 [ # # ]: 0 : pViewFunc->InsertPageBreak( sal_True, sal_True, &aNewAddr, false );
964 : : }
965 [ # # ]: 0 : if ( bGrow )
966 : : {
967 : : // vorigen Break auf hart, und Skalierung aendern
968 [ # # ]: 0 : bool bManualBreak = (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakPrev), nTab) & BREAK_MANUAL);
969 [ # # ][ # # ]: 0 : if ( static_cast<SCCOL>(nPagebreakPrev) > aPagebreakSource.aStart.Col() && !bManualBreak )
[ # # ]
970 : : {
971 : 0 : ScAddress aPrev( static_cast<SCCOL>(nPagebreakPrev), nPosY, nTab );
972 [ # # ]: 0 : pViewFunc->InsertPageBreak( sal_True, sal_True, &aPrev, false );
973 : : }
974 : :
975 [ # # ]: 0 : if (!pDocSh->AdjustPrintZoom( ScRange(
976 [ # # ]: 0 : static_cast<SCCOL>(nPagebreakPrev),0,nTab, static_cast<SCCOL>(nNew-1),0,nTab ) ))
977 : 0 : bGrow = false;
978 : : }
979 : : }
980 : : else
981 : : {
982 [ # # ][ # # ]: 0 : if (pDoc->HasRowBreak(nPagebreakBreak, nTab) & BREAK_MANUAL)
983 : : {
984 : 0 : ScAddress aOldAddr( nPosX, nPagebreakBreak, nTab );
985 [ # # ]: 0 : pViewFunc->DeletePageBreak( false, sal_True, &aOldAddr, false );
986 : : }
987 [ # # ][ # # ]: 0 : if ( !bHide && !bToEnd ) // am Ende nicht
988 : : {
989 : 0 : ScAddress aNewAddr( nPosX, nNew, nTab );
990 [ # # ]: 0 : pViewFunc->InsertPageBreak( false, sal_True, &aNewAddr, false );
991 : : }
992 [ # # ]: 0 : if ( bGrow )
993 : : {
994 : : // vorigen Break auf hart, und Skalierung aendern
995 [ # # ]: 0 : bool bManualBreak = (pDoc->HasRowBreak(nPagebreakPrev, nTab) & BREAK_MANUAL);
996 [ # # ][ # # ]: 0 : if ( nPagebreakPrev > aPagebreakSource.aStart.Row() && !bManualBreak )
[ # # ]
997 : : {
998 : 0 : ScAddress aPrev( nPosX, nPagebreakPrev, nTab );
999 [ # # ]: 0 : pViewFunc->InsertPageBreak( false, sal_True, &aPrev, false );
1000 : : }
1001 : :
1002 [ # # ]: 0 : if (!pDocSh->AdjustPrintZoom( ScRange(
1003 [ # # ]: 0 : 0,nPagebreakPrev,nTab, 0,nNew-1,nTab ) ))
1004 : 0 : bGrow = false;
1005 : : }
1006 : : }
1007 : :
1008 [ # # ]: 0 : if (bUndo)
1009 : : {
1010 [ # # ][ # # ]: 0 : pDocSh->GetUndoManager()->LeaveListAction();
1011 : : }
1012 : :
1013 [ # # ]: 0 : if (!bGrow) // sonst in AdjustPrintZoom schon passiert
1014 : : {
1015 [ # # ]: 0 : pViewFunc->UpdatePageBreakData( sal_True );
1016 [ # # ]: 0 : pDocSh->SetDocumentModified();
1017 : : }
1018 : : }
1019 : : }
1020 [ # # ][ # # ]: 0 : else if ( bHide || aPagebreakDrag != aPagebreakSource )
[ # # ]
1021 : : {
1022 : : // Druckbereich setzen
1023 : :
1024 [ # # ]: 0 : String aNewRanges;
1025 [ # # ]: 0 : sal_uInt16 nOldCount = pDoc->GetPrintRangeCount( nTab );
1026 [ # # ]: 0 : if ( nOldCount )
1027 : : {
1028 [ # # ]: 0 : for (sal_uInt16 nPos=0; nPos<nOldCount; nPos++)
1029 : : {
1030 [ # # ]: 0 : const ScRange* pOld = pDoc->GetPrintRange( nTab, nPos );
1031 [ # # ]: 0 : if ( pOld )
1032 : : {
1033 [ # # ]: 0 : String aTemp;
1034 [ # # ]: 0 : if ( *pOld != aPagebreakSource )
1035 [ # # ]: 0 : pOld->Format( aTemp, SCA_VALID );
1036 [ # # ]: 0 : else if ( !bHide )
1037 [ # # ]: 0 : aPagebreakDrag.Format( aTemp, SCA_VALID );
1038 [ # # ]: 0 : if (aTemp.Len())
1039 : : {
1040 [ # # ]: 0 : if ( aNewRanges.Len() )
1041 [ # # ]: 0 : aNewRanges += ';';
1042 [ # # ]: 0 : aNewRanges += aTemp;
1043 [ # # ]: 0 : }
1044 : : }
1045 : : }
1046 : : }
1047 [ # # ]: 0 : else if (!bHide)
1048 [ # # ]: 0 : aPagebreakDrag.Format( aNewRanges, SCA_VALID );
1049 : :
1050 [ # # ][ # # ]: 0 : pViewFunc->SetPrintRanges( pDoc->IsPrintEntireSheet( nTab ), &aNewRanges, NULL, NULL, false );
[ # # ]
1051 : : }
1052 : : }
1053 : :
1054 : : // Timer fuer Scrolling
1055 : :
1056 [ # # ][ # # ]: 0 : if (bTimer && !bUp)
1057 [ # # ]: 0 : pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen
1058 : : else
1059 [ # # ]: 0 : pViewData->GetView()->ResetTimer();
1060 [ + - ][ + - ]: 153 : }
1061 : :
1062 : :
1063 : :
1064 : :
1065 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|