summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter/uiwriter.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-14 11:34:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-14 11:39:16 +0200
commit3c0805e1f4f4d14e92c7e655d59c87de5c207e48 (patch)
treef83e033781b6724aa77a19537e035d3cfced524e /sw/qa/extras/uiwriter/uiwriter.cxx
parent7e9a4944e53d95f7defb1da384b665e65b2ebc55 (diff)
tdf#86639 SwEditShell: when setting para style, reset char attrs if needed
The old internal RTF filter used to call SwTxtNode::SetAttr() without setting SetAttrMode::NOFORMATATTR, so character attributes which cover the whole node got converted to paragraph attributes. The new UNO filter goes through SwXText::insertTextPortion(), which sets SetAttrMode::NOFORMATATTR, so this doesn't happen. The result of this is that when the UI sets a new paragraph style on the text node, then such character attributes are no longer removed. Given that in RTF you can't really have character properties on a paragraph, going back to the document model produced by the old internal filter doesn't sound like the good direction -- not to mention that changing SwXText::insertTextPortion() this way would be an implicit API change. Fix the problem by tweaking SwEditShell::SetTxtFmtColl() instead, so that it removes these full-text-node character attributes, too. The logic in SwTxtNode::RstTxtAttr() can be extended later if necessary to delete more attributes, but to be on the safe side, just handle the bare minimum necessary to fix the problem for now. Change-Id: I5faa3226fc0f9c18e005da185fe0830d8c393256
Diffstat (limited to 'sw/qa/extras/uiwriter/uiwriter.cxx')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f0a14494b8c5..3a47b8d8fbf1 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -28,6 +28,7 @@
#include <swacorr.hxx>
#include <swmodule.hxx>
#include <modcfg.hxx>
+#include <charatr.hxx>
#include <editeng/acorrcfg.hxx>
#include <unotools/streamwrap.hxx>
#include <test/mtfxmldump.hxx>
@@ -90,6 +91,7 @@ public:
void testSearchWithTransliterate();
void testTdf90362();
void testUndoCharAttribute();
+ void testTdf86639();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -125,6 +127,7 @@ public:
CPPUNIT_TEST(testSearchWithTransliterate);
CPPUNIT_TEST(testTdf90362);
CPPUNIT_TEST(testUndoCharAttribute);
+ CPPUNIT_TEST(testTdf86639);
CPPUNIT_TEST_SUITE_END();
@@ -948,6 +951,17 @@ void SwUiWriterTest::testUndoCharAttribute()
CPPUNIT_ASSERT_EQUAL((*aPoolItem == ampPoolItem), false);
}
+void SwUiWriterTest::testTdf86639()
+{
+ SwDoc* pDoc = createDoc("tdf86639.rtf");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName("Heading");
+ pWrtShell->SetTxtFmtColl(pColl);
+ OUString aExpected = pColl->GetAttrSet().GetFont().GetFamilyName();
+ // This was Calibri, should be Liberation Sans.
+ CPPUNIT_ASSERT_EQUAL(aExpected, getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();