1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
33cdf0e10cSrcweir #include <svl/style.hxx>
34cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35cdf0e10cSrcweir #include <view.hxx>
36cdf0e10cSrcweir #include <wrtsh.hxx>
37cdf0e10cSrcweir #include <docsh.hxx>
38cdf0e10cSrcweir #include <charfmt.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir //#ifndef _FLDMGR_HXX //autogen
41cdf0e10cSrcweir //#include <fldmgr.hxx>
42cdf0e10cSrcweir //#endif
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include <docstyle.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include "fldbas.hxx"
48cdf0e10cSrcweir #include "lineinfo.hxx"
49cdf0e10cSrcweir #include "globals.hrc"
50cdf0e10cSrcweir #include "linenum.hrc"
51cdf0e10cSrcweir #include "linenum.hxx"
52cdf0e10cSrcweir #include "uitool.hxx"
53cdf0e10cSrcweir
54cdf0e10cSrcweir #include <IDocumentStylePoolAccess.hxx>
55cdf0e10cSrcweir
56cdf0e10cSrcweir /*--------------------------------------------------------------------
57cdf0e10cSrcweir Beschreibung:
58cdf0e10cSrcweir --------------------------------------------------------------------*/
59cdf0e10cSrcweir
SwLineNumberingDlg(SwView * pVw)60cdf0e10cSrcweir SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw) :
61cdf0e10cSrcweir SfxSingleTabDialog(&pVw->GetViewFrame()->GetWindow(), 0, 0),
62cdf0e10cSrcweir pSh(pVw->GetWrtShellPtr())
63cdf0e10cSrcweir {
64cdf0e10cSrcweir // TabPage erzeugen
65cdf0e10cSrcweir SetTabPage(SwLineNumberingPage::Create(this, *(SfxItemSet*)0));
66cdf0e10cSrcweir
67cdf0e10cSrcweir GetOKButton()->SetClickHdl(LINK(this, SwLineNumberingDlg, OKHdl));
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir /*--------------------------------------------------------------------
71cdf0e10cSrcweir Beschreibung:
72cdf0e10cSrcweir --------------------------------------------------------------------*/
73cdf0e10cSrcweir
~SwLineNumberingDlg()74cdf0e10cSrcweir __EXPORT SwLineNumberingDlg::~SwLineNumberingDlg()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir /*--------------------------------------------------------------------
79cdf0e10cSrcweir Beschreibung:
80cdf0e10cSrcweir --------------------------------------------------------------------*/
81cdf0e10cSrcweir
IMPL_LINK(SwLineNumberingDlg,OKHdl,Button *,EMPTYARG)82cdf0e10cSrcweir IMPL_LINK( SwLineNumberingDlg, OKHdl, Button *, EMPTYARG )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir if (GetOKButton()->IsEnabled())
85cdf0e10cSrcweir {
86cdf0e10cSrcweir SfxTabPage* pCurPage = GetTabPage();
87cdf0e10cSrcweir if( pCurPage )
88cdf0e10cSrcweir pCurPage->FillItemSet(*(SfxItemSet*)0);
89cdf0e10cSrcweir
90cdf0e10cSrcweir EndDialog( RET_OK );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir return 0;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir /*-----------------------------------------------------------------------
97cdf0e10cSrcweir Beschreibung:
98cdf0e10cSrcweir -----------------------------------------------------------------------*/
99cdf0e10cSrcweir
SwLineNumberingPage(Window * pParent,const SfxItemSet & rSet)100cdf0e10cSrcweir SwLineNumberingPage::SwLineNumberingPage( Window* pParent,
101cdf0e10cSrcweir const SfxItemSet& rSet )
102cdf0e10cSrcweir : SfxTabPage(pParent, SW_RES(TP_LINENUMBERING), rSet),
103cdf0e10cSrcweir aNumberingOnCB ( this, SW_RES( CB_NUMBERING_ON )),
104cdf0e10cSrcweir aDisplayFL ( this, SW_RES( FL_DISPLAY )),
105cdf0e10cSrcweir aCharStyleFT ( this, SW_RES( FT_CHAR_STYLE )),
106cdf0e10cSrcweir aCharStyleLB ( this, SW_RES( LB_CHAR_STYLE )),
107cdf0e10cSrcweir aFormatFT ( this, SW_RES( FT_FORMAT )),
108cdf0e10cSrcweir aFormatLB ( this, SW_RES( LB_FORMAT ), INSERT_NUM_EXTENDED_TYPES),
109cdf0e10cSrcweir aPosFT ( this, SW_RES( FT_POS )),
110cdf0e10cSrcweir aPosLB ( this, SW_RES( LB_POS )),
111cdf0e10cSrcweir aOffsetFT ( this, SW_RES( FT_OFFSET )),
112cdf0e10cSrcweir aOffsetMF ( this, SW_RES( MF_OFFSET )),
113cdf0e10cSrcweir aNumIntervalFT ( this, SW_RES( FT_NUM_INVERVAL )),
114cdf0e10cSrcweir aNumIntervalNF ( this, SW_RES( NF_NUM_INVERVAL )),
115cdf0e10cSrcweir aNumRowsFT ( this, SW_RES( FT_NUM_ROWS )),
116cdf0e10cSrcweir aDivisorFL ( this, SW_RES( FL_DIVISOR )),
117cdf0e10cSrcweir aDivisorFT ( this, SW_RES( FT_DIVISOR )),
118cdf0e10cSrcweir aDivisorED ( this, SW_RES( ED_DIVISOR )),
119cdf0e10cSrcweir aDivIntervalFT ( this, SW_RES( FT_DIV_INTERVAL )),
120cdf0e10cSrcweir aDivIntervalNF ( this, SW_RES( NF_DIV_INTERVAL )),
121cdf0e10cSrcweir aDivRowsFT ( this, SW_RES( FT_DIV_ROWS )),
122cdf0e10cSrcweir aCountFL ( this, SW_RES( FL_COUNT )),
123cdf0e10cSrcweir aCountEmptyLinesCB ( this, SW_RES( CB_COUNT_EMPTYLINES )),
124cdf0e10cSrcweir aCountFrameLinesCB ( this, SW_RES( CB_COUNT_FRAMELINES )),
125cdf0e10cSrcweir aRestartEachPageCB ( this, SW_RES( CB_RESTART_PAGE ))
126cdf0e10cSrcweir
127cdf0e10cSrcweir {
128cdf0e10cSrcweir String sIntervalName = aDivIntervalFT.GetAccessibleName();
129cdf0e10cSrcweir sIntervalName += String::CreateFromAscii("(");
130cdf0e10cSrcweir sIntervalName += aDivRowsFT.GetAccessibleName();
131cdf0e10cSrcweir sIntervalName += String::CreateFromAscii(")");
132cdf0e10cSrcweir aDivIntervalNF.SetAccessibleName(sIntervalName);
133cdf0e10cSrcweir sIntervalName = aNumIntervalFT.GetAccessibleName();
134cdf0e10cSrcweir sIntervalName += String::CreateFromAscii("(");
135cdf0e10cSrcweir sIntervalName += aNumRowsFT.GetAccessibleName();
136cdf0e10cSrcweir sIntervalName += String::CreateFromAscii(")");
137cdf0e10cSrcweir aNumIntervalNF.SetAccessibleName(sIntervalName);
138cdf0e10cSrcweir
139cdf0e10cSrcweir FreeResource();
140cdf0e10cSrcweir SwLineNumberingDlg *pDlg = (SwLineNumberingDlg *)GetParent();
141cdf0e10cSrcweir pSh = pDlg->GetWrtShell();
142cdf0e10cSrcweir // Zeichenvorlagen
143cdf0e10cSrcweir ::FillCharStyleListBox(aCharStyleLB, pSh->GetView().GetDocShell());
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir /*-----------------------------------------------------------------------
147cdf0e10cSrcweir Beschreibung:
148cdf0e10cSrcweir -----------------------------------------------------------------------*/
149cdf0e10cSrcweir
~SwLineNumberingPage()150cdf0e10cSrcweir __EXPORT SwLineNumberingPage::~SwLineNumberingPage()
151cdf0e10cSrcweir {
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir /*-----------------------------------------------------------------------
155cdf0e10cSrcweir Beschreibung:
156cdf0e10cSrcweir -----------------------------------------------------------------------*/
157cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rSet)158cdf0e10cSrcweir SfxTabPage* __EXPORT SwLineNumberingPage::Create( Window* pParent, const SfxItemSet& rSet )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir return new SwLineNumberingPage( pParent, rSet );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir /*-----------------------------------------------------------------------
164cdf0e10cSrcweir Beschreibung:
165cdf0e10cSrcweir -----------------------------------------------------------------------*/
166cdf0e10cSrcweir
Reset(const SfxItemSet &)167cdf0e10cSrcweir void __EXPORT SwLineNumberingPage::Reset( const SfxItemSet& )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir const SwLineNumberInfo &rInf = pSh->GetLineNumberInfo();
170cdf0e10cSrcweir IDocumentStylePoolAccess* pIDSPA = pSh->getIDocumentStylePoolAccess();
171cdf0e10cSrcweir
172cdf0e10cSrcweir String sStyleName(rInf.GetCharFmt( *pIDSPA )->GetName());
173cdf0e10cSrcweir const sal_uInt16 nPos = aCharStyleLB.GetEntryPos(sStyleName);
174cdf0e10cSrcweir
175cdf0e10cSrcweir if (nPos != LISTBOX_ENTRY_NOTFOUND)
176cdf0e10cSrcweir aCharStyleLB.SelectEntryPos(nPos);
177cdf0e10cSrcweir else
178cdf0e10cSrcweir {
179cdf0e10cSrcweir if (sStyleName.Len())
180cdf0e10cSrcweir {
181cdf0e10cSrcweir aCharStyleLB.InsertEntry(sStyleName);
182cdf0e10cSrcweir aCharStyleLB.SelectEntry(sStyleName);
183cdf0e10cSrcweir }
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir // Format
187cdf0e10cSrcweir // SwFldMgr aMgr( pSh );
188cdf0e10cSrcweir sal_uInt16 nSelFmt = rInf.GetNumType().GetNumberingType();
189cdf0e10cSrcweir // sal_uInt16 nCnt = aMgr.GetFormatCount( TYP_SEQFLD, sal_False );
190cdf0e10cSrcweir
191cdf0e10cSrcweir // for( sal_uInt16 i = 0; i < nCnt; i++)
192cdf0e10cSrcweir // {
193cdf0e10cSrcweir // aFormatLB.InsertEntry(aMgr.GetFormatStr( TYP_SEQFLD, i));
194cdf0e10cSrcweir // sal_uInt16 nFmtId = aMgr.GetFormatId( TYP_SEQFLD, i );
195cdf0e10cSrcweir // aFormatLB.SetEntryData( i, (void*)nFmtId );
196cdf0e10cSrcweir // if( nFmtId == nSelFmt )
197cdf0e10cSrcweir // aFormatLB.SelectEntryPos( i );
198cdf0e10cSrcweir // }
199cdf0e10cSrcweir aFormatLB.SelectNumberingType(nSelFmt);
200cdf0e10cSrcweir
201cdf0e10cSrcweir // if ( !aFormatLB.GetSelectEntryCount() )
202cdf0e10cSrcweir // aFormatLB.SelectEntryPos(aFormatLB.GetEntryCount() - 1);
203cdf0e10cSrcweir
204cdf0e10cSrcweir // Position
205cdf0e10cSrcweir aPosLB.SelectEntryPos((sal_uInt16)rInf.GetPos());
206cdf0e10cSrcweir
207cdf0e10cSrcweir // Offset
208cdf0e10cSrcweir sal_uInt16 nOffset = rInf.GetPosFromLeft();
209cdf0e10cSrcweir if (nOffset == USHRT_MAX)
210cdf0e10cSrcweir nOffset = 0;
211cdf0e10cSrcweir
212cdf0e10cSrcweir aOffsetMF.SetValue(aOffsetMF.Normalize(nOffset), FUNIT_TWIP);
213cdf0e10cSrcweir
214cdf0e10cSrcweir // Numerierungsoffset
215cdf0e10cSrcweir aNumIntervalNF.SetValue(rInf.GetCountBy());
216cdf0e10cSrcweir
217cdf0e10cSrcweir // Teiler
218cdf0e10cSrcweir aDivisorED.SetText(rInf.GetDivider());
219cdf0e10cSrcweir
220cdf0e10cSrcweir // Teileroffset
221cdf0e10cSrcweir aDivIntervalNF.SetValue(rInf.GetDividerCountBy());
222cdf0e10cSrcweir
223cdf0e10cSrcweir // Zaehlen
224cdf0e10cSrcweir aCountEmptyLinesCB.Check(rInf.IsCountBlankLines());
225cdf0e10cSrcweir aCountFrameLinesCB.Check(rInf.IsCountInFlys());
226cdf0e10cSrcweir aRestartEachPageCB.Check(rInf.IsRestartEachPage());
227cdf0e10cSrcweir
228cdf0e10cSrcweir aNumberingOnCB.Check(rInf.IsPaintLineNumbers());
229cdf0e10cSrcweir
230cdf0e10cSrcweir aNumberingOnCB.SetClickHdl(LINK(this, SwLineNumberingPage, LineOnOffHdl));
231cdf0e10cSrcweir aDivisorED.SetModifyHdl(LINK(this, SwLineNumberingPage, ModifyHdl));
232cdf0e10cSrcweir ModifyHdl();
233cdf0e10cSrcweir LineOnOffHdl();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir /*--------------------------------------------------------------------
237cdf0e10cSrcweir Beschreibung: Modify
238cdf0e10cSrcweir --------------------------------------------------------------------*/
239cdf0e10cSrcweir
IMPL_LINK(SwLineNumberingPage,ModifyHdl,Edit *,EMPTYARG)240cdf0e10cSrcweir IMPL_LINK( SwLineNumberingPage, ModifyHdl, Edit *, EMPTYARG )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir sal_Bool bHasValue = aDivisorED.GetText().Len() != 0;
243cdf0e10cSrcweir
244cdf0e10cSrcweir aDivIntervalFT.Enable(bHasValue);
245cdf0e10cSrcweir aDivIntervalNF.Enable(bHasValue);
246cdf0e10cSrcweir aDivRowsFT.Enable(bHasValue);
247cdf0e10cSrcweir
248cdf0e10cSrcweir return 0;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
251cdf0e10cSrcweir /*--------------------------------------------------------------------
252cdf0e10cSrcweir Beschreibung: On/Off
253cdf0e10cSrcweir --------------------------------------------------------------------*/
254cdf0e10cSrcweir
IMPL_LINK(SwLineNumberingPage,LineOnOffHdl,CheckBox *,EMPTYARG)255cdf0e10cSrcweir IMPL_LINK( SwLineNumberingPage, LineOnOffHdl, CheckBox *, EMPTYARG )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir sal_Bool bEnable = aNumberingOnCB.IsChecked();
258cdf0e10cSrcweir
259cdf0e10cSrcweir aCharStyleFT.Enable(bEnable);
260cdf0e10cSrcweir aCharStyleLB.Enable(bEnable);
261cdf0e10cSrcweir aFormatFT.Enable(bEnable);
262cdf0e10cSrcweir aFormatLB.Enable(bEnable);
263cdf0e10cSrcweir aPosFT.Enable(bEnable);
264cdf0e10cSrcweir aPosLB.Enable(bEnable);
265cdf0e10cSrcweir aOffsetFT.Enable(bEnable);
266cdf0e10cSrcweir aOffsetMF.Enable(bEnable);
267cdf0e10cSrcweir aNumIntervalFT.Enable(bEnable);
268cdf0e10cSrcweir aNumIntervalNF.Enable(bEnable);
269cdf0e10cSrcweir aNumRowsFT.Enable(bEnable);
270cdf0e10cSrcweir aDisplayFL.Enable(bEnable);
271cdf0e10cSrcweir aDivisorFT.Enable(bEnable);
272cdf0e10cSrcweir aDivisorED.Enable(bEnable);
273cdf0e10cSrcweir aDivIntervalFT.Enable(bEnable);
274cdf0e10cSrcweir aDivIntervalNF.Enable(bEnable);
275cdf0e10cSrcweir aDivRowsFT.Enable(bEnable);
276cdf0e10cSrcweir aDivisorFL.Enable(bEnable);
277cdf0e10cSrcweir aCountEmptyLinesCB.Enable(bEnable);
278cdf0e10cSrcweir aCountFrameLinesCB.Enable(bEnable);
279cdf0e10cSrcweir aRestartEachPageCB.Enable(bEnable);
280cdf0e10cSrcweir aCountFL.Enable(bEnable);
281cdf0e10cSrcweir
282cdf0e10cSrcweir return 0;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir
285cdf0e10cSrcweir /*-----------------------------------------------------------------------
286cdf0e10cSrcweir Beschreibung:
287cdf0e10cSrcweir -----------------------------------------------------------------------*/
288cdf0e10cSrcweir
FillItemSet(SfxItemSet &)289cdf0e10cSrcweir sal_Bool __EXPORT SwLineNumberingPage::FillItemSet( SfxItemSet& )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir SwLineNumberInfo aInf(pSh->GetLineNumberInfo());
292cdf0e10cSrcweir
293cdf0e10cSrcweir // Zeichenvorlagen
294cdf0e10cSrcweir String sCharFmtName(aCharStyleLB.GetSelectEntry());
295cdf0e10cSrcweir SwCharFmt *pCharFmt = pSh->FindCharFmtByName(sCharFmtName);
296cdf0e10cSrcweir
297cdf0e10cSrcweir if (!pCharFmt)
298cdf0e10cSrcweir {
299cdf0e10cSrcweir SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
300cdf0e10cSrcweir SfxStyleSheetBase* pBase;
301cdf0e10cSrcweir pBase = pPool->Find(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
302cdf0e10cSrcweir if(!pBase)
303cdf0e10cSrcweir pBase = &pPool->Make(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
304cdf0e10cSrcweir pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
305cdf0e10cSrcweir }
306cdf0e10cSrcweir
307cdf0e10cSrcweir if (pCharFmt)
308cdf0e10cSrcweir aInf.SetCharFmt(pCharFmt);
309cdf0e10cSrcweir
310cdf0e10cSrcweir // Format
311cdf0e10cSrcweir SvxNumberType aType;
312cdf0e10cSrcweir aType.SetNumberingType(aFormatLB.GetSelectedNumberingType());
313cdf0e10cSrcweir aInf.SetNumType(aType);
314cdf0e10cSrcweir
315cdf0e10cSrcweir // Position
316cdf0e10cSrcweir aInf.SetPos((LineNumberPosition)aPosLB.GetSelectEntryPos());
317cdf0e10cSrcweir
318cdf0e10cSrcweir // Offset
319cdf0e10cSrcweir aInf.SetPosFromLeft((sal_uInt16)aOffsetMF.Denormalize(aOffsetMF.GetValue(FUNIT_TWIP)));
320cdf0e10cSrcweir
321cdf0e10cSrcweir // Numerierungsoffset
322cdf0e10cSrcweir aInf.SetCountBy((sal_uInt16)aNumIntervalNF.GetValue());
323cdf0e10cSrcweir
324cdf0e10cSrcweir // Teiler
325cdf0e10cSrcweir aInf.SetDivider(aDivisorED.GetText());
326cdf0e10cSrcweir
327cdf0e10cSrcweir // Teileroffset
328cdf0e10cSrcweir aInf.SetDividerCountBy((sal_uInt16)aDivIntervalNF.GetValue());
329cdf0e10cSrcweir
330cdf0e10cSrcweir // Zaehlen
331cdf0e10cSrcweir aInf.SetCountBlankLines(aCountEmptyLinesCB.IsChecked());
332cdf0e10cSrcweir aInf.SetCountInFlys(aCountFrameLinesCB.IsChecked());
333cdf0e10cSrcweir aInf.SetRestartEachPage(aRestartEachPageCB.IsChecked());
334cdf0e10cSrcweir
335cdf0e10cSrcweir aInf.SetPaintLineNumbers(aNumberingOnCB.IsChecked());
336cdf0e10cSrcweir
337cdf0e10cSrcweir pSh->SetLineNumberInfo(aInf);
338cdf0e10cSrcweir
339cdf0e10cSrcweir return sal_False;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir
343