summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2020-08-23 14:02:40 +0300
committerAndras Timar <andras.timar@collabora.com>2020-08-31 07:18:24 +0200
commit0a75c12c04638b7be457717f2c0ccd5d29fb6728 (patch)
treeca0b90ccfc081f6557b9a087831242adecba3b2e /sw
parentaa5b8ff2805d6272dfc7975245901f51dd270778 (diff)
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@CIB.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101438 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf135973.odtbin0 -> 14301 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx21
-rw-r--r--sw/source/filter/ww8/wrtw8num.cxx30
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx3
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx158
5 files changed, 107 insertions, 105 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf135973.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index dedad4d00eab..2942b74dd194 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -33,6 +33,27 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133334_followPgStyle, "tdf133334_followPgStyle.o
CPPUNIT_ASSERT_EQUAL(2, 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"));
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index b52bc5857fb9..e8f26c3292b3 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -91,22 +91,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,
@@ -148,17 +145,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 7af4da2b7fd0..851e50a4b55b 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -463,8 +463,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;
@@ -473,7 +471,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 320bfc80ccb1..00d69c6cf681 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3591,110 +3591,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) );