LCOV - code coverage report
Current view: top level - svx/source/dialog - frmsel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 610 0.0 %
Date: 2012-08-25 Functions: 0 91 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1069 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                 :            : #include <svx/frmsel.hxx>
      30                 :            : 
      31                 :            : #include <algorithm>
      32                 :            : #include <math.h>
      33                 :            : #include "frmselimpl.hxx"
      34                 :            : #include "AccessibleFrameSelector.hxx"
      35                 :            : #include <svx/dialmgr.hxx>
      36                 :            : 
      37                 :            : #include <svx/dialogs.hrc>
      38                 :            : #include "frmsel.hrc"
      39                 :            : 
      40                 :            : #include <tools/rcid.h>
      41                 :            : 
      42                 :            : using namespace ::com::sun::star;
      43                 :            : using namespace ::editeng;
      44                 :            : 
      45                 :            : namespace svx {
      46                 :            : 
      47                 :            : using ::com::sun::star::uno::Reference;
      48                 :            : using ::com::sun::star::accessibility::XAccessible;
      49                 :            : 
      50                 :            : // ============================================================================
      51                 :            : // global functions from framebordertype.hxx
      52                 :            : 
      53                 :          0 : FrameBorderType GetFrameBorderTypeFromIndex( size_t nIndex )
      54                 :            : {
      55                 :            :     DBG_ASSERT( nIndex < (size_t)FRAMEBORDERTYPE_COUNT,
      56                 :            :         "svx::GetFrameBorderTypeFromIndex - invalid index" );
      57                 :          0 :     return static_cast< FrameBorderType >( nIndex + 1 );
      58                 :            : }
      59                 :            : 
      60                 :          0 : size_t GetIndexFromFrameBorderType( FrameBorderType eBorder )
      61                 :            : {
      62                 :            :     DBG_ASSERT( eBorder != FRAMEBORDER_NONE,
      63                 :            :         "svx::GetIndexFromFrameBorderType - invalid frame border type" );
      64                 :          0 :     return static_cast< size_t >( eBorder ) - 1;
      65                 :            : }
      66                 :            : 
      67                 :            : // ============================================================================
      68                 :            : 
      69                 :            : namespace {
      70                 :            : 
      71                 :            : /** Space between outer control border and any graphical element of the control. */
      72                 :            : const long FRAMESEL_GEOM_OUTER    = 2;
      73                 :            : 
      74                 :            : /** Space between arrows and usable inner area. */
      75                 :            : const long FRAMESEL_GEOM_INNER    = 3;
      76                 :            : 
      77                 :            : /** Maximum width to draw a frame border style. */
      78                 :            : const long FRAMESEL_GEOM_WIDTH    = 9;
      79                 :            : 
      80                 :            : /** Additional margin for click area of outer lines. */
      81                 :            : const long FRAMESEL_GEOM_ADD_CLICK_OUTER = 5;
      82                 :            : 
      83                 :            : /** Additional margin for click area of inner lines. */
      84                 :            : const long FRAMESEL_GEOM_ADD_CLICK_INNER = 2;
      85                 :            : 
      86                 :            : // ----------------------------------------------------------------------------
      87                 :            : 
      88                 :            : /** Returns the corresponding flag for a frame border. */
      89                 :          0 : FrameSelFlags lclGetFlagFromType( FrameBorderType eBorder )
      90                 :            : {
      91   [ #  #  #  #  :          0 :     switch( eBorder )
          #  #  #  #  #  
                      # ]
      92                 :            :     {
      93                 :          0 :         case FRAMEBORDER_LEFT:      return FRAMESEL_LEFT;
      94                 :          0 :         case FRAMEBORDER_RIGHT:     return FRAMESEL_RIGHT;
      95                 :          0 :         case FRAMEBORDER_TOP:       return FRAMESEL_TOP;
      96                 :          0 :         case FRAMEBORDER_BOTTOM:    return FRAMESEL_BOTTOM;
      97                 :          0 :         case FRAMEBORDER_HOR:       return FRAMESEL_INNER_HOR;
      98                 :          0 :         case FRAMEBORDER_VER:       return FRAMESEL_INNER_VER;
      99                 :          0 :         case FRAMEBORDER_TLBR:      return FRAMESEL_DIAG_TLBR;
     100                 :          0 :         case FRAMEBORDER_BLTR:      return FRAMESEL_DIAG_BLTR;
     101                 :          0 :         case FRAMEBORDER_NONE : break;
     102                 :            :     }
     103                 :          0 :     return FRAMESEL_NONE;
     104                 :            : }
     105                 :            : 
     106                 :            : /** Merges the rSource polypolygon into the rDest polypolygon. */
     107                 :          0 : inline void lclPolyPolyUnion( PolyPolygon& rDest, const PolyPolygon& rSource )
     108                 :            : {
     109         [ #  # ]:          0 :     const PolyPolygon aTmp( rDest );
     110 [ #  # ][ #  # ]:          0 :     aTmp.GetUnion( rSource, rDest );
     111                 :          0 : }
     112                 :            : 
     113                 :            : } // namespace
     114                 :            : 
     115                 :            : // ============================================================================
     116                 :            : // FrameBorder
     117                 :            : // ============================================================================
     118                 :            : 
     119                 :          0 : FrameBorder::FrameBorder( FrameBorderType eType ) :
     120                 :            :     meType( eType ),
     121                 :            :     meState( FRAMESTATE_HIDE ),
     122                 :            :     meKeyLeft( FRAMEBORDER_NONE ),
     123                 :            :     meKeyRight( FRAMEBORDER_NONE ),
     124                 :            :     meKeyTop( FRAMEBORDER_NONE ),
     125                 :            :     meKeyBottom( FRAMEBORDER_NONE ),
     126                 :            :     mbEnabled( false ),
     127         [ #  # ]:          0 :     mbSelected( false )
     128                 :            : {
     129                 :          0 : }
     130                 :            : 
     131                 :          0 : void FrameBorder::Enable( FrameSelFlags nFlags )
     132                 :            : {
     133                 :          0 :     mbEnabled = (nFlags & lclGetFlagFromType( meType )) != 0;
     134         [ #  # ]:          0 :     if( !mbEnabled )
     135                 :          0 :         SetState( FRAMESTATE_HIDE );
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : void FrameBorder::SetCoreStyle( const SvxBorderLine* pStyle )
     139                 :            : {
     140         [ #  # ]:          0 :     if( pStyle )
     141                 :          0 :         maCoreStyle = *pStyle;
     142                 :            :     else
     143         [ #  # ]:          0 :         maCoreStyle = SvxBorderLine();
     144                 :            : 
     145                 :            :     // from twips to points
     146                 :          0 :     maUIStyle.Set( maCoreStyle, 0.05, FRAMESEL_GEOM_WIDTH );
     147                 :          0 :     meState = maUIStyle.Prim() ? FRAMESTATE_SHOW : FRAMESTATE_HIDE;
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : void FrameBorder::SetState( FrameBorderState eState )
     151                 :            : {
     152                 :          0 :     meState = eState;
     153   [ #  #  #  # ]:          0 :     switch( meState )
     154                 :            :     {
     155                 :            :         case FRAMESTATE_SHOW:
     156                 :            :             SAL_WARN( "svx.dialog", "svx::FrameBorder::SetState - use SetCoreStyle to make border visible" );
     157                 :          0 :         break;
     158                 :            :         case FRAMESTATE_HIDE:
     159         [ #  # ]:          0 :             maCoreStyle = SvxBorderLine();
     160                 :          0 :             maUIStyle.Clear();
     161                 :          0 :         break;
     162                 :            :         case FRAMESTATE_DONTCARE:
     163         [ #  # ]:          0 :             maCoreStyle = SvxBorderLine();
     164                 :          0 :             maUIStyle = frame::Style(3, 0, 0, table::BorderLineStyle::SOLID); //OBJ_FRAMESTYLE_DONTCARE
     165                 :          0 :         break;
     166                 :            :     }
     167                 :          0 : }
     168                 :            : 
     169                 :          0 : void FrameBorder::AddFocusPolygon( const Polygon& rFocus )
     170                 :            : {
     171         [ #  # ]:          0 :     lclPolyPolyUnion( maFocusArea, rFocus );
     172                 :          0 : }
     173                 :            : 
     174                 :          0 : void FrameBorder::MergeFocusToPolyPolygon( PolyPolygon& rPPoly ) const
     175                 :            : {
     176                 :          0 :     lclPolyPolyUnion( rPPoly, maFocusArea );
     177                 :          0 : }
     178                 :            : 
     179                 :          0 : void FrameBorder::AddClickRect( const Rectangle& rRect )
     180                 :            : {
     181 [ #  # ][ #  # ]:          0 :     lclPolyPolyUnion( maClickArea, Polygon( rRect ) );
                 [ #  # ]
     182                 :          0 : }
     183                 :            : 
     184                 :          0 : bool FrameBorder::ContainsClickPoint( const Point& rPos ) const
     185                 :            : {
     186         [ #  # ]:          0 :     return Region( maClickArea ).IsInside( rPos );
     187                 :            : }
     188                 :            : 
     189                 :          0 : Rectangle FrameBorder::GetClickBoundRect() const
     190                 :            : {
     191                 :          0 :     return maClickArea.GetBoundRect();
     192                 :            : }
     193                 :            : 
     194                 :          0 : void FrameBorder::SetKeyboardNeighbors(
     195                 :            :         FrameBorderType eLeft, FrameBorderType eRight, FrameBorderType eTop, FrameBorderType eBottom )
     196                 :            : {
     197                 :          0 :     meKeyLeft = eLeft;
     198                 :          0 :     meKeyRight = eRight;
     199                 :          0 :     meKeyTop = eTop;
     200                 :          0 :     meKeyBottom = eBottom;
     201                 :          0 : }
     202                 :            : 
     203                 :          0 : FrameBorderType FrameBorder::GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const
     204                 :            : {
     205                 :          0 :     FrameBorderType eBorder = FRAMEBORDER_NONE;
     206   [ #  #  #  #  :          0 :     switch( nKeyCode )
                      # ]
     207                 :            :     {
     208                 :          0 :         case KEY_LEFT:  eBorder = meKeyLeft;      break;
     209                 :          0 :         case KEY_RIGHT: eBorder = meKeyRight;     break;
     210                 :          0 :         case KEY_UP:    eBorder = meKeyTop;       break;
     211                 :          0 :         case KEY_DOWN:  eBorder = meKeyBottom;    break;
     212                 :            :         default:        SAL_WARN( "svx.dialog", "svx::FrameBorder::GetKeyboardNeighbor - unknown key code" );
     213                 :            :     }
     214                 :          0 :     return eBorder;
     215                 :            : }
     216                 :            : 
     217                 :            : // ============================================================================
     218                 :            : // FrameSelectorImpl
     219                 :            : // ============================================================================
     220                 :            : 
     221                 :          0 : FrameSelectorImpl::FrameSelectorImpl( FrameSelector& rFrameSel ) :
     222                 :          0 :     Resource( SVX_RES( RID_SVXSTR_BORDER_CONTROL ) ),
     223                 :            :     mrFrameSel( rFrameSel ),
     224                 :            :     maILArrows( 16 ),
     225                 :            :     maLeft( FRAMEBORDER_LEFT ),
     226                 :            :     maRight( FRAMEBORDER_RIGHT ),
     227                 :            :     maTop( FRAMEBORDER_TOP ),
     228                 :            :     maBottom( FRAMEBORDER_BOTTOM ),
     229                 :            :     maHor( FRAMEBORDER_HOR ),
     230                 :            :     maVer( FRAMEBORDER_VER ),
     231                 :            :     maTLBR( FRAMEBORDER_TLBR ),
     232                 :            :     maBLTR( FRAMEBORDER_BLTR ),
     233                 :            :     mnFlags( FRAMESEL_OUTER ),
     234                 :            :     mbHor( false ),
     235                 :            :     mbVer( false ),
     236                 :            :     mbTLBR( false ),
     237                 :            :     mbBLTR( false ),
     238                 :            :     mbFullRepaint( true ),
     239                 :            :     mbAutoSelect( true ),
     240                 :            :     mbClicked( false ),
     241                 :            :     mbHCMode( false ),
     242                 :            :     mpAccess( 0 ),
     243                 :            :     maChildVec( 8, static_cast< a11y::AccFrameSelector* >( 0 ) ),
     244 [ #  # ][ #  # ]:          0 :     mxChildVec( 8 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     245                 :            : {
     246         [ #  # ]:          0 :     FreeResource();
     247                 :            : 
     248         [ #  # ]:          0 :     maAllBorders.resize( FRAMEBORDERTYPE_COUNT, 0 );
     249                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_LEFT   ) ] = &maLeft;
     250                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_RIGHT  ) ] = &maRight;
     251                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_TOP    ) ] = &maTop;
     252                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_BOTTOM ) ] = &maBottom;
     253                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_HOR    ) ] = &maHor;
     254                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_VER    ) ] = &maVer;
     255                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_TLBR   ) ] = &maTLBR;
     256                 :          0 :     maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_BLTR   ) ] = &maBLTR;
     257                 :            : #if OSL_DEBUG_LEVEL >= 2
     258                 :            :     {
     259                 :            :         bool bOk = true;
     260                 :            :         for( FrameBorderCIter aIt( maAllBorders ); bOk && aIt.Is(); bOk = (*aIt != 0), ++aIt );
     261                 :            :         DBG_ASSERT( bOk, "svx::FrameSelectorImpl::FrameSelectorImpl - missing entry in maAllBorders" );
     262                 :            :     }
     263                 :            : #endif
     264                 :            :     //                             left neighbor     right neighbor     upper neighbor    lower neighbor
     265                 :          0 :     maLeft.SetKeyboardNeighbors(   FRAMEBORDER_NONE, FRAMEBORDER_TLBR,  FRAMEBORDER_TOP,  FRAMEBORDER_BOTTOM );
     266                 :          0 :     maRight.SetKeyboardNeighbors(  FRAMEBORDER_BLTR, FRAMEBORDER_NONE,  FRAMEBORDER_TOP,  FRAMEBORDER_BOTTOM );
     267                 :          0 :     maTop.SetKeyboardNeighbors(    FRAMEBORDER_LEFT, FRAMEBORDER_RIGHT, FRAMEBORDER_NONE, FRAMEBORDER_TLBR );
     268                 :          0 :     maBottom.SetKeyboardNeighbors( FRAMEBORDER_LEFT, FRAMEBORDER_RIGHT, FRAMEBORDER_BLTR, FRAMEBORDER_NONE );
     269                 :          0 :     maHor.SetKeyboardNeighbors(    FRAMEBORDER_LEFT, FRAMEBORDER_RIGHT, FRAMEBORDER_TLBR, FRAMEBORDER_BLTR );
     270                 :          0 :     maVer.SetKeyboardNeighbors(    FRAMEBORDER_TLBR, FRAMEBORDER_BLTR,  FRAMEBORDER_TOP,  FRAMEBORDER_BOTTOM );
     271                 :          0 :     maTLBR.SetKeyboardNeighbors(   FRAMEBORDER_LEFT, FRAMEBORDER_VER,   FRAMEBORDER_TOP,  FRAMEBORDER_HOR );
     272                 :          0 :     maBLTR.SetKeyboardNeighbors(   FRAMEBORDER_VER,  FRAMEBORDER_RIGHT, FRAMEBORDER_HOR,  FRAMEBORDER_BOTTOM );
     273                 :          0 : }
     274                 :            : 
     275 [ #  # ][ #  # ]:          0 : FrameSelectorImpl::~FrameSelectorImpl()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     276                 :            : {
     277         [ #  # ]:          0 :     if( mpAccess )
     278         [ #  # ]:          0 :         mpAccess->Invalidate();
     279 [ #  # ][ #  # ]:          0 :     for( AccessibleImplVec::iterator aIt = maChildVec.begin(), aEnd = maChildVec.end(); aIt != aEnd; ++aIt )
     280         [ #  # ]:          0 :         if( *aIt )
     281         [ #  # ]:          0 :             (*aIt)->Invalidate();
     282                 :          0 : }
     283                 :            : 
     284                 :            : // initialization -------------------------------------------------------------
     285                 :            : 
     286                 :          0 : void FrameSelectorImpl::Initialize( FrameSelFlags nFlags )
     287                 :            : {
     288                 :          0 :     mnFlags = nFlags;
     289                 :            : 
     290                 :          0 :     maEnabBorders.clear();
     291 [ #  # ][ #  # ]:          0 :     for( FrameBorderIter aIt( maAllBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     292                 :            :     {
     293 [ #  # ][ #  # ]:          0 :         (*aIt)->Enable( mnFlags );
     294 [ #  # ][ #  # ]:          0 :         if( (*aIt)->IsEnabled() )
     295 [ #  # ][ #  # ]:          0 :             maEnabBorders.push_back( *aIt );
     296                 :            :     }
     297                 :          0 :     mbHor = maHor.IsEnabled();
     298                 :          0 :     mbVer = maVer.IsEnabled();
     299                 :          0 :     mbTLBR = maTLBR.IsEnabled();
     300                 :          0 :     mbBLTR = maBLTR.IsEnabled();
     301                 :            : 
     302                 :          0 :     InitVirtualDevice();
     303                 :          0 : }
     304                 :            : 
     305                 :          0 : void FrameSelectorImpl::InitColors()
     306                 :            : {
     307                 :          0 :     const StyleSettings& rSett = mrFrameSel.GetSettings().GetStyleSettings();
     308                 :          0 :     maBackCol = rSett.GetFieldColor();
     309                 :          0 :     mbHCMode = rSett.GetHighContrastMode();
     310                 :          0 :     maArrowCol = rSett.GetFieldTextColor();
     311         [ #  # ]:          0 :     maMarkCol.operator=( maBackCol ).Merge( maArrowCol, mbHCMode ? 0x80 : 0xC0 );
     312                 :          0 :     maHCLineCol = rSett.GetLabelTextColor();
     313                 :          0 : }
     314                 :            : 
     315                 :          0 : void FrameSelectorImpl::InitArrowImageList()
     316                 :            : {
     317                 :            :     /* Build the arrow images bitmap with current colors. */
     318         [ #  # ]:          0 :     Color pColorAry1[3];
     319         [ #  # ]:          0 :     Color pColorAry2[3];
     320                 :          0 :     pColorAry1[0] = Color( 0, 0, 0 );
     321                 :          0 :     pColorAry2[0] = maArrowCol;       // black -> arrow color
     322                 :          0 :     pColorAry1[1] = Color( 0, 255, 0 );
     323                 :          0 :     pColorAry2[1] = maMarkCol;        // green -> marker color
     324                 :          0 :     pColorAry1[2] = Color( 255, 0, 255 );
     325                 :          0 :     pColorAry2[2] = maBackCol;       // magenta -> background
     326                 :            : 
     327 [ #  # ][ #  # ]:          0 :     GetRes( SVX_RES( RID_SVXSTR_BORDER_CONTROL ).SetRT( RSC_RESOURCE ) );
     328                 :            :     maILArrows.InsertFromHorizontalBitmap(
     329 [ #  # ][ #  # ]:          0 :         SVX_RES( BMP_FRMSEL_ARROWS ), 16, NULL, pColorAry1, pColorAry2, 3);
     330         [ #  # ]:          0 :     FreeResource();
     331                 :            :     DBG_ASSERT( maILArrows.GetImageSize().Height() == maILArrows.GetImageSize().Width(),
     332                 :            :         "svx::FrameSelectorImpl::InitArrowImageList - images are not squarish" );
     333         [ #  # ]:          0 :     mnArrowSize = maILArrows.GetImageSize().Height();
     334                 :          0 : }
     335                 :            : 
     336                 :          0 : void FrameSelectorImpl::InitGlobalGeometry()
     337                 :            : {
     338 [ #  # ][ #  # ]:          0 :     Size aCtrlSize( mrFrameSel.CalcOutputSize( mrFrameSel.GetSizePixel() ) );
     339                 :            :     /*  nMinSize is the lower of width and height (control will always be squarish).
     340                 :            :         FRAMESEL_GEOM_OUTER is the minimal distance between inner control border
     341                 :            :         and any element. */
     342                 :          0 :     long nMinSize = Min( aCtrlSize.Width(), aCtrlSize.Height() ) - 2 * FRAMESEL_GEOM_OUTER;
     343                 :            :     /*  nFixedSize is the size all existing elements need in one direction:
     344                 :            :         the diag. arrow, space betw. arrow and frame border, outer frame border,
     345                 :            :         inner frame border, other outer frame border, space betw. frame border
     346                 :            :         and arrow, the other arrow. */
     347                 :          0 :     long nFixedSize = 2 * mnArrowSize + 2 * FRAMESEL_GEOM_INNER + 3 * FRAMESEL_GEOM_WIDTH;
     348                 :            :     /*  nBetwBordersSize contains the size between an outer and inner frame border (made odd). */
     349                 :          0 :     long nBetwBordersSize = (((nMinSize - nFixedSize) / 2) - 1) | 1;
     350                 :            : 
     351                 :            :     /*  The final size of the usable area. */
     352                 :          0 :     mnCtrlSize = 2 * nBetwBordersSize + nFixedSize;
     353         [ #  # ]:          0 :     maVirDev.SetOutputSizePixel( Size( mnCtrlSize, mnCtrlSize ) );
     354                 :            : 
     355                 :            :     /*  Center the virtual device in the control. */
     356                 :          0 :     maVirDevPos = Point( (aCtrlSize.Width() - mnCtrlSize) / 2, (aCtrlSize.Height() - mnCtrlSize) / 2 );
     357                 :          0 : }
     358                 :            : 
     359                 :          0 : void FrameSelectorImpl::InitBorderGeometry()
     360                 :            : {
     361                 :            :     size_t nCol, nCols, nRow, nRows;
     362                 :            : 
     363                 :            :     // Global border geometry values ------------------------------------------
     364                 :            : 
     365                 :            :     /*  mnLine* is the middle point inside a frame border (i.e. mnLine1 is mid X inside left border). */
     366                 :          0 :     mnLine1 = mnArrowSize + FRAMESEL_GEOM_INNER + FRAMESEL_GEOM_WIDTH / 2;
     367                 :          0 :     mnLine2 = mnCtrlSize / 2;
     368                 :          0 :     mnLine3 = 2 * mnLine2 - mnLine1;
     369                 :            : 
     370                 :            :     // Frame helper array -----------------------------------------------------
     371                 :            : 
     372 [ #  # ][ #  # ]:          0 :     maArray.Initialize( mbVer ? 2 : 1, mbHor ? 2 : 1 );
     373                 :          0 :     maArray.SetUseDiagDoubleClipping( true );
     374                 :            : 
     375                 :          0 :     maArray.SetXOffset( mnLine1 );
     376         [ #  # ]:          0 :     maArray.SetAllColWidths( (mbVer ? mnLine2 : mnLine3) - mnLine1 );
     377                 :            : 
     378                 :          0 :     maArray.SetYOffset( mnLine1 );
     379         [ #  # ]:          0 :     maArray.SetAllRowHeights( (mbHor ? mnLine2 : mnLine3) - mnLine1 );
     380                 :            : 
     381                 :            :     // Focus polygons ---------------------------------------------------------
     382                 :            : 
     383                 :            :     /*  Width for focus rectangles from center of frame borders. */
     384                 :          0 :     mnFocusOffs = FRAMESEL_GEOM_WIDTH / 2 + 1;
     385                 :            : 
     386 [ #  # ][ #  # ]:          0 :     maLeft.AddFocusPolygon(   Rectangle( mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine1 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
                 [ #  # ]
     387 [ #  # ][ #  # ]:          0 :     maVer.AddFocusPolygon(    Rectangle( mnLine2 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine2 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
                 [ #  # ]
     388 [ #  # ][ #  # ]:          0 :     maRight.AddFocusPolygon(  Rectangle( mnLine3 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
                 [ #  # ]
     389 [ #  # ][ #  # ]:          0 :     maTop.AddFocusPolygon(    Rectangle( mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine1 + mnFocusOffs ) );
                 [ #  # ]
     390 [ #  # ][ #  # ]:          0 :     maHor.AddFocusPolygon(    Rectangle( mnLine1 - mnFocusOffs, mnLine2 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine2 + mnFocusOffs ) );
                 [ #  # ]
     391 [ #  # ][ #  # ]:          0 :     maBottom.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine3 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
                 [ #  # ]
     392                 :            : 
     393         [ #  # ]:          0 :     for( nCol = 0, nCols = maArray.GetColCount(); nCol < nCols; ++nCol )
     394                 :            :     {
     395         [ #  # ]:          0 :         for( nRow = 0, nRows = maArray.GetRowCount(); nRow < nRows; ++nRow )
     396                 :            :         {
     397         [ #  # ]:          0 :             Rectangle aRect( maArray.GetCellRect( nCol, nRow ) );
     398 [ #  # ][ #  # ]:          0 :             long nDiagFocusOffsX = frame::GetTLDiagOffset( -mnFocusOffs, mnFocusOffs, maArray.GetHorDiagAngle( nCol, nRow ) );
     399 [ #  # ][ #  # ]:          0 :             long nDiagFocusOffsY = frame::GetTLDiagOffset( -mnFocusOffs, mnFocusOffs, maArray.GetVerDiagAngle( nCol, nRow ) );
     400                 :            : 
     401         [ #  # ]:          0 :             std::vector< Point > aFocusVec;
     402         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Left()  - mnFocusOffs,     aRect.Top()    + nDiagFocusOffsY ) );
     403         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Left()  - mnFocusOffs,     aRect.Top()    - mnFocusOffs     ) );
     404         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Left()  + nDiagFocusOffsX, aRect.Top()    - mnFocusOffs     ) );
     405         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs,     aRect.Bottom() - nDiagFocusOffsY ) );
     406         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs,     aRect.Bottom() + mnFocusOffs     ) );
     407         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Right() - nDiagFocusOffsX, aRect.Bottom() + mnFocusOffs     ) );
     408 [ #  # ][ #  # ]:          0 :             maTLBR.AddFocusPolygon( Polygon( static_cast< sal_uInt16 >( aFocusVec.size() ), &aFocusVec[ 0 ] ) );
                 [ #  # ]
     409                 :            : 
     410                 :          0 :             aFocusVec.clear();
     411         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs,     aRect.Top()    + nDiagFocusOffsY ) );
     412         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs,     aRect.Top()    - mnFocusOffs     ) );
     413         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Right() - nDiagFocusOffsX, aRect.Top()    - mnFocusOffs     ) );
     414         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Left()  - mnFocusOffs,     aRect.Bottom() - nDiagFocusOffsY ) );
     415         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Left()  - mnFocusOffs,     aRect.Bottom() + mnFocusOffs     ) );
     416         [ #  # ]:          0 :             aFocusVec.push_back( Point( aRect.Left()  + nDiagFocusOffsX, aRect.Bottom() + mnFocusOffs     ) );
     417 [ #  # ][ #  # ]:          0 :             maBLTR.AddFocusPolygon( Polygon( static_cast< sal_uInt16 >( aFocusVec.size() ), &aFocusVec[ 0 ] ) );
                 [ #  # ]
     418                 :          0 :         }
     419                 :            :     }
     420                 :            : 
     421                 :            :     // Click areas ------------------------------------------------------------
     422                 :            : 
     423 [ #  # ][ #  # ]:          0 :     for( FrameBorderIter aIt( maAllBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     424 [ #  # ][ #  # ]:          0 :         (*aIt)->ClearClickArea();
     425                 :            : 
     426                 :            :     /*  Additional space for click area: is added to the space available to draw
     427                 :            :         the frame borders. For instance left frame border:
     428                 :            :         - To left, top, and bottom always big additional space (outer area).
     429                 :            :         - To right: Dependent on existence of inner vertical frame border
     430                 :            :             (if enabled, use less space).
     431                 :            :      */
     432                 :          0 :     long nClO = FRAMESEL_GEOM_WIDTH / 2 + FRAMESEL_GEOM_ADD_CLICK_OUTER;
     433 [ #  # ][ #  # ]:          0 :     long nClI = (mbTLBR && mbBLTR) ? (FRAMESEL_GEOM_WIDTH / 2 + FRAMESEL_GEOM_ADD_CLICK_INNER) : nClO;
     434         [ #  # ]:          0 :     long nClH = mbHor ? nClI : nClO;            // additional space dependent of horizontal inner border
     435         [ #  # ]:          0 :     long nClV = mbVer ? nClI : nClO;            // additional space dependent of vertical inner border
     436                 :            : 
     437         [ #  # ]:          0 :     maLeft.AddClickRect(   Rectangle( mnLine1 - nClO, mnLine1 - nClO, mnLine1 + nClV, mnLine3 + nClO ) );
     438         [ #  # ]:          0 :     maVer.AddClickRect(    Rectangle( mnLine2 - nClI, mnLine1 - nClO, mnLine2 + nClI, mnLine3 + nClO ) );
     439         [ #  # ]:          0 :     maRight.AddClickRect(  Rectangle( mnLine3 - nClV, mnLine1 - nClO, mnLine3 + nClO, mnLine3 + nClO ) );
     440         [ #  # ]:          0 :     maTop.AddClickRect(    Rectangle( mnLine1 - nClO, mnLine1 - nClO, mnLine3 + nClO, mnLine1 + nClH ) );
     441         [ #  # ]:          0 :     maHor.AddClickRect(    Rectangle( mnLine1 - nClO, mnLine2 - nClI, mnLine3 + nClO, mnLine2 + nClI ) );
     442         [ #  # ]:          0 :     maBottom.AddClickRect( Rectangle( mnLine1 - nClO, mnLine3 - nClH, mnLine3 + nClO, mnLine3 + nClO ) );
     443                 :            : 
     444                 :            :     /*  Diagonal frame borders use the remaining space between outer and inner frame borders. */
     445 [ #  # ][ #  # ]:          0 :     if( mbTLBR || mbBLTR )
     446                 :            :     {
     447         [ #  # ]:          0 :         for( nCol = 0, nCols = maArray.GetColCount(); nCol < nCols; ++nCol )
     448                 :            :         {
     449         [ #  # ]:          0 :             for( nRow = 0, nRows = maArray.GetRowCount(); nRow < nRows; ++nRow )
     450                 :            :             {
     451                 :            :                 // the usable area between horizonal/vertical frame borders of current quadrant
     452         [ #  # ]:          0 :                 Rectangle aRect( maArray.GetCellRect( nCol, nRow ) );
     453                 :          0 :                 aRect.Left() += nClV + 1;
     454                 :          0 :                 aRect.Right() -= nClV + 1;
     455                 :          0 :                 aRect.Top() += nClH + 1;
     456                 :          0 :                 aRect.Bottom() -= nClH + 1;
     457                 :            : 
     458                 :            :                 /*  Both diagonal frame borders enabled. */
     459 [ #  # ][ #  # ]:          0 :                 if( mbTLBR && mbBLTR )
     460                 :            :                 {
     461                 :            :                     // single areas
     462         [ #  # ]:          0 :                     Point aMid( aRect.Center() );
     463 [ #  # ][ #  # ]:          0 :                     maTLBR.AddClickRect( Rectangle( aRect.TopLeft(), aMid ) );
     464 [ #  # ][ #  # ]:          0 :                     maTLBR.AddClickRect( Rectangle( aMid + Point( 1, 1 ), aRect.BottomRight() ) );
                 [ #  # ]
     465 [ #  # ][ #  # ]:          0 :                     maBLTR.AddClickRect( Rectangle( aRect.Left(), aMid.Y() + 1, aMid.X(), aRect.Bottom() ) );
     466 [ #  # ][ #  # ]:          0 :                     maBLTR.AddClickRect( Rectangle( aMid.X() + 1, aRect.Top(), aRect.Right(), aMid.Y() ) );
     467                 :            :                     // centered rectangle for both frame borders
     468 [ #  # ][ #  # ]:          0 :                     Rectangle aMidRect( aRect.TopLeft(), Size( aRect.GetWidth() / 3, aRect.GetHeight() / 3 ) );
                 [ #  # ]
     469 [ #  # ][ #  # ]:          0 :                     aMidRect.Move( (aRect.GetWidth() - aMidRect.GetWidth()) / 2, (aRect.GetHeight() - aMidRect.GetHeight()) / 2 );
         [ #  # ][ #  # ]
                 [ #  # ]
     470         [ #  # ]:          0 :                     maTLBR.AddClickRect( aMidRect );
     471         [ #  # ]:          0 :                     maBLTR.AddClickRect( aMidRect );
     472                 :            :                 }
     473                 :            :                 /*  One of the diagonal frame borders enabled - use entire rectangle. */
     474 [ #  # ][ #  # ]:          0 :                 else if( mbTLBR && !mbBLTR )    // top-left to bottom-right only
     475         [ #  # ]:          0 :                     maTLBR.AddClickRect( aRect );
     476 [ #  # ][ #  # ]:          0 :                 else if( !mbTLBR && mbBLTR )    // bottom-left to top-right only
     477         [ #  # ]:          0 :                     maBLTR.AddClickRect( aRect );
     478                 :            :             }
     479                 :            :         }
     480                 :            :     }
     481                 :          0 : }
     482                 :            : 
     483                 :          0 : void FrameSelectorImpl::InitVirtualDevice()
     484                 :            : {
     485                 :            :     // initialize resources
     486                 :          0 :     InitColors();
     487                 :          0 :     InitArrowImageList();
     488                 :            : 
     489                 :            :     // initialize geometry
     490                 :          0 :     InitGlobalGeometry();
     491                 :          0 :     InitBorderGeometry();
     492                 :            : 
     493                 :            :     // correct background around the used area
     494         [ #  # ]:          0 :     mrFrameSel.SetBackground( Wallpaper( maBackCol ) );
     495                 :          0 :     DoInvalidate( true );
     496                 :          0 : }
     497                 :            : 
     498                 :            : // frame border access --------------------------------------------------------
     499                 :            : 
     500                 :          0 : const FrameBorder& FrameSelectorImpl::GetBorder( FrameBorderType eBorder ) const
     501                 :            : {
     502                 :          0 :     size_t nIndex = GetIndexFromFrameBorderType( eBorder );
     503         [ #  # ]:          0 :     if( nIndex < maAllBorders.size() )
     504                 :          0 :         return *maAllBorders[ nIndex ];
     505                 :            :     SAL_WARN( "svx.dialog", "svx::FrameSelectorImpl::GetBorder - unknown border type" );
     506                 :          0 :     return maTop;
     507                 :            : }
     508                 :            : 
     509                 :          0 : FrameBorder& FrameSelectorImpl::GetBorderAccess( FrameBorderType eBorder )
     510                 :            : {
     511                 :          0 :     return const_cast< FrameBorder& >( GetBorder( eBorder ) );
     512                 :            : }
     513                 :            : 
     514                 :            : // drawing --------------------------------------------------------------------
     515                 :            : 
     516                 :          0 : void FrameSelectorImpl::DrawBackground()
     517                 :            : {
     518                 :            :     // clear the area
     519         [ #  # ]:          0 :     maVirDev.SetLineColor();
     520         [ #  # ]:          0 :     maVirDev.SetFillColor( maBackCol );
     521 [ #  # ][ #  # ]:          0 :     maVirDev.DrawRect( Rectangle( Point( 0, 0 ), maVirDev.GetOutputSizePixel() ) );
     522                 :            : 
     523                 :            :     // draw the inner gray (or whatever color) rectangle
     524         [ #  # ]:          0 :     maVirDev.SetLineColor();
     525         [ #  # ]:          0 :     maVirDev.SetFillColor( maMarkCol );
     526                 :            :     maVirDev.DrawRect( Rectangle(
     527 [ #  # ][ #  # ]:          0 :         mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
     528                 :            : 
     529                 :            :     // draw the white space for enabled frame borders
     530         [ #  # ]:          0 :     PolyPolygon aPPoly;
     531 [ #  # ][ #  # ]:          0 :     for( FrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     532 [ #  # ][ #  # ]:          0 :         (*aIt)->MergeFocusToPolyPolygon( aPPoly );
     533         [ #  # ]:          0 :     aPPoly.Optimize( POLY_OPTIMIZE_CLOSE );
     534         [ #  # ]:          0 :     maVirDev.SetLineColor( maBackCol );
     535         [ #  # ]:          0 :     maVirDev.SetFillColor( maBackCol );
     536 [ #  # ][ #  # ]:          0 :     maVirDev.DrawPolyPolygon( aPPoly );
     537                 :          0 : }
     538                 :            : 
     539                 :          0 : void FrameSelectorImpl::DrawArrows( const FrameBorder& rBorder )
     540                 :            : {
     541                 :            :     DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::DrawArrows - access to disabled border" );
     542                 :            : 
     543                 :          0 :     long nLinePos = 0;
     544   [ #  #  #  # ]:          0 :     switch( rBorder.GetType() )
     545                 :            :     {
     546                 :            :         case FRAMEBORDER_LEFT:
     547                 :          0 :         case FRAMEBORDER_TOP:       nLinePos = mnLine1; break;
     548                 :            :         case FRAMEBORDER_VER:
     549                 :          0 :         case FRAMEBORDER_HOR:       nLinePos = mnLine2; break;
     550                 :            :         case FRAMEBORDER_RIGHT:
     551                 :          0 :         case FRAMEBORDER_BOTTOM:    nLinePos = mnLine3; break;
     552                 :            :         default: ; //prevent warning
     553                 :            :     }
     554                 :          0 :     nLinePos -= mnArrowSize / 2;
     555                 :            : 
     556                 :          0 :     long nTLPos = 0;
     557                 :          0 :     long nBRPos = mnCtrlSize - mnArrowSize;
     558                 :          0 :     Point aPos1, aPos2;
     559                 :          0 :     sal_uInt16 nImgId1 = 0, nImgId2 = 0;
     560   [ #  #  #  #  :          0 :     switch( rBorder.GetType() )
                      # ]
     561                 :            :     {
     562                 :            :         case FRAMEBORDER_LEFT:
     563                 :            :         case FRAMEBORDER_RIGHT:
     564                 :            :         case FRAMEBORDER_VER:
     565                 :          0 :             aPos1 = Point( nLinePos, nTLPos ); nImgId1 = 1;
     566                 :          0 :             aPos2 = Point( nLinePos, nBRPos ); nImgId2 = 2;
     567                 :          0 :         break;
     568                 :            : 
     569                 :            :         case FRAMEBORDER_TOP:
     570                 :            :         case FRAMEBORDER_BOTTOM:
     571                 :            :         case FRAMEBORDER_HOR:
     572                 :          0 :             aPos1 = Point( nTLPos, nLinePos ); nImgId1 = 3;
     573                 :          0 :             aPos2 = Point( nBRPos, nLinePos ); nImgId2 = 4;
     574                 :          0 :         break;
     575                 :            : 
     576                 :            :         case FRAMEBORDER_TLBR:
     577                 :          0 :             aPos1 = Point( nTLPos, nTLPos ); nImgId1 = 5;
     578                 :          0 :             aPos2 = Point( nBRPos, nBRPos ); nImgId2 = 6;
     579                 :          0 :         break;
     580                 :            :         case FRAMEBORDER_BLTR:
     581                 :          0 :             aPos1 = Point( nTLPos, nBRPos ); nImgId1 = 7;
     582                 :          0 :             aPos2 = Point( nBRPos, nTLPos ); nImgId2 = 8;
     583                 :          0 :         break;
     584                 :            :         default: ; //prevent warning
     585                 :            :     }
     586                 :            : 
     587                 :            :     // Arrow or marker? Do not draw arrows into disabled control.
     588 [ #  # ][ #  # ]:          0 :     sal_uInt16 nSelectAdd = (mrFrameSel.IsEnabled() && rBorder.IsSelected()) ? 0 : 8;
                 [ #  # ]
     589 [ #  # ][ #  # ]:          0 :     maVirDev.DrawImage( aPos1, maILArrows.GetImage( nImgId1 + nSelectAdd ) );
                 [ #  # ]
     590 [ #  # ][ #  # ]:          0 :     maVirDev.DrawImage( aPos2, maILArrows.GetImage( nImgId2 + nSelectAdd ) );
                 [ #  # ]
     591                 :          0 : }
     592                 :            : 
     593                 :          0 : void FrameSelectorImpl::DrawAllArrows()
     594                 :            : {
     595 [ #  # ][ #  # ]:          0 :     for( FrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     596 [ #  # ][ #  # ]:          0 :         DrawArrows( **aIt );
     597                 :          0 : }
     598                 :            : 
     599                 :          0 : Color FrameSelectorImpl::GetDrawLineColor( const Color& rColor ) const
     600                 :            : {
     601         [ #  # ]:          0 :     Color aColor( mbHCMode ? maHCLineCol : rColor );
     602         [ #  # ]:          0 :     if( aColor == maBackCol )
     603                 :          0 :         aColor.Invert();
     604                 :          0 :     return aColor;
     605                 :            : }
     606                 :            : 
     607                 :          0 : void FrameSelectorImpl::DrawAllFrameBorders()
     608                 :            : {
     609                 :            :     // Translate core colors to current UI colors (regards current background and HC mode).
     610 [ #  # ][ #  # ]:          0 :     for( FrameBorderIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     611                 :            :     {
     612 [ #  # ][ #  # ]:          0 :         Color aCoreColorPrim = ((*aIt)->GetState() == FRAMESTATE_DONTCARE) ? maMarkCol : (*aIt)->GetCoreStyle().GetColorOut();
         [ #  # ][ #  # ]
     613 [ #  # ][ #  # ]:          0 :         Color aCoreColorSecn = ((*aIt)->GetState() == FRAMESTATE_DONTCARE) ? maMarkCol : (*aIt)->GetCoreStyle().GetColorIn();
         [ #  # ][ #  # ]
     614 [ #  # ][ #  # ]:          0 :         (*aIt)->SetUIColorPrim( GetDrawLineColor( aCoreColorPrim ) );
     615 [ #  # ][ #  # ]:          0 :         (*aIt)->SetUIColorSecn( GetDrawLineColor( aCoreColorSecn ) );
     616                 :            :     }
     617                 :            : 
     618                 :            :     // Copy all frame border styles to the helper array
     619         [ #  # ]:          0 :     maArray.SetColumnStyleLeft( 0, maLeft.GetUIStyle() );
     620 [ #  # ][ #  # ]:          0 :     if( mbVer ) maArray.SetColumnStyleLeft( 1, maVer.GetUIStyle() );
     621                 :            : 
     622                 :            :     // Invert the style for the right line
     623                 :          0 :     const frame::Style rRightStyle = maRight.GetUIStyle( );
     624                 :          0 :     frame::Style rInvertedRight( rRightStyle.GetColorPrim(),
     625                 :          0 :             rRightStyle.GetColorSecn(), rRightStyle.GetColorGap(),
     626                 :          0 :             rRightStyle.UseGapColor(),
     627                 :            :             rRightStyle.Secn(), rRightStyle.Dist(), rRightStyle.Prim( ),
     628         [ #  # ]:          0 :             rRightStyle.Type( ) );
     629 [ #  # ][ #  # ]:          0 :     maArray.SetColumnStyleRight( mbVer ? 1 : 0, rInvertedRight );
     630                 :            : 
     631         [ #  # ]:          0 :     maArray.SetRowStyleTop( 0, maTop.GetUIStyle() );
     632         [ #  # ]:          0 :     if( mbHor )
     633                 :            :     {
     634                 :            :         // Invert the style for the hor line to match the real borders
     635                 :          0 :         const frame::Style rHorStyle = maHor.GetUIStyle();
     636                 :          0 :         frame::Style rInvertedHor( rHorStyle.GetColorPrim(),
     637                 :          0 :             rHorStyle.GetColorSecn(), rHorStyle.GetColorGap(),
     638                 :          0 :             rHorStyle.UseGapColor(),
     639                 :            :             rHorStyle.Secn(), rHorStyle.Dist(), rHorStyle.Prim( ),
     640         [ #  # ]:          0 :             rHorStyle.Type() );
     641         [ #  # ]:          0 :         maArray.SetRowStyleTop( 1, rInvertedHor );
     642                 :            :     }
     643                 :            : 
     644                 :            :     // Invert the style for the bottom line
     645                 :          0 :     const frame::Style rBottomStyle = maBottom.GetUIStyle( );
     646                 :          0 :     frame::Style rInvertedBottom( rBottomStyle.GetColorPrim(),
     647                 :          0 :             rBottomStyle.GetColorSecn(), rBottomStyle.GetColorGap(),
     648                 :          0 :             rBottomStyle.UseGapColor(),
     649                 :            :             rBottomStyle.Secn(), rBottomStyle.Dist(), rBottomStyle.Prim( ),
     650         [ #  # ]:          0 :             rBottomStyle.Type() );
     651 [ #  # ][ #  # ]:          0 :     maArray.SetRowStyleBottom( mbHor ? 1 : 0, rInvertedBottom );
     652                 :            : 
     653 [ #  # ][ #  # ]:          0 :     for( size_t nCol = 0; nCol < maArray.GetColCount(); ++nCol )
     654 [ #  # ][ #  # ]:          0 :         for( size_t nRow = 0; nRow < maArray.GetRowCount(); ++nRow )
     655         [ #  # ]:          0 :             maArray.SetCellStyleDiag( nCol, nRow, maTLBR.GetUIStyle(), maBLTR.GetUIStyle() );
     656                 :            : 
     657                 :            :     // Let the helper array draw itself
     658         [ #  # ]:          0 :     maArray.DrawArray( maVirDev );
     659                 :          0 : }
     660                 :            : 
     661                 :          0 : void FrameSelectorImpl::DrawVirtualDevice()
     662                 :            : {
     663                 :          0 :     DrawBackground();
     664                 :          0 :     DrawAllArrows();
     665                 :          0 :     DrawAllFrameBorders();
     666                 :          0 :     mbFullRepaint = false;
     667                 :          0 : }
     668                 :            : 
     669                 :          0 : void FrameSelectorImpl::CopyVirDevToControl()
     670                 :            : {
     671         [ #  # ]:          0 :     if( mbFullRepaint )
     672                 :          0 :         DrawVirtualDevice();
     673 [ #  # ][ #  # ]:          0 :     mrFrameSel.DrawBitmap( maVirDevPos, maVirDev.GetBitmap( Point( 0, 0 ), maVirDev.GetOutputSizePixel() ) );
                 [ #  # ]
     674                 :          0 : }
     675                 :            : 
     676                 :          0 : void FrameSelectorImpl::DrawAllTrackingRects()
     677                 :            : {
     678         [ #  # ]:          0 :     PolyPolygon aPPoly;
     679 [ #  # ][ #  # ]:          0 :     if( mrFrameSel.IsAnyBorderSelected() )
     680                 :            :     {
     681 [ #  # ][ #  # ]:          0 :         for( SelFrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     682 [ #  # ][ #  # ]:          0 :             (*aIt)->MergeFocusToPolyPolygon( aPPoly );
     683         [ #  # ]:          0 :         aPPoly.Move( maVirDevPos.X(), maVirDevPos.Y() );
     684                 :            :     }
     685                 :            :     else
     686                 :            :         // no frame border selected -> draw tracking rectangle around entire control
     687 [ #  # ][ #  # ]:          0 :         aPPoly.Insert( Polygon( Rectangle( maVirDevPos, maVirDev.GetOutputSizePixel() ) ) );
         [ #  # ][ #  # ]
     688                 :            : 
     689         [ #  # ]:          0 :     aPPoly.Optimize( POLY_OPTIMIZE_CLOSE );
     690 [ #  # ][ #  # ]:          0 :     for( sal_uInt16 nIdx = 0, nCount = aPPoly.Count(); nIdx < nCount; ++nIdx )
     691 [ #  # ][ #  # ]:          0 :         mrFrameSel.InvertTracking( aPPoly.GetObject( nIdx ), SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
                 [ #  # ]
     692                 :          0 : }
     693                 :            : 
     694                 :          0 : Point FrameSelectorImpl::GetDevPosFromMousePos( const Point& rMousePos ) const
     695                 :            : {
     696                 :          0 :     return rMousePos - maVirDevPos;
     697                 :            : }
     698                 :            : 
     699                 :          0 : void FrameSelectorImpl::DoInvalidate( bool bFullRepaint )
     700                 :            : {
     701                 :          0 :     mbFullRepaint |= bFullRepaint;
     702                 :          0 :     mrFrameSel.Invalidate( INVALIDATE_NOERASE );
     703                 :          0 : }
     704                 :            : 
     705                 :            : // frame border state and style -----------------------------------------------
     706                 :            : 
     707                 :          0 : void FrameSelectorImpl::SetBorderState( FrameBorder& rBorder, FrameBorderState eState )
     708                 :            : {
     709                 :            :     DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::SetBorderState - access to disabled border" );
     710         [ #  # ]:          0 :     if( eState == FRAMESTATE_SHOW )
     711                 :          0 :         SetBorderCoreStyle( rBorder, &maCurrStyle );
     712                 :            :     else
     713                 :          0 :         rBorder.SetState( eState );
     714                 :          0 :     DoInvalidate( true );
     715                 :          0 : }
     716                 :            : 
     717                 :          0 : void FrameSelectorImpl::SetBorderCoreStyle( FrameBorder& rBorder, const SvxBorderLine* pStyle )
     718                 :            : {
     719                 :            :     DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::SetBorderCoreStyle - access to disabled border" );
     720                 :          0 :     rBorder.SetCoreStyle( pStyle );
     721                 :          0 :     DoInvalidate( true );
     722                 :          0 : }
     723                 :            : 
     724                 :          0 : void FrameSelectorImpl::ToggleBorderState( FrameBorder& rBorder )
     725                 :            : {
     726                 :          0 :     bool bDontCare = mrFrameSel.SupportsDontCareState();
     727   [ #  #  #  # ]:          0 :     switch( rBorder.GetState() )
     728                 :            :     {
     729                 :            :         // same order as tristate check box: visible -> don't care -> hidden
     730                 :            :         case FRAMESTATE_SHOW:
     731         [ #  # ]:          0 :             SetBorderState( rBorder, bDontCare ? FRAMESTATE_DONTCARE : FRAMESTATE_HIDE );
     732                 :          0 :         break;
     733                 :            :         case FRAMESTATE_HIDE:
     734                 :          0 :             SetBorderState( rBorder, FRAMESTATE_SHOW );
     735                 :          0 :         break;
     736                 :            :         case FRAMESTATE_DONTCARE:
     737                 :          0 :             SetBorderState( rBorder, FRAMESTATE_HIDE );
     738                 :          0 :         break;
     739                 :            :     }
     740                 :          0 : }
     741                 :            : 
     742                 :            : // frame border selection -----------------------------------------------------
     743                 :            : 
     744                 :          0 : void FrameSelectorImpl::SelectBorder( FrameBorder& rBorder, bool bSelect )
     745                 :            : {
     746                 :            :     DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::SelectBorder - access to disabled border" );
     747                 :          0 :     rBorder.Select( bSelect );
     748                 :          0 :     DrawArrows( rBorder );
     749                 :          0 :     DoInvalidate( false );
     750                 :          0 : }
     751                 :            : 
     752                 :          0 : void FrameSelectorImpl::SilentGrabFocus()
     753                 :            : {
     754                 :          0 :     bool bOldAuto = mbAutoSelect;
     755                 :          0 :     mbAutoSelect = false;
     756                 :          0 :     mrFrameSel.GrabFocus();
     757                 :          0 :     mbAutoSelect = bOldAuto;
     758                 :          0 : }
     759                 :            : 
     760                 :          0 : bool FrameSelectorImpl::SelectedBordersEqual() const
     761                 :            : {
     762                 :          0 :     bool bEqual = true;
     763         [ #  # ]:          0 :     SelFrameBorderCIter aIt( maEnabBorders );
     764 [ #  # ][ #  # ]:          0 :     if( aIt.Is() )
     765                 :            :     {
     766         [ #  # ]:          0 :         const SvxBorderLine& rFirstStyle = (*aIt)->GetCoreStyle();
     767 [ #  # ][ #  # ]:          0 :         for( ++aIt; bEqual && aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     768 [ #  # ][ #  # ]:          0 :             bEqual = ((*aIt)->GetCoreStyle() == rFirstStyle);
     769                 :            :     }
     770                 :          0 :     return bEqual;
     771                 :            : }
     772                 :            : 
     773                 :            : // ============================================================================
     774                 :            : // FrameSelector
     775                 :            : // ============================================================================
     776                 :            : 
     777                 :          0 : FrameSelector::FrameSelector( Window* pParent, const ResId& rResId ) :
     778                 :          0 :     Control( pParent, rResId )
     779                 :            : {
     780                 :            :     // not in c'tor init list (avoid warning about usage of *this)
     781 [ #  # ][ #  # ]:          0 :     mxImpl.reset( new FrameSelectorImpl( *this ) );
     782         [ #  # ]:          0 :     EnableRTL( false ); // #107808# don't mirror the mouse handling
     783                 :          0 : }
     784                 :            : 
     785         [ #  # ]:          0 : FrameSelector::~FrameSelector()
     786                 :            : {
     787         [ #  # ]:          0 : }
     788                 :            : 
     789                 :          0 : void FrameSelector::Initialize( FrameSelFlags nFlags )
     790                 :            : {
     791                 :          0 :     mxImpl->Initialize( nFlags );
     792                 :          0 :     Show();
     793                 :          0 : }
     794                 :            : 
     795                 :            : // enabled frame borders ------------------------------------------------------
     796                 :            : 
     797                 :          0 : bool FrameSelector::IsBorderEnabled( FrameBorderType eBorder ) const
     798                 :            : {
     799                 :          0 :     return mxImpl->GetBorder( eBorder ).IsEnabled();
     800                 :            : }
     801                 :            : 
     802                 :          0 : sal_Int32 FrameSelector::GetEnabledBorderCount() const
     803                 :            : {
     804                 :          0 :     return static_cast< sal_Int32 >( mxImpl->maEnabBorders.size() );
     805                 :            : }
     806                 :            : 
     807                 :          0 : FrameBorderType FrameSelector::GetEnabledBorderType( sal_Int32 nIndex ) const
     808                 :            : {
     809                 :          0 :     FrameBorderType eBorder = FRAMEBORDER_NONE;
     810         [ #  # ]:          0 :     if( nIndex >= 0 )
     811                 :            :     {
     812                 :          0 :         size_t nVecIdx = static_cast< size_t >( nIndex );
     813         [ #  # ]:          0 :         if( nVecIdx < mxImpl->maEnabBorders.size() )
     814                 :          0 :             eBorder = mxImpl->maEnabBorders[ nVecIdx ]->GetType();
     815                 :            :     }
     816                 :          0 :     return eBorder;
     817                 :            : }
     818                 :            : 
     819                 :          0 : sal_Int32 FrameSelector::GetEnabledBorderIndex( FrameBorderType eBorder ) const
     820                 :            : {
     821                 :          0 :     sal_Int32 nIndex = 0;
     822 [ #  # ][ #  # ]:          0 :     for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt, ++nIndex )
         [ #  # ][ #  # ]
     823 [ #  # ][ #  # ]:          0 :         if( (*aIt)->GetType() == eBorder )
     824                 :          0 :             return nIndex;
     825                 :          0 :     return -1;
     826                 :            : }
     827                 :            : 
     828                 :            : // frame border state and style -----------------------------------------------
     829                 :            : 
     830                 :          0 : bool FrameSelector::SupportsDontCareState() const
     831                 :            : {
     832                 :          0 :     return (mxImpl->mnFlags & FRAMESEL_DONTCARE) != 0;
     833                 :            : }
     834                 :            : 
     835                 :          0 : FrameBorderState FrameSelector::GetFrameBorderState( FrameBorderType eBorder ) const
     836                 :            : {
     837                 :          0 :     return mxImpl->GetBorder( eBorder ).GetState();
     838                 :            : }
     839                 :            : 
     840                 :          0 : const SvxBorderLine* FrameSelector::GetFrameBorderStyle( FrameBorderType eBorder ) const
     841                 :            : {
     842                 :          0 :     const SvxBorderLine& rStyle = mxImpl->GetBorder( eBorder ).GetCoreStyle();
     843                 :            :     // rest of the world uses null pointer for invisible frame border
     844         [ #  # ]:          0 :     return rStyle.GetOutWidth() ? &rStyle : 0;
     845                 :            : }
     846                 :            : 
     847                 :          0 : void FrameSelector::ShowBorder( FrameBorderType eBorder, const SvxBorderLine* pStyle )
     848                 :            : {
     849                 :          0 :     mxImpl->SetBorderCoreStyle( mxImpl->GetBorderAccess( eBorder ), pStyle );
     850                 :          0 : }
     851                 :            : 
     852                 :          0 : void FrameSelector::SetBorderDontCare( FrameBorderType eBorder )
     853                 :            : {
     854                 :          0 :     mxImpl->SetBorderState( mxImpl->GetBorderAccess( eBorder ), FRAMESTATE_DONTCARE );
     855                 :          0 : }
     856                 :            : 
     857                 :          0 : bool FrameSelector::IsAnyBorderVisible() const
     858                 :            : {
     859                 :          0 :     bool bIsSet = false;
     860 [ #  # ][ #  # ]:          0 :     for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); !bIsSet && aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     861         [ #  # ]:          0 :         bIsSet = ((*aIt)->GetState() == FRAMESTATE_SHOW);
     862                 :          0 :     return bIsSet;
     863                 :            : }
     864                 :            : 
     865                 :          0 : void FrameSelector::HideAllBorders()
     866                 :            : {
     867 [ #  # ][ #  # ]:          0 :     for( FrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     868 [ #  # ][ #  # ]:          0 :         mxImpl->SetBorderState( **aIt, FRAMESTATE_HIDE );
     869                 :          0 : }
     870                 :            : 
     871                 :          0 : bool FrameSelector::GetVisibleWidth( long& rnWidth, SvxBorderStyle& rnStyle ) const
     872                 :            : {
     873         [ #  # ]:          0 :     VisFrameBorderCIter aIt( mxImpl->maEnabBorders );
     874 [ #  # ][ #  # ]:          0 :     if( !aIt.Is() )
     875                 :          0 :         return false;
     876                 :            : 
     877         [ #  # ]:          0 :     const SvxBorderLine& rStyle = (*aIt)->GetCoreStyle();
     878                 :          0 :     bool bFound = true;
     879 [ #  # ][ #  # ]:          0 :     for( ++aIt; bFound && aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     880                 :            :     {
     881                 :            :         bFound =
     882         [ #  # ]:          0 :             (rStyle.GetWidth() == (*aIt)->GetCoreStyle().GetWidth()) &&
     883                 :          0 :             (rStyle.GetBorderLineStyle() ==
     884         [ #  # ]:          0 :                 (*aIt)->GetCoreStyle().GetBorderLineStyle());
           [ #  #  #  # ]
     885                 :            :     }
     886                 :            : 
     887         [ #  # ]:          0 :     if( bFound )
     888                 :            :     {
     889                 :          0 :         rnWidth = rStyle.GetWidth();
     890                 :          0 :         rnStyle = rStyle.GetBorderLineStyle();
     891                 :            :     }
     892                 :          0 :     return bFound;
     893                 :            : }
     894                 :            : 
     895                 :          0 : bool FrameSelector::GetVisibleColor( Color& rColor ) const
     896                 :            : {
     897         [ #  # ]:          0 :     VisFrameBorderCIter aIt( mxImpl->maEnabBorders );
     898 [ #  # ][ #  # ]:          0 :     if( !aIt.Is() )
     899                 :          0 :         return false;
     900                 :            : 
     901         [ #  # ]:          0 :     const SvxBorderLine& rStyle = (*aIt)->GetCoreStyle();
     902                 :          0 :     bool bFound = true;
     903 [ #  # ][ #  # ]:          0 :     for( ++aIt; bFound && aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     904         [ #  # ]:          0 :         bFound = (rStyle.GetColor() == (*aIt)->GetCoreStyle().GetColor());
     905                 :            : 
     906         [ #  # ]:          0 :     if( bFound )
     907                 :          0 :         rColor = rStyle.GetColor();
     908                 :          0 :     return bFound;
     909                 :            : }
     910                 :            : 
     911                 :            : // frame border selection -----------------------------------------------------
     912                 :            : 
     913                 :          0 : const Link& FrameSelector::GetSelectHdl() const
     914                 :            : {
     915                 :          0 :     return mxImpl->maSelectHdl;
     916                 :            : }
     917                 :            : 
     918                 :          0 : void FrameSelector::SetSelectHdl( const Link& rHdl )
     919                 :            : {
     920                 :          0 :     mxImpl->maSelectHdl = rHdl;
     921                 :          0 : }
     922                 :            : 
     923                 :          0 : bool FrameSelector::IsBorderSelected( FrameBorderType eBorder ) const
     924                 :            : {
     925                 :          0 :     return mxImpl->GetBorder( eBorder ).IsSelected();
     926                 :            : }
     927                 :            : 
     928                 :          0 : void FrameSelector::SelectBorder( FrameBorderType eBorder, bool bSelect )
     929                 :            : {
     930                 :          0 :     mxImpl->SelectBorder( mxImpl->GetBorderAccess( eBorder ), bSelect );
     931                 :          0 : }
     932                 :            : 
     933                 :          0 : bool FrameSelector::IsAnyBorderSelected() const
     934                 :            : {
     935                 :            :     // Construct an iterator for selected borders. If it is valid, there is a selected border.
     936         [ #  # ]:          0 :     return SelFrameBorderCIter( mxImpl->maEnabBorders ).Is();
     937                 :            : }
     938                 :            : 
     939                 :          0 : void FrameSelector::SelectAllBorders( bool bSelect )
     940                 :            : {
     941 [ #  # ][ #  # ]:          0 :     for( FrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     942 [ #  # ][ #  # ]:          0 :         mxImpl->SelectBorder( **aIt, bSelect );
     943                 :          0 : }
     944                 :            : 
     945                 :          0 : void FrameSelector::SelectAllVisibleBorders( bool bSelect )
     946                 :            : {
     947 [ #  # ][ #  # ]:          0 :     for( VisFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     948 [ #  # ][ #  # ]:          0 :         mxImpl->SelectBorder( **aIt, bSelect );
     949                 :          0 : }
     950                 :            : 
     951                 :          0 : void FrameSelector::SetStyleToSelection( long nWidth, SvxBorderStyle nStyle )
     952                 :            : {
     953                 :          0 :     mxImpl->maCurrStyle.SetBorderLineStyle( nStyle );
     954                 :          0 :     mxImpl->maCurrStyle.SetWidth( nWidth );
     955 [ #  # ][ #  # ]:          0 :     for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     956 [ #  # ][ #  # ]:          0 :         mxImpl->SetBorderState( **aIt, FRAMESTATE_SHOW );
     957                 :          0 : }
     958                 :            : 
     959                 :          0 : void FrameSelector::SetColorToSelection( const Color& rColor )
     960                 :            : {
     961                 :          0 :     mxImpl->maCurrStyle.SetColor( rColor );
     962 [ #  # ][ #  # ]:          0 :     for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
     963 [ #  # ][ #  # ]:          0 :         mxImpl->SetBorderState( **aIt, FRAMESTATE_SHOW );
     964                 :          0 : }
     965                 :            : 
     966                 :            : // accessibility --------------------------------------------------------------
     967                 :            : 
     968                 :          0 : Reference< XAccessible > FrameSelector::CreateAccessible()
     969                 :            : {
     970         [ #  # ]:          0 :     if( !mxImpl->mxAccess.is() )
     971                 :          0 :         mxImpl->mxAccess = mxImpl->mpAccess =
     972   [ #  #  #  # ]:          0 :             new a11y::AccFrameSelector( *this, FRAMEBORDER_NONE );
     973                 :          0 :     return mxImpl->mxAccess;
     974                 :            : }
     975                 :            : 
     976                 :          0 : Reference< XAccessible > FrameSelector::GetChildAccessible( FrameBorderType eBorder )
     977                 :            : {
     978                 :          0 :     Reference< XAccessible > xRet;
     979                 :          0 :     size_t nVecIdx = static_cast< size_t >( eBorder );
     980 [ #  # ][ #  # ]:          0 :     if( IsBorderEnabled( eBorder ) && (1 <= nVecIdx) && (nVecIdx <= mxImpl->maChildVec.size()) )
         [ #  # ][ #  # ]
                 [ #  # ]
     981                 :            :     {
     982                 :          0 :         --nVecIdx;
     983         [ #  # ]:          0 :         if( !mxImpl->maChildVec[ nVecIdx ] )
     984                 :          0 :             mxImpl->mxChildVec[ nVecIdx ] = mxImpl->maChildVec[ nVecIdx ] =
     985   [ #  #  #  # ]:          0 :                 new a11y::AccFrameSelector( *this, eBorder );
                 [ #  # ]
     986         [ #  # ]:          0 :         xRet = mxImpl->mxChildVec[ nVecIdx ];
     987                 :            :     }
     988                 :          0 :     return xRet;
     989                 :            : }
     990                 :            : 
     991                 :          0 : Reference< XAccessible > FrameSelector::GetChildAccessible( sal_Int32 nIndex )
     992                 :            : {
     993                 :          0 :     return GetChildAccessible( GetEnabledBorderType( nIndex ) );
     994                 :            : }
     995                 :            : 
     996                 :          0 : Reference< XAccessible > FrameSelector::GetChildAccessible( const Point& rPos )
     997                 :            : {
     998                 :          0 :     Reference< XAccessible > xRet;
     999 [ #  # ][ #  # ]:          0 :     for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); !xRet.is() && aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1000 [ #  # ][ #  # ]:          0 :         if( (*aIt)->ContainsClickPoint( rPos ) )
                 [ #  # ]
    1001 [ #  # ][ #  # ]:          0 :             xRet = GetChildAccessible( (*aIt)->GetType() );
                 [ #  # ]
    1002                 :          0 :     return xRet;
    1003                 :            : }
    1004                 :            : 
    1005                 :          0 : bool FrameSelector::ContainsClickPoint( const Point& rPos ) const
    1006                 :            : {
    1007                 :          0 :     bool bContains = false;
    1008 [ #  # ][ #  # ]:          0 :     for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); !bContains && aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1009 [ #  # ][ #  # ]:          0 :         bContains = (*aIt)->ContainsClickPoint( rPos );
    1010                 :          0 :     return bContains;
    1011                 :            : }
    1012                 :            : 
    1013                 :          0 : Rectangle FrameSelector::GetClickBoundRect( FrameBorderType eBorder ) const
    1014                 :            : {
    1015                 :          0 :     Rectangle aRect;
    1016                 :          0 :     const FrameBorder& rBorder = mxImpl->GetBorder( eBorder );
    1017         [ #  # ]:          0 :     if( rBorder.IsEnabled() )
    1018                 :          0 :         aRect = rBorder.GetClickBoundRect();
    1019                 :          0 :     return aRect;
    1020                 :            : }
    1021                 :            : 
    1022                 :            : // virtual functions from base class ------------------------------------------
    1023                 :            : 
    1024                 :          0 : void FrameSelector::Paint( const Rectangle& )
    1025                 :            : {
    1026                 :          0 :     mxImpl->CopyVirDevToControl();
    1027         [ #  # ]:          0 :     if( HasFocus() )
    1028                 :          0 :         mxImpl->DrawAllTrackingRects();
    1029                 :          0 : }
    1030                 :            : 
    1031                 :          0 : void FrameSelector::MouseButtonDown( const MouseEvent& rMEvt )
    1032                 :            : {
    1033                 :            :     /*  Mouse handling:
    1034                 :            :         * Click on an unselected frame border:
    1035                 :            :             Set current style/color, make frame border visible, deselect all
    1036                 :            :             other frame borders.
    1037                 :            :         * Click on a selected frame border:
    1038                 :            :             Toggle state of the frame border (visible -> don't care -> hidden),
    1039                 :            :             deselect all other frame borders.
    1040                 :            :         * SHIFT+Click or CTRL+Click on an unselected frame border:
    1041                 :            :             Extend selection, set current style/color to all selected frame
    1042                 :            :             borders independent of the state/style/color of the borders.
    1043                 :            :         * SHIFT+Click or CTRL+Click on a selected frame border:
    1044                 :            :             If all frame borders have same style/color, toggle state of all
    1045                 :            :             borders (see above), otherwise set current style/color to all
    1046                 :            :             borders.
    1047                 :            :         * Click on unused area: Do not modify selection and selected frame
    1048                 :            :             borders.
    1049                 :            :      */
    1050                 :            : 
    1051                 :            :     // #107394# do not auto-select a frame border
    1052                 :          0 :     mxImpl->SilentGrabFocus();
    1053                 :            : 
    1054         [ #  # ]:          0 :     if( rMEvt.IsLeft() )
    1055                 :            :     {
    1056                 :          0 :         Point aPos( mxImpl->GetDevPosFromMousePos( rMEvt.GetPosPixel() ) );
    1057         [ #  # ]:          0 :         FrameBorderPtrVec aDeselectBorders;
    1058                 :            : 
    1059                 :          0 :         bool bAnyClicked = false;   // Any frame border clicked?
    1060                 :          0 :         bool bNewSelected = false;  // Any unselected frame border selected?
    1061                 :            : 
    1062                 :            :         /*  If frame borders are set to "don't care" and the control does not
    1063                 :            :             support this state, hide them on first mouse click.
    1064                 :            :             DR 2004-01-30: Why are the borders set to "don't care" then?!? */
    1065 [ #  # ][ #  # ]:          0 :         bool bHideDontCare = !mxImpl->mbClicked && !SupportsDontCareState();
                 [ #  # ]
    1066                 :            : 
    1067 [ #  # ][ #  # ]:          0 :         for( FrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
    1068                 :            :         {
    1069 [ #  # ][ #  # ]:          0 :             if( (*aIt)->ContainsClickPoint( aPos ) )
                 [ #  # ]
    1070                 :            :             {
    1071                 :            :                 // frame border is clicked
    1072                 :          0 :                 bAnyClicked = true;
    1073 [ #  # ][ #  # ]:          0 :                 if( !(*aIt)->IsSelected() )
    1074                 :            :                 {
    1075                 :          0 :                     bNewSelected = true;
    1076 [ #  # ][ #  # ]:          0 :                     mxImpl->SelectBorder( **aIt, true );
    1077                 :            :                 }
    1078                 :            :             }
    1079                 :            :             else
    1080                 :            :             {
    1081                 :            :                 // hide a "don't care" frame border only if it is not clicked
    1082 [ #  # ][ #  # ]:          0 :                 if( bHideDontCare && ((*aIt)->GetState() == FRAMESTATE_DONTCARE) )
         [ #  # ][ #  # ]
    1083 [ #  # ][ #  # ]:          0 :                     mxImpl->SetBorderState( **aIt, FRAMESTATE_HIDE );
    1084                 :            : 
    1085                 :            :                 // deselect frame borders not clicked (if SHIFT or CTRL are not pressed)
    1086 [ #  # ][ #  # ]:          0 :                 if( !rMEvt.IsShift() && !rMEvt.IsMod1() )
                 [ #  # ]
    1087 [ #  # ][ #  # ]:          0 :                     aDeselectBorders.push_back( *aIt );
    1088                 :            :             }
    1089                 :            :         }
    1090                 :            : 
    1091         [ #  # ]:          0 :         if( bAnyClicked )
    1092                 :            :         {
    1093                 :            :             // any valid frame border clicked? -> deselect other frame borders
    1094 [ #  # ][ #  # ]:          0 :             for( FrameBorderIter aIt( aDeselectBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
    1095 [ #  # ][ #  # ]:          0 :                 mxImpl->SelectBorder( **aIt, false );
    1096                 :            : 
    1097 [ #  # ][ #  # ]:          0 :             if( bNewSelected || !mxImpl->SelectedBordersEqual() )
         [ #  # ][ #  # ]
    1098                 :            :             {
    1099                 :            :                 // new frame border selected, selection extended, or selected borders different? -> show
    1100 [ #  # ][ #  # ]:          0 :                 for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
    1101                 :            :                     // SetBorderState() sets current style and color to the frame border
    1102 [ #  # ][ #  # ]:          0 :                     mxImpl->SetBorderState( **aIt, FRAMESTATE_SHOW );
    1103                 :            :             }
    1104                 :            :             else
    1105                 :            :             {
    1106                 :            :                 // all selected frame borders are equal -> toggle state
    1107 [ #  # ][ #  # ]:          0 :                 for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
    1108 [ #  # ][ #  # ]:          0 :                     mxImpl->ToggleBorderState( **aIt );
    1109                 :            :             }
    1110                 :            : 
    1111 [ #  # ][ #  # ]:          0 :             GetSelectHdl().Call( this );
    1112                 :          0 :         }
    1113                 :            :     }
    1114                 :          0 : }
    1115                 :            : 
    1116                 :          0 : void FrameSelector::KeyInput( const KeyEvent& rKEvt )
    1117                 :            : {
    1118                 :          0 :     bool bHandled = false;
    1119                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    1120         [ #  # ]:          0 :     if( !aKeyCode.GetModifier() )
    1121                 :            :     {
    1122                 :          0 :         sal_uInt16 nCode = aKeyCode.GetCode();
    1123      [ #  #  # ]:          0 :         switch( nCode )
    1124                 :            :         {
    1125                 :            :             case KEY_SPACE:
    1126                 :            :             {
    1127 [ #  # ][ #  # ]:          0 :                 for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
         [ #  # ][ #  # ]
    1128 [ #  # ][ #  # ]:          0 :                     mxImpl->ToggleBorderState( **aIt );
    1129                 :          0 :                 bHandled = true;
    1130                 :            :             }
    1131                 :          0 :             break;
    1132                 :            : 
    1133                 :            :             case KEY_UP:
    1134                 :            :             case KEY_DOWN:
    1135                 :            :             case KEY_LEFT:
    1136                 :            :             case KEY_RIGHT:
    1137                 :            :             {
    1138         [ #  # ]:          0 :                 if( !mxImpl->maEnabBorders.empty() )
    1139                 :            :                 {
    1140                 :            :                     // start from first selected frame border
    1141         [ #  # ]:          0 :                     SelFrameBorderCIter aIt( mxImpl->maEnabBorders );
    1142 [ #  # ][ #  # ]:          0 :                     FrameBorderType eBorder = aIt.Is() ? (*aIt)->GetType() : mxImpl->maEnabBorders.front()->GetType();
         [ #  # ][ #  # ]
    1143                 :            : 
    1144                 :            :                     // search for next enabled frame border
    1145 [ #  # ][ #  # ]:          0 :                     do
                 [ #  # ]
    1146                 :            :                     {
    1147 [ #  # ][ #  # ]:          0 :                         eBorder = mxImpl->GetBorder( eBorder ).GetKeyboardNeighbor( nCode );
    1148                 :            :                     }
    1149         [ #  # ]:          0 :                     while( (eBorder != FRAMEBORDER_NONE) && !IsBorderEnabled( eBorder ) );
    1150                 :            : 
    1151                 :            :                     // select the frame border
    1152         [ #  # ]:          0 :                     if( eBorder != FRAMEBORDER_NONE )
    1153                 :            :                     {
    1154         [ #  # ]:          0 :                         DeselectAllBorders();
    1155         [ #  # ]:          0 :                         SelectBorder( eBorder );
    1156                 :            :                     }
    1157                 :            :                 }
    1158                 :            :             }
    1159                 :          0 :             break;
    1160                 :            :         }
    1161                 :            :     }
    1162         [ #  # ]:          0 :     if( !bHandled )
    1163         [ #  # ]:          0 :         Window::KeyInput(rKEvt);
    1164                 :          0 : }
    1165                 :            : 
    1166                 :          0 : void FrameSelector::GetFocus()
    1167                 :            : {
    1168                 :            :     // auto-selection of a frame border, if focus reaches control, and nothing is selected
    1169 [ #  # ][ #  # ]:          0 :     if( mxImpl->mbAutoSelect && !IsAnyBorderSelected() && !mxImpl->maEnabBorders.empty() )
         [ #  # ][ #  # ]
    1170                 :          0 :         mxImpl->SelectBorder( *mxImpl->maEnabBorders.front(), true );
    1171                 :            : 
    1172                 :          0 :     mxImpl->DoInvalidate( false );
    1173         [ #  # ]:          0 :     if( mxImpl->mxAccess.is() )
    1174                 :          0 :         mxImpl->mpAccess->NotifyFocusListeners( sal_True );
    1175                 :          0 :     Control::GetFocus();
    1176                 :          0 : }
    1177                 :            : 
    1178                 :          0 : void FrameSelector::LoseFocus()
    1179                 :            : {
    1180                 :          0 :     mxImpl->DoInvalidate( false );
    1181         [ #  # ]:          0 :     if( mxImpl->mxAccess.is() )
    1182                 :          0 :         mxImpl->mpAccess->NotifyFocusListeners( sal_False );
    1183                 :          0 :     Control::LoseFocus();
    1184                 :          0 : }
    1185                 :            : 
    1186                 :          0 : void FrameSelector::DataChanged( const DataChangedEvent& rDCEvt )
    1187                 :            : {
    1188                 :          0 :     Control::DataChanged( rDCEvt );
    1189 [ #  # ][ #  # ]:          0 :     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
                 [ #  # ]
    1190                 :          0 :         mxImpl->InitVirtualDevice();
    1191                 :          0 : }
    1192                 :            : 
    1193                 :            : // ============================================================================
    1194                 :            : 
    1195                 :            : template< typename Cont, typename Iter, typename Pred >
    1196                 :          0 : FrameBorderIterBase< Cont, Iter, Pred >::FrameBorderIterBase( container_type& rCont ) :
    1197                 :            :     maIt( rCont.begin() ),
    1198                 :          0 :     maEnd( rCont.end() )
    1199                 :            : {
    1200 [ #  # ][ #  # ]:          0 :     while( Is() && !maPred( *maIt ) ) ++maIt;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1201                 :          0 : }
    1202                 :            : 
    1203                 :            : template< typename Cont, typename Iter, typename Pred >
    1204                 :          0 : FrameBorderIterBase< Cont, Iter, Pred >& FrameBorderIterBase< Cont, Iter, Pred >::operator++()
    1205                 :            : {
    1206 [ #  # ][ #  # ]:          0 :     do { ++maIt; } while( Is() && !maPred( *maIt ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1207                 :          0 :     return *this;
    1208                 :            : }
    1209                 :            : 
    1210                 :            : // ============================================================================
    1211                 :            : 
    1212                 :            : } // namespace svx
    1213                 :            : 
    1214                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10