summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-06-10 13:35:59 +0000
committerEike Rathke <erack@redhat.com>2013-03-14 17:40:01 +0100
commit1441052007fca390313b721b4ff8b07bae9967a5 (patch)
tree84c6dd912966a75e345cde7c3ddc8d640bc608d5 /sc
parent71124925511b5c36b3348e89692e25db7230976c (diff)
i119411 - Read/write RDF support on ODS file format
Patch by: Tsutomu Uchino Review by: arielch Conflicts: sc/inc/scerrors.hxx Change-Id: Idebf093b599b57cd0be4c871590db75c59c14dc1
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/scerrors.hxx1
-rw-r--r--sc/source/filter/xml/xmlwrap.cxx64
-rw-r--r--sc/source/ui/src/scerrors.src4
3 files changed, 68 insertions, 1 deletions
diff --git a/sc/inc/scerrors.hxx b/sc/inc/scerrors.hxx
index 3115cc27a274..1a98f73aa24d 100644
--- a/sc/inc/scerrors.hxx
+++ b/sc/inc/scerrors.hxx
@@ -57,6 +57,7 @@
#define SCWARN_IMPORT_COLUMN_OVERFLOW ( 3 | ERRCODE_CLASS_IMPORT | ERRCODE_WARNING_MASK | ERRCODE_AREA_SC )
#define SCWARN_IMPORT_SHEET_OVERFLOW ( 4 | ERRCODE_CLASS_IMPORT | ERRCODE_WARNING_MASK | ERRCODE_AREA_SC )
#define SCWARN_IMPORT_CELL_OVERFLOW ( 5 | ERRCODE_CLASS_IMPORT | ERRCODE_WARNING_MASK | ERRCODE_AREA_SC )
+#define SCWARN_IMPORT_FEATURES_LOST ( 6 | ERRCODE_CLASS_IMPORT | ERRCODE_WARNING_MASK | ERRCODE_AREA_SC )
// ERRCODE_CLASS_EXPORT - does not display "Write-Error" in MsgBox
#define SCWARN_EXPORT_NONCONVERTIBLE_CHARS ( 1 | ERRCODE_CLASS_EXPORT | ERRCODE_WARNING_MASK | ERRCODE_AREA_SC )
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index 281fa8670050..8355e62fae0d 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -50,7 +50,12 @@
#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
+#include <sfx2/DocumentMetadataAccess.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/documentconstants.hxx>
#include <svx/xmleohlp.hxx>
#include <rtl/logfile.hxx>
#include <rtl/strbuf.hxx>
@@ -394,9 +399,9 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
// TODO/LATER: do not do it for embedded links
+ OUString aName;
if( SFX_CREATE_MODE_EMBEDDED == pObjSh->GetCreateMode() )
{
- OUString aName;
if ( pMedium && pMedium->GetItemSet() )
{
const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
@@ -425,6 +430,38 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
sal_Bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
+ if (!bStylesOnly && bOasis)
+ {
+ // RDF metadata: ODF >= 1.2
+ try
+ {
+ ::comphelper::ComponentContext aContext( xServiceFactory );
+ const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
+ xModel, uno::UNO_QUERY_THROW );
+ const uno::Reference< rdf::XURI > xBaseURI(
+ ::sfx2::createBaseURI( aContext.getUNOContext(), xStorage, aBaseURL, aName ) );
+ const uno::Reference< task::XInteractionHandler > xHandler(
+ pObjSh->GetMedium()->GetInteractionHandler() );
+ xDMA->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
+ }
+ catch (lang::WrappedTargetException & e)
+ {
+ ucb::InteractiveAugmentedIOException iaioe;
+ if ( e.TargetException >>= iaioe )
+ {
+ nError = SCERR_IMPORT_UNKNOWN;
+ }
+ else
+ {
+ nError = SCWARN_IMPORT_FEATURES_LOST;
+ }
+ }
+ catch (uno::Exception &)
+ {
+ nError = SCWARN_IMPORT_FEATURES_LOST;
+ }
+ }
+
// #i103539#: always read meta.xml for generator
sal_uInt32 nMetaRetval(0);
uno::Sequence<uno::Any> aMetaArgs(1);
@@ -828,6 +865,31 @@ sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly)
sal_Bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
+ // RDF metadata: ODF >= 1.2
+ if ( !bStylesOnly && bOasis )
+ {
+ const uno::Reference< beans::XPropertySet > xPropSet( xStorage, uno::UNO_QUERY_THROW );
+ try
+ {
+ ::rtl::OUString aVersion;
+ if (( xPropSet->getPropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Version"))) >>= aVersion )
+ && !aVersion.equals(ODFVER_010_TEXT)
+ && !aVersion.equals(ODFVER_011_TEXT) )
+ {
+ const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
+ xModel, uno::UNO_QUERY_THROW );
+ xDMA->storeMetadataToStorage( xStorage );
+ }
+ }
+ catch (beans::UnknownPropertyException &)
+ {
+ }
+ catch (uno::Exception &)
+ {
+ }
+ }
+
// meta export
if (!bStylesOnly && !bMetaRet)
{
diff --git a/sc/source/ui/src/scerrors.src b/sc/source/ui/src/scerrors.src
index 763ff0e2b463..6cf19a15ec1a 100644
--- a/sc/source/ui/src/scerrors.src
+++ b/sc/source/ui/src/scerrors.src
@@ -170,6 +170,10 @@ Resource RID_ERRHDLSC
{
Text [ en-US ] = "Format error discovered in the file in sub-document $(ARG1) at $(ARG2)(row,col).";
};
+ String SCWARN_IMPORT_FEATURES_LOST & ERRCODE_RES_MASK
+ {
+ Text [ en-US] = "Not all attributes could be read." ;
+ };
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */