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


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2046

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/46/2046/1

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
---
M sw/source/filter/ww8/ww8par.hxx
M sw/source/filter/ww8/ww8par3.cxx
2 files changed, 44 insertions(+), 35 deletions(-)



diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 8ff035e..0296994 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1635,6 +1635,15 @@
                                         // 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 0b9de03..343c098 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1881,15 +1881,17 @@
 
     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 @@
 
     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 );
 
-                pCtrlStck->NewAttr(*pPaM->GetPoint(), SvxLRSpaceItem(RES_LR_SPACE));
-                pCtrlStck->SetAttr(*pPaM->GetPoint(), 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);
+
+                // 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

-- 
To view, visit https://gerrit.libreoffice.org/2046
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If0568f341b82c2e8354f1728e5fc6f1ab310ea51
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Maxime de Roucy <mderoucy@linagora.com>

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.