LCOV - code coverage report
Current view: top level - svx/source/dialog - dlgctrl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 55 1166 4.7 %
Date: 2014-04-11 Functions: 9 135 6.7 %
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             : #include <vcl/settings.hxx>
      24             : #include <sfx2/dialoghelper.hxx>
      25             : #include <svx/xtable.hxx>
      26             : #include <svx/xpool.hxx>
      27             : #include <svx/dialogs.hrc>
      28             : #include <accessibility.hrc>
      29             : #include <svx/dlgctrl.hxx>
      30             : #include <svx/dialmgr.hxx>
      31             : #include <tools/poly.hxx>
      32             : #include <vcl/region.hxx>
      33             : #include <vcl/gradient.hxx>
      34             : #include <vcl/hatch.hxx>
      35             : #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
      36             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      37             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      38             : #include "svxpixelctlaccessiblecontext.hxx"
      39             : #include <svtools/colorcfg.hxx>
      40             : #include <svxrectctaccessiblecontext.hxx>
      41             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      42             : #include <basegfx/point/b2dpoint.hxx>
      43             : #include <basegfx/polygon/b2dpolygon.hxx>
      44             : #include <svx/svdorect.hxx>
      45             : #include <svx/svdmodel.hxx>
      46             : #include <svx/svdopath.hxx>
      47             : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      48             : #include <svx/sdr/contact/displayinfo.hxx>
      49             : #include <vcl/bmpacc.hxx>
      50             : #include <svx/xbtmpit.hxx>
      51             : 
      52             : #define OUTPUT_DRAWMODE_COLOR       (DRAWMODE_DEFAULT)
      53             : #define OUTPUT_DRAWMODE_CONTRAST    (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
      54             : 
      55             : using namespace ::com::sun::star::uno;
      56             : using namespace ::com::sun::star::lang;
      57             : using namespace ::com::sun::star::accessibility;
      58             : 
      59             : // Control for display and selection of the corner points and
      60             : // mid point of an object
      61             : 
      62           0 : Bitmap& SvxRectCtl::GetRectBitmap( void )
      63             : {
      64           0 :     if( !pBitmap )
      65           0 :         InitRectBitmap();
      66             : 
      67           0 :     return *pBitmap;
      68             : }
      69             : 
      70           0 : SvxRectCtl::SvxRectCtl(Window* pParent, RECT_POINT eRpt,
      71             :     sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle)
      72             :     : Control(pParent, WB_BORDER | WB_TABSTOP)
      73             :     , pAccContext(NULL)
      74             :     , nBorderWidth(nBorder)
      75             :     , nRadius(nCircle)
      76             :     , eDefRP(eRpt)
      77             :     , eCS(eStyle)
      78             :     , pBitmap(NULL)
      79             :     , m_nState(0)
      80           0 :     , mbCompleteDisable(false)
      81             : {
      82           0 :     SetMapMode(MAP_100TH_MM);
      83           0 :     Resize_Impl();
      84           0 : }
      85             : 
      86           0 : void SvxRectCtl::SetControlSettings(RECT_POINT eRpt, sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle)
      87             : {
      88           0 :     nBorderWidth = nBorder;
      89           0 :     nRadius = nCircle;
      90           0 :     eDefRP = eRpt;
      91           0 :     eCS = eStyle;
      92           0 :     Resize_Impl();
      93           0 : }
      94             : 
      95           0 : Size SvxRectCtl::GetOptimalSize() const
      96             : {
      97           0 :     return LogicToPixel(Size(78, 39), MAP_APPFONT);
      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( true, 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( bool bForeground, 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 :             Window *pTabPage = getNonLayoutParent(this);
     362           0 :             if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
     363           0 :                 ((SvxTabPage*) pTabPage)->PointChanged(this, eRP);
     364             : 
     365           0 :             SetFocusRect();
     366             :         }
     367             :     }
     368             : }
     369             : 
     370             : 
     371             : 
     372           0 : void SvxRectCtl::StateChanged( StateChangedType nType )
     373             : {
     374           0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     375           0 :         InitSettings( true, false );
     376           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     377           0 :         InitSettings( false, true );
     378             : 
     379           0 :     Window::StateChanged( nType );
     380           0 : }
     381             : 
     382             : 
     383             : 
     384           0 : void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
     385             : {
     386           0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
     387           0 :         InitSettings( true, true );
     388             :     else
     389           0 :         Window::DataChanged( rDCEvt );
     390           0 : }
     391             : 
     392             : // the control (rectangle with 9 circles)
     393             : 
     394           0 : void SvxRectCtl::Paint( const Rectangle& )
     395             : {
     396           0 :     Point   aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
     397             : 
     398           0 :     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     399             : 
     400           0 :     SetLineColor( rStyles.GetDialogColor() );
     401           0 :     SetFillColor( rStyles.GetDialogColor() );
     402           0 :     DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
     403             : 
     404           0 :     if( IsEnabled() )
     405           0 :         SetLineColor( rStyles.GetLabelTextColor() );
     406             :     else
     407           0 :         SetLineColor( rStyles.GetShadowColor() );
     408             : 
     409           0 :     SetFillColor();
     410             : 
     411           0 :     switch( eCS )
     412             :     {
     413             : 
     414             :         case CS_RECT:
     415             :         case CS_SHADOW:
     416           0 :             if( !IsEnabled() )
     417             :             {
     418           0 :                 Color aOldCol = GetLineColor();
     419           0 :                 SetLineColor( rStyles.GetLightColor() );
     420           0 :                 DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
     421           0 :                 SetLineColor( aOldCol );
     422             :             }
     423           0 :             DrawRect( Rectangle( aPtLT, aPtRB ) );
     424           0 :         break;
     425             : 
     426             :         case CS_LINE:
     427           0 :             if( !IsEnabled() )
     428             :             {
     429           0 :                 Color aOldCol = GetLineColor();
     430           0 :                 SetLineColor( rStyles.GetLightColor() );
     431           0 :                 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
     432           0 :                           aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
     433           0 :                 SetLineColor( aOldCol );
     434             :             }
     435           0 :             DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
     436           0 :                       aPtRM + Point( 2 * nBorderWidth, 0 ) );
     437           0 :         break;
     438             : 
     439             :         case CS_ANGLE:
     440           0 :             if( !IsEnabled() )
     441             :             {
     442           0 :                 Color aOldCol = GetLineColor();
     443           0 :                 SetLineColor( rStyles.GetLightColor() );
     444           0 :                 DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
     445           0 :                 DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
     446           0 :                 DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
     447           0 :                 DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
     448           0 :                 SetLineColor( aOldCol );
     449             :             }
     450           0 :             DrawLine( aPtLT, aPtRB );
     451           0 :             DrawLine( aPtLB, aPtRT );
     452           0 :             DrawLine( aPtLM, aPtRM );
     453           0 :             DrawLine( aPtMT, aPtMB );
     454           0 :         break;
     455             : 
     456             :         default:
     457           0 :             break;
     458             :     }
     459           0 :     SetFillColor( GetBackground().GetColor() );
     460             : 
     461           0 :     Size aBtnSize( 11, 11 );
     462           0 :     Size aDstBtnSize(  PixelToLogic( aBtnSize ) );
     463           0 :     Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
     464           0 :     Point aBtnPnt1( IsEnabled()?0:22,0 );
     465           0 :     Point aBtnPnt2( 11,0 );
     466           0 :     Point aBtnPnt3( 22,0 );
     467             : 
     468           0 :     bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
     469           0 :     bool bNoVert = (m_nState & CS_NOVERT) != 0;
     470             : 
     471           0 :     Bitmap&         rBitmap = GetRectBitmap();
     472             : 
     473             :     // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     474           0 :     if(IsCompletelyDisabled())
     475             :     {
     476           0 :         DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     477           0 :         DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     478           0 :         DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     479           0 :         DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     480           0 :         if( eCS == CS_RECT || eCS == CS_LINE )
     481           0 :             DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     482           0 :         DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     483           0 :         DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     484           0 :         DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     485           0 :         DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
     486             :     }
     487             :     else
     488             :     {
     489           0 :         DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     490           0 :         DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     491           0 :         DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     492             : 
     493           0 :         DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     494             : 
     495             :         // Center for rectangle and line
     496           0 :         if( eCS == CS_RECT || eCS == CS_LINE )
     497           0 :             DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
     498             : 
     499           0 :         DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     500             : 
     501           0 :         DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     502           0 :         DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     503           0 :         DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
     504             :     }
     505             : 
     506             :     // draw active button, avoid center pos for angle
     507             :     // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     508           0 :     if(!IsCompletelyDisabled())
     509             :     {
     510           0 :         if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
     511             :         {
     512           0 :             Point       aCenterPt( aPtNew );
     513           0 :             aCenterPt -= aToCenter;
     514             : 
     515           0 :             DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
     516             :         }
     517             :     }
     518           0 : }
     519             : 
     520             : // Convert RECT_POINT Point
     521             : 
     522           0 : Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
     523             : {
     524           0 :     switch( _eRP )
     525             :     {
     526           0 :         case RP_LT: return aPtLT;
     527           0 :         case RP_MT: return aPtMT;
     528           0 :         case RP_RT: return aPtRT;
     529           0 :         case RP_LM: return aPtLM;
     530           0 :         case RP_MM: return aPtMM;
     531           0 :         case RP_RM: return aPtRM;
     532           0 :         case RP_LB: return aPtLB;
     533           0 :         case RP_MB: return aPtMB;
     534           0 :         case RP_RB: return aPtRB;
     535             :     }
     536           0 :     return( aPtMM ); // default
     537             : }
     538             : 
     539             : 
     540           0 : void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
     541             : {
     542           0 :     HideFocus();
     543             : 
     544           0 :     if( pRect )
     545           0 :         ShowFocus( *pRect );
     546             :     else
     547           0 :         ShowFocus( CalculateFocusRectangle() );
     548           0 : }
     549             : 
     550           0 : Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
     551             : {
     552           0 :     Point aPtLast = aPtNew;
     553           0 :     aPtNew = GetPointFromRP( eNewRP );
     554             : 
     555           0 :     if( (m_nState & CS_NOHORZ) != 0 )
     556           0 :         aPtNew.X() = aPtMM.X();
     557             : 
     558           0 :     if( (m_nState & CS_NOVERT) != 0 )
     559           0 :         aPtNew.Y() = aPtMM.Y();
     560             : 
     561             :     // fdo#74751 this fix reverse base point on RTL UI.
     562           0 :     bool bRTL = Application::GetSettings().GetLayoutRTL();
     563           0 :     eNewRP = GetRPFromPoint( aPtNew, bRTL );
     564             : 
     565           0 :     eDefRP = eNewRP;
     566           0 :     eRP = eNewRP;
     567             : 
     568           0 :     return aPtLast;
     569             : }
     570             : 
     571           0 : void SvxRectCtl::GetFocus()
     572             : {
     573           0 :     SetFocusRect();
     574             :     // Send the accessible focused event
     575           0 :     Control::GetFocus();
     576             :     // Send accessibility event.
     577           0 :     if(pAccContext)
     578             :     {
     579           0 :         pAccContext->FireChildFocus(GetActualRP());
     580             :     }
     581           0 : }
     582             : 
     583             : 
     584           0 : void SvxRectCtl::LoseFocus()
     585             : {
     586           0 :     HideFocus();
     587           0 : }
     588             : 
     589             : 
     590           0 : Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
     591             : {
     592           0 :     Point   aPt = PixelToLogic( rPt );
     593             :     long    x;
     594             :     long    y;
     595             : 
     596           0 :     if( ( m_nState & CS_NOHORZ ) == 0 )
     597             :     {
     598           0 :         if( aPt.X() < aSize.Width() / 3 )
     599           0 :             x = aPtLT.X();
     600           0 :         else if( aPt.X() < aSize.Width() * 2 / 3 )
     601           0 :             x = aPtMM.X();
     602             :         else
     603           0 :             x = aPtRB.X();
     604             :     }
     605             :     else
     606           0 :         x = aPtMM.X();
     607             : 
     608           0 :     if( ( m_nState & CS_NOVERT ) == 0 )
     609             :     {
     610           0 :         if( aPt.Y() < aSize.Height() / 3 )
     611           0 :             y = aPtLT.Y();
     612           0 :         else if( aPt.Y() < aSize.Height() * 2 / 3 )
     613           0 :             y = aPtMM.Y();
     614             :         else
     615           0 :             y = aPtRB.Y();
     616             :     }
     617             :     else
     618           0 :             y = aPtMM.Y();
     619             : 
     620           0 :     return Point( x, y );
     621             : }
     622             : 
     623             : 
     624             : // Converts Point in RECT_POINT
     625             : 
     626           0 : RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt, bool bRTL ) const
     627             : {
     628           0 :     RECT_POINT rPoint = RP_MM;  // default
     629             : 
     630           0 :     if     ( aPt == aPtLT) rPoint = bRTL ? RP_RT : RP_LT;
     631           0 :     else if( aPt == aPtMT) rPoint = RP_MT;
     632           0 :     else if( aPt == aPtRT) rPoint = bRTL ? RP_LT : RP_RT;
     633           0 :     else if( aPt == aPtLM) rPoint = bRTL ? RP_RM : RP_LM;
     634           0 :     else if( aPt == aPtRM) rPoint = bRTL ? RP_LM : RP_RM;
     635           0 :     else if( aPt == aPtLB) rPoint = bRTL ? RP_RB : RP_LB;
     636           0 :     else if( aPt == aPtMB) rPoint = RP_MB;
     637           0 :     else if( aPt == aPtRB) rPoint = bRTL ? RP_LB : RP_RB;
     638             : 
     639           0 :     return rPoint;
     640             : }
     641             : 
     642             : // Resets to the original state of the control
     643             : 
     644           0 : void SvxRectCtl::Reset()
     645             : {
     646           0 :     aPtNew = GetPointFromRP( eDefRP );
     647           0 :     eRP = eDefRP;
     648           0 :     Invalidate();
     649           0 : }
     650             : 
     651             : // Returns the currently selected RECT_POINT
     652             : 
     653           0 : RECT_POINT SvxRectCtl::GetActualRP() const
     654             : {
     655           0 :     return( eRP );
     656             : }
     657             : 
     658           0 : void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
     659             : {
     660           0 :     Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
     661             : 
     662           0 :     Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
     663           0 :     Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
     664             : 
     665             :     // notify accessibility object about change
     666           0 :     if( pAccContext )
     667           0 :         pAccContext->selectChild( eNewRP /* MT, bFireFocus */ );
     668           0 : }
     669             : 
     670           0 : void SvxRectCtl::SetState( CTL_STATE nState )
     671             : {
     672           0 :     m_nState = nState;
     673             : 
     674           0 :     Point aPtLast( GetPointFromRP( eRP ) );
     675           0 :     Point _aPtNew( aPtLast );
     676             : 
     677           0 :     if( (m_nState & CS_NOHORZ) != 0 )
     678           0 :         _aPtNew.X() = aPtMM.X();
     679             : 
     680           0 :     if( (m_nState & CS_NOVERT) != 0 )
     681           0 :         _aPtNew.Y() = aPtMM.Y();
     682             : 
     683           0 :     eRP = GetRPFromPoint( _aPtNew );
     684           0 :     Invalidate();
     685             : 
     686           0 :     Window *pTabPage = getNonLayoutParent(this);
     687           0 :     if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
     688           0 :         ((SvxTabPage*)pTabPage)->PointChanged(this, eRP);
     689           0 : }
     690             : 
     691           0 : sal_uInt8 SvxRectCtl::GetNumOfChildren( void ) const
     692             : {
     693           0 :     return ( eCS == CS_ANGLE )? 8 : 9;
     694             : }
     695             : 
     696           0 : Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
     697             : {
     698           0 :     Size        aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
     699           0 :     return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
     700             : }
     701             : 
     702           0 : Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
     703             : {
     704           0 :     Rectangle   aRet;
     705           0 :     RECT_POINT  eOldRectPoint = GetActualRP();
     706             : 
     707           0 :     if( eOldRectPoint == eRectPoint )
     708           0 :         aRet = CalculateFocusRectangle();
     709             :     else
     710             :     {
     711           0 :         SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
     712             : 
     713           0 :         pThis->SetActualRPWithoutInvalidate( eRectPoint );      // no invalidation because it's only temporary!
     714           0 :         aRet = CalculateFocusRectangle();
     715             : 
     716           0 :         pThis->SetActualRPWithoutInvalidate( eOldRectPoint );   // no invalidation because nothing has changed!
     717             :     }
     718             : 
     719           0 :     return aRet;
     720             : }
     721             : 
     722           0 : Reference< XAccessible > SvxRectCtl::CreateAccessible()
     723             : {
     724           0 :     Window*                     pParent = GetAccessibleParentWindow();
     725             : 
     726             :     DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
     727             : 
     728           0 :     Reference< XAccessible >    xAccParent  = pParent->GetAccessible();
     729           0 :     if( xAccParent.is() )
     730             :     {
     731           0 :         pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
     732           0 :         pAccContext->acquire();
     733             : 
     734           0 :         SetActualRP( GetActualRP() );
     735             : 
     736           0 :         return pAccContext;
     737             :     }
     738             :     else
     739           0 :         return Reference< XAccessible >();
     740             : }
     741             : 
     742           0 : RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
     743             : {
     744           0 :     return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
     745             : }
     746             : 
     747             : // CompletelyDisabled() added to have a disabled state for SvxRectCtl
     748           0 : void SvxRectCtl::DoCompletelyDisable(bool bNew)
     749             : {
     750           0 :     mbCompleteDisable = bNew;
     751           0 :     Invalidate();
     752           0 : }
     753             : 
     754           0 : void SvxRectCtl::SetCS(CTL_STYLE eNew)
     755             : {
     756           0 :     eCS = eNew;
     757           0 : }
     758             : 
     759             : // Control for editing bitmaps
     760             : 
     761           0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SvxPixelCtl::CreateAccessible()
     762             : {
     763           0 :     if(!m_xAccess.is())
     764             :     {
     765           0 :         m_xAccess = m_pAccess =  new SvxPixelCtlAccessible(*this);
     766             :     }
     767           0 :     return m_xAccess;
     768             : }
     769             : 
     770             : //Logic Pixel
     771           0 : long SvxPixelCtl::PointToIndex(const Point &aPt) const
     772             : {
     773           0 :     sal_Int32 nX = aPt.X() * nLines / aRectSize.Width();
     774           0 :     sal_Int32 nY = aPt.Y() * nLines / aRectSize.Height();
     775             : 
     776           0 :     return nX + nY * nLines ;
     777             : }
     778             : 
     779           0 : Point SvxPixelCtl::IndexToPoint(long nIndex) const
     780             : {
     781             :     DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index");
     782             : 
     783           0 :     sal_Int32 nXIndex = nIndex % nLines;
     784           0 :     sal_Int32 nYIndex = nIndex / nLines;
     785             : 
     786           0 :     Point aPtTl;
     787           0 :     aPtTl.Y() = aRectSize.Height() * nYIndex / nLines + 1;
     788           0 :     aPtTl.X() = aRectSize.Width() * nXIndex / nLines + 1;
     789             : 
     790           0 :     return aPtTl;
     791             : }
     792             : 
     793           0 : long SvxPixelCtl::GetFoucsPosIndex() const
     794             : {
     795           0 :     return aFocusPosition.getX() + aFocusPosition.getY() * nLines ;
     796             : }
     797             : 
     798           0 : long SvxPixelCtl::ShowPosition( const Point &pt)
     799             : {
     800           0 :     Point aPt = PixelToLogic( pt );
     801             : 
     802           0 :     sal_Int32 nX = aPt.X() * nLines / aRectSize.Width();
     803           0 :     sal_Int32 nY = aPt.Y() * nLines / aRectSize.Height();
     804             : 
     805           0 :     ChangePixel( nX + nY * nLines );
     806             : 
     807             :     //Solution:Set new focus position and repaint
     808             :     //Invalidate( Rectangle( aPtTl, aPtBr ) );
     809           0 :     aFocusPosition.setX(nX);
     810           0 :     aFocusPosition.setY(nY);
     811           0 :     Invalidate(Rectangle(Point(0,0),aRectSize));
     812             : 
     813           0 :     Window *pTabPage = getNonLayoutParent(this);
     814           0 :     if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
     815           0 :         ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
     816             : 
     817           0 :     return GetFoucsPosIndex();
     818             : 
     819             : }
     820             : 
     821           0 : SvxPixelCtl::SvxPixelCtl(Window* pParent, sal_uInt16 nNumber)
     822             :     : Control(pParent, WB_BORDER)
     823             :     , nLines(nNumber)
     824             :     , bPaintable(true)
     825           0 :     , aFocusPosition(0,0)
     826             : {
     827           0 :     SetPixelColor( Color( COL_BLACK ) );
     828           0 :     SetBackgroundColor( Color( COL_WHITE ) );
     829           0 :     SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
     830             : 
     831           0 :     nSquares = nLines * nLines;
     832           0 :     pPixel = new sal_uInt16[ nSquares ];
     833           0 :     memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
     834           0 :     m_pAccess=NULL;
     835           0 : }
     836             : 
     837           0 : void SvxPixelCtl::Resize()
     838             : {
     839           0 :     Control::Resize();
     840           0 :     aRectSize = GetOutputSize();
     841           0 : }
     842             : 
     843           0 : Size SvxPixelCtl::GetOptimalSize() const
     844             : {
     845           0 :     return LogicToPixel(Size(72, 72), MAP_APPFONT);
     846             : }
     847             : 
     848           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxPixelCtl(Window *pParent, VclBuilder::stringmap&)
     849             : {
     850           0 :     return new SvxPixelCtl(pParent, 8);
     851             : }
     852             : // Destructor dealocating the dynamic array
     853             : 
     854           0 : SvxPixelCtl::~SvxPixelCtl( )
     855             : {
     856           0 :     delete []pPixel;
     857           0 : }
     858             : 
     859             : // Changes the foreground or Background color
     860             : 
     861           0 : void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
     862             : {
     863           0 :     if( *( pPixel + nPixel) == 0 )
     864           0 :         *( pPixel + nPixel) = 1; //  could be extended to more colors
     865             :     else
     866           0 :         *( pPixel + nPixel) = 0;
     867           0 : }
     868             : 
     869             : // The clicked rectangle is identified, to change its color
     870             : 
     871           0 : void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
     872             : {
     873           0 :     if (!aRectSize.Width() || !aRectSize.Height())
     874           0 :         return;
     875             : 
     876             :     //Grab focus when click in window
     877           0 :     if (!HasFocus())
     878             :     {
     879           0 :         GrabFocus();
     880             :     }
     881             : 
     882           0 :     long nIndex = ShowPosition(rMEvt.GetPosPixel());
     883             : 
     884           0 :     if(m_pAccess)
     885             :     {
     886           0 :         m_pAccess->NotifyChild(nIndex,sal_True, sal_True);
     887             :     }
     888             : }
     889             : 
     890             : // Draws the Control (Rectangle with nine circles)
     891             : 
     892           0 : void SvxPixelCtl::Paint( const Rectangle& )
     893             : {
     894           0 :     if (!aRectSize.Width() || !aRectSize.Height())
     895           0 :         return;
     896             : 
     897             :     sal_uInt16  i, j, nTmp;
     898           0 :     Point   aPtTl, aPtBr;
     899             : 
     900           0 :     if( bPaintable )
     901             :     {
     902             :         // Draw lines
     903           0 :         Control::SetLineColor( aLineColor );
     904           0 :         for( i = 1; i < nLines; i++)
     905             :         {
     906             :             // horizontal
     907           0 :             nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
     908           0 :             DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
     909             :             // vertically
     910           0 :             nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
     911           0 :             DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
     912             :         }
     913             : 
     914             :         //Draw Rectangles (squares)
     915           0 :         Control::SetLineColor();
     916           0 :         sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
     917             : 
     918           0 :         for( i = 0; i < nLines; i++)
     919             :         {
     920           0 :             aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
     921           0 :             aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
     922             : 
     923           0 :             for( j = 0; j < nLines; j++)
     924             :             {
     925           0 :                 aPtTl.X() = aRectSize.Width() * j / nLines + 1;
     926           0 :                 aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
     927             : 
     928           0 :                 if ( *( pPixel + i * nLines + j ) != nLastPixel )
     929             :                 {
     930           0 :                     nLastPixel = *( pPixel + i * nLines + j );
     931             :                     // Change color: 0 -> Background color
     932           0 :                     SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
     933             :                 }
     934           0 :                 DrawRect( Rectangle( aPtTl, aPtBr ) );
     935             :             }
     936             :         }
     937             :         //Draw visual focus when has focus
     938           0 :         if( HasFocus() )
     939             :         {
     940           0 :             ShowFocus(implCalFocusRect(aFocusPosition));
     941             :         }
     942             :     } // bPaintable
     943             :     else
     944             :     {
     945           0 :         SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
     946           0 :         Control::SetLineColor( Color( COL_LIGHTRED ) );
     947           0 :         DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
     948           0 :         DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
     949             :     }
     950             : }
     951             : 
     952             : //Calculate visual focus rectangle via focus position
     953           0 : Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition )
     954             : {
     955             :     long nLeft,nTop,nRight,nBottom;
     956             :     long i,j;
     957           0 :     i = aPosition.Y();
     958           0 :     j = aPosition.X();
     959           0 :     nLeft = aRectSize.Width() * j / nLines + 1;
     960           0 :     nRight = aRectSize.Width() * (j + 1) / nLines - 1;
     961           0 :     nTop = aRectSize.Height() * i / nLines + 1;
     962           0 :     nBottom = aRectSize.Height() * (i + 1) / nLines - 1;
     963           0 :     return Rectangle(nLeft,nTop,nRight,nBottom);
     964             : }
     965             : 
     966             : //Solution:Keyboard fucntion
     967           0 : void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt )
     968             : {
     969           0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
     970           0 :     sal_uInt16 nCode = aKeyCode.GetCode();
     971           0 :     sal_Bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2();
     972             : 
     973           0 :     if( !bIsMod )
     974             :     {
     975           0 :         Point pRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1,
     976           0 :                              aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1
     977           0 :                             );
     978           0 :         Size  mRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2);
     979           0 :         Rectangle mRepaintRect( pRepaintPoint, mRepaintSize );
     980           0 :         sal_Bool bFocusPosChanged=sal_False;
     981           0 :         switch(nCode)
     982             :         {
     983             :             case KEY_LEFT:
     984           0 :                 if((aFocusPosition.getX() >= 1))
     985             :                 {
     986           0 :                     aFocusPosition.setX( aFocusPosition.getX() - 1 );
     987           0 :                     Invalidate(mRepaintRect);
     988           0 :                     bFocusPosChanged=sal_True;
     989             :                 }
     990           0 :                 break;
     991             :             case KEY_RIGHT:
     992           0 :                 if( aFocusPosition.getX() < (nLines - 1) )
     993             :                 {
     994           0 :                     aFocusPosition.setX( aFocusPosition.getX() + 1 );
     995           0 :                     Invalidate(mRepaintRect);
     996           0 :                     bFocusPosChanged=sal_True;
     997             :                 }
     998           0 :                 break;
     999             :             case KEY_UP:
    1000           0 :                 if((aFocusPosition.getY() >= 1))
    1001             :                 {
    1002           0 :                     aFocusPosition.setY( aFocusPosition.getY() - 1 );
    1003           0 :                     Invalidate(mRepaintRect);
    1004           0 :                     bFocusPosChanged=sal_True;
    1005             :                 }
    1006           0 :                 break;
    1007             :             case KEY_DOWN:
    1008           0 :                 if( aFocusPosition.getY() < ( nLines - 1 ) )
    1009             :                 {
    1010           0 :                     aFocusPosition.setY( aFocusPosition.getY() + 1 );
    1011           0 :                     Invalidate(mRepaintRect);
    1012           0 :                     bFocusPosChanged=sal_True;
    1013             :                 }
    1014           0 :                 break;
    1015             :             case KEY_SPACE:
    1016           0 :                 ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) );
    1017           0 :                 Invalidate( implCalFocusRect(aFocusPosition) );
    1018           0 :                 break;
    1019             :             default:
    1020           0 :                 Control::KeyInput( rKEvt );
    1021           0 :                 return;
    1022             :         }
    1023           0 :         if(m_xAccess.is())
    1024             :         {
    1025           0 :             long nIndex = GetFoucsPosIndex();
    1026           0 :             switch(nCode)
    1027             :             {
    1028             :             case KEY_LEFT:
    1029             :             case KEY_RIGHT:
    1030             :             case KEY_UP:
    1031             :             case KEY_DOWN:
    1032           0 :                 if (bFocusPosChanged)
    1033             :                 {
    1034           0 :                     m_pAccess->NotifyChild(nIndex,sal_False,sal_False);
    1035             :                 }
    1036           0 :                 break;
    1037             :             case KEY_SPACE:
    1038           0 :                 m_pAccess->NotifyChild(nIndex,sal_False,sal_True);
    1039           0 :                 break;
    1040             :             default:
    1041           0 :                 break;
    1042             :             }
    1043             :         }
    1044             :     }
    1045             :     else
    1046             :     {
    1047           0 :         Control::KeyInput( rKEvt );
    1048             :     }
    1049             : }
    1050             : 
    1051             : //Draw focus when get focus
    1052           0 : void SvxPixelCtl::GetFocus()
    1053             : {
    1054           0 :     Invalidate(implCalFocusRect(aFocusPosition));
    1055             : 
    1056           0 :     if(m_pAccess)
    1057             :     {
    1058           0 :         m_pAccess->NotifyChild(GetFoucsPosIndex(),sal_True,sal_False);
    1059             :     }
    1060             : 
    1061           0 :     Control::GetFocus();
    1062           0 : }
    1063             : 
    1064             : //Hide focus when lose focus
    1065           0 : void SvxPixelCtl::LoseFocus()
    1066             : {
    1067           0 :     HideFocus();
    1068           0 :     if (m_pAccess)
    1069             :     {
    1070           0 :         m_pAccess->LoseFocus();
    1071             :     }
    1072           0 :     Control::LoseFocus();
    1073           0 : }
    1074             : 
    1075           0 : void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx )
    1076             : {
    1077           0 :     BitmapColor aBack;
    1078           0 :     BitmapColor aFront;
    1079             : 
    1080           0 :     if(isHistorical8x8(rBitmapEx, aBack, aFront))
    1081             :     {
    1082           0 :         Bitmap aBitmap(rBitmapEx.GetBitmap());
    1083           0 :         BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
    1084             : 
    1085           0 :         aBackgroundColor = aBack;
    1086           0 :         aPixelColor = aFront;
    1087             : 
    1088           0 :         for(sal_uInt16 i(0); i < nSquares; i++)
    1089             :         {
    1090           0 :             const BitmapColor aColor(pRead->GetColor(i/8, i%8));
    1091             : 
    1092           0 :             if(aColor == aBack)
    1093             :             {
    1094           0 :                 *( pPixel + i ) = 0;
    1095             :             }
    1096             :             else
    1097             :             {
    1098           0 :                 *( pPixel + i ) = 1;
    1099             :             }
    1100           0 :         }
    1101             : 
    1102           0 :         aBitmap.ReleaseAccess(pRead);
    1103           0 :     }
    1104           0 : }
    1105             : 
    1106             : // Returns a specific pixel
    1107             : 
    1108           0 : sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel )
    1109             : {
    1110           0 :     return( *( pPixel + nPixel ) );
    1111             : }
    1112             : 
    1113             : // Resets to the original state of the control
    1114             : 
    1115           0 : void SvxPixelCtl::Reset()
    1116             : {
    1117             :     // clear pixel area
    1118           0 :     memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
    1119           0 :     Invalidate();
    1120           0 : }
    1121             : 
    1122             : // Constructor: BitmapCtl for SvxPixelCtl
    1123             : 
    1124           0 : SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
    1125             :     : aSize(rSize)
    1126             :     , nLines(0)
    1127           0 :     , pBmpArray(NULL)
    1128             : {
    1129           0 : }
    1130             : 
    1131           0 : SvxBitmapCtl::~SvxBitmapCtl()
    1132             : {
    1133           0 : }
    1134             : 
    1135             : // BitmapCtl: Returns the Bitmap
    1136             : 
    1137           0 : BitmapEx SvxBitmapCtl::GetBitmapEx()
    1138             : {
    1139           0 :     const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
    1140             : 
    1141           0 :     return BitmapEx(aRetval);
    1142             : }
    1143             : 
    1144           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeColorLB(Window *pParent, VclBuilder::stringmap &rMap)
    1145             : {
    1146           0 :     bool bDropdown = VclBuilder::extractDropdown(rMap);
    1147           0 :     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP;
    1148           0 :     if (bDropdown)
    1149           0 :         nWinBits |= WB_DROPDOWN;
    1150           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1151           0 :     if (!sBorder.isEmpty())
    1152           0 :         nWinBits |= WB_BORDER;
    1153           0 :     ColorLB *pListBox = new ColorLB(pParent, nWinBits);
    1154           0 :     pListBox->EnableAutoSize(true);
    1155           0 :     return pListBox;
    1156             : }
    1157             : 
    1158             : // Fills the Listbox with color and strings
    1159             : 
    1160          63 : void ColorLB::Fill( const XColorListRef &pColorTab )
    1161             : {
    1162          63 :     if( !pColorTab.is() )
    1163          63 :         return;
    1164             : 
    1165          63 :     long nCount = pColorTab->Count();
    1166             :     XColorEntry* pEntry;
    1167          63 :     SetUpdateMode( false );
    1168             : 
    1169       10584 :     for( long i = 0; i < nCount; i++ )
    1170             :     {
    1171       10521 :         pEntry = pColorTab->GetColor( i );
    1172       10521 :         InsertEntry( pEntry->GetColor(), pEntry->GetName() );
    1173             :     }
    1174             : 
    1175          63 :     AdaptDropDownLineCountToMaximum();
    1176          63 :     SetUpdateMode( true );
    1177             : }
    1178             : 
    1179             : /************************************************************************/
    1180             : 
    1181           0 : void ColorLB::Append( const XColorEntry& rEntry )
    1182             : {
    1183           0 :     InsertEntry( rEntry.GetColor(), rEntry.GetName() );
    1184           0 :     AdaptDropDownLineCountToMaximum();
    1185           0 : }
    1186             : 
    1187             : /************************************************************************/
    1188             : 
    1189           0 : void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos )
    1190             : {
    1191           0 :     RemoveEntry( nPos );
    1192           0 :     InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos );
    1193           0 : }
    1194             : 
    1195             : // Fills the Listbox with color and strings
    1196             : 
    1197          61 : void FillAttrLB::Fill( const XColorListRef &pColorTab )
    1198             : {
    1199          61 :     long nCount = pColorTab->Count();
    1200             :     XColorEntry* pEntry;
    1201          61 :     SetUpdateMode( false );
    1202             : 
    1203       10248 :     for( long i = 0; i < nCount; i++ )
    1204             :     {
    1205       10187 :         pEntry = pColorTab->GetColor( i );
    1206       10187 :         InsertEntry( pEntry->GetColor(), pEntry->GetName() );
    1207             :     }
    1208             : 
    1209          61 :     AdaptDropDownLineCountToMaximum();
    1210          61 :     SetUpdateMode( true );
    1211          61 : }
    1212             : 
    1213             : // Fills the listbox (provisional) with strings
    1214             : 
    1215           0 : HatchingLB::HatchingLB( Window* pParent, WinBits nWinStyle)
    1216             : : ListBox( pParent, nWinStyle ),
    1217           0 :   mpList ( NULL )
    1218             : {
    1219           0 :     SetEdgeBlending(true);
    1220           0 : }
    1221             : 
    1222           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeHatchingLB(Window *pParent, VclBuilder::stringmap& rMap)
    1223             : {
    1224           0 :     WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
    1225           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1226           0 :     if (!sBorder.isEmpty())
    1227           0 :         nWinStyle |= WB_BORDER;
    1228           0 :     HatchingLB *pListBox = new HatchingLB(pParent, nWinStyle);
    1229           0 :     pListBox->EnableAutoSize(true);
    1230           0 :     return pListBox;
    1231             : }
    1232             : 
    1233           0 : void HatchingLB::Fill( const XHatchListRef &pList )
    1234             : {
    1235           0 :     if( !pList.is() )
    1236           0 :         return;
    1237             : 
    1238           0 :     mpList = pList;
    1239             :     XHatchEntry* pEntry;
    1240           0 :     long nCount = pList->Count();
    1241             : 
    1242           0 :     SetUpdateMode( false );
    1243             : 
    1244           0 :     for( long i = 0; i < nCount; i++ )
    1245             :     {
    1246           0 :         pEntry = pList->GetHatch( i );
    1247           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1248           0 :         if( !aBitmap.IsEmpty() )
    1249           0 :             InsertEntry(pEntry->GetName(), Image(aBitmap));
    1250             :         else
    1251           0 :             InsertEntry( pEntry->GetName() );
    1252           0 :     }
    1253             : 
    1254           0 :     AdaptDropDownLineCountToMaximum();
    1255           0 :     SetUpdateMode( true );
    1256             : }
    1257             : 
    1258             : /************************************************************************/
    1259             : 
    1260           0 : void HatchingLB::Append( const XHatchEntry& rEntry, const Bitmap& rBitmap )
    1261             : {
    1262           0 :     if(!rBitmap.IsEmpty())
    1263             :     {
    1264           0 :         InsertEntry(rEntry.GetName(), Image(rBitmap));
    1265             :     }
    1266             :     else
    1267             :     {
    1268           0 :         InsertEntry( rEntry.GetName() );
    1269             :     }
    1270             : 
    1271           0 :     AdaptDropDownLineCountToMaximum();
    1272           0 : }
    1273             : 
    1274             : /************************************************************************/
    1275             : 
    1276           0 : void HatchingLB::Modify( const XHatchEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap )
    1277             : {
    1278           0 :     RemoveEntry( nPos );
    1279             : 
    1280           0 :     if( !rBitmap.IsEmpty() )
    1281             :     {
    1282           0 :         InsertEntry( rEntry.GetName(), Image(rBitmap), nPos );
    1283             :     }
    1284             :     else
    1285             :     {
    1286           0 :         InsertEntry( rEntry.GetName(), nPos );
    1287             :     }
    1288           0 : }
    1289             : 
    1290             : // Fills the listbox (provisional) with strings
    1291             : 
    1292           0 : void FillAttrLB::Fill( const XHatchListRef &pList )
    1293             : {
    1294           0 :     long nCount = pList->Count();
    1295             :     XHatchEntry* pEntry;
    1296           0 :     ListBox::SetUpdateMode( false );
    1297             : 
    1298           0 :     for( long i = 0; i < nCount; i++ )
    1299             :     {
    1300           0 :         pEntry = pList->GetHatch( i );
    1301           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1302           0 :         if( !aBitmap.IsEmpty() )
    1303           0 :             ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
    1304             :         else
    1305           0 :             InsertEntry( pEntry->GetName() );
    1306           0 :     }
    1307             : 
    1308           0 :     AdaptDropDownLineCountToMaximum();
    1309           0 :     ListBox::SetUpdateMode( true );
    1310           0 : }
    1311             : 
    1312             : // Fills the listbox (provisional) with strings
    1313             : 
    1314           0 : GradientLB::GradientLB( Window* pParent, WinBits aWB)
    1315             : : ListBox( pParent, aWB ),
    1316           0 :   mpList(NULL)
    1317             : {
    1318           0 :     SetEdgeBlending(true);
    1319           0 : }
    1320             : 
    1321           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeGradientLB(Window *pParent, VclBuilder::stringmap &rMap)
    1322             : {
    1323           0 :     WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
    1324           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1325           0 :     if (!sBorder.isEmpty())
    1326           0 :         nWinStyle |= WB_BORDER;
    1327           0 :     GradientLB *pListBox = new GradientLB(pParent, nWinStyle);
    1328           0 :     pListBox->EnableAutoSize(true);
    1329           0 :     return pListBox;
    1330             : }
    1331             : 
    1332           0 : void GradientLB::Fill( const XGradientListRef &pList )
    1333             : {
    1334           0 :     if( !pList.is() )
    1335           0 :         return;
    1336             : 
    1337           0 :     mpList = pList;
    1338             :     XGradientEntry* pEntry;
    1339           0 :     long nCount = pList->Count();
    1340             : 
    1341           0 :     SetUpdateMode( false );
    1342             : 
    1343           0 :     for( long i = 0; i < nCount; i++ )
    1344             :     {
    1345           0 :         pEntry = pList->GetGradient( i );
    1346           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1347           0 :         if( !aBitmap.IsEmpty() )
    1348           0 :             InsertEntry(pEntry->GetName(), Image(aBitmap));
    1349             :         else
    1350           0 :             InsertEntry( pEntry->GetName() );
    1351           0 :     }
    1352             : 
    1353           0 :     AdaptDropDownLineCountToMaximum();
    1354           0 :     SetUpdateMode( true );
    1355             : }
    1356             : 
    1357             : /************************************************************************/
    1358             : 
    1359           0 : void GradientLB::Append( const XGradientEntry& rEntry, const Bitmap& rBitmap )
    1360             : {
    1361           0 :     if(!rBitmap.IsEmpty())
    1362             :     {
    1363           0 :         InsertEntry(rEntry.GetName(), Image(rBitmap));
    1364             :     }
    1365             :     else
    1366             :     {
    1367           0 :         InsertEntry( rEntry.GetName() );
    1368             :     }
    1369             : 
    1370           0 :     AdaptDropDownLineCountToMaximum();
    1371           0 : }
    1372             : 
    1373             : /************************************************************************/
    1374             : 
    1375           0 : void GradientLB::Modify( const XGradientEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap )
    1376             : {
    1377           0 :     RemoveEntry( nPos );
    1378             : 
    1379           0 :     if(!rBitmap.IsEmpty())
    1380             :     {
    1381           0 :         InsertEntry( rEntry.GetName(), Image(rBitmap), nPos );
    1382             :     }
    1383             :     else
    1384             :     {
    1385           0 :         InsertEntry( rEntry.GetName(), nPos );
    1386             :     }
    1387           0 : }
    1388             : 
    1389             : /************************************************************************/
    1390             : 
    1391           0 : void GradientLB::SelectEntryByList( const XGradientListRef &pList, const OUString& rStr,
    1392             :                                     const XGradient& rGradient, sal_uInt16 nDist )
    1393             : {
    1394           0 :     long nCount = pList.get() ? pList->Count() : 0;
    1395             :     XGradientEntry* pEntry;
    1396           0 :     bool bFound = false;
    1397           0 :     OUString aStr;
    1398             : 
    1399             :     long i;
    1400           0 :     for( i = 0; i < nCount && !bFound; i++ )
    1401             :     {
    1402           0 :         pEntry = pList->GetGradient( i );
    1403             : 
    1404           0 :         aStr = pEntry->GetName();
    1405             : 
    1406           0 :         if( rStr == aStr && rGradient == pEntry->GetGradient() )
    1407           0 :             bFound = true;
    1408             :     }
    1409           0 :     if( bFound )
    1410           0 :         SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
    1411           0 : }
    1412             : 
    1413             : // Fills the listbox (provisional) with strings
    1414             : 
    1415           0 : void FillAttrLB::Fill( const XGradientListRef &pList )
    1416             : {
    1417           0 :     long nCount = pList->Count();
    1418             :     XGradientEntry* pEntry;
    1419           0 :     ListBox::SetUpdateMode( false );
    1420             : 
    1421           0 :     for( long i = 0; i < nCount; i++ )
    1422             :     {
    1423           0 :         pEntry = pList->GetGradient( i );
    1424           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1425           0 :         if( !aBitmap.IsEmpty() )
    1426           0 :             ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
    1427             :         else
    1428           0 :             InsertEntry( pEntry->GetName() );
    1429           0 :     }
    1430             : 
    1431           0 :     AdaptDropDownLineCountToMaximum();
    1432           0 :     ListBox::SetUpdateMode( true );
    1433           0 : }
    1434             : 
    1435             : // BitmapLB Constructor
    1436             : 
    1437           0 : BitmapLB::BitmapLB( Window* pParent, WinBits aWB)
    1438             : :   ListBox( pParent, aWB ),
    1439             :     maBitmapEx(),
    1440           0 :     mpList(NULL)
    1441             : {
    1442           0 :     SetEdgeBlending(true);
    1443           0 : }
    1444             : 
    1445           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeBitmapLB(Window *pParent, VclBuilder::stringmap &rMap)
    1446             : {
    1447           0 :     WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
    1448           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1449           0 :     if (!sBorder.isEmpty())
    1450           0 :         nWinStyle |= WB_BORDER;
    1451           0 :     BitmapLB *pListBox = new BitmapLB(pParent, nWinStyle);
    1452           0 :     pListBox->EnableAutoSize(true);
    1453           0 :     return pListBox;
    1454             : }
    1455             : 
    1456             : /************************************************************************/
    1457             : 
    1458             : namespace
    1459             : {
    1460           0 :     void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
    1461             :     {
    1462           0 :         if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
    1463             :         {
    1464           0 :             VirtualDevice aVirtualDevice;
    1465           0 :             aVirtualDevice.SetOutputSizePixel(rSize);
    1466             : 
    1467           0 :             if(rBitmapEx.IsTransparent())
    1468             :             {
    1469           0 :                 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1470             : 
    1471           0 :                 if(rStyleSettings.GetPreviewUsesCheckeredBackground())
    1472             :                 {
    1473           0 :                     const Point aNull(0, 0);
    1474             :                     static const sal_uInt32 nLen(8);
    1475           0 :                     static const Color aW(COL_WHITE);
    1476           0 :                     static const Color aG(0xef, 0xef, 0xef);
    1477             : 
    1478           0 :                     aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
    1479             :                 }
    1480             :                 else
    1481             :                 {
    1482           0 :                     aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
    1483           0 :                     aVirtualDevice.Erase();
    1484             :                 }
    1485             :             }
    1486             : 
    1487           0 :             if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
    1488             :             {
    1489           0 :                 rBitmapEx.Scale(rSize, BMP_SCALE_DEFAULT);
    1490           0 :                 aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx);
    1491             :             }
    1492             :             else
    1493             :             {
    1494           0 :                 const Size aBitmapSize(rBitmapEx.GetSizePixel());
    1495             : 
    1496           0 :                 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height())
    1497             :                 {
    1498           0 :                     for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width())
    1499             :                     {
    1500             :                         aVirtualDevice.DrawBitmapEx(
    1501             :                             Point(x, y),
    1502           0 :                             rBitmapEx);
    1503             :                     }
    1504             :                 }
    1505             :             }
    1506             : 
    1507           0 :             rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize);
    1508             :         }
    1509           0 :     }
    1510             : } // end of anonymous namespace
    1511             : 
    1512             : /************************************************************************/
    1513             : 
    1514           0 : void BitmapLB::Fill( const XBitmapListRef &pList )
    1515             : {
    1516           0 :     if( !pList.is() )
    1517           0 :         return;
    1518             : 
    1519           0 :     mpList = pList;
    1520             :     XBitmapEntry* pEntry;
    1521           0 :     const long nCount(pList->Count());
    1522           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1523           0 :     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
    1524             : 
    1525           0 :     SetUpdateMode(false);
    1526             : 
    1527           0 :     for(long i(0); i < nCount; i++)
    1528             :     {
    1529           0 :         pEntry = pList->GetBitmap(i);
    1530           0 :         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
    1531           0 :         formatBitmapExToSize(maBitmapEx, aSize);
    1532           0 :         InsertEntry(pEntry->GetName(), Image(maBitmapEx));
    1533             :     }
    1534             : 
    1535           0 :     AdaptDropDownLineCountToMaximum();
    1536           0 :     SetUpdateMode(true);
    1537             : }
    1538             : 
    1539             : /************************************************************************/
    1540             : 
    1541           0 : void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry)
    1542             : {
    1543           0 :     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
    1544             : 
    1545           0 :     if(!maBitmapEx.IsEmpty())
    1546             :     {
    1547           0 :         formatBitmapExToSize(maBitmapEx, rSize);
    1548           0 :         InsertEntry(rEntry.GetName(), Image(maBitmapEx));
    1549             :     }
    1550             :     else
    1551             :     {
    1552           0 :         InsertEntry(rEntry.GetName());
    1553             :     }
    1554             : 
    1555           0 :     AdaptDropDownLineCountToMaximum();
    1556           0 : }
    1557             : 
    1558             : /************************************************************************/
    1559             : 
    1560           0 : void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_Int32 nPos)
    1561             : {
    1562           0 :     RemoveEntry(nPos);
    1563           0 :     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
    1564             : 
    1565           0 :     if(!maBitmapEx.IsEmpty())
    1566             :     {
    1567           0 :         formatBitmapExToSize(maBitmapEx, rSize);
    1568           0 :         InsertEntry(rEntry.GetName(), Image(maBitmapEx), nPos);
    1569             :     }
    1570             :     else
    1571             :     {
    1572           0 :         InsertEntry(rEntry.GetName());
    1573             :     }
    1574           0 : }
    1575             : 
    1576          63 : FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB)
    1577          63 : :   ColorListBox(pParent, aWB)
    1578             : {
    1579          63 : }
    1580             : 
    1581             : /************************************************************************/
    1582             : 
    1583           0 : void FillAttrLB::Fill( const XBitmapListRef &pList )
    1584             : {
    1585           0 :     const long nCount(pList->Count());
    1586             :     XBitmapEntry* pEntry;
    1587           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1588           0 :     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
    1589             : 
    1590           0 :     ListBox::SetUpdateMode(false);
    1591             : 
    1592           0 :     for(long i(0); i < nCount; i++)
    1593             :     {
    1594           0 :         pEntry = pList->GetBitmap( i );
    1595           0 :         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
    1596           0 :         formatBitmapExToSize(maBitmapEx, aSize);
    1597           0 :         ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx));
    1598             :     }
    1599             : 
    1600           0 :     AdaptDropDownLineCountToMaximum();
    1601           0 :     ListBox::SetUpdateMode(true);
    1602           0 : }
    1603             : 
    1604          63 : void FillTypeLB::Fill()
    1605             : {
    1606          63 :     SetUpdateMode( false );
    1607             : 
    1608          63 :     InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) );
    1609          63 :     InsertEntry( SVX_RESSTR(RID_SVXSTR_COLOR) );
    1610          63 :     InsertEntry( SVX_RESSTR(RID_SVXSTR_GRADIENT) );
    1611          63 :     InsertEntry( SVX_RESSTR(RID_SVXSTR_HATCH) );
    1612          63 :     InsertEntry( SVX_RESSTR(RID_SVXSTR_BITMAP) );
    1613             : 
    1614          63 :     AdaptDropDownLineCountToMaximum();
    1615          63 :     SetUpdateMode( true );
    1616          63 : }
    1617             : 
    1618          63 : LineLB::LineLB(Window* pParent, WinBits aWB)
    1619             : :   ListBox(pParent, aWB),
    1620          63 :     mbAddStandardFields(true)
    1621             : {
    1622             :     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
    1623          63 : }
    1624             : 
    1625           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLineLB(Window *pParent, VclBuilder::stringmap &rMap)
    1626             : {
    1627           0 :     bool bDropdown = VclBuilder::extractDropdown(rMap);
    1628           0 :     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP;
    1629           0 :     if (bDropdown)
    1630           0 :         nWinBits |= WB_DROPDOWN;
    1631           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1632           0 :     if (!sBorder.isEmpty())
    1633           0 :         nWinBits |= WB_BORDER;
    1634           0 :     LineLB *pListBox = new LineLB(pParent, nWinBits);
    1635           0 :     pListBox->EnableAutoSize(true);
    1636           0 :     return pListBox;
    1637             : }
    1638             : 
    1639          63 : LineLB::~LineLB()
    1640             : {
    1641          63 : }
    1642             : 
    1643           0 : void LineLB::setAddStandardFields(bool bNew)
    1644             : {
    1645           0 :     if(getAddStandardFields() != bNew)
    1646             :     {
    1647           0 :         mbAddStandardFields = bNew;
    1648             :     }
    1649           0 : }
    1650             : 
    1651             : // Fills the listbox (provisional) with strings
    1652             : 
    1653          62 : void LineLB::Fill( const XDashListRef &pList )
    1654             : {
    1655          62 :     Clear();
    1656             : 
    1657          62 :     if( !pList.is() )
    1658          62 :         return;
    1659             : 
    1660          62 :     if(getAddStandardFields())
    1661             :     {
    1662             :         // entry for 'none'
    1663          62 :         InsertEntry(pList->GetStringForUiNoLine());
    1664             : 
    1665             :         // entry for solid line
    1666             :         InsertEntry(pList->GetStringForUiSolidLine(),
    1667          62 :                 Image(pList->GetBitmapForUISolidLine()));
    1668             :     }
    1669             : 
    1670             :     // entries for dashed lines
    1671             : 
    1672          62 :     long nCount = pList->Count();
    1673             :     XDashEntry* pEntry;
    1674          62 :     SetUpdateMode( false );
    1675             : 
    1676         682 :     for( long i = 0; i < nCount; i++ )
    1677             :     {
    1678         620 :         pEntry = pList->GetDash( i );
    1679         620 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1680         620 :         if( !aBitmap.IsEmpty() )
    1681             :         {
    1682         620 :             InsertEntry(pEntry->GetName(), Image(aBitmap));
    1683             :         }
    1684             :         else
    1685           0 :             InsertEntry( pEntry->GetName() );
    1686         620 :     }
    1687             : 
    1688          62 :     AdaptDropDownLineCountToMaximum();
    1689          62 :     SetUpdateMode( true );
    1690             : }
    1691             : 
    1692             : /************************************************************************/
    1693             : 
    1694           0 : void LineLB::Append( const XDashEntry& rEntry, const Bitmap& rBitmap )
    1695             : {
    1696           0 :     if(!rBitmap.IsEmpty())
    1697             :     {
    1698           0 :         InsertEntry(rEntry.GetName(), Image(rBitmap));
    1699             :     }
    1700             :     else
    1701             :     {
    1702           0 :         InsertEntry( rEntry.GetName() );
    1703             :     }
    1704             : 
    1705           0 :     AdaptDropDownLineCountToMaximum();
    1706           0 : }
    1707             : 
    1708             : /************************************************************************/
    1709             : 
    1710           0 : void LineLB::Modify( const XDashEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap )
    1711             : {
    1712           0 :     RemoveEntry( nPos );
    1713             : 
    1714           0 :     if(!rBitmap.IsEmpty())
    1715             :     {
    1716           0 :         InsertEntry( rEntry.GetName(), Image(rBitmap), nPos );
    1717             :     }
    1718             :     else
    1719             :     {
    1720           0 :         InsertEntry( rEntry.GetName(), nPos );
    1721             :     }
    1722           0 : }
    1723             : 
    1724             : // Fills the listbox (provisional) with strings
    1725             : 
    1726           0 : LineEndLB::LineEndLB( Window* pParent, WinBits aWB )
    1727           0 :     : ListBox( pParent, aWB )
    1728             : {
    1729             :     // No EdgeBlending for LineEnds SetEdgeBlending(true);
    1730           0 : }
    1731             : 
    1732           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLineEndLB(Window *pParent, VclBuilder::stringmap &rMap)
    1733             : {
    1734           0 :     bool bDropdown = VclBuilder::extractDropdown(rMap);
    1735           0 :     WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP;
    1736           0 :     if (bDropdown)
    1737           0 :         nWinBits |= WB_DROPDOWN;
    1738           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1739           0 :     if (!sBorder.isEmpty())
    1740           0 :         nWinBits |= WB_BORDER;
    1741           0 :     LineEndLB *pListBox = new LineEndLB(pParent, nWinBits);
    1742           0 :     pListBox->EnableAutoSize(true);
    1743           0 :     return pListBox;
    1744             : }
    1745             : 
    1746           0 : LineEndLB::~LineEndLB(void)
    1747             : {
    1748           0 : }
    1749             : 
    1750           0 : void LineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
    1751             : {
    1752           0 :     if( !pList.is() )
    1753           0 :         return;
    1754             : 
    1755           0 :     long nCount = pList->Count();
    1756             :     XLineEndEntry* pEntry;
    1757           0 :     VirtualDevice aVD;
    1758           0 :     SetUpdateMode( false );
    1759             : 
    1760           0 :     for( long i = 0; i < nCount; i++ )
    1761             :     {
    1762           0 :         pEntry = pList->GetLineEnd( i );
    1763           0 :         const Bitmap aBitmap = pList->GetUiBitmap( i );
    1764           0 :         if( !aBitmap.IsEmpty() )
    1765             :         {
    1766           0 :             Size aBmpSize( aBitmap.GetSizePixel() );
    1767           0 :             aVD.SetOutputSizePixel( aBmpSize, false );
    1768           0 :             aVD.DrawBitmap( Point(), aBitmap );
    1769           0 :             InsertEntry( pEntry->GetName(),
    1770             :                 Image(aVD.GetBitmap(
    1771           0 :                     (bStart) ? Point() : Point(aBmpSize.Width() / 2, 0),
    1772           0 :                     Size(aBmpSize.Width() / 2, aBmpSize.Height()))));
    1773             :             //delete pBitmap;
    1774             :         }
    1775             :         else
    1776           0 :             InsertEntry( pEntry->GetName() );
    1777           0 :     }
    1778             : 
    1779           0 :     AdaptDropDownLineCountToMaximum();
    1780           0 :     SetUpdateMode( true );
    1781             : }
    1782             : 
    1783             : /************************************************************************/
    1784             : 
    1785           0 : void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart )
    1786             : {
    1787           0 :     if(!rBitmap.IsEmpty())
    1788             :     {
    1789           0 :         VirtualDevice aVD;
    1790           0 :         const Size aBmpSize(rBitmap.GetSizePixel());
    1791             : 
    1792           0 :         aVD.SetOutputSizePixel(aBmpSize, false);
    1793           0 :         aVD.DrawBitmap(Point(), rBitmap);
    1794             :         InsertEntry(
    1795           0 :             rEntry.GetName(),
    1796             :             Image(aVD.GetBitmap(
    1797           0 :                 (bStart) ? Point() : Point(aBmpSize.Width() / 2, 0),
    1798           0 :                 Size(aBmpSize.Width() / 2, aBmpSize.Height()))));
    1799             :     }
    1800             :     else
    1801             :     {
    1802           0 :         InsertEntry(rEntry.GetName());
    1803             :     }
    1804             : 
    1805           0 :     AdaptDropDownLineCountToMaximum();
    1806           0 : }
    1807             : 
    1808             : /************************************************************************/
    1809             : 
    1810           0 : void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap, bool bStart )
    1811             : {
    1812           0 :     RemoveEntry( nPos );
    1813             : 
    1814           0 :     if(!rBitmap.IsEmpty())
    1815             :     {
    1816           0 :         VirtualDevice aVD;
    1817           0 :         const Size aBmpSize(rBitmap.GetSizePixel());
    1818             : 
    1819           0 :         aVD.SetOutputSizePixel(aBmpSize, false);
    1820           0 :         aVD.DrawBitmap(Point(), rBitmap);
    1821             :         InsertEntry(
    1822           0 :             rEntry.GetName(),
    1823             :             Image(aVD.GetBitmap(
    1824           0 :                     (bStart) ? Point() : Point(aBmpSize.Width() / 2, 0),
    1825           0 :                     Size(aBmpSize.Width() / 2, aBmpSize.Height()))),
    1826           0 :             nPos);
    1827             :     }
    1828             :     else
    1829             :     {
    1830           0 :         InsertEntry(rEntry.GetName(), nPos);
    1831             :     }
    1832           0 : }
    1833             : 
    1834             : 
    1835             : 
    1836           0 : void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
    1837             : {
    1838           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1839             : 
    1840           0 :     if(bForeground)
    1841             :     {
    1842           0 :         svtools::ColorConfig aColorConfig;
    1843           0 :         Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
    1844             : 
    1845           0 :         if(IsControlForeground())
    1846             :         {
    1847           0 :             aTextColor = GetControlForeground();
    1848             :         }
    1849             : 
    1850           0 :         getBufferDevice().SetTextColor(aTextColor);
    1851             :     }
    1852             : 
    1853           0 :     if(bBackground)
    1854             :     {
    1855           0 :         if(IsControlBackground())
    1856             :         {
    1857           0 :             getBufferDevice().SetBackground(GetControlBackground());
    1858             :         }
    1859             :         else
    1860             :         {
    1861           0 :             getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
    1862             :         }
    1863             :     }
    1864             : 
    1865             :     // do not paint background self, it gets painted buffered
    1866           0 :     SetControlBackground();
    1867           0 :     SetBackground();
    1868             : 
    1869           0 :     Invalidate();
    1870           0 : }
    1871             : 
    1872           0 : SvxPreviewBase::SvxPreviewBase(Window* pParent)
    1873             :     : Control(pParent, WB_BORDER)
    1874           0 :     , mpModel(new SdrModel())
    1875           0 :     , mpBufferDevice(new VirtualDevice(*this))
    1876             : {
    1877             :     //  Draw the control's border as a flat thin black line.
    1878           0 :     SetBorderStyle(WINDOW_BORDER_MONO);
    1879           0 :     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
    1880           0 :     SetMapMode(MAP_100TH_MM);
    1881             : 
    1882             :     // init model
    1883           0 :     mpModel->GetItemPool().FreezeIdRanges();
    1884           0 : }
    1885             : 
    1886           0 : SvxPreviewBase::~SvxPreviewBase()
    1887             : {
    1888           0 :     delete mpModel;
    1889           0 :     delete mpBufferDevice;
    1890           0 : }
    1891             : 
    1892           0 : void SvxPreviewBase::LocalPrePaint()
    1893             : {
    1894             :     // init BufferDevice
    1895           0 :     if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
    1896             :     {
    1897           0 :         mpBufferDevice->SetDrawMode(GetDrawMode());
    1898           0 :         mpBufferDevice->SetSettings(GetSettings());
    1899           0 :         mpBufferDevice->SetAntialiasing(GetAntialiasing());
    1900           0 :         mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
    1901           0 :         mpBufferDevice->SetMapMode(GetMapMode());
    1902             :     }
    1903             : 
    1904           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1905             : 
    1906           0 :     if(rStyleSettings.GetPreviewUsesCheckeredBackground())
    1907             :     {
    1908           0 :         const Point aNull(0, 0);
    1909             :         static const sal_uInt32 nLen(8);
    1910           0 :         static const Color aW(COL_WHITE);
    1911           0 :         static const Color aG(0xef, 0xef, 0xef);
    1912           0 :         const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
    1913             : 
    1914           0 :         mpBufferDevice->EnableMapMode(false);
    1915           0 :         mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG);
    1916           0 :         mpBufferDevice->EnableMapMode(bWasEnabled);
    1917             :     }
    1918             :     else
    1919             :     {
    1920           0 :         mpBufferDevice->Erase();
    1921             :     }
    1922           0 : }
    1923             : 
    1924           0 : void SvxPreviewBase::LocalPostPaint()
    1925             : {
    1926             :     // copy to front (in pixel mode)
    1927           0 :     const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
    1928           0 :     const bool bWasEnabledDst(IsMapModeEnabled());
    1929           0 :     const Point aEmptyPoint;
    1930             : 
    1931           0 :     mpBufferDevice->EnableMapMode(false);
    1932           0 :     EnableMapMode(false);
    1933             : 
    1934             :     DrawOutDev(
    1935           0 :         aEmptyPoint, GetOutputSizePixel(),
    1936           0 :         aEmptyPoint, GetOutputSizePixel(),
    1937           0 :         *mpBufferDevice);
    1938             : 
    1939           0 :     mpBufferDevice->EnableMapMode(bWasEnabledSrc);
    1940           0 :     EnableMapMode(bWasEnabledDst);
    1941           0 : }
    1942             : 
    1943           0 : void SvxPreviewBase::StateChanged(StateChangedType nType)
    1944             : {
    1945           0 :     Control::StateChanged(nType);
    1946             : 
    1947           0 :     if(STATE_CHANGE_CONTROLFOREGROUND == nType)
    1948             :     {
    1949           0 :         InitSettings(true, false);
    1950             :     }
    1951           0 :     else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
    1952             :     {
    1953           0 :         InitSettings(false, true);
    1954             :     }
    1955           0 : }
    1956             : 
    1957           0 : void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
    1958             : {
    1959           0 :     SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
    1960             : 
    1961           0 :     if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
    1962             :     {
    1963           0 :         InitSettings(true, true);
    1964             :     }
    1965             :     else
    1966             :     {
    1967           0 :         Control::DataChanged(rDCEvt);
    1968             :     }
    1969           0 : }
    1970             : 
    1971           0 : void SvxXLinePreview::Resize()
    1972             : {
    1973           0 :     SvxPreviewBase::Resize();
    1974             : 
    1975           0 :     const Size aOutputSize(GetOutputSize());
    1976           0 :     const sal_Int32 nDistance(500L);
    1977           0 :     const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
    1978             : 
    1979             :     // create DrawObectA
    1980           0 :     const sal_Int32 aYPosA(aOutputSize.Height() / 2);
    1981           0 :     const basegfx::B2DPoint aPointA1( nDistance,  aYPosA);
    1982           0 :     const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
    1983           0 :     basegfx::B2DPolygon aPolygonA;
    1984           0 :     aPolygonA.append(aPointA1);
    1985           0 :     aPolygonA.append(aPointA2);
    1986           0 :     mpLineObjA->SetPathPoly(basegfx::B2DPolyPolygon(aPolygonA));
    1987             : 
    1988             :     // create DrawObectB
    1989           0 :     const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
    1990           0 :     const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
    1991           0 :     const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance,  aYPosB1);
    1992           0 :     const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
    1993           0 :     const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
    1994           0 :     basegfx::B2DPolygon aPolygonB;
    1995           0 :     aPolygonB.append(aPointB1);
    1996           0 :     aPolygonB.append(aPointB2);
    1997           0 :     aPolygonB.append(aPointB3);
    1998           0 :     mpLineObjB->SetPathPoly(basegfx::B2DPolyPolygon(aPolygonB));
    1999             : 
    2000             :     // create DrawObectC
    2001           0 :     basegfx::B2DPolygon aPolygonC;
    2002           0 :     const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance,  aYPosB1);
    2003           0 :     const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
    2004           0 :     const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
    2005           0 :     aPolygonC.append(aPointC1);
    2006           0 :     aPolygonC.append(aPointC2);
    2007           0 :     aPolygonC.append(aPointC3);
    2008           0 :     mpLineObjC->SetPathPoly(basegfx::B2DPolyPolygon(aPolygonC));
    2009           0 : }
    2010             : 
    2011           0 : SvxXLinePreview::SvxXLinePreview(Window* pParent)
    2012             :     : SvxPreviewBase(pParent)
    2013             :     , mpLineObjA(NULL)
    2014             :     , mpLineObjB(NULL)
    2015             :     , mpLineObjC(NULL)
    2016             :     , mpGraphic(NULL)
    2017           0 :     , mbWithSymbol(false)
    2018             : {
    2019           0 :     InitSettings( true, true );
    2020             : 
    2021           0 :     mpLineObjA = new SdrPathObj(OBJ_LINE);
    2022           0 :     mpLineObjA->SetModel(&getModel());
    2023             : 
    2024           0 :     mpLineObjB = new SdrPathObj(OBJ_PLIN);
    2025           0 :     mpLineObjB->SetModel(&getModel());
    2026             : 
    2027           0 :     mpLineObjC = new SdrPathObj(OBJ_PLIN);
    2028           0 :     mpLineObjC->SetModel(&getModel());
    2029           0 : }
    2030             : 
    2031           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxXLinePreview(Window *pParent, VclBuilder::stringmap &)
    2032             : {
    2033           0 :     return new SvxXLinePreview(pParent);
    2034             : }
    2035             : 
    2036           0 : Size SvxXLinePreview::GetOptimalSize() const
    2037             : {
    2038           0 :     return getPreviewStripSize(this);
    2039             : }
    2040             : 
    2041           0 : SvxXLinePreview::~SvxXLinePreview()
    2042             : {
    2043           0 :     SdrObject *pFoo = mpLineObjA;
    2044           0 :     SdrObject::Free( pFoo );
    2045           0 :     pFoo = mpLineObjB;
    2046           0 :     SdrObject::Free( pFoo );
    2047           0 :     pFoo = mpLineObjC;
    2048           0 :     SdrObject::Free( pFoo );
    2049           0 : }
    2050             : 
    2051             : 
    2052             : 
    2053           0 : void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
    2054             : {
    2055           0 :     mpGraphic = p;
    2056           0 :     maSymbolSize = s;
    2057           0 : }
    2058             : 
    2059             : 
    2060             : 
    2061           0 : void SvxXLinePreview::ResizeSymbol(const Size& s)
    2062             : {
    2063           0 :     if ( s != maSymbolSize )
    2064             :     {
    2065           0 :         maSymbolSize = s;
    2066           0 :         Invalidate();
    2067             :     }
    2068           0 : }
    2069             : 
    2070             : 
    2071             : 
    2072           0 : void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
    2073             : {
    2074             :     // Set ItemSet at objects
    2075           0 :     mpLineObjA->SetMergedItemSet(rItemSet);
    2076             : 
    2077             :     // At line joints, do not use arrows
    2078           0 :     SfxItemSet aTempSet(rItemSet);
    2079           0 :     aTempSet.ClearItem(XATTR_LINESTART);
    2080           0 :     aTempSet.ClearItem(XATTR_LINEEND);
    2081             : 
    2082           0 :     mpLineObjB->SetMergedItemSet(aTempSet);
    2083           0 :     mpLineObjC->SetMergedItemSet(aTempSet);
    2084           0 : }
    2085             : 
    2086             : 
    2087             : 
    2088           0 : void SvxXLinePreview::Paint( const Rectangle& )
    2089             : {
    2090           0 :     LocalPrePaint();
    2091             : 
    2092             :     // paint objects to buffer device
    2093           0 :     sdr::contact::SdrObjectVector aObjectVector;
    2094           0 :     aObjectVector.push_back(mpLineObjA);
    2095           0 :     aObjectVector.push_back(mpLineObjB);
    2096           0 :     aObjectVector.push_back(mpLineObjC);
    2097             : 
    2098           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
    2099           0 :     sdr::contact::DisplayInfo aDisplayInfo;
    2100             : 
    2101             :     // do processing
    2102           0 :     aPainter.ProcessDisplay(aDisplayInfo);
    2103             : 
    2104           0 :     if ( mbWithSymbol && mpGraphic )
    2105             :     {
    2106           0 :         const Size aOutputSize(GetOutputSize());
    2107           0 :         Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
    2108           0 :         aPos.X() -= maSymbolSize.Width() / 2;
    2109           0 :         aPos.Y() -= maSymbolSize.Height() / 2;
    2110           0 :         mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
    2111             :     }
    2112             : 
    2113           0 :     LocalPostPaint();
    2114           0 : }
    2115             : 
    2116           0 : SvxXRectPreview::SvxXRectPreview(Window* pParent)
    2117             :     : SvxPreviewBase(pParent)
    2118           0 :     , mpRectangleObject(0)
    2119             : {
    2120           0 :     InitSettings(true, true);
    2121             : 
    2122             :     // create RectangleObject
    2123           0 :     const Rectangle aObjectSize(Point(), GetOutputSize());
    2124           0 :     mpRectangleObject = new SdrRectObj(aObjectSize);
    2125           0 :     mpRectangleObject->SetModel(&getModel());
    2126           0 : }
    2127             : 
    2128           0 : void SvxXRectPreview::Resize()
    2129             : {
    2130           0 :     const Rectangle aObjectSize(Point(), GetOutputSize());
    2131           0 :     SdrObject *pOrigObject = mpRectangleObject;
    2132           0 :     if (pOrigObject)
    2133             :     {
    2134           0 :         mpRectangleObject = new SdrRectObj(aObjectSize);
    2135           0 :         mpRectangleObject->SetModel(&getModel());
    2136           0 :         SetAttributes(pOrigObject->GetMergedItemSet());
    2137           0 :         SdrObject::Free(pOrigObject);
    2138             :     }
    2139           0 :     SvxPreviewBase::Resize();
    2140           0 : }
    2141             : 
    2142           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxXRectPreview(Window *pParent, VclBuilder::stringmap &)
    2143             : {
    2144           0 :     return new SvxXRectPreview(pParent);
    2145             : }
    2146             : 
    2147           0 : SvxXRectPreview::~SvxXRectPreview()
    2148             : {
    2149           0 :     SdrObject::Free(mpRectangleObject);
    2150           0 : }
    2151             : 
    2152           0 : void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
    2153             : {
    2154           0 :     mpRectangleObject->SetMergedItemSet(rItemSet, true);
    2155           0 :     mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
    2156           0 : }
    2157             : 
    2158           0 : void SvxXRectPreview::Paint( const Rectangle& )
    2159             : {
    2160           0 :     LocalPrePaint();
    2161             : 
    2162           0 :     sdr::contact::SdrObjectVector aObjectVector;
    2163             : 
    2164           0 :     aObjectVector.push_back(mpRectangleObject);
    2165             : 
    2166           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
    2167           0 :     sdr::contact::DisplayInfo aDisplayInfo;
    2168             : 
    2169           0 :     aPainter.ProcessDisplay(aDisplayInfo);
    2170             : 
    2171           0 :     LocalPostPaint();
    2172           0 : }
    2173             : 
    2174           0 : SvxXShadowPreview::SvxXShadowPreview( Window* pParent )
    2175             :     : SvxPreviewBase(pParent)
    2176             :     , mpRectangleObject(0)
    2177           0 :     , mpRectangleShadow(0)
    2178             : {
    2179           0 :     InitSettings(true, true);
    2180             : 
    2181             :     // prepare size
    2182           0 :     Size aSize = GetOutputSize();
    2183           0 :     aSize.Width() = aSize.Width() / 3;
    2184           0 :     aSize.Height() = aSize.Height() / 3;
    2185             : 
    2186             :     // create RectangleObject
    2187           0 :     const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
    2188           0 :     mpRectangleObject = new SdrRectObj(aObjectSize);
    2189           0 :     mpRectangleObject->SetModel(&getModel());
    2190             : 
    2191             :     // create ShadowObject
    2192           0 :     const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
    2193           0 :     mpRectangleShadow = new SdrRectObj(aShadowSize);
    2194           0 :     mpRectangleShadow->SetModel(&getModel());
    2195           0 : }
    2196             : 
    2197           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxXShadowPreview (Window *pParent, VclBuilder::stringmap &)
    2198             : {
    2199           0 :     return new SvxXShadowPreview(pParent);
    2200             : }
    2201             : 
    2202           0 : SvxXShadowPreview::~SvxXShadowPreview()
    2203             : {
    2204           0 :     SdrObject::Free(mpRectangleObject);
    2205           0 :     SdrObject::Free(mpRectangleShadow);
    2206           0 : }
    2207             : 
    2208           0 : void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
    2209             : {
    2210           0 :     mpRectangleObject->SetMergedItemSet(rItemSet, true);
    2211           0 :     mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
    2212           0 : }
    2213             : 
    2214           0 : void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
    2215             : {
    2216           0 :     mpRectangleShadow->SetMergedItemSet(rItemSet, true);
    2217           0 :     mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
    2218           0 : }
    2219             : 
    2220           0 : void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
    2221             : {
    2222           0 :     maShadowOffset = rPos;
    2223           0 : }
    2224             : 
    2225           0 : void SvxXShadowPreview::Paint( const Rectangle& )
    2226             : {
    2227           0 :     LocalPrePaint();
    2228             : 
    2229             :     // prepare size
    2230           0 :     Size aSize = GetOutputSize();
    2231           0 :     aSize.Width() = aSize.Width() / 3;
    2232           0 :     aSize.Height() = aSize.Height() / 3;
    2233             : 
    2234           0 :     Rectangle aObjectRect(Point(aSize.Width(), aSize.Height()), aSize);
    2235           0 :     mpRectangleObject->SetSnapRect(aObjectRect);
    2236           0 :     aObjectRect.Move(maShadowOffset.X(), maShadowOffset.Y());
    2237           0 :     mpRectangleShadow->SetSnapRect(aObjectRect);
    2238             : 
    2239           0 :     sdr::contact::SdrObjectVector aObjectVector;
    2240             : 
    2241           0 :     aObjectVector.push_back(mpRectangleShadow);
    2242           0 :     aObjectVector.push_back(mpRectangleObject);
    2243             : 
    2244           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
    2245           0 :     sdr::contact::DisplayInfo aDisplayInfo;
    2246             : 
    2247           0 :     aPainter.ProcessDisplay(aDisplayInfo);
    2248             : 
    2249           0 :     LocalPostPaint();
    2250         255 : }
    2251             : 
    2252             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10