1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifdef SD_DLLIMPLEMENTATION 28cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <vcl/field.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svl/cjkoptions.hxx> 34cdf0e10cSrcweir #include <svl/eitem.hxx> 35cdf0e10cSrcweir #include <svl/intitem.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <editeng/editdata.hxx> 38cdf0e10cSrcweir #include <svx/dialogs.hrc> 39cdf0e10cSrcweir #include <editeng/eeitem.hxx> 40cdf0e10cSrcweir #include <svx/flagsdef.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include "eetext.hxx" 43cdf0e10cSrcweir #include "paragr.hxx" 44cdf0e10cSrcweir #include "sdresid.hxx" 45cdf0e10cSrcweir #include "glob.hrc" 46cdf0e10cSrcweir #include "sdattr.hrc" 47cdf0e10cSrcweir 48cdf0e10cSrcweir class SdParagraphNumTabPage : public SfxTabPage 49cdf0e10cSrcweir { 50cdf0e10cSrcweir public: 51cdf0e10cSrcweir SdParagraphNumTabPage(Window* pParent, const SfxItemSet& rSet ); 52cdf0e10cSrcweir ~SdParagraphNumTabPage(); 53cdf0e10cSrcweir 54cdf0e10cSrcweir static SfxTabPage* Create( Window* pParent, const SfxItemSet& rSet ); 55cdf0e10cSrcweir static sal_uInt16* GetRanges(); 56cdf0e10cSrcweir 57cdf0e10cSrcweir virtual sal_Bool FillItemSet( SfxItemSet& rSet ); 58cdf0e10cSrcweir virtual void Reset( const SfxItemSet& rSet ); 59cdf0e10cSrcweir 60cdf0e10cSrcweir private: 61cdf0e10cSrcweir TriStateBox maNewStartCB; 62cdf0e10cSrcweir TriStateBox maNewStartNumberCB; 63cdf0e10cSrcweir NumericField maNewStartNF; 64cdf0e10cSrcweir bool mbModified; 65cdf0e10cSrcweir 66cdf0e10cSrcweir DECL_LINK( ImplNewStartHdl, CheckBox* ); 67cdf0e10cSrcweir }; 68cdf0e10cSrcweir 69cdf0e10cSrcweir SdParagraphNumTabPage::SdParagraphNumTabPage(Window* pParent, const SfxItemSet& rAttr ) 70cdf0e10cSrcweir : SfxTabPage(pParent, SdResId(RID_TABPAGE_PARA_NUMBERING), rAttr) 71cdf0e10cSrcweir , maNewStartCB( this, SdResId( CB_NEW_START ) ) 72cdf0e10cSrcweir , maNewStartNumberCB( this, SdResId( CB_NUMBER_NEW_START ) ) 73cdf0e10cSrcweir , maNewStartNF( this, SdResId( NF_NEW_START ) ) 74cdf0e10cSrcweir , mbModified(false) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir FreeResource(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir maNewStartCB.SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl)); 79cdf0e10cSrcweir maNewStartNumberCB.SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl)); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir SdParagraphNumTabPage::~SdParagraphNumTabPage() 83cdf0e10cSrcweir { 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir SfxTabPage* SdParagraphNumTabPage::Create(Window *pParent, const SfxItemSet & rAttrSet) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir return new SdParagraphNumTabPage( pParent, rAttrSet ); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir sal_uInt16* SdParagraphNumTabPage::GetRanges() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir static sal_uInt16 __FAR_DATA aRange[] = 94cdf0e10cSrcweir { 95cdf0e10cSrcweir ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END, 96cdf0e10cSrcweir 0 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir return aRange; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir sal_Bool SdParagraphNumTabPage::FillItemSet( SfxItemSet& rSet ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir if(maNewStartCB.GetState() != maNewStartCB.GetSavedValue() || 105cdf0e10cSrcweir maNewStartNumberCB.GetState() != maNewStartNumberCB.GetSavedValue()|| 106cdf0e10cSrcweir maNewStartNF.GetText() != maNewStartNF.GetSavedValue()) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir mbModified = true; 109cdf0e10cSrcweir sal_Bool bNewStartChecked = STATE_CHECK == maNewStartCB.GetState(); 110cdf0e10cSrcweir sal_Bool bNumberNewStartChecked = STATE_CHECK == maNewStartNumberCB.GetState(); 111cdf0e10cSrcweir rSet.Put(SfxBoolItem(ATTR_NUMBER_NEWSTART, bNewStartChecked)); 112cdf0e10cSrcweir 113cdf0e10cSrcweir const sal_Int16 nStartAt = (sal_Int16)maNewStartNF.GetValue(); 114cdf0e10cSrcweir rSet.Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT, bNumberNewStartChecked && bNewStartChecked ? nStartAt : -1)); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir return mbModified; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir void SdParagraphNumTabPage::Reset( const SfxItemSet& rSet ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir SfxItemState eItemState = rSet.GetItemState( ATTR_NUMBER_NEWSTART ); 123cdf0e10cSrcweir if(eItemState > SFX_ITEM_AVAILABLE ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir const SfxBoolItem& rStart = (const SfxBoolItem&)rSet.Get(ATTR_NUMBER_NEWSTART); 126cdf0e10cSrcweir maNewStartCB.SetState( rStart.GetValue() ? STATE_CHECK : STATE_NOCHECK ); 127cdf0e10cSrcweir maNewStartCB.EnableTriState(sal_False); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else 130cdf0e10cSrcweir { 131cdf0e10cSrcweir maNewStartCB.SetState(STATE_DONTKNOW); 132cdf0e10cSrcweir maNewStartCB.Disable(); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir maNewStartCB.SaveValue(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir eItemState = rSet.GetItemState( ATTR_NUMBER_NEWSTART_AT); 137cdf0e10cSrcweir if( eItemState > SFX_ITEM_AVAILABLE ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir sal_Int16 nNewStart = ((const SfxInt16Item&)rSet.Get(ATTR_NUMBER_NEWSTART_AT)).GetValue(); 140cdf0e10cSrcweir maNewStartNumberCB.Check(-1 != nNewStart); 141cdf0e10cSrcweir if(-1 == nNewStart) 142cdf0e10cSrcweir nNewStart = 1; 143cdf0e10cSrcweir 144cdf0e10cSrcweir maNewStartNF.SetValue(nNewStart); 145cdf0e10cSrcweir maNewStartNumberCB.EnableTriState(sal_False); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir else 148cdf0e10cSrcweir { 149cdf0e10cSrcweir maNewStartCB.SetState(STATE_DONTKNOW); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir ImplNewStartHdl(&maNewStartCB); 152cdf0e10cSrcweir maNewStartNF.SaveValue(); 153cdf0e10cSrcweir maNewStartNumberCB.SaveValue(); 154cdf0e10cSrcweir mbModified = sal_False; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir IMPL_LINK( SdParagraphNumTabPage, ImplNewStartHdl, CheckBox*, EMPTYARG ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir sal_Bool bEnable = maNewStartCB.IsChecked(); 160cdf0e10cSrcweir maNewStartNumberCB.Enable(bEnable); 161cdf0e10cSrcweir maNewStartNF.Enable(bEnable && maNewStartNumberCB.IsChecked()); 162cdf0e10cSrcweir return 0; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir SdParagraphDlg::SdParagraphDlg( Window* pParent, const SfxItemSet* pAttr ) 166cdf0e10cSrcweir : SfxTabDialog( pParent, SdResId( TAB_PARAGRAPH ), pAttr ) 167cdf0e10cSrcweir , rOutAttrs( *pAttr ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir FreeResource(); 170cdf0e10cSrcweir 171cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_STD_PARAGRAPH ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir SvtCJKOptions aCJKOptions; 174cdf0e10cSrcweir if( aCJKOptions.IsAsianTypographyEnabled() ) 175cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_PARA_ASIAN); 176cdf0e10cSrcweir else 177cdf0e10cSrcweir RemoveTabPage( RID_SVXPAGE_PARA_ASIAN ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir static const sal_Bool bShowParaNumbering = ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != NULL ); 182cdf0e10cSrcweir if( bShowParaNumbering ) 183cdf0e10cSrcweir AddTabPage( RID_TABPAGE_PARA_NUMBERING, SdParagraphNumTabPage::Create, SdParagraphNumTabPage::GetRanges ); 184cdf0e10cSrcweir else 185cdf0e10cSrcweir RemoveTabPage( RID_TABPAGE_PARA_NUMBERING ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_TABULATOR ); 188cdf0e10cSrcweir } 189