LCOV - code coverage report
Current view: top level - sw/source/ui/misc - linenum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 122 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 <sfx2/viewfrm.hxx>
      30                 :            : #include <svl/style.hxx>
      31                 :            : #include <vcl/msgbox.hxx>
      32                 :            : #include <view.hxx>
      33                 :            : #include <wrtsh.hxx>
      34                 :            : #include <docsh.hxx>
      35                 :            : #include <charfmt.hxx>
      36                 :            : 
      37                 :            : #include <docstyle.hxx>
      38                 :            : 
      39                 :            : #include "fldbas.hxx"
      40                 :            : #include "lineinfo.hxx"
      41                 :            : #include "globals.hrc"
      42                 :            : #include "linenum.hrc"
      43                 :            : #include "linenum.hxx"
      44                 :            : #include "uitool.hxx"
      45                 :            : 
      46                 :            : #include <IDocumentStylePoolAccess.hxx>
      47                 :            : 
      48                 :          0 : SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw) :
      49                 :          0 :     SfxSingleTabDialog(&pVw->GetViewFrame()->GetWindow(), 0, 0),
      50                 :          0 :     pSh(pVw->GetWrtShellPtr())
      51                 :            : {
      52                 :            :     // create TabPage
      53                 :          0 :     SetTabPage(SwLineNumberingPage::Create(this, *(SfxItemSet*)0));
      54                 :            : 
      55                 :          0 :     GetOKButton()->SetClickHdl(LINK(this, SwLineNumberingDlg, OKHdl));
      56                 :          0 : }
      57                 :            : 
      58                 :          0 : SwLineNumberingDlg::~SwLineNumberingDlg()
      59                 :            : {
      60                 :          0 : }
      61                 :            : 
      62                 :          0 : IMPL_LINK_NOARG(SwLineNumberingDlg, OKHdl)
      63                 :            : {
      64                 :          0 :     if (GetOKButton()->IsEnabled())
      65                 :            :     {
      66                 :          0 :         SfxTabPage* pCurPage = GetTabPage();
      67                 :          0 :         if( pCurPage )
      68                 :          0 :             pCurPage->FillItemSet(*(SfxItemSet*)0);
      69                 :            : 
      70                 :          0 :         EndDialog( RET_OK );
      71                 :            :     }
      72                 :            : 
      73                 :          0 :     return 0;
      74                 :            : }
      75                 :            : 
      76                 :          0 : SwLineNumberingPage::SwLineNumberingPage( Window* pParent,
      77                 :            :                                                     const SfxItemSet& rSet )
      78                 :            :     : SfxTabPage(pParent, SW_RES(TP_LINENUMBERING), rSet),
      79                 :            :     aNumberingOnCB      ( this, SW_RES( CB_NUMBERING_ON )),
      80                 :            :     aDisplayFL          ( this, SW_RES( FL_DISPLAY )),
      81                 :            :     aCharStyleFT        ( this, SW_RES( FT_CHAR_STYLE )),
      82                 :            :     aCharStyleLB        ( this, SW_RES( LB_CHAR_STYLE )),
      83                 :            :     aFormatFT           ( this, SW_RES( FT_FORMAT )),
      84                 :            :     aFormatLB           ( this, SW_RES( LB_FORMAT ), INSERT_NUM_EXTENDED_TYPES),
      85                 :            :     aPosFT              ( this, SW_RES( FT_POS )),
      86                 :            :     aPosLB              ( this, SW_RES( LB_POS )),
      87                 :            :     aOffsetFT           ( this, SW_RES( FT_OFFSET )),
      88                 :            :     aOffsetMF           ( this, SW_RES( MF_OFFSET )),
      89                 :            :     aNumIntervalFT      ( this, SW_RES( FT_NUM_INVERVAL )),
      90                 :            :     aNumIntervalNF      ( this, SW_RES( NF_NUM_INVERVAL )),
      91                 :            :     aNumRowsFT          ( this, SW_RES( FT_NUM_ROWS )),
      92                 :            :     aDivisorFL          ( this, SW_RES( FL_DIVISOR )),
      93                 :            :     aDivisorFT          ( this, SW_RES( FT_DIVISOR )),
      94                 :            :     aDivisorED          ( this, SW_RES( ED_DIVISOR )),
      95                 :            :     aDivIntervalFT      ( this, SW_RES( FT_DIV_INTERVAL )),
      96                 :            :     aDivIntervalNF      ( this, SW_RES( NF_DIV_INTERVAL )),
      97                 :            :     aDivRowsFT          ( this, SW_RES( FT_DIV_ROWS )),
      98                 :            :     aCountFL            ( this, SW_RES( FL_COUNT )),
      99                 :            :     aCountEmptyLinesCB  ( this, SW_RES( CB_COUNT_EMPTYLINES )),
     100                 :            :     aCountFrameLinesCB  ( this, SW_RES( CB_COUNT_FRAMELINES )),
     101                 :          0 :     aRestartEachPageCB  ( this, SW_RES( CB_RESTART_PAGE ))
     102                 :            : 
     103                 :            : {
     104                 :          0 :     String sIntervalName = aDivIntervalFT.GetAccessibleName();
     105                 :          0 :     sIntervalName += rtl::OUString("(");
     106                 :          0 :     sIntervalName += aDivRowsFT.GetAccessibleName();
     107                 :          0 :     sIntervalName += rtl::OUString(")");
     108                 :          0 :     aDivIntervalNF.SetAccessibleName(sIntervalName);
     109                 :          0 :     sIntervalName = aNumIntervalFT.GetAccessibleName();
     110                 :          0 :     sIntervalName += rtl::OUString("(");
     111                 :          0 :     sIntervalName += aNumRowsFT.GetAccessibleName();
     112                 :          0 :     sIntervalName += rtl::OUString(")");
     113                 :          0 :     aNumIntervalNF.SetAccessibleName(sIntervalName);
     114                 :            : 
     115                 :          0 :     FreeResource();
     116                 :          0 :     SwLineNumberingDlg *pDlg = (SwLineNumberingDlg *)GetParent();
     117                 :          0 :     pSh = pDlg->GetWrtShell();
     118                 :            :     // char styles
     119                 :          0 :     ::FillCharStyleListBox(aCharStyleLB, pSh->GetView().GetDocShell());
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : SwLineNumberingPage::~SwLineNumberingPage()
     123                 :            : {
     124                 :          0 : }
     125                 :            : 
     126                 :          0 : SfxTabPage* SwLineNumberingPage::Create( Window* pParent, const SfxItemSet& rSet )
     127                 :            : {
     128                 :          0 :     return new SwLineNumberingPage( pParent, rSet );
     129                 :            : }
     130                 :            : 
     131                 :          0 : void SwLineNumberingPage::Reset( const SfxItemSet&  )
     132                 :            : {
     133                 :          0 :     const SwLineNumberInfo &rInf = pSh->GetLineNumberInfo();
     134                 :          0 :     IDocumentStylePoolAccess* pIDSPA = pSh->getIDocumentStylePoolAccess();
     135                 :            : 
     136                 :          0 :     String sStyleName(rInf.GetCharFmt( *pIDSPA )->GetName());
     137                 :          0 :     const sal_uInt16 nPos = aCharStyleLB.GetEntryPos(sStyleName);
     138                 :            : 
     139                 :          0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
     140                 :          0 :         aCharStyleLB.SelectEntryPos(nPos);
     141                 :            :     else
     142                 :            :     {
     143                 :          0 :         if (sStyleName.Len())
     144                 :            :         {
     145                 :          0 :             aCharStyleLB.InsertEntry(sStyleName);
     146                 :          0 :             aCharStyleLB.SelectEntry(sStyleName);
     147                 :            :         }
     148                 :            :     }
     149                 :            : 
     150                 :            :     // format
     151                 :          0 :     sal_uInt16 nSelFmt = rInf.GetNumType().GetNumberingType();
     152                 :            : 
     153                 :          0 :     aFormatLB.SelectNumberingType(nSelFmt);
     154                 :            : 
     155                 :            :     // position
     156                 :          0 :     aPosLB.SelectEntryPos((sal_uInt16)rInf.GetPos());
     157                 :            : 
     158                 :            :     // offset
     159                 :          0 :     sal_uInt16 nOffset = rInf.GetPosFromLeft();
     160                 :          0 :     if (nOffset == USHRT_MAX)
     161                 :          0 :         nOffset = 0;
     162                 :            : 
     163                 :          0 :     aOffsetMF.SetValue(aOffsetMF.Normalize(nOffset), FUNIT_TWIP);
     164                 :            : 
     165                 :            :     // numbering offset
     166                 :          0 :     aNumIntervalNF.SetValue(rInf.GetCountBy());
     167                 :            : 
     168                 :            :     // divider
     169                 :          0 :     aDivisorED.SetText(rInf.GetDivider());
     170                 :            : 
     171                 :            :     // divider offset
     172                 :          0 :     aDivIntervalNF.SetValue(rInf.GetDividerCountBy());
     173                 :            : 
     174                 :            :     // count
     175                 :          0 :     aCountEmptyLinesCB.Check(rInf.IsCountBlankLines());
     176                 :          0 :     aCountFrameLinesCB.Check(rInf.IsCountInFlys());
     177                 :          0 :     aRestartEachPageCB.Check(rInf.IsRestartEachPage());
     178                 :            : 
     179                 :          0 :     aNumberingOnCB.Check(rInf.IsPaintLineNumbers());
     180                 :            : 
     181                 :          0 :     aNumberingOnCB.SetClickHdl(LINK(this, SwLineNumberingPage, LineOnOffHdl));
     182                 :          0 :     aDivisorED.SetModifyHdl(LINK(this, SwLineNumberingPage, ModifyHdl));
     183                 :          0 :     ModifyHdl();
     184                 :          0 :     LineOnOffHdl();
     185                 :          0 : }
     186                 :            : 
     187                 :            : /*--------------------------------------------------------------------
     188                 :            :     Description: modify
     189                 :            :  --------------------------------------------------------------------*/
     190                 :          0 : IMPL_LINK_NOARG(SwLineNumberingPage, ModifyHdl)
     191                 :            : {
     192                 :          0 :     sal_Bool bHasValue = aDivisorED.GetText().Len() != 0;
     193                 :            : 
     194                 :          0 :     aDivIntervalFT.Enable(bHasValue);
     195                 :          0 :     aDivIntervalNF.Enable(bHasValue);
     196                 :          0 :     aDivRowsFT.Enable(bHasValue);
     197                 :            : 
     198                 :          0 :     return 0;
     199                 :            : }
     200                 :            : 
     201                 :            : /*--------------------------------------------------------------------
     202                 :            :     Description: On/Off
     203                 :            :  --------------------------------------------------------------------*/
     204                 :          0 : IMPL_LINK_NOARG(SwLineNumberingPage, LineOnOffHdl)
     205                 :            : {
     206                 :          0 :     sal_Bool bEnable = aNumberingOnCB.IsChecked();
     207                 :            : 
     208                 :          0 :     aCharStyleFT.Enable(bEnable);
     209                 :          0 :     aCharStyleLB.Enable(bEnable);
     210                 :          0 :     aFormatFT.Enable(bEnable);
     211                 :          0 :     aFormatLB.Enable(bEnable);
     212                 :          0 :     aPosFT.Enable(bEnable);
     213                 :          0 :     aPosLB.Enable(bEnable);
     214                 :          0 :     aOffsetFT.Enable(bEnable);
     215                 :          0 :     aOffsetMF.Enable(bEnable);
     216                 :          0 :     aNumIntervalFT.Enable(bEnable);
     217                 :          0 :     aNumIntervalNF.Enable(bEnable);
     218                 :          0 :     aNumRowsFT.Enable(bEnable);
     219                 :          0 :     aDisplayFL.Enable(bEnable);
     220                 :          0 :     aDivisorFT.Enable(bEnable);
     221                 :          0 :     aDivisorED.Enable(bEnable);
     222                 :          0 :     aDivIntervalFT.Enable(bEnable);
     223                 :          0 :     aDivIntervalNF.Enable(bEnable);
     224                 :          0 :     aDivRowsFT.Enable(bEnable);
     225                 :          0 :     aDivisorFL.Enable(bEnable);
     226                 :          0 :     aCountEmptyLinesCB.Enable(bEnable);
     227                 :          0 :     aCountFrameLinesCB.Enable(bEnable);
     228                 :          0 :     aRestartEachPageCB.Enable(bEnable);
     229                 :          0 :     aCountFL.Enable(bEnable);
     230                 :            : 
     231                 :          0 :     return 0;
     232                 :            : }
     233                 :            : 
     234                 :          0 : sal_Bool SwLineNumberingPage::FillItemSet( SfxItemSet& )
     235                 :            : {
     236                 :          0 :     SwLineNumberInfo aInf(pSh->GetLineNumberInfo());
     237                 :            : 
     238                 :            :     // char styles
     239                 :          0 :     String sCharFmtName(aCharStyleLB.GetSelectEntry());
     240                 :          0 :     SwCharFmt *pCharFmt = pSh->FindCharFmtByName(sCharFmtName);
     241                 :            : 
     242                 :          0 :     if (!pCharFmt)
     243                 :            :     {
     244                 :          0 :         SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
     245                 :            :         SfxStyleSheetBase* pBase;
     246                 :          0 :         pBase = pPool->Find(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
     247                 :          0 :         if(!pBase)
     248                 :          0 :             pBase = &pPool->Make(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
     249                 :          0 :         pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
     250                 :            :     }
     251                 :            : 
     252                 :          0 :     if (pCharFmt)
     253                 :          0 :         aInf.SetCharFmt(pCharFmt);
     254                 :            : 
     255                 :            :     // format
     256                 :          0 :     SvxNumberType aType;
     257                 :          0 :     aType.SetNumberingType(aFormatLB.GetSelectedNumberingType());
     258                 :          0 :     aInf.SetNumType(aType);
     259                 :            : 
     260                 :            :     // position
     261                 :          0 :     aInf.SetPos((LineNumberPosition)aPosLB.GetSelectEntryPos());
     262                 :            : 
     263                 :            :     // offset
     264                 :          0 :     aInf.SetPosFromLeft((sal_uInt16)aOffsetMF.Denormalize(aOffsetMF.GetValue(FUNIT_TWIP)));
     265                 :            : 
     266                 :            :     // numbering offset
     267                 :          0 :     aInf.SetCountBy((sal_uInt16)aNumIntervalNF.GetValue());
     268                 :            : 
     269                 :            :     // divider
     270                 :          0 :     aInf.SetDivider(aDivisorED.GetText());
     271                 :            : 
     272                 :            :     // divider offset
     273                 :          0 :     aInf.SetDividerCountBy((sal_uInt16)aDivIntervalNF.GetValue());
     274                 :            : 
     275                 :            :     // count
     276                 :          0 :     aInf.SetCountBlankLines(aCountEmptyLinesCB.IsChecked());
     277                 :          0 :     aInf.SetCountInFlys(aCountFrameLinesCB.IsChecked());
     278                 :          0 :     aInf.SetRestartEachPage(aRestartEachPageCB.IsChecked());
     279                 :            : 
     280                 :          0 :     aInf.SetPaintLineNumbers(aNumberingOnCB.IsChecked());
     281                 :            : 
     282                 :          0 :     pSh->SetLineNumberInfo(aInf);
     283                 :            : 
     284                 :          0 :     return sal_False;
     285                 :            : }
     286                 :            : 
     287                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10