summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/rtfimport/data/tdf107116.rtf10
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx21
3 files changed, 36 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/tdf107116.rtf b/sw/qa/extras/rtfimport/data/tdf107116.rtf
new file mode 100644
index 000000000000..17c2f5b61a59
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf107116.rtf
@@ -0,0 +1,10 @@
+{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033
+{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;
+\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
+{\stylesheet
+{\s15\brdrt\brdrs\brdrw15\brsp120\brdrcf15 \brdrb\brdrs\brdrw15\brsp120\brdrcf15 \snext15 style;}
+}
+\pard\plain before\par
+\pard\plain \s15\brdrt\brdrs\brdrw15\brsp120\brdrcf15 \brdrb\brdrs\brdrw15\brsp120\brdrcf15 border \par
+\pard\plain after\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 72f7e04d2e6e..2cfaa282ab2b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2811,6 +2811,12 @@ DECLARE_RTFIMPORT_TEST(testTdf106694, "tdf106694.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(14605), aTabs[0].Position);
}
+DECLARE_RTFIMPORT_TEST(testTdf107116, "tdf107116.rtf")
+{
+ // This was 0, upper border around text (and its distance) was missing.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(120)), getProperty<sal_Int32>(getParagraph(2), "TopBorderDistance"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 7afee14a4189..3f4f6659d2e8 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -170,6 +170,23 @@ static bool isSPRMDeduplicateBlacklist(Id nId)
}
}
+/// Should this SPRM be removed if all its children is removed?
+static bool isSPRMChildrenExpected(Id nId)
+{
+ switch (nId)
+ {
+ case NS_ooxml::LN_CT_PBdr_top:
+ case NS_ooxml::LN_CT_PBdr_left:
+ case NS_ooxml::LN_CT_PBdr_bottom:
+ case NS_ooxml::LN_CT_PBdr_right:
+ // Expected children are NS_ooxml::LN_CT_Border_*.
+ return true;
+
+ default:
+ return false;
+ }
+}
+
/// Does the clone / deduplication of a single sprm.
static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t>& rSprm, RTFSprms& ret)
{
@@ -185,7 +202,9 @@ static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t>& rSprm, R
{
RTFSprms const sprms(pValue->getSprms().cloneAndDeduplicate(rSprm.second->getSprms()));
RTFSprms const attributes(pValue->getAttributes().cloneAndDeduplicate(rSprm.second->getAttributes()));
- ret.set(rSprm.first, RTFValue::Pointer_t(pValue->CloneWithSprms(attributes, sprms)));
+ // Don't copy the sprm in case we expect it to have children but it doesn't have some.
+ if (!isSPRMChildrenExpected(rSprm.first) || !sprms.empty() || !attributes.empty())
+ ret.set(rSprm.first, RTFValue::Pointer_t(pValue->CloneWithSprms(attributes, sprms)));
}
}
else