summaryrefslogtreecommitdiff
path: root/filter/source/xsltdialog/xmlfiltertestdialog.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/xsltdialog/xmlfiltertestdialog.cxx')
-rw-r--r--filter/source/xsltdialog/xmlfiltertestdialog.cxx69
1 files changed, 30 insertions, 39 deletions
diff --git a/filter/source/xsltdialog/xmlfiltertestdialog.cxx b/filter/source/xsltdialog/xmlfiltertestdialog.cxx
index 032e00782a7b..e89ecc2d13d3 100644
--- a/filter/source/xsltdialog/xmlfiltertestdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltertestdialog.cxx
@@ -38,11 +38,12 @@
#include <com/sun/star/xml/sax/Writer.hpp>
#include <comphelper/oslfile2streamwrap.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/filedlghelper.hxx>
#include <osl/file.hxx>
#include <unotools/tempfile.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
#include <comphelper/processfactory.hxx>
@@ -198,7 +199,7 @@ void XMLFilterTestDialog::test( const filter_info_impl& rFilterInfo )
m_xDialog->run();
}
-static OUString getFileNameFromURL( OUString const & rURL )
+static OUString getFileNameFromURL( std::u16string_view rURL )
{
INetURLObject aURL( rURL );
OUString aName( aURL.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset) );
@@ -309,7 +310,7 @@ void XMLFilterTestDialog::onExportBrowse()
int nFound = 0;
- for( const PropertyValue& rValue : std::as_const(aValues) )
+ for (const PropertyValue& rValue : aValues)
{
if ( rValue.Name == "Type" )
{
@@ -347,7 +348,7 @@ void XMLFilterTestDialog::onExportBrowse()
if( aAny >>= aValues2 )
{
OUString aExtension;
- for( const PropertyValue& rProp : std::as_const(aValues2) )
+ for (const PropertyValue& rProp : aValues2)
{
if ( rProp.Name == "Extensions" )
{
@@ -388,9 +389,8 @@ void XMLFilterTestDialog::onExportBrowse()
Reference< XDesktop2 > xLoader = Desktop::create( mxContext );
Reference< XInteractionHandler2 > xInter = InteractionHandler::createWithParent(mxContext, nullptr);
- Sequence< PropertyValue > aArguments(1);
- aArguments[0].Name = "InteractionHandler";
- aArguments[0].Value <<= xInter;
+ Sequence< PropertyValue > aArguments{ comphelper::makePropertyValue("InteractionHandler",
+ xInter) };
Reference< XComponent > xComp( xLoader->loadComponentFromURL( m_sExportRecentFile, "_default", 0, aArguments ) );
if( xComp.is() )
{
@@ -418,33 +418,33 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp )
Reference< XStorable > xStorable( xComp, UNO_QUERY );
if( xStorable.is() )
{
- OUString const ext(".xml");
- utl::TempFile aTempFile(OUString(), true, &ext);
+ utl::TempFileNamed aTempFile(u"", true, u".xml");
OUString aTempFileURL( aTempFile.GetURL() );
const application_info_impl* pAppInfo = getApplicationInfo( m_xFilterInfo->maExportService );
if( pAppInfo )
{
File aOutputFile( aTempFileURL );
- /* File::RC rc = */ aOutputFile.open( osl_File_OpenFlag_Write );
+ (void)aOutputFile.open( osl_File_OpenFlag_Write );
// create xslt exporter
Reference< XOutputStream > xIS( new comphelper::OSLOutputStreamWrapper( aOutputFile ) );
int bUseDocType = m_xFilterInfo->maDocType.isEmpty() ? 0 : 1;
Sequence< PropertyValue > aSourceData( 2 + bUseDocType );
+ auto pSourceData = aSourceData.getArray();
int i = 0;
- aSourceData[i ].Name = "OutputStream";
- aSourceData[i++].Value <<= xIS;
+ pSourceData[i ].Name = "OutputStream";
+ pSourceData[i++].Value <<= xIS;
- aSourceData[i].Name = "Indent";
- aSourceData[i++].Value <<= true;
+ pSourceData[i].Name = "Indent";
+ pSourceData[i++].Value <<= true;
if( bUseDocType )
{
- aSourceData[i ].Name = "DocType_Public";
- aSourceData[i++].Value <<= m_xFilterInfo->maDocType;
+ pSourceData[i ].Name = "DocType_Public";
+ pSourceData[i++].Value <<= m_xFilterInfo->maDocType;
}
Reference< XExportFilter > xExporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY );
@@ -490,9 +490,8 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp )
{
xExporter2->setSourceDocument( xComp );
- Sequence< PropertyValue > aDescriptor( 1 );
- aDescriptor[0].Name = "FileName";
- aDescriptor[0].Value <<= aTempFileURL;
+ Sequence< PropertyValue > aDescriptor{comphelper::makePropertyValue(
+ "FileName", aTempFileURL) };
if( xFilter->filter( aDescriptor ) )
displayXMLFile( aTempFileURL );
@@ -569,44 +568,36 @@ void XMLFilterTestDialog::import( const OUString& rURL )
Reference< XDesktop2 > xLoader = Desktop::create( mxContext );
Reference< XInteractionHandler2 > xInter = InteractionHandler::createWithParent(mxContext, nullptr);
- Sequence< PropertyValue > aArguments(2);
- aArguments[0].Name = "FilterName";
- aArguments[0].Value <<= m_xFilterInfo->maFilterName;
- aArguments[1].Name = "InteractionHandler";
- aArguments[1].Value <<= xInter;
+ Sequence< PropertyValue > aArguments{
+ comphelper::makePropertyValue("FilterName", m_xFilterInfo->maFilterName),
+ comphelper::makePropertyValue("InteractionHandler", xInter)
+ };
xLoader->loadComponentFromURL( rURL, "_default", 0, aArguments );
if( m_xCBXDisplaySource->get_active() )
{
- OUString const ext(".xml");
- TempFile aTempFile(OUString(), true, &ext);
+ TempFileNamed aTempFile(u"", true, u".xml");
OUString aTempFileURL( aTempFile.GetURL() );
Reference< XImportFilter > xImporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY );
if( xImporter.is() )
{
osl::File aInputFile( rURL );
- aInputFile.open( osl_File_OpenFlag_Read );
+ (void)aInputFile.open( osl_File_OpenFlag_Read );
Reference< XInputStream > xIS( new comphelper::OSLInputStreamWrapper( aInputFile ) );
- Sequence< PropertyValue > aSourceData( 3 );
- int i = 0;
-
- aSourceData[i ].Name = "InputStream";
- aSourceData[i++].Value <<= xIS;
-
- aSourceData[i ].Name = "FileName";
- aSourceData[i++].Value <<= rURL;
-
- aSourceData[i ].Name = "Indent";
- aSourceData[i++].Value <<= true;
+ Sequence< PropertyValue > aSourceData{
+ comphelper::makePropertyValue("InputStream", xIS),
+ comphelper::makePropertyValue("FileName", rURL),
+ comphelper::makePropertyValue("Indent", true)
+ };
Reference< XWriter > xWriter = Writer::create( mxContext );
File aOutputFile( aTempFileURL );
- aOutputFile.open( osl_File_OpenFlag_Write );
+ (void)aOutputFile.open( osl_File_OpenFlag_Write );
Reference< XOutputStream > xOS( new OSLOutputStreamWrapper( aOutputFile ) );
xWriter->setOutputStream( xOS );