You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2014/07/08 17:08:10 UTC

svn commit: r1608825 - in /openoffice/branches/AOO410: ./ main/ main/sw/ main/sw/source/filter/rtf/ main/sw/source/filter/ww8/ main/sw/source/filter/xml/

Author: orw
Date: Tue Jul  8 15:08:09 2014
New Revision: 1608825

URL: http://svn.apache.org/r1608825
Log:
78498:  WW8 import - improvements/corrections regarding outline level & Co
	- import outline level attribute at Paragraph Styles
	- import outline level attribute at paragraphs
	- refactor code to apply list level properties to Outline Style
	-- only consider WW8 list styles applied to WW8 Built-in Heading Styles
	-- only assign AOO counterparts of WW8 Built-in Heading Styles to Outline Style

	cherry-picked - from trunk


Modified:
    openoffice/branches/AOO410/   (props changed)
    openoffice/branches/AOO410/main/   (props changed)
    openoffice/branches/AOO410/main/sw/   (props changed)
    openoffice/branches/AOO410/main/sw/source/filter/rtf/swparrtf.cxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.cxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.hxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.cxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.hxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par3.cxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par5.cxx
    openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx
    openoffice/branches/AOO410/main/sw/source/filter/xml/swxml.cxx

Propchange: openoffice/branches/AOO410/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1606061

Propchange: openoffice/branches/AOO410/main/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main:r1606061

Propchange: openoffice/branches/AOO410/main/sw/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main/sw:r1606061

Modified: openoffice/branches/AOO410/main/sw/source/filter/rtf/swparrtf.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/rtf/swparrtf.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/rtf/swparrtf.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/rtf/swparrtf.cxx Tue Jul  8 15:08:09 2014
@@ -3931,13 +3931,12 @@ SwTxtFmtColl* SwRTFParser::MakeColl(cons
         if( !nPos )
         {
             pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
-			//pColl->SetOutlineLevel( nOutlineLevel );		//#outline level,removed by zhaojianwei
-			if(nOutlineLevel < MAXLEVEL )							//->add by zhaojianwei
-				pColl->AssignToListLevelOfOutlineStyle( nOutlineLevel );
-			else
-				pColl->DeleteAssignmentToListLevelOfOutlineStyle();	//<-end,zhaojianwei
-			return pColl;
-		}
+            if ( nOutlineLevel < MAXLEVEL )
+                pColl->AssignToListLevelOfOutlineStyle( nOutlineLevel );
+            else
+                pColl->DeleteAssignmentToListLevelOfOutlineStyle();
+            return pColl;
+        }
 
 		// erzeuge einen Namen
 		aNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NoName(" ));

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.cxx Tue Jul  8 15:08:09 2014
@@ -3791,7 +3791,6 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uIn
     mpDrawEditEngine = 0;
     pWWZOrder = 0;
     pFormImpl = 0;
-    mpChosenOutlineNumRule = 0;
     pNumFldType = 0;
     nFldNum = 0;
 
@@ -4448,7 +4447,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8G
     pStyles->PostProcessStyles();
 
     if (pCollA)
-        SetOutLineStyles();
+        SetOutlineStyles();
 
     pSBase = new WW8ScannerBase(pStrm,pTableStream,pDataStream,pWwFib);
 
@@ -5185,178 +5184,135 @@ public:
     }
 };
 
