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

Generated by: LCOV version 1.10