diff options
author | Charu Tyagi <charu.tyagi@ericsson.com> | 2014-10-01 10:42:13 +0530 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-08 15:29:58 +0000 |
commit | 8f6a9117d6ad4cb6cc1f6017ca534cd773ee2b4f (patch) | |
tree | 0beb58307d33f7d708ebdd944017804a86e17e17 /sw/source | |
parent | ad8c2f7090ea2e77bb9afe77b2764f1b4560ad76 (diff) |
fdo#84504: UI- LineNumbering for header/footer
Change-Id: I5b432273ce24d8575ac36f5336717669db733c35
Reviewed-on: https://gerrit.libreoffice.org/11730
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/misc/linenum.cxx | 47 | ||||
-rw-r--r-- | sw/source/uibase/inc/linenum.hxx | 3 |
2 files changed, 48 insertions, 2 deletions
diff --git a/sw/source/ui/misc/linenum.cxx b/sw/source/ui/misc/linenum.cxx index 48e6732fed88..082862548868 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 0e7db9c87528..7b3f0734dee6 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(); }; |