writerperfect/source/draw/CDRImportFilter.cxx | 7 ++-- writerperfect/source/draw/CMXImportFilter.cxx | 8 ++--- writerperfect/source/draw/MSPUBImportFilter.cxx | 8 ++--- writerperfect/source/draw/VisioImportFilter.cxx | 8 ++--- writerperfect/source/draw/WPGImportFilter.cxx | 8 ++--- writerperfect/source/writer/MSWorksImportFilter.cxx | 24 ---------------- writerperfect/source/writer/WordPerfectImportFilter.cxx | 21 -------------- 7 files changed, 17 insertions(+), 67 deletions(-)
New commits: commit 866ebf66b3a50b2d601825e4533898949d5b86c8 Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Fri Mar 1 23:01:28 2013 +0100 Simplify a bit the boilerplate code The XInputStream is guaranteed to be there always and if it is not there, do not try to create it. Change-Id: Ie133489dfcb3d9cec0c4efe78740348a1efa2423 diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx index 026c7b1..216e1fd 100644 --- a/writerperfect/source/draw/CDRImportFilter.cxx +++ b/writerperfect/source/draw/CDRImportFilter.cxx @@ -74,16 +74,12 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { OSL_ASSERT( 0 ); return sal_False; } - OString sFileName; - sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII); // An XML import service: what we push sax messages to.. OUString sXMLImportService ( "com.sun.star.comp.Draw.XMLOasisImporter" ); @@ -142,6 +138,9 @@ throw( com::sun::star::uno::RuntimeException ) pValue[i].Value >>= xInputStream; } + if (!xInputStream.is()) + return ::rtl::OUString(); + WPXSvInputStream input( xInputStream ); if (libcdr::CDRDocument::isSupported(&input)) diff --git a/writerperfect/source/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx index 9d53df3..8854490 100644 --- a/writerperfect/source/draw/CMXImportFilter.cxx +++ b/writerperfect/source/draw/CMXImportFilter.cxx @@ -39,7 +39,6 @@ using com::sun::star::io::XInputStream; using com::sun::star::io::XSeekable; using com::sun::star::uno::Sequence; using namespace ::rtl; -using rtl::OString; using rtl::OUString; using com::sun::star::uno::Sequence; using com::sun::star::uno::Reference; @@ -74,16 +73,12 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { OSL_ASSERT( 0 ); return sal_False; } - OString sFileName; - sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII); // An XML import service: what we push sax messages to.. OUString sXMLImportService ( "com.sun.star.comp.Draw.XMLOasisImporter" ); @@ -142,6 +137,9 @@ throw( com::sun::star::uno::RuntimeException ) pValue[i].Value >>= xInputStream; } + if (!xInputStream.is()) + return ::rtl::OUString(); + WPXSvInputStream input( xInputStream ); if (libcdr::CMXDocument::isSupported(&input)) diff --git a/writerperfect/source/draw/MSPUBImportFilter.cxx b/writerperfect/source/draw/MSPUBImportFilter.cxx index 5f886ab..b80b6d6 100644 --- a/writerperfect/source/draw/MSPUBImportFilter.cxx +++ b/writerperfect/source/draw/MSPUBImportFilter.cxx @@ -35,7 +35,6 @@ using com::sun::star::io::XInputStream; using com::sun::star::io::XSeekable; using com::sun::star::uno::Sequence; using namespace ::rtl; -using rtl::OString; using rtl::OUString; using com::sun::star::uno::Sequence; using com::sun::star::uno::Reference; @@ -70,16 +69,12 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { OSL_ASSERT( 0 ); return sal_False; } - OString sFileName; - sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII); // An XML import service: what we push sax messages to.. OUString sXMLImportService ( "com.sun.star.comp.Draw.XMLOasisImporter" ); @@ -138,6 +133,9 @@ throw( com::sun::star::uno::RuntimeException ) pValue[i].Value >>= xInputStream; } + if (!xInputStream.is()) + return ::rtl::OUString(); + WPXSvInputStream input( xInputStream ); if (libmspub::MSPUBDocument::isSupported(&input)) diff --git a/writerperfect/source/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx index 291f358..9b39b64 100644 --- a/writerperfect/source/draw/VisioImportFilter.cxx +++ b/writerperfect/source/draw/VisioImportFilter.cxx @@ -35,7 +35,6 @@ using com::sun::star::io::XInputStream; using com::sun::star::io::XSeekable; using com::sun::star::uno::Sequence; using namespace ::rtl; -using rtl::OString; using rtl::OUString; using com::sun::star::uno::Sequence; using com::sun::star::uno::Reference; @@ -70,16 +69,12 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { OSL_ASSERT( 0 ); return sal_False; } - OString sFileName; - sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII); // An XML import service: what we push sax messages to.. OUString sXMLImportService ( "com.sun.star.comp.Draw.XMLOasisImporter" ); @@ -138,6 +133,9 @@ throw( com::sun::star::uno::RuntimeException ) pValue[i].Value >>= xInputStream; } + if (!xInputStream.is()) + return ::rtl::OUString(); + WPXSvInputStream input( xInputStream ); if (libvisio::VisioDocument::isSupported(&input)) diff --git a/writerperfect/source/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx index 7538ee9..b142e1a 100644 --- a/writerperfect/source/draw/WPGImportFilter.cxx +++ b/writerperfect/source/draw/WPGImportFilter.cxx @@ -40,7 +40,6 @@ using com::sun::star::io::XInputStream; using com::sun::star::io::XSeekable; using com::sun::star::uno::Sequence; using namespace ::rtl; -using rtl::OString; using rtl::OUString; using com::sun::star::uno::Sequence; using com::sun::star::uno::Reference; @@ -75,16 +74,12 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { OSL_ASSERT( 0 ); return sal_False; } - OString sFileName; - sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII); // An XML import service: what we push sax messages to.. OUString sXMLImportService ( "com.sun.star.comp.Draw.XMLOasisImporter" ); @@ -143,6 +138,9 @@ throw( com::sun::star::uno::RuntimeException ) pValue[i].Value >>= xInputStream; } + if (!xInputStream.is()) + return ::rtl::OUString(); + WPXSvInputStream input( xInputStream ); if (libwpg::WPGraphics::isSupported(&input)) diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx index 0c15e30..4ef2b0e 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.cxx +++ b/writerperfect/source/writer/MSWorksImportFilter.cxx @@ -19,7 +19,6 @@ #include <com/sun/star/xml/sax/XParser.hpp> #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <comphelper/componentcontext.hxx> #include <xmloff/attrlist.hxx> @@ -36,7 +35,6 @@ #include <iostream> using namespace ::com::sun::star::uno; -using rtl::OString; using rtl::OUString; using com::sun::star::uno::Sequence; using com::sun::star::uno::Reference; @@ -72,16 +70,12 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { OSL_ASSERT( 0 ); return sal_False; } - OString sFileName; - sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII); // An XML import service: what we push sax messages to.. OUString sXMLImportService ( "com.sun.star.comp.Writer.XMLOasisImporter" ); @@ -142,26 +136,10 @@ throw( com::sun::star::uno::RuntimeException ) location=i; else if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } - Reference< com::sun::star::ucb::XCommandEnvironment > xEnv; if (!xInputStream.is()) - { - try - { - ::ucbhelper::Content aContent(sURL, xEnv, mxContext); - xInputStream = aContent.openStream(); - } - catch ( ... ) - { - return ::rtl::OUString(); - } - - if (!xInputStream.is()) - return ::rtl::OUString(); - } + return ::rtl::OUString(); WPXSvInputStream input( xInputStream ); diff --git a/writerperfect/source/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx index cf1c61f..b4adfba 100644 --- a/writerperfect/source/writer/WordPerfectImportFilter.cxx +++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx @@ -19,7 +19,6 @@ #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <comphelper/componentcontext.hxx> #include <xmloff/attrlist.hxx> @@ -100,8 +99,6 @@ throw (RuntimeException) { if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } if ( !xInputStream.is() ) { @@ -194,26 +191,10 @@ throw( RuntimeException ) location=i; else if ( pValue[i].Name == "InputStream" ) pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; } - Reference< com::sun::star::ucb::XCommandEnvironment > xEnv; if (!xInputStream.is()) - { - try - { - Content aContent(sURL, xEnv, mxContext); - xInputStream = aContent.openStream(); - } - catch ( ... ) - { - return OUString(); - } - - if (!xInputStream.is()) - return OUString(); - } + return OUString(); WPXSvInputStream input( xInputStream );
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits