LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - numpara.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 164 0.0 %
Date: 2014-04-11 Functions: 0 18 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 "cmdid.h"
      21             : #include "swtypes.hxx"
      22             : #include "hintids.hxx"
      23             : #include "globals.hrc"
      24             : #include "helpid.h"
      25             : #include <sfx2/objsh.hxx>
      26             : #include <sfx2/htmlmode.hxx>
      27             : #include <svx/svxids.hrc>
      28             : #include <svl/eitem.hxx>
      29             : #include <svl/stritem.hxx>
      30             : #include <svl/intitem.hxx>
      31             : #include <fmtline.hxx>
      32             : #include <numpara.hxx>
      33             : 
      34             : #include <app.hrc>
      35             : 
      36             : // Globals ******************************************************************
      37             : 
      38             : static sal_uInt16 aPageRg[] = {
      39             :     FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT,
      40             :     0
      41             : };
      42             : 
      43           0 : SwParagraphNumTabPage::SwParagraphNumTabPage(Window* pParent, const SfxItemSet& rAttr ) :
      44             :     SfxTabPage(pParent, "NumParaPage", "modules/swriter/ui/numparapage.ui", rAttr),
      45             : 
      46             :     msOutlineNumbering( SW_RES( STR_OUTLINE_NUMBERING ) ),
      47             :     bModified(sal_False),
      48           0 :     bCurNumrule(sal_False)
      49             : {
      50           0 :     get(m_pOutlineStartBX,         "boxOUTLINE");
      51           0 :     get(m_pOutlineLvLB,            "comboLB_OUTLINE_LEVEL");
      52             : 
      53           0 :     get(m_pNumberStyleBX,          "boxNUMBER_STYLE");
      54           0 :     get(m_pNumberStyleLB,          "comboLB_NUMBER_STYLE");
      55             : 
      56           0 :     get(m_pNewStartBX,             "boxNEW_START");
      57           0 :     get(m_pNewStartCB,             "checkCB_NEW_START");
      58           0 :     m_pNewStartCB->SetState(TRISTATE_FALSE);
      59           0 :     get(m_pNewStartNumberCB,       "checkCB_NUMBER_NEW_START");
      60           0 :     m_pNewStartNumberCB->SetState(TRISTATE_FALSE);
      61           0 :     get(m_pNewStartNF,             "spinNF_NEW_START");
      62             : 
      63           0 :     get(m_pCountParaFram,          "frameFL_COUNT_PARA");
      64           0 :     get(m_pCountParaCB,            "checkCB_COUNT_PARA");
      65           0 :     m_pCountParaCB->SetState(TRISTATE_FALSE);
      66           0 :     get(m_pRestartParaCountCB,     "checkCB_RESTART_PARACOUNT");
      67           0 :     m_pRestartParaCountCB->SetState(TRISTATE_FALSE);
      68             : 
      69           0 :     get(m_pRestartBX,              "boxRESTART_NO");
      70           0 :     get(m_pRestartNF,              "spinNF_RESTART_PARA");
      71             : 
      72             :     const SfxPoolItem* pItem;
      73             :     SfxObjectShell* pObjSh;
      74           0 :     if(SFX_ITEM_SET == rAttr.GetItemState(SID_HTML_MODE, false, &pItem) ||
      75           0 :         ( 0 != ( pObjSh = SfxObjectShell::Current()) &&
      76           0 :           0 != (pItem = pObjSh->GetItem(SID_HTML_MODE))))
      77             :     {
      78           0 :         sal_uInt16 nHtmlMode = ((const SfxUInt16Item*)pItem)->GetValue();
      79             : 
      80           0 :         if (HTMLMODE_ON & nHtmlMode)
      81           0 :             m_pCountParaFram->Hide();
      82             :     }
      83             : 
      84           0 :     m_pNewStartCB->SetClickHdl(LINK(this, SwParagraphNumTabPage, NewStartHdl_Impl));
      85           0 :     m_pNewStartNumberCB->SetClickHdl(LINK(this, SwParagraphNumTabPage, NewStartHdl_Impl));
      86           0 :     m_pNumberStyleLB->SetSelectHdl(LINK(this, SwParagraphNumTabPage, StyleHdl_Impl));
      87           0 :     m_pCountParaCB->SetClickHdl(LINK(this, SwParagraphNumTabPage, LineCountHdl_Impl));
      88           0 :     m_pRestartParaCountCB->SetClickHdl( LINK(this, SwParagraphNumTabPage, LineCountHdl_Impl));
      89           0 : }
      90             : 
      91           0 : SwParagraphNumTabPage::~SwParagraphNumTabPage()
      92             : {
      93           0 : }
      94             : 
      95           0 : SfxTabPage* SwParagraphNumTabPage::Create(  Window* pParent,
      96             :                                 const SfxItemSet& rSet )
      97             : {
      98           0 :     return new SwParagraphNumTabPage(pParent, rSet);
      99             : }
     100             : 
     101           0 : sal_uInt16* SwParagraphNumTabPage::GetRanges()
     102             : {
     103           0 :     return aPageRg;
     104             : }
     105             : 
     106           0 : bool    SwParagraphNumTabPage::FillItemSet( SfxItemSet& rSet )
     107             : {
     108           0 :     if( m_pOutlineLvLB->GetSelectEntryPos() != m_pOutlineLvLB->GetSavedValue())
     109             :     {
     110           0 :         sal_uInt16 aOutlineLv = m_pOutlineLvLB->GetSelectEntryPos();
     111           0 :         const SfxUInt16Item* pOldOutlineLv = (const SfxUInt16Item*)GetOldItem( rSet, SID_ATTR_PARA_OUTLINE_LEVEL);
     112           0 :         SfxUInt16Item* pOutlineLv = (SfxUInt16Item*)pOldOutlineLv->Clone();
     113           0 :         pOutlineLv->SetValue( aOutlineLv );
     114           0 :         rSet.Put(*pOutlineLv);
     115           0 :         delete pOutlineLv;
     116           0 :         bModified = sal_True;
     117             :     }
     118             : 
     119           0 :     if( m_pNumberStyleLB->GetSelectEntryPos() != m_pNumberStyleLB->GetSavedValue())
     120             :     {
     121           0 :         OUString aStyle;
     122           0 :         if(m_pNumberStyleLB->GetSelectEntryPos())
     123           0 :             aStyle = m_pNumberStyleLB->GetSelectEntry();
     124           0 :         const SfxStringItem* pOldRule = (const SfxStringItem*)GetOldItem( rSet, SID_ATTR_PARA_NUMRULE);
     125           0 :         SfxStringItem* pRule = (SfxStringItem*)pOldRule->Clone();
     126           0 :         if (pRule)
     127             :         {
     128           0 :             pRule->SetValue(aStyle);
     129           0 :             rSet.Put(*pRule);
     130           0 :             delete pRule;
     131           0 :             bModified = sal_True;
     132           0 :         }
     133             :     }
     134           0 :     if(m_pNewStartCB->GetState() != m_pNewStartCB->GetSavedValue() ||
     135           0 :         m_pNewStartNumberCB->GetState() != m_pNewStartNumberCB->GetSavedValue()||
     136           0 :        m_pNewStartNF->GetText() != m_pNewStartNF->GetSavedValue())
     137             :     {
     138           0 :         bModified = sal_True;
     139           0 :         bool bNewStartChecked = TRISTATE_TRUE == m_pNewStartCB->GetState();
     140           0 :         bool bNumberNewStartChecked = TRISTATE_TRUE == m_pNewStartNumberCB->GetState();
     141           0 :         rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART, bNewStartChecked));
     142             :         rSet.Put(SfxUInt16Item(FN_NUMBER_NEWSTART_AT,
     143           0 :                   bNumberNewStartChecked && bNewStartChecked ? (sal_uInt16)m_pNewStartNF->GetValue() : USHRT_MAX));
     144             :     }
     145             : 
     146           0 :     if(m_pCountParaCB->GetSavedValue() != m_pCountParaCB->GetState() ||
     147           0 :         m_pRestartParaCountCB->GetSavedValue() != m_pRestartParaCountCB->GetState() ||
     148           0 :        m_pRestartNF->GetSavedValue() != m_pRestartNF->GetText() )
     149             :     {
     150           0 :         SwFmtLineNumber aFmt;
     151           0 :         aFmt.SetStartValue( static_cast< sal_uLong >(m_pRestartParaCountCB->GetState() == TRISTATE_TRUE ?
     152           0 :                                 m_pRestartNF->GetValue() : 0 ));
     153           0 :         aFmt.SetCountLines( m_pCountParaCB->IsChecked() );
     154           0 :         rSet.Put(aFmt);
     155           0 :         bModified = sal_True;
     156             :     }
     157           0 :     return bModified;
     158             : }
     159             : 
     160           0 : void    SwParagraphNumTabPage::Reset( const SfxItemSet& rSet )
     161             : {
     162           0 :     bool bHasNumberStyle = false;
     163             : 
     164           0 :     SfxItemState eItemState = rSet.GetItemState( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) );
     165             : 
     166             :     sal_Int16 nOutlineLv;
     167           0 :     if( eItemState >= SFX_ITEM_AVAILABLE )
     168             :     {
     169           0 :         nOutlineLv = ((const SfxUInt16Item &)rSet.Get( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) )).GetValue();
     170           0 :         m_pOutlineLvLB->SelectEntryPos( nOutlineLv ) ;
     171             :     }
     172             :     else
     173             :     {
     174           0 :         m_pOutlineLvLB->SetNoSelection();
     175             :     }
     176           0 :     m_pOutlineLvLB->SaveValue();
     177             : 
     178           0 :     eItemState = rSet.GetItemState( GetWhich(SID_ATTR_PARA_NUMRULE) );
     179             : 
     180           0 :     OUString aStyle;
     181           0 :     if( eItemState >= SFX_ITEM_AVAILABLE )
     182             :     {
     183           0 :         aStyle = ((const SfxStringItem &)rSet.Get( GetWhich(SID_ATTR_PARA_NUMRULE) )).GetValue();
     184           0 :         if(aStyle.isEmpty())
     185           0 :             aStyle = m_pNumberStyleLB->GetEntry(0);
     186             : 
     187           0 :         if( aStyle == "Outline")
     188             :         {
     189           0 :             m_pNumberStyleLB->InsertEntry( msOutlineNumbering );
     190           0 :             m_pNumberStyleLB->SelectEntry( msOutlineNumbering );
     191           0 :             m_pNumberStyleLB->RemoveEntry(msOutlineNumbering);
     192           0 :             m_pNumberStyleLB->SaveValue();
     193             :         }
     194             :         else
     195           0 :             m_pNumberStyleLB->SelectEntry( aStyle );
     196             : 
     197           0 :         bHasNumberStyle = true;
     198             :     }
     199             :     else
     200             :     {
     201           0 :         m_pNumberStyleLB->SetNoSelection();
     202             :     }
     203             : 
     204           0 :     m_pNumberStyleLB->SaveValue();
     205             : 
     206           0 :     eItemState = rSet.GetItemState( FN_NUMBER_NEWSTART );
     207           0 :     if(eItemState > SFX_ITEM_AVAILABLE )
     208             :     {
     209           0 :         bCurNumrule = sal_True;
     210           0 :         const SfxBoolItem& rStart = (const SfxBoolItem&)rSet.Get(FN_NUMBER_NEWSTART);
     211             : 
     212           0 :         m_pNewStartCB->SetState(rStart.GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
     213             : 
     214           0 :         m_pNewStartCB->EnableTriState(false);
     215             :     }
     216             :     else
     217           0 :         m_pNewStartCB->SetState(bHasNumberStyle ? TRISTATE_FALSE : TRISTATE_INDET);
     218             : 
     219           0 :     m_pNewStartCB->SaveValue();
     220             : 
     221           0 :     eItemState = rSet.GetItemState( FN_NUMBER_NEWSTART_AT);
     222           0 :     if( eItemState > SFX_ITEM_AVAILABLE )
     223             :     {
     224           0 :         sal_uInt16 nNewStart = ((const SfxUInt16Item&)rSet.Get(FN_NUMBER_NEWSTART_AT)).GetValue();
     225           0 :         m_pNewStartNumberCB->Check(USHRT_MAX != nNewStart);
     226           0 :         if(USHRT_MAX == nNewStart)
     227           0 :             nNewStart = 1;
     228             : 
     229           0 :         m_pNewStartNF->SetValue(nNewStart);
     230           0 :         m_pNewStartNumberCB->EnableTriState(false);
     231             :     }
     232             :     else
     233           0 :         m_pNewStartCB->SetState(TRISTATE_INDET);
     234           0 :     NewStartHdl_Impl(m_pNewStartCB);
     235           0 :     m_pNewStartNF->SaveValue();
     236           0 :     m_pNewStartNumberCB->SaveValue();
     237           0 :     StyleHdl_Impl(m_pNumberStyleLB);
     238           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_LINENUMBER))
     239             :     {
     240           0 :         SwFmtLineNumber& rNum = (SwFmtLineNumber&)rSet.Get(RES_LINENUMBER);
     241           0 :         sal_uLong nStartValue = rNum.GetStartValue();
     242           0 :         bool bCount = rNum.IsCount();
     243           0 :         m_pCountParaCB->SetState( bCount ? TRISTATE_TRUE : TRISTATE_FALSE );
     244           0 :         m_pRestartParaCountCB->SetState( 0 != nStartValue ? TRISTATE_TRUE : TRISTATE_FALSE );
     245           0 :         m_pRestartNF->SetValue(nStartValue == 0 ? 1 : nStartValue);
     246           0 :         LineCountHdl_Impl(m_pCountParaCB);
     247           0 :         m_pCountParaCB->EnableTriState(false);
     248           0 :         m_pRestartParaCountCB->EnableTriState(false);
     249             :     }
     250             :     else
     251             :     {
     252           0 :         m_pCountParaCB->SetState(TRISTATE_INDET);
     253           0 :         m_pRestartParaCountCB->SetState(TRISTATE_INDET);
     254             :     }
     255           0 :     m_pCountParaCB->SaveValue();
     256           0 :     m_pRestartParaCountCB->SaveValue();
     257           0 :     m_pRestartNF->SaveValue();
     258             : 
     259           0 :     bModified = sal_False;
     260           0 : }
     261             : 
     262           0 : void SwParagraphNumTabPage::DisableOutline()
     263             : {
     264           0 :     m_pOutlineStartBX->Disable();
     265           0 : }
     266             : 
     267           0 : void SwParagraphNumTabPage::DisableNumbering()
     268             : {
     269           0 :     m_pNumberStyleBX->Disable();
     270           0 : }
     271             : 
     272           0 : void SwParagraphNumTabPage::EnableNewStart()
     273             : {
     274           0 :     m_pNewStartCB->Show();
     275           0 :     m_pNewStartBX->Show();
     276           0 : }
     277             : 
     278           0 : IMPL_LINK_NOARG(SwParagraphNumTabPage, NewStartHdl_Impl)
     279             : {
     280           0 :     bool bEnable = m_pNewStartCB->IsChecked();
     281           0 :     m_pNewStartNumberCB->Enable(bEnable);
     282           0 :     m_pNewStartNF->Enable(bEnable && m_pNewStartNumberCB->IsChecked());
     283           0 :     return 0;
     284             : }
     285             : 
     286           0 : IMPL_LINK_NOARG(SwParagraphNumTabPage, LineCountHdl_Impl)
     287             : {
     288           0 :     m_pRestartParaCountCB->Enable(m_pCountParaCB->IsChecked());
     289             : 
     290           0 :     bool bEnableRestartValue = m_pRestartParaCountCB->IsEnabled() &&
     291           0 :                                m_pRestartParaCountCB->IsChecked();
     292           0 :     m_pRestartBX->Enable(bEnableRestartValue);
     293             : 
     294           0 :     return 0;
     295             : }
     296             : 
     297           0 : IMPL_LINK( SwParagraphNumTabPage, StyleHdl_Impl, ListBox*, pBox )
     298             : {
     299           0 :     bool bEnable = bCurNumrule || pBox->GetSelectEntryPos() > 0;
     300           0 :     m_pNewStartCB->Enable(bEnable);
     301           0 :     NewStartHdl_Impl(m_pNewStartCB);
     302             : 
     303           0 :     return 0;
     304           0 : }
     305             : 
     306             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10