diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2020-05-07 13:45:12 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2020-05-07 13:45:12 +0200 |
commit | 601b4d14eebd08fdba2c81f14e796e05e159af39 (patch) | |
tree | 5a812427472ef37e0b545ce7a62e2c0cac991bd0 /sw/source/filter | |
parent | 3e1f891a9f733f0b0a6d4f16e1455dd015661f7e (diff) | |
parent | 3cf7ffb23f3024ba4c477399dde26f224b0fb554 (diff) |
Merge branch 'libreoffice-6-4' into distro/lhm/libreoffice-6-4+backports
Conflicts:
writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
Change-Id: I2e0b84875a10a1255d88d54a3c5857c3e5832521
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/attributeoutputbase.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 53 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8num.cxx | 36 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 24 |
7 files changed, 97 insertions, 42 deletions
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index 70509ed47806..3d8daa633daa 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -348,7 +348,8 @@ public: virtual void NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule ) = 0; /// Numbering definition that overrides abstract numbering definition - virtual void OverrideNumberingDefinition(SwNumRule const&, sal_uInt16 /*nNum*/, sal_uInt16 /*nAbstractNum*/) + virtual void OverrideNumberingDefinition(SwNumRule const&, sal_uInt16 /*nNum*/, sal_uInt16 /*nAbstractNum*/, + const std::map< size_t, size_t > & /*rLevelOverrides*/) { assert(false); } // TODO implement for WW8/RTF /// Start of the abstract numbering definition instance. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 303f38b1376e..f7a17b4288af 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6647,9 +6647,41 @@ void DocxAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule & m_pSerializer->endElementNS( XML_w, XML_num ); } +// Not all attibutes of SwNumFormat are important for export, so can't just use embedded in +// that classes comparison. +static bool lcl_ListLevelsAreDifferentForExport(const SwNumFormat & rFormat1, const SwNumFormat & rFormat2) +{ + if (rFormat1 == rFormat2) + // They are equal, nothing to do + return false; + + if (!rFormat1.GetCharFormat() != !rFormat2.GetCharFormat()) + // One has charformat, other not. they are different + return true; + + if (rFormat1.GetCharFormat() && rFormat2.GetCharFormat()) + { + const SwAttrSet & a1 = rFormat1.GetCharFormat()->GetAttrSet(); + const SwAttrSet & a2 = rFormat2.GetCharFormat()->GetAttrSet(); + + if (!(a1 == a2)) + // Difference in charformat: they are different + return true; + } + + // Compare numformats with empty charformats + SwNumFormat modified1 = rFormat1; + SwNumFormat modified2 = rFormat2; + modified1.SetCharFormatName(OUString()); + modified2.SetCharFormatName(OUString()); + modified1.SetCharFormat(nullptr); + modified2.SetCharFormat(nullptr); + return modified1 != modified2; +} + void DocxAttributeOutput::OverrideNumberingDefinition( SwNumRule const& rRule, - sal_uInt16 const nNum, sal_uInt16 const nAbstractNum) + sal_uInt16 const nNum, sal_uInt16 const nAbstractNum, const std::map< size_t, size_t > & rLevelOverrides ) { m_pSerializer->startElementNS(XML_w, XML_num, FSNS(XML_w, XML_numId), OString::number(nNum)); @@ -6660,12 +6692,25 @@ void DocxAttributeOutput::OverrideNumberingDefinition( ? WW8ListManager::nMinLevel : WW8ListManager::nMaxLevel); for (sal_uInt8 nLevel = 0; nLevel < nLevels; ++nLevel) { - // only export it if it differs from abstract numbering definition - if (rRule.Get(nLevel) != rAbstractRule.Get(nLevel)) + const auto levelOverride = rLevelOverrides.find(nLevel); + bool bListsAreDifferent = lcl_ListLevelsAreDifferentForExport(rRule.Get(nLevel), rAbstractRule.Get(nLevel)); + + // Export list override only if it is different to abstract one + // or we have a level numbering override + if (bListsAreDifferent || levelOverride != rLevelOverrides.end()) { m_pSerializer->startElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nLevel)); - GetExport().NumberingLevel(rRule, nLevel); + if (bListsAreDifferent) + { + GetExport().NumberingLevel(rRule, nLevel); + } + if (levelOverride != rLevelOverrides.end()) + { + // list numbering restart override + m_pSerializer->singleElementNS(XML_w, XML_startOverride, + FSNS(XML_w, XML_val), OString::number(levelOverride->second)); + } m_pSerializer->endElementNS(XML_w, XML_lvlOverride); } diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index edb6825f1fdc..a7733d62209b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -329,8 +329,9 @@ public: virtual void NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule ) override; /// Numbering definition that overrides abstract numbering definition - virtual void OverrideNumberingDefinition(SwNumRule const& rRule, - sal_uInt16 nNum, sal_uInt16 nAbstractNum) override; + virtual void OverrideNumberingDefinition( SwNumRule const& rRule, + sal_uInt16 nNum, sal_uInt16 nAbstractNum, + const std::map< size_t, size_t > & rLevelOverrides ) override; /// Start of the abstract numbering definition instance. virtual void StartAbstractNumbering( sal_uInt16 nId ) override; diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 573db097a2b4..7cacc4eb3173 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -440,8 +440,12 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons ->getIDocumentDrawModelAccess() .GetInvisibleHellId(); - nRotation = pObj->GetRotateAngle(); - lclMovePositionWithRotation(aPos, rSize, nRotation); + // Do not do this with lines. + if (pObj->GetObjIdentifier() != OBJ_LINE) + { + nRotation = pObj->GetRotateAngle(); + lclMovePositionWithRotation(aPos, rSize, nRotation); + } } attrList->add(XML_behindDoc, bOpaque ? "0" : "1"); // Extend distance with the effect extent if the shape is not rotated, which is the opposite diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx index d9f284c3380b..afe0204a48cd 100644 --- a/sw/source/filter/ww8/wrtw8num.cxx +++ b/sw/source/filter/ww8/wrtw8num.cxx @@ -61,24 +61,6 @@ SwNumRule* MSWordExportBase::DuplicateNumRuleImpl(const SwNumRule *pRule) return pMyNumRule; } -sal_uInt16 MSWordExportBase::DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal ) -{ - sal_uInt16 nNumId = USHRT_MAX; - - SwNumRule *const pMyNumRule = DuplicateNumRuleImpl(pRule); - - SwNumFormat aNumFormat( pMyNumRule->Get( nLevel ) ); - aNumFormat.SetStart( nVal ); - pMyNumRule->Set( nLevel, aNumFormat ); - - nNumId = GetNumberingId( *pMyNumRule ); - - // Map the old list to our new list - m_aRuleDuplicates[GetNumberingId( *pRule )] = nNumId; - - return nNumId; -} - // multiple SwList can be based on the same SwNumRule; ensure one w:abstractNum // per SwList sal_uInt16 MSWordExportBase::DuplicateAbsNum(OUString const& rListId, @@ -109,7 +91,6 @@ sal_uInt16 MSWordExportBase::OverrideNumRule( OUString const& rListId, SwNumRule const& rAbstractRule) { - assert(&rExistingRule != &rAbstractRule); auto const numdef = GetNumberingId(rExistingRule); auto const absnumdef = rListId == rAbstractRule.GetDefaultListId() ? GetNumberingId(rAbstractRule) @@ -128,6 +109,13 @@ sal_uInt16 MSWordExportBase::OverrideNumRule( return it->second; } +void MSWordExportBase::AddListLevelOverride(sal_uInt16 nListId, + sal_uInt16 nLevelNum, + sal_uInt16 nStartAt) +{ + m_ListLevelOverrides[nListId][nLevelNum] = nStartAt; +} + sal_uInt16 MSWordExportBase::GetNumberingId( const SwNumRule& rNumRule ) { if ( !m_pUsedNumTable ) @@ -248,7 +236,7 @@ void MSWordExportBase::NumberingDefinitions() assert(it != m_OverridingNums.end()); pRule = (*m_pUsedNumTable)[it->second.first]; assert(pRule); - AttrOutput().OverrideNumberingDefinition(*pRule, n + 1, it->second.second + 1); + AttrOutput().OverrideNumberingDefinition(*pRule, n + 1, it->second.second + 1, m_ListLevelOverrides[n]); } } } @@ -501,7 +489,13 @@ void MSWordExportBase::NumberingLevel( const vcl::Font* pBulletFont=nullptr; rtl_TextEncoding eChrSet=0; FontFamily eFamily=FAMILY_DECORATIVE; - if (SVX_NUM_CHAR_SPECIAL == rFormat.GetNumberingType() || + + if (!rRule.Get(nLvl).GetListFormat().isEmpty()) + { + // We have stored list format, use it + sNumStr = rRule.Get(nLvl).GetListFormat(); + } + else if (SVX_NUM_CHAR_SPECIAL == rFormat.GetNumberingType() || SVX_NUM_BITMAP == rFormat.GetNumberingType()) { sNumStr = OUString(rFormat.GetBulletChar()); diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 8c9c324d0509..45c444c1f0b3 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -467,6 +467,10 @@ public: /// list-id -> abstractnumdef index std::map<OUString, size_t> m_Lists; + /// Map of maps for list levels overrides + /// listid -> level number -> restart value + std::map < size_t, std::map<size_t, size_t> > m_ListLevelOverrides; + const SwTextNode *m_pTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft std::map< sal_uInt16, sal_uInt16 > m_aRuleDuplicates; //map to Duplicated numrules std::stack< sal_Int32 > m_aCurrentCharPropStarts; ///< To remember the position in a run. @@ -655,7 +659,6 @@ public: /// List is set to restart at a particular value so for export make a /// completely new list based on this one and export that instead, /// which duplicates words behaviour in this respect. - sal_uInt16 DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal ); SwNumRule * DuplicateNumRuleImpl(const SwNumRule *pRule); /// check if a new abstractNum is needed for this list @@ -669,6 +672,11 @@ public: OUString const& rListId, SwNumRule const& rAbstractRule); + /// Store list level overrides (restart of list) + void AddListLevelOverride(sal_uInt16 nListId, + sal_uInt16 nLevelNum, + sal_uInt16 nStartAt); + /// Access to the attribute output class. virtual AttributeOutputBase& AttrOutput() const = 0; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 4be2d36e177b..0aad9bd083ef 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3604,20 +3604,14 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule ) nLvl = static_cast< sal_uInt8 >(nLevel); - if ( pTextNd->IsListRestart() ) - { - sal_uInt16 nStartWith = static_cast< sal_uInt16 >( pTextNd->GetActualListStartValue() ); - nNumId = GetExport().DuplicateNumRule( pRule, nLvl, nStartWith ); - if ( USHRT_MAX != nNumId ) - ++nNumId; - } - else if (GetExport().GetExportFormat() == MSWordExportBase::DOCX) // FIXME + if (GetExport().GetExportFormat() == MSWordExportBase::DOCX) // FIXME { // tdf#95848 find the abstract list definition OUString const listId(pTextNd->GetListId()); if (!listId.isEmpty() - // default list id uses the 1:1 mapping - && listId != pRule->GetDefaultListId()) + && (listId != pRule->GetDefaultListId() // default list id uses the 1:1 mapping + || pTextNd->IsListRestart()) // or restarting previous list + ) { SwList const*const pList( GetExport().m_pDoc->getIDocumentListsAccess().getListByName(listId)); @@ -3627,7 +3621,7 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule ) GetExport().m_pDoc->FindNumRulePtr( pList->GetDefaultListStyleName())); assert(pAbstractRule); - if (pAbstractRule == pRule) + if (pAbstractRule == pRule && !pTextNd->IsListRestart()) { // different list, but no override nNumId = GetExport().DuplicateAbsNum(listId, *pAbstractRule); @@ -3636,6 +3630,14 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule ) { nNumId = GetExport().OverrideNumRule( *pRule, listId, *pAbstractRule); + + if (pTextNd->IsListRestart()) + { + // For restarted lists we should also keep value for + // future w:lvlOverride / w:startOverride + GetExport().AddListLevelOverride(nNumId, pTextNd->GetActualListLevel(), + pTextNd->GetActualListStartValue()); + } } assert(nNumId != USHRT_MAX); ++nNumId; |