[Libreoffice-commits] core.git: sw/source

Maxime de Roucy mderoucy at linagora.com
Tue Mar 5 05:05:56 PST 2013


 sw/source/filter/ww8/ww8par.hxx  |    9 +++++
 sw/source/filter/ww8/ww8par3.cxx |   70 +++++++++++++++++++--------------------
 2 files changed, 44 insertions(+), 35 deletions(-)

New commits:
commit d5405d4c42459304a1152b7a1722a1627f775b07
Author: Maxime de Roucy <mderoucy at linagora.com>
Date:   Wed Feb 6 17:24:29 2013 +0100

    res. bug on numbered paragraph when .doc import
    
    This patch solve an issue on .doc import (on paragraph numbering).
    It was created from the code found in SwDoc::DelNumRules.
    
    To see the problem you can download simple test document :
    wget ftp://craoc.fr/{a,b,c,d}.{doc,png}
    
    Each document contain a paragraph "Test test test2" using Normal/default
    style (this paragraph is imported correctly) and a "Test test test1"
    using nouveau_style paragraph style.
    
    In a.doc no direct paragraph formating are apply to the test1 paragraph.
    a.doc is imported correctly.
    
    To create b.doc, in Microsoft Office Word I opened a.doc, put my cursor
    in front of the first charactère of the test1 paragraph (T) and push
    "backspace".
    The result is that it apply some direct paragraph formating on test1 :
    * disable paragraph numbering
    * apply some indent
    
    To create c.doc I did on b.doc the same things I did to a.doc to create
    b.doc.
    c.doc direct paragraph formating on test1 :
    * disable paragraph numbering
    * apply some (other) indent
    
    To create d.doc I did on c.doc the same things I did to a.doc to create
    b.doc.
    d.doc direct paragraph formating on test1 :
    * disable paragraph numbering
    
    Without this patch, when importing {b,c,d}.doc in Writer :
    The "disable paragraph numbering" direct formating isn't correctly
    apply and test1 remain a numbered paragraph (even if the "dot" in front
    of the paragraph is removed).
    The indent are not correctly apply.
    
    With this patch {a,b,c,d}.doc are correctly imported.
    
    It also reset the left indent of paragraph when the numbering style is
    remove.
    
    Change-Id: If0568f341b82c2e8354f1728e5fc6f1ab310ea51
    Reviewed-on: https://gerrit.libreoffice.org/2046
    Tested-by: LibreOffice gerrit bot <gerrit at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at iki.fi>
    Reviewed-by: Muthu Subramanian K <muthusuba at gmail.com>
    Tested-by: Muthu Subramanian K <muthusuba at gmail.com>

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 0a19e72..f9034e1 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1633,6 +1633,15 @@ public:     // eigentlich private, geht aber leider nur public
                                         // Ver8-Listen
 
     void Read_ListLevel(        sal_uInt16 nId, const sal_uInt8* pData, short nLen);
