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