LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/dlg - paragr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 75 0.0 %
Date: 2013-07-09 Functions: 0 13 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 <vcl/field.hxx>
      21             : 
      22             : #include <svl/cjkoptions.hxx>
      23             : #include <svl/eitem.hxx>
      24             : #include <svl/intitem.hxx>
      25             : 
      26             : #include <editeng/editdata.hxx>
      27             : #include <svx/dialogs.hrc>
      28             : #include <editeng/eeitem.hxx>
      29             : #include <svx/flagsdef.hxx>
      30             : 
      31             : #include <editeng/outliner.hxx>
      32             : #include "paragr.hxx"
      33             : #include "sdresid.hxx"
      34             : #include "glob.hrc"
      35             : #include "sdattr.hrc"
      36             : 
      37             : class SdParagraphNumTabPage : public SfxTabPage
      38             : {
      39             : public:
      40             :     SdParagraphNumTabPage(Window* pParent, const SfxItemSet& rSet );
      41             :     ~SdParagraphNumTabPage();
      42             : 
      43             :     static SfxTabPage*  Create( Window* pParent, const SfxItemSet& rSet );
      44             :     static sal_uInt16*      GetRanges();
      45             : 
      46             :     virtual sal_Bool        FillItemSet( SfxItemSet& rSet );
      47             :     virtual void        Reset( const SfxItemSet& rSet );
      48             : 
      49             : private:
      50             :     TriStateBox     maNewStartCB;
      51             :     TriStateBox     maNewStartNumberCB;
      52             :     NumericField    maNewStartNF;
      53             :     bool            mbModified;
      54             : 
      55             :     DECL_LINK( ImplNewStartHdl, void* );
      56             : };
      57             : 
      58           0 : SdParagraphNumTabPage::SdParagraphNumTabPage(Window* pParent, const SfxItemSet& rAttr )
      59             : : SfxTabPage(pParent, SdResId(RID_TABPAGE_PARA_NUMBERING), rAttr)
      60             : , maNewStartCB( this, SdResId( CB_NEW_START ) )
      61             : , maNewStartNumberCB( this, SdResId( CB_NUMBER_NEW_START ) )
      62             : , maNewStartNF( this, SdResId( NF_NEW_START ) )
      63           0 : , mbModified(false)
      64             : {
      65           0 :     FreeResource();
      66             : 
      67           0 :     maNewStartCB.SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
      68           0 :     maNewStartNumberCB.SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
      69           0 : }
      70             : 
      71           0 : SdParagraphNumTabPage::~SdParagraphNumTabPage()
      72             : {
      73           0 : }
      74             : 
      75           0 : SfxTabPage* SdParagraphNumTabPage::Create(Window *pParent, const SfxItemSet & rAttrSet)
      76             : {
      77           0 :     return new SdParagraphNumTabPage( pParent, rAttrSet );
      78             : }
      79             : 
      80           0 : sal_uInt16* SdParagraphNumTabPage::GetRanges()
      81             : {
      82             :     static sal_uInt16 aRange[] =
      83             :     {
      84             :         ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
      85             :         0
      86             :     };
      87             : 
      88           0 :     return aRange;
      89             : }
      90             : 
      91           0 : sal_Bool SdParagraphNumTabPage::FillItemSet( SfxItemSet& rSet )
      92             : {
      93           0 :     if(maNewStartCB.GetState() != maNewStartCB.GetSavedValue() ||
      94           0 :         maNewStartNumberCB.GetState() != maNewStartNumberCB.GetSavedValue()||
      95           0 :        maNewStartNF.GetText() != maNewStartNF.GetSavedValue())
      96             :     {
      97           0 :         mbModified = true;
      98           0 :         sal_Bool bNewStartChecked = STATE_CHECK == maNewStartCB.GetState();
      99           0 :         sal_Bool bNumberNewStartChecked = STATE_CHECK == maNewStartNumberCB.GetState();
     100           0 :         rSet.Put(SfxBoolItem(ATTR_NUMBER_NEWSTART, bNewStartChecked));
     101             : 
     102           0 :         const sal_Int16 nStartAt = (sal_Int16)maNewStartNF.GetValue();
     103           0 :         rSet.Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT, bNumberNewStartChecked && bNewStartChecked ? nStartAt : -1));
     104             :     }
     105             : 
     106           0 :     return mbModified;
     107             : }
     108             : 
     109           0 : void SdParagraphNumTabPage::Reset( const SfxItemSet& rSet )
     110             : {
     111           0 :     SfxItemState eItemState = rSet.GetItemState( ATTR_NUMBER_NEWSTART );
     112           0 :     if(eItemState > SFX_ITEM_AVAILABLE )
     113             :     {
     114           0 :         const SfxBoolItem& rStart = (const SfxBoolItem&)rSet.Get(ATTR_NUMBER_NEWSTART);
     115           0 :         maNewStartCB.SetState( rStart.GetValue() ? STATE_CHECK : STATE_NOCHECK );
     116           0 :         maNewStartCB.EnableTriState(sal_False);
     117             :     }
     118             :     else
     119             :     {
     120           0 :         maNewStartCB.SetState(STATE_DONTKNOW);
     121           0 :         maNewStartCB.Disable();
     122             :     }
     123           0 :     maNewStartCB.SaveValue();
     124             : 
     125           0 :     eItemState = rSet.GetItemState( ATTR_NUMBER_NEWSTART_AT);
     126           0 :     if( eItemState > SFX_ITEM_AVAILABLE )
     127             :     {
     128           0 :         sal_Int16 nNewStart = ((const SfxInt16Item&)rSet.Get(ATTR_NUMBER_NEWSTART_AT)).GetValue();
     129           0 :         maNewStartNumberCB.Check(-1 != nNewStart);
     130           0 :         if(-1 == nNewStart)
     131           0 :             nNewStart = 1;
     132             : 
     133           0 :         maNewStartNF.SetValue(nNewStart);
     134           0 :         maNewStartNumberCB.EnableTriState(sal_False);
     135             :     }
     136             :     else
     137             :     {
     138           0 :         maNewStartCB.SetState(STATE_DONTKNOW);
     139             :     }
     140           0 :     ImplNewStartHdl(&maNewStartCB);
     141           0 :     maNewStartNF.SaveValue();
     142           0 :     maNewStartNumberCB.SaveValue();
     143           0 :     mbModified = sal_False;
     144           0 : }
     145             : 
     146           0 : IMPL_LINK_NOARG(SdParagraphNumTabPage, ImplNewStartHdl)
     147             : {
     148           0 :     sal_Bool bEnable = maNewStartCB.IsChecked();
     149           0 :     maNewStartNumberCB.Enable(bEnable);
     150           0 :     maNewStartNF.Enable(bEnable && maNewStartNumberCB.IsChecked());
     151           0 :     return 0;
     152             : }
     153             : 
     154           0 : SdParagraphDlg::SdParagraphDlg( Window* pParent, const SfxItemSet* pAttr )
     155           0 : : SfxTabDialog( pParent, SdResId( TAB_PARAGRAPH ), pAttr )
     156             : {
     157           0 :     FreeResource();
     158             : 
     159           0 :     AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
     160             : 
     161           0 :     SvtCJKOptions aCJKOptions;
     162           0 :     if( aCJKOptions.IsAsianTypographyEnabled() )
     163           0 :         AddTabPage( RID_SVXPAGE_PARA_ASIAN);
     164             :     else
     165           0 :         RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
     166             : 
     167           0 :     AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
     168             : 
     169           0 :     static const sal_Bool bShowParaNumbering = ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != NULL );
     170           0 :     if( bShowParaNumbering )
     171           0 :         AddTabPage( RID_TABPAGE_PARA_NUMBERING, SdParagraphNumTabPage::Create, SdParagraphNumTabPage::GetRanges );
     172             :     else
     173           0 :         RemoveTabPage( RID_TABPAGE_PARA_NUMBERING );
     174             : 
     175           0 :        AddTabPage( RID_SVXPAGE_TABULATOR );
     176           0 : }
     177             : 
     178           0 : void SdParagraphDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     179             : {
     180           0 :     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
     181           0 :     switch( nId )
     182             :     {
     183             :     case RID_SVXPAGE_STD_PARAGRAPH:
     184           0 :         aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/2));
     185           0 :         rPage.PageCreated(aSet);
     186           0 :         break;
     187             :     default:
     188           0 :         break;
     189           0 :     }
     190           0 : }
     191             : 
     192             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10