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

Generated by: LCOV version 1.10