LCOV - code coverage report
Current view: top level - sc/source/ui/view - hdrcont.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 249 494 50.4 %
Date: 2012-08-25 Functions: 11 28 39.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 243 703 34.6 %

           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 <sfx2/dispatch.hxx>
      30                 :            : #include <vcl/help.hxx>
      31                 :            : #include <tools/poly.hxx>
      32                 :            : #include <svtools/colorcfg.hxx>
      33                 :            : 
      34                 :            : #include "scresid.hxx"
      35                 :            : #include "sc.hrc"
      36                 :            : #include "tabvwsh.hxx"
      37                 :            : #include "hdrcont.hxx"
      38                 :            : #include "scmod.hxx"        // Optionen
      39                 :            : #include "inputopt.hxx"     // Optionen
      40                 :            : #include "gridmerg.hxx"
      41                 :            : #include "document.hxx"
      42                 :            : #include "markdata.hxx"
      43                 :            : 
      44                 :            : // -----------------------------------------------------------------------
      45                 :            : 
      46                 :            : #define SC_DRAG_MIN     2
      47                 :            : 
      48                 :            : //  passes in paint
      49                 :            : //  (selection left/right must be first because the continuous lines
      50                 :            : //  are partly overwritten later)
      51                 :            : 
      52                 :            : #define SC_HDRPAINT_SEL_RIGHT   0
      53                 :            : #define SC_HDRPAINT_SEL_LEFT    1
      54                 :            : #define SC_HDRPAINT_TOP         2
      55                 :            : #define SC_HDRPAINT_SEL_TOP     3
      56                 :            : #define SC_HDRPAINT_SEL_BOTTOM  4
      57                 :            : #define SC_HDRPAINT_BOTTOM      5
      58                 :            : #define SC_HDRPAINT_TEXT        6
      59                 :            : #define SC_HDRPAINT_COUNT       7
      60                 :            : 
      61                 :            : //==================================================================
      62                 :            : 
      63                 :        458 : ScHeaderControl::ScHeaderControl( Window* pParent, SelectionEngine* pSelectionEngine,
      64                 :            :                                     SCCOLROW nNewSize, sal_uInt16 nNewFlags ) :
      65                 :            :             Window      ( pParent ),
      66                 :            :             pSelEngine  ( pSelectionEngine ),
      67                 :            :             nFlags      ( nNewFlags ),
      68                 :            :             bVertical   ( (nNewFlags & HDR_VERTICAL) != 0 ),
      69                 :            :             nSize       ( nNewSize ),
      70                 :            :             nMarkStart  ( 0 ),
      71                 :            :             nMarkEnd    ( 0 ),
      72                 :            :             bMarkRange  ( false ),
      73                 :            :             bDragging   ( false ),
      74 [ +  - ][ +  - ]:        458 :             bIgnoreMove ( false )
      75                 :            : {
      76                 :            :     // --- RTL --- no default mirroring for this window, the spreadsheet itself
      77                 :            :     // is also not mirrored
      78                 :            :     // mirror the vertical window for correct border drawing
      79                 :            :     // table layout depends on sheet format, not UI setting, so the
      80                 :            :     // borders of the vertical window have to be handled manually, too.
      81         [ +  - ]:        458 :     EnableRTL( false );
      82                 :            : 
      83         [ +  - ]:        458 :     aNormFont = GetFont();
      84         [ +  - ]:        458 :     aNormFont.SetTransparent( sal_True );       //! WEIGHT_NORMAL hart setzen ???
      85         [ +  - ]:        458 :     aBoldFont = aNormFont;
      86         [ +  - ]:        458 :     aBoldFont.SetWeight( WEIGHT_BOLD );
      87                 :            : 
      88         [ +  - ]:        458 :     SetFont(aBoldFont);
      89                 :        458 :     bBoldSet = sal_True;
      90                 :            : 
      91                 :            :     Size aSize = LogicToPixel( Size(
      92                 :            :         GetTextWidth(rtl::OUString("8888")),
      93 [ +  - ][ +  - ]:        458 :         GetTextHeight() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
      94                 :        458 :     aSize.Width()  += 4;    // Platz fuer hervorgehobene Umrandung
      95                 :        458 :     aSize.Height() += 3;
      96         [ +  - ]:        458 :     SetSizePixel( aSize );
      97                 :            : 
      98                 :        458 :     nWidth = nSmallWidth = aSize.Width();
      99 [ +  - ][ +  - ]:        458 :     nBigWidth = LogicToPixel( Size( GetTextWidth(rtl::OUString("8888888")), 0 ) ).Width() + 5;
         [ +  - ][ +  - ]
     100                 :            : 
     101         [ +  - ]:        458 :     SetBackground();    // sonst Probleme auf OS/2 !?!?!
     102                 :        458 : }
     103                 :            : 
     104                 :        229 : void ScHeaderControl::SetWidth( long nNew )
     105                 :            : {
     106                 :            :     OSL_ENSURE( bVertical, "SetDigits nur fuer Zeilenkoepfe erlaubt" );
     107         [ +  - ]:        229 :     if ( nNew != nWidth )
     108                 :            :     {
     109         [ +  - ]:        229 :         Size aSize( nNew, GetSizePixel().Height() );    // Hoehe nicht aendern
     110         [ +  - ]:        229 :         SetSizePixel( aSize );
     111                 :            : 
     112                 :        229 :         nWidth = nNew;
     113                 :            : 
     114         [ +  - ]:        229 :         Invalidate();       // neu zentrieren
     115                 :            :     }
     116                 :        229 : }
     117                 :            : 
     118 [ +  - ][ +  - ]:        450 : ScHeaderControl::~ScHeaderControl()
     119                 :            : {
     120         [ -  + ]:        450 : }
     121                 :            : 
     122                 :        542 : void ScHeaderControl::DoPaint( SCCOLROW nStart, SCCOLROW nEnd )
     123                 :            : {
     124         [ +  - ]:        542 :     sal_Bool bLayoutRTL = IsLayoutRTL();
     125         [ -  + ]:        542 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
     126                 :            : 
     127         [ +  - ]:        542 :     Rectangle aRect( Point(0,0), GetOutputSizePixel() );
     128         [ +  + ]:        542 :     if ( bVertical )
     129                 :            :     {
     130         [ +  - ]:        271 :         aRect.Top() = GetScrPos( nStart )-nLayoutSign;      // extra pixel for line at top of selection
     131         [ +  - ]:        271 :         aRect.Bottom() = GetScrPos( nEnd+1 )-nLayoutSign;
     132                 :            :     }
     133                 :            :     else
     134                 :            :     {
     135         [ +  - ]:        271 :         aRect.Left() = GetScrPos( nStart )-nLayoutSign;     // extra pixel for line left of selection
     136         [ +  - ]:        271 :         aRect.Right() = GetScrPos( nEnd+1 )-nLayoutSign;
     137                 :            :     }
     138         [ +  - ]:        542 :     Invalidate(aRect);
     139                 :        542 : }
     140                 :            : 
     141                 :       2992 : void ScHeaderControl::SetMark( sal_Bool bNewSet, SCCOLROW nNewStart, SCCOLROW nNewEnd )
     142                 :            : {
     143                 :       2992 :     sal_Bool bEnabled = SC_MOD()->GetInputOptions().GetMarkHeader();    //! cachen?
     144         [ +  + ]:       2992 :     if (!bEnabled)
     145                 :        312 :         bNewSet = false;
     146                 :            : 
     147                 :            :     //  Variablen setzen
     148                 :            : 
     149                 :       2992 :     sal_Bool bOldSet     = bMarkRange;
     150                 :       2992 :     SCCOLROW nOldStart = nMarkStart;
     151                 :       2992 :     SCCOLROW nOldEnd     = nMarkEnd;
     152                 :       2992 :     PutInOrder( nNewStart, nNewEnd );
     153                 :       2992 :     bMarkRange = bNewSet;
     154                 :       2992 :     nMarkStart = nNewStart;
     155                 :       2992 :     nMarkEnd   = nNewEnd;
     156                 :            : 
     157                 :            :     //  Paint
     158                 :            : 
     159         [ +  + ]:       2992 :     if ( bNewSet )
     160                 :            :     {
     161         [ +  + ]:       2680 :         if ( bOldSet )
     162                 :            :         {
     163         [ +  + ]:       2274 :             if ( nNewStart == nOldStart )
     164                 :            :             {
     165         [ +  + ]:       2240 :                 if ( nNewEnd != nOldEnd )
     166                 :         68 :                     DoPaint( Min( nNewEnd, nOldEnd ) + 1, Max( nNewEnd, nOldEnd ) );
     167                 :            :                 // sonst nix
     168                 :            :             }
     169         [ -  + ]:         34 :             else if ( nNewEnd == nOldEnd )
     170                 :          0 :                 DoPaint( Min( nNewStart, nOldStart ), Max( nNewStart, nOldStart ) - 1 );
     171 [ -  + ][ #  # ]:         34 :             else if ( nNewStart > nOldEnd || nNewEnd < nOldStart )
     172                 :            :             {
     173                 :            :                 //  zwei Bereiche...
     174                 :         34 :                 DoPaint( nOldStart, nOldEnd );
     175                 :         34 :                 DoPaint( nNewStart, nNewEnd );
     176                 :            :             }
     177                 :            :             else                //  irgendwie ueberlappend... (kommt eh nicht oft vor)
     178                 :       2274 :                 DoPaint( Min( nNewStart, nOldStart ), Max( nNewEnd, nOldEnd ) );
     179                 :            :         }
     180                 :            :         else
     181                 :        406 :             DoPaint( nNewStart, nNewEnd );      //  komplett neu
     182                 :            :     }
     183         [ -  + ]:        312 :     else if ( bOldSet )
     184                 :          0 :         DoPaint( nOldStart, nOldEnd );          //  komplett aufheben
     185                 :            : 
     186                 :            :     //  sonst war nix, is nix
     187                 :       2992 : }
     188                 :            : 
     189                 :       1084 : long ScHeaderControl::GetScrPos( SCCOLROW nEntryNo )
     190                 :            : {
     191                 :            :     long nScrPos;
     192                 :            : 
     193 [ +  + ][ +  + ]:       1084 :     long nMax = ( bVertical ? GetOutputSizePixel().Height() : GetOutputSizePixel().Width() ) + 1;
                 [ +  + ]
     194         [ -  + ]:       1084 :     if (nEntryNo >= nSize)
     195                 :          0 :         nScrPos = nMax;
     196                 :            :     else
     197                 :            :     {
     198                 :       1084 :         nScrPos = 0;
     199 [ +  + ][ +  + ]:       2318 :         for (SCCOLROW i=GetPos(); i<nEntryNo && nScrPos<nMax; i++)
                 [ +  + ]
     200                 :            :         {
     201                 :       1234 :             sal_uInt16 nAdd = GetEntrySize(i);
     202         [ +  + ]:       1234 :             if (nAdd)
     203                 :       1222 :                 nScrPos += nAdd;
     204                 :            :             else
     205                 :            :             {
     206                 :         12 :                 SCCOLROW nHidden = GetHiddenCount(i);
     207         [ +  - ]:         12 :                 if (nHidden > 0)
     208                 :         12 :                     i += nHidden - 1;
     209                 :            :             }
     210                 :            :         }
     211                 :            :     }
     212                 :            : 
     213         [ -  + ]:       1084 :     if ( IsLayoutRTL() )
     214                 :          0 :         nScrPos = nMax - nScrPos - 2;
     215                 :            : 
     216                 :       1084 :     return nScrPos;
     217                 :            : }
     218                 :            : 
     219                 :            : // draw a rectangle across the window's width/height, with the outer part in a lighter color
     220                 :            : 
     221                 :       1182 : void ScHeaderControl::DrawShadedRect( long nStart, long nEnd, const Color& rBaseColor )
     222                 :            : {
     223                 :       1182 :     Color aWhite( COL_WHITE );
     224                 :            : 
     225                 :       1182 :     Color aInner( rBaseColor );             // highlight color, unchanged
     226                 :       1182 :     Color aCenter( rBaseColor );
     227         [ +  - ]:       1182 :     aCenter.Merge( aWhite, 0xd0 );          // lighten up a bit
     228                 :       1182 :     Color aOuter( rBaseColor );
     229         [ +  - ]:       1182 :     aOuter.Merge( aWhite, 0xa0 );           // lighten up more
     230                 :            : 
     231 [ +  - ][ +  + ]:       1182 :     if ( IsMirrored() )
     232                 :          4 :         std::swap( aInner, aOuter );        // just swap colors instead of positions
     233                 :            : 
     234         [ +  - ]:       1182 :     Size aWinSize = GetSizePixel();
     235         [ +  + ]:       1182 :     long nBarSize = bVertical ? aWinSize.Width() : aWinSize.Height();
     236                 :       1182 :     long nCenterPos = (nBarSize / 2) - 1;
     237                 :            : 
     238         [ +  - ]:       1182 :     SetLineColor();
     239         [ +  - ]:       1182 :     SetFillColor( aOuter );
     240         [ +  + ]:       1182 :     if (bVertical)
     241 [ +  - ][ +  - ]:        668 :         DrawRect( Rectangle( 0, nStart, nCenterPos-1, nEnd ) );
     242                 :            :     else
     243 [ +  - ][ +  - ]:        514 :         DrawRect( Rectangle( nStart, 0, nEnd, nCenterPos-1 ) );
     244         [ +  - ]:       1182 :     SetFillColor( aCenter );
     245         [ +  + ]:       1182 :     if (bVertical)
     246 [ +  - ][ +  - ]:        668 :         DrawRect( Rectangle( nCenterPos, nStart, nCenterPos, nEnd ) );
     247                 :            :     else
     248 [ +  - ][ +  - ]:        514 :         DrawRect( Rectangle( nStart, nCenterPos, nEnd, nCenterPos ) );
     249         [ +  - ]:       1182 :     SetFillColor( aInner );
     250         [ +  + ]:       1182 :     if (bVertical)
     251 [ +  - ][ +  - ]:        668 :         DrawRect( Rectangle( nCenterPos+1, nStart, nBarSize-1, nEnd ) );
     252                 :            :     else
     253 [ +  - ][ +  - ]:        514 :         DrawRect( Rectangle( nStart, nCenterPos+1, nEnd, nBarSize-1 ) );
     254                 :       1182 : }
     255                 :            : 
     256                 :            : //
     257                 :            : //      Paint
     258                 :            : //
     259                 :            : 
     260                 :        629 : void ScHeaderControl::Paint( const Rectangle& rRect )
     261                 :            : {
     262                 :            :     //  fuer VCL ist es wichtig, wenig Aufrufe zu haben, darum werden die aeusseren
     263                 :            :     //  Linien zusammengefasst
     264                 :            : 
     265                 :        629 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     266                 :        629 :     sal_Bool bHighContrast = rStyleSettings.GetHighContrastMode();
     267         [ +  - ]:        629 :     sal_Bool bDark = rStyleSettings.GetFaceColor().IsDark();
     268                 :            :     // Use the same distinction for bDark as in Window::DrawSelectionBackground
     269                 :            : 
     270                 :        629 :     Color aTextColor = rStyleSettings.GetButtonTextColor();
     271                 :        629 :     Color aSelTextColor = rStyleSettings.GetHighlightTextColor();
     272         [ +  - ]:        629 :     aNormFont.SetColor( aTextColor );
     273         [ -  + ]:        629 :     if ( bHighContrast )
     274         [ #  # ]:          0 :         aBoldFont.SetColor( aTextColor );
     275                 :            :     else
     276         [ +  - ]:        629 :         aBoldFont.SetColor( aSelTextColor );
     277 [ +  + ][ +  - ]:        629 :     SetTextColor( ( bBoldSet && !bHighContrast ) ? aSelTextColor : aTextColor );
                 [ +  - ]
     278                 :            : 
     279                 :        629 :     Color aBlack( COL_BLACK );
     280                 :        629 :     Color aSelLineColor = rStyleSettings.GetHighlightColor();
     281         [ +  - ]:        629 :     aSelLineColor.Merge( aBlack, 0xe0 );        // darken just a little bit
     282                 :            : 
     283         [ +  - ]:        629 :     sal_Bool bLayoutRTL = IsLayoutRTL();
     284         [ +  + ]:        629 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
     285         [ +  - ]:        629 :     sal_Bool bMirrored = IsMirrored();
     286                 :            : 
     287         [ +  - ]:        629 :     String              aString;
     288                 :            :     sal_uInt16              nBarSize;
     289                 :        629 :     Point               aScrPos;
     290                 :        629 :     Size                aTextSize;
     291                 :            : 
     292         [ +  + ]:        629 :     if (bVertical)
     293         [ +  - ]:        356 :         nBarSize = (sal_uInt16) GetSizePixel().Width();
     294                 :            :     else
     295         [ +  - ]:        273 :         nBarSize = (sal_uInt16) GetSizePixel().Height();
     296                 :            : 
     297         [ +  - ]:        629 :     SCCOLROW    nPos = GetPos();
     298                 :            : 
     299         [ +  + ]:        629 :     long nPStart = bVertical ? rRect.Top() : rRect.Left();
     300         [ +  + ]:        629 :     long nPEnd = bVertical ? rRect.Bottom() : rRect.Right();
     301                 :            : 
     302                 :        629 :     long nTransStart = nPEnd + 1;
     303                 :        629 :     long nTransEnd = 0;
     304                 :            : 
     305                 :        629 :     long nInitScrPos = 0;
     306         [ +  + ]:        629 :     if ( bLayoutRTL )
     307                 :            :     {
     308                 :          2 :         long nTemp = nPStart;       // swap nPStart / nPEnd
     309                 :          2 :         nPStart = nPEnd;
     310                 :          2 :         nPEnd = nTemp;
     311                 :          2 :         nTemp = nTransStart;        // swap nTransStart / nTransEnd
     312                 :          2 :         nTransStart = nTransEnd;
     313                 :          2 :         nTransEnd = nTemp;
     314         [ -  + ]:          2 :         if ( bVertical )            // start loops from the end
     315         [ #  # ]:          0 :             nInitScrPos = GetSizePixel().Height() - 1;
     316                 :            :         else
     317         [ +  - ]:          2 :             nInitScrPos = GetSizePixel().Width() - 1;
     318                 :            :     }
     319                 :            : 
     320                 :            :     //  aeussere Linien komplett durchzeichnen
     321                 :            :     //  Zuerst Ende der letzten Zelle finden
     322                 :            : 
     323                 :        629 :     long nLineEnd = nInitScrPos - nLayoutSign;
     324                 :            : 
     325         [ +  - ]:      11529 :     for (SCCOLROW i=nPos; i<nSize; i++)
     326                 :            :     {
     327         [ +  - ]:      11529 :         sal_uInt16 nSizePix = GetEntrySize( i );
     328         [ +  + ]:      11529 :         if (nSizePix)
     329                 :            :         {
     330                 :      11524 :             nLineEnd += nSizePix * nLayoutSign;
     331                 :            : 
     332 [ +  + ][ +  + ]:      11524 :             if ( bMarkRange && i >= nMarkStart && i <= nMarkEnd )
                 [ +  + ]
     333                 :            :             {
     334                 :        652 :                 long nLineStart = nLineEnd - ( nSizePix - 1 ) * nLayoutSign;
     335         [ +  + ]:        652 :                 if ( nLineStart * nLayoutSign < nTransStart * nLayoutSign )
     336                 :        553 :                     nTransStart = nLineStart;
     337         [ +  - ]:        652 :                 if ( nLineEnd * nLayoutSign > nTransEnd * nLayoutSign )
     338                 :        652 :                     nTransEnd = nLineEnd;
     339                 :            :             }
     340                 :            : 
     341         [ +  + ]:      11524 :             if ( nLineEnd * nLayoutSign > nPEnd * nLayoutSign )
     342                 :            :             {
     343                 :        629 :                 nLineEnd = nPEnd;
     344                 :        629 :                 break;
     345                 :            :             }
     346                 :            :         }
     347                 :            :         else
     348                 :            :         {
     349         [ +  - ]:          5 :             SCCOLROW nHidden = GetHiddenCount(i);
     350         [ +  - ]:          5 :             if (nHidden > 0)
     351                 :          5 :                 i += nHidden - 1;
     352                 :            :         }
     353                 :            :     }
     354                 :            : 
     355                 :            :     //  background is different for entry area and behind the entries
     356                 :            : 
     357         [ +  - ]:        629 :     Rectangle aFillRect;
     358         [ +  - ]:        629 :     SetLineColor();
     359                 :            : 
     360         [ +  - ]:        629 :     if ( nLineEnd * nLayoutSign >= nInitScrPos * nLayoutSign )
     361                 :            :     {
     362         [ -  + ]:        629 :         if ( bHighContrast )
     363                 :            :         {
     364                 :            :             // high contrast: single-color background
     365         [ #  # ]:          0 :             SetFillColor( rStyleSettings.GetFaceColor() );
     366         [ #  # ]:          0 :             if ( bVertical )
     367         [ #  # ]:          0 :                 aFillRect = Rectangle( 0, nInitScrPos, nBarSize-1, nLineEnd );
     368                 :            :             else
     369         [ #  # ]:          0 :                 aFillRect = Rectangle( nInitScrPos, 0, nLineEnd, nBarSize-1 );
     370         [ #  # ]:          0 :             DrawRect( aFillRect );
     371                 :            :         }
     372                 :            :         else
     373                 :            :         {
     374                 :            :             // normal: 3-part background
     375         [ +  - ]:        629 :             DrawShadedRect( nInitScrPos, nLineEnd, rStyleSettings.GetFaceColor() );
     376                 :            :         }
     377                 :            :     }
     378                 :            : 
     379         [ -  + ]:        629 :     if ( nLineEnd * nLayoutSign < nPEnd * nLayoutSign )
     380                 :            :     {
     381 [ #  # ][ #  # ]:          0 :         SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::APPBACKGROUND).nColor );
         [ #  # ][ #  # ]
     382         [ #  # ]:          0 :         if ( bVertical )
     383         [ #  # ]:          0 :             aFillRect = Rectangle( 0, nLineEnd+nLayoutSign, nBarSize-1, nPEnd );
     384                 :            :         else
     385         [ #  # ]:          0 :             aFillRect = Rectangle( nLineEnd+nLayoutSign, 0, nPEnd, nBarSize-1 );
     386         [ #  # ]:          0 :         DrawRect( aFillRect );
     387                 :            :     }
     388                 :            : 
     389         [ +  - ]:        629 :     if ( nLineEnd * nLayoutSign >= nPStart * nLayoutSign )
     390                 :            :     {
     391         [ +  + ]:        629 :         if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign )
     392                 :            :         {
     393         [ -  + ]:        553 :             if ( bHighContrast )
     394                 :            :             {
     395         [ #  # ]:          0 :                 if ( bDark )
     396                 :            :                 {
     397                 :            :                     //  solid grey background for dark face color is drawn before lines
     398                 :            : 
     399         [ #  # ]:          0 :                     SetLineColor();
     400         [ #  # ]:          0 :                     SetFillColor( COL_LIGHTGRAY );
     401         [ #  # ]:          0 :                     if (bVertical)
     402 [ #  # ][ #  # ]:          0 :                         DrawRect( Rectangle( 0, nTransStart, nBarSize-1, nTransEnd ) );
     403                 :            :                     else
     404 [ #  # ][ #  # ]:          0 :                         DrawRect( Rectangle( nTransStart, 0, nTransEnd, nBarSize-1 ) );
     405                 :            :                 }
     406                 :            :             }
     407                 :            :             else
     408                 :            :             {
     409                 :            :                 // background for selection
     410                 :            : 
     411         [ +  - ]:        553 :                 DrawShadedRect( nTransStart, nTransEnd, rStyleSettings.GetHighlightColor() );
     412                 :            :             }
     413                 :            :         }
     414                 :            : 
     415         [ +  - ]:        629 :         SetLineColor( rStyleSettings.GetDarkShadowColor() );
     416         [ +  + ]:        629 :         if (bVertical)
     417                 :            :         {
     418         [ +  + ]:        356 :             long nDarkPos = bMirrored ? 0 : nBarSize-1;
     419         [ +  - ]:        356 :             DrawLine( Point( nDarkPos, nPStart ), Point( nDarkPos, nLineEnd ) );
     420                 :            :         }
     421                 :            :         else
     422         [ +  - ]:        273 :             DrawLine( Point( nPStart, nBarSize-1 ), Point( nLineEnd, nBarSize-1 ) );
     423                 :            : 
     424                 :            :         // line in different color for selection
     425 [ +  + ][ +  - ]:        629 :         if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign && !bHighContrast )
     426                 :            :         {
     427         [ +  - ]:        553 :             SetLineColor( aSelLineColor );
     428         [ +  + ]:        553 :             if (bVertical)
     429                 :            :             {
     430         [ +  + ]:        312 :                 long nDarkPos = bMirrored ? 0 : nBarSize-1;
     431         [ +  - ]:        312 :                 DrawLine( Point( nDarkPos, nTransStart ), Point( nDarkPos, nTransEnd ) );
     432                 :            :             }
     433                 :            :             else
     434         [ +  - ]:        241 :                 DrawLine( Point( nTransStart, nBarSize-1 ), Point( nTransEnd, nBarSize-1 ) );
     435                 :            :         }
     436                 :            :     }
     437                 :            : 
     438                 :            :     //
     439                 :            :     //  loop through entries several times to avoid changing the line color too often
     440                 :            :     //  and to allow merging of lines
     441                 :            :     //
     442                 :            : 
     443         [ +  - ]:        629 :     ScGridMerger aGrid( this, 1, 1 );
     444                 :            : 
     445                 :            :     //  start at SC_HDRPAINT_BOTTOM instead of 0 - selection doesn't get different
     446                 :            :     //  borders, light border at top isn't used anymore
     447                 :            :     //  use SC_HDRPAINT_SEL_BOTTOM for different color
     448                 :            : 
     449         [ +  + ]:       2516 :     for (sal_uInt16 nPass = SC_HDRPAINT_SEL_BOTTOM; nPass < SC_HDRPAINT_COUNT; nPass++)
     450                 :            :     {
     451                 :            :         //  set line color etc. before entry loop
     452   [ +  +  +  - ]:       1887 :         switch ( nPass )
     453                 :            :         {
     454                 :            :             case SC_HDRPAINT_SEL_BOTTOM:
     455                 :            :                 // same as non-selected for high contrast
     456 [ -  + ][ +  - ]:        629 :                 SetLineColor( bHighContrast ? rStyleSettings.GetDarkShadowColor() : aSelLineColor );
     457                 :        629 :                 break;
     458                 :            :             case SC_HDRPAINT_BOTTOM:
     459         [ +  - ]:        629 :                 SetLineColor( rStyleSettings.GetDarkShadowColor() );
     460                 :        629 :                 break;
     461                 :            :             case SC_HDRPAINT_TEXT:
     462                 :            :                 // DrawSelectionBackground is used only for high contrast on light background
     463 [ +  + ][ -  + ]:        629 :                 if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign && bHighContrast && !bDark )
                 [ #  # ]
     464                 :            :                 {
     465                 :            :                     //  Transparent selection background is drawn after lines, before text.
     466                 :            :                     //  Use DrawSelectionBackground to make sure there is a visible
     467                 :            :                     //  difference. The case of a dark face color, where DrawSelectionBackground
     468                 :            :                     //  would just paint over the lines, is handled separately (bDark).
     469                 :            :                     //  Otherwise, GetHighlightColor is used with 80% transparency.
     470                 :            :                     //  The window's background color (SetBackground) has to be the background
     471                 :            :                     //  of the cell area, for the contrast comparison in DrawSelectionBackground.
     472                 :            : 
     473         [ #  # ]:          0 :                     Rectangle aTransRect;
     474         [ #  # ]:          0 :                     if (bVertical)
     475         [ #  # ]:          0 :                         aTransRect = Rectangle( 0, nTransStart, nBarSize-1, nTransEnd );
     476                 :            :                     else
     477         [ #  # ]:          0 :                         aTransRect = Rectangle( nTransStart, 0, nTransEnd, nBarSize-1 );
     478 [ #  # ][ #  # ]:          0 :                     SetBackground( Color( rStyleSettings.GetFaceColor() ) );
                 [ #  # ]
     479         [ #  # ]:          0 :                     DrawSelectionBackground( aTransRect, 0, sal_True, false, false );
     480         [ #  # ]:          0 :                     SetBackground();
     481                 :            :                 }
     482                 :        629 :                 break;
     483                 :            :         }
     484                 :            : 
     485                 :       1887 :         SCCOLROW    nCount=0;
     486                 :       1887 :         long    nScrPos=nInitScrPos;
     487         [ +  + ]:      34560 :         do
     488                 :            :         {
     489         [ +  + ]:      34560 :             if (bVertical)
     490                 :      26565 :                 aScrPos = Point( 0, nScrPos );
     491                 :            :             else
     492                 :       7995 :                 aScrPos = Point( nScrPos, 0 );
     493                 :            : 
     494                 :      34560 :             SCCOLROW    nEntryNo = nCount + nPos;
     495         [ -  + ]:      34560 :             if ( nEntryNo >= nSize )                // MAXCOL/MAXROW
     496                 :          0 :                 nScrPos = nPEnd + nLayoutSign;      //  beyond nPEnd -> stop
     497                 :            :             else
     498                 :            :             {
     499         [ +  - ]:      34560 :                 sal_uInt16 nSizePix = GetEntrySize( nEntryNo );
     500                 :            : 
     501         [ +  + ]:      34560 :                 if (nSizePix == 0)
     502                 :            :                 {
     503         [ +  - ]:         15 :                     SCCOLROW nHidden = GetHiddenCount(nEntryNo);
     504         [ +  - ]:         15 :                     if (nHidden > 0)
     505                 :         15 :                         nCount += nHidden - 1;
     506                 :            :                 }
     507         [ +  + ]:      34545 :                 else if ((nScrPos+nSizePix*nLayoutSign)*nLayoutSign >= nPStart*nLayoutSign)
     508                 :            :                 {
     509                 :      34437 :                     Point aEndPos(aScrPos);
     510         [ +  + ]:      34437 :                     if (bVertical)
     511                 :      26442 :                         aEndPos = Point( aScrPos.X()+nBarSize-1, aScrPos.Y()+(nSizePix-1)*nLayoutSign );
     512                 :            :                     else
     513                 :       7995 :                         aEndPos = Point( aScrPos.X()+(nSizePix-1)*nLayoutSign, aScrPos.Y()+nBarSize-1 );
     514                 :            : 
     515 [ +  + ][ +  + ]:      34437 :                     sal_Bool bMark = bMarkRange && nEntryNo >= nMarkStart && nEntryNo <= nMarkEnd;
                 [ +  + ]
     516 [ +  + ][ +  + ]:      34437 :                     sal_Bool bNextToMark = bMarkRange && nEntryNo + 1 >= nMarkStart && nEntryNo <= nMarkEnd;
                 [ +  + ]
     517                 :            : 
     518      [ +  +  - ]:      34437 :                     switch ( nPass )
     519                 :            :                     {
     520                 :            :                         case SC_HDRPAINT_SEL_BOTTOM:
     521                 :            :                         case SC_HDRPAINT_BOTTOM:
     522 [ +  + ][ +  + ]:      22958 :                             if ( nPass == ( bNextToMark ? SC_HDRPAINT_SEL_BOTTOM : SC_HDRPAINT_BOTTOM ) )
     523                 :            :                             {
     524         [ +  + ]:      11479 :                                 if (bVertical)
     525         [ +  - ]:       8814 :                                     aGrid.AddHorLine( aScrPos.X(), aEndPos.X(), aEndPos.Y() );
     526                 :            :                                 else
     527         [ +  - ]:       2665 :                                     aGrid.AddVerLine( aEndPos.X(), aScrPos.Y(), aEndPos.Y() );
     528                 :            : 
     529                 :            :                                 //  thick bottom for hidden rows
     530                 :            :                                 //  (drawn directly, without aGrid)
     531         [ +  - ]:      11479 :                                 if ( nEntryNo+1 < nSize )
     532 [ +  - ][ +  + ]:      11479 :                                     if ( GetEntrySize(nEntryNo+1)==0 )
     533                 :            :                                     {
     534         [ +  - ]:          2 :                                         if (bVertical)
     535                 :          2 :                                             DrawLine( Point(aScrPos.X(),aEndPos.Y()-nLayoutSign),
     536         [ +  - ]:          4 :                                                       Point(aEndPos.X(),aEndPos.Y()-nLayoutSign) );
     537                 :            :                                         else
     538                 :          0 :                                             DrawLine( Point(aEndPos.X()-nLayoutSign,aScrPos.Y()),
     539         [ #  # ]:          0 :                                                       Point(aEndPos.X()-nLayoutSign,aEndPos.Y()) );
     540                 :            :                                     }
     541                 :            :                             }
     542                 :      22958 :                             break;
     543                 :            : 
     544                 :            :                         case SC_HDRPAINT_TEXT:
     545         [ +  - ]:      11479 :                             if ( nSizePix > 1 )     // minimal check for small columns/rows
     546                 :            :                             {
     547         [ +  + ]:      11479 :                                 if ( bMark != bBoldSet )
     548                 :            :                                 {
     549         [ +  + ]:        770 :                                     if (bMark)
     550         [ +  - ]:        184 :                                         SetFont(aBoldFont);
     551                 :            :                                     else
     552         [ +  - ]:        586 :                                         SetFont(aNormFont);
     553                 :        770 :                                     bBoldSet = bMark;
     554                 :            :                                 }
     555 [ +  - ][ +  - ]:      11479 :                                 aString = GetEntryText( nEntryNo );
                 [ +  - ]
     556         [ +  - ]:      11479 :                                 aTextSize.Width() = GetTextWidth( aString );
     557         [ +  - ]:      11479 :                                 aTextSize.Height() = GetTextHeight();
     558                 :            : 
     559                 :      11479 :                                 Point aTxtPos(aScrPos);
     560         [ +  + ]:      11479 :                                 if (bVertical)
     561                 :            :                                 {
     562                 :       8814 :                                     aTxtPos.X() += (nBarSize-aTextSize.Width())/2;
     563                 :       8814 :                                     aTxtPos.Y() += (nSizePix*nLayoutSign-aTextSize.Height())/2;
     564         [ +  + ]:       8814 :                                     if ( bMirrored )
     565                 :         54 :                                         aTxtPos.X() += 1;   // dark border is left instead of right
     566                 :            :                                 }
     567                 :            :                                 else
     568                 :            :                                 {
     569                 :       2665 :                                     aTxtPos.X() += (nSizePix*nLayoutSign-aTextSize.Width()+1)/2;
     570                 :       2665 :                                     aTxtPos.Y() += (nBarSize-aTextSize.Height())/2;
     571                 :            :                                 }
     572         [ +  - ]:      11479 :                                 DrawText( aTxtPos, aString );
     573                 :            :                             }
     574                 :      34437 :                             break;
     575                 :            :                     }
     576                 :            : 
     577                 :            :                     //  bei Selektion der ganzen Zeile/Spalte:
     578                 :            :                     //  InvertRect( Rectangle( aScrPos, aEndPos ) );
     579                 :            :                 }
     580                 :      34560 :                 nScrPos += nSizePix * nLayoutSign;      // also if before the visible area
     581                 :            :             }
     582                 :      34560 :             ++nCount;
     583                 :            :         }
     584                 :            :         while ( nScrPos * nLayoutSign <= nPEnd * nLayoutSign );
     585                 :            : 
     586         [ +  - ]:       1887 :         aGrid.Flush();
     587 [ +  - ][ +  - ]:        629 :     }
     588                 :        629 : }
     589                 :            : 
     590                 :            : //
     591                 :            : //      Maus - Handling
     592                 :            : //
     593                 :            : 
     594                 :          0 : SCCOLROW ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, sal_Bool& rBorder )
     595                 :            : {
     596                 :          0 :     sal_Bool    bFound=false;
     597                 :          0 :     SCCOLROW    nCount = 1;
     598         [ #  # ]:          0 :     SCCOLROW    nPos = GetPos();
     599                 :          0 :     SCCOLROW    nHitNo = nPos;
     600                 :            :     long    nScrPos;
     601         [ #  # ]:          0 :     long    nMousePos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
     602                 :            :     long    nDif;
     603                 :          0 :     Size    aSize = GetOutputSizePixel();
     604         [ #  # ]:          0 :     long    nWinSize = bVertical ? aSize.Height() : aSize.Width();
     605                 :            : 
     606         [ #  # ]:          0 :     sal_Bool bLayoutRTL = IsLayoutRTL();
     607         [ #  # ]:          0 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
     608         [ #  # ]:          0 :     long nEndPos = bLayoutRTL ? -1 : nWinSize;
     609                 :            : 
     610         [ #  # ]:          0 :     nScrPos = GetScrPos( nPos ) - nLayoutSign;
     611 [ #  # ][ #  # ]:          0 :     do
                 [ #  # ]
     612                 :            :     {
     613                 :          0 :         SCCOLROW nEntryNo = nCount + nPos;
     614                 :            : 
     615         [ #  # ]:          0 :         if (nEntryNo > nSize)
     616                 :          0 :             nScrPos = nEndPos + nLayoutSign;
     617                 :            :         else
     618         [ #  # ]:          0 :             nScrPos += GetEntrySize( nEntryNo - 1 ) * nLayoutSign;      //! GetHiddenCount() ??
     619                 :            : 
     620                 :          0 :         nDif = nMousePos - nScrPos;
     621 [ #  # ][ #  # ]:          0 :         if (nDif >= -2 && nDif <= 2 && nCount > 0)
                 [ #  # ]
     622                 :            :         {
     623                 :          0 :             bFound=sal_True;
     624                 :          0 :             nHitNo=nEntryNo-1;
     625                 :            :         }
     626 [ #  # ][ #  # ]:          0 :         else if (nDif * nLayoutSign >= 0 && nEntryNo < nSize)
     627                 :          0 :             nHitNo = nEntryNo;
     628                 :          0 :         ++nCount;
     629                 :            :     }
     630                 :            :     while ( nScrPos * nLayoutSign < nEndPos * nLayoutSign && nDif * nLayoutSign > 0 );
     631                 :            : 
     632                 :          0 :     rBorder = bFound;
     633                 :          0 :     return nHitNo;
     634                 :            : }
     635                 :            : 
     636                 :          0 : bool ScHeaderControl::IsSelectionAllowed(SCCOLROW nPos) const
     637                 :            : {
     638         [ #  # ]:          0 :     ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
     639         [ #  # ]:          0 :     if (!pViewSh)
     640                 :          0 :         return false;
     641                 :            : 
     642                 :          0 :     ScViewData* pViewData = pViewSh->GetViewData();
     643                 :          0 :     sal_uInt16 nTab = pViewData->GetTabNo();
     644                 :          0 :     ScDocument* pDoc = pViewData->GetDocument();
     645                 :          0 :     const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
     646                 :          0 :     bool bSelectAllowed = true;
     647 [ #  # ][ #  # ]:          0 :     if ( pProtect && pProtect->isProtected() )
                 [ #  # ]
     648                 :            :     {
     649                 :            :         // This sheet is protected.  Check if a context menu is allowed on this cell.
     650                 :          0 :         bool bCellsProtected = false;
     651         [ #  # ]:          0 :         if (bVertical)
     652                 :            :         {
     653                 :            :             // row header
     654                 :          0 :             SCROW nRPos = static_cast<SCROW>(nPos);
     655                 :          0 :             bCellsProtected = pDoc->HasAttrib(0, nRPos, nTab, MAXCOL, nRPos, nTab, HASATTR_PROTECTED);
     656                 :            :         }
     657                 :            :         else
     658                 :            :         {
     659                 :            :             // column header
     660                 :          0 :             SCCOL nCPos = static_cast<SCCOL>(nPos);
     661                 :          0 :             bCellsProtected = pDoc->HasAttrib(nCPos, 0, nTab, nCPos, MAXROW, nTab, HASATTR_PROTECTED);
     662                 :            :         }
     663                 :            : 
     664                 :          0 :         bool bSelProtected   = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
     665                 :          0 :         bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
     666                 :            : 
     667         [ #  # ]:          0 :         if (bCellsProtected)
     668                 :          0 :             bSelectAllowed = bSelProtected;
     669                 :            :         else
     670                 :          0 :             bSelectAllowed = bSelUnprotected;
     671                 :            :     }
     672                 :          0 :     return bSelectAllowed;
     673                 :            : }
     674                 :            : 
     675                 :          0 : void ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
     676                 :            : {
     677 [ #  # ][ #  # ]:          0 :     if (IsDisabled())
     678                 :            :         return;
     679                 :            : 
     680                 :          0 :     bIgnoreMove = false;
     681         [ #  # ]:          0 :     SelectWindow();
     682                 :            : 
     683                 :            :     sal_Bool bFound;
     684         [ #  # ]:          0 :     SCCOLROW nHitNo = GetMousePos( rMEvt, bFound );
     685 [ #  # ][ #  # ]:          0 :     if (!IsSelectionAllowed(nHitNo))
     686                 :            :         return;
     687                 :            : 
     688 [ #  # ][ #  # ]:          0 :     if ( bFound && rMEvt.IsLeft() && ResizeAllowed() )
         [ #  # ][ #  # ]
                 [ #  # ]
     689                 :            :     {
     690                 :          0 :         nDragNo = nHitNo;
     691                 :          0 :         sal_uInt16 nClicks = rMEvt.GetClicks();
     692 [ #  # ][ #  # ]:          0 :         if ( nClicks && nClicks%2==0 )
     693                 :            :         {
     694         [ #  # ]:          0 :             SetEntrySize( nDragNo, HDR_SIZE_OPTIMUM );
     695         [ #  # ]:          0 :             SetPointer( Pointer( POINTER_ARROW ) );
     696                 :            :         }
     697                 :            :         else
     698                 :            :         {
     699         [ #  # ]:          0 :             if (bVertical)
     700                 :          0 :                 nDragStart = rMEvt.GetPosPixel().Y();
     701                 :            :             else
     702                 :          0 :                 nDragStart = rMEvt.GetPosPixel().X();
     703                 :          0 :             nDragPos = nDragStart;
     704         [ #  # ]:          0 :             ShowDragHelp();
     705         [ #  # ]:          0 :             DrawInvert( nDragPos );
     706                 :            : 
     707         [ #  # ]:          0 :             StartTracking();
     708                 :          0 :             bDragging = sal_True;
     709                 :          0 :             bDragMoved = false;
     710                 :            :         }
     711                 :            :     }
     712         [ #  # ]:          0 :     else if (rMEvt.IsLeft())
     713                 :            :     {
     714         [ #  # ]:          0 :         pSelEngine->SetWindow( this );
     715                 :          0 :         Point aPoint;
     716         [ #  # ]:          0 :         Rectangle aVis( aPoint,GetOutputSizePixel() );
     717         [ #  # ]:          0 :         if (bVertical)
     718                 :          0 :             aVis.Left() = LONG_MIN, aVis.Right() = LONG_MAX;
     719                 :            :         else
     720                 :          0 :             aVis.Top() = LONG_MIN, aVis.Bottom() = LONG_MAX;
     721                 :          0 :         pSelEngine->SetVisibleArea( aVis );
     722                 :            : 
     723         [ #  # ]:          0 :         SetMarking( sal_True );     //  muss vor SelMouseButtonDown sein
     724         [ #  # ]:          0 :         pSelEngine->SelMouseButtonDown( rMEvt );
     725                 :            : 
     726                 :            :         //  In column/row headers a simple click already is a selection.
     727                 :            :         //  -> Call SelMouseMove to ensure CreateAnchor is called (and DestroyAnchor
     728                 :            :         //  if the next click is somewhere else with Control key).
     729         [ #  # ]:          0 :         pSelEngine->SelMouseMove( rMEvt );
     730                 :            : 
     731 [ #  # ][ #  # ]:          0 :         if (IsMouseCaptured())
     732                 :            :         {
     733                 :            :             //  Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
     734                 :            :             //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
     735         [ #  # ]:          0 :             ReleaseMouse();
     736         [ #  # ]:          0 :             StartTracking();
     737                 :            :         }
     738                 :            :     }
     739                 :            : }
     740                 :            : 
     741                 :          0 : void ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt )
     742                 :            : {
     743         [ #  # ]:          0 :     if ( IsDisabled() )
     744                 :          0 :         return;
     745                 :            : 
     746                 :          0 :     SetMarking( false );
     747                 :          0 :     bIgnoreMove = false;
     748                 :            : 
     749         [ #  # ]:          0 :     if ( bDragging )
     750                 :            :     {
     751                 :          0 :         DrawInvert( nDragPos );
     752                 :          0 :         ReleaseMouse();
     753                 :          0 :         bDragging   = false;
     754                 :            : 
     755                 :          0 :         long nScrPos    = GetScrPos( nDragNo );
     756         [ #  # ]:          0 :         long nMousePos  = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
     757                 :          0 :         sal_Bool bLayoutRTL = IsLayoutRTL();
     758                 :            :         long nNewWidth  = bLayoutRTL ? ( nScrPos - nMousePos + 1 )
     759         [ #  # ]:          0 :                                      : ( nMousePos + 2 - nScrPos );
     760                 :            : 
     761         [ #  # ]:          0 :         if ( nNewWidth < 0 /* && !IsSelected(nDragNo) */ )
     762                 :            :         {
     763                 :          0 :             SCCOLROW nStart = 0;
     764                 :          0 :             SCCOLROW nEnd = nDragNo;
     765         [ #  # ]:          0 :             while (nNewWidth < 0)
     766                 :            :             {
     767                 :          0 :                 nStart = nDragNo;
     768         [ #  # ]:          0 :                 if (nDragNo>0)
     769                 :            :                 {
     770                 :          0 :                     --nDragNo;
     771                 :          0 :                     nNewWidth += GetEntrySize( nDragNo );   //! GetHiddenCount() ???
     772                 :            :                 }
     773                 :            :                 else
     774                 :          0 :                     nNewWidth = 0;
     775                 :            :             }
     776                 :          0 :             HideEntries( nStart, nEnd );
     777                 :            :         }
     778                 :            :         else
     779                 :            :         {
     780         [ #  # ]:          0 :             if (nNewWidth<0) nNewWidth=0;
     781         [ #  # ]:          0 :             if (bDragMoved)
     782                 :          0 :                 SetEntrySize( nDragNo, (sal_uInt16) nNewWidth );
     783                 :            :         }
     784                 :            :     }
     785                 :            :     else
     786                 :            :     {
     787                 :          0 :         pSelEngine->SelMouseButtonUp( rMEvt );
     788                 :          0 :         ReleaseMouse();
     789                 :            :     }
     790                 :            : }
     791                 :            : 
     792                 :          0 : void ScHeaderControl::MouseMove( const MouseEvent& rMEvt )
     793                 :            : {
     794 [ #  # ][ #  # ]:          0 :     if ( IsDisabled() )
     795                 :            :     {
     796         [ #  # ]:          0 :         SetPointer( Pointer( POINTER_ARROW ) );
     797                 :          0 :         return;
     798                 :            :     }
     799                 :            : 
     800                 :            :     sal_Bool bFound;
     801         [ #  # ]:          0 :     (void)GetMousePos( rMEvt, bFound );
     802                 :            : 
     803         [ #  # ]:          0 :     if ( bDragging )
     804                 :            :     {
     805         [ #  # ]:          0 :         long nNewPos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
     806         [ #  # ]:          0 :         if ( nNewPos != nDragPos )
     807                 :            :         {
     808         [ #  # ]:          0 :             DrawInvert( nDragPos );
     809                 :          0 :             nDragPos = nNewPos;
     810         [ #  # ]:          0 :             ShowDragHelp();
     811         [ #  # ]:          0 :             DrawInvert( nDragPos );
     812                 :            : 
     813 [ #  # ][ #  # ]:          0 :             if (nDragPos <= nDragStart-SC_DRAG_MIN || nDragPos >= nDragStart+SC_DRAG_MIN)
     814                 :          0 :                 bDragMoved = sal_True;
     815                 :            :         }
     816                 :            :     }
     817                 :            :     else
     818                 :            :     {
     819 [ #  # ][ #  # ]:          0 :         if ( bFound && rMEvt.GetButtons()==0 && ResizeAllowed() )
         [ #  # ][ #  # ]
                 [ #  # ]
     820 [ #  # ][ #  # ]:          0 :             SetPointer( Pointer( bVertical ? POINTER_VSIZEBAR : POINTER_HSIZEBAR ) );
     821                 :            :         else
     822         [ #  # ]:          0 :             SetPointer( Pointer( POINTER_ARROW ) );
     823                 :            : 
     824         [ #  # ]:          0 :         if (!bIgnoreMove)
     825         [ #  # ]:          0 :             pSelEngine->SelMouseMove( rMEvt );
     826                 :            :     }
     827                 :            : }
     828                 :            : 
     829                 :          0 : void ScHeaderControl::Tracking( const TrackingEvent& rTEvt )
     830                 :            : {
     831                 :            :     //  Weil die SelectionEngine kein Tracking kennt, die Events nur auf
     832                 :            :     //  die verschiedenen MouseHandler verteilen...
     833                 :            : 
     834         [ #  # ]:          0 :     if ( rTEvt.IsTrackingCanceled() )
     835                 :          0 :         StopMarking();
     836         [ #  # ]:          0 :     else if ( rTEvt.IsTrackingEnded() )
     837                 :          0 :         MouseButtonUp( rTEvt.GetMouseEvent() );
     838                 :            :     else
     839                 :          0 :         MouseMove( rTEvt.GetMouseEvent() );
     840                 :          0 : }
     841                 :            : 
     842                 :          0 : void ScHeaderControl::Command( const CommandEvent& rCEvt )
     843                 :            : {
     844                 :          0 :     sal_uInt16 nCmd = rCEvt.GetCommand();
     845         [ #  # ]:          0 :     if ( nCmd == COMMAND_CONTEXTMENU )
     846                 :            :     {
     847                 :          0 :         StopMarking();      // Selektion / Dragging beenden
     848                 :            : 
     849                 :            :         //  Popup ausfuehren
     850                 :            : 
     851 [ #  # ][ #  # ]:          0 :         ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell,
     852                 :            :                                             SfxViewShell::Current() );
     853         [ #  # ]:          0 :         if ( pViewSh )
     854                 :            :         {
     855         [ #  # ]:          0 :             if ( rCEvt.IsMouseEvent() )
     856                 :            :             {
     857                 :            :                 // #i18735# select the column/row under the mouse pointer
     858                 :          0 :                 ScViewData* pViewData = pViewSh->GetViewData();
     859                 :            : 
     860         [ #  # ]:          0 :                 SelectWindow();     // also deselects drawing objects, stops draw text edit
     861         [ #  # ]:          0 :                 if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
     862 [ #  # ][ #  # ]:          0 :                     SC_MOD()->InputEnterHandler();  // always end edit mode
     863                 :            : 
     864         [ #  # ]:          0 :                 MouseEvent aMEvt( rCEvt.GetMousePosPixel() );
     865                 :            :                 sal_Bool bBorder;
     866         [ #  # ]:          0 :                 SCCOLROW nPos = GetMousePos( aMEvt, bBorder );
     867 [ #  # ][ #  # ]:          0 :                 if (!IsSelectionAllowed(nPos))
     868                 :            :                     // Selecting this cell is not allowed, neither is context menu.
     869                 :          0 :                     return;
     870                 :            : 
     871                 :          0 :                 SCTAB nTab = pViewData->GetTabNo();
     872                 :          0 :                 ScRange aNewRange;
     873         [ #  # ]:          0 :                 if ( bVertical )
     874                 :            :                     aNewRange = ScRange( 0, sal::static_int_cast<SCROW>(nPos), nTab,
     875                 :          0 :                                          MAXCOL, sal::static_int_cast<SCROW>(nPos), nTab );
     876                 :            :                 else
     877                 :          0 :                     aNewRange = ScRange( sal::static_int_cast<SCCOL>(nPos), 0, nTab,
     878                 :          0 :                                          sal::static_int_cast<SCCOL>(nPos), MAXROW, nTab );
     879                 :            : 
     880                 :            :                 // see if any part of the range is already selected
     881         [ #  # ]:          0 :                 ScRangeList aRanges;
     882 [ #  # ][ #  # ]:          0 :                 pViewData->GetMarkData().FillRangeListWithMarks( &aRanges, false );
     883         [ #  # ]:          0 :                 bool bSelected = aRanges.Intersects(aNewRange);
     884                 :            : 
     885                 :            :                 // select the range if no part of it was selected
     886         [ #  # ]:          0 :                 if ( !bSelected )
     887 [ #  # ][ #  # ]:          0 :                     pViewSh->MarkRange( aNewRange );
     888                 :            :             }
     889                 :            : 
     890 [ #  # ][ #  # ]:          0 :             ScResId aResId( bVertical ? RID_POPUP_ROWHEADER : RID_POPUP_COLHEADER );
     891 [ #  # ][ #  # ]:          0 :             pViewSh->GetDispatcher()->ExecutePopup( aResId );
     892                 :            :         }
     893                 :            :     }
     894         [ #  # ]:          0 :     else if ( nCmd == COMMAND_STARTDRAG )
     895                 :            :     {
     896                 :          0 :         pSelEngine->Command( rCEvt );
     897                 :            :     }
     898                 :            : }
     899                 :            : 
     900                 :        916 : void ScHeaderControl::StopMarking()
     901                 :            : {
     902         [ -  + ]:        916 :     if ( bDragging )
     903                 :            :     {
     904                 :          0 :         DrawInvert( nDragPos );
     905                 :          0 :         bDragging = false;
     906                 :            :     }
     907                 :            : 
     908                 :        916 :     SetMarking( false );
     909                 :        916 :     bIgnoreMove = sal_True;
     910                 :            : 
     911                 :            :     //  don't call pSelEngine->Reset, so selection across the parts of
     912                 :            :     //  a split/frozen view is possible
     913                 :            : 
     914                 :        916 :     ReleaseMouse();
     915                 :        916 : }
     916                 :            : 
     917                 :          0 : void ScHeaderControl::ShowDragHelp()
     918                 :            : {
     919         [ #  # ]:          0 :     if (Help::IsQuickHelpEnabled())
     920                 :            :     {
     921         [ #  # ]:          0 :         long nScrPos    = GetScrPos( nDragNo );
     922         [ #  # ]:          0 :         sal_Bool bLayoutRTL = IsLayoutRTL();
     923                 :            :         long nVal = bLayoutRTL ? ( nScrPos - nDragPos + 1 )
     924         [ #  # ]:          0 :                                : ( nDragPos + 2 - nScrPos );
     925                 :            : 
     926         [ #  # ]:          0 :         String aHelpStr = GetDragHelp( nVal );
     927         [ #  # ]:          0 :         Point aPos = OutputToScreenPixel( Point(0,0) );
     928         [ #  # ]:          0 :         Size aSize = GetSizePixel();
     929                 :            : 
     930 [ #  # ][ #  # ]:          0 :         Point aMousePos = OutputToScreenPixel(GetPointerPosPixel());
     931                 :            : 
     932         [ #  # ]:          0 :         Rectangle aRect;
     933                 :            :         sal_uInt16 nAlign;
     934         [ #  # ]:          0 :         if (!bVertical)
     935                 :            :         {
     936                 :            :             //  oberhalb
     937                 :          0 :             aRect.Left() = aMousePos.X();
     938                 :          0 :             aRect.Top()  = aPos.Y() - 4;
     939                 :          0 :             nAlign       = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
     940                 :            :         }
     941                 :            :         else
     942                 :            :         {
     943                 :            :             //  rechts oben
     944                 :          0 :             aRect.Left() = aPos.X() + aSize.Width() + 8;
     945                 :          0 :             aRect.Top()  = aMousePos.Y() - 2;
     946                 :          0 :             nAlign       = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
     947                 :            :         }
     948                 :            : 
     949                 :          0 :         aRect.Right()   = aRect.Left();
     950                 :          0 :         aRect.Bottom()  = aRect.Top();
     951                 :            : 
     952 [ #  # ][ #  # ]:          0 :         Help::ShowQuickHelp(this, aRect, aHelpStr, nAlign);
     953                 :            :     }
     954                 :          0 : }
     955                 :            : 
     956                 :          0 : void ScHeaderControl::RequestHelp( const HelpEvent& rHEvt )
     957                 :            : {
     958                 :            :     //  Wenn eigene QuickHelp angezeigt wird, nicht durch RequestHelp
     959                 :            :     //  wieder wegnehmen lassen
     960                 :            : 
     961 [ #  # ][ #  # ]:          0 :     sal_Bool bOwn = bDragging && Help::IsQuickHelpEnabled();
     962         [ #  # ]:          0 :     if (!bOwn)
     963                 :          0 :         Window::RequestHelp(rHEvt);
     964                 :          0 : }
     965                 :            : 
     966                 :            : // -----------------------------------------------------------------------
     967                 :            : //                  Dummys fuer virtuelle Methoden
     968                 :            : // -----------------------------------------------------------------------
     969                 :            : 
     970                 :          0 : SCCOLROW ScHeaderControl::GetHiddenCount( SCCOLROW nEntryNo )
     971                 :            : {
     972                 :          0 :     SCCOLROW nHidden = 0;
     973 [ #  # ][ #  # ]:          0 :     while ( nEntryNo < nSize && GetEntrySize( nEntryNo ) == 0 )
                 [ #  # ]
     974                 :            :     {
     975                 :          0 :         ++nEntryNo;
     976                 :          0 :         ++nHidden;
     977                 :            :     }
     978                 :          0 :     return nHidden;
     979                 :            : }
     980                 :            : 
     981                 :       1169 : sal_Bool ScHeaderControl::IsLayoutRTL()
     982                 :            : {
     983                 :       1169 :     return false;
     984                 :            : }
     985                 :            : 
     986                 :        787 : sal_Bool ScHeaderControl::IsMirrored()
     987                 :            : {
     988                 :        787 :     return false;
     989                 :            : }
     990                 :            : 
     991                 :          0 : sal_Bool ScHeaderControl::IsDisabled()
     992                 :            : {
     993                 :          0 :     return false;
     994                 :            : }
     995                 :            : 
     996                 :          0 : sal_Bool ScHeaderControl::ResizeAllowed()
     997                 :            : {
     998                 :          0 :     return sal_True;
     999                 :            : }
    1000                 :            : 
    1001                 :          0 : void ScHeaderControl::SelectWindow()
    1002                 :            : {
    1003                 :          0 : }
    1004                 :            : 
    1005                 :          0 : void ScHeaderControl::DrawInvert( long /* nDragPos */ )
    1006                 :            : {
    1007                 :          0 : }
    1008                 :            : 
    1009                 :          0 : String ScHeaderControl::GetDragHelp( long /* nVal */ )
    1010                 :            : {
    1011                 :          0 :     return EMPTY_STRING;
    1012                 :            : }
    1013                 :            : 
    1014                 :          0 : void ScHeaderControl::SetMarking( sal_Bool /* bSet */ )
    1015                 :            : {
    1016                 :          0 : }
    1017                 :            : 
    1018                 :            : 
    1019                 :            : 
    1020                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10