diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-09 08:52:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-21 08:42:30 +0200 |
commit | 528632660b72b105345945c13c5b68060d94a91b (patch) | |
tree | 860508d482959abeb9175f0ce6b9e65954269f95 /chart2 | |
parent | aee66aa85e75f67135e5c6079a281e18402d261a (diff) |
convert ErrCode to strong typedef
would have preferred to re-use o3tl::strong_int, of which this
is a modified copy, but there are lots of convenience accessors
which are nice to define on the class.
Change-Id: I301b807aaf02fbced3bf75de1e1692cde6c0340a
Reviewed-on: https://gerrit.libreoffice.org/38497
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/model/filter/XMLFilter.cxx | 44 | ||||
-rw-r--r-- | chart2/source/model/inc/XMLFilter.hxx | 9 |
2 files changed, 28 insertions, 25 deletions
diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index a8edb72827bc..e34e2170f976 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -209,7 +209,7 @@ sal_Bool SAL_CALL XMLFilter::filter( { OSL_ENSURE( ! m_xTargetDoc.is(), "source doc is set -> target document should not be set" ); if( impl_Export( m_xSourceDoc, - aDescriptor ) == 0 ) + aDescriptor ) == ERRCODE_NONE ) { m_xSourceDoc = nullptr; bResult = true; @@ -218,7 +218,7 @@ sal_Bool SAL_CALL XMLFilter::filter( else if( m_xTargetDoc.is()) { if( impl_Import( m_xTargetDoc, - aDescriptor ) == 0 ) + aDescriptor ) == ERRCODE_NONE ) { m_xTargetDoc = nullptr; bResult = true; @@ -262,11 +262,11 @@ void SAL_CALL XMLFilter::setSourceDocument( m_xSourceDoc = Document; } -sal_Int32 XMLFilter::impl_Import( +ErrCode XMLFilter::impl_Import( const Reference< lang::XComponent > & xDocumentComp, const Sequence< beans::PropertyValue > & rMediaDescriptor ) { - sal_Int32 nWarning = 0; + ErrCode nWarning = ERRCODE_NONE; OSL_ENSURE( xDocumentComp.is(), "Import: No Model" ); OSL_ENSURE( m_xContext.is(), "Import: No ComponentContext" ); @@ -359,30 +359,31 @@ sal_Int32 XMLFilter::impl_Import( // import meta information if( bOasis ) - nWarning |= impl_ImportStream( + nWarning = impl_ImportStream( sXML_metaStreamName, "com.sun.star.comp.Chart.XMLOasisMetaImporter", xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo ); // import styles - nWarning |= impl_ImportStream( + ErrCode nTmpErr = impl_ImportStream( sXML_styleStreamName, bOasis ? OUString("com.sun.star.comp.Chart.XMLOasisStylesImporter") : OUString("com.sun.star.comp.Chart.XMLStylesImporter"), xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo ); + nWarning = nWarning != ERRCODE_NONE ? nWarning : nTmpErr; // import content - sal_Int32 nContentWarning = impl_ImportStream( + ErrCode nContentWarning = impl_ImportStream( sXML_contentStreamName, bOasis ? OUString("com.sun.star.comp.Chart.XMLOasisContentImporter") : OUString("com.sun.star.comp.Chart.XMLContentImporter"), xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo ); - nWarning |= nContentWarning; + nWarning = nWarning != ERRCODE_NONE ? nWarning : nContentWarning; // import of "content.xml" didn't work - try old "Content.xml" stream - if( nContentWarning != 0 ) + if( nContentWarning != ERRCODE_NONE ) { nWarning = impl_ImportStream( "Content.xml", // old content stream name @@ -401,7 +402,7 @@ sal_Int32 XMLFilter::impl_Import( return nWarning; } -sal_Int32 XMLFilter::impl_ImportStream( +ErrCode XMLFilter::impl_ImportStream( const OUString & rStreamName, const OUString & rServiceName, const Reference< embed::XStorage > & xStorage, @@ -410,12 +411,12 @@ sal_Int32 XMLFilter::impl_ImportStream( const Reference< document::XGraphicObjectResolver > & xGraphicObjectResolver, uno::Reference< beans::XPropertySet >& xImportInfo ) { - sal_Int32 nWarning = ERRCODE_SFX_GENERAL; + ErrCode nWarning = ERRCODE_SFX_GENERAL; Reference< container::XNameAccess > xNameAcc( xStorage, uno::UNO_QUERY ); if( ! (xNameAcc.is() && xNameAcc->hasByName( rStreamName ))) - return 0; + return ERRCODE_NONE; if( xImportInfo.is() ) xImportInfo->setPropertyValue( "StreamName", uno::Any( rStreamName ) ); @@ -483,7 +484,7 @@ sal_Int32 XMLFilter::impl_ImportStream( } // load was successful - nWarning = 0; + nWarning = ERRCODE_NONE; } catch (const xml::sax::SAXParseException&) { @@ -509,14 +510,14 @@ sal_Int32 XMLFilter::impl_ImportStream( return nWarning; } -sal_Int32 XMLFilter::impl_Export( +ErrCode XMLFilter::impl_Export( const Reference< lang::XComponent > & xDocumentComp, const Sequence< beans::PropertyValue > & rMediaDescriptor ) { m_aMediaDescriptor = rMediaDescriptor; //save - sal_Int32 nWarning = 0; + ErrCode nWarning = ERRCODE_NONE; OSL_ENSURE( xDocumentComp.is(), "Export: No Model" ); OSL_ENSURE( m_xContext.is(), "Export: No ComponentContext" ); @@ -613,27 +614,28 @@ sal_Int32 XMLFilter::impl_Export( // export meta information if( bOasis ) - nWarning |= impl_ExportStream( + nWarning = impl_ExportStream( sXML_metaStreamName, "com.sun.star.comp.Chart.XMLOasisMetaExporter", xStorage, xSaxWriter, xServiceFactory, aFilterProperties ); // export styles - nWarning |= impl_ExportStream( + ErrCode nTmp = impl_ExportStream( sXML_styleStreamName, bOasis ? OUString("com.sun.star.comp.Chart.XMLOasisStylesExporter") : OUString("com.sun.star.comp.Chart.XMLStylesExporter"), // soffice 6/7 xStorage, xSaxWriter, xServiceFactory, aFilterProperties ); + nWarning = nWarning != ERRCODE_NONE ? nWarning : nTmp; // export content - sal_Int32 nContentWarning = impl_ExportStream( + ErrCode nContentWarning = impl_ExportStream( sXML_contentStreamName, bOasis ? OUString("com.sun.star.comp.Chart.XMLOasisContentExporter") : OUString("com.sun.star.comp.Chart.XMLContentExporter"), xStorage, xSaxWriter, xServiceFactory, aFilterProperties ); - nWarning |= nContentWarning; + nWarning = nWarning != ERRCODE_NONE ? nWarning : nContentWarning; Reference< lang::XComponent > xComp( xGraphicObjectResolver, uno::UNO_QUERY ); if( xComp.is()) @@ -654,7 +656,7 @@ sal_Int32 XMLFilter::impl_Export( return nWarning; } -sal_Int32 XMLFilter::impl_ExportStream( +ErrCode XMLFilter::impl_ExportStream( const OUString & rStreamName, const OUString & rServiceName, const Reference< embed::XStorage > & xStorage, @@ -720,7 +722,7 @@ sal_Int32 XMLFilter::impl_ExportStream( { ASSERT_EXCEPTION( rEx ); } - return 0; + return ERRCODE_NONE; } void XMLFilter::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDescriptor, bool & rOutOASIS ) diff --git a/chart2/source/model/inc/XMLFilter.hxx b/chart2/source/model/inc/XMLFilter.hxx index de69e205b28f..5eef0f5ac708 100644 --- a/chart2/source/model/inc/XMLFilter.hxx +++ b/chart2/source/model/inc/XMLFilter.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/xml/sax/XWriter.hpp> #include <osl/mutex.hxx> +#include <vcl/errcode.hxx> namespace com { namespace sun { namespace star { @@ -95,10 +96,10 @@ private: // methods /// @return a warning code, or 0 for successful operation - sal_Int32 impl_Import( const css::uno::Reference< css::lang::XComponent > & xDocumentComp, + ErrCode impl_Import( const css::uno::Reference< css::lang::XComponent > & xDocumentComp, const css::uno::Sequence< css::beans::PropertyValue > & aMediaDescriptor ); /// @return a warning code, or 0 for successful operation - sal_Int32 impl_ImportStream( + ErrCode impl_ImportStream( const OUString & rStreamName, const OUString & rServiceName, const css::uno::Reference< css::embed::XStorage > & xStorage, @@ -108,10 +109,10 @@ private: css::uno::Reference< css::beans::XPropertySet >& xPropSet ); /// @return a warning code, or 0 for successful operation - sal_Int32 impl_Export( const css::uno::Reference< css::lang::XComponent > & xDocumentComp, + ErrCode impl_Export( const css::uno::Reference< css::lang::XComponent > & xDocumentComp, const css::uno::Sequence< css::beans::PropertyValue > & aMediaDescriptor ); /// @return a warning code, or 0 for successful operation - sal_Int32 impl_ExportStream( + ErrCode impl_ExportStream( const OUString & rStreamName, const OUString & rServiceName, const css::uno::Reference< css::embed::XStorage > & xStorage, |