[Libreoffice-commits] core.git: writerfilter/source
Vasily Melenchuk (via logerrit)
logerrit at kemper.freedesktop.org
Sun May 17 01:06:58 UTC 2020
writerfilter/source/dmapper/NumberingManager.cxx | 38 +++++++++++++----------
writerfilter/source/dmapper/NumberingManager.hxx | 6 +++
2 files changed, 28 insertions(+), 16 deletions(-)
New commits:
commit 047de8a887628dc45d5b8df7b297abd6fa2fafc5
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri May 15 18:36:08 2020 +0300
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Sun May 17 03:06:22 2020 +0200
tdf#120394: docx import: support for w:styleLink
Previous implementation for w:numStyleLink was referring
just ordinal styles, but there can be another abstract
list marked with w:styleLink which should be used in
given context.
Change-Id: Ic5d4fe8bfd41b19e2f65d74defb6961e38ec9a9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94332
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 5455bda3a617..762bd623a1d3 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -1069,6 +1069,12 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
m_pCurrentDefinition->SetNumStyleLink(sStyleName);
}
break;
+ case NS_ooxml::LN_CT_AbstractNum_styleLink:
+ {
+ OUString sStyleName = rSprm.getValue()->getString();
+ m_pCurrentDefinition->SetStyleLink(sStyleName);
+ }
+ break;
case NS_ooxml::LN_EG_RPrBase_rFonts: //contains font properties
case NS_ooxml::LN_EG_RPrBase_color:
case NS_ooxml::LN_EG_RPrBase_u:
@@ -1107,21 +1113,17 @@ void ListsManager::lcl_entry(writerfilter::Reference<Properties>::Pointer_t ref
AbstractListDef::Pointer ListsManager::GetAbstractList( sal_Int32 nId )
{
- AbstractListDef::Pointer pAbstractList;
-
- int nLen = m_aAbstractLists.size( );
- int i = 0;
- while ( !pAbstractList && i < nLen )
+ for (const auto& listDef : m_aAbstractLists)
{
- if ( m_aAbstractLists[i]->GetId( ) == nId )
+ if (listDef->GetId( ) == nId)
{
- if ( m_aAbstractLists[i]->GetNumStyleLink().getLength() > 0 )
+ if (listDef->GetNumStyleLink().getLength() > 0)
{
// If the abstract num has a style linked, check the linked style's number id.
StyleSheetTablePtr pStylesTable = m_rDMapper.GetStyleSheetTable( );
const StyleSheetEntryPtr pStyleSheetEntry =
- pStylesTable->FindStyleSheetByISTD( m_aAbstractLists[i]->GetNumStyleLink() );
+ pStylesTable->FindStyleSheetByISTD(listDef->GetNumStyleLink() );
const StyleSheetPropertyMap* pStyleSheetProperties =
dynamic_cast<const StyleSheetPropertyMap*>(pStyleSheetEntry ? pStyleSheetEntry->pProperties.get() : nullptr);
@@ -1131,20 +1133,24 @@ AbstractListDef::Pointer ListsManager::GetAbstractList( sal_Int32 nId )
ListDef::Pointer pList = GetList( pStyleSheetProperties->GetListId() );
if ( pList!=nullptr )
return pList->GetAbstractDefinition();
- else
- pAbstractList = m_aAbstractLists[i];
}
+ // In stylesheet we did not found anything useful. Try to find base abstractnum having this stylelink
+ for (const auto & baseListDef : m_aAbstractLists)
+ {
+ if (baseListDef->GetStyleLink() == listDef->GetNumStyleLink())
+ {
+ return baseListDef;
+ }
+ }
}
- else
- {
- pAbstractList = m_aAbstractLists[i];
- }
+
+ // Standalone abstract list
+ return listDef;
}
- i++;
}
- return pAbstractList;
+ return nullptr;
}
ListDef::Pointer ListsManager::GetList( sal_Int32 nId )
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index 9719e74d87f4..e1d2f2f1bef2 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -132,6 +132,9 @@ private:
// The style name linked to.
OUString m_sNumStyleLink;
+ // This absract numbering is a base definition for this style
+ OUString m_sStyleLink;
+
/// list id to use for all derived numbering definitions
std::optional<OUString> m_oListId;
@@ -159,6 +162,9 @@ public:
void SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
const OUString& GetNumStyleLink() const { return m_sNumStyleLink; };
+ void SetStyleLink(const OUString& sValue) { m_sStyleLink = sValue; };
+ const OUString& GetStyleLink() const { return m_sStyleLink; };
+
const OUString& MapListId(OUString const& rId);
};
More information about the Libreoffice-commits
mailing list