LCOV - code coverage report
Current view: top level - cui/source/tabpages - tabstpge.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 383 0.0 %
Date: 2014-04-11 Functions: 0 40 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 <sfx2/app.hxx>
      21             : #include <tools/shl.hxx>
      22             : #include <svtools/ruler.hxx>
      23             : #include <svx/dialogs.hrc>
      24             : #include <vcl/settings.hxx>
      25             : 
      26             : #include <cuires.hrc>
      27             : #include <editeng/lrspitem.hxx>
      28             : #include "tabstpge.hxx"
      29             : #include <dialmgr.hxx>
      30             : #include "svx/dlgutil.hxx"
      31             : #include <sfx2/module.hxx>
      32             : #include <svl/cjkoptions.hxx>
      33             : #include <unotools/localedatawrapper.hxx>
      34             : #include <comphelper/processfactory.hxx>
      35             : #include <sfx2/request.hxx>
      36             : #include <svl/intitem.hxx>
      37             : 
      38             : // class TabWin_Impl -----------------------------------------------------
      39             : 
      40           0 : class TabWin_Impl : public Window
      41             : {
      42             :     SvxTabulatorTabPage* mpPage;
      43             : private:
      44             :     sal_uInt16  nTabStyle;
      45             : 
      46             : public:
      47             : 
      48           0 :     TabWin_Impl(Window* pParent, WinBits nBits)
      49             :         : Window(pParent, nBits)
      50             :         , mpPage(0)
      51           0 :         , nTabStyle(0)
      52             :     {
      53           0 :     }
      54             : 
      55             :     virtual void    Paint( const Rectangle& rRect ) SAL_OVERRIDE;
      56             : 
      57           0 :     void SetTabulatorTabPage(SvxTabulatorTabPage* pPage) { mpPage = pPage; }
      58           0 :     void SetTabStyle(sal_uInt16 nStyle) {nTabStyle = nStyle; }
      59             : };
      60             : 
      61           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTabWin_Impl(Window *pParent, VclBuilder::stringmap &)
      62             : {
      63           0 :     return new TabWin_Impl(pParent, 0);
      64             : }
      65             : // static ----------------------------------------------------------------
      66             : 
      67             : static sal_uInt16 pRanges[] =
      68             : {
      69             :     SID_ATTR_TABSTOP,
      70             :     SID_ATTR_TABSTOP_OFFSET,
      71             :     0
      72             : };
      73             : 
      74             : // C function ------------------------------------------------------------
      75             : 
      76           0 : void FillUpWithDefTabs_Impl( long nDefDist, SvxTabStopItem& rTabs )
      77             : {
      78           0 :     if( rTabs.Count() )
      79           0 :         return;
      80             :     {
      81           0 :         SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
      82           0 :         rTabs.Insert( aSwTabStop );
      83             :     }
      84             : }
      85             : 
      86             : // class TabWin_Impl -----------------------------------------------------
      87             : 
      88           0 : void TabWin_Impl::Paint( const Rectangle& )
      89             : {
      90             :     // Paint tabulators
      91           0 :     Point aPnt;
      92           0 :     Size aSize = GetOutputSizePixel();
      93           0 :     aPnt.X() = aSize.Width() / 2;
      94           0 :     aPnt.Y() = aSize.Height() / 2;
      95           0 :     Ruler::DrawTab( this, GetSettings().GetStyleSettings().GetFontColor(), aPnt, nTabStyle );
      96           0 : }
      97             : 
      98             : // class SvxTabulatorTabPage ---------------------------------------------
      99             : 
     100           0 : SvxTabulatorTabPage::SvxTabulatorTabPage( Window* pParent, const SfxItemSet& rAttr ):
     101             : 
     102             :     SfxTabPage( pParent, "ParagraphTabsPage","cui/ui/paratabspage.ui", rAttr ),
     103             : 
     104             :     aAktTab     ( 0 ),
     105           0 :     aNewTabs    ( 0, 0, SVX_TAB_ADJUST_LEFT, GetWhich( SID_ATTR_TABSTOP ) ),
     106             :     nDefDist    ( 0 ),
     107             :     eDefUnit    ( FUNIT_100TH_MM ),
     108           0 :     bCheck      ( sal_False )
     109             : 
     110             : {
     111           0 :     get(m_pTabBox,"ED_TABPOS");
     112             :     //the tab images
     113           0 :     get(m_pLeftWin,"drawingareaWIN_TABLEFT");
     114           0 :     get(m_pRightWin,"drawingareaWIN_TABRIGHT");
     115           0 :     get(m_pCenterWin,"drawingareaWIN_TABCENTER");
     116           0 :     get(m_pDezWin,"drawingareaWIN_TABDECIMAL");
     117           0 :     m_pLeftWin->SetTabulatorTabPage(this);
     118           0 :     m_pRightWin->SetTabulatorTabPage(this);
     119           0 :     m_pCenterWin->SetTabulatorTabPage(this);
     120           0 :     m_pDezWin->SetTabulatorTabPage(this);
     121           0 :     m_pLeftWin->SetTabStyle((sal_uInt16)(RULER_TAB_LEFT|WB_HORZ));
     122           0 :     m_pRightWin->SetTabStyle((sal_uInt16)(RULER_TAB_RIGHT|WB_HORZ));
     123           0 :     m_pCenterWin->SetTabStyle((sal_uInt16)(RULER_TAB_CENTER|WB_HORZ));
     124           0 :     m_pDezWin->SetTabStyle((sal_uInt16)(RULER_TAB_DECIMAL|WB_HORZ));
     125             :     //upper radiobuttons
     126           0 :     SvtCJKOptions aCJKOptions;
     127           0 :     get(m_pLeftTab,  aCJKOptions.IsAsianTypographyEnabled() ? "radiobuttonST_LEFTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_LEFT");
     128           0 :     get(m_pRightTab, aCJKOptions.IsAsianTypographyEnabled() ? "radiobuttonST_RIGHTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_RIGHT");
     129           0 :     m_pLeftTab->Show(true);
     130           0 :     m_pRightTab->Show(true);
     131           0 :     get(m_pCenterTab,"radiobuttonBTN_TABTYPE_CENTER");
     132           0 :     get(m_pDezTab,"radiobuttonBTN_TABTYPE_DECIMAL");
     133           0 :     get(m_pDezChar,"entryED_TABTYPE_DECCHAR");
     134           0 :     get(m_pDezCharLabel,"labelFT_TABTYPE_DECCHAR");
     135             :     //lower radio buttons
     136           0 :     get(m_pNoFillChar,"radiobuttonBTN_FILLCHAR_NO");
     137           0 :     get(m_pFillPoints,"radiobuttonBTN_FILLCHAR_POINTS");
     138           0 :     get(m_pFillDashLine,"radiobuttonBTN_FILLCHAR_DASHLINE");
     139           0 :     get(m_pFillSolidLine,"radiobuttonBTN_FILLCHAR_UNDERSCORE");
     140           0 :     get(m_pFillSpecial,"radiobuttonBTN_FILLCHAR_OTHER");
     141           0 :     get(m_pFillChar,"entryED_FILLCHAR_OTHER");
     142             :     //button bar
     143           0 :     get(m_pNewBtn,"buttonBTN_NEW");
     144           0 :     get(m_pDelAllBtn,"buttonBTN_DELALL");
     145           0 :     get(m_pDelBtn,"buttonBTN_DEL");
     146             : 
     147           0 :     get(m_pTypeFrame, "frameFL_TABTYPE");
     148           0 :     get(m_pFillFrame, "frameFL_FILLCHAR");
     149             : 
     150             :     // This page needs ExchangeSupport
     151           0 :     SetExchangeSupport();
     152             : 
     153             :     // Set metric
     154           0 :     FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
     155           0 :     SetFieldUnit( *m_pTabBox, eFUnit );
     156             : 
     157             :     // Initialize buttons
     158           0 :     m_pNewBtn->SetClickHdl( LINK( this,SvxTabulatorTabPage, NewHdl_Impl ) );
     159           0 :     m_pDelBtn->SetClickHdl( LINK( this,SvxTabulatorTabPage, DelHdl_Impl ) );
     160           0 :     m_pDelAllBtn->SetClickHdl( LINK( this,SvxTabulatorTabPage, DelAllHdl_Impl ) );
     161             : 
     162           0 :     Link aLink = LINK( this, SvxTabulatorTabPage, TabTypeCheckHdl_Impl );
     163           0 :     m_pLeftTab->SetClickHdl( aLink );
     164           0 :     m_pRightTab->SetClickHdl( aLink );
     165           0 :     m_pDezTab->SetClickHdl( aLink );
     166           0 :     m_pCenterTab->SetClickHdl( aLink );
     167             : 
     168           0 :     m_pDezChar->SetLoseFocusHdl( LINK( this,  SvxTabulatorTabPage, GetDezCharHdl_Impl ) );
     169           0 :     m_pDezChar->Disable();
     170           0 :     m_pDezCharLabel->Disable();
     171             : 
     172           0 :     aLink = LINK( this, SvxTabulatorTabPage, FillTypeCheckHdl_Impl );
     173           0 :     m_pNoFillChar->SetClickHdl( aLink );
     174           0 :     m_pFillPoints->SetClickHdl( aLink );
     175           0 :     m_pFillDashLine->SetClickHdl( aLink );
     176           0 :     m_pFillSolidLine->SetClickHdl( aLink );
     177           0 :     m_pFillSpecial->SetClickHdl( aLink );
     178           0 :     m_pFillChar->SetLoseFocusHdl( LINK( this,  SvxTabulatorTabPage, GetFillCharHdl_Impl ) );
     179           0 :     m_pFillChar->Disable();
     180             : 
     181           0 :     m_pTabBox->SetDoubleClickHdl( LINK( this, SvxTabulatorTabPage, SelectHdl_Impl ) );
     182           0 :     m_pTabBox->SetModifyHdl( LINK( this, SvxTabulatorTabPage, ModifyHdl_Impl ) );
     183             : 
     184             :     // Get the default decimal char from the system
     185           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     186           0 :     aAktTab.GetDecimal() = rLocaleWrapper.getNumDecimalSep()[0];
     187           0 : }
     188             : 
     189             : 
     190             : 
     191           0 : SvxTabulatorTabPage::~SvxTabulatorTabPage()
     192             : {
     193           0 : }
     194             : 
     195             : 
     196             : 
     197           0 : sal_uInt16* SvxTabulatorTabPage::GetRanges()
     198             : {
     199           0 :     return pRanges;
     200             : }
     201             : 
     202             : 
     203             : 
     204           0 : bool SvxTabulatorTabPage::FillItemSet( SfxItemSet& rSet )
     205             : {
     206           0 :     sal_Bool bModified = sal_False;
     207             : 
     208             :     // Put the controls' values in here
     209           0 :     if ( m_pNewBtn->IsEnabled() )
     210           0 :         NewHdl_Impl( 0 );
     211             : 
     212             :     // Call the LoseFocus-Handler first
     213           0 :     GetDezCharHdl_Impl( m_pDezChar );
     214           0 :     GetFillCharHdl_Impl( m_pFillChar );
     215             : 
     216           0 :     FillUpWithDefTabs_Impl( nDefDist, aNewTabs );
     217           0 :     SfxItemPool* pPool = rSet.GetPool();
     218           0 :     MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
     219           0 :     const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_TABSTOP );
     220             : 
     221           0 :     if ( MAP_100TH_MM != eUnit )
     222             :     {
     223             :         // If the ItemSet contains a LRSpaceItem with negative first line indent,
     224             :         // the TabStopItem needs to have a DefTab at position 0.
     225             :         const SfxPoolItem* pLRSpace;
     226             :         // If not in the new set, then maybe in the old one
     227           0 :         if ( SFX_ITEM_SET != rSet.GetItemState( GetWhich( SID_ATTR_LRSPACE ), true, &pLRSpace ) )
     228           0 :             pLRSpace = GetOldItem( rSet, SID_ATTR_LRSPACE );
     229             : 
     230           0 :         if ( pLRSpace && ( (SvxLRSpaceItem*)pLRSpace )->GetTxtFirstLineOfst() < 0 )
     231             :         {
     232           0 :             SvxTabStop aNull( 0, SVX_TAB_ADJUST_DEFAULT );
     233           0 :             aNewTabs.Insert( aNull );
     234             :         }
     235             : 
     236           0 :         SvxTabStopItem aTmp( aNewTabs );
     237           0 :         aTmp.Remove( 0, aTmp.Count() );
     238             : 
     239           0 :         for ( sal_uInt16 i = 0; i < aNewTabs.Count(); ++i )
     240             :         {
     241           0 :             SvxTabStop aTmpStop = aNewTabs[i];
     242           0 :             aTmpStop.GetTabPos() =
     243           0 :                 LogicToLogic( aTmpStop.GetTabPos(), MAP_100TH_MM, eUnit );
     244           0 :             aTmp.Insert( aTmpStop );
     245             :         }
     246             : 
     247           0 :         if ( !pOld || !( *( (SvxTabStopItem*)pOld ) == aTmp ) )
     248             :         {
     249           0 :             rSet.Put( aTmp );
     250           0 :             bModified = sal_True;
     251           0 :         }
     252             :     }
     253           0 :     else if ( !pOld || !( *( (SvxTabStopItem*)pOld ) == aNewTabs ) )
     254             :     {
     255           0 :         rSet.Put( aNewTabs );
     256           0 :         bModified = sal_True;
     257             :     }
     258           0 :     return bModified;
     259             : }
     260             : 
     261             : 
     262             : 
     263           0 : SfxTabPage* SvxTabulatorTabPage::Create( Window* pParent,
     264             :                                          const SfxItemSet& rSet)
     265             : {
     266           0 :     return ( new SvxTabulatorTabPage( pParent, rSet ) );
     267             : }
     268             : 
     269             : 
     270             : 
     271           0 : void SvxTabulatorTabPage::Reset( const SfxItemSet& rSet )
     272             : {
     273           0 :     SfxItemPool* pPool = rSet.GetPool();
     274           0 :     MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
     275             : 
     276             :     // Current tabs
     277           0 :     const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_TABSTOP );
     278             : 
     279           0 :     if ( pItem )
     280             :     {
     281           0 :         if ( MAP_100TH_MM != eUnit )
     282             :         {
     283           0 :             SvxTabStopItem aTmp( *( (const SvxTabStopItem*)pItem ) );
     284           0 :             aNewTabs.Remove( 0, aNewTabs.Count() );
     285             : 
     286           0 :             for ( sal_uInt16 i = 0; i < aTmp.Count(); ++i )
     287             :             {
     288           0 :                 SvxTabStop aTmpStop = aTmp[i];
     289           0 :                 aTmpStop.GetTabPos() = LogicToLogic( aTmpStop.GetTabPos(), eUnit, MAP_100TH_MM );
     290           0 :                 aNewTabs.Insert( aTmpStop );
     291           0 :             }
     292             :         }
     293             :         else
     294           0 :             aNewTabs = *( (const SvxTabStopItem*)pItem );
     295             :     }
     296             :     else
     297           0 :         aNewTabs.Remove( 0, aNewTabs.Count() );
     298             : 
     299             :     // Defaul tab distance
     300           0 :     nDefDist = SVX_TAB_DEFDIST;
     301           0 :     pItem = GetItem( rSet, SID_ATTR_TABSTOP_DEFAULTS );
     302             : 
     303           0 :     if ( pItem )
     304             :         nDefDist = LogicToLogic(
     305           0 :             (long)((const SfxUInt16Item*)pItem)->GetValue(), eUnit, MAP_100TH_MM );
     306             : 
     307             :     // Tab pos currently selected
     308           0 :     sal_uInt16 nTabPos = 0;
     309           0 :     pItem = GetItem( rSet, SID_ATTR_TABSTOP_POS );
     310             : 
     311           0 :     if ( pItem )
     312           0 :         nTabPos = ( (const SfxUInt16Item*)pItem )->GetValue();
     313             : 
     314           0 :     InitTabPos_Impl( nTabPos );
     315           0 : }
     316             : 
     317             : 
     318             : 
     319           0 : void SvxTabulatorTabPage::DisableControls( const sal_uInt16 nFlag )
     320             : {
     321           0 :     if ( ( TABTYPE_LEFT & nFlag ) == TABTYPE_LEFT )
     322             :     {
     323           0 :         m_pLeftTab->Disable();
     324           0 :         m_pLeftWin->Disable();
     325             :     }
     326           0 :     if ( ( TABTYPE_RIGHT & nFlag ) == TABTYPE_RIGHT )
     327             :     {
     328           0 :         m_pRightTab->Disable();
     329           0 :         m_pRightWin->Disable();
     330             :     }
     331           0 :     if ( ( TABTYPE_CENTER & nFlag ) == TABTYPE_CENTER )
     332             :     {
     333           0 :         m_pCenterTab->Disable();
     334           0 :         m_pCenterWin->Disable();
     335             :     }
     336           0 :     if ( ( TABTYPE_DEZIMAL & nFlag ) == TABTYPE_DEZIMAL )
     337             :     {
     338           0 :         m_pDezTab->Disable();
     339           0 :         m_pDezWin->Disable();
     340           0 :         m_pDezCharLabel->Disable();
     341           0 :         m_pDezChar->Disable();
     342             :     }
     343           0 :      if ( ( TABTYPE_ALL & nFlag ) == TABTYPE_ALL )
     344           0 :          m_pTypeFrame->Disable();
     345           0 :     if ( ( TABFILL_NONE & nFlag ) == TABFILL_NONE )
     346           0 :         m_pNoFillChar->Disable();
     347           0 :     if ( ( TABFILL_POINT & nFlag ) == TABFILL_POINT )
     348           0 :         m_pFillPoints->Disable();
     349           0 :     if ( ( TABFILL_DASHLINE & nFlag ) == TABFILL_DASHLINE )
     350           0 :         m_pFillDashLine->Disable();
     351           0 :     if ( ( TABFILL_SOLIDLINE & nFlag ) == TABFILL_SOLIDLINE )
     352           0 :         m_pFillSolidLine->Disable();
     353           0 :     if ( ( TABFILL_SPECIAL & nFlag ) == TABFILL_SPECIAL )
     354             :     {
     355           0 :         m_pFillSpecial->Disable();
     356           0 :         m_pFillChar->Disable();
     357             :     }
     358           0 :      if ( ( TABFILL_ALL & nFlag ) == TABFILL_ALL )
     359           0 :          m_pFillFrame->Disable();
     360           0 : }
     361             : 
     362             : 
     363             : 
     364           0 : int SvxTabulatorTabPage::DeactivatePage( SfxItemSet* _pSet )
     365             : {
     366           0 :     if ( _pSet )
     367           0 :         FillItemSet( *_pSet );
     368           0 :     return LEAVE_PAGE;
     369             : }
     370             : 
     371             : 
     372             : 
     373           0 : void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos )
     374             : {
     375           0 :     m_pTabBox->Clear();
     376             : 
     377           0 :     long nOffset = 0;
     378           0 :     const SfxPoolItem* pItem = 0;
     379           0 :     if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, true, &pItem )
     380             :             == SFX_ITEM_SET )
     381             :     {
     382           0 :         nOffset = ( (const SfxInt32Item*)pItem )->GetValue();
     383           0 :         MapUnit eUnit = (MapUnit)GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
     384           0 :         nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MAP_100TH_MM  );
     385             :     }
     386             : 
     387             :     // Correct current TabPos and default tabs
     388           0 :     for ( sal_uInt16 i = 0; i < aNewTabs.Count(); i++ )
     389             :     {
     390           0 :         if ( aNewTabs[i].GetAdjustment() != SVX_TAB_ADJUST_DEFAULT )
     391             :         {
     392             :             m_pTabBox->InsertValue( m_pTabBox->Normalize(
     393           0 :                 aNewTabs[i].GetTabPos() + nOffset ), eDefUnit );
     394             :         }
     395             :         else
     396           0 :             aNewTabs.Remove( i-- );
     397             :     }
     398             : 
     399             :     // Select current tabulator
     400           0 :     const sal_uInt16 nSize = aNewTabs.Count();
     401             : 
     402           0 :     if ( nTabPos >= nSize )
     403           0 :         nTabPos = 0;
     404             : 
     405             :     // Switch off all RadioButtons for a start
     406           0 :     m_pLeftTab->Check( true );
     407           0 :     m_pNoFillChar->Check( true );
     408             : 
     409           0 :     if( m_pTabBox->GetEntryCount() > 0 )
     410             :     {
     411           0 :         m_pTabBox->SetText( m_pTabBox->GetEntry( nTabPos ) );
     412           0 :         aAktTab = aNewTabs[nTabPos];
     413             : 
     414           0 :         SetFillAndTabType_Impl();
     415           0 :         m_pNewBtn->Disable();
     416           0 :         m_pDelBtn->Enable();
     417             :     }
     418             :     else
     419             :     {   // If no entry, 0 is the default value
     420           0 :         m_pTabBox->SetValue( 0, eDefUnit );
     421             : 
     422           0 :         m_pNewBtn->Enable();
     423           0 :         m_pDelBtn->Disable();
     424             :     }
     425           0 : }
     426             : 
     427             : 
     428             : 
     429           0 : void SvxTabulatorTabPage::SetFillAndTabType_Impl()
     430             : {
     431           0 :     RadioButton* pTypeBtn = 0;
     432           0 :     RadioButton* pFillBtn = 0;
     433             : 
     434           0 :     m_pDezChar->Disable();
     435           0 :     m_pDezCharLabel->Disable();
     436             : 
     437           0 :     if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_LEFT )
     438           0 :         pTypeBtn = m_pLeftTab;
     439           0 :     else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
     440           0 :         pTypeBtn = m_pRightTab;
     441           0 :     else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_DECIMAL )
     442             :     {
     443           0 :         pTypeBtn = m_pDezTab;
     444           0 :         m_pDezChar->Enable();
     445           0 :         m_pDezCharLabel->Enable();
     446           0 :         m_pDezChar->SetText( OUString( (sal_Unicode)aAktTab.GetDecimal() ) );
     447             :     }
     448           0 :     else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_CENTER )
     449           0 :         pTypeBtn = m_pCenterTab;
     450             : 
     451           0 :     if ( pTypeBtn )
     452           0 :         pTypeBtn->Check();
     453             : 
     454           0 :     m_pFillChar->Disable();
     455           0 :     m_pFillChar->SetText( "" );
     456             : 
     457           0 :     if ( aAktTab.GetFill() == ' ' )
     458           0 :         pFillBtn = m_pNoFillChar;
     459           0 :     else if ( aAktTab.GetFill() == '-' )
     460           0 :         pFillBtn = m_pFillDashLine;
     461           0 :     else if ( aAktTab.GetFill() == '_' )
     462           0 :         pFillBtn = m_pFillSolidLine;
     463           0 :     else if ( aAktTab.GetFill() == '.' )
     464           0 :         pFillBtn = m_pFillPoints;
     465             :     else
     466             :     {
     467           0 :         pFillBtn = m_pFillSpecial;
     468           0 :         m_pFillChar->Enable();
     469           0 :         m_pFillChar->SetText( OUString( (sal_Unicode)aAktTab.GetFill() ) );
     470             :     }
     471           0 :     pFillBtn->Check();
     472           0 : }
     473             : 
     474             : 
     475             : 
     476           0 : IMPL_LINK( SvxTabulatorTabPage, NewHdl_Impl, Button *, pBtn )
     477             : {
     478             :     // Add a new one and select it
     479             :     // Get the value from the display
     480           0 :     long nVal = static_cast<long>(m_pTabBox->Denormalize( m_pTabBox->GetValue( eDefUnit ) ));
     481             : 
     482             :     // If the pBtn == 0 && the value == 0 then do not create a tab, because we create via OK
     483           0 :     if ( nVal == 0 && pBtn == 0 )
     484           0 :         return 0;
     485             : 
     486           0 :     long nOffset = 0;
     487           0 :     const SfxPoolItem* pItem = 0;
     488             : 
     489           0 :     if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, true, &pItem ) ==
     490             :          SFX_ITEM_SET )
     491             :     {
     492           0 :         nOffset = ( (const SfxInt32Item*)pItem )->GetValue();
     493           0 :         MapUnit eUnit = (MapUnit)GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
     494           0 :         nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MAP_100TH_MM  );
     495             :     }
     496           0 :     const long nReal = nVal - nOffset;
     497           0 :     sal_Int32 nSize = m_pTabBox->GetEntryCount();
     498             : 
     499             :     sal_Int32 i;
     500           0 :     for( i = 0; i < nSize; i++ )
     501             :     {
     502           0 :         if ( nReal < aNewTabs[i].GetTabPos() )
     503           0 :             break;
     504             :     }
     505             : 
     506             :     // Make ListBox entry
     507           0 :     m_pTabBox->InsertValue( m_pTabBox->Normalize( nVal ), eDefUnit, i );
     508           0 :     aAktTab.GetTabPos() = nReal;
     509           0 :     SvxTabAdjust eAdj = SVX_TAB_ADJUST_LEFT;
     510             : 
     511           0 :     if ( m_pRightTab->IsChecked() )
     512           0 :         eAdj = SVX_TAB_ADJUST_RIGHT;
     513           0 :     else if ( m_pCenterTab->IsChecked() )
     514           0 :         eAdj = SVX_TAB_ADJUST_CENTER;
     515           0 :     else if ( m_pDezTab->IsChecked() )
     516           0 :         eAdj = SVX_TAB_ADJUST_DECIMAL;
     517             : 
     518           0 :     aAktTab.GetAdjustment() = eAdj;
     519           0 :     aNewTabs.Insert( aAktTab );
     520             : 
     521           0 :     m_pNewBtn->Disable();
     522           0 :     m_pDelBtn->Enable();
     523           0 :     m_pTabBox->GrabFocus();
     524             : 
     525             :     // If no RadioButton was clicked, we need to put anyway
     526           0 :     bCheck |= sal_True;
     527             :     // Set the selection into the position Edit
     528           0 :     m_pTabBox->SetSelection(Selection(0, m_pTabBox->GetText().getLength()));
     529           0 :     return 0;
     530             : }
     531             : 
     532             : 
     533             : 
     534           0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, DelHdl_Impl)
     535             : {
     536           0 :     sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue() );
     537             : 
     538           0 :     if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
     539           0 :         return 0;
     540             : 
     541           0 :     if ( m_pTabBox->GetEntryCount() == 1 )
     542             :     {
     543           0 :         DelAllHdl_Impl( 0 );
     544           0 :         return 0;
     545             :     }
     546             : 
     547             :     // Delete Tab
     548           0 :     m_pTabBox->RemoveEntryAt(nPos);
     549           0 :     aNewTabs.Remove( nPos );
     550             : 
     551             :     // Reset aAktTab
     552           0 :     const sal_uInt16 nSize = aNewTabs.Count();
     553             : 
     554           0 :     if ( nSize > 0 )
     555             :     {
     556             :         // Correct Pos
     557           0 :         nPos = ( ( nSize - 1 ) >= nPos) ? nPos : nPos - 1;
     558           0 :         m_pTabBox->SetValue( m_pTabBox->GetValue( nPos ) );
     559           0 :         aAktTab = aNewTabs[nPos];
     560             :     }
     561             : 
     562             :     // If no Tabs Enable Disable Controls
     563           0 :     if ( m_pTabBox->GetEntryCount() == 0 )
     564             :     {
     565           0 :         m_pDelBtn->Disable();
     566           0 :         m_pNewBtn->Enable();
     567           0 :         m_pTabBox->GrabFocus();
     568             :     }
     569             : 
     570             :     // If no RadioButton was clicked, we need to put anyway
     571           0 :     bCheck |= sal_True;
     572           0 :     return 0;
     573             : }
     574             : 
     575             : 
     576             : 
     577           0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, DelAllHdl_Impl)
     578             : {
     579           0 :     if ( aNewTabs.Count() )
     580             :     {
     581           0 :         aNewTabs = SvxTabStopItem( 0 );
     582           0 :         InitTabPos_Impl();
     583             : 
     584             :         // So that we put in FillItemSet()
     585           0 :         bCheck |= sal_True;
     586             :     }
     587           0 :     return 0;
     588             : }
     589             : 
     590             : 
     591             : 
     592           0 : IMPL_LINK( SvxTabulatorTabPage, TabTypeCheckHdl_Impl, RadioButton *, pBox )
     593             : {
     594           0 :     bCheck |= sal_True;
     595             :     SvxTabAdjust eAdj;
     596           0 :     m_pDezChar->Disable();
     597           0 :     m_pDezCharLabel->Disable();
     598           0 :     m_pDezChar->SetText( "" );
     599             : 
     600           0 :     if ( pBox == m_pLeftTab )
     601           0 :         eAdj = SVX_TAB_ADJUST_LEFT;
     602           0 :     else if ( pBox == m_pRightTab )
     603           0 :         eAdj = SVX_TAB_ADJUST_RIGHT;
     604           0 :     else if ( pBox == m_pCenterTab )
     605           0 :         eAdj = SVX_TAB_ADJUST_CENTER;
     606             :     else
     607             :     {
     608           0 :         eAdj = SVX_TAB_ADJUST_DECIMAL;
     609           0 :         m_pDezChar->Enable();
     610           0 :         m_pDezCharLabel->Enable();
     611           0 :         m_pDezChar->SetText( OUString( (sal_Unicode)aAktTab.GetDecimal() ) );
     612             :     }
     613             : 
     614           0 :     aAktTab.GetAdjustment() = eAdj;
     615           0 :     sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
     616             : 
     617           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     618             :     {
     619           0 :         aNewTabs.Remove( nPos );
     620           0 :         aNewTabs.Insert( aAktTab );
     621             :     }
     622           0 :     return 0;
     623             : }
     624             : 
     625             : 
     626             : 
     627           0 : IMPL_LINK( SvxTabulatorTabPage, FillTypeCheckHdl_Impl, RadioButton *, pBox )
     628             : {
     629           0 :     bCheck |= sal_True;
     630           0 :     sal_uInt8 cFill = ' ';
     631           0 :     m_pFillChar->SetText( "" );
     632           0 :     m_pFillChar->Disable();
     633             : 
     634           0 :     if( pBox == m_pFillSpecial )
     635           0 :         m_pFillChar->Enable();
     636           0 :     else if ( pBox == m_pNoFillChar )
     637           0 :         cFill = ' ';
     638           0 :     else if ( pBox == m_pFillSolidLine )
     639           0 :         cFill = '_';
     640           0 :     else if ( pBox == m_pFillPoints )
     641           0 :         cFill = '.';
     642           0 :     else if ( pBox == m_pFillDashLine )
     643           0 :         cFill = '-';
     644             : 
     645           0 :     aAktTab.GetFill() = cFill;
     646           0 :     sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
     647             : 
     648           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     649             :     {
     650           0 :         aNewTabs.Remove( nPos );
     651           0 :         aNewTabs.Insert( aAktTab );
     652             :     }
     653           0 :     return 0;
     654             : }
     655             : 
     656             : 
     657             : 
     658           0 : IMPL_LINK( SvxTabulatorTabPage, GetFillCharHdl_Impl, Edit *, pEdit )
     659             : {
     660           0 :     OUString aChar( pEdit->GetText() );
     661             : 
     662           0 :     if ( !aChar.isEmpty() )
     663           0 :         aAktTab.GetFill() = aChar[0];
     664             : 
     665           0 :     const sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit);
     666           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     667             :     {
     668           0 :         aNewTabs.Remove( nPos );
     669           0 :         aNewTabs.Insert( aAktTab );
     670             :     }
     671           0 :     return 0;
     672             : }
     673             : 
     674             : 
     675             : 
     676           0 : IMPL_LINK( SvxTabulatorTabPage, GetDezCharHdl_Impl, Edit *, pEdit )
     677             : {
     678           0 :     OUString aChar( pEdit->GetText() );
     679           0 :     if ( !aChar.isEmpty() && ( aChar[0] >= ' '))
     680           0 :         aAktTab.GetDecimal() = aChar[0];
     681             : 
     682           0 :     sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
     683           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     684             :     {
     685           0 :         aNewTabs.Remove( nPos );
     686           0 :         aNewTabs.Insert( aAktTab );
     687             :     }
     688           0 :     return 0;
     689             : }
     690             : 
     691             : 
     692             : 
     693           0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, SelectHdl_Impl)
     694             : {
     695           0 :     sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
     696           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     697             :     {
     698           0 :         aAktTab = aNewTabs[nPos];
     699           0 :         m_pNewBtn->Disable();
     700           0 :         SetFillAndTabType_Impl();
     701             :     }
     702           0 :     return 0;
     703             : }
     704             : 
     705             : 
     706             : 
     707           0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, ModifyHdl_Impl)
     708             : {
     709           0 :     sal_Int32 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
     710           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     711             :     {
     712           0 :         aAktTab = aNewTabs[nPos];
     713           0 :         SetFillAndTabType_Impl();
     714             : 
     715           0 :         aAktTab.GetTabPos() =
     716           0 :             static_cast<long>(m_pTabBox->Denormalize( m_pTabBox->GetValue( eDefUnit ) ));
     717             : 
     718           0 :         m_pNewBtn->Disable();
     719           0 :         m_pDelBtn->Enable();
     720           0 :         return 0;
     721             :     }
     722           0 :     m_pNewBtn->Enable();
     723           0 :     m_pDelBtn->Disable();
     724           0 :     return 0;
     725             : }
     726             : 
     727           0 : void SvxTabulatorTabPage::PageCreated(SfxAllItemSet aSet)
     728             : {
     729           0 :     SFX_ITEMSET_ARG (&aSet,pControlItem,SfxUInt16Item,SID_SVXTABULATORTABPAGE_CONTROLFLAGS,false);
     730           0 :     if (pControlItem)
     731           0 :         DisableControls(pControlItem->GetValue());
     732           0 : }
     733             : 
     734             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10