Kaydet (Commit) 23ad78fe authored tarafından Ariel Constenla-Haile's avatar Ariel Constenla-Haile

i119411 - Read/write RDF support on ODS file format

Patch by: Tsutomu Uchino
Review by: arielch
üst 655eace2
......@@ -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 )
......
......@@ -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_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*>(
......@@ -495,6 +500,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);
......@@ -917,6 +954,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)
{
......
......@@ -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." ;
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment