LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - numfmt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 781 0.1 %
Date: 2012-12-17 Functions: 2 49 4.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10