+
+    /**
+     * read and interpret the sprmPIlfo used to determine which list
+     * contains the paragraph.
+     * @param     nId   unused (sprm value, 0x460b for sprmPIlfo).
+     * @param[in] pData operand.
+     * @param[in] nLen  size of the operand (pData) in byte, should be 2.
+     *                  -1 to indicate the actual level is finished.
+     */
     void Read_LFOPosition(      sal_uInt16 nId, const sal_uInt8* pData, short nLen);
     bool SetTxtFmtCollAndListLevel(const SwPaM& rRg, SwWW8StyInf& rStyleInfo);
 
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index c750221..2f0956e 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1881,15 +1881,17 @@ void SwWW8ImplReader::Read_ListLevel(sal_uInt16, const sal_uInt8* pData,
 
     if( nLen < 0 )
     {
-        // aktuelle Liste ist hier zu Ende, was ist zu tun ???
+        // the actual level is finished, what should we do ?
         nListLevel = WW8ListManager::nMaxLevel;
         if (pStyles && !bVer67)
             pStyles->nWwNumLevel = 0;
     }
     else
     {
-        // Sicherheitspruefung auf NIL Pointer
-        if( !pData ) return;
+        // security check
+        if( !pData )
+            return;
+
         // die Streamdaten sind hier Null basiert, so wie wir es brauchen
         nListLevel = *pData;
 
@@ -1927,67 +1929,65 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData,
 
     if( nLen < 0 )
     {
-        // aktueller Level ist hier zu Ende, was ist zu tun ???
+        // the actual level is finished, what should we do ?
         nLFOPosition = USHRT_MAX;
         nListLevel = WW8ListManager::nMaxLevel;
     }
     else
     {
-        // Sicherheitspruefung auf NIL Pointer
+        // security check
         if( !pData )
             return;
+
         short nData = SVBT16ToShort( pData );
         if( 0 >= nData )
         {
+            // disable the numbering/list style apply to the paragraph or the style
+
             /*
             If you have a paragraph in word with left and/or hanging indent
             and remove its numbering, then the indentation appears to get
             reset, but not back to the base style, instead its goes to a blank
             setting.
             Unless its a broken ww6 list in 97 in which case more hackery is
-            required, some more details about that in
+            required, some more details about broken ww6 list in
             ww8par6.cxx#SwWW8ImplReader::Read_LR
             */
 
             if (pAktColl)
             {
-                pAktColl->SetFmtAttr(*GetDfltAttr( RES_PARATR_NUMRULE));
+                // here a "named" style is beeing configured
+
+                // disable the numbering/list in the style currently configured
+                pAktColl->SetFmtAttr(*GetDfltAttr(RES_PARATR_NUMRULE));
+
+                // reset/blank the indent
                 pAktColl->SetFmtAttr(SvxLRSpaceItem(RES_LR_SPACE));
             }
             else if (SwTxtNode* pTxtNode = pPaM->GetNode()->GetTxtNode())
             {
-                pTxtNode->ResetAttr( RES_PARATR_NUMRULE ); // #i54393#
-                pTxtNode->SetCountedInList(false);
+                // here a paragraph is being directly formated
 
-                /*
-                #i24553#
-                Hmm, I can't remove outline numbering on a per txtnode basis,
-                but I can set some normal numbering, and that overrides outline
-                numbering, and then I can say when I come to say that I want no
-                number on the normal numbering rule, that should all work out
+                // empty the numbering/list style applied to the current paragraph
+                SwNumRuleItem aEmptyRule( aEmptyStr );
+                pTxtNode->SetAttr( aEmptyRule );
 
-                No special outline number in textnode any more
-                */
-                if (pTxtNode->IsOutline())
-                {
-                    // #i54393#
-                    // It's not needed to call <SetCounted( false )> again - see above.
-                    // #i54393#
-                    // Assure that the numbering rule, which is retrieved at
-                    // the paragraph is the outline numbering rule, instead of
-                    // incorrectly setting the chosen outline rule.
-                    // Note: The chosen outline rule doesn't have to correspond
-                    //       to the outline rule
-                    if ( pTxtNode->GetNumRule() != rDoc.GetOutlineNumRule() )
-                    {
-                        pTxtNode->SetAttr(
-                            SwNumRuleItem( rDoc.GetOutlineNumRule()->GetName() ) );
-                    }
-                }
+                // create an empty SvxLRSpaceItem
+                SvxLRSpaceItem aLR( RES_LR_SPACE );
+
+                // replace it with the one of the current node if it exist
+                const SfxPoolItem* pLR = GetFmtAttr(RES_LR_SPACE);
+                if( pLR )
+                    aLR = *static_cast<const SvxLRSpaceItem*>(pLR);
 
-                pCtrlStck->NewAttr(*pPaM->GetPoint(), SvxLRSpaceItem(RES_LR_SPACE));
-                pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_LR_SPACE);
+                // reset/blank the left indent (and only the left)
+                aLR.SetTxtLeft(0);
+                aLR.SetTxtFirstLineOfst(0);
+
+                // apply the modified SvxLRSpaceItem to the current paragraph
+                pTxtNode->SetAttr( aLR );
             }
+
             nLFOPosition = USHRT_MAX;
         }
         else


More information about the Libreoffice-commits mailing list