LCOV - code coverage report
Current view: top level - sc/source/ui/view - gridwin4.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 337 816 41.3 %
Date: 2012-08-25 Functions: 6 15 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 336 1540 21.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : #include <editeng/eeitem.hxx>
      31                 :            : 
      32                 :            : #include <svtools/colorcfg.hxx>
      33                 :            : #include <editeng/colritem.hxx>
      34                 :            : #include <editeng/editview.hxx>
      35                 :            : #include <editeng/fhgtitem.hxx>
      36                 :            : #include <editeng/scripttypeitem.hxx>
      37                 :            : #include <sfx2/bindings.hxx>
      38                 :            : #include <sfx2/printer.hxx>
      39                 :            : 
      40                 :            : #include <svx/svdview.hxx>
      41                 :            : #include "tabvwsh.hxx"
      42                 :            : 
      43                 :            : #include "gridwin.hxx"
      44                 :            : #include "viewdata.hxx"
      45                 :            : #include "output.hxx"
      46                 :            : #include "document.hxx"
      47                 :            : #include "attrib.hxx"
      48                 :            : #include "patattr.hxx"          // InvertSimple
      49                 :            : #include "dbdata.hxx"
      50                 :            : #include "docoptio.hxx"
      51                 :            : #include "notemark.hxx"
      52                 :            : #include "dbfunc.hxx"           // oder GetPageBreakData an die ViewData
      53                 :            : #include "scmod.hxx"
      54                 :            : #include "inputhdl.hxx"
      55                 :            : #include "rfindlst.hxx"
      56                 :            : #include "hiranges.hxx"
      57                 :            : #include "pagedata.hxx"
      58                 :            : #include "docpool.hxx"
      59                 :            : #include "globstr.hrc"
      60                 :            : #include "docsh.hxx"            // oder GetSfxInPlaceObject
      61                 :            : #include "cbutton.hxx"
      62                 :            : #include "invmerge.hxx"
      63                 :            : #include "editutil.hxx"
      64                 :            : #include "inputopt.hxx"
      65                 :            : #include "fillinfo.hxx"
      66                 :            : #include "dpcontrol.hxx"
      67                 :            : #include "queryparam.hxx"
      68                 :            : #include "queryentry.hxx"
      69                 :            : #include "markdata.hxx"
      70                 :            : #include "sc.hrc"
      71                 :            : #include <vcl/virdev.hxx>
      72                 :            : 
      73                 :            : // #i74769#
      74                 :            : #include <svx/sdrpaintwindow.hxx>
      75                 :            : 
      76                 :            : //------------------------------------------------------------------------
      77                 :            : 
      78                 :          0 : void lcl_LimitRect( Rectangle& rRect, const Rectangle& rVisible )
      79                 :            : {
      80         [ #  # ]:          0 :     if ( rRect.Top()    < rVisible.Top()-1 )    rRect.Top()    = rVisible.Top()-1;
      81         [ #  # ]:          0 :     if ( rRect.Bottom() > rVisible.Bottom()+1 ) rRect.Bottom() = rVisible.Bottom()+1;
      82                 :            : 
      83                 :            :     // auch wenn das inner-Rectangle nicht sichtbar ist, muss evtl.
      84                 :            :     // die Titelzeile gezeichnet werden, darum kein Rueckgabewert mehr.
      85                 :            :     // Wenn's weit daneben liegt, wird lcl_DrawOneFrame erst gar nicht gerufen.
      86                 :          0 : }
      87                 :            : 
      88                 :          0 : void lcl_DrawOneFrame( OutputDevice* pDev, const Rectangle& rInnerPixel,
      89                 :            :                         const String& rTitle, const Color& rColor, sal_Bool bTextBelow,
      90                 :            :                         double nPPTX, double nPPTY, const Fraction& rZoomY,
      91                 :            :                         ScDocument* pDoc, ScViewData* pButtonViewData, sal_Bool bLayoutRTL )
      92                 :            : {
      93                 :            :     //  pButtonViewData wird nur benutzt, um die Button-Groesse zu setzen,
      94                 :            :     //  darf ansonsten NULL sein!
      95                 :            : 
      96                 :          0 :     Rectangle aInner = rInnerPixel;
      97         [ #  # ]:          0 :     if ( bLayoutRTL )
      98                 :            :     {
      99                 :          0 :         aInner.Left() = rInnerPixel.Right();
     100                 :          0 :         aInner.Right() = rInnerPixel.Left();
     101                 :            :     }
     102                 :            : 
     103         [ #  # ]:          0 :     Rectangle aVisible( Point(0,0), pDev->GetOutputSizePixel() );
     104                 :          0 :     lcl_LimitRect( aInner, aVisible );
     105                 :            : 
     106                 :          0 :     Rectangle aOuter = aInner;
     107                 :          0 :     long nHor = (long) ( SC_SCENARIO_HSPACE * nPPTX );
     108                 :          0 :     long nVer = (long) ( SC_SCENARIO_VSPACE * nPPTY );
     109                 :          0 :     aOuter.Left()   -= nHor;
     110                 :          0 :     aOuter.Right()  += nHor;
     111                 :          0 :     aOuter.Top()    -= nVer;
     112                 :          0 :     aOuter.Bottom() += nVer;
     113                 :            : 
     114                 :            :     //  use ScPatternAttr::GetFont only for font size
     115         [ #  # ]:          0 :     Font aAttrFont;
     116 [ #  # ][ #  # ]:          0 :     ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).
     117         [ #  # ]:          0 :                                     GetFont(aAttrFont,SC_AUTOCOL_BLACK,pDev,&rZoomY);
     118                 :            : 
     119                 :            :     //  everything else from application font
     120         [ #  # ]:          0 :     Font aAppFont = pDev->GetSettings().GetStyleSettings().GetAppFont();
     121 [ #  # ][ #  # ]:          0 :     aAppFont.SetSize( aAttrFont.GetSize() );
     122                 :            : 
     123         [ #  # ]:          0 :     aAppFont.SetAlign( ALIGN_TOP );
     124         [ #  # ]:          0 :     pDev->SetFont( aAppFont );
     125                 :            : 
     126 [ #  # ][ #  # ]:          0 :     Size aTextSize( pDev->GetTextWidth( rTitle ), pDev->GetTextHeight() );
     127                 :            : 
     128         [ #  # ]:          0 :     if ( bTextBelow )
     129                 :          0 :         aOuter.Bottom() += aTextSize.Height();
     130                 :            :     else
     131                 :          0 :         aOuter.Top()    -= aTextSize.Height();
     132                 :            : 
     133         [ #  # ]:          0 :     pDev->SetLineColor();
     134         [ #  # ]:          0 :     pDev->SetFillColor( rColor );
     135                 :            :     //  links, oben, rechts, unten
     136 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( aOuter.Left(),  aOuter.Top(),    aInner.Left(),  aOuter.Bottom() ) );
     137 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( aOuter.Left(),  aOuter.Top(),    aOuter.Right(), aInner.Top()    ) );
     138 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( aInner.Right(), aOuter.Top(),    aOuter.Right(), aOuter.Bottom() ) );
     139 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( aOuter.Left(),  aInner.Bottom(), aOuter.Right(), aOuter.Bottom() ) );
     140                 :            : 
     141         [ #  # ]:          0 :     long nButtonY = bTextBelow ? aInner.Bottom() : aOuter.Top();
     142                 :            : 
     143         [ #  # ]:          0 :     ScDDComboBoxButton aComboButton((Window*)pDev);
     144         [ #  # ]:          0 :     aComboButton.SetOptSizePixel();
     145                 :          0 :     long nBWidth  = ( aComboButton.GetSizePixel().Width() * rZoomY.GetNumerator() )
     146                 :          0 :                         / rZoomY.GetDenominator();
     147                 :          0 :     long nBHeight = nVer + aTextSize.Height() + 1;
     148                 :          0 :     Size aButSize( nBWidth, nBHeight );
     149         [ #  # ]:          0 :     long nButtonPos = bLayoutRTL ? aOuter.Left() : aOuter.Right()-nBWidth+1;
     150         [ #  # ]:          0 :     aComboButton.Draw( Point(nButtonPos, nButtonY), aButSize, false );
     151         [ #  # ]:          0 :     if (pButtonViewData)
     152                 :          0 :         pButtonViewData->SetScenButSize( aButSize );
     153                 :            : 
     154         [ #  # ]:          0 :     long nTextStart = bLayoutRTL ? aInner.Right() - aTextSize.Width() + 1 : aInner.Left();
     155                 :            : 
     156                 :          0 :     sal_Bool bWasClip = false;
     157         [ #  # ]:          0 :     Region aOldClip;
     158                 :          0 :     sal_Bool bClip = ( aTextSize.Width() > aOuter.Right() - nBWidth - aInner.Left() );
     159         [ #  # ]:          0 :     if ( bClip )
     160                 :            :     {
     161         [ #  # ]:          0 :         if (pDev->IsClipRegion())
     162                 :            :         {
     163                 :          0 :             bWasClip = sal_True;
     164 [ #  # ][ #  # ]:          0 :             aOldClip = pDev->GetActiveClipRegion();
                 [ #  # ]
     165                 :            :         }
     166         [ #  # ]:          0 :         long nClipStartX = bLayoutRTL ? aOuter.Left() + nBWidth : aInner.Left();
     167         [ #  # ]:          0 :         long nClipEndX = bLayoutRTL ? aInner.Right() : aOuter.Right() - nBWidth;
     168                 :            :         pDev->SetClipRegion( Rectangle( nClipStartX, nButtonY + nVer/2,
     169 [ #  # ][ #  # ]:          0 :                                 nClipEndX, nButtonY + nVer/2 + aTextSize.Height() ) );
         [ #  # ][ #  # ]
     170                 :            :     }
     171                 :            : 
     172         [ #  # ]:          0 :     pDev->DrawText( Point( nTextStart, nButtonY + nVer/2 ), rTitle );
     173                 :            : 
     174         [ #  # ]:          0 :     if ( bClip )
     175                 :            :     {
     176         [ #  # ]:          0 :         if ( bWasClip )
     177         [ #  # ]:          0 :             pDev->SetClipRegion(aOldClip);
     178                 :            :         else
     179         [ #  # ]:          0 :             pDev->SetClipRegion();
     180                 :            :     }
     181                 :            : 
     182         [ #  # ]:          0 :     pDev->SetFillColor();
     183         [ #  # ]:          0 :     pDev->SetLineColor( COL_BLACK );
     184         [ #  # ]:          0 :     pDev->DrawRect( aInner );
     185 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( aOuter );
         [ #  # ][ #  # ]
                 [ #  # ]
     186                 :          0 : }
     187                 :            : 
     188                 :          0 : void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, ScSplitPos eWhich,
     189                 :            :                             SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
     190                 :            : {
     191                 :          0 :     ScDocument* pDoc = pViewData->GetDocument();
     192                 :          0 :     SCTAB nTab = pViewData->GetTabNo();
     193                 :          0 :     SCTAB nTabCount = pDoc->GetTableCount();
     194 [ #  # ][ #  # ]:          0 :     if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) )
         [ #  # ][ #  # ]
     195                 :            :     {
     196         [ #  # ]:          0 :         if ( nX1 > 0 ) --nX1;
     197         [ #  # ]:          0 :         if ( nY1>=2 ) nY1 -= 2;             // Hack: Titelzeile beruehrt zwei Zellen
     198         [ #  # ]:          0 :         else if ( nY1 > 0 ) --nY1;
     199         [ #  # ]:          0 :         if ( nX2 < MAXCOL ) ++nX2;
     200         [ #  # ]:          0 :         if ( nY2 < MAXROW-1 ) nY2 += 2;     // Hack: Titelzeile beruehrt zwei Zellen
     201         [ #  # ]:          0 :         else if ( nY2 < MAXROW ) ++nY2;
     202                 :          0 :         ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab );
     203                 :            : 
     204                 :            :         //! Ranges an der Table cachen!!!!
     205                 :            : 
     206         [ #  # ]:          0 :         ScMarkData aMarks;
     207 [ #  # ][ #  # ]:          0 :         for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
         [ #  # ][ #  # ]
     208         [ #  # ]:          0 :             pDoc->MarkScenario( i, nTab, aMarks, false, SC_SCENARIO_SHOWFRAME );
     209 [ #  # ][ #  # ]:          0 :         ScRangeListRef xRanges = new ScRangeList;
     210         [ #  # ]:          0 :         aMarks.FillRangeListWithMarks( xRanges, false );
     211                 :            : 
     212         [ #  # ]:          0 :         sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
     213         [ #  # ]:          0 :         long nLayoutSign = bLayoutRTL ? -1 : 1;
     214                 :            : 
     215 [ #  # ][ #  # ]:          0 :         for (size_t j = 0, n = xRanges->size(); j < n; ++j)
     216                 :            :         {
     217         [ #  # ]:          0 :             ScRange aRange = *(*xRanges)[j];
     218                 :            :             //  Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn
     219                 :            :             //  dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden
     220         [ #  # ]:          0 :             pDoc->ExtendTotalMerge( aRange );
     221                 :            : 
     222                 :            :             //! -> Repaint beim Zusammenfassen erweitern !!!
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :             if ( aRange.Intersects( aViewRange ) )          //! Platz fuer Text/Button?
     225                 :            :             {
     226                 :            :                 Point aStartPos = pViewData->GetScrPos(
     227         [ #  # ]:          0 :                                     aRange.aStart.Col(), aRange.aStart.Row(), eWhich, sal_True );
     228                 :            :                 Point aEndPos = pViewData->GetScrPos(
     229         [ #  # ]:          0 :                                     aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, sal_True );
     230                 :            :                 //  on the grid:
     231                 :          0 :                 aStartPos.X() -= nLayoutSign;
     232                 :          0 :                 aStartPos.Y() -= 1;
     233                 :          0 :                 aEndPos.X() -= nLayoutSign;
     234                 :          0 :                 aEndPos.Y() -= 1;
     235                 :            : 
     236                 :          0 :                 sal_Bool bTextBelow = ( aRange.aStart.Row() == 0 );
     237                 :            : 
     238                 :          0 :                 rtl::OUString aCurrent;
     239                 :          0 :                 Color aColor( COL_LIGHTGRAY );
     240 [ #  # ][ #  # ]:          0 :                 for (SCTAB nAct=nTab+1; nAct<nTabCount && pDoc->IsScenario(nAct); nAct++)
         [ #  # ][ #  # ]
     241 [ #  # ][ #  # ]:          0 :                     if ( pDoc->IsActiveScenario(nAct) && pDoc->HasScenarioRange(nAct,aRange) )
         [ #  # ][ #  # ]
                 [ #  # ]
     242                 :            :                     {
     243                 :          0 :                         rtl::OUString aDummyComment;
     244                 :            :                         sal_uInt16 nDummyFlags;
     245         [ #  # ]:          0 :                         pDoc->GetName( nAct, aCurrent );
     246         [ #  # ]:          0 :                         pDoc->GetScenarioData( nAct, aDummyComment, aColor, nDummyFlags );
     247                 :            :                     }
     248                 :            : 
     249         [ #  # ]:          0 :                 if (aCurrent.isEmpty())
     250 [ #  # ][ #  # ]:          0 :                     aCurrent = ScGlobal::GetRscString( STR_EMPTYDATA );
     251                 :            : 
     252                 :            :                 //! eigener Text "(keins)" statt "(leer)" ???
     253                 :            : 
     254                 :            :                 lcl_DrawOneFrame( pDev, Rectangle( aStartPos, aEndPos ),
     255                 :            :                                     aCurrent, aColor, bTextBelow,
     256                 :          0 :                                     pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomY(),
     257 [ #  # ][ #  # ]:          0 :                                     pDoc, pViewData, bLayoutRTL );
         [ #  # ][ #  # ]
     258                 :            :             }
     259 [ #  # ][ #  # ]:          0 :         }
     260                 :            :     }
     261                 :          0 : }
     262                 :            : 
     263                 :            : //------------------------------------------------------------------------
     264                 :            : 
     265                 :          0 : void lcl_DrawHighlight( ScOutputData& rOutputData, ScViewData* pViewData,
     266                 :            :                         const std::vector<ScHighlightEntry>& rHighlightRanges )
     267                 :            : {
     268                 :          0 :     SCTAB nTab = pViewData->GetTabNo();
     269                 :          0 :     std::vector<ScHighlightEntry>::const_iterator pIter;
     270 [ #  # ][ #  # ]:          0 :     for ( pIter = rHighlightRanges.begin(); pIter != rHighlightRanges.end(); ++pIter)
     271                 :            :     {
     272                 :          0 :         ScRange aRange = pIter->aRef;
     273 [ #  # ][ #  # ]:          0 :         if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
                 [ #  # ]
     274                 :            :         {
     275                 :            :             rOutputData.DrawRefMark(
     276                 :          0 :                                 aRange.aStart.Col(), aRange.aStart.Row(),
     277                 :          0 :                                 aRange.aEnd.Col(), aRange.aEnd.Row(),
     278         [ #  # ]:          0 :                                 pIter->aColor, false );
     279                 :            :         }
     280                 :            :     }
     281                 :          0 : }
     282                 :            : 
     283                 :            : //------------------------------------------------------------------------
     284                 :            : 
     285                 :          0 : void ScGridWindow::DoInvertRect( const Rectangle& rPixel )
     286                 :            : {
     287         [ #  # ]:          0 :     if ( rPixel == aInvertRect )
     288                 :          0 :         aInvertRect = Rectangle();      // aufheben
     289                 :            :     else
     290                 :            :     {
     291                 :            :         OSL_ENSURE( aInvertRect.IsEmpty(), "DoInvertRect nicht paarig" );
     292                 :            : 
     293                 :          0 :         aInvertRect = rPixel;           // neues Rechteck merken
     294                 :            :     }
     295                 :            : 
     296                 :          0 :     UpdateHeaderOverlay();      // uses aInvertRect
     297                 :          0 : }
     298                 :            : 
     299                 :            : //------------------------------------------------------------------------
     300                 :            : 
     301                 :       1823 : void ScGridWindow::PrePaint()
     302                 :            : {
     303                 :            :     // forward PrePaint to DrawingLayer
     304                 :       1823 :     ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
     305                 :            : 
     306         [ +  - ]:       1823 :     if(pTabViewShell)
     307                 :            :     {
     308                 :       1823 :         SdrView* pDrawView = pTabViewShell->GetSdrView();
     309                 :            : 
     310         [ +  - ]:       1823 :         if(pDrawView)
     311                 :            :         {
     312                 :       1823 :             pDrawView->PrePaint();
     313                 :            :         }
     314                 :            :     }
     315                 :       1823 : }
     316                 :            : 
     317                 :            : //------------------------------------------------------------------------
     318                 :            : 
     319                 :       1278 : void ScGridWindow::Paint( const Rectangle& rRect )
     320                 :            : {
     321         [ +  - ]:       1278 :     ScDocument* pDoc = pViewData->GetDocument();
     322         [ -  + ]:       1278 :     if ( pDoc->IsInInterpreter() )
     323                 :            :     {
     324                 :            :         //  via Reschedule, interpretierende Zellen nicht nochmal anstossen
     325                 :            :         //  hier kein Invalidate, sonst kommt z.B. eine Error-Box nie an die Reihe
     326                 :            :         //  (Bug 36381). Durch bNeedsRepaint wird spaeter alles nochmal gemalt.
     327                 :            : 
     328         [ #  # ]:          0 :         if ( bNeedsRepaint )
     329                 :            :         {
     330                 :            :             //! Rechtecke zusammenfassen?
     331         [ #  # ]:          0 :             aRepaintPixel = Rectangle();            // mehrfach -> alles painten
     332                 :            :         }
     333                 :            :         else
     334                 :            :         {
     335                 :          0 :             bNeedsRepaint = true;
     336         [ #  # ]:          0 :             aRepaintPixel = LogicToPixel(rRect);    // nur betroffenen Bereich
     337                 :            :         }
     338                 :            :         return;
     339                 :            :     }
     340                 :            : 
     341                 :            :     // #i117893# If GetSizePixel needs to call the resize handler, the resulting nested Paint call
     342                 :            :     // (possibly for a larger rectangle) has to be allowed. Call GetSizePixel before setting bIsInPaint.
     343         [ +  - ]:       1278 :     GetSizePixel();
     344                 :            : 
     345         [ +  - ]:       1278 :     if (bIsInPaint)
     346                 :            :         return;
     347                 :            : 
     348                 :       1278 :     bIsInPaint = true;
     349                 :            : 
     350         [ +  - ]:       1278 :     Rectangle aPixRect = LogicToPixel( rRect );
     351                 :            : 
     352                 :       1278 :     SCCOL nX1 = pViewData->GetPosX(eHWhich);
     353                 :       1278 :     SCROW nY1 = pViewData->GetPosY(eVWhich);
     354                 :            : 
     355                 :       1278 :     SCTAB nTab = pViewData->GetTabNo();
     356                 :            : 
     357                 :       1278 :     double nPPTX = pViewData->GetPPTX();
     358                 :       1278 :     double nPPTY = pViewData->GetPPTY();
     359                 :            : 
     360                 :       1278 :     Rectangle aMirroredPixel = aPixRect;
     361 [ +  + ][ +  - ]:       1278 :     if ( pDoc->IsLayoutRTL( nTab ) )
     362                 :            :     {
     363                 :            :         //  mirror and swap
     364         [ +  - ]:          2 :         long nWidth = GetSizePixel().Width();
     365                 :          2 :         aMirroredPixel.Left()  = nWidth - 1 - aPixRect.Right();
     366                 :          2 :         aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left();
     367                 :            :     }
     368                 :            : 
     369         [ +  - ]:       1278 :     long nScrX = ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
     370 [ +  + ][ +  - ]:       2204 :     while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
                 [ +  + ]
     371                 :            :     {
     372                 :        926 :         ++nX1;
     373         [ +  - ]:        926 :         nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
     374                 :            :     }
     375                 :       1278 :     SCCOL nX2 = nX1;
     376 [ +  + ][ +  - ]:      11702 :     while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
                 [ +  + ]
     377                 :            :     {
     378                 :      10424 :         ++nX2;
     379         [ +  - ]:      10424 :         nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX );
     380                 :            :     }
     381                 :            : 
     382                 :       1278 :     long nScrY = 0;
     383         [ +  - ]:       1278 :     ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab);
     384                 :       1278 :     SCROW nY2 = nY1;
     385 [ +  + ][ +  - ]:       1278 :     if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
                 [ +  + ]
     386                 :            :     {
     387                 :       1206 :         ++nY2;
     388         [ +  - ]:       1206 :         ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
     389                 :            :     }
     390                 :            : 
     391         [ +  - ]:       1278 :     Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS );           // nicht weiterzeichnen
     392                 :            : 
     393                 :       1278 :     bIsInPaint = false;
     394                 :            : }
     395                 :            : 
     396                 :            : //
     397                 :            : //  Draw  ----------------------------------------------------------------
     398                 :            : //
     399                 :            : 
     400                 :       1278 : void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode )
     401                 :            : {
     402         [ +  - ]:       1278 :     ScModule* pScMod = SC_MOD();
     403         [ +  - ]:       1278 :     sal_Bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
     404                 :            : 
     405 [ +  - ][ +  - ]:       1278 :     if (pViewData->IsMinimized())
     406                 :            :         return;
     407                 :            : 
     408                 :       1278 :     PutInOrder( nX1, nX2 );
     409                 :       1278 :     PutInOrder( nY1, nY2 );
     410                 :            : 
     411                 :            :     OSL_ENSURE( ValidCol(nX2) && ValidRow(nY2), "GridWin Draw Bereich zu gross" );
     412                 :            : 
     413         [ +  - ]:       1278 :     UpdateVisibleRange();
     414                 :            : 
     415 [ +  - ][ +  - ]:       1278 :     if (nX2 < maVisibleRange.mnCol1 || nY2 < maVisibleRange.mnRow1)
     416                 :            :         return;
     417                 :            :                     // unsichtbar
     418         [ -  + ]:       1278 :     if (nX1 < maVisibleRange.mnCol1)
     419                 :          0 :         nX1 = maVisibleRange.mnCol1;
     420         [ -  + ]:       1278 :     if (nY1 < maVisibleRange.mnRow1)
     421                 :          0 :         nY1 = maVisibleRange.mnRow1;
     422                 :            : 
     423 [ +  - ][ +  - ]:       1278 :     if (nX1 > maVisibleRange.mnCol2 || nY1 > maVisibleRange.mnRow2)
     424                 :            :         return;
     425                 :            : 
     426         [ -  + ]:       1278 :     if (nX2 > maVisibleRange.mnCol2)
     427                 :          0 :         nX2 = maVisibleRange.mnCol2;
     428         [ -  + ]:       1278 :     if (nY2 > maVisibleRange.mnRow2)
     429                 :          0 :         nY2 = maVisibleRange.mnRow2;
     430                 :            : 
     431 [ -  + ][ #  # ]:       1278 :     if ( eMode != SC_UPDATE_MARKS && nX2 < maVisibleRange.mnCol2)
     432                 :          0 :         nX2 = maVisibleRange.mnCol2;                                // zum Weiterzeichnen
     433                 :            : 
     434                 :            :         //  ab hier kein return mehr
     435                 :            : 
     436                 :       1278 :     ++nPaintCount;                  // merken, dass gemalt wird (wichtig beim Invertieren)
     437                 :            : 
     438                 :       1278 :     ScDocShell* pDocSh = pViewData->GetDocShell();
     439                 :       1278 :     ScDocument* pDoc = pDocSh->GetDocument();
     440                 :       1278 :     SCTAB nTab = pViewData->GetTabNo();
     441                 :            : 
     442         [ +  - ]:       1278 :     pDoc->ExtendHidden( nX1, nY1, nX2, nY2, nTab );
     443                 :            : 
     444         [ +  - ]:       1278 :     Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
     445         [ +  - ]:       1278 :     long nMirrorWidth = GetSizePixel().Width();
     446         [ +  - ]:       1278 :     sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
     447         [ +  + ]:       1278 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
     448         [ +  + ]:       1278 :     if ( bLayoutRTL )
     449                 :            :     {
     450         [ +  - ]:          2 :         long nEndPixel = pViewData->GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ).X();
     451                 :          2 :         nMirrorWidth = aScrPos.X() - nEndPixel;
     452                 :          2 :         aScrPos.X() = nEndPixel + 1;
     453                 :            :     }
     454                 :            : 
     455                 :       1278 :     long nScrX = aScrPos.X();
     456                 :       1278 :     long nScrY = aScrPos.Y();
     457                 :            : 
     458                 :       1278 :     SCCOL nCurX = pViewData->GetCurX();
     459                 :       1278 :     SCROW nCurY = pViewData->GetCurY();
     460                 :       1278 :     SCCOL nCurEndX = nCurX;
     461                 :       1278 :     SCROW nCurEndY = nCurY;
     462         [ +  - ]:       1278 :     pDoc->ExtendMerge( nCurX, nCurY, nCurEndX, nCurEndY, nTab );
     463                 :            :     sal_Bool bCurVis = nCursorHideCount==0 &&
     464 [ +  + ][ +  + ]:       1278 :                     ( nCurEndX+1 >= nX1 && nCurX <= nX2+1 && nCurEndY+1 >= nY1 && nCurY <= nY2+1 );
         [ +  - ][ +  + ]
                 [ +  - ]
     465                 :            : 
     466                 :            :     //  AutoFill-Anfasser
     467 [ +  + ][ +  + ]:       1970 :     if ( !bCurVis && nCursorHideCount==0 && bAutoMarkVisible && aAutoMarkPos.Tab() == nTab &&
         [ +  - ][ +  -  
             +  -  -  + ]
                 [ -  + ]
     468                 :        692 :             ( aAutoMarkPos.Col() != nCurX || aAutoMarkPos.Row() != nCurY ) )
     469                 :            :     {
     470                 :          0 :         SCCOL nHdlX = aAutoMarkPos.Col();
     471                 :          0 :         SCROW nHdlY = aAutoMarkPos.Row();
     472         [ #  # ]:          0 :         pDoc->ExtendMerge( nHdlX, nHdlY, nHdlX, nHdlY, nTab );
     473 [ #  # ][ #  # ]:          0 :         bCurVis = ( nHdlX+1 >= nX1 && nHdlX <= nX2 && nHdlY+1 >= nY1 && nHdlY <= nY2 );
         [ #  # ][ #  # ]
     474                 :            :         //  links und oben ist nicht betroffen
     475                 :            : 
     476                 :            :         //! AutoFill-Anfasser alleine (ohne Cursor) zeichnen ???
     477                 :            :     }
     478                 :            : 
     479                 :       1278 :     double nPPTX = pViewData->GetPPTX();
     480                 :       1278 :     double nPPTY = pViewData->GetPPTY();
     481                 :            : 
     482                 :       1278 :     const ScViewOptions& rOpts = pViewData->GetOptions();
     483                 :       1278 :     sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
     484                 :       1278 :     sal_Bool bMarkClipped = rOpts.GetOption( VOPT_CLIPMARKS );
     485                 :            : 
     486                 :            :         // Datenblock
     487                 :            : 
     488         [ +  - ]:       1278 :     ScTableInfo aTabInfo;
     489                 :            :     pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
     490                 :            :                                         nPPTX, nPPTY, false, bFormulaMode,
     491 [ +  - ][ +  - ]:       1278 :                                         &pViewData->GetMarkData() );
     492                 :            : 
     493                 :            :     //--------------------------------------------------------------------
     494                 :            : 
     495         [ +  - ]:       1278 :     Fraction aZoomX = pViewData->GetZoomX();
     496         [ +  - ]:       1278 :     Fraction aZoomY = pViewData->GetZoomY();
     497                 :            :     ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
     498                 :            :                                 nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
     499         [ +  - ]:       1278 :                                 &aZoomX, &aZoomY );
     500                 :            : 
     501         [ +  - ]:       1278 :     aOutputData.SetMirrorWidth( nMirrorWidth );         // needed for RTL
     502                 :            : 
     503                 :       1278 :     std::auto_ptr< VirtualDevice > xFmtVirtDev;
     504                 :       1278 :     sal_Bool bLogicText = bTextWysiwyg;                     // call DrawStrings in logic MapMode?
     505                 :            : 
     506         [ +  + ]:       1278 :     if ( bTextWysiwyg )
     507                 :            :     {
     508                 :            :         //  use printer for text formatting
     509                 :            : 
     510         [ +  - ]:         70 :         OutputDevice* pFmtDev = pDoc->GetPrinter();
     511 [ +  - ][ +  - ]:         70 :         pFmtDev->SetMapMode( pViewData->GetLogicMode(eWhich) );
     512                 :         70 :         aOutputData.SetFmtDevice( pFmtDev );
     513                 :            :     }
     514 [ +  - ][ -  + ]:       1208 :     else if ( aZoomX != aZoomY && pViewData->IsOle() )
         [ #  # ][ #  # ]
                 [ -  + ]
     515                 :            :     {
     516                 :            :         //  #i45033# For OLE inplace editing with different zoom factors,
     517                 :            :         //  use a virtual device with 1/100th mm as text formatting reference
     518                 :            : 
     519 [ #  # ][ #  # ]:          0 :         xFmtVirtDev.reset( new VirtualDevice );
     520 [ #  # ][ #  # ]:          0 :         xFmtVirtDev->SetMapMode( MAP_100TH_MM );
                 [ #  # ]
     521                 :          0 :         aOutputData.SetFmtDevice( xFmtVirtDev.get() );
     522                 :            : 
     523                 :          0 :         bLogicText = sal_True;                      // use logic MapMode
     524                 :            :     }
     525                 :            : 
     526         [ +  - ]:       1278 :     const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
     527         [ +  - ]:       1278 :     Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID, false ).nColor );
     528         [ +  - ]:       1278 :     if ( aGridColor.GetColor() == COL_TRANSPARENT )
     529                 :            :     {
     530                 :            :         //  use view options' grid color only if color config has "automatic" color
     531         [ +  - ]:       1278 :         aGridColor = rOpts.GetGridColor();
     532                 :            :     }
     533                 :            : 
     534         [ +  - ]:       1278 :     aOutputData.SetSyntaxMode       ( pViewData->IsSyntaxMode() );
     535         [ +  - ]:       1278 :     aOutputData.SetGridColor        ( aGridColor );
     536         [ +  - ]:       1278 :     aOutputData.SetShowNullValues   ( rOpts.GetOption( VOPT_NULLVALS ) );
     537         [ +  - ]:       1278 :     aOutputData.SetShowFormulas     ( bFormulaMode );
     538 [ +  - ][ +  - ]:       1278 :     aOutputData.SetShowSpellErrors  ( pDoc->GetDocOptions().IsAutoSpell() );
     539         [ +  - ]:       1278 :     aOutputData.SetMarkClipped      ( bMarkClipped );
     540                 :            : 
     541                 :       1278 :     aOutputData.SetUseStyleColor( true );       // always set in table view
     542                 :            : 
     543         [ +  - ]:       1278 :     aOutputData.SetEditObject( GetEditObject() );
     544                 :       1278 :     aOutputData.SetViewShell( pViewData->GetViewShell() );
     545                 :            : 
     546 [ +  - ][ +  + ]:       1278 :     sal_Bool bGrid = rOpts.GetOption( VOPT_GRID ) && pViewData->GetShowGrid();
     547                 :       1278 :     sal_Bool bGridFirst = !rOpts.GetOption( VOPT_GRID_ONTOP );
     548                 :            : 
     549                 :       1278 :     sal_Bool bPage = rOpts.GetOption( VOPT_PAGEBREAKS );
     550                 :            : 
     551         [ -  + ]:       1278 :     if ( eMode == SC_UPDATE_CHANGED )
     552                 :            :     {
     553         [ #  # ]:          0 :         aOutputData.FindChanged();
     554         [ #  # ]:          0 :         aOutputData.SetSingleGrid(sal_True);
     555                 :            :     }
     556                 :            : 
     557                 :       1278 :     sal_Bool bPageMode = pViewData->IsPagebreakMode();
     558         [ -  + ]:       1278 :     if (bPageMode)                                      // nach FindChanged
     559                 :            :     {
     560                 :            :         // SetPagebreakMode initialisiert auch bPrinted Flags
     561         [ #  # ]:          0 :         aOutputData.SetPagebreakMode( pViewData->GetView()->GetPageBreakData() );
     562                 :            :     }
     563                 :            : 
     564                 :       1278 :     EditView*   pEditView = NULL;
     565                 :       1278 :     sal_Bool        bEditMode = pViewData->HasEditView(eWhich);
     566 [ #  # ][ -  + ]:       1278 :     if ( bEditMode && pViewData->GetRefTabNo() == nTab )
                 [ -  + ]
     567                 :            :     {
     568                 :            :         SCCOL nEditCol;
     569                 :            :         SCROW nEditRow;
     570         [ #  # ]:          0 :         pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
     571                 :          0 :         SCCOL nEditEndCol = pViewData->GetEditEndCol();
     572                 :          0 :         SCROW nEditEndRow = pViewData->GetEditEndRow();
     573                 :            : 
     574 [ #  # ][ #  # ]:          0 :         if ( nEditEndCol >= nX1 && nEditCol <= nX2 && nEditEndRow >= nY1 && nEditRow <= nY2 )
         [ #  # ][ #  # ]
     575         [ #  # ]:          0 :             aOutputData.SetEditCell( nEditCol, nEditRow );
     576                 :            :         else
     577                 :          0 :             bEditMode = false;
     578                 :            :     }
     579                 :            : 
     580                 :            :     // define drawing layer map mode and paint rectangle
     581         [ +  - ]:       1278 :     const MapMode aDrawMode = GetDrawMapMode();
     582         [ +  - ]:       1278 :     Rectangle aDrawingRectLogic;
     583                 :            : 
     584                 :            :     {
     585                 :            :         // get drawing pixel rect
     586         [ +  - ]:       1278 :         Rectangle aDrawingRectPixel(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
     587                 :            : 
     588                 :            :         // correct for border (left/right)
     589         [ -  + ]:       1278 :         if(MAXCOL == nX2)
     590                 :            :         {
     591         [ #  # ]:          0 :             if(bLayoutRTL)
     592                 :            :             {
     593                 :          0 :                 aDrawingRectPixel.Left() = 0L;
     594                 :            :             }
     595                 :            :             else
     596                 :            :             {
     597                 :          0 :                 aDrawingRectPixel.Right() = GetOutputSizePixel().getWidth();
     598                 :            :             }
     599                 :            :         }
     600                 :            : 
     601                 :            :         // correct for border (bottom)
     602         [ -  + ]:       1278 :         if(MAXROW == nY2)
     603                 :            :         {
     604                 :          0 :             aDrawingRectPixel.Bottom() = GetOutputSizePixel().getHeight();
     605                 :            :         }
     606                 :            : 
     607                 :            :         // get logic positions
     608         [ +  - ]:       1278 :         aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
     609                 :            :     }
     610                 :            : 
     611                 :       1278 :     OutputDevice* pContentDev = this;       // device for document content, used by overlay manager
     612                 :       1278 :     SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with SdrPaintWindow directly
     613                 :            : 
     614                 :            :     {
     615                 :            :         // init redraw
     616                 :       1278 :         ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
     617                 :            : 
     618         [ +  - ]:       1278 :         if(pTabViewShell)
     619                 :            :         {
     620         [ +  - ]:       1278 :             MapMode aCurrentMapMode(pContentDev->GetMapMode());
     621         [ +  - ]:       1278 :             pContentDev->SetMapMode(aDrawMode);
     622         [ +  - ]:       1278 :             SdrView* pDrawView = pTabViewShell->GetSdrView();
     623                 :            : 
     624         [ +  - ]:       1278 :             if(pDrawView)
     625                 :            :             {
     626                 :            :                 // #i74769# Use new BeginDrawLayers() interface
     627         [ +  - ]:       1278 :                 Region aDrawingRegion(aDrawingRectLogic);
     628         [ +  - ]:       1278 :                 pTargetPaintWindow = pDrawView->BeginDrawLayers(this, aDrawingRegion);
     629                 :            :                 OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
     630                 :            : 
     631                 :            :                 // #i74769# get target device from SdrPaintWindow, this may be the prerender
     632                 :            :                 // device now, too.
     633                 :       1278 :                 pContentDev = &(pTargetPaintWindow->GetTargetOutputDevice());
     634 [ +  - ][ +  - ]:       1278 :                 aOutputData.SetContentDevice( pContentDev );
     635                 :            :             }
     636                 :            : 
     637 [ +  - ][ +  - ]:       1278 :             pContentDev->SetMapMode(aCurrentMapMode);
     638                 :            :         }
     639                 :            :     }
     640                 :            : 
     641                 :            :     //  Rand (Wiese) (Pixel)
     642 [ +  - ][ -  + ]:       1278 :     if ( nX2==MAXCOL || nY2==MAXROW )
     643                 :            :     {
     644                 :            :         // save MapMode and set to pixel
     645         [ #  # ]:          0 :         MapMode aCurrentMapMode(pContentDev->GetMapMode());
     646 [ #  # ][ #  # ]:          0 :         pContentDev->SetMapMode(MAP_PIXEL);
                 [ #  # ]
     647                 :            : 
     648         [ #  # ]:          0 :         Rectangle aPixRect = Rectangle( Point(), GetOutputSizePixel() );
     649 [ #  # ][ #  # ]:          0 :         pContentDev->SetFillColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
     650         [ #  # ]:          0 :         pContentDev->SetLineColor();
     651         [ #  # ]:          0 :         if ( nX2==MAXCOL )
     652                 :            :         {
     653                 :          0 :             Rectangle aDrawRect( aPixRect );
     654         [ #  # ]:          0 :             if ( bLayoutRTL )
     655                 :          0 :                 aDrawRect.Right() = nScrX - 1;
     656                 :            :             else
     657                 :          0 :                 aDrawRect.Left() = nScrX + aOutputData.GetScrW();
     658         [ #  # ]:          0 :             if (aDrawRect.Right() >= aDrawRect.Left())
     659         [ #  # ]:          0 :                 pContentDev->DrawRect( aDrawRect );
     660                 :            :         }
     661         [ #  # ]:          0 :         if ( nY2==MAXROW )
     662                 :            :         {
     663                 :          0 :             Rectangle aDrawRect( aPixRect );
     664                 :          0 :             aDrawRect.Top() = nScrY + aOutputData.GetScrH();
     665         [ #  # ]:          0 :             if ( nX2==MAXCOL )
     666                 :            :             {
     667                 :            :                 // no double painting of the corner
     668         [ #  # ]:          0 :                 if ( bLayoutRTL )
     669                 :          0 :                     aDrawRect.Left() = nScrX;
     670                 :            :                 else
     671                 :          0 :                     aDrawRect.Right() = nScrX + aOutputData.GetScrW() - 1;
     672                 :            :             }
     673         [ #  # ]:          0 :             if (aDrawRect.Bottom() >= aDrawRect.Top())
     674         [ #  # ]:          0 :                 pContentDev->DrawRect( aDrawRect );
     675                 :            :         }
     676                 :            : 
     677                 :            :         // restore MapMode
     678 [ #  # ][ #  # ]:          0 :         pContentDev->SetMapMode(aCurrentMapMode);
     679                 :            :     }
     680                 :            : 
     681 [ +  - ][ -  + ]:       1278 :     if ( pDoc->HasBackgroundDraw( nTab, aDrawingRectLogic ) )
     682                 :            :     {
     683 [ #  # ][ #  # ]:          0 :         pContentDev->SetMapMode(MAP_PIXEL);
                 [ #  # ]
     684         [ #  # ]:          0 :         aOutputData.DrawClear();
     685                 :            : 
     686                 :            :             // Drawing Hintergrund
     687                 :            : 
     688         [ #  # ]:          0 :         pContentDev->SetMapMode(aDrawMode);
     689         [ #  # ]:          0 :         DrawRedraw( aOutputData, eMode, SC_LAYER_BACK );
     690                 :            :     }
     691                 :            :     else
     692                 :       1278 :         aOutputData.SetSolidBackground(sal_True);
     693                 :            : 
     694 [ +  - ][ +  - ]:       1278 :     pContentDev->SetMapMode(MAP_PIXEL);
                 [ +  - ]
     695         [ +  - ]:       1278 :     aOutputData.DrawDocumentBackground();
     696                 :            : 
     697 [ +  - ][ +  + ]:       1278 :     if ( bGridFirst && ( bGrid || bPage ) )
                 [ +  - ]
     698         [ +  - ]:       1278 :         aOutputData.DrawGrid( bGrid, bPage );
     699                 :            : 
     700         [ +  - ]:       1278 :     aOutputData.DrawBackground();
     701                 :            : 
     702 [ -  + ][ #  # ]:       1278 :     if ( !bGridFirst && ( bGrid || bPage ) )
                 [ #  # ]
     703         [ #  # ]:          0 :         aOutputData.DrawGrid( bGrid, bPage );
     704                 :            : 
     705         [ -  + ]:       1278 :     if ( bPageMode )
     706                 :            :     {
     707                 :            :         // DrawPagePreview draws complete lines/page numbers, must always be clipped
     708 [ #  # ][ #  # ]:          0 :         if ( aOutputData.SetChangedClip() )
     709                 :            :         {
     710         [ #  # ]:          0 :             DrawPagePreview(nX1,nY1,nX2,nY2, pContentDev);
     711         [ #  # ]:          0 :             pContentDev->SetClipRegion();
     712                 :            :         }
     713                 :            :     }
     714                 :            : 
     715         [ +  - ]:       1278 :     aOutputData.DrawShadow();
     716         [ +  - ]:       1278 :     aOutputData.DrawFrame();
     717         [ +  + ]:       1278 :     if ( !bLogicText )
     718         [ +  - ]:       1208 :         aOutputData.DrawStrings(false);     // in pixel MapMode
     719                 :            : 
     720                 :            :     // edit cells and printer-metrics text must be before the buttons
     721                 :            :     // (DataPilot buttons contain labels in UI font)
     722                 :            : 
     723 [ +  - ][ +  - ]:       1278 :     pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich));
     724         [ +  + ]:       1278 :     if ( bLogicText )
     725         [ +  - ]:         70 :         aOutputData.DrawStrings(sal_True);      // in logic MapMode if bTextWysiwyg is set
     726         [ +  - ]:       1278 :     aOutputData.DrawEdit(sal_True);
     727 [ +  - ][ +  - ]:       1278 :     pContentDev->SetMapMode(MAP_PIXEL);
                 [ +  - ]
     728                 :            : 
     729                 :            :         // Autofilter- und Pivot-Buttons
     730                 :            : 
     731         [ +  - ]:       1278 :     DrawButtons( nX1, nY1, nX2, nY2, aTabInfo, pContentDev );          // Pixel
     732                 :            : 
     733                 :            :         // Notiz-Anzeiger
     734                 :            : 
     735         [ +  - ]:       1278 :     if ( rOpts.GetOption( VOPT_NOTES ) )
     736         [ +  - ]:       1278 :         aOutputData.DrawNoteMarks();
     737                 :            : 
     738         [ +  - ]:       1278 :     aOutputData.DrawClipMarks();
     739                 :            : 
     740                 :            :     //  Szenario / ChangeTracking muss auf jeden Fall nach DrawGrid sein, auch bei !bGridFirst
     741                 :            : 
     742                 :            :     //! Test, ob ChangeTrack-Anzeige aktiv ist
     743                 :            :     //! Szenario-Rahmen per View-Optionen abschaltbar?
     744                 :            : 
     745         [ +  - ]:       1278 :     SCTAB nTabCount = pDoc->GetTableCount();
     746                 :       1278 :     const std::vector<ScHighlightEntry> &rHigh = pViewData->GetView()->GetHighlightRanges();
     747 [ +  - ][ -  + ]:       1278 :     sal_Bool bHasScenario = ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) );
         [ #  # ][ #  # ]
                 [ +  + ]
     748                 :       1278 :     sal_Bool bHasChange = ( pDoc->GetChangeTrack() != NULL );
     749                 :            : 
     750 [ +  - ][ -  + ]:       1278 :     if ( bHasChange || bHasScenario || !rHigh.empty() )
         [ -  + ][ +  - ]
     751                 :            :     {
     752                 :            : 
     753                 :            :         //! SetChangedClip() mit DrawMarks() zusammenfassen?? (anderer MapMode!)
     754                 :            : 
     755                 :          0 :         sal_Bool bAny = sal_True;
     756         [ #  # ]:          0 :         if (eMode == SC_UPDATE_CHANGED)
     757         [ #  # ]:          0 :             bAny = aOutputData.SetChangedClip();
     758         [ #  # ]:          0 :         if (bAny)
     759                 :            :         {
     760         [ #  # ]:          0 :             if ( bHasChange )
     761         [ #  # ]:          0 :                 aOutputData.DrawChangeTrack();
     762                 :            : 
     763         [ #  # ]:          0 :             if ( bHasScenario )
     764         [ #  # ]:          0 :                 lcl_DrawScenarioFrames( pContentDev, pViewData, eWhich, nX1,nY1,nX2,nY2 );
     765                 :            : 
     766         [ #  # ]:          0 :             lcl_DrawHighlight( aOutputData, pViewData, rHigh );
     767                 :            : 
     768         [ #  # ]:          0 :             if (eMode == SC_UPDATE_CHANGED)
     769         [ #  # ]:          0 :                 pContentDev->SetClipRegion();
     770                 :            :         }
     771                 :            :     }
     772                 :            : 
     773                 :            :         // Drawing Vordergrund
     774                 :            : 
     775         [ +  - ]:       1278 :     pContentDev->SetMapMode(aDrawMode);
     776                 :            : 
     777         [ +  - ]:       1278 :     DrawRedraw( aOutputData, eMode, SC_LAYER_FRONT );
     778         [ +  - ]:       1278 :     DrawRedraw( aOutputData, eMode, SC_LAYER_INTERN );
     779         [ +  - ]:       1278 :     DrawSdrGrid( aDrawingRectLogic, pContentDev );
     780                 :            : 
     781         [ +  - ]:       1278 :     if (!bIsInScroll)                               // Drawing Markierungen
     782                 :            :     {
     783 [ -  + ][ #  # ]:       1278 :         if(eMode == SC_UPDATE_CHANGED && aOutputData.SetChangedClip())
         [ #  # ][ -  + ]
     784                 :            :         {
     785         [ #  # ]:          0 :             pContentDev->SetClipRegion();
     786                 :            :         }
     787                 :            :     }
     788                 :            : 
     789 [ +  - ][ +  - ]:       1278 :     pContentDev->SetMapMode(MAP_PIXEL);
                 [ +  - ]
     790                 :            : 
     791 [ -  + ][ #  # ]:       1278 :     if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() )
         [ #  # ][ -  + ]
     792                 :            :     {
     793         [ #  # ]:          0 :         Color aRefColor( rColorCfg.GetColorValue(svtools::CALCREFERENCE).nColor );
     794                 :          0 :         aOutputData.DrawRefMark( pViewData->GetRefStartX(), pViewData->GetRefStartY(),
     795                 :          0 :                                  pViewData->GetRefEndX(), pViewData->GetRefEndY(),
     796         [ #  # ]:          0 :                                  aRefColor, false );
     797                 :            :     }
     798                 :            : 
     799                 :            :         //  Range-Finder
     800                 :            : 
     801         [ +  - ]:       1278 :     ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
     802         [ +  - ]:       1278 :     if (pHdl)
     803                 :            :     {
     804                 :       1278 :         ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
     805 [ #  # ][ #  # ]:       2556 :         if ( pRangeFinder && !pRangeFinder->IsHidden() &&
         [ -  + ][ -  + ]
     806 [ #  # ][ #  # ]:       1278 :                 pRangeFinder->GetDocName() == pDocSh->GetTitle() )
         [ -  + ][ #  # ]
                 [ #  # ]
     807                 :            :         {
     808                 :          0 :             sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count();
     809         [ #  # ]:          0 :             for (sal_uInt16 i=0; i<nCount; i++)
     810                 :            :             {
     811         [ #  # ]:          0 :                 ScRangeFindData* pData = pRangeFinder->GetObject(i);
     812                 :            : 
     813                 :          0 :                 ScRange aRef = pData->aRef;
     814         [ #  # ]:          0 :                 aRef.Justify();
     815 [ #  # ][ #  # ]:          0 :                 if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
                 [ #  # ]
     816                 :          0 :                     aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(),
     817                 :          0 :                                             aRef.aEnd.Col(), aRef.aEnd.Row(),
     818                 :            :                                             Color( ScRangeFindList::GetColorName( i ) ),
     819 [ #  # ][ #  # ]:          0 :                                             sal_True );
     820                 :            :             }
     821                 :            :         }
     822                 :            :     }
     823                 :            : 
     824                 :            :     {
     825                 :            :         // end redraw
     826                 :       1278 :         ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
     827                 :            : 
     828         [ +  - ]:       1278 :         if(pTabViewShell)
     829                 :            :         {
     830         [ +  - ]:       1278 :             MapMode aCurrentMapMode(pContentDev->GetMapMode());
     831         [ +  - ]:       1278 :             pContentDev->SetMapMode(aDrawMode);
     832         [ +  - ]:       1278 :             SdrView* pDrawView = pTabViewShell->GetSdrView();
     833                 :            : 
     834         [ +  - ]:       1278 :             if(pDrawView)
     835                 :            :             {
     836                 :            :                 // #i74769# work with SdrPaintWindow directly
     837         [ +  - ]:       1278 :                 pDrawView->EndDrawLayers(*pTargetPaintWindow, true);
     838                 :            :             }
     839                 :            : 
     840 [ +  - ][ +  - ]:       1278 :             pContentDev->SetMapMode(aCurrentMapMode);
     841                 :            :         }
     842                 :            :     }
     843                 :            : 
     844                 :            :     //  InPlace Edit-View
     845                 :            :     // moved after EndDrawLayers() to get it outside the overlay buffer and
     846                 :            :     // on top of everything
     847 [ -  + ][ #  # ]:       1278 :     if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) )
                 [ -  + ]
     848                 :            :     {
     849                 :            :         //! use pContentDev for EditView?
     850 [ #  # ][ #  # ]:          0 :         SetMapMode(MAP_PIXEL);
                 [ #  # ]
     851                 :          0 :         SCCOL nCol1 = pViewData->GetEditStartCol();
     852                 :          0 :         SCROW nRow1 = pViewData->GetEditStartRow();
     853                 :          0 :         SCCOL nCol2 = pViewData->GetEditEndCol();
     854                 :          0 :         SCROW nRow2 = pViewData->GetEditEndRow();
     855         [ #  # ]:          0 :         SetLineColor();
     856 [ #  # ][ #  # ]:          0 :         SetFillColor( pEditView->GetBackgroundColor() );
     857         [ #  # ]:          0 :         Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
     858         [ #  # ]:          0 :         Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
     859                 :          0 :         aEnd.X() -= 2 * nLayoutSign;        // don't overwrite grid
     860                 :          0 :         aEnd.Y() -= 2;
     861 [ #  # ][ #  # ]:          0 :         DrawRect( Rectangle( aStart,aEnd ) );
     862                 :            : 
     863 [ #  # ][ #  # ]:          0 :         SetMapMode(pViewData->GetLogicMode());
     864                 :            :         pEditView->Paint( PixelToLogic( Rectangle( Point( nScrX, nScrY ),
     865 [ #  # ][ #  # ]:          0 :                             Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ) );
                 [ #  # ]
     866 [ #  # ][ #  # ]:          0 :         SetMapMode(MAP_PIXEL);
                 [ #  # ]
     867                 :            :     }
     868                 :            : 
     869         [ -  + ]:       1278 :     if (pViewData->HasEditView(eWhich))
     870                 :            :     {
     871                 :            :         // flush OverlayManager before changing the MapMode
     872         [ #  # ]:          0 :         flushOverlayManager();
     873                 :            : 
     874                 :            :         // set MapMode for text edit
     875 [ #  # ][ #  # ]:          0 :         SetMapMode(pViewData->GetLogicMode());
     876                 :            :     }
     877                 :            :     else
     878         [ +  - ]:       1278 :         SetMapMode(aDrawMode);
     879                 :            : 
     880         [ -  + ]:       1278 :     if ( pNoteMarker )
     881         [ #  # ]:          0 :         pNoteMarker->Draw();        // ueber den Cursor, im Drawing-MapMode
     882                 :            : 
     883                 :            :     //
     884                 :            :     //  Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert aus Basic-Macro),
     885                 :            :     //  ist das jetzt durcheinandergekommen und es muss neu gemalt werden
     886                 :            :     //
     887                 :            : 
     888                 :            :     OSL_ENSURE(nPaintCount, "nPaintCount falsch");
     889                 :       1278 :     --nPaintCount;
     890         [ +  - ]:       1278 :     if (!nPaintCount)
     891         [ +  - ]:       1278 :         CheckNeedsRepaint();
     892                 :            : 
     893                 :            :     // Flag drawn formula cells "unchanged".
     894 [ +  - ][ +  - ]:       1278 :     pDoc->ResetChanged(ScRange(nX1,nY1,nTab,nX2,nY2,nTab));
         [ +  - ][ +  - ]
                 [ +  - ]
     895                 :            : }
     896                 :            : 
     897                 :       6112 : void ScGridWindow::CheckNeedsRepaint()
     898                 :            : {
     899                 :            :     //  called at the end of painting, and from timer after background text width calculation
     900                 :            : 
     901         [ -  + ]:       6112 :     if (bNeedsRepaint)
     902                 :            :     {
     903                 :          0 :         bNeedsRepaint = false;
     904         [ #  # ]:          0 :         if (aRepaintPixel.IsEmpty())
     905                 :          0 :             Invalidate();
     906                 :            :         else
     907         [ #  # ]:          0 :             Invalidate(PixelToLogic(aRepaintPixel));
     908                 :          0 :         aRepaintPixel = Rectangle();
     909                 :            : 
     910                 :            :         // selection function in status bar might also be invalid
     911                 :          0 :         SfxBindings& rBindings = pViewData->GetBindings();
     912                 :          0 :         rBindings.Invalidate( SID_STATUS_SUM );
     913                 :          0 :         rBindings.Invalidate( SID_ATTR_SIZE );
     914                 :          0 :         rBindings.Invalidate( SID_TABLE_CELL );
     915                 :            :     }
     916                 :       6112 : }
     917                 :            : 
     918                 :          0 : void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev )
     919                 :            : {
     920                 :          0 :     ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData();
     921         [ #  # ]:          0 :     if (pPageData)
     922                 :            :     {
     923         [ #  # ]:          0 :         ScDocument* pDoc = pViewData->GetDocument();
     924                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
     925                 :          0 :         Size aWinSize = GetOutputSizePixel();
     926 [ #  # ][ #  # ]:          0 :         const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
     927         [ #  # ]:          0 :         Color aManual( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKMANUAL).nColor );
     928         [ #  # ]:          0 :         Color aAutomatic( rColorCfg.GetColorValue(svtools::CALCPAGEBREAK).nColor );
     929                 :            : 
     930 [ #  # ][ #  # ]:          0 :         String aPageStr = ScGlobal::GetRscString( STR_PGNUM );
     931         [ #  # ]:          0 :         if ( nPageScript == 0 )
     932                 :            :         {
     933                 :            :             //  get script type of translated "Page" string only once
     934 [ #  # ][ #  # ]:          0 :             nPageScript = pDoc->GetStringScriptType( aPageStr );
     935         [ #  # ]:          0 :             if (nPageScript == 0)
     936         [ #  # ]:          0 :                 nPageScript = ScGlobal::GetDefaultScriptType();
     937                 :            :         }
     938                 :            : 
     939         [ #  # ]:          0 :         Font aFont;
     940                 :          0 :         ScEditEngineDefaulter* pEditEng = NULL;
     941 [ #  # ][ #  # ]:          0 :         const ScPatternAttr& rDefPattern = ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN));
     942         [ #  # ]:          0 :         if ( nPageScript == SCRIPTTYPE_LATIN )
     943                 :            :         {
     944                 :            :             //  use single font and call DrawText directly
     945         [ #  # ]:          0 :             rDefPattern.GetFont( aFont, SC_AUTOCOL_BLACK );
     946         [ #  # ]:          0 :             aFont.SetColor( Color( COL_LIGHTGRAY ) );
     947                 :            :             //  font size is set as needed
     948                 :            :         }
     949                 :            :         else
     950                 :            :         {
     951                 :            :             //  use EditEngine to draw mixed-script string
     952 [ #  # ][ #  # ]:          0 :             pEditEng = new ScEditEngineDefaulter( EditEngine::CreatePool(), sal_True );
                 [ #  # ]
     953         [ #  # ]:          0 :             pEditEng->SetRefMapMode( pContentDev->GetMapMode() );
     954 [ #  # ][ #  # ]:          0 :             SfxItemSet* pEditDefaults = new SfxItemSet( pEditEng->GetEmptyItemSet() );
                 [ #  # ]
     955         [ #  # ]:          0 :             rDefPattern.FillEditItemSet( pEditDefaults );
     956 [ #  # ][ #  # ]:          0 :             pEditDefaults->Put( SvxColorItem( Color( COL_LIGHTGRAY ), EE_CHAR_COLOR ) );
                 [ #  # ]
     957         [ #  # ]:          0 :             pEditEng->SetDefaults( pEditDefaults );
     958                 :            :         }
     959                 :            : 
     960                 :          0 :         sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
     961         [ #  # ]:          0 :         for (sal_uInt16 nPos=0; nPos<nCount; nPos++)
     962                 :            :         {
     963         [ #  # ]:          0 :             ScPrintRangeData& rData = pPageData->GetData(nPos);
     964                 :          0 :             ScRange aRange = rData.GetPrintRange();
     965   [ #  #  #  #  :          0 :             if ( aRange.aStart.Col() <= nX2+1  && aRange.aEnd.Col()+1 >= nX1 &&
           #  # ][ #  # ]
                 [ #  # ]
     966                 :          0 :                  aRange.aStart.Row() <= nY2+1 && aRange.aEnd.Row()+1 >= nY1 )
     967                 :            :             {
     968                 :            :                 //  3 Pixel Rahmen um den Druckbereich
     969                 :            :                 //  (mittlerer Pixel auf den Gitterlinien)
     970                 :            : 
     971         [ #  # ]:          0 :                 pContentDev->SetLineColor();
     972         [ #  # ]:          0 :                 if (rData.IsAutomatic())
     973         [ #  # ]:          0 :                     pContentDev->SetFillColor( aAutomatic );
     974                 :            :                 else
     975         [ #  # ]:          0 :                     pContentDev->SetFillColor( aManual );
     976                 :            : 
     977                 :            :                 Point aStart = pViewData->GetScrPos(
     978         [ #  # ]:          0 :                                     aRange.aStart.Col(), aRange.aStart.Row(), eWhich, sal_True );
     979                 :            :                 Point aEnd = pViewData->GetScrPos(
     980         [ #  # ]:          0 :                                     aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, sal_True );
     981                 :          0 :                 aStart.X() -= 2;
     982                 :          0 :                 aStart.Y() -= 2;
     983                 :            : 
     984                 :            :                 //  Ueberlaeufe verhindern:
     985         [ #  # ]:          0 :                 if ( aStart.X() < -10 ) aStart.X() = -10;
     986         [ #  # ]:          0 :                 if ( aStart.Y() < -10 ) aStart.Y() = -10;
     987         [ #  # ]:          0 :                 if ( aEnd.X() > aWinSize.Width() + 10 )
     988                 :          0 :                     aEnd.X() = aWinSize.Width() + 10;
     989         [ #  # ]:          0 :                 if ( aEnd.Y() > aWinSize.Height() + 10 )
     990                 :          0 :                     aEnd.Y() = aWinSize.Height() + 10;
     991                 :            : 
     992 [ #  # ][ #  # ]:          0 :                 pContentDev->DrawRect( Rectangle( aStart, Point(aEnd.X(),aStart.Y()+2) ) );
     993 [ #  # ][ #  # ]:          0 :                 pContentDev->DrawRect( Rectangle( aStart, Point(aStart.X()+2,aEnd.Y()) ) );
     994 [ #  # ][ #  # ]:          0 :                 pContentDev->DrawRect( Rectangle( Point(aStart.X(),aEnd.Y()-2), aEnd ) );
     995 [ #  # ][ #  # ]:          0 :                 pContentDev->DrawRect( Rectangle( Point(aEnd.X()-2,aStart.Y()), aEnd ) );
     996                 :            : 
     997                 :            :                 //  Seitenumbrueche
     998                 :            :                 //! anders darstellen (gestrichelt ????)
     999                 :            : 
    1000                 :          0 :                 size_t nColBreaks = rData.GetPagesX();
    1001                 :          0 :                 const SCCOL* pColEnd = rData.GetPageEndX();
    1002                 :            :                 size_t nColPos;
    1003         [ #  # ]:          0 :                 for (nColPos=0; nColPos+1<nColBreaks; nColPos++)
    1004                 :            :                 {
    1005                 :          0 :                     SCCOL nBreak = pColEnd[nColPos]+1;
    1006 [ #  # ][ #  # ]:          0 :                     if ( nBreak >= nX1 && nBreak <= nX2+1 )
    1007                 :            :                     {
    1008                 :            :                         //! hidden suchen
    1009 [ #  # ][ #  # ]:          0 :                         if (pDoc->HasColBreak(nBreak, nTab) & BREAK_MANUAL)
    1010         [ #  # ]:          0 :                             pContentDev->SetFillColor( aManual );
    1011                 :            :                         else
    1012         [ #  # ]:          0 :                             pContentDev->SetFillColor( aAutomatic );
    1013                 :            :                         Point aBreak = pViewData->GetScrPos(
    1014         [ #  # ]:          0 :                                         nBreak, aRange.aStart.Row(), eWhich, sal_True );
    1015 [ #  # ][ #  # ]:          0 :                         pContentDev->DrawRect( Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) );
    1016                 :            :                     }
    1017                 :            :                 }
    1018                 :            : 
    1019                 :          0 :                 size_t nRowBreaks = rData.GetPagesY();
    1020                 :          0 :                 const SCROW* pRowEnd = rData.GetPageEndY();
    1021                 :            :                 size_t nRowPos;
    1022         [ #  # ]:          0 :                 for (nRowPos=0; nRowPos+1<nRowBreaks; nRowPos++)
    1023                 :            :                 {
    1024                 :          0 :                     SCROW nBreak = pRowEnd[nRowPos]+1;
    1025 [ #  # ][ #  # ]:          0 :                     if ( nBreak >= nY1 && nBreak <= nY2+1 )
    1026                 :            :                     {
    1027                 :            :                         //! hidden suchen
    1028 [ #  # ][ #  # ]:          0 :                         if (pDoc->HasRowBreak(nBreak, nTab) & BREAK_MANUAL)
    1029         [ #  # ]:          0 :                             pContentDev->SetFillColor( aManual );
    1030                 :            :                         else
    1031         [ #  # ]:          0 :                             pContentDev->SetFillColor( aAutomatic );
    1032                 :            :                         Point aBreak = pViewData->GetScrPos(
    1033         [ #  # ]:          0 :                                         aRange.aStart.Col(), nBreak, eWhich, sal_True );
    1034 [ #  # ][ #  # ]:          0 :                         pContentDev->DrawRect( Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) );
    1035                 :            :                     }
    1036                 :            :                 }
    1037                 :            : 
    1038                 :            :                 //  Seitenzahlen
    1039                 :            : 
    1040                 :          0 :                 SCROW nPrStartY = aRange.aStart.Row();
    1041         [ #  # ]:          0 :                 for (nRowPos=0; nRowPos<nRowBreaks; nRowPos++)
    1042                 :            :                 {
    1043                 :          0 :                     SCROW nPrEndY = pRowEnd[nRowPos];
    1044 [ #  # ][ #  # ]:          0 :                     if ( nPrEndY >= nY1 && nPrStartY <= nY2 )
    1045                 :            :                     {
    1046                 :          0 :                         SCCOL nPrStartX = aRange.aStart.Col();
    1047         [ #  # ]:          0 :                         for (nColPos=0; nColPos<nColBreaks; nColPos++)
    1048                 :            :                         {
    1049                 :          0 :                             SCCOL nPrEndX = pColEnd[nColPos];
    1050 [ #  # ][ #  # ]:          0 :                             if ( nPrEndX >= nX1 && nPrStartX <= nX2 )
    1051                 :            :                             {
    1052                 :            :                                 Point aPageStart = pViewData->GetScrPos(
    1053         [ #  # ]:          0 :                                                         nPrStartX, nPrStartY, eWhich, sal_True );
    1054                 :            :                                 Point aPageEnd = pViewData->GetScrPos(
    1055         [ #  # ]:          0 :                                                         nPrEndX+1,nPrEndY+1, eWhich, sal_True );
    1056                 :            : 
    1057                 :          0 :                                 long nPageNo = rData.GetFirstPage();
    1058         [ #  # ]:          0 :                                 if ( rData.IsTopDown() )
    1059                 :          0 :                                     nPageNo += ((long)nColPos)*nRowBreaks+nRowPos;
    1060                 :            :                                 else
    1061                 :          0 :                                     nPageNo += ((long)nRowPos)*nColBreaks+nColPos;
    1062                 :            : 
    1063         [ #  # ]:          0 :                                 String aThisPageStr = aPageStr; // Don't modify the original string.
    1064 [ #  # ][ #  # ]:          0 :                                 aThisPageStr.SearchAndReplaceAscii("%1", String::CreateFromInt32(nPageNo));
                 [ #  # ]
    1065                 :            : 
    1066         [ #  # ]:          0 :                                 if ( pEditEng )
    1067                 :            :                                 {
    1068                 :            :                                     //  find right font size with EditEngine
    1069                 :          0 :                                     long nHeight = 100;
    1070 [ #  # ][ #  # ]:          0 :                                     pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
                 [ #  # ]
    1071 [ #  # ][ #  # ]:          0 :                                     pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
                 [ #  # ]
    1072 [ #  # ][ #  # ]:          0 :                                     pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
                 [ #  # ]
    1073         [ #  # ]:          0 :                                     pEditEng->SetText( aThisPageStr );
    1074 [ #  # ][ #  # ]:          0 :                                     Size aSize100( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
    1075                 :            : 
    1076                 :            :                                     //  40% of width or 60% of height
    1077                 :          0 :                                     long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
    1078                 :          0 :                                     long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height();
    1079                 :          0 :                                     nHeight = Min(nSizeX,nSizeY);
    1080 [ #  # ][ #  # ]:          0 :                                     pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
                 [ #  # ]
    1081 [ #  # ][ #  # ]:          0 :                                     pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
                 [ #  # ]
    1082 [ #  # ][ #  # ]:          0 :                                     pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
                 [ #  # ]
    1083                 :            : 
    1084                 :            :                                     //  centered output with EditEngine
    1085 [ #  # ][ #  # ]:          0 :                                     Size aTextSize( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
    1086                 :          0 :                                     Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
    1087                 :          0 :                                                 (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
    1088         [ #  # ]:          0 :                                     pEditEng->Draw( pContentDev, aPos );
    1089                 :            :                                 }
    1090                 :            :                                 else
    1091                 :            :                                 {
    1092                 :            :                                     //  find right font size for DrawText
    1093         [ #  # ]:          0 :                                     aFont.SetSize( Size( 0,100 ) );
    1094         [ #  # ]:          0 :                                     pContentDev->SetFont( aFont );
    1095 [ #  # ][ #  # ]:          0 :                                     Size aSize100( pContentDev->GetTextWidth( aThisPageStr ), pContentDev->GetTextHeight() );
    1096                 :            : 
    1097                 :            :                                     //  40% of width or 60% of height
    1098                 :          0 :                                     long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
    1099                 :          0 :                                     long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height();
    1100         [ #  # ]:          0 :                                     aFont.SetSize( Size( 0,Min(nSizeX,nSizeY) ) );
    1101         [ #  # ]:          0 :                                     pContentDev->SetFont( aFont );
    1102                 :            : 
    1103                 :            :                                     //  centered output with DrawText
    1104 [ #  # ][ #  # ]:          0 :                                     Size aTextSize( pContentDev->GetTextWidth( aThisPageStr ), pContentDev->GetTextHeight() );
    1105                 :          0 :                                     Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
    1106                 :          0 :                                                 (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
    1107         [ #  # ]:          0 :                                     pContentDev->DrawText( aPos, aThisPageStr );
    1108         [ #  # ]:          0 :                                 }
    1109                 :            :                             }
    1110                 :          0 :                             nPrStartX = nPrEndX + 1;
    1111                 :            :                         }
    1112                 :            :                     }
    1113                 :          0 :                     nPrStartY = nPrEndY + 1;
    1114                 :            :                 }
    1115                 :            :             }
    1116                 :            :         }
    1117                 :            : 
    1118 [ #  # ][ #  # ]:          0 :         delete pEditEng;
         [ #  # ][ #  # ]
    1119                 :            :     }
    1120                 :          0 : }
    1121                 :            : 
    1122                 :       1278 : void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2*/, ScTableInfo& rTabInfo, OutputDevice* pContentDev )
    1123                 :            : {
    1124         [ +  - ]:       1278 :     aComboButton.SetOutputDevice( pContentDev );
    1125                 :            : 
    1126         [ +  - ]:       1278 :     ScDocument* pDoc = pViewData->GetDocument();
    1127         [ +  - ]:       1278 :     ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc);
    1128                 :            : 
    1129                 :            :     SCCOL nCol;
    1130                 :            :     SCROW nRow;
    1131                 :            :     SCSIZE nArrY;
    1132                 :            :     SCSIZE nQuery;
    1133                 :       1278 :     SCTAB           nTab = pViewData->GetTabNo();
    1134                 :       1278 :     ScDBData*       pDBData = NULL;
    1135                 :       1278 :     ScQueryParam*   pQueryParam = NULL;
    1136                 :            : 
    1137                 :       1278 :     RowInfo*        pRowInfo = rTabInfo.mpRowInfo;
    1138                 :       1278 :     sal_uInt16          nArrCount = rTabInfo.mnArrCount;
    1139                 :            : 
    1140         [ +  - ]:       1278 :     sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
    1141                 :            : 
    1142                 :       1278 :     Point aOldPos  = aComboButton.GetPosPixel();    // Zustand fuer MouseDown/Up
    1143                 :       1278 :     Size  aOldSize = aComboButton.GetSizePixel();   // merken
    1144                 :            : 
    1145         [ +  + ]:      16974 :     for (nArrY=1; nArrY+1<nArrCount; nArrY++)
    1146                 :            :     {
    1147 [ +  + ][ +  - ]:      15696 :         if ( pRowInfo[nArrY].bAutoFilter && pRowInfo[nArrY].bChanged )
    1148                 :            :         {
    1149                 :          2 :             RowInfo* pThisRowInfo = &pRowInfo[nArrY];
    1150                 :            : 
    1151                 :          2 :             nRow = pThisRowInfo->nRowNo;
    1152                 :            : 
    1153                 :            : 
    1154         [ +  + ]:         22 :             for (nCol=nX1; nCol<=nX2; nCol++)
    1155                 :            :             {
    1156                 :         20 :                 CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
    1157 [ +  + ][ +  - ]:         20 :                 if ( pInfo->bAutoFilter && !pInfo->bHOverlapped && !pInfo->bVOverlapped )
                 [ +  - ]
    1158                 :            :                 {
    1159         [ +  - ]:          2 :                     if (!pQueryParam)
    1160 [ +  - ][ +  - ]:          2 :                         pQueryParam = new ScQueryParam;
    1161                 :            : 
    1162                 :          2 :                     sal_Bool bNewData = sal_True;
    1163         [ -  + ]:          2 :                     if (pDBData)
    1164                 :            :                     {
    1165                 :            :                         SCCOL nStartCol;
    1166                 :            :                         SCROW nStartRow;
    1167                 :            :                         SCCOL nEndCol;
    1168                 :            :                         SCROW nEndRow;
    1169                 :            :                         SCTAB nAreaTab;
    1170         [ #  # ]:          0 :                         pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
    1171 [ #  # ][ #  # ]:          0 :                         if ( nCol >= nStartCol && nCol <= nEndCol &&
         [ #  # ][ #  # ]
    1172                 :            :                              nRow >= nStartRow && nRow <= nEndRow )
    1173                 :          0 :                             bNewData = false;
    1174                 :            :                     }
    1175         [ +  - ]:          2 :                     if (bNewData)
    1176                 :            :                     {
    1177         [ +  - ]:          2 :                         pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
    1178         [ +  - ]:          2 :                         if (pDBData)
    1179         [ +  - ]:          2 :                             pDBData->GetQueryParam( *pQueryParam );
    1180                 :            :                         else
    1181                 :            :                         {
    1182                 :            :                             // can also be part of DataPilot table
    1183                 :            :                             // OSL_FAIL("Auto-Filter-Button ohne DBData");
    1184                 :            :                         }
    1185                 :            :                     }
    1186                 :            : 
    1187                 :            :                     //  pQueryParam kann nur MAXQUERY Eintraege enthalten
    1188                 :            : 
    1189                 :          2 :                     sal_Bool bSimpleQuery = sal_True;
    1190                 :          2 :                     sal_Bool bColumnFound = false;
    1191         [ -  + ]:          2 :                     if (!pQueryParam->bInplace)
    1192                 :          0 :                         bSimpleQuery = false;
    1193         [ +  - ]:          2 :                     SCSIZE nCount = pQueryParam->GetEntryCount();
    1194 [ +  + ][ +  - ]:         18 :                     for (nQuery = 0; nQuery < nCount && bSimpleQuery; ++nQuery)
                 [ +  + ]
    1195 [ +  - ][ -  + ]:         16 :                         if (pQueryParam->GetEntry(nQuery).bDoQuery)
    1196                 :            :                         {
    1197                 :            :                             //  hier nicht auf EQUAL beschraenken
    1198                 :            :                             //  (auch bei ">1" soll der Spaltenkopf blau werden)
    1199                 :            : 
    1200 [ #  # ][ #  # ]:          0 :                             if (pQueryParam->GetEntry(nQuery).nField == nCol)
    1201                 :          0 :                                 bColumnFound = sal_True;
    1202         [ #  # ]:          0 :                             if (nQuery > 0)
    1203 [ #  # ][ #  # ]:          0 :                                 if (pQueryParam->GetEntry(nQuery).eConnect != SC_AND)
    1204                 :          0 :                                     bSimpleQuery = false;
    1205                 :            :                         }
    1206                 :            : 
    1207 [ +  - ][ -  + ]:          2 :                     bool bArrowState = bSimpleQuery && bColumnFound;
    1208                 :            :                     long    nSizeX;
    1209                 :            :                     long    nSizeY;
    1210         [ +  - ]:          2 :                     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
    1211         [ +  - ]:          2 :                     Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
    1212                 :            : 
    1213         [ +  - ]:          2 :                     aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);
    1214         [ +  - ]:          2 :                     aCellBtn.setPopupLeft(bLayoutRTL);   // #i114944# AutoFilter button is left-aligned in RTL
    1215         [ +  - ]:          2 :                     aCellBtn.setDrawBaseButton(false);
    1216         [ +  - ]:          2 :                     aCellBtn.setDrawPopupButton(true);
    1217         [ +  - ]:          2 :                     aCellBtn.setHasHiddenMember(bArrowState);
    1218         [ +  - ]:          2 :                     aCellBtn.draw();
    1219                 :            :                 }
    1220                 :            :             }
    1221                 :            :         }
    1222                 :            : 
    1223 [ +  + ][ +  - ]:      15696 :         if ( pRowInfo[nArrY].bPushButton && pRowInfo[nArrY].bChanged )
    1224                 :            :         {
    1225                 :         58 :             RowInfo* pThisRowInfo = &pRowInfo[nArrY];
    1226                 :         58 :             nRow = pThisRowInfo->nRowNo;
    1227         [ +  + ]:        638 :             for (nCol=nX1; nCol<=nX2; nCol++)
    1228                 :            :             {
    1229                 :        580 :                 CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
    1230 [ +  + ][ +  - ]:        580 :                 if ( pInfo->bPushButton && !pInfo->bHOverlapped && !pInfo->bVOverlapped )
                 [ +  - ]
    1231                 :            :                 {
    1232         [ +  - ]:         84 :                     Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
    1233                 :            :                     long nSizeX;
    1234                 :            :                     long nSizeY;
    1235         [ +  - ]:         84 :                     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
    1236                 :         84 :                     long nPosX = aScrPos.X();
    1237                 :         84 :                     long nPosY = aScrPos.Y();
    1238                 :            :                     // bLayoutRTL is handled in setBoundingBox
    1239                 :            : 
    1240         [ +  - ]:         84 :                     String aStr;
    1241         [ +  - ]:         84 :                     pDoc->GetString(nCol, nRow, nTab, aStr);
    1242 [ +  - ][ +  - ]:         84 :                     aCellBtn.setText(aStr);
    1243         [ +  - ]:         84 :                     aCellBtn.setBoundingBox(Point(nPosX, nPosY), Size(nSizeX-1, nSizeY-1), bLayoutRTL);
    1244         [ +  - ]:         84 :                     aCellBtn.setPopupLeft(false);   // DataPilot popup is always right-aligned for now
    1245         [ +  - ]:         84 :                     aCellBtn.setDrawBaseButton(true);
    1246         [ +  - ]:         84 :                     aCellBtn.setDrawPopupButton(pInfo->bPopupButton);
    1247         [ +  - ]:         84 :                     aCellBtn.setHasHiddenMember(pInfo->bFilterActive);
    1248 [ +  - ][ +  - ]:         84 :                     aCellBtn.draw();
    1249                 :            :                 }
    1250                 :            :             }
    1251                 :            :         }
    1252                 :            : 
    1253 [ -  + ][ #  # ]:      15696 :         if ( bListValButton && pRowInfo[nArrY].nRowNo == aListValPos.Row() && pRowInfo[nArrY].bChanged )
         [ #  # ][ -  + ]
    1254                 :            :         {
    1255         [ #  # ]:          0 :             Rectangle aRect = GetListValButtonRect( aListValPos );
    1256                 :          0 :             aComboButton.SetPosPixel( aRect.TopLeft() );
    1257         [ #  # ]:          0 :             aComboButton.SetSizePixel( aRect.GetSize() );
    1258 [ #  # ][ #  # ]:          0 :             pContentDev->SetClipRegion( aRect );
                 [ #  # ]
    1259         [ #  # ]:          0 :             aComboButton.Draw( false, false );
    1260         [ #  # ]:          0 :             pContentDev->SetClipRegion();           // always called from Draw() without clip region
    1261                 :          0 :             aComboButton.SetPosPixel( aOldPos );    // restore old state
    1262                 :          0 :             aComboButton.SetSizePixel( aOldSize );  // for MouseUp/Down (AutoFilter)
    1263                 :            :         }
    1264                 :            :     }
    1265                 :            : 
    1266 [ +  + ][ +  - ]:       1278 :     delete pQueryParam;
    1267 [ +  - ][ +  - ]:       1278 :     aComboButton.SetOutputDevice( this );
    1268                 :       1278 : }
    1269                 :            : 
    1270                 :          0 : Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos )
    1271                 :            : {
    1272         [ #  # ]:          0 :     ScDocument* pDoc = pViewData->GetDocument();
    1273                 :          0 :     SCTAB nTab = pViewData->GetTabNo();
    1274         [ #  # ]:          0 :     sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
    1275         [ #  # ]:          0 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
    1276                 :            : 
    1277         [ #  # ]:          0 :     ScDDComboBoxButton aButton( this );             // for optimal size
    1278                 :          0 :     Size aBtnSize = aButton.GetSizePixel();
    1279                 :            : 
    1280                 :          0 :     SCCOL nCol = rButtonPos.Col();
    1281                 :          0 :     SCROW nRow = rButtonPos.Row();
    1282                 :            : 
    1283                 :            :     long nCellSizeX;    // width of this cell, including merged
    1284                 :            :     long nDummy;
    1285         [ #  # ]:          0 :     pViewData->GetMergeSizePixel( nCol, nRow, nCellSizeX, nDummy );
    1286                 :            : 
    1287                 :            :     // for height, only the cell's row is used, excluding merged cells
    1288         [ #  # ]:          0 :     long nCellSizeY = ScViewData::ToPixel( pDoc->GetRowHeight( nRow, nTab ), pViewData->GetPPTY() );
    1289                 :          0 :     long nAvailable = nCellSizeX;
    1290                 :            : 
    1291                 :            :     //  left edge of next cell if there is a non-hidden next column
    1292                 :          0 :     SCCOL nNextCol = nCol + 1;
    1293         [ #  # ]:          0 :     const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE ));
    1294         [ #  # ]:          0 :     if ( pMerge->GetColMerge() > 1 )
    1295                 :          0 :         nNextCol = nCol + pMerge->GetColMerge();    // next cell after the merged area
    1296 [ #  # ][ #  # ]:          0 :     while ( nNextCol <= MAXCOL && pDoc->ColHidden(nNextCol, nTab) )
         [ #  # ][ #  # ]
    1297                 :          0 :         ++nNextCol;
    1298                 :          0 :     sal_Bool bNextCell = ( nNextCol <= MAXCOL );
    1299         [ #  # ]:          0 :     if ( bNextCell )
    1300         [ #  # ]:          0 :         nAvailable = ScViewData::ToPixel( pDoc->GetColWidth( nNextCol, nTab ), pViewData->GetPPTX() );
    1301                 :            : 
    1302         [ #  # ]:          0 :     if ( nAvailable < aBtnSize.Width() )
    1303                 :          0 :         aBtnSize.Width() = nAvailable;
    1304         [ #  # ]:          0 :     if ( nCellSizeY < aBtnSize.Height() )
    1305                 :          0 :         aBtnSize.Height() = nCellSizeY;
    1306                 :            : 
    1307         [ #  # ]:          0 :     Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich, sal_True );
    1308                 :          0 :     aPos.X() += nCellSizeX * nLayoutSign;               // start of next cell
    1309         [ #  # ]:          0 :     if (!bNextCell)
    1310                 :          0 :         aPos.X() -= aBtnSize.Width() * nLayoutSign;     // right edge of cell if next cell not available
    1311                 :          0 :     aPos.Y() += nCellSizeY - aBtnSize.Height();
    1312                 :            :     // X remains at the left edge
    1313                 :            : 
    1314         [ #  # ]:          0 :     if ( bLayoutRTL )
    1315                 :          0 :         aPos.X() -= aBtnSize.Width()-1;     // align right edge of button with cell border
    1316                 :            : 
    1317 [ #  # ][ #  # ]:          0 :     return Rectangle( aPos, aBtnSize );
    1318                 :            : }
    1319                 :            : 
    1320                 :          0 : bool ScGridWindow::IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab )
    1321                 :            : {
    1322         [ #  # ]:          0 :     ScDocument*     pDoc    = pViewData->GetDocument();
    1323         [ #  # ]:          0 :     ScDBData*       pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
    1324         [ #  # ]:          0 :     ScQueryParam    aQueryParam;
    1325                 :            : 
    1326         [ #  # ]:          0 :     if ( pDBData )
    1327         [ #  # ]:          0 :         pDBData->GetQueryParam( aQueryParam );
    1328                 :            :     else
    1329                 :            :     {
    1330                 :            :         OSL_FAIL("Auto-Filter-Button ohne DBData");
    1331                 :            :     }
    1332                 :            : 
    1333                 :          0 :     bool    bSimpleQuery = true;
    1334                 :          0 :     bool    bColumnFound = false;
    1335                 :            :     SCSIZE  nQuery;
    1336                 :            : 
    1337         [ #  # ]:          0 :     if ( !aQueryParam.bInplace )
    1338                 :          0 :         bSimpleQuery = false;
    1339                 :            : 
    1340                 :            :     //  aQueryParam kann nur MAXQUERY Eintraege enthalten
    1341                 :            : 
    1342         [ #  # ]:          0 :     SCSIZE nCount = aQueryParam.GetEntryCount();
    1343 [ #  # ][ #  # ]:          0 :     for (nQuery = 0; nQuery < nCount && bSimpleQuery; ++nQuery)
                 [ #  # ]
    1344 [ #  # ][ #  # ]:          0 :         if ( aQueryParam.GetEntry(nQuery).bDoQuery )
    1345                 :            :         {
    1346 [ #  # ][ #  # ]:          0 :             if (aQueryParam.GetEntry(nQuery).nField == nCol)
    1347                 :          0 :                 bColumnFound = sal_True;
    1348                 :            : 
    1349         [ #  # ]:          0 :             if (nQuery > 0)
    1350 [ #  # ][ #  # ]:          0 :                 if (aQueryParam.GetEntry(nQuery).eConnect != SC_AND)
    1351                 :          0 :                     bSimpleQuery = false;
    1352                 :            :         }
    1353                 :            : 
    1354 [ #  # ][ #  # ]:          0 :     return ( bSimpleQuery && bColumnFound );
                 [ #  # ]
    1355                 :            : }
    1356                 :            : 
    1357                 :       1237 : void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
    1358                 :            : {
    1359 [ +  - ][ +  - ]:       1237 :     ScMarkData aMultiMark( pViewData->GetMarkData() );
    1360                 :       1237 :     aMultiMark.SetMarking( false );
    1361         [ +  - ]:       1237 :     aMultiMark.MarkToMulti();
    1362                 :            : 
    1363         [ +  - ]:       1237 :     ScDocument* pDoc = pViewData->GetDocument();
    1364                 :       1237 :     SCTAB nTab = pViewData->GetTabNo();
    1365                 :            : 
    1366         [ +  - ]:       1237 :     sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
    1367         [ +  + ]:       1237 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
    1368                 :            : 
    1369         [ +  + ]:       1237 :     if ( !aMultiMark.IsMultiMarked() )
    1370                 :            :         return;
    1371                 :            : 
    1372                 :         39 :     ScRange aMultiRange;
    1373         [ +  - ]:         39 :     aMultiMark.GetMultiMarkArea( aMultiRange );
    1374                 :         39 :     SCCOL nX1 = aMultiRange.aStart.Col();
    1375                 :         39 :     SCROW nY1 = aMultiRange.aStart.Row();
    1376                 :         39 :     SCCOL nX2 = aMultiRange.aEnd.Col();
    1377                 :         39 :     SCROW nY2 = aMultiRange.aEnd.Row();
    1378                 :            : 
    1379                 :         39 :     PutInOrder( nX1, nX2 );
    1380                 :         39 :     PutInOrder( nY1, nY2 );
    1381                 :            : 
    1382                 :         39 :     sal_Bool bTestMerge = sal_True;
    1383                 :         39 :     bool bRepeat = true;
    1384                 :            : 
    1385                 :         39 :     SCCOL nTestX2 = nX2;
    1386                 :         39 :     SCROW nTestY2 = nY2;
    1387         [ +  - ]:         39 :     if (bTestMerge)
    1388         [ +  - ]:         39 :         pDoc->ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab );
    1389                 :            : 
    1390                 :         39 :     SCCOL nPosX = pViewData->GetPosX( eHWhich );
    1391                 :         39 :     SCROW nPosY = pViewData->GetPosY( eVWhich );
    1392 [ -  + ][ +  - ]:         39 :     if (nTestX2 < nPosX || nTestY2 < nPosY)
    1393                 :            :         return;                                         // unsichtbar
    1394                 :         39 :     SCCOL nRealX1 = nX1;
    1395         [ -  + ]:         39 :     if (nX1 < nPosX)
    1396                 :          0 :         nX1 = nPosX;
    1397         [ -  + ]:         39 :     if (nY1 < nPosY)
    1398                 :          0 :         nY1 = nPosY;
    1399                 :            : 
    1400         [ +  - ]:         39 :     SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
    1401         [ -  + ]:         39 :     if (nXRight > MAXCOL) nXRight = MAXCOL;
    1402         [ +  - ]:         39 :     SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
    1403         [ -  + ]:         39 :     if (nYBottom > MAXROW) nYBottom = MAXROW;
    1404                 :            : 
    1405 [ +  - ][ -  + ]:         39 :     if (nX1 > nXRight || nY1 > nYBottom)
    1406                 :            :         return;                                         // unsichtbar
    1407         [ -  + ]:         39 :     if (nX2 > nXRight) nX2 = nXRight;
    1408         [ -  + ]:         39 :     if (nY2 > nYBottom) nY2 = nYBottom;
    1409                 :            : 
    1410                 :         39 :     double nPPTX = pViewData->GetPPTX();
    1411                 :         39 :     double nPPTY = pViewData->GetPPTY();
    1412                 :            : 
    1413         [ +  - ]:         39 :     ScInvertMerger aInvert( &rPixelRects );
    1414                 :            : 
    1415         [ +  - ]:         39 :     Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
    1416                 :         39 :     long nScrY = aScrPos.Y();
    1417                 :         39 :     sal_Bool bWasHidden = false;
    1418         [ +  + ]:        128 :     for (SCROW nY=nY1; nY<=nY2; nY++)
    1419                 :            :     {
    1420                 :         89 :         sal_Bool bFirstRow = ( nY == nPosY );                       // first visible row?
    1421                 :         89 :         sal_Bool bDoHidden = false;                                 // versteckte nachholen ?
    1422         [ +  - ]:         89 :         sal_uInt16 nHeightTwips = pDoc->GetRowHeight( nY,nTab );
    1423                 :         89 :         sal_Bool bDoRow = ( nHeightTwips != 0 );
    1424         [ +  - ]:         89 :         if (bDoRow)
    1425                 :            :         {
    1426         [ +  - ]:         89 :             if (bTestMerge)
    1427         [ -  + ]:         89 :                 if (bWasHidden)                 // auf versteckte zusammengefasste testen
    1428                 :            :                 {
    1429                 :          0 :                     bDoHidden = sal_True;
    1430                 :          0 :                     bDoRow = sal_True;
    1431                 :            :                 }
    1432                 :            : 
    1433                 :         89 :             bWasHidden = false;
    1434                 :            :         }
    1435                 :            :         else
    1436                 :            :         {
    1437                 :          0 :             bWasHidden = sal_True;
    1438         [ #  # ]:          0 :             if (bTestMerge)
    1439         [ #  # ]:          0 :                 if (nY==nY2)
    1440                 :          0 :                     bDoRow = sal_True;              // letzte Zeile aus Block
    1441                 :            :         }
    1442                 :            : 
    1443         [ +  - ]:         89 :         if ( bDoRow )
    1444                 :            :         {
    1445                 :         89 :             SCCOL nLoopEndX = nX2;
    1446         [ -  + ]:         89 :             if (nX2 < nX1)                      // Rest von zusammengefasst
    1447                 :            :             {
    1448                 :          0 :                 SCCOL nStartX = nX1;
    1449         [ #  # ]:          0 :                 while ( ((const ScMergeFlagAttr*)pDoc->
    1450         [ #  # ]:          0 :                             GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG))->IsHorOverlapped() )
    1451                 :          0 :                     --nStartX;
    1452         [ #  # ]:          0 :                 if (nStartX <= nX2)
    1453                 :          0 :                     nLoopEndX = nX1;
    1454                 :            :             }
    1455                 :            : 
    1456                 :         89 :             long nEndY = nScrY + ScViewData::ToPixel( nHeightTwips, nPPTY ) - 1;
    1457                 :         89 :             long nScrX = aScrPos.X();
    1458         [ +  + ]:        536 :             for (SCCOL nX=nX1; nX<=nLoopEndX; nX++)
    1459                 :            :             {
    1460         [ +  - ]:        447 :                 long nWidth = ScViewData::ToPixel( pDoc->GetColWidth( nX,nTab ), nPPTX );
    1461         [ +  - ]:        447 :                 if ( nWidth > 0 )
    1462                 :            :                 {
    1463                 :        447 :                     long nEndX = nScrX + ( nWidth - 1 ) * nLayoutSign;
    1464         [ +  - ]:        447 :                     if (bTestMerge)
    1465                 :            :                     {
    1466                 :        447 :                         SCROW nThisY = nY;
    1467         [ +  - ]:        447 :                         const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab );
    1468                 :            :                         const ScMergeFlagAttr* pMergeFlag = (const ScMergeFlagAttr*) &pPattern->
    1469         [ +  - ]:        447 :                                                                         GetItem(ATTR_MERGE_FLAG);
    1470 [ -  + ][ #  # ]:        447 :                         if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) )
         [ #  # ][ -  + ]
    1471                 :            :                         {
    1472 [ #  # ][ #  # ]:          0 :                             while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1473         [ #  # ]:          0 :                                     (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) )
    1474                 :            :                             {
    1475                 :          0 :                                 --nThisY;
    1476         [ #  # ]:          0 :                                 pPattern = pDoc->GetPattern( nX, nThisY, nTab );
    1477         [ #  # ]:          0 :                                 pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
    1478                 :            :                             }
    1479                 :            :                         }
    1480                 :            : 
    1481                 :            :                         // nur Rest von zusammengefasster zu sehen ?
    1482                 :        447 :                         SCCOL nThisX = nX;
    1483 [ -  + ][ #  # ]:        447 :                         if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 )
         [ #  # ][ -  + ]
    1484                 :            :                         {
    1485         [ #  # ]:          0 :                             while ( pMergeFlag->IsHorOverlapped() )
    1486                 :            :                             {
    1487                 :          0 :                                 --nThisX;
    1488         [ #  # ]:          0 :                                 pPattern = pDoc->GetPattern( nThisX, nThisY, nTab );
    1489         [ #  # ]:          0 :                                 pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
    1490                 :            :                             }
    1491                 :            :                         }
    1492                 :            : 
    1493 [ +  - ][ +  - ]:        447 :                         if ( aMultiMark.IsCellMarked( nThisX, nThisY, sal_True ) == bRepeat )
    1494                 :            :                         {
    1495         [ +  - ]:        447 :                             if ( !pMergeFlag->IsOverlapped() )
    1496                 :            :                             {
    1497         [ +  - ]:        447 :                                 ScMergeAttr* pMerge = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
    1498 [ +  - ][ -  + ]:        447 :                                 if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
                 [ -  + ]
    1499                 :            :                                 {
    1500                 :            :                                     Point aEndPos = pViewData->GetScrPos(
    1501                 :          0 :                                             nThisX + pMerge->GetColMerge(),
    1502         [ #  # ]:          0 :                                             nThisY + pMerge->GetRowMerge(), eWhich );
    1503 [ #  # ][ #  # ]:          0 :                                     if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
                 [ #  # ]
    1504                 :            :                                     {
    1505                 :            :                                         aInvert.AddRect( Rectangle( nScrX,nScrY,
    1506 [ #  # ][ #  # ]:          0 :                                                     aEndPos.X()-nLayoutSign,aEndPos.Y()-1 ) );
    1507                 :            :                                     }
    1508                 :            :                                 }
    1509 [ +  - ][ +  - ]:        447 :                                 else if ( nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
    1510                 :            :                                 {
    1511 [ +  - ][ +  - ]:        447 :                                     aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) );
    1512                 :            :                                 }
    1513                 :            :                             }
    1514                 :            :                         }
    1515                 :            :                     }
    1516                 :            :                     else        // !bTestMerge
    1517                 :            :                     {
    1518 [ #  # ][ #  # ]:          0 :                         if ( aMultiMark.IsCellMarked( nX, nY, sal_True ) == bRepeat &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1519                 :            :                                                 nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
    1520                 :            :                         {
    1521 [ #  # ][ #  # ]:          0 :                             aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) );
    1522                 :            :                         }
    1523                 :            :                     }
    1524                 :            : 
    1525                 :        447 :                     nScrX = nEndX + nLayoutSign;
    1526                 :            :                 }
    1527                 :            :             }
    1528                 :         89 :             nScrY = nEndY + 1;
    1529                 :            :         }
    1530 [ +  - ][ +  - ]:       1237 :     }
                 [ +  + ]
    1531                 :            : }
    1532                 :            : 
    1533                 :            : // -------------------------------------------------------------------------
    1534                 :            : 
    1535                 :          0 : void ScGridWindow::DataChanged( const DataChangedEvent& rDCEvt )
    1536                 :            : {
    1537                 :          0 :     Window::DataChanged(rDCEvt);
    1538                 :            : 
    1539 [ #  # ][ #  #  :          0 :     if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    1540                 :          0 :          (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
    1541                 :          0 :          (rDCEvt.GetType() == DATACHANGED_FONTS) ||
    1542                 :          0 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    1543                 :          0 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1544                 :          0 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    1545                 :            :     {
    1546 [ #  # ][ #  # ]:          0 :         if ( rDCEvt.GetType() == DATACHANGED_FONTS && eWhich == pViewData->GetActivePart() )
                 [ #  # ]
    1547                 :          0 :             pViewData->GetDocShell()->UpdateFontList();
    1548                 :            : 
    1549   [ #  #  #  # ]:          0 :         if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
                 [ #  # ]
    1550                 :          0 :              (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1551                 :            :         {
    1552         [ #  # ]:          0 :             if ( eWhich == pViewData->GetActivePart() )     // only once for the view
    1553                 :            :             {
    1554         [ #  # ]:          0 :                 ScTabView* pView = pViewData->GetView();
    1555                 :            : 
    1556                 :            :                 //  update scale in case the UI ScreenZoom has changed
    1557                 :          0 :                 ScGlobal::UpdatePPT(this);
    1558                 :          0 :                 pView->RecalcPPT();
    1559                 :            : 
    1560                 :            :                 //  RepeatResize in case scroll bar sizes have changed
    1561                 :          0 :                 pView->RepeatResize();
    1562                 :          0 :                 pView->UpdateAllOverlays();
    1563                 :            : 
    1564                 :            :                 //  invalidate cell attribs in input handler, in case the
    1565                 :            :                 //  EditEngine BackgroundColor has to be changed
    1566         [ #  # ]:          0 :                 if ( pViewData->IsActive() )
    1567                 :            :                 {
    1568                 :          0 :                     ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    1569         [ #  # ]:          0 :                     if (pHdl)
    1570                 :          0 :                         pHdl->ForgetLastPattern();
    1571                 :            :                 }
    1572                 :            :             }
    1573                 :            :         }
    1574                 :            : 
    1575                 :          0 :         Invalidate();
    1576                 :            :     }
    1577                 :          0 : }
    1578                 :            : 
    1579                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10