incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arie...@apache.org
Subject svn commit: r1348605 - in /incubator/ooo/trunk/main/sc: inc/scerrors.hxx source/filter/xml/xmlwrap.cxx source/ui/src/scerrors.src
Date Sun, 10 Jun 2012 14:35:59 GMT
Author: arielch
Date: Sun Jun 10 14:35:59 2012
New Revision: 1348605

URL: http://svn.apache.org/viewvc?rev=1348605&view=rev
Log:
i119411 - Read/write RDF support on ODS file format

Patch by: Tsutomu Uchino
Review by: arielch

Modified:
    incubator/ooo/trunk/main/sc/inc/scerrors.hxx
    incubator/ooo/trunk/main/sc/source/filter/xml/xmlwrap.cxx
    incubator/ooo/trunk/main/sc/source/ui/src/scerrors.src

Modified: incubator/ooo/trunk/main/sc/inc/scerrors.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/scerrors.hxx?rev=1348605&r1=1348604&r2=1348605&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/scerrors.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/scerrors.hxx Sun Jun 10 14:35:59 2012
@@ -58,6 +58,7 @@
 #define SCWARN_IMPORT_ROW_OVERFLOW (  2 | ERRCODE_CLASS_IMPORT | ERRCODE_WARNING_MASK | ERRCODE_AREA_SC
)
 #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_FEATURES_LOST ( 5 | 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 )

Modified: incubator/ooo/trunk/main/sc/source/filter/xml/xmlwrap.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/xml/xmlwrap.cxx?rev=1348605&r1=1348604&r2=1348605&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/xml/xmlwrap.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/xml/xmlwrap.cxx Sun Jun 10 14:35:59 2012
@@ -62,7 +62,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 <unotools/saveopt.hxx>
@@ -466,9 +471,9 @@ sal_Bool ScXMLImportWrapper::Import(sal_
 	    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*>(
@@ -495,6 +500,38 @@ sal_Bool ScXMLImportWrapper::Import(sal_
 
     	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);
@@ -917,6 +954,31 @@ sal_Bool ScXMLImportWrapper::Export(sal_
 
         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)
 		{

Modified: incubator/ooo/trunk/main/sc/source/ui/src/scerrors.src
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/src/scerrors.src?rev=1348605&r1=1348604&r2=1348605&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/src/scerrors.src (original)
+++ incubator/ooo/trunk/main/sc/source/ui/src/scerrors.src Sun Jun 10 14:35:59 2012
@@ -162,5 +162,9 @@ 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." ;
+    };
 };
 



Mime
View raw message