-void SwWW8ImplReader::SetOutLineStyles()
+
+void SwWW8ImplReader::SetOutlineStyles()
 {
-    /*
-    #i3674# - Load new document and insert document cases.
-    */
-    SwNumRule aOutlineRule(*rDoc.GetOutlineNumRule());
-    // #i53044,i53213#
-    // <mpChosenOutlineNumRule> has to be set to point to local variable
-    // <aOutlineRule>, because its used below to be compared this <&aOutlineRule>.
-    // But at the end of the method <mpChosenOutlineNumRule> has to be set to
-    // <rDoc.GetOutlineNumRule()>, because <aOutlineRule> will be destroyed.
-    mpChosenOutlineNumRule = &aOutlineRule;
-
-    sw::ParaStyles aOutLined(sw::util::GetParaStyles(rDoc));
-    // #i98791# - sorting algorithm adjusted
-    sw::util::SortByAssignedOutlineStyleListLevel(aOutLined);
 
-    typedef sw::ParaStyleIter myParaStyleIter;
-    /*
-    If we are inserted into a document then don't clobber existing existing
-    levels.
-    */
-    sal_uInt16 nFlagsStyleOutlLevel = 0;
-    if (!mbNewDoc)
+    // If we are inserted into a document then don't clobber existing outline levels.
+    sal_uInt16 nOutlineStyleListLevelWithAssignment = 0;
+    if ( !mbNewDoc )
     {
-        // #i70748# - backward iteration needed due to the outline level attribute
+        sw::ParaStyles aOutLined( sw::util::GetParaStyles( rDoc ) );
+        sw::util::SortByAssignedOutlineStyleListLevel( aOutLined );
         sw::ParaStyles::reverse_iterator aEnd = aOutLined.rend();
-        for ( sw::ParaStyles::reverse_iterator aIter = aOutLined.rbegin(); aIter < aEnd; ++aIter)
+        for ( sw::ParaStyles::reverse_iterator aIter = aOutLined.rbegin(); aIter < aEnd; ++aIter )
         {
-            if ((*aIter)->IsAssignedToListLevelOfOutlineStyle())
-                nFlagsStyleOutlLevel |= 1 << (*aIter)->GetAssignedOutlineStyleLevel();
+            if ( ( *aIter )->IsAssignedToListLevelOfOutlineStyle() )
+                nOutlineStyleListLevelWithAssignment |= 1 << ( *aIter )->GetAssignedOutlineStyleLevel();
             else
                 break;
         }
     }
-    else
+
+    // Check applied WW8 list styles at WW8 Built-In Heading Styles
+    // - Choose the list style which occurs most often as the one which provides
+    //   the list level properties for the Outline Style.
+    // - Populate temporary list of WW8 Built-In Heading Styles for further iteration
+    std::vector< SwWW8StyInf* > aWW8BuiltInHeadingStyles;
+    const SwNumRule* pChosenWW8ListStyle = NULL;
     {
-        /*
-        Only import *one* of the possible multiple outline numbering rules, so
-        pick the one that affects most styles. If we're not importing a new
-        document, we got to stick with what is already there.
-        */
-        // use index in text format collection
-        // array <pCollA> as key of the outline numbering map <aRuleMap>
-        // instead of the memory pointer of the outline numbering rule
-        // to assure that, if two outline numbering rule affect the same
-        // count of text formats, always the same outline numbering rule is chosen.
-        std::map<sal_uInt16, int>aRuleMap;
-        typedef std::map<sal_uInt16, int>::iterator myIter;
-        for (sal_uInt16 nI = 0; nI < nColls; ++nI)
+        std::map< const SwNumRule*, int > aWW8ListStyleCounts;
+        for ( sal_uInt16 nI = 0; nI < nColls; ++nI )
         {
-            SwWW8StyInf& rSI = pCollA[ nI ];
-            if (
-                (MAXLEVEL > rSI.nOutlineLevel) && rSI.pOutlineNumrule &&
-                rSI.pFmt
-               )
+            SwWW8StyInf& rSI = pCollA[nI];
+
+            if ( !rSI.IsWW8BuiltInHeadingStyle()
+                 || !rSI.HasWW8OutlineLevel() )
             {
-                myIter aIter = aRuleMap.find(nI);
-                if (aIter == aRuleMap.end())
-                {
-                    aRuleMap[nI] = 1;
-                }
-                else
-                    ++(aIter->second);
+                continue;
             }
-        }
 
-        int nMax = 0;
-        myIter aEnd2 = aRuleMap.end();
-        for (myIter aIter = aRuleMap.begin(); aIter != aEnd2; ++aIter++)
-        {
-            if (aIter->second > nMax)
+            aWW8BuiltInHeadingStyles.push_back( &rSI );
+
+            const SwNumRule* pWW8ListStyle = rSI.GetOutlineNumrule();
+            if ( pWW8ListStyle != NULL )
             {
-                nMax = aIter->second;
-                mpChosenOutlineNumRule = pCollA[ aIter->first ].pOutlineNumrule;
+                std::map< const SwNumRule*, int >::iterator aCountIter =
+                        aWW8ListStyleCounts.find( pWW8ListStyle );
+                if ( aCountIter == aWW8ListStyleCounts.end() )
+                {
+                    aWW8ListStyleCounts[pWW8ListStyle] = 1;
+                }
+                else
+                {
+                    ++(aCountIter->second);
+                }
             }
         }
 
-        ASSERT(mpChosenOutlineNumRule, "Impossible");
-        if (mpChosenOutlineNumRule)
-            aOutlineRule = *mpChosenOutlineNumRule;
-
-        if (mpChosenOutlineNumRule != &aOutlineRule)
+        int nCurrentMaxCount = 0;
+        std::map< const SwNumRule*, int >::iterator aCountIterEnd =
+            aWW8ListStyleCounts.end();
+        for ( std::map< const SwNumRule*, int >::iterator aIter = aWW8ListStyleCounts.begin();
+              aIter != aCountIterEnd;
+              ++aIter )
         {
-            // #i70748# - backward iteration needed due to the outline level attribute
-            sw::ParaStyles::reverse_iterator aEnd = aOutLined.rend();
-            for ( sw::ParaStyles::reverse_iterator aIter = aOutLined.rbegin(); aIter < aEnd; ++aIter)
+            if ( aIter->second > nCurrentMaxCount )
             {
-                if((*aIter)->IsAssignedToListLevelOfOutlineStyle())
-                    (*aIter)->DeleteAssignmentToListLevelOfOutlineStyle();
-
-                else
-                    break;
+                nCurrentMaxCount = aIter->second;
+                pChosenWW8ListStyle = aIter->first;
             }
         }
     }
 
-    sal_uInt16 nOldFlags = nFlagsStyleOutlLevel;
+    if ( pChosenWW8ListStyle == NULL )
+    {
+        // no WW8 list style for Outline Style found --> nothing to do
+        return;
+    }
 
-    for (sal_uInt16 nI = 0; nI < nColls; ++nI)
+    // - set list level properties of Outline Style - ODF's list style applied by default to headings
+    // - assign corresponding Heading Paragraph Styles to the Outline Style
+    // - If a heading Paragraph Styles is not applying the WW8 list style which had been chosen as
+    //   the one which provides the list level properties for the Outline Style, its assignment to
+    //   the Outline Style is removed and a potential applied WW8 list style is assigned directly.
+    SwNumRule aOutlineRule( *rDoc.GetOutlineNumRule() );
+    bool bAppliedChangedOutlineStyle = false;
+    std::vector< SwWW8StyInf* >::iterator aStylesIterEnd =
+        aWW8BuiltInHeadingStyles.end();
+    for ( std::vector< SwWW8StyInf* >::iterator aStyleIter = aWW8BuiltInHeadingStyles.begin();
+          aStyleIter != aStylesIterEnd;
+          ++aStyleIter )
     {
-        SwWW8StyInf& rSI = pCollA[nI];
+        SwWW8StyInf* pStyleInf = (*aStyleIter);
 
-        if (rSI.IsOutlineNumbered())
+        const sal_uInt16 nOutlineStyleListLevelOfWW8BuiltInHeadingStyle = 1 << pStyleInf->mnWW8OutlineLevel;
+        if ( nOutlineStyleListLevelOfWW8BuiltInHeadingStyle & nOutlineStyleListLevelWithAssignment )
         {
-            sal_uInt16 nAktFlags = 1 << rSI.nOutlineLevel;
-            if (
-                 (nAktFlags & nFlagsStyleOutlLevel) ||
-                 (rSI.pOutlineNumrule != mpChosenOutlineNumRule)
-               )
-            {
-                /*
-                If our spot is already taken by something we can't replace
-                then don't insert and remove our outline level.
-                */
-                rSI.pFmt->SetFmtAttr(
-                        SwNumRuleItem( rSI.pOutlineNumrule->GetName() ) );
-				//((SwTxtFmtColl*)rSI.pFmt)->SetOutlineLevel(NO_NUMBERING);
-                ((SwTxtFmtColl*)rSI.pFmt)->DeleteAssignmentToListLevelOfOutlineStyle();//#outline level,zhaojianwei
-            }
-            else
-            {
-                /*
-                If there is a style already set for this outline
-                numbering level and its not a style set by us already
-                then we can remove it outline numbering.
-                (its one of the default headings in a new document
-                so we can clobber it)
-                Of course if we are being inserted into a document that
-                already has some set we can't do this, thats covered by
-                the list of level in nFlagsStyleOutlLevel to ignore.
-                */
-                outlineeq aCmp(rSI.nOutlineLevel);
-                myParaStyleIter aResult = std::find_if(aOutLined.begin(),
-                    aOutLined.end(), aCmp);
-
-                myParaStyleIter aEnd = aOutLined.end();
-                while (aResult != aEnd  && aCmp(*aResult))
-                {
-                    //(*aResult)->SetOutlineLevel(NO_NUMBERING);//#outline level,zhaojianwei
-					(*aResult)->DeleteAssignmentToListLevelOfOutlineStyle();
-                    ++aResult;
-                }
+            continue;
+        }
 
-                /*
-                #i1886#
-                I believe that when a list is registered onto a winword
-                style which is an outline numbering style (i.e.
-                nOutlineLevel is set) that the style of numbering is for
-                the level is indexed by the *list* level that was
-                registered on that style, and not the outlinenumbering
-                level, which is probably a logical sequencing, and not a
-                physical mapping into the list style reged on that outline
-                style.
-                */
-                sal_uInt8 nFromLevel = rSI.nListLevel;
-                sal_uInt8 nToLevel = rSI.nOutlineLevel;
-                const SwNumFmt& rRule=rSI.pOutlineNumrule->Get(nFromLevel);
-                aOutlineRule.Set(nToLevel, rRule);
-                // Set my outline level
-                //((SwTxtFmtColl*)rSI.pFmt)->SetOutlineLevel(nToLevel);//#outline level,zhaojianwei
-				((SwTxtFmtColl*)rSI.pFmt)->AssignToListLevelOfOutlineStyle(nToLevel);	//<-end,zhaojianwei
-                // If there are more styles on this level ignore them
-                nFlagsStyleOutlLevel |= nAktFlags;
+#if OSL_DEBUG_LEVEL > 1
+        ASSERT( pStyleInf->mnWW8OutlineLevel == pStyleInf->nListLevel,
+                "WW8 import - <SwWW8ImplReader::SetOutlineStyles()> - it is not expected that WW8 Built-In Heading styles have different outline level and list level" );
+#endif
+        const SwNumFmt& rRule = pChosenWW8ListStyle->Get( pStyleInf->mnWW8OutlineLevel );
+        aOutlineRule.Set( pStyleInf->mnWW8OutlineLevel, rRule );
+        bAppliedChangedOutlineStyle = true;
+        // in case that there are more styles on this level ignore them
+        nOutlineStyleListLevelWithAssignment |= nOutlineStyleListLevelOfWW8BuiltInHeadingStyle;
+
+        SwTxtFmtColl* pTxtFmtColl = static_cast<SwTxtFmtColl*>(pStyleInf->pFmt);
+        if ( pStyleInf->GetOutlineNumrule() != pChosenWW8ListStyle )
+        {
+            // WW8 Built-In Heading Style does not apply the chosen one.
+            // --> delete assignment to OutlineStyle, but keep its current outline level
+            pTxtFmtColl->DeleteAssignmentToListLevelOfOutlineStyle( false );
+            // Apply existing WW8 list style a normal list style at the Paragraph Style
+            if ( pStyleInf->GetOutlineNumrule() != NULL )
+            {
+                pTxtFmtColl->SetFmtAttr( SwNumRuleItem( pStyleInf->GetOutlineNumrule()->GetName() ) );
             }
         }
+        else
+        {
+            pTxtFmtColl->AssignToListLevelOfOutlineStyle( pStyleInf->mnWW8OutlineLevel );
+        }
     }
-    if (nOldFlags != nFlagsStyleOutlLevel)
-        rDoc.SetOutlineNumRule(aOutlineRule);
-    if ( mpChosenOutlineNumRule == &aOutlineRule )
+
+    if ( bAppliedChangedOutlineStyle )
     {
-        mpChosenOutlineNumRule = rDoc.GetOutlineNumRule();
+        rDoc.SetOutlineNumRule(aOutlineRule);
     }
 }
 

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.hxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.hxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par.hxx Tue Jul  8 15:08:09 2014
@@ -301,7 +301,12 @@ public:
 
     void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
 
-    virtual void SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand=LONG_MAX, sal_Bool consumedByField=sal_False);
+    virtual void SetAttr(
+        const SwPosition& rPos,
+        sal_uInt16 nAttrId = 0,
+        sal_Bool bTstEnde = sal_True,
+        long nHand = LONG_MAX,
+        sal_Bool consumedByField = sal_False );
 
 	void SetToggleAttr(sal_uInt8 nId, bool bOn)
     {
@@ -1032,14 +1037,6 @@ private:
     std::stack<rtl_TextEncoding> maFontSrcCharSets;
     std::stack<rtl_TextEncoding> maFontSrcCJKCharSets;
 
-    /*
-     Winword numbering gets imported as SwNumRules, there is a problem that
-     winword can have multiple outline numberings, only one gets chosen as
-     the writer outline numbering rule. The one that gets chosen is set here
-     as mpChosenOutlineNumRule
-    */
-    SwNumRule *mpChosenOutlineNumRule;
-
     SwMSConvertControls *pFormImpl; // Control-Implementierung
 
     SwFlyFrmFmt* pFlyFmtOfJustInsertedGraphic;
@@ -1500,8 +1497,11 @@ private:
 
 // Ver8-Listen
 
-    void RegisterNumFmtOnTxtNode(sal_uInt16 nActLFO, sal_uInt8 nActLevel,
-        bool bSetAttr = true);
+    void RegisterNumFmtOnTxtNode(
+        sal_uInt16 nActLFO,
+        sal_uInt8 nActLevel,
+        const bool bSetAttr = true );
+
     void RegisterNumFmtOnStyle(sal_uInt16 nStyle);
     void SetStylesList(sal_uInt16 nStyle, sal_uInt16 nActLFO,
         sal_uInt8 nActLevel);
@@ -1537,7 +1537,7 @@ private:
     SwTwips MoveOutsideFly(SwFrmFmt *pFlyFmt, const SwPosition &rPos,
         bool bTableJoin = true);
 
-    void SetOutLineStyles();
+    void SetOutlineStyles();
 
     bool SetSpacing(SwPaM &rMyPam, int nSpace, bool bIsUpper);
     bool SetUpperSpacing(SwPaM &pMyPam, int nSpace);
@@ -1700,7 +1700,6 @@ public:     // eigentlich private, geht 
     eF_ResT Read_F_NoteReference( WW8FieldDesc* pF, String& rStr );
 
     eF_ResT Read_F_Tox( WW8FieldDesc* pF, String& rStr );
-    bool AddExtraOutlinesAsExtraStyles(SwTOXBase& rBase);
     eF_ResT Read_F_Symbol( WW8FieldDesc*, String& rStr );
     eF_ResT Read_F_Embedd( WW8FieldDesc*, String& rStr );
     eF_ResT Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr);

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.cxx Tue Jul  8 15:08:09 2014
@@ -833,8 +833,7 @@ void SwWW8ImplReader::Read_ANLevelNo( sa
             {
                 nSwNumLevel = *pData - 1;
                 if (!bNoAttrImport)
-                    //((SwTxtFmtColl*)pAktColl)->SetOutlineLevel( nSwNumLevel );	//#outline level,zhaojianwei
-					((SwTxtFmtColl*)pAktColl)->AssignToListLevelOfOutlineStyle( nSwNumLevel ); //<-end,zhaojianwei
+                    ( (SwTxtFmtColl*) pAktColl )->AssignToListLevelOfOutlineStyle( nSwNumLevel );
                     // Bei WW-NoNumbering koennte auch NO_NUMBERING gesetzt
                     // werden. ( Bei normaler Nummerierung muss NO_NUM gesetzt
                     // werden: NO_NUM : Nummerierungs-Pause,
@@ -4036,7 +4035,7 @@ bool WW8RStyle::PrepareStyle(SwWW8StyInf
             rSI.eCJKFontSrcCharSet = pj->eCJKFontSrcCharSet;
             rSI.n81Flags = pj->n81Flags;
             rSI.n81BiDiFlags = pj->n81BiDiFlags;
-            rSI.nOutlineLevel = pj->nOutlineLevel;
+            rSI.mnWW8OutlineLevel = pj->mnWW8OutlineLevel;
             rSI.bParaAutoBefore = pj->bParaAutoBefore;
             rSI.bParaAutoAfter = pj->bParaAutoAfter;
 

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.hxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.hxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par2.hxx Tue Jul  8 15:08:09 2014
@@ -129,6 +129,8 @@ class SwWW8StyInf
 {
     String      sWWStyleName;
     sal_uInt16      nWWStyleId;
+
+
 public:
     rtl_TextEncoding eLTRFontSrcCharSet;    // rtl_TextEncoding fuer den Font
     rtl_TextEncoding eRTLFontSrcCharSet;    // rtl_TextEncoding fuer den Font
@@ -141,7 +143,15 @@ public:
     sal_uInt16      nFollow;
     sal_uInt16      nLFOIndex;
     sal_uInt8        nListLevel;
-    sal_uInt8        nOutlineLevel;      // falls Gliederungs-Style
+
+    // WW8 outline level is zero-based:
+    // 0: outline level 1
+    // 1: outline level 2
+    // ...
+    // 8: outline level 9
+    // 9: body text
+    sal_uInt8        mnWW8OutlineLevel;
+
     sal_uInt16  n81Flags;           // Fuer Bold, Italic, ...
     sal_uInt16  n81BiDiFlags;       // Fuer Bold, Italic, ...
     SvxLRSpaceItem maWordLR;
@@ -173,7 +183,7 @@ public:
         nFollow( 0 ),
         nLFOIndex( USHRT_MAX ),
         nListLevel(WW8ListManager::nMaxLevel),
-        nOutlineLevel( MAXLEVEL ),
+        mnWW8OutlineLevel( MAXLEVEL ),
         n81Flags( 0 ),
         n81BiDiFlags(0),
         maWordLR( RES_LR_SPACE ),
@@ -199,25 +209,61 @@ public:
         sWWStyleName = rName;
         nWWStyleId = nId;
     }
-    sal_uInt16 GetWWStyleId() const { return nWWStyleId; }
+
     const String& GetOrgWWName() const
     {
         return sWWStyleName;
     }
-    bool IsOutline() const
+
+    bool HasWW8OutlineLevel() const
     {
-        return (pFmt && (MAXLEVEL > nOutlineLevel));
+        return ( pFmt != NULL && (MAXLEVEL > mnWW8OutlineLevel) );
     }
+
     bool IsOutlineNumbered() const
     {
-        return pOutlineNumrule && IsOutline();
+        return pOutlineNumrule != NULL && HasWW8OutlineLevel();
     }
+
     const SwNumRule* GetOutlineNumrule() const
     {
         return pOutlineNumrule;
     }
+
     CharSet GetCharSet() const;
     CharSet GetCJKCharSet() const;
+
+    inline sal_uInt16 GetWWStyleId() const
+    {
+        return nWWStyleId;
+    }
+
+    inline bool IsWW8BuiltInHeadingStyle()
+    {
+        return GetWWStyleId() >= 1 && GetWWStyleId() <= 9;
+    }
+
+    inline bool IsWW8BuiltInDefaultStyle()
+    {
+        return GetWWStyleId() == 0;
+    }
+
+    static sal_uInt8 WW8OutlineLevelToOutlinelevel( const sal_uInt8 nWW8OutlineLevel )
+    {
+        if ( nWW8OutlineLevel < MAXLEVEL )
+        {
+            if ( nWW8OutlineLevel == 9 )
+            {
+                return 0; // no outline level --> body text
+            }
+            else
+            {
+                return nWW8OutlineLevel + 1; // outline level 1..9
+            }
+        }
+
+        return 0;
+    }
 };
 
 class WW8RStyle: public WW8Style

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par3.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par3.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par3.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par3.cxx Tue Jul  8 15:08:09 2014
@@ -1738,24 +1738,24 @@ bool SwWW8ImplReader::SetTxtFmtCollAndLi
     bool bRes = true;
     if( rStyleInfo.pFmt && rStyleInfo.bColl )
     {
-        bRes = rDoc.SetTxtFmtColl(rRg, (SwTxtFmtColl*)rStyleInfo.pFmt)
-            ? true : false;
+        bRes = rDoc.SetTxtFmtColl(rRg, (SwTxtFmtColl*)rStyleInfo.pFmt) ? true : false;
         SwTxtNode* pTxtNode = pPaM->GetNode()->GetTxtNode();
-        ASSERT( pTxtNode, "No Text-Node at PaM-Position" );
-        // --> OD 2006-10-19 #134160# - make code robust
-        if ( !pTxtNode )
+        ASSERT( pTxtNode != NULL, "No Text-Node at PaM-Position" );
+        if ( pTxtNode == NULL )
         {
+            // make code robust
             return bRes;
         }
-        // <--
 
-        SwNumRule * pNumRule = pTxtNode->GetNumRule(); // #i27610#
+        const SwNumRule * pNumRule = pTxtNode->GetNumRule(); // #i27610#
 
-        if( !IsInvalidOrToBeMergedTabCell() &&
-            ! (pNumRule && pNumRule->IsOutlineRule()) ) // #i27610#
+        if( !IsInvalidOrToBeMergedTabCell()
+            && ! (pNumRule && pNumRule->IsOutlineRule()) ) // #i27610#
+        {
             pTxtNode->ResetAttr( RES_PARATR_NUMRULE );
+        }
 
-        if( !rStyleInfo.pOutlineNumrule )
+        if ( rStyleInfo.GetOutlineNumrule() == NULL )
         {
             if (
                  (USHRT_MAX > rStyleInfo.nLFOIndex) &&
@@ -1766,19 +1766,6 @@ bool SwWW8ImplReader::SetTxtFmtCollAndLi
                     rStyleInfo.nListLevel, false);
             }
         }
-        else
-        {
-            // --> OD 2005-11-07 #127520#
-            // Use outline level set at the style info <rStyleInfo> instead of
-            // the outline level at the text format, because the WW8 document
-            // could contain more than one outline numbering rule and the one
-            // of the text format isn't the one, which a chosen as the Writer
-            // outline rule.
-//            pTxtNode->
-//                SetLevel(((SwTxtFmtColl*) rStyleInfo.pFmt)->GetOutlineLevel());
-            pTxtNode->SetAttrListLevel( rStyleInfo.nOutlineLevel );
-            // <--
-        }
     }
     return bRes;
 }
