LCOV - code coverage report
Current view: top level - svtools/source/contnr - imivctl1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2147 0.0 %
Date: 2012-08-25 Functions: 0 151 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2686 0.0 %

           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 <limits.h>
      31                 :            : #include <tools/debug.hxx>
      32                 :            : #include <vcl/wall.hxx>
      33                 :            : #include <vcl/help.hxx>
      34                 :            : #include <vcl/decoview.hxx>
      35                 :            : #include <vcl/svapp.hxx>
      36                 :            : #include <tools/poly.hxx>
      37                 :            : #include <vcl/lineinfo.hxx>
      38                 :            : #include <vcl/i18nhelp.hxx>
      39                 :            : #include <vcl/mnemonic.hxx>
      40                 :            : #include <vcl/controllayout.hxx>
      41                 :            : 
      42                 :            : #include <svtools/ivctrl.hxx>
      43                 :            : #include "imivctl.hxx"
      44                 :            : #include <svtools/svmedit.hxx>
      45                 :            : 
      46                 :            : #include <algorithm>
      47                 :            : #include <memory>
      48                 :            : 
      49                 :            : #define IMPICNVIEW_ACC_RETURN 1
      50                 :            : #define IMPICNVIEW_ACC_ESCAPE 2
      51                 :            : 
      52                 :            : #define DRAWTEXT_FLAGS_ICON \
      53                 :            :     ( TEXT_DRAW_CENTER | TEXT_DRAW_TOP | TEXT_DRAW_ENDELLIPSIS | \
      54                 :            :       TEXT_DRAW_CLIP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MNEMONIC )
      55                 :            : 
      56                 :            : #define DRAWTEXT_FLAGS_SMALLICON (TEXT_DRAW_LEFT|TEXT_DRAW_ENDELLIPSIS|TEXT_DRAW_CLIP)
      57                 :            : 
      58                 :            : #define EVENTID_SHOW_CURSOR             ((void*)1)
      59                 :            : #define EVENTID_ADJUST_SCROLLBARS       ((void*)2)
      60                 :            : 
      61                 :            : struct SvxIconChoiceCtrlEntry_Impl
      62                 :            : {
      63                 :            :     SvxIconChoiceCtrlEntry* _pEntry;
      64                 :            :     Point           _aPos;
      65                 :            :                     SvxIconChoiceCtrlEntry_Impl( SvxIconChoiceCtrlEntry* pEntry, const Rectangle& rBoundRect )
      66                 :            :                     : _pEntry( pEntry), _aPos( rBoundRect.TopLeft()) {}
      67                 :            : };
      68                 :            : 
      69                 :            : static sal_Bool bEndScrollInvalidate = sal_True;
      70                 :            : 
      71                 :            : class IcnViewEdit_Impl : public MultiLineEdit
      72                 :            : {
      73                 :            :     Link            aCallBackHdl;
      74                 :            :     Accelerator     aAccReturn;
      75                 :            :     Accelerator     aAccEscape;
      76                 :            :     Timer           aTimer;
      77                 :            :     sal_Bool            bCanceled;
      78                 :            :     sal_Bool            bAlreadyInCallback;
      79                 :            :     sal_Bool            bGrabFocus;
      80                 :            : 
      81                 :            :     void            CallCallBackHdl_Impl();
      82                 :            :                     DECL_LINK(Timeout_Impl, void *);
      83                 :            :                     DECL_LINK( ReturnHdl_Impl, Accelerator * );
      84                 :            :                     DECL_LINK( EscapeHdl_Impl, Accelerator * );
      85                 :            : 
      86                 :            : public:
      87                 :            : 
      88                 :            :                     IcnViewEdit_Impl(
      89                 :            :                         SvtIconChoiceCtrl* pParent,
      90                 :            :                         const Point& rPos,
      91                 :            :                         const Size& rSize,
      92                 :            :                         const XubString& rData,
      93                 :            :                         const Link& rNotifyEditEnd );
      94                 :            : 
      95                 :            :                     ~IcnViewEdit_Impl();
      96                 :            :     virtual void    KeyInput( const KeyEvent& rKEvt );
      97                 :            :     virtual long    PreNotify( NotifyEvent& rNEvt );
      98                 :          0 :     sal_Bool            EditingCanceled() const { return bCanceled; }
      99                 :            :     void            StopEditing( sal_Bool bCancel = sal_False );
     100                 :          0 :     sal_Bool            IsGrabFocus() const { return bGrabFocus; }
     101                 :            : };
     102                 :            : 
     103                 :          0 : SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl(
     104                 :            :     SvtIconChoiceCtrl* pCurView,
     105                 :            :     WinBits nWinStyle
     106                 :            : ) :
     107                 :            :     aEntries( this ),
     108                 :            :     aVerSBar( pCurView, WB_DRAG | WB_VSCROLL ),
     109                 :            :     aHorSBar( pCurView, WB_DRAG | WB_HSCROLL ),
     110                 :            :     aScrBarBox( pCurView ),
     111                 :            :     aImageSize( 32, 32 ),
     112 [ #  # ][ #  # ]:          0 :     pColumns( 0 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     113                 :            : {
     114                 :          0 :     bChooseWithCursor=sal_False;
     115                 :          0 :     pEntryPaintDev = 0;
     116                 :          0 :     pCurEditedEntry = 0;
     117                 :          0 :     pCurHighlightFrame = 0;
     118                 :          0 :     pEdit = 0;
     119                 :          0 :     pAnchor = 0;
     120                 :          0 :     pPrevDropTarget = 0;
     121                 :          0 :     pHdlEntry = 0;
     122                 :          0 :     pHead = NULL;
     123                 :          0 :     pCursor = NULL;
     124                 :          0 :     bUpdateMode = sal_True;
     125                 :          0 :     bEntryEditingEnabled = sal_False;
     126                 :          0 :     bHighlightFramePressed = sal_False;
     127                 :          0 :     eSelectionMode = MULTIPLE_SELECTION;
     128                 :          0 :     pView = pCurView;
     129 [ #  # ][ #  # ]:          0 :     pZOrderList = new SvxIconChoiceCtrlEntryList_impl();
     130                 :          0 :     ePositionMode = IcnViewPositionModeFree;
     131         [ #  # ]:          0 :     SetStyle( nWinStyle );
     132                 :          0 :     nFlags = 0;
     133                 :          0 :     nUserEventAdjustScrBars = 0;
     134                 :          0 :     nUserEventShowCursor = 0;
     135                 :          0 :     nMaxVirtWidth = DEFAULT_MAX_VIRT_WIDTH;
     136                 :          0 :     nMaxVirtHeight = DEFAULT_MAX_VIRT_HEIGHT;
     137                 :          0 :     pDDRefEntry = 0;
     138                 :          0 :     pDDDev = 0;
     139                 :          0 :     pDDBufDev = 0;
     140                 :          0 :     pDDTempDev = 0;
     141                 :          0 :     eTextMode = IcnShowTextShort;
     142 [ #  # ][ #  # ]:          0 :     pImpCursor = new IcnCursor_Impl( this );
     143 [ #  # ][ #  # ]:          0 :     pGridMap = new IcnGridMap_Impl( this );
     144                 :            : 
     145         [ #  # ]:          0 :     aVerSBar.SetScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, ScrollUpDownHdl ) );
     146         [ #  # ]:          0 :     aHorSBar.SetScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, ScrollLeftRightHdl ) );
     147         [ #  # ]:          0 :     Link aEndScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, EndScrollHdl ) );
     148                 :          0 :     aVerSBar.SetEndScrollHdl( aEndScrollHdl );
     149                 :          0 :     aHorSBar.SetEndScrollHdl( aEndScrollHdl );
     150                 :            : 
     151         [ #  # ]:          0 :     nHorSBarHeight = aHorSBar.GetSizePixel().Height();
     152         [ #  # ]:          0 :     nVerSBarWidth = aVerSBar.GetSizePixel().Width();
     153                 :            : 
     154         [ #  # ]:          0 :     aEditTimer.SetTimeout( 800 );
     155         [ #  # ]:          0 :     aEditTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,EditTimeoutHdl));
     156         [ #  # ]:          0 :     aAutoArrangeTimer.SetTimeout( 100 );
     157         [ #  # ]:          0 :     aAutoArrangeTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,AutoArrangeHdl));
     158         [ #  # ]:          0 :     aCallSelectHdlTimer.SetTimeout( 500 );
     159         [ #  # ]:          0 :     aCallSelectHdlTimer.SetTimeoutHdl( LINK(this,SvxIconChoiceCtrl_Impl,CallSelectHdlHdl));
     160                 :            : 
     161         [ #  # ]:          0 :     aDocRectChangedTimer.SetTimeout( 50 );
     162         [ #  # ]:          0 :     aDocRectChangedTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,DocRectChangedHdl));
     163         [ #  # ]:          0 :     aVisRectChangedTimer.SetTimeout( 50 );
     164         [ #  # ]:          0 :     aVisRectChangedTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,VisRectChangedHdl));
     165                 :            : 
     166         [ #  # ]:          0 :     Clear( sal_True );
     167                 :            : 
     168         [ #  # ]:          0 :     SetGrid( Size(100, 70) );
     169                 :          0 : }
     170                 :            : 
     171 [ #  # ][ #  # ]:          0 : SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     172                 :            : {
     173                 :          0 :     pCurEditedEntry = 0;
     174 [ #  # ][ #  # ]:          0 :     DELETEZ(pEdit);
     175         [ #  # ]:          0 :     Clear();
     176         [ #  # ]:          0 :     StopEditTimer();
     177         [ #  # ]:          0 :     CancelUserEvents();
     178         [ #  # ]:          0 :     delete pZOrderList;
     179 [ #  # ][ #  # ]:          0 :     delete pImpCursor;
     180 [ #  # ][ #  # ]:          0 :     delete pGridMap;
     181 [ #  # ][ #  # ]:          0 :     delete pDDDev;
     182 [ #  # ][ #  # ]:          0 :     delete pDDBufDev;
     183 [ #  # ][ #  # ]:          0 :     delete pDDTempDev;
     184 [ #  # ][ #  # ]:          0 :     delete pEntryPaintDev;
     185         [ #  # ]:          0 :     ClearSelectedRectList();
     186         [ #  # ]:          0 :     ClearColumnList();
     187                 :          0 : }
     188                 :            : 
     189                 :          0 : void SvxIconChoiceCtrl_Impl::Clear( sal_Bool bInCtor )
     190                 :            : {
     191                 :          0 :     StopEntryEditing( sal_True );
     192                 :          0 :     nSelectionCount = 0;
     193                 :          0 :     pCurHighlightFrame = 0;
     194                 :          0 :     StopEditTimer();
     195                 :          0 :     CancelUserEvents();
     196                 :          0 :     ShowCursor( sal_False );
     197                 :          0 :     bBoundRectsDirty = sal_False;
     198                 :          0 :     nMaxBoundHeight = 0;
     199                 :            : 
     200                 :          0 :     nFlags &= ~(F_PAINTED | F_MOVED_ENTRIES);
     201                 :          0 :     pCursor = 0;
     202         [ #  # ]:          0 :     if( !bInCtor )
     203                 :            :     {
     204         [ #  # ]:          0 :         pImpCursor->Clear();
     205         [ #  # ]:          0 :         pGridMap->Clear();
     206                 :          0 :         aVirtOutputSize.Width() = 0;
     207                 :          0 :         aVirtOutputSize.Height() = 0;
     208                 :          0 :         Size aSize( pView->GetOutputSizePixel() );
     209                 :          0 :         nMaxVirtWidth = aSize.Width() - nVerSBarWidth;
     210         [ #  # ]:          0 :         if( nMaxVirtWidth <= 0 )
     211                 :          0 :             nMaxVirtWidth = DEFAULT_MAX_VIRT_WIDTH;
     212                 :          0 :         nMaxVirtHeight = aSize.Height() - nHorSBarHeight;
     213         [ #  # ]:          0 :         if( nMaxVirtHeight <= 0 )
     214                 :          0 :             nMaxVirtHeight = DEFAULT_MAX_VIRT_HEIGHT;
     215                 :          0 :         pZOrderList->clear();
     216         [ #  # ]:          0 :         SetOrigin( Point() );
     217         [ #  # ]:          0 :         if( bUpdateMode )
     218         [ #  # ]:          0 :             pView->Invalidate(INVALIDATE_NOCHILDREN);
     219                 :            :     }
     220                 :          0 :     AdjustScrollBars();
     221                 :          0 :     size_t nCount = aEntries.size();
     222         [ #  # ]:          0 :     for( size_t nCur = 0; nCur < nCount; nCur++ )
     223                 :            :     {
     224                 :          0 :         SvxIconChoiceCtrlEntry* pCur = aEntries[ nCur ];
     225         [ #  # ]:          0 :         delete pCur;
     226                 :            :     }
     227                 :          0 :     aEntries.clear();
     228                 :          0 :     DocRectChanged();
     229                 :          0 :     VisRectChanged();
     230                 :          0 : }
     231                 :            : 
     232                 :          0 : void SvxIconChoiceCtrl_Impl::SetStyle( WinBits nWinStyle )
     233                 :            : {
     234                 :          0 :     nWinBits = nWinStyle;
     235                 :          0 :     nCurTextDrawFlags = DRAWTEXT_FLAGS_ICON;
     236         [ #  # ]:          0 :     if( nWinBits & (WB_SMALLICON | WB_DETAILS) )
     237                 :          0 :         nCurTextDrawFlags = DRAWTEXT_FLAGS_SMALLICON;
     238         [ #  # ]:          0 :     if( nWinBits & WB_NOSELECTION )
     239                 :          0 :         eSelectionMode = NO_SELECTION;
     240         [ #  # ]:          0 :     if( !(nWinStyle & (WB_ALIGN_TOP | WB_ALIGN_LEFT)))
     241                 :          0 :         nWinBits |= WB_ALIGN_LEFT;
     242         [ #  # ]:          0 :     if( (nWinStyle & WB_DETAILS))
     243                 :            :     {
     244         [ #  # ]:          0 :         if( !pColumns  )
     245         [ #  # ]:          0 :             SetColumn( 0, SvxIconChoiceCtrlColumnInfo( 0, 100, IcnViewAlignLeft ));
     246                 :            :     }
     247                 :          0 : }
     248                 :            : 
     249                 :          0 : IMPL_LINK( SvxIconChoiceCtrl_Impl, ScrollUpDownHdl, ScrollBar*, pScrollBar )
     250                 :            : {
     251                 :          0 :     StopEntryEditing( sal_True );
     252                 :            :     // arrow up: delta=-1; arrow down: delta=+1
     253                 :          0 :     Scroll( 0, pScrollBar->GetDelta(), sal_True );
     254                 :          0 :     bEndScrollInvalidate = sal_True;
     255                 :          0 :     return 0;
     256                 :            : }
     257                 :            : 
     258                 :          0 : IMPL_LINK( SvxIconChoiceCtrl_Impl, ScrollLeftRightHdl, ScrollBar*, pScrollBar )
     259                 :            : {
     260                 :          0 :     StopEntryEditing( sal_True );
     261                 :            :     // arrow left: delta=-1; arrow right: delta=+1
     262                 :          0 :     Scroll( pScrollBar->GetDelta(), 0, sal_True );
     263                 :          0 :     bEndScrollInvalidate = sal_True;
     264                 :          0 :     return 0;
     265                 :            : }
     266                 :            : 
     267                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, EndScrollHdl)
     268                 :            : {
     269 [ #  # ][ #  # ]:          0 :     if( pView->HasBackground() && !pView->GetBackground().IsScrollable() &&
         [ #  # ][ #  # ]
     270                 :            :         bEndScrollInvalidate )
     271                 :            :     {
     272                 :          0 :         pView->Invalidate(INVALIDATE_NOCHILDREN);
     273                 :            :     }
     274                 :          0 :     return 0;
     275                 :            : }
     276                 :            : 
     277                 :          0 : void SvxIconChoiceCtrl_Impl::FontModified()
     278                 :            : {
     279                 :          0 :     StopEditTimer();
     280         [ #  # ]:          0 :     DELETEZ(pDDDev);
     281         [ #  # ]:          0 :     DELETEZ(pDDBufDev);
     282         [ #  # ]:          0 :     DELETEZ(pDDTempDev);
     283         [ #  # ]:          0 :     DELETEZ(pEntryPaintDev);
     284                 :          0 :     SetDefaultTextSize();
     285                 :          0 :     ShowCursor( sal_False );
     286                 :          0 :     ShowCursor( sal_True );
     287                 :          0 : }
     288                 :            : 
     289                 :          0 : void SvxIconChoiceCtrl_Impl::InsertEntry( SvxIconChoiceCtrlEntry* pEntry, size_t nPos,
     290                 :            :     const Point* pPos )
     291                 :            : {
     292                 :          0 :     StopEditTimer();
     293                 :          0 :     aEntries.insert( nPos, pEntry );
     294 [ #  # ][ #  # ]:          0 :     if( (nFlags & F_ENTRYLISTPOS_VALID) && nPos >= aEntries.size() - 1 )
                 [ #  # ]
     295                 :          0 :         pEntry->nPos = aEntries.size() - 1;
     296                 :            :     else
     297                 :          0 :         nFlags &= ~F_ENTRYLISTPOS_VALID;
     298                 :            : 
     299                 :          0 :     pZOrderList->push_back( pEntry );
     300                 :          0 :     pImpCursor->Clear();
     301         [ #  # ]:          0 :     if( pPos )
     302                 :            :     {
     303         [ #  # ]:          0 :         Size aSize( CalcBoundingSize( pEntry ) );
     304         [ #  # ]:          0 :         SetBoundingRect_Impl( pEntry, *pPos, aSize );
     305         [ #  # ]:          0 :         SetEntryPos( pEntry, *pPos, sal_False, sal_True, sal_True /*keep grid map*/ );
     306                 :          0 :         pEntry->nFlags |= ICNVIEW_FLAG_POS_MOVED;
     307                 :          0 :         SetEntriesMoved( sal_True );
     308                 :            :     }
     309                 :            :     else
     310                 :            :     {
     311                 :            :         // If the UpdateMode is sal_True, don't set all bounding rectangles to
     312                 :            :         // 'to be checked', but only the bounding rectangle of the new entry.
     313                 :            :         // Thus, don't call InvalidateBoundingRect!
     314                 :          0 :         pEntry->aRect.Right() = LONG_MAX;
     315         [ #  # ]:          0 :         if( bUpdateMode )
     316                 :            :         {
     317         [ #  # ]:          0 :             FindBoundingRect( pEntry );
     318         [ #  # ]:          0 :             Rectangle aOutputArea( GetOutputRect() );
     319         [ #  # ]:          0 :             pGridMap->OccupyGrids( pEntry );
     320 [ #  # ][ #  # ]:          0 :             if( !aOutputArea.IsOver( pEntry->aRect ) )
     321                 :          0 :                 return; // is invisible
     322         [ #  # ]:          0 :             pView->Invalidate( pEntry->aRect );
     323                 :            :         }
     324                 :            :         else
     325                 :          0 :             InvalidateBoundingRect( pEntry->aRect );
     326                 :            :     }
     327                 :            : }
     328                 :            : 
     329                 :          0 : void SvxIconChoiceCtrl_Impl::CreateAutoMnemonics( MnemonicGenerator* _pGenerator )
     330                 :            : {
     331                 :          0 :     ::std::auto_ptr< MnemonicGenerator > pAutoDeleteOwnGenerator;
     332         [ #  # ]:          0 :     if ( !_pGenerator )
     333                 :            :     {
     334 [ #  # ][ #  # ]:          0 :         _pGenerator = new MnemonicGenerator;
     335                 :          0 :         pAutoDeleteOwnGenerator.reset( _pGenerator );
     336                 :            :     }
     337                 :            : 
     338                 :          0 :     sal_uLong   nEntryCount = GetEntryCount();
     339                 :            :     sal_uLong   i;
     340                 :            : 
     341                 :            :     // insert texts in generator
     342         [ #  # ]:          0 :     for( i = 0; i < nEntryCount; ++i )
     343                 :            :     {
     344                 :            :         DBG_ASSERT( GetEntry( i ), "-SvxIconChoiceCtrl_Impl::CreateAutoMnemonics(): more expected than provided!" );
     345                 :            : 
     346 [ #  # ][ #  # ]:          0 :         _pGenerator->RegisterMnemonic( GetEntry( i )->GetText() );
         [ #  # ][ #  # ]
     347                 :            :     }
     348                 :            : 
     349                 :            :     // exchange texts with generated mnemonics
     350         [ #  # ]:          0 :     for( i = 0; i < nEntryCount; ++i )
     351                 :            :     {
     352         [ #  # ]:          0 :         SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
     353         [ #  # ]:          0 :         String                  aTxt = pEntry->GetText();
     354                 :            : 
     355 [ #  # ][ #  # ]:          0 :         if( _pGenerator->CreateMnemonic( aTxt ) )
     356         [ #  # ]:          0 :             pEntry->SetText( aTxt );
     357 [ #  # ][ #  # ]:          0 :     }
     358                 :          0 : }
     359                 :            : 
     360                 :          0 : Rectangle SvxIconChoiceCtrl_Impl::GetOutputRect() const
     361                 :            : {
     362                 :          0 :     Point aOrigin( pView->GetMapMode().GetOrigin() );
     363                 :          0 :     aOrigin *= -1;
     364         [ #  # ]:          0 :     return Rectangle( aOrigin, aOutputSize );
     365                 :            : }
     366                 :            : 
     367                 :          0 : void SvxIconChoiceCtrl_Impl::SetListPositions()
     368                 :            : {
     369         [ #  # ]:          0 :     if( nFlags & F_ENTRYLISTPOS_VALID )
     370                 :          0 :         return;
     371                 :            : 
     372                 :          0 :     size_t nCount = aEntries.size();
     373         [ #  # ]:          0 :     for( size_t nCur = 0; nCur < nCount; nCur++ )
     374                 :            :     {
     375                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = aEntries[ nCur ];
     376                 :          0 :         pEntry->nPos = nCur;
     377                 :            :     }
     378                 :          0 :     nFlags |= F_ENTRYLISTPOS_VALID;
     379                 :            : }
     380                 :            : 
     381                 :          0 : void SvxIconChoiceCtrl_Impl::SelectEntry( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSelect,
     382                 :            :     sal_Bool bCallHdl, sal_Bool bAdd, sal_Bool bSyncPaint )
     383                 :            : {
     384         [ #  # ]:          0 :     if( eSelectionMode == NO_SELECTION )
     385                 :          0 :         return;
     386                 :            : 
     387         [ #  # ]:          0 :     if( !bAdd )
     388                 :            :     {
     389         [ #  # ]:          0 :         if ( 0 == ( nFlags & F_CLEARING_SELECTION ) )
     390                 :            :         {
     391                 :          0 :             nFlags |= F_CLEARING_SELECTION;
     392                 :          0 :             DeselectAllBut( pEntry, sal_True );
     393                 :          0 :             nFlags &= ~F_CLEARING_SELECTION;
     394                 :            :         }
     395                 :            :     }
     396         [ #  # ]:          0 :     if( pEntry->IsSelected() != bSelect )
     397                 :            :     {
     398                 :          0 :         pHdlEntry = pEntry;
     399                 :          0 :         sal_uInt16 nEntryFlags = pEntry->GetFlags();
     400         [ #  # ]:          0 :         if( bSelect )
     401                 :            :         {
     402                 :          0 :             nEntryFlags |= ICNVIEW_FLAG_SELECTED;
     403                 :          0 :             pEntry->AssignFlags( nEntryFlags );
     404                 :          0 :             nSelectionCount++;
     405         [ #  # ]:          0 :             if( bCallHdl )
     406                 :          0 :                 CallSelectHandler( pEntry );
     407                 :            :         }
     408                 :            :         else
     409                 :            :         {
     410                 :          0 :             nEntryFlags &= ~( ICNVIEW_FLAG_SELECTED);
     411                 :          0 :             pEntry->AssignFlags( nEntryFlags );
     412                 :          0 :             nSelectionCount--;
     413         [ #  # ]:          0 :             if( bCallHdl )
     414                 :          0 :                 CallSelectHandler( 0 );
     415                 :            :         }
     416                 :          0 :         EntrySelected( pEntry, bSelect, bSyncPaint );
     417                 :            :     }
     418                 :            : }
     419                 :            : 
     420                 :          0 : void SvxIconChoiceCtrl_Impl::EntrySelected( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSelect,
     421                 :            :     sal_Bool bSyncPaint )
     422                 :            : {
     423                 :            :     // When using SingleSelection, make sure that the cursor is always placed
     424                 :            :     // over the (only) selected entry. (But only if a cursor exists.)
     425 [ #  # ][ #  # ]:          0 :     if( bSelect && pCursor &&
         [ #  # ][ #  # ]
     426                 :            :         eSelectionMode == SINGLE_SELECTION &&
     427                 :            :         pEntry != pCursor )
     428                 :            :     {
     429                 :          0 :         SetCursor( pEntry );
     430                 :            :         //DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?")
     431                 :            :     }
     432                 :            : 
     433                 :            :     // Not when dragging though, else the loop in SelectRect doesn't work
     434                 :            :     // correctly!
     435         [ #  # ]:          0 :     if( !(nFlags & F_SELECTING_RECT) )
     436                 :          0 :         ToTop( pEntry );
     437         [ #  # ]:          0 :     if( bUpdateMode )
     438                 :            :     {
     439         [ #  # ]:          0 :         if( pEntry == pCursor )
     440                 :          0 :             ShowCursor( sal_False );
     441 [ #  # ][ #  # ]:          0 :         if( pView->IsTracking() && (bSelect || !pView->HasBackground()) ) // always synchronous when tracking
         [ #  # ][ #  # ]
     442                 :          0 :             PaintEntry( pEntry );
     443         [ #  # ]:          0 :         else if( bSyncPaint ) // synchronous & with a virtual OutDev!
     444                 :          0 :             PaintEntryVirtOutDev( pEntry );
     445                 :            :         else
     446                 :            :         {
     447         [ #  # ]:          0 :             pView->Invalidate( CalcFocusRect( pEntry ) );
     448                 :            :         }
     449         [ #  # ]:          0 :         if( pEntry == pCursor )
     450                 :          0 :             ShowCursor( sal_True );
     451                 :            :     }
     452                 :            : 
     453                 :            :     // #i101012# emit vcl event LISTBOX_SELECT only in case that the given entry is selected.
     454         [ #  # ]:          0 :     if ( bSelect )
     455                 :            :     {
     456                 :          0 :         CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
     457                 :            :     }
     458                 :          0 : }
     459                 :            : 
     460                 :          0 : void SvxIconChoiceCtrl_Impl::ResetVirtSize()
     461                 :            : {
     462                 :          0 :     StopEditTimer();
     463                 :          0 :     aVirtOutputSize.Width() = 0;
     464                 :          0 :     aVirtOutputSize.Height() = 0;
     465                 :          0 :     const size_t nCount = aEntries.size();
     466         [ #  # ]:          0 :     for( size_t nCur = 0; nCur < nCount; nCur++ )
     467                 :            :     {
     468                 :          0 :         SvxIconChoiceCtrlEntry* pCur = aEntries[ nCur ];
     469                 :          0 :         pCur->ClearFlags( ICNVIEW_FLAG_POS_MOVED );
     470         [ #  # ]:          0 :         if( pCur->IsPosLocked() )
     471                 :            :         {
     472                 :            :             // adapt (among others) VirtSize
     473         [ #  # ]:          0 :             if( !IsBoundingRectValid( pCur->aRect ) )
     474                 :          0 :                 FindBoundingRect( pCur );
     475                 :            :             else
     476                 :          0 :                 AdjustVirtSize( pCur->aRect );
     477                 :            :         }
     478                 :            :         else
     479                 :          0 :             InvalidateBoundingRect( pCur->aRect );
     480                 :            :     }
     481                 :            : 
     482         [ #  # ]:          0 :     if( !(nWinBits & (WB_NOVSCROLL | WB_NOHSCROLL)) )
     483                 :            :     {
     484                 :          0 :         Size aRealOutputSize( pView->GetOutputSizePixel() );
     485         [ #  # ]:          0 :         if( aVirtOutputSize.Width() < aRealOutputSize.Width() ||
           [ #  #  #  # ]
     486                 :          0 :             aVirtOutputSize.Height() < aRealOutputSize.Height() )
     487                 :            :         {
     488                 :            :             sal_uLong nGridCount = IcnGridMap_Impl::GetGridCount(
     489         [ #  # ]:          0 :                 aRealOutputSize, (sal_uInt16)nGridDX, (sal_uInt16)nGridDY );
     490         [ #  # ]:          0 :             if( nGridCount < nCount )
     491                 :            :             {
     492         [ #  # ]:          0 :                 if( nWinBits & WB_ALIGN_TOP )
     493                 :          0 :                     nMaxVirtWidth = aRealOutputSize.Width() - nVerSBarWidth;
     494                 :            :                 else // WB_ALIGN_LEFT
     495                 :          0 :                     nMaxVirtHeight = aRealOutputSize.Height() - nHorSBarHeight;
     496                 :            :             }
     497                 :            :         }
     498                 :            :     }
     499                 :            : 
     500                 :          0 :     pImpCursor->Clear();
     501                 :          0 :     pGridMap->Clear();
     502                 :          0 :     VisRectChanged();
     503                 :          0 : }
     504                 :            : 
     505                 :          0 : void SvxIconChoiceCtrl_Impl::AdjustVirtSize( const Rectangle& rRect )
     506                 :            : {
     507                 :          0 :     long nHeightOffs = 0;
     508                 :          0 :     long nWidthOffs = 0;
     509                 :            : 
     510         [ #  # ]:          0 :     if( aVirtOutputSize.Width() < (rRect.Right()+LROFFS_WINBORDER) )
     511                 :          0 :         nWidthOffs = (rRect.Right()+LROFFS_WINBORDER) - aVirtOutputSize.Width();
     512                 :            : 
     513         [ #  # ]:          0 :     if( aVirtOutputSize.Height() < (rRect.Bottom()+TBOFFS_WINBORDER) )
     514                 :          0 :         nHeightOffs = (rRect.Bottom()+TBOFFS_WINBORDER) - aVirtOutputSize.Height();
     515                 :            : 
     516 [ #  # ][ #  # ]:          0 :     if( nWidthOffs || nHeightOffs )
     517                 :            :     {
     518                 :          0 :         Range aRange;
     519                 :          0 :         aVirtOutputSize.Width() += nWidthOffs;
     520                 :          0 :         aRange.Max() = aVirtOutputSize.Width();
     521         [ #  # ]:          0 :         aHorSBar.SetRange( aRange );
     522                 :            : 
     523                 :          0 :         aVirtOutputSize.Height() += nHeightOffs;
     524                 :          0 :         aRange.Max() = aVirtOutputSize.Height();
     525         [ #  # ]:          0 :         aVerSBar.SetRange( aRange );
     526                 :            : 
     527         [ #  # ]:          0 :         pImpCursor->Clear();
     528         [ #  # ]:          0 :         pGridMap->OutputSizeChanged();
     529         [ #  # ]:          0 :         AdjustScrollBars();
     530         [ #  # ]:          0 :         DocRectChanged();
     531                 :            :     }
     532                 :          0 : }
     533                 :            : 
     534                 :          0 : void SvxIconChoiceCtrl_Impl::InitPredecessors()
     535                 :            : {
     536                 :            :     DBG_ASSERT(!pHead,"SvxIconChoiceCtrl_Impl::InitPredecessors() >> Already initialized");
     537                 :          0 :     size_t nCount = aEntries.size();
     538         [ #  # ]:          0 :     if( nCount )
     539                 :            :     {
     540                 :          0 :         SvxIconChoiceCtrlEntry* pPrev = aEntries[ 0 ];
     541         [ #  # ]:          0 :         for( size_t nCur = 1; nCur <= nCount; nCur++ )
     542                 :            :         {
     543                 :            :             pPrev->ClearFlags( ICNVIEW_FLAG_POS_LOCKED | ICNVIEW_FLAG_POS_MOVED |
     544                 :          0 :                                 ICNVIEW_FLAG_PRED_SET);
     545                 :            : 
     546                 :            :             SvxIconChoiceCtrlEntry* pNext;
     547         [ #  # ]:          0 :             if( nCur == nCount )
     548                 :          0 :                 pNext = aEntries[ 0 ];
     549                 :            :             else
     550                 :          0 :                 pNext = aEntries[ nCur ];
     551                 :          0 :             pPrev->pflink = pNext;
     552                 :          0 :             pNext->pblink = pPrev;
     553                 :          0 :             pPrev = pNext;
     554                 :            :         }
     555                 :          0 :         pHead = aEntries[ 0 ];
     556                 :            :     }
     557                 :            :     else
     558                 :          0 :         pHead = 0;
     559                 :          0 :     nFlags &= ~F_MOVED_ENTRIES;
     560                 :          0 : }
     561                 :            : 
     562                 :          0 : void SvxIconChoiceCtrl_Impl::ClearPredecessors()
     563                 :            : {
     564         [ #  # ]:          0 :     if( pHead )
     565                 :            :     {
     566                 :          0 :         size_t nCount = aEntries.size();
     567         [ #  # ]:          0 :         for( size_t nCur = 0; nCur < nCount; nCur++ )
     568                 :            :         {
     569                 :          0 :             SvxIconChoiceCtrlEntry* pCur = aEntries[ nCur ];
     570                 :          0 :             pCur->pflink = 0;
     571                 :          0 :             pCur->pblink = 0;
     572                 :          0 :             pCur->ClearFlags( ICNVIEW_FLAG_PRED_SET );
     573                 :            :         }
     574                 :          0 :         pHead = 0;
     575                 :            :     }
     576                 :          0 : }
     577                 :            : 
     578                 :          0 : void SvxIconChoiceCtrl_Impl::Arrange( sal_Bool bKeepPredecessors, long nSetMaxVirtWidth, long nSetMaxVirtHeight )
     579                 :            : {
     580         [ #  # ]:          0 :     if ( nSetMaxVirtWidth != 0 )
     581                 :          0 :         nMaxVirtWidth = nSetMaxVirtWidth;
     582                 :            :     else
     583                 :          0 :         nMaxVirtWidth = aOutputSize.Width();
     584                 :            : 
     585         [ #  # ]:          0 :     if ( nSetMaxVirtHeight != 0 )
     586                 :          0 :         nMaxVirtHeight = nSetMaxVirtHeight;
     587                 :            :     else
     588                 :          0 :         nMaxVirtHeight = aOutputSize.Height();
     589                 :            : 
     590                 :          0 :     ImpArrange( bKeepPredecessors );
     591                 :          0 : }
     592                 :            : 
     593                 :          0 : void SvxIconChoiceCtrl_Impl::ImpArrange( sal_Bool bKeepPredecessors )
     594                 :            : {
     595 [ #  # ][ #  # ]:          0 :     static Point aEmptyPoint;
     596                 :            : 
     597                 :          0 :     sal_Bool bOldUpdate = bUpdateMode;
     598         [ #  # ]:          0 :     Rectangle aCurOutputArea( GetOutputRect() );
     599 [ #  # ][ #  # ]:          0 :     if( (nWinBits & WB_SMART_ARRANGE) && aCurOutputArea.TopLeft() != aEmptyPoint )
         [ #  # ][ #  # ]
     600                 :          0 :         bUpdateMode = sal_False;
     601         [ #  # ]:          0 :     aAutoArrangeTimer.Stop();
     602                 :          0 :     nFlags &= ~F_MOVED_ENTRIES;
     603                 :          0 :     nFlags |= F_ARRANGING;
     604         [ #  # ]:          0 :     StopEditTimer();
     605         [ #  # ]:          0 :     ShowCursor( sal_False );
     606         [ #  # ]:          0 :     ResetVirtSize();
     607         [ #  # ]:          0 :     if( !bKeepPredecessors )
     608         [ #  # ]:          0 :         ClearPredecessors();
     609                 :          0 :     bBoundRectsDirty = sal_False;
     610         [ #  # ]:          0 :     SetOrigin( Point() );
     611         [ #  # ]:          0 :     VisRectChanged();
     612         [ #  # ]:          0 :     RecalcAllBoundingRectsSmart();
     613                 :            :     // TODO: the invalidation in the detail view should be more intelligent
     614                 :            :     //if( !(nWinBits & WB_DETAILS ))
     615         [ #  # ]:          0 :         pView->Invalidate( INVALIDATE_NOCHILDREN );
     616                 :          0 :     nFlags &= ~F_ARRANGING;
     617 [ #  # ][ #  # ]:          0 :     if( (nWinBits & WB_SMART_ARRANGE) && aCurOutputArea.TopLeft() != aEmptyPoint )
         [ #  # ][ #  # ]
     618                 :            :     {
     619         [ #  # ]:          0 :         MakeVisible( aCurOutputArea );
     620         [ #  # ]:          0 :         SetUpdateMode( bOldUpdate );
     621                 :            :     }
     622         [ #  # ]:          0 :     ShowCursor( sal_True );
     623                 :          0 : }
     624                 :            : 
     625                 :          0 : void SvxIconChoiceCtrl_Impl::Paint( const Rectangle& rRect )
     626                 :            : {
     627                 :          0 :     bEndScrollInvalidate = sal_False;
     628                 :            : 
     629                 :            : #if defined(OV_DRAWGRID)
     630                 :            :     Color aOldColor ( pView->GetLineColor() );
     631                 :            :     Color aColor( COL_BLACK );
     632                 :            :     pView->SetLineColor( aColor );
     633                 :            :     Point aOffs( pView->GetMapMode().GetOrigin());
     634                 :            :     Size aXSize( pView->GetOutputSizePixel() );
     635                 :            : 
     636                 :            :     {
     637                 :            :     Point aStart( LROFFS_WINBORDER, 0 );
     638                 :            :     Point aEnd( LROFFS_WINBORDER, aXSize.Height());
     639                 :            :     aStart -= aOffs;
     640                 :            :     aEnd -= aOffs;
     641                 :            :     pView->DrawLine( aStart, aEnd );
     642                 :            :     }
     643                 :            :     {
     644                 :            :     Point aStart( 0, TBOFFS_WINBORDER );
     645                 :            :     Point aEnd( aXSize.Width(), TBOFFS_WINBORDER );
     646                 :            :     aStart -= aOffs;
     647                 :            :     aEnd -= aOffs;
     648                 :            :     pView->DrawLine( aStart, aEnd );
     649                 :            :     }
     650                 :            : 
     651                 :            :     for( long nDX = nGridDX; nDX <= aXSize.Width(); nDX += nGridDX )
     652                 :            :     {
     653                 :            :         Point aStart( nDX+LROFFS_WINBORDER, 0 );
     654                 :            :         Point aEnd( nDX+LROFFS_WINBORDER, aXSize.Height());
     655                 :            :         aStart -= aOffs;
     656                 :            :         aEnd -= aOffs;
     657                 :            :         pView->DrawLine( aStart, aEnd );
     658                 :            :     }
     659                 :            :     for( long nDY = nGridDY; nDY <= aXSize.Height(); nDY += nGridDY )
     660                 :            :     {
     661                 :            :         Point aStart( 0, nDY+TBOFFS_WINBORDER );
     662                 :            :         Point aEnd( aXSize.Width(), nDY+TBOFFS_WINBORDER );
     663                 :            :         aStart -= aOffs;
     664                 :            :         aEnd -= aOffs;
     665                 :            :         pView->DrawLine( aStart, aEnd );
     666                 :            :     }
     667                 :            :     pView->SetLineColor( aOldColor );
     668                 :            : #endif
     669                 :          0 :     nFlags |= F_PAINTED;
     670                 :            : 
     671         [ #  # ]:          0 :     if( !aEntries.size() )
     672                 :          0 :         return;
     673         [ #  # ]:          0 :     if( !pCursor )
     674                 :            :     {
     675                 :            :         // set cursor to item with focus-flag
     676                 :          0 :         sal_Bool bfound = sal_False;
     677 [ #  # ][ #  # ]:          0 :         for ( sal_uLong i = 0; i < pView->GetEntryCount() && !bfound; i++)
                 [ #  # ]
     678                 :            :         {
     679                 :          0 :             SvxIconChoiceCtrlEntry* pEntry = pView->GetEntry ( i );
     680         [ #  # ]:          0 :             if( pEntry->IsFocused() )
     681                 :            :             {
     682                 :          0 :                 pCursor = pEntry;
     683                 :          0 :                 bfound=sal_True;
     684                 :            :             }
     685                 :            :         }
     686                 :            : 
     687         [ #  # ]:          0 :         if( !bfound )
     688                 :          0 :             pCursor = aEntries[ 0 ];
     689                 :            :     }
     690                 :            : 
     691                 :            :     // Show Focus at Init-Time
     692         [ #  # ]:          0 :     if ( pView->HasFocus() )
     693                 :          0 :         GetFocus();
     694                 :            : 
     695                 :          0 :     size_t nCount = pZOrderList->size();
     696         [ #  # ]:          0 :     if( !nCount )
     697                 :          0 :         return;
     698                 :            : 
     699                 :          0 :     sal_Bool bResetClipRegion = sal_False;
     700         [ #  # ]:          0 :     if( !pView->IsClipRegion() )
     701                 :            :     {
     702         [ #  # ]:          0 :         Rectangle aOutputArea( GetOutputRect() );
     703                 :          0 :         bResetClipRegion = sal_True;
     704 [ #  # ][ #  # ]:          0 :         pView->SetClipRegion( aOutputArea );
                 [ #  # ]
     705                 :            :     }
     706                 :            : 
     707         [ #  # ]:          0 :     SvxIconChoiceCtrlEntryList_impl* pNewZOrderList = new SvxIconChoiceCtrlEntryList_impl();
     708         [ #  # ]:          0 :     SvxIconChoiceCtrlEntryList_impl* pPaintedEntries = new SvxIconChoiceCtrlEntryList_impl();
     709                 :            : 
     710                 :          0 :     size_t nPos = 0;
     711         [ #  # ]:          0 :     while( nCount )
     712                 :            :     {
     713                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nPos ];
     714         [ #  # ]:          0 :         const Rectangle& rBoundRect = GetEntryBoundRect( pEntry );
     715 [ #  # ][ #  # ]:          0 :         if( rRect.IsOver( rBoundRect ) )
     716                 :            :         {
     717         [ #  # ]:          0 :             PaintEntry( pEntry, rBoundRect.TopLeft(), pView, sal_True );
     718                 :            :             // set entries to Top if they are being repainted
     719         [ #  # ]:          0 :             pPaintedEntries->push_back( pEntry );
     720                 :            :         }
     721                 :            :         else
     722         [ #  # ]:          0 :             pNewZOrderList->push_back( pEntry );
     723                 :            : 
     724                 :          0 :         nCount--;
     725                 :          0 :         nPos++;
     726                 :            :     }
     727         [ #  # ]:          0 :     delete pZOrderList;
     728                 :          0 :     pZOrderList = pNewZOrderList;
     729                 :          0 :     nCount = pPaintedEntries->size();
     730         [ #  # ]:          0 :     if( nCount )
     731                 :            :     {
     732         [ #  # ]:          0 :         for( size_t nCur = 0; nCur < nCount; nCur++ )
     733                 :          0 :             pZOrderList->push_back( (*pPaintedEntries)[ nCur ] );
     734                 :            :     }
     735         [ #  # ]:          0 :     delete pPaintedEntries;
     736                 :            : 
     737         [ #  # ]:          0 :     if( bResetClipRegion )
     738                 :          0 :         pView->SetClipRegion();
     739                 :            : }
     740                 :            : 
     741                 :          0 : void SvxIconChoiceCtrl_Impl::RepaintEntries( sal_uInt16 nEntryFlagsMask )
     742                 :            : {
     743                 :          0 :     const size_t nCount = pZOrderList->size();
     744         [ #  # ]:          0 :     if( !nCount )
     745                 :          0 :         return;
     746                 :            : 
     747                 :          0 :     sal_Bool bResetClipRegion = sal_False;
     748         [ #  # ]:          0 :     Rectangle aOutRect( GetOutputRect() );
     749         [ #  # ]:          0 :     if( !pView->IsClipRegion() )
     750                 :            :     {
     751                 :          0 :         bResetClipRegion = sal_True;
     752 [ #  # ][ #  # ]:          0 :         pView->SetClipRegion( aOutRect );
                 [ #  # ]
     753                 :            :     }
     754         [ #  # ]:          0 :     for( size_t nCur = 0; nCur < nCount; nCur++ )
     755                 :            :     {
     756                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCur ];
     757         [ #  # ]:          0 :         if( pEntry->GetFlags() & nEntryFlagsMask )
     758                 :            :         {
     759         [ #  # ]:          0 :             const Rectangle& rBoundRect = GetEntryBoundRect( pEntry );
     760 [ #  # ][ #  # ]:          0 :             if( aOutRect.IsOver( rBoundRect ) )
     761         [ #  # ]:          0 :                 PaintEntry( pEntry, rBoundRect.TopLeft() );
     762                 :            :         }
     763                 :            :     }
     764         [ #  # ]:          0 :     if( bResetClipRegion )
     765         [ #  # ]:          0 :         pView->SetClipRegion();
     766                 :            : }
     767                 :            : 
     768                 :            : 
     769                 :          0 : void SvxIconChoiceCtrl_Impl::InitScrollBarBox()
     770                 :            : {
     771         [ #  # ]:          0 :     aScrBarBox.SetSizePixel( Size(nVerSBarWidth-1, nHorSBarHeight-1) );
     772                 :          0 :     Size aSize( pView->GetOutputSizePixel() );
     773         [ #  # ]:          0 :     aScrBarBox.SetPosPixel( Point(aSize.Width()-nVerSBarWidth+1, aSize.Height()-nHorSBarHeight+1));
     774                 :          0 : }
     775                 :            : 
     776                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::MouseButtonDown( const MouseEvent& rMEvt)
     777                 :            : {
     778                 :          0 :     sal_Bool bHandled = sal_True;
     779                 :          0 :     bHighlightFramePressed = sal_False;
     780         [ #  # ]:          0 :     StopEditTimer();
     781 [ #  # ][ #  # ]:          0 :     sal_Bool bGotFocus = (sal_Bool)(!pView->HasFocus() && !(nWinBits & WB_NOPOINTERFOCUS));
                 [ #  # ]
     782         [ #  # ]:          0 :     if( !(nWinBits & WB_NOPOINTERFOCUS) )
     783         [ #  # ]:          0 :         pView->GrabFocus();
     784                 :            : 
     785                 :          0 :     Point aDocPos( rMEvt.GetPosPixel() );
     786 [ #  # ][ #  # ]:          0 :     if(aDocPos.X()>=aOutputSize.Width() || aDocPos.Y()>=aOutputSize.Height())
                 [ #  # ]
     787                 :          0 :         return sal_False;
     788                 :          0 :     ToDocPos( aDocPos );
     789         [ #  # ]:          0 :     SvxIconChoiceCtrlEntry* pEntry = GetEntry( aDocPos, sal_True );
     790         [ #  # ]:          0 :     if( pEntry )
     791         [ #  # ]:          0 :         MakeEntryVisible( pEntry, sal_False );
     792                 :            : 
     793 [ #  # ][ #  # ]:          0 :     if( rMEvt.IsShift() && eSelectionMode != SINGLE_SELECTION )
                 [ #  # ]
     794                 :            :     {
     795         [ #  # ]:          0 :         if( pEntry )
     796         [ #  # ]:          0 :             SetCursor_Impl( pCursor, pEntry, rMEvt.IsMod1(), rMEvt.IsShift(), sal_True);
     797                 :          0 :         return sal_True;
     798                 :            :     }
     799                 :            : 
     800 [ #  # ][ #  # ]:          0 :     if( pAnchor && (rMEvt.IsShift() || rMEvt.IsMod1())) // keyboard selection?
         [ #  # ][ #  # ]
     801                 :            :     {
     802                 :            :         DBG_ASSERT(eSelectionMode != SINGLE_SELECTION,"Invalid selection mode");
     803         [ #  # ]:          0 :         if( rMEvt.IsMod1() )
     804                 :          0 :             nFlags |= F_ADD_MODE;
     805                 :            : 
     806         [ #  # ]:          0 :         if( rMEvt.IsShift() )
     807                 :            :         {
     808         [ #  # ]:          0 :             Rectangle aRect( GetEntryBoundRect( pAnchor ));
     809         [ #  # ]:          0 :             if( pEntry )
     810 [ #  # ][ #  # ]:          0 :                 aRect.Union( GetEntryBoundRect( pEntry ) );
     811                 :            :             else
     812                 :            :             {
     813         [ #  # ]:          0 :                 Rectangle aTempRect( aDocPos, Size(1,1));
     814         [ #  # ]:          0 :                 aRect.Union( aTempRect );
     815                 :            :             }
     816                 :          0 :             aCurSelectionRect = aRect;
     817         [ #  # ]:          0 :             SelectRect( aRect, (nFlags & F_ADD_MODE)!=0, &aSelectedRectList );
     818                 :            :         }
     819         [ #  # ]:          0 :         else if( rMEvt.IsMod1() )
     820                 :            :         {
     821         [ #  # ]:          0 :             AddSelectedRect( aCurSelectionRect );
     822                 :          0 :             pAnchor = 0;
     823                 :          0 :             aCurSelectionRect.SetPos( aDocPos );
     824                 :            :         }
     825                 :            : 
     826 [ #  # ][ #  # ]:          0 :         if( !pEntry && !(nWinBits & WB_NODRAGSELECTION))
     827         [ #  # ]:          0 :             pView->StartTracking( STARTTRACK_SCROLLREPEAT );
     828                 :          0 :         return sal_True;
     829                 :            :     }
     830                 :            :     else
     831                 :            :     {
     832         [ #  # ]:          0 :         if( !pEntry )
     833                 :            :         {
     834         [ #  # ]:          0 :             if( eSelectionMode == MULTIPLE_SELECTION )
     835                 :            :             {
     836         [ #  # ]:          0 :                 if( !rMEvt.IsMod1() )  // Ctrl
     837                 :            :                 {
     838         [ #  # ]:          0 :                     if( !bGotFocus )
     839                 :            :                     {
     840         [ #  # ]:          0 :                         SetNoSelection();
     841         [ #  # ]:          0 :                         ClearSelectedRectList();
     842                 :            :                     }
     843                 :            :                 }
     844                 :            :                 else
     845                 :          0 :                     nFlags |= F_ADD_MODE;
     846                 :          0 :                 aCurSelectionRect.SetPos( aDocPos );
     847         [ #  # ]:          0 :                 pView->StartTracking( STARTTRACK_SCROLLREPEAT );
     848                 :            :             }
     849                 :            :             else
     850                 :          0 :                 bHandled = sal_False;
     851                 :          0 :             return bHandled;
     852                 :            :         }
     853                 :            :     }
     854                 :          0 :     sal_Bool bSelected = pEntry->IsSelected();
     855                 :          0 :     sal_Bool bEditingEnabled = IsEntryEditingEnabled();
     856                 :            : 
     857         [ #  # ]:          0 :     if( rMEvt.GetClicks() == 2 )
     858                 :            :     {
     859         [ #  # ]:          0 :         DeselectAllBut( pEntry );
     860         [ #  # ]:          0 :         SelectEntry( pEntry, sal_True, sal_True, sal_False, sal_True );
     861                 :          0 :         pHdlEntry = pEntry;
     862         [ #  # ]:          0 :         pView->ClickIcon();
     863                 :            :     }
     864                 :            :     else
     865                 :            :     {
     866                 :            :         // Inplace-Editing ?
     867         [ #  # ]:          0 :         if( rMEvt.IsMod2() )  // Alt?
     868                 :            :         {
     869         [ #  # ]:          0 :             if( bEntryEditingEnabled && pEntry &&
           [ #  #  #  # ]
                 [ #  # ]
     870                 :          0 :                 pEntry->IsSelected())
     871                 :            :             {
     872 [ #  # ][ #  # ]:          0 :                 if( pView->EditingEntry( pEntry ))
     873         [ #  # ]:          0 :                     EditEntry( pEntry );
     874                 :            :             }
     875                 :            :         }
     876         [ #  # ]:          0 :         else if( eSelectionMode == SINGLE_SELECTION )
     877                 :            :         {
     878         [ #  # ]:          0 :             DeselectAllBut( pEntry );
     879         [ #  # ]:          0 :             SetCursor( pEntry );
     880 [ #  # ][ #  # ]:          0 :             if( bEditingEnabled && bSelected && !rMEvt.GetModifier() &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     881         [ #  # ]:          0 :                 rMEvt.IsLeft() && IsTextHit( pEntry, aDocPos ) )
     882                 :            :             {
     883                 :          0 :                 nFlags |= F_START_EDITTIMER_IN_MOUSEUP;
     884                 :            :             }
     885                 :            :         }
     886         [ #  # ]:          0 :         else if( eSelectionMode == NO_SELECTION )
     887                 :            :         {
     888 [ #  # ][ #  # ]:          0 :             if( rMEvt.IsLeft() && (nWinBits & WB_HIGHLIGHTFRAME) )
                 [ #  # ]
     889                 :            :             {
     890                 :          0 :                 pCurHighlightFrame = 0; // force repaint of frame
     891                 :          0 :                 bHighlightFramePressed = sal_True;
     892         [ #  # ]:          0 :                 SetEntryHighlightFrame( pEntry, sal_True );
     893                 :            :             }
     894                 :            :         }
     895                 :            :         else
     896                 :            :         {
     897 [ #  # ][ #  # ]:          0 :             if( !rMEvt.GetModifier() && rMEvt.IsLeft() )
                 [ #  # ]
     898                 :            :             {
     899         [ #  # ]:          0 :                 if( !bSelected )
     900                 :            :                 {
     901         [ #  # ]:          0 :                     DeselectAllBut( pEntry, sal_True /* paint synchronously */ );
     902         [ #  # ]:          0 :                     SetCursor( pEntry );
     903         [ #  # ]:          0 :                     SelectEntry( pEntry, sal_True, sal_True, sal_False, sal_True );
     904                 :            :                 }
     905                 :            :                 else
     906                 :            :                 {
     907                 :            :                     // deselect only in the Up, if the Move happened via D&D!
     908                 :          0 :                     nFlags |= F_DOWN_DESELECT;
     909 [ #  # ][ #  # ]:          0 :                     if( bEditingEnabled && IsTextHit( pEntry, aDocPos ) &&
           [ #  #  #  # ]
                 [ #  # ]
     910                 :          0 :                         rMEvt.IsLeft())
     911                 :            :                     {
     912                 :          0 :                         nFlags |= F_START_EDITTIMER_IN_MOUSEUP;
     913                 :            :                     }
     914                 :            :                 }
     915                 :            :             }
     916         [ #  # ]:          0 :             else if( rMEvt.IsMod1() )
     917                 :          0 :                 nFlags |= F_DOWN_CTRL;
     918                 :            :         }
     919                 :            :     }
     920                 :          0 :     return bHandled;
     921                 :            : }
     922                 :            : 
     923                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::MouseButtonUp( const MouseEvent& rMEvt )
     924                 :            : {
     925                 :          0 :     sal_Bool bHandled = sal_False;
     926 [ #  # ][ #  # ]:          0 :     if( rMEvt.IsRight() && (nFlags & (F_DOWN_CTRL | F_DOWN_DESELECT) ))
                 [ #  # ]
     927                 :            :     {
     928                 :          0 :         nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
     929                 :          0 :         bHandled = sal_True;
     930                 :            :     }
     931                 :            : 
     932                 :          0 :     Point aDocPos( rMEvt.GetPosPixel() );
     933                 :          0 :     ToDocPos( aDocPos );
     934         [ #  # ]:          0 :     SvxIconChoiceCtrlEntry* pDocEntry = GetEntry( aDocPos );
     935         [ #  # ]:          0 :     if( pDocEntry )
     936                 :            :     {
     937         [ #  # ]:          0 :         if( nFlags & F_DOWN_CTRL )
     938                 :            :         {
     939                 :            :             // Ctrl & MultiSelection
     940         [ #  # ]:          0 :             ToggleSelection( pDocEntry );
     941         [ #  # ]:          0 :             SetCursor( pDocEntry );
     942                 :          0 :             bHandled = sal_True;
     943                 :            :         }
     944         [ #  # ]:          0 :         else if( nFlags & F_DOWN_DESELECT )
     945                 :            :         {
     946         [ #  # ]:          0 :             DeselectAllBut( pDocEntry );
     947         [ #  # ]:          0 :             SetCursor( pDocEntry );
     948         [ #  # ]:          0 :             SelectEntry( pDocEntry, sal_True, sal_True, sal_False, sal_True );
     949                 :          0 :             bHandled = sal_True;
     950                 :            :         }
     951                 :            :     }
     952                 :            : 
     953                 :          0 :     nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
     954         [ #  # ]:          0 :     if( nFlags & F_START_EDITTIMER_IN_MOUSEUP )
     955                 :            :     {
     956                 :          0 :         bHandled = sal_True;
     957         [ #  # ]:          0 :         StartEditTimer();
     958                 :          0 :         nFlags &= ~F_START_EDITTIMER_IN_MOUSEUP;
     959                 :            :     }
     960                 :            : 
     961 [ #  # ][ #  # ]:          0 :     if((nWinBits & WB_HIGHLIGHTFRAME) && bHighlightFramePressed && pCurHighlightFrame)
                 [ #  # ]
     962                 :            :     {
     963                 :          0 :         bHandled = sal_True;
     964                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = pCurHighlightFrame;
     965                 :          0 :         pCurHighlightFrame = 0; // force repaint of frame
     966                 :          0 :         bHighlightFramePressed = sal_False;
     967         [ #  # ]:          0 :         SetEntryHighlightFrame( pEntry, sal_True );
     968                 :            : 
     969                 :          0 :         pHdlEntry = pCurHighlightFrame;
     970         [ #  # ]:          0 :         pView->ClickIcon();
     971                 :            : 
     972                 :            :         // set focus on Icon
     973                 :          0 :         SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
     974         [ #  # ]:          0 :         SetCursor_Impl( pOldCursor, pHdlEntry, sal_False, sal_False, sal_True );
     975                 :            : 
     976                 :          0 :         pHdlEntry = 0;
     977                 :            :     }
     978                 :          0 :     return bHandled;
     979                 :            : }
     980                 :            : 
     981                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::MouseMove( const MouseEvent& rMEvt )
     982                 :            : {
     983         [ #  # ]:          0 :     const Point aDocPos( pView->PixelToLogic(rMEvt.GetPosPixel()) );
     984                 :            : 
     985 [ #  # ][ #  # ]:          0 :     if( pView->IsTracking() )
     986                 :          0 :         return sal_False;
     987         [ #  # ]:          0 :     else if( nWinBits & WB_HIGHLIGHTFRAME )
     988                 :            :     {
     989         [ #  # ]:          0 :         SvxIconChoiceCtrlEntry* pEntry = GetEntry( aDocPos, sal_True );
     990         [ #  # ]:          0 :         SetEntryHighlightFrame( pEntry );
     991                 :            :     }
     992                 :            :     else
     993                 :          0 :         return sal_False;
     994                 :          0 :     return sal_True;
     995                 :            : }
     996                 :            : 
     997                 :          0 : void SvxIconChoiceCtrl_Impl::SetCursor_Impl( SvxIconChoiceCtrlEntry* pOldCursor,
     998                 :            :     SvxIconChoiceCtrlEntry* pNewCursor, sal_Bool bMod1, sal_Bool bShift, sal_Bool bPaintSync )
     999                 :            : {
    1000         [ #  # ]:          0 :     if( pNewCursor )
    1001                 :            :     {
    1002                 :          0 :         SvxIconChoiceCtrlEntry* pFilterEntry = 0;
    1003                 :          0 :         sal_Bool bDeselectAll = sal_False;
    1004         [ #  # ]:          0 :         if( eSelectionMode != SINGLE_SELECTION )
    1005                 :            :         {
    1006 [ #  # ][ #  # ]:          0 :             if( !bMod1 && !bShift )
    1007                 :          0 :                 bDeselectAll = sal_True;
    1008 [ #  # ][ #  # ]:          0 :             else if( bShift && !bMod1 && !pAnchor )
                 [ #  # ]
    1009                 :            :             {
    1010                 :          0 :                 bDeselectAll = sal_True;
    1011                 :          0 :                 pFilterEntry = pOldCursor;
    1012                 :            :             }
    1013                 :            :         }
    1014         [ #  # ]:          0 :         if( bDeselectAll )
    1015                 :          0 :             DeselectAllBut( pFilterEntry, bPaintSync );
    1016                 :          0 :         ShowCursor( sal_False );
    1017                 :          0 :         MakeEntryVisible( pNewCursor );
    1018                 :          0 :         SetCursor( pNewCursor );
    1019 [ #  # ][ #  # ]:          0 :         if( bMod1 && !bShift )
    1020                 :            :         {
    1021         [ #  # ]:          0 :             if( pAnchor )
    1022                 :            :             {
    1023                 :          0 :                 AddSelectedRect( pAnchor, pOldCursor );
    1024                 :          0 :                 pAnchor = 0;
    1025                 :            :             }
    1026                 :            :         }
    1027         [ #  # ]:          0 :         else if( bShift )
    1028                 :            :         {
    1029         [ #  # ]:          0 :             if( !pAnchor )
    1030                 :          0 :                 pAnchor = pOldCursor;
    1031         [ #  # ]:          0 :             if ( nWinBits & WB_ALIGN_LEFT )
    1032                 :          0 :                 SelectRange( pAnchor, pNewCursor, (nFlags & F_ADD_MODE)!=0 );
    1033                 :            :             else
    1034                 :          0 :                 SelectRect(pAnchor,pNewCursor,(nFlags & F_ADD_MODE)!=0,&aSelectedRectList);
    1035                 :            :         }
    1036                 :            :         else
    1037                 :            :         {
    1038                 :          0 :             SelectEntry( pCursor, sal_True, sal_True,  sal_False, bPaintSync );
    1039                 :          0 :             aCurSelectionRect = GetEntryBoundRect( pCursor );
    1040                 :            :         }
    1041                 :            :     }
    1042                 :          0 : }
    1043                 :            : 
    1044                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
    1045                 :            : {
    1046         [ #  # ]:          0 :     StopEditTimer();
    1047                 :            : 
    1048                 :          0 :     sal_Bool bMod2 = rKEvt.GetKeyCode().IsMod2();
    1049                 :          0 :     sal_Unicode cChar = rKEvt.GetCharCode();
    1050                 :          0 :     sal_uLong nPos = (sal_uLong)-1;
    1051 [ #  # ][ #  # ]:          0 :     if ( bMod2 && cChar && IsMnemonicChar( cChar, nPos ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1052                 :            :     {
    1053                 :            :         // shortcut is clicked
    1054         [ #  # ]:          0 :         SvxIconChoiceCtrlEntry* pNewCursor = GetEntry( nPos );
    1055                 :          0 :         SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
    1056         [ #  # ]:          0 :         if ( pNewCursor != pOldCursor )
    1057         [ #  # ]:          0 :             SetCursor_Impl( pOldCursor, pNewCursor, sal_False, sal_False, sal_False );
    1058                 :          0 :         return sal_True;
    1059                 :            :     }
    1060                 :            : 
    1061         [ #  # ]:          0 :     if ( bMod2 )
    1062                 :            :         // no actions with <ALT>
    1063                 :          0 :         return sal_False;
    1064                 :            : 
    1065                 :          0 :     sal_Bool bKeyUsed = sal_True;
    1066                 :          0 :     sal_Bool bMod1 = rKEvt.GetKeyCode().IsMod1();
    1067                 :          0 :     sal_Bool bShift = rKEvt.GetKeyCode().IsShift();
    1068                 :            : 
    1069 [ #  # ][ #  # ]:          0 :     if( eSelectionMode == SINGLE_SELECTION || eSelectionMode == NO_SELECTION)
    1070                 :            :     {
    1071                 :          0 :         bShift = sal_False;
    1072                 :          0 :         bMod1 = sal_False;
    1073                 :            :     }
    1074                 :            : 
    1075         [ #  # ]:          0 :     if( bMod1 )
    1076                 :          0 :         nFlags |= F_ADD_MODE;
    1077                 :            : 
    1078                 :            :     SvxIconChoiceCtrlEntry* pNewCursor;
    1079                 :          0 :     SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
    1080                 :            : 
    1081                 :          0 :     sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
    1082   [ #  #  #  #  :          0 :     switch( nCode )
          #  #  #  #  #  
             #  #  #  # ]
    1083                 :            :     {
    1084                 :            :         case KEY_UP:
    1085                 :            :         case KEY_PAGEUP:
    1086         [ #  # ]:          0 :             if( pCursor )
    1087                 :            :             {
    1088         [ #  # ]:          0 :                 MakeEntryVisible( pCursor );
    1089         [ #  # ]:          0 :                 if( nCode == KEY_UP )
    1090         [ #  # ]:          0 :                     pNewCursor = pImpCursor->GoUpDown(pCursor,sal_False);
    1091                 :            :                 else
    1092         [ #  # ]:          0 :                     pNewCursor = pImpCursor->GoPageUpDown(pCursor,sal_False);
    1093         [ #  # ]:          0 :                 SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
    1094         [ #  # ]:          0 :                 if( !pNewCursor )
    1095                 :            :                 {
    1096         [ #  # ]:          0 :                     Rectangle aRect( GetEntryBoundRect( pCursor ) );
    1097         [ #  # ]:          0 :                     if( aRect.Top())
    1098                 :            :                     {
    1099                 :          0 :                         aRect.Bottom() -= aRect.Top();
    1100                 :          0 :                         aRect.Top() = 0;
    1101         [ #  # ]:          0 :                         MakeVisible( aRect );
    1102                 :            :                     }
    1103                 :            :                 }
    1104                 :            : 
    1105 [ #  # ][ #  # ]:          0 :                 if ( bChooseWithCursor && pNewCursor != NULL )
    1106                 :            :                 {
    1107                 :          0 :                     pHdlEntry = pNewCursor;//GetCurEntry();
    1108                 :          0 :                     pCurHighlightFrame = pHdlEntry;
    1109         [ #  # ]:          0 :                     pView->ClickIcon();
    1110                 :          0 :                     pCurHighlightFrame = NULL;
    1111                 :            :                 }
    1112                 :            :             }
    1113                 :          0 :             break;
    1114                 :            : 
    1115                 :            :         case KEY_DOWN:
    1116                 :            :         case KEY_PAGEDOWN:
    1117         [ #  # ]:          0 :             if( pCursor )
    1118                 :            :             {
    1119         [ #  # ]:          0 :                 if( nCode == KEY_DOWN )
    1120         [ #  # ]:          0 :                     pNewCursor=pImpCursor->GoUpDown( pCursor,sal_True );
    1121                 :            :                 else
    1122         [ #  # ]:          0 :                     pNewCursor=pImpCursor->GoPageUpDown( pCursor,sal_True );
    1123         [ #  # ]:          0 :                 SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
    1124                 :            : 
    1125 [ #  # ][ #  # ]:          0 :                 if ( bChooseWithCursor && pNewCursor != NULL)
    1126                 :            :                 {
    1127                 :          0 :                     pHdlEntry = pNewCursor;//GetCurEntry();
    1128                 :          0 :                     pCurHighlightFrame = pHdlEntry;
    1129         [ #  # ]:          0 :                     pView->ClickIcon();
    1130                 :          0 :                     pCurHighlightFrame = NULL;
    1131                 :            :                 }
    1132                 :            :             }
    1133                 :          0 :             break;
    1134                 :            : 
    1135                 :            :         case KEY_RIGHT:
    1136         [ #  # ]:          0 :             if( pCursor )
    1137                 :            :             {
    1138         [ #  # ]:          0 :                 pNewCursor=pImpCursor->GoLeftRight(pCursor,sal_True );
    1139         [ #  # ]:          0 :                 SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
    1140                 :            :             }
    1141                 :          0 :             break;
    1142                 :            : 
    1143                 :            :         case KEY_LEFT:
    1144         [ #  # ]:          0 :             if( pCursor )
    1145                 :            :             {
    1146         [ #  # ]:          0 :                 MakeEntryVisible( pCursor );
    1147         [ #  # ]:          0 :                 pNewCursor = pImpCursor->GoLeftRight(pCursor,sal_False );
    1148         [ #  # ]:          0 :                 SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
    1149         [ #  # ]:          0 :                 if( !pNewCursor )
    1150                 :            :                 {
    1151         [ #  # ]:          0 :                     Rectangle aRect( GetEntryBoundRect(pCursor));
    1152         [ #  # ]:          0 :                     if( aRect.Left() )
    1153                 :            :                     {
    1154                 :          0 :                         aRect.Right() -= aRect.Left();
    1155                 :          0 :                         aRect.Left() = 0;
    1156         [ #  # ]:          0 :                         MakeVisible( aRect );
    1157                 :            :                     }
    1158                 :            :                 }
    1159                 :            :             }
    1160                 :          0 :             break;
    1161                 :            : 
    1162                 :            :         case KEY_F2:
    1163 [ #  # ][ #  # ]:          0 :             if( !bMod1 && !bShift )
    1164         [ #  # ]:          0 :                 EditTimeoutHdl( 0 );
    1165                 :            :             else
    1166                 :          0 :                 bKeyUsed = sal_False;
    1167                 :          0 :             break;
    1168                 :            : 
    1169                 :            :         case KEY_F8:
    1170         [ #  # ]:          0 :             if( rKEvt.GetKeyCode().IsShift() )
    1171                 :            :             {
    1172         [ #  # ]:          0 :                 if( nFlags & F_ADD_MODE )
    1173                 :          0 :                     nFlags &= (~F_ADD_MODE);
    1174                 :            :                 else
    1175                 :          0 :                     nFlags |= F_ADD_MODE;
    1176                 :            :             }
    1177                 :            :             else
    1178                 :          0 :                 bKeyUsed = sal_False;
    1179                 :          0 :             break;
    1180                 :            : 
    1181                 :            :         case KEY_SPACE:
    1182 [ #  # ][ #  # ]:          0 :             if( pCursor && eSelectionMode != SINGLE_SELECTION )
    1183                 :            :             {
    1184         [ #  # ]:          0 :                 if( !bMod1 )
    1185                 :            :                 {
    1186                 :            :                     //SelectAll( sal_False );
    1187         [ #  # ]:          0 :                     SetNoSelection();
    1188         [ #  # ]:          0 :                     ClearSelectedRectList();
    1189                 :            : 
    1190                 :            :                     // click Icon with spacebar
    1191         [ #  # ]:          0 :                     SetEntryHighlightFrame( GetCurEntry(), sal_True );
    1192         [ #  # ]:          0 :                     pView->ClickIcon();
    1193                 :          0 :                     pHdlEntry = pCurHighlightFrame;
    1194                 :          0 :                     pCurHighlightFrame=0;
    1195                 :            :                 }
    1196                 :            :                 else
    1197         [ #  # ]:          0 :                     ToggleSelection( pCursor );
    1198                 :            :             }
    1199                 :          0 :             break;
    1200                 :            : 
    1201                 :            : #ifdef DBG_UTIL
    1202                 :            :         case KEY_F10:
    1203                 :            :             if( rKEvt.GetKeyCode().IsShift() )
    1204                 :            :             {
    1205                 :            :                 if( pCursor )
    1206                 :            :                     pView->SetEntryTextMode( IcnShowTextFull, pCursor );
    1207                 :            :             }
    1208                 :            :             if( rKEvt.GetKeyCode().IsMod1() )
    1209                 :            :             {
    1210                 :            :                 if( pCursor )
    1211                 :            :                     pView->SetEntryTextMode( IcnShowTextShort, pCursor );
    1212                 :            :             }
    1213                 :            :             break;
    1214                 :            : #endif
    1215                 :            : 
    1216                 :            :         case KEY_ADD:
    1217                 :            :         case KEY_DIVIDE :
    1218                 :            :         case KEY_A:
    1219 [ #  # ][ #  # ]:          0 :             if( bMod1 && (eSelectionMode != SINGLE_SELECTION))
    1220         [ #  # ]:          0 :                 SelectAll( sal_True );
    1221                 :            :             else
    1222                 :          0 :                 bKeyUsed = sal_False;
    1223                 :          0 :             break;
    1224                 :            : 
    1225                 :            :         case KEY_SUBTRACT:
    1226                 :            :         case KEY_COMMA :
    1227         [ #  # ]:          0 :             if( bMod1 )
    1228         [ #  # ]:          0 :                 SetNoSelection();
    1229                 :            :             else
    1230                 :          0 :                 bKeyUsed = sal_False;
    1231                 :          0 :             break;
    1232                 :            : 
    1233                 :            :         case KEY_RETURN:
    1234         [ #  # ]:          0 :             if( bMod1 )
    1235                 :            :             {
    1236 [ #  # ][ #  # ]:          0 :                 if( pCursor && bEntryEditingEnabled )
    1237         [ #  # ]:          0 :                     /*pView->*/EditEntry( pCursor );
    1238                 :            :             }
    1239                 :            :             else
    1240                 :          0 :                 bKeyUsed = sal_False;
    1241                 :          0 :             break;
    1242                 :            : 
    1243                 :            :         case KEY_END:
    1244         [ #  # ]:          0 :             if( pCursor )
    1245                 :            :             {
    1246         [ #  # ]:          0 :                 pNewCursor = aEntries[ aEntries.size() - 1 ];
    1247         [ #  # ]:          0 :                 SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
    1248                 :            :             }
    1249                 :          0 :             break;
    1250                 :            : 
    1251                 :            :         case KEY_HOME:
    1252         [ #  # ]:          0 :             if( pCursor )
    1253                 :            :             {
    1254         [ #  # ]:          0 :                 pNewCursor = aEntries[ 0 ];
    1255         [ #  # ]:          0 :                 SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
    1256                 :            :             }
    1257                 :          0 :             break;
    1258                 :            : 
    1259                 :            :         default:
    1260                 :          0 :             bKeyUsed = sal_False;
    1261                 :            : 
    1262                 :            :     }
    1263                 :          0 :     return bKeyUsed;
    1264                 :            : }
    1265                 :            : 
    1266                 :            : // recalculate TopLeft of scrollbars (but not their sizes!)
    1267                 :          0 : void SvxIconChoiceCtrl_Impl::PositionScrollBars( long nRealWidth, long nRealHeight )
    1268                 :            : {
    1269                 :            :     // horizontal scrollbar
    1270                 :          0 :     Point aPos( 0, nRealHeight );
    1271                 :          0 :     aPos.Y() -= nHorSBarHeight;
    1272                 :            : 
    1273 [ #  # ][ #  # ]:          0 :     if( aHorSBar.GetPosPixel() != aPos )
    1274         [ #  # ]:          0 :         aHorSBar.SetPosPixel( aPos );
    1275                 :            : 
    1276                 :            :     // vertical scrollbar
    1277                 :          0 :     aPos.X() = nRealWidth; aPos.Y() = 0;
    1278                 :          0 :     aPos.X() -= nVerSBarWidth;
    1279                 :          0 :     aPos.X()++;
    1280                 :          0 :     aPos.Y()--;
    1281                 :            : 
    1282 [ #  # ][ #  # ]:          0 :     if( aVerSBar.GetPosPixel() != aPos )
    1283         [ #  # ]:          0 :         aVerSBar.SetPosPixel( aPos );
    1284                 :          0 : }
    1285                 :            : 
    1286                 :          0 : void SvxIconChoiceCtrl_Impl::AdjustScrollBars( sal_Bool )
    1287                 :            : {
    1288         [ #  # ]:          0 :     Rectangle aOldOutRect( GetOutputRect() );
    1289                 :          0 :     long nVirtHeight = aVirtOutputSize.Height();
    1290                 :          0 :     long nVirtWidth = aVirtOutputSize.Width();
    1291                 :            : 
    1292                 :          0 :     Size aOSize( pView->Control::GetOutputSizePixel() );
    1293                 :          0 :     long nRealHeight = aOSize.Height();
    1294                 :          0 :     long nRealWidth = aOSize.Width();
    1295                 :            : 
    1296         [ #  # ]:          0 :     PositionScrollBars( nRealWidth, nRealHeight );
    1297                 :            : 
    1298                 :          0 :     const MapMode& rMapMode = pView->GetMapMode();
    1299                 :          0 :     Point aOrigin( rMapMode.GetOrigin() );
    1300                 :            : 
    1301                 :            :     long nVisibleWidth;
    1302         [ #  # ]:          0 :     if( nRealWidth > nVirtWidth )
    1303                 :          0 :         nVisibleWidth = nVirtWidth + aOrigin.X();
    1304                 :            :     else
    1305                 :          0 :         nVisibleWidth = nRealWidth;
    1306                 :            : 
    1307                 :            :     long nVisibleHeight;
    1308         [ #  # ]:          0 :     if( nRealHeight > nVirtHeight )
    1309                 :          0 :         nVisibleHeight = nVirtHeight + aOrigin.Y();
    1310                 :            :     else
    1311                 :          0 :         nVisibleHeight = nRealHeight;
    1312                 :            : 
    1313                 :          0 :     sal_Bool bVerSBar = ( nWinBits & WB_VSCROLL ) != 0;
    1314                 :          0 :     sal_Bool bHorSBar = ( nWinBits & WB_HSCROLL ) != 0;
    1315                 :          0 :     sal_Bool bNoVerSBar = ( nWinBits & WB_NOVSCROLL ) != 0;
    1316                 :          0 :     sal_Bool bNoHorSBar = ( nWinBits & WB_NOHSCROLL ) != 0;
    1317                 :            : 
    1318                 :          0 :     sal_uInt16 nResult = 0;
    1319         [ #  # ]:          0 :     if( nVirtHeight )
    1320                 :            :     {
    1321                 :            :         // activate vertical scrollbar?
    1322 [ #  # ][ #  # ]:          0 :         if( !bNoVerSBar && (bVerSBar || ( nVirtHeight > nVisibleHeight)) )
                 [ #  # ]
    1323                 :            :         {
    1324                 :          0 :             nResult = 0x0001;
    1325                 :          0 :             nRealWidth -= nVerSBarWidth;
    1326                 :            : 
    1327         [ #  # ]:          0 :             if( nRealWidth > nVirtWidth )
    1328                 :          0 :                 nVisibleWidth = nVirtWidth + aOrigin.X();
    1329                 :            :             else
    1330                 :          0 :                 nVisibleWidth = nRealWidth;
    1331                 :            : 
    1332                 :          0 :             nFlags |= F_HOR_SBARSIZE_WITH_VBAR;
    1333                 :            :         }
    1334                 :            :         // activate horizontal scrollbar?
    1335 [ #  # ][ #  # ]:          0 :         if( !bNoHorSBar && (bHorSBar || (nVirtWidth > nVisibleWidth)) )
                 [ #  # ]
    1336                 :            :         {
    1337                 :          0 :             nResult |= 0x0002;
    1338                 :          0 :             nRealHeight -= nHorSBarHeight;
    1339                 :            : 
    1340         [ #  # ]:          0 :             if( nRealHeight > nVirtHeight )
    1341                 :          0 :                 nVisibleHeight = nVirtHeight + aOrigin.Y();
    1342                 :            :             else
    1343                 :          0 :                 nVisibleHeight = nRealHeight;
    1344                 :            : 
    1345                 :            :             // do we need a vertical scrollbar after all?
    1346 [ #  # ][ #  # ]:          0 :             if( !(nResult & 0x0001) &&  // only if not already there
         [ #  # ][ #  # ]
    1347                 :            :                 ( !bNoVerSBar && ((nVirtHeight > nVisibleHeight) || bVerSBar)) )
    1348                 :            :             {
    1349                 :          0 :                 nResult = 3; // both turned on
    1350                 :          0 :                 nRealWidth -= nVerSBarWidth;
    1351                 :            : 
    1352         [ #  # ]:          0 :                 if( nRealWidth > nVirtWidth )
    1353                 :          0 :                     nVisibleWidth = nVirtWidth + aOrigin.X();
    1354                 :            :                 else
    1355                 :          0 :                     nVisibleWidth = nRealWidth;
    1356                 :            : 
    1357                 :          0 :                 nFlags |= F_VER_SBARSIZE_WITH_HBAR;
    1358                 :            :             }
    1359                 :            :         }
    1360                 :            :     }
    1361                 :            : 
    1362                 :            :     // size vertical scrollbar
    1363                 :          0 :     long nThumb = aVerSBar.GetThumbPos();
    1364                 :          0 :     Size aSize( nVerSBarWidth, nRealHeight );
    1365                 :          0 :     aSize.Height() += 2;
    1366 [ #  # ][ #  # ]:          0 :     if( aSize != aVerSBar.GetSizePixel() )
    1367         [ #  # ]:          0 :         aVerSBar.SetSizePixel( aSize );
    1368         [ #  # ]:          0 :     aVerSBar.SetVisibleSize( nVisibleHeight );
    1369                 :          0 :     aVerSBar.SetPageSize( GetScrollBarPageSize( nVisibleHeight ));
    1370                 :            : 
    1371         [ #  # ]:          0 :     if( nResult & 0x0001 )
    1372                 :            :     {
    1373         [ #  # ]:          0 :         aVerSBar.SetThumbPos( nThumb );
    1374         [ #  # ]:          0 :         aVerSBar.Show();
    1375                 :            :     }
    1376                 :            :     else
    1377                 :            :     {
    1378         [ #  # ]:          0 :         aVerSBar.SetThumbPos( 0 );
    1379         [ #  # ]:          0 :         aVerSBar.Hide();
    1380                 :            :     }
    1381                 :            : 
    1382                 :            :     // size horizontal scrollbar
    1383                 :          0 :     nThumb = aHorSBar.GetThumbPos();
    1384                 :          0 :     aSize.Width() = nRealWidth;
    1385                 :          0 :     aSize.Height() = nHorSBarHeight;
    1386                 :          0 :     aSize.Width()++;
    1387         [ #  # ]:          0 :     if( nResult & 0x0001 ) // vertical scrollbar?
    1388                 :            :     {
    1389                 :          0 :         aSize.Width()++;
    1390                 :          0 :         nRealWidth++;
    1391                 :            :     }
    1392 [ #  # ][ #  # ]:          0 :     if( aSize != aHorSBar.GetSizePixel() )
    1393         [ #  # ]:          0 :         aHorSBar.SetSizePixel( aSize );
    1394         [ #  # ]:          0 :     aHorSBar.SetVisibleSize( nVisibleWidth );
    1395                 :          0 :     aHorSBar.SetPageSize( GetScrollBarPageSize(nVisibleWidth ));
    1396         [ #  # ]:          0 :     if( nResult & 0x0002 )
    1397                 :            :     {
    1398         [ #  # ]:          0 :         aHorSBar.SetThumbPos( nThumb );
    1399         [ #  # ]:          0 :         aHorSBar.Show();
    1400                 :            :     }
    1401                 :            :     else
    1402                 :            :     {
    1403         [ #  # ]:          0 :         aHorSBar.SetThumbPos( 0 );
    1404         [ #  # ]:          0 :         aHorSBar.Hide();
    1405                 :            :     }
    1406                 :            : 
    1407                 :          0 :     aOutputSize.Width() = nRealWidth;
    1408         [ #  # ]:          0 :     if( nResult & 0x0002 ) // horizontal scrollbar ?
    1409                 :          0 :         nRealHeight++; // because lower border is clipped
    1410                 :          0 :     aOutputSize.Height() = nRealHeight;
    1411                 :            : 
    1412         [ #  # ]:          0 :     Rectangle aNewOutRect( GetOutputRect() );
    1413 [ #  # ][ #  # ]:          0 :     if( aNewOutRect != aOldOutRect && pView->HasBackground() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1414                 :            :     {
    1415         [ #  # ]:          0 :         Wallpaper aPaper( pView->GetBackground() );
    1416         [ #  # ]:          0 :         aPaper.SetRect( aNewOutRect );
    1417 [ #  # ][ #  # ]:          0 :         pView->SetBackground( aPaper );
    1418                 :            :     }
    1419                 :            : 
    1420         [ #  # ]:          0 :     if( (nResult & (0x0001|0x0002)) == (0x0001|0x0002) )
    1421         [ #  # ]:          0 :         aScrBarBox.Show();
    1422                 :            :     else
    1423         [ #  # ]:          0 :         aScrBarBox.Hide();
    1424                 :          0 : }
    1425                 :            : 
    1426                 :          0 : void SvxIconChoiceCtrl_Impl::Resize()
    1427                 :            : {
    1428                 :          0 :     StopEditTimer();
    1429                 :          0 :     InitScrollBarBox();
    1430                 :          0 :     aOutputSize = pView->GetOutputSizePixel();
    1431                 :          0 :     pImpCursor->Clear();
    1432                 :          0 :     pGridMap->OutputSizeChanged();
    1433                 :            : 
    1434                 :          0 :     const Size& rSize = pView->Control::GetOutputSizePixel();
    1435                 :          0 :     PositionScrollBars( rSize.Width(), rSize.Height() );
    1436                 :            :     // The scrollbars are shown/hidden asynchronously, so derived classes can
    1437                 :            :     // do an Arrange during Resize, without the scrollbars suddenly turning
    1438                 :            :     // on and off again.
    1439                 :            :     // If an event is already underway, we don't need to send a new one, at least
    1440                 :            :     // as long as there is only one event type.
    1441         [ #  # ]:          0 :     if ( ! nUserEventAdjustScrBars )
    1442                 :            :         nUserEventAdjustScrBars =
    1443                 :            :             Application::PostUserEvent( LINK( this, SvxIconChoiceCtrl_Impl, UserEventHdl),
    1444         [ #  # ]:          0 :                 EVENTID_ADJUST_SCROLLBARS);
    1445                 :            : 
    1446 [ #  # ][ #  # ]:          0 :     if( pView->HasBackground() && !pView->GetBackground().IsScrollable() )
                 [ #  # ]
    1447                 :            :     {
    1448         [ #  # ]:          0 :         Rectangle aRect( GetOutputRect());
    1449         [ #  # ]:          0 :         Wallpaper aPaper( pView->GetBackground() );
    1450         [ #  # ]:          0 :         aPaper.SetRect( aRect );
    1451 [ #  # ][ #  # ]:          0 :         pView->SetBackground( aPaper );
    1452                 :            :     }
    1453                 :          0 :     VisRectChanged();
    1454                 :          0 : }
    1455                 :            : 
    1456                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::CheckHorScrollBar()
    1457                 :            : {
    1458 [ #  # ][ #  # ]:          0 :     if( !pZOrderList || !aHorSBar.IsVisible() )
         [ #  # ][ #  # ]
    1459                 :          0 :         return sal_False;
    1460                 :          0 :     const MapMode& rMapMode = pView->GetMapMode();
    1461                 :          0 :     Point aOrigin( rMapMode.GetOrigin() );
    1462 [ #  # ][ #  # ]:          0 :     if(!( nWinBits & WB_HSCROLL) && !aOrigin.X() )
                 [ #  # ]
    1463                 :            :     {
    1464                 :          0 :         long nWidth = aOutputSize.Width();
    1465                 :          0 :         const size_t nCount = pZOrderList->size();
    1466                 :          0 :         long nMostRight = 0;
    1467         [ #  # ]:          0 :         for( size_t nCur = 0; nCur < nCount; nCur++ )
    1468                 :            :         {
    1469                 :          0 :             SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCur ];
    1470         [ #  # ]:          0 :             long nRight = GetEntryBoundRect(pEntry).Right();
    1471         [ #  # ]:          0 :             if( nRight > nWidth )
    1472                 :          0 :                 return sal_False;
    1473         [ #  # ]:          0 :             if( nRight > nMostRight )
    1474                 :          0 :                 nMostRight = nRight;
    1475                 :            :         }
    1476         [ #  # ]:          0 :         aHorSBar.Hide();
    1477                 :          0 :         aOutputSize.Height() += nHorSBarHeight;
    1478                 :          0 :         aVirtOutputSize.Width() = nMostRight;
    1479         [ #  # ]:          0 :         aHorSBar.SetThumbPos( 0 );
    1480                 :          0 :         Range aRange;
    1481                 :          0 :         aRange.Max() = nMostRight - 1;
    1482         [ #  # ]:          0 :         aHorSBar.SetRange( aRange  );
    1483 [ #  # ][ #  # ]:          0 :         if( aVerSBar.IsVisible() )
    1484                 :            :         {
    1485         [ #  # ]:          0 :             Size aSize( aVerSBar.GetSizePixel());
    1486                 :          0 :             aSize.Height() += nHorSBarHeight;
    1487         [ #  # ]:          0 :             aVerSBar.SetSizePixel( aSize );
    1488                 :            :         }
    1489                 :          0 :         return sal_True;
    1490                 :            :     }
    1491                 :          0 :     return sal_False;
    1492                 :            : }
    1493                 :            : 
    1494                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::CheckVerScrollBar()
    1495                 :            : {
    1496 [ #  # ][ #  # ]:          0 :     if( !pZOrderList || !aVerSBar.IsVisible() )
         [ #  # ][ #  # ]
    1497                 :          0 :         return sal_False;
    1498                 :          0 :     const MapMode& rMapMode = pView->GetMapMode();
    1499                 :          0 :     Point aOrigin( rMapMode.GetOrigin() );
    1500 [ #  # ][ #  # ]:          0 :     if(!( nWinBits & WB_VSCROLL) && !aOrigin.Y() )
                 [ #  # ]
    1501                 :            :     {
    1502                 :          0 :         long nDeepest = 0;
    1503                 :          0 :         long nHeight = aOutputSize.Height();
    1504                 :          0 :         const size_t nCount = pZOrderList->size();
    1505         [ #  # ]:          0 :         for( size_t nCur = 0; nCur < nCount; nCur++ )
    1506                 :            :         {
    1507                 :          0 :             SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCur ];
    1508         [ #  # ]:          0 :             long nBottom = GetEntryBoundRect(pEntry).Bottom();
    1509         [ #  # ]:          0 :             if( nBottom > nHeight )
    1510                 :          0 :                 return sal_False;
    1511         [ #  # ]:          0 :             if( nBottom > nDeepest )
    1512                 :          0 :                 nDeepest = nBottom;
    1513                 :            :         }
    1514         [ #  # ]:          0 :         aVerSBar.Hide();
    1515                 :          0 :         aOutputSize.Width() += nVerSBarWidth;
    1516                 :          0 :         aVirtOutputSize.Height() = nDeepest;
    1517         [ #  # ]:          0 :         aVerSBar.SetThumbPos( 0 );
    1518                 :          0 :         Range aRange;
    1519                 :          0 :         aRange.Max() = nDeepest - 1;
    1520         [ #  # ]:          0 :         aVerSBar.SetRange( aRange  );
    1521 [ #  # ][ #  # ]:          0 :         if( aHorSBar.IsVisible() )
    1522                 :            :         {
    1523         [ #  # ]:          0 :             Size aSize( aHorSBar.GetSizePixel());
    1524                 :          0 :             aSize.Width() += nVerSBarWidth;
    1525         [ #  # ]:          0 :             aHorSBar.SetSizePixel( aSize );
    1526                 :            :         }
    1527                 :          0 :         return sal_True;
    1528                 :            :     }
    1529                 :          0 :     return sal_False;
    1530                 :            : }
    1531                 :            : 
    1532                 :            : 
    1533                 :            : // hides scrollbars if they're unnecessary
    1534                 :          0 : void SvxIconChoiceCtrl_Impl::CheckScrollBars()
    1535                 :            : {
    1536                 :          0 :     CheckVerScrollBar();
    1537         [ #  # ]:          0 :     if( CheckHorScrollBar() )
    1538                 :          0 :         CheckVerScrollBar();
    1539 [ #  # ][ #  # ]:          0 :     if( aVerSBar.IsVisible() && aHorSBar.IsVisible() )
                 [ #  # ]
    1540                 :          0 :         aScrBarBox.Show();
    1541                 :            :     else
    1542                 :          0 :         aScrBarBox.Hide();
    1543                 :          0 : }
    1544                 :            : 
    1545                 :            : 
    1546                 :          0 : void SvxIconChoiceCtrl_Impl::GetFocus()
    1547                 :            : {
    1548                 :          0 :     RepaintEntries( ICNVIEW_FLAG_SELECTED );
    1549         [ #  # ]:          0 :     if( pCursor )
    1550                 :            :     {
    1551                 :          0 :         pCursor->SetFlags( ICNVIEW_FLAG_FOCUSED );
    1552                 :          0 :         ShowCursor( sal_True );
    1553                 :            :     }
    1554                 :          0 : }
    1555                 :            : 
    1556                 :          0 : void SvxIconChoiceCtrl_Impl::LoseFocus()
    1557                 :            : {
    1558                 :          0 :     StopEditTimer();
    1559         [ #  # ]:          0 :     if( pCursor )
    1560                 :          0 :         pCursor->ClearFlags( ICNVIEW_FLAG_FOCUSED );
    1561                 :          0 :     ShowCursor( sal_False );
    1562                 :            : 
    1563                 :            : //  HideFocus ();
    1564                 :            : //  pView->Invalidate ( aFocus.aRect );
    1565                 :            : 
    1566                 :          0 :     RepaintEntries( ICNVIEW_FLAG_SELECTED );
    1567                 :          0 : }
    1568                 :            : 
    1569                 :          0 : void SvxIconChoiceCtrl_Impl::SetUpdateMode( sal_Bool bUpdate )
    1570                 :            : {
    1571         [ #  # ]:          0 :     if( bUpdate != bUpdateMode )
    1572                 :            :     {
    1573                 :          0 :         bUpdateMode = bUpdate;
    1574         [ #  # ]:          0 :         if( bUpdate )
    1575                 :            :         {
    1576                 :          0 :             AdjustScrollBars();
    1577                 :          0 :             pImpCursor->Clear();
    1578                 :          0 :             pGridMap->Clear();
    1579                 :          0 :             pView->Invalidate(INVALIDATE_NOCHILDREN);
    1580                 :            :         }
    1581                 :            :     }
    1582                 :          0 : }
    1583                 :            : 
    1584                 :          0 : void SvxIconChoiceCtrl_Impl::PaintEntry( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bIsBackgroundPainted )
    1585                 :            : {
    1586                 :          0 :     Point aPos( GetEntryPos( pEntry ) );
    1587         [ #  # ]:          0 :     PaintEntry( pEntry, aPos, 0, bIsBackgroundPainted );
    1588                 :          0 : }
    1589                 :            : 
    1590                 :            : // priorities of the emphasis:  bDropTarget => bCursored => bSelected
    1591                 :          0 : void SvxIconChoiceCtrl_Impl::PaintEmphasis(
    1592                 :            :     const Rectangle& rTextRect, const Rectangle& rImageRect,
    1593                 :            :     sal_Bool bSelected, sal_Bool bDropTarget, sal_Bool bCursored, OutputDevice* pOut,
    1594                 :            :     sal_Bool bIsBackgroundPainted )
    1595                 :            : {
    1596 [ #  # ][ #  # ]:          0 :     static Color aTransparent( COL_TRANSPARENT );
    1597                 :            : 
    1598         [ #  # ]:          0 :     if( !pOut )
    1599                 :          0 :         pOut = pView;
    1600                 :            : 
    1601                 :            : #ifdef OV_CHECK_EMPH_RECTS
    1602                 :            :     {
    1603                 :            :         Color aXOld( pOut->GetFillColor() );
    1604                 :            :         pOut->SetFillColor( Color( COL_GREEN ));
    1605                 :            :         pOut->DrawRect( rTextRect );
    1606                 :            :         pOut->DrawRect( rImageRect );
    1607                 :            :         pOut->SetFillColor( aXOld );
    1608                 :            :     }
    1609                 :            : #endif
    1610                 :            : 
    1611                 :          0 :     const StyleSettings& rSettings = pOut->GetSettings().GetStyleSettings();
    1612                 :          0 :     Color aOldFillColor( pOut->GetFillColor() );
    1613                 :            : 
    1614                 :          0 :     sal_Bool bSolidTextRect = sal_False;
    1615                 :          0 :     sal_Bool bSolidImageRect = sal_False;
    1616                 :            : 
    1617 [ #  # ][ #  # ]:          0 :     if( bDropTarget && ( eSelectionMode != NO_SELECTION ) )
    1618                 :            :     {
    1619         [ #  # ]:          0 :         pOut->SetFillColor( rSettings.GetHighlightColor() );
    1620                 :          0 :         bSolidTextRect = sal_True;
    1621                 :          0 :         bSolidImageRect = sal_True;
    1622                 :            :     }
    1623                 :            :     else
    1624                 :            :     {
    1625 [ #  # ][ #  # ]:          0 :         if ( !bSelected || bCursored )
    1626                 :            :         {
    1627 [ #  # ][ #  # ]:          0 :             if( !pView->HasFontFillColor() )
    1628 [ #  # ][ #  # ]:          0 :                 pOut->SetFillColor( pOut->GetBackground().GetColor() );
    1629                 :            :             else
    1630                 :            :             {
    1631         [ #  # ]:          0 :                 const Color& rFillColor = pView->GetFont().GetFillColor();
    1632         [ #  # ]:          0 :                 pOut->SetFillColor( rFillColor );
    1633         [ #  # ]:          0 :                 if( rFillColor != aTransparent )
    1634                 :          0 :                     bSolidTextRect = sal_True;
    1635                 :            :             }
    1636                 :            :         }
    1637                 :            :     }
    1638                 :            : 
    1639                 :            :     // draw text rectangle
    1640         [ #  # ]:          0 :     if( !bSolidTextRect )
    1641                 :            :     {
    1642         [ #  # ]:          0 :         if( !bIsBackgroundPainted )
    1643         [ #  # ]:          0 :             pOut->Erase( rTextRect );
    1644                 :            :     }
    1645                 :            :     else
    1646                 :            :     {
    1647                 :          0 :         Color aOldLineColor;
    1648         [ #  # ]:          0 :         if( bCursored )
    1649                 :            :         {
    1650                 :          0 :             aOldLineColor = pOut->GetLineColor();
    1651         [ #  # ]:          0 :             pOut->SetLineColor( Color( COL_GRAY ) );
    1652                 :            :         }
    1653         [ #  # ]:          0 :         pOut->DrawRect( rTextRect );
    1654         [ #  # ]:          0 :         if( bCursored )
    1655         [ #  # ]:          0 :             pOut->SetLineColor( aOldLineColor );
    1656                 :            :     }
    1657                 :            : 
    1658                 :            :     // draw image rectangle
    1659         [ #  # ]:          0 :     if( !bSolidImageRect )
    1660                 :            :     {
    1661         [ #  # ]:          0 :         if( !bIsBackgroundPainted )
    1662         [ #  # ]:          0 :             pOut->Erase( rImageRect );
    1663                 :            :     }
    1664                 :            : // the emphasis of the images has to be drawn by the derived class (in the
    1665                 :            : // virtual function DrawEntryImage)
    1666                 :            : //  else
    1667                 :            : //      pOut->DrawRect( rImageRect );
    1668                 :            : 
    1669         [ #  # ]:          0 :     pOut->SetFillColor( aOldFillColor );
    1670                 :          0 : }
    1671                 :            : 
    1672                 :            : 
    1673                 :          0 : void SvxIconChoiceCtrl_Impl::PaintItem( const Rectangle& rRect,
    1674                 :            :     IcnViewFieldType eItem, SvxIconChoiceCtrlEntry* pEntry, sal_uInt16 nPaintFlags,
    1675                 :            :     OutputDevice* pOut, const String* pStr, ::vcl::ControlLayoutData* _pLayoutData )
    1676                 :            : {
    1677         [ #  # ]:          0 :     if( eItem == IcnViewFieldTypeText )
    1678                 :            :     {
    1679         [ #  # ]:          0 :         String aText;
    1680         [ #  # ]:          0 :         if( !pStr )
    1681 [ #  # ][ #  # ]:          0 :             aText = pView->GetEntryText( pEntry, sal_False );
                 [ #  # ]
    1682                 :            :         else
    1683         [ #  # ]:          0 :             aText = *pStr;
    1684                 :            : 
    1685         [ #  # ]:          0 :         if ( _pLayoutData )
    1686                 :            :         {
    1687                 :            :             pOut->DrawText( rRect, aText, nCurTextDrawFlags,
    1688         [ #  # ]:          0 :                 &_pLayoutData->m_aUnicodeBoundRects, &_pLayoutData->m_aDisplayText );
    1689                 :            :         }
    1690                 :            :         else
    1691                 :            :         {
    1692                 :          0 :             Color aOldFontColor = pOut->GetTextColor();
    1693         [ #  # ]:          0 :             if ( pView->AutoFontColor() )
    1694                 :            :             {
    1695         [ #  # ]:          0 :                 Color aBkgColor( pOut->GetBackground().GetColor() );
    1696                 :          0 :                 Color aFontColor;
    1697                 :          0 :                 sal_uInt16 nColor = ( aBkgColor.GetRed() + aBkgColor.GetGreen() + aBkgColor.GetBlue() ) / 3;
    1698         [ #  # ]:          0 :                 if ( nColor > 127 )
    1699                 :          0 :                     aFontColor.SetColor ( COL_BLACK );
    1700                 :            :                 else
    1701                 :          0 :                     aFontColor.SetColor( COL_WHITE );
    1702         [ #  # ]:          0 :                 pOut->SetTextColor( aFontColor );
    1703                 :            :             }
    1704                 :            : 
    1705         [ #  # ]:          0 :             pOut->DrawText( rRect, aText, nCurTextDrawFlags );
    1706                 :            : 
    1707         [ #  # ]:          0 :             if ( pView->AutoFontColor() )
    1708         [ #  # ]:          0 :                 pOut->SetTextColor( aOldFontColor );
    1709                 :            : 
    1710         [ #  # ]:          0 :             if( pEntry->IsFocused() )
    1711                 :            :             {
    1712         [ #  # ]:          0 :                 Rectangle aRect ( CalcFocusRect( (SvxIconChoiceCtrlEntry*)pEntry ) );
    1713         [ #  # ]:          0 :                 /*pView->*/ShowFocus( aRect );
    1714         [ #  # ]:          0 :                 DrawFocusRect( pOut );
    1715                 :            :             }
    1716         [ #  # ]:          0 :         }
    1717                 :            :     }
    1718                 :            :     else
    1719                 :            :     {
    1720                 :          0 :         Point aPos( rRect.TopLeft() );
    1721         [ #  # ]:          0 :         if( nPaintFlags & PAINTFLAG_HOR_CENTERED )
    1722         [ #  # ]:          0 :             aPos.X() += (rRect.GetWidth() - aImageSize.Width() ) / 2;
    1723         [ #  # ]:          0 :         if( nPaintFlags & PAINTFLAG_VER_CENTERED )
    1724         [ #  # ]:          0 :             aPos.Y() += (rRect.GetHeight() - aImageSize.Height() ) / 2;
    1725         [ #  # ]:          0 :         pView->DrawEntryImage( pEntry, aPos, *pOut );
    1726                 :            :     }
    1727                 :          0 : }
    1728                 :            : 
    1729                 :          0 : void SvxIconChoiceCtrl_Impl::PaintEntryVirtOutDev( SvxIconChoiceCtrlEntry* pEntry )
    1730                 :            : {
    1731                 :            : #ifdef OV_NO_VIRT_OUTDEV
    1732                 :            :     PaintEntry( pEntry );
    1733                 :            : #else
    1734         [ #  # ]:          0 :     if( !pEntryPaintDev )
    1735                 :            :     {
    1736 [ #  # ][ #  # ]:          0 :         pEntryPaintDev = new VirtualDevice( *pView );
    1737         [ #  # ]:          0 :         pEntryPaintDev->SetFont( pView->GetFont() );
    1738         [ #  # ]:          0 :         pEntryPaintDev->SetLineColor();
    1739                 :            :         //pEntryPaintDev->SetBackground( pView->GetBackground() );
    1740                 :            :     }
    1741         [ #  # ]:          0 :     const Rectangle& rRect = GetEntryBoundRect( pEntry );
    1742         [ #  # ]:          0 :     Rectangle aOutRect( GetOutputRect() );
    1743 [ #  # ][ #  # ]:          0 :     if( !rRect.IsOver( aOutRect ) )
    1744                 :          0 :         return;
    1745         [ #  # ]:          0 :     Wallpaper aPaper( pView->GetBackground() );
    1746         [ #  # ]:          0 :     Rectangle aRect( aPaper.GetRect() );
    1747                 :            : 
    1748                 :            :     // move rectangle, so the bounding rectangle of the entry lies in
    1749                 :            :     // VirtOut-Dev at 0,0
    1750         [ #  # ]:          0 :     aRect.Move( -rRect.Left(), -rRect.Top() );
    1751         [ #  # ]:          0 :     aPaper.SetRect( aRect );
    1752         [ #  # ]:          0 :     pEntryPaintDev->SetBackground( aPaper );
    1753         [ #  # ]:          0 :     pEntryPaintDev->SetFont( pView->GetFont() );
    1754                 :            : 
    1755         [ #  # ]:          0 :     Size aSize( rRect.GetSize() );
    1756         [ #  # ]:          0 :     pEntryPaintDev->SetOutputSizePixel( aSize );
    1757                 :            :     pEntryPaintDev->DrawOutDev(
    1758         [ #  # ]:          0 :         Point(), aSize, rRect.TopLeft(), aSize, *pView );
    1759                 :            : 
    1760         [ #  # ]:          0 :     PaintEntry( pEntry, Point(), pEntryPaintDev );
    1761                 :            : 
    1762                 :            :     pView->DrawOutDev(
    1763                 :            :         rRect.TopLeft(),
    1764                 :            :         aSize,
    1765                 :            :         Point(),
    1766                 :            :         aSize,
    1767 [ #  # ][ #  # ]:          0 :         *pEntryPaintDev );
    1768                 :            : #endif
    1769                 :            : }
    1770                 :            : 
    1771                 :            : 
    1772                 :          0 : void SvxIconChoiceCtrl_Impl::PaintEntry( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos,
    1773                 :            :     OutputDevice* pOut, sal_Bool bIsBackgroundPainted )
    1774                 :            : {
    1775         [ #  # ]:          0 :     if( !pOut )
    1776                 :          0 :         pOut = pView;
    1777                 :            : 
    1778                 :          0 :     sal_Bool bSelected = sal_False;
    1779                 :            : 
    1780         [ #  # ]:          0 :     if( eSelectionMode != NO_SELECTION )
    1781                 :          0 :         bSelected = pEntry->IsSelected();
    1782                 :            : 
    1783                 :          0 :     sal_Bool bCursored = pEntry->IsCursored();
    1784                 :          0 :     sal_Bool bDropTarget = pEntry->IsDropTarget();
    1785                 :          0 :     sal_Bool bNoEmphasis = pEntry->IsBlockingEmphasis();
    1786                 :            : 
    1787         [ #  # ]:          0 :     Font aTempFont( pOut->GetFont() );
    1788                 :            : 
    1789                 :            :     // AutoFontColor
    1790                 :            :     /*
    1791                 :            :     if ( pView->AutoFontColor() )
    1792                 :            :     {
    1793                 :            :         aTempFont.SetColor ( aFontColor );
    1794                 :            :     }
    1795                 :            :     */
    1796                 :            : 
    1797         [ #  # ]:          0 :     String aEntryText( pView->GetEntryText( pEntry, sal_False ) );
    1798         [ #  # ]:          0 :     Rectangle aTextRect( CalcTextRect(pEntry,&rPos,sal_False,&aEntryText));
    1799         [ #  # ]:          0 :     Rectangle aBmpRect( CalcBmpRect(pEntry, &rPos ) );
    1800                 :            : 
    1801                 :            :     sal_Bool    bShowSelection =
    1802                 :            :         (   (   ( bSelected && !bCursored )
    1803                 :            :             ||  bDropTarget
    1804                 :            :             )
    1805                 :            :         &&  !bNoEmphasis
    1806                 :            :         &&  ( eSelectionMode != NO_SELECTION )
    1807 [ #  # ][ #  # ]:          0 :         );
         [ #  # ][ #  # ]
                 [ #  # ]
    1808 [ #  # ][ #  # ]:          0 :     sal_Bool bActiveSelection = ( 0 != ( nWinBits & WB_NOHIDESELECTION ) ) || pView->HasFocus();
                 [ #  # ]
    1809                 :            : 
    1810         [ #  # ]:          0 :     if ( bShowSelection )
    1811                 :            :     {
    1812                 :          0 :         const StyleSettings& rSettings = pOut->GetSettings().GetStyleSettings();
    1813         [ #  # ]:          0 :         Font aNewFont( aTempFont );
    1814                 :            : 
    1815                 :            :         // font fill colors that are attributed "hard" need corresponding "hard"
    1816                 :            :         // attributed highlight colors
    1817 [ #  # ][ #  # ]:          0 :         if( pView->HasFontFillColor() )
    1818                 :            :         {
    1819 [ #  # ][ #  # ]:          0 :             if( (nWinBits & WB_NOHIDESELECTION) || pView->HasFocus() )
         [ #  # ][ #  # ]
    1820         [ #  # ]:          0 :                 aNewFont.SetFillColor( rSettings.GetHighlightColor() );
    1821                 :            :             else
    1822         [ #  # ]:          0 :                 aNewFont.SetFillColor( rSettings.GetDeactiveColor() );
    1823                 :            :         }
    1824                 :            : 
    1825                 :          0 :         Color aWinCol = rSettings.GetWindowTextColor();
    1826 [ #  # ][ #  # ]:          0 :         if ( !bActiveSelection && rSettings.GetFaceColor().IsBright() == aWinCol.IsBright() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1827         [ #  # ]:          0 :             aNewFont.SetColor( rSettings.GetWindowTextColor() );
    1828                 :            :         else
    1829         [ #  # ]:          0 :             aNewFont.SetColor( rSettings.GetHighlightTextColor() );
    1830                 :            : 
    1831         [ #  # ]:          0 :         pOut->SetFont( aNewFont );
    1832                 :            : 
    1833 [ #  # ][ #  # ]:          0 :         pOut->SetFillColor( pOut->GetBackground().GetColor() );
    1834 [ #  # ][ #  # ]:          0 :         pOut->DrawRect( CalcFocusRect( pEntry ) );
    1835 [ #  # ][ #  # ]:          0 :         pOut->SetFillColor( );
    1836                 :            :     }
    1837                 :            : 
    1838                 :          0 :     sal_Bool bResetClipRegion = sal_False;
    1839 [ #  # ][ #  # ]:          0 :     if( !pView->IsClipRegion() && (aVerSBar.IsVisible() || aHorSBar.IsVisible()) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1840                 :            :     {
    1841         [ #  # ]:          0 :         Rectangle aOutputArea( GetOutputRect() );
    1842 [ #  # ][ #  # ]:          0 :         if( aOutputArea.IsOver(aTextRect) || aOutputArea.IsOver(aBmpRect) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1843                 :            :         {
    1844 [ #  # ][ #  # ]:          0 :             pView->SetClipRegion( aOutputArea );
                 [ #  # ]
    1845                 :          0 :             bResetClipRegion = sal_True;
    1846                 :            :         }
    1847                 :            :     }
    1848                 :            : 
    1849                 :            : #ifdef OV_DRAWBOUNDRECT
    1850                 :            :     {
    1851                 :            :         Color aXOldColor = pOut->GetLineColor();
    1852                 :            :         pOut->SetLineColor( Color( COL_LIGHTRED ) );
    1853                 :            :         Rectangle aXRect( pEntry->aRect );
    1854                 :            :         aXRect.SetPos( rPos );
    1855                 :            :         pOut->DrawRect( aXRect );
    1856                 :            :         pOut->SetLineColor( aXOldColor );
    1857                 :            :     }
    1858                 :            : #endif
    1859                 :            : 
    1860                 :          0 :     sal_Bool bLargeIconMode = WB_ICON == ( nWinBits & (VIEWMODE_MASK) );
    1861                 :          0 :     sal_uInt16 nBmpPaintFlags = PAINTFLAG_VER_CENTERED;
    1862         [ #  # ]:          0 :     if ( bLargeIconMode )
    1863                 :          0 :         nBmpPaintFlags |= PAINTFLAG_HOR_CENTERED;
    1864         [ #  # ]:          0 :     sal_uInt16 nTextPaintFlags = bLargeIconMode ? PAINTFLAG_HOR_CENTERED : PAINTFLAG_VER_CENTERED;
    1865                 :            : 
    1866         [ #  # ]:          0 :     if( !bNoEmphasis )
    1867         [ #  # ]:          0 :         PaintEmphasis(aTextRect,aBmpRect,bSelected,bDropTarget,bCursored,pOut,bIsBackgroundPainted);
    1868                 :            : 
    1869         [ #  # ]:          0 :     if ( bShowSelection )
    1870                 :            :         pView->DrawSelectionBackground( CalcFocusRect( pEntry ),
    1871 [ #  # ][ #  # ]:          0 :         bActiveSelection ? 1 : 2 /* highlight */, sal_False /* check */, sal_True /* border */, sal_False /* ext border only */ );
                 [ #  # ]
    1872                 :            : 
    1873         [ #  # ]:          0 :     PaintItem( aBmpRect, IcnViewFieldTypeImage, pEntry, nBmpPaintFlags, pOut );
    1874                 :            : 
    1875                 :            :     PaintItem( aTextRect, IcnViewFieldTypeText, pEntry,
    1876         [ #  # ]:          0 :         nTextPaintFlags, pOut );
    1877                 :            : 
    1878                 :            :     // draw highlight frame
    1879 [ #  # ][ #  # ]:          0 :     if( pEntry == pCurHighlightFrame && !bNoEmphasis )
    1880 [ #  # ][ #  # ]:          0 :         DrawHighlightFrame( pOut, CalcFocusRect( pEntry ), sal_False );
    1881                 :            : 
    1882         [ #  # ]:          0 :     pOut->SetFont( aTempFont );
    1883         [ #  # ]:          0 :     if( bResetClipRegion )
    1884 [ #  # ][ #  # ]:          0 :         pView->SetClipRegion();
                 [ #  # ]
    1885                 :          0 : }
    1886                 :            : 
    1887                 :          0 : void SvxIconChoiceCtrl_Impl::SetEntryPos( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos,
    1888                 :            :     sal_Bool bAdjustAtGrid, sal_Bool bCheckScrollBars, sal_Bool bKeepGridMap )
    1889                 :            : {
    1890         [ #  # ]:          0 :     ShowCursor( sal_False );
    1891         [ #  # ]:          0 :     Rectangle aBoundRect( GetEntryBoundRect( pEntry ));
    1892         [ #  # ]:          0 :     pView->Invalidate( aBoundRect );
    1893         [ #  # ]:          0 :     ToTop( pEntry );
    1894         [ #  # ]:          0 :     if( !IsAutoArrange() )
    1895                 :            :     {
    1896                 :          0 :         sal_Bool bAdjustVirtSize = sal_False;
    1897         [ #  # ]:          0 :         if( rPos != aBoundRect.TopLeft() )
    1898                 :            :         {
    1899                 :            :             Point aGridOffs(
    1900                 :          0 :                 pEntry->aGridRect.TopLeft() - pEntry->aRect.TopLeft() );
    1901         [ #  # ]:          0 :             pImpCursor->Clear();
    1902         [ #  # ]:          0 :             if( !bKeepGridMap )
    1903         [ #  # ]:          0 :                 pGridMap->Clear();
    1904                 :          0 :             aBoundRect.SetPos( rPos );
    1905                 :          0 :             pEntry->aRect = aBoundRect;
    1906                 :          0 :             pEntry->aGridRect.SetPos( rPos + aGridOffs );
    1907                 :          0 :             bAdjustVirtSize = sal_True;
    1908                 :            :         }
    1909         [ #  # ]:          0 :         if( bAdjustAtGrid )
    1910                 :            :         {
    1911         [ #  # ]:          0 :             if( bAdjustVirtSize )
    1912                 :            :             {
    1913                 :            :                 // By aligning the (in some cases newly positioned) entry, it
    1914                 :            :                 // can become completely visible again, so that maybe we don't
    1915                 :            :                 // need a scrollbar after all. To avoid suddenly turning the
    1916                 :            :                 // scrollbar(s) on and then off again, we use the aligned
    1917                 :            :                 // bounding rectangle of the entry to enlarge the virtual
    1918                 :            :                 // output size. The virtual size has to be adapted, because
    1919                 :            :                 // AdjustEntryAtGrid depends on it.
    1920         [ #  # ]:          0 :                 const Rectangle& rBoundRect = GetEntryBoundRect( pEntry );
    1921         [ #  # ]:          0 :                 Rectangle aCenterRect( CalcBmpRect( pEntry, 0 ));
    1922         [ #  # ]:          0 :                 Point aNewPos( AdjustAtGrid( aCenterRect, rBoundRect ) );
    1923 [ #  # ][ #  # ]:          0 :                 Rectangle aNewBoundRect( aNewPos, pEntry->aRect.GetSize());
    1924         [ #  # ]:          0 :                 AdjustVirtSize( aNewBoundRect );
    1925                 :          0 :                 bAdjustVirtSize = sal_False;
    1926                 :            :             }
    1927         [ #  # ]:          0 :             AdjustEntryAtGrid( pEntry );
    1928         [ #  # ]:          0 :             ToTop( pEntry );
    1929                 :            :         }
    1930         [ #  # ]:          0 :         if( bAdjustVirtSize )
    1931         [ #  # ]:          0 :             AdjustVirtSize( pEntry->aRect );
    1932                 :            : 
    1933 [ #  # ][ #  # ]:          0 :         if( bCheckScrollBars && bUpdateMode )
    1934         [ #  # ]:          0 :             CheckScrollBars();
    1935                 :            : 
    1936         [ #  # ]:          0 :         pView->Invalidate( pEntry->aRect );
    1937         [ #  # ]:          0 :         pGridMap->OccupyGrids( pEntry );
    1938                 :            :     }
    1939                 :            :     else
    1940                 :            :     {
    1941         [ #  # ]:          0 :         SvxIconChoiceCtrlEntry* pPrev = FindEntryPredecessor( pEntry, rPos );
    1942         [ #  # ]:          0 :         SetEntryPredecessor( pEntry, pPrev );
    1943         [ #  # ]:          0 :         aAutoArrangeTimer.Start();
    1944                 :            :     }
    1945         [ #  # ]:          0 :     ShowCursor( sal_True );
    1946                 :          0 : }
    1947                 :            : 
    1948                 :          0 : void SvxIconChoiceCtrl_Impl::SetNoSelection()
    1949                 :            : {
    1950                 :            :     // block recursive calls via SelectEntry
    1951         [ #  # ]:          0 :     if( !(nFlags & F_CLEARING_SELECTION ))
    1952                 :            :     {
    1953                 :          0 :         nFlags |= F_CLEARING_SELECTION;
    1954                 :          0 :         DeselectAllBut( 0, sal_True );
    1955                 :          0 :         nFlags &= ~F_CLEARING_SELECTION;
    1956                 :            :     }
    1957                 :          0 : }
    1958                 :            : 
    1959                 :          0 : SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetEntry( const Point& rDocPos, sal_Bool bHit )
    1960                 :            : {
    1961                 :          0 :     CheckBoundingRects();
    1962                 :            :     // search through z-order list from the end
    1963                 :          0 :     size_t nCount = pZOrderList->size();
    1964         [ #  # ]:          0 :     while( nCount )
    1965                 :            :     {
    1966                 :          0 :         nCount--;
    1967                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCount ];
    1968         [ #  # ]:          0 :         if( pEntry->aRect.IsInside( rDocPos ) )
    1969                 :            :         {
    1970         [ #  # ]:          0 :             if( bHit )
    1971                 :            :             {
    1972         [ #  # ]:          0 :                 Rectangle aRect = CalcBmpRect( pEntry );
    1973                 :          0 :                 aRect.Top() -= 3;
    1974                 :          0 :                 aRect.Bottom() += 3;
    1975                 :          0 :                 aRect.Left() -= 3;
    1976                 :          0 :                 aRect.Right() += 3;
    1977 [ #  # ][ #  # ]:          0 :                 if( aRect.IsInside( rDocPos ) )
    1978                 :          0 :                     return pEntry;
    1979         [ #  # ]:          0 :                 aRect = CalcTextRect( pEntry );
    1980 [ #  # ][ #  # ]:          0 :                 if( aRect.IsInside( rDocPos ) )
    1981                 :          0 :                     return pEntry;
    1982                 :            :             }
    1983                 :            :             else
    1984                 :          0 :                 return pEntry;
    1985                 :            :         }
    1986                 :            :     }
    1987                 :          0 :     return 0;
    1988                 :            : }
    1989                 :            : 
    1990                 :          0 : Point SvxIconChoiceCtrl_Impl::GetEntryPos( SvxIconChoiceCtrlEntry* pEntry )
    1991                 :            : {
    1992                 :          0 :     return pEntry->aRect.TopLeft();
    1993                 :            : }
    1994                 :            : 
    1995                 :          0 : void SvxIconChoiceCtrl_Impl::MakeEntryVisible( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bBound )
    1996                 :            : {
    1997         [ #  # ]:          0 :     if ( bBound )
    1998                 :            :     {
    1999                 :          0 :         const Rectangle& rRect = GetEntryBoundRect( pEntry );
    2000                 :          0 :         MakeVisible( rRect );
    2001                 :            :     }
    2002                 :            :     else
    2003                 :            :     {
    2004         [ #  # ]:          0 :         Rectangle aRect = CalcBmpRect( pEntry );
    2005 [ #  # ][ #  # ]:          0 :         aRect.Union( CalcTextRect( pEntry ) );
    2006                 :          0 :         aRect.Top() += TBOFFS_BOUND;
    2007                 :          0 :         aRect.Bottom() += TBOFFS_BOUND;
    2008                 :          0 :         aRect.Left() += LROFFS_BOUND;
    2009                 :          0 :         aRect.Right() += LROFFS_BOUND;
    2010         [ #  # ]:          0 :         MakeVisible( aRect );
    2011                 :            :     }
    2012                 :          0 : }
    2013                 :            : 
    2014                 :          0 : const Rectangle& SvxIconChoiceCtrl_Impl::GetEntryBoundRect( SvxIconChoiceCtrlEntry* pEntry )
    2015                 :            : {
    2016         [ #  # ]:          0 :     if( !IsBoundingRectValid( pEntry->aRect ))
    2017                 :          0 :         FindBoundingRect( pEntry );
    2018                 :          0 :     return pEntry->aRect;
    2019                 :            : }
    2020                 :            : 
    2021                 :          0 : Rectangle SvxIconChoiceCtrl_Impl::CalcBmpRect( SvxIconChoiceCtrlEntry* pEntry, const Point* pPos )
    2022                 :            : {
    2023         [ #  # ]:          0 :     Rectangle aBound = GetEntryBoundRect( pEntry );
    2024         [ #  # ]:          0 :     if( pPos )
    2025                 :          0 :         aBound.SetPos( *pPos );
    2026                 :          0 :     Point aPos( aBound.TopLeft() );
    2027                 :            : 
    2028      [ #  #  # ]:          0 :     switch( nWinBits & (VIEWMODE_MASK) )
    2029                 :            :     {
    2030                 :            :         case WB_ICON:
    2031                 :            :         {
    2032         [ #  # ]:          0 :             aPos.X() += ( aBound.GetWidth() - aImageSize.Width() ) / 2;
    2033         [ #  # ]:          0 :             return Rectangle( aPos, aImageSize );
    2034                 :            :         }
    2035                 :            : 
    2036                 :            :         case WB_SMALLICON:
    2037                 :            :         case WB_DETAILS:
    2038         [ #  # ]:          0 :             aPos.Y() += ( aBound.GetHeight() - aImageSize.Height() ) / 2;
    2039                 :            :             //TODO: determine horizontal distance to bounding rectangle
    2040         [ #  # ]:          0 :             return Rectangle( aPos, aImageSize );
    2041                 :            : 
    2042                 :            :         default:
    2043                 :            :             OSL_FAIL("IconView: Viewmode not set");
    2044                 :          0 :             return aBound;
    2045                 :            :     }
    2046                 :            : }
    2047                 :            : 
    2048                 :          0 : Rectangle SvxIconChoiceCtrl_Impl::CalcTextRect( SvxIconChoiceCtrlEntry* pEntry,
    2049                 :            :     const Point* pEntryPos, sal_Bool bEdit, const String* pStr )
    2050                 :            : {
    2051         [ #  # ]:          0 :     String aEntryText;
    2052         [ #  # ]:          0 :     if( !pStr )
    2053 [ #  # ][ #  # ]:          0 :         aEntryText = pView->GetEntryText( pEntry, bEdit );
                 [ #  # ]
    2054                 :            :     else
    2055         [ #  # ]:          0 :         aEntryText = *pStr;
    2056                 :            : 
    2057         [ #  # ]:          0 :     const Rectangle aMaxTextRect( CalcMaxTextRect( pEntry ) );
    2058         [ #  # ]:          0 :     Rectangle aBound( GetEntryBoundRect( pEntry ) );
    2059         [ #  # ]:          0 :     if( pEntryPos )
    2060                 :          0 :         aBound.SetPos( *pEntryPos );
    2061                 :            : 
    2062                 :          0 :     Rectangle aTextRect( aMaxTextRect );
    2063         [ #  # ]:          0 :     if( !bEdit )
    2064         [ #  # ]:          0 :         aTextRect = pView->GetTextRect( aTextRect, aEntryText, nCurTextDrawFlags );
    2065                 :            : 
    2066         [ #  # ]:          0 :     Size aTextSize( aTextRect.GetSize() );
    2067                 :            : 
    2068                 :          0 :     Point aPos( aBound.TopLeft() );
    2069         [ #  # ]:          0 :     long nBoundWidth = aBound.GetWidth();
    2070         [ #  # ]:          0 :     long nBoundHeight = aBound.GetHeight();
    2071                 :            : 
    2072      [ #  #  # ]:          0 :     switch( nWinBits & (VIEWMODE_MASK) )
    2073                 :            :     {
    2074                 :            :         case WB_ICON:
    2075                 :          0 :             aPos.Y() += aImageSize.Height();
    2076                 :          0 :             aPos.Y() += VER_DIST_BMP_STRING;
    2077                 :            :             // at little more space when editing
    2078         [ #  # ]:          0 :             if( bEdit )
    2079                 :            :             {
    2080                 :            :                 // +20%
    2081                 :          0 :                 long nMinWidth = (( (aImageSize.Width()*10) / 100 ) * 2 ) +
    2082                 :          0 :                                  aImageSize.Width();
    2083         [ #  # ]:          0 :                 if( nMinWidth > nBoundWidth )
    2084                 :          0 :                     nMinWidth = nBoundWidth;
    2085                 :            : 
    2086         [ #  # ]:          0 :                 if( aTextSize.Width() < nMinWidth )
    2087                 :          0 :                     aTextSize.Width() = nMinWidth;
    2088                 :            : 
    2089                 :            :                 // when editing, overlap with the area below is allowed
    2090         [ #  # ]:          0 :                 Size aOptSize = aMaxTextRect.GetSize();
    2091         [ #  # ]:          0 :                 if( aOptSize.Height() > aTextSize.Height() )
    2092                 :          0 :                     aTextSize.Height() = aOptSize.Height();
    2093                 :            :             }
    2094                 :          0 :             aPos.X() += (nBoundWidth - aTextSize.Width()) / 2;
    2095                 :          0 :             break;
    2096                 :            : 
    2097                 :            :         case WB_SMALLICON:
    2098                 :            :         case WB_DETAILS:
    2099                 :          0 :             aPos.X() += aImageSize.Width();
    2100                 :          0 :             aPos.X() += HOR_DIST_BMP_STRING;
    2101                 :          0 :             aPos.Y() += (nBoundHeight - aTextSize.Height()) / 2;
    2102                 :          0 :             break;
    2103                 :            :     }
    2104 [ #  # ][ #  # ]:          0 :     return Rectangle( aPos, aTextSize );
    2105                 :            : }
    2106                 :            : 
    2107                 :            : 
    2108                 :          0 : long SvxIconChoiceCtrl_Impl::CalcBoundingWidth( SvxIconChoiceCtrlEntry* pEntry ) const
    2109                 :            : {
    2110                 :          0 :     long nStringWidth = GetItemSize( pEntry, IcnViewFieldTypeText ).Width();
    2111                 :            : //  nStringWidth += 2*LROFFS_TEXT;
    2112                 :          0 :     long nWidth = 0;
    2113                 :            : 
    2114      [ #  #  # ]:          0 :     switch( nWinBits & (VIEWMODE_MASK) )
    2115                 :            :     {
    2116                 :            :         case WB_ICON:
    2117                 :          0 :             nWidth = Max( nStringWidth, aImageSize.Width() );
    2118                 :          0 :             break;
    2119                 :            : 
    2120                 :            :         case WB_SMALLICON:
    2121                 :            :         case WB_DETAILS:
    2122                 :          0 :             nWidth = aImageSize.Width();
    2123                 :          0 :             nWidth += HOR_DIST_BMP_STRING;
    2124                 :          0 :             nWidth += nStringWidth;
    2125                 :          0 :             break;
    2126                 :            :     }
    2127                 :          0 :     return nWidth;
    2128                 :            : }
    2129                 :            : 
    2130                 :          0 : long SvxIconChoiceCtrl_Impl::CalcBoundingHeight( SvxIconChoiceCtrlEntry* pEntry ) const
    2131                 :            : {
    2132                 :          0 :     long nStringHeight = GetItemSize( pEntry, IcnViewFieldTypeText).Height();
    2133                 :          0 :     long nHeight = 0;
    2134                 :            : 
    2135      [ #  #  # ]:          0 :     switch( nWinBits & (VIEWMODE_MASK) )
    2136                 :            :     {
    2137                 :            :         case WB_ICON:
    2138                 :          0 :             nHeight = aImageSize.Height();
    2139                 :          0 :             nHeight += VER_DIST_BMP_STRING;
    2140                 :          0 :             nHeight += nStringHeight;
    2141                 :          0 :             break;
    2142                 :            : 
    2143                 :            :         case WB_SMALLICON:
    2144                 :            :         case WB_DETAILS:
    2145                 :          0 :             nHeight = Max( aImageSize.Height(), nStringHeight );
    2146                 :          0 :             break;
    2147                 :            :     }
    2148         [ #  # ]:          0 :     if( nHeight > nMaxBoundHeight )
    2149                 :            :     {
    2150                 :          0 :         ((SvxIconChoiceCtrl_Impl*)this)->nMaxBoundHeight = nHeight;
    2151                 :          0 :         ((SvxIconChoiceCtrl_Impl*)this)->aHorSBar.SetLineSize( GetScrollBarLineSize() );
    2152                 :          0 :         ((SvxIconChoiceCtrl_Impl*)this)->aVerSBar.SetLineSize( GetScrollBarLineSize() );
    2153                 :            :     }
    2154                 :          0 :     return nHeight;
    2155                 :            : }
    2156                 :            : 
    2157                 :          0 : Size SvxIconChoiceCtrl_Impl::CalcBoundingSize( SvxIconChoiceCtrlEntry* pEntry ) const
    2158                 :            : {
    2159                 :            :     return Size( CalcBoundingWidth( pEntry ),
    2160                 :          0 :                  CalcBoundingHeight( pEntry ) );
    2161                 :            : }
    2162                 :            : 
    2163                 :          0 : void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart()
    2164                 :            : {
    2165                 :          0 :     nMaxBoundHeight = 0;
    2166                 :          0 :     pZOrderList->clear();
    2167                 :            :     size_t nCur;
    2168                 :            :     SvxIconChoiceCtrlEntry* pEntry;
    2169                 :          0 :     const size_t nCount = aEntries.size();
    2170                 :            : 
    2171 [ #  # ][ #  # ]:          0 :     if( !IsAutoArrange() || !pHead )
                 [ #  # ]
    2172                 :            :     {
    2173         [ #  # ]:          0 :         for( nCur = 0; nCur < nCount; nCur++ )
    2174                 :            :         {
    2175         [ #  # ]:          0 :             pEntry = aEntries[ nCur ];
    2176         [ #  # ]:          0 :             if( IsBoundingRectValid( pEntry->aRect ))
    2177                 :            :             {
    2178         [ #  # ]:          0 :                 Size aBoundSize( pEntry->aRect.GetSize() );
    2179         [ #  # ]:          0 :                 if( aBoundSize.Height() > nMaxBoundHeight )
    2180                 :          0 :                     nMaxBoundHeight = aBoundSize.Height();
    2181                 :            :             }
    2182                 :            :             else
    2183         [ #  # ]:          0 :                 FindBoundingRect( pEntry );
    2184         [ #  # ]:          0 :             pZOrderList->push_back( pEntry );
    2185                 :            :         }
    2186                 :            :     }
    2187                 :            :     else
    2188                 :            :     {
    2189                 :          0 :         nCur = 0;
    2190                 :          0 :         pEntry = pHead;
    2191         [ #  # ]:          0 :         while( nCur != nCount )
    2192                 :            :         {
    2193                 :            :             DBG_ASSERT(pEntry->pflink&&pEntry->pblink,"SvxIconChoiceCtrl_Impl::RecalcAllBoundingRect > Bad link(s)");
    2194         [ #  # ]:          0 :             if( IsBoundingRectValid( pEntry->aRect ))
    2195                 :            :             {
    2196         [ #  # ]:          0 :                 Size aBoundSize( pEntry->aRect.GetSize() );
    2197         [ #  # ]:          0 :                 if( aBoundSize.Height() > nMaxBoundHeight )
    2198                 :          0 :                     nMaxBoundHeight = aBoundSize.Height();
    2199                 :            :             }
    2200                 :            :             else
    2201         [ #  # ]:          0 :                 FindBoundingRect( pEntry );
    2202         [ #  # ]:          0 :             pZOrderList->push_back( pEntry );
    2203                 :          0 :             pEntry = pEntry->pflink;
    2204                 :          0 :             nCur++;
    2205                 :            :         }
    2206                 :            :     }
    2207         [ #  # ]:          0 :     AdjustScrollBars();
    2208                 :          0 : }
    2209                 :            : 
    2210                 :          0 : void SvxIconChoiceCtrl_Impl::FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry )
    2211                 :            : {
    2212                 :            :     DBG_ASSERT(!pEntry->IsPosLocked(),"Locked entry pos in FindBoundingRect");
    2213 [ #  # ][ #  # ]:          0 :     if( pEntry->IsPosLocked() && IsBoundingRectValid( pEntry->aRect) )
                 [ #  # ]
    2214                 :            :     {
    2215         [ #  # ]:          0 :         AdjustVirtSize( pEntry->aRect );
    2216                 :          0 :         return;
    2217                 :            :     }
    2218         [ #  # ]:          0 :     Size aSize( CalcBoundingSize( pEntry ) );
    2219 [ #  # ][ #  # ]:          0 :     Point aPos(pGridMap->GetGridRect(pGridMap->GetUnoccupiedGrid(sal_True)).TopLeft());
    2220         [ #  # ]:          0 :     SetBoundingRect_Impl( pEntry, aPos, aSize );
    2221                 :            : }
    2222                 :            : 
    2223                 :          0 : void SvxIconChoiceCtrl_Impl::SetBoundingRect_Impl( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos,
    2224                 :            :     const Size& /*rBoundingSize*/ )
    2225                 :            : {
    2226         [ #  # ]:          0 :     Rectangle aGridRect( rPos, Size(nGridDX, nGridDY) );
    2227                 :          0 :     pEntry->aGridRect = aGridRect;
    2228         [ #  # ]:          0 :     Center( pEntry );
    2229         [ #  # ]:          0 :     AdjustVirtSize( pEntry->aRect );
    2230         [ #  # ]:          0 :     pGridMap->OccupyGrids( pEntry );
    2231                 :          0 : }
    2232                 :            : 
    2233                 :            : 
    2234                 :          0 : void SvxIconChoiceCtrl_Impl::SetCursor( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSyncSingleSelection,
    2235                 :            :     sal_Bool bShowFocusAsync )
    2236                 :            : {
    2237         [ #  # ]:          0 :     if( pEntry == pCursor )
    2238                 :            :     {
    2239 [ #  # ][ #  # ]:          0 :         if( pCursor && eSelectionMode == SINGLE_SELECTION && bSyncSingleSelection &&
           [ #  #  #  # ]
                 [ #  # ]
    2240                 :          0 :                 !pCursor->IsSelected() )
    2241                 :          0 :             SelectEntry( pCursor, sal_True, sal_True );
    2242                 :          0 :         return;
    2243                 :            :     }
    2244                 :          0 :     ShowCursor( sal_False );
    2245                 :          0 :     SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
    2246                 :          0 :     pCursor = pEntry;
    2247         [ #  # ]:          0 :     if( pOldCursor )
    2248                 :            :     {
    2249                 :          0 :         pOldCursor->ClearFlags( ICNVIEW_FLAG_FOCUSED );
    2250 [ #  # ][ #  # ]:          0 :         if( eSelectionMode == SINGLE_SELECTION && bSyncSingleSelection )
    2251                 :          0 :             SelectEntry( pOldCursor, sal_False, sal_True ); // deselect old cursor
    2252                 :            :     }
    2253         [ #  # ]:          0 :     if( pCursor )
    2254                 :            :     {
    2255                 :          0 :         ToTop( pCursor );
    2256                 :          0 :         pCursor->SetFlags( ICNVIEW_FLAG_FOCUSED );
    2257 [ #  # ][ #  # ]:          0 :         if( eSelectionMode == SINGLE_SELECTION && bSyncSingleSelection )
    2258                 :          0 :             SelectEntry( pCursor, sal_True, sal_True );
    2259         [ #  # ]:          0 :         if( !bShowFocusAsync )
    2260                 :          0 :             ShowCursor( sal_True );
    2261                 :            :         else
    2262                 :            :         {
    2263         [ #  # ]:          0 :             if( !nUserEventShowCursor )
    2264                 :            :                 nUserEventShowCursor =
    2265                 :            :                     Application::PostUserEvent( LINK( this, SvxIconChoiceCtrl_Impl, UserEventHdl),
    2266         [ #  # ]:          0 :                         EVENTID_SHOW_CURSOR );
    2267                 :            :         }
    2268                 :            :     }
    2269                 :            : }
    2270                 :            : 
    2271                 :            : 
    2272                 :          0 : void SvxIconChoiceCtrl_Impl::ShowCursor( sal_Bool bShow )
    2273                 :            : {
    2274 [ #  # ][ #  # ]:          0 :     if( !pCursor || !bShow || !pView->HasFocus() )
         [ #  # ][ #  # ]
                 [ #  # ]
    2275                 :            :     {
    2276         [ #  # ]:          0 :         pView->HideFocus();
    2277                 :          0 :         return;
    2278                 :            :     }
    2279         [ #  # ]:          0 :     Rectangle aRect ( CalcFocusRect( pCursor ) );
    2280         [ #  # ]:          0 :     /*pView->*/ShowFocus( aRect );
    2281                 :            : }
    2282                 :            : 
    2283                 :            : 
    2284                 :          0 : void SvxIconChoiceCtrl_Impl::HideDDIcon()
    2285                 :            : {
    2286                 :          0 :     pView->Update();
    2287                 :          0 :     ImpHideDDIcon();
    2288                 :          0 :     pDDBufDev = pDDDev;
    2289                 :          0 :     pDDDev = 0;
    2290                 :          0 : }
    2291                 :            : 
    2292                 :          0 : void SvxIconChoiceCtrl_Impl::ImpHideDDIcon()
    2293                 :            : {
    2294         [ #  # ]:          0 :     if( pDDDev )
    2295                 :            :     {
    2296                 :          0 :         Size aSize( pDDDev->GetOutputSizePixel() );
    2297                 :            :         // restore pView
    2298         [ #  # ]:          0 :         pView->DrawOutDev( aDDLastRectPos, aSize, Point(), aSize, *pDDDev );
    2299                 :            :     }
    2300                 :          0 : }
    2301                 :            : 
    2302                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::HandleScrollCommand( const CommandEvent& rCmd )
    2303                 :            : {
    2304         [ #  # ]:          0 :     Rectangle aDocRect( GetDocumentRect() );
    2305         [ #  # ]:          0 :     Rectangle aVisRect( GetVisibleRect() );
    2306 [ #  # ][ #  # ]:          0 :     if( aVisRect.IsInside( aDocRect ))
    2307                 :          0 :         return sal_False;
    2308         [ #  # ]:          0 :     Size aDocSize( aDocRect.GetSize() );
    2309         [ #  # ]:          0 :     Size aVisSize( aVisRect.GetSize() );
    2310                 :          0 :     sal_Bool bHor = aDocSize.Width() > aVisSize.Width();
    2311                 :          0 :     sal_Bool bVer = aDocSize.Height() > aVisSize.Height();
    2312                 :            : 
    2313                 :          0 :     long nScrollDX = 0, nScrollDY = 0;
    2314                 :            : 
    2315   [ #  #  #  # ]:          0 :     switch( rCmd.GetCommand() )
    2316                 :            :     {
    2317                 :            :         case COMMAND_STARTAUTOSCROLL:
    2318                 :            :         {
    2319         [ #  # ]:          0 :             pView->EndTracking();
    2320                 :          0 :             sal_uInt16 nScrollFlags = 0;
    2321         [ #  # ]:          0 :             if( bHor )
    2322                 :          0 :                 nScrollFlags |= AUTOSCROLL_HORZ;
    2323         [ #  # ]:          0 :             if( bVer )
    2324                 :          0 :                 nScrollFlags |= AUTOSCROLL_VERT;
    2325         [ #  # ]:          0 :             if( nScrollFlags )
    2326                 :            :             {
    2327         [ #  # ]:          0 :                 pView->StartAutoScroll( nScrollFlags );
    2328                 :          0 :                 return sal_True;
    2329                 :            :             }
    2330                 :            :         }
    2331                 :          0 :         break;
    2332                 :            : 
    2333                 :            :         case COMMAND_WHEEL:
    2334                 :            :         {
    2335         [ #  # ]:          0 :             const CommandWheelData* pData = rCmd.GetWheelData();
    2336 [ #  # ][ #  # ]:          0 :             if( pData && (COMMAND_WHEEL_SCROLL == pData->GetMode()) && !pData->IsHorz() )
         [ #  # ][ #  # ]
    2337                 :            :             {
    2338                 :          0 :                 sal_uLong nScrollLines = pData->GetScrollLines();
    2339         [ #  # ]:          0 :                 if( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
    2340                 :            :                 {
    2341                 :          0 :                     nScrollDY = GetScrollBarPageSize( aVisSize.Width() );
    2342         [ #  # ]:          0 :                     if( pData->GetDelta() < 0 )
    2343                 :          0 :                         nScrollDY *= -1;
    2344                 :            :                 }
    2345                 :            :                 else
    2346                 :            :                 {
    2347                 :          0 :                     nScrollDY = pData->GetNotchDelta() * (long)nScrollLines;
    2348                 :          0 :                     nScrollDY *= GetScrollBarLineSize();
    2349                 :            :                 }
    2350                 :            :             }
    2351                 :            :         }
    2352                 :          0 :         break;
    2353                 :            : 
    2354                 :            :         case COMMAND_AUTOSCROLL:
    2355                 :            :         {
    2356         [ #  # ]:          0 :             const CommandScrollData* pData = rCmd.GetAutoScrollData();
    2357         [ #  # ]:          0 :             if( pData )
    2358                 :            :             {
    2359                 :          0 :                 nScrollDX = pData->GetDeltaX() * GetScrollBarLineSize();
    2360                 :          0 :                 nScrollDY = pData->GetDeltaY() * GetScrollBarLineSize();
    2361                 :            :             }
    2362                 :            :         }
    2363                 :          0 :         break;
    2364                 :            :     }
    2365                 :            : 
    2366 [ #  # ][ #  # ]:          0 :     if( nScrollDX || nScrollDY )
    2367                 :            :     {
    2368                 :          0 :         aVisRect.Top() -= nScrollDY;
    2369                 :          0 :         aVisRect.Bottom() -= nScrollDY;
    2370                 :          0 :         aVisRect.Left() -= nScrollDX;
    2371                 :          0 :         aVisRect.Right() -= nScrollDX;
    2372         [ #  # ]:          0 :         MakeVisible( aVisRect );
    2373                 :          0 :         return sal_True;
    2374                 :            :     }
    2375                 :          0 :     return sal_False;
    2376                 :            : }
    2377                 :            : 
    2378                 :            : 
    2379                 :          0 : void SvxIconChoiceCtrl_Impl::Command( const CommandEvent& rCEvt )
    2380                 :            : {
    2381                 :            :     // scroll mouse event?
    2382   [ #  #  #  #  :          0 :     if( (rCEvt.GetCommand() == COMMAND_WHEEL) ||
           #  # ][ #  # ]
    2383                 :          0 :         (rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
    2384                 :          0 :         (rCEvt.GetCommand() == COMMAND_AUTOSCROLL) )
    2385                 :            :     {
    2386         [ #  # ]:          0 :         if( HandleScrollCommand( rCEvt ) )
    2387                 :          0 :             return;
    2388                 :            :     }
    2389                 :            : }
    2390                 :            : 
    2391                 :          0 : void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry )
    2392                 :            : {
    2393   [ #  #  #  # ]:          0 :     if( !pZOrderList->empty()
                 [ #  # ]
    2394                 :          0 :     &&  pEntry != pZOrderList->back()
    2395                 :            :     ) {
    2396 [ #  # ][ #  # ]:          0 :         for(
    2397                 :          0 :             SvxIconChoiceCtrlEntryList_impl::iterator it = pZOrderList->begin();
    2398                 :          0 :             it != pZOrderList->end();
    2399                 :            :             ++it
    2400                 :            :         ) {
    2401         [ #  # ]:          0 :             if ( *it == pEntry )
    2402                 :            :             {
    2403         [ #  # ]:          0 :                 pZOrderList->erase( it );
    2404         [ #  # ]:          0 :                 pZOrderList->push_back( pEntry );
    2405                 :          0 :                 break;
    2406                 :            :             }
    2407                 :            :         }
    2408                 :            :     }
    2409                 :          0 : }
    2410                 :            : 
    2411                 :          0 : void SvxIconChoiceCtrl_Impl::ClipAtVirtOutRect( Rectangle& rRect ) const
    2412                 :            : {
    2413         [ #  # ]:          0 :     if( rRect.Bottom() >= aVirtOutputSize.Height() )
    2414                 :          0 :         rRect.Bottom() = aVirtOutputSize.Height() - 1;
    2415         [ #  # ]:          0 :     if( rRect.Right() >= aVirtOutputSize.Width() )
    2416                 :          0 :         rRect.Right() = aVirtOutputSize.Width() - 1;
    2417         [ #  # ]:          0 :     if( rRect.Top() < 0 )
    2418                 :          0 :         rRect.Top() = 0;
    2419         [ #  # ]:          0 :     if( rRect.Left() < 0 )
    2420                 :          0 :         rRect.Left() = 0;
    2421                 :          0 : }
    2422                 :            : 
    2423                 :            : // rRect: area of the document (in document coordinates) that we want to make
    2424                 :            : // visible
    2425                 :            : // bScrBar == sal_True: rectangle was calculated because of a scrollbar event
    2426                 :            : 
    2427                 :          0 : void SvxIconChoiceCtrl_Impl::MakeVisible( const Rectangle& rRect, sal_Bool bScrBar,
    2428                 :            :     sal_Bool bCallRectChangedHdl )
    2429                 :            : {
    2430                 :          0 :     Rectangle aVirtRect( rRect );
    2431                 :          0 :     ClipAtVirtOutRect( aVirtRect );
    2432                 :          0 :     Point aOrigin( pView->GetMapMode().GetOrigin() );
    2433                 :            :     // convert to document coordinate
    2434                 :          0 :     aOrigin *= -1;
    2435         [ #  # ]:          0 :     Rectangle aOutputArea( GetOutputRect() );
    2436 [ #  # ][ #  # ]:          0 :     if( aOutputArea.IsInside( aVirtRect ) )
    2437                 :          0 :         return; // is already visible
    2438                 :            : 
    2439                 :            :     long nDy;
    2440         [ #  # ]:          0 :     if( aVirtRect.Top() < aOutputArea.Top() )
    2441                 :            :     {
    2442                 :            :         // scroll up (nDy < 0)
    2443                 :          0 :         nDy = aVirtRect.Top() - aOutputArea.Top();
    2444                 :            :     }
    2445         [ #  # ]:          0 :     else if( aVirtRect.Bottom() > aOutputArea.Bottom() )
    2446                 :            :     {
    2447                 :            :         // scroll down (nDy > 0)
    2448                 :          0 :         nDy = aVirtRect.Bottom() - aOutputArea.Bottom();
    2449                 :            :     }
    2450                 :            :     else
    2451                 :          0 :         nDy = 0;
    2452                 :            : 
    2453                 :            :     long nDx;
    2454         [ #  # ]:          0 :     if( aVirtRect.Left() < aOutputArea.Left() )
    2455                 :            :     {
    2456                 :            :         // scroll to the left (nDx < 0)
    2457                 :          0 :         nDx = aVirtRect.Left() - aOutputArea.Left();
    2458                 :            :     }
    2459         [ #  # ]:          0 :     else if( aVirtRect.Right() > aOutputArea.Right() )
    2460                 :            :     {
    2461                 :            :         // scroll to the right (nDx > 0)
    2462                 :          0 :         nDx = aVirtRect.Right() - aOutputArea.Right();
    2463                 :            :     }
    2464                 :            :     else
    2465                 :          0 :         nDx = 0;
    2466                 :            : 
    2467                 :          0 :     aOrigin.X() += nDx;
    2468                 :          0 :     aOrigin.Y() += nDy;
    2469                 :          0 :     aOutputArea.SetPos( aOrigin );
    2470         [ #  # ]:          0 :     if( GetUpdateMode() )
    2471                 :            :     {
    2472         [ #  # ]:          0 :         HideDDIcon();
    2473         [ #  # ]:          0 :         pView->Update();
    2474         [ #  # ]:          0 :         ShowCursor( sal_False );
    2475                 :            :     }
    2476                 :            : 
    2477                 :            :     // invert origin for SV (so we can scroll/paint using document coordinates)
    2478                 :          0 :     aOrigin *= -1;
    2479         [ #  # ]:          0 :     SetOrigin( aOrigin );
    2480                 :            : 
    2481         [ #  # ]:          0 :     sal_Bool bScrollable = pView->GetBackground().IsScrollable();
    2482 [ #  # ][ #  # ]:          0 :     if( pView->HasBackground() && !bScrollable )
         [ #  # ][ #  # ]
    2483                 :            :     {
    2484         [ #  # ]:          0 :         Rectangle aRect( GetOutputRect());
    2485         [ #  # ]:          0 :         Wallpaper aPaper( pView->GetBackground() );
    2486         [ #  # ]:          0 :         aPaper.SetRect( aRect );
    2487 [ #  # ][ #  # ]:          0 :         pView->SetBackground( aPaper );
    2488                 :            :     }
    2489                 :            : 
    2490 [ #  # ][ #  # ]:          0 :     if( bScrollable && GetUpdateMode() )
                 [ #  # ]
    2491                 :            :     {
    2492                 :            :         // scroll in reverse direction!
    2493                 :            :         pView->Control::Scroll( -nDx, -nDy, aOutputArea,
    2494         [ #  # ]:          0 :             SCROLL_NOCHILDREN | SCROLL_USECLIPREGION | SCROLL_CLIP );
    2495                 :            :     }
    2496                 :            :     else
    2497         [ #  # ]:          0 :         pView->Invalidate(INVALIDATE_NOCHILDREN);
    2498                 :            : 
    2499 [ #  # ][ #  # ]:          0 :     if( aHorSBar.IsVisible() || aVerSBar.IsVisible() )
         [ #  # ][ #  # ]
                 [ #  # ]
    2500                 :            :     {
    2501         [ #  # ]:          0 :         if( !bScrBar )
    2502                 :            :         {
    2503                 :          0 :             aOrigin *= -1;
    2504                 :            :             // correct thumbs
    2505 [ #  # ][ #  # ]:          0 :             if(aHorSBar.IsVisible() && aHorSBar.GetThumbPos() != aOrigin.X())
         [ #  # ][ #  # ]
    2506         [ #  # ]:          0 :                 aHorSBar.SetThumbPos( aOrigin.X() );
    2507 [ #  # ][ #  # ]:          0 :             if(aVerSBar.IsVisible() && aVerSBar.GetThumbPos() != aOrigin.Y())
         [ #  # ][ #  # ]
    2508         [ #  # ]:          0 :                 aVerSBar.SetThumbPos( aOrigin.Y() );
    2509                 :            :         }
    2510                 :            :     }
    2511                 :            : 
    2512         [ #  # ]:          0 :     if( GetUpdateMode() )
    2513         [ #  # ]:          0 :         ShowCursor( sal_True );
    2514                 :            : 
    2515                 :            :     // check if we still need scrollbars
    2516         [ #  # ]:          0 :     CheckScrollBars();
    2517 [ #  # ][ #  # ]:          0 :     if( bScrollable && GetUpdateMode() )
                 [ #  # ]
    2518         [ #  # ]:          0 :         pView->Update();
    2519                 :            : 
    2520                 :            :     // If the requested area can not be made completely visible, the
    2521                 :            :     // Vis-Rect-Changed handler is called in any case. This case may occur e.g.
    2522                 :            :     // if only few pixels of the lower border are invisible, but a scrollbar has
    2523                 :            :     // a larger line size.
    2524 [ #  # ][ #  # ]:          0 :     if( bCallRectChangedHdl || GetOutputRect() != rRect )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2525         [ #  # ]:          0 :         VisRectChanged();
    2526                 :            : }
    2527                 :            : 
    2528                 :          0 : sal_uLong SvxIconChoiceCtrl_Impl::GetSelectionCount() const
    2529                 :            : {
    2530 [ #  # ][ #  # ]:          0 :     if( (nWinBits & WB_HIGHLIGHTFRAME) && pCurHighlightFrame )
    2531                 :          0 :         return 1;
    2532                 :          0 :     return nSelectionCount;
    2533                 :            : }
    2534                 :            : 
    2535                 :          0 : void SvxIconChoiceCtrl_Impl::ToggleSelection( SvxIconChoiceCtrlEntry* pEntry )
    2536                 :            : {
    2537                 :            :     sal_Bool bSel;
    2538         [ #  # ]:          0 :     if( pEntry->IsSelected() )
    2539                 :          0 :         bSel = sal_False;
    2540                 :            :     else
    2541                 :          0 :         bSel = sal_True;
    2542                 :          0 :     SelectEntry( pEntry, bSel, sal_True, sal_True );
    2543                 :          0 : }
    2544                 :            : 
    2545                 :          0 : void SvxIconChoiceCtrl_Impl::DeselectAllBut( SvxIconChoiceCtrlEntry* pThisEntryNot,
    2546                 :            :     sal_Bool bPaintSync )
    2547                 :            : {
    2548                 :          0 :     ClearSelectedRectList();
    2549                 :            :     //
    2550                 :            :     // TODO: work through z-order list, if necessary!
    2551                 :            :     //
    2552                 :          0 :     size_t nCount = aEntries.size();
    2553         [ #  # ]:          0 :     for( size_t nCur = 0; nCur < nCount; nCur++ )
    2554                 :            :     {
    2555                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = aEntries[ nCur ];
    2556 [ #  # ][ #  # ]:          0 :         if( pEntry != pThisEntryNot && pEntry->IsSelected() )
                 [ #  # ]
    2557                 :          0 :             SelectEntry( pEntry, sal_False, sal_True, sal_True, bPaintSync );
    2558                 :            :     }
    2559                 :          0 :     pAnchor = 0;
    2560                 :          0 :     nFlags &= (~F_ADD_MODE);
    2561                 :          0 : }
    2562                 :            : 
    2563                 :          0 : Size SvxIconChoiceCtrl_Impl::GetMinGrid() const
    2564                 :            : {
    2565                 :          0 :     Size aMinSize( aImageSize );
    2566                 :          0 :     aMinSize.Width() += 2 * LROFFS_BOUND;
    2567                 :          0 :     aMinSize.Height() += TBOFFS_BOUND;  // single offset is enough (FileDlg)
    2568         [ #  # ]:          0 :     String aStrDummy( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) );
    2569 [ #  # ][ #  # ]:          0 :     Size aTextSize( pView->GetTextWidth( aStrDummy ), pView->GetTextHeight() );
    2570         [ #  # ]:          0 :     if( nWinBits & WB_ICON )
    2571                 :            :     {
    2572                 :          0 :         aMinSize.Height() += VER_DIST_BMP_STRING;
    2573                 :          0 :         aMinSize.Height() += aTextSize.Height();
    2574                 :            :     }
    2575                 :            :     else
    2576                 :            :     {
    2577                 :          0 :         aMinSize.Width() += HOR_DIST_BMP_STRING;
    2578                 :          0 :         aMinSize.Width() += aTextSize.Width();
    2579                 :            :     }
    2580         [ #  # ]:          0 :     return aMinSize;
    2581                 :            : }
    2582                 :            : 
    2583                 :          0 : void SvxIconChoiceCtrl_Impl::SetGrid( const Size& rSize )
    2584                 :            : {
    2585                 :          0 :     Size aSize( rSize );
    2586         [ #  # ]:          0 :     Size aMinSize( GetMinGrid() );
    2587         [ #  # ]:          0 :     if( aSize.Width() < aMinSize.Width() )
    2588                 :          0 :         aSize.Width() = aMinSize.Width();
    2589         [ #  # ]:          0 :     if( aSize.Height() < aMinSize.Height() )
    2590                 :          0 :         aSize.Height() = aMinSize.Height();
    2591                 :            : 
    2592                 :          0 :     nGridDX = aSize.Width();
    2593                 :            :     // HACK: Detail mode is not yet fully implemented, this workaround makes it
    2594                 :            :     // fly with a single column
    2595         [ #  # ]:          0 :     if( nWinBits & WB_DETAILS )
    2596                 :            :     {
    2597         [ #  # ]:          0 :         const SvxIconChoiceCtrlColumnInfo* pCol = GetColumn( 0 );
    2598         [ #  # ]:          0 :         if( pCol )
    2599                 :          0 :             ((SvxIconChoiceCtrlColumnInfo*)pCol)->SetWidth( nGridDX );
    2600                 :            :     }
    2601                 :          0 :     nGridDY = aSize.Height();
    2602         [ #  # ]:          0 :     SetDefaultTextSize();
    2603                 :          0 : }
    2604                 :            : 
    2605                 :            : // Calculates the maximum size that the text rectangle may use within its
    2606                 :            : // bounding rectangle. In WB_ICON mode with IcnShowTextFull, Bottom is set to
    2607                 :            : // LONG_MAX.
    2608                 :            : 
    2609                 :          0 : Rectangle SvxIconChoiceCtrl_Impl::CalcMaxTextRect( const SvxIconChoiceCtrlEntry* pEntry ) const
    2610                 :            : {
    2611         [ #  # ]:          0 :     Rectangle aBoundRect;
    2612                 :            :     // avoid infinite recursion: don't calculate the bounding rectangle here
    2613         [ #  # ]:          0 :     if( IsBoundingRectValid( pEntry->aRect ) )
    2614                 :          0 :         aBoundRect = pEntry->aRect;
    2615                 :            :     else
    2616                 :          0 :         aBoundRect = pEntry->aGridRect;
    2617                 :            : 
    2618                 :            :     Rectangle aBmpRect( ((SvxIconChoiceCtrl_Impl*)this)->CalcBmpRect(
    2619         [ #  # ]:          0 :         (SvxIconChoiceCtrlEntry*)pEntry ) );
    2620         [ #  # ]:          0 :     if( nWinBits & WB_ICON )
    2621                 :            :     {
    2622                 :          0 :         aBoundRect.Top() = aBmpRect.Bottom();
    2623                 :          0 :         aBoundRect.Top() += VER_DIST_BMP_STRING;
    2624         [ #  # ]:          0 :         if( aBoundRect.Top() > aBoundRect.Bottom())
    2625                 :          0 :             aBoundRect.Top() = aBoundRect.Bottom();
    2626                 :          0 :         aBoundRect.Left() += LROFFS_BOUND;
    2627                 :          0 :         aBoundRect.Left()++;
    2628                 :          0 :         aBoundRect.Right() -= LROFFS_BOUND;
    2629                 :          0 :         aBoundRect.Right()--;
    2630         [ #  # ]:          0 :         if( aBoundRect.Left() > aBoundRect.Right())
    2631                 :          0 :             aBoundRect.Left() = aBoundRect.Right();
    2632         [ #  # ]:          0 :         if( GetEntryTextModeSmart( pEntry ) == IcnShowTextFull )
    2633                 :          0 :             aBoundRect.Bottom() = LONG_MAX;
    2634                 :            :     }
    2635                 :            :     else
    2636                 :            :     {
    2637                 :          0 :         aBoundRect.Left() = aBmpRect.Right();
    2638                 :          0 :         aBoundRect.Left() += HOR_DIST_BMP_STRING;
    2639                 :          0 :         aBoundRect.Right() -= LROFFS_BOUND;
    2640         [ #  # ]:          0 :         if( aBoundRect.Left() > aBoundRect.Right() )
    2641                 :          0 :             aBoundRect.Left() = aBoundRect.Right();
    2642         [ #  # ]:          0 :         long nHeight = aBoundRect.GetSize().Height();
    2643                 :          0 :         nHeight = nHeight - aDefaultTextSize.Height();
    2644                 :          0 :         nHeight /= 2;
    2645                 :          0 :         aBoundRect.Top() += nHeight;
    2646                 :          0 :         aBoundRect.Bottom() -= nHeight;
    2647                 :            :     }
    2648                 :          0 :     return aBoundRect;
    2649                 :            : }
    2650                 :            : 
    2651                 :          0 : void SvxIconChoiceCtrl_Impl::SetDefaultTextSize()
    2652                 :            : {
    2653                 :          0 :     long nDY = nGridDY;
    2654                 :          0 :     nDY -= aImageSize.Height();
    2655                 :          0 :     nDY -= VER_DIST_BMP_STRING;
    2656                 :          0 :     nDY -= 2*TBOFFS_BOUND;
    2657         [ #  # ]:          0 :     if( nDY <= 0 )
    2658                 :          0 :         nDY = 2;
    2659                 :            : 
    2660                 :          0 :     long nDX = nGridDX;
    2661                 :          0 :     nDX -= 2*LROFFS_BOUND;
    2662                 :          0 :     nDX -= 2;
    2663         [ #  # ]:          0 :     if( nDX <= 0 )
    2664                 :          0 :         nDX = 2;
    2665                 :            : 
    2666         [ #  # ]:          0 :     String aStrDummy( RTL_CONSTASCII_USTRINGPARAM( "X" ) );
    2667         [ #  # ]:          0 :     long nHeight = pView->GetTextHeight();
    2668         [ #  # ]:          0 :     if( nDY < nHeight )
    2669                 :          0 :         nDY = nHeight;
    2670         [ #  # ]:          0 :     aDefaultTextSize = Size( nDX, nDY );
    2671                 :          0 : }
    2672                 :            : 
    2673                 :            : 
    2674                 :          0 : void SvxIconChoiceCtrl_Impl::Center( SvxIconChoiceCtrlEntry* pEntry ) const
    2675                 :            : {
    2676                 :          0 :     pEntry->aRect = pEntry->aGridRect;
    2677         [ #  # ]:          0 :     Size aSize( CalcBoundingSize( pEntry ) );
    2678         [ #  # ]:          0 :     if( nWinBits & WB_ICON )
    2679                 :            :     {
    2680                 :            :         // center horizontally
    2681         [ #  # ]:          0 :         long nBorder = pEntry->aGridRect.GetWidth() - aSize.Width();
    2682                 :          0 :         pEntry->aRect.Left() += nBorder / 2;
    2683                 :          0 :         pEntry->aRect.Right() -= nBorder / 2;
    2684                 :            :     }
    2685                 :            :     // center vertically
    2686                 :          0 :     pEntry->aRect.Bottom() = pEntry->aRect.Top() + aSize.Height();
    2687                 :          0 : }
    2688                 :            : 
    2689                 :            : 
    2690                 :            : // The deltas are the offsets by which the view is moved on the document.
    2691                 :            : // left, up: offsets < 0
    2692                 :            : // right, down: offsets > 0
    2693                 :          0 : void SvxIconChoiceCtrl_Impl::Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar )
    2694                 :            : {
    2695                 :          0 :     const MapMode& rMapMode = pView->GetMapMode();
    2696                 :          0 :     Point aOrigin( rMapMode.GetOrigin() );
    2697                 :            :     // convert to document coordinate
    2698                 :          0 :     aOrigin *= -1;
    2699                 :          0 :     aOrigin.Y() += nDeltaY;
    2700                 :          0 :     aOrigin.X() += nDeltaX;
    2701         [ #  # ]:          0 :     Rectangle aRect( aOrigin, aOutputSize );
    2702         [ #  # ]:          0 :     MakeVisible( aRect, bScrollBar );
    2703                 :          0 : }
    2704                 :            : 
    2705                 :            : 
    2706                 :          0 : const Size& SvxIconChoiceCtrl_Impl::GetItemSize( SvxIconChoiceCtrlEntry*,
    2707                 :            :     IcnViewFieldType eItem ) const
    2708                 :            : {
    2709         [ #  # ]:          0 :     if( eItem == IcnViewFieldTypeText )
    2710                 :          0 :         return aDefaultTextSize;
    2711                 :          0 :     return aImageSize;
    2712                 :            : }
    2713                 :            : 
    2714                 :          0 : Rectangle SvxIconChoiceCtrl_Impl::CalcFocusRect( SvxIconChoiceCtrlEntry* pEntry )
    2715                 :            : {
    2716         [ #  # ]:          0 :     Rectangle aBmpRect( CalcBmpRect( pEntry ) );
    2717         [ #  # ]:          0 :     Rectangle aTextRect( CalcTextRect( pEntry ) );
    2718         [ #  # ]:          0 :     Rectangle aBoundRect( GetEntryBoundRect( pEntry ) );
    2719                 :          0 :     Rectangle aFocusRect( aBoundRect.Left(), aBmpRect.Top() - 1,
    2720         [ #  # ]:          0 :                           aBoundRect.Right() - 4, aTextRect.Bottom() + 1 );
    2721                 :            :     // the focus rectangle should not touch the text
    2722         [ #  # ]:          0 :     if( aFocusRect.Left() - 1 >= pEntry->aRect.Left() )
    2723                 :          0 :         aFocusRect.Left()--;
    2724         [ #  # ]:          0 :     if( aFocusRect.Right() + 1 <= pEntry->aRect.Right() )
    2725                 :          0 :         aFocusRect.Right()++;
    2726                 :            : 
    2727                 :          0 :     return aFocusRect;
    2728                 :            : }
    2729                 :            : 
    2730                 :            : // the hot spot is the inner 50 % of the rectangle
    2731                 :          0 : static Rectangle GetHotSpot( const Rectangle& rRect )
    2732                 :            : {
    2733                 :          0 :     Rectangle aResult( rRect );
    2734         [ #  # ]:          0 :     aResult.Justify();
    2735         [ #  # ]:          0 :     Size aSize( rRect.GetSize() );
    2736                 :          0 :     long nDelta = aSize.Width() / 4;
    2737                 :          0 :     aResult.Left() += nDelta;
    2738                 :          0 :     aResult.Right() -= nDelta;
    2739                 :          0 :     nDelta = aSize.Height() / 4;
    2740                 :          0 :     aResult.Top() += nDelta;
    2741                 :          0 :     aResult.Bottom() -= nDelta;
    2742                 :          0 :     return aResult;
    2743                 :            : }
    2744                 :            : 
    2745                 :          0 : void SvxIconChoiceCtrl_Impl::SelectRect( SvxIconChoiceCtrlEntry* pEntry1, SvxIconChoiceCtrlEntry* pEntry2,
    2746                 :            :     sal_Bool bAdd, std::vector<Rectangle*>* pOtherRects )
    2747                 :            : {
    2748                 :            :     DBG_ASSERT(pEntry1 && pEntry2,"SelectEntry: Invalid Entry-Ptr");
    2749         [ #  # ]:          0 :     Rectangle aRect( GetEntryBoundRect( pEntry1 ) );
    2750 [ #  # ][ #  # ]:          0 :     aRect.Union( GetEntryBoundRect( pEntry2 ) );
    2751         [ #  # ]:          0 :     SelectRect( aRect, bAdd, pOtherRects );
    2752                 :          0 : }
    2753                 :            : 
    2754                 :          0 : void SvxIconChoiceCtrl_Impl::SelectRect( const Rectangle& rRect, bool bAdd,
    2755                 :            :     std::vector<Rectangle*>* pOtherRects )
    2756                 :            : {
    2757                 :          0 :     aCurSelectionRect = rRect;
    2758 [ #  # ][ #  # ]:          0 :     if( !pZOrderList || !pZOrderList->size() )
                 [ #  # ]
    2759                 :          0 :         return;
    2760                 :            : 
    2761                 :            :     // set flag, so ToTop won't be called in Select
    2762         [ #  # ]:          0 :     sal_Bool bAlreadySelectingRect = nFlags & F_SELECTING_RECT ? sal_True : sal_False;
    2763                 :          0 :     nFlags |= F_SELECTING_RECT;
    2764                 :            : 
    2765         [ #  # ]:          0 :     CheckBoundingRects();
    2766         [ #  # ]:          0 :     pView->Update();
    2767                 :          0 :     const size_t nCount = pZOrderList->size();
    2768                 :            : 
    2769                 :          0 :     Rectangle aRect( rRect );
    2770         [ #  # ]:          0 :     aRect.Justify();
    2771 [ #  # ][ #  # ]:          0 :     bool bCalcOverlap = (bAdd && pOtherRects && !pOtherRects->empty()) ? true : false;
                 [ #  # ]
    2772                 :            : 
    2773                 :          0 :     sal_Bool bResetClipRegion = sal_False;
    2774         [ #  # ]:          0 :     if( !pView->IsClipRegion() )
    2775                 :            :     {
    2776                 :          0 :         bResetClipRegion = sal_True;
    2777 [ #  # ][ #  # ]:          0 :         pView->SetClipRegion( GetOutputRect() );
         [ #  # ][ #  # ]
    2778                 :            :     }
    2779                 :            : 
    2780         [ #  # ]:          0 :     for( size_t nPos = 0; nPos < nCount; nPos++ )
    2781                 :            :     {
    2782                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nPos ];
    2783                 :            : 
    2784         [ #  # ]:          0 :         if( !IsBoundingRectValid( pEntry->aRect ))
    2785         [ #  # ]:          0 :             FindBoundingRect( pEntry );
    2786         [ #  # ]:          0 :         Rectangle aBoundRect( GetHotSpot( pEntry->aRect ) );
    2787                 :          0 :         sal_Bool bSelected = pEntry->IsSelected();
    2788                 :            : 
    2789                 :            :         sal_Bool bOverlaps;
    2790         [ #  # ]:          0 :         if( bCalcOverlap )
    2791         [ #  # ]:          0 :             bOverlaps = IsOver( pOtherRects, aBoundRect );
    2792                 :            :         else
    2793                 :          0 :             bOverlaps = sal_False;
    2794         [ #  # ]:          0 :         sal_Bool bOver = aRect.IsOver( aBoundRect );
    2795                 :            : 
    2796 [ #  # ][ #  # ]:          0 :         if( bOver && !bOverlaps )
    2797                 :            :         {
    2798                 :            :             // is inside the new selection rectangle and outside of any old one
    2799                 :            :             // => select
    2800         [ #  # ]:          0 :             if( !bSelected )
    2801         [ #  # ]:          0 :                 SelectEntry( pEntry, sal_True, sal_True, sal_True );
    2802                 :            :         }
    2803         [ #  # ]:          0 :         else if( !bAdd )
    2804                 :            :         {
    2805                 :            :             // is outside of the selection rectangle
    2806                 :            :             // => deselect
    2807         [ #  # ]:          0 :             if( bSelected )
    2808         [ #  # ]:          0 :                 SelectEntry( pEntry, sal_False, sal_True, sal_True );
    2809                 :            :         }
    2810 [ #  # ][ #  # ]:          0 :         else if( bAdd && bOverlaps )
    2811                 :            :         {
    2812                 :            :             // The entry is inside an old (=>span multiple rectangles with Ctrl)
    2813                 :            :             // selection rectangle.
    2814                 :            : 
    2815                 :            :             // There is still a bug here! The selection status of an entry in a
    2816                 :            :             // previous rectangle has to be restored, if it was touched by the
    2817                 :            :             // current selection rectangle but is not inside it any more.
    2818                 :            :             // For simplicity's sake, let's assume that all entries in the old
    2819                 :            :             // rectangles were correctly selected. It is wrong to just deselect
    2820                 :            :             // the intersection.
    2821                 :            :             // Possible solution: remember a snapshot of the selection before
    2822                 :            :             // spanning the rectangle.
    2823 [ #  # ][ #  # ]:          0 :             if( aBoundRect.IsOver( rRect))
    2824                 :            :             {
    2825                 :            :                 // deselect intersection between old rectangles and current rectangle
    2826         [ #  # ]:          0 :                 if( bSelected )
    2827         [ #  # ]:          0 :                     SelectEntry( pEntry, sal_False, sal_True, sal_True );
    2828                 :            :             }
    2829                 :            :             else
    2830                 :            :             {
    2831                 :            :                 // select entry of an old rectangle
    2832         [ #  # ]:          0 :                 if( !bSelected )
    2833         [ #  # ]:          0 :                     SelectEntry( pEntry, sal_True, sal_True, sal_True );
    2834                 :            :             }
    2835                 :            :         }
    2836 [ #  # ][ #  # ]:          0 :         else if( !bOver && bSelected )
    2837                 :            :         {
    2838                 :            :             // this entry is completely outside the rectangle => deselect it
    2839         [ #  # ]:          0 :             SelectEntry( pEntry, sal_False, sal_True, sal_True );
    2840                 :            :         }
    2841                 :            :     }
    2842                 :            : 
    2843         [ #  # ]:          0 :     if( !bAlreadySelectingRect )
    2844                 :          0 :         nFlags &= ~F_SELECTING_RECT;
    2845                 :            : 
    2846         [ #  # ]:          0 :     pView->Update();
    2847         [ #  # ]:          0 :     if( bResetClipRegion )
    2848         [ #  # ]:          0 :         pView->SetClipRegion();
    2849                 :            : }
    2850                 :            : 
    2851                 :          0 : void SvxIconChoiceCtrl_Impl::SelectRange(
    2852                 :            :                         SvxIconChoiceCtrlEntry* pStart,
    2853                 :            :                         SvxIconChoiceCtrlEntry* pEnd,
    2854                 :            :                         sal_Bool bAdd )
    2855                 :            : {
    2856         [ #  # ]:          0 :     sal_uLong nFront = GetEntryListPos( pStart );
    2857         [ #  # ]:          0 :     sal_uLong nBack  = GetEntryListPos( pEnd );
    2858         [ #  # ]:          0 :     sal_uLong nFirst = std::min( nFront, nBack );
    2859         [ #  # ]:          0 :     sal_uLong nLast  = std::max( nFront, nBack );
    2860                 :            :     sal_uLong i;
    2861                 :            :     SvxIconChoiceCtrlEntry* pEntry;
    2862                 :            : 
    2863         [ #  # ]:          0 :     if ( ! bAdd )
    2864                 :            :     {
    2865                 :            :         // deselect everything before the first entry if not in
    2866                 :            :         // adding mode
    2867         [ #  # ]:          0 :         for ( i=0; i<nFirst; i++ )
    2868                 :            :         {
    2869         [ #  # ]:          0 :             pEntry = GetEntry( i );
    2870         [ #  # ]:          0 :             if( pEntry->IsSelected() )
    2871         [ #  # ]:          0 :                 SelectEntry( pEntry, sal_False, sal_True, sal_True, sal_True );
    2872                 :            :         }
    2873                 :            :     }
    2874                 :            : 
    2875                 :            :     // select everything between nFirst and nLast
    2876         [ #  # ]:          0 :     for ( i=nFirst; i<=nLast; i++ )
    2877                 :            :     {
    2878         [ #  # ]:          0 :         pEntry = GetEntry( i );
    2879         [ #  # ]:          0 :         if( ! pEntry->IsSelected() )
    2880         [ #  # ]:          0 :             SelectEntry( pEntry, sal_True, sal_True,  sal_True, sal_True );
    2881                 :            :     }
    2882                 :            : 
    2883         [ #  # ]:          0 :     if ( ! bAdd )
    2884                 :            :     {
    2885                 :            :         // deselect everything behind the last entry if not in
    2886                 :            :         // adding mode
    2887                 :          0 :         sal_uLong nEnd = GetEntryCount();
    2888         [ #  # ]:          0 :         for ( ; i<nEnd; i++ )
    2889                 :            :         {
    2890         [ #  # ]:          0 :             pEntry = GetEntry( i );
    2891         [ #  # ]:          0 :             if( pEntry->IsSelected() )
    2892         [ #  # ]:          0 :                 SelectEntry( pEntry, sal_False, sal_True, sal_True, sal_True );
    2893                 :            :         }
    2894                 :            :     }
    2895                 :          0 : }
    2896                 :            : 
    2897                 :          0 : bool SvxIconChoiceCtrl_Impl::IsOver( std::vector<Rectangle*>* pRectList, const Rectangle& rBoundRect ) const
    2898                 :            : {
    2899                 :          0 :     const sal_uInt16 nCount = pRectList->size();
    2900         [ #  # ]:          0 :     for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
    2901                 :            :     {
    2902                 :          0 :         Rectangle* pRect = (*pRectList)[ nCur ];
    2903         [ #  # ]:          0 :         if( rBoundRect.IsOver( *pRect ))
    2904                 :          0 :             return true;
    2905                 :            :     }
    2906                 :          0 :     return false;
    2907                 :            : }
    2908                 :            : 
    2909                 :          0 : void SvxIconChoiceCtrl_Impl::AddSelectedRect( SvxIconChoiceCtrlEntry* pEntry1,
    2910                 :            :     SvxIconChoiceCtrlEntry* pEntry2 )
    2911                 :            : {
    2912                 :            :     DBG_ASSERT(pEntry1 && pEntry2,"SelectEntry: Invalid Entry-Ptr");
    2913         [ #  # ]:          0 :     Rectangle aRect( GetEntryBoundRect( pEntry1 ) );
    2914 [ #  # ][ #  # ]:          0 :     aRect.Union( GetEntryBoundRect( pEntry2 ) );
    2915         [ #  # ]:          0 :     AddSelectedRect( aRect );
    2916                 :          0 : }
    2917                 :            : 
    2918                 :          0 : void SvxIconChoiceCtrl_Impl::AddSelectedRect( const Rectangle& rRect )
    2919                 :            : {
    2920         [ #  # ]:          0 :     Rectangle* pRect = new Rectangle( rRect );
    2921         [ #  # ]:          0 :     pRect->Justify();
    2922         [ #  # ]:          0 :     aSelectedRectList.push_back( pRect );
    2923                 :          0 : }
    2924                 :            : 
    2925                 :          0 : void SvxIconChoiceCtrl_Impl::ClearSelectedRectList()
    2926                 :            : {
    2927                 :          0 :     const sal_uInt16 nCount = aSelectedRectList.size();
    2928         [ #  # ]:          0 :     for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
    2929                 :            :     {
    2930                 :          0 :         Rectangle* pRect = aSelectedRectList[ nCur ];
    2931                 :          0 :         delete pRect;
    2932                 :            :     }
    2933                 :          0 :     aSelectedRectList.clear();
    2934                 :          0 : }
    2935                 :            : 
    2936                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, AutoArrangeHdl)
    2937                 :            : {
    2938                 :          0 :     aAutoArrangeTimer.Stop();
    2939                 :          0 :     Arrange( IsAutoArrange() );
    2940                 :          0 :     return 0;
    2941                 :            : }
    2942                 :            : 
    2943                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, VisRectChangedHdl)
    2944                 :            : {
    2945                 :          0 :     aVisRectChangedTimer.Stop();
    2946                 :          0 :     pView->VisibleRectChanged();
    2947                 :          0 :     return 0;
    2948                 :            : }
    2949                 :            : 
    2950                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, DocRectChangedHdl)
    2951                 :            : {
    2952                 :          0 :     aDocRectChangedTimer.Stop();
    2953                 :          0 :     pView->DocumentRectChanged();
    2954                 :          0 :     return 0;
    2955                 :            : }
    2956                 :            : 
    2957                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::IsTextHit( SvxIconChoiceCtrlEntry* pEntry, const Point& rDocPos )
    2958                 :            : {
    2959         [ #  # ]:          0 :     Rectangle aRect( CalcTextRect( pEntry ));
    2960 [ #  # ][ #  # ]:          0 :     if( aRect.IsInside( rDocPos ) )
    2961                 :          0 :         return sal_True;
    2962                 :          0 :     return sal_False;
    2963                 :            : }
    2964                 :            : 
    2965                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, EditTimeoutHdl)
    2966                 :            : {
    2967                 :          0 :     SvxIconChoiceCtrlEntry* pEntry = GetCurEntry();
    2968   [ #  #  #  # ]:          0 :     if( bEntryEditingEnabled && pEntry &&
         [ #  # ][ #  # ]
    2969                 :          0 :         pEntry->IsSelected())
    2970                 :            :     {
    2971         [ #  # ]:          0 :         if( pView->EditingEntry( pEntry ))
    2972                 :          0 :             EditEntry( pEntry );
    2973                 :            :     }
    2974                 :          0 :     return 0;
    2975                 :            : }
    2976                 :            : 
    2977                 :            : 
    2978                 :            : //
    2979                 :            : // Function to align entries to the grid
    2980                 :            : //
    2981                 :            : 
    2982                 :            : // pStart == 0: align all entries
    2983                 :            : // else: align all entries of the row from pStart on (including pStart)
    2984                 :          0 : void SvxIconChoiceCtrl_Impl::AdjustEntryAtGrid( SvxIconChoiceCtrlEntry* pStart )
    2985                 :            : {
    2986         [ #  # ]:          0 :     IconChoiceMap aLists;
    2987         [ #  # ]:          0 :     pImpCursor->CreateGridAjustData( aLists, pStart );
    2988         [ #  # ]:          0 :     for (IconChoiceMap::const_iterator iter = aLists.begin();
    2989                 :          0 :             iter != aLists.end(); ++iter)
    2990                 :            :     {
    2991         [ #  # ]:          0 :         AdjustAtGrid(iter->second, pStart);
    2992                 :            :     }
    2993         [ #  # ]:          0 :     IcnCursor_Impl::DestroyGridAdjustData( aLists );
    2994         [ #  # ]:          0 :     CheckScrollBars();
    2995                 :          0 : }
    2996                 :            : 
    2997                 :            : // align a row, might expand width, doesn't break the line
    2998                 :          0 : void SvxIconChoiceCtrl_Impl::AdjustAtGrid( const SvxIconChoiceCtrlEntryPtrVec& rRow, SvxIconChoiceCtrlEntry* pStart )
    2999                 :            : {
    3000         [ #  # ]:          0 :     if( rRow.empty() )
    3001                 :          0 :         return;
    3002                 :            : 
    3003                 :            :     sal_Bool bGo;
    3004         [ #  # ]:          0 :     if( !pStart )
    3005                 :          0 :         bGo = sal_True;
    3006                 :            :     else
    3007                 :          0 :         bGo = sal_False;
    3008                 :            : 
    3009                 :          0 :     long nCurRight = 0;
    3010         [ #  # ]:          0 :     for( sal_uInt16 nCur = 0; nCur < rRow.size(); nCur++ )
    3011                 :            :     {
    3012                 :          0 :         SvxIconChoiceCtrlEntry* pCur = rRow[ nCur ];
    3013 [ #  # ][ #  # ]:          0 :         if( !bGo && pCur == pStart )
    3014                 :          0 :             bGo = sal_True;
    3015                 :            : 
    3016                 :            :         // SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pCur);
    3017                 :            :         // Decisive (for our eye) is the bitmap, else, the entry might jump too
    3018                 :            :         // much within long texts.
    3019         [ #  # ]:          0 :         const Rectangle& rBoundRect = GetEntryBoundRect( pCur );
    3020         [ #  # ]:          0 :         Rectangle aCenterRect( CalcBmpRect( pCur, 0 ));
    3021 [ #  # ][ #  # ]:          0 :         if( bGo && !pCur->IsPosLocked() )
                 [ #  # ]
    3022                 :            :         {
    3023         [ #  # ]:          0 :             long nWidth = aCenterRect.GetSize().Width();
    3024         [ #  # ]:          0 :             Point aNewPos( AdjustAtGrid( aCenterRect, rBoundRect ) );
    3025         [ #  # ]:          0 :             while( aNewPos.X() < nCurRight )
    3026                 :          0 :                 aNewPos.X() += nGridDX;
    3027         [ #  # ]:          0 :             if( aNewPos != rBoundRect.TopLeft() )
    3028                 :            :             {
    3029         [ #  # ]:          0 :                 SetEntryPos( pCur, aNewPos );
    3030                 :          0 :                 pCur->SetFlags( ICNVIEW_FLAG_POS_MOVED );
    3031                 :          0 :                 nFlags |= F_MOVED_ENTRIES;
    3032                 :            :             }
    3033                 :          0 :             nCurRight = aNewPos.X() + nWidth;
    3034                 :            :         }
    3035                 :            :         else
    3036                 :            :         {
    3037                 :          0 :             nCurRight = rBoundRect.Right();
    3038                 :            :         }
    3039                 :            :     }
    3040                 :            : }
    3041                 :            : 
    3042                 :            : // Aligns a rectangle to the grid, but doesn't guarantee that the new position
    3043                 :            : // is vacant. The position can be used for SetEntryPos. The CenterRect describes
    3044                 :            : // a part of the bounding rectangle that is used for calculating the target
    3045                 :            : // rectangle.
    3046                 :          0 : Point SvxIconChoiceCtrl_Impl::AdjustAtGrid( const Rectangle& rCenterRect,
    3047                 :            :     const Rectangle& rBoundRect ) const
    3048                 :            : {
    3049                 :          0 :     Point aPos( rCenterRect.TopLeft() );
    3050         [ #  # ]:          0 :     Size aSize( rCenterRect.GetSize() );
    3051                 :            : 
    3052                 :          0 :     aPos.X() -= LROFFS_WINBORDER;
    3053                 :          0 :     aPos.Y() -= TBOFFS_WINBORDER;
    3054                 :            : 
    3055                 :            :     // align (the center of the rectangle is the reference)
    3056                 :          0 :     short nGridX = (short)((aPos.X()+(aSize.Width()/2)) / nGridDX);
    3057                 :          0 :     short nGridY = (short)((aPos.Y()+(aSize.Height()/2)) / nGridDY);
    3058                 :          0 :     aPos.X() = nGridX * nGridDX;
    3059                 :          0 :     aPos.Y() = nGridY * nGridDY;
    3060                 :            :     // horizontal center
    3061         [ #  # ]:          0 :     aPos.X() += (nGridDX - rBoundRect.GetSize().Width() ) / 2;
    3062                 :            : 
    3063                 :          0 :     aPos.X() += LROFFS_WINBORDER;
    3064                 :          0 :     aPos.Y() += TBOFFS_WINBORDER;
    3065                 :            : 
    3066                 :          0 :     return aPos;
    3067                 :            : }
    3068                 :            : 
    3069                 :          0 : void SvxIconChoiceCtrl_Impl::SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode, SvxIconChoiceCtrlEntry* pEntry )
    3070                 :            : {
    3071         [ #  # ]:          0 :     if( !pEntry )
    3072                 :            :     {
    3073         [ #  # ]:          0 :         if( eTextMode != eMode )
    3074                 :            :         {
    3075         [ #  # ]:          0 :             if( eTextMode == IcnShowTextDontKnow )
    3076                 :          0 :                 eTextMode = IcnShowTextShort;
    3077                 :          0 :             eTextMode = eMode;
    3078                 :          0 :             Arrange( sal_True );
    3079                 :            :         }
    3080                 :            :     }
    3081                 :            :     else
    3082                 :            :     {
    3083         [ #  # ]:          0 :         if( pEntry->eTextMode != eMode )
    3084                 :            :         {
    3085                 :          0 :             pEntry->eTextMode = eMode;
    3086                 :          0 :             InvalidateEntry( pEntry );
    3087                 :          0 :             pView->Invalidate( GetEntryBoundRect( pEntry ) );
    3088                 :          0 :             AdjustVirtSize( pEntry->aRect );
    3089                 :            :         }
    3090                 :            :     }
    3091                 :          0 : }
    3092                 :            : 
    3093                 :          0 : SvxIconChoiceCtrlTextMode SvxIconChoiceCtrl_Impl::GetEntryTextModeSmart( const SvxIconChoiceCtrlEntry* pEntry ) const
    3094                 :            : {
    3095                 :            :     DBG_ASSERT(pEntry,"GetEntryTextModeSmart: Entry not set");
    3096                 :          0 :     SvxIconChoiceCtrlTextMode eMode = pEntry->GetTextMode();
    3097         [ #  # ]:          0 :     if( eMode == IcnShowTextDontKnow )
    3098                 :          0 :         return eTextMode;
    3099                 :          0 :     return eMode;
    3100                 :            : }
    3101                 :            : 
    3102                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////
    3103                 :            : //
    3104                 :            : // Draw my own focusrect, because the focusrect of the outputdevice has got the inverted color
    3105                 :            : // of the background. But what will we see, if the the backgroundcolor is gray ? - We will see
    3106                 :            : // a gray focusrect on a gray background !!!
    3107                 :            : //
    3108                 :          0 : void SvxIconChoiceCtrl_Impl::ShowFocus ( Rectangle& rRect )
    3109                 :            : {
    3110         [ #  # ]:          0 :     Color aBkgColor ( pView->GetBackground().GetColor() );
    3111                 :          0 :     Color aPenColor;
    3112                 :          0 :     sal_uInt16 nColor = ( aBkgColor.GetRed() + aBkgColor.GetGreen() + aBkgColor.GetBlue() ) / 3;
    3113         [ #  # ]:          0 :     if ( nColor > 128 )
    3114                 :          0 :         aPenColor.SetColor ( COL_BLACK );
    3115                 :            :     else
    3116                 :          0 :         aPenColor.SetColor( COL_WHITE );
    3117                 :            : 
    3118                 :          0 :     aFocus.bOn = sal_True;
    3119                 :          0 :     aFocus.aPenColor = aPenColor;
    3120                 :          0 :     aFocus.aRect = rRect;
    3121                 :          0 : }
    3122                 :            : 
    3123                 :          0 : void SvxIconChoiceCtrl_Impl::DrawFocusRect ( OutputDevice* pOut )
    3124                 :            : {
    3125         [ #  # ]:          0 :     pOut->SetLineColor( aFocus.aPenColor );
    3126         [ #  # ]:          0 :     pOut->SetFillColor();
    3127         [ #  # ]:          0 :     Polygon aPolygon ( aFocus.aRect );
    3128                 :            : 
    3129         [ #  # ]:          0 :     LineInfo aLineInfo ( LINE_DASH );
    3130                 :            : 
    3131         [ #  # ]:          0 :     aLineInfo.SetDashLen ( 1 );
    3132                 :            : 
    3133         [ #  # ]:          0 :     aLineInfo.SetDotLen ( 1L );
    3134         [ #  # ]:          0 :     aLineInfo.SetDistance ( 1L );
    3135         [ #  # ]:          0 :     aLineInfo.SetDotCount ( 1 );
    3136                 :            : 
    3137 [ #  # ][ #  # ]:          0 :     pOut->DrawPolyLine ( aPolygon, aLineInfo );
                 [ #  # ]
    3138                 :          0 : }
    3139                 :            : 
    3140                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::IsMnemonicChar( sal_Unicode cChar, sal_uLong& rPos ) const
    3141                 :            : {
    3142                 :          0 :     sal_Bool bRet = sal_False;
    3143                 :          0 :     const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
    3144                 :          0 :     size_t nEntryCount = GetEntryCount();
    3145         [ #  # ]:          0 :     for ( size_t i = 0; i < nEntryCount; ++i )
    3146                 :            :     {
    3147 [ #  # ][ #  # ]:          0 :         if ( rI18nHelper.MatchMnemonic( GetEntry( i )->GetText(), cChar ) )
    3148                 :            :         {
    3149                 :          0 :             bRet = sal_True;
    3150                 :          0 :             rPos = i;
    3151                 :          0 :             break;
    3152                 :            :         }
    3153                 :            :     }
    3154                 :            : 
    3155                 :          0 :     return bRet;
    3156                 :            : }
    3157                 :            : 
    3158                 :            : //
    3159                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////
    3160                 :            : 
    3161                 :          0 : IMPL_LINK(SvxIconChoiceCtrl_Impl, UserEventHdl, void*, nId )
    3162                 :            : {
    3163         [ #  # ]:          0 :     if( nId == EVENTID_ADJUST_SCROLLBARS )
    3164                 :            :     {
    3165                 :          0 :         nUserEventAdjustScrBars = 0;
    3166                 :          0 :         AdjustScrollBars();
    3167                 :            :     }
    3168         [ #  # ]:          0 :     else if( nId == EVENTID_SHOW_CURSOR )
    3169                 :            :     {
    3170                 :          0 :         nUserEventShowCursor = 0;
    3171                 :          0 :         ShowCursor( sal_True );
    3172                 :            :     }
    3173                 :          0 :     return 0;
    3174                 :            : }
    3175                 :            : 
    3176                 :          0 : void SvxIconChoiceCtrl_Impl::CancelUserEvents()
    3177                 :            : {
    3178         [ #  # ]:          0 :     if( nUserEventAdjustScrBars )
    3179                 :            :     {
    3180                 :          0 :         Application::RemoveUserEvent( nUserEventAdjustScrBars );
    3181                 :          0 :         nUserEventAdjustScrBars = 0;
    3182                 :            :     }
    3183         [ #  # ]:          0 :     if( nUserEventShowCursor )
    3184                 :            :     {
    3185                 :          0 :         Application::RemoveUserEvent( nUserEventShowCursor );
    3186                 :          0 :         nUserEventShowCursor = 0;
    3187                 :            :     }
    3188                 :          0 : }
    3189                 :            : 
    3190                 :          0 : void SvxIconChoiceCtrl_Impl::InvalidateEntry( SvxIconChoiceCtrlEntry* pEntry )
    3191                 :            : {
    3192         [ #  # ]:          0 :     if( pEntry == pCursor )
    3193                 :          0 :         ShowCursor( sal_False );
    3194                 :          0 :     pView->Invalidate( pEntry->aRect );
    3195                 :          0 :     Center( pEntry );
    3196                 :          0 :     pView->Invalidate( pEntry->aRect );
    3197         [ #  # ]:          0 :     if( pEntry == pCursor )
    3198                 :          0 :         ShowCursor( sal_True );
    3199                 :          0 : }
    3200                 :            : 
    3201                 :          0 : void SvxIconChoiceCtrl_Impl::EditEntry( SvxIconChoiceCtrlEntry* pEntry )
    3202                 :            : {
    3203                 :            :     DBG_ASSERT(pEntry,"EditEntry: Entry not set");
    3204         [ #  # ]:          0 :     if( !pEntry )
    3205                 :          0 :         return;
    3206                 :            : 
    3207         [ #  # ]:          0 :     StopEntryEditing( sal_True );
    3208 [ #  # ][ #  # ]:          0 :     DELETEZ(pEdit);
    3209         [ #  # ]:          0 :     SetNoSelection();
    3210                 :            : 
    3211                 :          0 :     pCurEditedEntry = pEntry;
    3212         [ #  # ]:          0 :     String aEntryText( pView->GetEntryText( pEntry, sal_True ) );
    3213         [ #  # ]:          0 :     Rectangle aRect( CalcTextRect( pEntry, 0, sal_True, &aEntryText ) );
    3214         [ #  # ]:          0 :     MakeVisible( aRect );
    3215                 :          0 :     Point aPos( aRect.TopLeft() );
    3216         [ #  # ]:          0 :     aPos = pView->GetPixelPos( aPos );
    3217                 :          0 :     aRect.SetPos( aPos );
    3218         [ #  # ]:          0 :     pView->HideFocus();
    3219                 :            :     pEdit = new IcnViewEdit_Impl(
    3220                 :            :         pView,
    3221                 :            :         aRect.TopLeft(),
    3222                 :            :         aRect.GetSize(),
    3223                 :            :         aEntryText,
    3224 [ #  # ][ #  # ]:          0 :         LINK( this, SvxIconChoiceCtrl_Impl, TextEditEndedHdl ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    3225                 :            : }
    3226                 :            : 
    3227                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, TextEditEndedHdl)
    3228                 :            : {
    3229                 :            :     DBG_ASSERT(pEdit,"TextEditEnded: pEdit not set");
    3230         [ #  # ]:          0 :     if( !pEdit )
    3231                 :            :     {
    3232                 :          0 :         pCurEditedEntry = 0;
    3233                 :          0 :         return 0;
    3234                 :            :     }
    3235                 :            :     DBG_ASSERT(pCurEditedEntry,"TextEditEnded: pCurEditedEntry not set");
    3236                 :            : 
    3237         [ #  # ]:          0 :     if( !pCurEditedEntry )
    3238                 :            :     {
    3239         [ #  # ]:          0 :         pEdit->Hide();
    3240         [ #  # ]:          0 :         if( pEdit->IsGrabFocus() )
    3241         [ #  # ]:          0 :             pView->GrabFocus();
    3242                 :          0 :         return 0;
    3243                 :            :     }
    3244                 :            : 
    3245         [ #  # ]:          0 :     String aText;
    3246         [ #  # ]:          0 :     if ( !pEdit->EditingCanceled() )
    3247 [ #  # ][ #  # ]:          0 :         aText = pEdit->GetText();
                 [ #  # ]
    3248                 :            :     else
    3249         [ #  # ]:          0 :         aText = pEdit->GetSavedValue();
    3250                 :            : 
    3251 [ #  # ][ #  # ]:          0 :     if( pView->EditedEntry( pCurEditedEntry, aText, pEdit->EditingCanceled() ) )
                 [ #  # ]
    3252         [ #  # ]:          0 :         InvalidateEntry( pCurEditedEntry );
    3253         [ #  # ]:          0 :     if( !GetSelectionCount() )
    3254         [ #  # ]:          0 :         SelectEntry( pCurEditedEntry, sal_True );
    3255                 :            : 
    3256         [ #  # ]:          0 :     pEdit->Hide();
    3257         [ #  # ]:          0 :     if( pEdit->IsGrabFocus() )
    3258         [ #  # ]:          0 :         pView->GrabFocus();
    3259                 :            :     // The edit can not be deleted here, because it is not within a handler. It
    3260                 :            :     // will be deleted in the dtor or in the next EditEntry.
    3261                 :          0 :     pCurEditedEntry = 0;
    3262         [ #  # ]:          0 :     return 0;
    3263                 :            : }
    3264                 :            : 
    3265                 :          0 : void SvxIconChoiceCtrl_Impl::StopEntryEditing( sal_Bool bCancel )
    3266                 :            : {
    3267         [ #  # ]:          0 :     if( pEdit )
    3268                 :          0 :         pEdit->StopEditing( bCancel );
    3269                 :          0 : }
    3270                 :            : 
    3271                 :          0 : SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry( sal_uLong& rPos ) const
    3272                 :            : {
    3273         [ #  # ]:          0 :     if( !GetSelectionCount() )
    3274                 :          0 :         return 0;
    3275                 :            : 
    3276 [ #  # ][ #  # ]:          0 :     if( (nWinBits & WB_HIGHLIGHTFRAME) && (eSelectionMode == NO_SELECTION) )
    3277                 :            :     {
    3278                 :          0 :         rPos = pView->GetEntryListPos( pCurHighlightFrame );
    3279                 :          0 :         return pCurHighlightFrame;
    3280                 :            :     }
    3281                 :            : 
    3282                 :          0 :     size_t nCount = aEntries.size();
    3283         [ #  # ]:          0 :     if( !pHead )
    3284                 :            :     {
    3285         [ #  # ]:          0 :         for( size_t nCur = 0; nCur < nCount; nCur++ )
    3286                 :            :         {
    3287                 :          0 :             SvxIconChoiceCtrlEntry* pEntry = aEntries[ nCur ];
    3288         [ #  # ]:          0 :             if( pEntry->IsSelected() )
    3289                 :            :             {
    3290                 :          0 :                 rPos = nCur;
    3291                 :          0 :                 return pEntry;
    3292                 :            :             }
    3293                 :            :         }
    3294                 :            :     }
    3295                 :            :     else
    3296                 :            :     {
    3297                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = pHead;
    3298         [ #  # ]:          0 :         while( nCount-- )
    3299                 :            :         {
    3300         [ #  # ]:          0 :             if( pEntry->IsSelected() )
    3301                 :            :             {
    3302                 :          0 :                 rPos = GetEntryListPos( pEntry );
    3303                 :          0 :                 return pEntry;
    3304                 :            :             }
    3305                 :          0 :             pEntry = pEntry->pflink;
    3306 [ #  # ][ #  # ]:          0 :             if( nCount && pEntry == pHead )
    3307                 :            :             {
    3308                 :            :                 OSL_FAIL("SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry > infinite loop!");
    3309                 :          0 :                 return 0;
    3310                 :            :             }
    3311                 :            :         }
    3312                 :            :     }
    3313                 :          0 :     return 0;
    3314                 :            : }
    3315                 :            : 
    3316                 :          0 : void SvxIconChoiceCtrl_Impl::SelectAll( sal_Bool bSelect, sal_Bool bPaint )
    3317                 :            : {
    3318                 :          0 :     bPaint = sal_True;
    3319                 :            : 
    3320                 :          0 :     size_t nCount = aEntries.size();
    3321 [ #  # ][ #  # ]:          0 :     for( size_t nCur = 0; nCur < nCount && (bSelect || GetSelectionCount() ); nCur++ )
         [ #  # ][ #  # ]
    3322                 :            :     {
    3323                 :          0 :         SvxIconChoiceCtrlEntry* pEntry = aEntries[ nCur ];
    3324                 :          0 :         SelectEntry( pEntry, bSelect, sal_True, sal_True, bPaint );
    3325                 :            :     }
    3326                 :          0 :     nFlags &= (~F_ADD_MODE);
    3327                 :          0 :     pAnchor = 0;
    3328                 :          0 : }
    3329                 :            : 
    3330                 :          0 : IcnViewEdit_Impl::IcnViewEdit_Impl( SvtIconChoiceCtrl* pParent, const Point& rPos,
    3331                 :            :     const Size& rSize, const XubString& rData, const Link& rNotifyEditEnd ) :
    3332                 :          0 :     MultiLineEdit( pParent, (pParent->GetStyle() & WB_ICON) ? WB_CENTER : WB_LEFT),
    3333                 :            :     aCallBackHdl( rNotifyEditEnd ),
    3334                 :            :     bCanceled( sal_False ),
    3335                 :            :     bAlreadyInCallback( sal_False ),
    3336 [ #  # ][ #  # ]:          0 :     bGrabFocus( sal_False )
         [ #  # ][ #  # ]
    3337                 :            : {
    3338         [ #  # ]:          0 :     Font aFont( pParent->GetPointFont() );
    3339         [ #  # ]:          0 :     aFont.SetTransparent( sal_False );
    3340         [ #  # ]:          0 :     SetControlFont( aFont );
    3341 [ #  # ][ #  # ]:          0 :     if( !pParent->HasFontFillColor() )
    3342                 :            :     {
    3343         [ #  # ]:          0 :         Color aColor( pParent->GetBackground().GetColor() );
    3344         [ #  # ]:          0 :         SetControlBackground( aColor );
    3345                 :            :     }
    3346                 :            :     else
    3347 [ #  # ][ #  # ]:          0 :         SetControlBackground( aFont.GetFillColor() );
    3348 [ #  # ][ #  # ]:          0 :     SetControlForeground( aFont.GetColor() );
    3349         [ #  # ]:          0 :     SetPosPixel( rPos );
    3350 [ #  # ][ #  # ]:          0 :     SetSizePixel( CalcAdjustedSize(rSize) );
    3351         [ #  # ]:          0 :     SetText( rData );
    3352         [ #  # ]:          0 :     SaveValue();
    3353                 :            : 
    3354         [ #  # ]:          0 :     aAccReturn.InsertItem( IMPICNVIEW_ACC_RETURN, KeyCode(KEY_RETURN) );
    3355         [ #  # ]:          0 :     aAccEscape.InsertItem( IMPICNVIEW_ACC_ESCAPE, KeyCode(KEY_ESCAPE) );
    3356                 :            : 
    3357         [ #  # ]:          0 :     aAccReturn.SetActivateHdl( LINK( this, IcnViewEdit_Impl, ReturnHdl_Impl) );
    3358         [ #  # ]:          0 :     aAccEscape.SetActivateHdl( LINK( this, IcnViewEdit_Impl, EscapeHdl_Impl) );
    3359 [ #  # ][ #  # ]:          0 :     GetpApp()->InsertAccel( &aAccReturn);//, ACCEL_ALWAYS );
    3360 [ #  # ][ #  # ]:          0 :     GetpApp()->InsertAccel( &aAccEscape);//, ACCEL_ALWAYS );
    3361         [ #  # ]:          0 :     Show();
    3362 [ #  # ][ #  # ]:          0 :     GrabFocus();
    3363                 :          0 : }
    3364                 :            : 
    3365 [ #  # ][ #  # ]:          0 : IcnViewEdit_Impl::~IcnViewEdit_Impl()
                 [ #  # ]
    3366                 :            : {
    3367         [ #  # ]:          0 :     if( !bAlreadyInCallback )
    3368                 :            :     {
    3369 [ #  # ][ #  # ]:          0 :         GetpApp()->RemoveAccel( &aAccReturn );
    3370 [ #  # ][ #  # ]:          0 :         GetpApp()->RemoveAccel( &aAccEscape );
    3371                 :            :     }
    3372         [ #  # ]:          0 : }
    3373                 :            : 
    3374                 :          0 : void IcnViewEdit_Impl::CallCallBackHdl_Impl()
    3375                 :            : {
    3376                 :          0 :     aTimer.Stop();
    3377         [ #  # ]:          0 :     if ( !bAlreadyInCallback )
    3378                 :            :     {
    3379                 :          0 :         bAlreadyInCallback = sal_True;
    3380                 :          0 :         GetpApp()->RemoveAccel( &aAccReturn );
    3381                 :          0 :         GetpApp()->RemoveAccel( &aAccEscape );
    3382                 :          0 :         Hide();
    3383                 :          0 :         aCallBackHdl.Call( this );
    3384                 :            :     }
    3385                 :          0 : }
    3386                 :            : 
    3387                 :          0 : IMPL_LINK_NOARG(IcnViewEdit_Impl, Timeout_Impl)
    3388                 :            : {
    3389                 :          0 :     CallCallBackHdl_Impl();
    3390                 :          0 :     return 0;
    3391                 :            : }
    3392                 :            : 
    3393                 :          0 : IMPL_LINK( IcnViewEdit_Impl, ReturnHdl_Impl, Accelerator*, EMPTYARG  )
    3394                 :            : {
    3395                 :          0 :     bCanceled = sal_False;
    3396                 :          0 :     bGrabFocus = sal_True;
    3397                 :          0 :     CallCallBackHdl_Impl();
    3398                 :          0 :     return 1;
    3399                 :            : }
    3400                 :            : 
    3401                 :          0 : IMPL_LINK( IcnViewEdit_Impl, EscapeHdl_Impl, Accelerator*, EMPTYARG  )
    3402                 :            : {
    3403                 :          0 :     bCanceled = sal_True;
    3404                 :          0 :     bGrabFocus = sal_True;
    3405                 :          0 :     CallCallBackHdl_Impl();
    3406                 :          0 :     return 1;
    3407                 :            : }
    3408                 :            : 
    3409                 :          0 : void IcnViewEdit_Impl::KeyInput( const KeyEvent& rKEvt )
    3410                 :            : {
    3411                 :          0 :     KeyCode aCode = rKEvt.GetKeyCode();
    3412                 :          0 :     sal_uInt16 nCode = aCode.GetCode();
    3413                 :            : 
    3414      [ #  #  # ]:          0 :     switch ( nCode )
    3415                 :            :     {
    3416                 :            :         case KEY_ESCAPE:
    3417                 :          0 :             bCanceled = sal_True;
    3418                 :          0 :             bGrabFocus = sal_True;
    3419         [ #  # ]:          0 :             CallCallBackHdl_Impl();
    3420                 :          0 :             break;
    3421                 :            : 
    3422                 :            :         case KEY_RETURN:
    3423                 :          0 :             bCanceled = sal_False;
    3424                 :          0 :             bGrabFocus = sal_True;
    3425         [ #  # ]:          0 :             CallCallBackHdl_Impl();
    3426                 :          0 :             break;
    3427                 :            : 
    3428                 :            :         default:
    3429         [ #  # ]:          0 :             MultiLineEdit::KeyInput( rKEvt );
    3430                 :            :     }
    3431                 :          0 : }
    3432                 :            : 
    3433                 :          0 : long IcnViewEdit_Impl::PreNotify( NotifyEvent& rNEvt )
    3434                 :            : {
    3435         [ #  # ]:          0 :     if( rNEvt.GetType() == EVENT_LOSEFOCUS )
    3436                 :            :     {
    3437   [ #  #  #  #  :          0 :         if ( !bAlreadyInCallback &&
           #  # ][ #  # ]
    3438                 :          0 :             ((!Application::GetFocusWindow()) || !IsChild(Application::GetFocusWindow())))
    3439                 :            :         {
    3440                 :          0 :             bCanceled = sal_False;
    3441                 :          0 :             aTimer.SetTimeout(10);
    3442                 :          0 :             aTimer.SetTimeoutHdl(LINK(this,IcnViewEdit_Impl,Timeout_Impl));
    3443                 :          0 :             aTimer.Start();
    3444                 :            :         }
    3445                 :            :     }
    3446                 :          0 :     return 0;
    3447                 :            : }
    3448                 :            : 
    3449                 :          0 : void IcnViewEdit_Impl::StopEditing( sal_Bool bCancel )
    3450                 :            : {
    3451         [ #  # ]:          0 :     if ( !bAlreadyInCallback )
    3452                 :            :     {
    3453                 :          0 :         bCanceled = bCancel;
    3454                 :          0 :         CallCallBackHdl_Impl();
    3455                 :            :     }
    3456                 :          0 : }
    3457                 :            : 
    3458                 :          0 : sal_uLong SvxIconChoiceCtrl_Impl::GetEntryListPos( SvxIconChoiceCtrlEntry* pEntry ) const
    3459                 :            : {
    3460         [ #  # ]:          0 :     if( !(nFlags & F_ENTRYLISTPOS_VALID ))
    3461                 :          0 :         ((SvxIconChoiceCtrl_Impl*)this)->SetListPositions();
    3462                 :          0 :     return pEntry->nPos;
    3463                 :            : }
    3464                 :            : 
    3465                 :          0 : void SvxIconChoiceCtrl_Impl::InitSettings()
    3466                 :            : {
    3467                 :          0 :     const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings();
    3468                 :            : 
    3469         [ #  # ]:          0 :     if( !pView->HasFont() )
    3470                 :            :     {
    3471                 :            :         // unit (from settings) is Point
    3472         [ #  # ]:          0 :         Font aFont( rStyleSettings.GetFieldFont() );
    3473                 :            :         //const Font& rFont = pView->GetFont();
    3474                 :            :         //if( pView->HasFontTextColor() )
    3475         [ #  # ]:          0 :             aFont.SetColor( rStyleSettings.GetWindowTextColor() );
    3476                 :            :         //if( pView->HasFontFillColor() )
    3477                 :            :             //aFont.SetFillColor( rFont.GetFillColor() );
    3478         [ #  # ]:          0 :         pView->SetPointFont( aFont );
    3479 [ #  # ][ #  # ]:          0 :         SetDefaultTextSize();
    3480                 :            :     }
    3481                 :            : 
    3482                 :            :     //if( !pView->HasFontTextColor() )
    3483                 :          0 :         pView->SetTextColor( rStyleSettings.GetFieldTextColor() );
    3484                 :            :     //if( !pView->HasFontFillColor() )
    3485                 :          0 :         pView->SetTextFillColor();
    3486                 :            : 
    3487                 :            :     //if( !pView->HasBackground() )
    3488         [ #  # ]:          0 :         pView->SetBackground( rStyleSettings.GetFieldColor());
    3489                 :            : 
    3490                 :          0 :     long nScrBarSize = rStyleSettings.GetScrollBarSize();
    3491 [ #  # ][ #  # ]:          0 :     if( nScrBarSize != nHorSBarHeight || nScrBarSize != nVerSBarWidth )
    3492                 :            :     {
    3493                 :          0 :         nHorSBarHeight = nScrBarSize;
    3494         [ #  # ]:          0 :         Size aSize( aHorSBar.GetSizePixel() );
    3495                 :          0 :         aSize.Height() = nScrBarSize;
    3496         [ #  # ]:          0 :         aHorSBar.Hide();
    3497         [ #  # ]:          0 :         aHorSBar.SetSizePixel( aSize );
    3498                 :            : 
    3499                 :          0 :         nVerSBarWidth = nScrBarSize;
    3500         [ #  # ]:          0 :         aSize = aVerSBar.GetSizePixel();
    3501                 :          0 :         aSize.Width() = nScrBarSize;
    3502         [ #  # ]:          0 :         aVerSBar.Hide();
    3503         [ #  # ]:          0 :         aVerSBar.SetSizePixel( aSize );
    3504                 :            : 
    3505                 :          0 :         Size aOSize( pView->Control::GetOutputSizePixel() );
    3506         [ #  # ]:          0 :         PositionScrollBars( aOSize.Width(), aOSize.Height() );
    3507         [ #  # ]:          0 :         AdjustScrollBars();
    3508                 :            :     }
    3509                 :          0 : }
    3510                 :            : 
    3511                 :          0 : EntryList_Impl::EntryList_Impl( SvxIconChoiceCtrl_Impl* pOwner ) :
    3512                 :          0 :     _pOwner( pOwner )
    3513                 :            : {
    3514                 :          0 :     _pOwner->pHead = 0;
    3515                 :          0 : }
    3516                 :            : 
    3517                 :          0 : EntryList_Impl::~EntryList_Impl()
    3518                 :            : {
    3519                 :          0 :     _pOwner->pHead = 0;
    3520                 :          0 : }
    3521                 :            : 
    3522                 :          0 : void EntryList_Impl::clear()
    3523                 :            : {
    3524                 :          0 :     _pOwner->pHead = 0;
    3525                 :          0 :     maIconChoiceCtrlEntryList.clear();
    3526                 :          0 : }
    3527                 :            : 
    3528                 :          0 : void EntryList_Impl::insert( size_t nPos, SvxIconChoiceCtrlEntry* pEntry )
    3529                 :            : {
    3530         [ #  # ]:          0 :     if ( nPos < maIconChoiceCtrlEntryList.size() ) {
    3531 [ #  # ][ #  # ]:          0 :         maIconChoiceCtrlEntryList.insert( maIconChoiceCtrlEntryList.begin() + nPos, pEntry );
    3532                 :            :     } else {
    3533                 :          0 :         maIconChoiceCtrlEntryList.push_back( pEntry );
    3534                 :            :     }
    3535         [ #  # ]:          0 :     if( _pOwner->pHead )
    3536                 :          0 :         pEntry->SetBacklink( _pOwner->pHead->pblink );
    3537                 :          0 : }
    3538                 :            : 
    3539                 :          0 : void SvxIconChoiceCtrl_Impl::SetPositionMode( SvxIconChoiceCtrlPositionMode eMode )
    3540                 :            : {
    3541         [ #  # ]:          0 :     if( eMode == ePositionMode )
    3542                 :          0 :         return;
    3543                 :            : 
    3544                 :          0 :     SvxIconChoiceCtrlPositionMode eOldMode = ePositionMode;
    3545                 :          0 :     ePositionMode = eMode;
    3546                 :          0 :     size_t nCount = aEntries.size();
    3547                 :            : 
    3548         [ #  # ]:          0 :     if( eOldMode == IcnViewPositionModeAutoArrange )
    3549                 :            :     {
    3550                 :            :         // when positioning moved entries "hard", there are problems with
    3551                 :            :         // unwanted overlaps, as these entries aren't taken into account in
    3552                 :            :         // Arrange.
    3553         [ #  # ]:          0 :         if( aEntries.size() )
    3554                 :          0 :             aAutoArrangeTimer.Start();
    3555                 :          0 :         return;
    3556                 :            :     }
    3557                 :            : 
    3558         [ #  # ]:          0 :     if( ePositionMode == IcnViewPositionModeAutoArrange )
    3559                 :            :     {
    3560         [ #  # ]:          0 :         for( size_t nCur = 0; nCur < nCount; nCur++ )
    3561                 :            :         {
    3562                 :          0 :             SvxIconChoiceCtrlEntry* pEntry = aEntries[ nCur ];
    3563         [ #  # ]:          0 :             if( pEntry->GetFlags() & (ICNVIEW_FLAG_POS_LOCKED | ICNVIEW_FLAG_POS_MOVED))
    3564         [ #  # ]:          0 :                 SetEntryPos(pEntry, GetEntryBoundRect( pEntry ).TopLeft());
    3565                 :            :         }
    3566                 :            : 
    3567         [ #  # ]:          0 :         if( aEntries.size() )
    3568                 :          0 :             aAutoArrangeTimer.Start();
    3569                 :            :     }
    3570         [ #  # ]:          0 :     else if( ePositionMode == IcnViewPositionModeAutoAdjust )
    3571                 :            :     {
    3572                 :          0 :         AdjustEntryAtGrid( 0 );
    3573                 :            :     }
    3574                 :            : }
    3575                 :            : 
    3576                 :          0 : void SvxIconChoiceCtrl_Impl::SetEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry,
    3577                 :            :     SvxIconChoiceCtrlEntry* pPredecessor )
    3578                 :            : {
    3579         [ #  # ]:          0 :     if( !IsAutoArrange() )
    3580                 :          0 :         return;
    3581                 :            : 
    3582         [ #  # ]:          0 :     if( pEntry == pPredecessor )
    3583                 :          0 :         return;
    3584                 :            : 
    3585                 :          0 :     sal_uLong nPos1 = GetEntryListPos( pEntry );
    3586         [ #  # ]:          0 :     if( !pHead )
    3587                 :            :     {
    3588         [ #  # ]:          0 :         if( pPredecessor )
    3589                 :            :         {
    3590                 :          0 :             sal_uLong nPos2 = GetEntryListPos( pPredecessor );
    3591         [ #  # ]:          0 :             if( nPos1 == (nPos2 + 1) )
    3592                 :          0 :                 return; // is already the predecessor
    3593                 :            :         }
    3594         [ #  # ]:          0 :         else if( !nPos1 )
    3595                 :          0 :             return;
    3596                 :            :     }
    3597                 :            : 
    3598         [ #  # ]:          0 :     if( !pHead )
    3599                 :          0 :         InitPredecessors();
    3600                 :            : 
    3601 [ #  # ][ #  # ]:          0 :     if( !pPredecessor && pHead == pEntry )
    3602                 :          0 :         return; // is already the first one
    3603                 :            : 
    3604                 :          0 :     sal_Bool bSetHead = sal_False;
    3605         [ #  # ]:          0 :     if( !pPredecessor )
    3606                 :            :     {
    3607                 :          0 :         bSetHead = sal_True;
    3608                 :          0 :         pPredecessor = pHead->pblink;
    3609                 :            :     }
    3610         [ #  # ]:          0 :     if( pEntry == pHead )
    3611                 :            :     {
    3612                 :          0 :         pHead = pHead->pflink;
    3613                 :          0 :         bSetHead = sal_False;
    3614                 :            :     }
    3615         [ #  # ]:          0 :     if( pEntry != pPredecessor )
    3616                 :            :     {
    3617                 :          0 :         pEntry->Unlink();
    3618                 :          0 :         pEntry->SetBacklink( pPredecessor );
    3619                 :            :     }
    3620         [ #  # ]:          0 :     if( bSetHead )
    3621                 :          0 :         pHead = pEntry;
    3622                 :          0 :     pEntry->SetFlags( ICNVIEW_FLAG_PRED_SET );
    3623                 :          0 :     aAutoArrangeTimer.Start();
    3624                 :            : }
    3625                 :            : 
    3626                 :          0 : SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::FindEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry,
    3627                 :            :     const Point& rPosTopLeft )
    3628                 :            : {
    3629                 :          0 :     Point aPos( rPosTopLeft ); //TopLeft
    3630         [ #  # ]:          0 :     Rectangle aCenterRect( CalcBmpRect( pEntry, &aPos ));
    3631         [ #  # ]:          0 :     Point aNewPos( aCenterRect.Center() );
    3632                 :          0 :     sal_uLong nGrid = GetPredecessorGrid( aNewPos );
    3633                 :          0 :     size_t nCount = aEntries.size();
    3634         [ #  # ]:          0 :     if( nGrid == ULONG_MAX )
    3635                 :          0 :         return 0;
    3636         [ #  # ]:          0 :     if( nGrid >= nCount )
    3637                 :          0 :         nGrid = nCount - 1;
    3638         [ #  # ]:          0 :     if( !pHead )
    3639         [ #  # ]:          0 :         return aEntries[ nGrid ];
    3640                 :            : 
    3641                 :          0 :     SvxIconChoiceCtrlEntry* pCur = pHead; // Grid 0
    3642                 :            :     // TODO: go through list from the end if nGrid > nCount/2
    3643         [ #  # ]:          0 :     for( sal_uLong nCur = 0; nCur < nGrid; nCur++ )
    3644                 :          0 :         pCur = pCur->pflink;
    3645                 :            : 
    3646                 :          0 :     return pCur;
    3647                 :            : }
    3648                 :            : 
    3649                 :          0 : sal_uLong SvxIconChoiceCtrl_Impl::GetPredecessorGrid( const Point& rPos) const
    3650                 :            : {
    3651                 :          0 :     Point aPos( rPos );
    3652                 :          0 :     aPos.X() -= LROFFS_WINBORDER;
    3653                 :          0 :     aPos.Y() -= TBOFFS_WINBORDER;
    3654                 :          0 :     sal_uInt16 nMaxCol = (sal_uInt16)(aVirtOutputSize.Width() / nGridDX);
    3655         [ #  # ]:          0 :     if( nMaxCol )
    3656                 :          0 :         nMaxCol--;
    3657                 :          0 :     sal_uInt16 nGridX = (sal_uInt16)(aPos.X() / nGridDX);
    3658         [ #  # ]:          0 :     if( nGridX > nMaxCol )
    3659                 :          0 :         nGridX = nMaxCol;
    3660                 :          0 :     sal_uInt16 nGridY = (sal_uInt16)(aPos.Y() / nGridDY);
    3661                 :          0 :     sal_uInt16 nGridsX = (sal_uInt16)(aOutputSize.Width() / nGridDX);
    3662                 :          0 :     sal_uLong nGrid = (nGridY * nGridsX) + nGridX;
    3663                 :          0 :     long nMiddle = (nGridX * nGridDX) + (nGridDX / 2);
    3664         [ #  # ]:          0 :     if( rPos.X() < nMiddle )
    3665                 :            :     {
    3666         [ #  # ]:          0 :         if( !nGrid )
    3667                 :          0 :             nGrid = ULONG_MAX;
    3668                 :            :         else
    3669                 :          0 :             nGrid--;
    3670                 :            :     }
    3671                 :          0 :     return nGrid;
    3672                 :            : }
    3673                 :            : 
    3674                 :          0 : sal_Bool SvxIconChoiceCtrl_Impl::RequestHelp( const HelpEvent& rHEvt )
    3675                 :            : {
    3676         [ #  # ]:          0 :     if ( !(rHEvt.GetMode() & HELPMODE_QUICK ) )
    3677                 :          0 :         return sal_False;
    3678                 :            : 
    3679 [ #  # ][ #  # ]:          0 :     Point aPos( pView->ScreenToOutputPixel(rHEvt.GetMousePosPixel() ) );
    3680                 :          0 :     aPos -= pView->GetMapMode().GetOrigin();
    3681         [ #  # ]:          0 :     SvxIconChoiceCtrlEntry* pEntry = GetEntry( aPos, sal_True );
    3682                 :            : 
    3683         [ #  # ]:          0 :     if ( !pEntry )
    3684                 :          0 :         return sal_False;
    3685                 :            : 
    3686         [ #  # ]:          0 :     String sQuickHelpText = pEntry->GetQuickHelpText();
    3687         [ #  # ]:          0 :     String aEntryText( pView->GetEntryText( pEntry, sal_False ) );
    3688         [ #  # ]:          0 :     Rectangle aTextRect( CalcTextRect( pEntry, 0, sal_False, &aEntryText ) );
    3689 [ #  # ][ #  # ]:          0 :     if ( ( !aTextRect.IsInside( aPos ) || !aEntryText.Len() ) && !sQuickHelpText.Len() )
         [ #  # ][ #  # ]
                 [ #  # ]
    3690                 :          0 :         return sal_False;
    3691                 :            : 
    3692                 :          0 :     Rectangle aOptTextRect( aTextRect );
    3693                 :          0 :     aOptTextRect.Bottom() = LONG_MAX;
    3694                 :          0 :     sal_uInt16 nNewFlags = nCurTextDrawFlags;
    3695                 :          0 :     nNewFlags &= ~( TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS );
    3696         [ #  # ]:          0 :     aOptTextRect = pView->GetTextRect( aOptTextRect, aEntryText, nNewFlags );
    3697 [ #  # ][ #  # ]:          0 :     if ( aOptTextRect != aTextRect || sQuickHelpText.Len() > 0 )
         [ #  # ][ #  # ]
    3698                 :            :     {
    3699                 :            :         //aTextRect.Right() = aTextRect.Left() + aRealSize.Width() + 4;
    3700                 :          0 :         Point aPt( aOptTextRect.TopLeft() );
    3701                 :          0 :         aPt += pView->GetMapMode().GetOrigin();
    3702         [ #  # ]:          0 :         aPt = pView->OutputToScreenPixel( aPt );
    3703                 :            :         // subtract border of tooltip help
    3704                 :          0 :         aPt.Y() -= 1;
    3705                 :          0 :         aPt.X() -= 3;
    3706                 :          0 :         aOptTextRect.SetPos( aPt );
    3707         [ #  # ]:          0 :         String sHelpText;
    3708         [ #  # ]:          0 :         if ( sQuickHelpText.Len() > 0 )
    3709         [ #  # ]:          0 :             sHelpText = sQuickHelpText;
    3710                 :            :         else
    3711         [ #  # ]:          0 :             sHelpText = aEntryText;
    3712 [ #  # ][ #  # ]:          0 :         Help::ShowQuickHelp( (Window*)pView, aOptTextRect, sHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
    3713                 :            :     }
    3714                 :            : 
    3715 [ #  # ][ #  # ]:          0 :     return sal_True;
    3716                 :            : }
    3717                 :            : 
    3718                 :          0 : void SvxIconChoiceCtrl_Impl::ClearColumnList()
    3719                 :            : {
    3720         [ #  # ]:          0 :     if( !pColumns )
    3721                 :          0 :         return;
    3722                 :            : 
    3723                 :          0 :     pColumns->clear();
    3724         [ #  # ]:          0 :     DELETEZ(pColumns);
    3725                 :            : }
    3726                 :            : 
    3727                 :          0 : void SvxIconChoiceCtrl_Impl::SetColumn( sal_uInt16 nIndex, const SvxIconChoiceCtrlColumnInfo& rInfo)
    3728                 :            : {
    3729         [ #  # ]:          0 :     if( !pColumns )
    3730         [ #  # ]:          0 :         pColumns = new SvxIconChoiceCtrlColumnInfoMap;
    3731                 :            : 
    3732         [ #  # ]:          0 :     SvxIconChoiceCtrlColumnInfo* pInfo = new SvxIconChoiceCtrlColumnInfo( rInfo );
    3733                 :          0 :     pColumns->insert( nIndex,  pInfo );
    3734                 :            : 
    3735                 :            :     // HACK: Detail mode is not yet fully implemented, this workaround makes it
    3736                 :            :     // fly with a single column
    3737 [ #  # ][ #  # ]:          0 :     if( !nIndex && (nWinBits & WB_DETAILS) )
    3738                 :          0 :         nGridDX = pInfo->GetWidth();
    3739                 :            : 
    3740         [ #  # ]:          0 :     if( GetUpdateMode() )
    3741                 :          0 :         Arrange( IsAutoArrange() );
    3742                 :          0 : }
    3743                 :            : 
    3744                 :          0 : const SvxIconChoiceCtrlColumnInfo* SvxIconChoiceCtrl_Impl::GetColumn( sal_uInt16 nIndex ) const
    3745                 :            : {
    3746         [ #  # ]:          0 :     if (!pColumns)
    3747                 :          0 :         return 0;
    3748 [ #  # ][ #  # ]:          0 :     SvxIconChoiceCtrlColumnInfoMap::const_iterator it = pColumns->find( nIndex );
    3749 [ #  # ][ #  # ]:          0 :     if( it == pColumns->end() )
                 [ #  # ]
    3750                 :          0 :         return 0;
    3751         [ #  # ]:          0 :     return it->second;
    3752                 :            : }
    3753                 :            : 
    3754                 :          0 : void SvxIconChoiceCtrl_Impl::DrawHighlightFrame(
    3755                 :            :     OutputDevice* pOut, const Rectangle& rBmpRect, sal_Bool bHide )
    3756                 :            : {
    3757                 :          0 :     Rectangle aBmpRect( rBmpRect );
    3758                 :          0 :     long nBorder = 2;
    3759         [ #  # ]:          0 :     if( aImageSize.Width() < 32 )
    3760                 :          0 :         nBorder = 1;
    3761                 :          0 :     aBmpRect.Right() += nBorder;
    3762                 :          0 :     aBmpRect.Left() -= nBorder;
    3763                 :          0 :     aBmpRect.Bottom() += nBorder;
    3764                 :          0 :     aBmpRect.Top() -= nBorder;
    3765                 :            : 
    3766         [ #  # ]:          0 :     if ( bHide )
    3767         [ #  # ]:          0 :         pView->Invalidate( aBmpRect );
    3768                 :            :     else
    3769                 :            :     {
    3770                 :          0 :         DecorationView aDecoView( pOut );
    3771                 :            :         sal_uInt16 nDecoFlags;
    3772         [ #  # ]:          0 :         if ( bHighlightFramePressed )
    3773                 :          0 :             nDecoFlags = FRAME_HIGHLIGHT_TESTBACKGROUND | FRAME_HIGHLIGHT_IN;
    3774                 :            :         else
    3775                 :          0 :             nDecoFlags = FRAME_HIGHLIGHT_TESTBACKGROUND | FRAME_HIGHLIGHT_OUT;
    3776         [ #  # ]:          0 :         aDecoView.DrawHighlightFrame( aBmpRect, nDecoFlags );
    3777                 :            :     }
    3778                 :          0 : }
    3779                 :            : 
    3780                 :          0 : void SvxIconChoiceCtrl_Impl::SetEntryHighlightFrame( SvxIconChoiceCtrlEntry* pEntry,
    3781                 :            :     sal_Bool bKeepHighlightFlags )
    3782                 :            : {
    3783         [ #  # ]:          0 :     if( pEntry == pCurHighlightFrame )
    3784                 :          0 :         return;
    3785                 :            : 
    3786         [ #  # ]:          0 :     if( !bKeepHighlightFlags )
    3787                 :          0 :         bHighlightFramePressed = sal_False;
    3788                 :            : 
    3789                 :          0 :     HideEntryHighlightFrame();
    3790                 :          0 :     pCurHighlightFrame = pEntry;
    3791         [ #  # ]:          0 :     if( pEntry )
    3792                 :            :     {
    3793         [ #  # ]:          0 :         Rectangle aBmpRect( CalcFocusRect(pEntry) );
    3794         [ #  # ]:          0 :         DrawHighlightFrame( pView, aBmpRect, sal_False );
    3795                 :            :     }
    3796                 :            : }
    3797                 :            : 
    3798                 :          0 : void SvxIconChoiceCtrl_Impl::HideEntryHighlightFrame()
    3799                 :            : {
    3800         [ #  # ]:          0 :     if( !pCurHighlightFrame )
    3801                 :          0 :         return;
    3802                 :            : 
    3803                 :          0 :     SvxIconChoiceCtrlEntry* pEntry = pCurHighlightFrame;
    3804                 :          0 :     pCurHighlightFrame = 0;
    3805         [ #  # ]:          0 :     Rectangle aBmpRect( CalcFocusRect(pEntry) );
    3806         [ #  # ]:          0 :     DrawHighlightFrame( pView, aBmpRect, sal_True );
    3807                 :            : }
    3808                 :            : 
    3809                 :          0 : void SvxIconChoiceCtrl_Impl::CallSelectHandler( SvxIconChoiceCtrlEntry* )
    3810                 :            : {
    3811                 :            :     // When single-click mode is active, the selection handler should be called
    3812                 :            :     // synchronously, as the selection is automatically taken away once the
    3813                 :            :     // mouse cursor doesn't touch the object any more. Else, we might run into
    3814                 :            :     // missing calls to Select if the object is selected from a mouse movement,
    3815                 :            :     // because when starting the timer, the mouse cursor might have already left
    3816                 :            :     // the object.
    3817                 :            :     // In special cases (=>SfxFileDialog!), synchronous calls can be forced via
    3818                 :            :     // WB_NOASYNCSELECTHDL.
    3819         [ #  # ]:          0 :     if( nWinBits & (WB_NOASYNCSELECTHDL | WB_HIGHLIGHTFRAME) )
    3820                 :            :     {
    3821                 :          0 :         pHdlEntry = 0;
    3822                 :          0 :         pView->ClickIcon();
    3823                 :            :         //pView->Select();
    3824                 :            :     }
    3825                 :            :     else
    3826                 :          0 :         aCallSelectHdlTimer.Start();
    3827                 :          0 : }
    3828                 :            : 
    3829                 :          0 : IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, CallSelectHdlHdl)
    3830                 :            : {
    3831                 :          0 :     pHdlEntry = 0;
    3832                 :          0 :     pView->ClickIcon();
    3833                 :            :     //pView->Select();
    3834                 :          0 :     return 0;
    3835                 :            : }
    3836                 :            : 
    3837                 :          0 : void SvxIconChoiceCtrl_Impl::SetOrigin( const Point& rPos, sal_Bool bDoNotUpdateWallpaper )
    3838                 :            : {
    3839         [ #  # ]:          0 :     MapMode aMapMode( pView->GetMapMode() );
    3840         [ #  # ]:          0 :     aMapMode.SetOrigin( rPos );
    3841         [ #  # ]:          0 :     pView->SetMapMode( aMapMode );
    3842         [ #  # ]:          0 :     if( !bDoNotUpdateWallpaper )
    3843                 :            :     {
    3844         [ #  # ]:          0 :         sal_Bool bScrollable = pView->GetBackground().IsScrollable();
    3845 [ #  # ][ #  # ]:          0 :         if( pView->HasBackground() && !bScrollable )
         [ #  # ][ #  # ]
    3846                 :            :         {
    3847         [ #  # ]:          0 :             Rectangle aRect( GetOutputRect());
    3848         [ #  # ]:          0 :             Wallpaper aPaper( pView->GetBackground() );
    3849         [ #  # ]:          0 :             aPaper.SetRect( aRect );
    3850 [ #  # ][ #  # ]:          0 :             pView->SetBackground( aPaper );
    3851                 :            :         }
    3852         [ #  # ]:          0 :     }
    3853                 :          0 : }
    3854                 :            : 
    3855                 :          0 : void SvxIconChoiceCtrl_Impl::CallEventListeners( sal_uLong nEvent, void* pData )
    3856                 :            : {
    3857                 :          0 :     pView->CallImplEventListeners( nEvent, pData );
    3858                 :          0 : }
    3859                 :            : 
    3860                 :            : 
    3861                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10