LCOV - code coverage report
Current view: top level - svx/source/tbxctrls - colrctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 250 0.4 %
Date: 2012-08-25 Functions: 2 31 6.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 380 0.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <svx/dialogs.hrc>
      31                 :            : 
      32                 :            : #include <sfx2/viewsh.hxx>
      33                 :            : #include <sfx2/objsh.hxx>
      34                 :            : #include <sfx2/dispatch.hxx>
      35                 :            : #include <vcl/image.hxx>
      36                 :            : 
      37                 :            : #include <svx/colrctrl.hxx>
      38                 :            : 
      39                 :            : #include <svx/svdview.hxx>
      40                 :            : #include "svx/drawitem.hxx"
      41                 :            : #include <editeng/colritem.hxx>
      42                 :            : #include "svx/xattr.hxx"
      43                 :            : #include <svx/xtable.hxx>
      44                 :            : #include <svx/dialmgr.hxx>
      45                 :            : #include "svx/xexch.hxx"
      46                 :            : #include <vcl/svapp.hxx>
      47                 :            : 
      48 [ #  # ][ +  - ]:         75 : SFX_IMPL_DOCKINGWINDOW_WITHID( SvxColorChildWindow, SID_COLOR_CONTROL )
                 [ #  # ]
      49                 :            : 
      50                 :            : // ------------------------
      51                 :            : // - SvxColorValueSetData -
      52                 :            : // ------------------------
      53                 :            : 
      54 [ #  # ][ #  # ]:          0 : class SvxColorValueSetData : public TransferableHelper
      55                 :            : {
      56                 :            : private:
      57                 :            : 
      58                 :            :     XFillExchangeData       maData;
      59                 :            : 
      60                 :            : protected:
      61                 :            : 
      62                 :            :     virtual void            AddSupportedFormats();
      63                 :            :     virtual sal_Bool        GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
      64                 :            :     virtual sal_Bool        WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
      65                 :            : 
      66                 :            : public:
      67                 :            : 
      68                 :          0 :                             SvxColorValueSetData( const XFillAttrSetItem& rSetItem ) :
      69 [ #  # ][ #  # ]:          0 :                                 maData( rSetItem ) {}
                 [ #  # ]
      70                 :            : };
      71                 :            : 
      72                 :            : // -----------------------------------------------------------------------------
      73                 :            : 
      74                 :          0 : void SvxColorValueSetData::AddSupportedFormats()
      75                 :            : {
      76                 :          0 :     AddFormat( SOT_FORMATSTR_ID_XFA );
      77                 :          0 : }
      78                 :            : 
      79                 :            : // -----------------------------------------------------------------------------
      80                 :            : 
      81                 :          0 : sal_Bool SvxColorValueSetData::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
      82                 :            : {
      83                 :          0 :     sal_Bool bRet = sal_False;
      84                 :            : 
      85         [ #  # ]:          0 :     if( SotExchange::GetFormat( rFlavor ) == SOT_FORMATSTR_ID_XFA )
      86                 :            :     {
      87                 :          0 :         SetObject( &maData, 0, rFlavor );
      88                 :          0 :         bRet = sal_True;
      89                 :            :     }
      90                 :            : 
      91                 :          0 :     return bRet;
      92                 :            : }
      93                 :            : 
      94                 :            : // -----------------------------------------------------------------------------
      95                 :            : 
      96                 :          0 : sal_Bool SvxColorValueSetData::WriteObject( SotStorageStreamRef& rxOStm, void*, sal_uInt32 , const ::com::sun::star::datatransfer::DataFlavor&  )
      97                 :            : {
      98                 :          0 :     *rxOStm << maData;
      99                 :          0 :     return( rxOStm->GetError() == ERRCODE_NONE );
     100                 :            : }
     101                 :            : 
     102                 :            : /*************************************************************************
     103                 :            : |*
     104                 :            : |* SvxColorValueSet: Ctor
     105                 :            : |*
     106                 :            : \************************************************************************/
     107                 :            : 
     108                 :          0 : SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) :
     109                 :            :     ValueSet( _pParent, rResId ),
     110                 :            :     DragSourceHelper( this ),
     111         [ #  # ]:          0 :     bLeft (sal_True)
     112                 :            : {
     113 [ #  # ][ #  # ]:          0 :     SetAccessibleName(String( SVX_RES( STR_COLORTABLE )  ));
         [ #  # ][ #  # ]
     114                 :          0 : }
     115                 :            : 
     116                 :            : /*************************************************************************
     117                 :            : |*
     118                 :            : |* SvxColorValueSet: MouseButtonDown
     119                 :            : |*
     120                 :            : \************************************************************************/
     121                 :            : 
     122                 :          0 : void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt )
     123                 :            : {
     124                 :            :     // Fuer Mac noch anders handlen !
     125         [ #  # ]:          0 :     if( rMEvt.IsLeft() )
     126                 :            :     {
     127                 :          0 :         bLeft = sal_True;
     128                 :          0 :         ValueSet::MouseButtonDown( rMEvt );
     129                 :            :     }
     130                 :            :     else
     131                 :            :     {
     132                 :          0 :         bLeft = sal_False;
     133                 :          0 :         MouseEvent aMEvt( rMEvt.GetPosPixel(),
     134                 :          0 :                           rMEvt.GetClicks(),
     135                 :          0 :                           rMEvt.GetMode(),
     136                 :            :                           MOUSE_LEFT,
     137         [ #  # ]:          0 :                           rMEvt.GetModifier() );
     138         [ #  # ]:          0 :         ValueSet::MouseButtonDown( aMEvt );
     139                 :            :     }
     140                 :            : 
     141                 :          0 :     aDragPosPixel = GetPointerPosPixel();
     142                 :          0 : }
     143                 :            : 
     144                 :            : /*************************************************************************
     145                 :            : |*
     146                 :            : |* SvxColorValueSet: MouseButtonUp
     147                 :            : |*
     148                 :            : \************************************************************************/
     149                 :            : 
     150                 :          0 : void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt )
     151                 :            : {
     152                 :            :     // Fuer Mac noch anders handlen !
     153         [ #  # ]:          0 :     if( rMEvt.IsLeft() )
     154                 :            :     {
     155                 :          0 :         bLeft = sal_True;
     156                 :          0 :         ValueSet::MouseButtonUp( rMEvt );
     157                 :            :     }
     158                 :            :     else
     159                 :            :     {
     160                 :          0 :         bLeft = sal_False;
     161                 :          0 :         MouseEvent aMEvt( rMEvt.GetPosPixel(),
     162                 :          0 :                           rMEvt.GetClicks(),
     163                 :          0 :                           rMEvt.GetMode(),
     164                 :            :                           MOUSE_LEFT,
     165         [ #  # ]:          0 :                           rMEvt.GetModifier() );
     166         [ #  # ]:          0 :         ValueSet::MouseButtonUp( aMEvt );
     167                 :            :     }
     168                 :          0 :     SetNoSelection();
     169                 :          0 : }
     170                 :            : 
     171                 :            : /*************************************************************************
     172                 :            : |*
     173                 :            : |* Command-Event
     174                 :            : |*
     175                 :            : \************************************************************************/
     176                 :            : 
     177                 :          0 : void SvxColorValueSet::Command(const CommandEvent& rCEvt)
     178                 :            : {
     179                 :            :     // Basisklasse
     180                 :          0 :     ValueSet::Command(rCEvt);
     181                 :          0 : }
     182                 :            : 
     183                 :            : /*************************************************************************
     184                 :            : |*
     185                 :            : |* StartDrag
     186                 :            : |*
     187                 :            : \************************************************************************/
     188                 :            : 
     189                 :          0 : void SvxColorValueSet::StartDrag( sal_Int8 , const Point&  )
     190                 :            : {
     191         [ #  # ]:          0 :     Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl));
     192                 :          0 : }
     193                 :            : 
     194                 :            : /*************************************************************************
     195                 :            : |*
     196                 :            : |* Drag&Drop asynchron ausfuehren
     197                 :            : |*
     198                 :            : \************************************************************************/
     199                 :            : 
     200                 :          0 : void SvxColorValueSet::DoDrag()
     201                 :            : {
     202                 :          0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
     203                 :          0 :     sal_uInt16          nItemId = GetItemId( aDragPosPixel );
     204                 :            : 
     205 [ #  # ][ #  # ]:          0 :     if( pDocSh && nItemId )
     206                 :            :     {
     207         [ #  # ]:          0 :         XFillAttrSetItem    aXFillSetItem( &pDocSh->GetPool() );
     208                 :          0 :         SfxItemSet&         rSet = aXFillSetItem.GetItemSet();
     209                 :            : 
     210 [ #  # ][ #  # ]:          0 :         rSet.Put( XFillColorItem( GetItemText( nItemId ), GetItemColor( nItemId ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     211 [ #  # ][ #  # ]:          0 :         rSet.Put(XFillStyleItem( ( 1 == nItemId ) ? XFILL_NONE : XFILL_SOLID ) );
                 [ #  # ]
     212                 :            : 
     213         [ #  # ]:          0 :         EndSelection();
     214 [ #  # ][ #  # ]:          0 :         ( new SvxColorValueSetData( aXFillSetItem ) )->StartDrag( this, DND_ACTION_COPY );
     215 [ #  # ][ #  # ]:          0 :         ReleaseMouse();
     216                 :            :     }
     217                 :          0 : }
     218                 :            : 
     219                 :          0 : IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG)
     220                 :            : {
     221                 :            :     // Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die
     222                 :            :     // Farbleiste geloescht werden darf
     223                 :          0 :     pThis->DoDrag();
     224                 :          0 :     return(0);
     225                 :            : }
     226                 :            : 
     227                 :            : /*************************************************************************
     228                 :            : |*
     229                 :            : |* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator
     230                 :            : |*
     231                 :            : \************************************************************************/
     232                 :            : 
     233                 :          0 : SvxColorChildWindow::SvxColorChildWindow( Window* _pParent,
     234                 :            :                                           sal_uInt16 nId,
     235                 :            :                                           SfxBindings* pBindings,
     236                 :            :                                           SfxChildWinInfo* pInfo ) :
     237                 :          0 :     SfxChildWindow( _pParent, nId )
     238                 :            : {
     239                 :            :     SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this,
     240 [ #  # ][ #  # ]:          0 :                                         _pParent, SVX_RES( RID_SVXCTRL_COLOR ) );
                 [ #  # ]
     241                 :          0 :     pWindow = pWin;
     242                 :            : 
     243                 :          0 :     eChildAlignment = SFX_ALIGN_BOTTOM;
     244                 :            : 
     245         [ #  # ]:          0 :     pWin->Initialize( pInfo );
     246                 :          0 : }
     247                 :            : 
     248                 :            : 
     249                 :            : 
     250                 :            : /*************************************************************************
     251                 :            : |*
     252                 :            : |* Ctor: SvxColorDockingWindow
     253                 :            : |*
     254                 :            : \************************************************************************/
     255                 :            : 
     256                 :          0 : SvxColorDockingWindow::SvxColorDockingWindow
     257                 :            : (
     258                 :            :     SfxBindings* _pBindings,
     259                 :            :     SfxChildWindow* pCW,
     260                 :            :     Window* _pParent,
     261                 :            :     const ResId& rResId
     262                 :            : ) :
     263                 :            : 
     264                 :            :     SfxDockingWindow( _pBindings, pCW, _pParent, rResId ),
     265                 :            :     pColorList      (),
     266                 :          0 :     aColorSet       ( this, ResId( 1, *rResId.GetResMgr() ) ),
     267                 :            :     nLeftSlot       ( SID_ATTR_FILL_COLOR ),
     268                 :            :     nRightSlot      ( SID_ATTR_LINE_COLOR ),
     269                 :            :     nCols           ( 20 ),
     270                 :            :     nLines          ( 1 ),
     271 [ #  # ][ #  # ]:          0 :     aColorSize      ( 14, 14 )
     272                 :            : 
     273                 :            : {
     274         [ #  # ]:          0 :     FreeResource();
     275                 :            : 
     276 [ #  # ][ #  # ]:          0 :     aColorSet.SetStyle( aColorSet.GetStyle() | WB_ITEMBORDER );
     277         [ #  # ]:          0 :     aColorSet.SetSelectHdl( LINK( this, SvxColorDockingWindow, SelectHdl ) );
     278                 :            : 
     279                 :            :     // Get the model from the view shell.  Using SfxObjectShell::Current()
     280                 :            :     // is unreliable when called at the wrong times.
     281                 :          0 :     SfxObjectShell* pDocSh = NULL;
     282         [ #  # ]:          0 :     if (_pBindings != NULL)
     283                 :            :     {
     284                 :          0 :         SfxDispatcher* pDispatcher = _pBindings->GetDispatcher();
     285         [ #  # ]:          0 :         if (pDispatcher != NULL)
     286                 :            :         {
     287         [ #  # ]:          0 :             SfxViewFrame* pFrame = pDispatcher->GetFrame();
     288         [ #  # ]:          0 :             if (pFrame != NULL)
     289                 :            :             {
     290         [ #  # ]:          0 :                 SfxViewShell* pViewShell = pFrame->GetViewShell();
     291         [ #  # ]:          0 :                 if (pViewShell != NULL)
     292         [ #  # ]:          0 :                     pDocSh = pViewShell->GetObjectShell();
     293                 :            :             }
     294                 :            :         }
     295                 :            :     }
     296                 :            : 
     297         [ #  # ]:          0 :     if ( pDocSh )
     298                 :            :     {
     299         [ #  # ]:          0 :         const SfxPoolItem*  pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     300         [ #  # ]:          0 :         if( pItem )
     301                 :            :         {
     302 [ #  # ][ #  # ]:          0 :             pColorList = ( (SvxColorListItem*) pItem )->GetColorList();
     303         [ #  # ]:          0 :             FillValueSet();
     304                 :            :         }
     305                 :            :     }
     306         [ #  # ]:          0 :     aItemSize = aColorSet.CalcItemSizePixel( aColorSize );
     307                 :          0 :     aItemSize.Width() = aItemSize.Width() + aColorSize.Width();
     308                 :          0 :     aItemSize.Width() /= 2;
     309                 :          0 :     aItemSize.Height() = aItemSize.Height() + aColorSize.Height();
     310                 :          0 :     aItemSize.Height() /= 2;
     311                 :            : 
     312         [ #  # ]:          0 :     SetSize();
     313         [ #  # ]:          0 :     aColorSet.Show();
     314         [ #  # ]:          0 :     StartListening( *_pBindings, sal_True );
     315                 :          0 : }
     316                 :            : 
     317                 :            : 
     318                 :            : /*************************************************************************
     319                 :            : |*
     320                 :            : |* Dtor: SvxColorDockingWindow
     321                 :            : |*
     322                 :            : \************************************************************************/
     323                 :            : 
     324 [ #  # ][ #  # ]:          0 : SvxColorDockingWindow::~SvxColorDockingWindow()
     325                 :            : {
     326         [ #  # ]:          0 :     EndListening( GetBindings() );
     327         [ #  # ]:          0 : }
     328                 :            : 
     329                 :            : /*************************************************************************
     330                 :            : |*
     331                 :            : |* Notify
     332                 :            : |*
     333                 :            : \************************************************************************/
     334                 :            : 
     335                 :          0 : void SvxColorDockingWindow::Notify( SfxBroadcaster& , const SfxHint& rHint )
     336                 :            : {
     337 [ #  # ][ #  # ]:          0 :     const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
     338   [ #  #  #  # ]:          0 :     if ( pPoolItemHint
                 [ #  # ]
     339                 :          0 :          && ( pPoolItemHint->GetObject()->ISA( SvxColorListItem ) ) )
     340                 :            :     {
     341                 :            :         // Die Liste der Farben hat sich geaendert
     342         [ #  # ]:          0 :         pColorList = ( (SvxColorListItem*) pPoolItemHint->GetObject() )->GetColorList();
     343                 :          0 :         FillValueSet();
     344                 :            :     }
     345                 :          0 : }
     346                 :            : 
     347                 :            : /*************************************************************************
     348                 :            : |*
     349                 :            : |* FillValueSet
     350                 :            : |*
     351                 :            : \************************************************************************/
     352                 :            : 
     353                 :          0 : void SvxColorDockingWindow::FillValueSet()
     354                 :            : {
     355         [ #  # ]:          0 :     if( pColorList.is() )
     356                 :            :     {
     357         [ #  # ]:          0 :         aColorSet.Clear();
     358                 :            : 
     359                 :            :         // Erster Eintrag: unsichtbar
     360                 :          0 :         long nPtX = aColorSize.Width() - 1;
     361                 :          0 :         long nPtY = aColorSize.Height() - 1;
     362         [ #  # ]:          0 :         VirtualDevice aVD;
     363         [ #  # ]:          0 :         aVD.SetOutputSizePixel( aColorSize );
     364         [ #  # ]:          0 :         aVD.SetLineColor( Color( COL_BLACK ) );
     365 [ #  # ][ #  # ]:          0 :         aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) );
                 [ #  # ]
     366         [ #  # ]:          0 :         aVD.DrawLine( Point(), Point( nPtX, nPtY ) );
     367         [ #  # ]:          0 :         aVD.DrawLine( Point( 0, nPtY ), Point( nPtX, 0 ) );
     368                 :            : 
     369         [ #  # ]:          0 :         Bitmap aBmp( aVD.GetBitmap( Point(), aColorSize ) );
     370                 :            : 
     371 [ #  # ][ #  # ]:          0 :         aColorSet.InsertItem( (sal_uInt16)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     372                 :            : 
     373                 :            :         XColorEntry* pEntry;
     374         [ #  # ]:          0 :         nCount = pColorList->Count();
     375                 :            : 
     376         [ #  # ]:          0 :         for( long i = 0; i < nCount; i++ )
     377                 :            :         {
     378         [ #  # ]:          0 :             pEntry = pColorList->GetColor( i );
     379                 :            :             aColorSet.InsertItem( (sal_uInt16)i+2,
     380         [ #  # ]:          0 :                             pEntry->GetColor(), pEntry->GetName() );
     381 [ #  # ][ #  # ]:          0 :         }
     382                 :            :     }
     383                 :          0 : }
     384                 :            : 
     385                 :            : /*************************************************************************
     386                 :            : |*
     387                 :            : |* SetSize
     388                 :            : |*
     389                 :            : \************************************************************************/
     390                 :            : 
     391                 :          0 : void SvxColorDockingWindow::SetSize()
     392                 :            : {
     393                 :            :     // Groesse fuer ValueSet berechnen
     394         [ #  # ]:          0 :     Size aSize = GetOutputSizePixel();
     395                 :          0 :     aSize.Width()  -= 4;
     396                 :          0 :     aSize.Height() -= 4;
     397                 :            : 
     398                 :            :     // Zeilen und Spalten berechnen
     399                 :          0 :     nCols = (sal_uInt16) ( aSize.Width() / aItemSize.Width() );
     400                 :          0 :     nLines = (sal_uInt16) ( (float) aSize.Height() / (float) aItemSize.Height() /*+ 0.35*/ );
     401         [ #  # ]:          0 :     if( nLines == 0 )
     402                 :          0 :         nLines++;
     403                 :            : 
     404                 :            :     // Scrollbar setzen/entfernen
     405         [ #  # ]:          0 :     WinBits nBits = aColorSet.GetStyle();
     406         [ #  # ]:          0 :     if ( nLines * nCols >= nCount )
     407                 :          0 :         nBits &= ~WB_VSCROLL;
     408                 :            :     else
     409                 :          0 :         nBits |= WB_VSCROLL;
     410         [ #  # ]:          0 :     aColorSet.SetStyle( nBits );
     411                 :            : 
     412                 :            :     // ScrollBar ?
     413         [ #  # ]:          0 :     long nScrollWidth = aColorSet.GetScrollWidth();
     414         [ #  # ]:          0 :     if( nScrollWidth > 0 )
     415                 :            :     {
     416                 :            :         // Spalten mit ScrollBar berechnen
     417                 :          0 :         nCols = (sal_uInt16) ( ( aSize.Width() - nScrollWidth ) / aItemSize.Width() );
     418                 :            :     }
     419         [ #  # ]:          0 :     aColorSet.SetColCount( nCols );
     420                 :            : 
     421 [ #  # ][ #  # ]:          0 :     if( IsFloatingMode() )
     422         [ #  # ]:          0 :         aColorSet.SetLineCount( nLines );
     423                 :            :     else
     424                 :            :     {
     425         [ #  # ]:          0 :         aColorSet.SetLineCount( 0 ); // sonst wird LineHeight ignoriert
     426         [ #  # ]:          0 :         aColorSet.SetItemHeight( aItemSize.Height() );
     427                 :            :     }
     428                 :            : 
     429         [ #  # ]:          0 :     aColorSet.SetPosSizePixel( Point( 2, 2 ), aSize );
     430                 :          0 : }
     431                 :            : 
     432                 :            : /*************************************************************************
     433                 :            : |*
     434                 :            : |* SvxColorDockingWindow: Close
     435                 :            : |*
     436                 :            : \************************************************************************/
     437                 :            : 
     438                 :          0 : sal_Bool SvxColorDockingWindow::Close()
     439                 :            : {
     440         [ #  # ]:          0 :     SfxBoolItem aItem( SID_COLOR_CONTROL, sal_False );
     441                 :          0 :     GetBindings().GetDispatcher()->Execute(
     442         [ #  # ]:          0 :         SID_COLOR_CONTROL, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
     443         [ #  # ]:          0 :     SfxDockingWindow::Close();
     444         [ #  # ]:          0 :     return( sal_True );
     445                 :            : }
     446                 :            : 
     447                 :            : /*************************************************************************
     448                 :            : |*
     449                 :            : |* SelectHdl
     450                 :            : |*
     451                 :            : \************************************************************************/
     452                 :            : 
     453                 :          0 : IMPL_LINK_NOARG(SvxColorDockingWindow, SelectHdl)
     454                 :            : {
     455                 :          0 :     SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
     456                 :          0 :     sal_uInt16 nPos = aColorSet.GetSelectItemId();
     457         [ #  # ]:          0 :     Color  aColor( aColorSet.GetItemColor( nPos ) );
     458         [ #  # ]:          0 :     String aStr( aColorSet.GetItemText( nPos ) );
     459                 :            : 
     460         [ #  # ]:          0 :     if (aColorSet.IsLeftButton())
     461                 :            :     {
     462         [ #  # ]:          0 :         if ( nLeftSlot == SID_ATTR_FILL_COLOR )
     463                 :            :         {
     464         [ #  # ]:          0 :             if ( nPos == 1 )        // unsichtbar
     465                 :            :             {
     466         [ #  # ]:          0 :                 XFillStyleItem aXFillStyleItem( XFILL_NONE );
     467 [ #  # ][ #  # ]:          0 :                 pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L );
     468                 :            :             }
     469                 :            :             else
     470                 :            :             {
     471                 :          0 :                 sal_Bool bDone = sal_False;
     472                 :            : 
     473                 :            :                 // Wenn wir eine DrawView haben und uns im TextEdit-Modus befinden,
     474                 :            :                 // wird nicht die Flaechen-, sondern die Textfarbe zugewiesen
     475         [ #  # ]:          0 :                 SfxViewShell* pViewSh = SfxViewShell::Current();
     476         [ #  # ]:          0 :                 if ( pViewSh )
     477                 :            :                 {
     478         [ #  # ]:          0 :                     SdrView* pView = pViewSh->GetDrawView();
     479 [ #  # ][ #  # ]:          0 :                     if ( pView && pView->IsTextEdit() )
         [ #  # ][ #  # ]
     480                 :            :                     {
     481         [ #  # ]:          0 :                         SvxColorItem aTextColorItem( aColor, SID_ATTR_CHAR_COLOR );
     482                 :            :                         pDispatcher->Execute(
     483         [ #  # ]:          0 :                             SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aTextColorItem, 0L );
     484         [ #  # ]:          0 :                         bDone = sal_True;
     485                 :            :                     }
     486                 :            :                 }
     487         [ #  # ]:          0 :                 if ( !bDone )
     488                 :            :                 {
     489         [ #  # ]:          0 :                     XFillStyleItem aXFillStyleItem( XFILL_SOLID );
     490         [ #  # ]:          0 :                     XFillColorItem aXFillColorItem( aStr, aColor );
     491                 :            :                     pDispatcher->Execute(
     492 [ #  # ][ #  # ]:          0 :                         nLeftSlot, SFX_CALLMODE_RECORD, &aXFillColorItem, &aXFillStyleItem, 0L );
                 [ #  # ]
     493                 :            :                 }
     494                 :            :             }
     495                 :            :         }
     496         [ #  # ]:          0 :         else if ( nPos != 1 )       // unsichtbar
     497                 :            :         {
     498         [ #  # ]:          0 :             SvxColorItem aLeftColorItem( aColor, nLeftSlot );
     499 [ #  # ][ #  # ]:          0 :             pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aLeftColorItem, 0L );
     500                 :            :         }
     501                 :            :     }
     502                 :            :     else
     503                 :            :     {
     504         [ #  # ]:          0 :         if ( nRightSlot == SID_ATTR_LINE_COLOR )
     505                 :            :         {
     506         [ #  # ]:          0 :             if( nPos == 1 )     // unsichtbar
     507                 :            :             {
     508         [ #  # ]:          0 :                 XLineStyleItem aXLineStyleItem( XLINE_NONE );
     509 [ #  # ][ #  # ]:          0 :                 pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L );
     510                 :            :             }
     511                 :            :             else
     512                 :            :             {
     513                 :            :                 // Sollte der LineStyle unsichtbar sein, so wird er auf SOLID gesetzt
     514         [ #  # ]:          0 :                 SfxViewShell* pViewSh = SfxViewShell::Current();
     515         [ #  # ]:          0 :                 if ( pViewSh )
     516                 :            :                 {
     517         [ #  # ]:          0 :                     SdrView* pView = pViewSh->GetDrawView();
     518         [ #  # ]:          0 :                     if ( pView )
     519                 :            :                     {
     520         [ #  # ]:          0 :                         SfxItemSet aAttrSet( pView->GetModel()->GetItemPool() );
     521         [ #  # ]:          0 :                         pView->GetAttributes( aAttrSet );
     522 [ #  # ][ #  # ]:          0 :                         if ( aAttrSet.GetItemState( XATTR_LINESTYLE ) != SFX_ITEM_DONTCARE )
     523                 :            :                         {
     524                 :            :                             XLineStyle eXLS = (XLineStyle)
     525         [ #  # ]:          0 :                                 ( (const XLineStyleItem&)aAttrSet.Get( XATTR_LINESTYLE ) ).GetValue();
     526         [ #  # ]:          0 :                             if ( eXLS == XLINE_NONE )
     527                 :            :                             {
     528         [ #  # ]:          0 :                                 XLineStyleItem aXLineStyleItem( XLINE_SOLID );
     529 [ #  # ][ #  # ]:          0 :                                 pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L );
     530                 :            :                             }
     531         [ #  # ]:          0 :                         }
     532                 :            :                     }
     533                 :            :                 }
     534                 :            : 
     535         [ #  # ]:          0 :                 XLineColorItem aXLineColorItem( aStr, aColor );
     536 [ #  # ][ #  # ]:          0 :                 pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineColorItem, 0L );
     537                 :            :             }
     538                 :            :         }
     539         [ #  # ]:          0 :         else if ( nPos != 1 )       // unsichtbar
     540                 :            :         {
     541         [ #  # ]:          0 :             SvxColorItem aRightColorItem( aColor, nRightSlot );
     542 [ #  # ][ #  # ]:          0 :             pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aRightColorItem, 0L );
     543                 :            :         }
     544                 :            :     }
     545                 :            : 
     546         [ #  # ]:          0 :     return 0;
     547                 :            : }
     548                 :            : 
     549                 :            : /*************************************************************************
     550                 :            : |*
     551                 :            : |* Resizing
     552                 :            : |*
     553                 :            : \************************************************************************/
     554                 :            : 
     555                 :            : 
     556                 :          0 : void SvxColorDockingWindow::Resizing( Size& rNewSize )
     557                 :            : {
     558                 :          0 :     rNewSize.Width()  -= 4;
     559                 :          0 :     rNewSize.Height() -= 4;
     560                 :            : 
     561                 :            :     // Spalten und Reihen ermitteln
     562                 :          0 :     nCols = (sal_uInt16) ( (float) rNewSize.Width() / (float) aItemSize.Width() + 0.5 );
     563                 :          0 :     nLines = (sal_uInt16) ( (float) rNewSize.Height() / (float) aItemSize.Height() + 0.5 );
     564         [ #  # ]:          0 :     if( nLines == 0 )
     565                 :          0 :         nLines = 1;
     566                 :            : 
     567                 :            :     // Scrollbar setzen/entfernen
     568         [ #  # ]:          0 :     WinBits nBits = aColorSet.GetStyle();
     569         [ #  # ]:          0 :     if ( nLines * nCols >= nCount )
     570                 :          0 :         nBits &= ~WB_VSCROLL;
     571                 :            :     else
     572                 :          0 :         nBits |= WB_VSCROLL;
     573         [ #  # ]:          0 :     aColorSet.SetStyle( nBits );
     574                 :            : 
     575                 :            :     // ScrollBar ?
     576         [ #  # ]:          0 :     long nScrollWidth = aColorSet.GetScrollWidth();
     577         [ #  # ]:          0 :     if( nScrollWidth > 0 )
     578                 :            :     {
     579                 :            :         // Spalten mit ScrollBar berechnen
     580                 :          0 :         nCols = (sal_uInt16) ( ( ( (float) rNewSize.Width() - (float) nScrollWidth ) )
     581                 :          0 :                             / (float) aItemSize.Width() + 0.5 );
     582                 :            :     }
     583         [ #  # ]:          0 :     if( nCols <= 1 )
     584                 :          0 :         nCols = 2;
     585                 :            : 
     586                 :            :     // Max. Reihen anhand der gegebenen Spalten berechnen
     587                 :          0 :     long nMaxLines = nCount / nCols;
     588         [ #  # ]:          0 :     if( nCount %  nCols )
     589                 :          0 :         nMaxLines++;
     590                 :            : 
     591                 :            :     nLines = sal::static_int_cast< sal_uInt16 >(
     592         [ #  # ]:          0 :         std::min< long >( nLines, nMaxLines ) );
     593                 :            : 
     594                 :            :     // Groesse des Windows setzen
     595                 :          0 :     rNewSize.Width()  = nCols * aItemSize.Width() + nScrollWidth + 4;
     596                 :          0 :     rNewSize.Height() = nLines * aItemSize.Height() + 4;
     597                 :          0 : }
     598                 :            : 
     599                 :            : /*************************************************************************
     600                 :            : |*
     601                 :            : |* Resize
     602                 :            : |*
     603                 :            : \************************************************************************/
     604                 :            : 
     605                 :          0 : void SvxColorDockingWindow::Resize()
     606                 :            : {
     607 [ #  # ][ #  # ]:          0 :     if ( !IsFloatingMode() || !GetFloatingWindow()->IsRollUp() )
                 [ #  # ]
     608                 :          0 :         SetSize();
     609                 :          0 :     SfxDockingWindow::Resize();
     610                 :          0 : }
     611                 :            : 
     612                 :            : 
     613                 :            : 
     614                 :          0 : void SvxColorDockingWindow::GetFocus (void)
     615                 :            : {
     616                 :          0 :     SfxDockingWindow::GetFocus();
     617                 :            :     // Grab the focus to the color value set so that it can be controlled
     618                 :            :     // with the keyboard.
     619                 :          0 :     aColorSet.GrabFocus();
     620                 :          0 : }
     621                 :            : 
     622                 :          0 : long SvxColorDockingWindow::Notify( NotifyEvent& rNEvt )
     623                 :            : {
     624                 :          0 :     long nRet = 0;
     625         [ #  # ]:          0 :     if( ( rNEvt.GetType() == EVENT_KEYINPUT ) )
     626                 :            :     {
     627 [ #  # ][ #  # ]:          0 :         KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
     628                 :          0 :         sal_uInt16   nKeyCode = aKeyEvt.GetKeyCode().GetCode();
     629         [ #  # ]:          0 :         switch( nKeyCode )
     630                 :            :         {
     631                 :            :             case KEY_ESCAPE:
     632         [ #  # ]:          0 :                 GrabFocusToDocument();
     633                 :          0 :                 nRet = 1;
     634                 :          0 :                 break;
     635                 :            :         }
     636                 :            :     }
     637                 :            : 
     638         [ #  # ]:          0 :     return nRet ? nRet : SfxDockingWindow::Notify( rNEvt );
     639                 :            : }
     640                 :            : 
     641                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10