LCOV - code coverage report
Current view: top level - cui/source/tabpages - numfmt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 806 0.0 %
Date: 2012-08-25 Functions: 0 48 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1563 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svl/eitem.hxx>
      30                 :            : #include <svl/intitem.hxx>
      31                 :            : #include <sfx2/objsh.hxx>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <unotools/localedatawrapper.hxx>
      34                 :            : #include <i18npool/lang.h>
      35                 :            : #include <svx/dialogs.hrc>
      36                 :            : #include <svtools/colorcfg.hxx>
      37                 :            : 
      38                 :            : #define _SVX_NUMFMT_CXX
      39                 :            : 
      40                 :            : #include <cuires.hrc>
      41                 :            : #include "numfmt.hrc"
      42                 :            : 
      43                 :            : #include <svx/numinf.hxx>
      44                 :            : 
      45                 :            : #include "numfmt.hxx"
      46                 :            : #include <svx/numfmtsh.hxx>
      47                 :            : #include <dialmgr.hxx>
      48                 :            : #include <sfx2/request.hxx>
      49                 :            : #include <sfx2/app.hxx>
      50                 :            : #include <sfx2/basedlgs.hxx>
      51                 :            : #include "svx/flagsdef.hxx"
      52                 :            : #include <vector>
      53                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      54                 :            : 
      55                 :            : using ::com::sun::star::uno::Reference;
      56                 :            : using ::com::sun::star::lang::XServiceInfo;
      57                 :            : using ::com::sun::star::uno::UNO_QUERY;
      58                 :            : 
      59                 :            : #define NUMKEY_UNDEFINED SAL_MAX_UINT32
      60                 :            : 
      61                 :            : // static ----------------------------------------------------------------
      62                 :            : 
      63                 :            : static sal_uInt16 pRanges[] =
      64                 :            : {
      65                 :            :     SID_ATTR_NUMBERFORMAT_VALUE,
      66                 :            :     SID_ATTR_NUMBERFORMAT_INFO,
      67                 :            :     SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
      68                 :            :     SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
      69                 :            :     SID_ATTR_NUMBERFORMAT_ONE_AREA,
      70                 :            :     SID_ATTR_NUMBERFORMAT_ONE_AREA,
      71                 :            :     SID_ATTR_NUMBERFORMAT_SOURCE,
      72                 :            :     SID_ATTR_NUMBERFORMAT_SOURCE,
      73                 :            :     0
      74                 :            : };
      75                 :            : 
      76                 :            : /*************************************************************************
      77                 :            : #*  Method:        SvxNumberPreviewImpl
      78                 :            : #*------------------------------------------------------------------------
      79                 :            : #*
      80                 :            : #*  Class:      SvxNumberPreview
      81                 :            : #*  Function:   Constructor of the class SvxNumberPreviewImpl
      82                 :            : #*  Input:      Window, Resource-ID
      83                 :            : #*  Output:     ---
      84                 :            : #*
      85                 :            : #************************************************************************/
      86                 :            : 
      87                 :          0 : SvxNumberPreviewImpl::SvxNumberPreviewImpl( Window* pParent, const ResId& rResId ) :
      88                 :            : 
      89                 :            :     Window( pParent, rResId ),
      90                 :            :     mnPos( STRING_NOTFOUND ),
      91         [ #  # ]:          0 :     mnChar( 0x0 )
      92                 :            : {
      93         [ #  # ]:          0 :     Font aFont( GetFont() );
      94         [ #  # ]:          0 :     aFont.SetTransparent( sal_True );
      95 [ #  # ][ #  # ]:          0 :     aFont.SetColor( Application::GetSettings().GetStyleSettings().GetFieldColor() );
      96         [ #  # ]:          0 :     SetFont( aFont );
      97         [ #  # ]:          0 :     InitSettings( sal_True, sal_True );
      98 [ #  # ][ #  # ]:          0 :     SetBorderStyle( WINDOW_BORDER_MONO );
      99                 :          0 : }
     100                 :            : 
     101                 :            : /*************************************************************************
     102                 :            : #*  Method:        SvxNumberPreviewImpl
     103                 :            : #*------------------------------------------------------------------------
     104                 :            : #*
     105                 :            : #*  Class:      SvxNumberPreview
     106                 :            : #*  Function:   Destructor of the class SvxNumberPreviewImpl
     107                 :            : #*  Input:      ---
     108                 :            : #*  Output:     ---
     109                 :            : #*
     110                 :            : #************************************************************************/
     111                 :            : 
     112         [ #  # ]:          0 : SvxNumberPreviewImpl::~SvxNumberPreviewImpl()
     113                 :            : {
     114         [ #  # ]:          0 : }
     115                 :            : 
     116                 :            : /*************************************************************************
     117                 :            : #*  Method:        NotifyChange
     118                 :            : #*------------------------------------------------------------------------
     119                 :            : #*
     120                 :            : #*  Class:      SvxNumberPreviewImpl
     121                 :            : #*  Function:   Function for changing the preview string
     122                 :            : #*  Input:      String, color
     123                 :            : #*  Output:     ---
     124                 :            : #*
     125                 :            : #************************************************************************/
     126                 :            : 
     127                 :          0 : void SvxNumberPreviewImpl::NotifyChange( const String& rPrevStr,
     128                 :            :                                          const Color* pColor )
     129                 :            : {
     130                 :            :     // detect and strip out '*' related placeholders
     131         [ #  # ]:          0 :     aPrevStr = rPrevStr;
     132         [ #  # ]:          0 :     mnPos = aPrevStr.Search( 0x1B );
     133         [ #  # ]:          0 :     if ( mnPos != STRING_NOTFOUND )
     134                 :            :     {
     135                 :          0 :         --mnPos;
     136                 :          0 :         mnChar = aPrevStr.GetChar( mnPos );
     137                 :            :         // delete placeholder and char to repeat
     138         [ #  # ]:          0 :         aPrevStr.Erase( mnPos, 2 );
     139                 :            :     }
     140         [ #  # ]:          0 :     svtools::ColorConfig aColorConfig;
     141         [ #  # ]:          0 :     Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
     142         [ #  # ]:          0 :     aPrevCol = pColor ? *pColor : aWindowTextColor;
     143         [ #  # ]:          0 :     Invalidate();
     144 [ #  # ][ #  # ]:          0 :     Update();
     145                 :          0 : }
     146                 :            : 
     147                 :            : /*************************************************************************
     148                 :            : #*  Method:        Paint
     149                 :            : #*------------------------------------------------------------------------
     150                 :            : #*
     151                 :            : #*  Class:      SvxNumberPreviewImpl
     152                 :            : #*  Function:   Function for repainting the window.
     153                 :            : #*  Input:      ---
     154                 :            : #*  Output:     ---
     155                 :            : #*
     156                 :            : #************************************************************************/
     157                 :            : 
     158                 :          0 : void SvxNumberPreviewImpl::Paint( const Rectangle& )
     159                 :            : {
     160         [ #  # ]:          0 :     Font    aDrawFont   = GetFont();
     161                 :          0 :     Size    aSzWnd      = GetOutputSizePixel();
     162         [ #  # ]:          0 :     String aTmpStr( aPrevStr );
     163         [ #  # ]:          0 :     long    nLeadSpace = (aSzWnd.Width()  - GetTextWidth( aTmpStr )) /2;
     164                 :            : 
     165         [ #  # ]:          0 :     aDrawFont.SetColor( aPrevCol );
     166         [ #  # ]:          0 :     SetFont( aDrawFont );
     167                 :            : 
     168         [ #  # ]:          0 :     if ( mnPos != STRING_NOTFOUND )
     169                 :            :     {
     170 [ #  # ][ #  # ]:          0 :         long nCharWidth = GetTextWidth( rtl::OUString::valueOf( mnChar ) );
                 [ #  # ]
     171                 :          0 :         int nNumCharsToInsert = nLeadSpace / nCharWidth;
     172                 :            : 
     173         [ #  # ]:          0 :         if ( nNumCharsToInsert )
     174                 :            :         {
     175         [ #  # ]:          0 :             for ( int i = 0; i < nNumCharsToInsert; ++i )
     176         [ #  # ]:          0 :                 aTmpStr.Insert( mnChar, mnPos );
     177                 :            :         }
     178                 :            :     }
     179                 :            :     Point   aPosText    = Point( ( mnPos != STRING_NOTFOUND ) ? 0 : nLeadSpace,
     180 [ #  # ][ #  # ]:          0 :                                  (aSzWnd.Height() - GetTextHeight())/2 );
     181 [ #  # ][ #  # ]:          0 :     DrawText( aPosText, aTmpStr );
                 [ #  # ]
     182                 :          0 : }
     183                 :            : 
     184                 :            : // -----------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : void SvxNumberPreviewImpl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
     187                 :            : {
     188                 :          0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     189                 :            : 
     190         [ #  # ]:          0 :     if ( bForeground )
     191                 :            :     {
     192         [ #  # ]:          0 :         svtools::ColorConfig aColorConfig;
     193         [ #  # ]:          0 :         Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
     194                 :            : 
     195 [ #  # ][ #  # ]:          0 :         if ( IsControlForeground() )
     196         [ #  # ]:          0 :             aTextColor = GetControlForeground();
     197 [ #  # ][ #  # ]:          0 :         SetTextColor( aTextColor );
     198                 :            :     }
     199                 :            : 
     200         [ #  # ]:          0 :     if ( bBackground )
     201                 :            :     {
     202         [ #  # ]:          0 :         if ( IsControlBackground() )
     203 [ #  # ][ #  # ]:          0 :             SetBackground( GetControlBackground() );
                 [ #  # ]
     204                 :            :         else
     205         [ #  # ]:          0 :             SetBackground( rStyleSettings.GetWindowColor() );
     206                 :            :     }
     207                 :          0 :     Invalidate();
     208                 :          0 : }
     209                 :            : 
     210                 :            : // -----------------------------------------------------------------------
     211                 :            : 
     212                 :          0 : void SvxNumberPreviewImpl::StateChanged( StateChangedType nType )
     213                 :            : {
     214         [ #  # ]:          0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     215                 :          0 :         InitSettings( sal_True, sal_False );
     216         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     217                 :          0 :         InitSettings( sal_False, sal_True );
     218                 :            : 
     219                 :          0 :     Window::StateChanged( nType );
     220                 :          0 : }
     221                 :            : 
     222                 :            : // -----------------------------------------------------------------------
     223                 :            : 
     224                 :          0 : void SvxNumberPreviewImpl::DataChanged( const DataChangedEvent& rDCEvt )
     225                 :            : {
     226                 :          0 :     Window::DataChanged( rDCEvt );
     227                 :            : 
     228 [ #  # ][ #  # ]:          0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
                 [ #  # ]
     229                 :          0 :         InitSettings( sal_True, sal_True );
     230                 :          0 : }
     231                 :            : 
     232                 :            : // class SvxNumberFormatTabPage ------------------------------------------
     233                 :            : 
     234                 :            : #define REMOVE_DONTKNOW() \
     235                 :            :     if ( !aFtLanguage.IsEnabled() )                                     \
     236                 :            :     {                                                                   \
     237                 :            :         aFtLanguage .Enable();                                          \
     238                 :            :         aLbLanguage .Enable();                                          \
     239                 :            :         aLbLanguage .SelectLanguage( pNumFmtShell->GetCurLanguage() );  \
     240                 :            :     }
     241                 :            : 
     242                 :            : #define HDL(hdl) LINK( this, SvxNumberFormatTabPage, hdl )
     243                 :            : 
     244                 :          0 : SvxNumberFormatTabPage::SvxNumberFormatTabPage( Window*             pParent,
     245                 :            :                                                 const SfxItemSet&   rCoreAttrs )
     246                 :            : 
     247                 :          0 :     :   SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_NUMBERFORMAT ), rCoreAttrs ),
     248                 :            : 
     249         [ #  # ]:          0 :         aFtCategory     ( this, CUI_RES( FT_CATEGORY ) ),
     250         [ #  # ]:          0 :         aLbCategory     ( this, CUI_RES( LB_CATEGORY ) ),
     251         [ #  # ]:          0 :         aFtFormat       ( this, CUI_RES( FT_FORMAT ) ),
     252         [ #  # ]:          0 :         aLbCurrency     ( this, CUI_RES( LB_CURRENCY) ),
     253         [ #  # ]:          0 :         aLbFormat       ( this, CUI_RES( LB_FORMAT ) ),
     254         [ #  # ]:          0 :         aFtLanguage     ( this, CUI_RES( FT_LANGUAGE ) ),
     255         [ #  # ]:          0 :         aLbLanguage     ( this, CUI_RES( LB_LANGUAGE ), sal_False ),
     256         [ #  # ]:          0 :         aCbSourceFormat ( this, CUI_RES( CB_SOURCEFORMAT ) ),
     257         [ #  # ]:          0 :         aWndPreview     ( this, CUI_RES( WND_NUMBER_PREVIEW ) ),
     258         [ #  # ]:          0 :         aFlOptions      ( this, CUI_RES( FL_OPTIONS ) ),
     259         [ #  # ]:          0 :         aFtDecimals     ( this, CUI_RES( FT_DECIMALS ) ),
     260         [ #  # ]:          0 :         aEdDecimals     ( this, CUI_RES( ED_DECIMALS ) ),
     261         [ #  # ]:          0 :         aBtnNegRed      ( this, CUI_RES( BTN_NEGRED ) ),
     262         [ #  # ]:          0 :         aFtLeadZeroes   ( this, CUI_RES( FT_LEADZEROES ) ),
     263         [ #  # ]:          0 :         aEdLeadZeroes   ( this, CUI_RES( ED_LEADZEROES ) ),
     264         [ #  # ]:          0 :         aBtnThousand    ( this, CUI_RES( BTN_THOUSAND ) ),
     265                 :            : 
     266         [ #  # ]:          0 :         aFtEdFormat     ( this, CUI_RES( FT_EDFORMAT ) ),
     267         [ #  # ]:          0 :         aEdFormat       ( this, CUI_RES( ED_FORMAT ) ),
     268         [ #  # ]:          0 :         aIbAdd          ( this, CUI_RES( IB_ADD       ) ),
     269         [ #  # ]:          0 :         aIbInfo         ( this, CUI_RES( IB_INFO      ) ),
     270         [ #  # ]:          0 :         aIbRemove       ( this, CUI_RES( IB_REMOVE    ) ),
     271         [ #  # ]:          0 :         aFtComment      ( this, CUI_RES( FT_COMMENT ) ),
     272         [ #  # ]:          0 :         aEdComment      ( this, CUI_RES( ED_COMMENT ) ),
     273                 :            : 
     274                 :            :         pNumItem        ( NULL ),
     275                 :            :         pNumFmtShell    ( NULL ),
     276                 :            :         nInitFormat     ( ULONG_MAX ),
     277                 :            : 
     278         [ #  # ]:          0 :         sAutomaticEntry ( CUI_RES( STR_AUTO_ENTRY)),
     279 [ #  # ][ #  # ]:          0 :         pLastActivWindow( NULL )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     280                 :            : {
     281         [ #  # ]:          0 :     Init_Impl();
     282                 :          0 :     SetExchangeSupport(); // this page needs ExchangeSupport
     283         [ #  # ]:          0 :     FreeResource();
     284                 :          0 :     nFixedCategory=-1;
     285                 :          0 : }
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 : SvxNumberFormatTabPage::~SvxNumberFormatTabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     288                 :            : {
     289 [ #  # ][ #  # ]:          0 :     delete pNumFmtShell;
     290 [ #  # ][ #  # ]:          0 :     delete pNumItem;
     291         [ #  # ]:          0 : }
     292                 :            : 
     293                 :          0 : void SvxNumberFormatTabPage::Init_Impl()
     294                 :            : {
     295 [ #  # ][ #  # ]:          0 :     ImageList               aIconList( CUI_RES ( IL_ICON ) );
     296                 :            : 
     297                 :          0 :     bNumItemFlag=sal_True;
     298                 :          0 :     bOneAreaFlag=sal_False;
     299                 :            : 
     300         [ #  # ]:          0 :     nCatHeight=aLbCategory.GetSizePixel().Height();
     301                 :            : 
     302         [ #  # ]:          0 :     nCurFormatY     =aLbFormat.GetPosPixel().Y();
     303         [ #  # ]:          0 :     nCurFormatHeight=aLbFormat.GetSizePixel().Height();
     304         [ #  # ]:          0 :     nStdFormatY     =aLbCurrency.GetPosPixel().Y();
     305                 :          0 :     nStdFormatHeight=nCurFormatY-nStdFormatY+nCurFormatHeight;
     306                 :            : 
     307 [ #  # ][ #  # ]:          0 :     aIbAdd.     SetModeImage( aIconList.GetImage( IID_ADD ) );
                 [ #  # ]
     308 [ #  # ][ #  # ]:          0 :     aIbRemove.  SetModeImage( aIconList.GetImage( IID_REMOVE ) );
                 [ #  # ]
     309 [ #  # ][ #  # ]:          0 :     aIbInfo.    SetModeImage( aIconList.GetImage( IID_INFO ) );
                 [ #  # ]
     310                 :            : 
     311         [ #  # ]:          0 :     aIbAdd.Enable(sal_False );
     312         [ #  # ]:          0 :     aIbRemove.Enable(sal_False );
     313         [ #  # ]:          0 :     aIbInfo.Enable(sal_False );
     314                 :            : 
     315 [ #  # ][ #  # ]:          0 :     aEdComment.SetText(aLbCategory.GetEntry(1));    // string for user defined
                 [ #  # ]
     316                 :            : 
     317         [ #  # ]:          0 :     aEdComment.Hide();
     318                 :            : 
     319         [ #  # ]:          0 :     aCbSourceFormat.Check( sal_False );
     320         [ #  # ]:          0 :     aCbSourceFormat.Disable();
     321         [ #  # ]:          0 :     aCbSourceFormat.Hide();
     322                 :            : 
     323         [ #  # ]:          0 :     Link aLink = LINK( this, SvxNumberFormatTabPage, SelFormatHdl_Impl );
     324                 :            : 
     325                 :          0 :     aLbCategory     .SetSelectHdl( aLink );
     326                 :          0 :     aLbFormat       .SetSelectHdl( aLink );
     327                 :          0 :     aLbLanguage     .SetSelectHdl( aLink );
     328                 :          0 :     aLbCurrency     .SetSelectHdl( aLink );
     329                 :          0 :     aCbSourceFormat .SetClickHdl( aLink );
     330                 :            : 
     331         [ #  # ]:          0 :     aLink = LINK( this, SvxNumberFormatTabPage, OptHdl_Impl );
     332                 :            : 
     333                 :          0 :     aEdDecimals     .SetModifyHdl( aLink );
     334                 :          0 :     aEdLeadZeroes   .SetModifyHdl( aLink );
     335                 :          0 :     aBtnNegRed      .SetClickHdl( aLink );
     336                 :          0 :     aBtnThousand    .SetClickHdl( aLink );
     337         [ #  # ]:          0 :     aLbFormat       .SetDoubleClickHdl( HDL( DoubleClickHdl_Impl ) );
     338         [ #  # ]:          0 :     aEdFormat       .SetModifyHdl( HDL( EditHdl_Impl ) );
     339         [ #  # ]:          0 :     aIbAdd.SetClickHdl( HDL( ClickHdl_Impl ) );
     340         [ #  # ]:          0 :     aIbRemove.SetClickHdl( HDL( ClickHdl_Impl ) );
     341         [ #  # ]:          0 :     aIbInfo.SetClickHdl( HDL( ClickHdl_Impl ) );
     342                 :            : 
     343         [ #  # ]:          0 :     aLink = LINK( this, SvxNumberFormatTabPage, LostFocusHdl_Impl);
     344                 :            : 
     345                 :          0 :     aEdComment      .SetLoseFocusHdl( aLink);
     346         [ #  # ]:          0 :     aResetWinTimer  .SetTimeoutHdl(LINK( this, SvxNumberFormatTabPage, TimeHdl_Impl));
     347         [ #  # ]:          0 :     aResetWinTimer  .SetTimeout( 10);
     348                 :            : 
     349                 :            :     // initialize language ListBox
     350                 :            : 
     351         [ #  # ]:          0 :     aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM );
     352                 :            :     // Don't list ambiguous locales where we won't be able to convert the
     353                 :            :     // LanguageType back to an identical Language_Country name and therefore
     354                 :            :     // couldn't load the i18n LocaleData. Show DebugMsg in non-PRODUCT version.
     355                 :            :     ::com::sun::star::uno::Sequence< sal_uInt16 > xLang =
     356         [ #  # ]:          0 :         LocaleDataWrapper::getInstalledLanguageTypes();
     357                 :          0 :     sal_Int32 nCount = xLang.getLength();
     358         [ #  # ]:          0 :     for ( sal_Int32 i=0; i<nCount; i++ )
     359                 :            :     {
     360 [ #  # ][ #  # ]:          0 :         aLbLanguage.InsertLanguage( xLang[i] );
     361                 :            :     }
     362                 :            : 
     363         [ #  # ]:          0 :     aIbAdd.SetAccessibleRelationLabeledBy( &aFtEdFormat );
     364         [ #  # ]:          0 :     aIbInfo.SetAccessibleRelationLabeledBy( &aFtEdFormat );
     365         [ #  # ]:          0 :     aIbRemove.SetAccessibleRelationLabeledBy( &aFtEdFormat );
     366         [ #  # ]:          0 :     aIbAdd.SetAccessibleRelationMemberOf( &aIbAdd );
     367         [ #  # ]:          0 :     aIbInfo.SetAccessibleRelationMemberOf( &aIbInfo );
     368 [ #  # ][ #  # ]:          0 :     aIbRemove.SetAccessibleRelationMemberOf( &aIbRemove );
                 [ #  # ]
     369                 :          0 : }
     370                 :            : 
     371                 :            : /*************************************************************************
     372                 :            : #*  Method:        GetRanges
     373                 :            : #*------------------------------------------------------------------------
     374                 :            : #*
     375                 :            : #*  Class:      SvxNumberFormatTabPage
     376                 :            : #*  Function:   Returns area information.
     377                 :            : #*  Input:      ---
     378                 :            : #*  Output:     area
     379                 :            : #*
     380                 :            : #************************************************************************/
     381                 :            : 
     382                 :          0 : sal_uInt16* SvxNumberFormatTabPage::GetRanges()
     383                 :            : {
     384                 :          0 :     return pRanges;
     385                 :            : }
     386                 :            : 
     387                 :            : 
     388                 :            : /*************************************************************************
     389                 :            : #*  Method:        Create
     390                 :            : #*------------------------------------------------------------------------
     391                 :            : #*
     392                 :            : #*  Class:      SvxNumberFormatTabPage
     393                 :            : #*  Function:   Creates a new number format page.
     394                 :            : #*  Input:      Window, SfxItemSet
     395                 :            : #*  Output:     new TabPage
     396                 :            : #*
     397                 :            : #************************************************************************/
     398                 :            : 
     399                 :          0 : SfxTabPage* SvxNumberFormatTabPage::Create( Window* pParent,
     400                 :            :                                             const SfxItemSet& rAttrSet )
     401                 :            : {
     402         [ #  # ]:          0 :     return ( new SvxNumberFormatTabPage( pParent, rAttrSet ) );
     403                 :            : }
     404                 :            : 
     405                 :            : 
     406                 :            : /*************************************************************************
     407                 :            : #*  Method:        Reset
     408                 :            : #*------------------------------------------------------------------------
     409                 :            : #*
     410                 :            : #*  Class:      SvxNumberFormatTabPage
     411                 :            : #*  Function:   The dialog's attributes are reset
     412                 :            : #*              using the Itemset.
     413                 :            : #*  Input:      SfxItemSet
     414                 :            : #*  Output:     ---
     415                 :            : #*
     416                 :            : #************************************************************************/
     417                 :            : 
     418                 :          0 : void SvxNumberFormatTabPage::Reset( const SfxItemSet& rSet )
     419                 :            : {
     420                 :          0 :     const SfxUInt32Item*        pValFmtAttr     = NULL;
     421                 :          0 :     const SfxPoolItem*          pItem           = NULL;
     422                 :          0 :     const SfxBoolItem*          pAutoEntryAttr = NULL;
     423                 :            : 
     424                 :          0 :     sal_uInt16                      nCatLbSelPos    = 0;
     425                 :          0 :     sal_uInt16                      nFmtLbSelPos    = 0;
     426                 :          0 :     LanguageType                eLangType       = LANGUAGE_DONTKNOW;
     427         [ #  # ]:          0 :     std::vector<String*>        aFmtEntryList;
     428                 :          0 :     SvxNumberValueType          eValType        = SVX_VALUE_TYPE_UNDEFINED;
     429                 :          0 :     double                      nValDouble      = 0;
     430         [ #  # ]:          0 :     String                      aValString;
     431                 :          0 :     SfxItemState                eState          = SFX_ITEM_DONTCARE;
     432                 :            : 
     433                 :            : 
     434 [ #  # ][ #  # ]:          0 :     eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_NOLANGUAGE ),sal_True,&pItem);
     435                 :            : 
     436         [ #  # ]:          0 :     if(eState==SFX_ITEM_SET)
     437                 :            :     {
     438                 :            :         const SfxBoolItem* pBoolLangItem = (const SfxBoolItem*)
     439         [ #  # ]:          0 :                       GetItem( rSet, SID_ATTR_NUMBERFORMAT_NOLANGUAGE);
     440                 :            : 
     441 [ #  # ][ #  # ]:          0 :         if(pBoolLangItem!=NULL && pBoolLangItem->GetValue())
                 [ #  # ]
     442                 :            :         {
     443         [ #  # ]:          0 :             HideLanguage();
     444                 :            :         }
     445                 :            :         else
     446                 :            :         {
     447         [ #  # ]:          0 :             HideLanguage(sal_False);
     448                 :            :         }
     449                 :            : 
     450                 :            :     }
     451                 :            : 
     452 [ #  # ][ #  # ]:          0 :     eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),sal_True,&pItem);
     453                 :            : 
     454         [ #  # ]:          0 :     if(eState==SFX_ITEM_SET)
     455                 :            :     {
     456         [ #  # ]:          0 :         if(pNumItem==NULL)
     457                 :            :         {
     458                 :          0 :             bNumItemFlag=sal_True;
     459         [ #  # ]:          0 :             pNumItem= (SvxNumberInfoItem *) pItem->Clone();
     460                 :            :         }
     461                 :            :         else
     462                 :            :         {
     463                 :          0 :             bNumItemFlag=sal_False;
     464                 :            :         }
     465                 :            :     }
     466                 :            :     else
     467                 :            :     {
     468                 :          0 :         bNumItemFlag=sal_False;
     469                 :            :     }
     470                 :            : 
     471                 :            : 
     472 [ #  # ][ #  # ]:          0 :     eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ONE_AREA ));
     473                 :            : 
     474         [ #  # ]:          0 :     if(eState==SFX_ITEM_SET)
     475                 :            :     {
     476                 :            :         const SfxBoolItem* pBoolItem = (const SfxBoolItem*)
     477         [ #  # ]:          0 :                       GetItem( rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA);
     478                 :            : 
     479         [ #  # ]:          0 :         if(pBoolItem!=NULL)
     480                 :            :         {
     481                 :          0 :             bOneAreaFlag= pBoolItem->GetValue();
     482                 :            :         }
     483                 :            :     }
     484                 :            : 
     485 [ #  # ][ #  # ]:          0 :     eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ) );
     486                 :            : 
     487         [ #  # ]:          0 :     if ( eState == SFX_ITEM_SET )
     488                 :            :     {
     489                 :            :         const SfxBoolItem* pBoolItem = (const SfxBoolItem*)
     490         [ #  # ]:          0 :                       GetItem( rSet, SID_ATTR_NUMBERFORMAT_SOURCE );
     491         [ #  # ]:          0 :         if ( pBoolItem )
     492         [ #  # ]:          0 :             aCbSourceFormat.Check( pBoolItem->GetValue() );
     493                 :            :         else
     494         [ #  # ]:          0 :             aCbSourceFormat.Check( sal_False );
     495         [ #  # ]:          0 :         aCbSourceFormat.Enable();
     496         [ #  # ]:          0 :         aCbSourceFormat.Show();
     497                 :            :     }
     498                 :            :     else
     499                 :            :     {
     500                 :          0 :         sal_Bool bInit = sal_False;     // set to sal_True for debug test
     501         [ #  # ]:          0 :         aCbSourceFormat.Check( bInit );
     502         [ #  # ]:          0 :         aCbSourceFormat.Enable( bInit );
     503         [ #  # ]:          0 :         aCbSourceFormat.Show( bInit );
     504                 :            :     }
     505                 :            : 
     506                 :            :     // pNumItem must have been set from outside!
     507                 :            :     DBG_ASSERT( pNumItem, "No NumberInfo, no NumberFormatter, good bye.CRASH. :-(" );
     508                 :            : 
     509 [ #  # ][ #  # ]:          0 :     eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ) );
     510                 :            : 
     511         [ #  # ]:          0 :     if ( SFX_ITEM_DONTCARE != eState )
     512                 :            :         pValFmtAttr = (const SfxUInt32Item*)
     513         [ #  # ]:          0 :                       GetItem( rSet, SID_ATTR_NUMBERFORMAT_VALUE );
     514                 :            : 
     515                 :          0 :     eValType = pNumItem->GetValueType();
     516                 :            : 
     517      [ #  #  # ]:          0 :     switch ( eValType )
     518                 :            :     {
     519                 :            :         case SVX_VALUE_TYPE_STRING:
     520         [ #  # ]:          0 :             aValString = pNumItem->GetValueString();
     521                 :          0 :             break;
     522                 :            :         case SVX_VALUE_TYPE_NUMBER:
     523                 :            :             //  #50441# string may be set in addition to the value
     524         [ #  # ]:          0 :             aValString = pNumItem->GetValueString();
     525                 :          0 :             nValDouble = pNumItem->GetValueDouble();
     526                 :          0 :             break;
     527                 :            :         case SVX_VALUE_TYPE_UNDEFINED:
     528                 :            :         default:
     529                 :          0 :             break;
     530                 :            :     }
     531                 :            : 
     532         [ #  # ]:          0 :     if ( pNumFmtShell )
     533 [ #  # ][ #  # ]:          0 :          delete pNumFmtShell;   // delete old shell if applicable (== reset)
     534                 :            : 
     535                 :            :     nInitFormat = ( pValFmtAttr )               // memorize init key
     536                 :          0 :                     ? pValFmtAttr->GetValue()   // (for FillItemSet())
     537         [ #  # ]:          0 :                     : ULONG_MAX;                // == DONT_KNOW
     538                 :            : 
     539                 :            : 
     540         [ #  # ]:          0 :     if ( eValType == SVX_VALUE_TYPE_STRING )
     541                 :            :         pNumFmtShell =SvxNumberFormatShell::Create(
     542                 :            :                                 pNumItem->GetNumberFormatter(),
     543                 :            :                                 (pValFmtAttr) ? nInitFormat : 0L,
     544                 :            :                                 eValType,
     545 [ #  # ][ #  # ]:          0 :                                 aValString );
     546                 :            :     else
     547                 :            :         pNumFmtShell =SvxNumberFormatShell::Create(
     548                 :            :                                 pNumItem->GetNumberFormatter(),
     549                 :            :                                 (pValFmtAttr) ? nInitFormat : 0L,
     550                 :            :                                 eValType,
     551                 :            :                                 nValDouble,
     552 [ #  # ][ #  # ]:          0 :                                 &aValString );
     553                 :            : 
     554                 :            : 
     555                 :          0 :     bool bUseStarFormat = false;
     556         [ #  # ]:          0 :     SfxObjectShell* pDocSh  = SfxObjectShell::Current();
     557         [ #  # ]:          0 :     if ( pDocSh )
     558                 :            :     {
     559                 :            :         // is this a calc document
     560 [ #  # ][ #  # ]:          0 :         Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
     561         [ #  # ]:          0 :         if ( xSI.is() )
     562 [ #  # ][ #  # ]:          0 :             bUseStarFormat = xSI->supportsService( rtl::OUString( "com.sun.star.sheet.SpreadsheetDocument" ) );
     563                 :            :     }
     564                 :          0 :     pNumFmtShell->SetUseStarFormat( bUseStarFormat );
     565                 :            : 
     566         [ #  # ]:          0 :     FillCurrencyBox();
     567                 :            : 
     568         [ #  # ]:          0 :     String aPrevString;
     569                 :          0 :     Color* pDummy = NULL;
     570                 :            :     pNumFmtShell->GetInitSettings( nCatLbSelPos, eLangType, nFmtLbSelPos,
     571         [ #  # ]:          0 :                                    aFmtEntryList, aPrevString, pDummy );
     572                 :            : 
     573 [ #  # ][ #  # ]:          0 :     aLbCurrency.SelectEntryPos((sal_uInt16)pNumFmtShell->GetCurrencySymbol());
     574                 :            : 
     575                 :          0 :     nFixedCategory=nCatLbSelPos;
     576         [ #  # ]:          0 :     if(bOneAreaFlag)
     577                 :            :     {
     578         [ #  # ]:          0 :         String sFixedCategory=aLbCategory.GetEntry(nFixedCategory);
     579         [ #  # ]:          0 :         aLbCategory.Clear();
     580         [ #  # ]:          0 :         aLbCategory.InsertEntry(sFixedCategory);
     581 [ #  # ][ #  # ]:          0 :         SetCategory(0);
     582                 :            :     }
     583                 :            :     else
     584                 :            :     {
     585         [ #  # ]:          0 :         SetCategory(nCatLbSelPos );
     586                 :            :     }
     587 [ #  # ][ #  # ]:          0 :     eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ADD_AUTO ) );
     588         [ #  # ]:          0 :     if(SFX_ITEM_SET == eState)
     589                 :            :          pAutoEntryAttr = (const SfxBoolItem*)
     590         [ #  # ]:          0 :                       GetItem( rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO );
     591                 :            :     // no_NO is an alias for nb_NO and normally isn't listed, we need it for
     592                 :            :     // backwards compatibility, but only if the format passed is of
     593                 :            :     // LanguageType no_NO.
     594         [ #  # ]:          0 :     if ( eLangType == LANGUAGE_NORWEGIAN )
     595                 :            :     {
     596         [ #  # ]:          0 :         aLbLanguage.RemoveLanguage( eLangType );    // in case we're already called
     597         [ #  # ]:          0 :         aLbLanguage.InsertLanguage( eLangType );
     598                 :            :     }
     599         [ #  # ]:          0 :     aLbLanguage.SelectLanguage( eLangType );
     600         [ #  # ]:          0 :     if(pAutoEntryAttr)
     601         [ #  # ]:          0 :         AddAutomaticLanguage_Impl(eLangType, pAutoEntryAttr->GetValue());
     602         [ #  # ]:          0 :     UpdateFormatListBox_Impl(sal_False,sal_True);
     603                 :            : 
     604                 :            : //! This spoils everything because it rematches currency formats based on
     605                 :            : //! the selected aLbCurrency entry instead of the current format.
     606                 :            : //! Besides that everything seems to be initialized by now, so why call it?
     607                 :            : //  SelFormatHdl_Impl( &aLbCategory );
     608                 :            : 
     609         [ #  # ]:          0 :     if ( pValFmtAttr )
     610                 :            :     {
     611         [ #  # ]:          0 :         EditHdl_Impl( &aEdFormat ); // UpdateOptions_Impl() als Seiteneffekt
     612                 :            :     }
     613                 :            :     else    // DONT_KNOW
     614                 :            :     {
     615                 :            :         // everything disabled except direct input or changing the category
     616         [ #  # ]:          0 :         Obstructing();
     617                 :            :     }
     618                 :            : 
     619 [ #  # ][ #  # ]:          0 :     if ( aCbSourceFormat.IsChecked() )
     620                 :            :     {
     621                 :            :         // everything disabled except SourceFormat checkbox
     622         [ #  # ]:          0 :         EnableBySourceFormat_Impl();
     623                 :            :     }
     624                 :            : 
     625 [ #  # ][ #  # ]:          0 :     DeleteEntryList_Impl(aFmtEntryList);
                 [ #  # ]
     626                 :          0 : }
     627                 :            : 
     628                 :            : /*************************************************************************
     629                 :            : #*  Method:        Obstructing
     630                 :            : #*------------------------------------------------------------------------
     631                 :            : #*
     632                 :            : #*  Class:      SvxNumberFormatTabPage
     633                 :            : #*  Function:   Disable the controls except from changing the category
     634                 :            : #*              and direct input.
     635                 :            : #*  Input:      ---
     636                 :            : #*  Output:     ---
     637                 :            : #*
     638                 :            : #************************************************************************/
     639                 :          0 : void SvxNumberFormatTabPage::Obstructing()
     640                 :            : {
     641                 :          0 :     aLbFormat       .SetNoSelection();
     642                 :          0 :     aLbLanguage     .SetNoSelection();
     643                 :          0 :     aFtLanguage     .Disable();
     644                 :          0 :     aLbLanguage     .Disable();
     645                 :            : 
     646                 :          0 :     aIbAdd.Enable(sal_False );
     647                 :          0 :     aIbRemove.Enable(sal_False );
     648                 :          0 :     aIbInfo.Enable(sal_False );
     649                 :            : 
     650                 :          0 :     aBtnNegRed      .Disable();
     651                 :          0 :     aBtnThousand    .Disable();
     652                 :          0 :     aFtLeadZeroes   .Disable();
     653                 :          0 :     aFtDecimals     .Disable();
     654                 :          0 :     aEdLeadZeroes   .Disable();
     655                 :          0 :     aEdDecimals     .Disable();
     656                 :          0 :     aFlOptions      .Disable();
     657         [ #  # ]:          0 :     aEdDecimals     .SetText( String() );
     658         [ #  # ]:          0 :     aEdLeadZeroes   .SetText( String() );
     659                 :          0 :     aBtnNegRed      .Check( sal_False );
     660                 :          0 :     aBtnThousand    .Check( sal_False );
     661         [ #  # ]:          0 :     aWndPreview     .NotifyChange( String() );
     662                 :            : 
     663                 :          0 :     aLbCategory     .SelectEntryPos( 0 );
     664         [ #  # ]:          0 :     aEdFormat       .SetText( String() );
     665         [ #  # ]:          0 :     aFtComment      .SetText( String() );
     666         [ #  # ]:          0 :     aEdComment      .SetText(aLbCategory.GetEntry(1));  // string for user defined
     667                 :            : 
     668                 :          0 :     aEdFormat       .GrabFocus();
     669                 :          0 : }
     670                 :            : 
     671                 :            : 
     672                 :            : /*************************************************************************
     673                 :            : #* Enable/Disable dialog parts depending on the value of the SourceFormat
     674                 :            : #* checkbox.
     675                 :            : #************************************************************************/
     676                 :          0 : void SvxNumberFormatTabPage::EnableBySourceFormat_Impl()
     677                 :            : {
     678                 :          0 :     sal_Bool bEnable = !aCbSourceFormat.IsChecked();
     679         [ #  # ]:          0 :     if ( !bEnable )
     680                 :          0 :         aCbSourceFormat.GrabFocus();
     681                 :          0 :     aFtCategory     .Enable( bEnable );
     682                 :          0 :     aLbCategory     .Enable( bEnable );
     683                 :          0 :     aFtFormat       .Enable( bEnable );
     684                 :          0 :     aLbCurrency     .Enable( bEnable );
     685                 :          0 :     aLbFormat       .Enable( bEnable );
     686                 :          0 :     aFtLanguage     .Enable( bEnable );
     687                 :          0 :     aLbLanguage     .Enable( bEnable );
     688                 :          0 :     aFtDecimals     .Enable( bEnable );
     689                 :          0 :     aEdDecimals     .Enable( bEnable );
     690                 :          0 :     aFtLeadZeroes   .Enable( bEnable );
     691                 :          0 :     aEdLeadZeroes   .Enable( bEnable );
     692                 :          0 :     aBtnNegRed      .Enable( bEnable );
     693                 :          0 :     aBtnThousand    .Enable( bEnable );
     694                 :          0 :     aFlOptions      .Enable( bEnable );
     695                 :          0 :     aFtEdFormat     .Enable( bEnable );
     696                 :          0 :     aEdFormat       .Enable( bEnable );
     697                 :          0 :     aIbAdd          .Enable( bEnable );
     698                 :          0 :     aIbRemove       .Enable( bEnable );
     699                 :          0 :     aIbInfo         .Enable( bEnable );
     700                 :          0 :     aFtComment      .Enable( bEnable );
     701                 :          0 :     aEdComment      .Enable( bEnable );
     702                 :          0 :     aLbFormat.Invalidate(); // #i43322#
     703                 :          0 : }
     704                 :            : 
     705                 :            : 
     706                 :            : /*************************************************************************
     707                 :            : #*  Method:    HideLanguage
     708                 :            : #*------------------------------------------------------------------------
     709                 :            : #*
     710                 :            : #*  Class:      SvxNumberFormatTabPage
     711                 :            : #*  Function:   Hides the language settings:
     712                 :            : #*  Input:      sal_Bool nFlag
     713                 :            : #*  Output:     ---
     714                 :            : #*
     715                 :            : #************************************************************************/
     716                 :            : 
     717                 :          0 : void SvxNumberFormatTabPage::HideLanguage(sal_Bool nFlag)
     718                 :            : {
     719         [ #  # ]:          0 :     Size aSize=aLbCategory.GetSizePixel();
     720                 :            : 
     721         [ #  # ]:          0 :     if(nFlag)
     722                 :            :     {
     723         [ #  # ]:          0 :         aSize.Height()=aLbFormat.GetSizePixel().Height();
     724                 :            :     }
     725                 :            :     else
     726                 :            :     {
     727                 :          0 :         aSize.Height()=nCatHeight;
     728                 :            :     }
     729                 :            : 
     730         [ #  # ]:          0 :     aLbCategory.SetSizePixel(aSize);
     731                 :            : 
     732         [ #  # ]:          0 :     aFtLanguage.Show(!nFlag);
     733         [ #  # ]:          0 :     aLbLanguage.Show(!nFlag);
     734                 :          0 : }
     735                 :            : 
     736                 :            : /*************************************************************************
     737                 :            : #*  Method:        FillItemSet
     738                 :            : #*------------------------------------------------------------------------
     739                 :            : #*
     740                 :            : #*  Class:      SvxNumberFormatTabPage
     741                 :            : #*  Function:   Adjusts the attributes in the ItemSet,
     742                 :            : #*              and - if bNumItemFlag is not set - the
     743                 :            : #*              numItem in the DocShell.
     744                 :            : #*  Input:      SfxItemSet
     745                 :            : #*  Output:     ---
     746                 :            : #*
     747                 :            : #************************************************************************/
     748                 :            : 
     749                 :          0 : sal_Bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
     750                 :            : {
     751 [ #  # ][ #  # ]:          0 :     sal_Bool bDataChanged   = aFtLanguage.IsEnabled() || aCbSourceFormat.IsEnabled();
     752         [ #  # ]:          0 :     if ( bDataChanged )
     753                 :            :     {
     754                 :          0 :         const SfxItemSet& rMyItemSet = GetItemSet();
     755         [ #  # ]:          0 :         sal_uInt16          nWhich       = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE );
     756         [ #  # ]:          0 :         SfxItemState    eItemState   = rMyItemSet.GetItemState( nWhich, sal_False );
     757                 :            : 
     758                 :            :         // OK chosen - Is format code input entered already taken over?
     759                 :            :         // If not, simulate Add. Upon syntax error ignore input and prevent Put.
     760         [ #  # ]:          0 :         String      aFormat = aEdFormat.GetText();
     761                 :          0 :         sal_uInt32 nCurKey = pNumFmtShell->GetCurNumFmtKey();
     762                 :            : 
     763 [ #  # ][ #  # ]:          0 :         if ( aIbAdd.IsEnabled() || pNumFmtShell->IsTmpCurrencyFormat(aFormat) )
         [ #  # ][ #  # ]
                 [ #  # ]
     764                 :            :         {   // #79599# It is not sufficient to just add the format code (or
     765                 :            :             // delete it in case of bOneAreaFlag and resulting category change).
     766                 :            :             // Upon switching tab pages we need all settings to be consistent
     767                 :            :             // in case this page will be redisplayed later.
     768         [ #  # ]:          0 :             bDataChanged = (ClickHdl_Impl( &aIbAdd ) != 0);
     769                 :          0 :             nCurKey = pNumFmtShell->GetCurNumFmtKey();
     770                 :            :         }
     771         [ #  # ]:          0 :         else if(nCurKey == NUMKEY_UNDEFINED)
     772                 :            :         {   // something went wrong, e.g. in Writer #70281#
     773         [ #  # ]:          0 :             pNumFmtShell->FindEntry(aFormat, &nCurKey);
     774                 :            :         }
     775                 :            : 
     776                 :            :         //---------------------------------------------------------------
     777                 :            :         // Chosen format:
     778                 :            :         // --------------
     779         [ #  # ]:          0 :         if ( bDataChanged )
     780                 :            :         {
     781                 :          0 :             bDataChanged = ( nInitFormat != nCurKey );
     782                 :            : 
     783         [ #  # ]:          0 :             if (bDataChanged)
     784                 :            :             {
     785 [ #  # ][ #  # ]:          0 :                 rCoreAttrs.Put( SfxUInt32Item( nWhich, nCurKey ) );
                 [ #  # ]
     786                 :            :             }
     787         [ #  # ]:          0 :             else if(SFX_ITEM_DEFAULT == eItemState)
     788                 :            :             {
     789         [ #  # ]:          0 :                 rCoreAttrs.ClearItem( nWhich );
     790                 :            :             }
     791                 :            :         }
     792                 :            : 
     793                 :            :         // --------------------------------------------------------------
     794                 :            :         // List of changed user defined formats:
     795                 :            :         // -------------------------------------
     796         [ #  # ]:          0 :         const size_t nDelCount = pNumFmtShell->GetUpdateDataCount();
     797                 :            : 
     798         [ #  # ]:          0 :         if ( nDelCount > 0 )
     799                 :            :         {
     800         [ #  # ]:          0 :             sal_uInt32*         pDelArr = new sal_uInt32[nDelCount];
     801                 :            : 
     802         [ #  # ]:          0 :             pNumFmtShell->GetUpdateData( pDelArr, nDelCount );
     803         [ #  # ]:          0 :             pNumItem->SetDelFormatArray( pDelArr, nDelCount );
     804                 :            : 
     805         [ #  # ]:          0 :             if(bNumItemFlag==sal_True)
     806                 :            :             {
     807         [ #  # ]:          0 :                 rCoreAttrs.Put( *pNumItem );
     808                 :            :             }
     809                 :            :             else
     810                 :            :             {
     811         [ #  # ]:          0 :                 SfxObjectShell* pDocSh  = SfxObjectShell::Current();
     812                 :            : 
     813                 :            :                 DBG_ASSERT( pDocSh, "DocShell not found!" );
     814                 :            : 
     815                 :            : 
     816         [ #  # ]:          0 :                 if ( pDocSh )
     817         [ #  # ]:          0 :                     pDocSh->PutItem( *pNumItem );
     818                 :            :             }
     819         [ #  # ]:          0 :             delete [] pDelArr;
     820                 :            :         }
     821                 :            : 
     822                 :            :         //---------------------------------------------------------------
     823                 :            :         // Whether source format is to be taken or not:
     824                 :            :         // --------------------------------------------
     825 [ #  # ][ #  # ]:          0 :         if ( aCbSourceFormat.IsEnabled() )
     826                 :            :         {
     827         [ #  # ]:          0 :             sal_uInt16 _nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE );
     828         [ #  # ]:          0 :             SfxItemState _eItemState = rMyItemSet.GetItemState( _nWhich, sal_False );
     829                 :            :             const SfxBoolItem* pBoolItem = (const SfxBoolItem*)
     830         [ #  # ]:          0 :                         GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE );
     831         [ #  # ]:          0 :             sal_Bool bOld = (pBoolItem ? pBoolItem->GetValue() : sal_False);
     832 [ #  # ][ #  # ]:          0 :             rCoreAttrs.Put( SfxBoolItem( _nWhich, aCbSourceFormat.IsChecked() ) );
         [ #  # ][ #  # ]
     833         [ #  # ]:          0 :             if ( !bDataChanged )
     834         [ #  # ]:          0 :                 bDataChanged = (bOld != (sal_Bool) aCbSourceFormat.IsChecked() ||
     835 [ #  # ][ #  # ]:          0 :                     _eItemState != SFX_ITEM_SET);
     836                 :            :         }
     837                 :            : 
     838                 :            :         // FillItemSet is only called on OK, here we can notify the
     839                 :            :         // NumberFormatShell that all new user defined formats are valid.
     840                 :          0 :         pNumFmtShell->ValidateNewEntries();
     841 [ #  # ][ #  # ]:          0 :         if(aLbLanguage.IsVisible() &&
         [ #  # ][ #  # ]
     842         [ #  # ]:          0 :                 LISTBOX_ENTRY_NOTFOUND != aLbLanguage.GetEntryPos(sAutomaticEntry))
     843                 :            :                 rCoreAttrs.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO,
     844 [ #  # ][ #  # ]:          0 :                     aLbLanguage.GetSelectEntry() == sAutomaticEntry));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     845                 :            :     }
     846                 :            : 
     847                 :          0 :     return bDataChanged;
     848                 :            : }
     849                 :            : 
     850                 :            : 
     851                 :          0 : int SvxNumberFormatTabPage::DeactivatePage( SfxItemSet* _pSet )
     852                 :            : {
     853         [ #  # ]:          0 :     if ( _pSet )
     854                 :          0 :         FillItemSet( *_pSet );
     855                 :          0 :     return LEAVE_PAGE;
     856                 :            : }
     857                 :            : 
     858                 :          0 : void SvxNumberFormatTabPage::SetInfoItem( const SvxNumberInfoItem& rItem )
     859                 :            : {
     860         [ #  # ]:          0 :     if(pNumItem==NULL)
     861                 :            :     {
     862                 :          0 :         pNumItem = (SvxNumberInfoItem*)rItem.Clone();
     863                 :            :     }
     864                 :          0 : }
     865                 :            : 
     866                 :          0 : void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<String*>& rEntries )
     867                 :            : {
     868                 :            :     String*     pEntry;
     869         [ #  # ]:          0 :     String      aTmpString;
     870         [ #  # ]:          0 :     String      aTmpCatString;
     871         [ #  # ]:          0 :     Font        aFont=aLbCategory.GetFont();
     872                 :          0 :     size_t      i = 0;
     873                 :            :     short       nTmpCatPos;
     874                 :            :     short       aPrivCat;
     875                 :            : 
     876         [ #  # ]:          0 :     aLbFormat.Clear();
     877         [ #  # ]:          0 :     aLbFormat.SetUpdateMode( sal_False );
     878                 :            : 
     879         [ #  # ]:          0 :     if( rEntries.empty() )
     880                 :          0 :         return;
     881                 :            : 
     882         [ #  # ]:          0 :     if(bOneAreaFlag)
     883                 :            :     {
     884                 :          0 :         nTmpCatPos=nFixedCategory;
     885                 :            :     }
     886                 :            :     else
     887                 :            :     {
     888         [ #  # ]:          0 :         nTmpCatPos=aLbCategory.GetSelectEntryPos();
     889                 :            :     }
     890                 :            : 
     891         [ #  # ]:          0 :     switch (nTmpCatPos)
     892                 :            :     {
     893                 :            :         case CAT_ALL:
     894                 :            :         case CAT_TEXT:
     895                 :          0 :         case CAT_NUMBER:        i=1;
     896         [ #  # ]:          0 :                                 pEntry=rEntries[0];
     897         [ #  # ]:          0 :                                 if(pEntry!=NULL)
     898                 :            :                                 {
     899         [ #  # ]:          0 :                                     if (nTmpCatPos == CAT_TEXT)
     900         [ #  # ]:          0 :                                         aTmpString=*pEntry;
     901                 :            :                                     else
     902 [ #  # ][ #  # ]:          0 :                                         aTmpString = pNumFmtShell->GetStandardName();
                 [ #  # ]
     903         [ #  # ]:          0 :                                     aPrivCat=pNumFmtShell->GetCategory4Entry(0);
     904         [ #  # ]:          0 :                                     aLbFormat.InsertFontEntry( aTmpString, aFont );
     905                 :            :                                 }
     906                 :          0 :                                 break;
     907                 :            : 
     908                 :          0 :         default:                break;
     909                 :            :     }
     910                 :            : 
     911         [ #  # ]:          0 :     if(pNumFmtShell!=NULL)
     912                 :            :     {
     913         [ #  # ]:          0 :         for ( ; i < rEntries.size(); ++i )
     914                 :            :         {
     915         [ #  # ]:          0 :             pEntry = rEntries[i];
     916         [ #  # ]:          0 :             aPrivCat=pNumFmtShell->GetCategory4Entry( static_cast<sal_uInt16>(i) );
     917         [ #  # ]:          0 :             if(aPrivCat!=CAT_TEXT)
     918                 :            :             {
     919                 :          0 :                 Color* pPreviewColor = NULL;
     920         [ #  # ]:          0 :                 String aPreviewString( GetExpColorString( pPreviewColor, *pEntry, aPrivCat ) );
     921         [ #  # ]:          0 :                 Font aEntryFont( aLbFormat.GetFont() );
     922 [ #  # ][ #  # ]:          0 :                 aLbFormat.InsertFontEntry( aPreviewString, aEntryFont, pPreviewColor );
                 [ #  # ]
     923                 :            :             }
     924                 :            :             else
     925                 :            :             {
     926         [ #  # ]:          0 :                 aLbFormat.InsertFontEntry(*pEntry,aFont);
     927                 :            :             }
     928                 :            :         }
     929                 :            :     }
     930         [ #  # ]:          0 :     aLbFormat.SetUpdateMode( sal_True );
     931 [ #  # ][ #  # ]:          0 :     DeleteEntryList_Impl(rEntries);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     932                 :            : }
     933                 :            : 
     934                 :            : 
     935                 :          0 : void SvxNumberFormatTabPage::DeleteEntryList_Impl( std::vector<String*>& rEntries )
     936                 :            : {
     937 [ #  # ][ #  # ]:          0 :     for( std::vector<String*>::const_iterator it(rEntries.begin()); it != rEntries.end(); ++it )
         [ #  # ][ #  # ]
     938 [ #  # ][ #  # ]:          0 :         delete *it;
                 [ #  # ]
     939                 :          0 :     rEntries.clear();
     940                 :          0 : }
     941                 :            : 
     942                 :            : 
     943                 :            : /*************************************************************************
     944                 :            : #*  Method:        UpdateOptions_Impl
     945                 :            : #*------------------------------------------------------------------------
     946                 :            : #*
     947                 :            : #*  Class:      SvxNumberFormatTabPage
     948                 :            : #*  Function:   Adjusts the options attributes
     949                 :            : #*              depending on the selected format.
     950                 :            : #*  Input:      Flag, whether the category has changed.
     951                 :            : #*  Output:     ---
     952                 :            : #*
     953                 :            : #************************************************************************/
     954                 :            : 
     955                 :          0 : void SvxNumberFormatTabPage::UpdateOptions_Impl( sal_Bool bCheckCatChange /*= sal_False*/ )
     956                 :            : {
     957         [ #  # ]:          0 :     String  theFormat           = aEdFormat.GetText();
     958         [ #  # ]:          0 :     sal_uInt16  nCurCategory        = aLbCategory.GetSelectEntryPos();
     959                 :          0 :     sal_uInt16  nCategory           = nCurCategory;
     960                 :          0 :     sal_uInt16  nDecimals           = 0;
     961                 :          0 :     sal_uInt16  nZeroes             = 0;
     962                 :          0 :     bool        bNegRed             = false;
     963                 :          0 :     bool        bThousand           = false;
     964         [ #  # ]:          0 :     sal_uInt16  nCurrencyPos        =aLbCurrency.GetSelectEntryPos();
     965                 :            : 
     966         [ #  # ]:          0 :     if(bOneAreaFlag)
     967                 :          0 :         nCurCategory=nFixedCategory;
     968                 :            : 
     969                 :            : 
     970                 :            :     pNumFmtShell->GetOptions( theFormat,
     971                 :            :                               bThousand, bNegRed,
     972                 :            :                               nDecimals, nZeroes,
     973         [ #  # ]:          0 :                               nCategory );
     974                 :          0 :     sal_Bool bDoIt=sal_False;
     975         [ #  # ]:          0 :     if(nCategory==CAT_CURRENCY)
     976                 :            :     {
     977         [ #  # ]:          0 :         sal_uInt16 nTstPos=pNumFmtShell->FindCurrencyFormat(theFormat);
     978 [ #  # ][ #  # ]:          0 :         if(nCurrencyPos!=nTstPos && nTstPos!=(sal_uInt16)-1)
     979                 :            :         {
     980         [ #  # ]:          0 :             aLbCurrency.SelectEntryPos(nTstPos);
     981         [ #  # ]:          0 :             pNumFmtShell->SetCurrencySymbol(nTstPos);
     982                 :          0 :             bDoIt=sal_True;
     983                 :            :         }
     984                 :            :     }
     985                 :            : 
     986                 :            : 
     987                 :            : 
     988 [ #  # ][ #  # ]:          0 :     if ( nCategory != nCurCategory || bDoIt)
     989                 :            :     {
     990         [ #  # ]:          0 :         if ( bCheckCatChange )
     991                 :            :         {
     992         [ #  # ]:          0 :             if(bOneAreaFlag)
     993         [ #  # ]:          0 :                 SetCategory(0);
     994                 :            :             else
     995         [ #  # ]:          0 :                 SetCategory(nCategory );
     996                 :            : 
     997         [ #  # ]:          0 :             UpdateFormatListBox_Impl( sal_True, sal_False );
     998                 :            :         }
     999                 :            :     }
    1000         [ #  # ]:          0 :     else if ( aLbFormat.GetEntryCount() > 0 )
    1001                 :            :     {
    1002                 :          0 :         sal_uInt32 nCurEntryKey=NUMKEY_UNDEFINED;
    1003 [ #  # ][ #  # ]:          0 :         if(!pNumFmtShell->FindEntry( aEdFormat.GetText(),&nCurEntryKey))
         [ #  # ][ #  # ]
    1004                 :            :         {
    1005         [ #  # ]:          0 :             aLbFormat.SetNoSelection();
    1006                 :            :         }
    1007                 :            :     }
    1008         [ #  # ]:          0 :     if(bOneAreaFlag)
    1009                 :            :     {
    1010                 :          0 :         nCategory=nFixedCategory;
    1011                 :            :     }
    1012                 :            : 
    1013         [ #  # ]:          0 :     switch ( nCategory )
    1014                 :            :     {
    1015                 :            :         case CAT_NUMBER:
    1016                 :            :         case CAT_PERCENT:
    1017                 :            :         case CAT_CURRENCY:
    1018         [ #  # ]:          0 :             aFlOptions.Enable();
    1019         [ #  # ]:          0 :             aFtDecimals.Enable();
    1020         [ #  # ]:          0 :             aEdDecimals.Enable();
    1021         [ #  # ]:          0 :             aFtLeadZeroes.Enable();
    1022         [ #  # ]:          0 :             aEdLeadZeroes.Enable();
    1023         [ #  # ]:          0 :             aBtnNegRed.Enable();
    1024         [ #  # ]:          0 :             aBtnThousand.Enable();
    1025 [ #  # ][ #  # ]:          0 :             aEdDecimals  .SetText( UniString::CreateFromInt32( nDecimals ) );
                 [ #  # ]
    1026 [ #  # ][ #  # ]:          0 :             aEdLeadZeroes.SetText( UniString::CreateFromInt32( nZeroes ) );
                 [ #  # ]
    1027         [ #  # ]:          0 :             aBtnNegRed   .Check( bNegRed );
    1028         [ #  # ]:          0 :             aBtnThousand .Check( bThousand );
    1029                 :          0 :             break;
    1030                 :            : 
    1031                 :            :         case CAT_ALL:
    1032                 :            :         case CAT_USERDEFINED:
    1033                 :            :         case CAT_TEXT:
    1034                 :            :         case CAT_DATE:
    1035                 :            :         case CAT_TIME:
    1036                 :            :         case CAT_BOOLEAN:
    1037                 :            :         case CAT_SCIENTIFIC:
    1038                 :            :         case CAT_FRACTION:
    1039                 :            :         default:
    1040         [ #  # ]:          0 :             aFlOptions      .Disable();
    1041         [ #  # ]:          0 :             aFtDecimals     .Disable();
    1042         [ #  # ]:          0 :             aEdDecimals     .Disable();
    1043         [ #  # ]:          0 :             aFtLeadZeroes   .Disable();
    1044         [ #  # ]:          0 :             aEdLeadZeroes   .Disable();
    1045         [ #  # ]:          0 :             aBtnNegRed      .Disable();
    1046         [ #  # ]:          0 :             aBtnThousand    .Disable();
    1047 [ #  # ][ #  # ]:          0 :             aEdDecimals     .SetText( UniString::CreateFromInt32( 0 ) );
                 [ #  # ]
    1048 [ #  # ][ #  # ]:          0 :             aEdLeadZeroes   .SetText( UniString::CreateFromInt32( 0 ) );
                 [ #  # ]
    1049         [ #  # ]:          0 :             aBtnNegRed      .Check( sal_False );
    1050         [ #  # ]:          0 :             aBtnThousand    .Check( sal_False );
    1051         [ #  # ]:          0 :     }
    1052                 :          0 : }
    1053                 :            : 
    1054                 :            : 
    1055                 :            : /*************************************************************************
    1056                 :            : #*  Method:        UpdateFormatListBox_Impl
    1057                 :            : #*------------------------------------------------------------------------
    1058                 :            : #*
    1059                 :            : #*  Class:      SvxNumberFormatTabPage
    1060                 :            : #*  Function:   Updates the format lisbox and additionally the
    1061                 :            : #*              string in the editbox is changed depending on
    1062                 :            : #*              the bUpdateEdit flag.
    1063                 :            : #*  Input:      Flags for category and editbox.
    1064                 :            : #*  Output:     ---
    1065                 :            : #*
    1066                 :            : #************************************************************************/
    1067                 :            : 
    1068                 :          0 : void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
    1069                 :            :     (
    1070                 :            :         sal_uInt16 bCat,        // Category or country/language ListBox?
    1071                 :            :         sal_Bool   bUpdateEdit
    1072                 :            :     )
    1073                 :            : {
    1074         [ #  # ]:          0 :     std::vector<String*> aEntryList;
    1075                 :          0 :     short                nFmtLbSelPos = 0;
    1076                 :            :     short                nTmpCatPos;
    1077                 :            : 
    1078         [ #  # ]:          0 :     if(bOneAreaFlag)
    1079                 :            :     {
    1080                 :          0 :         nTmpCatPos=nFixedCategory;
    1081                 :            :     }
    1082                 :            :     else
    1083                 :            :     {
    1084         [ #  # ]:          0 :         nTmpCatPos=aLbCategory.GetSelectEntryPos();
    1085                 :            :     }
    1086                 :            : 
    1087                 :            : 
    1088         [ #  # ]:          0 :     if ( bCat )
    1089                 :            :     {
    1090         [ #  # ]:          0 :         Point aPos=aLbFormat.GetPosPixel();
    1091         [ #  # ]:          0 :         Size  aSize=aLbFormat.GetSizePixel();
    1092                 :            : 
    1093         [ #  # ]:          0 :         if(nTmpCatPos!=CAT_CURRENCY)
    1094                 :            :         {
    1095                 :          0 :             aPos.Y()=nStdFormatY;
    1096                 :          0 :             aSize.Height()=nStdFormatHeight;
    1097         [ #  # ]:          0 :             aLbFormat.SetPosSizePixel(aPos,aSize);
    1098         [ #  # ]:          0 :             aLbCurrency.Hide();
    1099                 :            :         }
    1100                 :            :         else
    1101                 :            :         {
    1102                 :          0 :             aPos.Y()=nCurFormatY;
    1103                 :          0 :             aSize.Height()=nCurFormatHeight;
    1104         [ #  # ]:          0 :             aLbFormat.SetPosSizePixel(aPos,aSize);
    1105         [ #  # ]:          0 :             aLbCurrency.Show();
    1106                 :            :         }
    1107                 :            : 
    1108         [ #  # ]:          0 :         pNumFmtShell->CategoryChanged( nTmpCatPos,nFmtLbSelPos, aEntryList );
    1109                 :            :     }
    1110                 :            :     else
    1111         [ #  # ]:          0 :         pNumFmtShell->LanguageChanged( aLbLanguage.GetSelectLanguage(),
    1112         [ #  # ]:          0 :                                        nFmtLbSelPos,aEntryList );
    1113                 :            : 
    1114 [ #  # ][ #  # ]:          0 :     REMOVE_DONTKNOW() // possibly UI-Enable
         [ #  # ][ #  # ]
                 [ #  # ]
    1115                 :            : 
    1116                 :            : 
    1117 [ #  # ][ #  # ]:          0 :     if ( (!aEntryList.empty()) && (nFmtLbSelPos != SELPOS_NONE) )
                 [ #  # ]
    1118                 :            :     {
    1119         [ #  # ]:          0 :         if(bUpdateEdit)
    1120                 :            :         {
    1121 [ #  # ][ #  # ]:          0 :             String aFormat=*aEntryList[nFmtLbSelPos];
    1122         [ #  # ]:          0 :             aEdFormat.SetText(aFormat);
    1123 [ #  # ][ #  # ]:          0 :             aFtComment.SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
         [ #  # ][ #  # ]
    1124                 :            :         }
    1125                 :            : 
    1126 [ #  # ][ #  # ]:          0 :         if(!bOneAreaFlag || !bCat)
    1127                 :            :         {
    1128         [ #  # ]:          0 :             FillFormatListBox_Impl( aEntryList );
    1129         [ #  # ]:          0 :             aLbFormat.SelectEntryPos( nFmtLbSelPos );
    1130                 :            : 
    1131 [ #  # ][ #  # ]:          0 :             aFtComment.SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
                 [ #  # ]
    1132 [ #  # ][ #  # ]:          0 :             if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
    1133                 :            :             {
    1134 [ #  # ][ #  # ]:          0 :                 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).Len()==0)
                 [ #  # ]
    1135                 :            :                 {
    1136 [ #  # ][ #  # ]:          0 :                     aFtComment.SetText(aLbCategory.GetEntry(1));
                 [ #  # ]
    1137                 :            :                 }
    1138                 :            :             }
    1139         [ #  # ]:          0 :             ChangePreviewText( (sal_uInt16)nFmtLbSelPos );
    1140                 :            :         }
    1141                 :            : 
    1142                 :            :     }
    1143                 :            :     else
    1144                 :            :     {
    1145         [ #  # ]:          0 :         FillFormatListBox_Impl( aEntryList );
    1146         [ #  # ]:          0 :         if(nFmtLbSelPos != SELPOS_NONE)
    1147                 :            :         {
    1148         [ #  # ]:          0 :             aLbFormat.SelectEntryPos( (sal_uInt16)nFmtLbSelPos );
    1149                 :            : 
    1150 [ #  # ][ #  # ]:          0 :             aFtComment.SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
                 [ #  # ]
    1151 [ #  # ][ #  # ]:          0 :             if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
    1152                 :            :             {
    1153 [ #  # ][ #  # ]:          0 :                 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).Len()==0)
                 [ #  # ]
    1154                 :            :                 {
    1155 [ #  # ][ #  # ]:          0 :                     aFtComment.SetText(aLbCategory.GetEntry(1));
                 [ #  # ]
    1156                 :            :                 }
    1157                 :            :             }
    1158                 :            :         }
    1159                 :            :         else
    1160                 :            :         {
    1161         [ #  # ]:          0 :             aLbFormat.SetNoSelection();
    1162                 :            :         }
    1163                 :            : 
    1164         [ #  # ]:          0 :         if ( bUpdateEdit )
    1165                 :            :         {
    1166 [ #  # ][ #  # ]:          0 :             aEdFormat.SetText( String() );
                 [ #  # ]
    1167 [ #  # ][ #  # ]:          0 :             aWndPreview.NotifyChange( String() );
                 [ #  # ]
    1168                 :            :         }
    1169                 :            :     }
    1170                 :            : 
    1171         [ #  # ]:          0 :     DeleteEntryList_Impl( aEntryList );
    1172                 :          0 : }
    1173                 :            : 
    1174                 :            : 
    1175                 :            : /*************************************************************************
    1176                 :            : #*  Handle:     DoubleClickHdl_Impl
    1177                 :            : #*------------------------------------------------------------------------
    1178                 :            : #*
    1179                 :            : #*  Class:      SvxNumberFormatTabPage
    1180                 :            : #*  Function:   On a double click in the format lisbox the
    1181                 :            : #*              value is adopted and the OK button pushed.
    1182                 :            : #*  Input:      Pointer on the Listbox
    1183                 :            : #*  Output:     ---
    1184                 :            : #*
    1185                 :            : #************************************************************************/
    1186                 :            : 
    1187                 :          0 : IMPL_LINK( SvxNumberFormatTabPage, DoubleClickHdl_Impl, SvxFontListBox*, pLb )
    1188                 :            : {
    1189         [ #  # ]:          0 :     if ( pLb == &aLbFormat )
    1190                 :            :     {
    1191                 :          0 :         SelFormatHdl_Impl( pLb );
    1192                 :            : 
    1193         [ #  # ]:          0 :         if ( fnOkHdl.IsSet() )
    1194                 :            :         {   // temporary solution, should be offered by SfxTabPage
    1195                 :          0 :             fnOkHdl.Call( NULL );
    1196                 :            :         }
    1197                 :            :         else
    1198                 :            :         {
    1199         [ #  # ]:          0 :             SfxSingleTabDialog* pParent = dynamic_cast< SfxSingleTabDialog* >( GetParent() );
    1200         [ #  # ]:          0 :             OKButton* pOKButton = pParent ? pParent->GetOKButton() : NULL;
    1201         [ #  # ]:          0 :             if ( pOKButton )
    1202                 :          0 :                 pOKButton->Click();
    1203                 :            :         }
    1204                 :            :     }
    1205                 :          0 :     return 0;
    1206                 :            : }
    1207                 :            : 
    1208                 :            : 
    1209                 :            : /*************************************************************************
    1210                 :            : #*  Method:    SelFormatHdl_Impl
    1211                 :            : #*------------------------------------------------------------------------
    1212                 :            : #*
    1213                 :            : #*  Class:      SvxNumberFormatTabPage
    1214                 :            : #*  Function:   Is called when the language, the category or the format
    1215                 :            : #*              is changed. Accordingly the settings are adjusted.
    1216                 :            : #*  Input:      Pointer on the Listbox
    1217                 :            : #*  Output:     ---
    1218                 :            : #*
    1219                 :            : #************************************************************************/
    1220                 :            : 
    1221                 :          0 : IMPL_LINK( SvxNumberFormatTabPage, SelFormatHdl_Impl, void *, pLb )
    1222                 :            : {
    1223         [ #  # ]:          0 :     if ( (CheckBox*)pLb == &aCbSourceFormat )
    1224                 :            :     {
    1225                 :          0 :         EnableBySourceFormat_Impl();    // enable/disable everything else
    1226         [ #  # ]:          0 :         if ( aCbSourceFormat.IsChecked() )
    1227                 :          0 :             return 0;   // just disabled everything else
    1228                 :            : 
    1229                 :            :         // Reinit options enable/disable for current selection.
    1230                 :            : 
    1231                 :            :         // Current category may be UserDefined with no format entries defined.
    1232                 :            :         // And yes, aLbFormat is a SvxFontListBox with sal_uLong list positions,
    1233                 :            :         // implementation returns a LIST_APPEND if empty, comparison with
    1234                 :            :         // sal_uInt16 LISTBOX_ENTRY_NOTFOUND wouldn't match.
    1235         [ #  # ]:          0 :         if ( aLbFormat.GetSelectEntryPos() == LIST_APPEND )
    1236                 :          0 :             pLb = &aLbCategory; // continue with the current category selected
    1237                 :            :         else
    1238                 :          0 :             pLb = &aLbFormat;   // continue with the current format selected
    1239                 :            :     }
    1240                 :            : 
    1241                 :            :     short       nTmpCatPos;
    1242                 :            : 
    1243         [ #  # ]:          0 :     if(bOneAreaFlag)
    1244                 :            :     {
    1245                 :          0 :         nTmpCatPos=nFixedCategory;
    1246                 :            :     }
    1247                 :            :     else
    1248                 :            :     {
    1249                 :          0 :         nTmpCatPos=aLbCategory.GetSelectEntryPos();
    1250                 :            :     }
    1251                 :            : 
    1252                 :          0 :     sal_uInt16 nCurrencyPos=LISTBOX_ENTRY_NOTFOUND ;
    1253                 :            : 
    1254 [ #  # ][ #  # ]:          0 :     if(nTmpCatPos==CAT_CURRENCY && (ListBox *)pLb == &aLbCurrency )
    1255                 :            :     {
    1256                 :          0 :         nCurrencyPos=aLbCurrency.GetSelectEntryPos();
    1257                 :          0 :         pNumFmtShell->SetCurrencySymbol(nCurrencyPos);
    1258                 :            :     }
    1259                 :            : 
    1260                 :            :     //--------------------------------------------------------------------
    1261                 :            :     // Format-ListBox ----------------------------------------------------
    1262         [ #  # ]:          0 :     if ( (SvxFontListBox *)pLb == &aLbFormat )
    1263                 :            :     {
    1264         [ #  # ]:          0 :         sal_uInt16  nSelPos = (sal_uInt16) aLbFormat.GetSelectEntryPos();
    1265         [ #  # ]:          0 :         String  aFormat = aLbFormat.GetSelectEntry();
    1266         [ #  # ]:          0 :         String  aComment;
    1267                 :            : 
    1268                 :          0 :         short       nFmtLbSelPos = nSelPos;
    1269                 :            : 
    1270 [ #  # ][ #  # ]:          0 :         aFormat=pNumFmtShell->GetFormat4Entry(nSelPos);
                 [ #  # ]
    1271 [ #  # ][ #  # ]:          0 :         aComment=pNumFmtShell->GetComment4Entry(nSelPos);
                 [ #  # ]
    1272 [ #  # ][ #  # ]:          0 :         if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
    1273                 :            :         {
    1274 [ #  # ][ #  # ]:          0 :             if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).Len()==0)
                 [ #  # ]
    1275                 :            :             {
    1276 [ #  # ][ #  # ]:          0 :                 aComment=aLbCategory.GetEntry(1);
                 [ #  # ]
    1277                 :            :             }
    1278                 :            :         }
    1279                 :            : 
    1280         [ #  # ]:          0 :         if ( aFormat.Len() > 0 )
    1281                 :            :         {
    1282 [ #  # ][ #  # ]:          0 :             if(!aEdFormat.HasFocus()) aEdFormat.SetText( aFormat );
                 [ #  # ]
    1283         [ #  # ]:          0 :             aFtComment.SetText(aComment);
    1284         [ #  # ]:          0 :             ChangePreviewText( nSelPos );
    1285                 :            :         }
    1286                 :            : 
    1287 [ #  # ][ #  # ]:          0 :         REMOVE_DONTKNOW() // possibly UI-Enable
         [ #  # ][ #  # ]
                 [ #  # ]
    1288                 :            : 
    1289 [ #  # ][ #  # ]:          0 :         if ( pNumFmtShell->FindEntry( aFormat) )
    1290                 :            :         {
    1291         [ #  # ]:          0 :             aIbAdd.Enable(sal_False );
    1292         [ #  # ]:          0 :             sal_Bool bIsUserDef=pNumFmtShell->IsUserDefined( aFormat );
    1293         [ #  # ]:          0 :             aIbRemove.Enable(bIsUserDef);
    1294         [ #  # ]:          0 :             aIbInfo.Enable(bIsUserDef);
    1295                 :            : 
    1296                 :            :         }
    1297                 :            :         else
    1298                 :            :         {
    1299         [ #  # ]:          0 :             aIbAdd.Enable(sal_True );
    1300         [ #  # ]:          0 :             aIbInfo.Enable(sal_True );
    1301         [ #  # ]:          0 :             aIbRemove.Enable(sal_False );
    1302 [ #  # ][ #  # ]:          0 :             aFtComment.SetText(aEdComment.GetText());
                 [ #  # ]
    1303                 :            : 
    1304                 :            :         }
    1305         [ #  # ]:          0 :         UpdateOptions_Impl( sal_False );
    1306                 :            : 
    1307 [ #  # ][ #  # ]:          0 :         return 0;
    1308                 :            :     }
    1309                 :            : 
    1310                 :            :     //--------------------------------------------------------------------
    1311                 :            :     // category-ListBox -------------------------------------------------
    1312 [ #  # ][ #  # ]:          0 :     if ( pLb == &aLbCategory || pLb == &aLbCurrency)
    1313                 :            :     {
    1314                 :          0 :         UpdateFormatListBox_Impl( sal_True, sal_True );
    1315                 :          0 :         EditHdl_Impl( NULL );
    1316                 :          0 :         UpdateOptions_Impl( sal_False );
    1317                 :            : 
    1318                 :          0 :         return 0;
    1319                 :            :     }
    1320                 :            : 
    1321                 :            :     //--------------------------------------------------------------------
    1322                 :            :     // language/country-ListBox ----------------------------------------------
    1323         [ #  # ]:          0 :     if ( pLb == &aLbLanguage )
    1324                 :            :     {
    1325                 :          0 :         UpdateFormatListBox_Impl( sal_False, sal_True );
    1326                 :          0 :         EditHdl_Impl( &aEdFormat );
    1327                 :            : 
    1328                 :          0 :         return 0;
    1329                 :            :     }
    1330                 :          0 :     return 0;
    1331                 :            : }
    1332                 :            : 
    1333                 :            : 
    1334                 :            : /*************************************************************************
    1335                 :            : #*  Method:    ClickHdl_Impl, ImageButton* pIB
    1336                 :            : #*------------------------------------------------------------------------
    1337                 :            : #*
    1338                 :            : #*  Class:      SvxNumberFormatTabPage
    1339                 :            : #*  Function:   Called when the add or delete button is pushed,
    1340                 :            : #*              adjusts the number format list.
    1341                 :            : #*  Input:      Toolbox- Button
    1342                 :            : #*  Output:     ---
    1343                 :            : #*
    1344                 :            : #************************************************************************/
    1345                 :            : 
    1346                 :          0 : IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, ImageButton*, pIB)
    1347                 :            : {
    1348                 :          0 :     sal_Bool        bAdded = sal_False;
    1349                 :          0 :     sal_Bool        bDeleted = sal_False;
    1350                 :          0 :     sal_uLong       nReturn = 0;
    1351                 :          0 :     const sal_uLong nReturnChanged  = 0x1;  // THE boolean return value
    1352                 :          0 :     const sal_uLong nReturnAdded    = 0x2;  // temp: format added
    1353                 :          0 :     const sal_uLong nReturnOneArea  = 0x4;  // temp: one area but category changed => ignored
    1354                 :            : 
    1355         [ #  # ]:          0 :     if(pIB==&aIbAdd)
    1356                 :            :     {   // Also called from FillItemSet() if a temporary currency format has
    1357                 :            :         // to be added, not only if the Add button is enabled.
    1358         [ #  # ]:          0 :         String               aFormat = aEdFormat.GetText();
    1359         [ #  # ]:          0 :         std::vector<String*> aEntryList;
    1360         [ #  # ]:          0 :         std::vector<String*> a2EntryList;
    1361                 :          0 :         sal_uInt16           nCatLbSelPos = 0;
    1362                 :          0 :         short                nFmtLbSelPos = SELPOS_NONE;
    1363                 :          0 :         xub_StrLen           nErrPos=0;
    1364                 :            : 
    1365         [ #  # ]:          0 :         pNumFmtShell->SetCurCurrencyEntry(NULL);
    1366                 :            :         bAdded = pNumFmtShell->AddFormat( aFormat, nErrPos,
    1367                 :            :                                           nCatLbSelPos, nFmtLbSelPos,
    1368         [ #  # ]:          0 :                                           aEntryList);
    1369         [ #  # ]:          0 :         if ( bAdded )
    1370                 :          0 :             nReturn |= nReturnChanged | nReturnAdded;
    1371                 :            : 
    1372         [ #  # ]:          0 :         if(pLastActivWindow== (Window *) &aEdComment)
    1373                 :            :         {
    1374         [ #  # ]:          0 :             aEdFormat.GrabFocus();
    1375         [ #  # ]:          0 :             aEdComment.Hide();
    1376         [ #  # ]:          0 :             aFtComment.Show();
    1377 [ #  # ][ #  # ]:          0 :             aFtComment.SetText(aEdComment.GetText());
                 [ #  # ]
    1378                 :            :         }
    1379                 :            : 
    1380         [ #  # ]:          0 :         if ( !nErrPos ) // Syntax ok?
    1381                 :            :         {
    1382                 :            :             // May be sorted under a different locale if LCID was parsed.
    1383         [ #  # ]:          0 :             if (bAdded)
    1384         [ #  # ]:          0 :                 aLbLanguage.SelectLanguage( pNumFmtShell->GetCurLanguage() );
    1385                 :            : 
    1386         [ #  # ]:          0 :             if(nCatLbSelPos==CAT_CURRENCY)
    1387                 :            :             {
    1388 [ #  # ][ #  # ]:          0 :                 aLbCurrency.SelectEntryPos((sal_uInt16)pNumFmtShell->GetCurrencySymbol());
    1389                 :            :             }
    1390                 :            : 
    1391 [ #  # ][ #  # ]:          0 :             if(bOneAreaFlag && (nFixedCategory!=nCatLbSelPos))
    1392                 :            :             {
    1393 [ #  # ][ #  # ]:          0 :                 if(bAdded) DeleteEntryList_Impl(aEntryList);
    1394                 :            :                 bDeleted = pNumFmtShell->RemoveFormat( aFormat,
    1395                 :            :                                                nCatLbSelPos,
    1396                 :            :                                                nFmtLbSelPos,
    1397         [ #  # ]:          0 :                                                a2EntryList);
    1398 [ #  # ][ #  # ]:          0 :                 if(bDeleted) DeleteEntryList_Impl(a2EntryList);
    1399         [ #  # ]:          0 :                 aEdFormat.GrabFocus();
    1400         [ #  # ]:          0 :                 aEdFormat.SetSelection( Selection( (short)nErrPos, SELECTION_MAX ) );
    1401                 :          0 :                 nReturn |= nReturnOneArea;
    1402                 :            :             }
    1403                 :            :             else
    1404                 :            :             {
    1405 [ #  # ][ #  # ]:          0 :                 if ( bAdded && (nFmtLbSelPos != SELPOS_NONE) )
    1406                 :            :                 {
    1407                 :            :                     // everything alright
    1408         [ #  # ]:          0 :                     if(bOneAreaFlag)                  //@@ ???
    1409         [ #  # ]:          0 :                         SetCategory(0);
    1410                 :            :                     else
    1411         [ #  # ]:          0 :                         SetCategory(nCatLbSelPos );
    1412                 :            : 
    1413         [ #  # ]:          0 :                     FillFormatListBox_Impl( aEntryList );
    1414 [ #  # ][ #  # ]:          0 :                     if(aEdComment.GetText()!=aLbCategory.GetEntry(1))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1415                 :            :                     {
    1416                 :            :                         pNumFmtShell->SetComment4Entry(nFmtLbSelPos,
    1417 [ #  # ][ #  # ]:          0 :                                                     aEdComment.GetText());
                 [ #  # ]
    1418                 :            :                     }
    1419                 :            :                     else
    1420                 :            :                     {
    1421                 :            :                         pNumFmtShell->SetComment4Entry(nFmtLbSelPos,
    1422 [ #  # ][ #  # ]:          0 :                                                         String());
                 [ #  # ]
    1423                 :            :                     }
    1424         [ #  # ]:          0 :                     aLbFormat.SelectEntryPos( (sal_uInt16)nFmtLbSelPos );
    1425         [ #  # ]:          0 :                     aEdFormat.SetText( aFormat );
    1426                 :            : 
    1427 [ #  # ][ #  # ]:          0 :                     aEdComment.SetText(aLbCategory.GetEntry(1));    // String for user defined
                 [ #  # ]
    1428                 :            : 
    1429         [ #  # ]:          0 :                     ChangePreviewText( (sal_uInt16)nFmtLbSelPos );
    1430                 :            :                 }
    1431                 :            :             }
    1432                 :            :         }
    1433                 :            :         else // syntax error
    1434                 :            :         {
    1435         [ #  # ]:          0 :             aEdFormat.GrabFocus();
    1436         [ #  # ]:          0 :             aEdFormat.SetSelection( Selection( (short)nErrPos, SELECTION_MAX ) );
    1437                 :            :         }
    1438         [ #  # ]:          0 :         EditHdl_Impl( &aEdFormat );
    1439         [ #  # ]:          0 :         nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged));
    1440                 :            : 
    1441         [ #  # ]:          0 :         DeleteEntryList_Impl( aEntryList );
    1442 [ #  # ][ #  # ]:          0 :         DeleteEntryList_Impl( a2EntryList );
    1443                 :            :     }
    1444         [ #  # ]:          0 :     else if(pIB==&aIbRemove)
    1445                 :            :     {
    1446         [ #  # ]:          0 :         String               aFormat = aEdFormat.GetText();
    1447         [ #  # ]:          0 :         std::vector<String*> aEntryList;
    1448                 :          0 :         sal_uInt16           nCatLbSelPos = 0;
    1449                 :          0 :         short                nFmtLbSelPos = SELPOS_NONE;
    1450                 :            : 
    1451                 :            :         bDeleted = pNumFmtShell->RemoveFormat( aFormat,
    1452                 :            :                                                nCatLbSelPos,
    1453                 :            :                                                nFmtLbSelPos,
    1454         [ #  # ]:          0 :                                                aEntryList );
    1455                 :            : 
    1456 [ #  # ][ #  # ]:          0 :         aEdComment.SetText(aLbCategory.GetEntry(1));
                 [ #  # ]
    1457         [ #  # ]:          0 :         if ( bDeleted )
    1458                 :            :         {
    1459 [ #  # ][ #  # ]:          0 :             if( nFmtLbSelPos>=0 && static_cast<size_t>(nFmtLbSelPos)<aEntryList.size() )
                 [ #  # ]
    1460                 :            :             {
    1461 [ #  # ][ #  # ]:          0 :                 aFormat = *aEntryList[nFmtLbSelPos];
    1462                 :            :             }
    1463                 :            : 
    1464         [ #  # ]:          0 :             FillFormatListBox_Impl( aEntryList );
    1465                 :            : 
    1466         [ #  # ]:          0 :             if ( nFmtLbSelPos != SELPOS_NONE )
    1467                 :            :             {
    1468         [ #  # ]:          0 :                 if(bOneAreaFlag)                  //@@ ???
    1469         [ #  # ]:          0 :                         SetCategory(0);
    1470                 :            :                     else
    1471         [ #  # ]:          0 :                         SetCategory(nCatLbSelPos );
    1472                 :            : 
    1473         [ #  # ]:          0 :                 aLbFormat.SelectEntryPos( (sal_uInt16)nFmtLbSelPos );
    1474         [ #  # ]:          0 :                 aEdFormat.SetText( aFormat );
    1475         [ #  # ]:          0 :                 ChangePreviewText( (sal_uInt16)nFmtLbSelPos );
    1476                 :            :             }
    1477                 :            :             else
    1478                 :            :             {
    1479                 :            :                 // set to "all/standard"
    1480         [ #  # ]:          0 :                 SetCategory(0 );
    1481         [ #  # ]:          0 :                 SelFormatHdl_Impl( &aLbCategory );
    1482                 :            :             }
    1483                 :            :         }
    1484         [ #  # ]:          0 :         EditHdl_Impl( &aEdFormat );
    1485                 :            : 
    1486 [ #  # ][ #  # ]:          0 :         DeleteEntryList_Impl( aEntryList );
    1487                 :            :     }
    1488         [ #  # ]:          0 :     else if(pIB==&aIbInfo)
    1489                 :            :     {
    1490         [ #  # ]:          0 :         if(!(pLastActivWindow== (Window *) &aEdComment))
    1491                 :            :         {
    1492         [ #  # ]:          0 :             aEdComment.SetText(aFtComment.GetText());
    1493                 :          0 :             aEdComment.Show();
    1494                 :          0 :             aFtComment.Hide();
    1495                 :          0 :             aEdComment.GrabFocus();
    1496                 :            :         }
    1497                 :            :         else
    1498                 :            :         {
    1499                 :          0 :             aEdFormat.GrabFocus();
    1500                 :          0 :             aEdComment.Hide();
    1501                 :          0 :             aFtComment.Show();
    1502                 :            :         }
    1503                 :            :     }
    1504                 :            : 
    1505                 :          0 :     return nReturn;
    1506                 :            : }
    1507                 :            : 
    1508                 :            : 
    1509                 :            : /*************************************************************************
    1510                 :            : #*  Method:    EditHdl_Impl
    1511                 :            : #*------------------------------------------------------------------------
    1512                 :            : #*
    1513                 :            : #*  Class:      SvxNumberFormatTabPage
    1514                 :            : #*  Function:   When the entry in the edit field is changed
    1515                 :            : #*              the preview is updated and
    1516                 :            : #*  Input:      Pointer on Editbox
    1517                 :            : #*  Output:     ---
    1518                 :            : #*
    1519                 :            : #************************************************************************/
    1520                 :            : 
    1521                 :          0 : IMPL_LINK( SvxNumberFormatTabPage, EditHdl_Impl, Edit*, pEdFormat )
    1522                 :            : {
    1523                 :          0 :     sal_uInt32 nCurKey = NUMKEY_UNDEFINED;
    1524                 :            : 
    1525 [ #  # ][ #  # ]:          0 :     if ( aEdFormat.GetText().Len() == 0 )
                 [ #  # ]
    1526                 :            :     {
    1527         [ #  # ]:          0 :         aIbAdd.Enable(sal_False );
    1528         [ #  # ]:          0 :         aIbRemove.Enable(sal_False );
    1529         [ #  # ]:          0 :         aIbInfo.Enable(sal_False );
    1530 [ #  # ][ #  # ]:          0 :         aFtComment.SetText(String());
                 [ #  # ]
    1531                 :            :     }
    1532                 :            :     else
    1533                 :            :     {
    1534         [ #  # ]:          0 :         String aFormat = aEdFormat.GetText();
    1535         [ #  # ]:          0 :         MakePreviewText( aFormat );
    1536                 :            : 
    1537 [ #  # ][ #  # ]:          0 :         if ( pNumFmtShell->FindEntry( aFormat, &nCurKey ) )
    1538                 :            :         {
    1539         [ #  # ]:          0 :             aIbAdd.Enable(sal_False );
    1540         [ #  # ]:          0 :             sal_Bool bUserDef=pNumFmtShell->IsUserDefined( aFormat );
    1541                 :            : 
    1542         [ #  # ]:          0 :             aIbRemove.Enable(bUserDef);
    1543         [ #  # ]:          0 :             aIbInfo.Enable(bUserDef);
    1544                 :            : 
    1545         [ #  # ]:          0 :             if(bUserDef)
    1546                 :            :             {
    1547         [ #  # ]:          0 :                 sal_uInt16 nTmpCurPos=pNumFmtShell->FindCurrencyFormat(aFormat );
    1548                 :            : 
    1549         [ #  # ]:          0 :                 if(nTmpCurPos!=(sal_uInt16)-1)
    1550         [ #  # ]:          0 :                     aLbCurrency.SelectEntryPos(nTmpCurPos);
    1551                 :            :             }
    1552         [ #  # ]:          0 :             short nPosi=pNumFmtShell->GetListPos4Entry(aFormat);
    1553         [ #  # ]:          0 :             if(nPosi>=0)
    1554         [ #  # ]:          0 :                 aLbFormat.SelectEntryPos( (sal_uInt16)nPosi);
    1555                 :            : 
    1556                 :            :         }
    1557                 :            :         else
    1558                 :            :         {
    1559                 :            : 
    1560         [ #  # ]:          0 :             aIbAdd.Enable(sal_True );
    1561         [ #  # ]:          0 :             aIbInfo.Enable(sal_True);
    1562         [ #  # ]:          0 :             aIbRemove.Enable(sal_False );
    1563                 :            : 
    1564 [ #  # ][ #  # ]:          0 :             aFtComment.SetText(aEdComment.GetText());
                 [ #  # ]
    1565                 :            : 
    1566         [ #  # ]:          0 :         }
    1567                 :            :     }
    1568                 :            : 
    1569         [ #  # ]:          0 :     if ( pEdFormat )
    1570                 :            :     {
    1571                 :          0 :         pNumFmtShell->SetCurNumFmtKey( nCurKey );
    1572         [ #  # ]:          0 :         UpdateOptions_Impl( sal_True );
    1573                 :            :     }
    1574                 :            : 
    1575                 :          0 :     return 0;
    1576                 :            : }
    1577                 :            : 
    1578                 :            : 
    1579                 :            : /*************************************************************************
    1580                 :            : #*  Method:        NotifyChange
    1581                 :            : #*------------------------------------------------------------------------
    1582                 :            : #*
    1583                 :            : #*  Class:      SvxNumberFormatTabPage
    1584                 :            : #*  Function:   Does changes in the number attributes.
    1585                 :            : #*  Input:      Options- Controls
    1586                 :            : #*  Output:     ---
    1587                 :            : #*
    1588                 :            : #************************************************************************/
    1589                 :            : 
    1590                 :          0 : IMPL_LINK( SvxNumberFormatTabPage, OptHdl_Impl, void *, pOptCtrl )
    1591                 :            : {
    1592 [ #  # ][ #  # ]:          0 :     if (   ((NumericField*)pOptCtrl == &aEdLeadZeroes)
         [ #  # ][ #  # ]
    1593                 :            :         || ((NumericField*)pOptCtrl == &aEdDecimals)
    1594                 :            :         || ((CheckBox*)    pOptCtrl == &aBtnNegRed)
    1595                 :            :         || ((CheckBox*)    pOptCtrl == &aBtnThousand) )
    1596                 :            :     {
    1597         [ #  # ]:          0 :         String        aFormat;
    1598         [ #  # ]:          0 :         sal_Bool          bThousand     =    aBtnThousand.IsEnabled()
    1599 [ #  # ][ #  # ]:          0 :                                       && aBtnThousand.IsChecked();
                 [ #  # ]
    1600         [ #  # ]:          0 :         sal_Bool          bNegRed       =    aBtnNegRed.IsEnabled()
    1601 [ #  # ][ #  # ]:          0 :                                       && aBtnNegRed.IsChecked();
                 [ #  # ]
    1602         [ #  # ]:          0 :         sal_uInt16        nPrecision    = (aEdDecimals.IsEnabled())
    1603         [ #  # ]:          0 :                                         ? (sal_uInt16)aEdDecimals.GetValue()
    1604         [ #  # ]:          0 :                                         : (sal_uInt16)0;
    1605         [ #  # ]:          0 :         sal_uInt16        nLeadZeroes   = (aEdLeadZeroes.IsEnabled())
    1606         [ #  # ]:          0 :                                         ? (sal_uInt16)aEdLeadZeroes.GetValue()
    1607         [ #  # ]:          0 :                                         : (sal_uInt16)0;
    1608                 :            : 
    1609                 :            :         pNumFmtShell->MakeFormat( aFormat,
    1610                 :            :                                   bThousand, bNegRed,
    1611                 :            :                                   nPrecision, nLeadZeroes,
    1612 [ #  # ][ #  # ]:          0 :                                   (sal_uInt16)aLbFormat.GetSelectEntryPos() );
    1613                 :            : 
    1614         [ #  # ]:          0 :         aEdFormat.SetText( aFormat );
    1615         [ #  # ]:          0 :         MakePreviewText( aFormat );
    1616                 :            : 
    1617 [ #  # ][ #  # ]:          0 :         if ( pNumFmtShell->FindEntry( aFormat ) )
    1618                 :            :         {
    1619         [ #  # ]:          0 :             aIbAdd.Enable(sal_False );
    1620         [ #  # ]:          0 :             sal_Bool bUserDef=pNumFmtShell->IsUserDefined( aFormat );
    1621         [ #  # ]:          0 :             aIbRemove.Enable(bUserDef);
    1622         [ #  # ]:          0 :             aIbInfo.Enable(bUserDef);
    1623         [ #  # ]:          0 :             EditHdl_Impl( &aEdFormat);
    1624                 :            : 
    1625                 :            :         }
    1626                 :            :         else
    1627                 :            :         {
    1628         [ #  # ]:          0 :             EditHdl_Impl( NULL );
    1629         [ #  # ]:          0 :             aLbFormat.SetNoSelection();
    1630         [ #  # ]:          0 :         }
    1631                 :            :     }
    1632                 :          0 :     return 0;
    1633                 :            : }
    1634                 :            : 
    1635                 :          0 : IMPL_LINK_NOARG(SvxNumberFormatTabPage, TimeHdl_Impl)
    1636                 :            : {
    1637                 :          0 :     pLastActivWindow=NULL;
    1638                 :          0 :     return 0;
    1639                 :            : }
    1640                 :            : 
    1641                 :            : 
    1642                 :            : /*************************************************************************
    1643                 :            : #*  Method:    LostFocusHdl_Impl
    1644                 :            : #*------------------------------------------------------------------------
    1645                 :            : #*
    1646                 :            : #*  Class:      SvxNumberFormatTabPage
    1647                 :            : #*  Function:   Does changes in the number attributes.
    1648                 :            : #*  Input:      Options- Controls
    1649                 :            : #*  Output:     ---
    1650                 :            : #*
    1651                 :            : #************************************************************************/
    1652                 :            : 
    1653                 :          0 : IMPL_LINK( SvxNumberFormatTabPage, LostFocusHdl_Impl, Edit *, pEd)
    1654                 :            : {
    1655         [ #  # ]:          0 :     if (pEd==&aEdComment)
    1656                 :            :     {
    1657                 :          0 :         aResetWinTimer.Start();
    1658         [ #  # ]:          0 :         aFtComment.SetText(aEdComment.GetText());
    1659                 :          0 :         aEdComment.Hide();
    1660                 :          0 :         aFtComment.Show();
    1661         [ #  # ]:          0 :         if(!aIbAdd.IsEnabled())
    1662                 :            :         {
    1663                 :          0 :             sal_uInt16  nSelPos = (sal_uInt16) aLbFormat.GetSelectEntryPos();
    1664                 :            :             pNumFmtShell->SetComment4Entry(nSelPos,
    1665         [ #  # ]:          0 :                                         aEdComment.GetText());
    1666         [ #  # ]:          0 :             aEdComment.SetText(aLbCategory.GetEntry(1));    // String for user defined
    1667                 :            :         }
    1668                 :            :     }
    1669                 :          0 :     return 0;
    1670                 :            : }
    1671                 :            : 
    1672                 :            : /*************************************************************************
    1673                 :            : #*  Method:        NotifyChange
    1674                 :            : #*------------------------------------------------------------------------
    1675                 :            : #*
    1676                 :            : #*  Class:      SvxNumberFormatTabPage
    1677                 :            : #*  Function:   Does changes in the number attributes.
    1678                 :            : #*  Input:      Options- Controls
    1679                 :            : #*  Output:     ---
    1680                 :            : #*
    1681                 :            : #************************************************************************/
    1682                 :            : 
    1683                 :          0 : String SvxNumberFormatTabPage::GetExpColorString(
    1684                 :            :         Color*& rpPreviewColor, const String& rFormatStr, short nTmpCatPos)
    1685                 :            : {
    1686                 :          0 :     double nVal = 0;
    1687   [ #  #  #  #  :          0 :     switch (nTmpCatPos)
             #  #  #  # ]
    1688                 :            :     {
    1689                 :          0 :         case CAT_CURRENCY:      nVal=SVX_NUMVAL_CURRENCY; break;
    1690                 :            : 
    1691                 :            :         case CAT_SCIENTIFIC:
    1692                 :            :         case CAT_FRACTION:
    1693                 :          0 :         case CAT_NUMBER:        nVal=SVX_NUMVAL_STANDARD; break;
    1694                 :            : 
    1695                 :          0 :         case CAT_PERCENT:       nVal=SVX_NUMVAL_PERCENT; break;
    1696                 :            : 
    1697                 :          0 :         case CAT_ALL:           nVal=SVX_NUMVAL_STANDARD; break;
    1698                 :            : 
    1699                 :          0 :         case CAT_TIME:          nVal=SVX_NUMVAL_TIME; break;
    1700                 :          0 :         case CAT_DATE:          nVal=SVX_NUMVAL_DATE; break;
    1701                 :            : 
    1702                 :          0 :         case CAT_BOOLEAN:       nVal=SVX_NUMVAL_BOOLEAN; break;
    1703                 :            : 
    1704                 :            :         case CAT_USERDEFINED:
    1705                 :            :         case CAT_TEXT:
    1706                 :          0 :         default:                nVal=0;break;
    1707                 :            :     }
    1708                 :            : 
    1709                 :          0 :     String aPreviewString;
    1710         [ #  # ]:          0 :     pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, nVal );
    1711                 :          0 :     return aPreviewString;
    1712                 :            : }
    1713                 :            : 
    1714                 :          0 : void SvxNumberFormatTabPage::MakePreviewText( const String& rFormat )
    1715                 :            : {
    1716         [ #  # ]:          0 :     String aPreviewString;
    1717                 :          0 :     Color* pPreviewColor = NULL;
    1718         [ #  # ]:          0 :     pNumFmtShell->MakePreviewString( rFormat, aPreviewString, pPreviewColor );
    1719 [ #  # ][ #  # ]:          0 :     aWndPreview.NotifyChange( aPreviewString, pPreviewColor );
    1720                 :          0 : }
    1721                 :            : 
    1722                 :          0 : void SvxNumberFormatTabPage::ChangePreviewText( sal_uInt16 nPos )
    1723                 :            : {
    1724         [ #  # ]:          0 :     String aPreviewString;
    1725                 :          0 :     Color* pPreviewColor = NULL;
    1726         [ #  # ]:          0 :     pNumFmtShell->FormatChanged( nPos, aPreviewString, pPreviewColor );
    1727 [ #  # ][ #  # ]:          0 :     aWndPreview.NotifyChange( aPreviewString, pPreviewColor );
    1728                 :          0 : }
    1729                 :            : 
    1730                 :          0 : long SvxNumberFormatTabPage::PreNotify( NotifyEvent& rNEvt )
    1731                 :            : {
    1732         [ #  # ]:          0 :     if(rNEvt.GetType()==EVENT_LOSEFOCUS)
    1733                 :            :     {
    1734 [ #  # ][ #  # ]:          0 :         if ( rNEvt.GetWindow() == dynamic_cast< Window* >( &aEdComment ) && !aEdComment.IsVisible() )
                 [ #  # ]
    1735                 :            :         {
    1736                 :          0 :             pLastActivWindow = NULL;
    1737                 :            :         }
    1738                 :            :         else
    1739                 :            :         {
    1740                 :          0 :             pLastActivWindow = rNEvt.GetWindow();
    1741                 :            :         }
    1742                 :            :     }
    1743                 :            : 
    1744                 :          0 :     return SfxTabPage::PreNotify( rNEvt );
    1745                 :            : }
    1746                 :            : /*************************************************************************
    1747                 :            : #*  Method:    SetOkHdl
    1748                 :            : #*------------------------------------------------------------------------
    1749                 :            : #*
    1750                 :            : #*  Class:      SvxNumberFormatTabPage
    1751                 :            : #*  Function:   Resets the OkHandler.
    1752                 :            : #*  Input:      new OkHandler
    1753                 :            : #*  Output:     ---
    1754                 :            : #*
    1755                 :            : #************************************************************************/
    1756                 :            : 
    1757                 :          0 : void SvxNumberFormatTabPage::SetOkHdl( const Link& rOkHandler )
    1758                 :            : {
    1759                 :          0 :     fnOkHdl = rOkHandler;
    1760                 :          0 : }
    1761                 :            : 
    1762                 :          0 : void SvxNumberFormatTabPage::FillCurrencyBox()
    1763                 :            : {
    1764         [ #  # ]:          0 :     std::vector<rtl::OUString> aList;
    1765                 :            : 
    1766                 :          0 :     sal_uInt16  nSelPos=0;
    1767         [ #  # ]:          0 :     pNumFmtShell->GetCurrencySymbols(aList, &nSelPos);
    1768                 :            : 
    1769 [ #  # ][ #  # ]:          0 :     for(std::vector<rtl::OUString>::iterator i = aList.begin() + 1;i != aList.end(); ++i)
                 [ #  # ]
    1770 [ #  # ][ #  # ]:          0 :         aLbCurrency.InsertEntry(*i);
                 [ #  # ]
    1771                 :            : 
    1772         [ #  # ]:          0 :     aLbCurrency.SelectEntryPos(nSelPos);
    1773                 :          0 : }
    1774                 :            : 
    1775                 :          0 : void SvxNumberFormatTabPage::SetCategory(sal_uInt16 nPos)
    1776                 :            : {
    1777         [ #  # ]:          0 :     sal_uInt16  nCurCategory = aLbCategory.GetSelectEntryPos();
    1778         [ #  # ]:          0 :     Point aPos=aLbFormat.GetPosPixel();
    1779         [ #  # ]:          0 :     Size  aSize=aLbFormat.GetSizePixel();
    1780                 :            :     sal_uInt16 nTmpCatPos;
    1781                 :            : 
    1782         [ #  # ]:          0 :     if(bOneAreaFlag)
    1783                 :            :     {
    1784                 :          0 :         nTmpCatPos=nFixedCategory;
    1785                 :            :     }
    1786                 :            :     else
    1787                 :            :     {
    1788                 :          0 :         nTmpCatPos=nPos;
    1789                 :            :     }
    1790                 :            : 
    1791 [ #  # ][ #  # ]:          0 :     if(aLbCategory.GetEntryCount()==1 || nCurCategory!=nPos)
         [ #  # ][ #  # ]
    1792                 :            :     {
    1793         [ #  # ]:          0 :         if(nTmpCatPos!=CAT_CURRENCY)
    1794                 :            :         {
    1795                 :          0 :             aPos.Y()=nStdFormatY;
    1796                 :          0 :             aSize.Height()=nStdFormatHeight;
    1797         [ #  # ]:          0 :             aLbFormat.SetPosSizePixel(aPos,aSize);
    1798         [ #  # ]:          0 :             aLbCurrency.Hide();
    1799                 :            :         }
    1800                 :            :         else
    1801                 :            :         {
    1802                 :          0 :             aPos.Y()=nCurFormatY;
    1803                 :          0 :             aSize.Height()=nCurFormatHeight;
    1804         [ #  # ]:          0 :             aLbFormat.SetPosSizePixel(aPos,aSize);
    1805         [ #  # ]:          0 :             aLbCurrency.Show();
    1806                 :            :         }
    1807                 :            :     }
    1808         [ #  # ]:          0 :     aLbCategory.SelectEntryPos(nPos);
    1809                 :          0 : }
    1810                 :            : /* to support Writer text field language handling an
    1811                 :            :    additional entry needs to be inserted into the ListBox
    1812                 :            :    which marks a certain language as automatically detected
    1813                 :            :    Additionally the "Default" language is removed
    1814                 :            : */
    1815                 :          0 : void SvxNumberFormatTabPage::AddAutomaticLanguage_Impl(LanguageType eAutoLang, sal_Bool bSelect)
    1816                 :            : {
    1817                 :          0 :     aLbLanguage.RemoveLanguage(LANGUAGE_SYSTEM);
    1818                 :          0 :     sal_uInt16 nPos = aLbLanguage.InsertEntry(sAutomaticEntry);
    1819                 :          0 :     aLbLanguage.SetEntryData(nPos, (void*)(sal_uLong)eAutoLang);
    1820         [ #  # ]:          0 :     if(bSelect)
    1821                 :          0 :         aLbLanguage.SelectEntryPos(nPos);
    1822                 :          0 : }
    1823                 :            : 
    1824                 :          0 : void SvxNumberFormatTabPage::PageCreated (SfxAllItemSet aSet)
    1825                 :            : {
    1826                 :          0 :     SFX_ITEMSET_ARG (&aSet,pNumberInfoItem,SvxNumberInfoItem,SID_ATTR_NUMBERFORMAT_INFO,sal_False);
    1827                 :          0 :     SFX_ITEMSET_ARG (&aSet,pLinkItem,SfxLinkItem,SID_LINK_TYPE,sal_False);
    1828         [ #  # ]:          0 :     if (pNumberInfoItem)
    1829                 :          0 :         SetNumberFormatList(*pNumberInfoItem);
    1830         [ #  # ]:          0 :     if (pLinkItem)
    1831                 :          0 :         SetOkHdl(pLinkItem->GetValue());
    1832                 :          0 : }
    1833                 :            : 
    1834                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10