LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/misc - linenum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 100 0.0 %
Date: 2013-07-09 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/viewfrm.hxx>
      21             : #include <svl/style.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <view.hxx>
      24             : #include <wrtsh.hxx>
      25             : #include <docsh.hxx>
      26             : #include <charfmt.hxx>
      27             : 
      28             : #include <docstyle.hxx>
      29             : 
      30             : #include "fldbas.hxx"
      31             : #include "lineinfo.hxx"
      32             : #include "linenum.hxx"
      33             : #include "uitool.hxx"
      34             : 
      35             : #include <IDocumentStylePoolAccess.hxx>
      36             : 
      37           0 : SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
      38           0 :     : SfxModalDialog( &pVw->GetViewFrame()->GetWindow(), "LineNumberingDialog",
      39             :         "modules/swriter/ui/linenumbering.ui" )
      40           0 :     , pSh(pVw->GetWrtShellPtr())
      41             : {
      42           0 :     get(m_pBodyContent, "content");
      43           0 :     get(m_pDivIntervalFT, "every");
      44           0 :     get(m_pDivIntervalNF, "linesspin");
      45           0 :     get(m_pDivRowsFT, "lines");
      46           0 :     get(m_pNumIntervalNF, "intervalspin");
      47           0 :     get(m_pCharStyleLB, "styledropdown");
      48           0 :     get(m_pFormatLB, "formatdropdown");
      49           0 :     get(m_pPosLB, "positiondropdown");
      50           0 :     get(m_pOffsetMF, "spacingspin");
      51           0 :     get(m_pDivisorED, "textentry");
      52           0 :     get(m_pCountEmptyLinesCB, "blanklines");
      53           0 :     get(m_pCountFrameLinesCB, "linesintextframes");
      54           0 :     get(m_pRestartEachPageCB, "restarteverynewpage");
      55           0 :     get(m_pNumberingOnCB, "shownumbering");
      56             : 
      57           0 :     String sIntervalName = m_pDivIntervalFT->GetAccessibleName();
      58           0 :     sIntervalName += OUString("(");
      59           0 :     sIntervalName += m_pDivRowsFT->GetAccessibleName();
      60           0 :     sIntervalName += OUString(")");
      61           0 :     m_pDivIntervalNF->SetAccessibleName(sIntervalName);
      62             : 
      63           0 :     Window *pNumIntervalFT = get<Window>("interval");
      64           0 :     Window *pNumRowsFT = get<Window>("intervallines");
      65           0 :     sIntervalName = pNumIntervalFT->GetAccessibleName();
      66           0 :     sIntervalName += OUString("(");
      67           0 :     sIntervalName += pNumRowsFT->GetAccessibleName();
      68           0 :     sIntervalName += OUString(")");
      69           0 :     m_pNumIntervalNF->SetAccessibleName(sIntervalName);
      70             : 
      71             :     // char styles
      72           0 :     ::FillCharStyleListBox(*m_pCharStyleLB, pSh->GetView().GetDocShell());
      73             : 
      74           0 :     const SwLineNumberInfo &rInf = pSh->GetLineNumberInfo();
      75           0 :     IDocumentStylePoolAccess* pIDSPA = pSh->getIDocumentStylePoolAccess();
      76             : 
      77           0 :     String sStyleName(rInf.GetCharFmt( *pIDSPA )->GetName());
      78           0 :     const sal_uInt16 nPos = m_pCharStyleLB->GetEntryPos(sStyleName);
      79             : 
      80           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
      81           0 :         m_pCharStyleLB->SelectEntryPos(nPos);
      82             :     else
      83             :     {
      84           0 :         if (sStyleName.Len())
      85             :         {
      86           0 :             m_pCharStyleLB->InsertEntry(sStyleName);
      87           0 :             m_pCharStyleLB->SelectEntry(sStyleName);
      88             :         }
      89             :     }
      90             : 
      91             :     // format
      92           0 :     sal_uInt16 nSelFmt = rInf.GetNumType().GetNumberingType();
      93             : 
      94           0 :     m_pFormatLB->SelectNumberingType(nSelFmt);
      95             : 
      96             :     // position
      97           0 :     m_pPosLB->SelectEntryPos((sal_uInt16)rInf.GetPos());
      98             : 
      99             :     // offset
     100           0 :     sal_uInt16 nOffset = rInf.GetPosFromLeft();
     101           0 :     if (nOffset == USHRT_MAX)
     102           0 :         nOffset = 0;
     103             : 
     104           0 :     m_pOffsetMF->SetValue(m_pOffsetMF->Normalize(nOffset), FUNIT_TWIP);
     105             : 
     106             :     // numbering offset
     107           0 :     m_pNumIntervalNF->SetValue(rInf.GetCountBy());
     108             : 
     109             :     // divider
     110           0 :     m_pDivisorED->SetText(rInf.GetDivider());
     111             : 
     112             :     // divider offset
     113           0 :     m_pDivIntervalNF->SetValue(rInf.GetDividerCountBy());
     114             : 
     115             :     // count
     116           0 :     m_pCountEmptyLinesCB->Check(rInf.IsCountBlankLines());
     117           0 :     m_pCountFrameLinesCB->Check(rInf.IsCountInFlys());
     118           0 :     m_pRestartEachPageCB->Check(rInf.IsRestartEachPage());
     119             : 
     120           0 :     m_pNumberingOnCB->Check(rInf.IsPaintLineNumbers());
     121             : 
     122           0 :     m_pNumberingOnCB->SetClickHdl(LINK(this, SwLineNumberingDlg, LineOnOffHdl));
     123           0 :     m_pDivisorED->SetModifyHdl(LINK(this, SwLineNumberingDlg, ModifyHdl));
     124           0 :     ModifyHdl();
     125           0 :     LineOnOffHdl();
     126             : 
     127           0 :     get<PushButton>("ok")->SetClickHdl(LINK(this, SwLineNumberingDlg, OKHdl));
     128           0 : }
     129             : 
     130           0 : SwLineNumberingDlg::~SwLineNumberingDlg()
     131             : {
     132           0 : }
     133             : 
     134           0 : IMPL_LINK_NOARG(SwLineNumberingDlg, OKHdl)
     135             : {
     136           0 :     SwLineNumberInfo aInf(pSh->GetLineNumberInfo());
     137             : 
     138             :     // char styles
     139           0 :     String sCharFmtName(m_pCharStyleLB->GetSelectEntry());
     140           0 :     SwCharFmt *pCharFmt = pSh->FindCharFmtByName(sCharFmtName);
     141             : 
     142           0 :     if (!pCharFmt)
     143             :     {
     144           0 :         SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
     145             :         SfxStyleSheetBase* pBase;
     146           0 :         pBase = pPool->Find(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
     147           0 :         if(!pBase)
     148           0 :             pBase = &pPool->Make(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
     149           0 :         pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
     150             :     }
     151             : 
     152           0 :     if (pCharFmt)
     153           0 :         aInf.SetCharFmt(pCharFmt);
     154             : 
     155             :     // format
     156           0 :     SvxNumberType aType;
     157           0 :     aType.SetNumberingType(m_pFormatLB->GetSelectedNumberingType());
     158           0 :     aInf.SetNumType(aType);
     159             : 
     160             :     // position
     161           0 :     aInf.SetPos((LineNumberPosition)m_pPosLB->GetSelectEntryPos());
     162             : 
     163             :     // offset
     164           0 :     aInf.SetPosFromLeft((sal_uInt16)m_pOffsetMF->Denormalize(m_pOffsetMF->GetValue(FUNIT_TWIP)));
     165             : 
     166             :     // numbering offset
     167           0 :     aInf.SetCountBy((sal_uInt16)m_pNumIntervalNF->GetValue());
     168             : 
     169             :     // divider
     170           0 :     aInf.SetDivider(m_pDivisorED->GetText());
     171             : 
     172             :     // divider offset
     173           0 :     aInf.SetDividerCountBy((sal_uInt16)m_pDivIntervalNF->GetValue());
     174             : 
     175             :     // count
     176           0 :     aInf.SetCountBlankLines(m_pCountEmptyLinesCB->IsChecked());
     177           0 :     aInf.SetCountInFlys(m_pCountFrameLinesCB->IsChecked());
     178           0 :     aInf.SetRestartEachPage(m_pRestartEachPageCB->IsChecked());
     179             : 
     180           0 :     aInf.SetPaintLineNumbers(m_pNumberingOnCB->IsChecked());
     181             : 
     182           0 :     pSh->SetLineNumberInfo(aInf);
     183             : 
     184           0 :     EndDialog( RET_OK );
     185             : 
     186           0 :     return 0;
     187             : }
     188             : 
     189             : /*--------------------------------------------------------------------
     190             :     Description: modify
     191             :  --------------------------------------------------------------------*/
     192           0 : IMPL_LINK_NOARG(SwLineNumberingDlg, ModifyHdl)
     193             : {
     194           0 :     bool bEnable = m_pNumberingOnCB->IsChecked() && !m_pDivisorED->GetText().isEmpty();
     195             : 
     196           0 :     m_pDivIntervalFT->Enable(bEnable);
     197           0 :     m_pDivIntervalNF->Enable(bEnable);
     198           0 :     m_pDivRowsFT->Enable(bEnable);
     199             : 
     200           0 :     return 0;
     201             : }
     202             : 
     203             : /*--------------------------------------------------------------------
     204             :     Description: On/Off
     205             :  --------------------------------------------------------------------*/
     206           0 : IMPL_LINK_NOARG(SwLineNumberingDlg, LineOnOffHdl)
     207             : {
     208           0 :     bool bEnable = m_pNumberingOnCB->IsChecked();
     209           0 :     m_pBodyContent->Enable(bEnable);
     210           0 :     ModifyHdl();
     211           0 :     return 0;
     212           0 : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10