LCOV - code coverage report
Current view: top level - svx/source/tbxctrls - linectrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 95 315 30.2 %
Date: 2012-08-25 Functions: 29 48 60.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 59 442 13.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                 :            : #include <string>
      30                 :            : 
      31                 :            : #include <vcl/toolbox.hxx>
      32                 :            : #include <sfx2/app.hxx>
      33                 :            : #include <sfx2/dispatch.hxx>
      34                 :            : #include <sfx2/objsh.hxx>
      35                 :            : 
      36                 :            : #include <svx/dialogs.hrc>
      37                 :            : #include "helpid.hrc"
      38                 :            : 
      39                 :            : #include "svx/drawitem.hxx"
      40                 :            : #include "svx/xattr.hxx"
      41                 :            : #include <svx/xtable.hxx>
      42                 :            : #include "svx/linectrl.hxx"
      43                 :            : #include <svx/itemwin.hxx>
      44                 :            : #include <svx/dialmgr.hxx>
      45                 :            : 
      46                 :            : using namespace ::com::sun::star::uno;
      47                 :            : using namespace ::com::sun::star::beans;
      48                 :            : using namespace ::com::sun::star::util;
      49                 :            : using namespace ::com::sun::star::frame;
      50                 :            : using namespace ::com::sun::star::lang;
      51                 :            : 
      52                 :            : // Fuer Linienenden-Controller
      53                 :            : #define MAX_LINES 12
      54                 :            : 
      55                 :            : // STATIC DATA -----------------------------------------------------------
      56                 :            : 
      57         [ +  - ]:        278 : SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem );
      58         [ +  - ]:        278 : SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem );
      59         [ +  - ]:        278 : SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem );
      60         [ +  - ]:        278 : SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl,   SfxBoolItem );
      61                 :            : 
      62                 :            : /*************************************************************************
      63                 :            : |*
      64                 :            : |* SvxLineStyleToolBoxControl
      65                 :            : |*
      66                 :            : \************************************************************************/
      67                 :            : 
      68                 :        129 : SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( sal_uInt16 nSlotId,
      69                 :            :                                                         sal_uInt16 nId,
      70                 :            :                                                         ToolBox& rTbx ) :
      71                 :            :     SfxToolBoxControl( nSlotId, nId, rTbx ),
      72                 :            :     pStyleItem      ( NULL ),
      73                 :            :     pDashItem       ( NULL ),
      74                 :        129 :     bUpdate         ( sal_False )
      75                 :            : {
      76 [ +  - ][ +  - ]:        129 :     addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )));
      77 [ +  - ][ +  - ]:        129 :     addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DashListState" )));
      78                 :        129 : }
      79                 :            : 
      80                 :            : //========================================================================
      81                 :            : 
      82                 :        129 : SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl()
      83                 :            : {
      84 [ +  + ][ +  - ]:        129 :     delete pStyleItem;
      85 [ +  + ][ +  - ]:        129 :     delete pDashItem;
      86         [ -  + ]:        258 : }
      87                 :            : 
      88                 :            : //========================================================================
      89                 :            : 
      90                 :        450 : void SvxLineStyleToolBoxControl::StateChanged (
      91                 :            : 
      92                 :            :     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
      93                 :            : 
      94                 :            : {
      95                 :        450 :     SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
      96                 :            :     DBG_ASSERT( pBox, "Window not found!" );
      97                 :            : 
      98         [ -  + ]:        450 :     if( eState == SFX_ITEM_DISABLED )
      99                 :            :     {
     100                 :          0 :         pBox->Disable();
     101                 :          0 :         pBox->SetNoSelection();
     102                 :            :     }
     103                 :            :     else
     104                 :            :     {
     105                 :        450 :         pBox->Enable();
     106                 :            : 
     107         [ +  + ]:        450 :         if ( eState == SFX_ITEM_AVAILABLE )
     108                 :            :         {
     109         [ +  + ]:        300 :             if( nSID == SID_ATTR_LINE_STYLE )
     110                 :            :             {
     111         [ +  + ]:        150 :                 delete pStyleItem;
     112                 :        150 :                 pStyleItem = (XLineStyleItem*)pState->Clone();
     113                 :            :             }
     114         [ +  - ]:        150 :             else if( nSID == SID_ATTR_LINE_DASH )
     115                 :            :             {
     116         [ +  + ]:        150 :                 delete pDashItem;
     117                 :        150 :                 pDashItem = (XLineDashItem*)pState->Clone();
     118                 :            :             }
     119                 :            : 
     120                 :        300 :             bUpdate = sal_True;
     121                 :        300 :             Update( pState );
     122                 :            :         }
     123         [ -  + ]:        150 :         else if ( nSID != SID_DASH_LIST )
     124                 :            :         {
     125                 :            :             // kein oder uneindeutiger Status
     126                 :          0 :             pBox->SetNoSelection();
     127                 :            :         }
     128                 :            :     }
     129                 :        450 : }
     130                 :            : 
     131                 :            : //========================================================================
     132                 :            : 
     133                 :        300 : void SvxLineStyleToolBoxControl::Update( const SfxPoolItem* pState )
     134                 :            : {
     135 [ +  - ][ +  - ]:        300 :     if ( pState && bUpdate )
     136                 :            :     {
     137                 :        300 :         bUpdate = sal_False;
     138                 :            : 
     139                 :        300 :         SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
     140                 :            :         DBG_ASSERT( pBox, "Window not found!" );
     141                 :            : 
     142                 :            :         // Da der Timer unerwartet zuschlagen kann, kann es vorkommen, dass
     143                 :            :         // die LB noch nicht gefuellt ist. Ein ClearCache() am Control im
     144                 :            :         // DelayHdl() blieb ohne Erfolg.
     145         [ -  + ]:        300 :         if( pBox->GetEntryCount() == 0 )
     146                 :          0 :             pBox->FillControl();
     147                 :            : 
     148                 :            :         XLineStyle eXLS;
     149                 :            : 
     150         [ +  - ]:        300 :         if ( pStyleItem )
     151                 :        300 :             eXLS = ( XLineStyle )pStyleItem->GetValue();
     152                 :            :         else
     153                 :          0 :             eXLS = XLINE_NONE;
     154                 :            : 
     155   [ -  +  -  - ]:        300 :         switch( eXLS )
     156                 :            :         {
     157                 :            :             case XLINE_NONE:
     158                 :          0 :                 pBox->SelectEntryPos( 0 );
     159                 :          0 :                 break;
     160                 :            : 
     161                 :            :             case XLINE_SOLID:
     162                 :        300 :                 pBox->SelectEntryPos( 1 );
     163                 :        300 :                 break;
     164                 :            : 
     165                 :            :             case XLINE_DASH:
     166                 :            :             {
     167         [ #  # ]:          0 :                 if( pDashItem )
     168                 :            :                 {
     169         [ #  # ]:          0 :                     String aString( pDashItem->GetName() );
     170 [ #  # ][ #  # ]:          0 :                     pBox->SelectEntry( aString );
     171                 :            :                 }
     172                 :            :                 else
     173                 :          0 :                     pBox->SetNoSelection();
     174                 :            :             }
     175                 :          0 :             break;
     176                 :            : 
     177                 :            :             default:
     178                 :            :                 OSL_FAIL( "Nicht unterstuetzter Linientyp" );
     179                 :        300 :                 break;
     180                 :            :         }
     181                 :            :     }
     182                 :            : 
     183 [ +  - ][ -  + ]:        300 :     if ( pState && ( pState->ISA( SvxDashListItem ) ) )
                 [ -  + ]
     184                 :            :     {
     185                 :            :         // Die Liste der Linienstile hat sich geaendert
     186 [ #  # ][ #  # ]:          0 :         SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
                 [ #  # ]
     187                 :            :         DBG_ASSERT( pBox, "Window not found!" );
     188                 :            : 
     189         [ #  # ]:          0 :         String aString( pBox->GetSelectEntry() );
     190         [ #  # ]:          0 :         pBox->Clear();
     191 [ #  # ][ #  # ]:          0 :         pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) );
         [ #  # ][ #  # ]
                 [ #  # ]
     192 [ #  # ][ #  # ]:          0 :         pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_SOLID) );
         [ #  # ][ #  # ]
                 [ #  # ]
     193 [ #  # ][ #  # ]:          0 :         pBox->Fill( ((SvxDashListItem*)pState )->GetDashList() );
     194 [ #  # ][ #  # ]:          0 :         pBox->SelectEntry( aString );
     195                 :            :     }
     196                 :        300 : }
     197                 :            : 
     198                 :            : //========================================================================
     199                 :            : 
     200                 :        129 : Window* SvxLineStyleToolBoxControl::CreateItemWindow( Window *pParent )
     201                 :            : {
     202         [ +  - ]:        129 :     return new SvxLineBox( pParent, m_xFrame );
     203                 :            : }
     204                 :            : 
     205                 :            : /*************************************************************************
     206                 :            : |*
     207                 :            : |* SvxLineWidthToolBoxControl
     208                 :            : |*
     209                 :            : \************************************************************************/
     210                 :            : 
     211                 :        129 : SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl(
     212                 :            :     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     213                 :        129 :     SfxToolBoxControl( nSlotId, nId, rTbx )
     214                 :            : {
     215 [ +  - ][ +  - ]:        129 :     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" )));
     216                 :        129 : }
     217                 :            : 
     218                 :            : //========================================================================
     219                 :            : 
     220                 :        129 : SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl()
     221                 :            : {
     222         [ -  + ]:        258 : }
     223                 :            : 
     224                 :            : //========================================================================
     225                 :            : 
     226                 :        356 : void SvxLineWidthToolBoxControl::StateChanged(
     227                 :            :     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
     228                 :            : {
     229                 :            :     SvxMetricField* pFld = (SvxMetricField*)
     230                 :        356 :                            GetToolBox().GetItemWindow( GetId() );
     231                 :            :     DBG_ASSERT( pFld, "Window not found" );
     232                 :            : 
     233         [ +  + ]:        356 :     if ( nSID == SID_ATTR_METRIC )
     234                 :            :     {
     235                 :        206 :         pFld->RefreshDlgUnit();
     236                 :            :     }
     237                 :            :     else
     238                 :            :     {
     239         [ -  + ]:        150 :         if ( eState == SFX_ITEM_DISABLED )
     240                 :            :         {
     241                 :          0 :             pFld->Disable();
     242         [ #  # ]:          0 :             pFld->SetText( String() );
     243                 :            :         }
     244                 :            :         else
     245                 :            :         {
     246                 :        150 :             pFld->Enable();
     247                 :            : 
     248         [ +  - ]:        150 :             if ( eState == SFX_ITEM_AVAILABLE )
     249                 :            :             {
     250                 :            :                 DBG_ASSERT( pState->ISA(XLineWidthItem), "falscher ItemType" );
     251                 :            : 
     252                 :            :                 // Core-Unit an MetricField uebergeben
     253                 :            :                 // Darf nicht in CreateItemWin() geschehen!
     254                 :        150 :                 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; // CD!!! GetCoreMetric();
     255                 :        150 :                 pFld->SetCoreUnit( eUnit );
     256                 :            : 
     257                 :        150 :                 pFld->Update( (const XLineWidthItem*)pState );
     258                 :            :             }
     259                 :            :             else
     260                 :          0 :                 pFld->Update( NULL );
     261                 :            :         }
     262                 :            :     }
     263                 :        356 : }
     264                 :            : 
     265                 :            : //========================================================================
     266                 :            : 
     267                 :        129 : Window* SvxLineWidthToolBoxControl::CreateItemWindow( Window *pParent )
     268                 :            : {
     269         [ +  - ]:        129 :     return( new SvxMetricField( pParent, m_xFrame ) );
     270                 :            : }
     271                 :            : 
     272                 :            : /*************************************************************************
     273                 :            : |*
     274                 :            : |* SvxLineColorToolBoxControl
     275                 :            : |*
     276                 :            : \************************************************************************/
     277                 :            : 
     278                 :        129 : SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
     279                 :            :     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     280                 :        129 :     SfxToolBoxControl( nSlotId, nId, rTbx )
     281                 :            : {
     282 [ +  - ][ +  - ]:        129 :     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
     283                 :        129 : }
     284                 :            : 
     285                 :            : //========================================================================
     286                 :            : 
     287                 :        129 : SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
     288                 :            : {
     289         [ -  + ]:        258 : }
     290                 :            : 
     291                 :            : //========================================================================
     292                 :            : 
     293                 :        300 : void SvxLineColorToolBoxControl::StateChanged(
     294                 :            : 
     295                 :            :     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
     296                 :            : 
     297                 :            : {
     298                 :        300 :     SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
     299                 :            :     DBG_ASSERT( pBox, "Window not found" );
     300                 :            : 
     301         [ +  + ]:        300 :     if ( nSID != SID_COLOR_TABLE )
     302                 :            :     {
     303         [ -  + ]:        150 :         if ( eState == SFX_ITEM_DISABLED )
     304                 :            :         {
     305                 :          0 :             pBox->Disable();
     306                 :          0 :             pBox->SetNoSelection();
     307                 :            :         }
     308                 :            :         else
     309                 :            :         {
     310                 :        150 :             pBox->Enable();
     311                 :            : 
     312         [ +  - ]:        150 :             if ( eState == SFX_ITEM_AVAILABLE )
     313                 :            :             {
     314                 :            :                 DBG_ASSERT( pState->ISA(XLineColorItem), "falscher ItemTyoe" );
     315                 :        150 :                 pBox->Update( (const XLineColorItem*) pState );
     316                 :            :             }
     317                 :            :             else
     318                 :          0 :                 pBox->Update( NULL );
     319                 :            :         }
     320                 :            :     }
     321                 :            :     else
     322                 :        150 :         Update( pState );
     323                 :        300 : }
     324                 :            : 
     325                 :            : //========================================================================
     326                 :            : 
     327                 :        150 : void SvxLineColorToolBoxControl::Update( const SfxPoolItem* pState )
     328                 :            : {
     329 [ +  - ][ -  + ]:        150 :     if ( pState && ( pState->ISA( SvxColorListItem ) ) )
                 [ -  + ]
     330                 :            :     {
     331 [ #  # ][ #  # ]:          0 :         SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
                 [ #  # ]
     332                 :            : 
     333                 :            :         DBG_ASSERT( pBox, "Window not found" );
     334                 :            : 
     335                 :            :         // Die Liste der Farben (ColorTable) hat sich geaendert:
     336         [ #  # ]:          0 :         ::Color aTmpColor( pBox->GetSelectEntryColor() );
     337         [ #  # ]:          0 :         pBox->Clear();
     338 [ #  # ][ #  # ]:          0 :         pBox->Fill( ( (SvxColorListItem*)pState )->GetColorList() );
     339         [ #  # ]:          0 :         pBox->SelectEntry( aTmpColor );
     340                 :            :     }
     341                 :        150 : }
     342                 :            : 
     343                 :            : //========================================================================
     344                 :            : 
     345                 :        129 : Window* SvxLineColorToolBoxControl::CreateItemWindow( Window *pParent )
     346                 :            : {
     347         [ +  - ]:        129 :     return new SvxColorBox( pParent, m_aCommandURL, m_xFrame );
     348                 :            : }
     349                 :            : 
     350                 :            : /*************************************************************************
     351                 :            : |*
     352                 :            : |* SvxLineEndWindow
     353                 :            : |*
     354                 :            : \************************************************************************/
     355                 :            : 
     356                 :          0 : SvxLineEndWindow::SvxLineEndWindow(
     357                 :            :     sal_uInt16 nSlotId,
     358                 :            :     const Reference< XFrame >& rFrame,
     359                 :            :     const String& rWndTitle ) :
     360                 :            :     SfxPopupWindow( nSlotId,
     361                 :            :                     rFrame,
     362                 :            :                     WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
     363                 :            :     aLineEndSet     ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
     364                 :            :     nCols           ( 2 ),
     365                 :            :     nLines          ( 12 ),
     366                 :            :     nLineEndWidth   ( 400 ),
     367                 :            :     bPopupMode      ( sal_True ),
     368                 :            :     mbInResize      ( false ),
     369         [ #  # ]:          0 :     mxFrame         ( rFrame )
     370                 :            : {
     371         [ #  # ]:          0 :     SetText( rWndTitle );
     372         [ #  # ]:          0 :     implInit();
     373                 :          0 : }
     374                 :            : 
     375                 :          0 : SvxLineEndWindow::SvxLineEndWindow(
     376                 :            :     sal_uInt16 nSlotId,
     377                 :            :     const Reference< XFrame >& rFrame,
     378                 :            :     Window* pParentWindow,
     379                 :            :     const String& rWndTitle ) :
     380                 :            :     SfxPopupWindow( nSlotId,
     381                 :            :                     rFrame,
     382                 :            :                     pParentWindow,
     383                 :            :                     WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
     384                 :            :     aLineEndSet     ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
     385                 :            :     nCols           ( 2 ),
     386                 :            :     nLines          ( 12 ),
     387                 :            :     nLineEndWidth   ( 400 ),
     388                 :            :     bPopupMode      ( sal_True ),
     389                 :            :     mbInResize      ( false ),
     390         [ #  # ]:          0 :     mxFrame         ( rFrame )
     391                 :            : {
     392         [ #  # ]:          0 :     SetText( rWndTitle );
     393         [ #  # ]:          0 :     implInit();
     394                 :          0 : }
     395                 :            : 
     396                 :          0 : void SvxLineEndWindow::implInit()
     397                 :            : {
     398                 :          0 :     SfxObjectShell*     pDocSh  = SfxObjectShell::Current();
     399                 :          0 :     const SfxPoolItem*  pItem   = NULL;
     400                 :            : 
     401         [ #  # ]:          0 :     SetHelpId( HID_POPUP_LINEEND );
     402         [ #  # ]:          0 :     aLineEndSet.SetHelpId( HID_POPUP_LINEEND_CTRL );
     403                 :            : 
     404         [ #  # ]:          0 :     if ( pDocSh )
     405                 :            :     {
     406                 :          0 :         pItem = pDocSh->GetItem( SID_LINEEND_LIST );
     407         [ #  # ]:          0 :         if( pItem )
     408         [ #  # ]:          0 :             pLineEndList = ( (SvxLineEndListItem*) pItem )->GetLineEndList();
     409                 :            : 
     410                 :          0 :         pItem = pDocSh->GetItem( SID_ATTR_LINEEND_WIDTH_DEFAULT );
     411         [ #  # ]:          0 :         if( pItem )
     412                 :          0 :             nLineEndWidth = ( (SfxUInt16Item*) pItem )->GetValue();
     413                 :            :     }
     414                 :            :     DBG_ASSERT( pLineEndList.is(), "LineEndList wurde nicht gefunden" );
     415                 :            : 
     416                 :          0 :     aLineEndSet.SetSelectHdl( LINK( this, SvxLineEndWindow, SelectHdl ) );
     417                 :          0 :     aLineEndSet.SetColCount( nCols );
     418                 :            : 
     419                 :            :     // ValueSet mit Eintraegen der LineEndList fuellen
     420                 :          0 :     FillValueSet();
     421                 :            : 
     422         [ #  # ]:          0 :     AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndListState" )));
     423                 :            : 
     424                 :            :     //ChangeHelpId( HID_POPUP_LINEENDSTYLE );
     425                 :          0 :     aLineEndSet.Show();
     426                 :          0 : }
     427                 :            : 
     428                 :          0 : SfxPopupWindow* SvxLineEndWindow::Clone() const
     429                 :            : {
     430 [ #  # ][ #  # ]:          0 :     return new SvxLineEndWindow( GetId(), mxFrame, GetText() );
     431                 :            : }
     432                 :            : 
     433                 :            : // -----------------------------------------------------------------------
     434                 :            : 
     435         [ #  # ]:          0 : SvxLineEndWindow::~SvxLineEndWindow()
     436                 :            : {
     437         [ #  # ]:          0 : }
     438                 :            : 
     439                 :            : // -----------------------------------------------------------------------
     440                 :            : 
     441                 :          0 : IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
     442                 :            : {
     443                 :          0 :     XLineEndItem*           pLineEndItem = NULL;
     444                 :          0 :     XLineStartItem*         pLineStartItem = NULL;
     445                 :          0 :     sal_uInt16                  nId = aLineEndSet.GetSelectItemId();
     446                 :            : 
     447         [ #  # ]:          0 :     if( nId == 1 )
     448                 :            :     {
     449 [ #  # ][ #  # ]:          0 :         pLineStartItem  = new XLineStartItem();
     450                 :            :     }
     451         [ #  # ]:          0 :     else if( nId == 2 )
     452                 :            :     {
     453 [ #  # ][ #  # ]:          0 :         pLineEndItem    = new XLineEndItem();
     454                 :            :     }
     455         [ #  # ]:          0 :     else if( nId % 2 ) // LinienAnfang
     456                 :            :     {
     457         [ #  # ]:          0 :         XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
     458 [ #  # ][ #  # ]:          0 :         pLineStartItem  = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() );
     459                 :            :     }
     460                 :            :     else // LinienEnde
     461                 :            :     {
     462         [ #  # ]:          0 :         XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
     463 [ #  # ][ #  # ]:          0 :         pLineEndItem    = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() );
     464                 :            :     }
     465                 :            : 
     466         [ #  # ]:          0 :     if ( IsInPopupMode() )
     467         [ #  # ]:          0 :         EndPopupMode();
     468                 :            : 
     469         [ #  # ]:          0 :     Sequence< PropertyValue > aArgs( 1 );
     470                 :          0 :     Any a;
     471                 :            : 
     472         [ #  # ]:          0 :     if ( pLineStartItem )
     473                 :            :     {
     474 [ #  # ][ #  # ]:          0 :         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStart" ));
     475         [ #  # ]:          0 :         pLineStartItem->QueryValue( a );
     476         [ #  # ]:          0 :         aArgs[0].Value = a;
     477                 :            :     }
     478                 :            :     else
     479                 :            :     {
     480 [ #  # ][ #  # ]:          0 :         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" ));
     481         [ #  # ]:          0 :         pLineEndItem->QueryValue( a );
     482         [ #  # ]:          0 :         aArgs[0].Value = a;
     483                 :            :     }
     484                 :            : 
     485                 :            :     /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
     486                 :            :         This instance may be deleted in the meantime (i.e. when a dialog is opened
     487                 :            :         while in Dispatch()), accessing members will crash in this case. */
     488         [ #  # ]:          0 :     aLineEndSet.SetNoSelection();
     489                 :            : 
     490         [ #  # ]:          0 :     SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
     491                 :            :                                  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndStyle" )),
     492 [ #  # ][ #  # ]:          0 :                                  aArgs );
         [ #  # ][ #  # ]
     493                 :            : 
     494 [ #  # ][ #  # ]:          0 :     delete pLineEndItem;
     495 [ #  # ][ #  # ]:          0 :     delete pLineStartItem;
     496                 :            : 
     497         [ #  # ]:          0 :     return 0;
     498                 :            : }
     499                 :            : 
     500                 :            : // -----------------------------------------------------------------------
     501                 :            : 
     502                 :          0 : void SvxLineEndWindow::FillValueSet()
     503                 :            : {
     504         [ #  # ]:          0 :     if( pLineEndList.is() )
     505                 :            :     {
     506                 :          0 :         XLineEndEntry*      pEntry  = NULL;
     507                 :          0 :         Bitmap*             pBmp    = NULL;
     508         [ #  # ]:          0 :         VirtualDevice       aVD;
     509                 :            : 
     510         [ #  # ]:          0 :         long nCount = pLineEndList->Count();
     511                 :            : 
     512                 :            :         // Erster Eintrag: kein LinienEnde
     513                 :            :         // Temporaer wird ein Eintrag hinzugefuegt, um die UI-Bitmap zu erhalten
     514         [ #  # ]:          0 :         basegfx::B2DPolyPolygon aNothing;
     515 [ #  # ][ #  # ]:          0 :         pLineEndList->Insert( new XLineEndEntry( aNothing, SVX_RESSTR( RID_SVXSTR_NONE ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     516         [ #  # ]:          0 :         pEntry = pLineEndList->GetLineEnd( nCount );
     517         [ #  # ]:          0 :         pBmp = pLineEndList->GetBitmap( nCount );
     518                 :            :         DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" );
     519                 :            : 
     520         [ #  # ]:          0 :         aBmpSize = pBmp->GetSizePixel();
     521         [ #  # ]:          0 :         aVD.SetOutputSizePixel( aBmpSize, sal_False );
     522                 :          0 :         aBmpSize.Width() = aBmpSize.Width() / 2;
     523                 :          0 :         Point aPt0( 0, 0 );
     524                 :          0 :         Point aPt1( aBmpSize.Width(), 0 );
     525                 :            : 
     526         [ #  # ]:          0 :         aVD.DrawBitmap( Point(), *pBmp );
     527 [ #  # ][ #  # ]:          0 :         aLineEndSet.InsertItem( 1, aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() );
         [ #  # ][ #  # ]
                 [ #  # ]
     528 [ #  # ][ #  # ]:          0 :         aLineEndSet.InsertItem( 2, aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() );
         [ #  # ][ #  # ]
                 [ #  # ]
     529                 :            : 
     530 [ #  # ][ #  # ]:          0 :         delete pLineEndList->Remove( nCount );
                 [ #  # ]
     531                 :            : 
     532         [ #  # ]:          0 :         for( long i = 0; i < nCount; i++ )
     533                 :            :         {
     534         [ #  # ]:          0 :             pEntry = pLineEndList->GetLineEnd( i );
     535                 :            :             DBG_ASSERT( pEntry, "Konnte auf LineEndEntry nicht zugreifen" );
     536         [ #  # ]:          0 :             pBmp = pLineEndList->GetBitmap( i );
     537                 :            :             DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" );
     538                 :            : 
     539         [ #  # ]:          0 :             aVD.DrawBitmap( aPt0, *pBmp );
     540 [ #  # ][ #  # ]:          0 :             aLineEndSet.InsertItem( (sal_uInt16)((i+1L)*2L+1L), aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() );
         [ #  # ][ #  # ]
                 [ #  # ]
     541 [ #  # ][ #  # ]:          0 :             aLineEndSet.InsertItem( (sal_uInt16)((i+2L)*2L),    aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() );
         [ #  # ][ #  # ]
                 [ #  # ]
     542                 :            :         }
     543                 :          0 :         nLines = Min( (sal_uInt16)(nCount + 1), (sal_uInt16) MAX_LINES );
     544         [ #  # ]:          0 :         aLineEndSet.SetLineCount( nLines );
     545                 :            : 
     546 [ #  # ][ #  # ]:          0 :         SetSize();
                 [ #  # ]
     547                 :            :     }
     548                 :          0 : }
     549                 :            : 
     550                 :            : // -----------------------------------------------------------------------
     551                 :            : 
     552                 :          0 : void SvxLineEndWindow::Resize()
     553                 :            : {
     554                 :            :     // since we change the size inside this call, check if we
     555                 :            :     // are called recursive
     556         [ #  # ]:          0 :     if( !mbInResize )
     557                 :            :     {
     558                 :          0 :         mbInResize = true;
     559         [ #  # ]:          0 :         if ( !IsRollUp() )
     560                 :            :         {
     561         [ #  # ]:          0 :             aLineEndSet.SetColCount( nCols );
     562         [ #  # ]:          0 :             aLineEndSet.SetLineCount( nLines );
     563                 :            : 
     564         [ #  # ]:          0 :             SetSize();
     565                 :            : 
     566                 :          0 :             Size aSize = GetOutputSizePixel();
     567                 :          0 :             aSize.Width()  -= 4;
     568                 :          0 :             aSize.Height() -= 4;
     569         [ #  # ]:          0 :             aLineEndSet.SetPosSizePixel( Point( 2, 2 ), aSize );
     570                 :            :         }
     571                 :            :         //SfxPopupWindow::Resize();
     572                 :          0 :         mbInResize = false;
     573                 :            :     }
     574                 :          0 : }
     575                 :            : 
     576                 :            : // -----------------------------------------------------------------------
     577                 :            : 
     578                 :          0 : void SvxLineEndWindow::Resizing( Size& rNewSize )
     579                 :            : {
     580                 :          0 :     Size aBitmapSize = aBmpSize; // -> Member
     581                 :          0 :     aBitmapSize.Width()  += 6; //
     582                 :          0 :     aBitmapSize.Height() += 6; //
     583                 :            : 
     584         [ #  # ]:          0 :     Size aItemSize = aLineEndSet.CalcItemSizePixel( aBitmapSize );  // -> Member
     585                 :            :     //Size aOldSize = GetOutputSizePixel(); // fuer Breite
     586                 :            : 
     587         [ #  # ]:          0 :     sal_uInt16 nItemCount = aLineEndSet.GetItemCount(); // -> Member
     588                 :            : 
     589                 :            :     // Spalten ermitteln
     590                 :          0 :     long nItemW = aItemSize.Width();
     591                 :          0 :     long nW = rNewSize.Width();
     592                 :            :     nCols = (sal_uInt16) Max( ( (sal_uIntPtr)(( nW + nItemW ) / ( nItemW * 2 ) )),
     593                 :          0 :                                             (sal_uIntPtr) 1L );
     594                 :          0 :     nCols *= 2;
     595                 :            : 
     596                 :            :     // Reihen ermitteln
     597                 :          0 :     long nItemH = aItemSize.Height();
     598                 :          0 :     long nH = rNewSize.Height();
     599                 :          0 :     nLines = (sal_uInt16) Max( ( ( nH + nItemH / 2 ) / nItemH ), 1L );
     600                 :            : 
     601                 :          0 :     sal_uInt16 nMaxCols  = nItemCount / nLines;
     602         [ #  # ]:          0 :     if( nItemCount % nLines )
     603                 :          0 :         nMaxCols++;
     604         [ #  # ]:          0 :     if( nCols > nMaxCols )
     605                 :          0 :         nCols = nMaxCols;
     606                 :          0 :     nW = nItemW * nCols;
     607                 :            : 
     608                 :            :     // Keine ungerade Anzahl von Spalten
     609         [ #  # ]:          0 :     if( nCols % 2 )
     610                 :          0 :         nCols--;
     611                 :          0 :     nCols = Max( nCols, (sal_uInt16) 2 );
     612                 :            : 
     613                 :          0 :     sal_uInt16 nMaxLines  = nItemCount / nCols;
     614         [ #  # ]:          0 :     if( nItemCount % nCols )
     615                 :          0 :         nMaxLines++;
     616         [ #  # ]:          0 :     if( nLines > nMaxLines )
     617                 :          0 :         nLines = nMaxLines;
     618                 :          0 :     nH = nItemH * nLines;
     619                 :            : 
     620                 :          0 :     rNewSize.Width() = nW;
     621                 :          0 :     rNewSize.Height() = nH;
     622                 :          0 : }
     623                 :            : // -----------------------------------------------------------------------
     624                 :            : 
     625                 :          0 : void SvxLineEndWindow::StartSelection()
     626                 :            : {
     627                 :          0 :     aLineEndSet.StartSelection();
     628                 :          0 : }
     629                 :            : 
     630                 :            : // -----------------------------------------------------------------------
     631                 :            : 
     632                 :          0 : sal_Bool SvxLineEndWindow::Close()
     633                 :            : {
     634                 :          0 :     return SfxPopupWindow::Close();
     635                 :            : }
     636                 :            : 
     637                 :            : // -----------------------------------------------------------------------
     638                 :            : 
     639                 :          0 : void SvxLineEndWindow::StateChanged(
     640                 :            :     sal_uInt16 nSID, SfxItemState, const SfxPoolItem* pState )
     641                 :            : {
     642         [ #  # ]:          0 :     if ( nSID == SID_LINEEND_LIST )
     643                 :            :     {
     644                 :            :         // Die Liste der LinienEnden (LineEndList) hat sich geaendert:
     645 [ #  # ][ #  # ]:          0 :         if ( pState && pState->ISA( SvxLineEndListItem ))
                 [ #  # ]
     646                 :            :         {
     647 [ #  # ][ #  # ]:          0 :             pLineEndList = ((SvxLineEndListItem*)pState)->GetLineEndList();
     648                 :            :             DBG_ASSERT( pLineEndList.is(), "LineEndList nicht gefunden" );
     649                 :            : 
     650         [ #  # ]:          0 :             aLineEndSet.Clear();
     651         [ #  # ]:          0 :             FillValueSet();
     652                 :            : 
     653                 :          0 :             Size aSize = GetOutputSizePixel();
     654         [ #  # ]:          0 :             Resizing( aSize );
     655         [ #  # ]:          0 :             Resize();
     656                 :            :         }
     657                 :            :     }
     658                 :          0 : }
     659                 :            : 
     660                 :            : // -----------------------------------------------------------------------
     661                 :            : 
     662                 :          0 : void SvxLineEndWindow::PopupModeEnd()
     663                 :            : {
     664         [ #  # ]:          0 :     if ( IsVisible() )
     665                 :            :     {
     666                 :          0 :         bPopupMode = sal_False;
     667                 :          0 :         SetSize();
     668                 :            :     }
     669                 :          0 :     SfxPopupWindow::PopupModeEnd();
     670                 :          0 : }
     671                 :            : 
     672                 :            : // -----------------------------------------------------------------------
     673                 :            : 
     674                 :          0 : void SvxLineEndWindow::SetSize()
     675                 :            : {
     676                 :            :     //if( !bPopupMode )
     677         [ #  # ]:          0 :     if( !IsInPopupMode() )
     678                 :            :     {
     679         [ #  # ]:          0 :         sal_uInt16 nItemCount = aLineEndSet.GetItemCount(); // -> Member
     680                 :          0 :         sal_uInt16 nMaxLines  = nItemCount / nCols; // -> Member ?
     681         [ #  # ]:          0 :         if( nItemCount % nCols )
     682                 :          0 :             nMaxLines++;
     683                 :            : 
     684         [ #  # ]:          0 :         WinBits nBits = aLineEndSet.GetStyle();
     685         [ #  # ]:          0 :         if ( nLines == nMaxLines )
     686                 :          0 :             nBits &= ~WB_VSCROLL;
     687                 :            :         else
     688                 :          0 :             nBits |= WB_VSCROLL;
     689         [ #  # ]:          0 :         aLineEndSet.SetStyle( nBits );
     690                 :            :     }
     691                 :            : 
     692                 :          0 :     Size aSize( aBmpSize );
     693                 :          0 :     aSize.Width()  += 6;
     694                 :          0 :     aSize.Height() += 6;
     695         [ #  # ]:          0 :     aSize = aLineEndSet.CalcWindowSizePixel( aSize );
     696                 :          0 :     aSize.Width()  += 4;
     697                 :          0 :     aSize.Height() += 4;
     698         [ #  # ]:          0 :     SetOutputSizePixel( aSize );
     699                 :          0 :     aSize.Height() = aBmpSize.Height();
     700                 :          0 :     aSize.Height() += 14;
     701                 :            :     //SetMinOutputSizePixel( aSize );
     702                 :          0 : }
     703                 :            : 
     704                 :          0 : void SvxLineEndWindow::GetFocus (void)
     705                 :            : {
     706                 :          0 :     SfxPopupWindow::GetFocus();
     707                 :            :     // Grab the focus to the line ends value set so that it can be controlled
     708                 :            :     // with the keyboard.
     709                 :          0 :     aLineEndSet.GrabFocus();
     710                 :          0 : }
     711                 :            : 
     712                 :            : /*************************************************************************
     713                 :            : |*
     714                 :            : |* SvxLineEndToolBoxControl
     715                 :            : |*
     716                 :            : \************************************************************************/
     717                 :            : 
     718                 :        129 : SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) :
     719                 :        129 :     SfxToolBoxControl( nSlotId, nId, rTbx )
     720                 :            : {
     721 [ +  - ][ +  - ]:        129 :     rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
     722         [ +  - ]:        129 :     rTbx.Invalidate();
     723                 :        129 : }
     724                 :            : 
     725                 :            : // -----------------------------------------------------------------------
     726                 :            : 
     727                 :        129 : SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl()
     728                 :            : {
     729         [ -  + ]:        258 : }
     730                 :            : 
     731                 :            : // -----------------------------------------------------------------------
     732                 :            : 
     733                 :          0 : SfxPopupWindowType SvxLineEndToolBoxControl::GetPopupWindowType() const
     734                 :            : {
     735                 :          0 :     return SFX_POPUPWINDOW_ONCLICK;
     736                 :            : }
     737                 :            : 
     738                 :            : // -----------------------------------------------------------------------
     739                 :            : 
     740                 :          0 : SfxPopupWindow* SvxLineEndToolBoxControl::CreatePopupWindow()
     741                 :            : {
     742                 :            :     SvxLineEndWindow* pLineEndWin =
     743 [ #  # ][ #  # ]:          0 :         new SvxLineEndWindow( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     744                 :          0 :     pLineEndWin->StartPopupMode( &GetToolBox(),
     745                 :            :                                  FLOATWIN_POPUPMODE_GRABFOCUS |
     746                 :            :                                  FLOATWIN_POPUPMODE_ALLOWTEAROFF |
     747                 :          0 :                                  FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
     748                 :          0 :     pLineEndWin->StartSelection();
     749                 :          0 :     SetPopupWindow( pLineEndWin );
     750                 :          0 :     return pLineEndWin;
     751                 :            : }
     752                 :            : 
     753                 :            : // -----------------------------------------------------------------------
     754                 :            : 
     755                 :        150 : void SvxLineEndToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* )
     756                 :            : {
     757                 :        150 :     sal_uInt16 nId = GetId();
     758                 :        150 :     ToolBox& rTbx = GetToolBox();
     759                 :            : 
     760                 :        150 :     rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
     761         [ -  + ]:        150 :     rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
     762                 :        150 : }
     763                 :            : 
     764                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10