LCOV - code coverage report
Current view: top level - sw/source/ui/misc - insfnote.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 141 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <hintids.hxx>
      30                 :            : #include <svl/eitem.hxx>
      31                 :            : #include <svl/stritem.hxx>
      32                 :            : #include <sfx2/request.hxx>
      33                 :            : #include <editeng/fontitem.hxx>
      34                 :            : #include <vcl/msgbox.hxx>
      35                 :            : #include <fmtftn.hxx>
      36                 :            : #include <swundo.hxx>
      37                 :            : #include <cmdid.h>
      38                 :            : #include <wrtsh.hxx>
      39                 :            : #include <view.hxx>
      40                 :            : #include <basesh.hxx>
      41                 :            : #include <insfnote.hxx>
      42                 :            : #include <crsskip.hxx>
      43                 :            : #include <misc.hrc>
      44                 :            : #include <insfnote.hrc>
      45                 :            : #include <svx/svxdlg.hxx>
      46                 :            : #include <svx/dialogs.hrc>
      47                 :            : #include <sfx2/viewfrm.hxx>
      48                 :            : 
      49                 :            : static sal_Bool bFootnote = sal_True;
      50                 :            : 
      51                 :            : /*------------------------------------------------------------------------
      52                 :            :  Description:   inserting a footnote with OK
      53                 :            : ------------------------------------------------------------------------*/
      54                 :            : 
      55                 :          0 : void SwInsFootNoteDlg::Apply()
      56                 :            : {
      57                 :          0 :     String aStr;
      58                 :            : 
      59                 :          0 :     if ( aNumberCharBtn.IsChecked() )
      60                 :          0 :         aStr = aNumberCharEdit.GetText();
      61                 :            : 
      62                 :          0 :     if ( bEdit )
      63                 :            :     {
      64                 :          0 :         rSh.StartAction();
      65                 :          0 :         rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
      66                 :          0 :         rSh.StartUndo( UNDO_START );
      67                 :          0 :         SwFmtFtn aNote( aEndNoteBtn.IsChecked() );
      68                 :          0 :         aNote.SetNumStr( aStr );
      69                 :            : 
      70                 :          0 :         if( rSh.SetCurFtn( aNote ) && bExtCharAvailable )
      71                 :            :         {
      72                 :          0 :             rSh.Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False );
      73                 :          0 :             SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT );
      74                 :          0 :             rSh.GetCurAttr( aSet );
      75                 :          0 :             SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT );
      76                 :            :             SvxFontItem aFont( rFont.GetFamily(), aFontName,
      77                 :          0 :                                rFont.GetStyleName(), rFont.GetPitch(),
      78                 :          0 :                                eCharSet, RES_CHRATR_FONT );
      79                 :          0 :             aSet.Put( aFont );
      80                 :          0 :             rSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND );
      81                 :          0 :             rSh.ResetSelect(0, sal_False);
      82                 :          0 :             rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
      83                 :            :         }
      84                 :          0 :         rSh.EndUndo( UNDO_END );
      85                 :          0 :         rSh.EndAction();
      86                 :            :     }
      87                 :            :     else
      88                 :            :     {
      89                 :            : 
      90                 :            :     }
      91                 :            : 
      92                 :          0 :     bFootnote = aFtnBtn.IsChecked();
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : IMPL_LINK_NOARG_INLINE_START(SwInsFootNoteDlg, NumberCharHdl)
      96                 :            : {
      97                 :          0 :     aNumberCharEdit.GrabFocus();
      98                 :          0 :     aOkBtn.Enable( aNumberCharEdit.GetText().Len() || bExtCharAvailable );
      99                 :          0 :     return 0;
     100                 :            : }
     101                 :          0 : IMPL_LINK_NOARG_INLINE_END(SwInsFootNoteDlg, NumberCharHdl)
     102                 :            : 
     103                 :          0 : IMPL_LINK_NOARG_INLINE_START(SwInsFootNoteDlg, NumberEditHdl)
     104                 :            : {
     105                 :          0 :     aNumberCharBtn.Check( sal_True );
     106                 :          0 :     aOkBtn.Enable( 0 != aNumberCharEdit.GetText().Len() );
     107                 :            : 
     108                 :          0 :     return 0;
     109                 :            : }
     110                 :          0 : IMPL_LINK_NOARG_INLINE_END(SwInsFootNoteDlg, NumberEditHdl)
     111                 :            : 
     112                 :          0 : IMPL_LINK_NOARG_INLINE_START(SwInsFootNoteDlg, NumberAutoBtnHdl)
     113                 :            : {
     114                 :          0 :     aOkBtn.Enable( sal_True );
     115                 :          0 :     return 0;
     116                 :            : }
     117                 :          0 : IMPL_LINK_NOARG_INLINE_END(SwInsFootNoteDlg, NumberAutoBtnHdl)
     118                 :            : 
     119                 :          0 : IMPL_LINK_NOARG(SwInsFootNoteDlg, NumberExtCharHdl)
     120                 :            : {
     121                 :          0 :     aNumberCharBtn.Check( sal_True );
     122                 :            : 
     123                 :          0 :     SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT );
     124                 :          0 :     rSh.GetCurAttr( aSet );
     125                 :          0 :     const SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT );
     126                 :            : 
     127                 :          0 :     SfxAllItemSet aAllSet( rSh.GetAttrPool() );
     128                 :          0 :     aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
     129                 :          0 :     aAllSet.Put( rFont );
     130                 :            : 
     131                 :          0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     132                 :            :     SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aAllSet,
     133                 :          0 :         rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
     134                 :          0 :     if (RET_OK == pDlg->Execute())
     135                 :            :     {
     136                 :          0 :         SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False );
     137                 :          0 :         SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
     138                 :          0 :         if ( pItem )
     139                 :            :         {
     140                 :          0 :             String sExtChars(pItem->GetValue());
     141                 :          0 :             aNumberCharEdit.SetText( sExtChars );
     142                 :            : 
     143                 :          0 :             if ( pFontItem )
     144                 :            :             {
     145                 :          0 :                 aFontName = pFontItem->GetFamilyName();
     146                 :          0 :                 eCharSet  = pFontItem->GetCharSet();
     147                 :          0 :                 Font aFont( aFontName, pFontItem->GetStyleName(), aNumberCharEdit.GetFont().GetSize() );
     148                 :          0 :                 aFont.SetCharSet( pFontItem->GetCharSet() );
     149                 :          0 :                 aFont.SetPitch( pFontItem->GetPitch() );
     150                 :          0 :                 aNumberCharEdit.SetFont( aFont  );
     151                 :            :             }
     152                 :            : 
     153                 :          0 :             bExtCharAvailable = sal_True;
     154                 :          0 :             aOkBtn.Enable(0 != aNumberCharEdit.GetText().Len());
     155                 :            :         }
     156                 :            :     }
     157                 :          0 :     delete pDlg;
     158                 :            : 
     159                 :          0 :     return 0;
     160                 :            : }
     161                 :            : 
     162                 :          0 : IMPL_LINK( SwInsFootNoteDlg, NextPrevHdl, Button *, pBtn )
     163                 :            : {
     164                 :          0 :     Apply();
     165                 :            : 
     166                 :            :     // go to the next foot/endnote here
     167                 :          0 :     rSh.ResetSelect(0, sal_False);
     168                 :          0 :     if (pBtn == &aNextBT)
     169                 :          0 :         rSh.GotoNextFtnAnchor();
     170                 :            :     else
     171                 :          0 :         rSh.GotoPrevFtnAnchor();
     172                 :            : 
     173                 :          0 :     Init();
     174                 :            : 
     175                 :          0 :     return 0;
     176                 :            : }
     177                 :            : 
     178                 :          0 : SwInsFootNoteDlg::SwInsFootNoteDlg(Window *pParent, SwWrtShell &rShell, sal_Bool bEd) :
     179                 :            : 
     180                 :            :     SvxStandardDialog(pParent,SW_RES(DLG_INS_FOOTNOTE)),
     181                 :            : 
     182                 :            :     rSh(rShell),
     183                 :            :     bExtCharAvailable(sal_False),
     184                 :            :     bEdit(bEd),
     185                 :            :     aNumberFL      (this,SW_RES(FL_NUMBER)),
     186                 :            :     aNumberAutoBtn  (this,SW_RES(RB_NUMBER_AUTO)),
     187                 :            :     aNumberCharBtn  (this,SW_RES(RB_NUMBER_CHAR)),
     188                 :            :     aNumberCharEdit (this,SW_RES(ED_NUMBER_CHAR)),
     189                 :            :     aNumberExtChar  (this,SW_RES(BT_NUMBER_CHAR)),
     190                 :            : 
     191                 :            :     aTypeFL        (this,SW_RES(FL_TYPE)),
     192                 :            :     aFtnBtn         (this,SW_RES(RB_TYPE_FTN)),
     193                 :            :     aEndNoteBtn     (this,SW_RES(RB_TYPE_ENDNOTE)),
     194                 :            : 
     195                 :            :     aOkBtn          (this,SW_RES(BT_OK)),
     196                 :            :     aCancelBtn      (this,SW_RES(BT_CANCEL)),
     197                 :            :     aHelpBtn        (this,SW_RES(BT_HELP)),
     198                 :            :     aPrevBT         (this,SW_RES(BT_PREV)),
     199                 :          0 :     aNextBT         (this,SW_RES(BT_NEXT))
     200                 :            : {
     201                 :          0 :     aNumberCharEdit.SetAccessibleName(String(SW_RES(STR_CHAR)));
     202                 :          0 :     aNumberExtChar.SetAccessibleRelationMemberOf(&aNumberFL);
     203                 :          0 :     aNumberCharEdit.SetAccessibleRelationLabeledBy(&aNumberCharBtn);
     204                 :            : 
     205                 :          0 :     aNumberAutoBtn.SetClickHdl(LINK(this,SwInsFootNoteDlg,NumberAutoBtnHdl));
     206                 :          0 :     aNumberExtChar.SetClickHdl(LINK(this,SwInsFootNoteDlg,NumberExtCharHdl));
     207                 :          0 :     aNumberCharBtn.SetClickHdl(LINK(this,SwInsFootNoteDlg,NumberCharHdl));
     208                 :          0 :     aNumberCharEdit.SetModifyHdl(LINK(this,SwInsFootNoteDlg,NumberEditHdl));
     209                 :          0 :     aNumberCharEdit.SetMaxTextLen(10);
     210                 :          0 :     aNumberCharEdit.Enable();
     211                 :            : 
     212                 :          0 :     aPrevBT.SetClickHdl(LINK(this, SwInsFootNoteDlg, NextPrevHdl));
     213                 :          0 :     aNextBT.SetClickHdl(LINK(this, SwInsFootNoteDlg, NextPrevHdl));
     214                 :            : 
     215                 :          0 :     FreeResource();
     216                 :          0 :     rSh.SetCareWin(this);
     217                 :            : 
     218                 :          0 :     if (bEdit)
     219                 :            :     {
     220                 :          0 :         Init();
     221                 :            : 
     222                 :          0 :         aPrevBT.Show();
     223                 :          0 :         aNextBT.Show();
     224                 :            :     }
     225                 :          0 : }
     226                 :            : 
     227                 :          0 : SwInsFootNoteDlg::~SwInsFootNoteDlg()
     228                 :            : {
     229                 :          0 :     rSh.SetCareWin(0);
     230                 :            : 
     231                 :          0 :     if (bEdit)
     232                 :          0 :         rSh.ResetSelect(0, sal_False);
     233                 :          0 : }
     234                 :            : 
     235                 :          0 : void SwInsFootNoteDlg::Init()
     236                 :            : {
     237                 :          0 :     SwFmtFtn aFtnNote;
     238                 :          0 :     String sNumStr;
     239                 :          0 :     Font aFont;
     240                 :          0 :     bExtCharAvailable = sal_False;
     241                 :            : 
     242                 :          0 :     rSh.StartAction();
     243                 :            : 
     244                 :          0 :     if( rSh.GetCurFtn( &aFtnNote ))
     245                 :            :     {
     246                 :          0 :         if(aFtnNote.GetNumStr().Len())
     247                 :            :         {
     248                 :          0 :             sNumStr = aFtnNote.GetNumStr();
     249                 :            : 
     250                 :          0 :             rSh.Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False );
     251                 :          0 :             SfxItemSet aSet( rSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT );
     252                 :          0 :             rSh.GetCurAttr( aSet );
     253                 :          0 :             const SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT );
     254                 :            : 
     255                 :          0 :             aFont = aNumberCharEdit.GetFont();
     256                 :          0 :             aFontName = rFont.GetFamilyName();
     257                 :          0 :             eCharSet = rFont.GetCharSet();
     258                 :          0 :             aFont.SetName(aFontName);
     259                 :          0 :             aFont.SetCharSet(eCharSet);
     260                 :          0 :             bExtCharAvailable = sal_True;
     261                 :          0 :             rSh.Left( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
     262                 :            :         }
     263                 :          0 :         bFootnote = !aFtnNote.IsEndNote();
     264                 :            :     }
     265                 :          0 :     aNumberCharEdit.SetFont(aFont);
     266                 :            : 
     267                 :          0 :     sal_Bool bNumChar = sNumStr.Len() != 0;
     268                 :            : 
     269                 :          0 :     aNumberCharEdit.SetText(sNumStr);
     270                 :          0 :     aNumberCharBtn.Check(bNumChar);
     271                 :          0 :     aNumberAutoBtn.Check(!bNumChar);
     272                 :          0 :     if (bNumChar)
     273                 :          0 :         aNumberCharEdit.GrabFocus();
     274                 :            : 
     275                 :          0 :     if (bFootnote)
     276                 :          0 :         aFtnBtn.Check();
     277                 :            :     else
     278                 :          0 :         aEndNoteBtn.Check();
     279                 :            : 
     280                 :          0 :     sal_Bool bNext = rSh.GotoNextFtnAnchor();
     281                 :            : 
     282                 :          0 :     if (bNext)
     283                 :          0 :         rSh.GotoPrevFtnAnchor();
     284                 :            : 
     285                 :          0 :     sal_Bool bPrev = rSh.GotoPrevFtnAnchor();
     286                 :            : 
     287                 :          0 :     if (bPrev)
     288                 :          0 :         rSh.GotoNextFtnAnchor();
     289                 :            : 
     290                 :          0 :     aPrevBT.Enable(bPrev);
     291                 :          0 :     aNextBT.Enable(bNext);
     292                 :            : 
     293                 :          0 :     rSh.Right(CRSR_SKIP_CHARS, sal_True, 1, sal_False );
     294                 :            : 
     295                 :          0 :     rSh.EndAction();
     296                 :          0 : }
     297                 :            : 
     298                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10