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

Generated by: LCOV version 1.10