diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2010-10-12 09:57:29 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2010-10-12 10:21:23 +0200 |
commit | 96fd56399d5261f304e44ca24dacb569254c7321 (patch) | |
tree | 4727480d138fbd37d5dae092089f7e6f8aaffcdc /xmloff | |
parent | 86d85bfd4c3460023c64f4687c1c9533a89aa85c (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.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 95 |
2 files changed, 70 insertions, 30 deletions
diff --git a/xmloff/inc/xmloff/odffields.hxx b/xmloff/inc/xmloff/odffields.hxx index 2be06b578acd..7c596dd59603 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 140656fd4298..2bf2fd74074a 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)) { |