LCOV - code coverage report
Current view: top level - sc/source/ui/view - gridwin2.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 560 0.0 %
Date: 2014-04-14 Functions: 0 27 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10