summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-11-11 10:05:12 +0100
committerLászló Németh <nemeth@numbertext.org>2019-11-11 11:38:36 +0100
commit24f17f0336badfbba276c1e6713a89b4f9bb7cb8 (patch)
tree186b623027bc0edca336ae448716904b8c6436e8 /writerfilter/source
parent5e279f175289234b91f272bbbf48e70315fff5ac (diff)
tdf#128428 RTF: clean-up for longer space sequence mode
Fix regressions from commit 24b04db5a63b57a74e58a7616091437ad68548ac (tdf#123703 RTF import: fix length of space character sequence). It seems, longer space sequence is an obsolete RTF-only feature, eg. new RTF documents created in MSO don't use it, but old RTF documents still keep their layout (only in RTF). - Only old-style (without \stshfdbch) or compatible (\stshfdbch31505) RTF documents get longer space sequences using a one-time conversion; - because Writer always exports old-style RTF documents, to avoid of enlargement of space sequences of new-style RTF documents later, RTF import doesn't modify the RTF documents saved in Writer (checking \generator); - text in monospaced font "Courier New" doesn't get longer space sequence (despite its \prq2 (not monospaced) font setting). Change-Id: I308ab06db57a2db5deec1d4c4573da3317cad8e9 Reviewed-on: https://gerrit.libreoffice.org/82145 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx13
-rw-r--r--writerfilter/source/dmapper/SettingsTable.cxx16
-rw-r--r--writerfilter/source/dmapper/SettingsTable.hxx1
-rw-r--r--writerfilter/source/ooxml/model.xml1
-rw-r--r--writerfilter/source/rtftok/rtfcontrolwords.hxx1
-rw-r--r--writerfilter/source/rtftok/rtfdispatchdestination.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx6
8 files changed, 43 insertions, 4 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c787d7b39e19..be549f1a6965 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1884,11 +1884,18 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, const Proper
else
{
#if !defined(MACOSX) // TODO: check layout differences and support all platforms, if needed
- sal_Int32 nPos;
+ sal_Int32 nPos = 0;
+ OUString sFontName;
OUString sDoubleSpace(" ");
- if (IsRTFImport() && !IsOpenFieldCommand() && (nPos = rString.indexOf(sDoubleSpace)) > -1)
+ PropertyMapPtr pContext = GetTopContextOfType(CONTEXT_CHARACTER);
+ // tdf#123703 workaround for longer space sequences of the old or compatible RTF documents
+ if (GetSettingsTable()->GetLongerSpaceSequence() && !IsOpenFieldCommand() && (nPos = rString.indexOf(sDoubleSpace)) != -1 &&
+ // monospaced fonts have no longer space sequences, regardless of \fprq2 (not monospaced) font setting
+ // fix for the base monospaced font Courier
+ (!pContext || !pContext->isSet(PROP_CHAR_FONT_NAME) ||
+ ((pContext->getProperty(PROP_CHAR_FONT_NAME)->second >>= sFontName) && sFontName.indexOf("Courier") == -1)))
{
- // tdf#123703 an RTF space character is longer by an extra six-em-space in a space sequence,
+ // an RTF space character is longer by an extra six-em-space in an old-style RTF space sequence,
// insert them to keep RTF document layout formatted by consecutive spaces
const sal_Unicode aExtraSpace[5] = { 0x2006, 0x20, 0x2006, 0x20, 0 };
const sal_Unicode aExtraSpace2[4] = { 0x20, 0x2006, 0x20, 0 };
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index a861ac7a9ff7..c71850b30d0c 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -246,6 +246,7 @@ struct SettingsTable_Impl
bool m_bAutoHyphenation;
sal_Int16 m_nHyphenationZone;
bool m_bWidowControl;
+ bool m_bLongerSpaceSequence;
bool m_bSplitPgBreakAndParaMark;
bool m_bMirrorMargin;
bool m_bDoNotExpandShiftReturn;
@@ -280,6 +281,7 @@ struct SettingsTable_Impl
, m_bAutoHyphenation(false)
, m_nHyphenationZone(0)
, m_bWidowControl(false)
+ , m_bLongerSpaceSequence(false)
, m_bSplitPgBreakAndParaMark(false)
, m_bMirrorMargin(false)
, m_bDoNotExpandShiftReturn(false)
@@ -298,9 +300,13 @@ SettingsTable::SettingsTable(const DomainMapper& rDomainMapper)
, LoggedTable("SettingsTable")
, m_pImpl( new SettingsTable_Impl )
{
- // HTML paragraph auto-spacing is opt-in for RTF, opt-out for OOXML.
if (rDomainMapper.IsRTFImport())
+ {
+ // HTML paragraph auto-spacing is opt-in for RTF, opt-out for OOXML.
m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = true;
+ // Longer space sequence is opt-in for RTF, and not in OOXML.
+ m_pImpl->m_bLongerSpaceSequence = true;
+ }
}
SettingsTable::~SettingsTable()
@@ -547,6 +553,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
case NS_ooxml::LN_CT_Settings_widowControl:
m_pImpl->m_bWidowControl = nIntValue;
break;
+ case NS_ooxml::LN_CT_Settings_longerSpaceSequence:
+ m_pImpl->m_bLongerSpaceSequence = nIntValue;
+ break;
case NS_ooxml::LN_CT_Compat_doNotExpandShiftReturn:
m_pImpl->m_bDoNotExpandShiftReturn = true;
break;
@@ -753,6 +762,11 @@ sal_Int32 SettingsTable::GetWordCompatibilityMode() const
return -1; // Word compatibility mode not found
}
+bool SettingsTable::GetLongerSpaceSequence() const
+{
+ return m_pImpl->m_bLongerSpaceSequence;
+}
+
}//namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index 631ab5d92634..8d717c7212b0 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -77,6 +77,7 @@ class SettingsTable : public LoggedProperties, public LoggedTable
bool GetDoNotExpandShiftReturn() const;
bool GetNoColumnBalance() const;
bool GetProtectForm() const;
+ bool GetLongerSpaceSequence() const;
sal_Int16 GetHypenationZone() const;
css::uno::Sequence<css::beans::PropertyValue> const & GetThemeFontLangProperties() const;
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index f4fdf41dad57..66eedcaa63e4 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -65,6 +65,7 @@
<!-- Present in RTF, but not in OOXML. -->
<token tokenid="ooxml:CT_Settings_widowControl"/>
+ <token tokenid="ooxml:CT_Settings_longerSpaceSequence"/>
<namespace name="dml-stylesheet">
<start name="theme"/>
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index 392b30068449..2b350e552b2b 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -158,6 +158,7 @@ enum class Destination
USERPROPS,
PROPNAME,
STATICVAL,
+ GENERATOR,
};
enum RTFKeyword
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
index 6cdaab12eff8..79dfe91504c6 100644
--- a/writerfilter/source/rtftok/rtfdispatchdestination.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
@@ -632,6 +632,9 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_STATICVAL:
m_aStates.top().setDestination(Destination::STATICVAL);
break;
+ case RTF_GENERATOR:
+ m_aStates.top().setDestination(Destination::GENERATOR);
+ break;
default:
{
// Check if it's a math token.
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 3b7434228ab7..4f7c71ecf73e 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -519,6 +519,12 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_DEFF:
m_nDefaultFontIndex = nParam;
break;
+ case RTF_STSHFDBCH:
+ // tdf#123703 switch off longer space sequence except in the case of the fixed compatibility setting font id 31505
+ if (nParam != 31505)
+ m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence,
+ new RTFValue(0));
+ break;
case RTF_DEFLANG:
case RTF_ADEFLANG:
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 5a9d71d1b9e5..d92730f0fe28 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1467,6 +1467,12 @@ void RTFDocumentImpl::text(OUString& rString)
case Destination::STATICVAL:
m_aStates.top().appendDestinationText(rString);
break;
+ case Destination::GENERATOR:
+ // don't enlarge space sequences again, if the document was saved in LibreOffice
+ if (rString.indexOf("LibreOffice") != -1)
+ m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence,
+ new RTFValue(0));
+ break;
default:
bRet = false;
break;