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 #include <hintids.hxx> 32cdf0e10cSrcweir #include <svl/eitem.hxx> 33cdf0e10cSrcweir #include <svl/stritem.hxx> 34cdf0e10cSrcweir #include <sfx2/request.hxx> 35cdf0e10cSrcweir #include <editeng/fontitem.hxx> 36cdf0e10cSrcweir #include <vcl/msgbox.hxx> 37cdf0e10cSrcweir #include <fmtftn.hxx> 38cdf0e10cSrcweir #include <swundo.hxx> 39cdf0e10cSrcweir #include <cmdid.h> 40cdf0e10cSrcweir #include <wrtsh.hxx> 41cdf0e10cSrcweir #include <view.hxx> 42cdf0e10cSrcweir #include <basesh.hxx> 43cdf0e10cSrcweir #include <insfnote.hxx> 44cdf0e10cSrcweir #include <crsskip.hxx> 45cdf0e10cSrcweir #include <misc.hrc> 46cdf0e10cSrcweir #include <insfnote.hrc> 47cdf0e10cSrcweir #include <svx/svxdlg.hxx> 48cdf0e10cSrcweir #include <svx/dialogs.hrc> 49cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir static sal_Bool bFootnote = sal_True; 52cdf0e10cSrcweir 53cdf0e10cSrcweir /*------------------------------------------------------------------------ 54cdf0e10cSrcweir Beschreibung: Einfuegen der Fussnote durch OK 55cdf0e10cSrcweir ------------------------------------------------------------------------*/ 56cdf0e10cSrcweir 57cdf0e10cSrcweir void __EXPORT SwInsFootNoteDlg::Apply() 58cdf0e10cSrcweir { 59cdf0e10cSrcweir String aStr; 60cdf0e10cSrcweir 61cdf0e10cSrcweir if ( aNumberCharBtn.IsChecked() ) 62cdf0e10cSrcweir aStr = aNumberCharEdit.GetText(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir if ( bEdit ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir rSh.StartAction(); 67cdf0e10cSrcweir rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 68cdf0e10cSrcweir rSh.StartUndo( UNDO_START ); 69cdf0e10cSrcweir SwFmtFtn aNote( aEndNoteBtn.IsChecked() ); 70cdf0e10cSrcweir aNote.SetNumStr( aStr ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir if( rSh.SetCurFtn( aNote ) && bExtCharAvailable ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir rSh.Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 75cdf0e10cSrcweir SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT ); 76cdf0e10cSrcweir rSh.GetCurAttr( aSet ); 77cdf0e10cSrcweir SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT ); 78cdf0e10cSrcweir SvxFontItem aFont( rFont.GetFamily(), aFontName, 79cdf0e10cSrcweir rFont.GetStyleName(), rFont.GetPitch(), 80cdf0e10cSrcweir eCharSet, RES_CHRATR_FONT ); 81cdf0e10cSrcweir aSet.Put( aFont ); 82cdf0e10cSrcweir rSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND ); 83cdf0e10cSrcweir rSh.ResetSelect(0, sal_False); 84cdf0e10cSrcweir rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir rSh.EndUndo( UNDO_END ); 87cdf0e10cSrcweir rSh.EndAction(); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir else 90cdf0e10cSrcweir { 91cdf0e10cSrcweir /* 92cdf0e10cSrcweir rSh.StartUndo( UNDO_UI_INSERT_FOOTNOTE ); 93cdf0e10cSrcweir rSh.InsertFootnote( aStr, aEndNoteBtn.IsChecked(), !bExtCharAvailable ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir if ( bExtCharAvailable ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir rSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 98cdf0e10cSrcweir SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT ); 99cdf0e10cSrcweir rSh.GetAttr( aSet ); 100cdf0e10cSrcweir SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT ); 101cdf0e10cSrcweir SvxFontItem aFont( rFont.GetFamily(), aFontName, 102cdf0e10cSrcweir rFont.GetStyleName(), rFont.GetPitch(), 103cdf0e10cSrcweir eCharSet ); 104cdf0e10cSrcweir aSet.Put( aFont ); 105cdf0e10cSrcweir rSh.SetAttr( aSet, SETATTR_DONTEXPAND ); 106cdf0e10cSrcweir // zur Bearbeitung des Fussnotentextes 107cdf0e10cSrcweir rSh.ResetSelect(0, sal_False); 108cdf0e10cSrcweir rSh.GotoFtnTxt(); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir rSh.EndUndo( UNDO_UI_INSERT_FOOTNOTE ); 111cdf0e10cSrcweir */ 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir bFootnote = aFtnBtn.IsChecked(); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir /*------------------------------------------------------------------------ 119cdf0e10cSrcweir Beschreibung: 120cdf0e10cSrcweir ------------------------------------------------------------------------*/ 121cdf0e10cSrcweir 122cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwInsFootNoteDlg, NumberCharHdl, Button *, EMPTYARG ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir aNumberCharEdit.GrabFocus(); 125cdf0e10cSrcweir aOkBtn.Enable( aNumberCharEdit.GetText().Len() || bExtCharAvailable ); 126cdf0e10cSrcweir return 0; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwInsFootNoteDlg, NumberCharHdl, Button *, EMPTYARG ) 129cdf0e10cSrcweir 130cdf0e10cSrcweir /*------------------------------------------------------------------------ 131cdf0e10cSrcweir Beschreibung: 132cdf0e10cSrcweir ------------------------------------------------------------------------*/ 133cdf0e10cSrcweir 134cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwInsFootNoteDlg, NumberEditHdl, void *, EMPTYARG ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir aNumberCharBtn.Check( sal_True ); 137cdf0e10cSrcweir aOkBtn.Enable( 0 != aNumberCharEdit.GetText().Len() ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir return 0; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwInsFootNoteDlg, NumberEditHdl, void *, EMPTYARG ) 142cdf0e10cSrcweir 143cdf0e10cSrcweir /*------------------------------------------------------------------------ 144cdf0e10cSrcweir Beschreibung: 145cdf0e10cSrcweir ------------------------------------------------------------------------*/ 146cdf0e10cSrcweir 147cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwInsFootNoteDlg, NumberAutoBtnHdl, Button *, EMPTYARG ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir aOkBtn.Enable( sal_True ); 150cdf0e10cSrcweir return 0; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwInsFootNoteDlg, NumberAutoBtnHdl, Button *, EMPTYARG ) 153cdf0e10cSrcweir 154cdf0e10cSrcweir /*------------------------------------------------------------------------ 155cdf0e10cSrcweir Beschreibung: 156cdf0e10cSrcweir ------------------------------------------------------------------------*/ 157cdf0e10cSrcweir 158cdf0e10cSrcweir IMPL_LINK( SwInsFootNoteDlg, NumberExtCharHdl, Button *, EMPTYARG ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir aNumberCharBtn.Check( sal_True ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT ); 163cdf0e10cSrcweir rSh.GetCurAttr( aSet ); 164cdf0e10cSrcweir const SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir SfxAllItemSet aAllSet( rSh.GetAttrPool() ); 167cdf0e10cSrcweir aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) ); 168cdf0e10cSrcweir aAllSet.Put( rFont ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 171cdf0e10cSrcweir SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aAllSet, 172cdf0e10cSrcweir rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); 173cdf0e10cSrcweir if (RET_OK == pDlg->Execute()) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False ); 176cdf0e10cSrcweir SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False ); 177cdf0e10cSrcweir if ( pItem ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir String sExtChars(pItem->GetValue()); 180cdf0e10cSrcweir aNumberCharEdit.SetText( sExtChars ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir if ( pFontItem ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir aFontName = pFontItem->GetFamilyName(); 185cdf0e10cSrcweir eCharSet = pFontItem->GetCharSet(); 186cdf0e10cSrcweir Font aFont( aFontName, pFontItem->GetStyleName(), aNumberCharEdit.GetFont().GetSize() ); 187cdf0e10cSrcweir aFont.SetCharSet( pFontItem->GetCharSet() ); 188cdf0e10cSrcweir aFont.SetPitch( pFontItem->GetPitch() ); 189cdf0e10cSrcweir aNumberCharEdit.SetFont( aFont ); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir bExtCharAvailable = sal_True; 193cdf0e10cSrcweir aOkBtn.Enable(0 != aNumberCharEdit.GetText().Len()); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir } 196cdf0e10cSrcweir delete pDlg; 197cdf0e10cSrcweir 198cdf0e10cSrcweir return 0; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir /*------------------------------------------------------------------------ 202cdf0e10cSrcweir Beschreibung: 203cdf0e10cSrcweir ------------------------------------------------------------------------*/ 204cdf0e10cSrcweir 205cdf0e10cSrcweir IMPL_LINK( SwInsFootNoteDlg, NextPrevHdl, Button *, pBtn ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir Apply(); 208cdf0e10cSrcweir 209cdf0e10cSrcweir // Hier zur naechsten Fuss/Endnote wandern 210cdf0e10cSrcweir rSh.ResetSelect(0, sal_False); 211cdf0e10cSrcweir if (pBtn == &aNextBT) 212cdf0e10cSrcweir rSh.GotoNextFtnAnchor(); 213cdf0e10cSrcweir else 214cdf0e10cSrcweir rSh.GotoPrevFtnAnchor(); 215cdf0e10cSrcweir 216cdf0e10cSrcweir Init(); 217cdf0e10cSrcweir 218cdf0e10cSrcweir return 0; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir /*------------------------------------------------------------------------ 222cdf0e10cSrcweir Beschreibung: 223cdf0e10cSrcweir ------------------------------------------------------------------------*/ 224cdf0e10cSrcweir 225cdf0e10cSrcweir SwInsFootNoteDlg::SwInsFootNoteDlg(Window *pParent, SwWrtShell &rShell, sal_Bool bEd) : 226cdf0e10cSrcweir 227cdf0e10cSrcweir SvxStandardDialog(pParent,SW_RES(DLG_INS_FOOTNOTE)), 228cdf0e10cSrcweir 229cdf0e10cSrcweir rSh(rShell), 230cdf0e10cSrcweir bExtCharAvailable(sal_False), 231cdf0e10cSrcweir bEdit(bEd), 232cdf0e10cSrcweir aNumberFL (this,SW_RES(FL_NUMBER)), 233cdf0e10cSrcweir aNumberAutoBtn (this,SW_RES(RB_NUMBER_AUTO)), 234cdf0e10cSrcweir aNumberCharBtn (this,SW_RES(RB_NUMBER_CHAR)), 235cdf0e10cSrcweir aNumberCharEdit (this,SW_RES(ED_NUMBER_CHAR)), 236cdf0e10cSrcweir aNumberExtChar (this,SW_RES(BT_NUMBER_CHAR)), 237cdf0e10cSrcweir 238cdf0e10cSrcweir aTypeFL (this,SW_RES(FL_TYPE)), 239cdf0e10cSrcweir aFtnBtn (this,SW_RES(RB_TYPE_FTN)), 240cdf0e10cSrcweir aEndNoteBtn (this,SW_RES(RB_TYPE_ENDNOTE)), 241cdf0e10cSrcweir 242cdf0e10cSrcweir aOkBtn (this,SW_RES(BT_OK)), 243cdf0e10cSrcweir aCancelBtn (this,SW_RES(BT_CANCEL)), 244cdf0e10cSrcweir aHelpBtn (this,SW_RES(BT_HELP)), 245cdf0e10cSrcweir aPrevBT (this,SW_RES(BT_PREV)), 246cdf0e10cSrcweir aNextBT (this,SW_RES(BT_NEXT)) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir aNumberCharEdit.SetAccessibleName(String(SW_RES(STR_CHAR))); 249cdf0e10cSrcweir aNumberExtChar.SetAccessibleRelationMemberOf(&aNumberFL); 250cdf0e10cSrcweir aNumberCharEdit.SetAccessibleRelationLabeledBy(&aNumberCharBtn); 251cdf0e10cSrcweir 252cdf0e10cSrcweir aNumberAutoBtn.SetClickHdl(LINK(this,SwInsFootNoteDlg,NumberAutoBtnHdl)); 253cdf0e10cSrcweir aNumberExtChar.SetClickHdl(LINK(this,SwInsFootNoteDlg,NumberExtCharHdl)); 254cdf0e10cSrcweir aNumberCharBtn.SetClickHdl(LINK(this,SwInsFootNoteDlg,NumberCharHdl)); 255cdf0e10cSrcweir aNumberCharEdit.SetModifyHdl(LINK(this,SwInsFootNoteDlg,NumberEditHdl)); 256cdf0e10cSrcweir aNumberCharEdit.SetMaxTextLen(10); 257cdf0e10cSrcweir aNumberCharEdit.Enable(); 258cdf0e10cSrcweir 259cdf0e10cSrcweir aPrevBT.SetClickHdl(LINK(this, SwInsFootNoteDlg, NextPrevHdl)); 260cdf0e10cSrcweir aNextBT.SetClickHdl(LINK(this, SwInsFootNoteDlg, NextPrevHdl)); 261cdf0e10cSrcweir 262cdf0e10cSrcweir FreeResource(); 263cdf0e10cSrcweir rSh.SetCareWin(this); 264cdf0e10cSrcweir 265cdf0e10cSrcweir if (bEdit) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir Init(); 268cdf0e10cSrcweir 269cdf0e10cSrcweir aPrevBT.Show(); 270cdf0e10cSrcweir aNextBT.Show(); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir 275cdf0e10cSrcweir /*------------------------------------------------------------------------ 276cdf0e10cSrcweir Beschreibung: 277cdf0e10cSrcweir ------------------------------------------------------------------------*/ 278cdf0e10cSrcweir 279cdf0e10cSrcweir SwInsFootNoteDlg::~SwInsFootNoteDlg() 280cdf0e10cSrcweir { 281cdf0e10cSrcweir rSh.SetCareWin(0); 282cdf0e10cSrcweir 283cdf0e10cSrcweir if (bEdit) 284cdf0e10cSrcweir rSh.ResetSelect(0, sal_False); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir /*------------------------------------------------------------------------ 288cdf0e10cSrcweir Beschreibung: 289cdf0e10cSrcweir ------------------------------------------------------------------------*/ 290cdf0e10cSrcweir 291cdf0e10cSrcweir void SwInsFootNoteDlg::Init() 292cdf0e10cSrcweir { 293cdf0e10cSrcweir SwFmtFtn aFtnNote; 294cdf0e10cSrcweir String sNumStr; 295cdf0e10cSrcweir Font aFont; 296cdf0e10cSrcweir bExtCharAvailable = sal_False; 297cdf0e10cSrcweir 298cdf0e10cSrcweir rSh.StartAction(); 299cdf0e10cSrcweir 300cdf0e10cSrcweir if( rSh.GetCurFtn( &aFtnNote )) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir if(aFtnNote.GetNumStr().Len()) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir sNumStr = aFtnNote.GetNumStr(); 305cdf0e10cSrcweir 306cdf0e10cSrcweir rSh.Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 307cdf0e10cSrcweir SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT ); 308cdf0e10cSrcweir rSh.GetCurAttr( aSet ); 309cdf0e10cSrcweir const SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT ); 310cdf0e10cSrcweir 311cdf0e10cSrcweir aFont = aNumberCharEdit.GetFont(); 312cdf0e10cSrcweir aFontName = rFont.GetFamilyName(); 313cdf0e10cSrcweir eCharSet = rFont.GetCharSet(); 314cdf0e10cSrcweir aFont.SetName(aFontName); 315cdf0e10cSrcweir aFont.SetCharSet(eCharSet); 316cdf0e10cSrcweir bExtCharAvailable = sal_True; 317cdf0e10cSrcweir rSh.Left( CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir bFootnote = !aFtnNote.IsEndNote(); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir aNumberCharEdit.SetFont(aFont); 322cdf0e10cSrcweir 323cdf0e10cSrcweir sal_Bool bNumChar = sNumStr.Len() != 0; 324cdf0e10cSrcweir 325cdf0e10cSrcweir aNumberCharEdit.SetText(sNumStr); 326cdf0e10cSrcweir aNumberCharBtn.Check(bNumChar); 327cdf0e10cSrcweir aNumberAutoBtn.Check(!bNumChar); 328cdf0e10cSrcweir if (bNumChar) 329cdf0e10cSrcweir aNumberCharEdit.GrabFocus(); 330cdf0e10cSrcweir 331cdf0e10cSrcweir if (bFootnote) 332cdf0e10cSrcweir aFtnBtn.Check(); 333cdf0e10cSrcweir else 334cdf0e10cSrcweir aEndNoteBtn.Check(); 335cdf0e10cSrcweir 336cdf0e10cSrcweir sal_Bool bNext = rSh.GotoNextFtnAnchor(); 337cdf0e10cSrcweir 338cdf0e10cSrcweir if (bNext) 339cdf0e10cSrcweir rSh.GotoPrevFtnAnchor(); 340cdf0e10cSrcweir 341cdf0e10cSrcweir sal_Bool bPrev = rSh.GotoPrevFtnAnchor(); 342cdf0e10cSrcweir 343cdf0e10cSrcweir if (bPrev) 344cdf0e10cSrcweir rSh.GotoNextFtnAnchor(); 345cdf0e10cSrcweir 346cdf0e10cSrcweir aPrevBT.Enable(bPrev); 347cdf0e10cSrcweir aNextBT.Enable(bNext); 348cdf0e10cSrcweir 349cdf0e10cSrcweir rSh.Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 350cdf0e10cSrcweir 351cdf0e10cSrcweir rSh.EndAction(); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354