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