LCOV - code coverage report
Current view: top level - vcl/source/window - toolbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1109 2796 39.7 %
Date: 2012-08-25 Functions: 63 113 55.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1025 3978 25.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                 :            : 
      30                 :            : #include <rtl/logfile.hxx>
      31                 :            : 
      32                 :            : #include <tools/debug.hxx>
      33                 :            : #include <tools/rc.h>
      34                 :            : #include <tools/poly.hxx>
      35                 :            : 
      36                 :            : #include <vcl/event.hxx>
      37                 :            : #include <vcl/decoview.hxx>
      38                 :            : #include <vcl/accel.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : #include <vcl/help.hxx>
      41                 :            : #include <vcl/spin.h>
      42                 :            : #include <vcl/toolbox.hxx>
      43                 :            : #include <vcl/bitmap.hxx>
      44                 :            : #include <vcl/mnemonic.hxx>
      45                 :            : #include <vcl/gradient.hxx>
      46                 :            : #include <vcl/menu.hxx>
      47                 :            : 
      48                 :            : #include <svdata.hxx>
      49                 :            : #include <window.h>
      50                 :            : #include <toolbox.h>
      51                 :            : #include <salframe.hxx>
      52                 :            : #if defined WNT
      53                 :            : #include <svsys.h>
      54                 :            : #endif
      55                 :            : 
      56                 :            : #include <string.h>
      57                 :            : #include <vector>
      58                 :            : #include <math.h>
      59                 :            : 
      60                 :            : // =======================================================================
      61                 :            : 
      62                 :            : DBG_NAMEEX( Window )
      63                 :            : 
      64                 :            : // =======================================================================
      65                 :            : 
      66                 :            : #define SMALLBUTTON_HSIZE           7
      67                 :            : #define SMALLBUTTON_VSIZE           7
      68                 :            : 
      69                 :            : #define SMALLBUTTON_OFF_NORMAL_X    3
      70                 :            : #define SMALLBUTTON_OFF_NORMAL_Y    3
      71                 :            : 
      72                 :            : // -----------------------------------------------------------------------
      73                 :            : 
      74                 :            : #define TB_TEXTOFFSET           2
      75                 :            : #define TB_IMAGETEXTOFFSET      3
      76                 :            : #define TB_LINESPACING          3
      77                 :            : #define TB_SPIN_SIZE            14
      78                 :            : #define TB_SPIN_OFFSET          2
      79                 :            : #define TB_BORDER_OFFSET1       4
      80                 :            : #define TB_BORDER_OFFSET2       2
      81                 :            : #define TB_CUSTOMIZE_OFFSET     2
      82                 :            : #define TB_RESIZE_OFFSET        3
      83                 :            : #define TB_MAXLINES             5
      84                 :            : #define TB_MAXNOSCROLL          32765
      85                 :            : 
      86                 :            : #define TB_MIN_WIN_WIDTH        20
      87                 :            : 
      88                 :            : #define TB_CALCMODE_HORZ        1
      89                 :            : #define TB_CALCMODE_VERT        2
      90                 :            : #define TB_CALCMODE_FLOAT       3
      91                 :            : 
      92                 :            : #define TB_WBLINESIZING         (WB_SIZEABLE | WB_DOCKABLE | WB_SCROLL)
      93                 :            : 
      94                 :            : #define DOCK_LINEHSIZE          ((sal_uInt16)0x0001)
      95                 :            : #define DOCK_LINEVSIZE          ((sal_uInt16)0x0002)
      96                 :            : #define DOCK_LINERIGHT          ((sal_uInt16)0x1000)
      97                 :            : #define DOCK_LINEBOTTOM         ((sal_uInt16)0x2000)
      98                 :            : #define DOCK_LINELEFT           ((sal_uInt16)0x4000)
      99                 :            : #define DOCK_LINETOP            ((sal_uInt16)0x8000)
     100                 :            : #define DOCK_LINEOFFSET         3
     101                 :            : 
     102                 :            : 
     103                 :            : // -----------------------------------------------------------------------
     104                 :            : static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bEnabled, sal_Bool bIsWindow );
     105                 :            : // -----------------------------------------------------------------------
     106                 :            : 
     107                 :            : typedef ::std::vector< ToolBox* > ImplTBList;
     108                 :            : 
     109                 :            : class ImplTBDragMgr
     110                 :            : {
     111                 :            : private:
     112                 :            :     ImplTBList*     mpBoxList;
     113                 :            :     ToolBox*        mpDragBox;
     114                 :            :     Point           maMouseOff;
     115                 :            :     Rectangle       maRect;
     116                 :            :     Rectangle       maStartRect;
     117                 :            :     Accelerator     maAccel;
     118                 :            :     long            mnMinWidth;
     119                 :            :     long            mnMaxWidth;
     120                 :            :     sal_uInt16          mnLineMode;
     121                 :            :     sal_uInt16          mnStartLines;
     122                 :            :     void*           mpCustomizeData;
     123                 :            :     sal_Bool            mbCustomizeMode;
     124                 :            :     sal_Bool            mbResizeMode;
     125                 :            :     sal_Bool            mbShowDragRect;
     126                 :            : 
     127                 :            : public:
     128                 :            :                     ImplTBDragMgr();
     129                 :            :                     ~ImplTBDragMgr();
     130                 :            : 
     131                 :       3709 :     void            push_back( ToolBox* pBox )
     132                 :       3709 :                         { mpBoxList->push_back( pBox ); }
     133                 :       3527 :     void            erase( ToolBox* pBox )
     134                 :            :                     {
     135 [ +  - ][ +  - ]:       8416 :                         for ( ImplTBList::iterator it = mpBoxList->begin(); it != mpBoxList->end(); ++it ) {
                 [ +  - ]
     136 [ +  - ][ +  + ]:       8416 :                             if ( *it == pBox ) {
     137         [ +  - ]:       3527 :                                 mpBoxList->erase( it );
     138                 :       3527 :                                 break;
     139                 :            :                             }
     140                 :            :                         }
     141                 :       3527 :                     }
     142                 :       8539 :     size_t          size() const
     143                 :       8539 :                     { return mpBoxList->size(); }
     144                 :            : 
     145                 :            :     ToolBox*        FindToolBox( const Rectangle& rRect );
     146                 :            : 
     147                 :            :     void            StartDragging( ToolBox* pDragBox,
     148                 :            :                                    const Point& rPos, const Rectangle& rRect,
     149                 :            :                                    sal_uInt16 nLineMode, sal_Bool bResizeItem,
     150                 :            :                                    void* pData = NULL );
     151                 :            :     void            Dragging( const Point& rPos );
     152                 :            :     void            EndDragging( sal_Bool bOK = sal_True );
     153         [ #  # ]:          0 :     void            HideDragRect() { if ( mbShowDragRect ) mpDragBox->HideTracking(); }
     154                 :            :     void            UpdateDragRect();
     155                 :            :                     DECL_LINK( SelectHdl, Accelerator* );
     156                 :            : 
     157                 :            :     sal_Bool            IsCustomizeMode() { return mbCustomizeMode; }
     158                 :            :     sal_Bool            IsResizeMode() { return mbResizeMode; }
     159                 :            : };
     160                 :            : 
     161                 :            : // -----------------------------------------------------------------------
     162                 :            : 
     163                 :       3709 : static ImplTBDragMgr* ImplGetTBDragMgr()
     164                 :            : {
     165                 :       3709 :     ImplSVData* pSVData = ImplGetSVData();
     166         [ +  + ]:       3709 :     if ( !pSVData->maCtrlData.mpTBDragMgr )
     167         [ +  - ]:       1466 :         pSVData->maCtrlData.mpTBDragMgr = new ImplTBDragMgr;
     168                 :       3709 :     return pSVData->maCtrlData.mpTBDragMgr;
     169                 :            : }
     170                 :            : 
     171                 :            : // -----------------------------------------------------------------------
     172                 :            : 
     173                 :     188921 : int ToolBox::ImplGetDragWidth( ToolBox* pThis )
     174                 :            : {
     175                 :            :     #define TB_DRAGWIDTH 8  // the default width of the grip
     176                 :            : 
     177                 :     188921 :     int width = TB_DRAGWIDTH;
     178         [ -  + ]:     188921 :     if( pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
     179                 :            :     {
     180                 :            : 
     181                 :          0 :         ImplControlValue aControlValue;
     182                 :          0 :         Point aPoint;
     183 [ #  # ][ #  # ]:          0 :         Rectangle aContent, aBound;
     184 [ #  # ][ #  # ]:          0 :         Rectangle aArea( aPoint, pThis->GetOutputSizePixel() );
     185                 :            : 
     186         [ #  # ]:          0 :         if ( pThis->GetNativeControlRegion(CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_VERT : PART_THUMB_HORZ,
     187 [ #  # ][ #  # ]:          0 :                 aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
     188                 :            :         {
     189 [ #  # ][ #  # ]:          0 :             width = pThis->mbHorz ? aContent.GetWidth() : aContent.GetHeight();
                 [ #  # ]
     190         [ #  # ]:          0 :         }
     191                 :            :     }
     192                 :     188921 :     return width;
     193                 :            : }
     194                 :            : 
     195                 :     190671 : ButtonType determineButtonType( ImplToolItem* pItem, ButtonType defaultType )
     196                 :            : {
     197                 :     190671 :     ButtonType tmpButtonType = defaultType;
     198                 :     190671 :     ToolBoxItemBits nBits( pItem->mnBits & 0x300 );
     199         [ -  + ]:     190671 :     if ( nBits & TIB_TEXTICON ) // item has custom setting
     200                 :            :     {
     201                 :          0 :         tmpButtonType = BUTTON_SYMBOLTEXT;
     202         [ #  # ]:          0 :         if ( nBits == TIB_TEXT_ONLY )
     203                 :          0 :             tmpButtonType = BUTTON_TEXT;
     204         [ #  # ]:          0 :         else if ( nBits == TIB_ICON_ONLY )
     205                 :          0 :             tmpButtonType = BUTTON_SYMBOL;
     206                 :            :     }
     207                 :     190671 :     return tmpButtonType;
     208                 :            : }
     209                 :            : 
     210                 :            : // -----------------------------------------------------------------------
     211                 :            : 
     212                 :       6508 : void ToolBox::ImplUpdateDragArea( ToolBox *pThis )
     213                 :            : {
     214                 :       6508 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis );
     215         [ +  + ]:       6508 :     if( pWrapper )
     216                 :            :     {
     217 [ +  - ][ -  + ]:       4063 :         if ( pThis->ImplIsFloatingMode() || pWrapper->IsLocked() )
                 [ -  + ]
     218         [ #  # ]:          0 :             pWrapper->SetDragArea( Rectangle() );
     219                 :            :         else
     220                 :            :         {
     221 [ +  + ][ +  - ]:       4063 :             if( pThis->meAlign == WINDOWALIGN_TOP || pThis->meAlign == WINDOWALIGN_BOTTOM )
     222 [ +  - ][ +  - ]:       4063 :                 pWrapper->SetDragArea( Rectangle( 0, 0, ImplGetDragWidth( pThis ), pThis->GetOutputSizePixel().Height() ) );
                 [ +  - ]
     223                 :            :             else
     224 [ #  # ][ #  # ]:       4063 :                 pWrapper->SetDragArea( Rectangle( 0, 0, pThis->GetOutputSizePixel().Width(), ImplGetDragWidth( pThis ) ) );
     225                 :            :         }
     226                 :            :     }
     227                 :       6508 : }
     228                 :            : 
     229                 :            : // -----------------------------------------------------------------------
     230                 :            : 
     231                 :     157139 : void ToolBox::ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop,
     232                 :            :                               long& rRight, long& rBottom, const ToolBox *pThis )
     233                 :            : {
     234 [ +  - ][ +  + ]:     157139 :     if( pThis->ImplIsFloatingMode() || !(pThis->mnWinStyle & WB_BORDER) )
                 [ +  + ]
     235                 :            :     {
     236                 :            :         // no border in floating mode
     237                 :       9187 :         rLeft = rTop = rRight = rBottom = 0;
     238                 :     157139 :         return;
     239                 :            :     }
     240                 :            : 
     241                 :     147952 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis );
     242                 :            : 
     243                 :            :     // reserve dragarea only for dockable toolbars
     244 [ +  - ][ +  + ]:     147952 :     int    dragwidth = ( pWrapper && !pWrapper->IsLocked() ) ? ImplGetDragWidth( (ToolBox*)pThis ) : 0;
     245                 :            : 
     246                 :            :     // no shadow border for dockable toolbars
     247         [ +  + ]:     147952 :     int    borderwidth = pWrapper ? 0: 2;
     248                 :            : 
     249         [ +  + ]:     147952 :     if ( eAlign == WINDOWALIGN_TOP )
     250                 :            :     {
     251                 :     134828 :         rLeft   = borderwidth+dragwidth;
     252                 :     134828 :         rTop    = borderwidth;
     253                 :     134828 :         rRight  = borderwidth;
     254                 :     134828 :         rBottom = 0;
     255                 :            :     }
     256         [ -  + ]:      13124 :     else if ( eAlign == WINDOWALIGN_LEFT )
     257                 :            :     {
     258                 :          0 :         rLeft   = borderwidth;
     259                 :          0 :         rTop    = borderwidth+dragwidth;
     260                 :          0 :         rRight  = 0;
     261                 :          0 :         rBottom = borderwidth;
     262                 :            :     }
     263         [ +  - ]:      13124 :     else if ( eAlign == WINDOWALIGN_BOTTOM )
     264                 :            :     {
     265                 :      13124 :         rLeft   = borderwidth+dragwidth;
     266                 :      13124 :         rTop    = 0;
     267                 :      13124 :         rRight  = borderwidth;
     268                 :      13124 :         rBottom = borderwidth;
     269                 :            :     }
     270                 :            :     else
     271                 :            :     {
     272                 :          0 :         rLeft   = 0;
     273                 :          0 :         rTop    = borderwidth+dragwidth;
     274                 :          0 :         rRight  = borderwidth;
     275                 :          0 :         rBottom = borderwidth;
     276                 :            :     }
     277                 :            : }
     278                 :            : 
     279                 :            : // -----------------------------------------------------------------------
     280                 :            : 
     281                 :     284068 : static void ImplCheckUpdate( ToolBox *pThis )
     282                 :            : {
     283                 :            :     // remove any pending invalidates to avoid
     284                 :            :     // have them triggered when paint is locked (see mpData->mbIsPaintLocked)
     285                 :            :     // which would result in erasing the background only and not painting any items
     286                 :            :     // this must not be done when we're already in Paint()
     287                 :            : 
     288                 :            :     // this is only required for transparent toolbars (see ImplDrawTransparentBackground() )
     289 [ +  + ][ +  + ]:     284068 :     if( !pThis->IsBackground() && pThis->HasPaintEvent() && !pThis->IsInPaint() )
         [ -  + ][ -  + ]
     290                 :          0 :         pThis->Update();
     291                 :     284068 : }
     292                 :            : 
     293                 :            : // -----------------------------------------------------------------------
     294                 :            : 
     295                 :      10776 : void ToolBox::ImplDrawGrip( ToolBox* pThis )
     296                 :            : {
     297                 :      10776 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis );
     298 [ +  - ][ +  - ]:      10776 :     if( pWrapper && !pWrapper->GetDragArea().IsEmpty() )
         [ +  - ][ +  + ]
           [ +  +  #  # ]
                 [ +  + ]
     299                 :            :     {
     300                 :            :         // execute pending paint requests
     301         [ +  - ]:       8123 :         ImplCheckUpdate( pThis );
     302                 :            : 
     303                 :       8123 :         sal_Bool bNativeOk = sal_False;
     304 [ +  - ][ +  - ]:       8123 :         if( pThis->IsNativeControlSupported( CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_HORZ : PART_THUMB_VERT ) )
                 [ -  + ]
     305                 :            :         {
     306         [ #  # ]:          0 :             ToolbarValue        aToolbarValue;
     307         [ #  # ]:          0 :             aToolbarValue.maGripRect = pWrapper->GetDragArea();
     308                 :          0 :             Point aPt;
     309 [ #  # ][ #  # ]:          0 :             Rectangle           aCtrlRegion( aPt, pThis->GetOutputSizePixel() );
     310                 :          0 :             ControlState        nState = CTRL_STATE_ENABLED;
     311                 :            : 
     312                 :            :             bNativeOk = pThis->DrawNativeControl( CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_VERT : PART_THUMB_HORZ,
     313 [ #  # ][ #  # ]:          0 :                                             aCtrlRegion, nState, aToolbarValue, rtl::OUString() );
                 [ #  # ]
     314                 :            :         }
     315                 :            : 
     316         [ +  - ]:       8123 :         if( bNativeOk )
     317                 :      10776 :             return;
     318                 :            : 
     319                 :       8123 :         const StyleSettings&    rStyleSettings = pThis->GetSettings().GetStyleSettings();
     320         [ +  - ]:       8123 :         pThis->SetLineColor( rStyleSettings.GetShadowColor() );
     321                 :            : 
     322         [ +  - ]:       8123 :         Size aSz ( pThis->GetOutputSizePixel() );
     323                 :            : 
     324 [ +  + ][ +  - ]:       8123 :         if ( pThis->meAlign == WINDOWALIGN_TOP || pThis->meAlign == WINDOWALIGN_BOTTOM )
     325                 :            :         {
     326                 :       8123 :             int height = (int) (0.6 * aSz.Height() + 0.5);
     327                 :       8123 :             int i = (aSz.Height() - height) / 2;
     328                 :       8123 :             height += i;
     329         [ +  + ]:      48738 :             while( i <= height )
     330                 :            :             {
     331         [ +  - ]:      40615 :                 int x = ImplGetDragWidth( pThis ) / 2;
     332                 :            : 
     333         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x, i), rStyleSettings.GetDarkShadowColor() );
     334         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x+1, i), rStyleSettings.GetShadowColor() );
     335                 :            : 
     336         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x, i+1), rStyleSettings.GetShadowColor() );
     337         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x+1, i+1), rStyleSettings.GetFaceColor() );
     338         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x+2, i+1), Color(COL_WHITE) );
     339                 :            : 
     340         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x+1, i+2), Color(COL_WHITE) );
     341         [ +  - ]:      40615 :                 pThis->DrawPixel( Point(x+2, i+2), Color(COL_WHITE) );
     342                 :      40615 :                 i+=4;
     343                 :       8123 :             }
     344                 :            :         }
     345                 :            :         else
     346                 :            :         {
     347                 :          0 :             int width = (int) (0.6 * aSz.Width() + 0.5);
     348                 :          0 :             int i = (aSz.Width() - width) / 2;
     349                 :          0 :             width += i;
     350         [ #  # ]:       8123 :             while( i <= width )
     351                 :            :             {
     352         [ #  # ]:          0 :                 int y = ImplGetDragWidth(pThis) / 2;
     353                 :            : 
     354         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i, y), rStyleSettings.GetDarkShadowColor() );
     355         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i+1, y), rStyleSettings.GetShadowColor() );
     356                 :            : 
     357         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i, y+1), rStyleSettings.GetShadowColor() );
     358         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i+1, y+1), rStyleSettings.GetFaceColor() );
     359         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i+2, y+1), Color(COL_WHITE) );
     360                 :            : 
     361         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i+1, y+2), Color(COL_WHITE) );
     362         [ #  # ]:          0 :                 pThis->DrawPixel( Point(i+2, y+2), Color(COL_WHITE) );
     363                 :          0 :                 i+=4;
     364                 :            :             }
     365                 :            :         }
     366                 :            :     }
     367                 :            : }
     368                 :            : 
     369                 :     125653 : void ToolBox::ImplDrawGradientBackground( ToolBox* pThis, ImplDockingWindowWrapper * )
     370                 :            : {
     371                 :            :     // draw a nice gradient
     372                 :            : 
     373                 :     125653 :     Color startCol, endCol;
     374         [ +  - ]:     125653 :     startCol = pThis->GetSettings().GetStyleSettings().GetFaceGradientColor();
     375                 :     125653 :     endCol = pThis->GetSettings().GetStyleSettings().GetFaceColor();
     376         [ -  + ]:     125653 :     if( pThis->GetSettings().GetStyleSettings().GetHighContrastMode() )
     377                 :            :         // no 'extreme' gradient when high contrast
     378                 :          0 :         startCol = endCol;
     379                 :            : 
     380         [ +  - ]:     125653 :     Gradient g;
     381 [ +  - ][ +  - ]:     125653 :     g.SetAngle( pThis->mbHorz ? 0 : 900 );
     382         [ +  - ]:     125653 :     g.SetStyle( GradientStyle_LINEAR );
     383                 :            : 
     384         [ +  - ]:     125653 :     g.SetStartColor( startCol );
     385         [ +  - ]:     125653 :     g.SetEndColor( endCol );
     386                 :            : 
     387                 :     125653 :     sal_Bool bLineColor = pThis->IsLineColor();
     388                 :     125653 :     Color aOldCol = pThis->GetLineColor();
     389         [ +  - ]:     125653 :     pThis->SetLineColor( pThis->GetSettings().GetStyleSettings().GetShadowColor() );
     390                 :            : 
     391         [ +  - ]:     125653 :     Size aFullSz( pThis->GetOutputSizePixel() );
     392                 :     125653 :     Size aLineSz( aFullSz );
     393                 :            : 
     394                 :            :     // use the linesize only when floating
     395                 :            :     // full window height is used when docked (single line)
     396 [ +  - ][ -  + ]:     125653 :     if( pThis->ImplIsFloatingMode() )
     397                 :            :     {
     398                 :            :         long nLineSize;
     399         [ #  # ]:          0 :         if( pThis->mbHorz )
     400                 :            :         {
     401                 :          0 :             nLineSize = pThis->mnMaxItemHeight;
     402         [ #  # ]:          0 :             if ( pThis->mnWinHeight > pThis->mnMaxItemHeight )
     403                 :          0 :                 nLineSize = pThis->mnWinHeight;
     404                 :            : 
     405                 :          0 :             aLineSz.Height() = nLineSize;
     406                 :            :         }
     407                 :            :         else
     408                 :            :         {
     409                 :          0 :             nLineSize = pThis->mnMaxItemWidth;
     410                 :          0 :             aLineSz.Width() = nLineSize;
     411                 :            :         }
     412                 :            :     }
     413                 :            : 
     414                 :            :     long nLeft, nTop, nRight, nBottom;
     415         [ +  - ]:     125653 :     ImplCalcBorder( pThis->meAlign, nLeft, nTop, nRight, nBottom, pThis );
     416                 :            : 
     417                 :     125653 :     Size aTopLineSz( aLineSz );
     418                 :     125653 :     Size aBottomLineSz( aLineSz );
     419                 :            : 
     420         [ +  - ]:     125653 :     if ( pThis->mnWinStyle & WB_BORDER )
     421                 :            :     {
     422         [ +  - ]:     125653 :         if( pThis->mbHorz )
     423                 :            :         {
     424                 :     125653 :             aTopLineSz.Height() += TB_BORDER_OFFSET2 + nTop;
     425                 :     125653 :             aBottomLineSz.Height() += TB_BORDER_OFFSET2 + nBottom;
     426                 :            : 
     427         [ +  - ]:     125653 :             if( pThis->mnCurLines == 1 )
     428                 :     125653 :                 aTopLineSz.Height() += TB_BORDER_OFFSET2 + nBottom;
     429                 :            :         }
     430                 :            :         else
     431                 :            :         {
     432                 :          0 :             aTopLineSz.Width() += TB_BORDER_OFFSET1 + nLeft;
     433                 :          0 :             aBottomLineSz.Width() += TB_BORDER_OFFSET1 + nRight;
     434                 :            : 
     435         [ #  # ]:          0 :             if( pThis->mnCurLines == 1 )
     436                 :          0 :                 aTopLineSz.Width() += TB_BORDER_OFFSET1 + nLeft;
     437                 :            :         }
     438                 :            :     }
     439                 :            : 
     440         [ +  - ]:     125653 :     if ( pThis->mnWinStyle & WB_LINESPACING )
     441                 :            :     {
     442         [ +  - ]:     125653 :         if( pThis->mbHorz )
     443                 :            :         {
     444                 :     125653 :             aLineSz.Height() += TB_LINESPACING;
     445         [ -  + ]:     125653 :             if( pThis->mnCurLines > 1 )
     446                 :          0 :                 aTopLineSz.Height() += TB_LINESPACING;
     447                 :            :         }
     448                 :            :         else
     449                 :            :         {
     450                 :          0 :             aLineSz.Width() += TB_LINESPACING;
     451         [ #  # ]:          0 :             if( pThis->mnCurLines > 1 )
     452                 :          0 :                 aTopLineSz.Width() += TB_LINESPACING;
     453                 :            :         }
     454                 :            :     }
     455                 :            : 
     456         [ +  - ]:     125653 :     if( pThis->mbHorz )
     457                 :            :     {
     458                 :     125653 :         long y = 0;
     459                 :     125653 :         sal_Bool bDrawSep = sal_False; // pThis->ImplIsFloatingMode() && ( pThis->mnWinStyle & WB_LINESPACING );
     460                 :            : 
     461 [ +  - ][ +  - ]:     125653 :         pThis->DrawGradient( Rectangle( 0, y, aTopLineSz.Width(), y+aTopLineSz.Height()), g );
     462                 :     125653 :         y += aTopLineSz.Height();
     463                 :            : 
     464         [ -  + ]:     125653 :         if ( bDrawSep )
     465         [ #  # ]:          0 :             pThis->DrawLine( Point(0, y-2), Point(aTopLineSz.Width(), y-2) );
     466                 :            : 
     467         [ -  + ]:     125653 :         while( y < (pThis->mnDY - aBottomLineSz.Height()) )
     468                 :            :         {
     469 [ #  # ][ #  # ]:          0 :             pThis->DrawGradient( Rectangle( 0, y, aLineSz.Width(), y+aLineSz.Height()), g);
     470                 :          0 :             y += aLineSz.Height();
     471                 :            : 
     472         [ #  # ]:          0 :             if ( bDrawSep )
     473         [ #  # ]:          0 :                 pThis->DrawLine( Point(0, y-2), Point(aLineSz.Width(), y-2) );
     474                 :            :         }
     475                 :            : 
     476 [ +  - ][ +  - ]:     125653 :         pThis->DrawGradient( Rectangle( 0, y, aBottomLineSz.Width(), y+aBottomLineSz.Height()), g );
     477         [ -  + ]:     125653 :         if ( bDrawSep )
     478         [ #  # ]:          0 :             pThis->DrawLine( Point(0, y-2), Point(aBottomLineSz.Width(), y-2) );
     479                 :            :     }
     480                 :            :     else
     481                 :            :     {
     482                 :          0 :         long x = 0;
     483                 :            : 
     484 [ #  # ][ #  # ]:          0 :         pThis->DrawGradient( Rectangle( x, 0, x+aTopLineSz.Width(), aTopLineSz.Height()), g );
     485                 :          0 :         x += aTopLineSz.Width();
     486                 :            : 
     487         [ #  # ]:          0 :         while( x < (pThis->mnDX - aBottomLineSz.Width()) )
     488                 :            :         {
     489 [ #  # ][ #  # ]:          0 :             pThis->DrawGradient( Rectangle( x, 0, x+aLineSz.Width(), aLineSz.Height()), g);
     490                 :          0 :             x += aLineSz.Width();
     491                 :            :         }
     492                 :            : 
     493 [ #  # ][ #  # ]:          0 :         pThis->DrawGradient( Rectangle( x, 0, x+aBottomLineSz.Width(), aBottomLineSz.Height()), g );
     494                 :            :     }
     495                 :            : 
     496         [ +  - ]:     125653 :     if( bLineColor )
     497 [ +  - ][ +  - ]:     125653 :         pThis->SetLineColor( aOldCol );
     498                 :            : 
     499                 :     125653 : }
     500                 :            : 
     501                 :          0 : sal_Bool ToolBox::ImplDrawNativeBackground( ToolBox* pThis, const Region & )
     502                 :            : {
     503                 :            :     // use NWF
     504                 :          0 :     Point aPt;
     505 [ #  # ][ #  # ]:          0 :     Rectangle aCtrlRegion( aPt, pThis->GetOutputSizePixel() );
     506                 :          0 :     ControlState  nState = CTRL_STATE_ENABLED;
     507                 :            : 
     508                 :            :     return pThis->DrawNativeControl( CTRL_TOOLBAR, pThis->mbHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
     509 [ #  # ][ #  # ]:          0 :                                     aCtrlRegion, nState, ImplControlValue(), rtl::OUString() );
                 [ #  # ]
     510                 :            : }
     511                 :            : 
     512                 :          0 : void ToolBox::ImplDrawTransparentBackground( ToolBox* pThis, const Region &rRegion )
     513                 :            : {
     514                 :            :     // just invalidate to trigger paint of the parent
     515                 :            : 
     516                 :          0 :     const bool        bOldPaintLock = pThis->mpData->mbIsPaintLocked;
     517                 :          0 :     pThis->mpData->mbIsPaintLocked = true;
     518                 :            : 
     519                 :            :     // send an invalidate to the first opaque parent and invalidate the whole hierarchy from there (noclipchildren)
     520                 :          0 :     pThis->Invalidate( rRegion, INVALIDATE_UPDATE|INVALIDATE_NOCLIPCHILDREN );
     521                 :            : 
     522                 :          0 :     pThis->mpData->mbIsPaintLocked = bOldPaintLock;
     523                 :          0 : }
     524                 :            : 
     525                 :       6921 : void ToolBox::ImplDrawConstantBackground( ToolBox* pThis, const Region &rRegion, sal_Bool bIsInPopupMode )
     526                 :            : {
     527                 :            :     // draw a constant color
     528         [ +  - ]:       6921 :     if( !bIsInPopupMode )
     529                 :            :         // default background
     530         [ +  - ]:       6921 :         pThis->Erase( rRegion.GetBoundRect() );
     531                 :            :     else
     532                 :            :     {
     533                 :            :         // use different color in popupmode
     534                 :            :         pThis->DrawWallpaper( rRegion.GetBoundRect(),
     535 [ #  # ][ #  # ]:          0 :             Wallpaper( pThis->GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
         [ #  # ][ #  # ]
     536                 :            :     }
     537                 :       6921 : }
     538                 :            : 
     539                 :            : 
     540                 :     132574 : void ToolBox::ImplDrawBackground( ToolBox* pThis, const Rectangle &rRect )
     541                 :            : {
     542                 :            :     // execute pending paint requests
     543         [ +  - ]:     132574 :     ImplCheckUpdate( pThis );
     544                 :            : 
     545 [ +  - ][ +  - ]:     132574 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis );
     546         [ +  - ]:     132574 :     sal_Bool bIsInPopupMode = pThis->ImplIsInPopupMode();
     547                 :            : 
     548         [ +  - ]:     132574 :     Region aPaintRegion( rRect );
     549                 :            : 
     550                 :            :     // make sure we do not invalidate/erase too much
     551 [ +  - ][ +  + ]:     132574 :     if( pThis->IsInPaint() )
     552 [ +  - ][ +  - ]:     132191 :         aPaintRegion.Intersect( pThis->GetActiveClipRegion() );
                 [ +  - ]
     553                 :            : 
     554         [ +  - ]:     132574 :     pThis->Push( PUSH_CLIPREGION );
     555         [ +  - ]:     132574 :     pThis->IntersectClipRegion( aPaintRegion );
     556                 :            : 
     557                 :            : 
     558         [ +  + ]:     132574 :     if( !pWrapper /*|| bIsInPopupMode*/ )
     559                 :            :     {
     560                 :            :         // no gradient for ordinary toolbars (not dockable)
     561 [ +  + ][ +  - ]:       6921 :         if( !pThis->IsBackground() && !pThis->IsInPaint() )
         [ -  + ][ -  + ]
     562         [ #  # ]:          0 :             ImplDrawTransparentBackground( pThis, aPaintRegion );
     563                 :            :         else
     564         [ +  - ]:       6921 :             ImplDrawConstantBackground( pThis, aPaintRegion, bIsInPopupMode );
     565                 :            :     }
     566                 :            :     else
     567                 :            :     {
     568                 :            :         // toolbars known to the dockingmanager will be drawn using NWF or a gradient
     569                 :            :         // docked toolbars are transparent and NWF is already used in the docking area which is their common background
     570                 :            :         // so NWF is used here for floating toolbars only
     571                 :     125653 :         sal_Bool bNativeOk = sal_False;
     572 [ +  - ][ -  + ]:     125653 :         if( pThis->ImplIsFloatingMode() && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL) )
         [ #  # ][ #  # ]
                 [ -  + ]
     573         [ #  # ]:          0 :             bNativeOk = ImplDrawNativeBackground( pThis, aPaintRegion );
     574                 :            : 
     575         [ +  - ]:     125653 :         if( !bNativeOk )
     576                 :            :         {
     577         [ -  + ]:     125653 :             if( !pThis->IsBackground() )
     578                 :            :             {
     579 [ #  # ][ #  # ]:          0 :                 if( !pThis->IsInPaint() )
     580         [ #  # ]:          0 :                     ImplDrawTransparentBackground( pThis, aPaintRegion );
     581                 :            :             }
     582                 :            :             else
     583         [ +  - ]:     125653 :                 ImplDrawGradientBackground( pThis, pWrapper );
     584                 :            :         }
     585                 :            :     }
     586                 :            : 
     587                 :            :     // restore clip region
     588 [ +  - ][ +  - ]:     132574 :     pThis->Pop();
     589                 :     132574 : }
     590                 :            : 
     591                 :     121800 : void ToolBox::ImplErase( ToolBox* pThis, const Rectangle &rRect, sal_Bool bHighlight, sal_Bool bHasOpenPopup )
     592                 :            : {
     593                 :            :     // the background of non NWF buttons is painted in a constant color
     594                 :            :     // to have the same highlight color (transparency in DrawSelectionBackground())
     595                 :            :     // items with open popups will also painted using a constant color
     596         [ +  - ]:     243598 :     if( !pThis->mpData->mbNativeButtons &&
           [ +  +  +  + ]
                 [ +  + ]
     597                 :     121798 :         (bHighlight || ! (((Window*) pThis)->GetStyle() & WB_3DLOOK ) ) )
     598                 :            :     {
     599         [ +  + ]:       1377 :         if( (((Window*) pThis)->GetStyle() & WB_3DLOOK ) )
     600                 :            :         {
     601                 :          2 :             pThis->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
     602                 :          2 :             pThis->SetLineColor();
     603         [ -  + ]:          2 :             if( bHasOpenPopup )
     604                 :            :                 // choose the same color as the popup will use
     605         [ #  # ]:          0 :                 pThis->SetFillColor( pThis->GetSettings().GetStyleSettings().GetFaceGradientColor() );
     606                 :            :             else
     607         [ +  - ]:          2 :                 pThis->SetFillColor( Color( COL_WHITE ) );
     608                 :            : 
     609                 :          2 :             pThis->DrawRect( rRect );
     610                 :          2 :             pThis->Pop();
     611                 :            :         }
     612                 :            :         else
     613                 :       1375 :             ImplDrawBackground( pThis, rRect );
     614                 :            :     }
     615                 :            :     else
     616                 :     120423 :         ImplDrawBackground( pThis, rRect );
     617                 :     121800 : }
     618                 :            : 
     619                 :       8123 : void ToolBox::ImplDrawBorder( ToolBox* pWin )
     620                 :            : {
     621                 :       8123 :     const StyleSettings&    rStyleSettings = pWin->GetSettings().GetStyleSettings();
     622                 :       8123 :     long                    nDX = pWin->mnDX;
     623                 :       8123 :     long                    nDY = pWin->mnDY;
     624                 :            : 
     625                 :       8123 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pWin );
     626                 :            : 
     627                 :            :     // draw borders for ordinary toolbars only (not dockable)
     628         [ +  - ]:       8123 :     if( pWrapper )
     629                 :       8123 :         return;
     630                 :            : 
     631         [ #  # ]:          0 :     if ( pWin->meAlign == WINDOWALIGN_BOTTOM )
     632                 :            :     {
     633                 :            :         // draw bottom border
     634                 :          0 :         pWin->SetLineColor( rStyleSettings.GetShadowColor() );
     635         [ #  # ]:          0 :         pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
     636                 :          0 :         pWin->SetLineColor( rStyleSettings.GetLightColor() );
     637         [ #  # ]:          0 :         pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
     638                 :            :     }
     639                 :            :     else
     640                 :            :     {
     641                 :            :         // draw top border
     642                 :          0 :         pWin->SetLineColor( rStyleSettings.GetShadowColor() );
     643         [ #  # ]:          0 :         pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
     644                 :          0 :         pWin->SetLineColor( rStyleSettings.GetLightColor() );
     645         [ #  # ]:          0 :         pWin->DrawLine( Point( 0, 1 ), Point( nDX-1, 1 ) );
     646                 :            : 
     647 [ #  # ][ #  # ]:          0 :         if ( (pWin->meAlign == WINDOWALIGN_LEFT) || (pWin->meAlign == WINDOWALIGN_RIGHT) )
     648                 :            :         {
     649         [ #  # ]:          0 :             if ( pWin->meAlign == WINDOWALIGN_LEFT )
     650                 :            :             {
     651                 :            :                 // draw left-bottom border
     652                 :          0 :                 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
     653         [ #  # ]:          0 :                 pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
     654         [ #  # ]:          0 :                 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
     655                 :          0 :                 pWin->SetLineColor( rStyleSettings.GetLightColor() );
     656         [ #  # ]:          0 :                 pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
     657         [ #  # ]:          0 :                 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
     658                 :            :             }
     659                 :            :             else
     660                 :            :             {
     661                 :            :                 // draw right-bottom border
     662                 :          0 :                 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
     663         [ #  # ]:          0 :                 pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
     664         [ #  # ]:          0 :                 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-2, nDY-2 ) );
     665                 :          0 :                 pWin->SetLineColor( rStyleSettings.GetLightColor() );
     666         [ #  # ]:          0 :                 pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
     667         [ #  # ]:          0 :                 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
     668                 :            :             }
     669                 :            :         }
     670                 :            :     }
     671                 :            : 
     672                 :            : 
     673 [ #  # ][ #  # ]:          0 :     if ( pWin->meAlign == WINDOWALIGN_BOTTOM || pWin->meAlign == WINDOWALIGN_TOP )
     674                 :            :     {
     675                 :            :         // draw right border
     676                 :          0 :         pWin->SetLineColor( rStyleSettings.GetShadowColor() );
     677         [ #  # ]:          0 :         pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-1 ) );
     678                 :          0 :         pWin->SetLineColor( rStyleSettings.GetLightColor() );
     679         [ #  # ]:          0 :         pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
     680                 :            :     }
     681                 :            : }
     682                 :            : 
     683                 :            : // -----------------------------------------------------------------------
     684                 :            : 
     685                 :       2120 : static bool ImplIsFixedControl( const ImplToolItem *pItem )
     686                 :            : {
     687                 :            :     return ( pItem->mpWindow &&
     688                 :          0 :             (pItem->mpWindow->GetType() == WINDOW_FIXEDTEXT ||
     689                 :          0 :              pItem->mpWindow->GetType() == WINDOW_FIXEDLINE ||
     690   [ -  +  #  #  :       2120 :              pItem->mpWindow->GetType() == WINDOW_GROUPBOX) );
           #  # ][ #  # ]
     691                 :            : }
     692                 :            : 
     693                 :            : // -----------------------------------------------------------------------
     694                 :            : 
     695                 :          2 : const ImplToolItem *ToolBox::ImplGetFirstClippedItem( const ToolBox* pThis )
     696                 :            : {
     697                 :          2 :     std::vector< ImplToolItem >::const_iterator it;
     698         [ +  - ]:          2 :     it = pThis->mpData->m_aItems.begin();
     699 [ +  - ][ +  - ]:         72 :     while ( it != pThis->mpData->m_aItems.end() )
     700                 :            :     {
     701 [ +  - ][ +  + ]:         72 :         if( it->IsClipped() )
     702                 :          2 :             return &(*it);
     703                 :         70 :         ++it;
     704                 :            :     }
     705                 :          2 :     return NULL;
     706                 :            : }
     707                 :            : 
     708                 :            : // -----------------------------------------------------------------------
     709                 :            : 
     710                 :      24978 : Size ToolBox::ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uInt16 nCalcMode )
     711                 :            : {
     712                 :            :     long            nMax;
     713                 :      24978 :     long            nLeft = 0;
     714                 :      24978 :     long            nTop = 0;
     715                 :      24978 :     long            nRight = 0;
     716                 :      24978 :     long            nBottom = 0;
     717                 :      24978 :     Size            aSize;
     718                 :      24978 :     WindowAlign     eOldAlign = pThis->meAlign;
     719                 :      24978 :     sal_Bool            bOldHorz = pThis->mbHorz;
     720                 :      24978 :     sal_Bool            bOldAssumeDocked = pThis->mpData->mbAssumeDocked;
     721                 :      24978 :     sal_Bool            bOldAssumeFloating = pThis->mpData->mbAssumeFloating;
     722                 :            : 
     723         [ -  + ]:      24978 :     if ( nCalcMode )
     724                 :            :     {
     725         [ #  # ]:          0 :         sal_Bool bOldFloatingMode = pThis->ImplIsFloatingMode();
     726                 :            : 
     727                 :          0 :         pThis->mpData->mbAssumeDocked = sal_False;
     728                 :          0 :         pThis->mpData->mbAssumeFloating = sal_False;
     729                 :            : 
     730         [ #  # ]:          0 :         if ( nCalcMode == TB_CALCMODE_HORZ )
     731                 :            :         {
     732                 :          0 :             pThis->mpData->mbAssumeDocked = sal_True;   // force non-floating mode during calculation
     733         [ #  # ]:          0 :             ImplCalcBorder( WINDOWALIGN_TOP, nLeft, nTop, nRight, nBottom, pThis );
     734                 :          0 :             ((ToolBox*)pThis)->mbHorz = sal_True;
     735         [ #  # ]:          0 :             if ( pThis->mbHorz != bOldHorz )
     736                 :          0 :                 ((ToolBox*)pThis)->meAlign = WINDOWALIGN_TOP;
     737                 :            :         }
     738         [ #  # ]:          0 :         else if ( nCalcMode == TB_CALCMODE_VERT )
     739                 :            :         {
     740                 :          0 :             pThis->mpData->mbAssumeDocked = sal_True;   // force non-floating mode during calculation
     741         [ #  # ]:          0 :             ImplCalcBorder( WINDOWALIGN_LEFT, nLeft, nTop, nRight, nBottom, pThis );
     742                 :          0 :             ((ToolBox*)pThis)->mbHorz = sal_False;
     743         [ #  # ]:          0 :             if ( pThis->mbHorz != bOldHorz )
     744                 :          0 :                 ((ToolBox*)pThis)->meAlign = WINDOWALIGN_LEFT;
     745                 :            :         }
     746         [ #  # ]:          0 :         else if ( nCalcMode == TB_CALCMODE_FLOAT )
     747                 :            :         {
     748                 :          0 :             pThis->mpData->mbAssumeFloating = sal_True;   // force non-floating mode during calculation
     749                 :          0 :             nLeft = nTop = nRight = nBottom = 0;
     750                 :          0 :             ((ToolBox*)pThis)->mbHorz = sal_True;
     751         [ #  # ]:          0 :             if ( pThis->mbHorz != bOldHorz )
     752                 :          0 :                 ((ToolBox*)pThis)->meAlign = WINDOWALIGN_TOP;
     753                 :            :         }
     754                 :            : 
     755 [ #  # ][ #  # ]:          0 :         if ( (pThis->meAlign != eOldAlign) || (pThis->mbHorz != bOldHorz) ||
         [ #  # ][ #  # ]
     756         [ #  # ]:          0 :              (pThis->ImplIsFloatingMode() != bOldFloatingMode ) )
     757                 :          0 :             ((ToolBox*)pThis)->mbCalc = sal_True;
     758                 :            :     }
     759                 :            :     else
     760         [ +  - ]:      24978 :         ImplCalcBorder( pThis->meAlign, nLeft, nTop, nRight, nBottom, pThis );
     761                 :            : 
     762         [ +  - ]:      24978 :     ((ToolBox*)pThis)->ImplCalcItem();
     763                 :            : 
     764 [ +  - ][ +  - ]:      24978 :     if( !nCalcMode && pThis->ImplIsFloatingMode() )
         [ -  + ][ -  + ]
     765                 :            :     {
     766         [ #  # ]:          0 :         aSize = ImplCalcFloatSize( ((ToolBox*)pThis), nCalcLines );
     767                 :            :     }
     768                 :            :     else
     769                 :            :     {
     770         [ +  - ]:      24978 :         if ( pThis->mbHorz )
     771                 :            :         {
     772         [ +  + ]:      24978 :             if ( pThis->mnWinHeight > pThis->mnMaxItemHeight )
     773                 :         18 :                 aSize.Height() = nCalcLines * pThis->mnWinHeight;
     774                 :            :             else
     775                 :      24960 :                 aSize.Height() = nCalcLines * pThis->mnMaxItemHeight;
     776                 :            : 
     777         [ +  + ]:      24978 :             if ( pThis->mnWinStyle & WB_LINESPACING )
     778                 :      18236 :                 aSize.Height() += (nCalcLines-1)*TB_LINESPACING;
     779                 :            : 
     780         [ +  + ]:      24978 :             if ( pThis->mnWinStyle & WB_BORDER )
     781                 :      18236 :                 aSize.Height() += (TB_BORDER_OFFSET2*2) + nTop + nBottom;
     782                 :            : 
     783                 :      24978 :             nMax = 0;
     784         [ +  - ]:      24978 :             ((ToolBox*)pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz );
     785         [ +  + ]:      24978 :             if ( nMax )
     786                 :      20910 :                 aSize.Width() += nMax;
     787                 :            : 
     788         [ +  + ]:      24978 :             if ( pThis->mnWinStyle & WB_BORDER )
     789                 :      18236 :                 aSize.Width() += (TB_BORDER_OFFSET1*2) + nLeft + nRight;
     790                 :            :         }
     791                 :            :         else
     792                 :            :         {
     793                 :          0 :             aSize.Width() = nCalcLines * pThis->mnMaxItemWidth;
     794                 :            : 
     795         [ #  # ]:          0 :             if ( pThis->mnWinStyle & WB_LINESPACING )
     796                 :          0 :                 aSize.Width() += (nCalcLines-1)*TB_LINESPACING;
     797                 :            : 
     798         [ #  # ]:          0 :             if ( pThis->mnWinStyle & WB_BORDER )
     799                 :          0 :                 aSize.Width() += (TB_BORDER_OFFSET2*2) + nLeft + nRight;
     800                 :            : 
     801                 :          0 :             nMax = 0;
     802         [ #  # ]:          0 :             ((ToolBox*)pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz );
     803         [ #  # ]:          0 :             if ( nMax )
     804                 :          0 :                 aSize.Height() += nMax;
     805                 :            : 
     806         [ #  # ]:          0 :             if ( pThis->mnWinStyle & WB_BORDER )
     807                 :          0 :                 aSize.Height() += (TB_BORDER_OFFSET1*2) + nTop + nBottom;
     808                 :            :         }
     809                 :            :     }
     810                 :            :     // restore previous values
     811         [ -  + ]:      24978 :     if ( nCalcMode )
     812                 :            :     {
     813                 :          0 :         pThis->mpData->mbAssumeDocked = bOldAssumeDocked;
     814                 :          0 :         pThis->mpData->mbAssumeFloating = bOldAssumeFloating;
     815 [ #  # ][ #  # ]:          0 :         if ( (pThis->meAlign != eOldAlign) || (pThis->mbHorz != bOldHorz) )
     816                 :            :         {
     817                 :          0 :             ((ToolBox*)pThis)->meAlign  = eOldAlign;
     818                 :          0 :             ((ToolBox*)pThis)->mbHorz   = bOldHorz;
     819                 :      24978 :             ((ToolBox*)pThis)->mbCalc   = sal_True;
     820                 :            :         }
     821                 :            :     }
     822                 :            : 
     823                 :      24978 :     return aSize;
     824                 :            : }
     825                 :            : 
     826                 :            : // -----------------------------------------------------------------------
     827                 :            : 
     828                 :          0 : void ToolBox::ImplCalcFloatSizes( ToolBox* pThis )
     829                 :            : {
     830         [ #  # ]:          0 :     if ( !pThis->maFloatSizes.empty() )
     831                 :          0 :         return;
     832                 :            : 
     833                 :            :     // calculate the minimal size, i.e. where the biggest item just fits
     834                 :          0 :     long            nCalcSize = 0;
     835                 :            : 
     836                 :          0 :     std::vector< ImplToolItem >::const_iterator it;
     837         [ #  # ]:          0 :     it = pThis->mpData->m_aItems.begin();
     838 [ #  # ][ #  # ]:          0 :     while ( it != pThis->mpData->m_aItems.end() )
     839                 :            :     {
     840         [ #  # ]:          0 :         if ( it->mbVisible )
     841                 :            :         {
     842         [ #  # ]:          0 :             if ( it->mpWindow )
     843                 :            :             {
     844         [ #  # ]:          0 :                 long nTempSize = it->mpWindow->GetSizePixel().Width();
     845         [ #  # ]:          0 :                 if ( nTempSize > nCalcSize )
     846                 :          0 :                     nCalcSize = nTempSize;
     847                 :            :             }
     848                 :            :             else
     849                 :            :             {
     850         [ #  # ]:          0 :                 if( it->maItemSize.Width() > nCalcSize )
     851                 :          0 :                     nCalcSize = it->maItemSize.Width();
     852                 :            :             }
     853                 :            :         }
     854                 :          0 :         ++it;
     855                 :            :     }
     856                 :            : 
     857                 :            :     // calc an upper bound for ImplCalcBreaks below
     858                 :          0 :     long upperBoundWidth = nCalcSize * pThis->mpData->m_aItems.size();
     859                 :            : 
     860                 :            :     sal_uInt16  nLines;
     861                 :            :     sal_uInt16  nCalcLines;
     862                 :            :     sal_uInt16  nTempLines;
     863                 :            :     long    nMaxLineWidth;
     864         [ #  # ]:          0 :     nCalcLines = pThis->ImplCalcBreaks( nCalcSize, &nMaxLineWidth, sal_True );
     865                 :            : 
     866         [ #  # ]:          0 :     pThis->maFloatSizes.reserve( nCalcLines );
     867                 :            : 
     868                 :          0 :     nTempLines = nLines = nCalcLines;
     869         [ #  # ]:          0 :     while ( nLines )
     870                 :            :     {
     871         [ #  # ]:          0 :         long nHeight = ImplCalcSize( pThis, nTempLines, TB_CALCMODE_FLOAT ).Height();
     872                 :            : 
     873                 :            :         ImplToolSize aSize;
     874                 :          0 :         aSize.mnWidth  = nMaxLineWidth+(TB_BORDER_OFFSET1*2);
     875                 :          0 :         aSize.mnHeight = nHeight;
     876                 :          0 :         aSize.mnLines  = nTempLines;
     877         [ #  # ]:          0 :         pThis->maFloatSizes.push_back( aSize );
     878                 :          0 :         nLines--;
     879         [ #  # ]:          0 :         if ( nLines )
     880                 :            :         {
     881 [ #  # ][ #  # ]:          0 :             do
         [ #  # ][ #  # ]
     882                 :            :             {
     883                 :          0 :                 nCalcSize += pThis->mnMaxItemWidth;
     884         [ #  # ]:          0 :                 nTempLines = pThis->ImplCalcBreaks( nCalcSize, &nMaxLineWidth, sal_True );
     885                 :            :             }
     886                 :            :             while ( (nCalcSize < upperBoundWidth) && (nLines < nTempLines) && (nTempLines != 1) );
     887         [ #  # ]:          0 :             if ( nTempLines < nLines )
     888                 :          0 :                 nLines = nTempLines;
     889                 :            :         }
     890                 :            :     }
     891                 :            : }
     892                 :            : 
     893                 :            : // -----------------------------------------------------------------------
     894                 :            : 
     895                 :          0 : Size ToolBox::ImplCalcFloatSize( ToolBox* pThis, sal_uInt16& rLines )
     896                 :            : {
     897                 :          0 :     ImplCalcFloatSizes( pThis );
     898                 :            : 
     899         [ #  # ]:          0 :     if ( !rLines )
     900                 :            :     {
     901                 :          0 :         rLines = pThis->mnFloatLines;
     902         [ #  # ]:          0 :         if ( !rLines )
     903                 :          0 :             rLines = pThis->mnLines;
     904                 :            :     }
     905                 :            : 
     906                 :          0 :     sal_uInt16 i = 0;
     907   [ #  #  #  # ]:          0 :     while ( i + 1u < pThis->maFloatSizes.size() &&
                 [ #  # ]
     908                 :          0 :             rLines < pThis->maFloatSizes[i].mnLines )
     909                 :            :     {
     910                 :          0 :         i++;
     911                 :            :     }
     912                 :            : 
     913                 :          0 :     Size aSize( pThis->maFloatSizes[i].mnWidth,
     914                 :          0 :                 pThis->maFloatSizes[i].mnHeight );
     915                 :          0 :     rLines = pThis->maFloatSizes[i].mnLines;
     916                 :            : 
     917                 :          0 :     return aSize;
     918                 :            : }
     919                 :            : 
     920                 :            : // -----------------------------------------------------------------------
     921                 :            : 
     922                 :          0 : void ToolBox::ImplCalcMinMaxFloatSize( ToolBox* pThis, Size& rMinSize, Size& rMaxSize )
     923                 :            : {
     924                 :          0 :     ImplCalcFloatSizes( pThis );
     925                 :            : 
     926                 :          0 :     sal_uInt16 i = 0;
     927                 :          0 :     rMinSize = Size( pThis->maFloatSizes[i].mnWidth, pThis->maFloatSizes[i].mnHeight );
     928                 :          0 :     rMaxSize = Size( pThis->maFloatSizes[i].mnWidth, pThis->maFloatSizes[i].mnHeight );
     929         [ #  # ]:          0 :     while ( ++i < pThis->maFloatSizes.size() )
     930                 :            :     {
     931         [ #  # ]:          0 :         if( pThis->maFloatSizes[i].mnWidth < rMinSize.Width() )
     932                 :          0 :             rMinSize.Width() = pThis->maFloatSizes[i].mnWidth;
     933         [ #  # ]:          0 :         if( pThis->maFloatSizes[i].mnHeight < rMinSize.Height() )
     934                 :          0 :             rMinSize.Height() = pThis->maFloatSizes[i].mnHeight;
     935                 :            : 
     936         [ #  # ]:          0 :         if( pThis->maFloatSizes[i].mnWidth > rMaxSize.Width() )
     937                 :          0 :             rMaxSize.Width() = pThis->maFloatSizes[i].mnWidth;
     938         [ #  # ]:          0 :         if( pThis->maFloatSizes[i].mnHeight > rMaxSize.Height() )
     939                 :          0 :             rMaxSize.Height() = pThis->maFloatSizes[i].mnHeight;
     940                 :            :     }
     941                 :          0 : }
     942                 :            : 
     943                 :          0 : void ToolBox::ImplSetMinMaxFloatSize( ToolBox *pThis )
     944                 :            : {
     945 [ #  # ][ #  # ]:          0 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis );
     946                 :          0 :     Size aMinSize, aMaxSize;
     947         [ #  # ]:          0 :     ImplCalcMinMaxFloatSize( pThis, aMinSize, aMaxSize );
     948         [ #  # ]:          0 :     if( pWrapper )
     949                 :            :     {
     950         [ #  # ]:          0 :         pWrapper->SetMinOutputSizePixel( aMinSize );
     951         [ #  # ]:          0 :         pWrapper->SetMaxOutputSizePixel( aMaxSize );
     952 [ #  # ][ #  # ]:          0 :         pWrapper->ShowTitleButton( TITLE_BUTTON_MENU, ( pThis->GetMenuType() & TOOLBOX_MENUTYPE_CUSTOMIZE) ? sal_True : sal_False );
                 [ #  # ]
     953                 :            :     }
     954                 :            :     else
     955                 :            :     {
     956                 :            :         // TODO: change SetMinOutputSizePixel to be not inline
     957         [ #  # ]:          0 :         pThis->SetMinOutputSizePixel( aMinSize );
     958         [ #  # ]:          0 :         pThis->SetMaxOutputSizePixel( aMaxSize );
     959                 :            :     }
     960                 :          0 : }
     961                 :            : 
     962                 :            : // -----------------------------------------------------------------------
     963                 :            : 
     964                 :            : 
     965                 :       4063 : sal_uInt16 ToolBox::ImplCalcLines( ToolBox* pThis, long nToolSize )
     966                 :            : {
     967                 :            :     long nLineHeight;
     968                 :            : 
     969         [ +  - ]:       4063 :     if ( pThis->mbHorz )
     970                 :            :     {
     971         [ -  + ]:       4063 :         if ( pThis->mnWinHeight > pThis->mnMaxItemHeight )
     972                 :          0 :             nLineHeight = pThis->mnWinHeight;
     973                 :            :         else
     974                 :       4063 :             nLineHeight = pThis->mnMaxItemHeight;
     975                 :            :     }
     976                 :            :     else
     977                 :          0 :         nLineHeight = pThis->mnMaxItemWidth;
     978                 :            : 
     979         [ +  - ]:       4063 :     if ( pThis->mnWinStyle & WB_BORDER )
     980                 :       4063 :         nToolSize -= TB_BORDER_OFFSET2*2;
     981                 :            : 
     982         [ +  - ]:       4063 :     if ( pThis->mnWinStyle & WB_LINESPACING )
     983                 :            :     {
     984                 :       4063 :         nLineHeight += TB_LINESPACING;
     985                 :       4063 :         nToolSize += TB_LINESPACING;
     986                 :            :     }
     987                 :            : 
     988                 :            :     // #i91917# always report at least one line
     989                 :       4063 :     long nLines = nToolSize/nLineHeight;
     990         [ -  + ]:       4063 :     if( nLines < 1 )
     991                 :          0 :         nLines = 1;
     992                 :            : 
     993                 :       4063 :     return static_cast<sal_uInt16>(nLines);
     994                 :            : }
     995                 :            : 
     996                 :            : // -----------------------------------------------------------------------
     997                 :            : 
     998                 :          0 : sal_uInt16 ToolBox::ImplTestLineSize( ToolBox* pThis, const Point& rPos )
     999                 :            : {
    1000 [ #  # ][ #  # ]:          0 :     if ( !pThis->ImplIsFloatingMode() &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1001                 :          0 :          (!pThis->mbScroll || (pThis->mnLines > 1) || (pThis->mnCurLines > pThis->mnVisLines)) )
    1002                 :            :     {
    1003                 :          0 :         WindowAlign eAlign = pThis->GetAlign();
    1004                 :            : 
    1005         [ #  # ]:          0 :         if ( eAlign == WINDOWALIGN_LEFT )
    1006                 :            :         {
    1007         [ #  # ]:          0 :             if ( rPos.X() > pThis->mnDX-DOCK_LINEOFFSET )
    1008                 :          0 :                 return DOCK_LINEHSIZE | DOCK_LINERIGHT;
    1009                 :            :         }
    1010         [ #  # ]:          0 :         else if ( eAlign == WINDOWALIGN_TOP )
    1011                 :            :         {
    1012         [ #  # ]:          0 :             if ( rPos.Y() > pThis->mnDY-DOCK_LINEOFFSET )
    1013                 :          0 :                 return DOCK_LINEVSIZE | DOCK_LINEBOTTOM;
    1014                 :            :         }
    1015         [ #  # ]:          0 :         else if ( eAlign == WINDOWALIGN_RIGHT )
    1016                 :            :         {
    1017         [ #  # ]:          0 :             if ( rPos.X() < DOCK_LINEOFFSET )
    1018                 :          0 :                 return DOCK_LINEHSIZE | DOCK_LINELEFT;
    1019                 :            :         }
    1020         [ #  # ]:          0 :         else if ( eAlign == WINDOWALIGN_BOTTOM )
    1021                 :            :         {
    1022         [ #  # ]:          0 :             if ( rPos.Y() < DOCK_LINEOFFSET )
    1023                 :          0 :                 return DOCK_LINEVSIZE | DOCK_LINETOP;
    1024                 :            :         }
    1025                 :            :     }
    1026                 :            : 
    1027                 :          0 :     return 0;
    1028                 :            : }
    1029                 :            : 
    1030                 :            : // -----------------------------------------------------------------------
    1031                 :            : 
    1032                 :          0 : void ToolBox::ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect,
    1033                 :            :                      sal_uInt16 nLineMode )
    1034                 :            : {
    1035                 :            :     sal_Bool    mbHorz;
    1036                 :            :     long    nOneLineSize;
    1037                 :            :     long    nCurSize;
    1038                 :            :     long    nMaxSize;
    1039                 :            :     long    nSize;
    1040                 :          0 :     Size    aSize;
    1041                 :            : 
    1042         [ #  # ]:          0 :     if ( nLineMode & DOCK_LINERIGHT )
    1043                 :            :     {
    1044                 :          0 :         nCurSize = rPos.X() - rRect.Left();
    1045                 :          0 :         mbHorz = sal_False;
    1046                 :            :     }
    1047         [ #  # ]:          0 :     else if ( nLineMode & DOCK_LINEBOTTOM )
    1048                 :            :     {
    1049                 :          0 :         nCurSize = rPos.Y() - rRect.Top();
    1050                 :          0 :         mbHorz = sal_True;
    1051                 :            :     }
    1052         [ #  # ]:          0 :     else if ( nLineMode & DOCK_LINELEFT )
    1053                 :            :     {
    1054                 :          0 :         nCurSize = rRect.Right() - rPos.X();
    1055                 :          0 :         mbHorz = sal_False;
    1056                 :            :     }
    1057         [ #  # ]:          0 :     else if ( nLineMode & DOCK_LINETOP )
    1058                 :            :     {
    1059                 :          0 :         nCurSize = rRect.Bottom() - rPos.Y();
    1060                 :          0 :         mbHorz = sal_True;
    1061                 :            :     }
    1062                 :            :     else {
    1063                 :            :         OSL_FAIL( "ImplLineSizing: Trailing else" );
    1064                 :          0 :         nCurSize = 0;
    1065                 :          0 :         mbHorz = sal_False;
    1066                 :            :     }
    1067                 :            : 
    1068         [ #  # ]:          0 :     Size    aWinSize = pThis->GetSizePixel();
    1069         [ #  # ]:          0 :     sal_uInt16  nMaxLines = (pThis->mnLines > pThis->mnCurLines) ? pThis->mnLines : pThis->mnCurLines;
    1070         [ #  # ]:          0 :     if ( nMaxLines > TB_MAXLINES )
    1071                 :          0 :         nMaxLines = TB_MAXLINES;
    1072         [ #  # ]:          0 :     if ( mbHorz )
    1073                 :            :     {
    1074         [ #  # ]:          0 :         nOneLineSize = ImplCalcSize( pThis, 1 ).Height();
    1075         [ #  # ]:          0 :         nMaxSize = pThis->maOutDockRect.GetHeight() - 20;
    1076         [ #  # ]:          0 :         if ( nMaxSize < aWinSize.Height() )
    1077                 :          0 :             nMaxSize = aWinSize.Height();
    1078                 :            :     }
    1079                 :            :     else
    1080                 :            :     {
    1081         [ #  # ]:          0 :         nOneLineSize = ImplCalcSize( pThis, 1 ).Width();
    1082         [ #  # ]:          0 :         nMaxSize = pThis->maOutDockRect.GetWidth() - 20;
    1083         [ #  # ]:          0 :         if ( nMaxSize < aWinSize.Width() )
    1084                 :          0 :             nMaxSize = aWinSize.Width();
    1085                 :            :     }
    1086                 :            : 
    1087                 :          0 :     sal_uInt16 i = 1;
    1088         [ #  # ]:          0 :     if ( nCurSize <= nOneLineSize )
    1089                 :          0 :         nSize = nOneLineSize;
    1090                 :            :     else
    1091                 :            :     {
    1092                 :          0 :         nSize = 0;
    1093 [ #  # ][ #  # ]:          0 :         while ( (nSize < nCurSize) && (i < nMaxLines) )
                 [ #  # ]
    1094                 :            :         {
    1095                 :          0 :             i++;
    1096         [ #  # ]:          0 :             aSize = ImplCalcSize( pThis, i );
    1097         [ #  # ]:          0 :             if ( mbHorz )
    1098                 :          0 :                 nSize = aSize.Height();
    1099                 :            :             else
    1100                 :          0 :                 nSize = aSize.Width();
    1101         [ #  # ]:          0 :             if ( nSize > nMaxSize )
    1102                 :            :             {
    1103                 :          0 :                 i--;
    1104         [ #  # ]:          0 :                 aSize = ImplCalcSize( pThis, i );
    1105         [ #  # ]:          0 :                 if ( mbHorz )
    1106                 :          0 :                     nSize = aSize.Height();
    1107                 :            :                 else
    1108                 :          0 :                     nSize = aSize.Width();
    1109                 :          0 :                 break;
    1110                 :            :             }
    1111                 :            :         }
    1112                 :            :     }
    1113                 :            : 
    1114         [ #  # ]:          0 :     if ( nLineMode & DOCK_LINERIGHT )
    1115                 :          0 :         rRect.Right() = rRect.Left()+nSize-1;
    1116         [ #  # ]:          0 :     else if ( nLineMode & DOCK_LINEBOTTOM )
    1117                 :          0 :         rRect.Bottom() = rRect.Top()+nSize-1;
    1118         [ #  # ]:          0 :     else if ( nLineMode & DOCK_LINELEFT )
    1119                 :          0 :         rRect.Left() = rRect.Right()-nSize;
    1120                 :            :     else
    1121                 :          0 :         rRect.Top() = rRect.Bottom()-nSize;
    1122                 :            : 
    1123                 :          0 :     pThis->mnDockLines = i;
    1124                 :          0 : }
    1125                 :            : 
    1126                 :            : // -----------------------------------------------------------------------
    1127                 :            : 
    1128                 :          0 : sal_uInt16 ToolBox::ImplFindItemPos( ToolBox* pBox, const Point& rPos )
    1129                 :            : {
    1130                 :          0 :     sal_uInt16  nPos = 0;
    1131                 :          0 :     long    nLast = 0;
    1132                 :          0 :     Point   aPos = rPos;
    1133                 :          0 :     Size    aSize( pBox->mnDX, pBox->mnDY );
    1134                 :            : 
    1135         [ #  # ]:          0 :     if ( aPos.X() > aSize.Width()-TB_BORDER_OFFSET1 )
    1136                 :          0 :         aPos.X() = aSize.Width()-TB_BORDER_OFFSET1;
    1137         [ #  # ]:          0 :     if ( aPos.Y() > aSize.Height()-TB_BORDER_OFFSET1 )
    1138                 :          0 :         aPos.Y() = aSize.Height()-TB_BORDER_OFFSET1;
    1139                 :            : 
    1140                 :            :     // Item suchen, das geklickt wurde
    1141         [ #  # ]:          0 :     std::vector< ImplToolItem >::const_iterator it = pBox->mpData->m_aItems.begin();
    1142 [ #  # ][ #  # ]:          0 :     while ( it != pBox->mpData->m_aItems.end() )
    1143                 :            :     {
    1144         [ #  # ]:          0 :         if ( it->mbVisible )
    1145                 :            :         {
    1146 [ #  # ][ #  # ]:          0 :             if ( nLast || !it->maRect.IsEmpty() )
         [ #  # ][ #  # ]
    1147                 :            :             {
    1148         [ #  # ]:          0 :                 if ( pBox->mbHorz )
    1149                 :            :                 {
    1150   [ #  #  #  # ]:          0 :                     if ( nLast &&
         [ #  # ][ #  # ]
    1151         [ #  # ]:          0 :                          ((nLast < it->maRect.Top()) || it->maRect.IsEmpty()) )
    1152                 :          0 :                         return nPos;
    1153                 :            : 
    1154         [ #  # ]:          0 :                     if ( aPos.Y() <= it->maRect.Bottom() )
    1155                 :            :                     {
    1156         [ #  # ]:          0 :                         if ( aPos.X() < it->maRect.Left() )
    1157                 :          0 :                             return nPos;
    1158         [ #  # ]:          0 :                         else if ( aPos.X() < it->maRect.Right() )
    1159                 :          0 :                             return nPos+1;
    1160         [ #  # ]:          0 :                         else if ( !nLast )
    1161                 :          0 :                             nLast = it->maRect.Bottom();
    1162                 :            :                     }
    1163                 :            :                 }
    1164                 :            :                 else
    1165                 :            :                 {
    1166   [ #  #  #  # ]:          0 :                     if ( nLast &&
         [ #  # ][ #  # ]
    1167         [ #  # ]:          0 :                          ((nLast < it->maRect.Left()) || it->maRect.IsEmpty()) )
    1168                 :          0 :                         return nPos;
    1169                 :            : 
    1170         [ #  # ]:          0 :                     if ( aPos.X() <= it->maRect.Right() )
    1171                 :            :                     {
    1172         [ #  # ]:          0 :                         if ( aPos.Y() < it->maRect.Top() )
    1173                 :          0 :                             return nPos;
    1174         [ #  # ]:          0 :                         else if ( aPos.Y() < it->maRect.Bottom() )
    1175                 :          0 :                             return nPos+1;
    1176         [ #  # ]:          0 :                         else if ( !nLast )
    1177                 :          0 :                             nLast = it->maRect.Right();
    1178                 :            :                     }
    1179                 :            :                 }
    1180                 :            :             }
    1181                 :            :         }
    1182                 :            : 
    1183                 :          0 :         nPos++;
    1184                 :          0 :         ++it;
    1185                 :            :     }
    1186                 :            : 
    1187                 :          0 :     return nPos;
    1188                 :            : }
    1189                 :            : 
    1190                 :            : // -----------------------------------------------------------------------
    1191                 :            : 
    1192                 :       1466 : ImplTBDragMgr::ImplTBDragMgr()
    1193                 :            : {
    1194 [ +  - ][ +  - ]:       1466 :     mpBoxList       = new ImplTBList();
    1195                 :       1466 :     mnLineMode      = 0;
    1196                 :       1466 :     mnStartLines    = 0;
    1197                 :       1466 :     mbCustomizeMode = sal_False;
    1198                 :       1466 :     mbResizeMode    = sal_False;
    1199                 :       1466 :     mbShowDragRect  = sal_False;
    1200                 :       1466 :     mpDragBox       = NULL;
    1201                 :            : 
    1202         [ +  - ]:       1466 :     maAccel.InsertItem( KEY_RETURN, KeyCode( KEY_RETURN ) );
    1203         [ +  - ]:       1466 :     maAccel.InsertItem( KEY_ESCAPE, KeyCode( KEY_ESCAPE ) );
    1204         [ +  - ]:       1466 :     maAccel.SetSelectHdl( LINK( this, ImplTBDragMgr, SelectHdl ) );
    1205                 :       1466 : }
    1206                 :            : 
    1207                 :            : // -----------------------------------------------------------------------
    1208                 :            : 
    1209                 :       1456 : ImplTBDragMgr::~ImplTBDragMgr()
    1210                 :            : {
    1211         [ +  - ]:       1456 :     delete mpBoxList;
    1212                 :       1456 : }
    1213                 :            : 
    1214                 :            : // -----------------------------------------------------------------------
    1215                 :            : 
    1216                 :          0 : ToolBox* ImplTBDragMgr::FindToolBox( const Rectangle& rRect )
    1217                 :            : {
    1218         [ #  # ]:          0 :     for ( size_t i = 0, n = mpBoxList->size(); i < n; ++i )
    1219                 :            :     {
    1220                 :          0 :         ToolBox* pBox = (*mpBoxList)[ i ];
    1221                 :            :         /*
    1222                 :            :          *  FIXME: since we can have multiple frames now we cannot
    1223                 :            :          *  find the drag target by its position alone.
    1224                 :            :          *  As long as the toolbar config dialogue is not a system window
    1225                 :            :          *  this works in one frame only anyway. If the dialogue
    1226                 :            :          *  changes to a system window, we need a new implementation here
    1227                 :            :          */
    1228         [ #  # ]:          0 :         if (  pBox->IsReallyVisible()
           [ #  #  #  # ]
    1229                 :          0 :            && pBox->ImplGetWindowImpl()->mpFrame == mpDragBox->ImplGetWindowImpl()->mpFrame
    1230                 :            :         ) {
    1231         [ #  # ]:          0 :             if ( !pBox->ImplIsFloatingMode() )
    1232                 :            :             {
    1233         [ #  # ]:          0 :                 Point aPos = pBox->GetPosPixel();
    1234 [ #  # ][ #  # ]:          0 :                 aPos = pBox->GetParent()->OutputToScreenPixel( aPos );
    1235 [ #  # ][ #  # ]:          0 :                 Rectangle aTempRect( aPos, pBox->GetSizePixel() );
    1236 [ #  # ][ #  # ]:          0 :                 if ( aTempRect.IsOver( rRect ) )
    1237                 :          0 :                     return pBox;
    1238                 :            :             }
    1239                 :            :         }
    1240                 :            :     }
    1241                 :            : 
    1242                 :          0 :     return NULL;
    1243                 :            : }
    1244                 :            : 
    1245                 :            : // -----------------------------------------------------------------------
    1246                 :            : 
    1247                 :          0 : void ImplTBDragMgr::StartDragging( ToolBox* pToolBox,
    1248                 :            :                                    const Point& rPos, const Rectangle& rRect,
    1249                 :            :                                    sal_uInt16 nDragLineMode, sal_Bool bResizeItem,
    1250                 :            :                                    void* pData )
    1251                 :            : {
    1252                 :          0 :     mpDragBox = pToolBox;
    1253                 :          0 :     pToolBox->CaptureMouse();
    1254                 :          0 :     pToolBox->mbDragging = sal_True;
    1255                 :          0 :     Application::InsertAccel( &maAccel );
    1256                 :            : 
    1257         [ #  # ]:          0 :     if ( nDragLineMode )
    1258                 :            :     {
    1259                 :          0 :         mnLineMode = nDragLineMode;
    1260                 :          0 :         mnStartLines = pToolBox->mnDockLines;
    1261                 :            :     }
    1262                 :            :     else
    1263                 :            :     {
    1264                 :          0 :         mpCustomizeData = pData;
    1265                 :          0 :         mbResizeMode = bResizeItem;
    1266                 :          0 :         pToolBox->Activate();
    1267                 :          0 :         pToolBox->mnCurItemId = pToolBox->mnConfigItem;
    1268                 :          0 :         pToolBox->Highlight();
    1269                 :          0 :         pToolBox->mnCurItemId = 0;
    1270         [ #  # ]:          0 :         if ( mbResizeMode )
    1271                 :            :         {
    1272         [ #  # ]:          0 :             if ( rRect.GetWidth() < TB_MIN_WIN_WIDTH )
    1273                 :          0 :                 mnMinWidth = rRect.GetWidth();
    1274                 :            :             else
    1275                 :          0 :                 mnMinWidth = TB_MIN_WIN_WIDTH;
    1276                 :          0 :             mnMaxWidth = pToolBox->GetSizePixel().Width()-rRect.Left()-
    1277                 :          0 :                          TB_SPIN_SIZE-TB_BORDER_OFFSET1-(TB_SPIN_OFFSET*2);
    1278                 :            :         }
    1279                 :            :     }
    1280                 :            : 
    1281                 :            :     // MouseOffset berechnen
    1282                 :          0 :     maMouseOff.X() = rRect.Left() - rPos.X();
    1283                 :          0 :     maMouseOff.Y() = rRect.Top() - rPos.Y();
    1284                 :          0 :     maRect = rRect;
    1285                 :          0 :     maStartRect = rRect;
    1286                 :          0 :     mbShowDragRect = sal_True;
    1287                 :          0 :     pToolBox->ShowTracking( maRect );
    1288                 :          0 : }
    1289                 :            : 
    1290                 :            : // -----------------------------------------------------------------------
    1291                 :            : 
    1292                 :          0 : void ImplTBDragMgr::Dragging( const Point& rPos )
    1293                 :            : {
    1294         [ #  # ]:          0 :     if ( mnLineMode )
    1295                 :            :     {
    1296         [ #  # ]:          0 :         ToolBox::ImplLineSizing( mpDragBox, rPos, maRect, mnLineMode );
    1297         [ #  # ]:          0 :         Point aOff = mpDragBox->OutputToScreenPixel( Point() );
    1298         [ #  # ]:          0 :         maRect.Move( aOff.X(), aOff.Y() );
    1299         [ #  # ]:          0 :         mpDragBox->Docking( rPos, maRect );
    1300         [ #  # ]:          0 :         maRect.Move( -aOff.X(), -aOff.Y() );
    1301         [ #  # ]:          0 :         mpDragBox->ShowTracking( maRect );
    1302                 :            :     }
    1303                 :            :     else
    1304                 :            :     {
    1305         [ #  # ]:          0 :         if ( mbResizeMode )
    1306                 :            :         {
    1307                 :          0 :             long nXOff = rPos.X()-maStartRect.Left();
    1308                 :          0 :             nXOff += maMouseOff.X()+(maStartRect.Right()-maStartRect.Left());
    1309         [ #  # ]:          0 :             if ( nXOff < mnMinWidth )
    1310                 :          0 :                 nXOff = mnMinWidth;
    1311         [ #  # ]:          0 :             if ( nXOff > mnMaxWidth )
    1312                 :          0 :                 nXOff = mnMaxWidth;
    1313                 :          0 :             maRect.Right() = maStartRect.Left()+nXOff;
    1314                 :            :         }
    1315                 :            :         else
    1316                 :            :         {
    1317                 :          0 :             maRect.SetPos( rPos );
    1318                 :          0 :             maRect.Move( maMouseOff.X(), maMouseOff.Y() );
    1319                 :            :         }
    1320                 :          0 :         mpDragBox->ShowTracking( maRect );
    1321                 :            :     }
    1322                 :          0 : }
    1323                 :            : 
    1324                 :            : // -----------------------------------------------------------------------
    1325                 :            : 
    1326                 :          0 : void ImplTBDragMgr::EndDragging( sal_Bool bOK )
    1327                 :            : {
    1328                 :          0 :     mpDragBox->HideTracking();
    1329                 :          0 :     mpDragBox->ReleaseMouse();
    1330                 :          0 :     mpDragBox->mbDragging = sal_False;
    1331                 :          0 :     mbShowDragRect = sal_False;
    1332                 :          0 :     Application::RemoveAccel( &maAccel );
    1333                 :            : 
    1334         [ #  # ]:          0 :     if ( mnLineMode )
    1335                 :            :     {
    1336         [ #  # ]:          0 :         if ( !bOK )
    1337                 :            :         {
    1338                 :          0 :             mpDragBox->mnDockLines = mnStartLines;
    1339                 :          0 :             mpDragBox->EndDocking( maStartRect, sal_False );
    1340                 :            :         }
    1341                 :            :         else
    1342                 :          0 :             mpDragBox->EndDocking( maRect, sal_False );
    1343                 :          0 :         mnLineMode = 0;
    1344                 :          0 :         mnStartLines = 0;
    1345                 :            :     }
    1346                 :            :     else
    1347                 :            :     {
    1348                 :          0 :         sal_uInt16 nTempItem = mpDragBox->mnConfigItem;
    1349         [ #  # ]:          0 :         if ( nTempItem )
    1350                 :            :         {
    1351                 :          0 :             mpDragBox->mnConfigItem = 0;
    1352         [ #  # ]:          0 :             if ( !mbResizeMode )
    1353         [ #  # ]:          0 :                 mpDragBox->Invalidate( mpDragBox->GetItemRect( nTempItem ) );
    1354                 :            :         }
    1355                 :            : 
    1356 [ #  # ][ #  # ]:          0 :         if ( bOK && (maRect != maStartRect) )
                 [ #  # ]
    1357                 :            :         {
    1358         [ #  # ]:          0 :             if ( mbResizeMode )
    1359                 :            :             {
    1360         [ #  # ]:          0 :                 ImplToolItem* pItem = mpDragBox->ImplGetItem( nTempItem );
    1361         [ #  # ]:          0 :                 Size aSize = pItem->mpWindow->GetSizePixel();
    1362         [ #  # ]:          0 :                 aSize.Width() = maRect.GetWidth();
    1363         [ #  # ]:          0 :                 pItem->mpWindow->SetSizePixel( aSize );
    1364                 :            : 
    1365                 :            :                 // re-calculate and show ToolBox
    1366         [ #  # ]:          0 :                 mpDragBox->ImplInvalidate( sal_True );
    1367                 :            :                 mpDragBox->Customize( ToolBoxCustomizeEvent( mpDragBox, nTempItem,
    1368                 :            :                                                              TOOLBOX_CUSTOMIZE_RESIZE,
    1369 [ #  # ][ #  # ]:          0 :                                                              mpCustomizeData ) );
    1370                 :            :             }
    1371                 :            :             else
    1372                 :            :             {
    1373         [ #  # ]:          0 :                 Point aOff = mpDragBox->OutputToScreenPixel( Point() );
    1374                 :          0 :                 Rectangle aScreenRect( maRect );
    1375         [ #  # ]:          0 :                 aScreenRect.Move( aOff.X(), aOff.Y() );
    1376         [ #  # ]:          0 :                 ToolBox* pDropBox = FindToolBox( aScreenRect );
    1377         [ #  # ]:          0 :                 if ( pDropBox )
    1378                 :            :                 {
    1379                 :            :                     // Determine search position
    1380                 :          0 :                     Point aPos;
    1381         [ #  # ]:          0 :                     if ( pDropBox->mbHorz )
    1382                 :            :                     {
    1383                 :          0 :                         aPos.X() = aScreenRect.Left()-TB_CUSTOMIZE_OFFSET;
    1384         [ #  # ]:          0 :                         aPos.Y() = aScreenRect.Center().Y();
    1385                 :            :                     }
    1386                 :            :                     else
    1387                 :            :                     {
    1388         [ #  # ]:          0 :                         aPos.X() = aScreenRect.Center().X();
    1389                 :          0 :                         aPos.Y() = aScreenRect.Top()-TB_CUSTOMIZE_OFFSET;
    1390                 :            :                     }
    1391                 :            : 
    1392         [ #  # ]:          0 :                     aPos = pDropBox->ScreenToOutputPixel( aPos );
    1393         [ #  # ]:          0 :                     sal_uInt16 nPos = ToolBox::ImplFindItemPos( pDropBox, aPos );
    1394                 :            :                     mpDragBox->Customize( ToolBoxCustomizeEvent( pDropBox, nTempItem,
    1395 [ #  # ][ #  # ]:          0 :                                                                  nPos, mpCustomizeData ) );
    1396                 :            :                 }
    1397                 :            :                 else
    1398                 :            :                 {
    1399                 :            :                     mpDragBox->Customize( ToolBoxCustomizeEvent( NULL, nTempItem,
    1400 [ #  # ][ #  # ]:          0 :                                                                  0, mpCustomizeData ) );
    1401                 :            :                 }
    1402                 :            :             }
    1403                 :            :         }
    1404                 :          0 :         mpCustomizeData = NULL;
    1405                 :          0 :         mbResizeMode = sal_False;
    1406                 :          0 :         mpDragBox->Deactivate();
    1407                 :            :     }
    1408                 :            : 
    1409                 :          0 :     mpDragBox = NULL;
    1410                 :          0 : }
    1411                 :            : 
    1412                 :            : // -----------------------------------------------------------------------
    1413                 :            : 
    1414                 :          0 : void ImplTBDragMgr::UpdateDragRect()
    1415                 :            : {
    1416                 :            :     // Only update if we're already dragging
    1417         [ #  # ]:          0 :     if ( !mbShowDragRect )
    1418                 :          0 :         return;
    1419                 :            : 
    1420                 :          0 :     mpDragBox->ShowTracking( maRect );
    1421                 :            : }
    1422                 :            : 
    1423                 :            : // -----------------------------------------------------------------------
    1424                 :            : 
    1425                 :          0 : IMPL_LINK( ImplTBDragMgr, SelectHdl, Accelerator*, pAccel )
    1426                 :            : {
    1427         [ #  # ]:          0 :     if ( pAccel->GetCurItemId() == KEY_ESCAPE )
    1428                 :          0 :         EndDragging( sal_False );
    1429                 :            :     else
    1430                 :          0 :         EndDragging( sal_True );
    1431                 :            : 
    1432                 :          0 :     return sal_True;
    1433                 :            : }
    1434                 :            : 
    1435                 :            : // -----------------------------------------------------------------------
    1436                 :            : 
    1437                 :      10254 : void ToolBox::ImplInit( Window* pParent, WinBits nStyle )
    1438                 :            : {
    1439                 :            : 
    1440                 :            :     // initialize variables
    1441                 :      10254 :     ImplGetWindowImpl()->mbToolBox         = sal_True;
    1442         [ +  - ]:      10254 :     mpData                = new ImplToolBoxPrivateData;
    1443                 :      10254 :     mpFloatWin        = NULL;
    1444                 :      10254 :     mnDX              = 0;
    1445                 :      10254 :     mnDY              = 0;
    1446                 :      10254 :     mnMaxItemWidth    = 0;
    1447                 :      10254 :     mnMaxItemHeight   = 0;
    1448                 :      10254 :     mnWinHeight       = 0;
    1449                 :      10254 :     mnLeftBorder      = 0;
    1450                 :      10254 :     mnTopBorder       = 0;
    1451                 :      10254 :     mnRightBorder     = 0;
    1452                 :      10254 :     mnBottomBorder    = 0;
    1453                 :      10254 :     mnLastResizeDY    = 0;
    1454                 :      10254 :     mnOutStyle        = TOOLBOX_STYLE_FLAT; // force flat buttons since NWF
    1455                 :      10254 :     mnHighItemId      = 0;
    1456                 :      10254 :     mnCurItemId       = 0;
    1457                 :      10254 :     mnDownItemId      = 0;
    1458                 :      10254 :     mnCurPos          = TOOLBOX_ITEM_NOTFOUND;
    1459                 :      10254 :     mnFocusPos        = TOOLBOX_ITEM_NOTFOUND;    // current position during keyboard access
    1460                 :      10254 :     mnLines           = 1;
    1461                 :      10254 :     mnCurLine         = 1;
    1462                 :      10254 :     mnCurLines        = 1;
    1463                 :      10254 :     mnVisLines        = 1;
    1464                 :      10254 :     mnFloatLines      = 0;
    1465                 :      10254 :     mnConfigItem      = 0;
    1466                 :      10254 :     mnMouseClicks     = 0;
    1467                 :      10254 :     mnMouseModifier   = 0;
    1468                 :      10254 :     mbDrag            = sal_False;
    1469                 :      10254 :     mbSelection       = sal_False;
    1470                 :      10254 :     mbCommandDrag     = sal_False;
    1471                 :      10254 :     mbUpper           = sal_False;
    1472                 :      10254 :     mbLower           = sal_False;
    1473                 :      10254 :     mbIn              = sal_False;
    1474                 :      10254 :     mbCalc            = sal_True;
    1475                 :      10254 :     mbFormat          = sal_False;
    1476                 :      10254 :     mbFullPaint       = sal_False;
    1477                 :      10254 :     mbHorz            = sal_True;
    1478                 :      10254 :     mbScroll          = (nStyle & WB_SCROLL) != 0;
    1479                 :      10254 :     mbCustomize       = sal_False;
    1480                 :      10254 :     mbCustomizeMode   = sal_False;
    1481                 :      10254 :     mbDragging        = sal_False;
    1482                 :      10254 :     mbMenuStrings     = sal_False;
    1483                 :      10254 :     mbIsShift          = sal_False;
    1484                 :      10254 :     mbIsKeyEvent = sal_False;
    1485                 :      10254 :     mbChangingHighlight = sal_False;
    1486                 :      10254 :     meButtonType      = BUTTON_SYMBOL;
    1487                 :      10254 :     meAlign           = WINDOWALIGN_TOP;
    1488                 :      10254 :     meLastStyle       = POINTER_ARROW;
    1489                 :      10254 :     mnWinStyle        = nStyle;
    1490                 :      10254 :     meLayoutMode      = TBX_LAYOUT_NORMAL;
    1491                 :      10254 :     mnLastFocusItemId = 0;
    1492                 :      10254 :     mnKeyModifier     = 0;
    1493                 :      10254 :     mnActivateCount   = 0;
    1494                 :            : 
    1495                 :      10254 :     maTimer.SetTimeout( 50 );
    1496                 :      10254 :     maTimer.SetTimeoutHdl( LINK( this, ToolBox, ImplUpdateHdl ) );
    1497                 :            : 
    1498                 :            :     // set timeout and handler for dropdown items
    1499                 :      10254 :     mpData->maDropdownTimer.SetTimeout( 250 );
    1500                 :      10254 :     mpData->maDropdownTimer.SetTimeoutHdl( LINK( this, ToolBox, ImplDropdownLongClickHdl ) );
    1501                 :            : 
    1502                 :      10254 :     DockingWindow::ImplInit( pParent, nStyle & ~(WB_BORDER) );
    1503                 :            : 
    1504                 :            : 
    1505                 :            :     // always set WB_TABSTOP for ToolBars !!!  if( mnWinStyle & WB_TABSTOP )
    1506                 :            :     {
    1507                 :            :         // dockingwindow's ImplInit removes some bits, so restore them here
    1508                 :            :         // to allow keyboard handling for toolbars
    1509                 :      10254 :         ImplGetWindowImpl()->mnStyle |= WB_TABSTOP|WB_NODIALOGCONTROL;
    1510                 :      10254 :         ImplGetWindowImpl()->mnStyle &= ~WB_DIALOGCONTROL;
    1511                 :            :     }
    1512                 :            : 
    1513                 :      10254 :     ImplInitSettings( sal_True, sal_True, sal_True );
    1514                 :      10254 : }
    1515                 :            : 
    1516                 :            : // -----------------------------------------------------------------------
    1517                 :            : 
    1518                 :      10428 : void ToolBox::ImplInitSettings( sal_Bool bFont,
    1519                 :            :                                 sal_Bool bForeground, sal_Bool bBackground )
    1520                 :            : {
    1521                 :      10428 :     mpData->mbNativeButtons = IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON );
    1522                 :            : 
    1523                 :      10428 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    1524                 :            : 
    1525         [ +  - ]:      10428 :     if ( bFont )
    1526                 :            :     {
    1527         [ +  - ]:      10428 :         Font aFont = rStyleSettings.GetToolFont();
    1528 [ +  - ][ -  + ]:      10428 :         if ( IsControlFont() )
    1529 [ #  # ][ #  # ]:          0 :             aFont.Merge( GetControlFont() );
                 [ #  # ]
    1530 [ +  - ][ +  - ]:      10428 :         SetZoomedPointFont( aFont );
    1531                 :            :     }
    1532                 :            : 
    1533 [ -  + ][ #  # ]:      10428 :     if ( bForeground || bFont )
    1534                 :            :     {
    1535                 :      10428 :         Color aColor;
    1536 [ -  + ][ +  - ]:      10428 :         if ( IsControlForeground() )
    1537         [ #  # ]:          0 :             aColor = GetControlForeground();
    1538 [ +  - ][ +  + ]:      10428 :         else if ( Window::GetStyle() & WB_3DLOOK )
    1539                 :       7010 :             aColor = rStyleSettings.GetButtonTextColor();
    1540                 :            :         else
    1541                 :       3418 :             aColor = rStyleSettings.GetWindowTextColor();
    1542         [ +  - ]:      10428 :         SetTextColor( aColor );
    1543         [ +  - ]:      10428 :         SetTextFillColor();
    1544                 :            :     }
    1545                 :            : 
    1546         [ +  - ]:      10428 :     if ( bBackground )
    1547                 :            :     {
    1548                 :      10428 :         Color aColor;
    1549 [ -  + ][ +  - ]:      10428 :         if ( IsControlBackground() )
    1550                 :            :         {
    1551         [ #  # ]:          0 :             aColor = GetControlBackground();
    1552 [ #  # ][ #  # ]:          0 :             SetBackground( aColor );
                 [ #  # ]
    1553         [ #  # ]:          0 :             SetPaintTransparent( sal_False );
    1554         [ #  # ]:          0 :             SetParentClipMode( 0 );
    1555                 :            :         }
    1556                 :            :         else
    1557                 :            :         {
    1558 [ +  - ][ -  + ]:      10428 :             if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
    1559                 :            :             {
    1560         [ #  # ]:          0 :                 SetBackground();
    1561         [ #  # ]:          0 :                 SetPaintTransparent( sal_True );
    1562         [ #  # ]:          0 :                 SetParentClipMode( PARENTCLIPMODE_NOCLIP );
    1563 [ #  # ][ #  # ]:          0 :                 mpData->maDisplayBackground = Wallpaper( rStyleSettings.GetFaceColor() );
                 [ #  # ]
    1564                 :            :             }
    1565                 :            :             else
    1566                 :            :             {
    1567 [ +  - ][ +  + ]:      10428 :                 if ( Window::GetStyle() & WB_3DLOOK )
    1568                 :       7010 :                     aColor = rStyleSettings.GetFaceColor();
    1569                 :            :                 else
    1570                 :       3418 :                     aColor = rStyleSettings.GetWindowColor();
    1571                 :            : 
    1572 [ +  - ][ +  - ]:      10428 :                 SetBackground( aColor );
                 [ +  - ]
    1573         [ +  - ]:      10428 :                 SetPaintTransparent( sal_False );
    1574         [ +  - ]:      10428 :                 SetParentClipMode( 0 );
    1575                 :            : 
    1576         [ +  - ]:      10428 :                 ImplUpdateImageList();
    1577                 :            :             }
    1578                 :            :         }
    1579                 :            :     }
    1580                 :      10428 : }
    1581                 :            : 
    1582                 :            : // -----------------------------------------------------------------------
    1583                 :            : 
    1584                 :        460 : void ToolBox::ImplLoadRes( const ResId& rResId )
    1585                 :            : {
    1586                 :        460 :     ResMgr* pMgr = rResId.GetResMgr();
    1587         [ -  + ]:        460 :     if( ! pMgr )
    1588                 :        460 :         return;
    1589                 :            : 
    1590                 :        460 :     DockingWindow::ImplLoadRes( rResId );
    1591                 :            : 
    1592                 :            :     sal_uLong              nObjMask;
    1593                 :            : 
    1594                 :        460 :     nObjMask = ReadLongRes();
    1595                 :            : 
    1596         [ -  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_BUTTONTYPE )
    1597                 :          0 :         SetButtonType( (ButtonType)ReadLongRes() );
    1598                 :            : 
    1599         [ -  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_ALIGN )
    1600                 :          0 :         SetAlign( (WindowAlign)ReadLongRes() );
    1601                 :            : 
    1602         [ +  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_LINECOUNT )
    1603                 :        340 :         SetLineCount( sal::static_int_cast<sal_uInt16>(ReadLongRes()) );
    1604                 :            : 
    1605         [ -  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_CUSTOMIZE )
    1606                 :            :     {
    1607                 :          0 :         sal_Bool bCust = (sal_Bool)ReadShortRes();
    1608                 :          0 :         EnableCustomize( bCust );
    1609                 :            :     }
    1610                 :            : 
    1611         [ -  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_MENUSTRINGS )
    1612                 :            :     {
    1613                 :          0 :         sal_Bool bCust = (sal_Bool)ReadShortRes();
    1614                 :          0 :         EnableMenuStrings( bCust );
    1615                 :            :     }
    1616                 :            : 
    1617         [ -  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_FLOATLINES )
    1618                 :          0 :         SetFloatingLines( ReadShortRes() );
    1619                 :            : 
    1620         [ +  + ]:        460 :     if ( nObjMask & RSC_TOOLBOX_ITEMIMAGELIST )
    1621                 :            :     {
    1622 [ +  - ][ +  - ]:        120 :         maImageList = ImageList( ResId( (RSHEADER_TYPE*)GetClassRes(), *pMgr ) );
                 [ +  - ]
    1623                 :        120 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
    1624                 :            :     }
    1625                 :            : 
    1626         [ +  - ]:        460 :     if ( nObjMask & RSC_TOOLBOX_ITEMLIST )
    1627                 :            :     {
    1628                 :        460 :         sal_uLong nEle = ReadLongRes();
    1629                 :            : 
    1630                 :            :         // insert item
    1631         [ +  + ]:       8810 :         for ( sal_uLong i = 0; i < nEle; i++ )
    1632                 :            :         {
    1633         [ +  - ]:       8350 :             InsertItem( ResId( (RSHEADER_TYPE *)GetClassRes(), *pMgr ) );
    1634                 :       8350 :             IncrementRes( GetObjSizeRes( (RSHEADER_TYPE *)GetClassRes() ) );
    1635                 :            :         }
    1636                 :            :     }
    1637                 :            : }
    1638                 :            : 
    1639                 :            : // -----------------------------------------------------------------------
    1640                 :            : 
    1641                 :       9794 : ToolBox::ToolBox( Window* pParent, WinBits nStyle ) :
    1642 [ +  - ][ +  - ]:       9794 :     DockingWindow( WINDOW_TOOLBOX )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1643                 :            : {
    1644         [ +  - ]:       9794 :     ImplInit( pParent, nStyle );
    1645                 :       9794 : }
    1646                 :            : 
    1647                 :            : // -----------------------------------------------------------------------
    1648                 :            : 
    1649                 :        460 : ToolBox::ToolBox( Window* pParent, const ResId& rResId ) :
    1650 [ +  - ][ +  - ]:        460 :     DockingWindow( WINDOW_TOOLBOX )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1651                 :            : {
    1652                 :            :     RTL_LOGFILE_CONTEXT( aLog, "vcl: ToolBox::ToolBox( Window* pParent, const ResId& rResId )" );
    1653                 :            : 
    1654                 :        460 :     rResId.SetRT( RSC_TOOLBOX );
    1655         [ +  - ]:        460 :     WinBits nStyle = ImplInitRes( rResId );
    1656         [ +  - ]:        460 :     ImplInit( pParent, nStyle );
    1657         [ +  - ]:        460 :     ImplLoadRes( rResId );
    1658                 :            : 
    1659                 :            :     // calculate size of floating windows and switch if the
    1660                 :            :     // toolbox is initially in floating mode
    1661 [ +  - ][ -  + ]:        460 :     if ( ImplIsFloatingMode() )
    1662                 :          0 :         mbHorz = sal_True;
    1663                 :            :     else
    1664         [ +  - ]:        460 :         Resize();
    1665                 :            : 
    1666         [ +  + ]:        460 :     if ( !(nStyle & WB_HIDE) )
    1667         [ +  - ]:        154 :         Show();
    1668                 :        460 : }
    1669                 :            : 
    1670                 :            : // -----------------------------------------------------------------------
    1671                 :            : 
    1672 [ +  - ][ +  - ]:       9977 : ToolBox::~ToolBox()
    1673                 :            : {
    1674                 :            :     // custom menu event still running?
    1675         [ -  + ]:       9977 :     if( mpData->mnEventId )
    1676         [ #  # ]:          0 :         Application::RemoveUserEvent( mpData->mnEventId );
    1677                 :            : 
    1678                 :            :     // #103005# make sure our activate/deactivate balance is right
    1679         [ -  + ]:       9977 :     while( mnActivateCount > 0 )
    1680         [ #  # ]:          0 :         Deactivate();
    1681                 :            : 
    1682                 :            :     // terminate popupmode if the floating window is
    1683                 :            :     // still connected
    1684         [ -  + ]:       9977 :     if ( mpFloatWin )
    1685         [ #  # ]:          0 :         mpFloatWin->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
    1686                 :            : 
    1687                 :            :     // delete private data
    1688 [ +  - ][ +  - ]:       9977 :     delete mpData;
    1689                 :            : 
    1690                 :            :     // remove the lists when there are no more toolbox references to
    1691                 :            :     // the lists
    1692         [ +  - ]:       9977 :     ImplSVData* pSVData = ImplGetSVData();
    1693         [ +  + ]:       9977 :     if ( pSVData->maCtrlData.mpTBDragMgr )
    1694                 :            :     {
    1695                 :            :         // remove if in TBDrag-Manager
    1696         [ +  + ]:       8539 :         if ( mbCustomize )
    1697         [ +  - ]:       3527 :             pSVData->maCtrlData.mpTBDragMgr->erase( this );
    1698                 :            : 
    1699         [ +  + ]:       8539 :         if ( !pSVData->maCtrlData.mpTBDragMgr->size() )
    1700                 :            :         {
    1701 [ +  - ][ +  - ]:       1456 :             delete pSVData->maCtrlData.mpTBDragMgr;
    1702                 :       1456 :             pSVData->maCtrlData.mpTBDragMgr = NULL;
    1703                 :            :         }
    1704                 :            :     }
    1705         [ -  + ]:      12401 : }
    1706                 :            : 
    1707                 :            : // -----------------------------------------------------------------------
    1708                 :            : 
    1709                 :     721536 : ImplToolItem* ToolBox::ImplGetItem( sal_uInt16 nItemId ) const
    1710                 :            : {
    1711                 :     721536 :     std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
    1712 [ +  - ][ +  + ]:   13765196 :     while ( it != mpData->m_aItems.end() )
    1713                 :            :     {
    1714         [ +  + ]:   13764407 :         if ( it->mnId == nItemId )
    1715                 :     720747 :             return &(*it);
    1716                 :   13043660 :         ++it;
    1717                 :            :     }
    1718                 :            : 
    1719                 :     721536 :     return NULL;
    1720                 :            : }
    1721                 :            : // -----------------------------------------------------------------------
    1722                 :            : 
    1723                 :      95543 : static void ImplAddButtonBorder( long &rWidth, long& rHeight, sal_Bool bNativeButtons )
    1724                 :            : {
    1725                 :      95543 :     rWidth += SMALLBUTTON_HSIZE;
    1726                 :      95543 :     rHeight += SMALLBUTTON_VSIZE;
    1727                 :            : 
    1728         [ -  + ]:      95543 :     if( bNativeButtons )
    1729                 :            :     {
    1730                 :            :         // give more border space for rounded buttons
    1731                 :          0 :         rWidth += 2;
    1732                 :          0 :         rHeight += 4;
    1733                 :            :     }
    1734                 :      95543 : }
    1735                 :            : 
    1736                 :            : // -----------------------------------------------------------------------
    1737                 :            : 
    1738                 :      31486 : sal_Bool ToolBox::ImplCalcItem()
    1739                 :            : {
    1740                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    1741                 :            : 
    1742                 :            :     // recalc required ?
    1743         [ +  + ]:      31486 :     if ( !mbCalc )
    1744                 :      21323 :         return sal_False;
    1745                 :            : 
    1746                 :      10163 :     ImplDisableFlatButtons();
    1747                 :            : 
    1748                 :            :     long            nDefWidth;
    1749                 :            :     long            nDefHeight;
    1750                 :      10163 :     long            nMaxWidth = 0;
    1751                 :      10163 :     long            nMaxHeight = 0;
    1752                 :      10163 :     long            nMinWidth   = 6;
    1753                 :      10163 :     long            nMinHeight  = 6;
    1754                 :      10163 :     long            nDropDownArrowWidth = TB_DROPDOWNARROWWIDTH;
    1755                 :            : 
    1756                 :            :     // set defaults if image or text is needed but empty
    1757         [ +  - ]:      10163 :     nDefWidth       = GetDefaultImageSize().Width();
    1758         [ +  - ]:      10163 :     nDefHeight      = GetDefaultImageSize().Height();
    1759                 :            : 
    1760                 :      10163 :     mnWinHeight = 0;
    1761                 :            :     // determine minimum size necessary in NWF
    1762                 :            :     {
    1763         [ +  - ]:      10163 :         Rectangle aRect( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
    1764                 :      10163 :         Rectangle aReg( aRect );
    1765                 :      10163 :         ImplControlValue aVal;
    1766 [ +  - ][ +  - ]:      10163 :         Rectangle aNativeBounds, aNativeContent;
    1767 [ +  - ][ -  + ]:      10163 :         if( IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) )
    1768                 :            :         {
    1769         [ #  # ]:          0 :             if( GetNativeControlRegion( CTRL_TOOLBAR, PART_BUTTON,
    1770                 :            :                                         aReg,
    1771                 :            :                                         CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
    1772                 :            :                                         aVal, OUString(),
    1773         [ #  # ]:          0 :                                         aNativeBounds, aNativeContent ) )
    1774                 :            :             {
    1775                 :          0 :                 aRect = aNativeBounds;
    1776 [ #  # ][ #  # ]:          0 :                 if( aRect.GetWidth() > nMinWidth )
    1777         [ #  # ]:          0 :                     nMinWidth = aRect.GetWidth();
    1778 [ #  # ][ #  # ]:          0 :                 if( aRect.GetHeight() > nMinHeight )
    1779         [ #  # ]:          0 :                     nMinHeight = aRect.GetHeight();
    1780         [ #  # ]:          0 :                 if( nDropDownArrowWidth < nMinWidth )
    1781                 :          0 :                     nDropDownArrowWidth = nMinWidth;
    1782         [ #  # ]:          0 :                 if( nMinWidth > mpData->mnMenuButtonWidth )
    1783                 :          0 :                     mpData->mnMenuButtonWidth = nMinWidth;
    1784         [ #  # ]:          0 :                 else if( nMinWidth < TB_MENUBUTTON_SIZE )
    1785                 :          0 :                     mpData->mnMenuButtonWidth = TB_MENUBUTTON_SIZE;
    1786                 :            :             }
    1787                 :            :         }
    1788                 :            : 
    1789                 :            :         // also calculate the area for comboboxes, drop down list boxes and spinfields
    1790                 :            :         // as these are often inserted into toolboxes; set mnWinHeight to the
    1791                 :            :         // greater of those values to prevent toolbar flickering (#i103385#)
    1792         [ +  - ]:      10163 :         aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
    1793                 :      10163 :         aReg = aRect;
    1794         [ -  + ]:      10163 :         if( GetNativeControlRegion( CTRL_COMBOBOX, PART_ENTIRE_CONTROL,
    1795                 :            :                                     aReg,
    1796                 :            :                                     CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
    1797                 :            :                                     aVal, OUString(),
    1798         [ +  - ]:      10163 :                                     aNativeBounds, aNativeContent ) )
    1799                 :            :         {
    1800                 :          0 :             aRect = aNativeBounds;
    1801 [ #  # ][ #  # ]:          0 :             if( aRect.GetHeight() > mnWinHeight )
    1802         [ #  # ]:          0 :                 mnWinHeight = aRect.GetHeight();
    1803                 :            :         }
    1804         [ +  - ]:      10163 :         aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
    1805                 :      10163 :         aReg = aRect;
    1806         [ -  + ]:      10163 :         if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL,
    1807                 :            :                                     aReg,
    1808                 :            :                                     CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
    1809                 :            :                                     aVal, OUString(),
    1810         [ +  - ]:      10163 :                                     aNativeBounds, aNativeContent ) )
    1811                 :            :         {
    1812                 :          0 :             aRect = aNativeBounds;
    1813 [ #  # ][ #  # ]:          0 :             if( aRect.GetHeight() > mnWinHeight )
    1814         [ #  # ]:          0 :                 mnWinHeight = aRect.GetHeight();
    1815                 :            :         }
    1816         [ +  - ]:      10163 :         aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
    1817                 :      10163 :         aReg = aRect;
    1818         [ -  + ]:      10163 :         if( GetNativeControlRegion( CTRL_SPINBOX, PART_ENTIRE_CONTROL,
    1819                 :            :                                     aReg,
    1820                 :            :                                     CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
    1821                 :            :                                     aVal, OUString(),
    1822         [ +  - ]:      10163 :                                     aNativeBounds, aNativeContent ) )
    1823                 :            :         {
    1824                 :          0 :             aRect = aNativeBounds;
    1825 [ #  # ][ #  # ]:          0 :             if( aRect.GetHeight() > mnWinHeight )
    1826         [ #  # ]:          0 :                 mnWinHeight = aRect.GetHeight();
    1827         [ +  - ]:      10163 :         }
    1828                 :            :     }
    1829                 :            : 
    1830         [ +  + ]:      10163 :     if ( ! mpData->m_aItems.empty() )
    1831                 :            :     {
    1832                 :       8969 :         std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
    1833 [ +  - ][ +  + ]:     123306 :         while ( it != mpData->m_aItems.end() )
    1834                 :            :         {
    1835                 :            :             sal_Bool bImage;
    1836                 :            :             sal_Bool bText;
    1837                 :            : 
    1838                 :     114337 :             it->mbVisibleText = sal_False;  // indicates if text will definitely be drawn, influences dropdown pos
    1839                 :            : 
    1840         [ +  + ]:     114337 :             if ( it->meType == TOOLBOXITEM_BUTTON )
    1841                 :            :             {
    1842                 :            :                 // check if image and/or text exists
    1843         [ +  + ]:      90360 :                 if ( !(it->maImage) )
    1844                 :       3352 :                     bImage = sal_False;
    1845                 :            :                 else
    1846                 :      87008 :                     bImage = sal_True;
    1847         [ +  + ]:      90360 :                 if ( !it->maText.Len() )
    1848                 :       7481 :                     bText = sal_False;
    1849                 :            :                 else
    1850                 :      82879 :                     bText = sal_True;
    1851                 :      90360 :                 ButtonType tmpButtonType = determineButtonType( &(*it), meButtonType ); // default to toolbox setting
    1852 [ +  + ][ +  + ]:      90360 :                 if ( bImage || bText )
    1853                 :            :                 {
    1854                 :            : 
    1855                 :      88423 :                     it->mbEmptyBtn = sal_False;
    1856                 :            : 
    1857         [ +  - ]:     176846 :                     if ( tmpButtonType == BUTTON_SYMBOL )
    1858                 :            :                     {
    1859                 :            :                         // we're drawing images only
    1860 [ +  + ][ -  + ]:      88423 :                         if ( bImage || !bText )
    1861                 :            :                         {
    1862         [ +  - ]:      87008 :                             it->maItemSize = it->maImage.GetSizePixel();
    1863                 :            :                         }
    1864                 :            :                         else
    1865                 :            :                         {
    1866         [ +  - ]:       2830 :                             it->maItemSize = Size( GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET,
    1867         [ +  - ]:       2830 :                                                    GetTextHeight() );
    1868                 :      88423 :                             it->mbVisibleText = sal_True;
    1869                 :            :                         }
    1870                 :            :                     }
    1871         [ #  # ]:          0 :                     else if ( tmpButtonType == BUTTON_TEXT )
    1872                 :            :                     {
    1873                 :            :                         // we're drawing text only
    1874 [ #  # ][ #  # ]:          0 :                         if ( bText || !bImage )
    1875                 :            :                         {
    1876         [ #  # ]:          0 :                             it->maItemSize = Size( GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET,
    1877         [ #  # ]:          0 :                                                    GetTextHeight() );
    1878                 :          0 :                             it->mbVisibleText = sal_True;
    1879                 :            :                         }
    1880                 :            :                         else
    1881                 :            :                         {
    1882         [ #  # ]:          0 :                             it->maItemSize = it->maImage.GetSizePixel();
    1883                 :            :                         }
    1884                 :            :                     }
    1885                 :            :                     else
    1886                 :            :                     {
    1887                 :            :                         // we're drawing images and text
    1888 [ #  # ][ #  # ]:          0 :                         it->maItemSize.Width() = bText ? GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET : 0;
    1889 [ #  # ][ #  # ]:          0 :                         it->maItemSize.Height() = bText ? GetTextHeight() : 0;
    1890                 :            : 
    1891                 :            :                         // leave space between image and text
    1892         [ #  # ]:          0 :                         if( bText )
    1893                 :          0 :                             it->maItemSize.Width() += TB_IMAGETEXTOFFSET;
    1894                 :            : 
    1895                 :            :                         // image and text side by side
    1896         [ #  # ]:          0 :                         it->maItemSize.Width() += it->maImage.GetSizePixel().Width();
    1897 [ #  # ][ #  # ]:          0 :                         if ( it->maImage.GetSizePixel().Height() > it->maItemSize.Height() )
    1898         [ #  # ]:          0 :                             it->maItemSize.Height() = it->maImage.GetSizePixel().Height();
    1899                 :            : 
    1900                 :          0 :                         it->mbVisibleText = bText;
    1901                 :            :                     }
    1902                 :            :                 }
    1903                 :            :                 else
    1904                 :            :                 {   // no image and no text
    1905                 :       1937 :                     it->maItemSize = Size( nDefWidth, nDefHeight );
    1906                 :       1937 :                     it->mbEmptyBtn = sal_True;
    1907                 :            :                 }
    1908                 :            : 
    1909                 :            :                 // if required, take window height into consideration
    1910         [ +  + ]:      90360 :                 if ( it->mpWindow )
    1911                 :            :                 {
    1912         [ +  - ]:       4603 :                     long nHeight = it->mpWindow->GetSizePixel().Height();
    1913         [ +  + ]:       4603 :                     if ( nHeight > mnWinHeight )
    1914                 :       1544 :                         mnWinHeight = nHeight;
    1915                 :            :                 }
    1916                 :            : 
    1917                 :            :                 // add in drop down arrow
    1918         [ +  + ]:      90360 :                 if( it->mnBits & TIB_DROPDOWN )
    1919                 :            :                 {
    1920                 :      13569 :                     it->maItemSize.Width() += nDropDownArrowWidth;
    1921                 :      13569 :                     it->mnDropDownArrowWidth = nDropDownArrowWidth;
    1922                 :            :                 }
    1923                 :            : 
    1924                 :            :                 // text items will be rotated in vertical mode
    1925                 :            :                 // -> swap width and height
    1926 [ +  + ][ -  + ]:      90360 :                 if( it->mbVisibleText && !mbHorz )
                 [ -  + ]
    1927                 :            :                 {
    1928                 :          0 :                     long tmp = it->maItemSize.Width();
    1929                 :          0 :                     it->maItemSize.Width() = it->maItemSize.Height();
    1930                 :          0 :                     it->maItemSize.Height() = tmp;
    1931                 :            :                 }
    1932                 :            :             }
    1933         [ +  + ]:      23977 :             else if ( it->meType == TOOLBOXITEM_SPACE )
    1934                 :            :             {
    1935                 :         34 :                 it->maItemSize = Size( nDefWidth, nDefHeight );
    1936                 :            :             }
    1937                 :            : 
    1938 [ +  + ][ +  + ]:     114337 :             if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE )
                 [ +  + ]
    1939                 :            :             {
    1940                 :            :                 // add borders
    1941                 :      90394 :                 ImplAddButtonBorder( it->maItemSize.Width(), it->maItemSize.Height(), mpData->mbNativeButtons );
    1942                 :            : 
    1943         [ +  + ]:      90394 :                 if( it->meType == TOOLBOXITEM_BUTTON )
    1944                 :            :                 {
    1945         [ -  + ]:      90360 :                     if( it->maItemSize.Width() < nMinWidth )
    1946                 :          0 :                         it->maItemSize.Width() = nMinWidth;
    1947         [ -  + ]:      90360 :                     if( it->maItemSize.Height() < nMinHeight )
    1948                 :          0 :                         it->maItemSize.Height() = nMinHeight;
    1949                 :            :                 }
    1950                 :            : 
    1951                 :            :                 // keep track of max item size
    1952         [ +  + ]:      90394 :                 if ( it->maItemSize.Width() > nMaxWidth )
    1953                 :      13135 :                     nMaxWidth = it->maItemSize.Width();
    1954         [ +  + ]:      90394 :                 if ( it->maItemSize.Height() > nMaxHeight )
    1955                 :       9212 :                     nMaxHeight = it->maItemSize.Height();
    1956                 :            :             }
    1957                 :            : 
    1958                 :     114337 :             ++it;
    1959                 :            :         }
    1960                 :            :     }
    1961                 :            :     else
    1962                 :            :     {
    1963                 :       1194 :         nMaxWidth  = nDefWidth;
    1964                 :       1194 :         nMaxHeight = nDefHeight;
    1965                 :            : 
    1966                 :       1194 :         ImplAddButtonBorder( nMaxWidth, nMaxHeight, mpData->mbNativeButtons );
    1967                 :            :     }
    1968                 :            : 
    1969 [ +  - ][ +  - ]:      10163 :     if( !ImplIsFloatingMode() && GetToolboxButtonSize() != TOOLBOX_BUTTONSIZE_DONTCARE )
         [ +  - ][ +  + ]
                 [ +  + ]
    1970                 :            :     {
    1971                 :            :         // make sure all vertical toolbars have the same width and horizontal have the same height
    1972                 :            :         // this depends on the used button sizes
    1973                 :            :         // as this is used for alignement of multiple toolbars
    1974                 :            :         // it is only required for docked toolbars
    1975                 :            : 
    1976                 :       3955 :         long nFixedWidth = nDefWidth+nDropDownArrowWidth;
    1977                 :       3955 :         long nFixedHeight = nDefHeight;
    1978                 :       3955 :         ImplAddButtonBorder( nFixedWidth, nFixedHeight, mpData->mbNativeButtons );
    1979                 :            : 
    1980         [ +  - ]:       3955 :         if( mbHorz )
    1981                 :       3955 :             nMaxHeight = nFixedHeight;
    1982                 :            :         else
    1983                 :       3955 :             nMaxWidth = nFixedWidth;
    1984                 :            :     }
    1985                 :            : 
    1986                 :      10163 :     mbCalc = sal_False;
    1987                 :      10163 :     mbFormat = sal_True;
    1988                 :            : 
    1989                 :            :     // do we have to recalc the sizes ?
    1990 [ +  + ][ -  + ]:      10163 :     if ( (nMaxWidth != mnMaxItemWidth) || (nMaxHeight != mnMaxItemHeight) )
    1991                 :            :     {
    1992                 :       9798 :         mnMaxItemWidth  = nMaxWidth;
    1993                 :       9798 :         mnMaxItemHeight = nMaxHeight;
    1994                 :            : 
    1995                 :       9798 :         return sal_True;
    1996                 :            :     }
    1997                 :            :     else
    1998                 :      31486 :         return sal_False;
    1999                 :            : }
    2000                 :            : 
    2001                 :            : // -----------------------------------------------------------------------
    2002                 :            : 
    2003                 :      30337 : sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool bCalcHorz )
    2004                 :            : {
    2005                 :      30337 :     sal_uLong           nLineStart = 0;
    2006                 :      30337 :     sal_uLong           nGroupStart = 0;
    2007                 :      30337 :     long            nLineWidth = 0;
    2008                 :            :     long            nCurWidth;
    2009                 :      30337 :     long            nLastGroupLineWidth = 0;
    2010                 :      30337 :     long            nMaxLineWidth = 0;
    2011                 :      30337 :     sal_uInt16          nLines = 1;
    2012                 :            :     sal_Bool            bWindow;
    2013                 :      30337 :     sal_Bool            bBreak = sal_False;
    2014                 :      30337 :     long            nWidthTotal = nWidth;
    2015                 :      30337 :     long nMenuWidth = 0;
    2016                 :            : 
    2017                 :            :     // when docked the menubutton will be in the first line
    2018 [ +  - ][ +  + ]:      30337 :     if( IsMenuEnabled() && !ImplIsFloatingMode() )
         [ +  - ][ +  - ]
                 [ +  + ]
    2019                 :      21150 :         nMenuWidth = mpData->maMenubuttonItem.maItemSize.Width();
    2020                 :            : 
    2021                 :            :     // we need to know which item is the last visible one to be able to add
    2022                 :            :     // the menu width in case we are unable to show all the items
    2023                 :      30337 :     std::vector< ImplToolItem >::iterator it, lastVisible;
    2024 [ +  - ][ +  + ]:     626857 :     for ( it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it )
    2025                 :            :     {
    2026         [ +  + ]:     596520 :         if ( it->mbVisible )
    2027                 :     459422 :             lastVisible = it;
    2028                 :            :     }
    2029                 :            : 
    2030                 :      30337 :     it = mpData->m_aItems.begin();
    2031 [ +  - ][ +  + ]:     626857 :     while ( it != mpData->m_aItems.end() )
    2032                 :            :     {
    2033                 :     596520 :         it->mbBreak = bBreak;
    2034                 :     596520 :         bBreak = sal_False;
    2035                 :            : 
    2036         [ +  + ]:     596520 :         if ( it->mbVisible )
    2037                 :            :         {
    2038                 :     459422 :             bWindow     = sal_False;
    2039                 :     459422 :             bBreak      = sal_False;
    2040                 :     459422 :             nCurWidth   = 0;
    2041                 :            : 
    2042 [ +  + ][ +  + ]:     459422 :             if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE )
                 [ +  + ]
    2043                 :            :             {
    2044         [ +  - ]:     334742 :                 if ( bCalcHorz )
    2045                 :     334742 :                     nCurWidth = it->maItemSize.Width();
    2046                 :            :                 else
    2047                 :          0 :                     nCurWidth = it->maItemSize.Height();
    2048                 :            : 
    2049 [ +  + ][ +  - ]:     334742 :                 if ( it->mpWindow && bCalcHorz )
                 [ +  + ]
    2050                 :            :                 {
    2051         [ +  - ]:      23418 :                     long nWinItemWidth = it->mpWindow->GetSizePixel().Width();
    2052 [ +  - ][ +  + ]:      23418 :                     if ( !mbScroll || (nWinItemWidth <= nWidthTotal) )
    2053                 :            :                     {
    2054                 :      23418 :                         nCurWidth = nWinItemWidth;
    2055                 :      23418 :                         bWindow   = sal_True;
    2056                 :            :                     }
    2057                 :            :                     else
    2058                 :            :                     {
    2059         [ #  # ]:          0 :                         if ( it->mbEmptyBtn )
    2060                 :            :                         {
    2061                 :      23418 :                             nCurWidth = 0;
    2062                 :            :                         }
    2063                 :            :                     }
    2064                 :            :                 }
    2065                 :            : 
    2066                 :            :                 // in case we are able to show all the items, we do not want
    2067                 :            :                 // to show the toolbar's menu; otherwise yes
    2068 [ +  - ][ +  + ]:     668720 :                 if ( ( ( it == lastVisible ) && (nLineWidth+nCurWidth > nWidthTotal) && mbScroll ) ||
         [ +  + ][ -  + ]
         [ +  + ][ +  + ]
         [ +  - ][ +  + ]
    2069         [ +  - ]:     333978 :                      ( ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) && mbScroll ) )
    2070                 :        967 :                     bBreak = sal_True;
    2071                 :            :             }
    2072         [ +  + ]:     124680 :             else if ( it->meType == TOOLBOXITEM_SEPARATOR )
    2073                 :            :             {
    2074                 :     123982 :                 nCurWidth = it->mnSepSize;
    2075 [ +  - ][ +  - ]:     123982 :                 if ( !ImplIsFloatingMode() && ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) )
         [ +  + ][ -  + ]
         [ -  + ][ +  - ]
    2076                 :          0 :                     bBreak = sal_True;
    2077                 :            :             }
    2078                 :            :             // treat breaks as separators, except when using old style toolbars (ie. no menu button)
    2079 [ +  - ][ +  - ]:        698 :             else if ( (it->meType == TOOLBOXITEM_BREAK) && !IsMenuEnabled() )
         [ +  + ][ +  + ]
    2080                 :        680 :                 bBreak = sal_True;
    2081                 :            : 
    2082         [ +  + ]:     459422 :             if ( bBreak )
    2083                 :            :             {
    2084                 :       1647 :                 nLines++;
    2085                 :            : 
    2086                 :            :                 // Add break before the entire group or take group apart?
    2087 [ +  + ][ +  - ]:       1647 :                 if ( (it->meType == TOOLBOXITEM_BREAK) ||
                 [ +  - ]
    2088                 :            :                      (nLineStart == nGroupStart) )
    2089                 :            :                 {
    2090         [ +  + ]:       1647 :                     if ( nLineWidth > nMaxLineWidth )
    2091                 :       1305 :                         nMaxLineWidth = nLineWidth;
    2092                 :            : 
    2093                 :       1647 :                     nLineWidth = 0;
    2094         [ +  - ]:       1647 :                     nLineStart = it - mpData->m_aItems.begin();
    2095                 :       1647 :                     nGroupStart = nLineStart;
    2096                 :       1647 :                     it->mbBreak = sal_True;
    2097                 :       1647 :                     bBreak = sal_False;
    2098                 :            :                 }
    2099                 :            :                 else
    2100                 :            :                 {
    2101         [ #  # ]:          0 :                     if ( nLastGroupLineWidth > nMaxLineWidth )
    2102                 :          0 :                         nMaxLineWidth = nLastGroupLineWidth;
    2103                 :            : 
    2104                 :            :                     // if the break is added before the group, set it to
    2105                 :            :                     // beginning of line and re-calculate
    2106                 :          0 :                     nLineWidth = 0;
    2107                 :          0 :                     nLineStart = nGroupStart;
    2108         [ #  # ]:          0 :                     it = mpData->m_aItems.begin() + nGroupStart;
    2109                 :          0 :                     continue;
    2110                 :            :                 }
    2111                 :            :             }
    2112                 :            :             else
    2113                 :            :             {
    2114 [ +  - ][ +  - ]:     457775 :                 if( ImplIsFloatingMode() || !IsMenuEnabled() ) // no group breaking when being docked single-line
         [ +  - ][ +  + ]
                 [ +  + ]
    2115                 :            :                 {
    2116 [ +  + ][ +  + ]:      33189 :                     if ( (it->meType != TOOLBOXITEM_BUTTON) || bWindow )
                 [ +  + ]
    2117                 :            :                     {
    2118                 :            :                         // found separator or break
    2119                 :       8996 :                         nLastGroupLineWidth = nLineWidth;
    2120         [ +  - ]:       8996 :                         nGroupStart = it - mpData->m_aItems.begin();
    2121         [ +  + ]:       8996 :                         if ( !bWindow )
    2122                 :       4360 :                             nGroupStart++;
    2123                 :            :                     }
    2124                 :            :                 }
    2125                 :            :             }
    2126                 :            : 
    2127                 :     459422 :             nLineWidth += nCurWidth;
    2128                 :            :         }
    2129                 :            : 
    2130                 :     596520 :         ++it;
    2131                 :            :     }
    2132                 :            : 
    2133                 :            : 
    2134         [ +  + ]:      30337 :     if ( pMaxLineWidth )
    2135                 :            :     {
    2136         [ +  + ]:      24978 :         if ( nLineWidth > nMaxLineWidth )
    2137                 :      20638 :             nMaxLineWidth = nLineWidth;
    2138                 :            : 
    2139 [ +  - ][ -  + ]:      24978 :         if( ImplIsFloatingMode() && !ImplIsInPopupMode() )
         [ #  # ][ #  # ]
                 [ -  + ]
    2140                 :            :         {
    2141                 :            :             // leave enough space to display buttons in the decoration
    2142                 :          0 :             long aMinWidth = 2 * GetSettings().GetStyleSettings().GetFloatTitleHeight();
    2143         [ #  # ]:          0 :             if( nMaxLineWidth < aMinWidth )
    2144                 :          0 :                 nMaxLineWidth = aMinWidth;
    2145                 :            :         }
    2146                 :      24978 :         *pMaxLineWidth = nMaxLineWidth;
    2147                 :            :     }
    2148                 :            : 
    2149                 :      30337 :     return nLines;
    2150                 :            : }
    2151                 :            : 
    2152                 :            : // -----------------------------------------------------------------------
    2153                 :            : 
    2154                 :          0 : Size ToolBox::ImplGetOptimalFloatingSize()
    2155                 :            : {
    2156 [ #  # ][ #  # ]:          0 :     if( !ImplIsFloatingMode() )
    2157                 :          0 :         return Size();
    2158                 :            : 
    2159                 :          0 :     Size aCurrentSize( mnDX, mnDY );
    2160                 :          0 :     Size aSize1( aCurrentSize );
    2161                 :          0 :     Size aSize2( aCurrentSize );
    2162                 :            : 
    2163                 :            :     // try to preserve current height
    2164                 :            : 
    2165                 :            :     // calc number of floating lines for current window height
    2166                 :          0 :     sal_uInt16 nFloatLinesHeight = ImplCalcLines( this, mnDY );
    2167                 :            :     // calc window size according to this number
    2168         [ #  # ]:          0 :     aSize1 = ImplCalcFloatSize( this, nFloatLinesHeight );
    2169                 :            : 
    2170         [ #  # ]:          0 :     if( aCurrentSize == aSize1 )
    2171                 :          0 :         return aSize1;
    2172                 :            : 
    2173                 :            :     // try to preserve current width
    2174                 :            : 
    2175         [ #  # ]:          0 :     long nLineHeight = ( mnWinHeight > mnMaxItemHeight ) ? mnWinHeight : mnMaxItemHeight;
    2176                 :          0 :     int nBorderX = 2*TB_BORDER_OFFSET1 + mnLeftBorder + mnRightBorder;
    2177                 :          0 :     int nBorderY = 2*TB_BORDER_OFFSET2 + mnTopBorder + mnBottomBorder;
    2178                 :          0 :     Size aSz( aCurrentSize );
    2179                 :            :     long maxX;
    2180         [ #  # ]:          0 :     sal_uInt16 nLines = ImplCalcBreaks( aSz.Width()-nBorderX, &maxX, mbHorz );
    2181                 :            : 
    2182                 :          0 :     sal_uInt16 manyLines = 1000;
    2183         [ #  # ]:          0 :     Size aMinimalFloatSize = ImplCalcFloatSize( this, manyLines );
    2184                 :            : 
    2185                 :          0 :     aSz.Height() = nBorderY + nLineHeight * nLines;
    2186                 :            :     // line space when more than one line
    2187         [ #  # ]:          0 :     if ( mnWinStyle & WB_LINESPACING )
    2188                 :          0 :         aSz.Height() += (nLines-1)*TB_LINESPACING;
    2189                 :            : 
    2190                 :          0 :     aSz.Width() = nBorderX + maxX;
    2191                 :            : 
    2192                 :            :     // avoid clipping of any items
    2193         [ #  # ]:          0 :     if( aSz.Width() < aMinimalFloatSize.Width() )
    2194         [ #  # ]:          0 :         aSize2 = ImplCalcFloatSize( this, nLines );
    2195                 :            :     else
    2196                 :          0 :         aSize2 = aSz;
    2197                 :            : 
    2198         [ #  # ]:          0 :     if( aCurrentSize == aSize2 )
    2199                 :          0 :         return aSize2;
    2200                 :            : 
    2201                 :            :     // set the size with the smallest delta as the current size
    2202                 :          0 :     long dx1 = abs( mnDX - aSize1.Width() );
    2203                 :          0 :     long dy1 = abs( mnDY - aSize1.Height() );
    2204                 :            : 
    2205                 :          0 :     long dx2 = abs( mnDX - aSize2.Width() );
    2206                 :          0 :     long dy2 = abs( mnDY - aSize2.Height() );
    2207                 :            : 
    2208         [ #  # ]:          0 :     if( dx1*dy1 < dx2*dy2 )
    2209                 :          0 :         aCurrentSize = aSize1;
    2210                 :            :     else
    2211                 :          0 :         aCurrentSize = aSize2;
    2212                 :            : 
    2213                 :          0 :     return aCurrentSize;
    2214                 :            : }
    2215                 :            : 
    2216                 :            : namespace
    2217                 :            : {
    2218                 :       5359 : static void lcl_hideDoubleSeparators( std::vector< ImplToolItem >& rItems )
    2219                 :            : {
    2220                 :       5359 :     bool bLastSep( true );
    2221                 :       5359 :     std::vector< ImplToolItem >::iterator it;
    2222 [ +  - ][ +  + ]:     124000 :     for ( it = rItems.begin(); it != rItems.end(); ++it )
    2223                 :            :     {
    2224         [ +  + ]:     118641 :         if ( it->meType == TOOLBOXITEM_SEPARATOR )
    2225                 :            :         {
    2226                 :      25905 :             it->mbVisible = sal_False;
    2227         [ +  + ]:      25905 :             if ( !bLastSep )
    2228                 :            :             {
    2229                 :            :                 // check if any visible items have to appear behind it
    2230                 :      22500 :                 std::vector< ImplToolItem >::iterator temp_it;
    2231 [ +  - ][ +  - ]:      59317 :                 for ( temp_it = it+1; temp_it != rItems.end(); ++temp_it )
                 [ +  + ]
    2232                 :            :                 {
    2233   [ +  +  +  + ]:      70373 :                     if ( ((temp_it->meType == TOOLBOXITEM_BUTTON) &&
                 [ +  + ]
    2234                 :      33556 :                           temp_it->mbVisible) )
    2235                 :            :                     {
    2236                 :      21728 :                         it->mbVisible = sal_True;
    2237                 :      21728 :                         break;
    2238                 :            :                     }
    2239                 :            :                 }
    2240                 :            :             }
    2241                 :      25905 :             bLastSep = true;
    2242                 :            :         }
    2243         [ +  + ]:      92736 :         else if ( it->mbVisible )
    2244                 :      65166 :             bLastSep = false;
    2245                 :            :     }
    2246                 :       5359 : }
    2247                 :            : }
    2248                 :            : 
    2249                 :      27626 : void ToolBox::ImplFormat( sal_Bool bResize )
    2250                 :            : {
    2251                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    2252                 :            : 
    2253                 :            :     // Has to re-formatted
    2254         [ +  + ]:      27626 :     if ( !mbFormat )
    2255                 :      27626 :         return;
    2256                 :            : 
    2257         [ +  - ]:       6508 :     mpData->ImplClearLayoutData();
    2258                 :            : 
    2259                 :            :     // recalulate positions and sizes
    2260         [ +  - ]:       6508 :     Rectangle       aEmptyRect;
    2261                 :            :     long            nLineSize;
    2262                 :            :     long            nLeft;
    2263                 :            :     long            nTop;
    2264                 :            :     long            nMax;   // width of layoutarea in pixels
    2265                 :            :     sal_uInt16          nFormatLine;
    2266                 :            :     sal_Bool            bMustFullPaint;
    2267                 :            : 
    2268                 :       6508 :     std::vector< ImplToolItem >::iterator   it;
    2269                 :            : 
    2270 [ +  - ][ +  - ]:       6508 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
    2271         [ +  - ]:       6508 :     sal_Bool bIsInPopupMode = ImplIsInPopupMode();
    2272                 :            : 
    2273                 :       6508 :     maFloatSizes.clear();
    2274                 :            : 
    2275                 :            :     // compute border sizes
    2276         [ +  - ]:       6508 :     ImplCalcBorder( meAlign, mnLeftBorder, mnTopBorder, mnRightBorder, mnBottomBorder, this );
    2277                 :            : 
    2278                 :            :     // update drag area (where the 'grip' will be placed)
    2279         [ +  - ]:       6508 :     Rectangle aOldDragRect;
    2280         [ +  + ]:       6508 :     if( pWrapper )
    2281         [ +  - ]:       4063 :         aOldDragRect = pWrapper->GetDragArea();
    2282         [ +  - ]:       6508 :     ImplUpdateDragArea( this );
    2283                 :            : 
    2284 [ +  - ][ +  + ]:       6508 :     if ( ImplCalcItem() )
    2285                 :       1655 :         bMustFullPaint = sal_True;
    2286                 :            :     else
    2287                 :       4853 :         bMustFullPaint = sal_False;
    2288                 :            : 
    2289                 :            : 
    2290                 :            :     // calculate new size during interactive resize or
    2291                 :            :     // set computed size when formatting only
    2292 [ +  - ][ -  + ]:       6508 :     if ( ImplIsFloatingMode() )
    2293                 :            :     {
    2294         [ #  # ]:          0 :         if ( bResize )
    2295                 :          0 :             mnFloatLines = ImplCalcLines( this, mnDY );
    2296                 :            :         else
    2297 [ #  # ][ #  # ]:          0 :             SetOutputSizePixel( ImplGetOptimalFloatingSize() );
    2298                 :            :     }
    2299                 :            : 
    2300                 :            :     // Horizontal
    2301         [ +  - ]:       6508 :     if ( mbHorz )
    2302                 :            :     {
    2303                 :            :         long nBottom;
    2304                 :            :         // nLineSize: height of a single line, will fit highest item
    2305                 :       6508 :         nLineSize = mnMaxItemHeight;
    2306                 :            : 
    2307         [ +  + ]:       6508 :         if ( mnWinHeight > mnMaxItemHeight )
    2308                 :         36 :             nLineSize = mnWinHeight;
    2309                 :            : 
    2310         [ +  + ]:       6508 :         if ( mbScroll )
    2311                 :            :         {
    2312                 :       4063 :             nMax        = mnDX;
    2313                 :       4063 :             mnVisLines  = ImplCalcLines( this, mnDY );
    2314                 :            :         }
    2315                 :            :         else
    2316                 :            :         {
    2317                 :            :             // layout over all lines
    2318                 :       2445 :             mnVisLines  = mnLines;
    2319                 :       2445 :             nMax        = TB_MAXNOSCROLL;
    2320                 :            :         }
    2321                 :            : 
    2322                 :            :         // add in all border offsets
    2323         [ +  + ]:       6508 :         if ( mnWinStyle & WB_BORDER )
    2324                 :            :         {
    2325                 :       4063 :             nLeft       = TB_BORDER_OFFSET1 + mnLeftBorder;
    2326                 :       4063 :             nTop        = TB_BORDER_OFFSET2 + mnTopBorder;
    2327                 :       4063 :             nBottom     = TB_BORDER_OFFSET1 + mnBottomBorder;
    2328                 :       4063 :             nMax       -= nLeft + TB_BORDER_OFFSET1 + mnRightBorder;
    2329                 :            :         }
    2330                 :            :         else
    2331                 :            :         {
    2332                 :       2445 :             nLeft       = 0;
    2333                 :       2445 :             nTop        = 0;
    2334                 :       2445 :             nBottom     = 0;
    2335                 :            :         }
    2336                 :            : 
    2337                 :            :         // adjust linesize if docked in single-line mode (i.e. when using a clipped item menu)
    2338                 :            :         // we have to center all items in the window height
    2339 [ +  - ][ +  + ]:       6508 :         if( IsMenuEnabled() && !ImplIsFloatingMode() )
         [ +  - ][ +  - ]
                 [ +  + ]
    2340                 :            :         {
    2341                 :       4063 :             long  nWinHeight = mnDY - nTop - nBottom;
    2342         [ -  + ]:       4063 :             if( nWinHeight > nLineSize )
    2343                 :          0 :                 nLineSize = nWinHeight;
    2344                 :            :         }
    2345                 :            :     }
    2346                 :            :     else
    2347                 :            :     {
    2348                 :            :         long nRight;
    2349                 :          0 :         nLineSize = mnMaxItemWidth;
    2350                 :            : 
    2351         [ #  # ]:          0 :         if ( mbScroll )
    2352                 :            :         {
    2353                 :          0 :             mnVisLines  = ImplCalcLines( this, mnDX );
    2354                 :          0 :             nMax        = mnDY;
    2355                 :            :         }
    2356                 :            :         else
    2357                 :            :         {
    2358                 :          0 :             mnVisLines  = mnLines;
    2359                 :          0 :             nMax        = TB_MAXNOSCROLL;
    2360                 :            :         }
    2361                 :            : 
    2362         [ #  # ]:          0 :         if ( mnWinStyle & WB_BORDER )
    2363                 :            :         {
    2364                 :          0 :             nTop        = TB_BORDER_OFFSET1 + mnTopBorder;
    2365                 :          0 :             nLeft       = TB_BORDER_OFFSET2 + mnLeftBorder;
    2366                 :          0 :             nRight      = TB_BORDER_OFFSET2 + mnRightBorder;
    2367                 :          0 :             nMax       -= nTop + TB_BORDER_OFFSET1 + mnBottomBorder;
    2368                 :            :         }
    2369                 :            :         else
    2370                 :            :         {
    2371                 :          0 :             nLeft       = 0;
    2372                 :          0 :             nTop        = 0;
    2373                 :          0 :             nRight      = 0;
    2374                 :            :         }
    2375                 :            : 
    2376                 :            :         // adjust linesize if docked in single-line mode (i.e. when using a clipped item menu)
    2377                 :            :         // we have to center all items in the window height
    2378 [ #  # ][ #  # ]:          0 :         if( !ImplIsFloatingMode() && IsMenuEnabled() )
         [ #  # ][ #  # ]
                 [ #  # ]
    2379                 :            :         {
    2380                 :          0 :             long  nWinWidth = mnDX - nLeft - nRight;
    2381         [ #  # ]:          0 :             if( nWinWidth > nLineSize )
    2382                 :          0 :                 nLineSize = nWinWidth;
    2383                 :            :         }
    2384                 :            :     }
    2385                 :            : 
    2386                 :            :     // no calculation if the window has no size (nMax=0)
    2387                 :            :     // non scrolling toolboxes must be computed though
    2388 [ +  + ][ +  - ]:       6508 :     if ( (nMax <= 0) && mbScroll )
    2389                 :            :     {
    2390                 :       1149 :         mnVisLines   = 1;
    2391                 :       1149 :         mnCurLine    = 1;
    2392                 :       1149 :         mnCurLines   = 1;
    2393                 :            : 
    2394                 :       1149 :         it = mpData->m_aItems.begin();
    2395 [ +  - ][ -  + ]:       1149 :         while ( it != mpData->m_aItems.end() )
    2396                 :            :         {
    2397                 :          0 :             it->maRect = aEmptyRect;
    2398                 :          0 :             ++it;
    2399                 :            :         }
    2400                 :            : 
    2401                 :       1149 :         maLowerRect = aEmptyRect;
    2402                 :       1149 :         maUpperRect = aEmptyRect;
    2403                 :            :     }
    2404                 :            :     else
    2405                 :            :     {
    2406                 :            :         // init start values
    2407                 :       5359 :         long nX = nLeft;    // top-left offset
    2408                 :       5359 :         long nY = nTop;
    2409                 :       5359 :         nFormatLine = 1;
    2410                 :            : 
    2411                 :            :         // save old scroll rectangles and reset them
    2412                 :       5359 :         Rectangle aOldLowerRect = maLowerRect;
    2413                 :       5359 :         Rectangle aOldUpperRect = maUpperRect;
    2414                 :       5359 :         Rectangle aOldMenubuttonRect = mpData->maMenubuttonItem.maRect;
    2415                 :       5359 :         maUpperRect = aEmptyRect;
    2416                 :       5359 :         maLowerRect = aEmptyRect;
    2417                 :       5359 :         mpData->maMenubuttonItem.maRect = aEmptyRect;
    2418                 :            : 
    2419                 :            :         // do we have any toolbox items at all ?
    2420 [ -  + ][ #  # ]:       5359 :         if ( !mpData->m_aItems.empty() || IsMenuEnabled() )
         [ #  # ][ +  - ]
    2421                 :            :         {
    2422         [ +  - ]:       5359 :             lcl_hideDoubleSeparators( mpData->m_aItems );
    2423                 :            : 
    2424                 :            :             // compute line breaks and visible lines give the current window width (nMax)
    2425                 :            :             // the break indicators will be stored within each item (it->mbBreak)
    2426         [ +  - ]:       5359 :             mnCurLines = ImplCalcBreaks( nMax, NULL, mbHorz );
    2427                 :            : 
    2428                 :            :             // check for scrollbar buttons or dropdown menu
    2429                 :            :             // (if a menu is enabled, this will be used to store clipped
    2430                 :            :             //  items and no scroll buttons will appear)
    2431 [ +  - ][ +  - ]:       9753 :             if ( (!ImplIsFloatingMode() && (mnCurLines > mnVisLines) && mbScroll ) ||
         [ +  + ][ -  + ]
         [ +  + ][ +  + ]
    2432         [ +  - ]:       4394 :                 IsMenuEnabled() )
    2433                 :            :             {
    2434                 :            :                 // compute linebreaks again, incorporating scrollbar buttons
    2435 [ +  - ][ -  + ]:       2914 :                 if( !IsMenuEnabled() )
    2436                 :            :                 {
    2437                 :          0 :                     nMax -= TB_SPIN_SIZE+TB_SPIN_OFFSET;
    2438         [ #  # ]:          0 :                     mnCurLines = ImplCalcBreaks( nMax, NULL, mbHorz );
    2439                 :            :                 }
    2440                 :            : 
    2441                 :            :                 // compute scroll rectangles or menu button
    2442         [ +  - ]:       2914 :                 if ( mbHorz )
    2443                 :            :                 {
    2444 [ +  - ][ +  - ]:       2914 :                     if( IsMenuEnabled() && !ImplHasExternalMenubutton() && !bIsInPopupMode )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2445                 :            :                     {
    2446 [ +  - ][ +  - ]:       2914 :                         if( !ImplIsFloatingMode() )
    2447                 :            :                         {
    2448                 :       2914 :                             mpData->maMenubuttonItem.maRect.Right() = mnDX - 2;
    2449                 :       2914 :                             mpData->maMenubuttonItem.maRect.Top() = nTop;
    2450                 :       2914 :                             mpData->maMenubuttonItem.maRect.Bottom() = mnDY-mnBottomBorder-TB_BORDER_OFFSET2-1;
    2451                 :            :                         }
    2452                 :            :                         else
    2453                 :            :                         {
    2454                 :          0 :                             mpData->maMenubuttonItem.maRect.Right() = mnDX - mnRightBorder-TB_BORDER_OFFSET1-1;
    2455                 :          0 :                             mpData->maMenubuttonItem.maRect.Top() = nTop;
    2456                 :          0 :                             mpData->maMenubuttonItem.maRect.Bottom() = mnDY-mnBottomBorder-TB_BORDER_OFFSET2-1;
    2457                 :            :                         }
    2458                 :       2914 :                         mpData->maMenubuttonItem.maRect.Left() = mpData->maMenubuttonItem.maRect.Right() - mpData->mnMenuButtonWidth;
    2459                 :            :                     }
    2460                 :            :                     else
    2461                 :            :                     {
    2462                 :          0 :                         maUpperRect.Left()   = nLeft+nMax+TB_SPIN_OFFSET;
    2463                 :          0 :                         maUpperRect.Right()  = maUpperRect.Left()+TB_SPIN_SIZE-1;
    2464                 :          0 :                         maUpperRect.Top()    = nTop;
    2465                 :          0 :                         maLowerRect.Bottom() = mnDY-mnBottomBorder-TB_BORDER_OFFSET2-1;
    2466                 :          0 :                         maLowerRect.Left()   = maUpperRect.Left();
    2467                 :          0 :                         maLowerRect.Right()  = maUpperRect.Right();
    2468                 :          0 :                         maUpperRect.Bottom() = maUpperRect.Top() +
    2469                 :          0 :                                             (maLowerRect.Bottom()-maUpperRect.Top())/2;
    2470                 :          0 :                         maLowerRect.Top()    = maUpperRect.Bottom();
    2471                 :            :                     }
    2472                 :            :                 }
    2473                 :            :                 else
    2474                 :            :                 {
    2475 [ #  # ][ #  # ]:          0 :                     if( IsMenuEnabled() && !ImplHasExternalMenubutton() && !bIsInPopupMode )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2476                 :            :                     {
    2477 [ #  # ][ #  # ]:          0 :                         if( !ImplIsFloatingMode() )
    2478                 :            :                         {
    2479                 :          0 :                             mpData->maMenubuttonItem.maRect.Bottom() = mnDY - 2;
    2480                 :          0 :                             mpData->maMenubuttonItem.maRect.Left() = nLeft;
    2481                 :          0 :                             mpData->maMenubuttonItem.maRect.Right() = mnDX-mnRightBorder-TB_BORDER_OFFSET2-1;
    2482                 :            :                         }
    2483                 :            :                         else
    2484                 :            :                         {
    2485                 :          0 :                             mpData->maMenubuttonItem.maRect.Bottom() = mnDY - mnBottomBorder-TB_BORDER_OFFSET1-1;
    2486                 :          0 :                             mpData->maMenubuttonItem.maRect.Left() = nLeft;
    2487                 :          0 :                             mpData->maMenubuttonItem.maRect.Right() = mnDX-mnRightBorder-TB_BORDER_OFFSET2-1;
    2488                 :            :                         }
    2489                 :          0 :                         mpData->maMenubuttonItem.maRect.Top() = mpData->maMenubuttonItem.maRect.Bottom() - mpData->mnMenuButtonWidth;
    2490                 :            :                     }
    2491                 :            :                     else
    2492                 :            :                     {
    2493                 :          0 :                         maUpperRect.Top()    = nTop+nMax+TB_SPIN_OFFSET;
    2494                 :          0 :                         maUpperRect.Bottom() = maUpperRect.Top()+TB_SPIN_SIZE-1;
    2495                 :          0 :                         maUpperRect.Left()   = nLeft;
    2496                 :          0 :                         maLowerRect.Right()  = mnDX-mnRightBorder-TB_BORDER_OFFSET2-1;
    2497                 :          0 :                         maLowerRect.Top()    = maUpperRect.Top();
    2498                 :          0 :                         maLowerRect.Bottom() = maUpperRect.Bottom();
    2499                 :          0 :                         maUpperRect.Right()  = maUpperRect.Left() +
    2500                 :          0 :                                             (maLowerRect.Right()-maUpperRect.Left())/2;
    2501                 :          0 :                         maLowerRect.Left()   = maUpperRect.Right();
    2502                 :            :                     }
    2503                 :            :                 }
    2504                 :            :             }
    2505                 :            : 
    2506                 :            :             // no scrolling when there is a "more"-menu
    2507                 :            :             // anything will "fit" in a single line then
    2508 [ +  - ][ +  + ]:       5359 :             if( IsMenuEnabled() )
    2509                 :       2914 :                 mnCurLines = 1;
    2510                 :            : 
    2511                 :            :             // determine the currently visible line
    2512         [ +  - ]:       5359 :             if ( mnVisLines >= mnCurLines )
    2513                 :       5359 :                 mnCurLine = 1;
    2514         [ #  # ]:          0 :             else if ( mnCurLine+mnVisLines-1 > mnCurLines )
    2515                 :          0 :                 mnCurLine = mnCurLines - (mnVisLines-1);
    2516                 :            : 
    2517                 :       5359 :             it = mpData->m_aItems.begin();
    2518 [ +  - ][ +  + ]:     124000 :             while ( it != mpData->m_aItems.end() )
    2519                 :            :             {
    2520                 :     118641 :                 it->mbShowWindow = sal_False;
    2521                 :            : 
    2522                 :            :                 // check for line break and advance nX/nY accordingly
    2523         [ +  + ]:     118641 :                 if ( it->mbBreak )
    2524                 :            :                 {
    2525                 :       1103 :                     nFormatLine++;
    2526                 :            : 
    2527                 :            :                     // increment starting with the second line
    2528         [ +  - ]:       1103 :                     if ( nFormatLine > mnCurLine )
    2529                 :            :                     {
    2530         [ +  - ]:       1103 :                         if ( mbHorz )
    2531                 :            :                         {
    2532                 :       1103 :                             nX = nLeft;
    2533         [ +  + ]:       1103 :                             if ( mnWinStyle & WB_LINESPACING )
    2534                 :        967 :                                 nY += nLineSize+TB_LINESPACING;
    2535                 :            :                             else
    2536                 :        136 :                                 nY += nLineSize;
    2537                 :            :                         }
    2538                 :            :                         else
    2539                 :            :                         {
    2540                 :          0 :                             nY = nTop;
    2541         [ #  # ]:          0 :                             if ( mnWinStyle & WB_LINESPACING )
    2542                 :          0 :                                 nX += nLineSize+TB_LINESPACING;
    2543                 :            :                             else
    2544                 :          0 :                                 nX += nLineSize;
    2545                 :            :                         }
    2546                 :            :                     }
    2547                 :            :                 }
    2548                 :            : 
    2549 [ +  + ][ +  - ]:     118641 :                 if ( !it->mbVisible || (nFormatLine < mnCurLine) ||
         [ +  + ][ +  + ]
    2550                 :            :                      (nFormatLine > mnCurLine+mnVisLines-1) )
    2551                 :            :                      // item is not visible
    2552                 :      33114 :                     it->maCalcRect = aEmptyRect;
    2553                 :            :                 else
    2554                 :            :                 {
    2555                 :            :                     // 1. determine current item width/height
    2556                 :            :                     // take window size and orientation into account, because this affects the size of item windows
    2557                 :            : 
    2558         [ +  - ]:      85527 :                     Size aCurrentItemSize( it->GetSize( mbHorz, mbScroll, nMax, Size(mnMaxItemWidth, mnMaxItemHeight) ) );
    2559                 :            : 
    2560                 :            :                     // 2. position item rect and use size from step 1
    2561                 :            :                     //  items will be centered horizontally (if mbHorz) or vertically
    2562                 :            :                     //  advance nX and nY accordingly
    2563         [ +  - ]:      85527 :                     if ( mbHorz )
    2564                 :            :                     {
    2565                 :      85527 :                         it->maCalcRect.Left()     = nX;
    2566                 :            :                         // if special TBX_LAYOUT_LOCKVERT lock vertical position
    2567                 :            :                         // don't recalulate the vertical position of the item
    2568 [ #  # ][ -  + ]:      85527 :                         if ( meLayoutMode == TBX_LAYOUT_LOCKVERT && mnLines == 1 )
    2569                 :            :                         {
    2570                 :            :                             // Somewhat of a hack here, calc deletes and re-adds
    2571                 :            :                             // the sum/assign & ok/cancel items dynamically.
    2572                 :            :                             // Because TBX_LAYOUT_LOCKVERT effectively prevents
    2573                 :            :                             // recalculation of the vertical pos of an item the
    2574                 :            :                             // it->maRect.Top() for those newly added items is
    2575                 :            :                             // 0. The hack here is that we want to effectively
    2576                 :            :                             // recalculate the vertical pos for those added
    2577                 :            :                             // items here. ( Note: assume mnMaxItemHeight is
    2578                 :            :                             // equal to the LineSize when multibar has a single
    2579                 :            :                             // line size )
    2580         [ #  # ]:          0 :                             it->maCalcRect.Top()      =  it->maRect.Top() ? it->maRect.Top() : ( nY + ( mnMaxItemHeight-aCurrentItemSize.Height())/2 );
    2581                 :            :                         }
    2582                 :            :                         else
    2583                 :      85527 :                             it->maCalcRect.Top()      = nY+(nLineSize-aCurrentItemSize.Height())/2;
    2584                 :      85527 :                         it->maCalcRect.Right()    = nX+aCurrentItemSize.Width()-1;
    2585                 :      85527 :                         it->maCalcRect.Bottom()   = it->maCalcRect.Top()+aCurrentItemSize.Height()-1;
    2586                 :      85527 :                         nX += aCurrentItemSize.Width();
    2587                 :            :                     }
    2588                 :            :                     else
    2589                 :            :                     {
    2590                 :          0 :                         it->maCalcRect.Left()     = nX+(nLineSize-aCurrentItemSize.Width())/2;
    2591                 :          0 :                         it->maCalcRect.Top()      = nY;
    2592                 :          0 :                         it->maCalcRect.Right()    = it->maCalcRect.Left()+aCurrentItemSize.Width()-1;
    2593                 :          0 :                         it->maCalcRect.Bottom()   = nY+aCurrentItemSize.Height()-1;
    2594                 :      85527 :                         nY += aCurrentItemSize.Height();
    2595                 :            :                     }
    2596                 :            :                 }
    2597                 :            : 
    2598                 :            :                 // position window items into calculated item rect
    2599         [ +  + ]:     118641 :                 if ( it->mpWindow )
    2600                 :            :                 {
    2601         [ +  + ]:       5003 :                     if ( it->mbShowWindow )
    2602                 :            :                     {
    2603                 :       4302 :                         Point aPos( it->maCalcRect.Left(), it->maCalcRect.Top() );
    2604         [ +  - ]:       4302 :                         it->mpWindow->SetPosPixel( aPos );
    2605         [ +  - ]:       4302 :                         if ( !mbCustomizeMode )
    2606         [ +  - ]:       4302 :                             it->mpWindow->Show();
    2607                 :            :                     }
    2608                 :            :                     else
    2609         [ +  - ]:        701 :                         it->mpWindow->Hide();
    2610                 :            :                 }
    2611                 :            : 
    2612                 :     118641 :                 ++it;
    2613                 :            :             } // end of loop over all items
    2614                 :            :         }
    2615                 :            :         else
    2616                 :            :             // we have no toolbox items
    2617                 :          0 :             mnCurLines = 1;
    2618                 :            : 
    2619                 :            : 
    2620 [ +  - ][ +  + ]:       5359 :         if( IsMenuEnabled() && ImplIsFloatingMode() && !ImplHasExternalMenubutton() && !bIsInPopupMode )
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
    2621                 :            :         {
    2622                 :            :             // custom menu will be the last button in floating mode
    2623                 :          0 :             ImplToolItem &rIt = mpData->maMenubuttonItem;
    2624                 :            : 
    2625         [ #  # ]:          0 :             if ( mbHorz )
    2626                 :            :             {
    2627                 :          0 :                 rIt.maRect.Left()     = nX+TB_MENUBUTTON_OFFSET;
    2628                 :          0 :                 rIt.maRect.Top()      = nY;
    2629                 :          0 :                 rIt.maRect.Right()    = rIt.maRect.Left() + mpData->mnMenuButtonWidth;
    2630                 :          0 :                 rIt.maRect.Bottom()   = nY+nLineSize-1;
    2631                 :          0 :                 nX += rIt.maItemSize.Width();
    2632                 :            :             }
    2633                 :            :             else
    2634                 :            :             {
    2635                 :          0 :                 rIt.maRect.Left()     = nX;
    2636                 :          0 :                 rIt.maRect.Top()      = nY+TB_MENUBUTTON_OFFSET;
    2637                 :          0 :                 rIt.maRect.Right()    = nX+nLineSize-1;
    2638                 :          0 :                 rIt.maRect.Bottom()   = rIt.maRect.Top() + mpData->mnMenuButtonWidth;
    2639                 :          0 :                 nY += rIt.maItemSize.Height();
    2640                 :            :             }
    2641                 :            :         }
    2642                 :            : 
    2643                 :            : 
    2644                 :            :         // if toolbox visible trigger paint for changed regions
    2645 [ +  - ][ +  + ]:       5359 :         if ( IsVisible() && !mbFullPaint )
         [ +  + ][ +  + ]
    2646                 :            :         {
    2647         [ +  + ]:       4821 :             if ( bMustFullPaint )
    2648                 :            :             {
    2649                 :            :                 maPaintRect = Rectangle( mnLeftBorder, mnTopBorder,
    2650         [ +  - ]:       1655 :                                          mnDX-mnRightBorder, mnDY-mnBottomBorder );
    2651                 :            :             }
    2652                 :            :             else
    2653                 :            :             {
    2654 [ +  - ][ -  + ]:       3166 :                 if ( aOldLowerRect != maLowerRect )
    2655                 :            :                 {
    2656         [ #  # ]:          0 :                     maPaintRect.Union( maLowerRect );
    2657         [ #  # ]:          0 :                     maPaintRect.Union( aOldLowerRect );
    2658                 :            :                 }
    2659 [ +  - ][ -  + ]:       3166 :                 if ( aOldUpperRect != maUpperRect )
    2660                 :            :                 {
    2661         [ #  # ]:          0 :                     maPaintRect.Union( maUpperRect );
    2662         [ #  # ]:          0 :                     maPaintRect.Union( aOldUpperRect );
    2663                 :            :                 }
    2664 [ +  - ][ +  + ]:       3166 :                 if ( aOldMenubuttonRect != mpData->maMenubuttonItem.maRect )
    2665                 :            :                 {
    2666         [ +  - ]:       2583 :                     maPaintRect.Union( mpData->maMenubuttonItem.maRect );
    2667         [ +  - ]:       2583 :                     maPaintRect.Union( aOldMenubuttonRect );
    2668                 :            :                 }
    2669 [ +  + ][ +  - ]:       3166 :                 if ( pWrapper && aOldDragRect != pWrapper->GetDragArea() )
         [ +  - ][ +  + ]
                 [ +  + ]
           [ +  +  #  # ]
    2670                 :            :                 {
    2671 [ +  - ][ +  - ]:       2548 :                     maPaintRect.Union( pWrapper->GetDragArea() );
    2672         [ +  - ]:       2548 :                     maPaintRect.Union( aOldDragRect );
    2673                 :            :                 }
    2674                 :            : 
    2675                 :       3166 :                 it = mpData->m_aItems.begin();
    2676 [ +  - ][ +  + ]:     101743 :                 while ( it != mpData->m_aItems.end() )
    2677                 :            :                 {
    2678 [ +  - ][ +  + ]:      98577 :                     if ( it->maRect != it->maCalcRect )
    2679                 :            :                     {
    2680         [ +  - ]:      71939 :                         maPaintRect.Union( it->maRect );
    2681         [ +  - ]:      71939 :                         maPaintRect.Union( it->maCalcRect );
    2682                 :            :                     }
    2683                 :      98577 :                     ++it;
    2684                 :            :                 }
    2685                 :            :             }
    2686                 :            : 
    2687         [ +  - ]:       4821 :             Invalidate( maPaintRect );
    2688                 :            :         }
    2689                 :            : 
    2690                 :            :         // store the new calculated item rects
    2691                 :       5359 :         maPaintRect = aEmptyRect;
    2692 [ +  - ][ +  - ]:       5359 :         Rectangle aVisibleRect(Point(0, 0), GetOutputSizePixel());
    2693                 :       5359 :         it = mpData->m_aItems.begin();
    2694 [ +  - ][ +  + ]:     124000 :         while ( it != mpData->m_aItems.end() )
    2695                 :            :         {
    2696                 :     118641 :             it->maRect = it->maCalcRect;
    2697         [ +  - ]:     118641 :             it->maRect.IsOver(aVisibleRect);
    2698                 :     118641 :             ++it;
    2699                 :            :         }
    2700                 :            :     }
    2701                 :            : 
    2702                 :            :     // indicate formatting is done
    2703                 :      27626 :     mbFormat = sal_False;
    2704                 :            : }
    2705                 :            : 
    2706                 :            : // -----------------------------------------------------------------------
    2707                 :            : 
    2708                 :          0 : IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl)
    2709                 :            : {
    2710   [ #  #  #  # ]:          0 :     if( mnCurPos != TOOLBOX_ITEM_NOTFOUND &&
                 [ #  # ]
    2711                 :          0 :         (mpData->m_aItems[ mnCurPos ].mnBits & TIB_DROPDOWN)
    2712                 :            :         )
    2713                 :            :     {
    2714                 :          0 :         mpData->mbDropDownByKeyboard = sal_False;
    2715                 :          0 :         GetDropdownClickHdl().Call( this );
    2716                 :            : 
    2717                 :            :         // do not reset data if the dropdown handler opened a floating window
    2718                 :            :         // see ImplFloatControl()
    2719         [ #  # ]:          0 :         if( mpFloatWin == NULL )
    2720                 :            :         {
    2721                 :            :             // no floater was opened
    2722                 :          0 :             Deactivate();
    2723                 :          0 :             ImplDrawItem( mnCurPos, 0 );
    2724                 :            : 
    2725                 :          0 :             mnCurPos         = TOOLBOX_ITEM_NOTFOUND;
    2726                 :          0 :             mnCurItemId      = 0;
    2727                 :          0 :             mnDownItemId     = 0;
    2728                 :          0 :             mnMouseClicks    = 0;
    2729                 :          0 :             mnMouseModifier  = 0;
    2730                 :          0 :             mnHighItemId     = 0;
    2731                 :            :         }
    2732                 :            :     }
    2733                 :            : 
    2734                 :          0 :     return 0;
    2735                 :            : }
    2736                 :            : 
    2737                 :            : // -----------------------------------------------------------------------
    2738                 :            : 
    2739                 :        390 : IMPL_LINK_NOARG(ToolBox, ImplUpdateHdl)
    2740                 :            : {
    2741                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    2742                 :            : 
    2743         [ +  + ]:        390 :     if( mbFormat )
    2744                 :        114 :         ImplFormat();
    2745                 :            : 
    2746                 :        390 :     return 0;
    2747                 :            : }
    2748                 :            : 
    2749                 :            : // -----------------------------------------------------------------------
    2750                 :            : 
    2751                 :       2324 : static void ImplDrawMoreIndicator( ToolBox *pBox, const Rectangle& rRect, sal_Bool bSetColor, sal_Bool bRotate )
    2752                 :            : {
    2753                 :       2324 :     Color aOldFillColor = pBox->GetFillColor();
    2754                 :       2324 :     Color aOldLineColor = pBox->GetLineColor();
    2755         [ +  - ]:       2324 :     pBox->SetLineColor();
    2756                 :            : 
    2757         [ +  - ]:       2324 :     if ( bSetColor )
    2758                 :            :     {
    2759 [ +  - ][ -  + ]:       2324 :         if ( pBox->GetSettings().GetStyleSettings().GetFaceColor().IsDark() )
    2760         [ #  # ]:          0 :             pBox->SetFillColor( Color( COL_WHITE ) );
    2761                 :            :         else
    2762         [ +  - ]:       2324 :             pBox->SetFillColor( Color( COL_BLACK ) );
    2763                 :            :     }
    2764                 :            : 
    2765         [ +  - ]:       2324 :     if( !bRotate )
    2766                 :            :     {
    2767                 :       2324 :         long width = 8;
    2768                 :       2324 :         long height = 5;
    2769                 :       2324 :         long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1;
    2770                 :       2324 :         long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1;
    2771         [ +  + ]:      13944 :         while( height >= 1)
    2772                 :            :         {
    2773 [ +  - ][ +  - ]:      11620 :             pBox->DrawRect( Rectangle( x, y, x+1, y ) );
    2774                 :      11620 :             x+=4;
    2775 [ +  - ][ +  - ]:      11620 :             pBox->DrawRect( Rectangle( x, y, x+1, y ) );
    2776                 :      11620 :             x-=4;
    2777                 :      11620 :             y++;
    2778         [ +  + ]:      11620 :             if( height <= 3) x--;
    2779                 :       4648 :             else            x++;
    2780                 :      11620 :             height--;
    2781                 :            :         }
    2782                 :            :     }
    2783                 :            :     else
    2784                 :            :     {
    2785                 :          0 :         long width = 5;
    2786                 :          0 :         long height = 8;
    2787                 :          0 :         long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1;
    2788                 :          0 :         long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1;
    2789         [ #  # ]:          0 :         while( width >= 1)
    2790                 :            :         {
    2791 [ #  # ][ #  # ]:          0 :             pBox->DrawRect( Rectangle( x, y, x, y+1 ) );
    2792                 :          0 :             y+=4;
    2793 [ #  # ][ #  # ]:          0 :             pBox->DrawRect( Rectangle( x, y, x, y+1 ) );
    2794                 :          0 :             y-=4;
    2795                 :          0 :             x++;
    2796         [ #  # ]:          0 :             if( width <= 3) y--;
    2797                 :          0 :             else           y++;
    2798                 :          0 :             width--;
    2799                 :            :         }
    2800                 :            :     }
    2801                 :            : 
    2802         [ +  - ]:       2324 :     pBox->SetFillColor( aOldFillColor );
    2803         [ +  - ]:       2324 :     pBox->SetLineColor( aOldLineColor );
    2804                 :       2324 : }
    2805                 :            : 
    2806                 :      20100 : static void ImplDrawDropdownArrow( ToolBox *pBox, const Rectangle& rDropDownRect, sal_Bool bSetColor, sal_Bool bRotate )
    2807                 :            : {
    2808                 :      20100 :     sal_Bool bLineColor = pBox->IsLineColor();
    2809                 :      20100 :     sal_Bool bFillColor = pBox->IsFillColor();
    2810                 :      20100 :     Color aOldFillColor = pBox->GetFillColor();
    2811                 :      20100 :     Color aOldLineColor = pBox->GetLineColor();
    2812         [ +  - ]:      20100 :     pBox->SetLineColor();
    2813                 :            : 
    2814         [ +  + ]:      20100 :     if ( bSetColor )
    2815                 :            :     {
    2816 [ +  - ][ -  + ]:      15573 :         if ( pBox->GetSettings().GetStyleSettings().GetFaceColor().IsDark() )
    2817         [ #  # ]:          0 :             pBox->SetFillColor( Color( COL_WHITE ) );
    2818                 :            :         else
    2819         [ +  - ]:      15573 :             pBox->SetFillColor( Color( COL_BLACK ) );
    2820                 :            :     }
    2821                 :            : 
    2822         [ +  - ]:      20100 :     if( !bRotate )
    2823                 :            :     {
    2824                 :      20100 :         long width = 5;
    2825                 :      20100 :         long height = 3;
    2826                 :      20100 :         long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
    2827                 :      20100 :         long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
    2828         [ +  + ]:      80400 :         while( width >= 1)
    2829                 :            :         {
    2830 [ +  - ][ +  - ]:      60300 :             pBox->DrawRect( Rectangle( x, y, x+width-1, y ) );
    2831                 :      60300 :             y++; x++;
    2832                 :      60300 :             width -= 2;
    2833                 :            :         }
    2834                 :            :     }
    2835                 :            :     else
    2836                 :            :     {
    2837                 :          0 :         long width = 3;
    2838                 :          0 :         long height = 5;
    2839                 :          0 :         long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
    2840                 :          0 :         long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
    2841         [ #  # ]:          0 :         while( height >= 1)
    2842                 :            :         {
    2843 [ #  # ][ #  # ]:          0 :             pBox->DrawRect( Rectangle( x, y, x, y+height-1 ) );
    2844                 :          0 :             y++; x++;
    2845                 :          0 :             height -= 2;
    2846                 :            :         }
    2847                 :            :     }
    2848                 :            : 
    2849         [ +  + ]:      20100 :     if( bFillColor )
    2850         [ +  - ]:       4527 :         pBox->SetFillColor( aOldFillColor );
    2851                 :            :     else
    2852         [ +  - ]:      15573 :         pBox->SetFillColor();
    2853         [ +  - ]:      20100 :     if( bLineColor )
    2854         [ +  - ]:      20100 :         pBox->SetLineColor( aOldLineColor );
    2855                 :            :     else
    2856         [ #  # ]:          0 :         pBox->SetLineColor( );
    2857                 :      20100 : }
    2858                 :            : 
    2859                 :            : // -----------------------------------------------------------------------
    2860                 :            : 
    2861                 :      10776 : void ToolBox::ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight )
    2862                 :            : {
    2863         [ +  + ]:      10776 :     if( !pThis->mpData->maMenubuttonItem.maRect.IsEmpty() )
    2864                 :            :     {
    2865                 :            :         // #i53937# paint menu button only if necessary
    2866 [ +  - ][ +  + ]:       6805 :         if( !pThis->ImplHasClippedItems() )
    2867                 :      10776 :             return;
    2868                 :            : 
    2869                 :            :         // execute pending paint requests
    2870         [ +  - ]:       2324 :         ImplCheckUpdate( pThis );
    2871                 :            : 
    2872                 :       2324 :         sal_Bool bFillColor = pThis->IsFillColor();
    2873                 :       2324 :         sal_Bool bLineColor = pThis->IsLineColor();
    2874                 :       2324 :         Color aOldFillCol = pThis->GetFillColor();
    2875                 :       2324 :         Color aOldLineCol = pThis->GetLineColor();
    2876                 :            : 
    2877                 :            :         // draw the 'more' indicator / button (>>)
    2878         [ +  - ]:       2324 :         ImplErase( pThis, pThis->mpData->maMenubuttonItem.maRect, bHighlight );
    2879                 :            : 
    2880         [ -  + ]:       2324 :         if( bHighlight )
    2881         [ #  # ]:          0 :             ImplDrawButton( pThis, pThis->mpData->maMenubuttonItem.maRect, 2, sal_False, sal_True, sal_False );
    2882                 :            : 
    2883 [ +  - ][ +  - ]:       2324 :         if( pThis->ImplHasClippedItems() )
    2884         [ +  - ]:       2324 :             ImplDrawMoreIndicator( pThis, pThis->mpData->maMenubuttonItem.maRect, sal_True, !pThis->mbHorz );
    2885                 :            : 
    2886                 :            :         // store highlight state
    2887                 :       2324 :         pThis->mpData->mbMenubuttonSelected = bHighlight;
    2888                 :            : 
    2889                 :            :         // restore colors
    2890         [ +  + ]:       2324 :         if( bFillColor )
    2891         [ +  - ]:        960 :             pThis->SetFillColor( aOldFillCol );
    2892                 :            :         else
    2893         [ +  - ]:       1364 :             pThis->SetFillColor();
    2894         [ +  - ]:       2324 :         if( bLineColor )
    2895         [ +  - ]:       2324 :             pThis->SetLineColor( aOldLineCol );
    2896                 :            :         else
    2897         [ #  # ]:       6805 :             pThis->SetLineColor();
    2898                 :            :     }
    2899                 :            : }
    2900                 :            : 
    2901                 :            : // -----------------------------------------------------------------------
    2902                 :            : 
    2903                 :          0 : void ToolBox::ImplDrawSpin( sal_Bool bUpperIn, sal_Bool bLowerIn )
    2904                 :            : {
    2905                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    2906                 :            : 
    2907                 :            :     sal_Bool    bTmpUpper;
    2908                 :            :     sal_Bool    bTmpLower;
    2909                 :            : 
    2910 [ #  # ][ #  # ]:          0 :     if ( maUpperRect.IsEmpty() || maLowerRect.IsEmpty() )
                 [ #  # ]
    2911                 :          0 :         return;
    2912                 :            : 
    2913         [ #  # ]:          0 :     if ( mnCurLine > 1 )
    2914                 :          0 :         bTmpUpper = sal_True;
    2915                 :            :     else
    2916                 :          0 :         bTmpUpper = sal_False;
    2917                 :            : 
    2918         [ #  # ]:          0 :     if ( mnCurLine+mnVisLines-1 < mnCurLines )
    2919                 :          0 :         bTmpLower = sal_True;
    2920                 :            :     else
    2921                 :          0 :         bTmpLower = sal_False;
    2922                 :            : 
    2923         [ #  # ]:          0 :     if ( !IsEnabled() )
    2924                 :            :     {
    2925                 :          0 :         bTmpUpper = sal_False;
    2926                 :          0 :         bTmpLower = sal_False;
    2927                 :            :     }
    2928                 :            : 
    2929                 :            :     ImplDrawSpinButton( this, maUpperRect, maLowerRect,
    2930                 :          0 :                         bUpperIn, bLowerIn, bTmpUpper, bTmpLower, !mbHorz );
    2931                 :            : }
    2932                 :            : 
    2933                 :            : // -----------------------------------------------------------------------
    2934                 :            : 
    2935                 :      34706 : void ToolBox::ImplDrawSeparator( sal_uInt16 nPos, Rectangle rRect )
    2936                 :            : {
    2937                 :      34706 :     bool bNativeOk = false;
    2938                 :      34706 :     ImplToolItem* pItem = &mpData->m_aItems[nPos];
    2939                 :            : 
    2940         [ +  - ]:      34706 :     ControlPart nPart = IsHorizontal() ? PART_SEPARATOR_VERT : PART_SEPARATOR_HORZ;
    2941         [ -  + ]:      34706 :     if( IsNativeControlSupported( CTRL_TOOLBAR, nPart ) )
    2942                 :            :     {
    2943                 :          0 :         ImplControlValue    aControlValue;
    2944                 :          0 :         ControlState        nState = 0;
    2945                 :            :         bNativeOk = DrawNativeControl( CTRL_TOOLBAR, nPart,
    2946 [ #  # ][ #  # ]:          0 :                                        rRect, nState, aControlValue, rtl::OUString() );
    2947                 :            :     }
    2948                 :            : 
    2949                 :            :     /* Draw the widget only if it can't be drawn natively. */
    2950         [ +  - ]:      34706 :     if( !bNativeOk )
    2951                 :            :     {
    2952                 :      34706 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    2953                 :      34706 :         ImplToolItem* pTempItem = &mpData->m_aItems[nPos-1];
    2954                 :            : 
    2955                 :            :         // no separator before or after windows or at breaks
    2956 [ +  + ][ +  - ]:      34706 :         if ( pTempItem && !pTempItem->mbShowWindow && nPos < mpData->m_aItems.size()-1 )
         [ +  + ][ +  - ]
    2957                 :            :         {
    2958                 :      29905 :             pTempItem = &mpData->m_aItems[nPos+1];
    2959 [ +  - ][ +  + ]:      29905 :             if ( !pTempItem->mbShowWindow && !pTempItem->mbBreak )
    2960                 :            :             {
    2961                 :            :                 long nCenterPos, nSlim;
    2962         [ +  - ]:      27894 :                 SetLineColor( rStyleSettings.GetSeparatorColor() );
    2963         [ +  - ]:      27894 :                 if ( IsHorizontal() )
    2964                 :            :                 {
    2965                 :      27894 :                     nSlim = (pItem->maRect.Bottom() - pItem->maRect.Top ()) / 4;
    2966                 :      27894 :                     nCenterPos = pItem->maRect.Center().X();
    2967                 :      27894 :                     DrawLine( Point( nCenterPos, pItem->maRect.Top() + nSlim ),
    2968         [ +  - ]:      55788 :                               Point( nCenterPos, pItem->maRect.Bottom() - nSlim ) );
    2969                 :            :                 }
    2970                 :            :                 else
    2971                 :            :                 {
    2972                 :          0 :                     nSlim = (pItem->maRect.Right() - pItem->maRect.Left ()) / 4;
    2973                 :          0 :                     nCenterPos = pItem->maRect.Center().Y();
    2974                 :          0 :                     DrawLine( Point( pItem->maRect.Left() + nSlim, nCenterPos ),
    2975         [ #  # ]:          0 :                               Point( pItem->maRect.Right() - nSlim, nCenterPos ) );
    2976                 :            :                 }
    2977                 :            :             }
    2978                 :            :         }
    2979                 :            :     }
    2980                 :      34706 : }
    2981                 :            : 
    2982                 :            : // -----------------------------------------------------------------------
    2983                 :            : 
    2984                 :       4160 : static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bEnabled, sal_Bool bIsWindow )
    2985                 :            : {
    2986                 :            :     // draws toolbar button background either native or using a coloured selection
    2987                 :            :     // if bIsWindow is sal_True, the corresponding item is a control and only a selection border will be drawn
    2988                 :            : 
    2989                 :       4160 :     sal_Bool bNativeOk = sal_False;
    2990 [ +  - ][ -  + ]:       4160 :     if( !bIsWindow && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) )
                 [ -  + ]
    2991                 :            :     {
    2992                 :          0 :         ImplControlValue    aControlValue;
    2993                 :          0 :         ControlState        nState = 0;
    2994                 :            : 
    2995         [ #  # ]:          0 :         if ( highlight == 1 )   nState |= CTRL_STATE_PRESSED;
    2996         [ #  # ]:          0 :         if ( highlight == 2 )     nState |= CTRL_STATE_ROLLOVER;
    2997         [ #  # ]:          0 :         if ( bEnabled )         nState |= CTRL_STATE_ENABLED;
    2998                 :            : 
    2999         [ #  # ]:          0 :         aControlValue.setTristateVal( bChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
    3000                 :            : 
    3001                 :            : 
    3002                 :            :         bNativeOk = pThis->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON,
    3003 [ #  # ][ #  # ]:          0 :                                               rRect, nState, aControlValue, rtl::OUString() );
    3004                 :            :     }
    3005                 :            : 
    3006         [ +  - ]:       4160 :     if( !bNativeOk )
    3007         [ +  - ]:       4160 :         pThis->DrawSelectionBackground( rRect, bIsWindow ? 3 : highlight, bChecked, sal_True, bIsWindow, 2, NULL, NULL );
    3008                 :       4160 : }
    3009                 :            : 
    3010                 :     141047 : void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight, sal_Bool bPaint, sal_Bool bLayout )
    3011                 :            : {
    3012                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    3013                 :            : 
    3014         [ +  - ]:     141047 :     if( nPos >= mpData->m_aItems.size() )
    3015                 :            :         return;
    3016                 :            : 
    3017                 :            :     // execute pending paint requests
    3018         [ +  - ]:     141047 :     ImplCheckUpdate( this );
    3019                 :            : 
    3020                 :     141047 :     ImplDisableFlatButtons();
    3021                 :            : 
    3022         [ +  - ]:     141047 :     SetFillColor();
    3023                 :            : 
    3024                 :     141047 :     ImplToolItem* pItem = &mpData->m_aItems[nPos];
    3025         [ -  + ]:     141047 :     MetricVector* pVector = bLayout ? &mpData->m_pLayoutData->m_aUnicodeBoundRects : NULL;
    3026         [ -  + ]:     141047 :     String* pDisplayText = bLayout ? &mpData->m_pLayoutData->m_aDisplayText : NULL;
    3027                 :            : 
    3028         [ +  + ]:     141047 :     if(!pItem->mbEnabled)
    3029                 :      48153 :         nHighlight = 0;
    3030                 :            : 
    3031                 :            :     // if the rectangle is outside visible area
    3032 [ +  - ][ +  - ]:     141047 :     if ( pItem->maRect.IsEmpty() )
    3033                 :            :         return;
    3034                 :            : 
    3035                 :     141047 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    3036                 :            : 
    3037                 :            :     // no gradient background for items that have a popup open
    3038 [ #  # ][ -  + ]:     141047 :     sal_Bool bHasOpenPopup = (mpFloatWin != NULL) && (mnDownItemId==pItem->mnId);
    3039                 :            : 
    3040                 :     141047 :     sal_Bool bHighContrastWhite = sal_False;
    3041                 :            :     // check the face color as highcontrast indicator
    3042                 :            :     // because the toolbox itself might have a gradient
    3043         [ -  + ]:     141047 :     if( rStyleSettings.GetFaceColor() == Color( COL_WHITE ) )
    3044                 :          0 :         bHighContrastWhite = sal_True;
    3045                 :            : 
    3046                 :            :     // Compute buttons area.
    3047         [ +  - ]:     141047 :     Size    aBtnSize    = pItem->maRect.GetSize();
    3048 [ +  - ][ -  + ]:     141047 :     if( ImplGetSVData()->maNWFData.mbToolboxDropDownSeparate )
    3049                 :            :     {
    3050                 :            :         // separate button not for dropdown only where the whole button is painted
    3051 [ #  # ][ #  # ]:          0 :         if ( pItem->mnBits & TIB_DROPDOWN &&
    3052                 :            :             ((pItem->mnBits & TIB_DROPDOWNONLY) != TIB_DROPDOWNONLY) )
    3053                 :            :         {
    3054         [ #  # ]:          0 :             Rectangle aArrowRect = pItem->GetDropDownRect( mbHorz );
    3055         [ #  # ]:          0 :             if( aArrowRect.Top() == pItem->maRect.Top() ) // dropdown arrow on right side
    3056         [ #  # ]:          0 :                 aBtnSize.Width() -= aArrowRect.GetWidth();
    3057                 :            :             else // dropdown arrow on bottom side
    3058         [ #  # ]:          0 :                 aBtnSize.Height() -= aArrowRect.GetHeight();
    3059                 :            :         }
    3060                 :            :     }
    3061                 :            : 
    3062                 :            :     /* Compute the button/separator rectangle here, we'll need it for
    3063                 :            :      * both the buttons and the separators. */
    3064         [ +  - ]:     141047 :     Rectangle aButtonRect( pItem->maRect.TopLeft(), aBtnSize );
    3065                 :     141047 :     long    nOffX       = SMALLBUTTON_OFF_NORMAL_X;
    3066                 :     141047 :     long    nOffY       = SMALLBUTTON_OFF_NORMAL_Y;
    3067                 :     141047 :     long    nImageOffX  = 0;
    3068                 :     141047 :     long    nImageOffY  = 0;
    3069                 :     141047 :     sal_uInt16  nStyle      = 0;
    3070                 :            : 
    3071                 :            :     // draw separators in flat style only
    3072 [ +  - ][ +  - ]:     141047 :     if ( !bLayout &&
         [ +  + ][ +  - ]
    3073                 :            :          (mnOutStyle & TOOLBOX_STYLE_FLAT) &&
    3074                 :            :          (pItem->meType == TOOLBOXITEM_SEPARATOR) &&
    3075                 :            :          nPos > 0
    3076                 :            :          )
    3077                 :            :     {
    3078         [ +  - ]:      34706 :         ImplDrawSeparator( nPos, aButtonRect );
    3079                 :            :     }
    3080                 :            : 
    3081                 :            :     // do nothing if item is no button or will be displayed as window
    3082 [ +  + ][ +  + ]:     141047 :     if ( (pItem->meType != TOOLBOXITEM_BUTTON) ||
                 [ -  + ]
    3083                 :       5909 :          (pItem->mbShowWindow && !mbCustomizeMode) )
    3084                 :            :         return;
    3085                 :            : 
    3086                 :            :     // we need a TBDragMananger to draw the configuration item
    3087                 :            :     ImplTBDragMgr* pMgr;
    3088         [ -  + ]:     100311 :     if ( pItem->mnId == mnConfigItem )
    3089                 :            :     {
    3090         [ #  # ]:          0 :         pMgr = ImplGetTBDragMgr();
    3091         [ #  # ]:          0 :         pMgr->HideDragRect();
    3092                 :            :     }
    3093                 :            :     else
    3094                 :     100311 :         pMgr = NULL;
    3095                 :            : 
    3096                 :            :     // during configuration mode visible windows will be drawn in a special way
    3097 [ -  + ][ #  # ]:     100311 :     if ( mbCustomizeMode && pItem->mbShowWindow )
    3098                 :            :     {
    3099         [ #  # ]:          0 :         Font    aOldFont = GetFont();
    3100                 :          0 :         Color   aOldTextColor = GetTextColor();
    3101                 :            : 
    3102         [ #  # ]:          0 :         SetZoomedPointFont( rStyleSettings.GetAppFont() );
    3103         [ #  # ]:          0 :         SetLineColor( Color( COL_BLACK ) );
    3104         [ #  # ]:          0 :         SetFillColor( rStyleSettings.GetFieldColor() );
    3105         [ #  # ]:          0 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
    3106         [ #  # ]:          0 :         if( !bLayout )
    3107         [ #  # ]:          0 :             DrawRect( pItem->maRect );
    3108                 :            : 
    3109 [ #  # ][ #  # ]:          0 :         Size aSize( GetCtrlTextWidth( pItem->maText ), GetTextHeight() );
    3110                 :          0 :         Point aPos( pItem->maRect.Left()+2, pItem->maRect.Top() );
    3111         [ #  # ]:          0 :         aPos.Y() += (pItem->maRect.GetHeight()-aSize.Height())/2;
    3112                 :            :         sal_Bool bClip;
    3113 [ #  # ][ #  # ]:          0 :         if ( (aSize.Width() > pItem->maRect.GetWidth()-2) ||
         [ #  # ][ #  # ]
    3114         [ #  # ]:          0 :              (aSize.Height() > pItem->maRect.GetHeight()-2) )
    3115                 :            :         {
    3116                 :          0 :             bClip = sal_True;
    3117                 :          0 :             Rectangle aTempRect( pItem->maRect.Left()+1, pItem->maRect.Top()+1,
    3118         [ #  # ]:          0 :                                  pItem->maRect.Right()-1, pItem->maRect.Bottom()-1 );
    3119         [ #  # ]:          0 :             Region aTempRegion( aTempRect );
    3120 [ #  # ][ #  # ]:          0 :             SetClipRegion( aTempRegion );
    3121                 :            :         }
    3122                 :            :         else
    3123                 :          0 :             bClip = sal_False;
    3124         [ #  # ]:          0 :         if( bLayout )
    3125                 :            :         {
    3126         [ #  # ]:          0 :             mpData->m_pLayoutData->m_aLineIndices.push_back( mpData->m_pLayoutData->m_aDisplayText.Len() );
    3127         [ #  # ]:          0 :             mpData->m_pLayoutData->m_aLineItemIds.push_back( pItem->mnId );
    3128         [ #  # ]:          0 :             mpData->m_pLayoutData->m_aLineItemPositions.push_back( nPos );
    3129                 :            :         }
    3130         [ #  # ]:          0 :         DrawCtrlText( aPos, pItem->maText, 0, STRING_LEN, TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
    3131         [ #  # ]:          0 :         if ( bClip )
    3132         [ #  # ]:          0 :             SetClipRegion();
    3133         [ #  # ]:          0 :         SetFont( aOldFont );
    3134         [ #  # ]:          0 :         SetTextColor( aOldTextColor );
    3135                 :            : 
    3136                 :            :         // draw Config-Frame if required
    3137 [ #  # ][ #  # ]:          0 :         if ( pMgr && !bLayout)
    3138         [ #  # ]:          0 :             pMgr->UpdateDragRect();
    3139         [ #  # ]:          0 :         return;
    3140                 :            :     }
    3141                 :            : 
    3142         [ +  + ]:     100311 :     if ( pItem->meState == STATE_CHECK )
    3143                 :            :     {
    3144                 :       4158 :         nStyle |= BUTTON_DRAW_CHECKED;
    3145                 :            :     }
    3146         [ +  + ]:      96153 :     else if ( pItem->meState == STATE_DONTKNOW )
    3147                 :            :     {
    3148                 :         10 :         nStyle |= BUTTON_DRAW_DONTKNOW;
    3149                 :            :     }
    3150         [ -  + ]:     100311 :     if ( nHighlight == 1 )
    3151                 :            :     {
    3152                 :          0 :         nStyle |= BUTTON_DRAW_PRESSED;
    3153                 :            :     }
    3154                 :            : 
    3155         [ +  - ]:     100311 :     if( ! bLayout )
    3156                 :            :     {
    3157         [ +  - ]:     100311 :         if ( mnOutStyle & TOOLBOX_STYLE_FLAT )
    3158                 :            :         {
    3159 [ +  + ][ +  - ]:     100311 :             if ( (pItem->meState != STATE_NOCHECK) || !bPaint )
    3160                 :            :             {
    3161         [ +  - ]:     100311 :                 ImplErase( this, pItem->maRect, nHighlight != 0, bHasOpenPopup );
    3162                 :            :             }
    3163                 :            :         }
    3164                 :            :         else
    3165                 :            :         {
    3166                 :          0 :             DecorationView aDecoView( this );
    3167         [ #  # ]:          0 :             aDecoView.DrawButton( aButtonRect, nStyle );
    3168                 :            :         }
    3169                 :            :     }
    3170                 :            : 
    3171                 :     100311 :     nOffX += pItem->maRect.Left();
    3172                 :     100311 :     nOffY += pItem->maRect.Top();
    3173                 :            : 
    3174                 :            :     // determine what has to be drawn on the button: image, text or both
    3175                 :            :     sal_Bool bImage;
    3176                 :            :     sal_Bool bText;
    3177                 :     100311 :     ButtonType tmpButtonType = determineButtonType( pItem, meButtonType ); // default to toolbox setting
    3178         [ +  - ]:     100311 :     pItem->DetermineButtonDrawStyle( tmpButtonType, bImage, bText );
    3179                 :            : 
    3180                 :            :     // compute output values
    3181                 :     100311 :     long    nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE;
    3182                 :     100311 :     long    nBtnHeight = aBtnSize.Height()-SMALLBUTTON_VSIZE;
    3183                 :     100311 :     Size    aImageSize;
    3184                 :     100311 :     Size    aTxtSize;
    3185                 :            : 
    3186         [ +  + ]:     100311 :     if ( bText )
    3187                 :            :     {
    3188         [ +  - ]:        160 :         aTxtSize.Width() = GetCtrlTextWidth( pItem->maText );
    3189         [ +  - ]:        160 :         aTxtSize.Height() = GetTextHeight();
    3190                 :            :     }
    3191                 :            : 
    3192 [ +  + ][ +  - ]:     100311 :     if ( bImage && ! bLayout )
    3193                 :            :     {
    3194                 :            :         const Image* pImage;
    3195 [ +  + ][ -  + ]:     100151 :         if ( (nHighlight != 0) && (!(pItem->maHighImage)) == sal_False )
                 [ -  + ]
    3196                 :          0 :             pImage = &(pItem->maHighImage);
    3197                 :            :         else
    3198                 :     100151 :             pImage = &(pItem->maImage);
    3199                 :            : 
    3200         [ +  - ]:     100151 :         aImageSize = pImage->GetSizePixel();
    3201                 :            : 
    3202                 :            :         // determine drawing flags
    3203                 :     100151 :         sal_uInt16 nImageStyle = 0;
    3204                 :            : 
    3205 [ +  + ][ +  - ]:     100151 :         if ( !pItem->mbEnabled || !IsEnabled() )
         [ +  + ][ +  + ]
    3206                 :      12661 :             nImageStyle |= IMAGE_DRAW_DISABLE;
    3207                 :            : 
    3208                 :            :         // #i35563# the dontknow state indicates different states at the same time
    3209                 :            :         // which should not be rendered disabled but normal
    3210                 :            : 
    3211                 :            :         // draw the image
    3212                 :     100151 :         nImageOffX = nOffX;
    3213                 :     100151 :         nImageOffY = nOffY;
    3214 [ +  + ][ -  + ]:     100151 :         if ( (pItem->mnBits & (TIB_LEFT|TIB_DROPDOWN)) || bText )
    3215                 :            :         {
    3216                 :            :             // left align also to leave space for drop down arrow
    3217                 :            :             // and when drawing text+image
    3218                 :            :             // just center in y, except for vertical (ie rotated text)
    3219 [ -  + ][ #  # ]:      40104 :             if( mbHorz || !bText )
    3220                 :      20052 :                 nImageOffY += (nBtnHeight-aImageSize.Height())/2;
    3221                 :            :         }
    3222                 :            :         else
    3223                 :            :         {
    3224                 :      80099 :             nImageOffX += (nBtnWidth-aImageSize.Width())/2;
    3225                 :      80099 :             nImageOffY += (nBtnHeight-aImageSize.Height())/2;
    3226                 :            :         }
    3227 [ +  + ][ +  + ]:     100151 :         if ( nHighlight != 0 || (pItem->meState == STATE_CHECK) )
    3228                 :            :         {
    3229         [ -  + ]:       4160 :             if( bHasOpenPopup )
    3230         [ #  # ]:          0 :                 ImplDrawFloatwinBorder( pItem );
    3231                 :            :             else
    3232 [ -  + ][ +  - ]:       4160 :                 ImplDrawButton( this, aButtonRect, nHighlight, pItem->meState == STATE_CHECK, pItem->mbEnabled && IsEnabled(), pItem->mbShowWindow ? sal_True : sal_False );
         [ +  - ][ +  + ]
                 [ +  - ]
    3233                 :            : 
    3234         [ +  + ]:       4160 :             if( nHighlight != 0 )
    3235                 :            :             {
    3236         [ -  + ]:          2 :                 if( bHighContrastWhite )
    3237                 :          0 :                     nImageStyle |= IMAGE_DRAW_COLORTRANSFORM;
    3238                 :            :             }
    3239                 :            :         }
    3240         [ +  - ]:     100151 :         DrawImage( Point( nImageOffX, nImageOffY ), *pImage, nImageStyle );
    3241                 :            :     }
    3242                 :            : 
    3243                 :            :     // draw the text
    3244                 :     100311 :     sal_Bool bRotate = sal_False;
    3245         [ +  + ]:     100311 :     if ( bText )
    3246                 :            :     {
    3247                 :        160 :         long nTextOffX = nOffX;
    3248                 :        160 :         long nTextOffY = nOffY;
    3249                 :            : 
    3250                 :            :         // rotate text when vertically docked
    3251         [ +  - ]:        160 :         Font aOldFont = GetFont();
    3252 [ +  - ][ +  - ]:        160 :         if( pItem->mbVisibleText && !ImplIsFloatingMode() &&
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
    3253                 :            :             ((meAlign == WINDOWALIGN_LEFT) || (meAlign == WINDOWALIGN_RIGHT)) )
    3254                 :            :         {
    3255                 :          0 :             bRotate = sal_True;
    3256                 :            : 
    3257         [ #  # ]:          0 :             Font aRotateFont = aOldFont;
    3258         [ #  # ]:          0 :             aRotateFont.SetOrientation( 2700 );
    3259                 :            : 
    3260                 :            :             // center horizontally
    3261                 :          0 :             nTextOffX += aTxtSize.Height();
    3262                 :          0 :             nTextOffX += (nBtnWidth-aTxtSize.Height())/2;
    3263                 :            : 
    3264                 :            :             // add in image offset
    3265         [ #  # ]:          0 :             if( bImage )
    3266                 :          0 :                 nTextOffY = nImageOffY + aImageSize.Height() + TB_IMAGETEXTOFFSET;
    3267                 :            : 
    3268 [ #  # ][ #  # ]:          0 :             SetFont( aRotateFont );
    3269                 :            :         }
    3270                 :            :         else
    3271                 :            :         {
    3272                 :            :             // center vertically
    3273                 :        160 :             nTextOffY += (nBtnHeight-aTxtSize.Height())/2;
    3274                 :            : 
    3275                 :            :             // add in image offset
    3276         [ -  + ]:        160 :             if( bImage )
    3277                 :          0 :                 nTextOffX = nImageOffX + aImageSize.Width() + TB_IMAGETEXTOFFSET;
    3278                 :            :         }
    3279                 :            : 
    3280                 :            :         // draw selection only if not already drawn during image output (see above)
    3281 [ +  - ][ +  - ]:        160 :         if ( !bLayout && !bImage && (nHighlight != 0 || (pItem->meState == STATE_CHECK) ) )
         [ +  - ][ -  + ]
    3282                 :            :         {
    3283         [ #  # ]:          0 :             if( bHasOpenPopup )
    3284         [ #  # ]:          0 :                 ImplDrawFloatwinBorder( pItem );
    3285                 :            :             else
    3286 [ #  # ][ #  # ]:          0 :                 ImplDrawButton( this, pItem->maRect, nHighlight, pItem->meState == STATE_CHECK, pItem->mbEnabled && IsEnabled(), pItem->mbShowWindow ? sal_True : sal_False );
         [ #  # ][ #  # ]
                 [ #  # ]
    3287                 :            :         }
    3288                 :            : 
    3289                 :        160 :         sal_uInt16 nTextStyle = 0;
    3290         [ -  + ]:        160 :         if ( !pItem->mbEnabled )
    3291                 :          0 :             nTextStyle |= TEXT_DRAW_DISABLE;
    3292         [ -  + ]:        160 :         if( bLayout )
    3293                 :            :         {
    3294         [ #  # ]:          0 :             mpData->m_pLayoutData->m_aLineIndices.push_back( mpData->m_pLayoutData->m_aDisplayText.Len() );
    3295         [ #  # ]:          0 :             mpData->m_pLayoutData->m_aLineItemIds.push_back( pItem->mnId );
    3296         [ #  # ]:          0 :             mpData->m_pLayoutData->m_aLineItemPositions.push_back( nPos );
    3297                 :            :         }
    3298                 :            :         DrawCtrlText( Point( nTextOffX, nTextOffY ), pItem->maText,
    3299         [ +  - ]:        160 :                       0, STRING_LEN, nTextStyle, pVector, pDisplayText );
    3300         [ -  + ]:        160 :         if ( bRotate )
    3301 [ #  # ][ +  - ]:        160 :             SetFont( aOldFont );
    3302                 :            :     }
    3303                 :            : 
    3304         [ +  - ]:     100311 :     if( bLayout )
    3305                 :            :         return;
    3306                 :            : 
    3307                 :            :     // paint optional drop down arrow
    3308         [ +  + ]:     100311 :     if ( pItem->mnBits & TIB_DROPDOWN )
    3309                 :            :     {
    3310         [ +  - ]:      20100 :         Rectangle aDropDownRect( pItem->GetDropDownRect( mbHorz ) );
    3311                 :      20100 :         sal_Bool bSetColor = sal_True;
    3312 [ +  + ][ +  - ]:      20100 :         if ( !pItem->mbEnabled || !IsEnabled() )
         [ +  + ][ +  + ]
    3313                 :            :         {
    3314                 :       4527 :             bSetColor = sal_False;
    3315         [ +  - ]:       4527 :             SetFillColor( rStyleSettings.GetShadowColor() );
    3316                 :            :         }
    3317                 :            : 
    3318                 :            :         // dropdown only will be painted without inner border
    3319         [ +  + ]:      20100 :         if( (pItem->mnBits & TIB_DROPDOWNONLY) != TIB_DROPDOWNONLY )
    3320                 :            :         {
    3321         [ +  - ]:      19165 :             ImplErase( this, aDropDownRect, nHighlight != 0, bHasOpenPopup );
    3322                 :            : 
    3323 [ +  - ][ -  + ]:      19165 :             if( nHighlight != 0 || (pItem->meState == STATE_CHECK) )
    3324                 :            :             {
    3325         [ #  # ]:          0 :                 if( bHasOpenPopup )
    3326         [ #  # ]:          0 :                     ImplDrawFloatwinBorder( pItem );
    3327                 :            :                 else
    3328 [ #  # ][ #  # ]:          0 :                     ImplDrawButton( this, aDropDownRect, nHighlight, pItem->meState == STATE_CHECK, pItem->mbEnabled && IsEnabled(), sal_False );
         [ #  # ][ #  # ]
    3329                 :            :             }
    3330                 :            :         }
    3331         [ +  - ]:      20100 :         ImplDrawDropdownArrow( this, aDropDownRect, bSetColor, bRotate );
    3332                 :            :     }
    3333                 :            : 
    3334                 :            :     // draw config-frame if required
    3335         [ -  + ]:     100311 :     if ( pMgr )
    3336         [ #  # ]:     141047 :         pMgr->UpdateDragRect();
    3337                 :            : }
    3338                 :            : 
    3339                 :            : // -----------------------------------------------------------------------
    3340                 :            : 
    3341                 :          0 : void ToolBox::ImplDrawFloatwinBorder( ImplToolItem* pItem )
    3342                 :            : {
    3343         [ #  # ]:          0 :     if ( !pItem->maRect.IsEmpty() )
    3344                 :            :     {
    3345         [ #  # ]:          0 :         Rectangle aRect( mpFloatWin->ImplGetItemEdgeClipRect() );
    3346         [ #  # ]:          0 :         aRect.SetPos( AbsoluteScreenToOutputPixel( aRect.TopLeft() ) );
    3347         [ #  # ]:          0 :         SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
    3348                 :          0 :         Point p1, p2;
    3349                 :            : 
    3350                 :          0 :         p1 = pItem->maRect.TopLeft();
    3351                 :          0 :         p1.X()++;
    3352         [ #  # ]:          0 :         p2 = pItem->maRect.TopRight();
    3353                 :          0 :         p2.X()--;
    3354         [ #  # ]:          0 :         DrawLine( p1, p2);
    3355         [ #  # ]:          0 :         p1 = pItem->maRect.BottomLeft();
    3356                 :          0 :         p1.X()++;
    3357         [ #  # ]:          0 :         p2 = pItem->maRect.BottomRight();
    3358                 :          0 :         p2.X()--;
    3359         [ #  # ]:          0 :         DrawLine( p1, p2);
    3360                 :            : 
    3361                 :          0 :         p1 = pItem->maRect.TopLeft();
    3362                 :          0 :         p1.Y()++;
    3363         [ #  # ]:          0 :         p2 = pItem->maRect.BottomLeft();
    3364                 :          0 :         p2.Y()--;
    3365         [ #  # ]:          0 :         DrawLine( p1, p2);
    3366         [ #  # ]:          0 :         p1 = pItem->maRect.TopRight();
    3367                 :          0 :         p1.Y()++;
    3368         [ #  # ]:          0 :         p2 = pItem->maRect.BottomRight();
    3369                 :          0 :         p2.Y()--;
    3370         [ #  # ]:          0 :         DrawLine( p1, p2);
    3371                 :            : 
    3372                 :            :         //DrawRect( pItem->maRect );
    3373                 :            :     }
    3374                 :          0 : }
    3375                 :            : 
    3376                 :          0 : void ToolBox::ImplFloatControl( sal_Bool bStart, FloatingWindow* pFloatWindow )
    3377                 :            : {
    3378                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    3379                 :            : 
    3380         [ #  # ]:          0 :     if ( bStart )
    3381                 :            :     {
    3382                 :          0 :         mpFloatWin = pFloatWindow;
    3383                 :            : 
    3384                 :            :         // redraw item, to trigger drawing of a special border
    3385                 :          0 :         ImplDrawItem( mnCurPos, 1 );
    3386                 :            : 
    3387                 :          0 :         mbDrag = sal_False;
    3388                 :          0 :         EndTracking();
    3389                 :          0 :         ReleaseMouse();
    3390                 :            :     }
    3391                 :            :     else
    3392                 :            :     {
    3393                 :          0 :         mpFloatWin = NULL;
    3394                 :            : 
    3395                 :            :         // if focus is still in this toolbox, then the floater was opened by keyboard
    3396                 :            :         // draw current item with highlight and keep old state
    3397                 :          0 :         sal_Bool bWasKeyboardActivate = mpData->mbDropDownByKeyboard;
    3398                 :            : 
    3399                 :            : 
    3400         [ #  # ]:          0 :         if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
    3401         [ #  # ]:          0 :             ImplDrawItem( mnCurPos, bWasKeyboardActivate ? 2 : 0 );
    3402                 :          0 :         Deactivate();
    3403                 :            : 
    3404         [ #  # ]:          0 :         if( !bWasKeyboardActivate )
    3405                 :            :         {
    3406                 :          0 :             mnCurPos = TOOLBOX_ITEM_NOTFOUND;
    3407                 :          0 :             mnCurItemId = 0;
    3408                 :          0 :             mnHighItemId = 0;
    3409                 :            :         }
    3410                 :          0 :         mnDownItemId = 0;
    3411                 :            : 
    3412                 :            :     }
    3413                 :          0 : }
    3414                 :            : 
    3415                 :            : // -----------------------------------------------------------------------
    3416                 :            : 
    3417                 :          0 : void ToolBox::ShowLine( sal_Bool bNext )
    3418                 :            : {
    3419                 :            :     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    3420                 :            : 
    3421                 :          0 :     mbFormat = sal_True;
    3422                 :            : 
    3423         [ #  # ]:          0 :     if ( mpData->mbPageScroll )
    3424                 :            :     {
    3425                 :          0 :         sal_uInt16 delta = mnVisLines;
    3426         [ #  # ]:          0 :         if ( bNext )
    3427                 :            :         {
    3428                 :          0 :             mnCurLine = mnCurLine + delta;
    3429         [ #  # ]:          0 :             if ( mnCurLine+mnVisLines-1 > mnCurLines )
    3430                 :          0 :                 mnCurLine = mnCurLines - mnVisLines+1;
    3431                 :            :         }
    3432                 :            :         else
    3433                 :            :         {
    3434         [ #  # ]:          0 :             if( mnCurLine >= delta+1 )
    3435                 :          0 :                 mnCurLine = mnCurLine - delta;
    3436                 :            :             else
    3437                 :          0 :                 mnCurLine = 1;
    3438                 :            :         }
    3439                 :            :     }
    3440                 :            :     else
    3441                 :            :     {
    3442         [ #  # ]:          0 :         if ( bNext )
    3443                 :          0 :             mnCurLine++;
    3444                 :            :         else
    3445                 :          0 :             mnCurLine--;
    3446                 :            :     }
    3447                 :            : 
    3448                 :          0 :     ImplFormat();
    3449                 :          0 : }
    3450                 :            : 
    3451                 :            : // -----------------------------------------------------------------------
    3452                 :            : 
    3453                 :          0 : sal_Bool ToolBox::ImplHandleMouseMove( const MouseEvent& rMEvt, sal_Bool bRepeat )
    3454                 :            : {
    3455                 :          0 :     Point aMousePos = rMEvt.GetPosPixel();
    3456                 :            : 
    3457                 :            :     // ToolBox active?
    3458 [ #  # ][ #  # ]:          0 :     if ( mbDrag && mnCurPos != TOOLBOX_ITEM_NOTFOUND )
    3459                 :            :     {
    3460                 :            :         // is the cursor over the item?
    3461                 :          0 :         ImplToolItem* pItem = &mpData->m_aItems[mnCurPos];
    3462 [ #  # ][ #  # ]:          0 :         if ( pItem->maRect.IsInside( aMousePos ) )
    3463                 :            :         {
    3464         [ #  # ]:          0 :             if ( !mnCurItemId )
    3465                 :            :             {
    3466         [ #  # ]:          0 :                 ImplDrawItem( mnCurPos, 1 );
    3467                 :          0 :                 mnCurItemId = pItem->mnId;
    3468         [ #  # ]:          0 :                 Highlight();
    3469                 :            :             }
    3470                 :            : 
    3471 [ #  # ][ #  # ]:          0 :             if ( (pItem->mnBits & TIB_REPEAT) && bRepeat )
    3472         [ #  # ]:          0 :                 Select();
    3473                 :            :         }
    3474                 :            :         else
    3475                 :            :         {
    3476         [ #  # ]:          0 :             if ( mnCurItemId )
    3477                 :            :             {
    3478         [ #  # ]:          0 :                 ImplDrawItem( mnCurPos );
    3479                 :          0 :                 mnCurItemId = 0;
    3480         [ #  # ]:          0 :                 ImplDrawItem( mnCurPos );
    3481         [ #  # ]:          0 :                 Highlight();
    3482                 :            :             }
    3483                 :            :         }
    3484                 :            : 
    3485                 :          0 :         return sal_True;
    3486                 :            :     }
    3487                 :            : 
    3488         [ #  # ]:          0 :     if ( mbUpper )
    3489                 :            :     {
    3490         [ #  # ]:          0 :         sal_Bool bNewIn = maUpperRect.IsInside( aMousePos );
    3491         [ #  # ]:          0 :         if ( bNewIn != mbIn )
    3492                 :            :         {
    3493                 :          0 :             mbIn = bNewIn;
    3494         [ #  # ]:          0 :             ImplDrawSpin( mbIn, sal_False );
    3495                 :            :         }
    3496                 :          0 :         return sal_True;
    3497                 :            :     }
    3498                 :            : 
    3499         [ #  # ]:          0 :     if ( mbLower )
    3500                 :            :     {
    3501         [ #  # ]:          0 :         sal_Bool bNewIn = maLowerRect.IsInside( aMousePos );
    3502         [ #  # ]:          0 :         if ( bNewIn != mbIn )
    3503                 :            :         {
    3504                 :          0 :             mbIn = bNewIn;
    3505         [ #  # ]:          0 :             ImplDrawSpin( sal_False, mbIn );
    3506                 :            :         }
    3507                 :          0 :         return sal_True;
    3508                 :            :     }
    3509                 :            : 
    3510                 :          0 :     return sal_False;
    3511                 :            : }
    3512                 :            : 
    3513                 :            : // -----------------------------------------------------------------------
    3514                 :            : 
    3515                 :          0 : sal_Bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, sal_Bool bCancel )
    3516                 :            : {
    3517                 :          0 :     ImplDisableFlatButtons();
    3518                 :            : 
    3519                 :            :     // stop eventual running dropdown timer
    3520         [ #  # ]:          0 :     if( mnCurPos < mpData->m_aItems.size() &&
           [ #  #  #  # ]
    3521                 :          0 :         (mpData->m_aItems[mnCurPos].mnBits & TIB_DROPDOWN ) )
    3522                 :            :     {
    3523                 :          0 :         mpData->maDropdownTimer.Stop();
    3524                 :            :     }
    3525                 :            : 
    3526 [ #  # ][ #  # ]:          0 :     if ( mbDrag || mbSelection )
    3527                 :            :     {
    3528                 :            :         // set mouse data if in selection mode, as then
    3529                 :            :         // the MouseButtonDown handler cannot be called
    3530         [ #  # ]:          0 :         if ( mbSelection )
    3531                 :            :         {
    3532                 :          0 :             mnMouseClicks    = rMEvt.GetClicks();
    3533                 :          0 :             mnMouseModifier  = rMEvt.GetModifier();
    3534                 :            :         }
    3535                 :            : 
    3536                 :          0 :         Deactivate();
    3537                 :            : 
    3538         [ #  # ]:          0 :         if ( mbDrag )
    3539                 :          0 :             mbDrag = sal_False;
    3540                 :            :         else
    3541                 :            :         {
    3542                 :          0 :             mbSelection = sal_False;
    3543         [ #  # ]:          0 :             if ( mnCurPos == TOOLBOX_ITEM_NOTFOUND )
    3544                 :          0 :                 return sal_True;
    3545                 :            :         }
    3546                 :            : 
    3547                 :            :         // has mouse been released on top of item?
    3548         [ #  # ]:          0 :         if( mnCurPos < mpData->m_aItems.size() )
    3549                 :            :         {
    3550                 :          0 :             ImplToolItem* pItem = &mpData->m_aItems[mnCurPos];
    3551         [ #  # ]:          0 :             if ( pItem->maRect.IsInside( rMEvt.GetPosPixel() ) )
    3552                 :            :             {
    3553                 :          0 :                 mnCurItemId = pItem->mnId;
    3554         [ #  # ]:          0 :                 if ( !bCancel )
    3555                 :            :                 {
    3556                 :            :                     // execute AutoCheck if required
    3557         [ #  # ]:          0 :                     if ( pItem->mnBits & TIB_AUTOCHECK )
    3558                 :            :                     {
    3559         [ #  # ]:          0 :                         if ( pItem->mnBits & TIB_RADIOCHECK )
    3560                 :            :                         {
    3561         [ #  # ]:          0 :                             if ( pItem->meState != STATE_CHECK )
    3562                 :          0 :                                 SetItemState( pItem->mnId, STATE_CHECK );
    3563                 :            :                         }
    3564                 :            :                         else
    3565                 :            :                         {
    3566         [ #  # ]:          0 :                             if ( pItem->meState != STATE_CHECK )
    3567                 :          0 :                                 pItem->meState = STATE_CHECK;
    3568                 :            :                             else
    3569                 :          0 :                                 pItem->meState = STATE_NOCHECK;
    3570                 :            :                         }
    3571                 :            :                     }
    3572                 :            : 
    3573                 :            :                     // do not call Select when Repeat is active, as in this
    3574                 :            :                     // case that was triggered already in MouseButtonDown
    3575         [ #  # ]:          0 :                     if ( !(pItem->mnBits & TIB_REPEAT) )
    3576                 :            :                     {
    3577                 :            :                         // prevent from being destroyed in the select handler
    3578         [ #  # ]:          0 :                         ImplDelData aDelData;
    3579         [ #  # ]:          0 :                         ImplAddDel( &aDelData );
    3580         [ #  # ]:          0 :                         Select();
    3581         [ #  # ]:          0 :                         if ( aDelData.IsDead() )
    3582                 :          0 :                             return sal_True;
    3583 [ #  # ][ #  # ]:          0 :                         ImplRemoveDel( &aDelData );
                 [ #  # ]
    3584                 :            :                     }
    3585                 :            :                 }
    3586                 :            : 
    3587                 :            :                 {
    3588                 :            :                     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
    3589                 :            :                 }
    3590                 :            : 
    3591                 :            :                 // Items not destroyed, in Select handler
    3592         [ #  # ]:          0 :                 if ( mnCurItemId )
    3593                 :            :                 {
    3594                 :            :                     sal_uInt16 nHighlight;
    3595 [ #  # ][ #  # ]:          0 :                     if ( (mnCurItemId == mnHighItemId) && (mnOutStyle & TOOLBOX_STYLE_FLAT) )
    3596                 :          0 :                         nHighlight = 2;
    3597                 :            :                     else
    3598                 :          0 :                         nHighlight = 0;
    3599                 :            :                     // Get current pos for the case that items are inserted/removed
    3600                 :            :                     // in the toolBox
    3601                 :          0 :                     mnCurPos = GetItemPos( mnCurItemId );
    3602         [ #  # ]:          0 :                     if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
    3603                 :            :                     {
    3604                 :          0 :                         ImplDrawItem( mnCurPos, nHighlight );
    3605                 :          0 :                         Flush();
    3606                 :            :                     }
    3607                 :            :                 }
    3608                 :            :             }
    3609                 :            :         }
    3610                 :            : 
    3611                 :          0 :         mnCurPos         = TOOLBOX_ITEM_NOTFOUND;
    3612                 :          0 :         mnCurItemId      = 0;
    3613                 :          0 :         mnDownItemId     = 0;
    3614                 :          0 :         mnMouseClicks    = 0;
    3615                 :          0 :         mnMouseModifier  = 0;
    3616                 :          0 :         return sal_True;
    3617                 :            :     }
    3618 [ #  # ][ #  # ]:          0 :     else if ( mbUpper || mbLower )
    3619                 :            :     {
    3620         [ #  # ]:          0 :         if ( mbIn )
    3621                 :          0 :             ShowLine( !mbUpper );
    3622                 :          0 :         mbUpper = sal_False;
    3623                 :          0 :         mbLower = sal_False;
    3624                 :          0 :         mbIn    = sal_False;
    3625                 :          0 :         ImplDrawSpin( sal_False, sal_False );
    3626                 :          0 :         return sal_True;
    3627                 :            :     }
    3628                 :            : 
    3629                 :          0 :     return sal_False;
    3630                 :            : }
    3631                 :            : 
    3632                 :            : // -----------------------------------------------------------------------
    3633                 :            : 
    3634                 :          0 : void ToolBox::MouseMove( const MouseEvent& rMEvt )
    3635                 :            : {
    3636                 :            :     // pressing a modifier generates synthetic mouse moves
    3637                 :            :     // ignore it if keyboard selection is acive
    3638 [ #  # ][ #  # ]:          0 :     if( HasFocus() && ( rMEvt.GetMode() & MOUSE_MODIFIERCHANGED ) )
         [ #  # ][ #  # ]
    3639                 :            :         return;
    3640                 :            : 
    3641 [ #  # ][ #  # ]:          0 :     if ( ImplHandleMouseMove( rMEvt ) )
    3642                 :            :         return;
    3643                 :            : 
    3644                 :          0 :     ImplDisableFlatButtons();
    3645                 :            : 
    3646                 :          0 :     Point aMousePos = rMEvt.GetPosPixel();
    3647                 :            : 
    3648                 :            :     // only highlight when the focus is not inside a child window of a toolbox
    3649                 :            :     // eg, in a edit control
    3650                 :            :     // and do not hilight when focus is in a different toolbox
    3651                 :          0 :     sal_Bool bDrawHotSpot = sal_True;
    3652         [ #  # ]:          0 :     Window *pWin = Application::GetFocusWindow();
    3653 [ #  # ][ #  # ]:          0 :     if( pWin && pWin->ImplGetWindowImpl()->mbToolBox && pWin != this )
         [ #  # ][ #  # ]
    3654                 :          0 :         bDrawHotSpot = sal_False;
    3655                 :            : 
    3656 [ #  # ][ #  # ]:          0 :     if ( mbSelection && bDrawHotSpot )
    3657                 :            :     {
    3658                 :          0 :         sal_uInt16  i = 0;
    3659                 :          0 :         sal_uInt16  nNewPos = TOOLBOX_ITEM_NOTFOUND;
    3660                 :            : 
    3661                 :            :         // search the item that has been clicked
    3662         [ #  # ]:          0 :         std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    3663 [ #  # ][ #  # ]:          0 :         while ( it != mpData->m_aItems.end() )
    3664                 :            :         {
    3665                 :            :             // if the mouse position is in this item,
    3666                 :            :             // we can stop the search
    3667 [ #  # ][ #  # ]:          0 :             if ( it->maRect.IsInside( aMousePos ) )
    3668                 :            :             {
    3669                 :            :                 // select it if it is a button
    3670         [ #  # ]:          0 :                 if ( it->meType == TOOLBOXITEM_BUTTON )
    3671                 :            :                 {
    3672                 :            :                     // if button is disabled, do not
    3673                 :            :                     // change it
    3674 [ #  # ][ #  # ]:          0 :                     if ( !it->mbEnabled || it->mbShowWindow )
                 [ #  # ]
    3675                 :          0 :                         nNewPos = mnCurPos;
    3676                 :            :                     else
    3677                 :          0 :                         nNewPos = i;
    3678                 :            :                 }
    3679                 :            : 
    3680                 :          0 :                 break;
    3681                 :            :             }
    3682                 :            : 
    3683                 :          0 :             i++;
    3684                 :          0 :             ++it;
    3685                 :            :         }
    3686                 :            : 
    3687                 :            :         // was a new entery selected ?
    3688                 :            :         // don't  change selection if keyboard selection is active and
    3689                 :            :         // mouse leaves the toolbox
    3690 [ #  # ][ #  # ]:          0 :         if ( nNewPos != mnCurPos && !( HasFocus() && nNewPos == TOOLBOX_ITEM_NOTFOUND ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    3691                 :            :         {
    3692         [ #  # ]:          0 :             if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
    3693                 :            :             {
    3694         [ #  # ]:          0 :                 ImplDrawItem( mnCurPos );
    3695         [ #  # ]:          0 :                 ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( mnCurPos ) );
    3696                 :            :             }
    3697                 :            : 
    3698                 :          0 :             mnCurPos = nNewPos;
    3699         [ #  # ]:          0 :             if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
    3700                 :            :             {
    3701                 :          0 :                 mnCurItemId = mnHighItemId = it->mnId;
    3702         [ #  # ]:          0 :                 ImplDrawItem( mnCurPos, 2 ); // always use shadow effect (2)
    3703                 :            :             }
    3704                 :            :             else
    3705                 :          0 :                 mnCurItemId = mnHighItemId = 0;
    3706                 :            : 
    3707         [ #  # ]:          0 :             Highlight();
    3708                 :            :         }
    3709                 :            :         return;
    3710                 :            :     }
    3711                 :            : 
    3712         [ #  # ]:          0 :     if ( mbDragging )
    3713                 :            :     {
    3714         [ #  # ]:          0 :         ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
    3715         [ #  # ]:          0 :         pMgr->Dragging( aMousePos );
    3716                 :            :         return;
    3717                 :            :     }
    3718                 :            : 
    3719                 :          0 :     PointerStyle eStyle = POINTER_ARROW;
    3720                 :            : 
    3721                 :            :     // change mouse cursor over drag area
    3722 [ #  # ][ #  # ]:          0 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
    3723 [ #  # ][ #  # ]:          0 :     if( pWrapper && pWrapper->GetDragArea().IsInside( rMEvt.GetPosPixel() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    3724                 :          0 :         eStyle = POINTER_MOVE;
    3725                 :            : 
    3726         [ #  # ]:          0 :     if ( (mnWinStyle & TB_WBLINESIZING) == TB_WBLINESIZING )
    3727                 :            :     {
    3728         [ #  # ]:          0 :         if ( rMEvt.GetMode() & MOUSE_SIMPLEMOVE )
    3729                 :            :         {
    3730         [ #  # ]:          0 :             sal_uInt16 nLinePtr = ImplTestLineSize( this, rMEvt.GetPosPixel() );
    3731         [ #  # ]:          0 :             if ( nLinePtr & DOCK_LINEHSIZE )
    3732                 :            :             {
    3733         [ #  # ]:          0 :                 if ( meAlign == WINDOWALIGN_LEFT )
    3734                 :          0 :                     eStyle = POINTER_WINDOW_ESIZE;
    3735                 :            :                 else
    3736                 :          0 :                     eStyle = POINTER_WINDOW_WSIZE;
    3737                 :            :             }
    3738         [ #  # ]:          0 :             else if ( nLinePtr & DOCK_LINEVSIZE )
    3739                 :            :             {
    3740         [ #  # ]:          0 :                 if ( meAlign == WINDOWALIGN_TOP )
    3741                 :          0 :                     eStyle = POINTER_WINDOW_SSIZE;
    3742                 :            :                 else
    3743                 :          0 :                     eStyle = POINTER_WINDOW_NSIZE;
    3744                 :            :             }
    3745                 :            :         }
    3746                 :            :     }
    3747                 :            : 
    3748 [ #  # ][ #  # ]:          0 :     if ( (eStyle == POINTER_ARROW) && mbCustomizeMode )
    3749                 :            :     {
    3750                 :            :         // search the item which was clicked
    3751         [ #  # ]:          0 :         std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    3752 [ #  # ][ #  # ]:          0 :         while ( it != mpData->m_aItems.end() )
    3753                 :            :         {
    3754                 :            :             // show resize pointer if it is a customize window
    3755         [ #  # ]:          0 :             if ( it->mbShowWindow )
    3756                 :            :             {
    3757 [ #  # ][ #  # ]:          0 :                 if ( it->maRect.IsInside( aMousePos ) )
    3758                 :            :                 {
    3759         [ #  # ]:          0 :                     if ( it->maRect.Right()-TB_RESIZE_OFFSET <= aMousePos.X() )
    3760                 :          0 :                         eStyle = POINTER_HSIZEBAR;
    3761                 :          0 :                     break;
    3762                 :            :                 }
    3763                 :            :             }
    3764                 :            : 
    3765                 :          0 :             ++it;
    3766                 :            :         }
    3767                 :            :     }
    3768                 :            : 
    3769 [ #  # ][ #  # ]:          0 :     if ( bDrawHotSpot && ( (mnOutStyle & TOOLBOX_STYLE_FLAT) || !mnOutStyle ) )
                 [ #  # ]
    3770                 :            :     {
    3771                 :          0 :         sal_Bool bClearHigh = sal_True;
    3772 [ #  # ][ #  # ]:          0 :         if ( !rMEvt.IsLeaveWindow() && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
                 [ #  # ]
    3773                 :            :         {
    3774         [ #  # ]:          0 :             std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    3775 [ #  # ][ #  # ]:          0 :             while ( it != mpData->m_aItems.end() )
    3776                 :            :             {
    3777 [ #  # ][ #  # ]:          0 :                 if ( it->maRect.IsInside( aMousePos ) )
    3778                 :            :                 {
    3779 [ #  # ][ #  # ]:          0 :                     if ( (it->meType == TOOLBOXITEM_BUTTON) && it->mbEnabled )
                 [ #  # ]
    3780                 :            :                     {
    3781 [ #  # ][ #  # ]:          0 :                         if ( !mnOutStyle || (mnOutStyle & TOOLBOX_STYLE_FLAT) )
    3782                 :            :                         {
    3783                 :          0 :                             bClearHigh = sal_False;
    3784         [ #  # ]:          0 :                             if ( mnHighItemId != it->mnId )
    3785                 :            :                             {
    3786         [ #  # ]:          0 :                                 sal_uInt16 nTempPos = sal::static_int_cast<sal_uInt16>(it - mpData->m_aItems.begin());
    3787         [ #  # ]:          0 :                                 if ( mnHighItemId )
    3788                 :            :                                 {
    3789         [ #  # ]:          0 :                                     ImplHideFocus();
    3790         [ #  # ]:          0 :                                     sal_uInt16 nPos = GetItemPos( mnHighItemId );
    3791         [ #  # ]:          0 :                                     ImplDrawItem( nPos );
    3792         [ #  # ]:          0 :                                     ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( nPos ) );
    3793                 :            :                                 }
    3794         [ #  # ]:          0 :                                 if ( mpData->mbMenubuttonSelected )
    3795                 :            :                                 {
    3796                 :            :                                     // remove highlight from menubutton
    3797         [ #  # ]:          0 :                                     ImplDrawMenubutton( this, sal_False );
    3798                 :            :                                 }
    3799                 :          0 :                                 mnHighItemId = it->mnId;
    3800         [ #  # ]:          0 :                                 ImplDrawItem( nTempPos, 2 );
    3801         [ #  # ]:          0 :                                 ImplShowFocus();
    3802         [ #  # ]:          0 :                                 ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHT );
    3803                 :            :                             }
    3804                 :            :                         }
    3805                 :            :                     }
    3806                 :          0 :                     break;
    3807                 :            :                 }
    3808                 :            : 
    3809                 :          0 :                 ++it;
    3810                 :            :             }
    3811                 :            :         }
    3812                 :            : 
    3813                 :            :         // only clear highlight when focus is not in toolbar
    3814 [ #  # ][ #  # ]:          0 :         sal_Bool bMenuButtonHit = mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) && ImplHasClippedItems();
         [ #  # ][ #  # ]
    3815 [ #  # ][ #  # ]:          0 :         if ( bClearHigh || bMenuButtonHit )
    3816                 :            :         {
    3817 [ #  # ][ #  # ]:          0 :             if ( !bMenuButtonHit && mpData->mbMenubuttonSelected )
    3818                 :            :             {
    3819                 :            :                 // remove highlight from menubutton
    3820         [ #  # ]:          0 :                 ImplDrawMenubutton( this, sal_False );
    3821                 :            :             }
    3822                 :            : 
    3823         [ #  # ]:          0 :             if( mnHighItemId )
    3824                 :            :             {
    3825         [ #  # ]:          0 :                 sal_uInt16 nClearPos = GetItemPos( mnHighItemId );
    3826         [ #  # ]:          0 :                 if ( nClearPos != TOOLBOX_ITEM_NOTFOUND )
    3827                 :            :                 {
    3828 [ #  # ][ #  # ]:          0 :                     ImplDrawItem( nClearPos, (nClearPos == mnCurPos) ? 1 : 0 );
    3829         [ #  # ]:          0 :                     if( nClearPos != mnCurPos )
    3830         [ #  # ]:          0 :                         ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( nClearPos ) );
    3831                 :            :                 }
    3832         [ #  # ]:          0 :                 ImplHideFocus();
    3833                 :          0 :                 mnHighItemId = 0;
    3834                 :            :             }
    3835                 :            : 
    3836         [ #  # ]:          0 :             if( bMenuButtonHit )
    3837                 :            :             {
    3838         [ #  # ]:          0 :                 ImplDrawMenubutton( this, sal_True );
    3839                 :            :             }
    3840                 :            :         }
    3841                 :            :     }
    3842                 :            : 
    3843         [ #  # ]:          0 :     if ( meLastStyle != eStyle )
    3844                 :            :     {
    3845                 :          0 :         meLastStyle = eStyle;
    3846                 :          0 :         Pointer aPtr( eStyle );
    3847         [ #  # ]:          0 :         SetPointer( aPtr );
    3848                 :            :     }
    3849                 :            : 
    3850         [ #  # ]:          0 :     DockingWindow::MouseMove( rMEvt );
    3851                 :            : }
    3852                 :            : 
    3853                 :            : // -----------------------------------------------------------------------
    3854                 :            : 
    3855                 :          0 : void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
    3856                 :            : {
    3857                 :            :     // only trigger toolbox for left mouse button and when
    3858                 :            :     // we're not in normal operation
    3859 [ #  # ][ #  # ]:          0 :     if ( rMEvt.IsLeft() && !mbDrag && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
         [ #  # ][ #  # ]
    3860                 :            :     {
    3861                 :            :         // call activate already here, as items could
    3862                 :            :         // be exchanged
    3863         [ #  # ]:          0 :         Activate();
    3864                 :            : 
    3865                 :            :         // update ToolBox here, such that user knows it
    3866         [ #  # ]:          0 :         if ( mbFormat )
    3867                 :            :         {
    3868         [ #  # ]:          0 :             ImplFormat();
    3869         [ #  # ]:          0 :             Update();
    3870                 :            :         }
    3871                 :            : 
    3872                 :          0 :         Point  aMousePos = rMEvt.GetPosPixel();
    3873                 :          0 :         sal_uInt16 i = 0;
    3874                 :          0 :         sal_uInt16 nNewPos = TOOLBOX_ITEM_NOTFOUND;
    3875                 :            : 
    3876                 :            :         // search for item that was clicked
    3877         [ #  # ]:          0 :         std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    3878 [ #  # ][ #  # ]:          0 :         while ( it != mpData->m_aItems.end() )
    3879                 :            :         {
    3880                 :            :             // is this the item?
    3881 [ #  # ][ #  # ]:          0 :             if ( it->maRect.IsInside( aMousePos ) )
    3882                 :            :             {
    3883                 :            :                 // do nothing if it is a separator or
    3884                 :            :                 // if the item has been disabled
    3885   [ #  #  #  # ]:          0 :                 if ( (it->meType == TOOLBOXITEM_BUTTON) &&
         [ #  # ][ #  # ]
    3886                 :          0 :                      (!it->mbShowWindow || mbCustomizeMode) )
    3887                 :          0 :                     nNewPos = i;
    3888                 :            : 
    3889                 :          0 :                 break;
    3890                 :            :             }
    3891                 :            : 
    3892                 :          0 :             i++;
    3893                 :          0 :             ++it;
    3894                 :            :         }
    3895                 :            : 
    3896                 :            :         // item found
    3897         [ #  # ]:          0 :         if ( nNewPos != TOOLBOX_ITEM_NOTFOUND )
    3898                 :            :         {
    3899         [ #  # ]:          0 :             if ( mbCustomize )
    3900                 :            :             {
    3901 [ #  # ][ #  # ]:          0 :                 if ( rMEvt.IsMod2() || mbCustomizeMode )
                 [ #  # ]
    3902                 :            :                 {
    3903         [ #  # ]:          0 :                     Deactivate();
    3904                 :            : 
    3905         [ #  # ]:          0 :                     ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
    3906         [ #  # ]:          0 :                     Rectangle aItemRect = GetItemRect( it->mnId );
    3907                 :          0 :                     mnConfigItem = it->mnId;
    3908                 :            : 
    3909                 :            :                     sal_Bool bResizeItem;
    3910   [ #  #  #  # ]:          0 :                     if ( mbCustomizeMode && it->mbShowWindow &&
         [ #  # ][ #  # ]
    3911                 :          0 :                          (it->maRect.Right()-TB_RESIZE_OFFSET <= aMousePos.X()) )
    3912                 :          0 :                         bResizeItem = sal_True;
    3913                 :            :                     else
    3914                 :          0 :                         bResizeItem = sal_False;
    3915         [ #  # ]:          0 :                     pMgr->StartDragging( this, aMousePos, aItemRect, 0, bResizeItem );
    3916                 :            :                     return;
    3917                 :            :                 }
    3918                 :            :             }
    3919                 :            : 
    3920         [ #  # ]:          0 :             if ( !it->mbEnabled )
    3921                 :            :             {
    3922         [ #  # ]:          0 :                 Deactivate();
    3923                 :            :                 return;
    3924                 :            :             }
    3925                 :            : 
    3926                 :            : 
    3927                 :            :             // update actual data
    3928                 :          0 :             sal_uInt16 nTrackFlags = 0;
    3929                 :          0 :             mnCurPos         = i;
    3930                 :          0 :             mnCurItemId      = it->mnId;
    3931                 :          0 :             mnDownItemId     = mnCurItemId;
    3932                 :          0 :             mnMouseClicks    = rMEvt.GetClicks();
    3933                 :          0 :             mnMouseModifier  = rMEvt.GetModifier();
    3934         [ #  # ]:          0 :             if ( it->mnBits & TIB_REPEAT )
    3935                 :          0 :                 nTrackFlags |= STARTTRACK_BUTTONREPEAT;
    3936                 :            : 
    3937                 :            : 
    3938         [ #  # ]:          0 :             if ( mbSelection )
    3939                 :            :             {
    3940         [ #  # ]:          0 :                 ImplDrawItem( mnCurPos, 1 );
    3941         [ #  # ]:          0 :                 Highlight();
    3942                 :            :             }
    3943                 :            :             else
    3944                 :            :             {
    3945                 :            :                 // update bDrag here, as it is evaluated in the EndSelection
    3946                 :          0 :                 mbDrag = sal_True;
    3947                 :            : 
    3948                 :            :                 // on double-click: only call the handler, but do so before the button
    3949                 :            :                 // is hit, as in the handler dragging
    3950                 :            :                 // can be terminated
    3951         [ #  # ]:          0 :                 if ( rMEvt.GetClicks() == 2 )
    3952         [ #  # ]:          0 :                     DoubleClick();
    3953                 :            : 
    3954                 :            : 
    3955         [ #  # ]:          0 :                 if ( mbDrag )
    3956                 :            :                 {
    3957         [ #  # ]:          0 :                     ImplDrawItem( mnCurPos, 1 );
    3958         [ #  # ]:          0 :                     Highlight();
    3959                 :            :                 }
    3960                 :            : 
    3961                 :            :                 // was dropdown arrow pressed
    3962         [ #  # ]:          0 :                 if( (it->mnBits & TIB_DROPDOWN) )
    3963                 :            :                 {
    3964 [ #  # ][ #  # ]:          0 :                     if( ( (it->mnBits & TIB_DROPDOWNONLY) == TIB_DROPDOWNONLY) || it->GetDropDownRect( mbHorz ).IsInside( aMousePos ))
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    3965                 :            :                     {
    3966                 :            :                         // dropdownonly always triggers the dropdown handler, over the whole button area
    3967                 :            : 
    3968                 :            :                         // the drop down arrow should not trigger the item action
    3969                 :          0 :                         mpData->mbDropDownByKeyboard = sal_False;
    3970 [ #  # ][ #  # ]:          0 :                         GetDropdownClickHdl().Call( this );
    3971                 :            : 
    3972                 :            :                         // do not reset data if the dropdown handler opened a floating window
    3973                 :            :                         // see ImplFloatControl()
    3974         [ #  # ]:          0 :                         if( mpFloatWin == NULL )
    3975                 :            :                         {
    3976                 :            :                             // no floater was opened
    3977         [ #  # ]:          0 :                             Deactivate();
    3978         [ #  # ]:          0 :                             ImplDrawItem( mnCurPos, 0 );
    3979                 :            : 
    3980                 :          0 :                             mnCurPos         = TOOLBOX_ITEM_NOTFOUND;
    3981                 :          0 :                             mnCurItemId      = 0;
    3982                 :          0 :                             mnDownItemId     = 0;
    3983                 :          0 :                             mnMouseClicks    = 0;
    3984                 :          0 :                             mnMouseModifier  = 0;
    3985                 :          0 :                             mnHighItemId     = 0;
    3986                 :            :                         }
    3987                 :            :                         return;
    3988                 :            :                     }
    3989                 :            :                     else // activate long click timer
    3990         [ #  # ]:          0 :                         mpData->maDropdownTimer.Start();
    3991                 :            :                 }
    3992                 :            : 
    3993                 :            : 
    3994                 :            :                 // call Click handler
    3995         [ #  # ]:          0 :                 if ( rMEvt.GetClicks() != 2 )
    3996         [ #  # ]:          0 :                     Click();
    3997                 :            : 
    3998                 :            :                 // also call Select handler at repeat
    3999         [ #  # ]:          0 :                 if ( nTrackFlags & STARTTRACK_BUTTONREPEAT )
    4000         [ #  # ]:          0 :                     Select();
    4001                 :            : 
    4002                 :            :                 // if the actions was not aborted in Click handler
    4003         [ #  # ]:          0 :                 if ( mbDrag )
    4004         [ #  # ]:          0 :                     StartTracking( nTrackFlags );
    4005                 :            :             }
    4006                 :            : 
    4007                 :            :             // if mouse was clicked over an item we
    4008                 :            :             // can abort here
    4009                 :            :             return;
    4010                 :            :         }
    4011                 :            : 
    4012         [ #  # ]:          0 :         Deactivate();
    4013                 :            : 
    4014                 :            :         // menu button hit ?
    4015 [ #  # ][ #  # ]:          0 :         if( mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) && ImplHasClippedItems() )
         [ #  # ][ #  # ]
                 [ #  # ]
    4016                 :            :         {
    4017         [ #  # ]:          0 :             ExecuteCustomMenu();
    4018                 :            :             return;
    4019                 :            :         }
    4020                 :            : 
    4021                 :            :         // check scroll- and next-buttons here
    4022 [ #  # ][ #  # ]:          0 :         if ( maUpperRect.IsInside( aMousePos ) )
    4023                 :            :         {
    4024         [ #  # ]:          0 :             if ( mnCurLine > 1 )
    4025                 :            :             {
    4026         [ #  # ]:          0 :                 StartTracking();
    4027                 :          0 :                 mbUpper = sal_True;
    4028                 :          0 :                 mbIn    = sal_True;
    4029         [ #  # ]:          0 :                 ImplDrawSpin( sal_True, sal_False );
    4030                 :            :             }
    4031                 :            :             return;
    4032                 :            :         }
    4033 [ #  # ][ #  # ]:          0 :         if ( maLowerRect.IsInside( aMousePos ) )
    4034                 :            :         {
    4035         [ #  # ]:          0 :             if ( mnCurLine+mnVisLines-1 < mnCurLines )
    4036                 :            :             {
    4037         [ #  # ]:          0 :                 StartTracking();
    4038                 :          0 :                 mbLower = sal_True;
    4039                 :          0 :                 mbIn    = sal_True;
    4040         [ #  # ]:          0 :                 ImplDrawSpin( sal_False, sal_True );
    4041                 :            :             }
    4042                 :            :             return;
    4043                 :            :         }
    4044                 :            : 
    4045                 :            :         // Linesizing testen
    4046         [ #  # ]:          0 :         if ( (mnWinStyle & TB_WBLINESIZING) == TB_WBLINESIZING )
    4047                 :            :         {
    4048         [ #  # ]:          0 :             sal_uInt16 nLineMode = ImplTestLineSize( this, aMousePos );
    4049         [ #  # ]:          0 :             if ( nLineMode )
    4050                 :            :             {
    4051         [ #  # ]:          0 :                 ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
    4052                 :            : 
    4053                 :            :                 // call handler, such that we can set the
    4054                 :            :                 // dock rectangles
    4055         [ #  # ]:          0 :                 StartDocking();
    4056                 :            : 
    4057 [ #  # ][ #  # ]:          0 :                 Point aPos  = GetParent()->OutputToScreenPixel( GetPosPixel() );
                 [ #  # ]
    4058         [ #  # ]:          0 :                 Size  aSize = GetSizePixel();
    4059         [ #  # ]:          0 :                 aPos = ScreenToOutputPixel( aPos );
    4060                 :            : 
    4061                 :            :                 // start dragging
    4062                 :            :                 pMgr->StartDragging( this, aMousePos, Rectangle( aPos, aSize ),
    4063 [ #  # ][ #  # ]:          0 :                                      nLineMode, sal_False );
    4064                 :            :                 return;
    4065                 :            :             }
    4066                 :            :         }
    4067                 :            : 
    4068                 :            :         // no item, then only click or double click
    4069         [ #  # ]:          0 :         if ( rMEvt.GetClicks() == 2 )
    4070         [ #  # ]:          0 :             DoubleClick();
    4071                 :            :         else
    4072         [ #  # ]:          0 :             Click();
    4073                 :            :     }
    4074                 :            : 
    4075 [ #  # ][ #  # ]:          0 :     if ( !mbDrag && !mbSelection && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
                 [ #  # ]
    4076                 :          0 :         DockingWindow::MouseButtonDown( rMEvt );
    4077                 :            : }
    4078                 :            : 
    4079                 :            : // -----------------------------------------------------------------------
    4080                 :            : 
    4081                 :          0 : void ToolBox::MouseButtonUp( const MouseEvent& rMEvt )
    4082                 :            : {
    4083         [ #  # ]:          0 :     if ( ImplHandleMouseButtonUp( rMEvt ) )
    4084                 :          0 :         return;
    4085                 :            : 
    4086 [ #  # ][ #  # ]:          0 :     if ( mbDragging && (rMEvt.IsLeft() || mbCommandDrag) )
         [ #  # ][ #  # ]
    4087                 :            :     {
    4088                 :          0 :         ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
    4089                 :          0 :         pMgr->EndDragging();
    4090                 :          0 :         return;
    4091                 :            :     }
    4092                 :          0 :     mbCommandDrag = sal_False;
    4093                 :            : 
    4094                 :          0 :     DockingWindow::MouseButtonUp( rMEvt );
    4095                 :            : }
    4096                 :            : 
    4097                 :            : // -----------------------------------------------------------------------
    4098                 :            : 
    4099                 :          0 : void ToolBox::Tracking( const TrackingEvent& rTEvt )
    4100                 :            : {
    4101         [ #  # ]:          0 :     ImplDelData aDelData;
    4102         [ #  # ]:          0 :     ImplAddDel( &aDelData );
    4103                 :            : 
    4104         [ #  # ]:          0 :     if ( rTEvt.IsTrackingEnded() )
    4105         [ #  # ]:          0 :         ImplHandleMouseButtonUp( rTEvt.GetMouseEvent(), rTEvt.IsTrackingCanceled() );
    4106                 :            :     else
    4107         [ #  # ]:          0 :         ImplHandleMouseMove( rTEvt.GetMouseEvent(), rTEvt.IsTrackingRepeat() );
    4108                 :            : 
    4109         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    4110                 :            :         // toolbox was deleted
    4111                 :          0 :         return;
    4112         [ #  # ]:          0 :     ImplRemoveDel( &aDelData );
    4113 [ #  # ][ #  # ]:          0 :     DockingWindow::Tracking( rTEvt );
                 [ #  # ]
    4114                 :            : }
    4115                 :            : 
    4116                 :            : // -----------------------------------------------------------------------
    4117                 :            : 
    4118                 :      10776 : void ToolBox::Paint( const Rectangle& rPaintRect )
    4119                 :            : {
    4120         [ -  + ]:      10776 :     if( mpData->mbIsPaintLocked )
    4121                 :      10776 :         return;
    4122 [ +  - ][ +  + ]:      10776 :     if ( rPaintRect == Rectangle( 0, 0, mnDX-1, mnDY-1 ) )
    4123                 :       7219 :         mbFullPaint = sal_True;
    4124                 :      10776 :     ImplFormat();
    4125                 :      10776 :     mbFullPaint = sal_False;
    4126                 :            : 
    4127                 :            : 
    4128                 :      10776 :     ImplDrawBackground( this, rPaintRect );
    4129                 :            : 
    4130 [ +  - ][ +  + ]:      10776 :     if ( (mnWinStyle & WB_BORDER) && !ImplIsFloatingMode() )
                 [ +  + ]
    4131                 :       8123 :         ImplDrawBorder( this );
    4132                 :            : 
    4133         [ +  - ]:      10776 :     if( !ImplIsFloatingMode() )
    4134                 :      10776 :         ImplDrawGrip( this );
    4135                 :            : 
    4136                 :      10776 :     ImplDrawMenubutton( this, mpData->mbMenubuttonSelected );
    4137                 :            : 
    4138                 :            :     // draw SpinButtons
    4139         [ +  + ]:      10776 :     if ( mnWinStyle & WB_SCROLL )
    4140                 :            :     {
    4141         [ -  + ]:       8123 :         if ( mnCurLines > mnLines )
    4142                 :          0 :             ImplDrawSpin( sal_False, sal_False );
    4143                 :            :     }
    4144                 :            : 
    4145                 :            :     // draw buttons
    4146                 :            :     sal_uInt16 nHighPos;
    4147         [ -  + ]:      10776 :     if ( mnHighItemId )
    4148                 :          0 :         nHighPos = GetItemPos( mnHighItemId );
    4149                 :            :     else
    4150                 :      10776 :         nHighPos = TOOLBOX_ITEM_NOTFOUND;
    4151                 :            : 
    4152                 :      10776 :     sal_uInt16 nCount = (sal_uInt16)mpData->m_aItems.size();
    4153         [ +  + ]:     277425 :     for( sal_uInt16 i = 0; i < nCount; i++ )
    4154                 :            :     {
    4155                 :     266649 :         ImplToolItem* pItem = &mpData->m_aItems[i];
    4156                 :            : 
    4157                 :            :         // only draw when the rectangle is in the draw rectangle
    4158 [ +  + ][ +  + ]:     266649 :         if ( !pItem->maRect.IsEmpty() && rPaintRect.IsOver( pItem->maRect ) )
                 [ +  + ]
    4159                 :            :         {
    4160                 :     141045 :             sal_uInt16 nHighlight = 0;
    4161         [ -  + ]:     141045 :             if ( i == mnCurPos )
    4162                 :          0 :                 nHighlight = 1;
    4163         [ -  + ]:     141045 :             else if ( i == nHighPos )
    4164                 :          0 :                 nHighlight = 2;
    4165                 :     141045 :             ImplDrawItem( i, nHighlight );
    4166                 :            :         }
    4167                 :            :     }
    4168                 :      10776 :     ImplShowFocus();
    4169                 :            : }
    4170                 :            : 
    4171                 :            : // -----------------------------------------------------------------------
    4172                 :            : 
    4173                 :       8849 : void ToolBox::Move()
    4174                 :            : {
    4175                 :       8849 :     DockingWindow::Move();
    4176                 :       8849 : }
    4177                 :            : 
    4178                 :            : // -----------------------------------------------------------------------
    4179                 :            : 
    4180                 :       9993 : void ToolBox::Resize()
    4181                 :            : {
    4182         [ +  - ]:       9993 :     Size aSize = GetOutputSizePixel();
    4183                 :            :     // #i31422# some WindowManagers send (0,0) sizes when
    4184                 :            :     // switching virtual desktops - ignore this and avoid reformatting
    4185 [ +  + ][ +  + ]:       9993 :     if( !aSize.Width() && !aSize.Height() )
                 [ +  + ]
    4186                 :       9993 :         return;
    4187                 :            : 
    4188                 :       8075 :     long nOldDX = mnDX;
    4189                 :       8075 :     long nOldDY = mnDY;
    4190                 :       8075 :     mnDX = aSize.Width();
    4191                 :       8075 :     mnDY = aSize.Height();
    4192                 :            : 
    4193                 :       8075 :     mnLastResizeDY = 0;
    4194                 :            : 
    4195                 :            :     // invalidate everything to have gradient backgrounds properly drawn
    4196         [ +  - ]:       8075 :     Invalidate();
    4197                 :            : 
    4198                 :            :     // re-format or re-draw
    4199         [ +  + ]:       8075 :     if ( mbScroll )
    4200                 :            :     {
    4201         [ +  + ]:       4219 :         if ( !mbFormat )
    4202                 :            :         {
    4203                 :         35 :             mbFormat = sal_True;
    4204 [ +  - ][ +  - ]:         35 :             if( IsReallyVisible() )
    4205         [ +  - ]:         35 :                 ImplFormat( sal_True );
    4206                 :            :         }
    4207                 :            :     }
    4208                 :            : 
    4209                 :            :     // redraw border
    4210         [ +  + ]:       8075 :     if ( mnWinStyle & WB_BORDER )
    4211                 :            :     {
    4212                 :            :         // as otherwise, when painting we might think we have to re-draw everything
    4213 [ +  + ][ +  - ]:       4219 :         if ( mbFormat && IsReallyVisible() )
         [ +  + ][ +  + ]
    4214         [ +  - ]:        487 :             Invalidate();
    4215                 :            :         else
    4216                 :            :         {
    4217         [ -  + ]:       3732 :             if ( mnRightBorder )
    4218                 :            :             {
    4219         [ #  # ]:          0 :                 if ( nOldDX > mnDX )
    4220 [ #  # ][ #  # ]:          0 :                     Invalidate( Rectangle( mnDX-mnRightBorder-1, 0, mnDX, mnDY ) );
    4221                 :            :                 else
    4222 [ #  # ][ #  # ]:          0 :                     Invalidate( Rectangle( nOldDX-mnRightBorder-1, 0, nOldDX, nOldDY ) );
    4223                 :            :             }
    4224                 :            : 
    4225         [ -  + ]:       3732 :             if ( mnBottomBorder )
    4226                 :            :             {
    4227         [ #  # ]:          0 :                 if ( nOldDY > mnDY )
    4228 [ #  # ][ #  # ]:          0 :                     Invalidate( Rectangle( 0, mnDY-mnBottomBorder-1, mnDX, mnDY ) );
    4229                 :            :                 else
    4230 [ #  # ][ #  # ]:       9993 :                     Invalidate( Rectangle( 0, nOldDY-mnBottomBorder-1, nOldDX, nOldDY ) );
    4231                 :            :             }
    4232                 :            :         }
    4233                 :            :     }
    4234                 :            : }
    4235                 :            : 
    4236                 :            : // -----------------------------------------------------------------------
    4237                 :         12 : const XubString& ToolBox::ImplGetHelpText( sal_uInt16 nItemId ) const
    4238                 :            : {
    4239                 :         12 :     ImplToolItem* pItem = ImplGetItem( nItemId );
    4240                 :            : 
    4241         [ +  - ]:         12 :     if ( pItem )
    4242                 :            :     {
    4243 [ +  + ][ +  - ]:         12 :         if ( !pItem->maHelpText.Len() && ( !pItem->maHelpId.isEmpty() || pItem->maCommandStr.Len() ))
         [ +  - ][ +  + ]
    4244                 :            :         {
    4245                 :          2 :             Help* pHelp = Application::GetHelp();
    4246         [ +  - ]:          2 :             if ( pHelp )
    4247                 :            :             {
    4248         [ +  - ]:          2 :                 if ( pItem->maCommandStr.Len() )
    4249         [ +  - ]:          2 :                     pItem->maHelpText = pHelp->GetHelpText( pItem->maCommandStr, this );
    4250 [ -  + ][ #  # ]:          2 :                 if ( !pItem->maHelpText.Len() && !pItem->maHelpId.isEmpty() )
                 [ -  + ]
    4251 [ #  # ][ #  # ]:          0 :                     pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this );
         [ #  # ][ #  # ]
                 [ #  # ]
    4252                 :            :             }
    4253                 :            :         }
    4254                 :            : 
    4255                 :         12 :         return pItem->maHelpText;
    4256                 :            :     }
    4257                 :            :     else
    4258                 :         12 :         return ImplGetSVEmptyStr();
    4259                 :            : }
    4260                 :            : 
    4261                 :            : // -----------------------------------------------------------------------
    4262                 :            : 
    4263                 :          0 : void ToolBox::RequestHelp( const HelpEvent& rHEvt )
    4264                 :            : {
    4265                 :            :     sal_uInt16 nItemId;
    4266                 :          0 :     Point aHelpPos;
    4267                 :            : 
    4268         [ #  # ]:          0 :     if( !rHEvt.KeyboardActivated() )
    4269                 :            :     {
    4270 [ #  # ][ #  # ]:          0 :         nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
                 [ #  # ]
    4271         [ #  # ]:          0 :         aHelpPos = rHEvt.GetMousePosPixel();
    4272                 :            :     }
    4273                 :            :     else
    4274                 :            :     {
    4275         [ #  # ]:          0 :         if( !mnHighItemId )
    4276                 :            :             return;
    4277                 :            :         else
    4278                 :          0 :             nItemId = mnHighItemId;
    4279         [ #  # ]:          0 :         Rectangle aRect( GetItemRect( nItemId ) );
    4280 [ #  # ][ #  # ]:          0 :         if( aRect.IsEmpty() )
    4281                 :            :             return;
    4282                 :            :         else
    4283 [ #  # ][ #  # ]:          0 :             aHelpPos = OutputToScreenPixel( aRect.Center() );
    4284                 :            :     }
    4285                 :            : 
    4286         [ #  # ]:          0 :     if ( nItemId )
    4287                 :            :     {
    4288         [ #  # ]:          0 :         if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) )
    4289                 :            :         {
    4290                 :            :             // get rectangle
    4291         [ #  # ]:          0 :             Rectangle aTempRect = GetItemRect( nItemId );
    4292         [ #  # ]:          0 :             Point aPt = OutputToScreenPixel( aTempRect.TopLeft() );
    4293                 :          0 :             aTempRect.Left()   = aPt.X();
    4294                 :          0 :             aTempRect.Top()    = aPt.Y();
    4295 [ #  # ][ #  # ]:          0 :             aPt = OutputToScreenPixel( aTempRect.BottomRight() );
    4296                 :          0 :             aTempRect.Right()  = aPt.X();
    4297                 :          0 :             aTempRect.Bottom() = aPt.Y();
    4298                 :            : 
    4299                 :            :             // get text and display it
    4300 [ #  # ][ #  # ]:          0 :             XubString aStr = GetQuickHelpText( nItemId );
    4301         [ #  # ]:          0 :             const XubString& rHelpStr = GetHelpText( nItemId );
    4302         [ #  # ]:          0 :             if ( !aStr.Len() )
    4303 [ #  # ][ #  # ]:          0 :                 aStr = MnemonicGenerator::EraseAllMnemonicChars( GetItemText( nItemId ) );
         [ #  # ][ #  # ]
    4304         [ #  # ]:          0 :             if ( rHEvt.GetMode() & HELPMODE_BALLOON )
    4305                 :            :             {
    4306         [ #  # ]:          0 :                 if ( rHelpStr.Len() )
    4307         [ #  # ]:          0 :                     aStr = rHelpStr;
    4308         [ #  # ]:          0 :                 Help::ShowBalloon( this, aHelpPos, aTempRect, aStr );
    4309                 :            :             }
    4310                 :            :             else
    4311         [ #  # ]:          0 :                 Help::ShowQuickHelp( this, aTempRect, aStr, rHelpStr, QUICKHELP_CTRLTEXT );
    4312         [ #  # ]:          0 :             return;
    4313                 :            :         }
    4314         [ #  # ]:          0 :         else if ( rHEvt.GetMode() & HELPMODE_EXTENDED )
    4315                 :            :         {
    4316 [ #  # ][ #  # ]:          0 :             String aCommand = GetItemCommand( nItemId );
    4317         [ #  # ]:          0 :             rtl::OString  aHelpId( GetHelpId( nItemId ) );
    4318                 :            : 
    4319 [ #  # ][ #  # ]:          0 :             if ( aCommand.Len() || !aHelpId.isEmpty() )
                 [ #  # ]
    4320                 :            :             {
    4321                 :            :                 // If help is available then trigger it
    4322         [ #  # ]:          0 :                 Help* pHelp = Application::GetHelp();
    4323         [ #  # ]:          0 :                 if ( pHelp )
    4324                 :            :                 {
    4325         [ #  # ]:          0 :                     if ( aCommand.Len() )
    4326         [ #  # ]:          0 :                         pHelp->Start( aCommand, this );
    4327         [ #  # ]:          0 :                     else if ( !aHelpId.isEmpty() )
    4328 [ #  # ][ #  # ]:          0 :                         pHelp->Start( rtl::OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), this );
         [ #  # ][ #  # ]
    4329                 :            :                 }
    4330                 :            :                 return;
    4331 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
    4332                 :            :         }
    4333                 :            :     }
    4334                 :            : 
    4335         [ #  # ]:          0 :     DockingWindow::RequestHelp( rHEvt );
    4336                 :            : }
    4337                 :            : 
    4338                 :            : // -----------------------------------------------------------------------
    4339                 :            : 
    4340                 :      17003 : long ToolBox::Notify( NotifyEvent& rNEvt )
    4341                 :            : {
    4342         [ -  + ]:      17003 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
    4343                 :            :     {
    4344 [ #  # ][ #  # ]:          0 :         KeyEvent aKEvt = *rNEvt.GetKeyEvent();
    4345                 :          0 :         KeyCode aKeyCode = aKEvt.GetKeyCode();
    4346                 :          0 :         sal_uInt16  nKeyCode = aKeyCode.GetCode();
    4347         [ #  # ]:          0 :         switch( nKeyCode )
    4348                 :            :         {
    4349                 :            :             case KEY_TAB:
    4350                 :            :                 {
    4351                 :            :                 // internal TAB cycling only if parent is not a dialog or if we are the ony child
    4352                 :            :                 // otherwise the dialog control will take over
    4353 [ #  # ][ #  # ]:          0 :                 sal_Bool bNoTabCycling = ( ( ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL) ) == WB_DIALOGCONTROL &&
    4354 [ #  # ][ #  # ]:          0 :                     ImplGetParent()->GetChildCount() != 1 );
         [ #  # ][ #  # ]
    4355                 :            : 
    4356 [ #  # ][ #  # ]:          0 :                 if( bNoTabCycling &&  ! (GetStyle() & WB_FORCETABCYCLE) )
                 [ #  # ]
    4357         [ #  # ]:          0 :                     return DockingWindow::Notify( rNEvt );
    4358 [ #  # ][ #  # ]:          0 :                 else if( ImplChangeHighlightUpDn( aKeyCode.IsShift() ? sal_True : sal_False , bNoTabCycling ) )
                 [ #  # ]
    4359                 :          0 :                     return sal_False;
    4360                 :            :                 else
    4361         [ #  # ]:          0 :                     return DockingWindow::Notify( rNEvt );
    4362                 :            :                 }
    4363                 :            :             default:
    4364                 :          0 :                 break;
    4365                 :            :         };
    4366                 :            :     }
    4367         [ +  + ]:      17003 :     else if( rNEvt.GetType() == EVENT_GETFOCUS )
    4368                 :            :     {
    4369         [ +  + ]:          6 :         if( rNEvt.GetWindow() == this )
    4370                 :            :         {
    4371                 :            :             // the toolbar itself got the focus
    4372         [ -  + ]:          2 :             if( mnLastFocusItemId != 0 )
    4373                 :            :             {
    4374                 :            :                 // restore last item
    4375                 :          0 :                 ImplChangeHighlight( ImplGetItem( mnLastFocusItemId ) );
    4376                 :          0 :                 mnLastFocusItemId = 0;
    4377                 :            :             }
    4378         [ -  + ]:          2 :             else if( (GetGetFocusFlags() & (GETFOCUS_BACKWARD|GETFOCUS_TAB) ) == (GETFOCUS_BACKWARD|GETFOCUS_TAB))
    4379                 :            :                 // Shift-TAB was pressed in the parent
    4380                 :          0 :                 ImplChangeHighlightUpDn( sal_False );
    4381                 :            :             else
    4382                 :          2 :                 ImplChangeHighlightUpDn( sal_True );
    4383                 :            : 
    4384                 :          2 :             mnLastFocusItemId = 0;
    4385                 :            : 
    4386                 :          2 :             return true;
    4387                 :            :         }
    4388                 :            :         else
    4389                 :            :         {
    4390                 :            :             // a child window got the focus so update current item to
    4391                 :            :             // allow for proper lose focus handling in keyboard navigation
    4392         [ +  - ]:          4 :             std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    4393 [ +  - ][ +  + ]:         88 :             while( it != mpData->m_aItems.end() )
    4394                 :            :             {
    4395         [ +  + ]:         86 :                 if ( it->mbVisible )
    4396                 :            :                 {
    4397 [ +  + ][ +  - ]:         56 :                     if ( it->mpWindow && it->mpWindow->ImplIsWindowOrChild( rNEvt.GetWindow() ) )
         [ +  + ][ +  + ]
    4398                 :            :                     {
    4399                 :          2 :                         mnHighItemId = it->mnId;
    4400                 :          2 :                         break;
    4401                 :            :                     }
    4402                 :            :                 }
    4403                 :            : 
    4404                 :         84 :                 ++it;
    4405                 :            :             }
    4406         [ +  - ]:          4 :             return DockingWindow::Notify( rNEvt );
    4407                 :            :         }
    4408                 :            :     }
    4409         [ +  + ]:      16997 :     else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
    4410                 :            :     {
    4411                 :            :         // deselect
    4412                 :          4 :         ImplHideFocus();
    4413                 :          4 :         mnHighItemId = 0;
    4414                 :          4 :         mnCurPos = TOOLBOX_ITEM_NOTFOUND;
    4415                 :            :     }
    4416                 :            : 
    4417                 :      17003 :     return DockingWindow::Notify( rNEvt );
    4418                 :            : }
    4419                 :            : 
    4420                 :            : // -----------------------------------------------------------------------
    4421                 :            : 
    4422                 :          0 : void ToolBox::Command( const CommandEvent& rCEvt )
    4423                 :            : {
    4424                 :            :     // depict StartDrag on MouseButton/Left/Alt
    4425 [ #  # ][ #  # ]:          0 :     if ( (rCEvt.GetCommand() == COMMAND_STARTDRAG) && rCEvt.IsMouseEvent() &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4426                 :          0 :          mbCustomize && !mbDragging && !mbDrag && !mbSelection &&
    4427                 :            :          (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
    4428                 :            :     {
    4429                 :            :         // We only allow dragging of items. Therefore, we have to check
    4430                 :            :         // if an item was clicked, otherwise we could move the window, and
    4431                 :            :         // this is unwanted.
    4432                 :            :         // We only do this in customize mode, as otherwise
    4433                 :            :         // items could be moved accidentally
    4434         [ #  # ]:          0 :         if ( mbCustomizeMode )
    4435                 :            :         {
    4436                 :          0 :             Point           aMousePos = rCEvt.GetMousePosPixel();
    4437         [ #  # ]:          0 :             std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    4438 [ #  # ][ #  # ]:          0 :             while ( it != mpData->m_aItems.end() )
    4439                 :            :             {
    4440                 :            :                 // is this the item?
    4441 [ #  # ][ #  # ]:          0 :                 if ( it->maRect.IsInside( aMousePos ) )
    4442                 :            :                 {
    4443                 :            :                     // do nothing if it is a separator or
    4444                 :            :                     // the item has been disabled
    4445   [ #  #  #  # ]:          0 :                     if ( (it->meType == TOOLBOXITEM_BUTTON) &&
                 [ #  # ]
    4446                 :          0 :                          !it->mbShowWindow )
    4447                 :          0 :                         mbCommandDrag = sal_True;
    4448                 :          0 :                     break;
    4449                 :            :                 }
    4450                 :            : 
    4451                 :          0 :                 ++it;
    4452                 :            :             }
    4453                 :            : 
    4454         [ #  # ]:          0 :             if ( mbCommandDrag )
    4455                 :            :             {
    4456                 :            :                 MouseEvent aMEvt( aMousePos, 1, MOUSE_SIMPLECLICK,
    4457         [ #  # ]:          0 :                                   MOUSE_LEFT, KEY_MOD2 );
    4458         [ #  # ]:          0 :                 ToolBox::MouseButtonDown( aMEvt );
    4459                 :            :                 return;
    4460                 :            :             }
    4461                 :            :         }
    4462                 :            :     }
    4463         [ #  # ]:          0 :     else if ( rCEvt.GetCommand() == COMMAND_WHEEL )
    4464                 :            :     {
    4465 [ #  # ][ #  # ]:          0 :         if ( (mnCurLine > 1) || (mnCurLine+mnVisLines-1 < mnCurLines) )
    4466                 :            :         {
    4467                 :          0 :             const CommandWheelData* pData = rCEvt.GetWheelData();
    4468         [ #  # ]:          0 :             if ( pData->GetMode() == COMMAND_WHEEL_SCROLL )
    4469                 :            :             {
    4470 [ #  # ][ #  # ]:          0 :                 if ( (mnCurLine > 1) && (pData->GetDelta() > 0) )
                 [ #  # ]
    4471                 :          0 :                     ShowLine( sal_False );
    4472 [ #  # ][ #  # ]:          0 :                 else if ( (mnCurLine+mnVisLines-1 < mnCurLines) && (pData->GetDelta() < 0) )
                 [ #  # ]
    4473                 :          0 :                     ShowLine( sal_True );
    4474                 :          0 :                 ImplDrawSpin( sal_False, sal_False );
    4475                 :          0 :                 return;
    4476                 :            :             }
    4477                 :            :         }
    4478                 :            :     }
    4479                 :            : 
    4480                 :          0 :     DockingWindow::Command( rCEvt );
    4481                 :            : }
    4482                 :            : 
    4483                 :            : // -----------------------------------------------------------------------
    4484                 :            : 
    4485                 :      25830 : void ToolBox::StateChanged( StateChangedType nType )
    4486                 :            : {
    4487                 :      25830 :     DockingWindow::StateChanged( nType );
    4488                 :            : 
    4489         [ +  + ]:      25830 :     if ( nType == STATE_CHANGE_INITSHOW )
    4490                 :       7570 :         ImplFormat();
    4491         [ +  + ]:      18260 :     else if ( nType == STATE_CHANGE_ENABLE )
    4492                 :       1077 :         ImplUpdateItem();
    4493         [ -  + ]:      17183 :     else if ( nType == STATE_CHANGE_UPDATEMODE )
    4494                 :            :     {
    4495         [ #  # ]:          0 :         if ( IsUpdateMode() )
    4496                 :          0 :             Invalidate();
    4497                 :            :     }
    4498 [ +  - ][ -  + ]:      17183 :     else if ( (nType == STATE_CHANGE_ZOOM) ||
    4499                 :            :               (nType == STATE_CHANGE_CONTROLFONT) )
    4500                 :            :     {
    4501                 :          0 :         mbCalc = sal_True;
    4502                 :          0 :         mbFormat = sal_True;
    4503                 :          0 :         ImplInitSettings( sal_True, sal_False, sal_False );
    4504                 :          0 :         Invalidate();
    4505                 :            :     }
    4506         [ -  + ]:      17183 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
    4507                 :            :     {
    4508                 :          0 :         ImplInitSettings( sal_False, sal_True, sal_False );
    4509                 :          0 :         Invalidate();
    4510                 :            :     }
    4511         [ -  + ]:      17183 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
    4512                 :            :     {
    4513                 :          0 :         ImplInitSettings( sal_False, sal_False, sal_True ); // font, foreground, background
    4514                 :          0 :         Invalidate();
    4515                 :            :     }
    4516                 :      25830 : }
    4517                 :            : 
    4518                 :            : // -----------------------------------------------------------------------
    4519                 :            : 
    4520                 :        274 : void ToolBox::DataChanged( const DataChangedEvent& rDCEvt )
    4521                 :            : {
    4522                 :        274 :     DockingWindow::DataChanged( rDCEvt );
    4523                 :            : 
    4524 [ +  + ][ +  -  :       1370 :     if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
          +  -  +  -  +  
                -  +  + ]
    4525                 :        274 :          (rDCEvt.GetType() == DATACHANGED_FONTS) ||
    4526                 :        274 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    4527                 :        274 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    4528                 :        274 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    4529                 :            :     {
    4530                 :        174 :         mbCalc = sal_True;
    4531                 :        174 :         mbFormat = sal_True;
    4532                 :        174 :         ImplInitSettings( sal_True, sal_True, sal_True );
    4533                 :        174 :         Invalidate();
    4534                 :            :     }
    4535                 :        274 : }
    4536                 :            : 
    4537                 :            : // -----------------------------------------------------------------------
    4538                 :            : 
    4539                 :          0 : sal_Bool ToolBox::PrepareToggleFloatingMode()
    4540                 :            : {
    4541                 :          0 :     return DockingWindow::PrepareToggleFloatingMode();
    4542                 :            : }
    4543                 :            : 
    4544                 :            : // -----------------------------------------------------------------------
    4545                 :            : 
    4546                 :          0 : void ToolBox::ToggleFloatingMode()
    4547                 :            : {
    4548                 :          0 :     DockingWindow::ToggleFloatingMode();
    4549                 :            : 
    4550                 :          0 :     sal_Bool mbOldHorz = mbHorz;
    4551                 :            : 
    4552         [ #  # ]:          0 :     if ( ImplIsFloatingMode() )
    4553                 :            :     {
    4554                 :          0 :         mbHorz   = sal_True;
    4555                 :          0 :         meAlign  = WINDOWALIGN_TOP;
    4556                 :          0 :         mbScroll = sal_True;
    4557                 :            : 
    4558         [ #  # ]:          0 :         if( mbOldHorz != mbHorz )
    4559                 :          0 :             mbCalc = sal_True;  // orientation was changed !
    4560                 :            : 
    4561                 :          0 :         ImplSetMinMaxFloatSize( this );
    4562         [ #  # ]:          0 :         SetOutputSizePixel( ImplCalcFloatSize( this, mnFloatLines ) );
    4563                 :            :     }
    4564                 :            :     else
    4565                 :            :     {
    4566         [ #  # ]:          0 :         mbScroll = (mnWinStyle & WB_SCROLL) ? sal_True : sal_False;
    4567 [ #  # ][ #  # ]:          0 :         if ( (meAlign == WINDOWALIGN_TOP) || (meAlign == WINDOWALIGN_BOTTOM) )
    4568                 :          0 :             mbHorz = sal_True;
    4569                 :            :         else
    4570                 :          0 :             mbHorz = sal_False;
    4571                 :            : 
    4572                 :            :         // set focus back to document
    4573                 :          0 :         ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus();
    4574                 :            :     }
    4575                 :            : 
    4576         [ #  # ]:          0 :     if( mbOldHorz != mbHorz )
    4577                 :            :     {
    4578                 :            :         // if orientation changes, the toolbox has to be initialized again
    4579                 :            :         // to update the direction of the gradient
    4580                 :          0 :         mbCalc = sal_True;
    4581                 :          0 :         ImplInitSettings( sal_True, sal_True, sal_True );
    4582                 :            :     }
    4583                 :            : 
    4584                 :          0 :     mbFormat = sal_True;
    4585                 :          0 :     ImplFormat();
    4586                 :          0 : }
    4587                 :            : 
    4588                 :            : // -----------------------------------------------------------------------
    4589                 :            : 
    4590                 :          0 : void ToolBox::StartDocking()
    4591                 :            : {
    4592                 :          0 :     meDockAlign = meAlign;
    4593                 :          0 :     mnDockLines = mnLines;
    4594                 :          0 :     mbLastFloatMode = ImplIsFloatingMode();
    4595                 :          0 :     DockingWindow::StartDocking();
    4596                 :          0 : }
    4597                 :            : 
    4598                 :            : // -----------------------------------------------------------------------
    4599                 :            : 
    4600                 :          0 : sal_Bool ToolBox::Docking( const Point& rPos, Rectangle& rRect )
    4601                 :            : {
    4602                 :            :     // do nothing during dragging, it was calculated before
    4603         [ #  # ]:          0 :     if ( mbDragging )
    4604                 :          0 :         return sal_False;
    4605                 :            : 
    4606                 :          0 :     sal_Bool bFloatMode = sal_False;
    4607                 :            : 
    4608         [ #  # ]:          0 :     DockingWindow::Docking( rPos, rRect );
    4609                 :            : 
    4610                 :            :     // if the mouse is outside the area, it can only become a floating window
    4611                 :          0 :     Rectangle aDockingRect( rRect );
    4612 [ #  # ][ #  # ]:          0 :     if ( !ImplIsFloatingMode() )
    4613                 :            :     {
    4614                 :            :         // don't use tracking rectangle for alignment check, because it will be too large
    4615                 :            :         // to get a floating mode as result - switch to floating size
    4616                 :            :         // so the calculation only depends on the position of the rectangle, not the current
    4617                 :            :         // docking state of the window
    4618                 :          0 :         sal_uInt16 nTemp = 0;
    4619 [ #  # ][ #  # ]:          0 :         aDockingRect.SetSize( ImplCalcFloatSize( this, nTemp ) );
    4620                 :            : 
    4621                 :            :         // in this mode docking is never done by keyboard, so it's OK to use the mouse position
    4622 [ #  # ][ #  # ]:          0 :         aDockingRect.SetPos( ImplGetFrameWindow()->GetPointerPosPixel() );
    4623                 :            :     }
    4624                 :            : 
    4625         [ #  # ]:          0 :     Rectangle aIntersection = maOutDockRect.GetIntersection( aDockingRect );
    4626 [ #  # ][ #  # ]:          0 :     if ( !aIntersection.IsEmpty() && !IsDockingPrevented() )
         [ #  # ][ #  # ]
    4627                 :            :     {
    4628                 :          0 :         Rectangle   aInRect = maInDockRect;
    4629                 :          0 :         Size aDockSize;
    4630         [ #  # ]:          0 :         aDockSize.Width()  = ImplCalcSize( this, mnLines, TB_CALCMODE_VERT ).Width();
    4631         [ #  # ]:          0 :         aDockSize.Height() = ImplCalcSize( this, mnLines, TB_CALCMODE_HORZ ).Height();
    4632                 :          0 :         aInRect.Left()   += aDockSize.Width()/2;
    4633                 :          0 :         aInRect.Top()    += aDockSize.Height()/2;
    4634                 :          0 :         aInRect.Right()  -= aDockSize.Width()/2;
    4635                 :          0 :         aInRect.Bottom() -= aDockSize.Height()/2;
    4636                 :            : 
    4637                 :            :         // if the window is too small, use the complete InDock-Rect
    4638         [ #  # ]:          0 :         if ( aInRect.Left() >= aInRect.Right() )
    4639                 :            :         {
    4640                 :          0 :             aInRect.Left()  = maInDockRect.Left();
    4641                 :          0 :             aInRect.Right() = maInDockRect.Right();
    4642                 :            :         }
    4643         [ #  # ]:          0 :         if ( aInRect.Top() >= aInRect.Bottom() )
    4644                 :            :         {
    4645                 :          0 :             aInRect.Top()    = maInDockRect.Top();
    4646                 :          0 :             aInRect.Bottom() = maInDockRect.Bottom();
    4647                 :            :         }
    4648                 :            : 
    4649                 :            :         // if the mouse is outside the Dock area, it can only
    4650                 :            :         // become a floating window
    4651         [ #  # ]:          0 :         Rectangle aIntersect = aInRect.GetIntersection( aDockingRect );
    4652 [ #  # ][ #  # ]:          0 :         if ( aIntersect == aDockingRect )
    4653                 :          0 :             bFloatMode = sal_True;
    4654                 :            :         else
    4655                 :            :         {
    4656                 :            :             // docking rectangle is in the "sensible area"
    4657                 :          0 :             Point aPos = aDockingRect.TopLeft();
    4658                 :          0 :             Point aInPosTL( aPos.X()-aInRect.Left(), aPos.Y()-aInRect.Top() );
    4659 [ #  # ][ #  # ]:          0 :             Point aInPosBR( aPos.X()-aInRect.Left() + aDockingRect.GetWidth(), aPos.Y()-aInRect.Top() + aDockingRect.GetHeight() );
    4660         [ #  # ]:          0 :             Size  aInSize = aInRect.GetSize();
    4661                 :            : 
    4662         [ #  # ]:          0 :             if ( aInPosTL.X() <= 0 )
    4663                 :          0 :                 meDockAlign = WINDOWALIGN_LEFT;
    4664         [ #  # ]:          0 :             else if ( aInPosTL.Y() <= 0)
    4665                 :          0 :                 meDockAlign = WINDOWALIGN_TOP;
    4666         [ #  # ]:          0 :             else if ( aInPosBR.X() >= aInSize.Width() )
    4667                 :          0 :                 meDockAlign = WINDOWALIGN_RIGHT;
    4668         [ #  # ]:          0 :             else if ( aInPosBR.Y() >= aInSize.Height() )
    4669                 :          0 :                 meDockAlign = WINDOWALIGN_BOTTOM;
    4670                 :            : 
    4671                 :            :             // update the Dock size if Dock-Align was changed
    4672 [ #  # ][ #  # ]:          0 :             if ( (meDockAlign == WINDOWALIGN_TOP) || (meDockAlign == WINDOWALIGN_BOTTOM) )
    4673         [ #  # ]:          0 :                 aDockSize.Width() = maInDockRect.GetWidth();
    4674                 :            :             else
    4675         [ #  # ]:          0 :                 aDockSize.Height() = maInDockRect.GetHeight();
    4676                 :            : 
    4677         [ #  # ]:          0 :             aDockingRect.SetSize( aDockSize );
    4678                 :            : 
    4679                 :          0 :             Point aPosTL( maInDockRect.TopLeft() );
    4680   [ #  #  #  #  :          0 :             switch ( meDockAlign )
                      # ]
    4681                 :            :             {
    4682                 :            :                 case WINDOWALIGN_TOP :
    4683                 :          0 :                     aDockingRect.SetPos( aPosTL );
    4684                 :          0 :                     break;
    4685                 :            :                 case WINDOWALIGN_LEFT :
    4686                 :          0 :                     aDockingRect.SetPos( aPosTL );
    4687                 :          0 :                     break;
    4688                 :            :                 case WINDOWALIGN_BOTTOM :
    4689                 :            :                 {
    4690         [ #  # ]:          0 :                     Point aPosBL( maInDockRect.BottomLeft() );
    4691         [ #  # ]:          0 :                     aPosBL.Y() -= aDockingRect.GetHeight();
    4692                 :          0 :                     aDockingRect.SetPos( aPosBL );
    4693                 :            :                     break;
    4694                 :            :                 }
    4695                 :            :                 case WINDOWALIGN_RIGHT :
    4696                 :            :                 {
    4697         [ #  # ]:          0 :                     Point aPosTR( maInDockRect.TopRight() );
    4698         [ #  # ]:          0 :                     aPosTR.X() -= aDockingRect.GetWidth();
    4699                 :          0 :                     aDockingRect.SetPos( aPosTR );
    4700                 :            :                     break;
    4701                 :            :                 }
    4702                 :            :             }
    4703                 :            :         }
    4704                 :            :     }
    4705                 :            :     else
    4706                 :          0 :         bFloatMode = sal_True;
    4707                 :            : 
    4708         [ #  # ]:          0 :     if ( bFloatMode )
    4709                 :            :     {
    4710                 :          0 :         meDockAlign = meAlign;
    4711         [ #  # ]:          0 :         if ( !mbLastFloatMode )
    4712                 :            :         {
    4713                 :          0 :             sal_uInt16 nTemp = 0;
    4714 [ #  # ][ #  # ]:          0 :             aDockingRect.SetSize( ImplCalcFloatSize( this, nTemp ) );
    4715                 :            :         }
    4716                 :            :     }
    4717                 :            : 
    4718                 :          0 :     rRect = aDockingRect;
    4719                 :          0 :     mbLastFloatMode = bFloatMode;
    4720                 :            : 
    4721                 :          0 :     return bFloatMode;
    4722                 :            : }
    4723                 :            : 
    4724                 :            : // -----------------------------------------------------------------------
    4725                 :            : 
    4726                 :          0 : void ToolBox::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
    4727                 :            : {
    4728         [ #  # ]:          0 :     if ( !IsDockingCanceled() )
    4729                 :            :     {
    4730         [ #  # ]:          0 :         if ( mnLines != mnDockLines )
    4731                 :          0 :             SetLineCount( mnDockLines );
    4732         [ #  # ]:          0 :         if ( meAlign != meDockAlign )
    4733                 :          0 :             SetAlign( meDockAlign );
    4734                 :            :     }
    4735 [ #  # ][ #  # ]:          0 :     if ( bFloatMode || (bFloatMode != ImplIsFloatingMode()) )
                 [ #  # ]
    4736                 :          0 :         DockingWindow::EndDocking( rRect, bFloatMode );
    4737                 :          0 : }
    4738                 :            : 
    4739                 :            : // -----------------------------------------------------------------------
    4740                 :            : 
    4741                 :          0 : void ToolBox::Resizing( Size& rSize )
    4742                 :            : {
    4743                 :            :     sal_uInt16  nCalcLines;
    4744                 :            :     sal_uInt16  nTemp;
    4745                 :            : 
    4746                 :            :     // Alle Floatinggroessen berechnen
    4747         [ #  # ]:          0 :     ImplCalcFloatSizes( this );
    4748                 :            : 
    4749         [ #  # ]:          0 :     if ( !mnLastResizeDY )
    4750                 :          0 :         mnLastResizeDY = mnDY;
    4751                 :            : 
    4752                 :            :     // Ist vertikales Resizing angesagt
    4753 [ #  # ][ #  # ]:          0 :     if ( (mnLastResizeDY != rSize.Height()) && (mnDY != rSize.Height()) )
                 [ #  # ]
    4754                 :            :     {
    4755                 :          0 :         nCalcLines = ImplCalcLines( this, rSize.Height() );
    4756         [ #  # ]:          0 :         if ( nCalcLines < 1 )
    4757                 :          0 :             nCalcLines = 1;
    4758         [ #  # ]:          0 :         rSize = ImplCalcFloatSize( this, nCalcLines );
    4759                 :            :     }
    4760                 :            :     else
    4761                 :            :     {
    4762                 :          0 :         nCalcLines = 1;
    4763                 :          0 :         nTemp = nCalcLines;
    4764         [ #  # ]:          0 :         Size aTempSize = ImplCalcFloatSize( this, nTemp );
    4765   [ #  #  #  # ]:          0 :         while ( (aTempSize.Width() > rSize.Width()) &&
                 [ #  # ]
    4766                 :          0 :                 (nCalcLines <= maFloatSizes[0].mnLines) )
    4767                 :            :         {
    4768                 :          0 :             nCalcLines++;
    4769                 :          0 :             nTemp = nCalcLines;
    4770         [ #  # ]:          0 :             aTempSize = ImplCalcFloatSize( this, nTemp );
    4771                 :            :         }
    4772                 :          0 :         rSize = aTempSize;
    4773                 :            :     }
    4774                 :            : 
    4775                 :          0 :     mnLastResizeDY = rSize.Height();
    4776                 :          0 : }
    4777                 :            : 
    4778                 :            : // -----------------------------------------------------------------------
    4779                 :            : 
    4780                 :      24978 : Size ToolBox::CalcWindowSizePixel( sal_uInt16 nCalcLines ) const
    4781                 :            : {
    4782                 :      24978 :     return ImplCalcSize( this, nCalcLines );
    4783                 :            : }
    4784                 :            : 
    4785                 :          0 : Size ToolBox::CalcWindowSizePixel( sal_uInt16 nCalcLines, WindowAlign eAlign ) const
    4786                 :            : {
    4787                 :            :     return ImplCalcSize( this, nCalcLines,
    4788 [ #  # ][ #  # ]:          0 :         (eAlign == WINDOWALIGN_TOP || eAlign == WINDOWALIGN_BOTTOM) ? TB_CALCMODE_HORZ : TB_CALCMODE_VERT );
    4789                 :            : }
    4790                 :            : 
    4791                 :          0 : sal_uInt16 ToolBox::ImplCountLineBreaks( const ToolBox *pThis )
    4792                 :            : {
    4793                 :          0 :     sal_uInt16 nLines = 0;
    4794                 :            : 
    4795         [ #  # ]:          0 :     std::vector< ImplToolItem >::const_iterator it = ((ToolBox*)pThis)->mpData->m_aItems.begin();
    4796 [ #  # ][ #  # ]:          0 :     while ( it != ((ToolBox*)pThis)->mpData->m_aItems.end() )
    4797                 :            :     {
    4798         [ #  # ]:          0 :         if( it->meType == TOOLBOXITEM_BREAK )
    4799                 :          0 :             ++nLines;
    4800                 :          0 :         ++it;
    4801                 :            :     }
    4802                 :          0 :     return nLines;
    4803                 :            : }
    4804                 :            : 
    4805                 :          0 : Size ToolBox::CalcPopupWindowSizePixel() const
    4806                 :            : {
    4807                 :            :     // count number of breaks and calc corresponding floating window size
    4808                 :          0 :     sal_uInt16 nLines = ImplCountLineBreaks( this );
    4809                 :            : 
    4810         [ #  # ]:          0 :     if( nLines )
    4811                 :          0 :         ++nLines;   // add the first line
    4812                 :            :     else
    4813                 :            :     {
    4814                 :            :         // no breaks found: use quadratic layout
    4815                 :          0 :         nLines = (sal_uInt16) ceil( sqrt( (double) GetItemCount() ) );
    4816                 :            :     }
    4817                 :            : 
    4818                 :          0 :     sal_Bool bPopup = mpData->mbAssumePopupMode;
    4819                 :          0 :     ToolBox *pThis = (ToolBox*) this;
    4820                 :          0 :     pThis->mpData->mbAssumePopupMode = sal_True;
    4821                 :            : 
    4822                 :          0 :     Size aSize = CalcFloatingWindowSizePixel( nLines );
    4823                 :            : 
    4824                 :          0 :     pThis->mpData->mbAssumePopupMode = bPopup;
    4825                 :          0 :     return aSize;
    4826                 :            : }
    4827                 :            : 
    4828                 :          0 : Size ToolBox::CalcFloatingWindowSizePixel() const
    4829                 :            : {
    4830                 :          0 :     sal_uInt16 nLines = ImplCountLineBreaks( this );
    4831                 :          0 :     ++nLines; // add the first line
    4832                 :          0 :     return CalcFloatingWindowSizePixel( nLines );
    4833                 :            : }
    4834                 :            : 
    4835                 :          0 : Size ToolBox::CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const
    4836                 :            : {
    4837                 :          0 :     sal_Bool bFloat = mpData->mbAssumeFloating;
    4838                 :          0 :     sal_Bool bDocking = mpData->mbAssumeDocked;
    4839                 :            : 
    4840                 :            :     // simulate floating mode and force reformat before calculating
    4841                 :          0 :     ToolBox *pThis = (ToolBox*) this;
    4842                 :          0 :     pThis->mpData->mbAssumeFloating = sal_True;
    4843                 :          0 :     pThis->mpData->mbAssumeDocked = sal_False;
    4844                 :            : 
    4845                 :          0 :     Size aSize = ImplCalcFloatSize( (ToolBox*) this, nCalcLines );
    4846                 :            : 
    4847                 :          0 :     pThis->mbFormat = sal_True;
    4848                 :          0 :     pThis->mpData->mbAssumeFloating = bFloat;
    4849                 :          0 :     pThis->mpData->mbAssumeDocked = bDocking;
    4850                 :            : 
    4851                 :          0 :     return aSize;
    4852                 :            : }
    4853                 :            : 
    4854                 :            : // -----------------------------------------------------------------------
    4855                 :            : 
    4856                 :       2118 : Size ToolBox::CalcMinimumWindowSizePixel() const
    4857                 :            : {
    4858         [ -  + ]:       2118 :     if( ImplIsFloatingMode() )
    4859                 :          0 :         return ImplCalcSize( this, mnFloatLines );
    4860                 :            :     else
    4861                 :            :     {
    4862                 :            :         // create dummy toolbox for measurements
    4863 [ +  - ][ +  - ]:       2118 :         ToolBox *pToolBox = new ToolBox( GetParent(), GetStyle() );
                 [ +  - ]
    4864                 :            : 
    4865                 :            :         // copy until first useful item
    4866                 :       2118 :         std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
    4867 [ +  - ][ +  - ]:       2118 :         while( it != mpData->m_aItems.end() )
    4868                 :            :         {
    4869         [ +  - ]:       2118 :             pToolBox->CopyItem( *this, it->mnId );
    4870   [ +  -  +  - ]:       6354 :             if( (it->meType != TOOLBOXITEM_BUTTON) ||
         [ -  + ][ -  + ]
    4871         [ +  - ]:       4236 :                 !it->mbVisible || ImplIsFixedControl( &(*it) ) )
    4872                 :          0 :                 ++it;
    4873                 :            :             else
    4874                 :       2118 :                 break;
    4875                 :            :         }
    4876                 :            : 
    4877                 :            :         // add to docking manager if required to obtain a drag area
    4878                 :            :         // (which is accounted for in calcwindowsizepixel)
    4879 [ +  - ][ +  - ]:       2118 :         if( ImplGetDockingManager()->GetDockingWindowWrapper( this ) )
                 [ +  - ]
    4880 [ +  - ][ +  - ]:       2118 :             ImplGetDockingManager()->AddWindow( pToolBox );
    4881                 :            : 
    4882                 :            :         // account for menu
    4883 [ +  - ][ +  - ]:       2118 :         if( IsMenuEnabled() )
    4884 [ +  - ][ +  - ]:       2118 :             pToolBox->SetMenuType( GetMenuType() );
    4885                 :            : 
    4886         [ +  - ]:       2118 :         pToolBox->SetAlign( GetAlign() );
    4887         [ +  - ]:       2118 :         Size aSize = pToolBox->CalcWindowSizePixel( 1 );
    4888                 :            : 
    4889 [ +  - ][ +  - ]:       2118 :         ImplGetDockingManager()->RemoveWindow( pToolBox );
    4890         [ +  - ]:       2118 :         pToolBox->Clear();
    4891 [ +  - ][ +  - ]:       2118 :         delete pToolBox;
    4892                 :            : 
    4893                 :       2118 :         return aSize;
    4894                 :            :     }
    4895                 :            : }
    4896                 :            : 
    4897                 :            : // -----------------------------------------------------------------------
    4898                 :            : 
    4899                 :       3709 : void ToolBox::EnableCustomize( sal_Bool bEnable )
    4900                 :            : {
    4901         [ +  - ]:       3709 :     if ( bEnable != mbCustomize )
    4902                 :            :     {
    4903                 :       3709 :         mbCustomize = bEnable;
    4904                 :            : 
    4905                 :       3709 :         ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
    4906         [ +  - ]:       3709 :         if ( bEnable )
    4907                 :       3709 :             pMgr->push_back( this );
    4908                 :            :         else
    4909                 :          0 :             pMgr->erase( this );
    4910                 :            :     }
    4911                 :       3709 : }
    4912                 :            : 
    4913                 :            : // -----------------------------------------------------------------------
    4914                 :            : 
    4915                 :          2 : void ToolBox::GetFocus()
    4916                 :            : {
    4917                 :          2 :     DockingWindow::GetFocus();
    4918                 :          2 : }
    4919                 :            : 
    4920                 :            : // -----------------------------------------------------------------------
    4921                 :            : 
    4922                 :          0 : void ToolBox::LoseFocus()
    4923                 :            : {
    4924                 :          0 :     ImplChangeHighlight( NULL, sal_True );
    4925                 :            : 
    4926                 :          0 :     DockingWindow::LoseFocus();
    4927                 :          0 : }
    4928                 :            : 
    4929                 :            : // -----------------------------------------------------------------------
    4930                 :            : 
    4931                 :            : // performs the action associated with an item, ie simulates clicking the item
    4932                 :          2 : void ToolBox::TriggerItem( sal_uInt16 nItemId, sal_Bool bShift, sal_Bool bCtrl )
    4933                 :            : {
    4934                 :          2 :     mnHighItemId = nItemId;
    4935                 :          2 :     sal_uInt16 nModifier = 0;
    4936         [ -  + ]:          2 :     if( bShift )
    4937                 :          0 :         nModifier |= KEY_SHIFT;
    4938         [ -  + ]:          2 :     if( bCtrl )
    4939                 :          0 :         nModifier |= KEY_MOD1;
    4940                 :          2 :     KeyCode aKeyCode( 0, nModifier );
    4941         [ +  - ]:          2 :     ImplActivateItem( aKeyCode );
    4942                 :          2 : }
    4943                 :            : 
    4944                 :            : // -----------------------------------------------------------------------
    4945                 :            : 
    4946                 :            : // calls the button's action handler
    4947                 :            : // returns sal_True if action was called
    4948                 :          2 : sal_Bool ToolBox::ImplActivateItem( KeyCode aKeyCode )
    4949                 :            : {
    4950                 :          2 :     sal_Bool bRet = sal_True;
    4951         [ +  - ]:          2 :     if( mnHighItemId )
    4952                 :            :     {
    4953                 :          2 :         ImplToolItem *pToolItem = ImplGetItem( mnHighItemId );
    4954                 :            : 
    4955                 :            :         // #107712#, activate can also be called for disabled entries
    4956 [ -  + ][ +  - ]:          2 :         if( pToolItem && !pToolItem->mbEnabled )
    4957                 :          0 :             return sal_True;
    4958                 :            : 
    4959 [ +  - ][ -  + ]:          2 :         if( pToolItem && pToolItem->mpWindow && HasFocus() )
         [ #  # ][ -  + ]
    4960                 :            :         {
    4961                 :          0 :             ImplHideFocus();
    4962                 :          0 :             mbChangingHighlight = sal_True;  // avoid focus change due to loose focus
    4963                 :          0 :             pToolItem->mpWindow->ImplControlFocus( GETFOCUS_TAB );
    4964                 :          0 :             mbChangingHighlight = sal_False;
    4965                 :            :         }
    4966                 :            :         else
    4967                 :            :         {
    4968                 :          2 :             mnDownItemId = mnCurItemId = mnHighItemId;
    4969         [ +  - ]:          2 :             ImplToolItem* pItem = ImplGetItem( mnHighItemId );
    4970         [ -  + ]:          2 :             if ( pItem->mnBits & TIB_AUTOCHECK )
    4971                 :            :             {
    4972         [ #  # ]:          0 :                 if ( pItem->mnBits & TIB_RADIOCHECK )
    4973                 :            :                 {
    4974         [ #  # ]:          0 :                     if ( pItem->meState != STATE_CHECK )
    4975         [ #  # ]:          0 :                         SetItemState( pItem->mnId, STATE_CHECK );
    4976                 :            :                 }
    4977                 :            :                 else
    4978                 :            :                 {
    4979         [ #  # ]:          0 :                     if ( pItem->meState != STATE_CHECK )
    4980                 :          0 :                         pItem->meState = STATE_CHECK;
    4981                 :            :                     else
    4982                 :          0 :                         pItem->meState = STATE_NOCHECK;
    4983                 :            :                 }
    4984                 :            :             }
    4985                 :          2 :             mnMouseModifier = aKeyCode.GetModifier();
    4986                 :          2 :             mbIsKeyEvent = sal_True;
    4987         [ +  - ]:          2 :             Activate();
    4988         [ +  - ]:          2 :             Click();
    4989                 :            : 
    4990                 :            :             // #107776# we might be destroyed in the selecthandler
    4991         [ +  - ]:          2 :             ImplDelData aDelData;
    4992         [ +  - ]:          2 :             ImplAddDel( &aDelData );
    4993         [ +  - ]:          2 :             Select();
    4994         [ -  + ]:          2 :             if ( aDelData.IsDead() )
    4995                 :          0 :                 return bRet;
    4996         [ +  - ]:          2 :             ImplRemoveDel( &aDelData );
    4997                 :            : 
    4998         [ +  - ]:          2 :             Deactivate();
    4999                 :          2 :             mbIsKeyEvent = sal_False;
    5000 [ +  - ][ +  - ]:          2 :             mnMouseModifier = 0;
    5001                 :            :         }
    5002                 :            :     }
    5003                 :            :     else
    5004                 :          0 :         bRet = sal_False;
    5005                 :          2 :     return bRet;
    5006                 :            : }
    5007                 :            : 
    5008                 :            : // -----------------------------------------------------------------------
    5009                 :            : 
    5010                 :          0 : sal_Bool ImplCloseLastPopup( Window *pParent )
    5011                 :            : {
    5012                 :            :     // close last popup toolbox (see also:
    5013                 :            :     // ImplHandleMouseFloatMode(...) in winproc.cxx )
    5014                 :            : 
    5015         [ #  # ]:          0 :     if( ImplGetSVData()->maWinData.mpFirstFloat )
    5016                 :            :     {
    5017                 :          0 :         FloatingWindow* pLastLevelFloat = ImplGetSVData()->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
    5018                 :            :         // only close the floater if it is not our direct parent, which would kill ourself
    5019 [ #  # ][ #  # ]:          0 :         if( pLastLevelFloat && pLastLevelFloat != pParent )
    5020                 :            :         {
    5021                 :          0 :             pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
    5022                 :          0 :             return sal_True;
    5023                 :            :         }
    5024                 :            :     }
    5025                 :          0 :     return sal_False;
    5026                 :            : }
    5027                 :            : 
    5028                 :            : // opens a drop down toolbox item
    5029                 :            : // returns sal_True if item was opened
    5030                 :          0 : sal_Bool ToolBox::ImplOpenItem( KeyCode aKeyCode )
    5031                 :            : {
    5032                 :          0 :     sal_uInt16 nCode = aKeyCode.GetCode();
    5033                 :          0 :     sal_Bool bRet = sal_True;
    5034                 :            : 
    5035                 :            :     // arrow keys should work only in the opposite direction of alignment (to not break cursor travelling)
    5036 [ #  # ][ #  # ]:          0 :     if ( ((nCode == KEY_LEFT || nCode == KEY_RIGHT) && IsHorizontal())
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    5037                 :          0 :       || ((nCode == KEY_UP   || nCode == KEY_DOWN)  && !IsHorizontal()) )
    5038                 :          0 :         return sal_False;
    5039                 :            : 
    5040 [ #  # ][ #  # ]:          0 :     if( IsMenuEnabled() && mpData->mbMenubuttonSelected )
                 [ #  # ]
    5041                 :            :     {
    5042         [ #  # ]:          0 :         if( ImplCloseLastPopup( GetParent() ) )
    5043                 :          0 :             return bRet;
    5044                 :            : 
    5045                 :          0 :         UpdateCustomMenu();
    5046         [ #  # ]:          0 :         Application::PostUserEvent( mpData->mnEventId, LINK( this, ToolBox, ImplCallExecuteCustomMenu ) );
    5047                 :            :     }
    5048         [ #  # ]:          0 :     else if( mnHighItemId &&  ImplGetItem( mnHighItemId ) &&
           [ #  #  #  # ]
                 [ #  # ]
    5049                 :          0 :         (ImplGetItem( mnHighItemId )->mnBits & TIB_DROPDOWN) )
    5050                 :            :     {
    5051         [ #  # ]:          0 :         if( ImplCloseLastPopup( GetParent() ) )
    5052                 :          0 :             return bRet;
    5053                 :            : 
    5054                 :          0 :         mnDownItemId = mnCurItemId = mnHighItemId;
    5055                 :          0 :         mnCurPos = GetItemPos( mnCurItemId );
    5056                 :          0 :         mnLastFocusItemId = mnCurItemId; // save item id for possible later focus restore
    5057                 :          0 :         mnMouseModifier = aKeyCode.GetModifier();
    5058                 :          0 :         mbIsShift = sal_True;
    5059                 :          0 :         mbIsKeyEvent = sal_True;
    5060                 :          0 :         Activate();
    5061                 :            : 
    5062                 :          0 :         mpData->mbDropDownByKeyboard = sal_True;
    5063                 :          0 :         GetDropdownClickHdl().Call( this );
    5064                 :            : 
    5065                 :          0 :         mbIsKeyEvent = sal_False;
    5066                 :          0 :         mbIsShift = sal_False;
    5067                 :          0 :         mnMouseModifier = 0;
    5068                 :            :     }
    5069                 :            :     else
    5070                 :          0 :         bRet = sal_False;
    5071                 :            : 
    5072                 :          0 :     return bRet;
    5073                 :            : }
    5074                 :            : 
    5075                 :            : // -----------------------------------------------------------------------
    5076                 :            : 
    5077                 :          0 : void ToolBox::KeyInput( const KeyEvent& rKEvt )
    5078                 :            : {
    5079                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    5080                 :          0 :     mnKeyModifier = aKeyCode.GetModifier();
    5081                 :          0 :     sal_uInt16 nCode = aKeyCode.GetCode();
    5082 [ #  # ][ #  # ]:          0 :     sal_Bool bParentIsDialog = ( ( ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL) ) == WB_DIALOGCONTROL );
    5083                 :          0 :     sal_Bool bForwardKey = sal_False;
    5084                 :          0 :     sal_Bool bGrabFocusToDocument = sal_False;
    5085                 :            : 
    5086                 :            :     // #107776# we might be destroyed in the keyhandler
    5087         [ #  # ]:          0 :     ImplDelData aDelData;
    5088         [ #  # ]:          0 :     ImplAddDel( &aDelData );
    5089                 :            : 
    5090   [ #  #  #  #  :          0 :     switch ( nCode )
          #  #  #  #  #  
                   #  # ]
    5091                 :            :     {
    5092                 :            :         case KEY_UP:
    5093                 :            :         {
    5094                 :            :             // Ctrl-Cursor activates next toolbox, indicated by a blue arrow pointing to the left/up
    5095         [ #  # ]:          0 :             if( aKeyCode.GetModifier() )    // allow only pure cursor keys
    5096                 :          0 :                 break;
    5097         [ #  # ]:          0 :             if( !IsHorizontal() )
    5098         [ #  # ]:          0 :                 ImplChangeHighlightUpDn( sal_True );
    5099                 :            :             else
    5100         [ #  # ]:          0 :                 ImplOpenItem( aKeyCode );
    5101                 :            :         }
    5102                 :          0 :         break;
    5103                 :            :         case KEY_LEFT:
    5104                 :            :         {
    5105         [ #  # ]:          0 :             if( aKeyCode.GetModifier() )    // allow only pure cursor keys
    5106                 :          0 :                 break;
    5107         [ #  # ]:          0 :             if( IsHorizontal() )
    5108         [ #  # ]:          0 :                 ImplChangeHighlightUpDn( sal_True );
    5109                 :            :             else
    5110         [ #  # ]:          0 :                 ImplOpenItem( aKeyCode );
    5111                 :            :         }
    5112                 :          0 :         break;
    5113                 :            :         case KEY_DOWN:
    5114                 :            :         {
    5115         [ #  # ]:          0 :             if( aKeyCode.GetModifier() )    // allow only pure cursor keys
    5116                 :          0 :                 break;
    5117         [ #  # ]:          0 :             if( !IsHorizontal() )
    5118         [ #  # ]:          0 :                 ImplChangeHighlightUpDn( sal_False );
    5119                 :            :             else
    5120         [ #  # ]:          0 :                 ImplOpenItem( aKeyCode );
    5121                 :            :         }
    5122                 :          0 :         break;
    5123                 :            :         case KEY_RIGHT:
    5124                 :            :         {
    5125         [ #  # ]:          0 :             if( aKeyCode.GetModifier() )    // allow only pure cursor keys
    5126                 :          0 :                 break;
    5127         [ #  # ]:          0 :             if( IsHorizontal() )
    5128         [ #  # ]:          0 :                 ImplChangeHighlightUpDn( sal_False );
    5129                 :            :             else
    5130         [ #  # ]:          0 :                 ImplOpenItem( aKeyCode );
    5131                 :            :         }
    5132                 :          0 :         break;
    5133                 :            :         case KEY_PAGEUP:
    5134         [ #  # ]:          0 :             if ( mnCurLine > 1 )
    5135                 :            :             {
    5136         [ #  # ]:          0 :                 if( mnCurLine > mnVisLines )
    5137                 :          0 :                     mnCurLine = mnCurLine - mnVisLines;
    5138                 :            :                 else
    5139                 :          0 :                     mnCurLine = 1;
    5140                 :          0 :                 mbFormat = sal_True;
    5141         [ #  # ]:          0 :                 ImplFormat();
    5142         [ #  # ]:          0 :                 ImplDrawSpin( sal_False, sal_False );
    5143 [ #  # ][ #  # ]:          0 :                 ImplChangeHighlight( ImplGetFirstValidItem( mnCurLine ) );
    5144                 :            :             }
    5145                 :          0 :         break;
    5146                 :            :         case KEY_PAGEDOWN:
    5147         [ #  # ]:          0 :             if ( mnCurLine+mnVisLines-1 < mnCurLines )
    5148                 :            :             {
    5149         [ #  # ]:          0 :                 if( mnCurLine + 2*mnVisLines-1 < mnCurLines )
    5150                 :          0 :                     mnCurLine = mnCurLine + mnVisLines;
    5151                 :            :                 else
    5152                 :          0 :                     mnCurLine = mnCurLines;
    5153                 :          0 :                 mbFormat = sal_True;
    5154         [ #  # ]:          0 :                 ImplFormat();
    5155         [ #  # ]:          0 :                 ImplDrawSpin( sal_False, sal_False );
    5156 [ #  # ][ #  # ]:          0 :                 ImplChangeHighlight( ImplGetFirstValidItem( mnCurLine ) );
    5157                 :            :             }
    5158                 :          0 :         break;
    5159                 :            :         case KEY_END:
    5160                 :            :             {
    5161         [ #  # ]:          0 :                 ImplChangeHighlight( NULL );
    5162         [ #  # ]:          0 :                 ImplChangeHighlightUpDn( sal_False );
    5163                 :            :             }
    5164                 :          0 :             break;
    5165                 :            :         case KEY_HOME:
    5166                 :            :             {
    5167         [ #  # ]:          0 :                 ImplChangeHighlight( NULL );
    5168         [ #  # ]:          0 :                 ImplChangeHighlightUpDn( sal_True );
    5169                 :            :             }
    5170                 :          0 :             break;
    5171                 :            :         case KEY_ESCAPE:
    5172                 :            :         {
    5173 [ #  # ][ #  # ]:          0 :             if( !ImplIsFloatingMode() && bParentIsDialog )
         [ #  # ][ #  # ]
    5174         [ #  # ]:          0 :                 DockingWindow::KeyInput( rKEvt );
    5175                 :            :             else
    5176                 :            :             {
    5177                 :            :                 // send focus to document pane
    5178                 :          0 :                 Window *pWin = this;
    5179         [ #  # ]:          0 :                 while( pWin )
    5180                 :            :                 {
    5181 [ #  # ][ #  # ]:          0 :                     if( !pWin->GetParent() )
    5182                 :            :                     {
    5183 [ #  # ][ #  # ]:          0 :                         pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus();
                 [ #  # ]
    5184                 :          0 :                         break;
    5185                 :            :                     }
    5186         [ #  # ]:          0 :                     pWin = pWin->GetParent();
    5187                 :            :                 }
    5188                 :            :             }
    5189                 :            :         }
    5190                 :          0 :         break;
    5191                 :            :         case KEY_RETURN:
    5192                 :            :         {
    5193                 :            :             // #107712#, disabled entries are selectable now
    5194                 :            :             //  leave toolbox and move focus to document
    5195         [ #  # ]:          0 :             if( mnHighItemId )
    5196                 :            :             {
    5197         [ #  # ]:          0 :                 ImplToolItem *pItem = ImplGetItem( mnHighItemId );
    5198         [ #  # ]:          0 :                 if( !pItem->mbEnabled )
    5199                 :            :                 {
    5200                 :          0 :                     bGrabFocusToDocument = sal_True;
    5201                 :            :                 }
    5202                 :            :             }
    5203         [ #  # ]:          0 :             if( !bGrabFocusToDocument )
    5204         [ #  # ]:          0 :                 bForwardKey = !ImplActivateItem( aKeyCode );
    5205                 :            :         }
    5206                 :          0 :         break;
    5207                 :            :         default:
    5208                 :            :             {
    5209                 :          0 :             sal_uInt16 aKeyGroup = aKeyCode.GetGroup();
    5210                 :          0 :             ImplToolItem *pItem = NULL;
    5211         [ #  # ]:          0 :             if( mnHighItemId )
    5212         [ #  # ]:          0 :                 pItem = ImplGetItem( mnHighItemId );
    5213                 :            :             // #i13931# forward alphanum keyinput into embedded control
    5214 [ #  # ][ #  # ]:          0 :             if( (aKeyGroup == KEYGROUP_NUM || aKeyGroup == KEYGROUP_ALPHA ) && pItem && pItem->mpWindow && pItem->mbEnabled )
         [ #  # ][ #  # ]
                 [ #  # ]
    5215                 :            :             {
    5216         [ #  # ]:          0 :                 Window *pFocusWindow = Application::GetFocusWindow();
    5217         [ #  # ]:          0 :                 ImplHideFocus();
    5218                 :          0 :                 mbChangingHighlight = sal_True;  // avoid focus change due to loose focus
    5219         [ #  # ]:          0 :                 pItem->mpWindow->ImplControlFocus( GETFOCUS_TAB );
    5220                 :          0 :                 mbChangingHighlight = sal_False;
    5221 [ #  # ][ #  # ]:          0 :                 if( pFocusWindow != Application::GetFocusWindow() )
    5222 [ #  # ][ #  # ]:          0 :                     Application::GetFocusWindow()->KeyInput( rKEvt );
    5223                 :            :             }
    5224                 :            :             else
    5225                 :            :             {
    5226                 :            :                 // do nothing to avoid key presses going into the document
    5227                 :            :                 // while the toolbox has the focus
    5228                 :            :                 // just forward function and special keys and combinations with Alt-key
    5229 [ #  # ][ #  # ]:          0 :                 if( aKeyGroup == KEYGROUP_FKEYS || aKeyGroup == KEYGROUP_MISC || aKeyCode.IsMod2() )
         [ #  # ][ #  # ]
    5230                 :          0 :                     bForwardKey = sal_True;
    5231                 :            :             }
    5232                 :            :         }
    5233                 :            :     }
    5234                 :            : 
    5235         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    5236                 :            :         return;
    5237         [ #  # ]:          0 :     ImplRemoveDel( &aDelData );
    5238                 :            : 
    5239                 :            :     // #107251# move focus away if this toolbox was disabled during keyinput
    5240 [ #  # ][ #  # ]:          0 :     if( HasFocus() && mpData->mbKeyInputDisabled && (ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL) ) == WB_DIALOGCONTROL)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5241                 :            :     {
    5242                 :          0 :         sal_uInt16 n = 0;
    5243 [ #  # ][ #  # ]:          0 :         Window *pFocusControl = ImplGetParent()->ImplGetDlgWindow( n, DLGWINDOW_FIRST );
    5244 [ #  # ][ #  # ]:          0 :         if ( pFocusControl && pFocusControl != this )
    5245         [ #  # ]:          0 :             pFocusControl->ImplControlFocus( GETFOCUS_INIT );
    5246                 :            :     }
    5247                 :            : 
    5248                 :          0 :     mnKeyModifier = 0;
    5249                 :            : 
    5250                 :            :     // #107712#, leave toolbox
    5251         [ #  # ]:          0 :     if( bGrabFocusToDocument )
    5252                 :            :     {
    5253         [ #  # ]:          0 :         GrabFocusToDocument();
    5254                 :            :         return;
    5255                 :            :     }
    5256                 :            : 
    5257         [ #  # ]:          0 :     if( bForwardKey )
    5258 [ #  # ][ #  # ]:          0 :         DockingWindow::KeyInput( rKEvt );
                 [ #  # ]
    5259                 :            : }
    5260                 :            : 
    5261                 :            : // -----------------------------------------------------------------------
    5262                 :            : 
    5263                 :            : // returns the current toolbox line of the item
    5264                 :          2 : sal_uInt16 ToolBox::ImplGetItemLine( ImplToolItem* pCurrentItem )
    5265                 :            : {
    5266         [ +  - ]:          2 :     std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
    5267                 :          2 :     sal_uInt16 nLine = 1;
    5268 [ +  - ][ +  - ]:          2 :     while( it != mpData->m_aItems.end() )
    5269                 :            :     {
    5270         [ -  + ]:          2 :         if ( it->mbBreak )
    5271                 :          0 :             ++nLine;
    5272         [ +  - ]:          2 :         if( &(*it) == pCurrentItem)
    5273                 :          2 :             break;
    5274                 :          0 :         ++it;
    5275                 :            :     }
    5276                 :          2 :     return nLine;
    5277                 :            : }
    5278                 :            : 
    5279                 :            : // returns the first displayable item in the given line
    5280                 :          0 : ImplToolItem* ToolBox::ImplGetFirstValidItem( sal_uInt16 nLine )
    5281                 :            : {
    5282 [ #  # ][ #  # ]:          0 :     if( !nLine || nLine > mnCurLines )
    5283                 :          0 :         return NULL;
    5284                 :            : 
    5285                 :          0 :     nLine--;
    5286                 :            : 
    5287                 :          0 :     std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
    5288 [ #  # ][ #  # ]:          0 :     while( it != mpData->m_aItems.end() )
    5289                 :            :     {
    5290                 :            :         // find correct line
    5291         [ #  # ]:          0 :         if ( it->mbBreak )
    5292                 :          0 :             nLine--;
    5293         [ #  # ]:          0 :         if( !nLine )
    5294                 :            :         {
    5295                 :            :             // find first useful item
    5296 [ #  # ][ #  # ]:          0 :             while( it != mpData->m_aItems.end() && ((it->meType != TOOLBOXITEM_BUTTON) ||
           [ #  #  #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    5297         [ #  # ]:          0 :                 /*!it->mbEnabled ||*/ !it->mbVisible || ImplIsFixedControl( &(*it) )) )
    5298                 :            :             {
    5299                 :          0 :                 ++it;
    5300 [ #  # ][ #  # ]:          0 :                 if( it == mpData->m_aItems.end() || it->mbBreak )
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    5301                 :          0 :                     return NULL;    // no valid items in this line
    5302                 :            :             }
    5303                 :          0 :             return &(*it);
    5304                 :            :         }
    5305                 :          0 :         ++it;
    5306                 :            :     }
    5307                 :            : 
    5308 [ #  # ][ #  # ]:          0 :     return (it == mpData->m_aItems.end()) ? NULL : &(*it);
    5309                 :            : }
    5310                 :            : 
    5311                 :            : // -----------------------------------------------------------------------
    5312                 :            : 
    5313                 :          2 : sal_uInt16 ToolBox::ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList )
    5314                 :            : {
    5315         [ +  - ]:          2 :     if( pItem )
    5316                 :            :     {
    5317                 :            :         sal_uInt16 nPos;
    5318         [ +  - ]:          2 :         for( nPos = 0; nPos < rList.size(); ++nPos )
    5319         [ +  - ]:          2 :             if( &rList[ nPos ] == pItem )
    5320                 :          2 :                 return nPos;
    5321                 :            :     }
    5322                 :          2 :     return TOOLBOX_ITEM_NOTFOUND;
    5323                 :            : }
    5324                 :            : 
    5325                 :          0 : void ToolBox::ChangeHighlight( sal_uInt16 nPos )
    5326                 :            : {
    5327         [ #  # ]:          0 :     if ( nPos < GetItemCount() ) {
    5328                 :          0 :         ImplGrabFocus( 0 );
    5329                 :          0 :         ImplChangeHighlight ( ImplGetItem ( GetItemId ( (sal_uInt16) nPos ) ), sal_False );
    5330                 :            :     }
    5331                 :          0 : }
    5332                 :            : 
    5333                 :          2 : void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, sal_Bool bNoGrabFocus )
    5334                 :            : {
    5335                 :            :     // avoid recursion due to focus change
    5336         [ -  + ]:          2 :     if( mbChangingHighlight )
    5337                 :          2 :         return;
    5338                 :            : 
    5339                 :          2 :     mbChangingHighlight = sal_True;
    5340                 :            : 
    5341                 :          2 :     ImplToolItem* pOldItem = NULL;
    5342                 :            : 
    5343         [ -  + ]:          2 :     if ( mnHighItemId )
    5344                 :            :     {
    5345                 :          0 :         ImplHideFocus();
    5346                 :          0 :         sal_uInt16 nPos = GetItemPos( mnHighItemId );
    5347                 :          0 :         pOldItem = ImplGetItem( mnHighItemId );
    5348                 :            :         // #i89962# ImplDrawItem can cause Invalidate/Update
    5349                 :            :         // which will in turn ImplShowFocus again
    5350                 :            :         // set mnHighItemId to 0 already to prevent this hen/egg problem
    5351                 :          0 :         mnHighItemId = 0;
    5352                 :          0 :         ImplDrawItem( nPos, 0 );
    5353                 :          0 :         ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( nPos ) );
    5354                 :            :     }
    5355                 :            : 
    5356 [ +  - ][ +  - ]:          2 :     if( !bNoGrabFocus && pItem != pOldItem && pOldItem && pOldItem->mpWindow )
         [ -  + ][ #  # ]
    5357                 :            :     {
    5358                 :            :         // move focus into toolbox
    5359                 :          0 :         GrabFocus();
    5360                 :            :     }
    5361                 :            : 
    5362         [ +  - ]:          2 :     if( pItem )
    5363                 :            :     {
    5364                 :          2 :         sal_uInt16 aPos = ToolBox::ImplFindItemPos( pItem, mpData->m_aItems );
    5365         [ +  - ]:          2 :         if( aPos != TOOLBOX_ITEM_NOTFOUND)
    5366                 :            :         {
    5367                 :            :             // check for line breaks
    5368                 :          2 :             sal_uInt16 nLine = ImplGetItemLine( pItem );
    5369                 :            : 
    5370         [ -  + ]:          2 :             if( nLine >= mnCurLine + mnVisLines )
    5371                 :            :             {
    5372                 :          0 :                 mnCurLine = nLine - mnVisLines + 1;
    5373                 :          0 :                 mbFormat = sal_True;
    5374                 :            :             }
    5375         [ -  + ]:          2 :             else if ( nLine < mnCurLine )
    5376                 :            :             {
    5377                 :          0 :                 mnCurLine = nLine;
    5378                 :          0 :                 mbFormat = sal_True;
    5379                 :            :             }
    5380                 :            : 
    5381         [ +  - ]:          2 :             if( mbFormat )
    5382                 :            :             {
    5383                 :          2 :                 ImplFormat();
    5384                 :            :             }
    5385                 :            : 
    5386                 :          2 :             mnHighItemId = pItem->mnId;
    5387                 :          2 :             ImplDrawItem( aPos, 2 );    // always use shadow effect (2)
    5388                 :            : 
    5389         [ -  + ]:          2 :             if( mbSelection )
    5390                 :          0 :                 mnCurPos = aPos;
    5391                 :          2 :             ImplShowFocus();
    5392                 :            : 
    5393                 :          2 :             ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHT );
    5394                 :            :         }
    5395                 :            :     }
    5396                 :            :     else
    5397                 :            :     {
    5398                 :          0 :         ImplHideFocus();
    5399                 :          0 :         mnHighItemId = 0;
    5400                 :          0 :         mnCurPos = TOOLBOX_ITEM_NOTFOUND;
    5401                 :            :     }
    5402                 :            : 
    5403                 :          2 :     mbChangingHighlight = sal_False;
    5404                 :            : }
    5405                 :            : 
    5406                 :            : // -----------------------------------------------------------------------
    5407                 :            : 
    5408                 :            : // check for keyboard accessible items
    5409                 :          2 : static sal_Bool ImplIsValidItem( const ImplToolItem* pItem, sal_Bool bNotClipped )
    5410                 :            : {
    5411 [ +  - ][ +  - ]:          2 :     sal_Bool bValid = (pItem && pItem->meType == TOOLBOXITEM_BUTTON && pItem->mbVisible && !ImplIsFixedControl( pItem ));
         [ +  - ][ +  - ]
    5412 [ +  - ][ -  + ]:          2 :     if( bValid && bNotClipped && pItem->IsClipped() )
         [ #  # ][ -  + ]
    5413                 :          0 :         bValid = sal_False;
    5414                 :          2 :     return bValid;
    5415                 :            : }
    5416                 :            : 
    5417                 :            : // -----------------------------------------------------------------------
    5418                 :            : 
    5419                 :          2 : sal_Bool ToolBox::ImplChangeHighlightUpDn( sal_Bool bUp, sal_Bool bNoCycle )
    5420                 :            : {
    5421                 :          2 :     ImplToolItem* pToolItem = ImplGetItem( mnHighItemId );
    5422                 :            : 
    5423 [ +  - ][ +  - ]:          2 :     if( !pToolItem || !mnHighItemId )
    5424                 :            :     {
    5425                 :            :         // menubutton highlighted ?
    5426         [ -  + ]:          2 :         if( mpData->mbMenubuttonSelected )
    5427                 :            :         {
    5428         [ #  # ]:          0 :             if( bUp )
    5429                 :            :             {
    5430                 :            :                 // select last valid non-clipped item
    5431                 :          0 :                 std::vector< ImplToolItem >::iterator it = mpData->m_aItems.end();
    5432                 :          0 :                 ImplToolItem* pItem = NULL;
    5433 [ #  # ][ #  # ]:          0 :                 while( it != mpData->m_aItems.begin() )
    5434                 :            :                 {
    5435                 :          0 :                     --it;
    5436 [ #  # ][ #  # ]:          0 :                     if ( ImplIsValidItem( &(*it), sal_True ) )
    5437                 :            :                     {
    5438                 :          0 :                         pItem = &(*it);
    5439                 :          0 :                         break;
    5440                 :            :                     }
    5441                 :            :                 }
    5442         [ #  # ]:          0 :                 ImplDrawMenubutton( this, sal_False );
    5443         [ #  # ]:          0 :                 ImplChangeHighlight( pItem );
    5444                 :            :             }
    5445                 :            :             else
    5446                 :            :             {
    5447                 :            :                 // select first valid non-clipped item
    5448                 :          0 :                 std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
    5449 [ #  # ][ #  # ]:          0 :                 while( it != mpData->m_aItems.end() )
    5450                 :            :                 {
    5451 [ #  # ][ #  # ]:          0 :                     if ( ImplIsValidItem( &(*it), sal_True ) )
    5452                 :          0 :                         break;
    5453                 :          0 :                     ++it;
    5454                 :            :                 }
    5455 [ #  # ][ #  # ]:          0 :                 if( it != mpData->m_aItems.end() )
    5456                 :            :                 {
    5457         [ #  # ]:          0 :                     ImplDrawMenubutton( this, sal_False );
    5458         [ #  # ]:          0 :                     ImplChangeHighlight( &(*it) );
    5459                 :            :                 }
    5460                 :            :             }
    5461                 :          0 :             return sal_True;
    5462                 :            :         }
    5463                 :            : 
    5464         [ +  - ]:          2 :         if( bUp )
    5465                 :            :         {
    5466                 :            :             // Select first valid item
    5467                 :          2 :             std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
    5468 [ +  - ][ +  - ]:          2 :             while( it != mpData->m_aItems.end() )
    5469                 :            :             {
    5470 [ +  - ][ +  - ]:          2 :                 if ( ImplIsValidItem( &(*it), sal_False ) )
    5471                 :          2 :                     break;
    5472                 :          0 :                 ++it;
    5473                 :            :             }
    5474                 :            : 
    5475                 :            :             // select the menu button if a clipped item would be selected
    5476 [ +  - ][ +  - ]:          2 :             if( (it != mpData->m_aItems.end() && &(*it) == ImplGetFirstClippedItem( this )) && IsMenuEnabled() )
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
                 [ +  - ]
           [ -  +  #  # ]
    5477                 :            :             {
    5478         [ #  # ]:          0 :                 ImplChangeHighlight( NULL );
    5479         [ #  # ]:          0 :                 ImplDrawMenubutton( this, sal_True );
    5480                 :            :             }
    5481                 :            :             else
    5482 [ +  - ][ +  - ]:          2 :                 ImplChangeHighlight( (it != mpData->m_aItems.end()) ? &(*it) : NULL );
                 [ +  - ]
    5483                 :          2 :             return sal_True;
    5484                 :            :         }
    5485                 :            :         else
    5486                 :            :         {
    5487                 :            :             // Select last valid item
    5488                 :            : 
    5489                 :            :             // docked toolbars have the menubutton as last item - if this button is enabled
    5490 [ #  # ][ #  # ]:          0 :             if( IsMenuEnabled() && !ImplIsFloatingMode() )
                 [ #  # ]
    5491                 :            :             {
    5492                 :          0 :                 ImplChangeHighlight( NULL );
    5493                 :          0 :                 ImplDrawMenubutton( this, sal_True );
    5494                 :            :             }
    5495                 :            :             else
    5496                 :            :             {
    5497                 :          0 :                 std::vector< ImplToolItem >::iterator it = mpData->m_aItems.end();
    5498                 :          0 :                 ImplToolItem* pItem = NULL;
    5499 [ #  # ][ #  # ]:          0 :                 while( it != mpData->m_aItems.begin() )
    5500                 :            :                 {
    5501                 :          0 :                     --it;
    5502 [ #  # ][ #  # ]:          0 :                     if ( ImplIsValidItem( &(*it), sal_False ) )
    5503                 :            :                     {
    5504                 :          0 :                         pItem = &(*it);
    5505                 :          0 :                         break;
    5506                 :            :                     }
    5507                 :            :                 }
    5508         [ #  # ]:          0 :                 ImplChangeHighlight( pItem );
    5509                 :            :             }
    5510                 :          0 :             return sal_True;
    5511                 :            :         }
    5512                 :            :     }
    5513                 :            : 
    5514         [ #  # ]:          0 :     if( pToolItem )
    5515                 :            :     {
    5516                 :          0 :         sal_uLong pos = ToolBox::ImplFindItemPos( pToolItem, mpData->m_aItems );
    5517                 :          0 :         sal_uLong nCount = mpData->m_aItems.size();
    5518                 :            : 
    5519                 :          0 :         sal_uLong i=0;
    5520         [ #  # ]:          0 :         do
    5521                 :            :         {
    5522         [ #  # ]:          0 :             if( bUp )
    5523                 :            :             {
    5524         [ #  # ]:          0 :                 if( !pos-- )
    5525                 :            :                 {
    5526         [ #  # ]:          0 :                     if( bNoCycle )
    5527                 :          0 :                         return sal_False;
    5528                 :            : 
    5529                 :            :                     // highlight the menu button if it is the last item
    5530 [ #  # ][ #  # ]:          0 :                     if( IsMenuEnabled() && !ImplIsFloatingMode() )
                 [ #  # ]
    5531                 :            :                     {
    5532                 :          0 :                         ImplChangeHighlight( NULL );
    5533                 :          0 :                         ImplDrawMenubutton( this, sal_True );
    5534                 :          0 :                         return sal_True;
    5535                 :            :                     }
    5536                 :            :                     else
    5537                 :          0 :                         pos = nCount-1;
    5538                 :            :                 }
    5539                 :            :             }
    5540                 :            :             else
    5541                 :            :             {
    5542         [ #  # ]:          0 :                 if( ++pos >= nCount )
    5543                 :            :                 {
    5544         [ #  # ]:          0 :                     if( bNoCycle )
    5545                 :          0 :                         return sal_False;
    5546                 :            : 
    5547                 :            :                     // highlight the menu button if it is the last item
    5548 [ #  # ][ #  # ]:          0 :                     if( IsMenuEnabled() && !ImplIsFloatingMode() )
                 [ #  # ]
    5549                 :            :                     {
    5550                 :          0 :                         ImplChangeHighlight( NULL );
    5551                 :          0 :                         ImplDrawMenubutton( this, sal_True );
    5552                 :          0 :                         return sal_True;
    5553                 :            :                     }
    5554                 :            :                     else
    5555                 :          0 :                         pos = 0;
    5556                 :            :                 }
    5557                 :            :             }
    5558                 :            : 
    5559                 :          0 :             pToolItem = &mpData->m_aItems[pos];
    5560                 :            : 
    5561         [ #  # ]:          0 :             if ( ImplIsValidItem( pToolItem, sal_False ) )
    5562                 :          0 :                 break;
    5563                 :            : 
    5564                 :            :         } while( ++i < nCount);
    5565                 :            : 
    5566 [ #  # ][ #  # ]:          0 :         if( pToolItem->IsClipped() && IsMenuEnabled() )
                 [ #  # ]
    5567                 :            :         {
    5568                 :            :             // select the menu button if a clipped item would be selected
    5569                 :          0 :             ImplChangeHighlight( NULL );
    5570                 :          0 :             ImplDrawMenubutton( this, sal_True );
    5571                 :            :         }
    5572         [ #  # ]:          0 :         else if( i != nCount )
    5573                 :          0 :             ImplChangeHighlight( pToolItem );
    5574                 :            :         else
    5575                 :          0 :             return sal_False;
    5576                 :            :     }
    5577                 :          2 :     return sal_True;
    5578                 :            : }
    5579                 :            : 
    5580                 :            : // -----------------------------------------------------------------------
    5581                 :            : 
    5582                 :      10778 : void ToolBox::ImplShowFocus()
    5583                 :            : {
    5584 [ +  + ][ +  - ]:      10778 :     if( mnHighItemId && HasFocus() )
                 [ +  + ]
    5585                 :            :     {
    5586                 :          2 :         ImplToolItem* pItem = ImplGetItem( mnHighItemId );
    5587         [ -  + ]:          2 :         if( pItem->mpWindow )
    5588                 :            :         {
    5589         [ #  # ]:          0 :             Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow : pItem->mpWindow;
    5590                 :          0 :             pWin->ImplGetWindowImpl()->mbDrawSelectionBackground = sal_True;
    5591                 :          0 :             pWin->Invalidate( 0 );
    5592                 :            :         }
    5593                 :            :     }
    5594                 :      10778 : }
    5595                 :            : 
    5596                 :            : // -----------------------------------------------------------------------
    5597                 :            : 
    5598                 :          4 : void ToolBox::ImplHideFocus()
    5599                 :            : {
    5600         [ +  + ]:          4 :     if( mnHighItemId )
    5601                 :            :     {
    5602                 :          2 :         ImplToolItem* pItem = ImplGetItem( mnHighItemId );
    5603         [ -  + ]:          2 :         if( pItem->mpWindow )
    5604                 :            :         {
    5605         [ #  # ]:          0 :             Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow : pItem->mpWindow;
    5606                 :          0 :             pWin->ImplGetWindowImpl()->mbDrawSelectionBackground = sal_False;
    5607                 :          0 :             pWin->Invalidate( 0 );
    5608                 :            :         }
    5609                 :            :     }
    5610                 :            : 
    5611         [ -  + ]:          4 :     if ( mpData->mbMenubuttonSelected )
    5612                 :            :     {
    5613                 :            :         // remove highlight from menubutton
    5614                 :          0 :         ImplDrawMenubutton( this, sal_False );
    5615                 :            :     }
    5616                 :          4 : }
    5617                 :            : 
    5618                 :            : // -----------------------------------------------------------------------
    5619                 :            : 
    5620                 :     151210 : void ToolBox::ImplDisableFlatButtons()
    5621                 :            : {
    5622                 :            : #ifdef WNT        // Check in the Windows registry if an AT tool wants no flat toolboxes
    5623                 :            :     static bool bInit = false, bValue = false;
    5624                 :            :     if( ! bInit )
    5625                 :            :     {
    5626                 :            :         bInit = true;
    5627                 :            :         HKEY hkey;
    5628                 :            : 
    5629                 :            :         if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
    5630                 :            :             "Software\\LibreOffice\\Accessibility\\AtToolSupport",
    5631                 :            :             &hkey) )
    5632                 :            :         {
    5633                 :            :             DWORD dwType = 0;
    5634                 :            :             sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD
    5635                 :            :             DWORD cbData = sizeof(Data);
    5636                 :            : 
    5637                 :            :             if( ERROR_SUCCESS == RegQueryValueEx(hkey, "DisableFlatToolboxButtons",
    5638                 :            :                 NULL, &dwType, Data, &cbData) )
    5639                 :            :             {
    5640                 :            :                 switch (dwType)
    5641                 :            :                 {
    5642                 :            :                     case REG_SZ:
    5643                 :            :                         bValue = ((0 == stricmp((const char *) Data, "1")) || (0 == stricmp((const char *) Data, "true")));
    5644                 :            :                         break;
    5645                 :            :                     case REG_DWORD:
    5646                 :            :                         bValue = (bool)(((DWORD *) Data)[0]);
    5647                 :            :                         break;
    5648                 :            :                 }
    5649                 :            :             }
    5650                 :            :             RegCloseKey(hkey);
    5651                 :            :         }
    5652                 :            :     }
    5653                 :            :     if( bValue )
    5654                 :            :         mnOutStyle &= ~TOOLBOX_STYLE_FLAT;
    5655                 :            : #endif
    5656                 :     151210 : }
    5657                 :            : 
    5658                 :          0 : void ToolBox::SetToolbarLayoutMode( ToolBoxLayoutMode eLayout )
    5659                 :            : {
    5660         [ #  # ]:          0 :     if ( meLayoutMode != eLayout )
    5661                 :          0 :        meLayoutMode  = eLayout;
    5662                 :          0 : }
    5663                 :            : 
    5664                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10