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

Generated by: LCOV version 1.10