diff options
Diffstat (limited to 'sw/source/filter/ww8/ww8par.cxx')
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 267 |
1 files changed, 113 insertions, 154 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index de3f0fe89604..d159cd4bbb69 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1701,7 +1701,7 @@ void SwWW8ImplReader::ImportDop() // COMPATIBILITY FLAGS START // - // #i78951# - remember the unknown compatability options + // #i78951# - remember the unknown compatibility options // so as to export them out rDoc.Setn32DummyCompatabilityOptions1( pWDop->GetCompatabilityOptions()); rDoc.Setn32DummyCompatabilityOptions2( pWDop->GetCompatabilityOptions2()); @@ -3051,7 +3051,7 @@ bool SwWW8ImplReader::HandlePageBreakChar() /* If its a 0x0c without a paragraph end before it, act like a paragraph end, but nevertheless, numbering (and perhaps other - similiar constructs) do not exist on the para. + similar constructs) do not exist on the para. */ //xushanchuan add for issue106569 if (!bWasParaEnd && IsTemp) @@ -3740,8 +3740,9 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage, , nIdctHint(0) , bBidi(false) , bReadTable(false) - , mbLoadingTOCCache(false) - , mbLoadingTOCHyperlink(false) + , mbLoadingTOXCache(false) + , mnEmbeddedTOXLevel(0) + , mbLoadingTOXHyperlink(false) , mpPosAfterTOC(0) , mbCareFirstParaEndInToc(false) , mbCareLastParaEndInToc(false) @@ -3807,7 +3808,6 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage, mpDrawEditEngine = 0; pWWZOrder = 0; pFormImpl = 0; - mpChosenOutlineNumRule = 0; pNumFldType = 0; nFldNum = 0; @@ -4124,10 +4124,10 @@ void wwSectionManager::InsertSegments() //End getting the bounds of this section, quite a job eh ? SwSectionFmt *pRet = InsertSection(aSectPaM, *aIter); - //The last section if continous is always unbalanced + //The last section if continuous is always unbalanced if (pRet) { - //Set the columns to be UnBalanced if that compatability option + //Set the columns to be UnBalanced if that compatibility option //is set if (mrReader.pWDop->fNoColumnBalance) pRet->SetFmtAttr(SwFmtNoBalancedColumns(true)); @@ -4464,7 +4464,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) pStyles->PostProcessStyles(); if (pCollA) - SetOutLineStyles(); + SetOutlineStyles(); pSBase = new WW8ScannerBase(pStrm,pTableStream,pDataStream,pWwFib); @@ -4571,13 +4571,13 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) } else //ordinary case { - //Modify here for #119405, by easyfan, 2012-05-24 - mbOnLoadingMain = true; - //End of modification, by easyfan - ReadText(0, pWwFib->ccpText, MAN_MAINTEXT); - //Modify here for #119405, by easyfan, 2012-05-24 - mbOnLoadingMain = false; - //End of modification, by easyfan + //Modify here for #119405, by easyfan, 2012-05-24 + mbOnLoadingMain = true; + //End of modification, by easyfan + ReadText( 0, pWwFib->ccpText, MAN_MAINTEXT ); + //Modify here for #119405, by easyfan, 2012-05-24 + mbOnLoadingMain = false; + //End of modification, by easyfan } ::SetProgressState(nProgress, mpDocShell); // Update @@ -5201,178 +5201,137 @@ 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()) + continue; + } + + aWW8BuiltInHeadingStyles.push_back( &rSI ); + + const SwNumRule* pWW8ListStyle = rSI.GetOutlineNumrule(); + if ( pWW8ListStyle != NULL ) + { + std::map< const SwNumRule*, int >::iterator aCountIter = + aWW8ListStyleCounts.find( pWW8ListStyle ); + if ( aCountIter == aWW8ListStyleCounts.end() ) { - aRuleMap[nI] = 1; + aWW8ListStyleCounts[pWW8ListStyle] = 1; } else - ++(aIter->second); + { + ++(aCountIter->second); + } } } - int nMax = 0; - myIter aEnd2 = aRuleMap.end(); - for (myIter aIter = aRuleMap.begin(); aIter != aEnd2; ++aIter++) + 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 ) { - if (aIter->second > nMax) + if ( aIter->second > nCurrentMaxCount ) { - nMax = aIter->second; - mpChosenOutlineNumRule = pCollA[ aIter->first ].pOutlineNumrule; + nCurrentMaxCount = aIter->second; + pChosenWW8ListStyle = aIter->first; } } + } - ASSERT(mpChosenOutlineNumRule, "Impossible"); - if (mpChosenOutlineNumRule) - aOutlineRule = *mpChosenOutlineNumRule; - - if (mpChosenOutlineNumRule != &aOutlineRule) + // - 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. A potential applied WW8 list style is assigned directly and + // its default outline level is applied. + 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* pStyleInf = (*aStyleIter); + + const sal_uInt16 nOutlineStyleListLevelOfWW8BuiltInHeadingStyle = 1 << pStyleInf->mnWW8OutlineLevel; + if ( nOutlineStyleListLevelOfWW8BuiltInHeadingStyle & nOutlineStyleListLevelWithAssignment ) { - // #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)->IsAssignedToListLevelOfOutlineStyle()) - (*aIter)->DeleteAssignmentToListLevelOfOutlineStyle(); - - else - break; - } + continue; } - } - sal_uInt16 nOldFlags = nFlagsStyleOutlLevel; + if ( pChosenWW8ListStyle != NULL + && pStyleInf->mnWW8OutlineLevel == pStyleInf->nListLevel ) + { + const SwNumFmt& rRule = pChosenWW8ListStyle->Get( pStyleInf->mnWW8OutlineLevel ); + aOutlineRule.Set( pStyleInf->mnWW8OutlineLevel, rRule ); + bAppliedChangedOutlineStyle = true; + } - for (sal_uInt16 nI = 0; nI < nColls; ++nI) - { - SwWW8StyInf& rSI = pCollA[nI]; + // in case that there are more styles on this level ignore them + nOutlineStyleListLevelWithAssignment |= nOutlineStyleListLevelOfWW8BuiltInHeadingStyle; - if (rSI.IsOutlineNumbered()) + SwTxtFmtColl* pTxtFmtColl = static_cast<SwTxtFmtColl*>(pStyleInf->pFmt); + if ( pStyleInf->GetOutlineNumrule() != pChosenWW8ListStyle + || ( pStyleInf->nListLevel < WW8ListManager::nMaxLevel + && pStyleInf->mnWW8OutlineLevel != pStyleInf->nListLevel ) ) { - sal_uInt16 nAktFlags = 1 << rSI.nOutlineLevel; - if ( - (nAktFlags & nFlagsStyleOutlLevel) || - (rSI.pOutlineNumrule != mpChosenOutlineNumRule) - ) + // 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 ) { - /* - 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; - } - - /* - #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; + pTxtFmtColl->SetFmtAttr( SwNumRuleItem( pStyleInf->GetOutlineNumrule()->GetName() ) ); } + // apply default outline level of WW8 Built-in Heading Style + const sal_uInt8 nOutlineLevel = + SwWW8StyInf::WW8OutlineLevelToOutlinelevel( pStyleInf->mnWW8OutlineLevel ); + pTxtFmtColl->SetFmtAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL, nOutlineLevel ) ); + } + else + { + pTxtFmtColl->AssignToListLevelOfOutlineStyle( pStyleInf->mnWW8OutlineLevel ); } } - if (nOldFlags != nFlagsStyleOutlLevel) - rDoc.SetOutlineNumRule(aOutlineRule); - if ( mpChosenOutlineNumRule == &aOutlineRule ) + + if ( bAppliedChangedOutlineStyle ) { - mpChosenOutlineNumRule = rDoc.GetOutlineNumRule(); + rDoc.SetOutlineNumRule(aOutlineRule); } } |