summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorRohit Deshmukh <rohit.deshmukh@synerzip.com>2014-03-12 15:07:38 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-14 10:45:33 +0100
commit06f7d1a96eef5aa69d4872ff6d96eb5085296d09 (patch)
tree7b155faff164f15c78492b46a9c5586d05195e96 /writerfilter
parent7545a9054cd8fbca0073b4603b833080b4810a94 (diff)
fdo#74775: Preseved Citation after round trip.
Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/8473 Change-Id: Ie1b0ac3cb4d4b9bf305323599d5e4b63f913fb1b
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx80
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx1
-rw-r--r--writerfilter/source/dmapper/FieldTypes.hxx7
3 files changed, 86 insertions, 2 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 516c4361a333..b912ab48a62d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -143,6 +143,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_xTextFactory( xModel, uno::UNO_QUERY ),
m_xComponentContext( xContext ),
m_bSetUserFieldContent( false ),
+ m_bSetCitation( false ),
m_bIsFirstSection( true ),
m_bIsColumnBreakDeferred( false ),
m_bIsPageBreakDeferred( false ),
@@ -2395,6 +2396,7 @@ if(!bFilled)
{OUString("INDEX"), "com.sun.star.text.DocumentIndex", "", FIELD_INDEX},
{OUString("XE"), "com.sun.star.text.DocumentIndexMark", "", FIELD_XE},
{OUString("BIBLIOGRAPHY"), "com.sun.star.text.Bibliography", "", FILED_BIBLIOGRAPHY},
+ {OUString("CITATION"), "com.sun.star.text.TextField.Bibliography", "", FIELD_CITATION},
// {OUString(""), "", "", FIELD_},
@@ -3003,6 +3005,7 @@ void DomainMapper_Impl::CloseFieldCommand()
if( pContext.get() )
{
m_bSetUserFieldContent = false;
+ m_bSetCitation = false;
FieldConversionMap_t aFieldConversionMap = lcl_GetFieldConversion();
try
@@ -3029,6 +3032,7 @@ void DomainMapper_Impl::CloseFieldCommand()
case FIELD_INDEX:
case FIELD_XE:
case FILED_BIBLIOGRAPHY:
+ case FIELD_CITATION:
case FIELD_TC:
case FIELD_EQ:
bCreateField = false;
@@ -3548,6 +3552,38 @@ void DomainMapper_Impl::CloseFieldCommand()
}
}
break;
+ case FIELD_CITATION:
+ {
+ xFieldInterface = m_xTextFactory->createInstance(
+ OUString::createFromAscii(aIt->second.cFieldServiceName));
+ uno::Reference< beans::XPropertySet > xTC(xFieldInterface,
+ uno::UNO_QUERY_THROW);
+
+ if( !sFirstParam.isEmpty()){
+ uno::Sequence<com::sun::star::beans::PropertyValue> aValues(1);
+ com::sun::star::beans::PropertyValue propertyVal;
+ propertyVal.Name = "Identifier";
+ propertyVal.Value = uno::makeAny(sFirstParam);
+ aValues[0] = propertyVal;
+ xTC->setPropertyValue("Fields",
+ uno::makeAny(aValues));
+ }
+ uno::Reference< text::XTextContent > xToInsert( xTC, uno::UNO_QUERY );
+ uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
+ if (xTextAppend.is())
+ {
+ uno::Reference< text::XTextCursor > xCrsr = xTextAppend->getText()->createTextCursor();
+ uno::Reference< text::XText > xText = xTextAppend->getText();
+ if(xCrsr.is() && xText.is())
+ {
+ xCrsr->gotoEnd(false);
+ xText->insertTextContent(uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ), xToInsert, sal_False);
+ }
+ }
+ m_bSetCitation = true;
+ }
+ break;
+
case FIELD_TC :
{
uno::Reference< beans::XPropertySet > xTC(
@@ -3679,6 +3715,50 @@ void DomainMapper_Impl::SetFieldResult(OUString const& rResult)
rPropNameSupplier.GetName(PROP_CONTENT),
uno::makeAny( rResult ));
}
+ else if ( m_bSetCitation )
+ {
+
+ uno::Reference< beans::XPropertySet > xFieldProperties( xTextField, uno::UNO_QUERY_THROW);
+ // In case of SetExpression, the field result contains the content of the variable.
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY);
+
+ bool bIsSetbiblio = xServiceInfo->supportsService("com.sun.star.text.TextField.Bibliography");
+ if( bIsSetbiblio )
+ {
+ com::sun::star::uno::Any aProperty = xFieldProperties->getPropertyValue("Fields");
+ uno::Sequence<com::sun::star::beans::PropertyValue> aValues ;
+ aProperty >>= aValues;
+ com::sun::star::beans::PropertyValue propertyVal;
+ bool bTitleFound = false;
+ int i=0;
+ for (; i < aValues.getLength(); i++)
+ {
+ propertyVal = aValues[i];
+ if(propertyVal.Name == "Title")
+ {
+ bTitleFound = true;
+ break;
+ }
+ }
+ if(bTitleFound)
+ {
+ OUString titleStr;
+ uno::Any aValue(propertyVal.Value);
+ aValue >>= titleStr;
+ titleStr = titleStr + rResult;
+ propertyVal.Value = uno::makeAny(titleStr);
+ aValues[i] = propertyVal;
+ }
+ else
+ {
+ propertyVal.Name = "Title";
+ propertyVal.Value = uno::makeAny(rResult);
+ aValues[i] = propertyVal;
+ }
+ xFieldProperties->setPropertyValue("Fields",
+ uno::makeAny(aValues));
+ }
+ }
else
{
uno::Reference< beans::XPropertySet > xFieldProperties( xTextField, uno::UNO_QUERY_THROW);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 6b7ca583c9f6..fe8a93807078 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -313,6 +313,7 @@ private:
FieldStack m_aFieldStack;
bool m_bSetUserFieldContent;
+ bool m_bSetCitation;
bool m_bIsFirstSection;
bool m_bIsColumnBreakDeferred;
bool m_bIsPageBreakDeferred;
diff --git a/writerfilter/source/dmapper/FieldTypes.hxx b/writerfilter/source/dmapper/FieldTypes.hxx
index 9d3d360f8d3b..d4daff49526a 100644
--- a/writerfilter/source/dmapper/FieldTypes.hxx
+++ b/writerfilter/source/dmapper/FieldTypes.hxx
@@ -259,7 +259,7 @@ enum FieldId
\f Builds a table of contents using TC entries instead of outline levels
\h Hyperlinks the entries and page numbers within the table of contents
\l Defines the TC entries field level used to build a table of contents
- \n Builds a table of contents or a range of entries, sucah as 1-9, in a table of contents without page numbers
+ \n Builds a table of contents or a range of entries, sucah as �1-9�, in a table of contents without page numbers
\o Builds a table of contents by using outline levels instead of TC entries
\p Defines the separator between the table entry and its page number
\s Builds a table of contents by using a sequence type
@@ -271,7 +271,7 @@ enum FieldId
*/
,FIELD_TOC
/*
- TOC entry: text
+ TOC entry: �text�
\f TC entry in doc with multiple tables
\l Outline Level
\n Suppress page numbers
@@ -297,6 +297,9 @@ enum FieldId
* Bibliography
*/
,FILED_BIBLIOGRAPHY
+ /* Citation
+ */
+ ,FIELD_CITATION
};
}}