@@ -1865,25 +1852,27 @@ void SwWW8ImplReader::RegisterNumFmtOnSt
 
         // Phase 2: aktualisieren der StyleDef nach einlesen aller Listen
         SwNumRule* pNmRule = 0;
-        sal_uInt16 nLFO = rStyleInf.nLFOIndex;
-        sal_uInt8  nLevel = rStyleInf.nListLevel;
+        const sal_uInt16 nLFO = rStyleInf.nLFOIndex;
+        const sal_uInt8  nLevel = rStyleInf.nListLevel;
         if (
              (USHRT_MAX > nLFO) &&
              (WW8ListManager::nMaxLevel > nLevel)
            )
         {
             std::vector<sal_uInt8> aParaSprms;
-            pNmRule = pLstManager->GetNumRuleForActivation(nLFO, nLevel,
-                aParaSprms);
+            pNmRule =
+                pLstManager->GetNumRuleForActivation( nLFO, nLevel, aParaSprms );
 
-            if (pNmRule)
+            if ( pNmRule != NULL )
             {
-                if( MAXLEVEL > rStyleInf.nOutlineLevel )
+                if ( rStyleInf.IsWW8BuiltInHeadingStyle()
+                     && rStyleInf.HasWW8OutlineLevel() )
+                {
                     rStyleInf.pOutlineNumrule = pNmRule;
+                }
                 else
                 {
-                    rStyleInf.pFmt->SetFmtAttr(
-                        SwNumRuleItem( pNmRule->GetName() ) );
+                    rStyleInf.pFmt->SetFmtAttr( SwNumRuleItem( pNmRule->GetName() ) );
                     rStyleInf.bHasStyNumRule = true;
                 }
             }
@@ -1897,7 +1886,7 @@ void SwWW8ImplReader::RegisterNumFmtOnSt
 void SwWW8ImplReader::RegisterNumFmtOnTxtNode(
     sal_uInt16 nActLFO,
     sal_uInt8 nActLevel,
-    bool bSetAttr)
+    const bool bSetAttr)
 {
     // beachte: die Methode haengt die NumRule an den Text Node, falls
     // bSetAttr (dann muessen natuerlich vorher die Listen gelesen sein)
@@ -1910,11 +1899,13 @@ void SwWW8ImplReader::RegisterNumFmtOnTx
         SwTxtNode* pTxtNd = pPaM->GetNode()->GetTxtNode();
         ASSERT(pTxtNd, "Kein Text-Node an PaM-Position");
 
-        const SwNumRule* pRule = bSetAttr ?
-            pLstManager->GetNumRuleForActivation( nActLFO, nActLevel,
-                aParaSprms, pTxtNd) : 0;
+        const SwNumRule* pRule =
+            bSetAttr
+            ? pLstManager->GetNumRuleForActivation( nActLFO, nActLevel, aParaSprms, pTxtNd)
+            : 0;
 
-        if (pRule || !bSetAttr)
+        if ( pRule != NULL
+             || !bSetAttr)
         {
             //#i24136# old is the same as new, and its the outline numbering,
             //then we don't set the numrule again, and we just take the num node
@@ -1926,15 +1917,11 @@ void SwWW8ImplReader::RegisterNumFmtOnTx
              is the one that was chosen to be the outline numbering then all
              is unchanged
             */
-            // --> OD 2005-11-04 #???# - correct condition according to the
-            // above given comment.
-            if ( pTxtNd->GetNumRule() == rDoc.GetOutlineNumRule() &&
-                 pRule == mpChosenOutlineNumRule )
-            // <--
+            if ( pTxtNd->GetNumRule() == rDoc.GetOutlineNumRule() )
             {
                 bUnchangedOutlineNumbering = true;
             }
-            if (!bUnchangedOutlineNumbering)
+            if ( !bUnchangedOutlineNumbering )
             {
                 //If its normal numbering, see if its the same as it already
                 //was, if its not, and we have been asked to set it, then set

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par5.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par5.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par5.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par5.cxx Tue Jul  8 15:08:09 2014
@@ -2861,38 +2861,6 @@ void lcl_toxMatchACSwitch(  SwWW8ImplRea
     }
 }
 
-//For all outline styles that are not in the outline numbering add them here as
-//custom extra styles
-bool SwWW8ImplReader::AddExtraOutlinesAsExtraStyles(SwTOXBase& rBase)
-{
-    bool bExtras = false;
-    //This is the case if the winword outline numbering is set while the
-    //writer one is not
-    for (sal_uInt16 nI = 0; nI < nColls; ++nI)
-    {
-        SwWW8StyInf& rSI = pCollA[nI];
-        if (rSI.IsOutline())
-        {
-            const SwTxtFmtColl *pFmt = (const SwTxtFmtColl*)(rSI.pFmt);
-            sal_uInt16 nStyleLevel = rSI.nOutlineLevel;
-            sal_uInt16 nMaxLevel = rBase.GetLevel();
-            if (
-                 //nStyleLevel != pFmt->GetOutlineLevel() &&        //#outline level,zhaojianwei
-                 nStyleLevel != (pFmt->GetAttrOutlineLevel()-1) &&  //<-end,zhaojianwei
-                 nStyleLevel < nMaxLevel
-               )
-            {
-                String sStyles(rBase.GetStyleNames(rSI.nOutlineLevel));
-                if( sStyles.Len())
-                    sStyles += TOX_STYLE_DELIMITER;
-                sStyles += pFmt->GetName();
-                rBase.SetStyleNames(sStyles, rSI.nOutlineLevel);
-                bExtras = true;
-            }
-        }
-    }
-    return bExtras;
-}
 
 static void EnsureMaxLevelForTemplates(SwTOXBase& rBase)
 {
@@ -3374,13 +3342,9 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
                         sal_uInt16 eEffectivelyFrom = eCreateFrom ? eCreateFrom : nsSwTOXElement::TOX_OUTLINELEVEL;
                         if (eEffectivelyFrom & nsSwTOXElement::TOX_OUTLINELEVEL)
                         {
-                            if (AddExtraOutlinesAsExtraStyles(*pBase))
-                                eCreateFrom |= (nsSwTOXElement::TOX_TEMPLATE | nsSwTOXElement::TOX_OUTLINELEVEL);
-
-                            // --> FME 2004-12-16 #i19683# Insert a text token " " between the
-                            // number and entry token. In an ideal world we could handle the
-                            // tab stop between the number and the entry correctly, but I
-                            // currently have no clue how to obtain the tab stop position.
+                            // #i19683# Insert a text token " " between the number and entry token.
+                            // In an ideal world we could handle the tab stop between the number and
+                            // the entry correctly, but I currently have no clue how to obtain the tab stop position.
                             // It is _not_ set at the paragraph style.
                             SwForm* pForm = 0;
                             for (sal_uInt16 nI = 0; nI < nColls; ++nI)
@@ -3388,7 +3352,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
                                 const SwWW8StyInf& rSI = pCollA[nI];
                                 if (rSI.IsOutlineNumbered())
                                 {
-                                    sal_uInt16 nStyleLevel = rSI.nOutlineLevel;
+                                    sal_uInt16 nStyleLevel = rSI.mnWW8OutlineLevel;
                                     const SwNumFmt& rFmt = rSI.GetOutlineNumrule()->Get( nStyleLevel );
                                     if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() )
                                     {

Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx Tue Jul  8 15:08:09 2014
@@ -277,8 +277,9 @@ void SwWW8ImplReader::SetDocumentGrid(Sw
         sal_uInt32 nCharWidth=240;
         for (sal_uInt16 nI = 0; nI < pStyles->GetCount(); ++nI)
         {
-            if (pCollA[nI].bValid && pCollA[nI].pFmt &&
-                pCollA[nI].GetWWStyleId() == 0)
+            if (pCollA[nI].bValid
+                && pCollA[nI].pFmt != NULL
+                && pCollA[nI].IsWW8BuiltInDefaultStyle())
             {
                 nCharWidth = ItemGet<SvxFontHeightItem>(*(pCollA[nI].pFmt),
                     RES_CHRATR_CJK_FONTSIZE).GetHeight();
@@ -2863,20 +2864,34 @@ void SwWW8ImplReader::Read_PicLoc(sal_uI
     }
 }
 
+
 void SwWW8ImplReader::Read_POutLvl(sal_uInt16, const sal_uInt8* pData, short nLen )
 {
-    if (pAktColl && (0 < nLen))
+    if ( nLen < 0 )
+    {
+        pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_OUTLINELEVEL );
+        return;
+    }
+
+    if ( pAktColl != NULL )
     {
-        if (SwWW8StyInf* pSI = GetStyle(nAktColl))
+        SwWW8StyInf* pSI = GetStyle( nAktColl );
+        if ( pSI != NULL )
         {
-            pSI->nOutlineLevel = static_cast< sal_uInt8 >(
-                ( (1 <= pSI->GetWWStyleId()) && (9 >= pSI->GetWWStyleId()) )
-            ? pSI->GetWWStyleId()-1
-            : (pData ? *pData : 0) );
+            pSI->mnWW8OutlineLevel =
+                    static_cast< sal_uInt8 >( ( pData ? *pData : 0 ) );
+            NewAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL, SwWW8StyInf::WW8OutlineLevelToOutlinelevel( pSI->mnWW8OutlineLevel ) ) );
         }
     }
+    else if ( pPaM != NULL )
+    {
+        const sal_uInt8 nOutlineLevel =
+                SwWW8StyInf::WW8OutlineLevelToOutlinelevel( static_cast< sal_uInt8 >( ( pData ? *pData : 0 ) ) );
+        NewAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL, nOutlineLevel ) );
+    }
 }
 
+
 void SwWW8ImplReader::Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen )
 {
     if( !bIgnoreText )

Modified: openoffice/branches/AOO410/main/sw/source/filter/xml/swxml.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/xml/swxml.cxx?rev=1608825&r1=1608824&r2=1608825&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/xml/swxml.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/xml/swxml.cxx Tue Jul  8 15:08:09 2014
@@ -404,7 +404,7 @@ sal_Int32 ReadThroughComponent(
     return ERR_SWG_READ_ERROR;
 }
 
-// --> OD 2005-09-06 #i44177#
+
 void lcl_AdjustOutlineStylesForOOo( SwDoc& _rDoc )
 {
     // array containing the names of the default outline styles ('Heading 1',
@@ -463,20 +463,17 @@ void lcl_AdjustOutlineStylesForOOo( SwDo
     const SwNumRule* pOutlineRule = _rDoc.GetOutlineNumRule();
     for ( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
     {
-        // --> OD 2007-01-11 #i73361#
+        // #i73361#
         // Do not change assignment of already created default outline style
         // to a certain outline level.
-//        if ( aCreatedDefaultOutlineStyles[ i ] != 0 && !aOutlineLevelAssigned[ i ] )
         if ( !aOutlineLevelAssigned[ i ] &&
              aCreatedDefaultOutlineStyles[ i ] != 0 &&
              ! aCreatedDefaultOutlineStyles[ i ]->IsAssignedToListLevelOfOutlineStyle() )
-        // <--
         {
             // apply outline level at created default outline style
-			//aCreatedDefaultOutlineStyles[ i ]->SetOutlineLevel( i );
-			aCreatedDefaultOutlineStyles[ i ]->AssignToListLevelOfOutlineStyle(i);//#outline level added by zhaojianwei
+            aCreatedDefaultOutlineStyles[i]->AssignToListLevelOfOutlineStyle( i );        //#outline level added by zhaojianwei
 
-			// apply outline numbering rule, if none is set.
+            // apply outline numbering rule, if none is set.
             const SfxPoolItem& rItem =
                 aCreatedDefaultOutlineStyles[ i ]->GetFmtAttr( RES_PARATR_NUMRULE, sal_False );
             if ( static_cast<const SwNumRuleItem&>(rItem).GetValue().Len() == 0 )
@@ -488,9 +485,8 @@ void lcl_AdjustOutlineStylesForOOo( SwDo
     }
 
 }
-// <--
 
-// --> OD 2006-02-22 #b6382898#
+
 void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SwDoc& _rDoc )
 {
     if ( _rDoc.GetDrawModel() &&
@@ -528,7 +524,6 @@ void lcl_ConvertSdrOle2ObjsToSdrGrafObjs
         }
     }
 }
-// <--
 
 
 sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const String & rName )