[Libreoffice-commits] core.git: Branch 'feature/table-style' - sw/inc sw/source

Alex Ivan alexnivan at yahoo.com
Sun Sep 15 14:27:43 PDT 2013


Rebased ref, commits from common ancestor:
commit a96a03be3d8ccc36bb43b3af0f1e569d8e7257b5
Author: Alex Ivan <alexnivan at 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
 {


More information about the Libreoffice-commits mailing list