sw/inc/node.hxx | 1 sw/source/core/doc/swtblfmt.cxx | 42 ++++++++++++++++++++++++++++++++++++++++ sw/source/core/docnode/node.cxx | 23 +++++++++++++++++++++ sw/source/core/text/atrstck.cxx | 20 ++++--------------- 4 files changed, 71 insertions(+), 15 deletions(-)
New commits: commit a96a03be3d8ccc36bb43b3af0f1e569d8e7257b5 Author: Alex Ivan <alexni...@yahoo.com> Date: Sat Sep 7 19:38:48 2013 +0300 Correctly set the parent attribute set of the SwCntntNode The text properties are set on the SwCntntNode, similar to how it was done in the AutoFormat system. However, rather than setting them directly on the node's attribute set, they are put into the attribute set's parent. There are some minor issues with updating the allignment of the text within the cell. Change-Id: I814b3b7d67744895deeb4e551a968f21e47cc77a diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 7690cf8..9cebf4e 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -439,6 +439,7 @@ public: /// If bInParent is FALSE search for attribute only in this node. const SfxPoolItem& GetAttr( sal_uInt16 nWhich, sal_Bool bInParent=sal_True ) const; sal_Bool GetAttr( SfxItemSet& rSet, sal_Bool bInParent=sal_True ) const; + void SetAttrParent( const SfxItemSet* pParentSet ); /// made virtual virtual sal_Bool SetAttr( const SfxPoolItem& ); virtual sal_Bool SetAttr( const SfxItemSet& rSet ); diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx index ee5c3f0..072ef5a 100644 --- a/sw/source/core/doc/swtblfmt.cxx +++ b/sw/source/core/doc/swtblfmt.cxx @@ -367,6 +367,27 @@ void SwTableFmt::AssignBoxParents( SwTableLineFmt* pSrcLineFmt, SwTableLine &rLi if( rLine.GetTabBoxes()[ n ]->GetTabLines().size() ) AssignLineParents_Complex( pSrcLineFmt, pFmt, *rLine.GetTabBoxes()[ n ] ); + else + { + SfxItemSet* pCharSet = NULL; + if( pFmt ) + { + pCharSet = new SfxItemSet( pBoxFmt->GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_PARATR_LIST_END - 1 ); + pCharSet->Put( pFmt->GetAttrSet() ); + } + + sal_uLong nSttNd = rLine.GetTabBoxes()[ n ]->GetSttIdx() + 1; + sal_uLong nEndNd = rLine.GetTabBoxes()[ n ]->GetSttNd()->EndOfSectionIndex(); + for( ; nSttNd < nEndNd; ++nSttNd ) + { + SwCntntNode* pNd = pBoxFmt->GetDoc()->GetNodes()[ nSttNd ]->GetCntntNode(); + if( pNd ) + { + pNd->SetAttrParent( pCharSet ); + } + } + } ((SwModify*)pBoxFmt)->CheckCaching( RES_BOX ); } @@ -416,6 +437,27 @@ void SwTableFmt::AssignBoxParents_Complex( SwTableLineFmt* pSrcLineFmt, SwTableB if( rLine.GetTabBoxes()[ n ]->GetTabLines().size() ) AssignLineParents_Complex( pSrcLineFmt, pSrcBoxFmt, *rLine.GetTabBoxes()[ n ] ); + else + { + SfxItemSet* pCharSet = NULL; + if( pSrcBoxFmt ) + { + pCharSet = new SfxItemSet( pBoxFmt->GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_PARATR_LIST_END - 1 ); + pCharSet->Put( pSrcBoxFmt->GetAttrSet() ); + } + + sal_uLong nSttNd = rLine.GetTabBoxes()[ n ]->GetSttIdx() + 1; + sal_uLong nEndNd = rLine.GetTabBoxes()[ n ]->GetSttNd()->EndOfSectionIndex(); + for( ; nSttNd < nEndNd; ++nSttNd ) + { + SwCntntNode* pNd = pBoxFmt->GetDoc()->GetNodes()[ nSttNd ]->GetCntntNode(); + if( pNd ) + { + pNd->SetAttrParent( pCharSet ); + } + } + } ((SwModify*)pBoxFmt)->CheckCaching( RES_BOX ); } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 90f371c..b4ebf6c 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -130,6 +130,22 @@ void SetParent( boost::shared_ptr<const SfxItemSet>& mrpAttrSet, } } +void SetParent( boost::shared_ptr<const SfxItemSet>& mrpAttrSet, + const SwCntntNode& rNode, + const SfxItemSet* pParentSet ) +{ + const SwAttrSet* pAttrSet = static_cast<const SwAttrSet*>(mrpAttrSet.get()); + OSL_ENSURE( pAttrSet, "no SwAttrSet" ); + + if ( pParentSet != pAttrSet->GetParent() ) + { + SwAttrSet aNewSet( *pAttrSet ); + aNewSet.SetParent( pParentSet ); + + GetNewAutoStyle( mrpAttrSet, rNode, aNewSet ); + } +} + const SfxPoolItem* Put( boost::shared_ptr<const SfxItemSet>& mrpAttrSet, const SwCntntNode& rNode, const SfxPoolItem& rAttr ) @@ -1569,6 +1585,13 @@ sal_uInt16 SwCntntNode::ResetAllAttr() return aNew.Count(); } +void SwCntntNode::SetAttrParent( const SfxItemSet* pParentSet ) +{ + if( !GetpSwAttrSet() ) + NewAttrSet( GetDoc()->GetAttrPool() ); + + AttrSetHandleHelper::SetParent( mpAttrSet, *this, pParentSet ); +} sal_Bool SwCntntNode::GetAttr( SfxItemSet& rSet, sal_Bool bInParent ) const { commit d1b17ec6e6a994f7e835bb25117f335bed90783d Author: Alex Ivan <alexni...@yahoo.com> Date: Sat Sep 7 19:29:59 2013 +0300 Fix SwAttrHandler::Init to take parent attribute set into account The new implementation might not be as efficient as the previous, but the functionality is preserved. The change allows the correct text properties from the table style to be taken into consideration. Change-Id: Icf1460a40baa0c10c6234b05113b1c75848cb4da diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index 2747f26..a7dac25 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -419,26 +419,16 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS, // do we have to apply additional paragraph attributes? bVertLayout = bVL; - if ( pAS && pAS->Count() ) - { - SfxItemIter aIter( *pAS ); - sal_uInt16 nWhich; - const SfxPoolItem* pItem = aIter.GetCurItem(); - while( true ) + if( pAS ) + for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++ ) { - nWhich = pItem->Which(); - if (isCHRATR(nWhich)) + const SfxPoolItem* pItem = 0; + if( SFX_ITEM_SET == pAS->GetItemState( i, sal_True, &pItem ) ) { - pDefaultArray[ StackPos[ nWhich ] ] = pItem; + pDefaultArray[ StackPos[ i ] ] = pItem; FontChg( *pItem, rFnt, sal_True ); } - - if( aIter.IsAtEnd() ) - break; - - pItem = aIter.NextItem(); } - } // It is possible, that Init is called more than once, e.g., in a // SwTxtFrm::FormatOnceMore situation. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits