Kaydet (Commit) ff85e831 authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, convert io::TextInputStream service to new style

Change-Id: Ida4abdd6587399aa8ade88af672bcb23ab7ea0f1
üst a7ecab87
......@@ -29,7 +29,7 @@
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/io/XTextOutputStream.hpp>
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/TextInputStream.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/util/XModifiable.hpp>
......@@ -59,6 +59,7 @@ namespace dbaccess
using ::com::sun::star::uno::makeAny;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Type;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::embed::XStorage;
using ::com::sun::star::frame::XController;
using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
......@@ -68,7 +69,8 @@ namespace dbaccess
using ::com::sun::star::io::XStream;
using ::com::sun::star::io::XTextOutputStream;
using ::com::sun::star::io::XActiveDataSource;
using ::com::sun::star::io::XTextInputStream;
using ::com::sun::star::io::TextInputStream;
using ::com::sun::star::io::XTextInputStream2;
using ::com::sun::star::io::XActiveDataSink;
using ::com::sun::star::frame::XModel;
using ::com::sun::star::util::XModifiable;
......@@ -179,7 +181,7 @@ namespace dbaccess
}
// .........................................................................
static void lcl_readObjectMap_throw( const ::comphelper::ComponentContext& i_rContext, const Reference< XStorage >& i_rStorage,
static void lcl_readObjectMap_throw( const Reference<XComponentContext> & i_rxContext, const Reference< XStorage >& i_rStorage,
MapStringToCompDesc& o_mapStorageToObjectName )
{
ENSURE_OR_THROW( i_rStorage.is(), "invalid storage" );
......@@ -192,11 +194,9 @@ namespace dbaccess
Reference< XStream > xIniStream( i_rStorage->openStreamElement(
lcl_getObjectMapStreamName(), ElementModes::READ ), UNO_SET_THROW );
Reference< XTextInputStream > xTextInput( i_rContext.createComponent( "com.sun.star.io.TextInputStream" ), UNO_QUERY_THROW );
Reference< XTextInputStream2 > xTextInput = TextInputStream::create( i_rxContext );
xTextInput->setEncoding( lcl_getMapStreamEncodingName() );
Reference< XActiveDataSink > xDataSink( xTextInput, UNO_QUERY_THROW );
xDataSink->setInputStream( xIniStream->getInputStream() );
xTextInput->setInputStream( xIniStream->getInputStream() );
::rtl::OUString sCurrentSection;
bool bCurrentSectionIsKnownToBeUnsupported = true;
......@@ -352,7 +352,7 @@ namespace dbaccess
Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement(
SubComponentRecovery::getComponentsStorageName( aKnownTypes[i] ), ElementModes::READ ) );
lcl_readObjectMap_throw( m_pData->aContext, xComponentsStor, aMapCompDescs[ aKnownTypes[i] ] );
lcl_readObjectMap_throw( m_pData->aContext.getUNOContext(), xComponentsStor, aMapCompDescs[ aKnownTypes[i] ] );
xComponentsStor->dispose();
}
......
......@@ -31,6 +31,7 @@
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/debug.hxx>
#include <comphelper/processfactory.hxx>
// UNO classes
#include <com/sun/star/xml/dom/XNode.hpp>
......@@ -42,7 +43,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/TextInputStream.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/frame/XModel.hpp>
......@@ -57,7 +58,8 @@ using rtl::OUStringBuffer;
using com::sun::star::beans::PropertyValue;
using com::sun::star::io::XInputStream;
using com::sun::star::io::XActiveDataSink;
using com::sun::star::io::XTextInputStream;
using com::sun::star::io::TextInputStream;
using com::sun::star::io::XTextInputStream2;
using com::sun::star::container::XEnumeration;
using com::sun::star::container::XNameContainer;
using com::sun::star::xforms::XFormsSupplier;
......@@ -838,11 +840,8 @@ static OUString lcl_serializeForDisplay( const Reference<XNodeList>& xNodes )
aSerialization.serialize();
// copy stream into buffer
Reference<XTextInputStream> xTextInputStream(
createInstance( "com.sun.star.io.TextInputStream" ),
UNO_QUERY );
Reference<XActiveDataSink>( xTextInputStream, UNO_QUERY_THROW )
->setInputStream( aSerialization.getInputStream() );
Reference<XTextInputStream2> xTextInputStream = TextInputStream::create( comphelper::getProcessComponentContext() );
xTextInputStream->setInputStream( aSerialization.getInputStream() );
/* WORK AROUND for problem in serialization: currently, multiple
XML delarations (<?xml...?>) are being written out and we don't
......
......@@ -46,17 +46,6 @@ using com::sun::star::beans::PropertyAttribute::READONLY;
using rtl::OUString;
Reference<XInterface> xforms::createInstance( const OUString& sServiceName )
{
Reference<XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
OSL_ENSURE( xFactory.is(), "can't get service factory" );
Reference<XInterface> xInstance = xFactory->createInstance( sServiceName );
OSL_ENSURE( xInstance.is(), "failed to create instance" );
return xInstance;
}
void xforms::copy( const Reference<XPropertySet>& xFrom,
Reference<XPropertySet>& xTo )
{
......
......@@ -35,10 +35,6 @@ namespace com { namespace sun { namespace star {
namespace xforms
{
/** instantiate a UNO service using the process global service factory */
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
createInstance( const rtl::OUString& sServiceName );
/** copy the properties from one PropertySet into the next */
void copy( const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& , com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& );
......
......@@ -25,14 +25,13 @@
#include <uno/mapping.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <rtl/textenc.h>
#include <rtl/tencinfo.h>
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XTextInputStream2.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
......@@ -54,7 +53,7 @@ namespace io_TextInputStream
//===========================================================================
// Implementation XTextInputStream
typedef WeakImplHelper3< XTextInputStream, XActiveDataSink, XServiceInfo > TextInputStreamHelper;
typedef WeakImplHelper2< XTextInputStream2, XServiceInfo > TextInputStreamHelper;
#define INITIAL_UNICODE_BUFFER_CAPACITY 0x100
#define READ_BYTE_COUNT 0x100
......
......@@ -25,7 +25,7 @@
namespace com { namespace sun { namespace star {
namespace io { class XInputStream; }
namespace io { class XTextInputStream; }
namespace io { class XTextInputStream2; }
namespace uno { class XComponentContext; }
} } }
......@@ -91,7 +91,7 @@ public:
/** Creates a UNO text input stream object from the passed UNO input stream.
*/
static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream >
static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream2 >
createXTextInputStream(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
......@@ -108,7 +108,7 @@ private:
::rtl::OUString createFinalString( const ::rtl::OUString& rString );
private:
::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream >
::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream2 >
mxTextStrm;
sal_Unicode mcPendingChar;
};
......
......@@ -25,7 +25,7 @@
#include <rtl/string.hxx>
namespace com { namespace sun { namespace star {
namespace io { class XTextInputStream; }
namespace io { class XTextInputStream2; }
namespace uno { class XComponentContext; }
} } }
......@@ -78,7 +78,7 @@ private:
::rtl::OString readToElementEnd() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
private:
::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream >
::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream2 >
mxTextStrm;
::com::sun::star::uno::Sequence< sal_Unicode > maOpeningBracket;
::com::sun::star::uno::Sequence< sal_Unicode > maClosingBracket;
......
......@@ -20,7 +20,7 @@
#include "oox/helper/textinputstream.hxx"
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/TextInputStream.hpp>
#include <cppuhelper/implbase1.hxx>
#include <rtl/tencinfo.h>
#include "oox/helper/binaryinputstream.hxx"
......@@ -184,18 +184,16 @@ OUString TextInputStream::readToChar( sal_Unicode cChar, bool bIncludeChar )
return OUString();
}
/*static*/ Reference< XTextInputStream > TextInputStream::createXTextInputStream(
/*static*/ Reference< XTextInputStream2 > TextInputStream::createXTextInputStream(
const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm, rtl_TextEncoding eTextEnc )
{
Reference< XTextInputStream > xTextStrm;
Reference< XTextInputStream2 > xTextStrm;
const char* pcCharset = rtl_getBestMimeCharsetFromTextEncoding( eTextEnc );
OSL_ENSURE( pcCharset, "TextInputStream::createXTextInputStream - unsupported text encoding" );
if( rxContext.is() && rxInStrm.is() && pcCharset ) try
{
Reference< XMultiServiceFactory > xFactory( rxContext->getServiceManager(), UNO_QUERY_THROW );
Reference< XActiveDataSink > xDataSink( xFactory->createInstance( "com.sun.star.io.TextInputStream" ), UNO_QUERY_THROW );
xDataSink->setInputStream( rxInStrm );
xTextStrm.set( xDataSink, UNO_QUERY_THROW );
xTextStrm = com::sun::star::io::TextInputStream::create( rxContext );
xTextStrm->setInputStream( rxInStrm );
xTextStrm->setEncoding( OUString::createFromAscii( pcCharset ) );
}
catch (const Exception&)
......
......@@ -19,7 +19,7 @@
#include "oox/vml/vmlinputstream.hxx"
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/XTextInputStream2.hpp>
#include <map>
#include <string.h>
#include <rtl/strbuf.hxx>
......
......@@ -19,7 +19,7 @@
#include "stringresource.hxx"
#include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/TextInputStream.hpp>
#include <com/sun/star/io/XTextOutputStream.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
......@@ -1969,7 +1969,7 @@ sal_Unicode getEscapeChar( const sal_Unicode* pBuf, sal_Int32 nLen, sal_Int32& r
return cRet;
}
void CheckContinueInNextLine( Reference< io::XTextInputStream > xTextInputStream,
void CheckContinueInNextLine( Reference< io::XTextInputStream2 > xTextInputStream,
::rtl::OUString& aLine, bool& bEscapePending, const sal_Unicode*& pBuf,
sal_Int32& nLen, sal_Int32& i )
{
......@@ -1996,18 +1996,11 @@ bool StringResourcePersistenceImpl::implReadPropertiesFile
return false;
bool bSuccess = false;
Reference< XMultiComponentFactory > xMCF = getMultiComponentFactory();
Reference< io::XTextInputStream > xTextInputStream( xMCF->createInstanceWithContext
( ::rtl::OUString("com.sun.star.io.TextInputStream"), m_xContext ), UNO_QUERY );
Reference< io::XTextInputStream2 > xTextInputStream = io::TextInputStream::create( m_xContext );
if( xTextInputStream.is() )
{
Reference< io::XActiveDataSink> xActiveDataSink( xTextInputStream, UNO_QUERY );
if( xActiveDataSink.is() )
{
bSuccess = true;
xActiveDataSink->setInputStream( xInputStream );
xTextInputStream->setInputStream( xInputStream );
::rtl::OUString aEncodingStr = ::rtl::OUString::createFromAscii
( rtl_getMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
......@@ -2116,8 +2109,6 @@ bool StringResourcePersistenceImpl::implReadPropertiesFile
IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap;
rIndexMap[ aResourceID ] = pLocaleItem->m_nNextIndex++;
}
}
}
return bSuccess;
}
......
......@@ -65,7 +65,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/io,\
ObjectInputStream \
ObjectOutputStream \
Pump \
TextInputStream \
TextOutputStream \
))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/lang,\
......@@ -116,6 +115,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/io,\
SequenceInputStream \
SequenceOutputStream \
TempFile \
TextInputStream \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/java,\
JavaVirtualMachine \
......@@ -321,6 +321,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,udkapi,udkapi/com/sun/star/io,\
XStreamListener \
XTempFile \
XTextInputStream \
XTextInputStream2 \
XTextOutputStream \
XTruncate \
XXMLExtractor \
......
......@@ -19,12 +19,9 @@
#ifndef __com_sun_star_io_TextInputStream_idl__
#define __com_sun_star_io_TextInputStream_idl__
#include <com/sun/star/io/XTextInputStream.idl>
#include <com/sun/star/io/XTextInputStream2.idl>
#include <com/sun/star/io/XActiveDataSink.idl>
#include <com/sun/star/io/XConnectable.idl>
module com { module sun { module star { module io {
......@@ -37,15 +34,7 @@ module com { module sun { module star { module io {
<p>For details about the text functionality see
<type scope="com::sun::star::io">XTextInputStream</type>.
*/
published service TextInputStream
{
/// Interface to read text data
interface com::sun::star::io::XTextInputStream;
/// Interface to specify the used <type scope="com::sun::star::io">XInputStream</type>
interface com::sun::star::io::XActiveDataSink;
};
published service TextInputStream : XTextInputStream2;
}; }; }; };
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __com_sun_star_io_XTextInputStream2_idl__
#define __com_sun_star_io_XTextInputStream2_idl__
#include <com/sun/star/io/XTextInputStream.idl>
#include <com/sun/star/io/XActiveDataSink.idl>
module com { module sun { module star { module io {
/** Provides a unified interface for the new-style service TextInputStream.
@since LibreOffice 4.1
*/
published interface XTextInputStream2
{
/// Interface to read text data
interface com::sun::star::io::XTextInputStream;
/// Interface to specify the used <type scope="com::sun::star::io">XInputStream</type>
interface com::sun::star::io::XActiveDataSink;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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