Kaydet (Commit) 3ca1c14e authored tarafından Aidan Butler's avatar Aidan Butler

*** empty log message ***

üst acd4dca6
/*************************************************************************
*
* $RCSfile: XmlFilterAdaptor.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: aidan $ $Date: 2002-04-09 09:03:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): Martin Gallwey (gallwey@sun.com)
*
*
************************************************************************/
#ifndef _XMLFILTERADAPTOR_HXX
#define _XMLFILTERADAPTOR_HXX
#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
#include <com/sun/star/document/XFilter.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
#include <com/sun/star/document/XExporter.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
#include <com/sun/star/document/XImporter.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
#include <com/sun/star/lang/XInitialization.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE5_HXX_
#include <cppuhelper/implbase5.hxx>
#endif
enum FilterType
{
FILTER_IMPORT,
FILTER_EXPORT
};
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class XmlFilterAdaptor : public cppu::WeakImplHelper5
<
com::sun::star::document::XFilter,
com::sun::star::document::XExporter,
com::sun::star::document::XImporter,
com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo
>
{
protected:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
::rtl::OUString msFilterName;
::com::sun::star::uno::Sequence< ::rtl::OUString > msUserData;
FilterType meType;
sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (::com::sun::star::uno::RuntimeException);
sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (::com::sun::star::uno::RuntimeException);
public:
XmlFilterAdaptor( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
: mxMSF( rxMSF ) {}
virtual ~XmlFilterAdaptor() {}
// XFilter
virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL cancel( )
throw (::com::sun::star::uno::RuntimeException);
// XExporter
virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
// XImporter
virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( )
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException);
};
::rtl::OUString XmlFilterAdaptor_getImplementationName()
throw ( ::com::sun::star::uno::RuntimeException );
sal_Bool SAL_CALL XmlFilterAdaptor_supportsService( const ::rtl::OUString& ServiceName )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL XmlFilterAdaptor_getSupportedServiceNames( )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL XmlFilterAdaptor_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
throw ( ::com::sun::star::uno::Exception );
#endif
/*************************************************************************
*
* $RCSfile: genericfilter.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: aidan $ $Date: 2002-04-09 09:03:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#include <osl/mutex.hxx>
#include <osl/thread.h>
#include <cppuhelper/factory.hxx>
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
#include "XmlFilterAdaptor.hxx"
using namespace ::rtl;
using namespace ::cppu;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
extern "C"
{
//==================================================================================================
void SAL_CALL component_getImplementationEnvironment(
const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
//==================================================================================================
sal_Bool SAL_CALL component_writeInfo(
void * pServiceManager, void * pRegistryKey )
{
if (pRegistryKey)
{
try
{
Reference< XRegistryKey > xNewKey(
reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( XmlFilterAdaptor_getImplementationName() ) );
xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
const Sequence< OUString > & rSNL = XmlFilterAdaptor_getSupportedServiceNames();
const OUString * pArray = rSNL.getConstArray();
for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
xNewKey->createKey( pArray[nPos] );
return sal_True;
}
catch (InvalidRegistryException &)
{
OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
}
}
return sal_False;
}
//==================================================================================================
void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
{
void * pRet = 0;
OUString implName = OUString::createFromAscii( pImplName );
if ( pServiceManager && implName.equals(XmlFilterAdaptor_getImplementationName()) )
{
Reference< XSingleServiceFactory > xFactory( createSingleFactory(
reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
OUString::createFromAscii( pImplName ),
XmlFilterAdaptor_createInstance, XmlFilterAdaptor_getSupportedServiceNames() ) );
if (xFactory.is())
{
xFactory->acquire();
pRet = xFactory.get();
}
}
return pRet;
}
}
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: aidan $ $Date: 2002-04-09 09:03:43 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (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.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME= filter
TARGET= fl_xmlfilteradaptor
USE_DEFFILE= TRUE
NO_BSYMBOLIC= TRUE
ENABLE_EXCEPTIONS= TRUE
BOOTSTRAP_SERVICE= FALSE
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- defines ------------------------------------------------------
CDEFS+=-DCOMPMOD_NAMESPACE=framework
# --- Generate -----------------------------------------------------
SLOFILES= $(SLO)/XmlFilterAdaptor.obj \
$(SLO)/genericfilter.obj \
$(SLO)/streamwrap.obj
# --- Targets ------------------------------------------------------
SHL1TARGET= xmlfilteradaptor$(DLLPOSTFIX)
SHL1IMPLIB= i$(SHL1TARGET)
SHL1OBJS= $(SLO)$/genericfilter.obj \
$(SLO)$/XmlFilterAdaptor.obj\
$(SLO)$/streamwrap.obj
SHL1STDLIBS= $(CPPULIB) \
$(CPPUHELPERLIB) \
$(VOSLIB) \
$(SALLIB) \
$(TOOLSLIB) \
$(SVTOOLLIB) \
$(TKLIB) \
$(SVLIB) \
$(COMPHELPERLIB) \
$(UCBHELPERLIB) \
$(UNOTOOLSLIB) \
$(FWELIB) \
$(FWILIB) \
$(SVLLIB) \
$(SOTLIB)
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
DEF1EXPORTFILE= exports.dxp
.INCLUDE : target.mk
This diff is collapsed.
/*************************************************************************
*
* $RCSfile: streamwrap.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: aidan $ $Date: 2002-04-09 09:03:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _OSL_FILE_WRAPPER_HXX_
#define _OSL_FILE_WRAPPER_HXX_
#ifndef _OSL_MUTEX_HXX_ //autogen wg. ::osl::Mutex
#include <osl/mutex.hxx>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
#include <com/sun/star/io/XInputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#define DECLARE_UNO3_AGG_DEFAULTS(classname, baseclass) \
virtual void SAL_CALL acquire() throw() { baseclass::acquire(); } \
virtual void SAL_CALL release() throw() { baseclass::release(); } \
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) \
{ return baseclass::queryInterface(_rType); } \
void SAL_CALL PUT_SEMICOLON_AT_THE_END()
namespace osl
{
class File;
}
namespace foo
{
namespace stario = ::com::sun::star::io;
namespace staruno = ::com::sun::star::uno;
//==================================================================
//= OInputFileWrapper
//==================================================================
typedef ::cppu::WeakImplHelper1 < stario::XInputStream
> InputStreamWrapper_Base;
// needed for some compilers
/// helper class for wrapping a File into an <type scope="com.sun.star.io">XInputStream</type>
class OInputStreamWrapper : public InputStreamWrapper_Base
{
protected:
::osl::Mutex m_aMutex;
::osl::File* m_pSvStream;
sal_Bool m_bSvStreamOwner : 1;
public:
OInputStreamWrapper(::osl::File& _rStream);
OInputStreamWrapper(::osl::File* pStream, sal_Bool bOwner=sal_False);
virtual ~OInputStreamWrapper();
// UNO Anbindung
DECLARE_UNO3_AGG_DEFAULTS(OInputStreamWrapper, InputStreamWrapper_Base);
// stario::XInputStream
virtual sal_Int32 SAL_CALL readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
virtual sal_Int32 SAL_CALL readSomeBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
virtual sal_Int32 SAL_CALL available() throw(stario::NotConnectedException, staruno::RuntimeException);
virtual void SAL_CALL closeInput() throw(stario::NotConnectedException, staruno::RuntimeException);
protected:
/// throws a NotConnectedException if the object is not connected anymore
void checkConnected() const;
/// throws an exception according to the error flag of m_pSvStream
void checkError() const;
};
//==================================================================
//= OSeekableInputFIleWrapper
//==================================================================
typedef ::cppu::ImplHelper1 < ::com::sun::star::io::XSeekable
> OSeekableInputStreamWrapper_Base;
/** helper class for wrapping an File into an <type scope="com.sun.star.io">XInputStream</type>
which is seekable (i.e. supports the <type scope="com.sun.star.io">XSeekable</type> interface).
*/
class OSeekableInputStreamWrapper
:public OInputStreamWrapper
,public OSeekableInputStreamWrapper_Base
{
public:
OSeekableInputStreamWrapper(::osl::File& _rStream);
OSeekableInputStreamWrapper(::osl::File* _pStream, sal_Bool _bOwner = sal_False);
// disambiguate XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire( ) throw ();
virtual void SAL_CALL release( ) throw ();
// XSeekable
virtual void SAL_CALL seek( sal_Int64 _nLocation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int64 SAL_CALL getPosition( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int64 SAL_CALL getLength( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
};
//==================================================================
//= OOutputStreamWrapper
//==================================================================
typedef ::cppu::WeakImplHelper1<stario::XOutputStream> OutputStreamWrapper_Base;
// needed for some compilers
class OOutputStreamWrapper : public OutputStreamWrapper_Base
{
::osl::File& rStream;
public:
OOutputStreamWrapper(::osl::File& _rStream) :rStream(_rStream) { }
// UNO Anbindung
DECLARE_UNO3_AGG_DEFAULTS(OOutputStreamWrapper, OutputStreamWrapper_Base);
// stario::XOutputStream
virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
virtual void SAL_CALL flush() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
virtual void SAL_CALL closeOutput() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
};
} // namespace utl
#endif // _UTL_STREAM_WRAPPER_HXX_
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