sw/inc/swtblfmt.hxx | 29 +++++++++++ sw/inc/tblafmt.hxx | 12 ---- sw/source/core/doc/swtblfmt.cxx | 97 ++++++++++++++++++++++++++++++++++++++++ sw/source/core/doc/tblafmt.cxx | 93 +++++++++++++++++--------------------- 4 files changed, 170 insertions(+), 61 deletions(-)
New commits: commit 171093a390fb2c29cee610fd0f6924b3c0a351fd Author: Alex Ivan <alexni...@yahoo.com> Date: Thu Jun 27 15:28:29 2013 +0300 Move table format information into SwTableFmt Moved the information currently stored in SwTableAutoFmt into SwTableFmt class Change-Id: If0d0cf82a2ea14995410bcf03957d9a85b6e8e17 diff --git a/sw/inc/swtblfmt.hxx b/sw/inc/swtblfmt.hxx index 2a9d53a..a068fb9 100644 --- a/sw/inc/swtblfmt.hxx +++ b/sw/inc/swtblfmt.hxx @@ -19,6 +19,11 @@ #ifndef _SWTBLFMT_HXX #define _SWTBLFMT_HXX +#include <editeng/formatbreakitem.hxx> +#include <editeng/keepitem.hxx> +#include <editeng/shaditem.hxx> +#include <fmtpdsc.hxx> +#include <fmtlsplt.hxx> #include <frmfmt.hxx> class SwDoc; @@ -46,7 +51,11 @@ protected: SwTableLineFmt* pOddColFmt; SwTableLineFmt* pEvnColFmt; + sal_uInt16 m_aRepeatHeading; + sal_Bool m_bRowSplit; + public: + SwTableFmt& operator=( const SwTableFmt& rNew ); void SetFirstLineFmt( SwTableLineFmt* pNew ) { pFstLineFmt = pNew; } void SetLastLineFmt( SwTableLineFmt* pNew ) { pLstLineFmt = pNew; } @@ -68,6 +77,26 @@ public: SwTableLineFmt* GetOddColFmt() { return pOddColFmt; } SwTableLineFmt* GetEvenColFmt() { return pEvnColFmt; } + void SetRepeatHeading( const sal_uInt16& rNew ) { m_aRepeatHeading = rNew; } + void SetRowSplit( const sal_Bool& rNew ) { m_bRowSplit = rNew; } + + const sal_uInt16& GetRepeatHeading() const { return m_aRepeatHeading; } + const sal_Bool& GetRowSplit() const { return m_bRowSplit; } + + void SetBreak( const SvxFmtBreakItem& rNew ); + void SetPageDesc( const SwFmtPageDesc& rNew ); + void SetKeepWithNextPara( const SvxFmtKeepItem& rNew ); + void SetLayoutSplit( const sal_Bool& rNew ); + void SetCollapsingBorders( const sal_Bool& rNew ); + void SetShadow( const SvxShadowItem& rNew ); + + const SvxFmtBreakItem& GetBreak() const; + const SwFmtPageDesc& GetPageDesc() const; + const SvxFmtKeepItem& GetKeepWithNextPara() const; + sal_Bool GetLayoutSplit() const; + sal_Bool GetCollapsingBorders() const; + const SvxShadowItem& GetShadow() const; + TYPEINFO(); // Already in base class Content. DECL_FIXEDMEMPOOL_NEWDEL(SwTableFmt) diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 1988933..3ac0123 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -249,16 +249,6 @@ class SW_DLLPUBLIC SwTableAutoFmt SwBoxAutoFmt* aBoxAutoFmt[ 16 ]; - // Writer-specific options - SvxFmtBreakItem m_aBreak; - SwFmtPageDesc m_aPageDesc; - SvxFmtKeepItem m_aKeepWithNextPara; - sal_uInt16 m_aRepeatHeading; - sal_Bool m_bLayoutSplit; - sal_Bool m_bRowSplit; - sal_Bool m_bCollapsingBorders; - SvxShadowItem m_aShadow; - public: SwTableAutoFmt( const String& rName, SwTableFmt* pTableStyle ); SwTableAutoFmt( const SwTableAutoFmt& rNew ); @@ -266,6 +256,8 @@ public: SwTableAutoFmt& operator=( const SwTableAutoFmt& rNew ); + SwTableFmt* GetTableStyle() { return m_pTableStyle; } + void SetBoxFmt( const SwBoxAutoFmt& rNew, sal_uInt8 nPos ); const SwBoxAutoFmt& GetBoxFmt( sal_uInt8 nPos ) const; diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx index b3cd7ff..c3fcd1a 100644 --- a/sw/source/core/doc/swtblfmt.cxx +++ b/sw/source/core/doc/swtblfmt.cxx @@ -22,7 +22,15 @@ SwTableFmt::SwTableFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, SwFrmFmt *pDrvdFrm ) : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_FRMFMT, aTableSetRange ) + , m_aRepeatHeading( 0 ) + , m_bRowSplit( sal_True ) { + SetBreak( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) ); + SetKeepWithNextPara( SvxFmtKeepItem( sal_False, RES_KEEP ) ); + SetLayoutSplit( sal_True ); + SetCollapsingBorders( sal_True ); + SetShadow( SvxShadowItem( RES_SHADOW ) ); + pFstLineFmt = NULL; pLstLineFmt = NULL; pOddLineFmt = NULL; @@ -37,7 +45,15 @@ SwTableFmt::SwTableFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, SwTableFmt::SwTableFmt( SwAttrPool& rPool, const String &rFmtNm, SwFrmFmt *pDrvdFrm ) : SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_FRMFMT, aTableSetRange ) + , m_aRepeatHeading( 0 ) + , m_bRowSplit( sal_True ) { + SetBreak( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) ); + SetKeepWithNextPara( SvxFmtKeepItem( sal_False, RES_KEEP ) ); + SetLayoutSplit( sal_True ); + SetCollapsingBorders( sal_True ); + SetShadow( SvxShadowItem( RES_SHADOW ) ); + pFstLineFmt = NULL; pLstLineFmt = NULL; pOddLineFmt = NULL; @@ -49,6 +65,87 @@ SwTableFmt::SwTableFmt( SwAttrPool& rPool, const String &rFmtNm, pEvnColFmt = NULL; } +SwTableFmt& SwTableFmt::operator=( const SwTableFmt& rNew ) + { + if (&rNew == this) + return *this; + + m_aRepeatHeading = rNew.m_aRepeatHeading; + m_bRowSplit = rNew.m_bRowSplit; + + pFstLineFmt = rNew.pFstLineFmt; + pLstLineFmt = rNew.pLstLineFmt; + pOddLineFmt = rNew.pOddLineFmt; + pEvnLineFmt = rNew.pEvnLineFmt; + + pFstColFmt = rNew.pFstColFmt; + pLstColFmt = rNew.pLstColFmt; + pOddColFmt = rNew.pOddColFmt; + pEvnColFmt = rNew.pEvnColFmt; + + return *this; + } + +void SwTableFmt::SetBreak( const SvxFmtBreakItem& rNew ) +{ + SetFmtAttr( rNew ); +} + +void SwTableFmt::SetPageDesc( const SwFmtPageDesc& rNew ) +{ + SetFmtAttr( rNew ); +} + +void SwTableFmt::SetKeepWithNextPara( const SvxFmtKeepItem& rNew ) +{ + SetFmtAttr( rNew ); +} + +void SwTableFmt::SetLayoutSplit( const sal_Bool& rNew ) +{ + SetFmtAttr( SwFmtLayoutSplit( rNew ) ); +} + +void SwTableFmt::SetCollapsingBorders( const sal_Bool& rNew ) +{ + SetFmtAttr( SfxBoolItem( RES_COLLAPSING_BORDERS, rNew ) ); +} + +void SwTableFmt::SetShadow( const SvxShadowItem& rNew ) +{ + SetFmtAttr( rNew ); +} + +const SvxFmtBreakItem& SwTableFmt::GetBreak() const +{ + return static_cast<const SvxFmtBreakItem&>( GetFmtAttr( RES_BREAK ) ); +} + +const SwFmtPageDesc& SwTableFmt::GetPageDesc() const +{ + return static_cast<const SwFmtPageDesc&>( GetFmtAttr( RES_PAGEDESC ) ); +} + +const SvxFmtKeepItem& SwTableFmt::GetKeepWithNextPara() const +{ + return static_cast<const SvxFmtKeepItem&>( GetFmtAttr( RES_KEEP ) ); +} + +sal_Bool SwTableFmt::GetLayoutSplit() const +{ + return (static_cast<const SwFmtLayoutSplit&>( GetFmtAttr( RES_LAYOUT_SPLIT ) )).GetValue(); +} + +sal_Bool SwTableFmt::GetCollapsingBorders() const +{ + return (static_cast<const SfxBoolItem&>( GetFmtAttr( RES_COLLAPSING_BORDERS ) )).GetValue(); +} + +const SvxShadowItem& SwTableFmt::GetShadow() const +{ + return static_cast<const SvxShadowItem&>( GetFmtAttr( RES_SHADOW ) ); +} + SwTableLineFmt::SwTableLineFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, SwFrmFmt *pDrvdFrm ) : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_FRMFMT, aTableLineSetRange ) diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index bb4e682..abbddbc 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -594,13 +594,6 @@ SwTableAutoFmt::SwTableAutoFmt( const String& rName, SwTableFmt* pTableStyle ) : m_pTableStyle( pTableStyle ) , aName( rName ) , nStrResId( USHRT_MAX ) - , m_aBreak( SVX_BREAK_NONE, RES_BREAK ) - , m_aKeepWithNextPara( sal_False, RES_KEEP ) - , m_aRepeatHeading( 0 ) - , m_bLayoutSplit( sal_True ) - , m_bRowSplit( sal_True ) - , m_bCollapsingBorders(sal_True) - , m_aShadow( RES_SHADOW ) { bInclFont = sal_True; bInclJustify = sal_True; @@ -614,9 +607,6 @@ SwTableAutoFmt::SwTableAutoFmt( const String& rName, SwTableFmt* pTableStyle ) SwTableAutoFmt::SwTableAutoFmt( const SwTableAutoFmt& rNew ) - : m_aBreak( rNew.m_aBreak ) - , m_aKeepWithNextPara( sal_False, RES_KEEP ) - , m_aShadow( RES_SHADOW ) { for( sal_uInt8 n = 0; n < 16; ++n ) aBoxAutoFmt[ n ] = 0; @@ -650,15 +640,6 @@ SwTableAutoFmt& SwTableAutoFmt::operator=( const SwTableAutoFmt& rNew ) bInclValueFormat = rNew.bInclValueFormat; bInclWidthHeight = rNew.bInclWidthHeight; - m_aBreak = rNew.m_aBreak; - m_aPageDesc = rNew.m_aPageDesc; - m_aKeepWithNextPara = rNew.m_aKeepWithNextPara; - m_aRepeatHeading = rNew.m_aRepeatHeading; - m_bLayoutSplit = rNew.m_bLayoutSplit; - m_bRowSplit = rNew.m_bRowSplit; - m_bCollapsingBorders = rNew.m_bCollapsingBorders; - m_aShadow = rNew.m_aShadow; - return *this; } @@ -868,21 +849,12 @@ void SwTableAutoFmt::RestoreTableProperties(SwTable &table) const if (!pDoc) return; - SfxItemSet rSet(pDoc->GetAttrPool(), aTableSetRange); - - rSet.Put(m_aBreak); - rSet.Put(m_aPageDesc); - rSet.Put(SwFmtLayoutSplit(m_bLayoutSplit)); - rSet.Put(SfxBoolItem(RES_COLLAPSING_BORDERS, m_bCollapsingBorders)); - rSet.Put(m_aKeepWithNextPara); - rSet.Put(m_aShadow); - - pFormat->SetFmtAttr(rSet); + pFormat->SetFmtAttr( m_pTableStyle->GetAttrSet() ); SwEditShell *pShell = pDoc->GetEditShell(); - pDoc->SetRowSplit(*pShell->getShellCrsr(false), SwFmtRowSplit(m_bRowSplit)); + pDoc->SetRowSplit(*pShell->getShellCrsr(false), SwFmtRowSplit(m_pTableStyle->GetRowSplit())); - table.SetRowsToRepeat(m_aRepeatHeading); + table.SetRowsToRepeat(m_pTableStyle->GetRepeatHeading()); } void SwTableAutoFmt::StoreTableProperties(const SwTable &table) @@ -898,21 +870,11 @@ void SwTableAutoFmt::StoreTableProperties(const SwTable &table) SwEditShell *pShell = pDoc->GetEditShell(); SwFmtRowSplit *pRowSplit = 0; pDoc->GetRowSplit(*pShell->getShellCrsr(false), pRowSplit); - m_bRowSplit = pRowSplit ? pRowSplit->GetValue() : sal_False; + m_pTableStyle->SetRowSplit( pRowSplit ? pRowSplit->GetValue() : sal_False ); delete pRowSplit; pRowSplit = 0; - const SfxItemSet &rSet = pFormat->GetAttrSet(); - - m_aBreak = static_cast<const SvxFmtBreakItem&>(rSet.Get(RES_BREAK)); - m_aPageDesc = static_cast<const SwFmtPageDesc&>(rSet.Get(RES_PAGEDESC)); - const SwFmtLayoutSplit &layoutSplit = static_cast<const SwFmtLayoutSplit&>(rSet.Get(RES_LAYOUT_SPLIT)); - m_bLayoutSplit = layoutSplit.GetValue(); - m_bCollapsingBorders = static_cast<const SfxBoolItem&>(rSet.Get(RES_COLLAPSING_BORDERS)).GetValue(); - - m_aKeepWithNextPara = static_cast<const SvxFmtKeepItem&>(rSet.Get(RES_KEEP)); - m_aRepeatHeading = table.GetRowsToRepeat(); - m_aShadow = static_cast<const SvxShadowItem&>(rSet.Get(RES_SHADOW)); + m_pTableStyle->SetFmtAttr( pFormat->GetAttrSet() ); } SwTableAutoFmt* SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, SwDoc* pDoc ) @@ -964,13 +926,31 @@ SwTableAutoFmt* SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVe { SfxPoolItem* pNew = 0; - READ(pRet->m_aBreak, SvxFmtBreakItem, AUTOFORMAT_FILE_VERSION); - READ(pRet->m_aPageDesc, SwFmtPageDesc, AUTOFORMAT_FILE_VERSION); - READ(pRet->m_aKeepWithNextPara, SvxFmtKeepItem, AUTOFORMAT_FILE_VERSION); - - rStream >> pRet->m_aRepeatHeading >> pRet->m_bLayoutSplit >> pRet->m_bRowSplit >> pRet->m_bCollapsingBorders; - - READ(pRet->m_aShadow, SvxShadowItem, AUTOFORMAT_FILE_VERSION); + SvxFmtBreakItem m_aBreak = SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ); + READ(m_aBreak, SvxFmtBreakItem, AUTOFORMAT_FILE_VERSION); + pStyle->SetBreak( m_aBreak ); + + SwFmtPageDesc m_aPageDesc; + READ(m_aPageDesc, SwFmtPageDesc, AUTOFORMAT_FILE_VERSION); + pStyle->SetPageDesc( m_aPageDesc ); + + SvxFmtKeepItem m_aKeepWithNextPara = SvxFmtKeepItem( sal_False, RES_KEEP ); + READ(m_aKeepWithNextPara, SvxFmtKeepItem, AUTOFORMAT_FILE_VERSION); + pStyle->SetKeepWithNextPara( m_aKeepWithNextPara ); + + sal_uInt16 m_aRepeatHeading; + sal_Bool m_bLayoutSplit; + sal_Bool m_bRowSplit; + sal_Bool m_bCollapsingBorders; + rStream >> m_aRepeatHeading >> m_bLayoutSplit >> m_bRowSplit >> m_bCollapsingBorders; + pStyle->SetRepeatHeading( m_aRepeatHeading ); + pStyle->SetRowSplit( m_bRowSplit ); + pStyle->SetLayoutSplit( m_bLayoutSplit ); + pStyle->SetCollapsingBorders( m_bCollapsingBorders ); + + SvxShadowItem m_aShadow = SvxShadowItem( RES_SHADOW ); + READ(m_aShadow, SvxShadowItem, AUTOFORMAT_FILE_VERSION); + pStyle->SetShadow( m_aShadow ); } bRet = 0 == rStream.GetError(); @@ -1015,10 +995,21 @@ sal_Bool SwTableAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const { WriterSpecificAutoFormatBlock block(rStream); + SvxFmtBreakItem m_aBreak = m_pTableStyle->GetBreak(); m_aBreak.Store(rStream, m_aBreak.GetVersion(fileVersion)); + + SwFmtPageDesc m_aPageDesc = m_pTableStyle->GetPageDesc(); m_aPageDesc.Store(rStream, m_aPageDesc.GetVersion(fileVersion)); + + SvxFmtKeepItem m_aKeepWithNextPara = m_pTableStyle->GetKeepWithNextPara(); m_aKeepWithNextPara.Store(rStream, m_aKeepWithNextPara.GetVersion(fileVersion)); - rStream << m_aRepeatHeading << m_bLayoutSplit << m_bRowSplit << m_bCollapsingBorders; + + rStream << m_pTableStyle->GetRepeatHeading(); + rStream << m_pTableStyle->GetLayoutSplit(); + rStream << m_pTableStyle->GetRowSplit(); + rStream << m_pTableStyle->GetCollapsingBorders(); + + SvxShadowItem m_aShadow = m_pTableStyle->GetShadow(); m_aShadow.Store(rStream, m_aShadow.GetVersion(fileVersion)); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits