Hi,
See commit
http://cgit.freedesktop.org/libreoffice/core/commit/?id=9486851
which fixes the dmapper part, and the followup
http://cgit.freedesktop.org/libreoffice/core/commit/?id=b9508dd
that fixes the rtftok part.
From a user's PoV, the docx import never worked, the RTF import is a
regression. Backported patch attached.
Thanks,
Miklos
From b22230edd4b4b09d501d9ec63ce7ffe503554587 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@suse.cz>
Date: Tue, 29 May 2012 15:31:11 +0200
Subject: [PATCH] fdo#50665 fdo#37063 rtftok: don't ignore character
properties of text fields
Also fixes: n#760764
(Cherry-picked from commits 9486851 and b9508dd.)
---
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 ++++++++++-
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 1 +
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 20 ++++++++++++++++++--
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 +-
4 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5461a99..0a3ccb8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -193,6 +193,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bIsInShape( false ),
m_bRemovedLastAnchored( false ),
m_pLastSectionContext( ),
+ m_pLastCharacterContext(),
m_nCurrentTabStopIndex( 0 ),
m_sCurrentParaStyleId(),
m_bInStyleSheetImport( false ),
@@ -358,6 +359,8 @@ void DomainMapper_Impl::PopProperties(ContextType eId)
{
m_pLastSectionContext = m_aPropertyStacks[eId].top( );
}
+ else if (eId == CONTEXT_CHARACTER)
+ m_pLastCharacterContext = m_aPropertyStacks[eId].top();
m_aPropertyStacks[eId].pop();
m_aContextStack.pop();
@@ -3163,7 +3166,13 @@ void DomainMapper_Impl::PopFieldContext()
if( xToInsert.is() )
{
uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert(
xTextAppend, uno::UNO_QUERY_THROW );
- xTextAppendAndConvert->appendTextContent( xToInsert, uno::Sequence<
beans::PropertyValue >() );
+ uno::Sequence<beans::PropertyValue> aValues;
+ // Character properties of the field show up here the
+ // last (always empty) run. Inherit character
+ // properties from there.
+ if (m_pLastCharacterContext.get())
+ aValues = m_pLastCharacterContext->GetPropertyValues();
+ xTextAppendAndConvert->appendTextContent(xToInsert, aValues);
}
else
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index c4899cb..289b3c0 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -321,6 +321,7 @@ private:
PropertyMapPtr m_pTopContext;
PropertyMapPtr m_pLastSectionContext;
+ PropertyMapPtr m_pLastCharacterContext;
::std::vector<DeletableTabStop> m_aCurrentTabStops;
sal_uInt32 m_nCurrentTabStopIndex;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f76e1e2..314acc4 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -887,12 +887,28 @@ bool RTFFrame::inFrame()
|| nY > 0;
}
-void RTFDocumentImpl::singleChar(sal_uInt8 nValue)
+void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps)
{
sal_uInt8 sValue[] = { nValue };
if (!m_pCurrentBuffer)
{
Mapper().startCharacterGroup();
+ // Should we send run properties?
+ if (bRunProps)
+ {
+ if (!m_pCurrentBuffer)
+ {
+ writerfilter::Reference<Properties>::Pointer_t const pProperties(
+ new RTFReferenceProperties(m_aStates.top().aCharacterAttributes,
m_aStates.top().aCharacterSprms)
+ );
+ Mapper().props(pProperties);
+ }
+ else
+ {
+ RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aCharacterAttributes,
m_aStates.top().aCharacterSprms));
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue));
+ }
+ }
Mapper().text(sValue, 1);
Mapper().endCharacterGroup();
}
@@ -1616,7 +1632,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
OUString aStr(RTL_CONSTASCII_USTRINGPARAM("PAGE"));
singleChar(0x13);
text(aStr);
- singleChar(0x14);
+ singleChar(0x14, true);
singleChar(0x15);
}
break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index fa21c81..9d097bc 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -400,7 +400,7 @@ namespace writerfilter {
void text(rtl::OUString& rString);
// Sends a single character to dmapper, taking care of buffering.
- void singleChar(sal_uInt8 nValue);
+ void singleChar(sal_uInt8 nValue, bool bRunProps = false);
void parBreak();
void tableBreak();
void checkNeedPap();
--
1.7.7
Context
- [REVIEW:3-5] fdo#50665 fdo#37063 n#760764 rtftok/dmapper: don't ignore character properties of text fields · Miklos Vajna
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.