[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa sw/source
Vasily Melenchuk (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 27 08:40:30 UTC 2020
sw/qa/extras/ooxmlexport/data/tdf135973.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 20 +++
sw/source/filter/ww8/wrtw8num.cxx | 30 +----
sw/source/filter/ww8/wrtww8.hxx | 3
sw/source/filter/ww8/ww8atr.cxx | 158 +++++++++++++---------------
5 files changed, 106 insertions(+), 105 deletions(-)
New commits:
commit 892329fc88116cbe70f0d92f8d307775840595b4
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Sun Aug 23 14:02:40 2020 +0300
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Aug 27 10:39:56 2020 +0200
tdf#135973: DOCX export: improved list override support
Removed remains of old override support which are not working now.
Partial refactoring and fixing for listid and overrides detection.
Change-Id: I1f94a09b7d51fcc3300b056d6d9e8ea6367a4446
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101238
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101437
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135973.odt b/sw/qa/extras/ooxmlexport/data/tdf135973.odt
new file mode 100644
index 000000000000..0eb42080f9d6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135973.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 8dd905a6405b..f585934c896f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -39,6 +39,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133370_columnBreak, "tdf133370_columnBreak.odt")
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf135973, "tdf135973.odt")
+{
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("2."), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(6), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("2."), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+}
DECLARE_OOXMLEXPORT_TEST(testTdf134063, "tdf134063.docx")
{
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index df51bb99be36..87a6cb68f111 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -86,22 +86,19 @@ sal_uInt16 MSWordExportBase::OverrideNumRule(
OUString const& rListId,
SwNumRule const& rAbstractRule)
{
- auto const numdef = GetNumberingId(rExistingRule);
- auto const absnumdef = rListId == rAbstractRule.GetDefaultListId()
+ const sal_uInt16 numdef = GetNumberingId(rExistingRule);
+
+ const sal_uInt16 absnumdef = rListId == rAbstractRule.GetDefaultListId()
? GetNumberingId(rAbstractRule)
: DuplicateAbsNum(rListId, rAbstractRule);
auto const mapping = std::make_pair(numdef, absnumdef);
- auto it = m_OverridingNumsR.find(mapping);
- if (it == m_OverridingNumsR.end())
- {
- it = m_OverridingNumsR.insert(std::make_pair(mapping, m_pUsedNumTable->size())).first;
- m_OverridingNums.insert(std::make_pair(m_pUsedNumTable->size(), mapping));
+ auto it = m_OverridingNums.insert(std::make_pair(m_pUsedNumTable->size(), mapping));
- m_pUsedNumTable->push_back(nullptr); // dummy, it's unique_ptr...
- ++m_nUniqueList; // counter for DuplicateNumRule...
- }
- return it->second;
+ m_pUsedNumTable->push_back(nullptr); // dummy, it's unique_ptr...
+ ++m_nUniqueList; // counter for DuplicateNumRule...
+
+ return it.first->first;
}
void MSWordExportBase::AddListLevelOverride(sal_uInt16 nListId,
@@ -143,17 +140,6 @@ sal_uInt16 MSWordExportBase::GetNumberingId( const SwNumRule& rNumRule )
SwNumRule* p = const_cast<SwNumRule*>(&rNumRule);
sal_uInt16 nRet = static_cast<sal_uInt16>(m_pUsedNumTable->GetPos(p));
- // Is this list now duplicated into a new list which we should use
- // #i77812# - perform 'deep' search in duplication map
- std::map<sal_uInt16,sal_uInt16>::const_iterator aResult = m_aRuleDuplicates.end();
- do {
- aResult = m_aRuleDuplicates.find(nRet);
- if ( aResult != m_aRuleDuplicates.end() )
- {
- nRet = (*aResult).second;
- }
- } while ( aResult != m_aRuleDuplicates.end() );
-
return nRet;
}
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 8753314664ca..50d762f6e358 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -455,8 +455,6 @@ public:
std::unique_ptr<SwNumRuleTable> m_pUsedNumTable; // all used NumRules
/// overriding numdef index -> (existing numdef index, abstractnumdef index)
std::map<size_t, std::pair<size_t, size_t>> m_OverridingNums;
- /// same in reverse
- std::map<std::pair<size_t, size_t>, size_t> m_OverridingNumsR;
/// list-id -> abstractnumdef index
std::map<OUString, size_t> m_Lists;
@@ -465,7 +463,6 @@ public:
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.
WW8_WrtBookmarks* m_pBkmks;
WW8_WrtRedlineAuthor* m_pRedlAuthors;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index e9c236d8e872..7b908abb67e6 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3563,110 +3563,108 @@ void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
{
const SwTextNode* pTextNd = nullptr;
- sal_uInt16 nNumId;
+ if (rNumRule.GetValue().isEmpty())
+ {
+ ParaNumRule_Impl(pTextNd, 0, 0);
+ return;
+ }
+ const SwNumRule* pRule = GetExport().m_pDoc->FindNumRulePtr(
+ rNumRule.GetValue() );
+ if (!pRule)
+ return;
+
+ sal_uInt16 nNumId = GetExport().GetNumberingId(*pRule) + 1;
sal_uInt8 nLvl = 0;
- if (!rNumRule.GetValue().isEmpty())
+
+ if (!GetExport().m_pOutFormatNode)
{
- const SwNumRule* pRule = GetExport().m_pDoc->FindNumRulePtr(
- rNumRule.GetValue() );
- nNumId = pRule ? GetExport().GetNumberingId(*pRule) : USHRT_MAX;
- if (USHRT_MAX != nNumId)
- {
- ++nNumId;
- if ( GetExport().m_pOutFormatNode )
- {
- if ( dynamic_cast< const SwContentNode *>( GetExport().m_pOutFormatNode ) != nullptr )
- {
- pTextNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
+ ParaNumRule_Impl(pTextNd, nLvl, nNumId);
+ return;
+ }
- if( pTextNd->IsCountedInList())
- {
- int nLevel = pTextNd->GetActualListLevel();
+ if ( dynamic_cast< const SwContentNode *>( GetExport().m_pOutFormatNode ) != nullptr )
+ {
+ pTextNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
- if (nLevel < 0)
- nLevel = 0;
+ if( pTextNd->IsCountedInList())
+ {
+ int nLevel = pTextNd->GetActualListLevel();
+
+ if (nLevel < 0)
+ nLevel = 0;
- if (nLevel >= MAXLEVEL)
- nLevel = MAXLEVEL - 1;
+ if (nLevel >= MAXLEVEL)
+ nLevel = MAXLEVEL - 1;
- nLvl = static_cast< sal_uInt8 >(nLevel);
+ nLvl = static_cast< sal_uInt8 >(nLevel);
- 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()
+ && (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));
+ if (pList)
+ {
+ SwNumRule const*const pAbstractRule(
+ GetExport().m_pDoc->FindNumRulePtr(
+ pList->GetDefaultListStyleName()));
+ assert(pAbstractRule);
+ if (pAbstractRule == pRule && !pTextNd->IsListRestart())
{
- // tdf#95848 find the abstract list definition
- OUString const listId(pTextNd->GetListId());
- if (!listId.isEmpty()
- && (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));
- if (pList)
- {
- SwNumRule const*const pAbstractRule(
- GetExport().m_pDoc->FindNumRulePtr(
- pList->GetDefaultListStyleName()));
- assert(pAbstractRule);
- if (pAbstractRule == pRule && !pTextNd->IsListRestart())
- {
- // different list, but no override
- nNumId = GetExport().DuplicateAbsNum(listId, *pAbstractRule);
- }
- else
- {
- nNumId = GetExport().OverrideNumRule(
- *pRule, listId, *pAbstractRule);
+ // different list, but no override
+ nNumId = GetExport().DuplicateAbsNum(listId, *pAbstractRule) + 1;
+ }
+ else
+ {
+ nNumId = GetExport().OverrideNumRule(
+ *pRule, listId, *pAbstractRule) + 1;
- 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;
- }
+ if (pTextNd->IsListRestart())
+ {
+ // For restarted lists we should also keep value for
+ // future w:lvlOverride / w:startOverride
+ GetExport().AddListLevelOverride(nNumId-1, pTextNd->GetActualListLevel(),
+ pTextNd->GetActualListStartValue());
}
}
}
- else
- {
- // #i44815# adjust numbering for numbered paragraphs
- // without number (NO_NUMLEVEL). These paragraphs
- // will receive a list id 0, which WW interprets as
- // 'no number'.
- nNumId = 0;
- }
- }
- else if ( dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) != nullptr )
- {
- const SwTextFormatColl* pC = static_cast<const SwTextFormatColl*>(GetExport().m_pOutFormatNode);
- if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() )
- nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() );
}
}
}
else
- nNumId = USHRT_MAX;
+ {
+ // #i44815# adjust numbering for numbered paragraphs
+ // without number (NO_NUMLEVEL). These paragraphs
+ // will receive a list id 0, which WW interprets as
+ // 'no number'.
+ nNumId = 0;
+ }
}
- else
- nNumId = 0;
-
- if ( USHRT_MAX != nNumId )
+ else if ( dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) != nullptr )
{
- if ( nLvl >= WW8ListManager::nMaxLevel )
- nLvl = WW8ListManager::nMaxLevel - 1;
-
- ParaNumRule_Impl( pTextNd, nLvl, nNumId );
+ const SwTextFormatColl* pC = static_cast<const SwTextFormatColl*>(GetExport().m_pOutFormatNode);
+ if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() )
+ nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() );
}
+
+ if ( nLvl >= WW8ListManager::nMaxLevel )
+ nLvl = WW8ListManager::nMaxLevel - 1;
+
+ ParaNumRule_Impl( pTextNd, nLvl, nNumId);
}
void WW8AttributeOutput::ParaNumRule_Impl(const SwTextNode* /*pTextNd*/,
sal_Int32 const nLvl, sal_Int32 const nNumId)
{
+ if (USHRT_MAX == nNumId)
+ return;
+
// write sprmPIlvl and sprmPIlfo
SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::sprmPIlvl );
m_rWW8Export.pO->push_back( ::sal::static_int_cast<sal_uInt8>(nLvl) );
More information about the Libreoffice-commits
mailing list