Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hello

0001-add-SCWARN_EXPORT_MAXTAB-and-SCWARN_EXPORT_MAXCOL.patch
Add warning in the xls export filter in order to display different
messages when the number of column, row or tab are too high.

0002-rewrite-and-comment-SwEditShell-GetPaMTxtFmtColl.patch
comment, doxygen description, and rewrite of
SwEditShell::GetPaMTxtFmtColl and SwEditShell::GetCurTxtFmtColl.
Doesn't change the behavior of the functions.

0003-getMaxLookup-in-SwEditShell-GetPaMTxtFmtColl.patch
Handle getMaxLookup in SwEditShell::GetPaMTxtFmtColl.
getMaxLookup become the maximum number of nodes to inspect.
The function stop when it has inspect getMaxLookup nodes instead of
stopping (approximately) when it as to inspect more than getMaxLookup
nodes.

0004-SwEditShell-use-of-the-STL-swap-function.patch
Us of the swap STL function in the file sw/source/core/edit/edattr.cxx

Feel free to comment my code !

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


From 17a07d3c910a812f2dd0537d3a1e454ae9f06881 Mon Sep 17 00:00:00 2001
From: Maxime de Roucy <mderoucy@linagora.com>
Date: Thu, 8 Mar 2012 14:49:58 +0100
Subject: [PATCH 1/4] add SCWARN_EXPORT_MAXTAB and SCWARN_EXPORT_MAXCOL

Create separate warnings when the maximum number of row, columns or
sheets is reach in the export filter to xls forma.
---
 sc/inc/scerrors.hxx               |    4 +++-
 sc/source/filter/excel/expop2.cxx |    7 +++++--
 sc/source/ui/src/scerrors.src     |    8 ++++++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/sc/inc/scerrors.hxx b/sc/inc/scerrors.hxx
index 735f7ba..fc6b9cb 100644
--- a/sc/inc/scerrors.hxx
+++ b/sc/inc/scerrors.hxx
@@ -68,7 +68,9 @@
 #define SCWARN_EXPORT_NONCONVERTIBLE_CHARS  (   1 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
 #define SCWARN_EXPORT_ASCII         (   2 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
 #define SCWARN_EXPORT_MAXROW        (   3 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
-#define SCWARN_EXPORT_DATALOST      (   4 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
+#define SCWARN_EXPORT_MAXCOL        (   4 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
+#define SCWARN_EXPORT_MAXTAB        (   5 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
+#define SCWARN_EXPORT_DATALOST      (   6 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
 
 // ERRCODE_CLASS_GENERAL
 #define SCWARN_CORE_HARD_RECALC     (   1 | ERRCODE_CLASS_GENERAL | ERRCODE_WARNING_MASK | 
ERRCODE_AREA_SC )
diff --git a/sc/source/filter/excel/expop2.cxx b/sc/source/filter/excel/expop2.cxx
index a8a4ce1..ab31d97 100644
--- a/sc/source/filter/excel/expop2.cxx
+++ b/sc/source/filter/excel/expop2.cxx
@@ -124,10 +124,13 @@ FltError ExportBiff5::Write()
             sfx2::SaveOlePropertySet(xDocProps, xRootStrg );
     }
 
-    //! TODO: separate warnings for columns and sheets
     const XclExpAddressConverter& rAddrConv = GetAddressConverter();
-    if( rAddrConv.IsColTruncated() || rAddrConv.IsRowTruncated() || rAddrConv.IsTabTruncated() )
+    if( rAddrConv.IsRowTruncated() )
         return SCWARN_EXPORT_MAXROW;
+    if( rAddrConv.IsColTruncated() )
+        return SCWARN_EXPORT_MAXCOL;
+    if( rAddrConv.IsTabTruncated() )
+        return SCWARN_EXPORT_MAXTAB;
 
     return eERR_OK;
 }
diff --git a/sc/source/ui/src/scerrors.src b/sc/source/ui/src/scerrors.src
index 2a2e2ad..f77dcf0 100644
--- a/sc/source/ui/src/scerrors.src
+++ b/sc/source/ui/src/scerrors.src
@@ -150,6 +150,14 @@ Resource RID_ERRHDLSC
     {
         Text [ en-US ] = "The document contains more rows than supported in the selected 
format.\nAdditional rows were not saved." ;
     };
