summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-10-31 09:48:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-11-02 17:57:45 +0100
commit801a761c4f9a237ae7879e37ca043aa3e587a10c (patch)
treea2e2fbf0171d1efa30fad981353487f20c513269
parent3cf88ce3ac2a962cef4a91fe271cf16aa65c529d (diff)
tdf#113408 RTF import style dedup: separate paragraph and character handling
The problem was that the paragraph in question had no left margin, while it should have one. The reason for this is that the style deduplication logic took both the current paragraph and character style, but the direct formatting only contained character formatting, so it tried to emit the default values for all paragraph formatting. This started to show up after commit 657c6cc3acec0528209a8584b838cd6de581c437 (tdf#104228 RTF import: fix override of style left/right para margin, 2016-12-13), but the root cause is much older, it was there since commit 321d7ec2071472b3765a00806715e7ad9f8a306f (fdo#82078 RTF import: fix bold text spilling over to non-bold text, 2014-09-06). (cherry picked from commit 1970a686273c5d4fc1eeb4430283e37085d9f647) Change-Id: If03240a85cc9de89afe9111c2d29de2672e407bf Reviewed-on: https://gerrit.libreoffice.org/44115 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/rtfexport/data/tdf113408.rtf24
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx16
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
4 files changed, 40 insertions, 8 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf113408.rtf b/sw/qa/extras/rtfexport/data/tdf113408.rtf
new file mode 100644
index 000000000000..60d9bc98d70f
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf113408.rtf
@@ -0,0 +1,24 @@
+{\rtf1\adeflang1037\ansi\ansicpg1252\uc1\adeff1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs1025
+{\fonttbl
+{\f0\fbidi \froman\fcharset238\fprq2 Times New Roman;}
+}
+{\stylesheet
+{Normal;}
+{\s66\li720\ri0 List Paragraph;}
+}
+{\*\listtable
+{\list\listtemplateid1275618250\listhybrid
+{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0
+\levelstartat1\levelspace0\levelindent0
+{\leveltext\leveltemplateid67698703\'02\'00.;}
+{\levelnumbers\'01;}
+\rtlch\fcs1 \af0 \fbias0 \fi-360\li720 }
+{\listname ;}
+\listid1880166401}
+}
+{\*\listoverridetable
+{\listoverride\listid1880166401\listoverridecount0\ls9}
+}
+\paperw12240\paperh15840\margl1440\margr1440\margt1800\margb1440\gutter0\viewkind1
+\pard \s66\li720\ri0\itap0 \par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index fc6290d6ea15..12fb3dcf8708 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -745,6 +745,12 @@ DECLARE_RTFEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
}
+DECLARE_RTFEXPORT_TEST(testTdf113408, "tdf113408.rtf")
+{
+ // This was 0, left margin was not inherited from style properly.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
+}
+
DECLARE_RTFEXPORT_TEST(testAbi10039, "abi10039.odt")
{
// Make sure we don't just crash on export, and additionally the shape should not be inline (as it's at-page anchored originally).
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 229dc02781ba..af8ef382b53a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -437,7 +437,7 @@ static void lcl_copyFlatten(RTFReferenceProperties& rProps, RTFSprms& rStyleAttr
rStyleAttributes.set(rAttribute.first, rAttribute.second);
}
-writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RTFSprms& rAttributes, RTFSprms& rSprms)
+writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RTFSprms& rAttributes, RTFSprms& rSprms, Id nStyleType)
{
int nStyle = 0;
if (!m_aStates.empty())
@@ -459,13 +459,15 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT
RTFSprms aStyleSprms;
RTFSprms aStyleAttributes;
// Ensure the paragraph style is a flat list.
- lcl_copyFlatten(rProps, aStyleAttributes, aStyleSprms);
+ if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_paragraph)
+ lcl_copyFlatten(rProps, aStyleAttributes, aStyleSprms);
if (itChar != m_aStyleTableEntries.end())
{
// Found active character style, then update aStyleSprms/Attributes.
RTFReferenceProperties& rCharProps = *static_cast<RTFReferenceProperties*>(itChar->second.get());
- lcl_copyFlatten(rCharProps, aStyleAttributes, aStyleSprms);
+ if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_character)
+ lcl_copyFlatten(rCharProps, aStyleAttributes, aStyleSprms);
}
// Get rid of direct formatting what is already in the style.
@@ -489,7 +491,7 @@ void RTFDocumentImpl::checkNeedPap()
if (!m_aStates.top().pCurrentBuffer)
{
writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties(
- getProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)
+ getProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms, NS_ooxml::LN_Value_ST_StyleType_paragraph)
);
// Writer will ignore a page break before a text frame, so guard it with empty paragraphs
@@ -524,7 +526,7 @@ void RTFDocumentImpl::runProps()
{
if (!m_aStates.top().pCurrentBuffer)
{
- writerfilter::Reference<Properties>::Pointer_t const pProperties = getProperties(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms);
+ Reference<Properties>::Pointer_t const pProperties = getProperties(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms, NS_ooxml::LN_Value_ST_StyleType_character);
Mapper().props(pProperties);
}
else
@@ -1413,7 +1415,7 @@ void RTFDocumentImpl::prepareProperties(
writerfilter::Reference<Properties>::Pointer_t& o_rpTableRowProperties,
int const nCells, int const nCurrentCellX)
{
- o_rpParagraphProperties = getProperties(rState.aParagraphAttributes, rState.aParagraphSprms);
+ o_rpParagraphProperties = getProperties(rState.aParagraphAttributes, rState.aParagraphSprms, NS_ooxml::LN_Value_ST_StyleType_paragraph);
if (rState.aFrame.hasProperties())
{
@@ -1497,7 +1499,7 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
{
// Construct properties via getProperties() and not directly, to take care of deduplication.
writerfilter::Reference<Properties>::Pointer_t const pProp(
- getProperties(std::get<1>(aTuple)->getAttributes(), std::get<1>(aTuple)->getSprms())
+ getProperties(std::get<1>(aTuple)->getAttributes(), std::get<1>(aTuple)->getSprms(), 0)
);
Mapper().props(pProp);
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index bcd2aa90d39e..06c9ba62ffeb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -467,7 +467,7 @@ private:
void runBreak();
void parBreak();
void tableBreak();
- writerfilter::Reference<Properties>::Pointer_t getProperties(RTFSprms& rAttributes, RTFSprms& rSprms);
+ writerfilter::Reference<Properties>::Pointer_t getProperties(RTFSprms& rAttributes, RTFSprms& rSprms, Id nStyleType);
void checkNeedPap();
void sectBreak(bool bFinal = false);
void prepareProperties(