[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - writerfilter/source
Michael Stahl
mstahl at redhat.com
Tue Mar 4 06:49:43 PST 2014
writerfilter/source/dmapper/DomainMapper.cxx | 4 ++--
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 21 +++++++++++++++++----
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 7 ++++++-
3 files changed, 25 insertions(+), 7 deletions(-)
New commits:
commit 9a32be03681a595ce075e6fc6d6c60494a70a2fb
Author: Michael Stahl <mstahl at redhat.com>
Date: Sun Mar 2 00:32:17 2014 +0100
fdo#47811: RTF import: fix Database field content
1. the Database field master does not have a "Content" property
2. SetFieldContent was called once for every chunk of text in the field
result, always overwriting the previous value; accumulate the text.
Change-Id: I63cfda19e2e416c52d100d9071796305a5d813c6
(cherry picked from commit e24ae38c8ef233e4b44840058e35959194724743)
Reviewed-on: https://gerrit.libreoffice.org/8442
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 4b6ed8e..2532942 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3827,7 +3827,7 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len)
else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
/*depending on the success of the field insert operation this result will be
set at the field or directly inserted into the text*/
- m_pImpl->SetFieldResult( sText );
+ m_pImpl->AppendFieldResult(sText);
else
{
if (pContext == 0)
@@ -3930,7 +3930,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
/*depending on the success of the field insert operation this result will be
set at the field or directly inserted into the text*/
- m_pImpl->SetFieldResult( sText );
+ m_pImpl->AppendFieldResult(sText);
else
{
if (pContext == 0)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c7302cf..8822882 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3304,7 +3304,6 @@ void DomainMapper_Impl::CloseFieldCommand()
// uno::makeAny( pContext->GetCommand().copy( nIndex + 1 )));
uno::Reference< text::XDependentTextField > xDependentField( xFieldInterface, uno::UNO_QUERY_THROW );
xDependentField->attachTextFieldMaster( xMaster );
- m_bSetUserFieldContent = true;
}
break;
case FIELD_MERGEREC : break;
@@ -3538,8 +3537,18 @@ bool DomainMapper_Impl::IsFieldResultAsString()
return bRet;
}
+void DomainMapper_Impl::AppendFieldResult(OUString const& rString)
+{
+ assert(!m_aFieldStack.empty());
+ FieldContextPtr pContext = m_aFieldStack.top();
+ SAL_WARN_IF(!pContext.get(), "writerfilter.dmapper", "no field context");
+ if (pContext.get())
+ {
+ pContext->AppendResult(rString);
+ }
+}
-void DomainMapper_Impl::SetFieldResult( OUString& rResult )
+void DomainMapper_Impl::SetFieldResult(OUString const& rResult)
{
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->startElement("setFieldResult");
@@ -3595,9 +3604,10 @@ void DomainMapper_Impl::SetFieldResult( OUString& rResult )
}
}
}
- catch( const uno::Exception& )
+ catch (const uno::Exception& e)
{
-
+ SAL_WARN("writerfilter.dmapper",
+ "DomainMapper_Impl::SetFieldResult: exception: " << e.Message);
}
}
}
@@ -3641,6 +3651,9 @@ void DomainMapper_Impl::PopFieldContext()
if( !pContext->IsCommandCompleted() )
CloseFieldCommand();
+ if (!pContext->GetResult().isEmpty())
+ SetFieldResult(pContext->GetResult());
+
//insert the field, TC or TOC
uno::Reference< text::XTextAppend > xTextAppend;
if (!m_aTextAppendStack.empty())
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 4686baa..6792be2 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -124,6 +124,7 @@ class FieldContext
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xStartRange;
OUString m_sCommand;
+ OUString m_sResult;
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > m_xTextField;
::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > m_xFormField;
@@ -142,6 +143,9 @@ public:
void AppendCommand(const OUString& rPart);
const OUString& GetCommand() const {return m_sCommand; }
+ void AppendResult(OUString const& rResult) { m_sResult += rResult; }
+ const OUString& GetResult() const { return m_sResult; }
+
void SetCommandCompleted() { m_bFieldCommandCompleted = true; }
bool IsCommandCompleted() const { return m_bFieldCommandCompleted; }
@@ -597,8 +601,9 @@ public:
void CloseFieldCommand();
//the _current_ fields require a string type result while TOCs accept richt results
bool IsFieldResultAsString();
+ void AppendFieldResult(OUString const& rResult);
//apply the result text to the related field
- void SetFieldResult( OUString& rResult );
+ void SetFieldResult(OUString const& rResult);
// set FFData of top field context
void SetFieldFFData( FFDataHandler::Pointer_t pFFDataHandler );
//the end of field is reached (0x15 appeared) - the command might still be open
More information about the Libreoffice-commits
mailing list