+    String SCWARN_EXPORT_MAXCOL & ERRCODE_RES_MASK
+    {
+        Text [ en-US ] = "The document contains more columns than supported in the selected 
format.\nAdditional columns were not saved." ;
+    };
+    String SCWARN_EXPORT_MAXTAB & ERRCODE_RES_MASK
+    {
+        Text [ en-US ] = "The document contains more sheets than supported in the selected 
format.\nAdditional sheets were not saved." ;
+    };
     String SCWARN_IMPORT_INFOLOST & ERRCODE_RES_MASK
     {
         Text [ en-US ] = "The document contains information not recognized by this program 
version.\nResaving the document will delete this information!" ;
-- 
1.7.9.4

From 31b7640f7137964916062e64fca18869a18f5118 Mon Sep 17 00:00:00 2001
From: Maxime de Roucy <mderoucy@linagora.com>
Date: Tue, 13 Mar 2012 16:20:59 +0100
Subject: [PATCH 2/4] rewrite and comment SwEditShell::GetPaMTxtFmtColl

Classe SwEditShell.
Add some doxygen description for GetCurTxtFmtColl and GetPaMTxtFmtColl.
Rewrite of GetPaMTxtFmtColl in order to comment and simplify the code.
---
 sw/inc/editsh.hxx              |   18 ++++++++++++++++++
 sw/source/core/edit/edattr.cxx |   38 ++++++++++++++++++++------------------
 2 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index f6ba735..02b61f1 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -295,7 +295,25 @@ public:
     SwTxtFmtColl& GetDfltTxtFmtColl() const;
     sal_uInt16 GetTxtFmtCollCount() const;
     SwTxtFmtColl& GetTxtFmtColl( sal_uInt16 nTxtFmtColl) const;
+    /**
+     * Get the named character format of the current selection.
+     *
+     * @see GetPaMTxtFmtColl()
+     *
+     * @return the named character 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.
+     *
+     * @param pPaM
+     * input parameter - the selection where to look for the character format.
+     *
+     * @return the named character format of the first node that contains one.
+     */
     SwTxtFmtColl* GetPaMTxtFmtColl( SwPaM* pPaM ) const;
 
     // #i62675#
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 441ff2c..35f80c6 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -182,44 +182,46 @@ SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl( ) const
 
 SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
 {
-    SwTxtFmtColl *pFmt = 0;
-
     if ( GetCrsrCnt() > getMaxLookup() )
-        return 0;
+        return NULL;
 
     SwPaM* pStartPaM = pPaM;
-    do {
+    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();
-        xub_StrLen nSttCnt = pPaM->GetMark()->nContent.GetIndex(),
-                   nEndCnt = pPaM->GetPoint()->nContent.GetIndex();
 
-        if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
+        // reverse start and end if they aren't sorted correctly
+        if( nSttNd > nEndNd )
         {
-            sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
-            nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (xub_StrLen)nTmp;
+            sal_uLong tmpNd = nSttNd;
+            nSttNd = nEndNd;
+            nEndNd = tmpNd;
         }
 
         if( nEndNd - nSttNd >= getMaxLookup() )
-        {
-            pFmt = 0;
             break;
-        }
 
+        // for all the nodes in the current Point and Mark
         for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
         {
+            // get the node
             SwNode* pNd = GetDoc()->GetNodes()[ n ];
             if( pNd->IsTxtNode() )
             {
-                if( !pFmt )
-                    pFmt = ((SwTxtNode*)pNd)->GetTxtColl();
-                else if( pFmt == ((SwTxtNode*)pNd)->GetTxtColl() ) // ???
-                    break;
+                // if it's a text node get its named character format
+                SwTxtFmtColl* pFmt = static_cast<SwTxtNode*>(pNd)->GetTxtColl();
+
+                // if the character format exist stop here and return it
+                if( pFmt != NULL )
+                    return pFmt;
             }
         }
-    } while ( ( pPaM = ( SwPaM* )pPaM->GetNext() ) != pStartPaM );
+    } while ( ( pPaM = static_cast<SwPaM*>(pPaM->GetNext()) ) != pStartPaM );
 
-    return pFmt;
+    // if none of the selected node contain a named character format
+    return NULL;
 }
 
 
