summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-09-20 19:42:16 +0200
committerMichael Stahl <michael.stahl@cib.de>2019-09-23 13:35:19 +0200
commit1db6fb0f831e92ac3902af9c58e33f49ede5532b (patch)
treedb5678d6abb195d8d8d234195df07bad980ad8c1 /writerfilter
parentadceab34ca45128d4848edcc58affa220be87686 (diff)
writerfilter: fix assert importing fdo77404-1.docx
The problem is that StyleSheetTable::ApplyStyleSheets() inserts a SwNumRule with name "WW8Num1" and then ListDef::CreateNumberingRule() also wants to insert a SwNumRule with name "WW8Num1" but gets an exception instead, leaving ListDef::m_xNumRules null, and then finishParagraph thinks it's numbered but there's no ListId. Try to avoid collisions of the generated names in ListDef::GetStyleName(), by checking what styles actually exist in the document (which works better in the Insert->File case), and on the assumption that the initialising call always happens before the using calls. (regression from 7992bd73a2307edce96a145e954f8e4c3ab9f57d) Change-Id: I91c98aa897c12778fb214e9690da0bae99550b93 Reviewed-on: https://gerrit.libreoffice.org/79312 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx16
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx25
-rw-r--r--writerfilter/source/dmapper/NumberingManager.hxx7
3 files changed, 38 insertions, 10 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 192b5ab70130..81acdf59ebce 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1237,9 +1237,10 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
{
bool bNumberingFromBaseStyle = false;
sal_Int32 nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : -1;
- if (nListId >= 0 && !pParaContext->isSet(PROP_NUMBERING_STYLE_NAME))
+ auto const pList(GetListTable()->GetList(nListId));
+ if (pList && nListId >= 0 && !pParaContext->isSet(PROP_NUMBERING_STYLE_NAME))
{
- pParaContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny( ListDef::GetStyleName( nListId ) ), false);
+ pParaContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny( pList->GetStyleName(nListId) ), false);
isNumberingViaStyle = true;
// Indent properties from the paragraph style have priority
@@ -6075,7 +6076,12 @@ uno::Reference<container::XIndexAccess> DomainMapper_Impl::GetCurrentNumberingRu
*pListLevel = pStyleSheetProperties->GetListLevel();
// So we are in a paragraph style and it has numbering. Look up the relevant numbering rules.
- OUString aListName = ListDef::GetStyleName(nListId);
+ auto const pList(GetListTable()->GetList(nListId));
+ OUString aListName;
+ if (pList)
+ {
+ aListName = pList->GetStyleName(nListId);
+ }
uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xNumberingStyles;
@@ -6190,7 +6196,9 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const sal_Int32 nListId, sal_I
if (nNumberingLevel < 0) // It seems it's valid to omit numbering level, and in that case it means zero.
nNumberingLevel = 0;
- const OUString aListName = ListDef::GetStyleName(nListId);
+ auto const pList(GetListTable()->GetList(nListId));
+ assert(pList);
+ const OUString aListName = pList->GetStyleName(nListId);
const uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY_THROW);
const uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xNumberingStyles;
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 1b8a8b283f99..8f7d05e5f4d0 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -447,12 +447,27 @@ ListDef::~ListDef( )
{
}
-OUString ListDef::GetStyleName( sal_Int32 nId )
+OUString ListDef::GetStyleName(sal_Int32 const nId,
+ uno::Reference<container::XNameContainer> const& xStyles)
{
- OUString sStyleName( "WWNum" );
- sStyleName += OUString::number( nId );
+ if (xStyles.is())
+ {
+ OUString sStyleName( "WWNum" );
+ sStyleName += OUString::number( nId );
+
+ while (xStyles.is() && xStyles->hasByName(sStyleName)) // unique
+ {
+ sStyleName += "a";
+ }
+
+ m_StyleName = sStyleName;
+ }
+ else
+ {
+// fails in rtftok test assert(!m_StyleName.isEmpty()); // must be inited first
+ }
- return sStyleName;
+ return m_StyleName;
}
uno::Sequence<uno::Sequence<beans::PropertyValue>> ListDef::GetMergedPropertyValues()
@@ -519,7 +534,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
xFactory->createInstance("com.sun.star.style.NumberingStyle"),
uno::UNO_QUERY_THROW );
- OUString sStyleName = GetStyleName( GetId( ) );
+ OUString sStyleName = GetStyleName(GetId(), xStyles);
xStyles->insertByName( sStyleName, makeAny( xStyle ) );
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index c484b7bd9803..0ba356f64f3c 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -170,6 +170,9 @@ private:
// Cache for the UNO numbering rules
css::uno::Reference< css::container::XIndexReplace > m_xNumRules;
+ /// mapped list style name
+ OUString m_StyleName;
+
public:
typedef tools::SvRef< ListDef > Pointer;
@@ -181,7 +184,9 @@ public:
const AbstractListDef::Pointer& GetAbstractDefinition( ) { return m_pAbstractDef; };
// Mapping functions
- static OUString GetStyleName( sal_Int32 nId );
+ OUString GetStyleName(sal_Int32 nId,
+ css::uno::Reference<css::container::XNameContainer> const& xStyles
+ = css::uno::Reference<css::container::XNameContainer>());
css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetMergedPropertyValues();