1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: paragr.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
38 #include <vcl/field.hxx>
40 #include <svtools/cjkoptions.hxx>
41 #include <svtools/eitem.hxx>
42 #include <svtools/intitem.hxx>
44 #include <svx/editdata.hxx>
45 #include <svx/dialogs.hrc>
46 #include <svx/eeitem.hxx>
47 #include <svx/flagsdef.hxx>
51 #include "sdresid.hxx"
55 class SdParagraphNumTabPage
: public SfxTabPage
58 SdParagraphNumTabPage(Window
* pParent
, const SfxItemSet
& rSet
);
59 ~SdParagraphNumTabPage();
61 static SfxTabPage
* Create( Window
* pParent
, const SfxItemSet
& rSet
);
62 static USHORT
* GetRanges();
64 virtual BOOL
FillItemSet( SfxItemSet
& rSet
);
65 virtual void Reset( const SfxItemSet
& rSet
);
68 TriStateBox maNewStartCB
;
69 TriStateBox maNewStartNumberCB
;
70 NumericField maNewStartNF
;
73 DECL_LINK( ImplNewStartHdl
, CheckBox
* );
76 SdParagraphNumTabPage::SdParagraphNumTabPage(Window
* pParent
, const SfxItemSet
& rAttr
)
77 : SfxTabPage(pParent
, SdResId(RID_TABPAGE_PARA_NUMBERING
), rAttr
)
78 , maNewStartCB( this, SdResId( CB_NEW_START
) )
79 , maNewStartNumberCB( this, SdResId( CB_NUMBER_NEW_START
) )
80 , maNewStartNF( this, SdResId( NF_NEW_START
) )
85 maNewStartCB
.SetClickHdl(LINK(this, SdParagraphNumTabPage
, ImplNewStartHdl
));
86 maNewStartNumberCB
.SetClickHdl(LINK(this, SdParagraphNumTabPage
, ImplNewStartHdl
));
89 SdParagraphNumTabPage::~SdParagraphNumTabPage()
93 SfxTabPage
* SdParagraphNumTabPage::Create(Window
*pParent
, const SfxItemSet
& rAttrSet
)
95 return new SdParagraphNumTabPage( pParent
, rAttrSet
);
98 USHORT
* SdParagraphNumTabPage::GetRanges()
100 static USHORT __FAR_DATA aRange
[] =
102 ATTR_PARANUMBERING_START
, ATTR_PARANUMBERING_END
,
109 BOOL
SdParagraphNumTabPage::FillItemSet( SfxItemSet
& rSet
)
111 if(maNewStartCB
.GetState() != maNewStartCB
.GetSavedValue() ||
112 maNewStartNumberCB
.GetState() != maNewStartNumberCB
.GetSavedValue()||
113 maNewStartNF
.GetText() != maNewStartNF
.GetSavedValue())
116 BOOL bNewStartChecked
= STATE_CHECK
== maNewStartCB
.GetState();
117 BOOL bNumberNewStartChecked
= STATE_CHECK
== maNewStartNumberCB
.GetState();
118 rSet
.Put(SfxBoolItem(ATTR_NUMBER_NEWSTART
, bNewStartChecked
));
120 const sal_Int16 nStartAt
= (sal_Int16
)maNewStartNF
.GetValue();
121 rSet
.Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT
, bNumberNewStartChecked
&& bNewStartChecked
? nStartAt
: -1));
127 void SdParagraphNumTabPage::Reset( const SfxItemSet
& rSet
)
129 SfxItemState eItemState
= rSet
.GetItemState( ATTR_NUMBER_NEWSTART
);
130 if(eItemState
> SFX_ITEM_AVAILABLE
)
132 const SfxBoolItem
& rStart
= (const SfxBoolItem
&)rSet
.Get(ATTR_NUMBER_NEWSTART
);
133 maNewStartCB
.SetState( rStart
.GetValue() ? STATE_CHECK
: STATE_NOCHECK
);
134 maNewStartCB
.EnableTriState(FALSE
);
138 maNewStartCB
.SetState(STATE_DONTKNOW
);
139 maNewStartCB
.Disable();
141 maNewStartCB
.SaveValue();
143 eItemState
= rSet
.GetItemState( ATTR_NUMBER_NEWSTART_AT
);
144 if( eItemState
> SFX_ITEM_AVAILABLE
)
146 sal_Int16 nNewStart
= ((const SfxInt16Item
&)rSet
.Get(ATTR_NUMBER_NEWSTART_AT
)).GetValue();
147 maNewStartNumberCB
.Check(-1 != nNewStart
);
151 maNewStartNF
.SetValue(nNewStart
);
152 maNewStartNumberCB
.EnableTriState(FALSE
);
156 maNewStartCB
.SetState(STATE_DONTKNOW
);
158 ImplNewStartHdl(&maNewStartCB
);
159 maNewStartNF
.SaveValue();
160 maNewStartNumberCB
.SaveValue();
164 IMPL_LINK( SdParagraphNumTabPage
, ImplNewStartHdl
, CheckBox
*, EMPTYARG
)
166 BOOL bEnable
= maNewStartCB
.IsChecked();
167 maNewStartNumberCB
.Enable(bEnable
);
168 maNewStartNF
.Enable(bEnable
&& maNewStartNumberCB
.IsChecked());
172 SdParagraphDlg::SdParagraphDlg( Window
* pParent
, const SfxItemSet
* pAttr
)
173 : SfxTabDialog( pParent
, SdResId( TAB_PARAGRAPH
), pAttr
)
174 , rOutAttrs( *pAttr
)
178 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH
);
180 SvtCJKOptions aCJKOptions
;
181 if( aCJKOptions
.IsAsianTypographyEnabled() )
182 AddTabPage( RID_SVXPAGE_PARA_ASIAN
);
184 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN
);
186 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH
);
188 static const BOOL bShowParaNumbering
= ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != NULL
);
189 if( bShowParaNumbering
)
190 AddTabPage( RID_TABPAGE_PARA_NUMBERING
, SdParagraphNumTabPage::Create
, SdParagraphNumTabPage::GetRanges
);
192 RemoveTabPage( RID_TABPAGE_PARA_NUMBERING
);
194 AddTabPage( RID_SVXPAGE_TABULATOR
);
197 void SdParagraphDlg::PageCreated( USHORT nId
, SfxTabPage
&rPage
)
199 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
202 case RID_SVXPAGE_STD_PARAGRAPH
:
203 aSet
.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST
, MM50
/2));
204 rPage
.PageCreated(aSet
);