summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2010-10-12 09:57:29 +0200
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-10-12 10:21:23 +0200
commitd288cef69056f123377d288a49d7ed8f1563ad0f (patch)
tree08fe9e1b43ec610c278799c4c8eb5c6378d537ba /xmloff
parent65e1613653e13b13263222f6f6aa1701e3ed3f42 (diff)
Fix roundtrip of DOC unhandled fields
Partly fixes n#628098 (OLE links roundtrip) and fix the fieldmark export in ODF to allow it only for 1.2 Enhanced (fdo#30711).
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/xmloff/odffields.hxx5
-rw-r--r--xmloff/source/text/txtparae.cxx95
2 files changed, 70 insertions, 30 deletions
diff --git a/xmloff/inc/xmloff/odffields.hxx b/xmloff/inc/xmloff/odffields.hxx
index ef8121a081..152e1813fd 100644
--- a/xmloff/inc/xmloff/odffields.hxx
+++ b/xmloff/inc/xmloff/odffields.hxx
@@ -53,4 +53,9 @@
#define ODF_PAGEREF "vnd.oasis.opendocument.field.PAGEREF"
+#define ODF_UNHANDLED "vnd.oasis.opendocument.field.UNHANDLED"
+#define ODF_OLE_PARAM "vnd.oasis.opendocument.field.ole"
+#define ODF_ID_PARAM "vnd.oasis.opendocument.field.id"
+#define ODF_CODE_PARAM "vnd.oasis.opendocument.field.code"
+
#endif /* _ODFFIELDS_HXX */
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index a73600bfa4..7ba4adea3c 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -117,6 +117,11 @@
#include "XMLTextCharStyleNamesElementExport.hxx"
#include <comphelper/stlunosequence.hxx>
+#include <xmloff/odffields.hxx>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+
// --> OD 2008-04-25 #refactorlists#
#include <txtlists.hxx>
// <--
@@ -417,6 +422,27 @@ void FieldParamExporter::Export()
OUString sValue;
aValue >>= sValue;
ExportParameter(*pCurrent,sValue);
+
+ if ( pCurrent->equalsAscii( ODF_OLE_PARAM ) )
+ {
+ // Save the OLE object
+ Reference< embed::XStorage > xTargetStg = m_pExport->GetTargetStorage();
+ Reference< embed::XStorage > xDstStg = xTargetStg->openStorageElement(
+ rtl::OUString::createFromAscii( "OLELinks" ), embed::ElementModes::WRITE );
+
+ if ( !xDstStg->hasByName( sValue ) ) {
+ Reference< XStorageBasedDocument > xStgDoc (
+ m_pExport->GetModel( ), UNO_QUERY );
+ Reference< embed::XStorage > xDocStg = xStgDoc->getDocumentStorage();
+ Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement(
+ rtl::OUString::createFromAscii( "OLELinks" ), embed::ElementModes::READ );
+
+ xOleStg->copyElementTo( sValue, xDstStg, sValue );
+ Reference< embed::XTransactedObject > xTransact( xDstStg, UNO_QUERY );
+ if ( xTransact.is( ) )
+ xTransact->commit( );
+ }
+ }
}
else if(aValueType == aBoolType)
{
@@ -2311,46 +2337,55 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
}
else if (sType.equals(sTextFieldStart))
{
- Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
- if (xBookmark.is())
+ if ( GetExport().getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST )
{
- GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
- }
- Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
- if (xFormField.is())
- {
- GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
- }
- GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
- if (xFormField.is())
- {
- FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
+ Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+ if (xBookmark.is())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
+ }
+ Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+ if (xFormField.is())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
+ }
+ GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
+ if (xFormField.is())
+ {
+ FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
+ }
+ GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
}
- GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
}
else if (sType.equals(sTextFieldEnd))
{
- GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False);
- GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False);
+ if ( GetExport().getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST )
+ {
+ GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False);
+ GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False);
+ }
}
else if (sType.equals(sTextFieldStartEnd))
{
- Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
- if (xBookmark.is())
- {
- GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
- }
- Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
- if (xFormField.is())
- {
- GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
- }
- GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
- if (xFormField.is())
+ if ( GetExport().getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST )
{
- FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
+ Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+ if (xBookmark.is())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
+ }
+ Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
+ if (xFormField.is())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
+ }
+ GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
+ if (xFormField.is())
+ {
+ FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
+ }
+ GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
}
- GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
}
else if (sType.equals(sSoftPageBreak))
{