LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/dialog - dlgctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 55 1022 5.4 %
Date: 2013-07-09 Functions: 9 120 7.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/shl.hxx>
      21             : #include <vcl/builder.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : 
      24             : #include <svx/xtable.hxx>
      25             : #include <svx/xpool.hxx>
      26             : #include <svx/dialogs.hrc>
      27             : #include <accessibility.hrc>
      28             : #include <svx/dlgctrl.hxx>
      29             : #include <svx/dialmgr.hxx>
      30             : #include <tools/poly.hxx>
      31             : #include <vcl/region.hxx>
      32             : #include <vcl/gradient.hxx>
      33             : #include <vcl/hatch.hxx>
      34             : #include <svtools/colorcfg.hxx>
      35             : #include <svxrectctaccessiblecontext.hxx>
      36             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      37             : #include <basegfx/point/b2dpoint.hxx>
      38             : #include <basegfx/polygon/b2dpolygon.hxx>
      39             : #include <svx/svdorect.hxx>
      40             : #include <svx/svdmodel.hxx>
      41             : #include <svx/svdopath.hxx>
      42             : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      43             : #include <svx/sdr/contact/displayinfo.hxx>
      44             : #include <vcl/bmpacc.hxx>
      45             : #include <svx/xbtmpit.hxx>
      46             : 
      47             : #define OUTPUT_DRAWMODE_COLOR       (DRAWMODE_DEFAULT)
      48             : #define OUTPUT_DRAWMODE_CONTRAST    (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
      49             : 
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::lang;
      52             : using namespace ::com::sun::star::accessibility;
      53             : 
      54             : // Control for display and selection of the corner points and
      55             : // mid point of an object
      56             : 
      57           0 : Bitmap& SvxRectCtl::GetRectBitmap( void )
      58             : {
      59           0 :     if( !pBitmap )
      60           0 :         InitRectBitmap();
      61             : 
      62           0 :     return *pBitmap;
      63             : }
      64             : 
      65           0 : SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
      66             :                         sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) :
      67             : 
      68             :     Control( pParent, rResId ),
      69             : 
      70             :     pAccContext ( NULL ),
      71             :     nBorderWidth( nBorder ),
      72             :     nRadius     ( nCircle),
      73             :     eDefRP      ( eRpt ),
      74             :     eCS         ( eStyle ),
      75             :     pBitmap     ( NULL ),
      76             :     m_nState    ( 0 ),
      77           0 :     mbCompleteDisable(sal_False)
      78             : {
      79           0 :     SetMapMode( MAP_100TH_MM );
      80           0 :     Resize_Impl();
      81           0 : }
      82             : 
      83           0 : SvxRectCtl::SvxRectCtl(Window* pParent, RECT_POINT eRpt,
      84             :     sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle)
      85             :     : Control(pParent, WB_BORDER | WB_TABSTOP)
      86             :     , pAccContext(NULL)
      87             :     , nBorderWidth(nBorder)
      88             :     , nRadius(nCircle)
      89             :     , eDefRP(eRpt)
      90             :     , eCS(eStyle)
      91             :     , pBitmap(NULL)
      92             :     , m_nState(0)
      93           0 :     , mbCompleteDisable(false)
      94             : {
      95           0 :     SetMapMode(MAP_100TH_MM);
      96           0 :     Resize_Impl();
      97           0 : }
      98             : 
      99             : 
     100           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxRectCtl(Window *pParent, VclBuilder::stringmap &)
     101             : {
     102           0 :     return new SvxRectCtl(pParent);
     103             : }
     104             : 
     105             : // -----------------------------------------------------------------------
     106             : 
     107           0 : SvxRectCtl::~SvxRectCtl()
     108             : {
     109           0 :     delete pBitmap;
     110             : 
     111           0 :     if( pAccContext )
     112           0 :         pAccContext->release();
     113           0 : }
     114             : 
     115             : // -----------------------------------------------------------------------
     116           0 : void SvxRectCtl::Resize()
     117             : {
     118           0 :     Resize_Impl();
     119           0 :     Control::Resize();
     120           0 : }
     121             : 
     122             : // -----------------------------------------------------------------------
     123             : 
     124           0 : void SvxRectCtl::Resize_Impl()
     125             : {
     126           0 :     aSize = GetOutputSize();
     127             : 
     128           0 :     switch( eCS )
     129             :     {
     130             :         case CS_RECT:
     131             :         case CS_ANGLE:
     132             :         case CS_SHADOW:
     133           0 :             aPtLT = Point( 0 + nBorderWidth,  0 + nBorderWidth );
     134           0 :             aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
     135           0 :             aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
     136             : 
     137           0 :             aPtLM = Point( 0 + nBorderWidth,  aSize.Height() / 2 );
     138           0 :             aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
     139           0 :             aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
     140             : 
     141           0 :             aPtLB = Point( 0 + nBorderWidth,    aSize.Height() - nBorderWidth );
     142           0 :             aPtMB = Point( aSize.Width() / 2,   aSize.Height() - nBorderWidth );
     143           0 :             aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
     144           0 :         break;
     145             : 
     146             :         case CS_LINE:
     147           0 :             aPtLT = Point( 0 + 3 * nBorderWidth,  0 + nBorderWidth );
     148           0 :             aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
     149           0 :             aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
     150             : 
     151           0 :             aPtLM = Point( 0 + 3 * nBorderWidth,  aSize.Height() / 2 );
     152           0 :             aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
     153           0 :             aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
     154             : 
     155           0 :             aPtLB = Point( 0 + 3 * nBorderWidth,    aSize.Height() - nBorderWidth );
     156           0 :             aPtMB = Point( aSize.Width() / 2,   aSize.Height() - nBorderWidth );
     157           0 :             aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
     158           0 :         break;
     159             :     }
     160           0 :     Reset();
     161           0 :     InitSettings( sal_True, sal_True );
     162           0 : }
     163             : // -----------------------------------------------------------------------
     164             : 
     165           0 : void SvxRectCtl::InitRectBitmap( void )
     166             : {
     167           0 :     delete pBitmap;
     168             : 
     169           0 :     const StyleSettings&    rStyles = Application::GetSettings().GetStyleSettings();
     170           0 :     svtools::ColorConfig aColorConfig;
     171             : 
     172           0 :     pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
     173             : 
     174             :     // set bitmap-colors
     175           0 :     Color   aColorAry1[7];
     176           0 :     Color   aColorAry2[7];
     177           0 :     aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );  // light-gray
     178           0 :     aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );  // yellow
     179           0 :     aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );  // white
     180           0 :     aColorAry1[3] = Color( 0x80, 0x80, 0x80 );  // dark-gray
     181           0 :     aColorAry1[4] = Color( 0x00, 0x00, 0x00 );  // black
     182           0 :     aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );  // green
     183           0 :     aColorAry1[6] = Color( 0x00, 0x00, 0xFF );  // blue
     184           0 :     aColorAry2[0] = rStyles.GetDialogColor();       // background
     185           0 :     aColorAry2[1] = rStyles.GetWindowColor();
     186           0 :     aColorAry2[2] = rStyles.GetLightColor();
     187           0 :     aColorAry2[3] = rStyles.GetShadowColor();
     188           0 :     aColorAry2[4] = rStyles.GetDarkShadowColor();
     189           0 :     aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
     190           0 :     aColorAry2[6] = rStyles.GetDialogColor();
     191             : 
     192             : #ifdef DBG_UTIL
     193             :     static sal_Bool     bModify = sal_False;
     194             :     sal_Bool&           rModify = bModify;
     195             :     if( rModify )
     196             :     {
     197             :         static int      n = 0;
     198             :         static sal_uInt8    r = 0xFF;
     199             :         static sal_uInt8    g = 0x00;
     200             :         static sal_uInt8    b = 0xFF;
     201             :         int&            rn = n;
     202             :         sal_uInt8&          rr = r;
     203             :         sal_uInt8&          rg = g;
     204             :         sal_uInt8&          rb = b;
     205             :         aColorAry2[ rn ] = Color( rr, rg, rb );
     206             :     }
     207             : #endif
     208             : 
     209           0 :     pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
     210           0 : }
     211             : 
     212             : // -----------------------------------------------------------------------
     213             : 
     214           0 : void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
     215             : {
     216           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     217             : 
     218           0 :     if( bForeground )
     219             :     {
     220           0 :         svtools::ColorConfig aColorConfig;
     221           0 :         Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
     222             : 
     223           0 :         if ( IsControlForeground() )
     224           0 :             aTextColor = GetControlForeground();
     225           0 :         SetTextColor( aTextColor );
     226             :     }
     227             : 
     228           0 :     if( bBackground )
     229             :     {
     230           0 :         if ( IsControlBackground() )
     231           0 :             SetBackground( GetControlBackground() );
     232             :         else
     233           0 :             SetBackground( rStyleSettings.GetWindowColor() );
     234             :     }
     235             : 
     236           0 :     delete pBitmap;
     237           0 :     pBitmap = NULL;     // forces new creating of bitmap
     238             : 
     239           0 :     Invalidate();
     240           0 : }
     241             : 
     242             : // The clicked rectangle (3 x 3) is determined and the parent (dialog)
     243             : // is notified that the item was changed
     244           0 : void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
     245             : {
     246             :     // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     247           0 :     if(!IsCompletelyDisabled())
     248             :     {
     249           0 :         Point aPtLast = aPtNew;
     250             : 
     251           0 :         aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
     252             : 
     253           0 :         if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
     254             :         {
     255           0 :             aPtNew = aPtLast;
     256             :         }
     257             :         else
     258             :         {
     259           0 :             Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
     260           0 :                                    aPtLast + Point( nRadius, nRadius ) ) );
     261           0 :             Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
     262           0 :                                    aPtNew + Point( nRadius, nRadius ) ) );
     263           0 :             eRP = GetRPFromPoint( aPtNew );
     264             : 
     265           0 :             SetActualRP( eRP );
     266             : 
     267           0 :             Window* pParent = GetParent();
     268           0 :             while (pParent)
     269             :             {
     270           0 :                 if( WINDOW_TABPAGE == pParent->GetType() )
     271             :                 {
     272           0 :                     ( (SvxTabPage*) pParent )->PointChanged( this, eRP );
     273           0 :                     break;
     274             :                 }
     275           0 :                 pParent = pParent->GetParent();
     276             :             }
     277             :         }
     278             :     }
     279           0 : }
     280             : 
     281             : // -----------------------------------------------------------------------
     282             : 
     283           0 : void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
     284             : {
     285             :     // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     286           0 :     if(!IsCompletelyDisabled())
     287             :     {
     288           0 :         RECT_POINT eNewRP = eRP;
     289           0 :         bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
     290             : 
     291           0 :         switch( rKeyEvt.GetKeyCode().GetCode() )
     292             :         {
     293             :             case KEY_DOWN:
     294             :             {
     295           0 :                 if( !(m_nState & CS_NOVERT) )
     296           0 :                     switch( eNewRP )
     297             :                     {
     298           0 :                         case RP_LT: eNewRP = RP_LM; break;
     299           0 :                         case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
     300           0 :                         case RP_RT: eNewRP = RP_RM; break;
     301           0 :                         case RP_LM: eNewRP = RP_LB; break;
     302           0 :                         case RP_MM: eNewRP = RP_MB; break;
     303           0 :                         case RP_RM: eNewRP = RP_RB; break;
     304             :                         default: ; //prevent warning
     305             :                     }
     306             :             }
     307           0 :             break;
     308             :             case KEY_UP:
     309             :             {
     310           0 :                 if( !(m_nState & CS_NOVERT) )
     311           0 :                     switch( eNewRP )
     312             :                     {
     313           0 :                         case RP_LM: eNewRP = RP_LT; break;
     314           0 :                         case RP_MM: eNewRP = RP_MT; break;
     315           0 :                         case RP_RM: eNewRP = RP_RT; break;
     316           0 :                         case RP_LB: eNewRP = RP_LM; break;
     317           0 :                         case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
     318           0 :                         case RP_RB: eNewRP = RP_RM; break;
     319             :                         default: ; //prevent warning
     320             :                     }
     321             :             }
     322           0 :             break;
     323             :             case KEY_LEFT:
     324             :             {
     325           0 :                 if( !(m_nState & CS_NOHORZ) )
     326           0 :                     switch( eNewRP )
     327             :                     {
     328           0 :                         case RP_MT: eNewRP = RP_LT; break;
     329           0 :                         case RP_RT: eNewRP = RP_MT; break;
     330           0 :                         case RP_MM: eNewRP = RP_LM; break;
     331           0 :                         case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
     332           0 :                         case RP_MB: eNewRP = RP_LB; break;
     333           0 :                         case RP_RB: eNewRP = RP_MB; break;
     334             :                         default: ; //prevent warning
     335             :                     }
     336             :             }
     337           0 :             break;
     338             :             case KEY_RIGHT:
     339             :             {
     340           0 :                 if( !(m_nState & CS_NOHORZ) )
     341           0 :                     switch( eNewRP )
     342             :                     {
     343           0 :                         case RP_LT: eNewRP = RP_MT; break;
     344           0 :                         case RP_MT: eNewRP = RP_RT; break;
     345           0 :                         case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
     346           0 :                         case RP_MM: eNewRP = RP_RM; break;
     347           0 :                         case RP_LB: eNewRP = RP_MB; break;
     348           0 :                         case RP_MB: eNewRP = RP_RB; break;
     349             :                         default: ; //prevent warning
     350             :                     }
     351             :             }
     352           0 :             break;
     353             :             default:
     354           0 :                 Control::KeyInput( rKeyEvt );
     355           0 :                 return;
     356             :         }
     357           0 :         if( eNewRP != eRP )
     358             :         {
     359           0 :             SetActualRP( eNewRP );
     360             : 
     361           0 :             if( WINDOW_TABPAGE == GetParent()->GetType() )
     362           0 :                 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
     363             : 
     364           0 :             SetFocusRect();
     365             :         }
     366             :     }
     367             : }
     368             : 
     369             : // -----------------------------------------------------------------------
     370             : 
     371           0 : void SvxRectCtl::StateChanged( StateChangedType nType )
     372             : {
     373           0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     374           0 :         InitSettings( sal_True, sal_False );
     375           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     376           0 :         InitSettings( sal_False, sal_True );
     377             : 
     378           0 :     Window::StateChanged( nType );
     379           0 : }
     380             : 
     381             : // -----------------------------------------------------------------------
     382             : 
     383           0 : void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
     384             : {
     385           0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
     386           0 :         InitSettings( sal_True, sal_True );
     387             :     else
     388           0 :         Window::DataChanged( rDCEvt );
     389           0 : }
     390             : 
     391             : // the control (rectangle with 9 circles)
     392             : 
     393           0 : void SvxRectCtl::Paint( const Rectangle& )
     394             : {
     395           0 :     Point   aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
     396             : 
     397           0 :     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     398             : 
     399           0 :     SetLineColor( rStyles.GetDialogColor() );
     400           0 :     SetFillColor( rStyles.GetDialogColor() );
     401           0 :     DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
     402             : 
     403           0 :     if( IsEnabled() )
     404           0 :         SetLineColor( rStyles.GetLabelTextColor() );
     405             :     else
     406           0 :         SetLineColor( rStyles.GetShadowColor() );
     407             : 
     408           0 :     SetFillColor();
     409             : 
     410           0 :     switch( eCS )
     411             :     {
     412             : 
     413             :         case CS_RECT:
     414             :         case CS_SHADOW:
     415           0 :             if( !IsEnabled() )
     416             :             {
     417           0 :                 Color aOldCol = GetLineColor();
     418           0 :                 SetLineColor( rStyles.GetLightColor() );
     419           0 :                 DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
     420           0 :                 SetLineColor( aOldCol );
     421             :             }
     422           0 :             DrawRect( Rectangle( aPtLT, aPtRB ) );
     423           0 :         break;
     424             : 
     425             :         case CS_LINE:
     426           0 :             if( !IsEnabled() )
     427             :             {
     428           0 :                 Color aOldCol = GetLineColor();
     429           0 :                 SetLineColor( rStyles.GetLightColor() );
     430           0 :                 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
     431           0 :                           aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
     432           0 :                 SetLineColor( aOldCol );
     433             :             }
     434           0 :             DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
     435           0 :                       aPtRM + Point( 2 * nBorderWidth, 0 ) );
     436           0 :         break;
     437             : 
     438             :         case CS_ANGLE:
     439           0 :             if( !IsEnabled() )
     440             :             {
     441           0 :                 Color aOldCol = GetLineColor();
     442           0 :                 SetLineColor( rStyles.GetLightColor() );
     443           0 :                 DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
     444           0 :                 DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
     445           0 :                 DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
     446           0 :                 DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
     447           0 :                 SetLineColor( aOldCol );
     448             :             }
     449           0 :             DrawLine( aPtLT, aPtRB );
     450           0 :             DrawLine( aPtLB, aPtRT );
     451           0 :             DrawLine( aPtLM, aPtRM );
     452           0 :             DrawLine( aPtMT, aPtMB );
     453           0 :         break;
     454             : 
     455             :         default:
     456           0 :             break;
     457             :     }
     458           0 :     SetFillColor( GetBackground().GetColor() );
     459             : 
     460           0 :     Size aBtnSize( 11, 11 );
     461           0 :     Size aDstBtnSize(  PixelToLogic( aBtnSize ) );
     462           0 :     Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
     463           0 :     Point aBtnPnt1( IsEnabled()?0:22,0 );
     464           0 :     Point aBtnPnt2( 11,0 );
     465           0 :     Point aBtnPnt3( 22,0 );
     466             : 
     467           0 :     bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
     468           0 :     bool bNoVert = (m_nState & CS_NOVERT) != 0;
     469             : 
     470           0 :     Bitmap&         rBitmap = GetRectBitmap();
     471             : 
     472             :     // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     473           0 :     if(IsCompletelyDisabled())
     474             :     {
     475           0 :         DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     476           0 :         DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     477           0 :         DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     478           0 :         DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     479           0 :         if( eCS == CS_RECT || eCS == CS_LINE )
     480           0 :             DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     481           0 :         DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     482           0 :         DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     483           0 :         DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     484           0 :         DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     485             :     }
     486             :     else
     487             :     {
     488           0 :         DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     489           0 :         DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     490           0 :         DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     491             : 
     492           0 :         DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     493             : 
     494             :         // Center for rectangle and line
     495           0 :         if( eCS == CS_RECT || eCS == CS_LINE )
     496           0 :             DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
     497             : 
     498           0 :         DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     499             : 
     500           0 :         DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     501           0 :         DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     502           0 :         DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     503             :     }
     504             : 
     505             :     // draw active button, avoid center pos for angle
     506             :     // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     507           0 :     if(!IsCompletelyDisabled())
     508             :     {
     509           0 :         if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
     510             :         {
     511           0 :             Point       aCenterPt( aPtNew );
     512           0 :             aCenterPt -= aToCenter;
     513             : 
     514           0 :             DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
     515             :         }
     516             :     }
     517           0 : }
     518             : 
     519             : // Convert RECT_POINT Point
     520             : 
     521           0 : Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
     522             : {
     523           0 :     switch( _eRP )
     524             :     {
     525           0 :         case RP_LT: return aPtLT;
     526           0 :         case RP_MT: return aPtMT;
     527           0 :         case RP_RT: return aPtRT;
     528           0 :         case RP_LM: return aPtLM;
     529           0 :         case RP_MM: return aPtMM;
     530           0 :         case RP_RM: return aPtRM;
     531           0 :         case RP_LB: return aPtLB;
     532           0 :         case RP_MB: return aPtMB;
     533           0 :         case RP_RB: return aPtRB;
     534             :     }
     535           0 :     return( aPtMM ); // default
     536             : }
     537             : 
     538             : 
     539           0 : void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
     540             : {
     541           0 :     HideFocus();
     542             : 
     543           0 :     if( pRect )
     544           0 :         ShowFocus( *pRect );
     545             :     else
     546           0 :         ShowFocus( CalculateFocusRectangle() );
     547           0 : }
     548             : 
     549           0 : Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
     550             : {
     551           0 :     Point aPtLast = aPtNew;
     552           0 :     aPtNew = GetPointFromRP( eNewRP );
     553             : 
     554           0 :     if( (m_nState & CS_NOHORZ) != 0 )
     555           0 :         aPtNew.X() = aPtMM.X();
     556             : 
     557           0 :     if( (m_nState & CS_NOVERT) != 0 )
     558           0 :         aPtNew.Y() = aPtMM.Y();
     559             : 
     560           0 :     eNewRP = GetRPFromPoint( aPtNew );
     561             : 
     562           0 :     eDefRP = eNewRP;
     563           0 :     eRP = eNewRP;
     564             : 
     565           0 :     return aPtLast;
     566             : }
     567             : 
     568           0 : void SvxRectCtl::GetFocus()
     569             : {
     570           0 :     SetFocusRect();
     571           0 : }
     572             : 
     573             : 
     574           0 : void SvxRectCtl::LoseFocus()
     575             : {
     576           0 :     HideFocus();
     577           0 : }
     578             : 
     579             : 
     580           0 : Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
     581             : {
     582           0 :     Point   aPt = PixelToLogic( rPt );
     583             :     long    x;
     584             :     long    y;
     585             : 
     586           0 :     if( ( m_nState & CS_NOHORZ ) == 0 )
     587             :     {
     588           0 :         if( aPt.X() < aSize.Width() / 3 )
     589           0 :             x = aPtLT.X();
     590           0 :         else if( aPt.X() < aSize.Width() * 2 / 3 )
     591           0 :             x = aPtMM.X();
     592             :         else
     593           0 :             x = aPtRB.X();
     594             :     }
     595             :     else
     596           0 :         x = aPtMM.X();
     597             : 
     598           0 :     if( ( m_nState & CS_NOVERT ) == 0 )
     599             :     {
     600           0 :         if( aPt.Y() < aSize.Height() / 3 )
     601           0 :             y = aPtLT.Y();
     602           0 :         else if( aPt.Y() < aSize.Height() * 2 / 3 )
     603           0 :             y = aPtMM.Y();
     604             :         else
     605           0 :             y = aPtRB.Y();
     606             :     }
     607             :     else
     608           0 :             y = aPtMM.Y();
     609             : 
     610           0 :     return Point( x, y );
     611             : }
     612             : 
     613             : 
     614             : // Converts Point in RECT_POINT
     615             : 
     616           0 : RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
     617             : {
     618           0 :     if     ( aPt == aPtLT) return RP_LT;
     619           0 :     else if( aPt == aPtMT) return RP_MT;
     620           0 :     else if( aPt == aPtRT) return RP_RT;
     621           0 :     else if( aPt == aPtLM) return RP_LM;
     622           0 :     else if( aPt == aPtRM) return RP_RM;
     623           0 :     else if( aPt == aPtLB) return RP_LB;
     624           0 :     else if( aPt == aPtMB) return RP_MB;
     625           0 :     else if( aPt == aPtRB) return RP_RB;
     626             : 
     627             :     else
     628           0 :         return RP_MM; // default
     629             : }
     630             : 
     631             : // Resets to the original state of the control
     632             : 
     633           0 : void SvxRectCtl::Reset()
     634             : {
     635           0 :     aPtNew = GetPointFromRP( eDefRP );
     636           0 :     eRP = eDefRP;
     637           0 :     Invalidate();
     638           0 : }
     639             : 
     640             : // Returns the currently selected RECT_POINT
     641             : 
     642           0 : RECT_POINT SvxRectCtl::GetActualRP() const
     643             : {
     644           0 :     return( eRP );
     645             : }
     646             : 
     647           0 : void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
     648             : {
     649           0 :     Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
     650             : 
     651           0 :     Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
     652           0 :     Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
     653             : 
     654             :     // notify accessibility object about change
     655           0 :     if( pAccContext )
     656           0 :         pAccContext->selectChild( eNewRP );
     657           0 : }
     658             : 
     659           0 : void SvxRectCtl::SetState( CTL_STATE nState )
     660             : {
     661           0 :     m_nState = nState;
     662             : 
     663           0 :     Point aPtLast( GetPointFromRP( eRP ) );
     664           0 :     Point _aPtNew( aPtLast );
     665             : 
     666           0 :     if( (m_nState & CS_NOHORZ) != 0 )
     667           0 :         _aPtNew.X() = aPtMM.X();
     668             : 
     669           0 :     if( (m_nState & CS_NOVERT) != 0 )
     670           0 :         _aPtNew.Y() = aPtMM.Y();
     671             : 
     672           0 :     eRP = GetRPFromPoint( _aPtNew );
     673           0 :     Invalidate();
     674             : 
     675           0 :     if( WINDOW_TABPAGE == GetParent()->GetType() )
     676           0 :         ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
     677           0 : }
     678             : 
     679           0 : sal_uInt8 SvxRectCtl::GetNumOfChildren( void ) const
     680             : {
     681           0 :     return ( eCS == CS_ANGLE )? 8 : 9;
     682             : }
     683             : 
     684           0 : Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
     685             : {
     686           0 :     Size        aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
     687           0 :     return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
     688             : }
     689             : 
     690           0 : Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
     691             : {
     692           0 :     Rectangle   aRet;
     693           0 :     RECT_POINT  eOldRectPoint = GetActualRP();
     694             : 
     695           0 :     if( eOldRectPoint == eRectPoint )
     696           0 :         aRet = CalculateFocusRectangle();
     697             :     else
     698             :     {
     699           0 :         SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
     700             : 
     701           0 :         pThis->SetActualRPWithoutInvalidate( eRectPoint );      // no invalidation because it's only temporary!
     702           0 :         aRet = CalculateFocusRectangle();
     703             : 
     704           0 :         pThis->SetActualRPWithoutInvalidate( eOldRectPoint );   // no invalidation because nothing has changed!
     705             :     }
     706             : 
     707           0 :     return aRet;
     708             : }
     709             : 
     710           0 : Reference< XAccessible > SvxRectCtl::CreateAccessible()
     711             : {
     712           0 :     Window*                     pParent = GetAccessibleParentWindow();
     713             : 
     714             :     DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
     715             : 
     716           0 :     Reference< XAccessible >    xAccParent  = pParent->GetAccessible();
     717           0 :     if( xAccParent.is() )
     718             :     {
     719           0 :         pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
     720           0 :         pAccContext->acquire();
     721             : 
     722           0 :         SetActualRP( GetActualRP() );
     723             : 
     724           0 :         return pAccContext;
     725             :     }
     726             :     else
     727           0 :         return Reference< XAccessible >();
     728             : }
     729             : 
     730           0 : RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
     731             : {
     732           0 :     return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
     733             : }
     734             : 
     735             : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     736           0 : void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
     737             : {
     738           0 :     mbCompleteDisable = bNew;
     739           0 :     Invalidate();
     740           0 : }
     741             : 
     742           0 : void SvxRectCtl::SetCS(CTL_STYLE eNew)
     743             : {
     744           0 :     eCS = eNew;
     745           0 : }
     746             : 
     747             : // Control for editing bitmaps
     748             : 
     749           0 : SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) :
     750             :                         Control     ( pParent, rResId ),
     751             :                         nLines      ( nNumber ),
     752           0 :                         bPaintable  ( sal_True )
     753             : {
     754           0 :     aRectSize = GetOutputSize();
     755             : 
     756           0 :     SetPixelColor( Color( COL_BLACK ) );
     757           0 :     SetBackgroundColor( Color( COL_WHITE ) );
     758           0 :     SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
     759             : 
     760           0 :     nSquares = nLines * nLines;
     761           0 :     pPixel = new sal_uInt16[ nSquares ];
     762           0 :     memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
     763           0 : }
     764             : 
     765             : // Destructor dealocating the dynamic array
     766             : 
     767           0 : SvxPixelCtl::~SvxPixelCtl( )
     768             : {
     769           0 :     delete []pPixel;
     770           0 : }
     771             : 
     772             : // Changes the foreground or Background color
     773             : 
     774           0 : void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
     775             : {
     776           0 :     if( *( pPixel + nPixel) == 0 )
     777           0 :         *( pPixel + nPixel) = 1; //  could be extended to more colors
     778             :     else
     779           0 :         *( pPixel + nPixel) = 0;
     780           0 : }
     781             : 
     782             : // The clicked rectangle is identified, to change its color
     783             : 
     784           0 : void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
     785             : {
     786           0 :     Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
     787           0 :     Point aPtTl, aPtBr;
     788             :     sal_uInt16  nX, nY;
     789             : 
     790           0 :     nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
     791           0 :     nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
     792             : 
     793           0 :     ChangePixel( nX + nY * nLines );
     794             : 
     795           0 :     aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
     796           0 :     aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
     797           0 :     aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
     798           0 :     aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
     799             : 
     800           0 :     Invalidate( Rectangle( aPtTl, aPtBr ) );
     801             : 
     802           0 :     if( WINDOW_TABPAGE == GetParent()->GetType() )
     803           0 :         ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint is a dummy
     804           0 : }
     805             : 
     806             : // Draws the Control (Rectangle with nine circles)
     807             : 
     808           0 : void SvxPixelCtl::Paint( const Rectangle& )
     809             : {
     810             :     sal_uInt16  i, j, nTmp;
     811           0 :     Point   aPtTl, aPtBr;
     812             : 
     813           0 :     if( bPaintable )
     814             :     {
     815             :         // Draw lines
     816           0 :         Control::SetLineColor( aLineColor );
     817           0 :         for( i = 1; i < nLines; i++)
     818             :         {
     819             :             // horizontal
     820           0 :             nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
     821           0 :             DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
     822             :             // vertically
     823           0 :             nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
     824           0 :             DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
     825             :         }
     826             : 
     827             :         //Draw Rectangles (squares)
     828           0 :         Control::SetLineColor();
     829           0 :         sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
     830             : 
     831           0 :         for( i = 0; i < nLines; i++)
     832             :         {
     833           0 :             aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
     834           0 :             aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
     835             : 
     836           0 :             for( j = 0; j < nLines; j++)
     837             :             {
     838           0 :                 aPtTl.X() = aRectSize.Width() * j / nLines + 1;
     839           0 :                 aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
     840             : 
     841           0 :                 if ( *( pPixel + i * nLines + j ) != nLastPixel )
     842             :                 {
     843           0 :                     nLastPixel = *( pPixel + i * nLines + j );
     844             :                     // Change color: 0 -> Background color
     845           0 :                     SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
     846             :                 }
     847           0 :                 DrawRect( Rectangle( aPtTl, aPtBr ) );
     848             :             }
     849             :         }
     850             :     } // bPaintable
     851             :     else
     852             :     {
     853           0 :         SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
     854           0 :         Control::SetLineColor( Color( COL_LIGHTRED ) );
     855           0 :         DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
     856           0 :         DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
     857             :     }
     858           0 : }
     859             : 
     860           0 : void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx )
     861             : {
     862           0 :     BitmapColor aBack;
     863           0 :     BitmapColor aFront;
     864             : 
     865           0 :     if(isHistorical8x8(rBitmapEx, aBack, aFront))
     866             :     {
     867           0 :         Bitmap aBitmap(rBitmapEx.GetBitmap());
     868           0 :         BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
     869             : 
     870           0 :         aBackgroundColor = aBack;
     871           0 :         aPixelColor = aFront;
     872             : 
     873           0 :         for(sal_uInt16 i(0); i < nSquares; i++)
     874             :         {
     875           0 :             const BitmapColor aColor(pRead->GetColor(i/8, i%8));
     876             : 
     877           0 :             if(aColor == aBack)
     878             :             {
     879           0 :                 *( pPixel + i ) = 0;
     880             :             }
     881             :             else
     882             :             {
     883           0 :                 *( pPixel + i ) = 1;
     884             :             }
     885           0 :         }
     886             : 
     887           0 :         aBitmap.ReleaseAccess(pRead);
     888           0 :     }
     889           0 : }
     890             : 
     891             : // Resets to the original state of the control
     892             : 
     893           0 : void SvxPixelCtl::Reset()
     894             : {
     895             :     // clear pixel area
     896           0 :     memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
     897           0 :     Invalidate();
     898           0 : }
     899             : 
     900             : // Constructor: BitmapCtl for SvxPixelCtl
     901             : 
     902           0 : SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
     903             : {
     904           0 :     aSize = rSize;
     905           0 : }
     906             : 
     907           0 : SvxBitmapCtl::~SvxBitmapCtl()
     908             : {
     909           0 : }
     910             : 
     911             : // BitmapCtl: Returns the Bitmap
     912             : 
     913           0 : BitmapEx SvxBitmapCtl::GetBitmapEx()
     914             : {
     915           0 :     const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
     916             : 
     917           0 :     return BitmapEx(aRetval);
     918             : }
     919             : 
     920           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeColorLB(Window *pParent, VclBuilder::stringmap &)
     921             : {
     922           0 :     ColorLB *pListBox = new ColorLB(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE);
     923           0 :     pListBox->EnableAutoSize(true);
     924           0 :     return pListBox;
     925             : }
     926             : 
     927             : // Fills the Listbox with color and strings
     928             : 
     929          64 : void ColorLB::Fill( const XColorListRef &pColorTab )
     930             : {
     931          64 :     if( !pColorTab.is() )
     932          64 :         return;
     933             : 
     934          64 :     long nCount = pColorTab->Count();
     935             :     XColorEntry* pEntry;
     936          64 :     SetUpdateMode( sal_False );
     937             : 
     938       10624 :     for( long i = 0; i < nCount; i++ )
     939             :     {
     940       10560 :         pEntry = pColorTab->GetColor( i );
     941       10560 :         InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     942             :     }
     943             : 
     944          64 :     AdaptDropDownLineCountToMaximum();
     945          64 :     SetUpdateMode( sal_True );
     946             : }
     947             : 
     948             : /************************************************************************/
     949             : 
     950           0 : void ColorLB::Append( const XColorEntry& rEntry )
     951             : {
     952           0 :     InsertEntry( rEntry.GetColor(), rEntry.GetName() );
     953           0 :     AdaptDropDownLineCountToMaximum();
     954           0 : }
     955             : 
     956             : /************************************************************************/
     957             : 
     958           0 : void ColorLB::Modify( const XColorEntry& rEntry, sal_uInt16 nPos )
     959             : {
     960           0 :     RemoveEntry( nPos );
     961           0 :     InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos );
     962           0 : }
     963             : 
     964             : // Fills the Listbox with color and strings
     965             : 
     966          60 : void FillAttrLB::Fill( const XColorListRef &pColorTab )
     967             : {
     968          60 :     long nCount = pColorTab->Count();
     969             :     XColorEntry* pEntry;
     970          60 :     SetUpdateMode( sal_False );
     971             : 
     972        9960 :     for( long i = 0; i < nCount; i++ )
     973             :     {
     974        9900 :         pEntry = pColorTab->GetColor( i );
     975        9900 :         InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     976             :     }
     977             : 
     978          60 :     AdaptDropDownLineCountToMaximum();
     979          60 :     SetUpdateMode( sal_True );
     980          60 : }
     981             : 
     982             : // Fills the listbox (provisional) with strings
     983             : 
     984           0 : HatchingLB::HatchingLB( Window* pParent, ResId Id)
     985             : : ListBox( pParent, Id ),
     986           0 :   mpList ( NULL )
     987             : {
     988           0 :     SetEdgeBlending(true);
     989           0 : }
     990             : 
     991           0 : HatchingLB::HatchingLB( Window* pParent, WinBits nWinStyle)
     992             : : ListBox( pParent, nWinStyle ),
     993           0 :   mpList ( NULL )
     994             : {
     995           0 :     SetEdgeBlending(true);
     996           0 : }
     997             : 
     998           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeHatchingLB(Window *pParent, VclBuilder::stringmap& rMap)
     999             : {
    1000           0 :     WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
    1001           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1002           0 :     if (!sBorder.isEmpty())
    1003           0 :         nWinStyle |= WB_BORDER;
    1004           0 :     HatchingLB *pListBox = new HatchingLB(pParent, nWinStyle);
    1005           0 :     pListBox->EnableAutoSize(true);
    1006           0 :     return pListBox;
    1007             : }
    1008             : 
    1009           0 : void HatchingLB::Fill( const XHatchListRef &pList )
    1010             : {
    1011           0 :     if( !pList.is() )
    1012           0 :         return;
    1013             : 
    1014           0 :     mpList = pList;
    1015             :     XHatchEntry* pEntry;
    1016           0 :     long nCount = pList->Count();
    1017             : 
    1018           0 :     SetUpdateMode( sal_False );
    1019             : 
    1020           0 :     for( long i = 0; i < nCount; i++ )
    1021             :     {
    1022           0 :         pEntry = pList->GetHatch( i );
    1023           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1024           0 :         if( !aBitmap.IsEmpty() )
    1025           0 :             InsertEntry( pEntry->GetName(), aBitmap );
    1026             :         else
    1027           0 :             InsertEntry( pEntry->GetName() );
    1028           0 :     }
    1029             : 
    1030           0 :     AdaptDropDownLineCountToMaximum();
    1031           0 :     SetUpdateMode( sal_True );
    1032             : }
    1033             : 
    1034             : /************************************************************************/
    1035             : 
    1036           0 : void HatchingLB::Append( const XHatchEntry& rEntry, const Bitmap& rBitmap )
    1037             : {
    1038           0 :     if(!rBitmap.IsEmpty())
    1039             :     {
    1040           0 :         InsertEntry( rEntry.GetName(), rBitmap );
    1041             :     }
    1042             :     else
    1043             :     {
    1044           0 :         InsertEntry( rEntry.GetName() );
    1045             :     }
    1046             : 
    1047           0 :     AdaptDropDownLineCountToMaximum();
    1048           0 : }
    1049             : 
    1050             : /************************************************************************/
    1051             : 
    1052           0 : void HatchingLB::Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
    1053             : {
    1054           0 :     RemoveEntry( nPos );
    1055             : 
    1056           0 :     if( !rBitmap.IsEmpty() )
    1057             :     {
    1058           0 :         InsertEntry( rEntry.GetName(), rBitmap, nPos );
    1059             :     }
    1060             :     else
    1061             :     {
    1062           0 :         InsertEntry( rEntry.GetName(), nPos );
    1063             :     }
    1064           0 : }
    1065             : 
    1066             : // Fills the listbox (provisional) with strings
    1067             : 
    1068           0 : void FillAttrLB::Fill( const XHatchListRef &pList )
    1069             : {
    1070           0 :     long nCount = pList->Count();
    1071             :     XHatchEntry* pEntry;
    1072           0 :     ListBox::SetUpdateMode( sal_False );
    1073             : 
    1074           0 :     for( long i = 0; i < nCount; i++ )
    1075             :     {
    1076           0 :         pEntry = pList->GetHatch( i );
    1077           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1078           0 :         if( !aBitmap.IsEmpty() )
    1079           0 :             ListBox::InsertEntry( pEntry->GetName(), aBitmap );
    1080             :         else
    1081           0 :             InsertEntry( pEntry->GetName() );
    1082           0 :     }
    1083             : 
    1084           0 :     AdaptDropDownLineCountToMaximum();
    1085           0 :     ListBox::SetUpdateMode( sal_True );
    1086           0 : }
    1087             : 
    1088             : // Fills the listbox (provisional) with strings
    1089             : 
    1090           0 : GradientLB::GradientLB( Window* pParent, ResId Id)
    1091             : : ListBox( pParent, Id ),
    1092           0 :   mpList(NULL)
    1093             : {
    1094           0 :     SetEdgeBlending(true);
    1095           0 : }
    1096             : 
    1097           0 : GradientLB::GradientLB( Window* pParent, WinBits aWB)
    1098             : : ListBox( pParent, aWB ),
    1099           0 :   mpList(NULL)
    1100             : {
    1101           0 :     SetEdgeBlending(true);
    1102           0 : }
    1103             : 
    1104           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeGradientLB(Window *pParent, VclBuilder::stringmap &rMap)
    1105             : {
    1106           0 :     WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
    1107           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1108           0 :     if (!sBorder.isEmpty())
    1109           0 :         nWinStyle |= WB_BORDER;
    1110           0 :     GradientLB *pListBox = new GradientLB(pParent, nWinStyle);
    1111           0 :     pListBox->EnableAutoSize(true);
    1112           0 :     return pListBox;
    1113             : }
    1114             : 
    1115           0 : void GradientLB::Fill( const XGradientListRef &pList )
    1116             : {
    1117           0 :     if( !pList.is() )
    1118           0 :         return;
    1119             : 
    1120           0 :     mpList = pList;
    1121             :     XGradientEntry* pEntry;
    1122           0 :     long nCount = pList->Count();
    1123             : 
    1124           0 :     SetUpdateMode( sal_False );
    1125             : 
    1126           0 :     for( long i = 0; i < nCount; i++ )
    1127             :     {
    1128           0 :         pEntry = pList->GetGradient( i );
    1129           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1130           0 :         if( !aBitmap.IsEmpty() )
    1131           0 :             InsertEntry( pEntry->GetName(), aBitmap );
    1132             :         else
    1133           0 :             InsertEntry( pEntry->GetName() );
    1134           0 :     }
    1135             : 
    1136           0 :     AdaptDropDownLineCountToMaximum();
    1137           0 :     SetUpdateMode( sal_True );
    1138             : }
    1139             : 
    1140             : /************************************************************************/
    1141             : 
    1142           0 : void GradientLB::Append( const XGradientEntry& rEntry, const Bitmap& rBitmap )
    1143             : {
    1144           0 :     if(!rBitmap.IsEmpty())
    1145             :     {
    1146           0 :         InsertEntry( rEntry.GetName(), rBitmap );
    1147             :     }
    1148             :     else
    1149             :     {
    1150           0 :         InsertEntry( rEntry.GetName() );
    1151             :     }
    1152             : 
    1153           0 :     AdaptDropDownLineCountToMaximum();
    1154           0 : }
    1155             : 
    1156             : /************************************************************************/
    1157             : 
    1158           0 : void GradientLB::Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
    1159             : {
    1160           0 :     RemoveEntry( nPos );
    1161             : 
    1162           0 :     if(!rBitmap.IsEmpty())
    1163             :     {
    1164           0 :         InsertEntry( rEntry.GetName(), rBitmap, nPos );
    1165             :     }
    1166             :     else
    1167             :     {
    1168           0 :         InsertEntry( rEntry.GetName(), nPos );
    1169             :     }
    1170           0 : }
    1171             : 
    1172             : /************************************************************************/
    1173             : 
    1174           0 : void GradientLB::SelectEntryByList( const XGradientListRef &pList, const String& rStr,
    1175             :                                     const XGradient& rGradient, sal_uInt16 nDist )
    1176             : {
    1177           0 :     long nCount = pList->Count();
    1178             :     XGradientEntry* pEntry;
    1179           0 :     bool bFound = false;
    1180           0 :     String aStr;
    1181             : 
    1182             :     long i;
    1183           0 :     for( i = 0; i < nCount && !bFound; i++ )
    1184             :     {
    1185           0 :         pEntry = pList->GetGradient( i );
    1186             : 
    1187           0 :         aStr = pEntry->GetName();
    1188             : 
    1189           0 :         if( rStr == aStr && rGradient == pEntry->GetGradient() )
    1190           0 :             bFound = true;
    1191             :     }
    1192           0 :     if( bFound )
    1193           0 :         SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
    1194           0 : }
    1195             : 
    1196             : // Fills the listbox (provisional) with strings
    1197             : 
    1198           0 : void FillAttrLB::Fill( const XGradientListRef &pList )
    1199             : {
    1200           0 :     long nCount = pList->Count();
    1201             :     XGradientEntry* pEntry;
    1202           0 :     ListBox::SetUpdateMode( sal_False );
    1203             : 
    1204           0 :     for( long i = 0; i < nCount; i++ )
    1205             :     {
    1206           0 :         pEntry = pList->GetGradient( i );
    1207           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1208           0 :         if( !aBitmap.IsEmpty() )
    1209           0 :             ListBox::InsertEntry( pEntry->GetName(), aBitmap );
    1210             :         else
    1211           0 :             InsertEntry( pEntry->GetName() );
    1212           0 :     }
    1213             : 
    1214           0 :     AdaptDropDownLineCountToMaximum();
    1215           0 :     ListBox::SetUpdateMode( sal_True );
    1216           0 : }
    1217             : 
    1218             : // BitmapLB Constructor
    1219             : 
    1220           0 : BitmapLB::BitmapLB(Window* pParent, ResId Id)
    1221             : :   ListBox(pParent, Id),
    1222             :     maBitmapEx(),
    1223           0 :     mpList(NULL)
    1224             : {
    1225           0 :     SetEdgeBlending(true);
    1226           0 : }
    1227             : 
    1228             : /************************************************************************/
    1229             : 
    1230             : namespace
    1231             : {
    1232           0 :     void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
    1233             :     {
    1234           0 :         if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
    1235             :         {
    1236           0 :             VirtualDevice aVirtualDevice;
    1237           0 :             aVirtualDevice.SetOutputSizePixel(rSize);
    1238             : 
    1239           0 :             if(rBitmapEx.IsTransparent())
    1240             :             {
    1241           0 :                 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1242             : 
    1243           0 :                 if(rStyleSettings.GetPreviewUsesCheckeredBackground())
    1244             :                 {
    1245           0 :                     const Point aNull(0, 0);
    1246             :                     static const sal_uInt32 nLen(8);
    1247           0 :                     static const Color aW(COL_WHITE);
    1248           0 :                     static const Color aG(0xef, 0xef, 0xef);
    1249             : 
    1250           0 :                     aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
    1251             :                 }
    1252             :                 else
    1253             :                 {
    1254           0 :                     aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
    1255           0 :                     aVirtualDevice.Erase();
    1256             :                 }
    1257             :             }
    1258             : 
    1259           0 :             if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
    1260             :             {
    1261           0 :                 rBitmapEx.Scale(rSize, BMP_SCALE_DEFAULT);
    1262           0 :                 aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx);
    1263             :             }
    1264             :             else
    1265             :             {
    1266           0 :                 const Size aBitmapSize(rBitmapEx.GetSizePixel());
    1267             : 
    1268           0 :                 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height())
    1269             :                 {
    1270           0 :                     for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width())
    1271             :                     {
    1272             :                         aVirtualDevice.DrawBitmapEx(
    1273             :                             Point(x, y),
    1274           0 :                             rBitmapEx);
    1275             :                     }
    1276             :                 }
    1277             :             }
    1278             : 
    1279           0 :             rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize);
    1280             :         }
    1281           0 :     }
    1282             : } // end of anonymous namespace
    1283             : 
    1284             : /************************************************************************/
    1285             : 
    1286           0 : void BitmapLB::Fill( const XBitmapListRef &pList )
    1287             : {
    1288           0 :     if( !pList.is() )
    1289           0 :         return;
    1290             : 
    1291           0 :     mpList = pList;
    1292             :     XBitmapEntry* pEntry;
    1293           0 :     const long nCount(pList->Count());
    1294           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1295           0 :     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
    1296             : 
    1297           0 :     SetUpdateMode(false);
    1298             : 
    1299           0 :     for(long i(0); i < nCount; i++)
    1300             :     {
    1301           0 :         pEntry = pList->GetBitmap(i);
    1302           0 :         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
    1303           0 :         formatBitmapExToSize(maBitmapEx, aSize);
    1304           0 :         InsertEntry(pEntry->GetName(), maBitmapEx);
    1305             :     }
    1306             : 
    1307           0 :     AdaptDropDownLineCountToMaximum();
    1308           0 :     SetUpdateMode(true);
    1309             : }
    1310             : 
    1311             : /************************************************************************/
    1312             : 
    1313           0 : void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry)
    1314             : {
    1315           0 :     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
    1316             : 
    1317           0 :     if(!maBitmapEx.IsEmpty())
    1318             :     {
    1319           0 :         formatBitmapExToSize(maBitmapEx, rSize);
    1320           0 :         InsertEntry(rEntry.GetName(), maBitmapEx);
    1321             :     }
    1322             :     else
    1323             :     {
    1324           0 :         InsertEntry(rEntry.GetName());
    1325             :     }
    1326             : 
    1327           0 :     AdaptDropDownLineCountToMaximum();
    1328           0 : }
    1329             : 
    1330             : /************************************************************************/
    1331             : 
    1332           0 : void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos)
    1333             : {
    1334           0 :     RemoveEntry(nPos);
    1335           0 :     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
    1336             : 
    1337           0 :     if(!maBitmapEx.IsEmpty())
    1338             :     {
    1339           0 :         formatBitmapExToSize(maBitmapEx, rSize);
    1340           0 :         InsertEntry(rEntry.GetName(), maBitmapEx, nPos);
    1341             :     }
    1342             :     else
    1343             :     {
    1344           0 :         InsertEntry(rEntry.GetName());
    1345             :     }
    1346           0 : }
    1347             : 
    1348          64 : FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB)
    1349          64 : :   ColorListBox(pParent, aWB)
    1350             : {
    1351          64 : }
    1352             : 
    1353             : /************************************************************************/
    1354             : 
    1355           0 : void FillAttrLB::Fill( const XBitmapListRef &pList )
    1356             : {
    1357           0 :     const long nCount(pList->Count());
    1358             :     XBitmapEntry* pEntry;
    1359           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1360           0 :     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
    1361             : 
    1362           0 :     ListBox::SetUpdateMode(false);
    1363             : 
    1364           0 :     for(long i(0); i < nCount; i++)
    1365             :     {
    1366           0 :         pEntry = pList->GetBitmap( i );
    1367           0 :         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
    1368           0 :         formatBitmapExToSize(maBitmapEx, aSize);
    1369           0 :         ListBox::InsertEntry(pEntry->GetName(), maBitmapEx);
    1370             :     }
    1371             : 
    1372           0 :     AdaptDropDownLineCountToMaximum();
    1373           0 :     ListBox::SetUpdateMode(true);
    1374           0 : }
    1375             : 
    1376          64 : void FillTypeLB::Fill()
    1377             : {
    1378          64 :     SetUpdateMode( sal_False );
    1379             : 
    1380          64 :     InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
    1381          64 :     InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
    1382          64 :     InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
    1383          64 :     InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
    1384          64 :     InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
    1385             : 
    1386          64 :     AdaptDropDownLineCountToMaximum();
    1387          64 :     SetUpdateMode( sal_True );
    1388          64 : }
    1389             : 
    1390           0 : LineLB::LineLB(Window* pParent, ResId Id)
    1391             : :   ListBox(pParent, Id),
    1392           0 :     mbAddStandardFields(true)
    1393             : {
    1394             :     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
    1395           0 : }
    1396             : 
    1397          64 : LineLB::LineLB(Window* pParent, WinBits aWB)
    1398             : :   ListBox(pParent, aWB),
    1399          64 :     mbAddStandardFields(true)
    1400             : {
    1401             :     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
    1402          64 : }
    1403             : 
    1404          64 : LineLB::~LineLB()
    1405             : {
    1406          64 : }
    1407             : 
    1408           0 : void LineLB::setAddStandardFields(bool bNew)
    1409             : {
    1410           0 :     if(getAddStandardFields() != bNew)
    1411             :     {
    1412           0 :         mbAddStandardFields = bNew;
    1413             :     }
    1414           0 : }
    1415             : 
    1416             : // Fills the listbox (provisional) with strings
    1417             : 
    1418          61 : void LineLB::Fill( const XDashListRef &pList )
    1419             : {
    1420          61 :     Clear();
    1421             : 
    1422          61 :     if( !pList.is() )
    1423          61 :         return;
    1424             : 
    1425          61 :     if(getAddStandardFields())
    1426             :     {
    1427             :         // entry for 'none'
    1428          61 :         InsertEntry(pList->GetStringForUiNoLine());
    1429             : 
    1430             :         // entry for solid line
    1431          61 :         InsertEntry(pList->GetStringForUiSolidLine(), pList->GetBitmapForUISolidLine());
    1432             :     }
    1433             : 
    1434             :     // entries for dashed lines
    1435             : 
    1436          61 :     long nCount = pList->Count();
    1437             :     XDashEntry* pEntry;
    1438          61 :     SetUpdateMode( sal_False );
    1439             : 
    1440         732 :     for( long i = 0; i < nCount; i++ )
    1441             :     {
    1442         671 :         pEntry = pList->GetDash( i );
    1443         671 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1444         671 :         if( !aBitmap.IsEmpty() )
    1445             :         {
    1446         671 :             InsertEntry( pEntry->GetName(), aBitmap );
    1447             :         }
    1448             :         else
    1449           0 :             InsertEntry( pEntry->GetName() );
    1450         671 :     }
    1451             : 
    1452          61 :     AdaptDropDownLineCountToMaximum();
    1453          61 :     SetUpdateMode( sal_True );
    1454             : }
    1455             : 
    1456             : /************************************************************************/
    1457             : 
    1458           0 : void LineLB::Append( const XDashEntry& rEntry, const Bitmap& rBitmap )
    1459             : {
    1460           0 :     if(!rBitmap.IsEmpty())
    1461             :     {
    1462           0 :         InsertEntry( rEntry.GetName(), rBitmap );
    1463             :     }
    1464             :     else
    1465             :     {
    1466           0 :         InsertEntry( rEntry.GetName() );
    1467             :     }
    1468             : 
    1469           0 :     AdaptDropDownLineCountToMaximum();
    1470           0 : }
    1471             : 
    1472             : /************************************************************************/
    1473             : 
    1474           0 : void LineLB::Modify( const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
    1475             : {
    1476           0 :     RemoveEntry( nPos );
    1477             : 
    1478           0 :     if(!rBitmap.IsEmpty())
    1479             :     {
    1480           0 :         InsertEntry( rEntry.GetName(), rBitmap, nPos );
    1481             :     }
    1482             :     else
    1483             :     {
    1484           0 :         InsertEntry( rEntry.GetName(), nPos );
    1485             :     }
    1486           0 : }
    1487             : 
    1488             : // Fills the listbox (provisional) with strings
    1489             : 
    1490           0 : LineEndLB::LineEndLB( Window* pParent, ResId Id )
    1491           0 :     : ListBox( pParent, Id )
    1492             : {
    1493             :     // No EdgeBlending for LineEnds SetEdgeBlending(true);
    1494           0 : }
    1495             : 
    1496           0 : LineEndLB::LineEndLB( Window* pParent, WinBits aWB )
    1497           0 :     : ListBox( pParent, aWB )
    1498             : {
    1499             :     // No EdgeBlending for LineEnds SetEdgeBlending(true);
    1500           0 : }
    1501             : 
    1502           0 : LineEndLB::~LineEndLB(void)
    1503             : {
    1504           0 : }
    1505             : 
    1506           0 : void LineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
    1507             : {
    1508           0 :     if( !pList.is() )
    1509           0 :         return;
    1510             : 
    1511           0 :     long nCount = pList->Count();
    1512             :     XLineEndEntry* pEntry;
    1513           0 :     VirtualDevice aVD;
    1514           0 :     SetUpdateMode( sal_False );
    1515             : 
    1516           0 :     for( long i = 0; i < nCount; i++ )
    1517             :     {
    1518           0 :         pEntry = pList->GetLineEnd( i );
    1519           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1520           0 :         if( !aBitmap.IsEmpty() )
    1521             :         {
    1522           0 :             Size aBmpSize( aBitmap.GetSizePixel() );
    1523           0 :             aVD.SetOutputSizePixel( aBmpSize, sal_False );
    1524           0 :             aVD.DrawBitmap( Point(), aBitmap );
    1525           0 :             InsertEntry( pEntry->GetName(),
    1526           0 :                 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
    1527           0 :                     Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
    1528             :             //delete pBitmap;
    1529             :         }
    1530             :         else
    1531           0 :             InsertEntry( pEntry->GetName() );
    1532           0 :     }
    1533             : 
    1534           0 :     AdaptDropDownLineCountToMaximum();
    1535           0 :     SetUpdateMode( sal_True );
    1536             : }
    1537             : 
    1538             : /************************************************************************/
    1539             : 
    1540           0 : void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart )
    1541             : {
    1542           0 :     if(!rBitmap.IsEmpty())
    1543             :     {
    1544           0 :         VirtualDevice aVD;
    1545           0 :         const Size aBmpSize(rBitmap.GetSizePixel());
    1546             : 
    1547           0 :         aVD.SetOutputSizePixel(aBmpSize, false);
    1548           0 :         aVD.DrawBitmap(Point(), rBitmap);
    1549             :         InsertEntry(
    1550           0 :             rEntry.GetName(),
    1551           0 :             aVD.GetBitmap(bStart ? Point() : Point(aBmpSize.Width() / 2, 0 ), Size(aBmpSize.Width() / 2, aBmpSize.Height())));
    1552             :     }
    1553             :     else
    1554             :     {
    1555           0 :         InsertEntry(rEntry.GetName());
    1556             :     }
    1557             : 
    1558           0 :     AdaptDropDownLineCountToMaximum();
    1559           0 : }
    1560             : 
    1561             : /************************************************************************/
    1562             : 
    1563           0 : void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart )
    1564             : {
    1565           0 :     RemoveEntry( nPos );
    1566             : 
    1567           0 :     if(!rBitmap.IsEmpty())
    1568             :     {
    1569           0 :         VirtualDevice aVD;
    1570           0 :         const Size aBmpSize(rBitmap.GetSizePixel());
    1571             : 
    1572           0 :         aVD.SetOutputSizePixel(aBmpSize, false);
    1573           0 :         aVD.DrawBitmap(Point(), rBitmap);
    1574             :         InsertEntry(
    1575           0 :             rEntry.GetName(),
    1576           0 :             aVD.GetBitmap(bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), Size( aBmpSize.Width() / 2, aBmpSize.Height())),
    1577           0 :             nPos);
    1578             :     }
    1579             :     else
    1580             :     {
    1581           0 :         InsertEntry(rEntry.GetName(), nPos);
    1582             :     }
    1583           0 : }
    1584             : 
    1585             : //////////////////////////////////////////////////////////////////////////////
    1586             : 
    1587           0 : void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
    1588             : {
    1589           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1590             : 
    1591           0 :     if(bForeground)
    1592             :     {
    1593           0 :         svtools::ColorConfig aColorConfig;
    1594           0 :         Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
    1595             : 
    1596           0 :         if(IsControlForeground())
    1597             :         {
    1598           0 :             aTextColor = GetControlForeground();
    1599             :         }
    1600             : 
    1601           0 :         getBufferDevice().SetTextColor(aTextColor);
    1602             :     }
    1603             : 
    1604           0 :     if(bBackground)
    1605             :     {
    1606           0 :         if(IsControlBackground())
    1607             :         {
    1608           0 :             getBufferDevice().SetBackground(GetControlBackground());
    1609             :         }
    1610             :         else
    1611             :         {
    1612           0 :             getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
    1613             :         }
    1614             :     }
    1615             : 
    1616             :     // do not paint background self, it gets painted buffered
    1617           0 :     SetControlBackground();
    1618           0 :     SetBackground();
    1619             : 
    1620           0 :     Invalidate();
    1621           0 : }
    1622             : 
    1623           0 : SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
    1624             : :   Control( pParent, rResId ),
    1625           0 :     mpModel( new SdrModel() ),
    1626           0 :     mpBufferDevice( new VirtualDevice(*this) )
    1627             : {
    1628             :     //  Draw the control's border as a flat thin black line.
    1629           0 :     SetBorderStyle(WINDOW_BORDER_MONO);
    1630           0 :     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
    1631           0 :     SetMapMode(MAP_100TH_MM);
    1632             : 
    1633             :     // init model
    1634           0 :     mpModel->GetItemPool().FreezeIdRanges();
    1635           0 : }
    1636             : 
    1637           0 : SvxPreviewBase::SvxPreviewBase(Window* pParent)
    1638             :     : Control(pParent, WB_BORDER)
    1639           0 :     , mpModel(new SdrModel())
    1640           0 :     , mpBufferDevice(new VirtualDevice(*this))
    1641             : {
    1642             :     //  Draw the control's border as a flat thin black line.
    1643           0 :     SetBorderStyle(WINDOW_BORDER_MONO);
    1644           0 :     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
    1645           0 :     SetMapMode(MAP_100TH_MM);
    1646             : 
    1647             :     // init model
    1648           0 :     mpModel->GetItemPool().FreezeIdRanges();
    1649           0 : }
    1650             : 
    1651           0 : SvxPreviewBase::~SvxPreviewBase()
    1652             : {
    1653           0 :     delete mpModel;
    1654           0 :     delete mpBufferDevice;
    1655           0 : }
    1656             : 
    1657           0 : void SvxPreviewBase::LocalPrePaint()
    1658             : {
    1659             :     // init BufferDevice
    1660           0 :     if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
    1661             :     {
    1662           0 :         mpBufferDevice->SetDrawMode(GetDrawMode());
    1663           0 :         mpBufferDevice->SetSettings(GetSettings());
    1664           0 :         mpBufferDevice->SetAntialiasing(GetAntialiasing());
    1665           0 :         mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
    1666           0 :         mpBufferDevice->SetMapMode(GetMapMode());
    1667             :     }
    1668             : 
    1669           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1670             : 
    1671           0 :     if(rStyleSettings.GetPreviewUsesCheckeredBackground())
    1672             :     {
    1673           0 :         const Point aNull(0, 0);
    1674             :         static const sal_uInt32 nLen(8);
    1675           0 :         static const Color aW(COL_WHITE);
    1676           0 :         static const Color aG(0xef, 0xef, 0xef);
    1677           0 :         const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
    1678             : 
    1679           0 :         mpBufferDevice->EnableMapMode(false);
    1680           0 :         mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG);
    1681           0 :         mpBufferDevice->EnableMapMode(bWasEnabled);
    1682             :     }
    1683             :     else
    1684             :     {
    1685           0 :         mpBufferDevice->Erase();
    1686             :     }
    1687           0 : }
    1688             : 
    1689           0 : void SvxPreviewBase::LocalPostPaint()
    1690             : {
    1691             :     // copy to front (in pixel mode)
    1692           0 :     const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
    1693           0 :     const bool bWasEnabledDst(IsMapModeEnabled());
    1694           0 :     const Point aEmptyPoint;
    1695             : 
    1696           0 :     mpBufferDevice->EnableMapMode(false);
    1697           0 :     EnableMapMode(false);
    1698             : 
    1699             :     DrawOutDev(
    1700           0 :         aEmptyPoint, GetOutputSizePixel(),
    1701           0 :         aEmptyPoint, GetOutputSizePixel(),
    1702           0 :         *mpBufferDevice);
    1703             : 
    1704           0 :     mpBufferDevice->EnableMapMode(bWasEnabledSrc);
    1705           0 :     EnableMapMode(bWasEnabledDst);
    1706           0 : }
    1707             : 
    1708           0 : void SvxPreviewBase::StateChanged(StateChangedType nType)
    1709             : {
    1710           0 :     Control::StateChanged(nType);
    1711             : 
    1712           0 :     if(STATE_CHANGE_CONTROLFOREGROUND == nType)
    1713             :     {
    1714           0 :         InitSettings(true, false);
    1715             :     }
    1716           0 :     else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
    1717             :     {
    1718           0 :         InitSettings(false, true);
    1719             :     }
    1720           0 : }
    1721             : 
    1722           0 : void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
    1723             : {
    1724           0 :     SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
    1725             : 
    1726           0 :     if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
    1727             :     {
    1728           0 :         InitSettings(true, true);
    1729             :     }
    1730             :     else
    1731             :     {
    1732           0 :         Control::DataChanged(rDCEvt);
    1733             :     }
    1734           0 : }
    1735             : 
    1736           0 : SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
    1737             : :   SvxPreviewBase( pParent, rResId ),
    1738             :     mpLineObjA( 0L ),
    1739             :     mpLineObjB( 0L ),
    1740             :     mpLineObjC( 0L ),
    1741             :     mpGraphic( 0L ),
    1742           0 :     mbWithSymbol( sal_False )
    1743             : {
    1744           0 :     const Size aOutputSize(GetOutputSize());
    1745           0 :     InitSettings( sal_True, sal_True );
    1746             : 
    1747           0 :     const sal_Int32 nDistance(500L);
    1748           0 :     const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
    1749             : 
    1750             :     // create DrawObectA
    1751           0 :     const sal_Int32 aYPosA(aOutputSize.Height() / 2);
    1752           0 :     const basegfx::B2DPoint aPointA1( nDistance,  aYPosA);
    1753           0 :     const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
    1754           0 :     basegfx::B2DPolygon aPolygonA;
    1755           0 :     aPolygonA.append(aPointA1);
    1756           0 :     aPolygonA.append(aPointA2);
    1757           0 :     mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
    1758           0 :     mpLineObjA->SetModel(&getModel());
    1759             : 
    1760             :     // create DrawObectB
    1761           0 :     const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
    1762           0 :     const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
    1763           0 :     const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance,  aYPosB1);
    1764           0 :     const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
    1765           0 :     const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
    1766           0 :     basegfx::B2DPolygon aPolygonB;
    1767           0 :     aPolygonB.append(aPointB1);
    1768           0 :     aPolygonB.append(aPointB2);
    1769           0 :     aPolygonB.append(aPointB3);
    1770           0 :     mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
    1771           0 :     mpLineObjB->SetModel(&getModel());
    1772             : 
    1773             :     // create DrawObectC
    1774           0 :     const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance,  aYPosB1);
    1775           0 :     const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
    1776           0 :     const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
    1777           0 :     basegfx::B2DPolygon aPolygonC;
    1778           0 :     aPolygonC.append(aPointC1);
    1779           0 :     aPolygonC.append(aPointC2);
    1780           0 :     aPolygonC.append(aPointC3);
    1781           0 :     mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
    1782           0 :     mpLineObjC->SetModel(&getModel());
    1783           0 : }
    1784             : 
    1785           0 : SvxXLinePreview::~SvxXLinePreview()
    1786             : {
    1787           0 :     SdrObject::Free( mpLineObjA );
    1788           0 :     SdrObject::Free( mpLineObjB );
    1789           0 :     SdrObject::Free( mpLineObjC );
    1790           0 : }
    1791             : 
    1792             : // -----------------------------------------------------------------------
    1793             : 
    1794           0 : void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
    1795             : {
    1796           0 :     mpGraphic = p;
    1797           0 :     maSymbolSize = s;
    1798           0 : }
    1799             : 
    1800             : // -----------------------------------------------------------------------
    1801             : 
    1802           0 : void SvxXLinePreview::ResizeSymbol(const Size& s)
    1803             : {
    1804           0 :     if ( s != maSymbolSize )
    1805             :     {
    1806           0 :         maSymbolSize = s;
    1807           0 :         Invalidate();
    1808             :     }
    1809           0 : }
    1810             : 
    1811             : // -----------------------------------------------------------------------
    1812             : 
    1813           0 : void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
    1814             : {
    1815             :     // Set ItemSet at objects
    1816           0 :     mpLineObjA->SetMergedItemSet(rItemSet);
    1817             : 
    1818             :     // At line joints, do not use arrows
    1819           0 :     SfxItemSet aTempSet(rItemSet);
    1820           0 :     aTempSet.ClearItem(XATTR_LINESTART);
    1821           0 :     aTempSet.ClearItem(XATTR_LINEEND);
    1822             : 
    1823           0 :     mpLineObjB->SetMergedItemSet(aTempSet);
    1824           0 :     mpLineObjC->SetMergedItemSet(aTempSet);
    1825           0 : }
    1826             : 
    1827             : // -----------------------------------------------------------------------
    1828             : 
    1829           0 : void SvxXLinePreview::Paint( const Rectangle& )
    1830             : {
    1831           0 :     LocalPrePaint();
    1832             : 
    1833             :     // paint objects to buffer device
    1834           0 :     sdr::contact::SdrObjectVector aObjectVector;
    1835           0 :     aObjectVector.push_back(mpLineObjA);
    1836           0 :     aObjectVector.push_back(mpLineObjB);
    1837           0 :     aObjectVector.push_back(mpLineObjC);
    1838             : 
    1839           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
    1840           0 :     sdr::contact::DisplayInfo aDisplayInfo;
    1841             : 
    1842             :     // do processing
    1843           0 :     aPainter.ProcessDisplay(aDisplayInfo);
    1844             : 
    1845           0 :     if ( mbWithSymbol && mpGraphic )
    1846             :     {
    1847           0 :         const Size aOutputSize(GetOutputSize());
    1848           0 :         Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
    1849           0 :         aPos.X() -= maSymbolSize.Width() / 2;
    1850           0 :         aPos.Y() -= maSymbolSize.Height() / 2;
    1851           0 :         mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
    1852             :     }
    1853             : 
    1854           0 :     LocalPostPaint();
    1855           0 : }
    1856             : 
    1857           0 : SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
    1858             : :   SvxPreviewBase( pParent, rResId ),
    1859           0 :     mpRectangleObject(0)
    1860             : {
    1861           0 :     InitSettings(true, true);
    1862             : 
    1863             :     // create RectangleObject
    1864           0 :     const Rectangle aObjectSize(Point(), GetOutputSize());
    1865           0 :     mpRectangleObject = new SdrRectObj(aObjectSize);
    1866           0 :     mpRectangleObject->SetModel(&getModel());
    1867           0 : }
    1868             : 
    1869           0 : SvxXRectPreview::SvxXRectPreview(Window* pParent)
    1870             :     : SvxPreviewBase(pParent)
    1871           0 :     , mpRectangleObject(0)
    1872             : {
    1873           0 :     InitSettings(true, true);
    1874             : 
    1875             :     // create RectangleObject
    1876           0 :     const Rectangle aObjectSize(Point(), GetOutputSize());
    1877           0 :     mpRectangleObject = new SdrRectObj(aObjectSize);
    1878           0 :     mpRectangleObject->SetModel(&getModel());
    1879           0 : }
    1880             : 
    1881           0 : void SvxXRectPreview::Resize()
    1882             : {
    1883           0 :     const Rectangle aObjectSize(Point(), GetOutputSize());
    1884           0 :     SdrObject *pOrigObject = mpRectangleObject;
    1885           0 :     if (pOrigObject)
    1886             :     {
    1887           0 :         mpRectangleObject = new SdrRectObj(aObjectSize);
    1888           0 :         mpRectangleObject->SetModel(&getModel());
    1889           0 :         SetAttributes(pOrigObject->GetMergedItemSet());
    1890           0 :         SdrObject::Free(pOrigObject);
    1891             :     }
    1892           0 :     SvxPreviewBase::Resize();
    1893           0 : }
    1894             : 
    1895           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxXRectPreview(Window *pParent, VclBuilder::stringmap &)
    1896             : {
    1897           0 :     return new SvxXRectPreview(pParent);
    1898             : }
    1899             : 
    1900           0 : SvxXRectPreview::~SvxXRectPreview()
    1901             : {
    1902           0 :     SdrObject::Free(mpRectangleObject);
    1903           0 : }
    1904             : 
    1905           0 : void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
    1906             : {
    1907           0 :     mpRectangleObject->SetMergedItemSet(rItemSet, true);
    1908           0 :     mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
    1909           0 : }
    1910             : 
    1911           0 : void SvxXRectPreview::Paint( const Rectangle& )
    1912             : {
    1913           0 :     LocalPrePaint();
    1914             : 
    1915           0 :     sdr::contact::SdrObjectVector aObjectVector;
    1916             : 
    1917           0 :     aObjectVector.push_back(mpRectangleObject);
    1918             : 
    1919           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
    1920           0 :     sdr::contact::DisplayInfo aDisplayInfo;
    1921             : 
    1922           0 :     aPainter.ProcessDisplay(aDisplayInfo);
    1923             : 
    1924           0 :     LocalPostPaint();
    1925           0 : }
    1926             : 
    1927           0 : SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
    1928             : :   SvxPreviewBase( pParent, rResId ),
    1929             :     mpRectangleObject(0),
    1930           0 :     mpRectangleShadow(0)
    1931             : {
    1932           0 :     InitSettings(true, true);
    1933             : 
    1934             :     // prepare size
    1935           0 :     Size aSize = GetOutputSize();
    1936           0 :     aSize.Width() = aSize.Width() / 3;
    1937           0 :     aSize.Height() = aSize.Height() / 3;
    1938             : 
    1939             :     // create RectangleObject
    1940           0 :     const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
    1941           0 :     mpRectangleObject = new SdrRectObj(aObjectSize);
    1942           0 :     mpRectangleObject->SetModel(&getModel());
    1943             : 
    1944             :     // create ShadowObject
    1945           0 :     const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
    1946           0 :     mpRectangleShadow = new SdrRectObj(aShadowSize);
    1947           0 :     mpRectangleShadow->SetModel(&getModel());
    1948           0 : }
    1949             : 
    1950           0 : SvxXShadowPreview::~SvxXShadowPreview()
    1951             : {
    1952           0 :     SdrObject::Free(mpRectangleObject);
    1953           0 :     SdrObject::Free(mpRectangleShadow);
    1954           0 : }
    1955             : 
    1956           0 : void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
    1957             : {
    1958           0 :     mpRectangleObject->SetMergedItemSet(rItemSet, true);
    1959           0 :     mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
    1960           0 : }
    1961             : 
    1962           0 : void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
    1963             : {
    1964           0 :     mpRectangleShadow->SetMergedItemSet(rItemSet, true);
    1965           0 :     mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
    1966           0 : }
    1967             : 
    1968           0 : void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
    1969             : {
    1970           0 :     Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
    1971           0 :     aObjectPosition.Move(rPos.X(), rPos.Y());
    1972           0 :     mpRectangleShadow->SetSnapRect(aObjectPosition);
    1973           0 : }
    1974             : 
    1975           0 : void SvxXShadowPreview::Paint( const Rectangle& )
    1976             : {
    1977           0 :     LocalPrePaint();
    1978             : 
    1979           0 :     sdr::contact::SdrObjectVector aObjectVector;
    1980             : 
    1981           0 :     aObjectVector.push_back(mpRectangleShadow);
    1982           0 :     aObjectVector.push_back(mpRectangleObject);
    1983             : 
    1984           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
    1985           0 :     sdr::contact::DisplayInfo aDisplayInfo;
    1986             : 
    1987           0 :     aPainter.ProcessDisplay(aDisplayInfo);
    1988             : 
    1989           0 :     LocalPostPaint();
    1990         216 : }
    1991             : 
    1992             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10