[Libreoffice-commits] core.git: 2 commits - padmin/source sc/inc sc/source
Ariel Constenla-Haile
arielch at apache.org
Thu Mar 14 09:40:15 PDT 2013
padmin/source/adddlg.cxx | 20 ++++++------
sc/inc/scerrors.hxx | 1
sc/source/filter/xml/xmlwrap.cxx | 64 ++++++++++++++++++++++++++++++++++++++-
sc/source/ui/src/scerrors.src | 4 ++
4 files changed, 78 insertions(+), 11 deletions(-)
New commits:
commit 1441052007fca390313b721b4ff8b07bae9967a5
Author: Ariel Constenla-Haile <arielch at apache.org>
Date: Sun Jun 10 13:35:59 2012 +0000
i119411 - Read/write RDF support on ODS file format
Patch by: Tsutomu Uchino
Review by: arielch
Conflicts:
sc/inc/scerrors.hxx
Change-Id: Idebf093b599b57cd0be4c871590db75c59c14dc1
diff --git a/sc/inc/scerrors.hxx b/sc/inc/scerrors.hxx
index 3115cc2..1a98f73 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 281fa86..8355e62 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 763ff0e..6cf19a1 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: */
commit 71124925511b5c36b3348e89692e25db7230976c
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu Mar 14 17:38:26 2013 +0100
fix the non-intuitive OUString::replaceFirst() usage
Change-Id: I98ffe293dbdc900f702d63ee3d3d58dec27b9f7e
diff --git a/padmin/source/adddlg.cxx b/padmin/source/adddlg.cxx
index 6f8165b..b506db2 100644
--- a/padmin/source/adddlg.cxx
+++ b/padmin/source/adddlg.cxx
@@ -205,7 +205,7 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
if( aDriver.equalsIgnoreAsciiCase( "SGENPRT" ) )
{
OUString aText( PaResId( RID_ERR_REMOVESGENPRT ) );
- aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
+ aText = aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText );
aErrorBox.SetText( m_aRemStr );
aErrorBox.Execute();
@@ -218,7 +218,7 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
if( aDefInfo.m_aDriverName == aPPD )
{
OUString aText( PaResId( RID_ERR_REMOVEDEFAULTDRIVER ) );
- aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
+ aText = aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText );
aErrorBox.SetText( m_aRemStr );
aErrorBox.Execute();
@@ -238,7 +238,7 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
if( it != aPrinters.end() )
{
OUString aText( PaResId( RID_QUERY_DRIVERUSED ) );
- aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
+ aText = aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
QueryBox aBox( this, WB_YES_NO | WB_DEF_NO, aText );
aBox.SetText( m_aRemStr );
if( aBox.Execute() == RET_NO )
@@ -247,7 +247,7 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
else
{
OUString aText( PaResId( RID_QUERY_REMOVEDRIVER ) );
- aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
+ aText = aText.replaceFirst( OUString( "%s" ), m_aDriverBox.GetSelectEntry( i ) );
QueryBox aBox( this, WB_YES_NO | WB_DEF_NO, aText );
aBox.SetText( m_aRemStr );
if( aBox.Execute() == RET_NO )
@@ -289,8 +289,8 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
if (unlink(aSysPath.getStr()))
{
OUString aText( PaResId( RID_ERR_REMOVEDRIVERFAILED ) );
- aText.replaceFirst( OUString( "%s1" ), m_aDriverBox.GetSelectEntry( i ) );
- aText.replaceFirst( OUString( "%s2" ), aFile );
+ aText = aText.replaceFirst( OUString( "%s1" ), m_aDriverBox.GetSelectEntry( i ) );
+ aText = aText.replaceFirst( OUString( "%s2" ), aFile );
ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText );
aErrorBox.SetText( m_aRemStr );
aErrorBox.Execute();
@@ -516,8 +516,8 @@ APOldPrinterPage::APOldPrinterPage( AddPrinterDialog* pParent )
if( pParser == NULL )
{
OUString aText( PaResId( RID_TXT_DRIVERDOESNOTEXIST ) );
- aText.replaceFirst( OUString( "%s1" ), rtl::OStringToOUString(aPrinter, aEncoding) );
- aText.replaceFirst( OUString( "%s2" ), rtl::OStringToOUString(aDriver, aEncoding) );
+ aText = aText.replaceFirst( OUString( "%s1" ), rtl::OStringToOUString(aPrinter, aEncoding) );
+ aText = aText.replaceFirst( OUString( "%s2" ), rtl::OStringToOUString(aDriver, aEncoding) );
InfoBox aBox( this, aText );
aBox.Execute();
continue;
@@ -529,7 +529,7 @@ APOldPrinterPage::APOldPrinterPage( AddPrinterDialog* pParent )
if (!aCommand.isEmpty())
{
OUString aText( PaResId( RID_TXT_PRINTERWITHOUTCOMMAND ) );
- aText.replaceFirst( OUString( "%s" ), rtl::OStringToOUString(aPrinter, aEncoding) );
+ aText = aText.replaceFirst( OUString( "%s" ), rtl::OStringToOUString(aPrinter, aEncoding) );
InfoBox aBox( this, aText );
aBox.Execute();
continue;
@@ -640,7 +640,7 @@ void APOldPrinterPage::addOldPrinters()
if( ! rManager.addPrinter( pInfo->m_aPrinterName, pInfo->m_aDriverName ) )
{
OUString aText( PaResId( RID_TXT_PRINTERADDFAILED ) );
- aText.replaceFirst( OUString( "%s" ), pInfo->m_aPrinterName );
+ aText = aText.replaceFirst( OUString( "%s" ), pInfo->m_aPrinterName );
ErrorBox aBox( this, WB_OK | WB_DEF_OK, aText );
aBox.Execute();
continue;
More information about the Libreoffice-commits
mailing list