-- 
1.7.9.4

From ec9f5e9cdae263766f48a6cba8fb504df65cfd99 Mon Sep 17 00:00:00 2001
From: Maxime de Roucy <mderoucy@linagora.com>
Date: Tue, 13 Mar 2012 16:54:39 +0100
Subject: [PATCH 3/4] getMaxLookup in SwEditShell::GetPaMTxtFmtColl

Handle getMaxLookup as the maximum number of node to inspect.
---
 sw/source/core/edit/edattr.cxx |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 35f80c6..59356d6 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -72,6 +72,7 @@ const sal_uInt16& getMaxLookup()
 sal_Bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
                               const bool bMergeIndentValuesOfNumRule ) const
 {
+    // ??? pPaM can be different from the Cursor ???
     if( GetCrsrCnt() > getMaxLookup() )
     {
         rSet.InvalidateAllItems();
@@ -182,8 +183,8 @@ SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl( ) const
 
 SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
 {
-    if ( GetCrsrCnt() > getMaxLookup() )
-        return NULL;
+    // number of nodes the function have explore so far
+    sal_uInt16 numberOfLookup = 0;
 
     SwPaM* pStartPaM = pPaM;
     do { // for all the point and mark (selections)
@@ -200,14 +201,18 @@ SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
             nEndNd = tmpNd;
         }
 
-        if( nEndNd - nSttNd >= getMaxLookup() )
-            break;
-
         // for all the nodes in the current Point and Mark
         for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
         {
             // get the node
             SwNode* pNd = GetDoc()->GetNodes()[ n ];
+
+            ++numberOfLookup;
+
+            // if the maximum number of node that can be inspect has been reach
+            if (numberOfLookup >= getMaxLookup())
+                return NULL;
+
             if( pNd->IsTxtNode() )
             {
                 // if it's a text node get its named character format
-- 
1.7.9.4

From 97f01fd8a11bd3a8f0c9de6a6f1963eaf4e30a3a Mon Sep 17 00:00:00 2001
From: Maxime de Roucy <mderoucy@linagora.com>
Date: Tue, 13 Mar 2012 17:10:55 +0100
Subject: [PATCH 4/4] SwEditShell : use of the STL swap function

---
 sw/inc/editsh.hxx              |    1 +
 sw/source/core/edit/edattr.cxx |   14 ++++----------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 02b61f1..a160b6e 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -44,6 +44,7 @@
 #include <tblenum.hxx>
 #include <IMark.hxx>
 
+#include <algorithm>
 #include <vector>
 #include <set>
 #include <swundo.hxx>
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 59356d6..df6b4cd 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -116,8 +116,8 @@ sal_Bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
 
         if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
         {
-            sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
-            nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (xub_StrLen)nTmp;
+            std::swap(nSttNd, nEndNd);
+            std::swap(nSttCnt, nEndCnt);
         }
 
         if( nEndNd - nSttNd >= getMaxLookup() )
@@ -195,11 +195,7 @@ SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
 
         // reverse start and end if they aren't sorted correctly
         if( nSttNd > nEndNd )
-        {
-            sal_uLong tmpNd = nSttNd;
-            nSttNd = nEndNd;
-            nEndNd = tmpNd;
-        }
+            std::swap(nSttNd, nEndNd);
 
         // for all the nodes in the current Point and Mark
         for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
@@ -343,9 +339,7 @@ sal_Bool SwEditShell::IsMoveLeftMargin( sal_Bool bRight, sal_Bool bModulus ) con
               nEndNd = PCURCRSR->GetPoint()->nNode.GetIndex();
 
         if( nSttNd > nEndNd )
-        {
-            sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
-        }
+            std::swap(nSttNd, nEndNd);
 
         SwCntntNode* pCNd;
         for( sal_uLong n = nSttNd; bRet && n <= nEndNd; ++n )
-- 
1.7.9.4

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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.