summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-08-01 15:50:00 +0300
committerJan Holesovsky <kendy@collabora.com>2019-10-09 16:36:56 +0200
commit63521cbc0b86d2d33b55860b477f596f35026d4d (patch)
tree0b93306f830bd8887248fbb7147f736a98985fd7
parent9508477b677f7b63a5255e252440b9852c7b73ce (diff)
tdf#126544 writerfilter: check parent style exists before assigning
If you set the parent style to a style that is not yet created, then it silently fails, and thus inherits from nothing! Change-Id: Ibb85235643dd5b1eb9b0bd43f701580f24b2b7fa Reviewed-on: https://gerrit.libreoffice.org/76805 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> (cherry picked from commit b47a8f091ad8f9048a6b7962e9cde5d04ea0d665) Reviewed-on: https://gerrit.libreoffice.org/80503 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport3.cxx5
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx8
2 files changed, 12 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 178702a62e4e..7c2b1f5a3978 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -954,6 +954,11 @@ DECLARE_OOXMLEXPORT_TEST(testExtraSectionBreak, "1_page.docx")
uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
xCursor->jumpToLastPage();
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
+
+ // tdf126544 Styles were being added before their base/parent/inherited-from style existed, and so were using default settings.
+ uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles"));
+ uno::Reference<style::XStyle> xStyle(xParaStyles->getByName("Heading 1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString("Heading Base"), xStyle->getParentStyle() );
}
DECLARE_OOXMLEXPORT_TEST(testcolumnbreak, "columnbreak.docx")
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index d192eaa5ab53..f74022af4dc9 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -983,7 +983,13 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
StyleSheetEntryPtr pParent = FindStyleSheetByISTD( pEntry->sBaseStyleIdentifier );
// Writer core doesn't support numbering styles having a parent style, it seems
if (pParent.get() != nullptr && !bListStyle)
- xStyle->setParentStyle(ConvertStyleName( pParent->sStyleName ));
+ {
+ const OUString sParentStyleName = ConvertStyleName( pParent->sStyleName );
+ if ( !sParentStyleName.isEmpty() && !xStyles->hasByName( sParentStyleName ) )
+ aMissingParent.emplace_back( sParentStyleName, xStyle );
+ else
+ xStyle->setParentStyle( sParentStyleName );
+ }
}
catch( const uno::RuntimeException& )
{