[Libreoffice-commits] core.git: sw/source sw/uiconfig

Charu Tyagi charu.tyagi at ericsson.com
Wed Oct 8 08:30:18 PDT 2014


 sw/source/ui/misc/linenum.cxx           |   47 ++++++++++++++++++++++++++++++++
 sw/source/uibase/inc/linenum.hxx        |    3 --
 sw/uiconfig/swriter/ui/linenumbering.ui |   16 ++++++++++
 3 files changed, 64 insertions(+), 2 deletions(-)

New commits:
commit 8f6a9117d6ad4cb6cc1f6017ca534cd773ee2b4f
Author: Charu Tyagi <charu.tyagi at ericsson.com>
Date:   Wed Oct 1 10:42:13 2014 +0530

    fdo#84504: UI- LineNumbering for header/footer
    
    Change-Id: I5b432273ce24d8575ac36f5336717669db733c35
    Reviewed-on: https://gerrit.libreoffice.org/11730
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/ui/misc/linenum.cxx b/sw/source/ui/misc/linenum.cxx
index 48e6732..0828625 100644
--- a/sw/source/ui/misc/linenum.cxx
+++ b/sw/source/ui/misc/linenum.cxx
@@ -31,9 +31,34 @@
 #include "lineinfo.hxx"
 #include "linenum.hxx"
 #include "uitool.hxx"
+#include <fmtline.hxx>
 
 #include <IDocumentStylePoolAccess.hxx>
 
+static rtl::Reference<SwDocStyleSheet> lcl_getDocStyleSheet(OUString rName, SwWrtShell *pSh)
+{
+    sal_uInt16 nFamily = SFX_STYLE_FAMILY_PARA;
+    SfxStyleSheetBasePool* mpBase =  pSh->GetView().GetDocShell()->GetStyleSheetPool();
+    SfxStyleSheetBase* pStyle = mpBase->Find(rName, (SfxStyleFamily)nFamily);
+    SAL_WARN_IF( !pStyle, "linenumbering.ui", "Style not found" );
+    if(!pStyle)
+        return NULL;
+    return new SwDocStyleSheet(*(SwDocStyleSheet*)pStyle);
+}
+
+static void lcl_setLineNumbering(OUString rName, SwWrtShell* pSh, bool bLineNumber)
+{
+    rtl::Reference<SwDocStyleSheet> xStyleSheet = lcl_getDocStyleSheet(rName, pSh);
+    if(!xStyleSheet.is())
+        return;
+    SfxItemSet& rSet = xStyleSheet->GetItemSet();
+    SwFmtLineNumber aFmt;
+    aFmt.SetCountLines(bLineNumber);
+    rSet.Put(aFmt);
+    xStyleSheet->MergeIndentAttrsOfListStyle( rSet );
+    xStyleSheet->SetItemSet(rSet, false);
+}
+
 SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
     : SfxModalDialog( &pVw->GetViewFrame()->GetWindow(), "LineNumberingDialog",
         "modules/swriter/ui/linenumbering.ui" )
@@ -53,6 +78,7 @@ SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
     get(m_pCountFrameLinesCB, "linesintextframes");
     get(m_pRestartEachPageCB, "restarteverynewpage");
     get(m_pNumberingOnCB, "shownumbering");
+    get(m_pNumberingOnFooterHeader, "showfooterheadernumbering");
 
     OUString sIntervalName = m_pDivIntervalFT->GetAccessibleName();
     sIntervalName += "(";
@@ -119,6 +145,19 @@ SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
 
     m_pNumberingOnCB->Check(rInf.IsPaintLineNumbers());
 
+    // Header/Footer Line Numbering
+    rtl::Reference< SwDocStyleSheet > xStyleSheet = lcl_getDocStyleSheet("Footer", pSh);
+    if(xStyleSheet.is())
+    {
+        SfxItemSet& rSet = xStyleSheet->GetItemSet();
+        SwFmtLineNumber &aFmt = (SwFmtLineNumber&)(rSet.Get(RES_LINENUMBER));
+        if(aFmt.IsCount())
+            m_pNumberingOnFooterHeader->SetState(TRISTATE_TRUE);
+        else
+            m_pNumberingOnFooterHeader->SetState(TRISTATE_FALSE);
+    }
+
+    // Line Numbering
     m_pNumberingOnCB->SetClickHdl(LINK(this, SwLineNumberingDlg, LineOnOffHdl));
     m_pDivisorED->SetModifyHdl(LINK(this, SwLineNumberingDlg, ModifyHdl));
     ModifyHdl();
@@ -181,6 +220,14 @@ IMPL_LINK_NOARG(SwLineNumberingDlg, OKHdl)
 
     pSh->SetLineNumberInfo(aInf);
 
+    // Set LineNumber explicitly for Header and Footer
+    lcl_setLineNumbering("Footer",pSh,m_pNumberingOnFooterHeader->IsChecked());
+    lcl_setLineNumbering("Header",pSh,m_pNumberingOnFooterHeader->IsChecked());
+    if( m_pNumberingOnFooterHeader->IsChecked())
+       m_pNumberingOnFooterHeader->SetState(TRISTATE_TRUE);
+    else
+       m_pNumberingOnFooterHeader->SetState(TRISTATE_FALSE);
+
     EndDialog( RET_OK );
 
     return 0;
diff --git a/sw/source/uibase/inc/linenum.hxx b/sw/source/uibase/inc/linenum.hxx
index 0e7db9c..7b3f073 100644
--- a/sw/source/uibase/inc/linenum.hxx
+++ b/sw/source/uibase/inc/linenum.hxx
@@ -47,14 +47,13 @@ private:
     CheckBox* m_pCountFrameLinesCB;
     CheckBox* m_pRestartEachPageCB;
     CheckBox* m_pNumberingOnCB;
-
+    CheckBox* m_pNumberingOnFooterHeader;
     DECL_LINK(OKHdl, void *);
     DECL_LINK(LineOnOffHdl, void * = 0);
     DECL_LINK(ModifyHdl, void * = 0);
 
 public:
     SwWrtShell* GetWrtShell() const { return pSh; }
-
     SwLineNumberingDlg(SwView *pVw);
     virtual ~SwLineNumberingDlg();
 };
diff --git a/sw/uiconfig/swriter/ui/linenumbering.ui b/sw/uiconfig/swriter/ui/linenumbering.ui
index dbb2ea3..941b709 100644
--- a/sw/uiconfig/swriter/ui/linenumbering.ui
+++ b/sw/uiconfig/swriter/ui/linenumbering.ui
@@ -501,6 +501,22 @@
                                     <property name="position">2</property>
                                   </packing>
                                 </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="showfooterheadernumbering">
+                                    <property name="label" translatable="yes">Include footer/header in Line Numbering</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="yalign">0.60000002384185791</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
                               </object>
                             </child>
                           </object>


More information about the Libreoffice-commits mailing list