Hello

Here is 2 new patch :
0001-add-GetCurParAttr-and-GetPaMParAttr-in-SwEditShell.patch

Create the function GetCurParAttr and GetPaMParAttr in the SwEditShell
class. The function will be used in future patchs (on the format
paintbrush) that I need to format correctly.

0002-fix-of-comments.patch
I wrote wrong comment in my preview patch
(0002-rewrite-and-comment-SwEditShell-GetPaMTxtFmtColl.patch
31b7640f7137964916062e64fca18869a18f5118) which is waiting for moderator
approval to be post on the mailing list.
This patch fix the wrong comments.

Regards

Maxime de Roucy

-- 
Maxime de Roucy
Groupe LINAGORA - OSSA
80 rue Roque de Fillol
92800 PUTEAUX
Tel. : 0 810 251 251


From dc676cade8dd096e35582a79c25c02ca3263123f Mon Sep 17 00:00:00 2001
From: Maxime de Roucy <mdero...@linagora.com>
Date: Wed, 14 Mar 2012 12:22:30 +0100
Subject: [PATCH 1/2] add GetCurParAttr and GetPaMParAttr in SwEditShell

GetCurParAttr : Get the paragraph format attribute(s) of the current selection.
GetPaMParAttr : Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.

The advantage of these methods is that the take the named and automatic
format attributes.
---
 sw/inc/editsh.hxx              |   28 +++++++++++++++++++
 sw/source/core/edit/edattr.cxx |   59 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index a160b6e..392460e 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -253,6 +253,34 @@ public:
     void SetAttr( const SfxPoolItem&, sal_uInt16 nFlags = 0 );
     void SetAttr( const SfxItemSet&, sal_uInt16 nFlags = 0, SwPaM* pCrsr = NULL );
 
+    /**
+     * Get the paragraph format attribute(s) of the current selection.
+     *
+     * @see GetPaMParAttr()
+     *
+     * @param rSet
+     * output parameter - the SfxItemSet where the automatic paragraph format attribut(s) will be store.
+     * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limite.
+     *
+     * @return true if the function inspect all the nodes point by the pPaM parameter,
+     * false if the function reach the limit of getMaxLookup number of nodes inspected.
+     */
+    sal_Bool GetCurParAttr( SfxItemSet& rSet ) const;
+    /**
+     * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
+     *
+     * @param pPaM
+     * input parameter - the selection where to look for the paragraph format.
+     *
+     * @param rSet
+     * output parameter - the SfxItemSet where the automatic paragraph format attribut(s) will be store.
+     * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limite.
+     *
+     * @return true if the function inspect all the nodes point by the pPaM parameter,
+     * false if the function reach the limit of getMaxLookup number of nodes inspected.
+     */
+    sal_Bool GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
+
     // Set attribute as new default attribute in document.
     void SetDefault( const SfxPoolItem& );
 
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index df6b4cd..a604cbc 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -176,7 +176,64 @@ sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
     return GetPaMAttr( GetCrsr(), rSet, bMergeIndentValuesOfNumRule );
 }
 
-SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl( ) const
+sal_Bool SwEditShell::GetCurParAttr( SfxItemSet& rSet) const
+{
+    return GetPaMParAttr( GetCrsr(), rSet );
+}
+
+sal_Bool SwEditShell::GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const
+{
+    // number of nodes the function have explore so far
+    sal_uInt16 numberOfLookup = 0;
+
+    SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
+    SfxItemSet* pSet = &rSet;
+
+    SwPaM* pStartPaM = pPaM;
+    do { // for all the point and mark (selections)
+
+        // get the start and the end node of the current selection
+        sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
+              nEndNd = pPaM->GetPoint()->nNode.GetIndex();
+
+        // reverse start and end if there number aren't sorted correctly
+        if( nSttNd > nEndNd )
+            std::swap(nSttNd, nEndNd);
+
+        // for all the nodes in the current selection
+        // get the node (paragraph) attributes
+        // and merge them in rSet
+        for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
+        {
+            // get the node
+            SwNode* pNd = GetDoc()->GetNodes()[ n ];
+
+            if( pNd->IsTxtNode() )
+            {
+                // get the node (paragraph) attributes
+                static_cast<SwCntntNode*>(pNd)->GetAttr(*pSet);
+
+                if( pSet != &rSet && aSet.Count() )
+                {
+                    rSet.MergeValues( aSet );
+                    aSet.ClearItem();
+                }
+
+                pSet = &aSet;
+            }
+
+            ++numberOfLookup;
+
+            // if the maximum number of node that can be inspect has been reach
+            if (numberOfLookup >= getMaxLookup())
+                return sal_False;
+        }
+    } while ( ( pPaM = static_cast<SwPaM*>(pPaM->GetNext()) ) != pStartPaM );
+
+    return sal_True;
+}
+
+SwTxtFmtnoll* SwEditShell::GetCurTxtFmtColl( ) const
 {
     return GetPaMTxtFmtColl( GetCrsr() );
 }
-- 
1.7.9.4

From 84d54c3b21e165461ceceee3b5b412216338cc2b Mon Sep 17 00:00:00 2001
From: Maxime de Roucy <mdero...@linagora.com>
Date: Wed, 14 Mar 2012 12:34:56 +0100
Subject: [PATCH 2/2] fix of comments

fix some comments made in
31b7640f7137964916062e64fca18869a18f5118
---
 sw/inc/editsh.hxx              |   10 +++++-----
 sw/source/core/edit/edattr.cxx |    6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 392460e..a7110a9 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -325,23 +325,23 @@ public:
     sal_uInt16 GetTxtFmtCollCount() const;
     SwTxtFmtColl& GetTxtFmtColl( sal_uInt16 nTxtFmtColl) const;
     /**
-     * Get the named character format of the current selection.
+     * Get the named paragraph format of the current selection.
      *
      * @see GetPaMTxtFmtColl()
      *
-     * @return the named character format of the first node that contains one.
+     * @return the named paragraph format of the first node that contains one.
      * Nodes are sort by order of appearance in the selections ;
      * selections are sort by their order of creation
      * (last created selection first, oldest selection at last).
      */
     SwTxtFmtColl* GetCurTxtFmtColl() const;
     /**
-     * Get the named character format of the selection(s) described by a SwPaM.
+     * Get the named paragraph format of the selection(s) described by a SwPaM.
      *
      * @param pPaM
-     * input parameter - the selection where to look for the character format.
+     * input parameter - the selection where to look for the paragraph format.
      *
-     * @return the named character format of the first node that contains one.
+     * @return the named paragraph format of the first node that contains one.
      */
     SwTxtFmtColl* GetPaMTxtFmtColl( SwPaM* pPaM ) const;
 
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index a604cbc..b690c62 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -268,17 +268,17 @@ SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
 
             if( pNd->IsTxtNode() )
             {
-                // if it's a text node get its named character format
+                // if it's a text node get its named paragraph format
                 SwTxtFmtColl* pFmt = static_cast<SwTxtNode*>(pNd)->GetTxtColl();
 
-                // if the character format exist stop here and return it
+                // if the paragraph format exist stop here and return it
                 if( pFmt != NULL )
                     return pFmt;
             }
         }
     } while ( ( pPaM = static_cast<SwPaM*>(pPaM->GetNext()) ) != pStartPaM );
 
-    // if none of the selected node contain a named character format
+    // if none of the selected node contain a named paragraph format
     return NULL;
 }
 
-- 
1.7.9.4

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to