From c99f264be5eaf481f88606e2606c34170675c1b4 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Fri, 27 Jun 2014 12:34:10 +0000 Subject: Related: #i78498# 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 our counterparts of WW8 Built-in Heading Styles to Outline Style (cherry picked from commit 9032e17b9989d4fc8faefe7717d2ea14d124e653) (cherry picked from commit c3a35e3885334cb37b2b569daaf536a8cc26031d) Conflicts: sw/source/filter/rtf/swparrtf.cxx sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.hxx sw/source/filter/ww8/ww8par2.cxx sw/source/filter/ww8/ww8par2.hxx sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par5.cxx sw/source/filter/ww8/ww8par6.cxx sw/source/filter/xml/swxml.cxx Change-Id: Ia70920f91300fa47236533f59356abb546a94fb3 --- sw/source/filter/ww8/ww8par.cxx | 243 +++++++++++++++++---------------------- sw/source/filter/ww8/ww8par.hxx | 69 ++++++++--- sw/source/filter/ww8/ww8par2.cxx | 2 +- sw/source/filter/ww8/ww8par3.cxx | 46 ++++---- sw/source/filter/ww8/ww8par5.cxx | 37 +----- sw/source/filter/ww8/ww8par6.cxx | 27 +++-- sw/source/filter/xml/swxml.cxx | 4 +- 7 files changed, 204 insertions(+), 224 deletions(-) diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 34ca56e6dc4e..0513c26afd26 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4116,7 +4116,6 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage, , maGrfNameGenerator(bNewDoc, OUString('G')) , maParaStyleMapper(rD) , maCharStyleMapper(rD) - , mpChosenOutlineNumRule(0) , pFormImpl(0) , pFlyFmtOfJustInsertedGraphic(0) , pFmtOfJustInsertedApo(0) @@ -4983,7 +4982,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) pStyles->PostProcessStyles(); if (!vColl.empty()) - SetOutLineStyles(); + SetOutlineStyles(); pSBase = new WW8ScannerBase(pStrm,pTableStream,pDataStream,pWwFib); @@ -5737,178 +5736,148 @@ public: } }; -void SwWW8ImplReader::SetOutLineStyles() +void SwWW8ImplReader::SetOutlineStyles() { - /* - #i3674# - Load new document and insert document cases. - */ - SwNumRule aOutlineRule(*rDoc.GetOutlineNumRule()); - // #i53044,i53213# - // has to be set to point to local variable - // , because its used below to be compared this <&aOutlineRule>. - // But at the end of the method has to be set to - // , because 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 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) { if ((*aIter)->IsAssignedToListLevelOfOutlineStyle()) - nFlagsStyleOutlLevel |= 1 << (*aIter)->GetAssignedOutlineStyleLevel(); + 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 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 - // as key of the outline numbering map - // 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::mapaRuleMap; - typedef std::map::iterator myIter; + std::map aWW8ListStyleCounts; for (sal_uInt16 nI = 0; nI < vColl.size(); ++nI) { - SwWW8StyInf& rSI = vColl[ nI ]; - if ( - (MAXLEVEL > rSI.nOutlineLevel) && rSI.pOutlineNumrule && - rSI.pFmt - ) + SwWW8StyInf& rSI = vColl[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; - if(aIter->first < vColl.size()) - mpChosenOutlineNumRule = vColl[ aIter->first ].pOutlineNumrule; + std::map::iterator aCountIter + = aWW8ListStyleCounts.find(pWW8ListStyle); + if (aCountIter == aWW8ListStyleCounts.end()) + { + aWW8ListStyleCounts[pWW8ListStyle] = 1; + } else - mpChosenOutlineNumRule = 0; //TODO make sure this is what we want + { + ++(aCountIter->second); + } } } - OSL_ENSURE(mpChosenOutlineNumRule, "Impossible"); - if (mpChosenOutlineNumRule) - aOutlineRule = *mpChosenOutlineNumRule; - - if (mpChosenOutlineNumRule != &aOutlineRule) + int nCurrentMaxCount = 0; + std::map::iterator aCountIterEnd + = aWW8ListStyleCounts.end(); + for (std::map::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 < vColl.size(); ++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::iterator aStylesIterEnd + = aWW8BuiltInHeadingStyles.end(); + for (std::vector::iterator aStyleIter + = aWW8BuiltInHeadingStyles.begin(); + aStyleIter != aStylesIterEnd; ++aStyleIter) { - SwWW8StyInf& rSI = vColl[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)->DeleteAssignmentToListLevelOfOutlineStyle(); // #outline level - } - 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)->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); - ((SwTxtFmtColl*)rSI.pFmt)->AssignToListLevelOfOutlineStyle(nToLevel); - // If there are more styles on this level ignore them - nFlagsStyleOutlLevel |= nAktFlags; +#if OSL_DEBUG_LEVEL > 1 + OSL_ENSURE(pStyleInf->mnWW8OutlineLevel == pStyleInf->nListLevel, + "WW8 import - - 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(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); - // #i53044,i53213# - if ( mpChosenOutlineNumRule == &aOutlineRule ) + + if (bAppliedChangedOutlineStyle) { - mpChosenOutlineNumRule = rDoc.GetOutlineNumRule(); + rDoc.SetOutlineNumRule(aOutlineRule); } } diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index a9558a764bcf..372bd9aa7b1c 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -236,7 +236,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; @@ -268,7 +276,7 @@ public: nFollow( 0 ), nLFOIndex( USHRT_MAX ), nListLevel(WW8ListManager::nMaxLevel), - nOutlineLevel( MAXLEVEL ), + mnWW8OutlineLevel( MAXLEVEL ), n81Flags( 0 ), n81BiDiFlags(0), maWordLR( RES_LR_SPACE ), @@ -294,25 +302,60 @@ public: sWWStyleName = rName; nWWStyleId = nId; } - sal_uInt16 GetWWStyleId() const { return nWWStyleId; } const OUString& 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 && HasWW8OutlineLevel(); } + const SwNumRule* GetOutlineNumrule() const { return pOutlineNumrule; } rtl_TextEncoding GetCharSet() const; rtl_TextEncoding GetCJKCharSet() const; + + sal_uInt16 GetWWStyleId() const + { + return nWWStyleId; + } + + bool IsWW8BuiltInHeadingStyle() const + { + return GetWWStyleId() >= 1 && GetWWStyleId() <= 9; + } + + bool IsWW8BuiltInDefaultStyle() const + { + 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; + } }; // Stack @@ -1158,14 +1201,6 @@ private: std::stack maFontSrcCharSets; std::stack 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; @@ -1616,7 +1651,8 @@ private: // Ver8-Listen void RegisterNumFmtOnTxtNode(sal_uInt16 nActLFO, sal_uInt8 nActLevel, - bool bSetAttr = true); + const bool bSetAttr = true); + void RegisterNumFmtOnStyle(sal_uInt16 nStyle); void SetStylesList(sal_uInt16 nStyle, sal_uInt16 nActLFO, sal_uInt8 nActLevel); @@ -1657,7 +1693,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); @@ -1826,7 +1862,6 @@ public: // eigentlich private, geht aber leider nur public eF_ResT Read_F_NoteReference( WW8FieldDesc* pF, OUString& rStr ); eF_ResT Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ); - bool AddExtraOutlinesAsExtraStyles(SwTOXBase& rBase); eF_ResT Read_F_Symbol( WW8FieldDesc*, OUString& rStr ); eF_ResT Read_F_Embedd( WW8FieldDesc*, OUString& rStr ); eF_ResT Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 758c35b8e592..68da5370cb2b 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3745,7 +3745,7 @@ bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisSty 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; diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 77f01c3ccf0f..c55eeea3195a 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -1631,19 +1631,21 @@ bool SwWW8ImplReader::SetTxtFmtCollAndListLevel(const SwPaM& rRg, bRes = rDoc.SetTxtFmtColl(rRg, (SwTxtFmtColl*)rStyleInfo.pFmt); SwTxtNode* pTxtNode = pPaM->GetNode().GetTxtNode(); OSL_ENSURE( pTxtNode, "No Text-Node at PaM-Position" ); - // make code robust if ( !pTxtNode ) { + // make code robust return bRes; } - SwNumRule * pNumRule = pTxtNode->GetNumRule(); // #i27610# + const SwNumRule * pNumRule = pTxtNode->GetNumRule(); // #i27610# if( !IsInvalidOrToBeMergedTabCell() && ! (pNumRule && pNumRule->IsOutlineRule()) ) // #i27610# + { pTxtNode->ResetAttr( RES_PARATR_NUMRULE ); + } - if( !rStyleInfo.pOutlineNumrule ) + if (rStyleInfo.GetOutlineNumrule() == NULL) { if ( (USHRT_MAX > rStyleInfo.nLFOIndex) && @@ -1654,15 +1656,6 @@ bool SwWW8ImplReader::SetTxtFmtCollAndListLevel(const SwPaM& rRg, rStyleInfo.nListLevel, false); } } - else - { - // Use outline level set at the style info 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->SetAttrListLevel( rStyleInfo.nOutlineLevel ); - } } return bRes; } @@ -1756,8 +1749,8 @@ void SwWW8ImplReader::RegisterNumFmtOnStyle(sal_uInt16 nStyle) // 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) @@ -1767,13 +1760,19 @@ void SwWW8ImplReader::RegisterNumFmtOnStyle(sal_uInt16 nStyle) pNmRule = pLstManager->GetNumRuleForActivation(nLFO, nLevel, aParaSprms); - if (pNmRule) + if (pNmRule != NULL) { - if( MAXLEVEL > rStyleInf.nOutlineLevel ) + if (rStyleInf.IsWW8BuiltInHeadingStyle() + && rStyleInf.HasWW8OutlineLevel()) + { rStyleInf.pOutlineNumrule = pNmRule; - rStyleInf.pFmt->SetFmtAttr( - SwNumRuleItem( pNmRule->GetName() ) ); - rStyleInf.bHasStyNumRule = true; + } + else + { + rStyleInf.pFmt->SetFmtAttr( + SwNumRuleItem(pNmRule->GetName())); + rStyleInf.bHasStyNumRule = true; + } } } @@ -1783,7 +1782,8 @@ void SwWW8ImplReader::RegisterNumFmtOnStyle(sal_uInt16 nStyle) } void SwWW8ImplReader::RegisterNumFmtOnTxtNode(sal_uInt16 nActLFO, - sal_uInt8 nActLevel, bool bSetAttr) + sal_uInt8 nActLevel, + const bool bSetAttr) { // beachte: die Methode haengt die NumRule an den Text Node, falls // bSetAttr (dann muessen natuerlich vorher die Listen gelesen sein) @@ -1802,7 +1802,7 @@ void SwWW8ImplReader::RegisterNumFmtOnTxtNode(sal_uInt16 nActLFO, 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 @@ -1814,9 +1814,7 @@ void SwWW8ImplReader::RegisterNumFmtOnTxtNode(sal_uInt16 nActLFO, is the one that was chosen to be the outline numbering then all is unchanged */ - // correct condition according to the above given comment. - if ( pTxtNd->GetNumRule() == rDoc.GetOutlineNumRule() && - pRule == mpChosenOutlineNumRule ) + if (pTxtNd->GetNumRule() == rDoc.GetOutlineNumRule()) { bUnchangedOutlineNumbering = true; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index d9ca4f287ef4..a2e1eb983489 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2666,38 +2666,6 @@ static void lcl_toxMatchACSwitch( SwWW8ImplReader& /*rReader*/, } } -//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 < vColl.size(); ++nI) - { - SwWW8StyInf& rSI = vColl[nI]; - if (rSI.IsOutline()) - { - const SwTxtFmtColl *pFmt = (const SwTxtFmtColl*)(rSI.pFmt); - sal_uInt16 nStyleLevel = rSI.nOutlineLevel; - sal_uInt16 nMaxLevel = rBase.GetLevel(); - if ( - nStyleLevel != (pFmt->GetAttrOutlineLevel()-1) && - nStyleLevel < nMaxLevel - ) - { - OUString sStyles(rBase.GetStyleNames(rSI.nOutlineLevel)); - if ( !sStyles.isEmpty()) - sStyles += OUString(TOX_STYLE_DELIMITER); - sStyles += pFmt->GetName(); - rBase.SetStyleNames(sStyles, rSI.nOutlineLevel); - bExtras = true; - } - } - } - return bExtras; -} - static void EnsureMaxLevelForTemplates(SwTOXBase& rBase) { //If the TOC contains Template entries at levels > the evaluation level @@ -3180,9 +3148,6 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) sal_uInt16 eEffectivelyFrom = eCreateFrom ? eCreateFrom : nsSwTOXElement::TOX_OUTLINELEVEL; if (eEffectivelyFrom & nsSwTOXElement::TOX_OUTLINELEVEL) { - if (AddExtraOutlinesAsExtraStyles(*pBase)) - eCreateFrom |= (nsSwTOXElement::TOX_TEMPLATE | nsSwTOXElement::TOX_OUTLINELEVEL); - // #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 @@ -3193,7 +3158,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) const SwWW8StyInf& rSI = vColl[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() ) { diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 1ee747b12797..a73df0340a5e 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -270,7 +270,7 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrmFmt &rFmt, const wwSection &rSection) for (sal_uInt16 nI = 0; nI < pStyles->GetCount(); ++nI) { if (vColl[nI].bValid && vColl[nI].pFmt && - vColl[nI].GetWWStyleId() == 0) + vColl[nI].IsWW8BuiltInDefaultStyle()) { nCharWidth = ItemGet(*(vColl[nI].pFmt), RES_CHRATR_CJK_FONTSIZE).GetHeight(); @@ -2698,16 +2698,29 @@ void SwWW8ImplReader::Read_PicLoc(sal_uInt16 , const sal_uInt8* pData, short nLe void SwWW8ImplReader::Read_POutLvl(sal_uInt16, const sal_uInt8* pData, short nLen ) { - if (pAktColl && (0 < nLen)) + if (nLen < 0) { - if (SwWW8StyInf* pSI = GetStyle(nAktColl)) + pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_PARATR_OUTLINELEVEL); + return; + } + + if (pAktColl != NULL) + { + 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((pData ? *pData : 0))); + NewAttr(SfxUInt16Item(RES_PARATR_OUTLINELEVEL, nOutlineLevel)); + } } void SwWW8ImplReader::Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen ) diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index ff47693a9e0c..50986594a290 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -367,7 +367,7 @@ sal_Int32 ReadThroughComponent( } // #i44177# -static void lcl_AdjustOutlineStylesForOOo( SwDoc& _rDoc ) +static void lcl_AdjustOutlineStylesForOOo(SwDoc& _rDoc) { // array containing the names of the default outline styles ('Heading 1', // 'Heading 2', ..., 'Heading 10') @@ -445,7 +445,7 @@ static void lcl_AdjustOutlineStylesForOOo( SwDoc& _rDoc ) } } -static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SwDoc& _rDoc ) +static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SwDoc& _rDoc) { if ( _rDoc.getIDocumentDrawModelAccess().GetDrawModel() && _rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 ) ) -- cgit v1.2.3