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: docfnote.cxx,v $
10 * $Revision: 1.19.224.1 $
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_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
39 #include <svtools/style.hxx>
48 #include <docfnote.hxx>
49 #include <impfnote.hxx>
50 #include <ftninfo.hxx>
52 #include <pagedesc.hxx>
53 #include <charfmt.hxx>
54 #include <docstyle.hxx>
57 #include <poolfmt.hxx>
66 #include <docfnote.hrc>
71 #include <SwStyleNameMapper.hxx>
73 SwFootNoteOptionDlg::SwFootNoteOptionDlg( Window
*pParent
, SwWrtShell
&rS
) :
74 SfxTabDialog( pParent
, SW_RES(DLG_DOC_FOOTNOTE
) ),
80 aOldOkHdl
= GetOKButton().GetClickHdl();
81 GetOKButton().SetClickHdl( LINK( this, SwFootNoteOptionDlg
, OkHdl
) );
83 AddTabPage( TP_FOOTNOTEOPTION
, SwFootNoteOptionPage::Create
, 0 );
84 AddTabPage( TP_ENDNOTEOPTION
, SwEndNoteOptionPage::Create
, 0 );
87 void SwFootNoteOptionDlg::PageCreated( USHORT
/*nId*/, SfxTabPage
&rPage
)
89 ((SwEndNoteOptionPage
&)rPage
).SetShell( rSh
);
92 SwFootNoteOptionDlg::~SwFootNoteOptionDlg()
96 IMPL_LINK( SwFootNoteOptionDlg
, OkHdl
, Button
*, pBtn
)
98 SfxItemSet
aDummySet(rSh
.GetAttrPool(), 1, 1 );
99 SfxTabPage
*pPage
= GetTabPage( TP_FOOTNOTEOPTION
);
101 pPage
->FillItemSet( aDummySet
);
102 pPage
= GetTabPage( TP_ENDNOTEOPTION
);
104 pPage
->FillItemSet( aDummySet
);
105 aOldOkHdl
.Call( pBtn
);
110 //----------------------------------------------------------------------
113 SwEndNoteOptionPage::SwEndNoteOptionPage( Window
*pParent
, BOOL bEN
,
114 const SfxItemSet
&rSet
) :
115 SfxTabPage( pParent
, SW_RES(bEN
? TP_ENDNOTEOPTION
: TP_FOOTNOTEOPTION
), rSet
),
116 aNumTypeFT (this, SW_RES( FT_NUMTYPE
)),
117 aNumViewBox (this, SW_RES( LB_NUMVIEW
), INSERT_NUM_EXTENDED_TYPES
),
118 aOffsetLbl (this, SW_RES( FT_OFFSET
)),
119 aOffsetFld (this, SW_RES( FLD_OFFSET
)),
120 aNumCountFT (this, SW_RES( FT_NUMCOUNT
)),
121 aNumCountBox (this, SW_RES( LB_NUMCOUNT
)),
122 aPrefixFT (this, SW_RES( FT_PREFIX
)),
123 aPrefixED (this, SW_RES( ED_PREFIX
)),
124 aSuffixFT (this, SW_RES( FT_SUFFIX
)),
125 aSuffixED (this, SW_RES( ED_SUFFIX
)),
126 aPosFT (this, SW_RES( FT_POS
)),
127 aPosPageBox (this, SW_RES( RB_POS_PAGE
)),
128 aPosChapterBox (this, SW_RES( RB_POS_CHAPTER
)),
129 aNumFL (this, SW_RES( FL_NUM
)),
131 aParaTemplLbl (this, SW_RES( FT_PARA_TEMPL
)),
132 aParaTemplBox (this, SW_RES( LB_PARA_TEMPL
)),
133 aPageTemplLbl (this, SW_RES( FT_PAGE_TEMPL
)),
134 aPageTemplBox (this, SW_RES( LB_PAGE_TEMPL
)),
135 aTemplFL (this, SW_RES( FL_TEMPL
)),
137 aFtnCharAnchorTemplLbl( this, SW_RES( FT_ANCHR_CHARFMT
)),
138 aFtnCharAnchorTemplBox( this, SW_RES( LB_ANCHR_CHARFMT
)),
139 aFtnCharTextTemplLbl( this, SW_RES( FT_TEXT_CHARFMT
)),
140 aFtnCharTextTemplBox( this, SW_RES( LB_TEXT_CHARFMT
)),
141 aCharTemplFL( this, SW_RES(FL_CHAR_TEMPL
)),
143 aContLbl (this, SW_RES( FT_CONT
)),
144 aContEdit (this, SW_RES( ED_CONT
)),
145 aContFromLbl (this, SW_RES( FT_CONT_FROM
)),
146 aContFromEdit (this, SW_RES( ED_CONT_FROM
)),
147 aContFL (this, SW_RES( FL_CONT
)),
149 aNumDoc(aNumCountBox
.GetEntry(FTNNUM_DOC
)),
150 aNumPage(aNumCountBox
.GetEntry(FTNNUM_PAGE
)),
151 aNumChapter(aNumCountBox
.GetEntry(FTNNUM_CHAPTER
)),
158 aPosPageBox
.SetClickHdl(LINK(this, SwEndNoteOptionPage
, PosPageHdl
));
159 aPosChapterBox
.SetClickHdl(LINK(this, SwEndNoteOptionPage
, PosChapterHdl
));
160 aNumCountBox
.SetSelectHdl(LINK(this, SwEndNoteOptionPage
, NumCountHdl
));
164 void SwEndNoteOptionPage::Reset( const SfxItemSet
& )
166 SwEndNoteInfo
*pInf
= bEndNote
? new SwEndNoteInfo( pSh
->GetEndNoteInfo() )
167 : new SwFtnInfo( pSh
->GetFtnInfo() );
168 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
171 if(PTR_CAST(SwWebDocShell
, pDocSh
))
173 aParaTemplLbl
.Hide();
174 aParaTemplBox
.Hide();
175 aPageTemplLbl
.Hide();
176 aPageTemplBox
.Hide();
177 aFtnCharTextTemplLbl
.Hide();
178 aFtnCharTextTemplBox
.Hide();
179 aFtnCharAnchorTemplLbl
.Hide();
180 aFtnCharAnchorTemplBox
.Hide();
181 aCharTemplFL
.Hide();
187 aPosChapterBox
.Hide();
192 aContFromEdit
.Hide();
198 const SwFtnInfo
&rInf
= pSh
->GetFtnInfo();
199 // Position (Seite, Kapitel) setzen
200 if ( rInf
.ePos
== FTNPOS_PAGE
)
203 aPageTemplLbl
.Enable(FALSE
);
204 aPageTemplBox
.Enable(FALSE
);
206 else // if ( rInf.ePos == FTNPOS_CHAPTER )
208 aPosChapterBox
.Check();
209 aNumCountBox
.RemoveEntry(aNumPage
);
210 aNumCountBox
.RemoveEntry(aNumChapter
);
214 aContEdit
.SetText(rInf
.aQuoVadis
);
215 aContFromEdit
.SetText(rInf
.aErgoSum
);
218 SelectNumbering(rInf
.eNum
);
223 aNumViewBox
.SelectNumberingType( pInf
->aFmt
.GetNumberingType());
224 aOffsetFld
.SetValue(pInf
->nFtnOffset
+ 1);
225 aPrefixED
.SetText(pInf
->GetPrefix());
226 aSuffixED
.SetText(pInf
->GetSuffix());
228 const SwCharFmt
* pCharFmt
= pInf
->GetCharFmt(
229 *pSh
->GetView().GetDocShell()->GetDoc());
230 aFtnCharTextTemplBox
.SelectEntry(pCharFmt
->GetName());
231 aFtnCharTextTemplBox
.SaveValue();
233 pCharFmt
= pInf
->GetAnchorCharFmt( *pSh
->GetDoc() );
234 aFtnCharAnchorTemplBox
.SelectEntry( pCharFmt
->GetName() );
235 aFtnCharAnchorTemplBox
.SaveValue();
237 // Vorlagen - Sonderbereiche
239 SfxStyleSheetBasePool
* pStyleSheetPool
= pSh
->GetView().GetDocShell()->GetStyleSheetPool();
240 pStyleSheetPool
->SetSearchMask(SFX_STYLE_FAMILY_PARA
, SWSTYLEBIT_EXTRA
);
241 SfxStyleSheetBase
*pStyle
= pStyleSheetPool
->First();
244 aParaTemplBox
.InsertEntry(pStyle
->GetName());
245 pStyle
= pStyleSheetPool
->Next();
249 SwStyleNameMapper::FillUIName( static_cast< sal_uInt16
>(bEndNote
? RES_POOLCOLL_ENDNOTE
250 : RES_POOLCOLL_FOOTNOTE
), sStr
);
251 if(LISTBOX_ENTRY_NOTFOUND
== aParaTemplBox
.GetEntryPos( sStr
) )
252 aParaTemplBox
.InsertEntry( sStr
);
254 SwTxtFmtColl
* pColl
= pInf
->GetFtnTxtColl();
256 aParaTemplBox
.SelectEntry( sStr
); // Default
259 ASSERT(!pColl
->IsDefault(), "Defaultvorlage fuer Fussnoten ist falsch.");
260 const USHORT nPos
= aParaTemplBox
.GetEntryPos(pColl
->GetName());
261 if( LISTBOX_ENTRY_NOTFOUND
!= nPos
)
262 aParaTemplBox
.SelectEntryPos( nPos
);
265 aParaTemplBox
.InsertEntry(pColl
->GetName());
266 aParaTemplBox
.SelectEntry(pColl
->GetName());
271 for( i
= RES_POOLPAGE_BEGIN
; i
<= RES_POOLPAGE_LANDSCAPE
; ++i
)
272 aPageTemplBox
.InsertEntry(SwStyleNameMapper::GetUIName( i
, aEmptyStr
));
274 USHORT nCount
= pSh
->GetPageDescCnt();
275 for(i
= 0; i
< nCount
; ++i
)
277 const SwPageDesc
&rPageDesc
= pSh
->GetPageDesc(i
);
278 if(LISTBOX_ENTRY_NOTFOUND
== aPageTemplBox
.GetEntryPos(rPageDesc
.GetName()))
279 aPageTemplBox
.InsertEntry(rPageDesc
.GetName());
282 aPageTemplBox
.SelectEntry( pInf
->GetPageDesc( *pSh
->GetDoc() )->GetName());
286 SwEndNoteOptionPage::~SwEndNoteOptionPage()
290 SfxTabPage
*SwEndNoteOptionPage::Create( Window
*pParent
, const SfxItemSet
&rSet
)
292 return new SwEndNoteOptionPage( pParent
, TRUE
, rSet
);
295 /*------------------------------------------------------------------------
296 Beschreibung: Unterschiedliche Arten der Numerierung; da die Listbox
297 unterschiedlich viele Eintraege hat, hier Funktionen
298 fuer das Setzen und Erfragen der gemeinten Art
300 ------------------------------------------------------------------------*/
301 void SwEndNoteOptionPage::SelectNumbering(int eNum
)
313 sSelect
= aNumChapter
;
317 DBG_ERROR("Which numbering type?");
320 aNumCountBox
.SelectEntry(sSelect
);
321 NumCountHdl( &aNumCountBox
);
326 int SwEndNoteOptionPage::GetNumbering() const
328 const USHORT nPos
= aNumCountBox
.GetSelectEntryPos();
329 return (int) bPosDoc
? nPos
+ 1: nPos
;
332 /*-----------------09.02.98 11:17-------------------
334 --------------------------------------------------*/
335 void SwEndNoteOptionPage::SetShell( SwWrtShell
&rShell
)
338 // Zeichenvorlagen sammeln
339 aFtnCharTextTemplBox
.Clear();
340 aFtnCharAnchorTemplBox
.Clear();
341 ::FillCharStyleListBox(aFtnCharTextTemplBox
,
342 pSh
->GetView().GetDocShell());
344 ::FillCharStyleListBox(aFtnCharAnchorTemplBox
,
345 pSh
->GetView().GetDocShell());
348 /*------------------------------------------------------------------------
349 Beschreibung: Handler hinter dem Button fuer Sammeln der Fussnote
351 In diesem Fall koennen alle Numerierungsarten verwendet
353 ------------------------------------------------------------------------*/
356 IMPL_LINK( SwEndNoteOptionPage
, PosPageHdl
, Button
*, EMPTYARG
)
358 const SwFtnNum eNum
= (const SwFtnNum
)GetNumbering();
360 if(LISTBOX_ENTRY_NOTFOUND
== aNumCountBox
.GetEntryPos(aNumPage
))
362 aNumCountBox
.InsertEntry(aNumPage
, FTNNUM_PAGE
);
363 aNumCountBox
.InsertEntry(aNumChapter
, FTNNUM_CHAPTER
);
364 SelectNumbering(eNum
);
366 aPageTemplLbl
.Enable(FALSE
);
367 aPageTemplBox
.Enable(FALSE
);
372 /*------------------------------------------------------------------------
374 ------------------------------------------------------------------------*/
377 IMPL_LINK( SwEndNoteOptionPage
, NumCountHdl
, ListBox
*, EMPTYARG
)
380 if( aNumCountBox
.GetEntryCount() - 1 != aNumCountBox
.GetSelectEntryPos() )
383 aOffsetFld
.SetValue(1);
385 aOffsetLbl
.Enable(bEnable
);
386 aOffsetFld
.Enable(bEnable
);
390 /*------------------------------------------------------------------------
391 Beschreibung: Handler hinter dem Button fuer Sammeln der Fussnote
392 am Kapitel oder Dokumentende.
393 In diesem Fall kann keine seitenweise Numerierung verwendet
395 ------------------------------------------------------------------------*/
398 IMPL_LINK_INLINE_START( SwEndNoteOptionPage
, PosChapterHdl
, Button
*, EMPTYARG
)
401 SelectNumbering(FTNNUM_DOC
);
404 aNumCountBox
.RemoveEntry(aNumPage
);
405 aNumCountBox
.RemoveEntry(aNumChapter
);
406 aPageTemplLbl
.Enable();
407 aPageTemplBox
.Enable();
410 IMPL_LINK_INLINE_END( SwEndNoteOptionPage
, PosChapterHdl
, Button
*, EMPTYARG
)
412 SwCharFmt
* lcl_GetCharFormat( SwWrtShell
* pSh
, const String
& rCharFmtName
)
415 USHORT nChCount
= pSh
->GetCharFmtCount();
416 for(USHORT i
= 0; i
< nChCount
; i
++)
418 SwCharFmt
& rChFmt
= pSh
->GetCharFmt(i
);
419 if(rChFmt
.GetName() == rCharFmtName
)
427 SfxStyleSheetBasePool
* pPool
= pSh
->GetView().GetDocShell()->GetStyleSheetPool();
428 SfxStyleSheetBase
* pBase
;
429 pBase
= pPool
->Find(rCharFmtName
, SFX_STYLE_FAMILY_CHAR
);
431 pBase
= &pPool
->Make(rCharFmtName
, SFX_STYLE_FAMILY_CHAR
);
432 pFmt
= ((SwDocStyleSheet
*)pBase
)->GetCharFmt();
437 BOOL
SwEndNoteOptionPage::FillItemSet( SfxItemSet
& )
439 SwEndNoteInfo
*pInf
= bEndNote
? new SwEndNoteInfo() : new SwFtnInfo();
441 pInf
->nFtnOffset
= static_cast< USHORT
>(aOffsetFld
.GetValue() -1);
442 pInf
->aFmt
.SetNumberingType(aNumViewBox
.GetSelectedNumberingType() );
443 pInf
->SetPrefix(aPrefixED
.GetText());
444 pInf
->SetSuffix(aSuffixED
.GetText());
446 pInf
->SetCharFmt( lcl_GetCharFormat( pSh
,
447 aFtnCharTextTemplBox
.GetSelectEntry() ) );
448 pInf
->SetAnchorCharFmt( lcl_GetCharFormat( pSh
,
449 aFtnCharAnchorTemplBox
.GetSelectEntry() ) );
452 USHORT nPos
= aParaTemplBox
.GetSelectEntryPos();
453 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
455 const String
aFmtName( aParaTemplBox
.GetSelectEntry() );
456 SwTxtFmtColl
*pColl
= pSh
->GetParaStyle(aFmtName
, SwWrtShell::GETSTYLE_CREATEANY
);
457 ASSERT(pColl
, "Absatzvorlage nicht gefunden.");
458 pInf
->SetFtnTxtColl(*pColl
);
462 pInf
->ChgPageDesc( pSh
->FindPageDescByName(
463 aPageTemplBox
.GetSelectEntry(), TRUE
) );
467 if ( !(*pInf
== pSh
->GetEndNoteInfo()) )
468 pSh
->SetEndNoteInfo( *pInf
);
472 SwFtnInfo
*pI
= (SwFtnInfo
*)pInf
;
473 pI
->ePos
= aPosPageBox
.IsChecked() ? FTNPOS_PAGE
: FTNPOS_CHAPTER
;
474 pI
->eNum
= (SwFtnNum
)GetNumbering();
475 pI
->aQuoVadis
= aContEdit
.GetText();
476 pI
->aErgoSum
= aContFromEdit
.GetText();
477 if ( !(*pI
== pSh
->GetFtnInfo()) )
478 pSh
->SetFtnInfo( *pI
);
484 SwFootNoteOptionPage::SwFootNoteOptionPage( Window
*pParent
, const SfxItemSet
&rSet
) :
485 SwEndNoteOptionPage( pParent
, FALSE
, rSet
)
489 SwFootNoteOptionPage::~SwFootNoteOptionPage()
493 SfxTabPage
*SwFootNoteOptionPage::Create(Window
*pParent
, const SfxItemSet
&rSet
)
495 return new SwFootNoteOptionPage( pParent
, rSet
);