[Libreoffice-commits] core.git: sw/qa xmloff/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Dec 29 04:11:43 UTC 2018
sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 35 +++++++++++
xmloff/source/text/txtparae.cxx | 5 -
3 files changed, 38 insertions(+), 2 deletions(-)
New commits:
commit 43836a58ffe943e2fc65be638f9a7d343102cb07
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Wed Dec 26 10:49:55 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Sat Dec 29 05:11:22 2018 +0100
tdf#47471 odfexport: use stylename if autostyle missing.
My guess is the autoStylePool can be invalidated by some events
(like clearing all attributes), and if nothing is done that
re-creates the autostyle, then Find() returns an empty string.
The normal case when all attributes are reset is that since
there are no attributes, it doesn't bother looking for the
AutoStyle, and just sticks with the given "parent" style.
However, some attributes (like lists) aren't reset, and
in those cases the autoPool didn't exist, and yet it still
looked for something, returning an empty string when
nothing was found.
If there is a style, but autostyle returns nothing, then it
should be safe to always use the given style. There are two
more areas with similar coding that I will change in separate
commits. (However, note that bug 90221 shows that an empty
autostyle might not be exactly like the given style).
Change-Id: I6a3d7b1608160f555004ca9cf1c93ec301177288
Reviewed-on: https://gerrit.libreoffice.org/65616
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt b/sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt
new file mode 100644
index 000000000000..1d6f1a5f22fe
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 0ab26ac25485..67aa3b7d7145 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -34,6 +34,7 @@ class SwUiWriterTest2 : public SwModelTestBase
public:
void testRedlineMoveInsertInDelete();
void testRedlineInHiddenSection();
+ void testTdf47471_paraStyleBackground();
void testTdf101534();
void testTdf54819();
void testTdf108687_tabstop();
@@ -45,6 +46,7 @@ public:
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testRedlineMoveInsertInDelete);
CPPUNIT_TEST(testRedlineInHiddenSection);
+ CPPUNIT_TEST(testTdf47471_paraStyleBackground);
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testTdf54819);
CPPUNIT_TEST(testTdf108687_tabstop);
@@ -87,6 +89,39 @@ SwDoc* SwUiWriterTest2::createDoc(const char* pName)
return pTextDoc->GetDocShell()->GetDoc();
}
+void SwUiWriterTest2::testTdf47471_paraStyleBackground()
+{
+ SwDoc* pDoc = createDoc("tdf47471_paraStyleBackground.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ CPPUNIT_ASSERT_EQUAL(OUString("00Background"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(14729933), getProperty<sal_Int32>(getParagraph(2), "FillColor"));
+
+ pWrtShell->EndPara(/*bSelect=*/true);
+ pWrtShell->EndPara(/*bSelect=*/true);
+ pWrtShell->EndPara(/*bSelect=*/true);
+ lcl_dispatchCommand(mxComponent, ".uno:ResetAttributes", {});
+
+ // the background color should revert to the color for 00Background style
+ //CPPUNIT_ASSERT_EQUAL(sal_Int32(14605542), getProperty<sal_Int32>(getParagraph(2), "FillColor"));
+ // the paragraph style should not be reset
+ CPPUNIT_ASSERT_EQUAL(OUString("00Background"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("00Background"),
+ getProperty<OUString>(getParagraph(3), "ParaStyleName"));
+
+ // Save it and load it back.
+ reload("writer8", "tdf47471_paraStyleBackgroundRT.odt");
+
+ //CPPUNIT_ASSERT_EQUAL(sal_Int32(14605542), getProperty<sal_Int32>(getParagraph(2), "FillColor"));
+ // on round-trip, the paragraph style name was lost
+ CPPUNIT_ASSERT_EQUAL(OUString("00Background"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("00Background"),
+ getProperty<OUString>(getParagraph(3), "ParaStyleName"));
+}
+
void SwUiWriterTest2::testTdf101534()
{
// Copy the first paragraph of the document.
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index c59198bb92b3..9a7776eec9e3 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -1941,8 +1941,9 @@ void XMLTextParagraphExport::exportParagraph(
}
}
- OUString sAutoStyle( sStyle );
- sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle );
+ OUString sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle );
+ if ( sAutoStyle.isEmpty() )
+ sAutoStyle = sStyle;
if( !sAutoStyle.isEmpty() )
GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
GetExport().EncodeStyleName( sAutoStyle ) );
More information about the Libreoffice-commits
mailing list