summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2013-04-19 18:54:16 +0200
committerDavid Tardon <dtardon@redhat.com>2013-04-24 05:17:10 +0000
commit6c7659b584ea7ed3652ca4eb9a2297f36310c365 (patch)
treeadf631e2d3db309b0696babd9d026bce0996c215 /include
parent24500d6798007d84521eb24a81c121ebe69d3bfd (diff)
move URE headers to include/
Change-Id: Ib48a12e902f2311c295b2007f08f44dee28f431d Reviewed-on: https://gerrit.libreoffice.org/3499 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/com/sun/star/uno/Any.h376
-rw-r--r--include/com/sun/star/uno/Any.hxx596
-rw-r--r--include/com/sun/star/uno/Reference.h519
-rw-r--r--include/com/sun/star/uno/Reference.hxx423
-rw-r--r--include/com/sun/star/uno/Sequence.h282
-rw-r--r--include/com/sun/star/uno/Sequence.hxx306
-rw-r--r--include/com/sun/star/uno/Type.h460
-rw-r--r--include/com/sun/star/uno/Type.hxx321
-rw-r--r--include/com/sun/star/uno/genfunc.h63
-rw-r--r--include/com/sun/star/uno/genfunc.hxx82
-rw-r--r--include/cppu/Enterable.hxx108
-rw-r--r--include/cppu/EnvDcp.hxx69
-rw-r--r--include/cppu/EnvGuards.hxx107
-rw-r--r--include/cppu/Map.hxx107
-rw-r--r--include/cppu/cppudllapi.h21
-rw-r--r--include/cppu/helper/purpenv/Environment.hxx42
-rw-r--r--include/cppu/helper/purpenv/Mapping.hxx63
-rw-r--r--include/cppu/macros.hxx58
-rw-r--r--include/cppu/unotype.hxx375
-rw-r--r--include/cppuhelper/access_control.hxx119
-rw-r--r--include/cppuhelper/basemutex.hxx43
-rw-r--r--include/cppuhelper/bootstrap.hxx167
-rw-r--r--include/cppuhelper/compbase.hxx107
-rw-r--r--include/cppuhelper/compbase1.hxx158
-rw-r--r--include/cppuhelper/compbase10.hxx158
-rw-r--r--include/cppuhelper/compbase11.hxx158
-rw-r--r--include/cppuhelper/compbase12.hxx158
-rw-r--r--include/cppuhelper/compbase2.hxx159
-rw-r--r--include/cppuhelper/compbase3.hxx158
-rw-r--r--include/cppuhelper/compbase4.hxx158
-rw-r--r--include/cppuhelper/compbase5.hxx158
-rw-r--r--include/cppuhelper/compbase6.hxx158
-rw-r--r--include/cppuhelper/compbase7.hxx158
-rw-r--r--include/cppuhelper/compbase8.hxx158
-rw-r--r--include/cppuhelper/compbase9.hxx157
-rw-r--r--include/cppuhelper/compbase_ex.hxx168
-rw-r--r--include/cppuhelper/component.hxx113
-rw-r--r--include/cppuhelper/component_context.hxx91
-rw-r--r--include/cppuhelper/cppuhelperdllapi.h34
-rw-r--r--include/cppuhelper/exc_hlp.hxx94
-rw-r--r--include/cppuhelper/factory.hxx279
-rw-r--r--include/cppuhelper/findsofficepath.h39
-rw-r--r--include/cppuhelper/implbase.hxx296
-rw-r--r--include/cppuhelper/implbase1.hxx296
-rw-r--r--include/cppuhelper/implbase10.hxx296
-rw-r--r--include/cppuhelper/implbase11.hxx297
-rw-r--r--include/cppuhelper/implbase12.hxx298
-rw-r--r--include/cppuhelper/implbase13.hxx299
-rw-r--r--include/cppuhelper/implbase2.hxx287
-rw-r--r--include/cppuhelper/implbase3.hxx289
-rw-r--r--include/cppuhelper/implbase4.hxx290
-rw-r--r--include/cppuhelper/implbase5.hxx291
-rw-r--r--include/cppuhelper/implbase6.hxx292
-rw-r--r--include/cppuhelper/implbase7.hxx293
-rw-r--r--include/cppuhelper/implbase8.hxx294
-rw-r--r--include/cppuhelper/implbase9.hxx295
-rw-r--r--include/cppuhelper/implbase_ex.hxx165
-rw-r--r--include/cppuhelper/implbase_ex_post.hxx168
-rw-r--r--include/cppuhelper/implbase_ex_pre.hxx33
-rw-r--r--include/cppuhelper/implementationentry.hxx121
-rw-r--r--include/cppuhelper/interfacecontainer.h607
-rw-r--r--include/cppuhelper/interfacecontainer.hxx195
-rw-r--r--include/cppuhelper/propertysetmixin.hxx489
-rw-r--r--include/cppuhelper/propshlp.hxx736
-rw-r--r--include/cppuhelper/proptypehlp.h70
-rw-r--r--include/cppuhelper/proptypehlp.hxx523
-rw-r--r--include/cppuhelper/queryinterface.hxx534
-rw-r--r--include/cppuhelper/shlib.hxx133
-rw-r--r--include/cppuhelper/supportsservice.hxx49
-rw-r--r--include/cppuhelper/typeprovider.hxx233
-rw-r--r--include/cppuhelper/unourl.hxx185
-rw-r--r--include/cppuhelper/weak.hxx164
-rw-r--r--include/cppuhelper/weakagg.hxx104
-rw-r--r--include/cppuhelper/weakref.hxx164
-rw-r--r--include/osl/conditn.h88
-rw-r--r--include/osl/conditn.hxx121
-rw-r--r--include/osl/diagnose.h204
-rw-r--r--include/osl/diagnose.hxx209
-rw-r--r--include/osl/doublecheckedlocking.h75
-rw-r--r--include/osl/endian.h226
-rw-r--r--include/osl/file.h1639
-rw-r--r--include/osl/file.hxx1979
-rw-r--r--include/osl/getglobalmutex.hxx44
-rw-r--r--include/osl/interlck.h92
-rw-r--r--include/osl/module.h251
-rw-r--r--include/osl/module.hxx175
-rw-r--r--include/osl/mutex.h74
-rw-r--r--include/osl/mutex.hxx272
-rw-r--r--include/osl/nlsupport.h57
-rw-r--r--include/osl/pipe.h97
-rw-r--r--include/osl/pipe.hxx206
-rw-r--r--include/osl/pipe_decl.hxx229
-rw-r--r--include/osl/process.h451
-rw-r--r--include/osl/profile.h145
-rw-r--r--include/osl/profile.hxx196
-rw-r--r--include/osl/security.h163
-rw-r--r--include/osl/security.hxx103
-rw-r--r--include/osl/security_decl.hxx110
-rw-r--r--include/osl/signal.h112
-rw-r--r--include/osl/socket.h920
-rw-r--r--include/osl/socket.hxx559
-rw-r--r--include/osl/socket_decl.hxx721
-rw-r--r--include/osl/thread.h196
-rw-r--r--include/osl/thread.hxx238
-rw-r--r--include/osl/time.h159
-rw-r--r--include/osl/util.h50
-rw-r--r--include/rtl/alloc.h257
-rw-r--r--include/rtl/allocator.hxx175
-rw-r--r--include/rtl/bootstrap.h234
-rw-r--r--include/rtl/bootstrap.hxx226
-rw-r--r--include/rtl/byteseq.h317
-rw-r--r--include/rtl/byteseq.hxx136
-rw-r--r--include/rtl/character.hxx144
-rw-r--r--include/rtl/cipher.h317
-rw-r--r--include/rtl/crc.h63
-rw-r--r--include/rtl/digest.h643
-rw-r--r--include/rtl/instance.hxx637
-rw-r--r--include/rtl/locale.h136
-rw-r--r--include/rtl/logfile.h131
-rw-r--r--include/rtl/logfile.hxx205
-rw-r--r--include/rtl/malformeduriexception.hxx68
-rw-r--r--include/rtl/math.h475
-rw-r--r--include/rtl/math.hxx439
-rw-r--r--include/rtl/process.h79
-rw-r--r--include/rtl/random.h110
-rw-r--r--include/rtl/ref.hxx243
-rw-r--r--include/rtl/strbuf.h137
-rw-r--r--include/rtl/strbuf.hxx922
-rw-r--r--include/rtl/string.h1408
-rw-r--r--include/rtl/string.hxx1709
-rw-r--r--include/rtl/stringconcat.hxx284
-rw-r--r--include/rtl/stringutils.hxx187
-rw-r--r--include/rtl/tencinfo.h278
-rw-r--r--include/rtl/textcvt.h177
-rw-r--r--include/rtl/textenc.h270
-rw-r--r--include/rtl/unload.h92
-rw-r--r--include/rtl/uri.h352
-rw-r--r--include/rtl/uri.hxx144
-rw-r--r--include/rtl/ustrbuf.h212
-rw-r--r--include/rtl/ustrbuf.hxx1386
-rw-r--r--include/rtl/ustring.h2022
-rw-r--r--include/rtl/ustring.hxx2416
-rw-r--r--include/rtl/uuid.h182
-rw-r--r--include/sal/ByteBufferWrapper.hxx40
-rw-r--r--include/sal/alloca.h66
-rw-r--r--include/sal/config.h100
-rw-r--r--include/sal/detail/log.h106
-rw-r--r--include/sal/log-areas.dox355
-rw-r--r--include/sal/log.hxx317
-rw-r--r--include/sal/macros.h66
-rw-r--r--include/sal/main.h149
-rw-r--r--include/sal/mathconf.h156
-rw-r--r--include/sal/saldllapi.h35
-rw-r--r--include/sal/types.h566
-rw-r--r--include/sal/typesizes.h20
-rw-r--r--include/salhelper/condition.hxx118
-rw-r--r--include/salhelper/dynload.hxx204
-rw-r--r--include/salhelper/linkhelper.hxx75
-rw-r--r--include/salhelper/refobj.hxx104
-rw-r--r--include/salhelper/salhelperdllapi.h34
-rw-r--r--include/salhelper/simplereferenceobject.hxx131
-rw-r--r--include/salhelper/singletonref.hxx197
-rw-r--r--include/salhelper/thread.hxx93
-rw-r--r--include/salhelper/timer.hxx230
-rw-r--r--include/systools/win32/snprintf.h88
-rw-r--r--include/typelib/typeclass.h98
-rw-r--r--include/typelib/typedescription.h1148
-rw-r--r--include/typelib/typedescription.hxx216
-rw-r--r--include/typelib/uik.h45
-rw-r--r--include/uno/Enterable.h106
-rw-r--r--include/uno/EnvDcp.h58
-rw-r--r--include/uno/any2.h170
-rw-r--r--include/uno/current_context.h63
-rw-r--r--include/uno/current_context.hxx119
-rw-r--r--include/uno/data.h251
-rw-r--r--include/uno/dispatcher.h89
-rw-r--r--include/uno/dispatcher.hxx171
-rw-r--r--include/uno/environment.h386
-rw-r--r--include/uno/environment.hxx270
-rw-r--r--include/uno/lbnames.h54
-rw-r--r--include/uno/mapping.h214
-rw-r--r--include/uno/mapping.hxx346
-rw-r--r--include/uno/sequence2.h181
-rw-r--r--include/uno/threadpool.h185
184 files changed, 51108 insertions, 0 deletions
diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h
new file mode 100644
index 000000000000..f1d03e8709b5
--- /dev/null
+++ b/include/com/sun/star/uno/Any.h
@@ -0,0 +1,376 @@
+/* -*- 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_UNO_ANY_H_
+#define _COM_SUN_STAR_UNO_ANY_H_
+
+#include <uno/any2.h>
+#include <typelib/typedescription.h>
+#include <com/sun/star/uno/Type.h>
+#include "cppu/unotype.hxx"
+#include <rtl/alloc.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** C++ class representing an IDL any.
+ This class is used to transport any type defined in IDL. The class inherits from the
+ binary C representation of uno_Any.
+ You can insert a value by either using the <<= operators or the template function makeAny().
+ No any can hold an any. You can extract values from an any by using the >>= operators which
+ return true if the any contains an assignable value (no data loss), e.g. the any contains a
+ short and you >>= it into a long variable.
+*/
+class Any : public uno_Any
+{
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Default constructor: Any holds no value; its type is void.
+ */
+ inline Any() SAL_THROW(());
+
+ /** Templated ctor. Sets a copy of the given value.
+
+ @param value value of the Any
+ */
+ template <typename T>
+ explicit inline Any( T const & value );
+ /// Ctor support for C++ bool.
+ explicit inline Any( bool value );
+
+ /** Copy constructor: Sets value of the given any.
+
+ @param rAny another any
+ */
+ inline Any( const Any & rAny ) SAL_THROW(());
+
+ /** Constructor: Sets a copy of the given data.
+
+ @param pData_ value
+ @param rType type of value
+ */
+ inline Any( const void * pData_, const Type & rType ) SAL_THROW(());
+
+ /** Constructor: Sets a copy of the given data.
+
+ @param pData_ value
+ @param pTypeDescr type of value
+ */
+ inline Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
+
+ /** Constructor: Sets a copy of the given data.
+
+ @param pData_ value
+ @param pType type of value
+ */
+ inline Any( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
+
+ /** Destructor: Destructs any content and frees memory.
+ */
+ inline ~Any() SAL_THROW(());
+
+ /** Assignment operator: Sets the value of the given any.
+
+ @param rAny another any (right side)
+ @return this any
+ */
+ inline Any & SAL_CALL operator = ( const Any & rAny ) SAL_THROW(());
+
+ /** Gets the type of the set value.
+
+ @return a Type object of the set value
+ */
+ inline const Type & SAL_CALL getValueType() const SAL_THROW(())
+ { return * reinterpret_cast< const Type * >( &pType ); }
+ /** Gets the type of the set value.
+
+ @return the unacquired type description reference of the set value
+ */
+ inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const SAL_THROW(())
+ { return pType; }
+
+ /** Gets the type description of the set value. Provides ownership of the type description!
+ Call an explicit typelib_typedescription_release() to release afterwards.
+
+ @param ppTypeDescr a pointer to type description pointer
+ */
+ inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const SAL_THROW(())
+ { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, pType ); }
+
+ /** Gets the type class of the set value.
+
+ @return the type class of the set value
+ */
+ inline TypeClass SAL_CALL getValueTypeClass() const SAL_THROW(())
+ { return (TypeClass)pType->eTypeClass; }
+
+ /** Gets the type name of the set value.
+
+ @return the type name of the set value
+ */
+ inline ::rtl::OUString SAL_CALL getValueTypeName() const SAL_THROW(());
+
+ /** Tests if any contains a value.
+
+ @return true if any has a value, false otherwise
+ */
+ inline sal_Bool SAL_CALL hasValue() const SAL_THROW(())
+ { return (typelib_TypeClass_VOID != pType->eTypeClass); }
+
+ /** Gets a pointer to the set value.
+
+ @return a pointer to the set value
+ */
+ inline const void * SAL_CALL getValue() const SAL_THROW(())
+ { return pData; }
+
+#if ! defined(EXCEPTIONS_OFF)
+ /** Provides a value of specified type, so you can easily write e.g.
+ <pre>
+ sal_Int32 myVal = myAny.get<sal_Int32>();
+ </pre>
+ Widening conversion without data loss is taken into account.
+ Throws a
+ <type scope="com::sun::star::uno">RuntimeException</type>
+ if the specified type cannot be provided.
+
+ @return value of specified type
+ @exception <type scope="com::sun::star::uno">RuntimeException</type>
+ in case the specified type cannot be provided
+ */
+ template <typename T>
+ inline T get() const;
+#endif // ! defined(EXCEPTIONS_OFF)
+
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+
+ @param pData_ pointer to value
+ @param rType type of value
+ */
+ inline void SAL_CALL setValue( const void * pData_, const Type & rType ) SAL_THROW(());
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+
+ @param pData_ pointer to value
+ @param pType type of value
+ */
+ inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+
+ @param pData_ pointer to value
+ @param pTypeDescr type description of value
+ */
+ inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
+
+ /** Clears this any. If the any already contains a value, that value will be destructed
+ and its memory freed. After this has been called, the any does not contain a value.
+ */
+ inline void SAL_CALL clear() SAL_THROW(());
+
+ /** Tests whether this any is extractable to a value of given type.
+ Widening conversion without data loss is taken into account.
+
+ @param rType destination type
+ @return true if this any is extractable to value of given type (e.g. using >>= operator)
+ */
+ inline sal_Bool SAL_CALL isExtractableTo( const Type & rType ) const SAL_THROW(());
+
+ /** Tests whether this any can provide a value of specified type.
+ Widening conversion without data loss is taken into account.
+
+ @return true if this any can provide a value of specified type
+ (e.g. using >>= operator)
+ */
+ template <typename T>
+ inline bool has() const;
+
+ /** Equality operator: compares two anys.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+
+ @param rAny another any (right side)
+ @return true if both any contains equal values
+ */
+ inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const SAL_THROW(());
+ /** Unequality operator: compares two anys.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+
+ @param rAny another any (right side)
+ @return true if both any contains unequal values
+ */
+ inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const SAL_THROW(());
+
+private:
+ // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+ explicit Any( sal_uInt16 );
+#if defined(_MSC_VER)
+ // Omitting the following private declarations leads to an internal compiler
+ // error on MSVC (version 1310).
+ // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+#if ! defined(EXCEPTIONS_OFF)
+ template <>
+ sal_uInt16 get<sal_uInt16>() const;
+#endif // ! defined(EXCEPTIONS_OFF)
+ template <>
+ bool has<sal_uInt16>() const;
+#endif // defined(_MSC_VER)
+};
+
+/** Template function to generically construct an any from a C++ value.
+
+ @tparam C value type
+ @param value a value
+ @return an any
+*/
+template< class C >
+inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(());
+
+// additionally specialized for C++ bool
+template<>
+inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(());
+
+class BaseReference;
+class Type;
+
+/** Template binary <<= operator to set the value of an any.
+
+ @tparam C value type
+ @param rAny destination any (left side)
+ @param value source value (right side)
+*/
+template< class C >
+inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(());
+
+// additionally for C++ bool:
+inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
+ SAL_THROW(());
+
+/** Template binary >>= operator to assign a value from an any.
+ If the any does not contain a value that can be assigned without data loss, then this
+ operation will fail returning false.
+
+ @tparam C value type
+ @param rAny source any (left side)
+ @param value destination value (right side)
+ @return true if assignment was possible without data loss
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(());
+
+/** Template equality operator: compares set value of left side any to right side value.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+ This operator can be implemented as template member function, if all supported compilers
+ can cope with template member functions.
+
+ @tparam C value type
+ @param rAny another any (left side)
+ @param value a value (right side)
+ @return true if values are equal, false otherwise
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(());
+/** Template unequality operator: compares set value of left side any to right side value.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+ This operator can be implemented as template member function, if all supported compilers
+ can cope with template member functions.
+
+ @tparam C value type
+ @param rAny another any (left side)
+ @param value a value (right side)
+ @return true if values are unequal, false otherwise
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(());
+
+// additional specialized >>= and == operators
+// bool
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Bool & value ) SAL_THROW(());
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(());
+template<>
+inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
+ SAL_THROW(());
+template<>
+inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
+ SAL_THROW(());
+// byte
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int8 & value ) SAL_THROW(());
+// short
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(());
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(());
+// long
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(());
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(());
+// hyper
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(());
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(());
+// float
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(());
+// double
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(());
+// string
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(());
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(());
+// type
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(());
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(());
+// any
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(());
+// interface
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(());
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL type any.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type any
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Any * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::com::sun::star::uno::Any >::get();
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
new file mode 100644
index 000000000000..6f3bda9692bd
--- /dev/null
+++ b/include/com/sun/star/uno/Any.hxx
@@ -0,0 +1,596 @@
+/* -*- 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_UNO_ANY_HXX_
+#define _COM_SUN_STAR_UNO_ANY_HXX_
+
+#include <com/sun/star/uno/Any.h>
+#include <uno/data.h>
+#include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/genfunc.hxx>
+#include "cppu/unotype.hxx"
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline Any::Any() SAL_THROW(())
+{
+ ::uno_any_construct( this, 0, 0, (uno_AcquireFunc)cpp_acquire );
+}
+
+//______________________________________________________________________________
+template <typename T>
+inline Any::Any( T const & value )
+{
+ ::uno_type_any_construct(
+ this, const_cast<T *>(&value),
+ ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
+ (uno_AcquireFunc) cpp_acquire );
+}
+//______________________________________________________________________________
+inline Any::Any( bool value )
+{
+ sal_Bool b = value;
+ ::uno_type_any_construct(
+ this, &b, ::getCppuBooleanType().getTypeLibType(),
+ (uno_AcquireFunc) cpp_acquire );
+}
+
+//__________________________________________________________________________________________________
+inline Any::Any( const Any & rAny ) SAL_THROW(())
+{
+ ::uno_type_any_construct( this, rAny.pData, rAny.pType, (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData_, const Type & rType ) SAL_THROW(())
+{
+ ::uno_type_any_construct(
+ this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
+{
+ ::uno_any_construct(
+ this, const_cast< void * >( pData_ ), pTypeDescr, (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
+{
+ ::uno_type_any_construct(
+ this, const_cast< void * >( pData_ ), pType_, (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::~Any() SAL_THROW(())
+{
+ ::uno_any_destruct(
+ this, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline Any & Any::operator = ( const Any & rAny ) SAL_THROW(())
+{
+ if (this != &rAny)
+ {
+ ::uno_type_any_assign(
+ this, rAny.pData, rAny.pType,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+ }
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline ::rtl::OUString Any::getValueTypeName() const SAL_THROW(())
+{
+ return ::rtl::OUString( pType->pTypeName );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData_, const Type & rType ) SAL_THROW(())
+{
+ ::uno_type_any_assign(
+ this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
+{
+ ::uno_type_any_assign(
+ this, const_cast< void * >( pData_ ), pType_,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
+{
+ ::uno_any_assign(
+ this, const_cast< void * >( pData_ ), pTypeDescr,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline void Any::clear() SAL_THROW(())
+{
+ ::uno_any_clear(
+ this, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool Any::isExtractableTo( const Type & rType ) const SAL_THROW(())
+{
+ return ::uno_type_isAssignableFromData(
+ rType.getTypeLibType(), pData, pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
+}
+
+//______________________________________________________________________________
+template <typename T>
+inline bool Any::has() const
+{
+ Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
+ return ::uno_type_isAssignableFromData(
+ rType.getTypeLibType(), pData, pType,
+ (uno_QueryInterfaceFunc) cpp_queryInterface,
+ (uno_ReleaseFunc) cpp_release );
+}
+#if ! defined(__SUNPRO_CC)
+// not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+template <>
+bool Any::has<sal_uInt16>() const;
+#endif // ! defined(__SUNPRO_CC)
+
+//__________________________________________________________________________________________________
+inline sal_Bool Any::operator == ( const Any & rAny ) const SAL_THROW(())
+{
+ return ::uno_type_equalData(
+ pData, pType, rAny.pData, rAny.pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool Any::operator != ( const Any & rAny ) const SAL_THROW(())
+{
+ return (! ::uno_type_equalData(
+ pData, pType, rAny.pData, rAny.pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release ));
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(())
+{
+ return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
+}
+
+// additionally specialized for C++ bool
+//______________________________________________________________________________
+template<>
+inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(())
+{
+ const sal_Bool b = value;
+ return Any( &b, ::getCppuBooleanType() );
+}
+
+//__________________________________________________________________________________________________
+#ifdef RTL_FAST_STRING
+template< class C1, class C2 >
+inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value ) SAL_THROW(())
+{
+ const rtl::OUString str( value );
+ return Any( &str, ::cppu::getTypeFavourUnsigned(&str) );
+}
+#endif
+//__________________________________________________________________________________________________
+template< class C >
+inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(())
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
+ ::uno_type_any_assign(
+ &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+
+// additionally for C++ bool:
+//______________________________________________________________________________
+inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
+ SAL_THROW(())
+{
+ sal_Bool b = value;
+ ::uno_type_any_assign(
+ &rAny, &b, ::getCppuBooleanType().getTypeLibType(),
+ (uno_AcquireFunc) cpp_acquire, (uno_ReleaseFunc) cpp_release );
+}
+
+//______________________________________________________________________________
+#ifdef RTL_FAST_STRING
+template< class C1, class C2 >
+inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value )
+ SAL_THROW(())
+{
+ const rtl::OUString str( value );
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
+ ::uno_type_any_assign(
+ &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+#endif
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(())
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
+ return ::uno_type_assignData(
+ &value, rType.getTypeLibType(),
+ rAny.pData, rAny.pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+
+// bool
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) SAL_THROW(())
+{
+ if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
+ {
+ value = (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False);
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(())
+{
+ return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
+ (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False));
+}
+
+//______________________________________________________________________________
+template<>
+inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
+ SAL_THROW(())
+{
+ if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
+ {
+ value = *reinterpret_cast< sal_Bool const * >(
+ rAny.pData ) != sal_False;
+ return true;
+ }
+ return false;
+}
+
+//______________________________________________________________________________
+template<>
+inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
+ SAL_THROW(())
+{
+ return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
+ (value ==
+ (*reinterpret_cast< sal_Bool const * >( rAny.pData )
+ != sal_False)));
+}
+
+// byte
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) SAL_THROW(())
+{
+ if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
+ {
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
+ return sal_True;
+ }
+ return sal_False;
+}
+// short
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = (sal_uInt16)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// long
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = (sal_uInt32)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = (sal_uInt32)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// hyper
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ value = * reinterpret_cast< const sal_Int64 * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = (sal_uInt64)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = (sal_uInt64)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ value = (sal_uInt64)( * reinterpret_cast< const sal_Int32 * >( rAny.pData ) );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ value = * reinterpret_cast< const sal_uInt64 * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// float
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_FLOAT:
+ value = * reinterpret_cast< const float * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// double
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(())
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_FLOAT:
+ value = * reinterpret_cast< const float * >( rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_DOUBLE:
+ value = * reinterpret_cast< const double * >( rAny.pData );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// string
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(())
+{
+ if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
+ {
+ value = * reinterpret_cast< const ::rtl::OUString * >( rAny.pData );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(())
+{
+ return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
+ value.equals( * reinterpret_cast< const ::rtl::OUString * >( rAny.pData ) ));
+}
+// type
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(())
+{
+ if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
+ {
+ value = * reinterpret_cast< const Type * >( rAny.pData );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(())
+{
+ return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
+ value.equals( * reinterpret_cast< const Type * >( rAny.pData ) ));
+}
+// any
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(())
+{
+ if (&rAny != &value)
+ {
+ ::uno_type_any_assign(
+ &value, rAny.pData, rAny.pType,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+ }
+ return sal_True;
+}
+// interface
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(())
+{
+ if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
+ {
+ return reinterpret_cast< const BaseReference * >( rAny.pData )->operator == ( value );
+ }
+ return sal_False;
+}
+
+// operator to compare to an any.
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(())
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
+ return ::uno_type_equalData(
+ rAny.pData, rAny.pType,
+ const_cast< C * >( &value ), rType.getTypeLibType(),
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
+}
+// operator to compare to an any. may use specialized operators ==.
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(())
+{
+ return (! operator == ( rAny, value ));
+}
+
+#if ! defined(EXCEPTIONS_OFF)
+extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
+ uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+
+//______________________________________________________________________________
+template <typename T>
+T Any::get() const
+{
+ T value = T();
+ if (! (*this >>= value)) {
+ throw RuntimeException(
+ ::rtl::OUString(
+ cppu_Any_extraction_failure_msg(
+ this,
+ ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
+ SAL_NO_ACQUIRE ),
+ Reference<XInterface>() );
+ }
+ return value;
+}
+// not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+template <>
+sal_uInt16 Any::get<sal_uInt16>() const;
+#endif // ! defined(EXCEPTIONS_OFF)
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
new file mode 100644
index 000000000000..94551a087063
--- /dev/null
+++ b/include/com/sun/star/uno/Reference.h
@@ -0,0 +1,519 @@
+/* -*- 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_UNO_REFERENCE_H_
+#define _COM_SUN_STAR_UNO_REFERENCE_H_
+
+#include <rtl/alloc.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+class RuntimeException;
+class XInterface;
+class Type;
+class Any;
+
+/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
+ Deprecated, please use SAL_NO_ACQUIRE.
+ @deprecated
+*/
+enum UnoReference_NoAcquire
+{
+ /** This enum value can be used for creating a reference granting a given interface,
+ i.e. transferring ownership to it.
+ */
+ UNO_REF_NO_ACQUIRE
+};
+
+/** This base class serves as a base class for all template reference classes and
+ has been introduced due to compiler problems with templated operators ==, =!.
+*/
+class BaseReference
+{
+protected:
+ /** the interface pointer
+ */
+ XInterface * _pInterface;
+
+ /** Queries given interface for type rType.
+
+ @param pInterface interface pointer
+ @param rType interface type
+ @return interface of demanded type (may be null)
+ */
+ inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) );
+#ifndef EXCEPTIONS_OFF
+ /** Queries given interface for type rType.
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param pInterface interface pointer
+ @param rType interface type
+ @return interface of demanded type
+ */
+ inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) );
+#endif
+
+public:
+ /** Gets interface pointer. This call does not acquire the interface.
+
+ @return UNacquired interface pointer
+ */
+ inline XInterface * SAL_CALL get() const SAL_THROW(())
+ { return _pInterface; }
+
+ /** Checks if reference is null.
+
+ @return true if reference acquires an interface, i.e. true if it is not null
+ */
+ inline sal_Bool SAL_CALL is() const SAL_THROW(())
+ { return (0 != _pInterface); }
+
+ /** Equality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param pInterface another interface
+ @return true if both references are null or refer to the same object, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW(());
+ /** Unequality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param pInterface another interface
+ @return false if both references are null or refer to the same object, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW(());
+
+ /** Equality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param rRef another reference
+ @return true if both references are null or refer to the same object, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW(());
+ /** Unequality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param rRef another reference
+ @return false if both references are null or refer to the same object, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW(());
+
+ /** Needed by some STL containers.
+
+ @param rRef another reference
+ @return true, if this reference is less than rRef
+ */
+ inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW(());
+};
+
+/** Enum defining UNO_QUERY for implicit interface query.
+*/
+enum UnoReference_Query
+{
+ /** This enum value can be used for implicit interface query.
+ */
+ UNO_QUERY,
+};
+#ifndef EXCEPTIONS_OFF
+/** Enum defining UNO_QUERY_THROW for implicit interface query.
+ If the demanded interface is unavailable, then a RuntimeException is thrown.
+*/
+enum UnoReference_QueryThrow
+{
+ /** This enum value can be used for implicit interface query.
+ */
+ UNO_QUERY_THROW,
+};
+/** Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null
+ interface
+
+ @since UDK 3.2.8
+*/
+enum UnoReference_SetThrow
+{
+ UNO_SET_THROW
+};
+#endif
+
+/** Template reference class for interface type derived from BaseReference.
+ A special constructor given the UNO_QUERY identifier queries interfaces
+ for reference type.
+*/
+template< class interface_type >
+class Reference : public BaseReference
+{
+ /** Queries given interface for type interface_type.
+
+ @param pInterface interface pointer
+ @return interface of demanded type (may be null)
+ */
+ inline static XInterface * SAL_CALL iquery( XInterface * pInterface )
+ SAL_THROW( (RuntimeException) );
+#ifndef EXCEPTIONS_OFF
+ /** Queries given interface for type interface_type.
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param pInterface interface pointer
+ @return interface of demanded type
+ */
+ inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface )
+ SAL_THROW( (RuntimeException) );
+ /** Returns the given interface if it is not <NULL/>, throws a RuntimeException otherwise.
+
+ @param pInterface interface pointer
+ @return pInterface
+ */
+ inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface )
+ SAL_THROW( (RuntimeException) );
+#endif
+
+ /** Cast from an "interface pointer" (e.g., BaseReference::_pInterface) to a
+ pointer to this interface_type.
+
+ To work around ambiguities in the case of multiple-inheritance interface
+ types (which inherit XInterface more than once), use reinterpret_cast
+ (resp. a sequence of two static_casts, to avoid warnings about
+ reinterpret_cast used between related classes) to switch from a pointer
+ to XInterface to a pointer to this derived interface_type. In
+ principle, this is not guaranteed to work. In practice, it seems to
+ work on all supported platforms.
+ */
+ static inline interface_type * castFromXInterface(XInterface * p) {
+ return static_cast< interface_type * >(static_cast< void * >(p));
+ }
+
+ /** Cast from a pointer to this interface_type to an "interface pointer"
+ (e.g., BaseReference::_pInterface).
+
+ To work around ambiguities in the case of multiple-inheritance interface
+ types (which inherit XInterface more than once), use reinterpret_cast
+ (resp. a sequence of two static_casts, to avoid warnings about
+ reinterpret_cast used between related classes) to switch from a pointer
+ to this derived interface_type to a pointer to XInterface. In
+ principle, this is not guaranteed to work. In practice, it seems to
+ work on all supported platforms.
+ */
+ static inline XInterface * castToXInterface(interface_type * p) {
+ return static_cast< XInterface * >(static_cast< void * >(p));
+ }
+
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( ::size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( ::size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Destructor: Releases interface if set.
+ */
+ inline ~Reference() SAL_THROW(());
+
+ /** Default Constructor: Sets null reference.
+ */
+ inline Reference() SAL_THROW(());
+
+ /** Copy constructor: Copies interface reference.
+
+ @param rRef another reference
+ */
+ inline Reference( const Reference< interface_type > & rRef ) SAL_THROW(());
+ /** Constructor: Sets given interface pointer.
+
+ @param pInterface an interface pointer
+ */
+ inline Reference( interface_type * pInterface ) SAL_THROW(());
+
+ /** Constructor: Sets given interface pointer without acquiring it.
+
+ @param pInterface another reference
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Reference( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(());
+ /** Constructor: Sets given interface pointer without acquiring it.
+ Deprecated, please use SAL_NO_ACQUIRE version.
+
+ @deprecated
+ @param pInterface another reference
+ @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ) SAL_THROW(());
+
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+
+ @param rRef another reference
+ @param dummy UNO_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( const BaseReference & rRef, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( XInterface * pInterface, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given any for reference interface type (interface_type).
+
+ @param rAny an any
+ @param dummy UNO_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( const Any & rAny, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
+#ifndef EXCEPTIONS_OFF
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param rRef another reference
+ @param dummy UNO_QUERY_THROW to force obvious distinction
+ to other constructors
+ */
+ inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY_THROW to force obvious distinction
+ to other constructors
+ */
+ inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given any for reference interface type (interface_type).
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param rAny an any
+ @param dummy UNO_QUERY_THROW to force obvious distinction
+ to other constructors
+ */
+ inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
+ /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
+ if the source interface is NULL.
+
+ @param rRef another interface reference of the same type
+ @param dummy UNO_SET_THROW to distinguish from default copy constructor
+
+ @since UDK 3.2.8
+ */
+ inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) );
+ /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
+ if the source interface is NULL.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_SET_THROW to distinguish from default assignment constructor
+
+ @since UDK 3.2.8
+ */
+ inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) );
+#endif
+
+ /** Cast operator to Reference< XInterface >: Reference objects are binary compatible and
+ any interface must be derived from com.sun.star.uno.XInterface.
+ This a useful direct cast possibility.
+ */
+ inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW(())
+ { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
+
+ /** Dereference operator: Used to call interface methods.
+
+ @return UNacquired interface pointer
+ */
+ inline interface_type * SAL_CALL operator -> () const SAL_THROW(())
+ { return castFromXInterface(_pInterface); }
+
+ /** Gets interface pointer. This call does not acquire the interface.
+
+ @return UNacquired interface pointer
+ */
+ inline interface_type * SAL_CALL get() const SAL_THROW(())
+ { return castFromXInterface(_pInterface); }
+
+ /** Clears reference, i.e. releases interface. Reference is null after clear() call.
+ */
+ inline void SAL_CALL clear() SAL_THROW(());
+
+ /** Sets the given interface. An interface already set will be released.
+
+ @param rRef another reference
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW(());
+ /** Sets the given interface. An interface already set will be released.
+
+ @param pInterface another interface
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW(());
+
+ /** Sets interface pointer without acquiring it. An interface already set will be released.
+
+ @param pInterface an interface pointer
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(());
+ /** Sets interface pointer without acquiring it. An interface already set will be released.
+ Deprecated, please use SAL_NO_ACQUIRE version.
+
+ @deprecated
+ @param pInterface an interface pointer
+ @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy) SAL_THROW(());
+
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) );
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+
+ @param rRef another reference
+ @param dummy UNO_QUERY to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
+
+ /** Queries given any for reference interface type (interface_type)
+ and sets it. An interface already set will be released.
+
+ @param rAny
+ an Any containing an interface
+ @param dummy
+ UNO_QUERY to force obvious distinction
+ to set methods
+ @return
+ true, if non-null interface was set
+ */
+ inline bool set( Any const & rAny, UnoReference_Query dummy );
+
+#ifndef EXCEPTIONS_OFF
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+ Throws a RuntimeException if the demanded interface cannot be set.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY_THROW to force obvious distinction
+ to set methods
+ */
+ inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+ Throws a RuntimeException if the demanded interface cannot be set.
+
+ @param rRef another reference
+ @param dummy UNO_QUERY_THROW to force obvious distinction
+ to set methods
+ */
+ inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
+
+ /** Queries given any for reference interface type (interface_type) and
+ sets it. An interface already set will be released.
+ Throws a RuntimeException if the demanded interface cannot be set.
+
+ @param rAny
+ an Any containing an interface
+ @param dummy
+ UNO_QUERY_THROW to force obvious distinction to set methods
+ */
+ inline void set( Any const & rAny, UnoReference_QueryThrow dummy);
+ /** sets the given interface
+ An interface already set will be released.
+ Throws a RuntimeException if the source interface is @b NULL.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_SET_THROW to force obvious distinction to other set methods
+
+ @since UDK 3.2.8
+ */
+ inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) );
+ /** sets the given interface
+ An interface already set will be released.
+ Throws a RuntimeException if the source interface is @b NULL.
+
+ @param rRef an interface reference
+ @param dummy UNO_SET_THROW to force obvious distinction to other set methods
+
+ @since UDK 3.2.8
+ */
+ inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) );
+
+#endif
+
+ /** Assignment operator: Acquires given interface pointer and sets reference.
+ An interface already set will be released.
+
+ @param pInterface an interface pointer
+ @return this reference
+ */
+ inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW(());
+ /** Assignment operator: Acquires given interface reference and sets reference.
+ An interface already set will be released.
+
+ @param rRef an interface reference
+ @return this reference
+ */
+ inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ) SAL_THROW(());
+
+ /** Queries given interface reference for type interface_type.
+
+ @param rRef interface reference
+ @return interface reference of demanded type (may be null)
+ */
+ inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) );
+ /** Queries given interface for type interface_type.
+
+ @param pInterface interface pointer
+ @return interface reference of demanded type (may be null)
+ */
+ inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) );
+};
+
+/// @cond INTERNAL
+/** Enables boost::mem_fn and boost::bind to recognize Reference.
+*/
+template <typename T>
+inline T * get_pointer( Reference<T> const& r )
+{
+ return r.get();
+}
+/// @endcond
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Reference.hxx b/include/com/sun/star/uno/Reference.hxx
new file mode 100644
index 000000000000..aa39810159d3
--- /dev/null
+++ b/include/com/sun/star/uno/Reference.hxx
@@ -0,0 +1,423 @@
+/* -*- 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_UNO_REFERENCE_HXX_
+#define _COM_SUN_STAR_UNO_REFERENCE_HXX_
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/genfunc.hxx>
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline XInterface * BaseReference::iquery(
+ XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) )
+{
+ if (pInterface)
+ {
+ Any aRet( pInterface->queryInterface( rType ) );
+ if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
+ {
+ XInterface * pRet = static_cast< XInterface * >( aRet.pReserved );
+ aRet.pReserved = 0;
+ return pRet;
+ }
+ }
+ return 0;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline XInterface * Reference< interface_type >::iquery(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ return BaseReference::iquery(pInterface, interface_type::static_type());
+}
+#ifndef EXCEPTIONS_OFF
+extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iquery_msg(
+ typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iset_msg(
+ typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+//__________________________________________________________________________________________________
+inline XInterface * BaseReference::iquery_throw(
+ XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) )
+{
+ XInterface * pQueried = iquery( pInterface, rType );
+ if (pQueried)
+ return pQueried;
+ throw RuntimeException(
+ ::rtl::OUString( cppu_unsatisfied_iquery_msg( rType.getTypeLibType() ), SAL_NO_ACQUIRE ),
+ Reference< XInterface >( pInterface ) );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline XInterface * Reference< interface_type >::iquery_throw(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ return BaseReference::iquery_throw(
+ pInterface, interface_type::static_type());
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline interface_type * Reference< interface_type >::iset_throw(
+ interface_type * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ if (pInterface)
+ {
+ castToXInterface(pInterface)->acquire();
+ return pInterface;
+ }
+ throw RuntimeException(
+ ::rtl::OUString( cppu_unsatisfied_iset_msg( interface_type::static_type().getTypeLibType() ), SAL_NO_ACQUIRE ),
+ NULL );
+}
+#endif
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::~Reference() SAL_THROW(())
+{
+ if (_pInterface)
+ _pInterface->release();
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference() SAL_THROW(())
+{
+ _pInterface = 0;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Reference< interface_type > & rRef ) SAL_THROW(())
+{
+ _pInterface = rRef._pInterface;
+ if (_pInterface)
+ _pInterface->acquire();
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface ) SAL_THROW(())
+{
+ _pInterface = castToXInterface(pInterface);
+ if (_pInterface)
+ _pInterface->acquire();
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW(())
+{
+ _pInterface = castToXInterface(pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW(())
+{
+ _pInterface = castToXInterface(pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery( rRef.get() );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery( pInterface );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Any & rAny, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
+ ? iquery( static_cast< XInterface * >( rAny.pReserved ) ) : 0);
+}
+#ifndef EXCEPTIONS_OFF
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery_throw( rRef.get() );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery_throw( pInterface );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Any & rAny, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery_throw( typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
+ ? static_cast< XInterface * >( rAny.pReserved ) : 0 );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = castToXInterface( iset_throw( rRef.get() ) );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = castToXInterface( iset_throw( pInterface ) );
+}
+#endif
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::clear() SAL_THROW(())
+{
+ if (_pInterface)
+ {
+ XInterface * const pOld = _pInterface;
+ _pInterface = 0;
+ pOld->release();
+ }
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ interface_type * pInterface ) SAL_THROW(())
+{
+ if (pInterface)
+ castToXInterface(pInterface)->acquire();
+ XInterface * const pOld = _pInterface;
+ _pInterface = castToXInterface(pInterface);
+ if (pOld)
+ pOld->release();
+ return (0 != pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ interface_type * pInterface, __sal_NoAcquire ) SAL_THROW(())
+{
+ XInterface * const pOld = _pInterface;
+ _pInterface = castToXInterface(pInterface);
+ if (pOld)
+ pOld->release();
+ return (0 != pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW(())
+{
+ return set( pInterface, SAL_NO_ACQUIRE );
+}
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ const Reference< interface_type > & rRef ) SAL_THROW(())
+{
+ return set( castFromXInterface( rRef._pInterface ) );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ return set( castFromXInterface(iquery( pInterface )), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ return set( castFromXInterface(iquery( rRef.get() )), SAL_NO_ACQUIRE );
+}
+
+//______________________________________________________________________________
+template< class interface_type >
+inline bool Reference< interface_type >::set(
+ Any const & rAny, UnoReference_Query )
+{
+ return set(
+ castFromXInterface(
+ iquery(
+ rAny.pType->eTypeClass == typelib_TypeClass_INTERFACE
+ ? static_cast< XInterface * >( rAny.pReserved ) : 0 )),
+ SAL_NO_ACQUIRE );
+}
+
+#ifndef EXCEPTIONS_OFF
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( castFromXInterface(iquery_throw( pInterface )), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( castFromXInterface(iquery_throw( rRef.get() )), SAL_NO_ACQUIRE );
+}
+
+//______________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ Any const & rAny, UnoReference_QueryThrow )
+{
+ set( castFromXInterface(
+ iquery_throw(
+ rAny.pType->eTypeClass == typelib_TypeClass_INTERFACE
+ ? static_cast< XInterface * >( rAny.pReserved ) : 0 )),
+ SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( iset_throw( pInterface ), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( rRef.get(), UNO_SET_THROW );
+}
+
+#endif
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > & Reference< interface_type >::operator = (
+ interface_type * pInterface ) SAL_THROW(())
+{
+ set( pInterface );
+ return *this;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > & Reference< interface_type >::operator = (
+ const Reference< interface_type > & rRef ) SAL_THROW(())
+{
+ set( castFromXInterface( rRef._pInterface ) );
+ return *this;
+}
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > Reference< interface_type >::query(
+ const BaseReference & rRef ) SAL_THROW( (RuntimeException) )
+{
+ return Reference< interface_type >(
+ castFromXInterface(iquery( rRef.get() )), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > Reference< interface_type >::query(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ return Reference< interface_type >(
+ castFromXInterface(iquery( pInterface )), SAL_NO_ACQUIRE );
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator == ( XInterface * pInterface ) const SAL_THROW(())
+{
+ if (_pInterface == pInterface)
+ return sal_True;
+#ifndef EXCEPTIONS_OFF
+ try
+ {
+#endif
+ // only the query to XInterface must return the same pointer if they belong to same objects
+ Reference< XInterface > x1( _pInterface, UNO_QUERY );
+ Reference< XInterface > x2( pInterface, UNO_QUERY );
+ return (x1._pInterface == x2._pInterface);
+#ifndef EXCEPTIONS_OFF
+ }
+ catch (RuntimeException &)
+ {
+ return sal_False;
+ }
+#endif
+}
+
+//______________________________________________________________________________
+inline sal_Bool BaseReference::operator < (
+ const BaseReference & rRef ) const SAL_THROW(())
+{
+ if (_pInterface == rRef._pInterface)
+ return sal_False;
+#if ! defined EXCEPTIONS_OFF
+ try
+ {
+#endif
+ // only the query to XInterface must return the same pointer:
+ Reference< XInterface > x1( _pInterface, UNO_QUERY );
+ Reference< XInterface > x2( rRef, UNO_QUERY );
+ return (x1._pInterface < x2._pInterface);
+#if ! defined EXCEPTIONS_OFF
+ }
+ catch (RuntimeException &)
+ {
+ return sal_False;
+ }
+#endif
+}
+
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator != ( XInterface * pInterface ) const SAL_THROW(())
+{
+ return (! operator == ( pInterface ));
+}
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator == ( const BaseReference & rRef ) const SAL_THROW(())
+{
+ return operator == ( rRef._pInterface );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator != ( const BaseReference & rRef ) const SAL_THROW(())
+{
+ return (! operator == ( rRef._pInterface ));
+}
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Sequence.h b/include/com/sun/star/uno/Sequence.h
new file mode 100644
index 000000000000..ed754cf3ccf2
--- /dev/null
+++ b/include/com/sun/star/uno/Sequence.h
@@ -0,0 +1,282 @@
+/* -*- 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_UNO_SEQUENCE_H_
+#define _COM_SUN_STAR_UNO_SEQUENCE_H_
+
+#include "typelib/typedescription.h"
+#include "uno/sequence2.h"
+#include "com/sun/star/uno/Type.h"
+#include "rtl/alloc.h"
+
+#if ! defined EXCEPTIONS_OFF
+#include <new>
+#endif
+
+
+namespace rtl
+{
+class ByteSequence;
+}
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Template C++ class representing an IDL sequence. Template argument is the
+ sequence element type. C++ Sequences are reference counted and shared,
+ so the sequence keeps a handle to its data. To keep value semantics,
+ copies are only generated if the sequence is to be modified (new handle).
+
+ @tparam E element type of sequence
+*/
+template< class E >
+class Sequence
+{
+ /** sequence handle
+ */
+ uno_Sequence * _pSequence;
+
+public:
+ /// @cond INTERNAL
+
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( ::size_t nSize )
+ SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem )
+ SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( ::size_t, void * pMem )
+ SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * )
+ SAL_THROW(())
+ {}
+
+ /** Static pointer to typelib type of sequence.
+ Don't use directly, call getCppuType().
+ */
+ static typelib_TypeDescriptionReference * s_pType;
+
+ /// @endcond
+
+ /** typedefs the element type of the sequence
+ */
+ typedef E ElementType;
+
+ /** Default constructor: Creates an empty sequence.
+ */
+ inline Sequence() SAL_THROW(());
+
+ /** Copy constructor: Creates a copy of given sequence.
+
+ @param rSeq another sequence of same type
+ */
+ inline Sequence( const Sequence< E > & rSeq ) SAL_THROW(());
+
+ /** Constructor: Takes over ownership of given sequence.
+
+ @param pSequence a sequence
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to other
+ constructors
+ */
+ inline Sequence( uno_Sequence * pSequence, __sal_NoAcquire dummy )
+ SAL_THROW(());
+
+ /** Constructor: Creates a copy of given elements.
+
+ @param pElements an array of elements
+ @param len length of array
+ */
+ inline Sequence( const E * pElements, sal_Int32 len );
+
+ /** Constructor: Creates a default constructed sequence of given length.
+
+ @param len initial sequence length
+ */
+ inline explicit Sequence( sal_Int32 len );
+
+ /** Destructor: Releases sequence handle. Last handle will destruct
+ elements and free memory.
+ */
+ inline ~Sequence() SAL_THROW(());
+
+ /** Assignment operator: Acquires given sequence handle and releases
+ previously set handle.
+
+ @param rSeq another sequence of same type
+ @return this sequence
+ */
+ inline Sequence< E > & SAL_CALL operator = ( const Sequence< E > & rSeq )
+ SAL_THROW(());
+
+ /** Gets length of the sequence.
+
+ @return length of sequence
+ */
+ inline sal_Int32 SAL_CALL getLength() const SAL_THROW(())
+ { return _pSequence->nElements; }
+
+ /** Tests whether the sequence has elements, i.e. elements count is
+ greater than zero.
+
+ @return true, if elements count is greater than zero
+ */
+ inline sal_Bool SAL_CALL hasElements() const SAL_THROW(())
+ { return (_pSequence->nElements > 0); }
+
+ /** Gets a pointer to elements array for reading.
+ If the sequence has a length of 0, then the returned pointer is
+ undefined.
+
+ @return pointer to elements array
+ */
+ inline const E * SAL_CALL getConstArray() const SAL_THROW(())
+ { return reinterpret_cast< const E * >( _pSequence->elements ); }
+
+ /** Gets a pointer to elements array for reading and writing.
+ In general if the sequence has a handle acquired by other sequences
+ (reference count > 1), then a new sequence is created copy constructing
+ all elements to keep value semantics!
+ If the sequence has a length of 0, then the returned pointer is
+ undefined.
+
+ @return pointer to elements array
+ */
+ inline E * SAL_CALL getArray();
+
+ /** Non-const index operator: Obtains a reference to element indexed at
+ given position.
+ The implementation does not check for array bounds!
+ In general if the sequence has a handle acquired by other sequences
+ (reference count > 1), then a new sequence is created copy constructing
+ all elements to keep value semantics!
+
+ @param nIndex index
+ @return non-const C++ reference to element
+ */
+ inline E & SAL_CALL operator [] ( sal_Int32 nIndex );
+
+ /** Const index operator: Obtains a reference to element indexed at
+ given position. The implementation does not check for array bounds!
+
+ @param nIndex index
+ @return const C++ reference to element
+ */
+ inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const
+ SAL_THROW(());
+
+ /** Equality operator: Compares two sequences.
+
+ @param rSeq another sequence of same type (right side)
+ @return true if both sequences are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const Sequence< E > & rSeq ) const
+ SAL_THROW(());
+
+ /** Unequality operator: Compares two sequences.
+
+ @param rSeq another sequence of same type (right side)
+ @return false if both sequences are equal, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const Sequence< E > & rSeq ) const
+ SAL_THROW(());
+
+ /** Reallocates sequence to new length.
+ If the new length is smaller than the former, then upper elements will
+ be destructed (and their memory freed). If the new length is greater
+ than the former, then upper (new) elements are default constructed.
+ If the sequence has a handle acquired by other sequences
+ (reference count > 1), then the remaining elements are copy constructed
+ to a new sequence handle to keep value semantics!
+
+ @param nSize new size of sequence
+ */
+ inline void SAL_CALL realloc( sal_Int32 nSize );
+
+ /** Provides UNacquired sequence handle.
+
+ @return UNacquired sequence handle
+ */
+ inline uno_Sequence * SAL_CALL get() const SAL_THROW(())
+ { return _pSequence; }
+};
+
+/** Creates a UNO byte sequence from a SAL byte sequence.
+
+ @param rByteSequence a byte sequence
+ @return a UNO byte sequence
+*/
+inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
+ const ::rtl::ByteSequence & rByteSequence ) SAL_THROW(());
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL sequence.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @tparam E element type of sequence
+ @return type of IDL sequence
+*/
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * )
+ SAL_THROW(());
+
+/** Gets the meta type of IDL sequence.
+ This function has been introduced, because one cannot get the (templated)
+ cppu type out of C++ array types. Array types have special
+ getCppuArrayTypeN() functions.
+
+ @attention
+ the given element type must be the same as the template argument type!
+ @tparam E element type of sequence
+ @param rElementType element type of sequence
+ @return type of IDL sequence
+*/
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
+ SAL_THROW(());
+
+/** Gets the meta type of IDL sequence< char >.
+ This function has been introduced due to ambiguities with unsigned short.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL sequence< char >
+*/
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCharSequenceCppuType() SAL_THROW(());
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx
new file mode 100644
index 000000000000..a23fd3b48225
--- /dev/null
+++ b/include/com/sun/star/uno/Sequence.hxx
@@ -0,0 +1,306 @@
+/* -*- 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_UNO_SEQUENCE_HXX_
+#define _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+
+#include "sal/config.h"
+
+#include <cassert>
+
+#include "osl/interlck.h"
+#include "com/sun/star/uno/Sequence.h"
+#include "typelib/typedescription.h"
+#include "uno/data.h"
+#include "com/sun/star/uno/genfunc.hxx"
+#include "cppu/unotype.hxx"
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/// @cond INTERNAL
+template< class E >
+typelib_TypeDescriptionReference * Sequence< E >::s_pType = 0;
+/// @endcond
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence() SAL_THROW(())
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ ::uno_type_sequence_construct(
+ &_pSequence, rType.getTypeLibType(),
+ 0, 0, (uno_AcquireFunc)cpp_acquire );
+ // no bad_alloc, because empty sequence is statically allocated in cppu
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( const Sequence< E > & rSeq ) SAL_THROW(())
+{
+ osl_atomic_increment( &rSeq._pSequence->nRefCount );
+ _pSequence = rSeq._pSequence;
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence(
+ uno_Sequence * pSequence, __sal_NoAcquire ) SAL_THROW(())
+ : _pSequence( pSequence )
+{
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( const E * pElements, sal_Int32 len )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if ! defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_construct(
+ &_pSequence, rType.getTypeLibType(),
+ const_cast< E * >( pElements ), len, (uno_AcquireFunc)cpp_acquire );
+#if ! defined EXCEPTIONS_OFF
+ if (! success)
+ throw ::std::bad_alloc();
+#endif
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( sal_Int32 len )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if ! defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_construct(
+ &_pSequence, rType.getTypeLibType(),
+ 0, len, (uno_AcquireFunc)cpp_acquire );
+#if ! defined EXCEPTIONS_OFF
+ if (! success)
+ throw ::std::bad_alloc();
+#endif
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::~Sequence() SAL_THROW(())
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ ::uno_type_destructData(
+ this, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E > & Sequence< E >::operator = ( const Sequence< E > & rSeq ) SAL_THROW(())
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ ::uno_type_sequence_assign(
+ &_pSequence, rSeq._pSequence, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
+ return *this;
+}
+
+//______________________________________________________________________________
+template< class E >
+inline sal_Bool Sequence< E >::operator == ( const Sequence< E > & rSeq ) const
+ SAL_THROW(())
+{
+ if (_pSequence == rSeq._pSequence)
+ return sal_True;
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ return ::uno_type_equalData(
+ const_cast< Sequence< E > * >( this ), rType.getTypeLibType(),
+ const_cast< Sequence< E > * >( &rSeq ), rType.getTypeLibType(),
+ (uno_QueryInterfaceFunc)cpp_queryInterface,
+ (uno_ReleaseFunc)cpp_release );
+}
+
+//______________________________________________________________________________
+template< class E >
+inline sal_Bool Sequence< E >::operator != ( const Sequence< E > & rSeq ) const
+ SAL_THROW(())
+{
+ return (! operator == ( rSeq ));
+}
+
+//______________________________________________________________________________
+template< class E >
+inline E * Sequence< E >::getArray()
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if ! defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_reference2One(
+ &_pSequence, rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+#if ! defined EXCEPTIONS_OFF
+ if (! success)
+ throw ::std::bad_alloc();
+#endif
+ return reinterpret_cast< E * >( _pSequence->elements );
+}
+
+//______________________________________________________________________________
+template< class E >
+inline E & Sequence< E >::operator [] ( sal_Int32 nIndex )
+{
+ assert( nIndex >= 0 && nIndex < getLength() );
+ return getArray()[ nIndex ];
+}
+
+//______________________________________________________________________________
+template< class E >
+inline const E & Sequence< E >::operator [] ( sal_Int32 nIndex ) const
+ SAL_THROW(())
+{
+ assert( nIndex >= 0 && nIndex < getLength() );
+ return reinterpret_cast< const E * >( _pSequence->elements )[ nIndex ];
+}
+
+//______________________________________________________________________________
+template< class E >
+inline void Sequence< E >::realloc( sal_Int32 nSize )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if !defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_realloc(
+ &_pSequence, rType.getTypeLibType(), nSize,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+#if !defined EXCEPTIONS_OFF
+ if (!success)
+ throw ::std::bad_alloc();
+#endif
+}
+
+//------------------------------------------------------------------------------
+inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
+ const ::rtl::ByteSequence & rByteSequence ) SAL_THROW(())
+{
+ return ::com::sun::star::uno::Sequence< sal_Int8 >(
+ * reinterpret_cast< const ::com::sun::star::uno::Sequence< sal_Int8 > * >( &rByteSequence ) );
+}
+
+}
+}
+}
+}
+
+namespace cppu {
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
+{
+ if (::com::sun::star::uno::Sequence< T >::s_pType == 0) {
+ ::typelib_static_sequence_type_init(
+ &::com::sun::star::uno::Sequence< T >::s_pType,
+ (::cppu::getTypeFavourUnsigned(
+ static_cast<
+ typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
+ 0)).
+ getTypeLibType()));
+ }
+ return detail::getTypeFromTypeDescriptionReference(
+ &::com::sun::star::uno::Sequence< T >::s_pType);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
+{
+ //TODO On certain platforms with weak memory models, the following code can
+ // result in some threads observing that td points to garbage:
+ static typelib_TypeDescriptionReference * td = 0;
+ if (td == 0) {
+ ::typelib_static_sequence_type_init(
+ &td,
+ (::cppu::getTypeFavourChar(
+ static_cast<
+ typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
+ 0)).
+ getTypeLibType()));
+ }
+ return detail::getTypeFromTypeDescriptionReference(&td);
+}
+
+}
+
+// generic sequence template
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuType(
+ SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Sequence< E > * )
+ SAL_THROW(())
+{
+ return ::cppu::getTypeFavourUnsigned(
+ static_cast< ::com::sun::star::uno::Sequence< E > * >(0));
+}
+
+// generic sequence template for given element type (e.g. C++ arrays)
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
+ SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Sequence< E >::s_pType)
+ {
+ ::typelib_static_sequence_type_init(
+ & ::com::sun::star::uno::Sequence< E >::s_pType,
+ rElementType.getTypeLibType() );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Sequence< E >::s_pType );
+}
+
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
+static typelib_TypeDescriptionReference * s_pType_com_sun_star_uno_Sequence_Char = 0;
+#endif
+
+// char sequence
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCharSequenceCppuType() SAL_THROW(())
+{
+#if !( defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
+ static typelib_TypeDescriptionReference * s_pType_com_sun_star_uno_Sequence_Char = 0;
+#endif
+ if (! s_pType_com_sun_star_uno_Sequence_Char)
+ {
+ const ::com::sun::star::uno::Type & rElementType = ::getCharCppuType();
+ ::typelib_static_sequence_type_init(
+ & s_pType_com_sun_star_uno_Sequence_Char,
+ rElementType.getTypeLibType() );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & s_pType_com_sun_star_uno_Sequence_Char );
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Type.h b/include/com/sun/star/uno/Type.h
new file mode 100644
index 000000000000..1d71910b28ec
--- /dev/null
+++ b/include/com/sun/star/uno/Type.h
@@ -0,0 +1,460 @@
+/* -*- 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_UNO_TYPE_H_
+#define _COM_SUN_STAR_UNO_TYPE_H_
+
+#include <typelib/typedescription.h>
+#include <com/sun/star/uno/TypeClass.hdl>
+#include <cppu/macros.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/alloc.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
+*/
+enum UnoType_NoAcquire
+{
+ /** This enum value can be used for creating a Type object granting a given type description
+ reference, i.e. transferring ownership to it.
+ */
+ UNO_TYPE_NO_ACQUIRE
+};
+
+/** C++ class representing an IDL meta type. This class is used to represent a a type,
+ i.e. a type name and its type class.
+ Internally the type holds a C type description reference of the runtime.
+ You can obtain a full type description of a type by calling member function getDescription().
+
+ @see typelib_TypeDescriptionReference
+*/
+class Type
+{
+ /** the C typelib reference pointer
+ */
+ typelib_TypeDescriptionReference * _pType;
+
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Default Constructor: Type is set to void.
+ */
+ inline Type() SAL_THROW(());
+
+ /** Constructor: Type is constructed by given name and type class.
+
+ @param eTypeClass type class of type
+ @param rTypeName name of type
+ */
+ inline Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW(());
+
+ /** Constructor: Type is constructed by given name and type class.
+
+ @param eTypeClass type class of type
+ @param pTypeName name of type
+ */
+ inline Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW(());
+
+ /** Constructor: Type is (copy) constructed by given C type description reference.
+
+ @param pType C type description reference
+ */
+ inline Type( typelib_TypeDescriptionReference * pType ) SAL_THROW(());
+
+ /** Constructor: Type is (copy) constructed by given C type description reference
+ without acquiring it.
+
+ @param pType C type description reference
+ @param dummy UNO_TYPE_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire dummy ) SAL_THROW(());
+ /** Constructor: Type is (copy) constructed by given C type description reference
+ without acquiring it.
+
+ @param pType C type description reference
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire dummy ) SAL_THROW(());
+
+ /** Copy constructor: Type is copy constructed by given type.
+
+ @param rType another type
+ */
+ inline Type( const Type & rType ) SAL_THROW(());
+
+ /** Destructor: Releases acquired C type description reference.
+ */
+ inline ~Type() SAL_THROW(())
+ { ::typelib_typedescriptionreference_release( _pType ); }
+
+ /** Assignment operator: Acquires right side type and releases previously set type.
+
+ @param rType another type (right side)
+ @return this type
+ */
+ inline Type & SAL_CALL operator = ( const Type & rType ) SAL_THROW(());
+
+ /** Gets the type class of set type.
+
+ @return type class of set type
+ */
+ inline TypeClass SAL_CALL getTypeClass() const SAL_THROW(())
+ { return (TypeClass)_pType->eTypeClass; }
+
+ /** Gets the name of the set type.
+
+ @return name of the set type
+ */
+ inline ::rtl::OUString SAL_CALL getTypeName() const SAL_THROW(());
+
+ /** Obtains a full type description of set type.
+
+ @param ppDescr [inout] type description
+ */
+ inline void SAL_CALL getDescription( typelib_TypeDescription ** ppDescr ) const SAL_THROW(())
+ { ::typelib_typedescriptionreference_getDescription( ppDescr, _pType ); }
+
+ /** Gets the C typelib type description reference pointer. Does not acquire the reference!
+
+ @return UNacquired type description reference
+ */
+ inline typelib_TypeDescriptionReference * SAL_CALL getTypeLibType() const SAL_THROW(())
+ { return _pType; }
+
+ /** Tests if values of this reflected type can be assigned by values of given type.
+ This includes widening conversion (e.g., long assignable from short), as long as there
+ is no data loss.
+
+ @param rType another type
+ @return true if values of this type can be assigned from values of given type,
+ false otherwise
+ */
+ inline sal_Bool SAL_CALL isAssignableFrom( const Type & rType ) const SAL_THROW(())
+ { return ::typelib_typedescriptionreference_isAssignableFrom( _pType, rType._pType ); }
+
+ /** Compares two types.
+
+ @param rType another type
+ @return true if both types refer the same type, false otherwise
+ */
+ inline sal_Bool SAL_CALL equals( const Type & rType ) const SAL_THROW(())
+ { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
+ /** Equality operator: Compares two types.
+
+ @param rType another type
+ @return true if both types refer the same type, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const Type & rType ) const SAL_THROW(())
+ { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
+ /** Unequality operator: Compares two types.
+
+ @param rType another type
+ @return false if both types refer the same type, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const Type & rType ) const SAL_THROW(())
+ { return (! ::typelib_typedescriptionreference_equals( _pType, rType._pType )); }
+};
+
+/** Helper class to specify a type pointer for idl arrays.
+*/
+template< class T >
+class Array
+{
+public:
+ static typelib_TypeDescriptionReference * s_pType;
+};
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL type "type".
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type "type"
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type void.
+ @return type of IDL type void
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW(());
+/** Gets the meta type of IDL type void.
+
+ @return type of IDL type void
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW(());
+
+/** Gets the meta type of IDL type boolean.
+
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW(());
+/** Gets the meta type of IDL type boolean.
+
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW(());
+/** Gets the meta type of IDL type boolean.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * ) SAL_THROW(());
+/** Gets the meta type of IDL type boolean.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
+ bool const * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type char.
+
+ @return type of IDL type char
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW(());
+/** Gets the meta type of IDL type char.
+
+ @return type of IDL type char
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW(());
+
+/** Gets the meta type of IDL type byte.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type byte
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type string.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type string
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type short.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type short
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type unsigned short.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type unsigned short
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type long.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type long
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type unsigned long.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type unsigned long
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type hyper.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type hyper
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type unsigned hyper.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type unsigned hyper
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type float.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type float
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * ) SAL_THROW(());
+
+/** Gets the meta type of IDL type double.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ The dummy parameter is just a typed pointer for function signature.
+
+ @return type of IDL type double
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * ) SAL_THROW(());
+
+/** Array template function to get meta type for one-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW(());
+/** Array template function to get meta type for two-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW(());
+/** Array template function to get meta type for three-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW(());
+/** Array template function to get meta type for four-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW(());
+/** Array template function to get meta type for five-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW(());
+/** Array template function to get meta type for six-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW(());
+
+/** Gets the meta type of an IDL type.
+
+ The difference between this function template (with a type parameter) and
+ the overloaded getCppuType function with a single (dummy) parameter of a
+ specific type is that this function template may not work for the UNO type
+ "unsigned short" (sal_uInt16 in C++), while the overloaded one-parameter
+ function may not work for the UNO type "char" (sal_Unicode in C++, which may
+ have the same underlying C++ type as sal_uInt16 on certain platforms).
+
+ @return type of the given IDL type
+
+ @deprecated
+ Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar).
+ Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >()
+ does not work as expected.
+
+ @since UDK 3.2.0
+*/
+template< typename T > inline const ::com::sun::star::uno::Type & SAL_CALL
+getCppuType() SAL_THROW(());
+
+/** Gets the meta type of IDL type char.
+
+ @return type of IDL type char
+
+ @deprecated
+ Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar).
+ Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >()
+ does not work as expected.
+
+ @since UDK 3.2.0
+*/
+template<> inline const ::com::sun::star::uno::Type & SAL_CALL
+getCppuType< sal_Unicode >() SAL_THROW(());
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/Type.hxx b/include/com/sun/star/uno/Type.hxx
new file mode 100644
index 000000000000..40528af116ad
--- /dev/null
+++ b/include/com/sun/star/uno/Type.hxx
@@ -0,0 +1,321 @@
+/* -*- 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_UNO_TYPE_HXX_
+#define _COM_SUN_STAR_UNO_TYPE_HXX_
+
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/Type.h>
+#include "cppu/unotype.hxx"
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline Type::Type() SAL_THROW(())
+{
+ _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW(())
+ : _pType( 0 )
+{
+ ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW(())
+ : _pType( 0 )
+{
+ ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType ) SAL_THROW(())
+ : _pType( pType )
+{
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire ) SAL_THROW(())
+ : _pType( pType )
+{
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire ) SAL_THROW(())
+ : _pType( pType )
+{
+}
+//__________________________________________________________________________________________________
+inline Type::Type( const Type & rType ) SAL_THROW(())
+ : _pType( rType._pType )
+{
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline ::rtl::OUString Type::getTypeName() const SAL_THROW(())
+{
+ return ::rtl::OUString( _pType->pTypeName );
+}
+//__________________________________________________________________________________________________
+inline Type & Type::operator = ( const Type & rType ) SAL_THROW(())
+{
+ ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
+ return *this;
+}
+
+//__________________________________________________________________________________________________
+template< class T >
+typelib_TypeDescriptionReference * Array< T >::s_pType = 0;
+
+}
+}
+}
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW(())
+{
+ return ::cppu::UnoType< bool >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW(())
+{
+ return ::cppu::UnoType< bool >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< bool >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
+ SAL_UNUSED_PARAMETER bool const * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< bool >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::sal_Int8 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::rtl::OUString >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::sal_Int16 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::sal_Int32 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::sal_uInt32 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::sal_Int64 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< ::sal_uInt64 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< float >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * ) SAL_THROW(())
+{
+ return ::cppu::UnoType< double >::get();
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( *pT );
+ sal_Int32 size = sizeof( **pT );
+ sal_Int32 dim1 = sizeof( *pT ) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 1, dim1 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( **pT );
+ sal_Int32 size = sizeof( ***pT );
+ sal_Int32 dim2 = sizeof( **pT ) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / dim2 / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 2, dim1, dim2 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( ***pT );
+ sal_Int32 size = sizeof( ****pT );
+ sal_Int32 dim3 = sizeof( ***pT ) / size;
+ sal_Int32 dim2 = sizeof( **pT ) / dim3 / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3)/ size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 3, dim1, dim2, dim3 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( ****pT );
+ sal_Int32 size = sizeof( *****pT );
+ sal_Int32 dim4 = sizeof( ****pT ) / size;
+ sal_Int32 dim3 = sizeof( ***pT ) / dim4 / size;
+ sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 4, dim1, dim2, dim3, dim4 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( *****pT );
+ sal_Int32 size = sizeof( ******pT );
+ sal_Int32 dim5 = sizeof( *****pT ) / size;
+ sal_Int32 dim4 = sizeof( ****pT ) / dim5 / size;
+ sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5) / size;
+ sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 5, dim1, dim2, dim3, dim4, dim5 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW(())
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( ******pT );
+ sal_Int32 size = sizeof( *******pT );
+ sal_Int32 dim6 = sizeof( ******pT ) / size;
+ sal_Int32 dim5 = sizeof( *****pT ) / dim6 / size;
+ sal_Int32 dim4 = sizeof( ****pT ) / (dim5 * dim6) / size;
+ sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5 * dim6) / size;
+ sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5 * dim6) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5 * dim6) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 6, dim1, dim2, dim3, dim4, dim5, dim6 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< typename T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType() SAL_THROW(())
+{
+ return ::cppu::UnoType< T >::get();
+}
+
+template<>
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
+ SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/genfunc.h b/include/com/sun/star/uno/genfunc.h
new file mode 100644
index 000000000000..12b6ad7d4640
--- /dev/null
+++ b/include/com/sun/star/uno/genfunc.h
@@ -0,0 +1,63 @@
+/* -*- 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_UNO_GENFUNC_H_
+#define _COM_SUN_STAR_UNO_GENFUNC_H_
+
+#include "sal/types.h"
+
+typedef struct _typelib_TypeDescriptionReference typelib_TypeDescriptionReference;
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Function to acquire a C++ interface.
+
+ @param pCppI C++ interface pointer
+*/
+inline void SAL_CALL cpp_acquire( void * pCppI )
+ SAL_THROW(());
+/** Function to release a C++ interface.
+
+ @param pCppI C++ interface pointer
+*/
+inline void SAL_CALL cpp_release( void * pCppI )
+ SAL_THROW(());
+/** Function to query for a C++ interface.
+
+ @param pCppI C++ interface pointer
+ @param pType demanded interface type
+ @return acquired C++ interface pointer or null
+*/
+inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType )
+ SAL_THROW(());
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/com/sun/star/uno/genfunc.hxx b/include/com/sun/star/uno/genfunc.hxx
new file mode 100644
index 000000000000..d523123733e4
--- /dev/null
+++ b/include/com/sun/star/uno/genfunc.hxx
@@ -0,0 +1,82 @@
+/* -*- 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_UNO_GENFUNC_HXX_
+#define _COM_SUN_STAR_UNO_GENFUNC_HXX_
+
+#include <com/sun/star/uno/genfunc.h>
+#include <com/sun/star/uno/Any.hxx>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//==================================================================================================
+inline void SAL_CALL cpp_acquire( void * pCppI )
+ SAL_THROW(())
+{
+ reinterpret_cast< XInterface * >( pCppI )->acquire();
+}
+//==================================================================================================
+inline void SAL_CALL cpp_release( void * pCppI )
+ SAL_THROW(())
+{
+ reinterpret_cast< XInterface * >( pCppI )->release();
+}
+//==================================================================================================
+inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType )
+ SAL_THROW(())
+{
+ if (pCppI)
+ {
+#ifndef EXCEPTIONS_OFF
+ try
+ {
+#endif
+ Any aRet( reinterpret_cast< XInterface * >( pCppI )->queryInterface(
+ * reinterpret_cast< const Type * >( &pType ) ) );
+ if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
+ {
+ XInterface * pRet = reinterpret_cast< XInterface * >( aRet.pReserved );
+ aRet.pReserved = 0;
+ return pRet;
+ }
+#ifndef EXCEPTIONS_OFF
+ }
+ catch (RuntimeException &)
+ {
+ }
+#endif
+ }
+ return 0;
+}
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/Enterable.hxx b/include/cppu/Enterable.hxx
new file mode 100644
index 000000000000..6bb4a9c274d4
--- /dev/null
+++ b/include/cppu/Enterable.hxx
@@ -0,0 +1,108 @@
+/* -*- 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 INCLUDED_cppu_Enterable_hxx
+#define INCLUDED_cppu_Enterable_hxx
+
+#include "uno/Enterable.h"
+#include "rtl/ustring.hxx"
+
+namespace cppu
+{
+/** C++ wrapper for binary C Enterable
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Stack)
+
+ @see uno_Enterable
+ @since UDK 3.2.7
+*/
+class Enterable : public uno_Enterable
+{
+public:
+ /* These methods need to be implemented in a derived class.
+ */
+ virtual void v_enter (void) = 0;
+ virtual void v_leave (void) = 0;
+ virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) = 0;
+ virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam) = 0;
+ virtual int v_isValid (rtl::OUString * pReason) = 0;
+
+ virtual ~Enterable() {}
+
+public:
+ inline explicit Enterable(void);
+
+ inline void enter(void) {m_enter(this);}
+ inline void leave(void) {m_leave(this);}
+
+ inline void callInto_v(uno_EnvCallee * pCallee, va_list * pParam) {m_callInto_v(this, pCallee, pParam);}
+ inline void callOut_v (uno_EnvCallee * pCallee, va_list * pParam) {m_callOut_v (this, pCallee, pParam);}
+
+ inline void callInto(uno_EnvCallee * pCallee, ...);
+ inline void callOut (uno_EnvCallee * pCallee, ...);
+
+ inline int isValid (rtl::OUString * pReason) {return m_isValid(this, (rtl_uString **)pReason);}
+
+private:
+ Enterable(Enterable const &);
+ Enterable & operator = (Enterable const &);
+};
+
+extern "C" inline void Enterable_call_enter (void * context) { ((Enterable *)context)->v_enter(); }
+extern "C" inline void Enterable_call_leave (void * context) { ((Enterable *)context)->v_leave(); }
+extern "C" inline void Enterable_call_callInto_v(void * context, uno_EnvCallee * pCallee, va_list * pParam)
+ { ((Enterable *)context)->v_callInto_v(pCallee, pParam); }
+extern "C" inline void Enterable_call_callOut_v (void * context, uno_EnvCallee * pCallee, va_list * pParam)
+ { ((Enterable *)context)->v_callOut_v(pCallee, pParam); }
+extern "C" inline int Enterable_call_isValid (void * context, rtl_uString ** pReason)
+ {return ((Enterable *)context)->v_isValid((rtl::OUString *)pReason);}
+
+
+Enterable::Enterable(void)
+{
+ m_enter = Enterable_call_enter;
+ m_leave = Enterable_call_leave;
+ m_callInto_v = Enterable_call_callInto_v;
+ m_callOut_v = Enterable_call_callOut_v;
+ m_isValid = Enterable_call_isValid;
+}
+
+void Enterable::callInto(uno_EnvCallee * pCallee, ...)
+{
+ va_list param;
+
+ va_start(param, pCallee);
+ callInto_v(pCallee, &param);
+ va_end(param);
+}
+
+void Enterable::callOut(uno_EnvCallee * pCallee, ...)
+{
+ va_list param;
+
+ va_start(param, pCallee);
+ callOut_v(pCallee, &param);
+ va_end(param);
+}
+
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/EnvDcp.hxx b/include/cppu/EnvDcp.hxx
new file mode 100644
index 000000000000..340ebcb3d5e1
--- /dev/null
+++ b/include/cppu/EnvDcp.hxx
@@ -0,0 +1,69 @@
+/* -*- 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 INCLUDED_cppu_EnvDcp_hxx
+#define INCLUDED_cppu_EnvDcp_hxx
+
+#include "rtl/ustring.hxx"
+#include "uno/EnvDcp.h"
+
+
+namespace cppu
+{
+namespace EnvDcp
+{
+/** Get the OBI type part of an environment descriptor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Descriptor)
+
+ @param rEnvDcp the Environment Descriptor
+ @return the OBI type
+ @since UDK 3.2.7
+*/
+inline rtl::OUString getTypeName(rtl::OUString const & rEnvDcp)
+{
+ rtl::OUString typeName;
+
+ uno_EnvDcp_getTypeName(rEnvDcp.pData, &typeName.pData);
+
+ return typeName;
+}
+
+/** Get the purpose part of an environment descriptor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Descriptor)
+
+ @param rEnvDcp the Environment Descriptor
+ @return the purpose
+ @since UDK 3.2.7
+*/
+inline rtl::OUString getPurpose(rtl::OUString const & rEnvDcp)
+{
+ rtl::OUString purpose;
+
+ uno_EnvDcp_getPurpose(rEnvDcp.pData, &purpose.pData);
+
+ return purpose;
+}
+
+}
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/EnvGuards.hxx b/include/cppu/EnvGuards.hxx
new file mode 100644
index 000000000000..e1334ac7909a
--- /dev/null
+++ b/include/cppu/EnvGuards.hxx
@@ -0,0 +1,107 @@
+/* -*- 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 INCLUDED_cppu_EnvGuards_hxx
+#define INCLUDED_cppu_EnvGuards_hxx
+
+#include "uno/environment.hxx"
+#include "uno/mapping.hxx"
+
+
+namespace cssuno = com::sun::star::uno;
+
+
+namespace cppu
+{
+ /** Environment Guard
+ The provided Environment becomes entered in the constructor and left
+ in the destructor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Guard)
+
+ @since UDK 3.2.7
+ */
+ class EnvGuard
+ {
+ cssuno::Environment m_env;
+
+ public:
+ explicit EnvGuard(cssuno::Environment const & env)
+ {
+ if (env.is())
+ {
+ m_env = cssuno::Environment::getCurrent();
+ env.enter();
+ }
+ }
+
+ ~EnvGuard()
+ {
+ m_env.enter();
+ }
+
+ /** Checks if the associated environment is non empty.
+
+ @return 0 == empty, 1 == non empty
+ */
+ sal_Bool SAL_CALL is() const SAL_THROW(())
+ {
+ return m_env.is();
+ }
+
+ /** Leaves the associated environment and clears
+ the reference.
+ */
+ void clear()
+ {
+ if (m_env.is())
+ {
+ m_env.enter();
+ m_env.clear();
+ }
+ }
+ };
+
+ /** Environment Anti-Guard
+ Any entered Environment becomes left in the constructor and re-entered
+ in the destructor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_AntiGuard)
+
+ @since UDK 3.2.7
+ */
+ class AntiEnvGuard
+ {
+ cssuno::Environment m_env;
+
+ public:
+ explicit AntiEnvGuard()
+ : m_env(cssuno::Environment::getCurrent())
+ {
+ uno_Environment_enter(NULL);
+ }
+
+ ~AntiEnvGuard()
+ {
+ m_env.enter();
+ }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/Map.hxx b/include/cppu/Map.hxx
new file mode 100644
index 000000000000..576d2e9133ae
--- /dev/null
+++ b/include/cppu/Map.hxx
@@ -0,0 +1,107 @@
+/* -*- 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 INCLUDED_cppu_Map_hxx
+#define INCLUDED_cppu_Map_hxx
+
+#include <uno/mapping.hxx>
+
+
+namespace cssu = com::sun::star::uno;
+
+namespace cppu
+{
+ /** Helpers for mapping objects relative to the current environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Map_Helpers)
+ */
+
+ /** Maps an object from the current to an outer Environment, returns mapped object.
+
+ @param pT the object to be mapped
+ @param outerEnv the target environment
+ @return the mapped object
+ @since UDK 3.2.7
+ */
+ template<class T> inline T * mapOut(T * pT, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
+
+ return reinterpret_cast<T *>(curr2outer.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
+ }
+
+
+ /** Maps an object from an outer Environment to the current, returns mapped object.
+
+ @param pT the object to be mapped
+ @param outerEnv the source environment
+ @return the mapped object
+ @since UDK 3.2.7
+ */
+ template<class T> inline T * mapIn(T * pT, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
+
+ return reinterpret_cast<T *>(outer2curr.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
+ }
+
+
+ /** Maps an any from the current to an outer Environment, fills passed any.
+
+ @param any the any to be mapped
+ @param res the target any
+ @param outerEnv the target environment
+ @since UDK 3.2.7
+ */
+ // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
+ inline void mapOutAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
+
+ uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release);
+ uno_type_any_constructAndConvert(
+ res,
+ const_cast<void *>(any.getValue()),
+ any.getValueTypeRef(),
+ curr2outer.get());
+ }
+
+
+ /** Maps an any from an outer Environment to the current, fills passed any.
+
+ @param any the any to be mapped
+ @param res the target any
+ @param outerEnv the source environment
+ @since UDK 3.2.7
+ */
+ inline void mapInAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
+
+ uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release);
+ uno_type_any_constructAndConvert(
+ res,
+ const_cast<void *>(any.getValue()),
+ any.getValueTypeRef(),
+ outer2curr.get());
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/cppudllapi.h b/include/cppu/cppudllapi.h
new file mode 100644
index 000000000000..ee37e1b1c399
--- /dev/null
+++ b/include/cppu/cppudllapi.h
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#ifndef INCLUDED_CPPUDLLAPI_H
+#define INCLUDED_CPPUDLLAPI_H
+
+#include "sal/types.h"
+
+#if defined(CPPU_DLLIMPLEMENTATION)
+#define CPPU_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define CPPU_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#if defined(PURPENV_DLLIMPLEMENTATION)
+#define PURPENV_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define PURPENV_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif /* INCLUDED_CPPUDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/helper/purpenv/Environment.hxx b/include/cppu/helper/purpenv/Environment.hxx
new file mode 100644
index 000000000000..04985d7643b0
--- /dev/null
+++ b/include/cppu/helper/purpenv/Environment.hxx
@@ -0,0 +1,42 @@
+/* -*- 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 INCLUDED_cppu_helper_purpenv_Environment_hxx
+#define INCLUDED_cppu_helper_purpenv_Environment_hxx
+
+#include <cppu/cppudllapi.h>
+#include "uno/environment.h"
+#include "cppu/Enterable.hxx"
+
+
+namespace cppu { namespace helper { namespace purpenv {
+
+/** C++ helper for implementing Purpose Environments.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Purpose_Bridge_Implementation_Helper)
+
+ @since UDK 3.2.7
+*/
+PURPENV_DLLPUBLIC void Environment_initWithEnterable(
+ uno_Environment * pEnvironment, cppu::Enterable * pEnterable);
+
+}}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/helper/purpenv/Mapping.hxx b/include/cppu/helper/purpenv/Mapping.hxx
new file mode 100644
index 000000000000..83518cf75d21
--- /dev/null
+++ b/include/cppu/helper/purpenv/Mapping.hxx
@@ -0,0 +1,63 @@
+/* -*- 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 INCLUDED_cppu_helper_purpenv_Mapping_hxx
+#define INCLUDED_cppu_helper_purpenv_Mapping_hxx
+
+#include "com/sun/star/uno/Any.h"
+
+#include <cppu/cppudllapi.h>
+#include "uno/environment.h"
+#include "uno/mapping.h"
+
+
+namespace cppu { namespace helper { namespace purpenv {
+
+/** C++ helper for implementing Purpose Environments.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Purpose_Bridge_Implementation_Helper)
+
+ @since UDK 3.2.7
+*/
+
+typedef void ProbeFun(
+ bool pre,
+ void * pThis,
+ void * pContext,
+ typelib_TypeDescriptionReference * pReturnTypeRef,
+ typelib_MethodParameter * pParams,
+ sal_Int32 nParams,
+ typelib_TypeDescription const * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+
+
+
+PURPENV_DLLPUBLIC void createMapping(uno_Mapping ** ppMapping,
+ uno_Environment * pFrom,
+ uno_Environment * pTo,
+ ProbeFun * probeFun = NULL,
+ void * pContext = NULL
+ );
+
+}}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/macros.hxx b/include/cppu/macros.hxx
new file mode 100644
index 000000000000..ecaa1470893b
--- /dev/null
+++ b/include/cppu/macros.hxx
@@ -0,0 +1,58 @@
+/* -*- 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 _CPPU_MACROS_HXX_
+#define _CPPU_MACROS_HXX_
+
+#include <sal/types.h>
+#include <uno/lbnames.h>
+
+/** Namespace name for compiler/ platform, e.g. gcc3, msci */
+#define CPPU_CURRENT_NAMESPACE CPPU_ENV
+
+/// @cond INTERNAL
+
+/** Patching the GCC 3 incomatible alignment change for Linux.
+
+ This macro is appended by cppumaker to every first member of a struct, if
+ the struct inherits from a base struct and the first member is neither
+ double nor sal_[u]Int64. (The double/sal_[u]Int64 restriction is due to a
+ bug in GCC prior to version 3.3, which would cause __alignof__ of such a
+ struct to become 8 instead of 4 if CPPU_GCC3_ALIGN were added to its first
+ member.)
+*/
+#if defined(__GNUC__)
+#define CPPU_GCC3_ALIGN( base_struct ) __attribute__ ((aligned (__alignof__ (base_struct))))
+#else
+#define CPPU_GCC3_ALIGN( base_struct )
+#endif
+
+/**
+ Exporting the symbols necessary for exception handling on GCC.
+
+ These macros are used in the headers generated by cppumaker for UNO exception
+ types, to ensure that exception handling does not fail on GCC.
+*/
+#define CPPU_GCC_DLLPUBLIC_EXPORT SAL_EXCEPTION_DLLPUBLIC_EXPORT
+#define CPPU_GCC_DLLPRIVATE SAL_EXCEPTION_DLLPRIVATE
+
+/// @endcond
+
+#endif // _CPPU_MACROS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/unotype.hxx b/include/cppu/unotype.hxx
new file mode 100644
index 000000000000..2861bdb2c922
--- /dev/null
+++ b/include/cppu/unotype.hxx
@@ -0,0 +1,375 @@
+/* -*- 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 INCLUDED_CPPU_UNOTYPE_HXX
+#define INCLUDED_CPPU_UNOTYPE_HXX
+
+#include "sal/config.h"
+#include "com/sun/star/uno/Type.h"
+#include "sal/types.h"
+#include "typelib/typeclass.h"
+#include "typelib/typedescription.h"
+
+namespace com { namespace sun { namespace star { namespace uno {
+ class Any;
+ class Exception;
+ template< typename > class Reference;
+ template< typename > class Sequence;
+ class XInterface;
+} } } }
+namespace rtl { class OUString; }
+
+namespace cppu {
+
+template< typename > class UnoType;
+
+/**
+ A unique C++ type representing the UNO type VOID in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+struct UnoVoidType;
+
+/**
+ A unique C++ type representing the UNO type UNSIGNED SHORT in cppu::UnoType.
+
+ The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
+ type is needed to unambiguously specify UNO types in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+struct UnoUnsignedShortType;
+
+/**
+ A unique C++ type representing the UNO type UNSIGNED SHORT in cppu::UnoType.
+
+ The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
+ type is needed to unambiguously specify UNO types in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+struct UnoCharType;
+
+/**
+ A unique C++ type template representing the UNO sequence types in
+ cppu::UnoType.
+
+ The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
+ type is needed to unambiguously specify UNO types in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+template< typename > struct UnoSequenceType;
+
+namespace detail {
+
+inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
+ ::typelib_TypeDescriptionReference * const * tdr)
+{
+ return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
+}
+
+inline ::com::sun::star::uno::Type const &
+getTypeFromTypeClass(::typelib_TypeClass tc) {
+ return getTypeFromTypeDescriptionReference(
+ ::typelib_static_type_getByTypeClass(tc));
+}
+
+}
+
+}
+
+namespace cppu { namespace detail {
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER bool const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Bool const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int8 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(
+ ::typelib_TypeClass_UNSIGNED_SHORT);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(
+ ::typelib_TypeClass_UNSIGNED_LONG);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(
+ ::typelib_TypeClass_UNSIGNED_HYPER);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER float const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER double const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_ANY);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
+{
+ //TODO: depending on memory model, the following might not work reliably
+ static typelib_TypeDescriptionReference * p = 0;
+ if (p == 0) {
+ ::typelib_static_sequence_type_init(
+ &p, ::cppu::UnoType< T >::get().getTypeLibType());
+ }
+ return ::cppu::detail::getTypeFromTypeDescriptionReference(&p);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
+{
+ return cppu_detail_getUnoType(
+ static_cast< ::cppu::UnoSequenceType< T > * >(0));
+}
+
+inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION);
+}
+
+inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_INTERFACE);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
+{
+ return ::cppu::UnoType< T >::get();
+}
+
+} }
+
+namespace cppu {
+
+/**
+ Get the com::sun::star::uno::Type instance representing a certain UNO type.
+
+ For each C++ type representing a UNO type, the corresponding instantiation of
+ this template has a public static member function get(). (The template is
+ specialized for C++ templates representing polymorphic struct type templates
+ of UNO. In those cases, it does not work to instantiate UnoType with a C++
+ type that is derived from a C++ type that represents a UNO type, but does not
+ itself represent a UNO type. In all other cases, UnoType even works for such
+ C++ types that are unambiguously derived from one C++ type that represents a
+ UNO type.) In addition to those C++ types that are mappings of UNO types
+ (except for sal_uInt16 and sal_Unicode, see below), the following C++ types
+ are appropriate as template arguments: cppu::UnoVoidType, bool,
+ cppu::UnoUnsignedShortType, cppu::UnoCharType, cppu::UnoSequenceType with any
+ appropriate template argument (the latter three to unambiguously specify UNO
+ types, as the UNO types UNSIGNED SHORT and CHAR map to the same C++ type),
+ and com::sun::star::uno::Reference with any appropriate template argument.
+
+ @since UDK 3.2.2
+*/
+template< typename T > class UnoType {
+public:
+ static inline ::com::sun::star::uno::Type const & get() {
+ using namespace ::cppu::detail;
+ return cppu_detail_getUnoType(static_cast< T * >(0));
+ }
+
+private:
+ UnoType(UnoType &); // not defined
+ ~UnoType(); // not defined
+ void operator =(UnoType &); // not defined
+};
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of getCppuType. The replacement has exactly the same semantics as
+ getCppuType, in that it returns correct results for the UNO type UNSIGNED
+ SHORT but not for the UNO type CHAR.
+
+ @since UDK 3.2.2
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *) {
+ return ::cppu::UnoType< T >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of getCppuType. The replacement has exactly the same semantics as
+ getCppuType, in that it returns correct results for the UNO type UNSIGNED
+ SHORT but not for the UNO type CHAR.
+
+ @since UDK 3.2.2
+*/
+inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
+ return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of getCppuType. The replacement has exactly the same semantics as
+ getCppuType, in that it returns correct results for the UNO type UNSIGNED
+ SHORT but not for the UNO type CHAR.
+
+ @since UDK 3.2.2
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(::com::sun::star::uno::Sequence< T > const *);
+ // defined in com/sun/star/uno/Sequence.hxx
+
+/// @cond INTERNAL
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of the getCppuType template. The replacement has exactly the same semantics
+ as the getCppuType template, in that it returns correct results for the UNO
+ type CHAR but not for the UNO type UNSIGNED SHORT. Additionally, it also
+ returns the intended results for sequence types.
+
+ @since UDK 3.2.3
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(SAL_UNUSED_PARAMETER T const *) {
+ return ::cppu::UnoType< T >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of the getCppuType template. The replacement has exactly the same semantics
+ as the getCppuType template, in that it returns correct results for the UNO
+ type CHAR but not for the UNO type UNSIGNED SHORT. Additionally, it also
+ returns the intended results for sequence types.
+
+ @since UDK 3.2.3
+*/
+inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(SAL_UNUSED_PARAMETER ::sal_Unicode const *) {
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of the getCppuType template. The replacement has exactly the same semantics
+ as the getCppuType template, in that it returns correct results for the UNO
+ type CHAR but not for the UNO type UNSIGNED SHORT. Additionally, it also
+ returns the intended results for sequence types.
+
+ @since UDK 3.2.3
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(::com::sun::star::uno::Sequence< T > const *);
+ // defined in com/sun/star/uno/Sequence.hxx
+
+/// @endcond
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/access_control.hxx b/include/cppuhelper/access_control.hxx
new file mode 100644
index 000000000000..f1fbe3f13cd6
--- /dev/null
+++ b/include/cppuhelper/access_control.hxx
@@ -0,0 +1,119 @@
+/* -*- 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 _CPPUHELPER_ACCESS_CONTROL_HXX_
+#define _CPPUHELPER_ACCESS_CONTROL_HXX_
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/security/XAccessController.hpp>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+/** Helper class retriving access controller singleton from component context.
+*/
+class CPPUHELPER_DLLPUBLIC AccessControl
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessController > m_xController;
+
+public:
+ /** Ctor.
+
+ @param xContext component context to retrieve access controller singleton
+ */
+ AccessControl(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > const & xContext )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+ /** Ctor.
+
+ @param xController access controller
+ */
+ AccessControl(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::security::XAccessController > const & xController )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+ /** Copy ctor.
+
+ @param ac another object
+ */
+ AccessControl( ::cppu::AccessControl const & ac )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+ /** Clears the access controller reference being used.
+ */
+ inline void SAL_CALL clear() SAL_THROW(())
+ { m_xController.clear(); }
+
+ /** Returns access to the access controller reference being used.
+
+ @return access controller
+ */
+ inline ::com::sun::star::uno::Reference<
+ ::com::sun::star::security::XAccessController > const & SAL_CALL get() const SAL_THROW(())
+ { return m_xController; }
+
+ /** Returns access to the access controller reference being used.
+
+ @return access controller
+ */
+ inline ::com::sun::star::security::XAccessController * SAL_CALL operator -> () const SAL_THROW(())
+ { return m_xController.get(); }
+
+
+ /** A com.sun.star.security.RuntimePermission is for runtime permissions.
+ A RuntimePermission contains a name (also referred to as a "target name") but no
+ actions list; you either have the named permission or you don't.
+
+ @param name name of permission
+ */
+ void SAL_CALL checkRuntimePermission(
+ ::rtl::OUString const & name )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+ /** A com.sun.star.io.FilePermission represents access to a file or directory.
+ A FilePermission consists of a file url and a set of actions valid for that pathname.
+
+ @param url file url
+ @param actions actions list
+ */
+ void SAL_CALL checkFilePermission(
+ ::rtl::OUString const & url,
+ ::rtl::OUString const & actions )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+ /** A com.sun.star.connection.SocketPermission represents access to a network via sockets.
+ A SocketPermission consists of a host specification and a set of "actions"
+ specifying ways to connect to that host.
+
+ @param host host and optional portrange
+ @param actions actions list
+ */
+ void SAL_CALL checkSocketPermission(
+ ::rtl::OUString const & host,
+ ::rtl::OUString const & actions )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/basemutex.hxx b/include/cppuhelper/basemutex.hxx
new file mode 100644
index 000000000000..5394b834e434
--- /dev/null
+++ b/include/cppuhelper/basemutex.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 _CPPUHELPER_BASEMUTEX_HXX_
+#define _CPPUHELPER_BASEMUTEX_HXX_
+
+#include <osl/mutex.hxx>
+
+namespace cppu
+{
+ /** base class for all classes who want derive from
+ cppu::WeakComponentImplHelperXX.
+
+ Implmentation classes have first to derive from BaseMutex and then from
+ cppu::WeakComponentImplHelperXX to ensure that the BaseMutex is completely
+ initialized when the mutex is used to intialize the
+ cppu::WeakComponentImplHelperXX
+ */
+ class BaseMutex
+ {
+ protected:
+ mutable ::osl::Mutex m_aMutex;
+ };
+}
+#endif // _CPPUHELPER_BASEMUTEX_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/bootstrap.hxx b/include/cppuhelper/bootstrap.hxx
new file mode 100644
index 000000000000..d76379a2f3e3
--- /dev/null
+++ b/include/cppuhelper/bootstrap.hxx
@@ -0,0 +1,167 @@
+/* -*- 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 _CPPUHELPER_BOOTSTRAP_HXX_
+#define _CPPUHELPER_BOOTSTRAP_HXX_
+
+#include "sal/config.h"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "cppuhelperdllapi.h"
+
+namespace com { namespace sun { namespace star {
+ namespace container { class XHierarchicalNameAccess; }
+ namespace uno { class XComponentContext; }
+} } }
+
+namespace cppu
+{
+
+/** Installs type description manager instance, i.e. registers a callback at cppu core.
+
+ @param xTDMgr manager instance
+ @return true, if successfully registered
+*/
+CPPUHELPER_DLLPUBLIC sal_Bool SAL_CALL installTypeDescriptionManager(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess > const & xTDMgr )
+ SAL_THROW(());
+
+/** Bootstraps an initial component context with service manager upon
+ information from bootstrap variables.
+
+ This function tries to find its parameters via these bootstrap variables:
+
+ - UNO_TYPES -- a space separated list of file urls of type rdbs
+ - UNO_SERVICES -- a space separated list of file urls of service rdbs
+
+ Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
+ for further info.
+
+ @return component context
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
+defaultBootstrap_InitialComponentContext() SAL_THROW( (::com::sun::star::uno::Exception) );
+
+
+/** Bootstraps an initial component context with service manager upon
+ information from an ini file.
+
+ This function tries to find its parameters via these bootstrap variables:
+
+ - UNO_TYPES -- a space separated list of file urls of type rdbs
+ - UNO_SERVICES -- a space separated list of file urls of service rdbs
+
+ Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
+ for further info.
+
+ @param iniFile ini filename to get bootstrap variables
+ @return component context
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
+defaultBootstrap_InitialComponentContext(const ::rtl::OUString & iniFile) SAL_THROW( (::com::sun::star::uno::Exception) );
+
+/**
+ * An exception indicating a bootstrap error.
+ *
+ * @since UDK 3.2.0
+ */
+class CPPUHELPER_DLLPUBLIC BootstrapException
+{
+public:
+ /**
+ * Constructs a BootstrapException.
+ */
+ BootstrapException();
+
+ /**
+ * Constructs a BootstrapException with the specified detail message.
+ *
+ * @param rMessage
+ * A message containing any details about the exception.
+ */
+ BootstrapException( const ::rtl::OUString & rMessage );
+
+ /**
+ * Copy constructs a BootstrapException.
+ */
+ BootstrapException( const BootstrapException & e );
+
+ /**
+ * Destructs a BootstrapException.
+ */
+ virtual ~BootstrapException();
+
+ /**
+ * Assigns a BootstrapException.
+ */
+ BootstrapException & operator=( const BootstrapException & e );
+
+ /** Gets the message.
+
+ @return
+ A reference to the message. The reference is valid for the lifetime of
+ this BootstrapException.
+ */
+ const ::rtl::OUString & getMessage() const;
+
+private:
+ ::rtl::OUString m_aMessage;
+};
+
+/**
+ * Bootstraps the component context from a UNO installation.
+ *
+ * @return a bootstrapped component context
+ * @exception BootstrapException
+ * Thrown in case bootstrap() signals an exception due to a
+ * bootstrap error.
+ *
+ * @since UDK 3.2.0
+ */
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+SAL_CALL bootstrap();
+
+/// @cond INTERNAL
+/**
+ * Helper function to expand vnd.sun.star.expand URLs in contexts where no
+ * properly bootstrapped UNO is (yet) available.
+ *
+ * @param uri
+ * Some URI (but not a URI reference).
+ *
+ * @return
+ * If uri is a vnd.sun.star.expand URL, then the expansion of that URL is
+ * returned; expansion may lead to a string that is not a legal URI. Otherwise,
+ * the uri is returned unchanged.
+ *
+ * @exception com::sun::star::lang::IllegalArgumentException
+ * If uri is a vnd.sun.star.expand URL that contains unknown macros.
+ *
+ * @since UDK 3.2.8
+ */
+CPPUHELPER_DLLPUBLIC ::rtl::OUString
+SAL_CALL bootstrap_expandUri(::rtl::OUString const & uri);
+/// @endcond
+
+} // end namespace cppu
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase.hxx b/include/cppuhelper/compbase.hxx
new file mode 100644
index 000000000000..dc0b8dd4f905
--- /dev/null
+++ b/include/cppuhelper/compbase.hxx
@@ -0,0 +1,107 @@
+/* -*- 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 _CPPUHELPER_COMPBASE_HXX_
+#define _CPPUHELPER_COMPBASE_HXX_
+
+#include <cppuhelper/compbase_ex.hxx>
+#include <cppuhelper/implbase.hxx>
+
+/* This header should not be used anymore.
+ @deprecated
+*/
+
+/// @cond INTERNAL
+
+#define __DEF_COMPIMPLHELPER_A( N ) \
+namespace cppu \
+{ \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper##N \
+ : public ::cppu::WeakComponentImplHelperBase \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ WeakComponentImplHelper##N( ::osl::Mutex & rMutex ) SAL_THROW(()) \
+ : WeakComponentImplHelperBase( rMutex ) \
+ {} \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ if (aRet.hasValue()) \
+ return aRet; \
+ return WeakComponentImplHelperBase::queryInterface( rType ); \
+ } \
+ virtual void SAL_CALL acquire() throw () \
+ { WeakComponentImplHelperBase::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { WeakComponentImplHelperBase::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+}; \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper##N \
+ : public ::cppu::WeakAggComponentImplHelperBase \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ WeakAggComponentImplHelper##N( ::osl::Mutex & rMutex ) SAL_THROW(()) \
+ : WeakAggComponentImplHelperBase( rMutex ) \
+ {} \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); } \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ if (aRet.hasValue()) \
+ return aRet; \
+ return WeakAggComponentImplHelperBase::queryAggregation( rType ); \
+ } \
+ virtual void SAL_CALL acquire() throw () \
+ { WeakAggComponentImplHelperBase::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { WeakAggComponentImplHelperBase::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+};
+
+#define __DEF_COMPIMPLHELPER_B( N ) \
+template< __CLASS_IFC##N > \
+ClassData##N WeakComponentImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 4 ); \
+template< __CLASS_IFC##N > \
+ClassData##N WeakAggComponentImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 3 );
+
+#define __DEF_COMPIMPLHELPER_C( N ) \
+}
+
+#define __DEF_COMPIMPLHELPER( N ) \
+__DEF_COMPIMPLHELPER_A( N ) \
+__DEF_COMPIMPLHELPER_B( N ) \
+__DEF_COMPIMPLHELPER_C( N )
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase1.hxx b/include/cppuhelper/compbase1.hxx
new file mode 100644
index 000000000000..8948f0120f36
--- /dev/null
+++ b/include/cppuhelper/compbase1.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE1_HXX_
+#define _CPPUHELPER_COMPBASE1_HXX_
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper1
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakComponentImplHelper1< Ifc1 > > > {};
+ public:
+ inline WeakComponentImplHelper1( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper1, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper1
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, PartialWeakComponentImplHelper1< Ifc1 > > > {};
+ public:
+ inline PartialWeakComponentImplHelper1( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper1
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakAggComponentImplHelper1< Ifc1 > > > {};
+ public:
+ inline WeakAggComponentImplHelper1( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase10.hxx b/include/cppuhelper/compbase10.hxx
new file mode 100644
index 000000000000..588a47a6fa8a
--- /dev/null
+++ b/include/cppuhelper/compbase10.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE10_HXX_
+#define _CPPUHELPER_COMPBASE10_HXX_
+
+#include <cppuhelper/implbase10.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper10
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakComponentImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ public:
+ inline WeakComponentImplHelper10( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper10, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper10
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, PartialWeakComponentImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ public:
+ inline PartialWeakComponentImplHelper10( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper10
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakAggComponentImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ public:
+ inline WeakAggComponentImplHelper10( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase11.hxx b/include/cppuhelper/compbase11.hxx
new file mode 100644
index 000000000000..259a12258f8d
--- /dev/null
+++ b/include/cppuhelper/compbase11.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE11_HXX_
+#define _CPPUHELPER_COMPBASE11_HXX_
+
+#include <cppuhelper/implbase11.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper11
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakComponentImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ public:
+ inline WeakComponentImplHelper11( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper11, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper11
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, PartialWeakComponentImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ public:
+ inline PartialWeakComponentImplHelper11( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper11
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakAggComponentImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ public:
+ inline WeakAggComponentImplHelper11( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase12.hxx b/include/cppuhelper/compbase12.hxx
new file mode 100644
index 000000000000..3009dac8f46e
--- /dev/null
+++ b/include/cppuhelper/compbase12.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE12_HXX_
+#define _CPPUHELPER_COMPBASE12_HXX_
+
+#include <cppuhelper/implbase12.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper12
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakComponentImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ public:
+ inline WeakComponentImplHelper12( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper12, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper12
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, PartialWeakComponentImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ public:
+ inline PartialWeakComponentImplHelper12( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper12
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakAggComponentImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ public:
+ inline WeakAggComponentImplHelper12( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase2.hxx b/include/cppuhelper/compbase2.hxx
new file mode 100644
index 000000000000..e54a38b00e3b
--- /dev/null
+++ b/include/cppuhelper/compbase2.hxx
@@ -0,0 +1,159 @@
+/* -*- 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 _CPPUHELPER_COMPBASE2_HXX_
+#define _CPPUHELPER_COMPBASE2_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper2
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakComponentImplHelper2<Ifc1, Ifc2> > > {};
+ public:
+ inline WeakComponentImplHelper2( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper2, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper2
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, PartialWeakComponentImplHelper2<Ifc1, Ifc2> > > {};
+ public:
+ inline PartialWeakComponentImplHelper2( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper2
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggComponentImplHelper2<Ifc1, Ifc2> > > {};
+ public:
+ inline WeakAggComponentImplHelper2( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase3.hxx b/include/cppuhelper/compbase3.hxx
new file mode 100644
index 000000000000..e43991a7c117
--- /dev/null
+++ b/include/cppuhelper/compbase3.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE3_HXX_
+#define _CPPUHELPER_COMPBASE3_HXX_
+
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper3
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakComponentImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
+ public:
+ inline WeakComponentImplHelper3( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper3, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper3
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, PartialWeakComponentImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
+ public:
+ inline PartialWeakComponentImplHelper3( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper3
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakAggComponentImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
+ public:
+ inline WeakAggComponentImplHelper3( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase4.hxx b/include/cppuhelper/compbase4.hxx
new file mode 100644
index 000000000000..a20542e57abe
--- /dev/null
+++ b/include/cppuhelper/compbase4.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE4_HXX_
+#define _CPPUHELPER_COMPBASE4_HXX_
+
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper4
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakComponentImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ public:
+ inline WeakComponentImplHelper4( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper4, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper4
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, PartialWeakComponentImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ public:
+ inline PartialWeakComponentImplHelper4( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper4
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakAggComponentImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ public:
+ inline WeakAggComponentImplHelper4( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase5.hxx b/include/cppuhelper/compbase5.hxx
new file mode 100644
index 000000000000..b22b1038b573
--- /dev/null
+++ b/include/cppuhelper/compbase5.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE5_HXX_
+#define _CPPUHELPER_COMPBASE5_HXX_
+
+#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper5
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakComponentImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ public:
+ inline WeakComponentImplHelper5( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper5, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper5
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, PartialWeakComponentImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ public:
+ inline PartialWeakComponentImplHelper5( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper5
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakAggComponentImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ public:
+ inline WeakAggComponentImplHelper5( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase6.hxx b/include/cppuhelper/compbase6.hxx
new file mode 100644
index 000000000000..778bbb722295
--- /dev/null
+++ b/include/cppuhelper/compbase6.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE6_HXX_
+#define _CPPUHELPER_COMPBASE6_HXX_
+
+#include <cppuhelper/implbase6.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper6
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakComponentImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ public:
+ inline WeakComponentImplHelper6( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper6, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper6
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, PartialWeakComponentImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ public:
+ inline PartialWeakComponentImplHelper6( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper6
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakAggComponentImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ public:
+ inline WeakAggComponentImplHelper6( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase7.hxx b/include/cppuhelper/compbase7.hxx
new file mode 100644
index 000000000000..edf3af3fd258
--- /dev/null
+++ b/include/cppuhelper/compbase7.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE7_HXX_
+#define _CPPUHELPER_COMPBASE7_HXX_
+
+#include <cppuhelper/implbase7.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper7
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakComponentImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ public:
+ inline WeakComponentImplHelper7( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper7, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper7
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, PartialWeakComponentImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ public:
+ inline PartialWeakComponentImplHelper7( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper7
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakAggComponentImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ public:
+ inline WeakAggComponentImplHelper7( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase8.hxx b/include/cppuhelper/compbase8.hxx
new file mode 100644
index 000000000000..efff5c4a2d09
--- /dev/null
+++ b/include/cppuhelper/compbase8.hxx
@@ -0,0 +1,158 @@
+/* -*- 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 _CPPUHELPER_COMPBASE8_HXX_
+#define _CPPUHELPER_COMPBASE8_HXX_
+
+#include <cppuhelper/implbase8.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper8
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakComponentImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ public:
+ inline WeakComponentImplHelper8( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper8, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper8
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, PartialWeakComponentImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ public:
+ inline PartialWeakComponentImplHelper8( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper8
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakAggComponentImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ public:
+ inline WeakAggComponentImplHelper8( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase9.hxx b/include/cppuhelper/compbase9.hxx
new file mode 100644
index 000000000000..5496e63864bd
--- /dev/null
+++ b/include/cppuhelper/compbase9.hxx
@@ -0,0 +1,157 @@
+/* -*- 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 _CPPUHELPER_COMPBASE9_HXX_
+#define _CPPUHELPER_COMPBASE9_HXX_
+
+#include <cppuhelper/implbase9.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+
+namespace cppu
+{
+
+// Suppress warnings about hidden functions in case any of the IfcN has
+// functions named dispose, addEventListener, or removeEventListener:
+#if defined __SUNPRO_CC
+#pragma disable_warn
+#endif
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper9
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakComponentImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ public:
+ inline WeakComponentImplHelper9( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::dispose(); }
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::addEventListener(xListener); }
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
+ { WeakComponentImplHelperBase::removeEventListener(xListener); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#endif
+
+ /** Same as WeakComponentImplHelper9, except doesn't implement
+ addEventListener, removeEventListener and dispose.
+
+ This requires derived classes to implement those three methods.
+ This makes it possible to implement classes which are required to
+ implement methods from multiple bases which have different
+ addEventListener/removeEventListener signatures without triggering
+ the g++ overloaded-virtual warning
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper9
+ : public WeakComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, PartialWeakComponentImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ public:
+ inline PartialWeakComponentImplHelper9( ::osl::Mutex & rMutex ) throw ()
+ : WeakComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+
+ /** Implementation helper supporting com::sun::star::lang::XTypeProvider and
+ com::sun::star::lang::XComponent.
+ Upon disposing objects of this class, sub-classes receive a disposing()
+ call. Objects of this class can be held weakly, i.e. by a
+ com::sun::star::uno::WeakReference. Object of this class can be
+ aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ @deprecated
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper9
+ : public WeakAggComponentImplHelperBase
+ , public ::com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakAggComponentImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ public:
+ inline WeakAggComponentImplHelper9( ::osl::Mutex & rMutex ) throw ()
+ : WeakAggComponentImplHelperBase( rMutex )
+ {}
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelperBase::queryInterface( rType ); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { WeakAggComponentImplHelperBase::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { WeakAggComponentImplHelperBase::release(); }
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
+ { return WeakAggComponentImplHelper_getTypes( cd::get() ); }
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/compbase_ex.hxx b/include/cppuhelper/compbase_ex.hxx
new file mode 100644
index 000000000000..5937f60e29cc
--- /dev/null
+++ b/include/cppuhelper/compbase_ex.hxx
@@ -0,0 +1,168 @@
+/* -*- 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 _CPPUHELPER_COMPBASE_EX_HXX_
+#define _CPPUHELPER_COMPBASE_EX_HXX_
+
+#include <osl/mutex.hxx>
+#include <cppuhelper/implbase_ex.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include "cppuhelperdllapi.h"
+
+/// @cond INTERNAL
+
+namespace cppu
+{
+
+/** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and
+ ::com::sun::star::lang::XComponent.
+*/
+class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakComponentImplHelperBase
+ : public ::cppu::OWeakObject
+ , public ::com::sun::star::lang::XComponent
+{
+protected:
+ /** broadcast helper for disposing events
+ */
+ ::cppu::OBroadcastHelper rBHelper;
+
+ /** this function is called upon disposing the component
+ */
+ virtual void SAL_CALL disposing();
+
+ /** This is the one and only constructor that is called from derived implementations.
+
+ @param rMutex mutex to sync upon disposing
+ */
+ WeakComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW(());
+public:
+ /** Destructor
+ */
+ virtual ~WeakComponentImplHelperBase() SAL_THROW(());
+
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+/** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and
+ ::com::sun::star::lang::XComponent.
+*/
+class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakAggComponentImplHelperBase
+ : public ::cppu::OWeakAggObject
+ , public ::com::sun::star::lang::XComponent
+{
+protected:
+ ::cppu::OBroadcastHelper rBHelper;
+
+ /** Is called upon disposing the component.
+ */
+ virtual void SAL_CALL disposing();
+
+ WeakAggComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW(());
+public:
+ virtual ~WeakAggComponentImplHelperBase() SAL_THROW(());
+
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+/** WeakComponentImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL WeakComponentImplHelper_query(
+ ::com::sun::star::uno::Type const & rType,
+ class_data * cd,
+ void * that,
+ ::cppu::WeakComponentImplHelperBase * pBase )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** WeakComponentImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes(
+ class_data * cd )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+/** WeakAggComponentImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL WeakAggComponentImplHelper_queryAgg(
+ ::com::sun::star::uno::Type const & rType,
+ class_data * cd,
+ void * that,
+ ::cppu::WeakAggComponentImplHelperBase * pBase )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** WeakAggComponentImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes(
+ class_data * cd )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+}
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/component.hxx b/include/cppuhelper/component.hxx
new file mode 100644
index 000000000000..64460959fbbf
--- /dev/null
+++ b/include/cppuhelper/component.hxx
@@ -0,0 +1,113 @@
+/* -*- 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 _CPPUHELPER_COMPONENT_HXX_
+#define _CPPUHELPER_COMPONENT_HXX_
+
+#include <osl/mutex.hxx>
+#include <cppuhelper/weakagg.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+
+#include "cppuhelperdllapi.h"
+
+namespace cppu
+{
+
+/** Deprecated. Helper for implementing com::sun::star::lang::XComponent.
+ Upon disposing objects of this class, sub-classes receive a disposing() call. Objects of
+ this class can be held weakly, i.e. by a com::sun::star::uno::WeakReference. Object of
+ this class can be aggregated, i.e. incoming queryInterface() calls are delegated.
+
+ @attention
+ The life-cycle of the passed mutex reference has to be longer than objects of this class.
+ @deprecated
+*/
+class CPPUHELPER_DLLPUBLIC OComponentHelper
+ : public ::cppu::OWeakAggObject
+ , public ::com::sun::star::lang::XTypeProvider
+ , public ::com::sun::star::lang::XComponent
+{
+public:
+ /** Constructor.
+
+ @param rMutex
+ the mutex used to protect multi-threaded access;
+ lifetime must be longer than the lifetime of this object.
+ */
+ OComponentHelper( ::osl::Mutex & rMutex ) SAL_THROW(());
+ /** Destructor. If this object was not disposed previously, object will be disposed manually.
+ */
+ virtual ~OComponentHelper() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+ // XAggregation
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
+
+ /** @attention
+ XTypeProvider::getImplementationId() has to be implemented separately!
+ */
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw(::com::sun::star::uno::RuntimeException) = 0;
+ /** @attention
+ XTypeProvider::getTypes() has to be re-implemented!
+ */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ /** Called in dispose method after the listeners were notified.
+ */
+ virtual void SAL_CALL disposing();
+
+ /// @cond INTERNAL
+ OBroadcastHelper rBHelper;
+ /// @endcond
+
+private:
+ inline OComponentHelper( const OComponentHelper & ) SAL_THROW(());
+ inline OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW(());
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/component_context.hxx b/include/cppuhelper/component_context.hxx
new file mode 100644
index 000000000000..575fa490a452
--- /dev/null
+++ b/include/cppuhelper/component_context.hxx
@@ -0,0 +1,91 @@
+/* -*- 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 _CPPUHELPER_COMPONENT_CONTEXT_HXX_
+#define _CPPUHELPER_COMPONENT_CONTEXT_HXX_
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+/** Context entries init struct calling createComponentContext().
+*/
+struct ContextEntry_Init
+{
+ /** late init denotes a object that will be raised when first get() is calling for it
+
+ The context implementation expects either a com::sun::star::lang::XSingleComponentFactory
+ object as value (to instanciate the object) or a string as value for raising
+ a service via the used service manager.
+ */
+ bool bLateInitService;
+ /** name of context value
+ */
+ ::rtl::OUString name;
+ /** context value
+ */
+ ::com::sun::star::uno::Any value;
+
+ /** Default ctor.
+ */
+ inline ContextEntry_Init() SAL_THROW(())
+ : bLateInitService( false )
+ {}
+ /** Ctor.
+
+ @param name_
+ name of entry
+ @param value_
+ value of entry
+ @param bLateInitService_
+ whether this entry is a late-init named object entry
+ (value is object factory or service string)
+ */
+ inline ContextEntry_Init(
+ ::rtl::OUString const & name_,
+ ::com::sun::star::uno::Any const & value_,
+ bool bLateInitService_ = false ) SAL_THROW(())
+ : bLateInitService( bLateInitService_ ),
+ name( name_ ),
+ value( value_ )
+ {}
+};
+
+/** Creates a component context with the given entries.
+
+ @param pEntries array of entries
+ @param nEntries number of entries
+ @param xDelegate delegation to further context, if value was not found
+ @return new context object
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+SAL_CALL createComponentContext(
+ ContextEntry_Init const * pEntries, sal_Int32 nEntries,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xDelegate =
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
+ SAL_THROW(());
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/cppuhelperdllapi.h b/include/cppuhelper/cppuhelperdllapi.h
new file mode 100644
index 000000000000..8489402c4e86
--- /dev/null
+++ b/include/cppuhelper/cppuhelperdllapi.h
@@ -0,0 +1,34 @@
+/* -*- 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 INCLUDED_CPPUHELPERDLLAPI_H
+#define INCLUDED_CPPUHELPERDLLAPI_H
+
+#include "sal/types.h"
+
+#if defined(CPPUHELPER_DLLIMPLEMENTATION)
+#define CPPUHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define CPPUHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define CPPUHELPER_DLLPRIVATE SAL_DLLPRIVATE
+
+#endif /* INCLUDED_CPPUHELPERDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/exc_hlp.hxx b/include/cppuhelper/exc_hlp.hxx
new file mode 100644
index 000000000000..9c110ee6c018
--- /dev/null
+++ b/include/cppuhelper/exc_hlp.hxx
@@ -0,0 +1,94 @@
+/* -*- 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 _CPPUHELPER_EXC_HLP_HXX_
+#define _CPPUHELPER_EXC_HLP_HXX_
+
+#include <com/sun/star/uno/Any.hxx>
+#include "cppuhelperdllapi.h"
+
+namespace cppu
+{
+
+/** This function throws the exception given by rExc. The given value has to
+ be of typeclass EXCEPTION and must be dervived from or of
+ type com.sun.star.uno.Exception.
+
+ @param rExc
+ exception to be thrown.
+*/
+CPPUHELPER_DLLPUBLIC void SAL_CALL throwException( const ::com::sun::star::uno::Any & rExc )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+/** Use this function to get the dynamic type of a caught C++-UNO exception;
+ completes the above function throwing exceptions generically.
+
+ @code
+ try
+ {
+ ...
+ }
+ catch (::com::sun::star::uno::RuntimeException &)
+ {
+ // you ought not handle RuntimeExceptions:
+ throw;
+ }
+ catch (::com::sun::star::uno::Exception &)
+ {
+ ::com::sun::star::uno::Any caught( ::cppu::getCaughtException() );
+ ...
+ }
+ @endcode
+
+ Restrictions:
+ - use only for caught C++-UNO exceptions (UNOIDL defined)
+ - only as first statement in a catch block!
+ - don't do a C++ rethrow (throw;) after you have called this function
+ - call getCaughtException() just once in your catch block!
+ (function internally uses a C++ rethrow)
+
+ @return
+ caught UNO exception
+
+ @attention Caution!
+ This function is limited to the same C++ compiler runtime library.
+ E.g. for MSVC, this means that the catch handler code (the one
+ that calls getCaughtException()) needs to use the very same
+ C++ runtime library, e.g. msvcrt.dll as cppuhelper, e.g.
+ cppuhelper3MSC.dll and the bridge library, e.g. msci_uno.dll.
+ This is the case if all of them are compiled with the same
+ compiler version.
+ Background: The msci_uno.dll gets a rethrown exception out
+ of the internal msvcrt.dll thread local storage (tls).
+ Thus you _must_ not use this function if your code needs to run
+ in newer UDK versions without being recompiled, because those
+ newer UDK (-> OOo versions) potentially use newer C++ runtime
+ libraries which most often become incompatible!
+
+ But this function ought to be usable for most OOo internal C++-UNO
+ development, because the whole OOo code base is compiled using the
+ same C++ compiler (and linking against one runtime library).
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL getCaughtException();
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/factory.hxx b/include/cppuhelper/factory.hxx
new file mode 100644
index 000000000000..8dfda840d51c
--- /dev/null
+++ b/include/cppuhelper/factory.hxx
@@ -0,0 +1,279 @@
+/* -*- 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 _CPPUHELPER_FACTORY_HXX_
+#define _CPPUHELPER_FACTORY_HXX_
+
+#include <rtl/ustring.hxx>
+#include <uno/dispatcher.h>
+#include <rtl/unload.h>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include "cppuhelperdllapi.h"
+
+//##################################################################################################
+
+#define COMPONENT_GETENV "component_getImplementationEnvironment"
+#define COMPONENT_GETENVEXT "component_getImplementationEnvironmentExt"
+#define COMPONENT_GETDESCRIPTION "component_getDescription"
+#define COMPONENT_WRITEINFO "component_writeInfo"
+#define COMPONENT_GETFACTORY "component_getFactory"
+
+typedef struct _uno_Environment uno_Environment;
+
+/** Function pointer declaration.
+ Function determines the environment of the component implementation, i.e. which compiler
+ compiled it. If the environment is NOT session specific (needs no additional context),
+ then this function should return the environment type name and leave ppEnv (to 0).
+
+ @param ppEnvTypeName environment type name; string must be constant
+ @param ppEnv function returns its environment if the environment is session specific,
+ i.e. has special context
+*/
+typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );
+
+/** Function pointer declaration.
+ Function determines the environment of the component implementation, i.e. the compiler.
+ If the environment is NOT session specific (needs no additional context),
+ then this function should return the environment type name and leave ppEnv (to 0).
+
+ @param ppEnvTypeName environment type name; string must be a constant
+ @param ppEnv function returns an environment if the environment is session specific,
+ i.e. has special context
+ @param pImplName
+*/
+typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)(
+ sal_Char const ** ppEnvTypeName,
+ uno_Environment ** ppEnv,
+ sal_Char const * pImplName,
+ uno_Environment * pTargetEnv
+);
+
+/** Function pointer declaration.
+ Function retrieves a component description.
+
+ @return an XML formatted string containing a short component description
+ @deprecated
+*/
+typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);
+
+/** Function pointer declaration.
+
+ @deprecated component_writeInfo should no longer be used in new components
+
+ Function writes component registry info, at least writing the supported service names.
+
+ @param pServiceManager
+ a service manager (the type is an XMultiServiceFactory that can be used
+ by the environment returned by component_getImplementationEnvironment)
+ @param pRegistryKey a registry key
+ (the type is XRegistryKey that can be used by the environment
+ returned by component_getImplementationEnvironment)
+ @return true if everything went fine
+*/
+typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
+ void * pServiceManager, void * pRegistryKey );
+
+/** Function pointer declaration.
+ Retrieves a factory to create component instances.
+
+ @param pImplName
+ desired implementation name
+ @param pServiceManager
+ a service manager (the type is XMultiServiceFactory that can be used by the environment
+ returned by component_getImplementationEnvironment)
+ @param pRegistryKey
+ a registry key (the type is XRegistryKey that can be used by the environment
+ returned by component_getImplementationEnvironment)
+ @return acquired component factory
+ (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the
+ environment returned by component_getImplementationEnvironment)
+*/
+typedef void * (SAL_CALL * component_getFactoryFunc)(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+
+//##################################################################################################
+
+namespace cppu
+{
+
+/** Function pointer declaration.
+ Function creates component instance passing the component context to be used.
+
+ @param xContext component context to be used
+ @return component instance
+*/
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
+ SAL_CALL * ComponentFactoryFunc)(
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+/** Creates a single component factory supporting the XSingleComponentFactory interface.
+
+ @param fptr function pointer for instanciating the object
+ @param rImplementationName implementation name of service
+ @param rServiceNames supported services
+ @param pModCount a backwards-compatibility remainder of a removed library
+ unloading feature; always set to null
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >
+SAL_CALL createSingleComponentFactory(
+ ComponentFactoryFunc fptr,
+ ::rtl::OUString const & rImplementationName,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
+ rtl_ModuleCount * pModCount = 0 )
+ SAL_THROW(());
+
+/** Creates a single service factory which holds the instance created only once.
+
+ @param fptr function pointer for instanciating the object
+ @param rImplementationName implementation name of service
+ @param rServiceNames supported services
+ @param pModCount a backwards-compatibility remainder of a removed library
+ unloading feature; always set to null
+
+ @see createSingleComponentFactory
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > SAL_CALL
+createOneInstanceComponentFactory(
+ ComponentFactoryFunc fptr,
+ ::rtl::OUString const & rImplementationName,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
+ rtl_ModuleCount * pModCount = 0 )
+ SAL_THROW(());
+
+/** Deprecated. The type of the instanciate function used as argument of the create*Fcatory functions.
+
+ @see createSingleFactory
+ @see createOneInstanceFactory
+ @deprecated
+*/
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager );
+
+/** Deprecated. Creates a single service factory.
+
+ @param rServiceManager the service manager used by the implementation.
+ @param rImplementationName the implementation name. An empty string is possible.
+ @param pCreateFunction the function pointer to create an object.
+ @param rServiceNames the service supported by the implementation.
+ @param pModCount a backwards-compatibility remainder of a removed library
+ unloading feature; always set to null.
+ @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ XSingleServiceFactory and XComponent.
+
+ @see createOneInstanceFactory
+ @deprecated
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+createSingleFactory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rImplementationName,
+ ComponentInstantiation pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
+ rtl_ModuleCount * pModCount = 0 )
+ SAL_THROW(());
+
+/** Deprecated. Creates a factory wrapping another one.
+ This means the methods of the interfaces XServiceProvider, XServiceInfo and
+ XSingleServiceFactory are forwarded.
+ @attention
+ The XComponent interface is not supported!
+
+ @param rServiceManager the service manager used by the implementation.
+ @param rFactory the wrapped service factory.
+ @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ XSingleServiceFactory.
+
+ @see createSingleFactory
+ @deprecated
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+createFactoryProxy(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory )
+ SAL_THROW(());
+
+/** Deprecated. Creates a single service factory which holds the instance created only once.
+
+ @param rServiceManager the service manager used by the implementation.
+ @param rComponentName the implementation name. An empty string is possible.
+ @param pCreateFunction the function pointer to create an object.
+ @param rServiceNames the service supported by the implementation.
+ @param pModCount a backwards-compatibility remainder of a removed library
+ unloading feature; always set to null.
+ @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ XSingleServiceFactory and XComponent.
+
+ @see createSingleFactory
+ @deprecated
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+createOneInstanceFactory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rComponentName,
+ ComponentInstantiation pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
+ rtl_ModuleCount * pModCount = 0 )
+ SAL_THROW(());
+
+/** Deprecated. Creates a single service factory based on a registry.
+
+ @param rServiceManager the service manager used by the implementation.
+ @param rImplementationName the implementation name. An empty string is possible.
+ @param rImplementationKey the registry key of the implementation section.
+ @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ XSingleServiceFactory and XComponent.
+ @deprecated
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+createSingleRegistryFactory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rImplementationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
+ SAL_THROW(());
+
+/** Deprecated. Creates a single service factory which holds the instance created only once
+ based on a registry.
+
+ @param rServiceManager the service manager used by the implementation.
+ @param rComponentName the implementation name. An empty string is possible.
+ @param rImplementationKey the registry key of the implementation section.
+ @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ XSingleServiceFactory and XComponent.
+
+ @see createSingleRegistryFactory
+ @deprecated
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+createOneInstanceRegistryFactory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rComponentName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
+ SAL_THROW(());
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/findsofficepath.h b/include/cppuhelper/findsofficepath.h
new file mode 100644
index 000000000000..1d24009f6bb8
--- /dev/null
+++ b/include/cppuhelper/findsofficepath.h
@@ -0,0 +1,39 @@
+/* -*- 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 INCLUDED_CPPUHELPER_FINDSOFFICEPATH_H
+#define INCLUDED_CPPUHELPER_FINDSOFFICEPATH_H
+
+#include "sal/config.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/* Internal function to find an soffice installation.
+ Not to be called by client code */
+char const* cppuhelper_detail_findSofficePath(void);
+
+#if defined __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase.hxx b/include/cppuhelper/implbase.hxx
new file mode 100644
index 000000000000..06ac7a8c8d1a
--- /dev/null
+++ b/include/cppuhelper/implbase.hxx
@@ -0,0 +1,296 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE_HXX_
+#define _CPPUHELPER_IMPLBASE_HXX_
+
+#include <osl/mutex.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/weakagg.hxx>
+#include <rtl/instance.hxx>
+
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include "cppuhelperdllapi.h"
+
+/* This header should not be used anymore.
+ @deprecated
+*/
+
+/// @cond INTERNAL
+
+namespace cppu
+{
+
+/** Struct used for inline template implementation helpers: type entries.
+ Not for public use.
+*/
+struct Type_Offset
+{
+ /** binary offset of vtable pointer from object base
+ */
+ sal_Int32 nOffset;
+ /** interface type description of interface entry
+ */
+ typelib_InterfaceTypeDescription * pTD;
+};
+/** Struct used for inline template implementation helpers: class data of implementation.
+ Not for public use.
+*/
+struct CPPUHELPER_DLLPUBLIC ClassDataBase
+{
+ /** determines whether the class data has been statically initialized
+ */
+ sal_Bool bOffsetsInit;
+ /** length of static array ClassDataN
+ */
+ sal_Int32 nType2Offset;
+
+ /** class code determines which standard types are supported (and returned on
+ com.sun.star.lang.XTypeProvider::getTypes()) by the helper:
+
+ - 1 -- com.sun.star.uno.XWeak
+ - 2 -- com.sun.star.uno.XWeak, com.sun.star.uno.XAggregation
+ - 3 -- com.sun.star.uno.XWeak, com.sun.star.uno.XAggregation, com.sun.star.lang.XComponent
+ - 4 -- com.sun.star.uno.XWeak, com.sun.star.lang.XComponent
+ */
+ sal_Int32 nClassCode;
+
+ /** pointer to types sequence (com.sun.star.lang.XTypeProvider)
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > * pTypes;
+ /** pointer to class id (com.sun.star.lang.XTypeProvider)
+ */
+ ::com::sun::star::uno::Sequence< sal_Int8 > * pId;
+
+ /** def ctor
+ */
+ ClassDataBase() SAL_THROW(());
+ /** class code ctor
+
+ @param nClassCode class code, see ClassDataBase::nClassCode
+ */
+ ClassDataBase( sal_Int32 nClassCode ) SAL_THROW(());
+ /** dtor
+ */
+ ~ClassDataBase() SAL_THROW(());
+};
+/** Struct used for inline template implementation helpers:
+ There will be versions of this struct with varying arType2Offset[] array sizes, each of which
+ is binary compatible with this one to be casted and used uniform. The size of the varying array
+ is set in ClassDataBase::nType2Offset (base class).
+ Not for public use.
+*/
+struct CPPUHELPER_DLLPUBLIC ClassData : public ClassDataBase
+{
+ /** type entries array
+ */
+ Type_Offset arType2Offset[1];
+
+ /** init call for supporting com.sun.star.lang.XTypeProvider
+ */
+ void SAL_CALL initTypeProvider() SAL_THROW(());
+ /** initial writing type offsets for vtables
+
+ @param rType type of interface
+ @param nOffset offset to vtable entry
+ */
+ void SAL_CALL writeTypeOffset( const ::com::sun::star::uno::Type & rType, sal_Int32 nOffset )
+ SAL_THROW(());
+
+ /** Queries for an interface.
+
+ @param rType demanded interface type
+ @pBase base this pointer related when writing type offsets (writeTypeOffset())
+ @return demanded interface or empty any
+ */
+ ::com::sun::star::uno::Any SAL_CALL query(
+ const ::com::sun::star::uno::Type & rType, ::com::sun::star::lang::XTypeProvider * pBase )
+ SAL_THROW(());
+ /** Gets the types for supporting com.sun.star.lang.XTypeProvider
+
+ @return sequence of types supported
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ SAL_THROW(());
+ /** Gets the class id of implementation supporting com.sun.star.lang.XTypeProvider
+
+ @return class identifier (sequence< byte >)
+ */
+ ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ SAL_THROW(());
+};
+
+/** Shared mutex for implementation helper initialization.
+ Not for public use.
+*/
+CPPUHELPER_DLLPUBLIC ::osl::Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW(());
+}
+
+//
+// settle down beavis, here comes the macro template hell :]
+//
+
+//==================================================================================================
+
+#if defined _MSC_VER // public -> protected changes mangled names there
+#define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED public
+#else
+#define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED protected
+#endif
+
+/** Implementation helper macros
+ Not for common use. There are expanded forms of the macro usage in implbaseN.hxx/compbaseN.hxx.
+ So there is commonly no need to use these macros. Though, you may need to implement more than
+ 12 interfaces. Then you have to declare something like the following in your headers
+ (where N is your demanded number of interfaces):
+
+ #define __IFC3 Ifc1, Ifc2, Ifc3, ... up to N
+ #define __CLASS_IFC3 class Ifc1, class Ifc2, class Ifc3, ... up to N
+ #define __PUBLIC_IFC3 public Ifc1, public Ifc2, public Ifc3, ... up to N
+ __DEF_IMPLHELPER_PRE( N )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ), ... up to N
+ __DEF_IMPLHELPER_POST( N )
+*/
+#define __DEF_IMPLHELPER_PRE( N ) \
+namespace cppu \
+{ \
+struct ClassData##N : public ClassDataBase \
+{ \
+ Type_Offset arType2Offset[ N ]; \
+ ClassData##N( sal_Int32 nInClassCode ) SAL_THROW(()) \
+ : ClassDataBase( nInClassCode ) \
+ {} \
+}; \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelperBase##N \
+ : public ::com::sun::star::lang::XTypeProvider \
+ , __PUBLIC_IFC##N \
+{ \
+CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \
+ ~ImplHelperBase##N() throw () {} \
+protected: \
+ ClassData & SAL_CALL getClassData( ClassDataBase & s_aCD ) SAL_THROW(()) \
+ { \
+ ClassData & rCD = * static_cast< ClassData * >( &s_aCD ); \
+ if (! rCD.bOffsetsInit) \
+ { \
+ ::osl::MutexGuard aGuard( getImplHelperInitMutex() ); \
+ if (! rCD.bOffsetsInit) \
+ { \
+ char * pBase = (char *)this;
+/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE
+*/
+#define __IFC_WRITEOFFSET( N ) \
+ rCD.writeTypeOffset( ::getCppuType( (const ::com::sun::star::uno::Reference< Ifc##N > *)0 ), \
+ (char *)(Ifc##N *)this - pBase );
+/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE
+*/
+#define __DEF_IMPLHELPER_POST_A( N ) \
+ rCD.bOffsetsInit = sal_True; \
+ } \
+ } \
+ return rCD; \
+ } \
+}; \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper##N \
+ : public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).getImplementationId(); } \
+CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \
+ ~ImplHelper##N() throw () {} \
+}; \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper##N \
+ : public ::cppu::OWeakObject \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); \
+ } \
+ virtual void SAL_CALL acquire() throw () \
+ { OWeakObject::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { OWeakObject::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).getImplementationId(); } \
+}; \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper##N \
+ : public ::cppu::OWeakAggObject \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return OWeakAggObject::queryInterface( rType ); } \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); \
+ } \
+ virtual void SAL_CALL acquire() throw () \
+ { OWeakAggObject::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { OWeakAggObject::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return this->getClassData( s_aCD ).getImplementationId(); } \
+};
+
+/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE
+*/
+#define __DEF_IMPLHELPER_POST_B( N ) \
+template< __CLASS_IFC##N > \
+ClassData##N ImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 0 ); \
+template< __CLASS_IFC##N > \
+ClassData##N WeakImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 1 ); \
+template< __CLASS_IFC##N > \
+ClassData##N WeakAggImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 2 );
+/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE
+*/
+#define __DEF_IMPLHELPER_POST_C( N ) \
+}
+//==================================================================================================
+/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE
+*/
+#define __DEF_IMPLHELPER_POST( N ) \
+__DEF_IMPLHELPER_POST_A( N ) \
+__DEF_IMPLHELPER_POST_B( N ) \
+__DEF_IMPLHELPER_POST_C( N )
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase1.hxx b/include/cppuhelper/implbase1.hxx
new file mode 100644
index 000000000000..ead86fe6c56a
--- /dev/null
+++ b/include/cppuhelper/implbase1.hxx
@@ -0,0 +1,296 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE1_HXX_
+#define _CPPUHELPER_IMPLBASE1_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data1
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 1 + 1 ];
+ };
+
+ template< typename Ifc1, typename Impl > struct ImplClassData1
+ {
+ class_data* operator ()()
+ {
+ static class_data1 s_cd =
+ {
+ 1 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper1
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1 < Ifc1, ImplHelper1<Ifc1> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper1() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+
+ These classes are used when you implement your UNO component.
+ WeakImplHelper1 till WeakImplHelper12 can be used when you want
+ to implement 1 till 12 interfaces in your component.
+ */
+ template< class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper1
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakImplHelper1< Ifc1 > > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper1
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakAggImplHelper1< Ifc1 > > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper1
+ : public BaseClass
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, ImplInheritanceHelper1< BaseClass, Ifc1 > > > {};
+ protected:
+#if (defined __SUNPRO_CC && __SUNPRO_CC <= 0x550)
+ // Hack, to get comphelper::service_decl to work for non-trivial impl classes
+ ImplInheritanceHelper1( com::sun::star::uno::Sequence<com::sun::star::uno::Any> const& args,
+ com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const& xContext ) : BaseClass(args,xContext) {}
+#endif
+ template< typename T1 >
+ explicit ImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper1(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper1() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper1
+ : public BaseClass
+ , public Ifc1
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, AggImplInheritanceHelper1< BaseClass, Ifc1 > > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper1(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper1(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper1() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase10.hxx b/include/cppuhelper/implbase10.hxx
new file mode 100644
index 000000000000..57fdda5b3ce0
--- /dev/null
+++ b/include/cppuhelper/implbase10.hxx
@@ -0,0 +1,296 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE10_HXX_
+#define _CPPUHELPER_IMPLBASE10_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data10
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 10 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Impl >
+ struct ImplClassData10
+ {
+ class_data* operator ()()
+ {
+ static class_data10 s_cd =
+ {
+ 10 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 },
+ { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 },
+ { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper10
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, ImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper10() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper10
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper10
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakAggImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper10
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, ImplInheritanceHelper10<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper10(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper10(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper10() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper10
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, AggImplInheritanceHelper10<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper10(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper10(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper10(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper10() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase11.hxx b/include/cppuhelper/implbase11.hxx
new file mode 100644
index 000000000000..bd282e70fdc2
--- /dev/null
+++ b/include/cppuhelper/implbase11.hxx
@@ -0,0 +1,297 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE11_HXX_
+#define _CPPUHELPER_IMPLBASE11_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data11
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 11 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Ifc11, typename Impl >
+ struct ImplClassData11
+ {
+ class_data* operator ()()
+ {
+ static class_data11 s_cd =
+ {
+ 11 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 },
+ { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 },
+ { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 },
+ { { Ifc11::static_type }, ((sal_IntPtr)(Ifc11 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper11
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, ImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper11() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper11
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper11
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakAggImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper11
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, ImplInheritanceHelper11<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper11(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper11(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper11() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper11
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, AggImplInheritanceHelper11<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper11(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper11(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper11(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper11() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase12.hxx b/include/cppuhelper/implbase12.hxx
new file mode 100644
index 000000000000..a1d4bf17fa07
--- /dev/null
+++ b/include/cppuhelper/implbase12.hxx
@@ -0,0 +1,298 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE12_HXX_
+#define _CPPUHELPER_IMPLBASE12_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data12
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 12 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Ifc11, typename Ifc12, typename Impl >
+ struct ImplClassData12
+ {
+ class_data* operator ()()
+ {
+ static class_data12 s_cd =
+ {
+ 12 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 },
+ { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 },
+ { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 },
+ { { Ifc11::static_type }, ((sal_IntPtr)(Ifc11 *) (Impl *) 16) - 16 },
+ { { Ifc12::static_type }, ((sal_IntPtr)(Ifc12 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper12
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, ImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper12() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper12
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper12
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakAggImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper12
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, ImplInheritanceHelper12<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper12(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper12(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper12() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper12
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, AggImplInheritanceHelper12<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper12(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper12(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper12(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper12() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase13.hxx b/include/cppuhelper/implbase13.hxx
new file mode 100644
index 000000000000..b50fb038564c
--- /dev/null
+++ b/include/cppuhelper/implbase13.hxx
@@ -0,0 +1,299 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE13_HXX_
+#define _CPPUHELPER_IMPLBASE13_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data13
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 13 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Ifc11, typename Ifc12, typename Ifc13, typename Impl >
+ struct ImplClassData13
+ {
+ class_data* operator ()()
+ {
+ static class_data13 s_cd =
+ {
+ 13 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 },
+ { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 },
+ { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 },
+ { { Ifc11::static_type }, ((sal_IntPtr)(Ifc11 *) (Impl *) 16) - 16 },
+ { { Ifc12::static_type }, ((sal_IntPtr)(Ifc12 *) (Impl *) 16) - 16 },
+ { { Ifc13::static_type }, ((sal_IntPtr)(Ifc13 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper13
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, public Ifc13
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, ImplHelper13<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper13() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper13
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, public Ifc13
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, WeakImplHelper13<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper13
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, public Ifc13
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, WeakAggImplHelper13<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper13
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, public Ifc13
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, ImplInheritanceHelper13<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper13(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper13(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper13() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper13
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, public Ifc13
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, AggImplInheritanceHelper13<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper13(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper13(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper13(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper13() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase2.hxx b/include/cppuhelper/implbase2.hxx
new file mode 100644
index 000000000000..acd9bbe5e211
--- /dev/null
+++ b/include/cppuhelper/implbase2.hxx
@@ -0,0 +1,287 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE2_HXX_
+#define _CPPUHELPER_IMPLBASE2_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data2
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 2 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Impl > struct ImplClassData2
+ {
+ class_data* operator ()()
+ {
+ static class_data2 s_cd =
+ {
+ 2 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your base class defines method implementations, acquire(), release() and delegates incoming
+ queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper2
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplHelper2<Ifc1, Ifc2> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper2() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper2
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakImplHelper2<Ifc1, Ifc2> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper2
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggImplHelper2<Ifc1, Ifc2> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper2
+ : public BaseClass
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper2() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper2
+ : public BaseClass
+ , public Ifc1, public Ifc2
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, AggImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper2(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper2() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase3.hxx b/include/cppuhelper/implbase3.hxx
new file mode 100644
index 000000000000..f887ee470538
--- /dev/null
+++ b/include/cppuhelper/implbase3.hxx
@@ -0,0 +1,289 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE3_HXX_
+#define _CPPUHELPER_IMPLBASE3_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data3
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 3 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Impl > struct ImplClassData3
+ {
+ class_data* operator ()()
+ {
+ static class_data3 s_cd =
+ {
+ 3 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper3
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper3() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper3
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper3
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakAggImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+ also has to have a default ctor.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper3
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper3(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper3() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper3
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, AggImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper3(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper3(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper3() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase4.hxx b/include/cppuhelper/implbase4.hxx
new file mode 100644
index 000000000000..54fd60e0f54f
--- /dev/null
+++ b/include/cppuhelper/implbase4.hxx
@@ -0,0 +1,290 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE4_HXX_
+#define _CPPUHELPER_IMPLBASE4_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data4
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 4 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Impl >
+ struct ImplClassData4
+ {
+ class_data* operator ()()
+ {
+ static class_data4 s_cd =
+ {
+ 4 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper4
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper4() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper4
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper4
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakAggImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper4
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper4(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper4() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper4
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, AggImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper4(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper4(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper4() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase5.hxx b/include/cppuhelper/implbase5.hxx
new file mode 100644
index 000000000000..4a4b3e640426
--- /dev/null
+++ b/include/cppuhelper/implbase5.hxx
@@ -0,0 +1,291 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE5_HXX_
+#define _CPPUHELPER_IMPLBASE5_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data5
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 5 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Impl >
+ struct ImplClassData5
+ {
+ class_data* operator ()()
+ {
+ static class_data5 s_cd =
+ {
+ 5 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper5
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper5() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper5
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper5
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakAggImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper5
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplInheritanceHelper5<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper5(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper5(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper5() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper5
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, AggImplInheritanceHelper5<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper5(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper5(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper5(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper5() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase6.hxx b/include/cppuhelper/implbase6.hxx
new file mode 100644
index 000000000000..090da8d8a862
--- /dev/null
+++ b/include/cppuhelper/implbase6.hxx
@@ -0,0 +1,292 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE6_HXX_
+#define _CPPUHELPER_IMPLBASE6_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data6
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 6 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Impl >
+ struct ImplClassData6
+ {
+ class_data* operator ()()
+ {
+ static class_data6 s_cd =
+ {
+ 6 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper6
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, ImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper6() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper6
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper6
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakAggImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper6
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, ImplInheritanceHelper6<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper6(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper6(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper6() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper6
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, AggImplInheritanceHelper6<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper6(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper6(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper6(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper6() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase7.hxx b/include/cppuhelper/implbase7.hxx
new file mode 100644
index 000000000000..62998349b822
--- /dev/null
+++ b/include/cppuhelper/implbase7.hxx
@@ -0,0 +1,293 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE7_HXX_
+#define _CPPUHELPER_IMPLBASE7_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data7
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 7 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Impl >
+ struct ImplClassData7
+ {
+ class_data* operator ()()
+ {
+ static class_data7 s_cd =
+ {
+ 7 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper7
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, ImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper7() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper7
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper7
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakAggImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper7
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, ImplInheritanceHelper7<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper7(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper7(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper7() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper7
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, AggImplInheritanceHelper7<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper7(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper7(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper7(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper7() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase8.hxx b/include/cppuhelper/implbase8.hxx
new file mode 100644
index 000000000000..117dba731b9c
--- /dev/null
+++ b/include/cppuhelper/implbase8.hxx
@@ -0,0 +1,294 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE8_HXX_
+#define _CPPUHELPER_IMPLBASE8_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data8
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 8 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Impl >
+ struct ImplClassData8
+ {
+ class_data* operator ()()
+ {
+ static class_data8 s_cd =
+ {
+ 8 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper8
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, ImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper8() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper8
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper8
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakAggImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper8
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, ImplInheritanceHelper8<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper8(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper8(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper8() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper8
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, AggImplInheritanceHelper8<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper8(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper8(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper8(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper8() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase9.hxx b/include/cppuhelper/implbase9.hxx
new file mode 100644
index 000000000000..ca4cdba53f3d
--- /dev/null
+++ b/include/cppuhelper/implbase9.hxx
@@ -0,0 +1,295 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE9_HXX_
+#define _CPPUHELPER_IMPLBASE9_HXX_
+
+#include <cppuhelper/implbase_ex.hxx>
+#include <rtl/instance.hxx>
+
+namespace cppu
+{
+ /// @cond INTERNAL
+
+ struct class_data9
+ {
+ sal_Int16 m_nTypes;
+ sal_Bool m_storedTypeRefs;
+ sal_Bool m_storedId;
+ sal_Int8 m_id[ 16 ];
+ type_entry m_typeEntries[ 9 + 1 ];
+ };
+
+ template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Impl >
+ struct ImplClassData9
+ {
+ class_data* operator ()()
+ {
+ static class_data9 s_cd =
+ {
+ 9 +1, sal_False, sal_False,
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {
+ { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
+ { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
+ { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
+ { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
+ { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 },
+ { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 },
+ { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 },
+ { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 },
+ { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 },
+ { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
+ }
+ };
+ return reinterpret_cast< class_data * >(&s_cd);
+ }
+ };
+
+ /// @endcond
+
+ /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
+ and method XInterface::queryInterface(), but no reference counting.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s) including acquire()/
+ release() and delegates incoming queryInterface() calls to this base class.
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper9
+ : public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, ImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_query( rType, cd::get(), this ); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+ protected:
+#endif
+ ~ImplHelper9() throw () {}
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper9
+ : public OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
+ (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
+ In addition, it supports also aggregation meaning object of this class can be aggregated
+ (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
+ If a delegator is set (this object is aggregated), then incoming queryInterface()
+ calls are delegated to the delegator object. If the delegator does not support the
+ demanded interface, it calls queryAggregation() on its aggregated objects.
+
+ @derive
+ Inherit from this class giving your interface(s) to be implemented as template argument(s).
+ Your sub class defines method implementations for these interface(s).
+ */
+ template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper9
+ : public OWeakAggObject
+ , public com::sun::star::lang::XTypeProvider
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakAggImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ public:
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
+ virtual void SAL_CALL acquire() throw ()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { OWeakAggObject::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return WeakAggImplHelper_getTypes( cd::get() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
+ if a demanded interface is not supported by this class directly, the request is
+ delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
+ and com::sun::star::lang::XTypeProvider are implemented properly. The
+ BaseClass must have at least one ctor that can be called with six or
+ fewer arguments, of which none is of non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper9
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, ImplInheritanceHelper9<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ protected:
+ template< typename T1 >
+ explicit ImplInheritanceHelper9(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ ImplInheritanceHelper9(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ ImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ ImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ ImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ ImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ ImplInheritanceHelper9() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryInterface( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+ /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
+ com::sun::star::uno::XInterface inherting from a BaseClass.
+ All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
+ Upon queryAggregation(), if a demanded interface is not supported by this class directly,
+ the request is delegated to the BaseClass.
+
+ @attention
+ The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
+ com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
+ are implemented properly. The BaseClass must have at least one ctor
+ that can be called with six or fewer arguments, of which none is of
+ non-const reference type.
+
+ @derive
+ Inherit from this class giving your additional interface(s) to be implemented as
+ template argument(s). Your sub class defines method implementations for these interface(s).
+ */
+ template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 >
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper9
+ : public BaseClass
+ , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+ {
+ struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, AggImplInheritanceHelper9<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {};
+ protected:
+ template< typename T1 >
+ explicit AggImplInheritanceHelper9(T1 const & arg1): BaseClass(arg1) {}
+ template< typename T1, typename T2 >
+ AggImplInheritanceHelper9(T1 const & arg1, T2 const & arg2):
+ BaseClass(arg1, arg2) {}
+ template< typename T1, typename T2, typename T3 >
+ AggImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3):
+ BaseClass(arg1, arg2, arg3) {}
+ template< typename T1, typename T2, typename T3, typename T4 >
+ AggImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
+ BaseClass(arg1, arg2, arg3, arg4) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5 >
+ AggImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5):
+ BaseClass(arg1, arg2, arg3, arg4, arg5) {}
+ template<
+ typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6 >
+ AggImplInheritanceHelper9(
+ T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
+ T5 const & arg5, T6 const & arg6):
+ BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
+ public:
+ AggImplInheritanceHelper9() {}
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ { return BaseClass::queryInterface( rType ); }
+ virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
+ {
+ com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
+ if (aRet.hasValue())
+ return aRet;
+ return BaseClass::queryAggregation( rType );
+ }
+ virtual void SAL_CALL acquire() throw ()
+ { BaseClass::acquire(); }
+ virtual void SAL_CALL release() throw ()
+ { BaseClass::release(); }
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
+ { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
+ { return ImplHelper_getImplementationId( cd::get() ); }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase_ex.hxx b/include/cppuhelper/implbase_ex.hxx
new file mode 100644
index 000000000000..4eb111de898a
--- /dev/null
+++ b/include/cppuhelper/implbase_ex.hxx
@@ -0,0 +1,165 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE_EX_HXX_
+#define _CPPUHELPER_IMPLBASE_EX_HXX_
+
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/weakagg.hxx>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+
+// Despite the fact that the following include is not used in this header, it has to remain,
+// because it is expected by files including cppuhelper/implbaseN.hxx.
+// So maybe we can omit it some time in the future...
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+/* If you need to define implementation helper classes that deal with more than
+ 12 interfaces, then use macros as follows, e.g. for 3 interfaces:
+
+#include <cppuhelper/implbase_ex_pre.hxx>
+#define __IFC_EX_TYPE_INIT3( class_cast ) \
+ __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \
+ __IFC_EX_TYPE_INIT( class_cast, 3 )
+#include <cppuhelper/implbase_ex_post.hxx>
+__DEF_IMPLHELPER_EX( 3 )
+*/
+
+/// @cond INTERNAL
+
+namespace cppu
+{
+
+/** function pointer signature for getCppuType
+*/
+typedef ::com::sun::star::uno::Type const & (SAL_CALL * fptr_getCppuType)( void * ) SAL_THROW(());
+
+/** single type + object offset
+*/
+struct type_entry
+{
+ /** the type_entry is initialized with function pointer to ::getCppuType() function first,
+ but holds an unacquired typelib_TypeDescriptionReference * after initialization,
+ thus reusing the memory. Flag class_data::m_storedTypeRefs
+ */
+ union
+ {
+ fptr_getCppuType getCppuType;
+ typelib_TypeDescriptionReference * typeRef;
+ } m_type;
+ /** offset for interface pointer
+ */
+ sal_IntPtr m_offset;
+};
+
+/** identical dummy struct for casting class_dataN to class_data
+*/
+struct class_data
+{
+ /** number of supported types in m_typeEntries
+ */
+ sal_Int16 m_nTypes;
+
+ /** determines whether m_typeEntries is initialized and carries unacquired type refs
+ */
+ sal_Bool m_storedTypeRefs;
+
+ /** determines whether an implementation id was created in m_id
+ */
+ sal_Bool m_createdId;
+
+ /** implementation id
+ */
+ sal_Int8 m_id[ 16 ];
+
+ /** type, object offset
+ */
+ type_entry m_typeEntries[ 1 ];
+};
+
+/** ImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL ImplHelper_query(
+ ::com::sun::star::uno::Type const & rType,
+ class_data * cd,
+ void * that )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** ImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL ImplHelper_queryNoXInterface(
+ ::com::sun::star::uno::Type const & rType,
+ class_data * cd,
+ void * that )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** ImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
+SAL_CALL ImplHelper_getTypes(
+ class_data * cd )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** ImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
+SAL_CALL ImplInhHelper_getTypes(
+ class_data * cd,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > const & rAddTypes )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** ImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< sal_Int8 >
+SAL_CALL ImplHelper_getImplementationId(
+ class_data * cd )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+/** WeakImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL WeakImplHelper_query(
+ ::com::sun::star::uno::Type const & rType,
+ class_data * cd,
+ void * that,
+ ::cppu::OWeakObject * pBase )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** WeakImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
+SAL_CALL WeakImplHelper_getTypes(
+ class_data * cd )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+/** WeakAggImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any
+SAL_CALL WeakAggImplHelper_queryAgg(
+ ::com::sun::star::uno::Type const & rType,
+ class_data * cd,
+ void * that,
+ ::cppu::OWeakAggObject * pBase )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+/** WeakAggImplHelper
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
+SAL_CALL WeakAggImplHelper_getTypes(
+ class_data * cd )
+ SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+}
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase_ex_post.hxx b/include/cppuhelper/implbase_ex_post.hxx
new file mode 100644
index 000000000000..6d97b760613b
--- /dev/null
+++ b/include/cppuhelper/implbase_ex_post.hxx
@@ -0,0 +1,168 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE_EX_POST_HXX_
+#define _CPPUHELPER_IMPLBASE_EX_POST_HXX_
+
+/// @cond INTERNAL
+
+#define __DEF_CLASS_DATA_INIT_EX( N, class_cast ) \
+{ \
+N +1, sal_False, sal_False, \
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
+{ \
+__IFC_EX_TYPE_INIT##N( class_cast ), \
+__IFC_EX_TYPE_INIT_NAME( class_cast, ::com::sun::star::lang::XTypeProvider ) \
+} \
+}
+
+#define __DEF_IMPLHELPER_EX( N ) \
+namespace cppu \
+{ \
+struct class_data##N \
+{ \
+ sal_Int16 m_nTypes; \
+ sal_Bool m_storedTypeRefs; \
+ sal_Bool m_storedId; \
+ sal_Int8 m_id[ 16 ]; \
+ type_entry m_typeEntries[ N + 1 ]; \
+}; \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper##N \
+ : public ::com::sun::star::lang::XTypeProvider \
+ , __PUBLIC_IFC##N \
+{ \
+ static class_data##N s_cd; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_query( rType, (class_data *)&s_cd, this ); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_getTypes( (class_data *)&s_cd ); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \
+}; \
+template< __CLASS_IFC##N > \
+class_data##N ImplHelper##N< __IFC##N >::s_cd = \
+__DEF_CLASS_DATA_INIT_EX( N, (ImplHelper##N< __IFC##N > *) ); \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper##N \
+ : public OWeakObject \
+ , public ::com::sun::star::lang::XTypeProvider \
+ , __PUBLIC_IFC##N \
+{ \
+ static class_data##N s_cd; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return WeakImplHelper_query( rType, (class_data *)&s_cd, this, (OWeakObject *)this ); } \
+ virtual void SAL_CALL acquire() throw () \
+ { OWeakObject::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { OWeakObject::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return WeakImplHelper_getTypes( (class_data *)&s_cd ); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \
+}; \
+template< __CLASS_IFC##N > \
+class_data##N WeakImplHelper##N< __IFC##N >::s_cd = \
+__DEF_CLASS_DATA_INIT_EX( N, (WeakImplHelper##N< __IFC##N > *) ); \
+template< __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper##N \
+ : public OWeakAggObject \
+ , public ::com::sun::star::lang::XTypeProvider \
+ , __PUBLIC_IFC##N \
+{ \
+ static class_data##N s_cd; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return OWeakAggObject::queryInterface( rType ); } \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return WeakAggImplHelper_queryAgg( rType, (class_data *)&s_cd, this, (OWeakAggObject *)this ); } \
+ virtual void SAL_CALL acquire() throw () \
+ { OWeakAggObject::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { OWeakAggObject::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return WeakAggImplHelper_getTypes( (class_data *)&s_cd ); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \
+}; \
+template< __CLASS_IFC##N > \
+class_data##N WeakAggImplHelper##N< __IFC##N >::s_cd = \
+__DEF_CLASS_DATA_INIT_EX( N, (WeakAggImplHelper##N< __IFC##N > *) ); \
+template< class BaseClass, __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper##N \
+ : public BaseClass \
+ , __PUBLIC_IFC##N \
+{ \
+ static class_data##N s_cd; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, (class_data *)&s_cd, this ) ); \
+ if (aRet.hasValue()) \
+ return aRet; \
+ return BaseClass::queryInterface( rType ); \
+ } \
+ virtual void SAL_CALL acquire() throw () \
+ { BaseClass::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { BaseClass::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplInhHelper_getTypes( (class_data *)&s_cd, BaseClass::getTypes() ); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \
+}; \
+template< class BaseClass, __CLASS_IFC##N > \
+class_data##N ImplInheritanceHelper##N< BaseClass, __IFC##N >::s_cd = \
+__DEF_CLASS_DATA_INIT_EX( N, (ImplInheritanceHelper##N< BaseClass, __IFC##N > *) ); \
+template< class BaseClass, __CLASS_IFC##N > \
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper##N \
+ : public BaseClass \
+ , __PUBLIC_IFC##N \
+{ \
+ static class_data##N s_cd; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return BaseClass::queryInterface( rType ); } \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, (class_data *)&s_cd, this ) ); \
+ if (aRet.hasValue()) \
+ return aRet; \
+ return BaseClass::queryAggregation( rType ); \
+ } \
+ virtual void SAL_CALL acquire() throw () \
+ { BaseClass::acquire(); } \
+ virtual void SAL_CALL release() throw () \
+ { BaseClass::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplInhHelper_getTypes( (class_data *)&s_cd, BaseClass::getTypes() ); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \
+}; \
+template< class BaseClass, __CLASS_IFC##N > \
+class_data##N AggImplInheritanceHelper##N< BaseClass, __IFC##N >::s_cd = \
+__DEF_CLASS_DATA_INIT_EX( N, (AggImplInheritanceHelper##N< BaseClass, __IFC##N > *) ); \
+}
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implbase_ex_pre.hxx b/include/cppuhelper/implbase_ex_pre.hxx
new file mode 100644
index 000000000000..a9eb82df0251
--- /dev/null
+++ b/include/cppuhelper/implbase_ex_pre.hxx
@@ -0,0 +1,33 @@
+/* -*- 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 _CPPUHELPER_IMPLBASE_EX_PRE_HXX_
+#define _CPPUHELPER_IMPLBASE_EX_PRE_HXX_
+
+/// @cond INTERNAL
+
+#define __IFC_EX_TYPE_INIT_NAME( class_cast, ifc_name ) \
+{ { ifc_name::static_type }, ((sal_IntPtr)(ifc_name *) class_cast 16) - 16 }
+
+#define __IFC_EX_TYPE_INIT( class_cast, N ) __IFC_EX_TYPE_INIT_NAME( class_cast, Ifc##N )
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/implementationentry.hxx b/include/cppuhelper/implementationentry.hxx
new file mode 100644
index 000000000000..298c0dc9e9ba
--- /dev/null
+++ b/include/cppuhelper/implementationentry.hxx
@@ -0,0 +1,121 @@
+/* -*- 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 _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+#define _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+
+#include <cppuhelper/factory.hxx>
+#include "cppuhelperdllapi.h"
+
+// MinGW wants it the one way around while MSVC wants it the other (cf.
+// <sourceforge.net/support/tracker.php?aid=3514133> "Syntactic __cdecl
+// incompatibility with MSVC"; and everywhere else, SAL_CALL is empty, so
+// doesn't matter):
+#if defined __GNUC__
+#define MY_FN_PTR(name) SAL_CALL (* name)
+#else
+#define MY_FN_PTR(name) (SAL_CALL * name)
+#endif
+
+namespace cppu
+{
+/** One struct instance represents all data necessary for registering one service implementation.
+
+ */
+struct ImplementationEntry
+{
+ /** Function that creates an instance of the implementation
+ */
+ ComponentFactoryFunc create;
+
+ /** Function that returns the implementation-name of the implementation
+ (same as XServiceInfo.getImplementationName() ).
+ */
+ rtl::OUString MY_FN_PTR( getImplementationName )();
+
+ /** Function that returns all supported servicenames of the implementation
+ ( same as XServiceInfo.getSupportedServiceNames() ).
+ */
+ com::sun::star::uno::Sequence< rtl::OUString > MY_FN_PTR( getSupportedServiceNames ) ();
+
+ /** Function that creates a SingleComponentFactory.
+
+ The pModCount parameter is a backwards-compatibility remainder of a
+ removed library unloading feature; always set to null.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >
+ MY_FN_PTR( createFactory )(
+ ComponentFactoryFunc fptr,
+ ::rtl::OUString const & rImplementationName,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
+ rtl_ModuleCount * pModCount );
+
+ /** Backwards-compatibility remainder of a removed library unloading
+ feature; always set to null.
+ */
+ rtl_ModuleCount * moduleCounter;
+
+ /** Must be set to 0 !
+ For future extensions.
+ */
+ sal_Int32 nFlags;
+};
+
+/** Helper function for implementation of the component_writeInfo()-function.
+
+ @deprecated component_writeInfo should no longer be used in new components
+
+ @param pServiceManager The first parameter passed to component_writeInfo()-function
+ (This is an instance of the service manager, that creates the factory).
+ @param pRegistryKey The second parameter passed to the component_writeInfo()-function.
+ This is a reference to the registry key, into which the implementation
+ data shall be written to.
+ @param entries Each element of the entries-array must contains a function pointer
+ table for registering an implementation. The end of the array
+ must be marked with a 0 entry in the create-function.
+ @return sal_True, if all implementations could be registered, otherwise sal_False.
+ */
+CPPUHELPER_DLLPUBLIC sal_Bool component_writeInfoHelper(
+ void *pServiceManager, void *pRegistryKey , const struct ImplementationEntry entries[] );
+
+/** Helper function for implementation of the component_getFactory()-function,
+ that must be implemented by every shared library component.
+
+ @param pImplName The implementation-name to be instantiated ( This is the
+ first parameter passed to the component_getFactory
+ @param pServiceManager The second parameter passed to component_getFactory()-function
+ (This is a of the service manager, that creates the factory).
+ @param pRegistryKey The third parameter passed to the component_getFactory()-function.
+ This is a reference to the registry key, where the implementation
+ data has been written to.
+ @param entries Each element of the entries-array must contains a function pointer
+ table for creating a factor of the implementation. The end of the array
+ must be marked with a 0 entry in the create-function.
+ @return 0 if the helper failed to instantiate a factory, otherwise an acquired pointer
+ to a factory.
+ */
+CPPUHELPER_DLLPUBLIC void *component_getFactoryHelper(
+ const sal_Char * pImplName,
+ void * pServiceManager,
+ void * pRegistryKey,
+ const struct ImplementationEntry entries[] );
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/interfacecontainer.h b/include/cppuhelper/interfacecontainer.h
new file mode 100644
index 000000000000..774f900a8b26
--- /dev/null
+++ b/include/cppuhelper/interfacecontainer.h
@@ -0,0 +1,607 @@
+/* -*- 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 _CPPUHELPER_INTERFACECONTAINER_H_
+#define _CPPUHELPER_INTERFACECONTAINER_H_
+
+#include <vector>
+#include <osl/mutex.hxx>
+#include <rtl/alloc.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "cppuhelperdllapi.h"
+
+/** */ //for docpp
+namespace cppu
+{
+
+namespace detail {
+
+ union element_alias
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > *pAsSequence;
+ ::com::sun::star::uno::XInterface * pAsInterface;
+ element_alias() : pAsInterface(0) {}
+ };
+
+}
+
+//===================================================================
+class OInterfaceContainerHelper;
+/**
+ This is the iterator of a InterfaceContainerHelper. Typically
+ one constructs an instance on the stack for one firing session.
+ It is not allowed to assign or copy an instance of this class.
+
+ @see OInterfaceContainerHelper
+ */
+class CPPUHELPER_DLLPUBLIC OInterfaceIteratorHelper
+{
+public:
+ /**
+ Create an iterator over the elements of the container. The iterator
+ copies the elements of the conatainer. A change to the container
+ during the lifetime of an iterator is allowed and does not
+ affect the iterator-instance. The iterator and the container take cares
+ themself for concurrent access, no additional guarding is necessary.
+
+ Remark: The copy is on demand. The iterator copy the elements only if the container
+ change the contents. It is not allowed to destroy the container as long
+ as an iterator exist.
+
+ @param rCont the container of the elements.
+ */
+ OInterfaceIteratorHelper( OInterfaceContainerHelper & rCont ) SAL_THROW(());
+
+ /**
+ Releases the connection to the container.
+ */
+ ~OInterfaceIteratorHelper() SAL_THROW(());
+
+ /** Return sal_True, if there are more elements in the iterator. */
+ sal_Bool SAL_CALL hasMoreElements() const SAL_THROW(())
+ { return nRemain != 0; }
+ /** Return the next element of the iterator. Calling this method if
+ hasMoreElements() has returned sal_False, is an error. Cast the
+ returned pointer to the
+ */
+ ::com::sun::star::uno::XInterface * SAL_CALL next() SAL_THROW(());
+
+ /** Removes the current element (the last one returned by next())
+ from the underlying container. Calling this method before
+ next() has been called or calling it twice with no next()
+ inbetween is an error.
+ */
+ void SAL_CALL remove() SAL_THROW(());
+
+private:
+ OInterfaceContainerHelper & rCont;
+ sal_Bool bIsList;
+
+ detail::element_alias aData;
+
+ sal_Int32 nRemain;
+
+ OInterfaceIteratorHelper( const OInterfaceIteratorHelper & ) SAL_THROW(());
+ OInterfaceIteratorHelper & operator = ( const OInterfaceIteratorHelper & ) SAL_THROW(());
+};
+
+//===================================================================
+/**
+ A container of interfaces. To access the elements use an iterator.
+ This implementation is thread save.
+
+ @see OInterfaceIteratorHelper
+ */
+class CPPUHELPER_DLLPUBLIC OInterfaceContainerHelper
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ /**
+ Create an interface container.
+
+ @param rMutex the mutex to protect multi thread access.
+ The lifetime must be longer than the lifetime
+ of this object.
+ */
+ OInterfaceContainerHelper( ::osl::Mutex & rMutex ) SAL_THROW(());
+ /**
+ Release all interfaces. All iterators must be destroyed before
+ the container is destructed.
+ */
+ ~OInterfaceContainerHelper() SAL_THROW(());
+ /**
+ Return the number of Elements in the container. Only useful if you have acquired
+ the mutex.
+ */
+ sal_Int32 SAL_CALL getLength() const SAL_THROW(());
+
+ /**
+ Return all interfaces added to this container.
+ **/
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElements() const SAL_THROW(());
+
+ /** Inserts an element into the container. The position is not specified, thus it is not
+ specified in which order events are fired.
+
+ @attention
+ If you add the same interface more than once, then it will be added to the elements list
+ more than once and thus if you want to remove that interface from the list, you have to call
+ removeInterface() the same number of times.
+ In the latter case, you will also get events fired more than once (if the interface is a
+ listener interface).
+
+ @param rxIFace
+ interface to be added; it is allowed to insert null or
+ the same interface more than once
+ @return
+ the new count of elements in the container
+ */
+ sal_Int32 SAL_CALL addInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW(());
+ /** Removes an element from the container. It uses interface equality to remove the interface.
+
+ @param rxIFace
+ interface to be removed
+ @return
+ the new count of elements in the container
+ */
+ sal_Int32 SAL_CALL removeInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW(());
+ /**
+ Call disposing on all object in the container that
+ support XEventListener. Than clear the container.
+ */
+ void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
+ /**
+ Clears the container without calling disposing().
+ */
+ void SAL_CALL clear() SAL_THROW(());
+
+ /** Executes a functor for each contained listener of specified type, e.g.
+ <code>forEach<awt::XPaintListener>(...</code>.
+
+ If a com::sun::star::lang::DisposedException occurs which relates to
+ the called listener, then that listener is removed from the container.
+
+ @tparam ListenerT listener type
+ @tparam FuncT unary functor type, let your compiler deduce this for you
+ @param func unary functor object expecting an argument of type
+ com::sun::star::uno::Reference<ListenerT>
+ */
+ template <typename ListenerT, typename FuncT>
+ inline void forEach( FuncT const& func );
+
+ /** Calls a UNO listener method for each contained listener.
+
+ The listener method must take a single argument of type EventT,
+ and return <code>void</code>.
+
+ If a com::sun::star::lang::DisposedException occurs which relates to
+ the called listener, then that listener is removed from the container.
+
+ @tparam ListenerT UNO event listener type, let your compiler deduce this for you
+ @tparam EventT event type, let your compiler deduce this for you
+ @param NotificationMethod
+ Pointer to a method of a ListenerT interface.
+ @param Event
+ Event to notify to all contained listeners
+
+ Example:
+@code
+ awt::PaintEvent aEvent( static_cast< cppu::OWeakObject* >( this ), ... );
+ listeners.notifyEach( &XPaintListener::windowPaint, aEvent );
+@endcode
+ */
+ template< typename ListenerT, typename EventT >
+ inline void notifyEach( void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ), const EventT& Event );
+
+private:
+friend class OInterfaceIteratorHelper;
+ /**
+ bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >,
+ otherwise aData.pAsInterface == of type (XEventListener *)
+ */
+ detail::element_alias aData;
+ ::osl::Mutex & rMutex;
+ /** TRUE -> used by an iterator. */
+ sal_Bool bInUse;
+ /** TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >. */
+ sal_Bool bIsList;
+
+ OInterfaceContainerHelper( const OInterfaceContainerHelper & ) SAL_THROW(());
+ OInterfaceContainerHelper & operator = ( const OInterfaceContainerHelper & ) SAL_THROW(());
+
+ /*
+ Dulicate content of the conaitner and release the old one without destroying.
+ The mutex must be locked and the memberbInUse must be true.
+ */
+ void copyAndResetInUse() SAL_THROW(());
+
+private:
+ template< typename ListenerT, typename EventT >
+ class NotifySingleListener
+ {
+ private:
+ typedef void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& );
+ NotificationMethod m_pMethod;
+ const EventT& m_rEvent;
+ public:
+ NotifySingleListener( NotificationMethod method, const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
+
+ void operator()( const ::com::sun::star::uno::Reference<ListenerT>& listener ) const
+ {
+ (listener.get()->*m_pMethod)( m_rEvent );
+ }
+ };
+};
+
+template <typename ListenerT, typename FuncT>
+inline void OInterfaceContainerHelper::forEach( FuncT const& func )
+{
+ OInterfaceIteratorHelper iter( *this );
+ while (iter.hasMoreElements()) {
+ ::com::sun::star::uno::Reference<ListenerT> const xListener(
+ iter.next(), ::com::sun::star::uno::UNO_QUERY );
+ if (xListener.is()) {
+#if defined(EXCEPTIONS_OFF)
+ func( xListener );
+#else
+ try {
+ func( xListener );
+ }
+ catch (::com::sun::star::lang::DisposedException const& exc) {
+ if (exc.Context == xListener)
+ iter.remove();
+ }
+#endif
+ }
+ }
+}
+
+template< typename ListenerT, typename EventT >
+inline void OInterfaceContainerHelper::notifyEach( void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ), const EventT& Event )
+{
+ forEach< ListenerT, NotifySingleListener< ListenerT, EventT > >( NotifySingleListener< ListenerT, EventT >( NotificationMethod, Event ) );
+}
+
+//===================================================================
+/**
+ A helper class to store interface references of different types.
+
+ @see OInterfaceIteratorHelper
+ @see OInterfaceContainerHelper
+ */
+template< class key , class hashImpl , class equalImpl >
+class OMultiTypeInterfaceContainerHelperVar
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ /**
+ Create a container of interface containers.
+
+ @param rMutex the mutex to protect multi thread access.
+ The lifetime must be longer than the lifetime
+ of this object.
+ */
+ inline OMultiTypeInterfaceContainerHelperVar( ::osl::Mutex & rMutex ) SAL_THROW(());
+ /**
+ Deletes all containers.
+ */
+ inline ~OMultiTypeInterfaceContainerHelperVar() SAL_THROW(());
+
+ /**
+ Return all id's under which at least one interface is added.
+ */
+ inline ::com::sun::star::uno::Sequence< key > SAL_CALL getContainedTypes() const SAL_THROW(());
+
+ /**
+ Return the container created under this key.
+ The InterfaceContainerHelper exists until the whole MultiTypeContainer is destroyed.
+ @return the container created under this key. If the container
+ was not created, null was returned.
+ */
+ inline OInterfaceContainerHelper * SAL_CALL getContainer( const key & ) const SAL_THROW(());
+
+ /** Inserts an element into the container with the specified key.
+ The position is not specified, thus it is not specified in which order events are fired.
+
+ @attention
+ If you add the same interface more than once, then it will be added to the elements list
+ more than once and thus if you want to remove that interface from the list, you have to call
+ removeInterface() the same number of times.
+ In the latter case, you will also get events fired more than once (if the interface is a
+ listener interface).
+
+ @param rKey
+ the id of the container
+ @param r
+ interface to be added; it is allowed, to insert null or
+ the same interface more than once
+ @return
+ the new count of elements in the container
+ */
+ inline sal_Int32 SAL_CALL addInterface(
+ const key & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
+ SAL_THROW(());
+
+ /** Removes an element from the container with the specified key.
+ It uses interface equality to remove the interface.
+
+ @param rKey
+ the id of the container
+ @param rxIFace
+ interface to be removed
+ @return
+ the new count of elements in the container
+ */
+ inline sal_Int32 SAL_CALL removeInterface(
+ const key & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
+ SAL_THROW(());
+
+ /**
+ Call disposing on all references in the container, that
+ support XEventListener. Then clears the container.
+ @param rEvt the event object which is passed during disposing() call
+ */
+ inline void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
+ /**
+ Remove all elements of all containers. Does not delete the container.
+ */
+ inline void SAL_CALL clear() SAL_THROW(());
+
+ typedef key keyType;
+private:
+ typedef ::std::vector< std::pair < key , void* > > InterfaceMap;
+ InterfaceMap *m_pMap;
+ ::osl::Mutex & rMutex;
+
+ inline typename InterfaceMap::iterator find(const key &rKey) const
+ {
+ typename InterfaceMap::iterator iter = m_pMap->begin();
+ typename InterfaceMap::iterator end = m_pMap->end();
+
+ while( iter != end )
+ {
+ equalImpl equal;
+ if( equal( iter->first, rKey ) )
+ break;
+ iter++;
+ }
+ return iter;
+ }
+
+ inline OMultiTypeInterfaceContainerHelperVar( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW(());
+ inline OMultiTypeInterfaceContainerHelperVar & operator = ( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW(());
+};
+
+
+
+
+/**
+ This struct contains the standard variables of a broadcaster. Helper
+ classes only know a reference to this struct instead of references
+ to the four members. The access to the members must be guarded with
+ rMutex.
+
+ The additional template parameter keyType has been added, because gcc
+ can't compile addListener( const container::keyType &key ).
+ */
+template < class container , class keyType >
+struct OBroadcastHelperVar
+{
+ /** The shared mutex. */
+ ::osl::Mutex & rMutex;
+ /** ListenerContainer class is thread safe. */
+ container aLC;
+ /** Dispose call ready. */
+ sal_Bool bDisposed;
+ /** In dispose call. */
+ sal_Bool bInDispose;
+
+ /**
+ Initialize the structur. bDispose and bInDispose are set to false.
+ @param rMutex_ the mutex reference.
+ */
+ OBroadcastHelperVar( ::osl::Mutex & rMutex_ ) SAL_THROW(())
+ : rMutex( rMutex_ )
+ , aLC( rMutex_ )
+ , bDisposed( sal_False )
+ , bInDispose( sal_False )
+ {}
+
+ /**
+ adds a listener threadsafe.
+ **/
+ inline void addListener(
+ const keyType &key,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > &r )
+ SAL_THROW(())
+ {
+ ::osl::MutexGuard guard( rMutex );
+ OSL_ENSURE( !bInDispose, "do not add listeners in the dispose call" );
+ OSL_ENSURE( !bDisposed, "object is disposed" );
+ if( ! bInDispose && ! bDisposed )
+ aLC.addInterface( key , r );
+ }
+
+ /**
+ removes a listener threadsafe
+ **/
+ inline void removeListener(
+ const keyType &key,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > & r )
+ SAL_THROW(())
+ {
+ ::osl::MutexGuard guard( rMutex );
+ OSL_ENSURE( !bDisposed, "object is disposed" );
+ if( ! bInDispose && ! bDisposed )
+ aLC.removeInterface( key , r );
+ }
+
+ /**
+ Return the container created under this key.
+ @return the container created under this key. If the container
+ was not created, null was returned. This can be used to optimize
+ performance ( construction of an event object can be avoided ).
+ ***/
+ inline OInterfaceContainerHelper * SAL_CALL getContainer( const keyType &key ) const SAL_THROW(())
+ { return aLC.getContainer( key ); }
+};
+
+/*------------------------------------------
+*
+* In general, the above templates are used with a Type as key.
+* Therefore a default declaration is given ( OMultiTypeInterfaceContainerHelper and OBroadcastHelper )
+*
+*------------------------------------------*/
+
+// helper function call class
+struct hashType_Impl
+{
+ size_t operator()(const ::com::sun::star::uno::Type & s) const SAL_THROW(())
+ { return (size_t) s.getTypeName().hashCode(); }
+};
+
+
+/** Specialized class for key type com::sun::star::uno::Type,
+ without explicit usage of STL symbols.
+*/
+class CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelper
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ /**
+ Create a container of interface containers.
+
+ @param rMutex the mutex to protect multi thread access.
+ The lifetime must be longer than the lifetime
+ of this object.
+ */
+ OMultiTypeInterfaceContainerHelper( ::osl::Mutex & rMutex ) SAL_THROW(());
+ /**
+ Delete all containers.
+ */
+ ~OMultiTypeInterfaceContainerHelper() SAL_THROW(());
+
+ /**
+ Return all id's under which at least one interface is added.
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getContainedTypes() const SAL_THROW(());
+
+ /**
+ Return the container created under this key.
+ @return the container created under this key. If the container
+ was not created, null was returned.
+ */
+ OInterfaceContainerHelper * SAL_CALL getContainer( const ::com::sun::star::uno::Type & rKey ) const SAL_THROW(());
+
+ /** Inserts an element into the container with the specified key.
+ The position is not specified, thus it is not specified in which order events are fired.
+
+ @attention
+ If you add the same interface more than once, then it will be added to the elements list
+ more than once and thus if you want to remove that interface from the list, you have to call
+ removeInterface() the same number of times.
+ In the latter case, you will also get events fired more than once (if the interface is a
+ listener interface).
+
+ @param rKey
+ the id of the container
+ @param r
+ interface to be added; it is allowed, to insert null or
+ the same interface more than once
+ @return
+ the new count of elements in the container
+ */
+ sal_Int32 SAL_CALL addInterface(
+ const ::com::sun::star::uno::Type & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
+ SAL_THROW(());
+
+ /** Removes an element from the container with the specified key.
+ It uses interface equality to remove the interface.
+
+ @param rKey
+ the id of the container
+ @param rxIFace
+ interface to be removed
+ @return
+ the new count of elements in the container
+ */
+ sal_Int32 SAL_CALL removeInterface(
+ const ::com::sun::star::uno::Type & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
+ SAL_THROW(());
+
+ /**
+ Call disposing on all object in the container that
+ support XEventListener. Than clear the container.
+ */
+ void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
+ /**
+ Remove all elements of all containers. Does not delete the container.
+ */
+ void SAL_CALL clear() SAL_THROW(());
+
+ typedef ::com::sun::star::uno::Type keyType;
+private:
+ void *m_pMap;
+ ::osl::Mutex & rMutex;
+
+ inline OMultiTypeInterfaceContainerHelper( const OMultiTypeInterfaceContainerHelper & ) SAL_THROW(());
+ inline OMultiTypeInterfaceContainerHelper & operator = ( const OMultiTypeInterfaceContainerHelper & ) SAL_THROW(());
+};
+
+typedef OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper , OMultiTypeInterfaceContainerHelper::keyType > OBroadcastHelper;
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/interfacecontainer.hxx b/include/cppuhelper/interfacecontainer.hxx
new file mode 100644
index 000000000000..292278f7a078
--- /dev/null
+++ b/include/cppuhelper/interfacecontainer.hxx
@@ -0,0 +1,195 @@
+/* -*- 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 _CPPUHELPER_INTERFACECONTAINER_HXX_
+#define _CPPUHELPER_INTERFACECONTAINER_HXX_
+
+#include <cppuhelper/interfacecontainer.h>
+
+
+namespace cppu
+{
+
+template< class key , class hashImpl , class equalImpl >
+inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::OMultiTypeInterfaceContainerHelperVar( ::osl::Mutex & rMutex_ )
+ SAL_THROW(())
+ : rMutex( rMutex_ )
+{
+ m_pMap = new InterfaceMap;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::~OMultiTypeInterfaceContainerHelperVar()
+ SAL_THROW(())
+{
+ typename InterfaceMap::iterator iter = m_pMap->begin();
+ typename InterfaceMap::iterator end = m_pMap->end();
+
+ while( iter != end )
+ {
+ delete (OInterfaceContainerHelper*)(*iter).second;
+ (*iter).second = 0;
+ ++iter;
+ }
+ delete m_pMap;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+inline ::com::sun::star::uno::Sequence< key > OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::getContainedTypes() const
+ SAL_THROW(())
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ typename InterfaceMap::size_type nSize = m_pMap->size();
+ if( nSize != 0 )
+ {
+ ::com::sun::star::uno::Sequence< key > aInterfaceTypes( nSize );
+ key * pArray = aInterfaceTypes.getArray();
+
+ typename InterfaceMap::iterator iter = m_pMap->begin();
+ typename InterfaceMap::iterator end = m_pMap->end();
+
+ sal_uInt32 i = 0;
+ while( iter != end )
+ {
+ // are interfaces added to this container?
+ if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() )
+ // yes, put the type in the array
+ pArray[i++] = (*iter).first;
+ iter++;
+ }
+ if( i != nSize ) {
+ // may be empty container, reduce the sequence to the right size
+ aInterfaceTypes = ::com::sun::star::uno::Sequence<key>( pArray, i );
+ }
+ return aInterfaceTypes;
+ }
+ return ::com::sun::star::uno::Sequence<key>();
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::getContainer(
+ const key & rKey ) const SAL_THROW(())
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ typename InterfaceMap::iterator iter = find( rKey );
+ if( iter != m_pMap->end() )
+ return (OInterfaceContainerHelper*) (*iter).second;
+ return 0;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+sal_Int32 OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::addInterface(
+ const key & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener )
+ SAL_THROW(())
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ typename InterfaceMap::iterator iter = find( rKey );
+ if( iter == m_pMap->end() )
+ {
+ OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
+ m_pMap->push_back(std::pair<key, void*>(rKey, pLC));
+ return pLC->addInterface( rListener );
+ }
+ else
+ return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener );
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+inline sal_Int32 OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::removeInterface(
+ const key & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener )
+ SAL_THROW(())
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ // search container with id nUik
+ typename InterfaceMap::iterator iter = find( rKey );
+ // container found?
+ if( iter != m_pMap->end() )
+ return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
+
+ // no container with this id. Always return 0
+ return 0;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::disposeAndClear(
+ const ::com::sun::star::lang::EventObject & rEvt )
+ SAL_THROW(())
+{
+ typename InterfaceMap::size_type nSize = 0;
+ OInterfaceContainerHelper ** ppListenerContainers = NULL;
+ {
+ ::osl::MutexGuard aGuard( rMutex );
+ nSize = m_pMap->size();
+ if( nSize )
+ {
+ typedef OInterfaceContainerHelper* ppp;
+ ppListenerContainers = new ppp[nSize];
+
+ typename InterfaceMap::iterator iter = m_pMap->begin();
+ typename InterfaceMap::iterator end = m_pMap->end();
+
+ typename InterfaceMap::size_type i = 0;
+ while( iter != end )
+ {
+ ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second;
+ ++iter;
+ }
+ }
+ }
+
+ // create a copy, because do not fire event in a guarded section
+ for( typename InterfaceMap::size_type i = 0; i < nSize; i++ )
+ {
+ if( ppListenerContainers[i] )
+ ppListenerContainers[i]->disposeAndClear( rEvt );
+ }
+
+ delete [] ppListenerContainers;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::clear() SAL_THROW(())
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ typename InterfaceMap::iterator iter = m_pMap->begin();
+ typename InterfaceMap::iterator end = m_pMap->end();
+
+ while( iter != end )
+ {
+ ((OInterfaceContainerHelper*)(*iter).second)->clear();
+ ++iter;
+ }
+}
+
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/propertysetmixin.hxx b/include/cppuhelper/propertysetmixin.hxx
new file mode 100644
index 000000000000..bbca3ac479ee
--- /dev/null
+++ b/include/cppuhelper/propertysetmixin.hxx
@@ -0,0 +1,489 @@
+/* -*- 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 INCLUDED_CPPUHELPER_PROPERTYSETMIXIN_HXX
+#define INCLUDED_CPPUHELPER_PROPERTYSETMIXIN_HXX
+
+#include "sal/config.h"
+#include "com/sun/star/beans/PropertyVetoException.hpp"
+#include "com/sun/star/beans/UnknownPropertyException.hpp"
+#include "com/sun/star/beans/XFastPropertySet.hpp"
+#include "com/sun/star/beans/XPropertyAccess.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "sal/types.h"
+#include "cppuhelperdllapi.h"
+
+namespace com { namespace sun { namespace star {
+ namespace beans {
+ class XPropertyChangeListener;
+ class XPropertySetInfo;
+ class XVetoableChangeListener;
+ struct PropertyValue;
+ }
+ namespace uno {
+ class Any;
+ class Type;
+ class XComponentContext;
+ }
+} } }
+namespace rtl { class OUString; }
+
+namespace cppu {
+
+template< typename T > class PropertySetMixin;
+
+// Suppress warnings about virtual functions but non-virtual destructor:
+#if defined _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4265)
+#endif
+
+/**
+ @short A helper base class for <code>cppu::PropertySetMixin</code>.
+
+ See the documentation of <code>cppu::PropertySetMixin</code> for
+ further details.
+
+ That <code>cppu::PropertySetMixin</code> is derived from this
+ base class should be considered an implementation detail. The functionality
+ of <code>cppu::PropertySetMixin</code> that is inherited from this base
+ class and is visible to subclasses of
+ <code>cppu::PropertySetMixin</code> should be treated by such
+ subclasses as being provided by <code>cppu::PropertySetMixin</code>
+ directly (e.g., in such subclasses, use
+ &ldquo;<code>PropertySetMixin::Implements</code>&rdquo; instead of
+ &ldquo;<code>PropertySetMixinImpl::Implements</code>&rdquo;).
+
+ @since UDK 3.2.1
+*/
+#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY && HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE \
+ && !defined __clang__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+class CPPUHELPER_DLLPUBLIC PropertySetMixinImpl:
+ public com::sun::star::beans::XPropertySet,
+ public com::sun::star::beans::XFastPropertySet,
+ public com::sun::star::beans::XPropertyAccess
+{
+protected:
+ /**
+ @short Flags used by subclasses of
+ <code>cppu::PropertySetMixin</code> to specify what UNO interface
+ types shall be supported.
+ */
+ enum Implements {
+ /**
+ @short Flag specifying that the UNO interface type
+ <code>com::sun::star::beans::XPropertySet</code> shall be supported.
+ */
+ IMPLEMENTS_PROPERTY_SET = 1,
+
+ /**
+ @short Flag specifying that the UNO interface type
+ <code>com::sun::star::beans::XFastPropertySet</code> shall be
+ supported.
+ */
+ IMPLEMENTS_FAST_PROPERTY_SET = 2,
+
+ /**
+ @short Flag specifying that the UNO interface type
+ <code>com::sun::star::beans::XPropertyAccess</code> shall be
+ supported.
+ */
+ IMPLEMENTS_PROPERTY_ACCESS = 4
+ };
+
+ /**
+ @short A class used by subclasses of
+ <code>cppu::PropertySetMixin</code> when implementing UNO interface
+ type attribute setter functions.
+
+ This class is not thread safe; that is, the constructor,
+ <code>notify</code>, and the destructor must be called from the same
+ thread.
+
+ See <code>cppu::PropertySetMixinImpl::prepareSet</code> for
+ further details.
+ */
+ class CPPUHELPER_DLLPUBLIC BoundListeners {
+ public:
+ /**
+ @short The constructor.
+
+ May throw <code>std::bad_alloc</code>.
+ */
+ BoundListeners();
+
+ /**
+ @short The destructor.
+
+ Does not throw.
+ */
+ ~BoundListeners();
+
+ /**
+ @short Notifies any
+ <code>com::sun::star::beans::XPropertyChangeListener</code>s.
+
+ May throw <code>com::sun::star::uno::RuntimeException</code>
+ and <code>std::bad_alloc</code>.
+
+ See <code>cppu::PropertySetMixinImpl::prepareSet</code>
+ for further details.
+ */
+ void notify() const;
+
+ private:
+ BoundListeners(BoundListeners &); // not defined
+ void operator =(BoundListeners); // not defined
+
+ class Impl;
+ Impl * m_impl;
+
+ friend class PropertySetMixinImpl;
+ };
+
+ /**
+ @short A function used by subclasses of
+ <code>cppu::PropertySetMixin</code> when implementing UNO interface
+ type attribute setter functions.
+
+ First, this function checks whether this instance has already been
+ disposed (see <code>cppu::PropertySetMixinImpl::dispose</code>),
+ and throws a <code>com::sun::star::lang::DisposedException</code> if
+ applicable. For a constrained attribute (whose setter can explicitly
+ raise <code>com::sun::star::beans::PropertyVetoException</code>), this
+ function notifies any
+ <code>com::sun::star::beans::XVetoableChangeListener</code>s. For a
+ bound attribute, this function modifies the passed-in
+ <code>boundListeners</code> so that it can afterwards be used to notify
+ any <code>com::sun::star::beans::XPropertyChangeListener</code>s. This
+ function should be called before storing the new attribute value, and
+ <code>boundListeners->notify()</code> should be called exactly once after
+ storing the new attribute value (in case the attribute is bound;
+ otherwise, calling <code>boundListeners->notify()</code> is ignored).
+ Furthermore, <code>boundListeners->notify()</code> and this function have
+ to be called from the same thread.
+
+ May throw
+ <code>com::sun::star::beans::PropertyVetoException</code>,
+ <code>com::sun::star::uno::RuntimeException</code> (and
+ <code>com::sun::star::lang::DisposedException</code> in particular), and
+ <code>std::bad_alloc</code>.
+
+ @param propertyName the name of the property (which is the same as the
+ name of the attribute that is going to be set)
+
+ @param oldValue the property value corresponding to the old attribute
+ value. This is only used as
+ <code>com::sun::star::beans::PropertyChangeEvent::OldValue</code>, which
+ is rather useless, anyway (see &ldquo;Using the Observer Pattern&rdquo;
+ in <a href="http://tools.openoffice.org/CodingGuidelines.sxw">
+ OpenOffice.org Coding Guidelines</a>). If the attribute
+ that is going to be set is neither bound nor constrained, or if
+ <code>com::sun::star::beans::PropertyChangeEvent::OldValue</code> should
+ not be set, a <code>VOID</code> <code>Any</code> can be used instead.
+
+ @param newValue the property value corresponding to the new
+ attribute value. This is only used as
+ <code>com::sun::star::beans::PropertyChangeEvent::NewValue</code>, which
+ is rather useless, anyway (see &ldquo;Using the Observer Pattern&rdquo;
+ in <a href="http://tools.openoffice.org/CodingGuidelines.sxw">
+ OpenOffice.org Coding Guidelines</a>), <em>unless</em> the
+ attribute that is going to be set is constrained. If the attribute
+ that is going to be set is neither bound nor constrained, or if it is
+ only bound but
+ <code>com::sun::star::beans::PropertyChangeEvent::NewValue</code> should
+ not be set, a <code>VOID</code> <code>Any</code> can be used instead.
+
+ @param boundListeners a pointer to a fresh
+ <code>cppu::PropertySetMixinImpl::BoundListeners</code> instance
+ (which has not been passed to this function before, and on which
+ <code>notify</code> has not yet been called); may only be null if the
+ attribute that is going to be set is not bound
+ */
+ void prepareSet(
+ rtl::OUString const & propertyName,
+ com::sun::star::uno::Any const & oldValue,
+ com::sun::star::uno::Any const & newValue,
+ BoundListeners * boundListeners);
+
+ /**
+ @short Mark this instance as being disposed.
+
+ See <code>com::sun::star::lang::XComponent</code> for the general
+ concept of disposing UNO objects. On the first call to this function,
+ all registered listeners
+ (<code>com::sun::star::beans::XPropertyChangeListener</code>s and
+ <code>com::sun::star::beans::XVetoableChangeListener</code>s) are
+ notified of the disposing source. Any subsequent calls to this function
+ are ignored.
+
+ May throw <code>com::sun::star::uno::RuntimeException</code> and
+ <code>std::bad_alloc</code>.
+ */
+ void dispose();
+
+ /**
+ @short A function used by subclasses of
+ <code>cppu::PropertySetMixin</code> when implementing
+ <code>com::sun::star::uno::XInterface::queryInterface</code>.
+
+ This function checks for support of any of the UNO interface types
+ specified in the call of the <code>cppu::PropertySetMixin</code>
+ constructor. It does not check for any other UNO interface types (not
+ even for <code>com::sun::star::uno::XInterface</code>), and should not
+ be used directly as the implementation of
+ <code>com::sun::star::uno::XInterface::queryInterface</code> of this UNO
+ object.
+ */
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface(
+ com::sun::star::uno::Type const & type)
+ throw (com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertySet::getPropertySetInfo
+ virtual
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
+ SAL_CALL getPropertySetInfo() throw (com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertySet::setPropertyValue
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const & propertyName,
+ com::sun::star::uno::Any const & value)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertySet::getPropertyValue
+ virtual com::sun::star::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & propertyName)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ /**
+ @short Adds a
+ <code>com::sun::star::beans::XPropertyChangeListener</code>.
+
+ If a listener is added more than once, it will receive all
+ relevant notifications multiple times.
+
+ @see com::sun::star::beans::XPropertySet::addPropertyChangeListener
+ */
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const & propertyName,
+ com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener > const & listener)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertySet::removePropertyChangeListener
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const & propertyName,
+ com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener > const & listener)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ /**
+ @short Adds a
+ <code>com::sun::star::beans::XVetoableChangeListener</code>.
+
+ If a listener is added more than once, it will receive all
+ relevant notifications multiple times.
+
+ @see com::sun::star::beans::XPropertySet::addVetoableChangeListener
+ */
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const & propertyName,
+ com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener > const & listener)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertySet::removeVetoableChangeListener
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const & propertyName,
+ com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener > const & listener)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XFastPropertySet::setFastPropertyValue
+ virtual void SAL_CALL setFastPropertyValue(
+ sal_Int32 handle, com::sun::star::uno::Any const & value)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XFastPropertySet::getFastPropertyValue
+ virtual com::sun::star::uno::Any SAL_CALL getFastPropertyValue(
+ sal_Int32 handle)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertyAccess::getPropertyValues
+ virtual
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
+ SAL_CALL getPropertyValues() throw (com::sun::star::uno::RuntimeException);
+
+ // @see com::sun::star::beans::XPropertyAccess::setPropertyValues
+ virtual void SAL_CALL setPropertyValues(
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
+ const & props)
+ throw (
+ com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+
+private:
+ PropertySetMixinImpl(PropertySetMixinImpl &); // not defined
+ void operator =(PropertySetMixinImpl &); // not defined
+
+ PropertySetMixinImpl(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ const & context,
+ Implements implements,
+ com::sun::star::uno::Sequence< rtl::OUString > const & absentOptional,
+ com::sun::star::uno::Type const & type);
+
+ class Impl;
+ Impl * m_impl;
+
+ friend class Impl;
+ template< typename T > friend class PropertySetMixin;
+
+ ~PropertySetMixinImpl();
+
+ void checkUnknown(rtl::OUString const & propertyName);
+};
+#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY && HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE \
+ && !defined __clang__
+#pragma GCC diagnostic pop
+#endif
+
+/**
+ @short A helper mixin to implement certain UNO interfaces related to property
+ set handling on top of the attributes of a given UNO interface type.
+
+ The UNO interface type is specified by the type parameter
+ <code>T</code> (which must correspond to a UNO interface type).
+
+ No specializations of this class template should be added by client
+ code.
+
+ @since UDK 3.2.1
+*/
+template< typename T > class PropertySetMixin: public PropertySetMixinImpl {
+protected:
+ /**
+ @short The constructor.
+
+ May throw <code>com::sun::star::uno::RuntimeException</code> and
+ <code>std::bad_alloc</code>.
+
+ @param context the component context used by this class template; must
+ not be null, and must supply the service
+ <code>com.sun.star.reflection.CoreReflection</code> and the singleton
+ <code>com.sun.star.reflection.theTypeDescriptionManager</code>
+
+ @param implements a combination of zero or more flags specifying what
+ UNO interface types shall be supported
+
+ @param absentOptional a list of optional properties that are not
+ present, and should thus not be visible via
+ <code>com::sun::star::beans::XPropertySet::getPropertySetInfo</code>,
+ <code>com::sun::star::beans::XPropertySet::addPropertyChangeListener<!--
+ --></code>, <code>com::sun::star::beans::XPropertySet::<!--
+ -->removePropertyChangeListener</code>,
+ <code>com::sun::star::beans::XPropertySet::addVetoableChangeListener<!--
+ --></code>, and <code>com::sun::star::beans::XPropertySet::<!--
+ -->removeVetoableChangeListener</code>. For consistency reasons, the
+ given <code>absentOptional</code> should only contain the names of
+ attributes that represent optional properties that are not present (that
+ is, the attribute getters and setters always throw a
+ <code>com::sun::star::beans::UnknownPropertyException</code>), and should
+ contain each such name only once. If an optional property is not present
+ (that is, the corresponding attribute getter and setter always throw a
+ <code>com::sun::star::beans::UnknownPropertyException</code>) but is not
+ contained in the given <code>absentOptional</code>, then it will be
+ visible via
+ <code>com::sun::star::beans::XPropertySet::getPropertySetInfo</code> as a
+ <code>com::sun::star::beans::Property</code> with a set
+ <code>com::sun::star::beans::PropertyAttribute::OPTIONAL</code>. If the
+ given <code>implements</code> specifies that
+ <code>com::sun::star::beans::XPropertySet</code> is not supported, then
+ the given <code>absentOptional</code> is effectively ignored and can be
+ empty.
+ */
+ PropertySetMixin(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ const & context,
+ Implements implements,
+ com::sun::star::uno::Sequence< rtl::OUString > const & absentOptional):
+ PropertySetMixinImpl(
+ context, implements, absentOptional, T::static_type())
+ {}
+
+ /**
+ @short The destructor.
+
+ Does not throw.
+ */
+ ~PropertySetMixin() {}
+
+private:
+ PropertySetMixin(PropertySetMixin &); // not defined
+ void operator =(PropertySetMixin &); // not defined
+};
+
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/propshlp.hxx b/include/cppuhelper/propshlp.hxx
new file mode 100644
index 000000000000..aa99ebaa6536
--- /dev/null
+++ b/include/cppuhelper/propshlp.hxx
@@ -0,0 +1,736 @@
+/* -*- 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 _CPPUHELPER_PROPSHLP_HXX
+#define _CPPUHELPER_PROPSHLP_HXX
+
+#include <rtl/alloc.h>
+
+#include <cppuhelper/interfacecontainer.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetOption.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+
+#include <memory>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+
+/*************************************************************************
+*************************************************************************/
+
+
+/**
+ This interface is used by the OPropertyHelper, to access the property description.
+ */
+class CPPUHELPER_DLLPUBLIC IPropertyArrayHelper
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ /**
+ Following the rule, the first virtual method implies a virtual destructor.
+ */
+ virtual ~IPropertyArrayHelper();
+
+ /**
+ Return the property members Name and Attribute from the handle nHandle.
+ @param nHandle the handle of a property. If the values of the handles
+ are sorted in the same way as the names and the highest handle value
+ is getCount() -1, than it must be an indexed acces to the property array.
+ @param pPropName is an out parameter filled with property name of the property with the
+ handle nHandle. May be NULL.
+ @param pAttributes is an out parameter filled with attributes of the property with the
+ handle nHandle. May be NULL.
+ @return True, if the handle exist, otherwise false.
+ */
+ virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
+ ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
+ /**
+ Return the sequence of properties. The sequence is sorted by name.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) = 0;
+ /**
+ Return the property with the name rPropertyName.
+ @param rPropertyName the name of the property.
+ @exception UnknownPropertyException thrown if the property name is unknown.
+ */
+ virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
+ const ::rtl::OUString& rPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException) = 0;
+ /**
+ Return true if the property with the name rPropertyName exist, otherwise false.
+ @param rPropertyName the name of the property.
+ */
+ virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
+ /**
+ Return the handle of the property with the name rPropertyName.
+ If the property does not exist -1 is returned.
+ @param rPropertyName the name of the property.
+ */
+ virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
+ /**
+ Fill the array with the handles of the properties.
+ @return the handles of the names from the pHandles array. -1
+ indicates an unknown property name.
+ */
+ virtual sal_Int32 SAL_CALL fillHandles(
+ /*out*/ sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
+};
+
+/**
+ You can use this helper class to map a XPropertySet-Interface to a XFast-
+ or a XMultiPropertySet interface.
+ */
+class CPPUHELPER_DLLPUBLIC OPropertyArrayHelper : public IPropertyArrayHelper
+{
+public:
+ /**
+ Create an object which supports the common property interfaces.
+
+ @param pProps array of properties
+ The array pProps should be sorted.
+ @param nElements is the number of properties in the pProps structure.
+ @param bSorted indicates that the elements are sorted.
+ *********/
+ OPropertyArrayHelper(
+ ::com::sun::star::beans::Property *pProps,
+ sal_Int32 nElements ,
+ sal_Bool bSorted = sal_True )
+ SAL_THROW(());
+
+ /**
+ Create an object which supports the common property interfaces.
+ @param aProps sequence of properties which are supported by this helper.
+ The sequence aProps should be sorted.
+ @param bSorted indicates that the elements are sorted.
+ */
+ OPropertyArrayHelper(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > & aProps,
+ sal_Bool bSorted = sal_True )
+ SAL_THROW(());
+
+ /**
+ Return the number of properties.
+ */
+ sal_Int32 SAL_CALL getCount() const SAL_THROW(());
+ /**
+ Return the property members Name and Attribute from the handle nHandle.
+ @param nHandle the handle of a property. If the values of the handles
+ are sorted in the same way as the names and the highest handle value
+ is getCount() -1, than it is only an indexed acces to the property array.
+ Otherwise it is a linear search through the array.
+ @param pPropName is an out parameter filled with property name of the property with the
+ handle nHandle. May be NULL.
+ @param pAttributes is an out parameter filled with attributes of the property with the
+ handle nHandle. May be NULL.
+ @return True, if the handle exist, otherwise false.
+ */
+ virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
+ ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle );
+ /**
+ Return the sequence of properties. The sequence is sorted by name.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void);
+ /**
+ Return the property with the name rPropertyName.
+ @param rPropertyName the name of the property.
+ @exception UnknownPropertyException thrown if the property name is unknown.
+ */
+ virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
+ const ::rtl::OUString& rPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException);
+ /**
+ Return true if the property with the name rPropertyName exist, otherwise false.
+ @param rPropertyName the name of the property.
+ */
+ virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName);
+ /**
+ Return the handle of the property with the name rPropertyName.
+ If the property does not exist -1 is returned.
+ @param rPropertyName the name of the property.
+ */
+ virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName );
+ /**
+ Fill the array with the handles of the properties.
+ @return the handles of the names from the pHandles array. -1
+ indicates an unknown property name.
+ */
+ virtual sal_Int32 SAL_CALL fillHandles(
+ /*out*/sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames );
+
+protected:
+ /** reserved for future use. do not use.
+ */
+ void * m_pReserved;
+
+private:
+ void init( sal_Bool bSorted ) SAL_THROW(());
+
+ /** The sequence generated from the pProperties array. */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aInfos;
+
+ /**
+ True, If the values of the handles are sorted in the same way as the names
+ and the highest handle value is getCount() -1, otherwise false.
+ */
+ sal_Bool bRightOrdered;
+};
+
+
+//-----------------------------------------------------------------------------
+// helper defines needed for an interface container with a 32 bit key values
+
+struct equalInt32_Impl
+{
+ bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const SAL_THROW(())
+ { return i1 == i2; }
+};
+
+struct hashInt32_Impl
+{
+ size_t operator()(const sal_Int32 & i) const SAL_THROW(())
+ { return i; }
+};
+/** Specialized class for key type sal_Int32,
+ without explicit usage of STL symbols.
+*/
+class CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelperInt32
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ /**
+ Create a container of interface containers.
+
+ @param rMutex the mutex to protect multi thread access.
+ The lifetime must be longer than the lifetime
+ of this object.
+ */
+ OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & rMutex ) SAL_THROW(());
+ /**
+ Delete all containers.
+ */
+ ~OMultiTypeInterfaceContainerHelperInt32() SAL_THROW(());
+
+ /**
+ Return all id's under which at least one interface is added.
+ */
+ ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const SAL_THROW(());
+
+ /**
+ Return the container created under this key.
+ @return the container created under this key. If the container
+ was not created, null was returned.
+ */
+ OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const SAL_THROW(());
+
+ /**
+ Insert an element in the container specified with the key. The position is not specified.
+ @param rKey the id of the container.
+ @param r the added interface. It is allowed to insert null or
+ the same pointer more than once.
+ @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL addInterface(
+ const sal_Int32 & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
+ SAL_THROW(());
+
+ /**
+ Remove an element from the container specified with the key.
+ It uses the equal definition of uno objects to remove the interfaces.
+ @param rKey the id of the container.
+ @param rxIFace the removed interface.
+ @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL removeInterface(
+ const sal_Int32 & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
+ SAL_THROW(());
+
+ /**
+ Call disposing on all objects in the container that
+ support XEventListener. Then clear the container.
+ */
+ void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
+ /**
+ Remove all elements of all containers. Does not delete the container.
+ */
+ void SAL_CALL clear() SAL_THROW(());
+
+ typedef sal_Int32 keyType;
+private:
+ void *m_pMap;
+ ::osl::Mutex & rMutex;
+
+ inline OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW(());
+ inline OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW(());
+};
+
+
+/** An interface to extend event notification actions.
+ */
+class IEventNotificationHook
+{
+public:
+ /**
+ Method to be called by OPropertySetHelper::fire.
+
+ @param bIgnoreRuntimeExceptionsWhileFiring
+ indicates whether occuring RuntimeExceptions shall be
+ ignored when firing notifications
+ @param pnHandles the id's of the properties that changed.
+ @param nCount the number of elements in the arrays pnHandles, pNewValues and pOldValues.
+ @param bVetoable true means fire to VetoableChangeListener, false means fire to
+ XPropertyChangedListener and XMultiPropertyChangedListener.
+ @param bIgnoreRuntimeExceptionsWhileFiring
+ indicates whether occurring RuntimeExceptions will be
+ ignored when firing notifications
+ (vetoableChange(), propertyChange())
+ to listeners.
+ PropertyVetoExceptions may still be thrown.
+ This flag is useful in an inter-process scenario when
+ remote bridges may break down
+ (firing DisposedExceptions).
+
+ @see OPropertySetHelper::fire
+ */
+ virtual void fireEvents(
+ sal_Int32 * pnHandles,
+ sal_Int32 nCount,
+ sal_Bool bVetoable,
+ bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+protected:
+#endif
+ ~IEventNotificationHook() {}
+ // avoid warnings about virtual members and non-virtual dtor
+};
+
+
+
+/**
+ This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet
+ and XPropertySet to the methods getInfoHelper, convertFastPropertyValue,
+ setFastPropertyValue_NoBroadcast and getFastPropertyValue. You must derive from
+ this class and overload the methods.
+ It provides a standard implementation of the XPropertySetInfo.
+ The XPropertiesChangeListener are inserted in the rBHelper.aLC structure.
+ The XPropertyChangeListener and XVetoableChangeListener with no names are inserted
+ in the rBHelper.aLC structure. So it is possible to advise property listeners with
+ the connection point interfaces. But only listeners that listen to all property changes.
+
+ */
+class CPPUHELPER_DLLPUBLIC OPropertySetHelper :
+ public ::com::sun::star::beans::XMultiPropertySet,
+ public ::com::sun::star::beans::XFastPropertySet,
+ public ::com::sun::star::beans::XPropertySet
+{
+public:
+ /**
+ @param rBHelper this structure contains the basic members of
+ a broadcaster.
+ The lifetime must be longer than the lifetime
+ of this object. Stored in the variable rBHelper.
+ */
+ OPropertySetHelper( OBroadcastHelper & rBHelper ) SAL_THROW(());
+
+ /** Constructor.
+
+ @param rBHelper
+ this structure contains the basic members of
+ a broadcaster.
+ The lifetime must be longer than the lifetime
+ of this object. Stored in the variable rBHelper.
+
+ @param bIgnoreRuntimeExceptionsWhileFiring
+ indicates whether occurring RuntimeExceptions will be
+ ignored when firing notifications
+ (vetoableChange(), propertyChange())
+ to listeners.
+ PropertyVetoExceptions may still be thrown.
+ This flag is useful in an inter-process scenario when
+ remote bridges may break down
+ (firing DisposedExceptions).
+ */
+ OPropertySetHelper(
+ OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
+
+ /** Constructor.
+
+ @param rBHelper
+ this structure contains the basic members of
+ a broadcaster.
+ The lifetime must be longer than the lifetime
+ of this object. Stored in the variable rBHelper.
+
+ @param i_pFireEvents
+ additional event notifier
+
+ @param bIgnoreRuntimeExceptionsWhileFiring
+ indicates whether occurring RuntimeExceptions will be
+ ignored when firing notifications
+ (vetoableChange(), propertyChange())
+ to listeners.
+ PropertyVetoExceptions may still be thrown.
+ This flag is useful in an inter-process scenario when
+ remote bridges may break down
+ (firing DisposedExceptions).
+ */
+ OPropertySetHelper(
+ OBroadcastHelper & rBHelper,
+ IEventNotificationHook *i_pFireEvents,
+ bool bIgnoreRuntimeExceptionsWhileFiring = false);
+
+ /**
+ Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and
+ XEventListener.
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** eases implementing XTypeProvider::getTypes, returns the types of XMultiPropertySet, XFastPropertySet, XPropertySet
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > getTypes()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /**
+ Send a disposing notification to the listeners in the conatiners aBoundLC
+ and aVetoableLC.
+
+ @see OComponentHelper
+ */
+ void SAL_CALL disposing() SAL_THROW(());
+
+ /**
+ Throw UnknownPropertyException or PropertyVetoException if the property with the name
+ rPropertyName does not exist or is readonly. Otherwise rPropertyName is changed to its handle
+ value and setFastPropertyValue is called.
+ */
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ /**
+ Throw UnknownPropertyException if the property with the name
+ rPropertyName does not exist.
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ /** Ignored if the property is not bound. */
+ virtual void SAL_CALL addPropertyChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /** Ignored if the property is not bound. */
+ virtual void SAL_CALL removePropertyChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /** Ignored if the property is not constrained. */
+ virtual void SAL_CALL addVetoableChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /** Ignored if the property is not constrained. */
+ virtual void SAL_CALL removeVetoableChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /**
+ Throw UnknownPropertyException or PropertyVetoException if the property with the name
+ rPropertyName does not exist or is readonly. Otherwise the method convertFastPropertyValue
+ is called, then the vetoable listeners are notified. After this the value of the property
+ is changed with the setFastPropertyValue_NoBroadcast method and the bound listeners are
+ notified.
+ */
+ virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /**
+ @exception com::sun::star::beans::UnknownPropertyException
+ if the property with the handle nHandle does not exist.
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XMultiPropertySet
+ virtual void SAL_CALL setPropertyValues(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values )
+ throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertiesChangeListener(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL removePropertiesChangeListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL firePropertiesChangeEvent(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > & Listener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /**
+ The property sequence is created in the call. The interface isn't used after the call.
+ */
+ static ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ createPropertySetInfo( IPropertyArrayHelper & rProperties ) SAL_THROW(());
+protected:
+ /**
+ This method fire events to all registered property listeners.
+ @param pnHandles the id's of the properties that changed.
+ @param pNewValues the new values of the properties.
+ @param pOldValues the old values of the properties.
+ @param nCount the number of elements in the arrays pnHandles, pNewValues and pOldValues.
+ @param bVetoable true means fire to VetoableChangeListener, false means fire to
+ XPropertyChangedListener and XMultiPropertyChangedListener.
+ */
+ void SAL_CALL fire(
+ sal_Int32 * pnHandles,
+ const ::com::sun::star::uno::Any * pNewValues,
+ const ::com::sun::star::uno::Any * pOldValues,
+ sal_Int32 nCount,
+ sal_Bool bVetoable );
+
+ /**
+ Set multiple properties with the handles.
+ @param nSeqLen the length of the arrays pHandles and Values.
+ @param pHandles the handles of the properties. The number of elements
+ in the Values sequence is the length of the handle array. A value of -1
+ of a handle means invalid property. These are ignored.
+ @param pValues the values of the properties.
+ @param nHitCount the number of valid entries in the handle array.
+ */
+ void SAL_CALL setFastPropertyValues(
+ sal_Int32 nSeqLen,
+ sal_Int32 * pHandles,
+ const ::com::sun::star::uno::Any * pValues,
+ sal_Int32 nHitCount )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+ /**
+ This abstract method must return the name to index table. This table contains all property
+ names and types of this object. The method is not implemented in this class.
+ */
+ virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
+
+ /**
+ Converted the value rValue and return the result in rConvertedValue and the
+ old value in rOldValue. A IllegalArgumentException is thrown.
+ The method is not implemented in this class. After this call the vetoable
+ listeners are notified.
+
+ @param rConvertedValue the converted value. Only set if return is true.
+ @param rOldValue the old value. Only set if return is true.
+ @param nHandle the handle of the proberty.
+ @param rValue the value to be converted
+ @return true if the value converted.
+ */
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException) = 0;
+
+ /** The same as setFastProperyValue; nHandle is always valid.
+ The changes must not be broadcasted in this method.
+ The method is implemented in a derived class.
+
+ @attention
+ Although you are permitted to throw any UNO exception, only the following
+ are valid for usage:
+ -- com::sun::star::beans::UnknownPropertyException
+ -- com::sun::star::beans::PropertyVetoException
+ -- com::sun::star::lang::IllegalArgumentException
+ -- com::sun::star::lang::WrappedTargetException
+ -- com::sun::star::uno::RuntimeException
+
+ @param nHandle
+ handle
+ @param rValue
+ value
+ */
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception) = 0;
+ /**
+ The same as getFastProperyValue, but return the value through rValue and nHandle
+ is always valid.
+ The method is not implemented in this class.
+ */
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const = 0;
+
+ /** sets an dependent property's value
+
+ <p>Sometimes setting a given property needs to implicitly modify another property's value. Calling |setPropertyValue|
+ from within |setFastPropertyValue_NoBroadcast| is not an option here, as it would notify the property listeners
+ while our mutex is still locked. Setting the dependent property's value directly (e.g. by calling |setFastPropertyValue_NoBroadcast|
+ recursively) is not an option, too, since it would miss firing the property change event.</p>
+
+ <p>So, in such cases, you use |setDependentFastPropertyValue| from within |setFastPropertyValue_NoBroadcast|.
+ It will convert and actually set the property value (invoking |convertFastPropertyValue| and |setFastPropertyValue_NoBroadcast|
+ for the given handle and value), and add the property change event to the list of events to be notified
+ when the bottom-most |setFastPropertyValue_NoBroadcast| on the stack returns.</p>
+
+ <p><strong>Note</strong>: The method will <em>not</em> invoke veto listeners for the property.</p>
+
+ <p><strong>Note</strong>: It's the caller's responsibility to ensure that our mutex is locked. This is
+ canonically given when the method is invoked from within |setFastPropertyValue_NoBroadcast|, in other
+ contexts, you might need to take own measures.</p>
+ */
+ void setDependentFastPropertyValue(
+ sal_Int32 i_handle,
+ const ::com::sun::star::uno::Any& i_value
+ );
+
+ /** The common data of a broadcaster. Use the mutex, disposing state and the listener container. */
+ OBroadcastHelper &rBHelper;
+ /**
+ Container for the XProperyChangedListener. The listeners are inserted by handle.
+ */
+ OMultiTypeInterfaceContainerHelperInt32 aBoundLC;
+ /**
+ Container for the XPropertyVetoableListener. The listeners are inserted by handle.
+ */
+ OMultiTypeInterfaceContainerHelperInt32 aVetoableLC;
+
+ class Impl;
+
+ /** reserved for future use. finally, the future has arrived...
+ */
+ const std::auto_ptr<Impl> m_pReserved;
+
+private:
+ OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW(());
+ OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW(());
+
+ /** notifies the given changes in property's values, <em>plus</em> all property changes collected during recent
+ |setDependentFastPropertyValue| calls.
+ */
+ void impl_fireAll(
+ sal_Int32* i_handles,
+ const ::com::sun::star::uno::Any * i_newValues,
+ const ::com::sun::star::uno::Any * i_oldValues,
+ sal_Int32 i_count
+ );
+
+#if defined _MSC_VER // public -> protected changes mangled names there
+public:
+#else
+protected:
+#endif
+// Suppress warning about virtual functions but non-virtual destructor:
+#if defined _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4265)
+#endif
+ /**
+ You must call disposing before destruction.
+ */
+ ~OPropertySetHelper() SAL_THROW(());
+};
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+/**
+ OPropertySetHelper plus XPropertySetOption
+ */
+class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper,
+ public ::com::sun::star::beans::XPropertySetOption
+{
+public:
+ /** Constructor.
+
+ See OPropertySetHelper constructors documentation
+ */
+ explicit OPropertySetHelper2(
+ OBroadcastHelper & rBHelper,
+ IEventNotificationHook *i_pFireEvents = NULL,
+ bool bIgnoreRuntimeExceptionsWhileFiring = false);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertySetOption
+ virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable )
+ throw(::com::sun::star::uno::RuntimeException);
+
+
+
+private:
+ OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_THROW(());
+ OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & ) SAL_THROW(());
+
+#if defined _MSC_VER // public -> protected changes mangled names there
+public:
+#else
+protected:
+#endif
+// Suppress warning about virtual functions but non-virtual destructor:
+ /**
+ You must call disposing before destruction.
+ */
+ virtual ~OPropertySetHelper2() SAL_THROW(());
+};
+
+} // end namespace cppuhelper
+#endif //
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/proptypehlp.h b/include/cppuhelper/proptypehlp.h
new file mode 100644
index 000000000000..3236ca0363c3
--- /dev/null
+++ b/include/cppuhelper/proptypehlp.h
@@ -0,0 +1,70 @@
+/* -*- 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 _CPPUHELPER_PROPTYPEHLP_H
+#define _CPPUHELPER_PROPTYPEHLP_H
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/uno/TypeClass.hpp>
+
+
+namespace cppu {
+
+/** Converts the value stored in an any to a concrete C++ type.
+ The function does the same as the operator >>= () at the
+ Any class, except that it throws an IllegalArgumentException in case of
+ failures (the value cannot be extracted without data loss )
+
+ @exception com::sun::star::lang::IllegalArgumentException when the type could not be converted.
+ */
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , const ::com::sun::star::uno::Any & a);
+
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , ::com::sun::star::uno::Any & a);
+
+/**
+ conversion of basic types
+*/
+inline void SAL_CALL convertPropertyValue( sal_Int64 & target , const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( sal_uInt64 & target, const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( sal_Int32 & target , const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( sal_uInt32 & target, const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( sal_Int16 & target , const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( sal_uInt16 & target, const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( sal_Int8 & target , const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( float & target , const ::com::sun::star::uno::Any & source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( double &target , const ::com::sun::star::uno::Any &source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+inline void SAL_CALL convertPropertyValue( ::rtl::OUString &target , const ::com::sun::star::uno::Any &source )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
+
+} // end namespace cppu
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/proptypehlp.hxx b/include/cppuhelper/proptypehlp.hxx
new file mode 100644
index 000000000000..08107f3b91f7
--- /dev/null
+++ b/include/cppuhelper/proptypehlp.hxx
@@ -0,0 +1,523 @@
+/* -*- 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 _CPPUHELPER_PROPTYPEHLP_HXX
+#define _CPPUHELPER_PROPTYPEHLP_HXX
+
+#include <cppuhelper/proptypehlp.h>
+
+namespace cppu
+{
+
+/** Converts the value stored in an any to a concrete C++ type.
+ The function does the same as the operator >>= () at the
+ Any class, except that it throws an IllegalArgumentException in case of
+ failures (the value cannot be extracted without data loss )
+
+ @exception com::sun::star::lang::IllegalArgumentException when the type could not be converted.
+ */
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , const ::com::sun::star::uno::Any & a)
+{
+
+ if( !( a >>= value ) ) {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+// This template is needed at least for msci4 compiler
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , ::com::sun::star::uno::Any & a)
+{
+ convertPropertyValue( value , (const ::com::sun::star::uno::Any & ) a );
+}
+
+/**
+ conversion of basic types
+*/
+inline void SAL_CALL convertPropertyValue( sal_Bool & b , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32 = 0;
+ a >>= i32;
+ b = ( sal_Bool )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c = *(sal_Unicode*) a.getValue();
+ b = ( sal_Bool ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16 = 0;
+ a >>= i16;
+ b = ( sal_Bool ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ b = *((sal_Bool*)a.getValue());
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8 = 0;
+ a >>= i8;
+ b = ( sal_Bool ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16 = 0;
+ a >>= i16;
+ b = ( sal_Bool ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32 = 0;
+ a >>= i32;
+ b = ( sal_Bool ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_Int64 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ a >>= i;
+ }
+ else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ sal_uInt64 i64 = 0;
+ a >>= i64;
+ i = ( sal_Int64 ) i64;
+ }
+ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32 = 0;
+ a >>= i32;
+ i = ( sal_Int64 )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode *)a.getValue();
+ i = ( sal_Int64 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16 = 0;
+ a >>= i16;
+ i = ( sal_Int64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int64 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8 = 0;
+ a >>= i8;
+ i = ( sal_Int64 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16 = 0;
+ a >>= i16;
+ i = ( sal_Int64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32 = 0;
+ a >>= i32;
+ i = ( sal_Int64 ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+inline void SAL_CALL convertPropertyValue( sal_uInt64 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ a >>= i;
+ }
+ if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ sal_Int64 i64;
+ a >>= i64;
+ i = ( sal_uInt64 ) i64;
+ }
+ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ i = ( sal_uInt64 )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *( sal_Unicode * ) a.getValue() ;
+ i = ( sal_uInt64 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_uInt64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_uInt64 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_uInt64 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_uInt64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ i = ( sal_uInt64 ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+// the basic types
+// sal_Int32
+inline void SAL_CALL convertPropertyValue( sal_Int32 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ i = ( sal_Int32 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16 = 0;
+ a >>= i16;
+ i = ( sal_Int32 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int32 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8 = 0;
+ a >>= i8;
+ i = ( sal_Int32 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16 = 0;
+ a >>= i16;
+ i = ( sal_Int32 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32 = 0;
+ a >>= i32;
+ i = ( sal_Int32 ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_uInt32 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ a >>= i;
+ }
+ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ i = (sal_uInt32 ) i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ i = ( sal_uInt32 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_uInt32 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_uInt32 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_uInt32 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_uInt32 ) i16;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+inline void SAL_CALL convertPropertyValue( sal_Int16 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ i = ( sal_Int16 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int16 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8 = 0;
+ a >>= i8;
+ i = ( sal_Int16 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16 = 0;
+ a >>= i16;
+ i = ( sal_Int16 ) i16;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_uInt16 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode *) a.getValue();
+ i = ( sal_Int16 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int16 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8 = 0;
+ a >>= i8;
+ i = ( sal_Int16 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16 = 0;
+ a >>= i16;
+ i = ( sal_Int16 ) i16;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_Int8 & i , const ::com::sun::star::uno::Any & a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int8 ) b;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( float &f , const ::com::sun::star::uno::Any &a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_FLOAT == tc ) {
+ a >>= f;
+ }
+ else if( ::com::sun::star::uno::TypeClass_DOUBLE == tc ) {
+ double d = 0;
+ a >>= d;
+ f = ( float ) d;
+ }
+ else if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ sal_Int64 i64 = 0;
+ a >>= i64;
+ f = ( float ) i64;
+ }
+ // msci 4 does not support this conversion
+/* else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ sal_uInt64 i64;
+ a >>= i64;
+ f = ( float ) i64;
+ }
+*/ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32 = 0;
+ a >>= i32;
+ f = ( float )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ f = ( float ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16 = 0;
+ a >>= i16;
+ f = ( float ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ f = ( float ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8 = 0;
+ a >>= i8;
+ f = ( float ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16 = 0;
+ a >>= i16;
+ f = ( float ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32 = 0;
+ a >>= i32;
+ f = ( float ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+inline void SAL_CALL convertPropertyValue( double &d , const ::com::sun::star::uno::Any &a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_DOUBLE == tc ) {
+ float f;
+ a >>= f;
+ d = ( double ) f;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_FLOAT == tc ) {
+ float f;
+ a >>= f;
+ d = (double) f;
+ }
+ else if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ sal_Int64 i64;
+ a >>= i64;
+ d = (double) i64;
+ }
+ // msci 4 does not support this
+/* else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ sal_uInt64 i64;
+ a >>= i64;
+ d = (double) i64;
+ }
+*/ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ d = (double)i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ d = (double) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ d = (double) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ d = (double) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ d = (double) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ d = (double) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ d = (double) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( ::rtl::OUString &ow , const ::com::sun::star::uno::Any &a )
+ SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) )
+{
+ if( ::com::sun::star::uno::TypeClass_STRING == a.getValueType().getTypeClass() ) {
+ a >>= ow;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+} // end namespace cppu
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/queryinterface.hxx b/include/cppuhelper/queryinterface.hxx
new file mode 100644
index 000000000000..e8f2dfa9dcbf
--- /dev/null
+++ b/include/cppuhelper/queryinterface.hxx
@@ -0,0 +1,534 @@
+/* -*- 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 _CPPUHELPER_QUERYINTERFACE_HXX_
+#define _CPPUHELPER_QUERYINTERFACE_HXX_
+
+#include "sal/config.h"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Type.hxx"
+#include "sal/types.h"
+
+namespace cppu
+{
+
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @tparam Interface7 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @param p7 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == Interface7::static_type())
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @tparam Interface7 interface type
+ @tparam Interface8 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @param p7 interface pointer
+ @param p8 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == Interface7::static_type())
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == Interface8::static_type())
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @tparam Interface7 interface type
+ @tparam Interface8 interface type
+ @tparam Interface9 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @param p7 interface pointer
+ @param p8 interface pointer
+ @param p9 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == Interface7::static_type())
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == Interface8::static_type())
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == Interface9::static_type())
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @tparam Interface7 interface type
+ @tparam Interface8 interface type
+ @tparam Interface9 interface type
+ @tparam Interface10 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @param p7 interface pointer
+ @param p8 interface pointer
+ @param p9 interface pointer
+ @param p10 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == Interface7::static_type())
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == Interface8::static_type())
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == Interface9::static_type())
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else if (rType == Interface10::static_type())
+ return ::com::sun::star::uno::Any( &p10, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @tparam Interface7 interface type
+ @tparam Interface8 interface type
+ @tparam Interface9 interface type
+ @tparam Interface10 interface type
+ @tparam Interface11 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @param p7 interface pointer
+ @param p8 interface pointer
+ @param p9 interface pointer
+ @param p10 interface pointer
+ @param p11 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
+ class Interface11 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
+ Interface11 * p11 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == Interface7::static_type())
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == Interface8::static_type())
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == Interface9::static_type())
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else if (rType == Interface10::static_type())
+ return ::com::sun::star::uno::Any( &p10, rType );
+ else if (rType == Interface11::static_type())
+ return ::com::sun::star::uno::Any( &p11, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+/** Compares demanded type to given template argument types.
+
+ @tparam Interface1 interface type
+ @tparam Interface2 interface type
+ @tparam Interface3 interface type
+ @tparam Interface4 interface type
+ @tparam Interface5 interface type
+ @tparam Interface6 interface type
+ @tparam Interface7 interface type
+ @tparam Interface8 interface type
+ @tparam Interface9 interface type
+ @tparam Interface10 interface type
+ @tparam Interface11 interface type
+ @tparam Interface12 interface type
+ @param rType demanded type
+ @param p1 interface pointer
+ @param p2 interface pointer
+ @param p3 interface pointer
+ @param p4 interface pointer
+ @param p5 interface pointer
+ @param p6 interface pointer
+ @param p7 interface pointer
+ @param p8 interface pointer
+ @param p9 interface pointer
+ @param p10 interface pointer
+ @param p11 interface pointer
+ @param p12 interface pointer
+ @return acquired interface of demanded type or empty Any
+*/
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
+ class Interface11, class Interface12 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
+ Interface11 * p11, Interface12 * p12 )
+ SAL_THROW(())
+{
+ if (rType == Interface1::static_type())
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == Interface2::static_type())
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == Interface3::static_type())
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == Interface4::static_type())
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == Interface5::static_type())
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == Interface6::static_type())
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == Interface7::static_type())
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == Interface8::static_type())
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == Interface9::static_type())
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else if (rType == Interface10::static_type())
+ return ::com::sun::star::uno::Any( &p10, rType );
+ else if (rType == Interface11::static_type())
+ return ::com::sun::star::uno::Any( &p11, rType );
+ else if (rType == Interface12::static_type())
+ return ::com::sun::star::uno::Any( &p12, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/shlib.hxx b/include/cppuhelper/shlib.hxx
new file mode 100644
index 000000000000..666359fac851
--- /dev/null
+++ b/include/cppuhelper/shlib.hxx
@@ -0,0 +1,133 @@
+/* -*- 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 _CPPUHELPER_SHLIB_HXX_
+#define _CPPUHELPER_SHLIB_HXX_
+
+#include <osl/module.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
+#include <com/sun/star/registry/CannotRegisterImplementationException.hpp>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+// Note the pointless redundancy
+// "::com::sun::star::lang::XSingleComponentFactory or
+// ::com::sun::star::lang::XSingleComponentFactory" in the doc
+// comments below. Whether the documentation is supposed to mean only
+// XSingleComponentFactory, or whether the other one should be
+// something else, I don't know.
+
+/** Loads a shared library component and gets the factory out of it. You can give either a
+ fully qualified libname or single lib name. The libname need not be pre/postfixed
+ (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific
+ directory. The resulting path of the library will be checked against environment variable
+ CPLD_ACCESSPATH if set.
+
+ @param rLibName name of the library
+ @param rPath optional path
+ @param rImplName implementation to be retrieved from the library
+ @param xMgr service manager to be provided to the component
+ @param xKey registry key to be provided to the component
+ @return
+ factory instance (com::sun::star::lang::XSingleComponentFactory or
+ com::sun::star::lang::XSingleComponentFactory)
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL loadSharedLibComponentFactory(
+ ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
+ ::rtl::OUString const & rImplName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey )
+ SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) );
+
+/** Loads a shared library component and gets the factory out of it. You can give either a
+ fully qualified libname or single lib name. The libname need not be pre/postfixed
+ (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific
+ directory. The resulting path of the library will be checked against environment variable
+ CPLD_ACCESSPATH if set. An optional 'prefix' parameter is used to determine the symbol
+ name of the entry point in the library.
+
+ @param rLibName name of the library
+ @param rPath optional path
+ @param rImplName implementation to be retrieved from the library
+ @param xMgr service manager to be provided to the component
+ @param xKey registry key to be provided to the component
+ @param rPrefix optional component prefix
+ @return
+ factory instance (com::sun::star::lang::XSingleComponentFactory or
+ com::sun::star::lang::XSingleComponentFactory)
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL loadSharedLibComponentFactory(
+ ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
+ ::rtl::OUString const & rImplName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
+ ::rtl::OUString const & rPrefix )
+ SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) );
+
+/** Gets the factory out of an already loaded (for instance statically linked) component.
+
+ @param pGetter the component's component_getFactory function
+ @param rImplName implementation to be retrieved from the library
+ @param xMgr service manager to be provided to the component
+ @param xKey registry key to be provided to the component
+ @param rPrefix optional component prefix
+ @return
+ factory instance (com::sun::star::lang::XSingleComponentFactory or
+ com::sun::star::lang::XSingleComponentFactory)
+*/
+CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL invokeStaticComponentFactory(
+ oslGenericFunction pGetter,
+ ::rtl::OUString const & rImplName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
+ ::rtl::OUString const & rPrefix )
+ SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) );
+
+/** Invokes component_writeInfo() function of specified component library. You can give either
+ a fully qualified libname or single lib name. The libname need not be pre/postfixed
+ (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific
+ directory. The resulting path of the library will be checked against environment variable
+ CPLD_ACCESSPATH if set.
+
+ @deprecated component_writeInfo should no longer be used in new components
+
+ @param rLibName name of the library
+ @param rPath optional path
+ @param xMgr service manager to be provided to the component
+ @param xKey registry key to be provided to the component
+*/
+CPPUHELPER_DLLPUBLIC void
+SAL_CALL writeSharedLibComponentInfo(
+ ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey )
+ SAL_THROW( (::com::sun::star::registry::CannotRegisterImplementationException) );
+
+} // end namespace cppu
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/supportsservice.hxx b/include/cppuhelper/supportsservice.hxx
new file mode 100644
index 000000000000..a5cc2003a1ed
--- /dev/null
+++ b/include/cppuhelper/supportsservice.hxx
@@ -0,0 +1,49 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_CPPUHELPER_SUPPORTSSERVICE_HXX
+#define INCLUDED_CPPUHELPER_SUPPORTSSERVICE_HXX
+
+#include "sal/config.h"
+
+#include "cppuhelper/cppuhelperdllapi.h"
+
+namespace com { namespace sun { namespace star { namespace lang {
+ class XServiceInfo;
+} } } }
+namespace rtl { class OUString; }
+
+namespace cppu {
+
+/** A helper for implementations of com.sun.star.lang.XServiceInfo.
+
+ This function is supposed to be called from implementations of
+ com::sun::star::lang::XServiceInfo::supportsService (and therefore, for
+ easier coding takes the caller's this pointer by pointer rather than by
+ com::sun::star::uno::Reference).
+
+ @param implementation points to the service implementation whose
+ getSupportedServices method is consulted; must be non-null
+
+ @param name the service name to test
+
+ @return true iff the sequence returned by the given implementation's
+ getSupportedServices method contains the given name
+
+ @since LibreOffice 4.0
+*/
+bool CPPUHELPER_DLLPUBLIC supportsService(
+ com::sun::star::lang::XServiceInfo * implementation,
+ rtl::OUString const & name);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/typeprovider.hxx b/include/cppuhelper/typeprovider.hxx
new file mode 100644
index 000000000000..24201c9a8982
--- /dev/null
+++ b/include/cppuhelper/typeprovider.hxx
@@ -0,0 +1,233 @@
+/* -*- 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 _CPPUHELPER_TYPEPROVIDER_HXX_
+#define _CPPUHELPER_TYPEPROVIDER_HXX_
+
+#include <rtl/alloc.h>
+#include <rtl/uuid.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+/** Helper class to implement com::sun::star::lang::XTypeProvider. Construct a static object
+ of this class with your UNO object's supported types.
+*/
+class CPPUHELPER_DLLPUBLIC OTypeCollection
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _aTypes;
+
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ inline OTypeCollection( const OTypeCollection & rCollection )
+ SAL_THROW(())
+ : _aTypes( rCollection._aTypes )
+ {}
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Type & rType10,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Type & rType10,
+ const ::com::sun::star::uno::Type & rType11,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Type & rType10,
+ const ::com::sun::star::uno::Type & rType11,
+ const ::com::sun::star::uno::Type & rType12,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
+ SAL_THROW(());
+
+ /** Called upon XTypeProvider::getTypes().
+
+ @return type collection
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() SAL_THROW(())
+ { return _aTypes; }
+};
+
+/** Helper class to implement com::sun::star::lang::XTypeProvider. Construct a static object
+ of this class for your UNO object's implementation id.
+*/
+class CPPUHELPER_DLLPUBLIC OImplementationId
+{
+ mutable ::com::sun::star::uno::Sequence< sal_Int8 > * _pSeq;
+ sal_Bool _bUseEthernetAddress;
+
+public:
+ /// @cond INTERNAL
+
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+
+ ~OImplementationId() SAL_THROW(());
+
+ /// @endcond
+
+ /** Constructor.
+
+ @param bUseEthernetAddress whether an ethernet mac address should be taken into account
+ */
+ inline OImplementationId( sal_Bool bUseEthernetAddress = sal_True ) SAL_THROW(())
+ : _pSeq( 0 )
+ , _bUseEthernetAddress( bUseEthernetAddress )
+ {}
+ /** Constructor giving implementation id.
+
+ @param rSeq implementation id
+ */
+ inline OImplementationId( const ::com::sun::star::uno::Sequence< sal_Int8 > & rSeq ) SAL_THROW(())
+ : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rSeq ) )
+ {}
+ inline OImplementationId( const OImplementationId & rId ) SAL_THROW(())
+ : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rId.getImplementationId() ) )
+ {}
+
+ /** Called upon XTypeProvider::getImplementationId().
+
+ @return implementation id
+ */
+ ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() const SAL_THROW(());
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/unourl.hxx b/include/cppuhelper/unourl.hxx
new file mode 100644
index 000000000000..e9a7f2baa55e
--- /dev/null
+++ b/include/cppuhelper/unourl.hxx
@@ -0,0 +1,185 @@
+/* -*- 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 INCLUDED_CPPUHELPER_UNOURL_HXX
+#define INCLUDED_CPPUHELPER_UNOURL_HXX
+
+#include <memory>
+#include "cppuhelperdllapi.h"
+
+namespace rtl { class OUString; }
+
+namespace cppu {
+
+/** A descriptor as part of a UNO URL (connection descriptor or protocol
+ descriptor).
+
+ Such a descriptor can also be useful outside the context of a full UNO URL.
+ For example, some functions take a string representing a connection or
+ protocol descriptor as input, and can use this class to parse the string.
+ */
+class CPPUHELPER_DLLPUBLIC UnoUrlDescriptor
+{
+public:
+ class Impl;
+
+ /** Construct a descriptor from a string representation.
+
+ @param rDescriptor
+ The string representation of a descriptor.
+
+ @exception rtl::MalformedUriException
+ Thrown when the given string representation is invalid.
+ */
+ explicit UnoUrlDescriptor(rtl::OUString const & rDescriptor);
+
+ /// @cond INTERNAL
+ explicit UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl);
+ /// @endcond
+
+ UnoUrlDescriptor(UnoUrlDescriptor const & rOther);
+
+ ~UnoUrlDescriptor();
+
+ UnoUrlDescriptor & operator =(UnoUrlDescriptor const & rOther);
+
+ /** Return the string representation of the descriptor.
+
+ @return
+ A reference to the string representation used to construct this
+ descriptor, without any modifications. The reference is valid for the
+ lifetime of this URL object.
+ */
+ rtl::OUString const & getDescriptor() const;
+
+ /** Return the name component of the descriptor.
+
+ @return
+ A reference to the (case insensitive) name, in lower case form. The
+ reference is valid for the lifetime of this URL object.
+ */
+ rtl::OUString const & getName() const;
+
+ /** Test whether the parameters contain a key.
+
+ @param
+ rKey A (case insensitive) key.
+
+ @return
+ True if the parameters contain a matching key/value pair.
+ */
+ bool hasParameter(rtl::OUString const & rKey) const;
+
+ /** Return the parameter value for a key.
+
+ @param
+ rKey A (case insensitive) key.
+
+ @return
+ The (case sensitive) value associated with the given key, or an empty
+ string if there is no matching key/value pair.
+ */
+ rtl::OUString getParameter(rtl::OUString const & rKey) const;
+
+private:
+ std::auto_ptr< Impl > m_xImpl;
+};
+
+/** Parse UNO URLs into their components.
+
+ The ABNF for UNO URLs is as follows (see RFCs 2234, 2396, also see
+ <http://udk.openoffice.org/common/man/spec/uno-url.html>):
+
+ uno-url = "UNO:" connection ";" protocol ";" object-name
+ connection = descriptor
+ protocol = descriptor
+ descriptor = name *("," parameter)
+ name = 1*alphanum
+ parameter = key "=" value
+ key = 1*alphanum
+ value = *vchar
+ valchar = unreserved / escaped / "$" / "&" / "+" / "/" / ":" / "?" / "@"
+ object-name = 1*ochar
+ ochar = unreserved / "$" / "&" / "+" / "," / "/" / ":" / "=" / "?" / "@"
+
+ Within a descriptor, the name and the keys are case insensitive, and within
+ the parameter list all keys must be distinct.
+
+ Parameter values are encoded using UTF-8. Note that parsing of parameter
+ values as done by UnoUrl and UnoUrlDescriptor is not strict: Invalid UTF-16
+ entities in the input, as well as broken escape sequences ("%" not followed
+ by two hex digits) are copied verbatim to the output, invalid bytes in the
+ converted UTF-8 data are considered individual Unicode characters, and
+ invalid UTF-16 entities in the resulting output (e.g., a high surrogate not
+ followed by a low surrogate) are not detected.
+ */
+class CPPUHELPER_DLLPUBLIC UnoUrl
+{
+public:
+ /** Construct a UNO URL from a string representation.
+
+ @param rUrl
+ The string representation of a UNO URL.
+
+ @exception rtl::MalformedUriException
+ Thrown when the given string representation is invalid.
+ */
+ explicit UnoUrl(rtl::OUString const & rUrl);
+
+ UnoUrl(UnoUrl const & rOther);
+
+ ~UnoUrl();
+
+ UnoUrl & operator =(UnoUrl const & rOther);
+
+ /** Return the connection descriptor component of the URL.
+
+ @return
+ A reference to the connection descriptor. The reference is valid for
+ the lifetime of this URL object.
+ */
+ UnoUrlDescriptor const & getConnection() const;
+
+ /** Return the protocol descriptor component of the URL.
+
+ @return
+ A reference to the protocol descriptor. The reference is valid for the
+ lifetime of this URL object.
+ */
+ UnoUrlDescriptor const & getProtocol() const;
+
+ /** Return the object-name component of the URL.
+
+ @return
+ A reference to the (case sensitive) object-name. The reference is valid
+ for the lifetime of this URL object.
+ */
+ rtl::OUString const & getObjectName() const;
+
+private:
+ class Impl;
+
+ std::auto_ptr< Impl > m_xImpl;
+};
+
+}
+
+#endif // INCLUDED_RTL_UNOURL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/weak.hxx b/include/cppuhelper/weak.hxx
new file mode 100644
index 000000000000..80d5ec07c500
--- /dev/null
+++ b/include/cppuhelper/weak.hxx
@@ -0,0 +1,164 @@
+/* -*- 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 _CPPUHELPER_WEAK_HXX_
+#define _CPPUHELPER_WEAK_HXX_
+
+#include <osl/interlck.h>
+#include <rtl/alloc.h>
+#include <cppuhelper/weakref.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <com/sun/star/uno/XWeak.hpp>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+class OWeakConnectionPoint;
+
+/** Base class to implement an UNO object supporting weak references, i.e. the object can be held
+ weakly (by a ::com::sun::star::uno::WeakReference).
+ This implementation copes with reference counting. Upon last release(), the virtual dtor
+ is called.
+
+ @derive
+ Inherit from this class and delegate acquire()/ release() calls.
+*/
+class CPPUHELPER_DLLPUBLIC OWeakObject : public ::com::sun::star::uno::XWeak
+{
+ friend class OWeakConnectionPoint;
+
+protected:
+ /** Virtual dtor.
+
+ @attention
+ Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any
+ exception upon destruction!
+ */
+ virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+ /** disposes and resets m_pWeakConnectionPoint
+ @pre
+ m_refCount equals 0
+ */
+ void disposeWeakConnectionPoint();
+
+ /** reference count.
+
+ @attention
+ Don't modify manually! Use acquire() and release().
+ */
+ oslInterlockedCount m_refCount;
+
+ /// @cond INTERNAL
+
+ /** Container of all weak reference listeners and the connection point from the weak reference.
+ */
+ OWeakConnectionPoint * m_pWeakConnectionPoint;
+
+ /** reserved for future use. do not use.
+ */
+ void * m_pReserved;
+
+ /// @endcond
+
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+#ifdef _MSC_VER
+ /** Default Constructor. Sets the reference count to zero.
+ Accidentally occurs in msvc mapfile = > had to be outlined.
+ */
+ OWeakObject() SAL_THROW(());
+#else
+ /** Default Constructor. Sets the reference count to zero.
+ */
+ inline OWeakObject() SAL_THROW(())
+ : m_refCount( 0 )
+ , m_pWeakConnectionPoint( 0 )
+ {}
+#endif
+ /** Dummy copy constructor. Set the reference count to zero.
+
+ @param rObj dummy param
+ */
+ inline OWeakObject( const OWeakObject & rObj ) SAL_THROW(())
+ : com::sun::star::uno::XWeak()
+ , m_refCount( 0 )
+ , m_pWeakConnectionPoint( 0 )
+ {
+ (void) rObj;
+ }
+ /** Dummy assignment operator. Does not affect reference count.
+
+ @return this OWeakObject
+ */
+ inline OWeakObject & SAL_CALL operator = ( const OWeakObject &)
+ SAL_THROW(())
+ { return *this; }
+
+ /** Basic queryInterface() implementation supporting \::com::sun::star::uno::XWeak and
+ \::com::sun::star::uno::XInterface.
+
+ @param rType demanded type
+ @return demanded type or empty any
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ /** increasing m_refCount
+ */
+ virtual void SAL_CALL acquire()
+ throw ();
+ /** decreasing m_refCount
+ */
+ virtual void SAL_CALL release()
+ throw ();
+
+ /** XWeak::queryAdapter() implementation
+
+ @return a \::com::sun::star::uno::XAdapter reference
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Cast operator to XInterface reference.
+
+ @return XInterface reference
+ */
+ inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () SAL_THROW(())
+ { return this; }
+};
+
+}
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/weakagg.hxx b/include/cppuhelper/weakagg.hxx
new file mode 100644
index 000000000000..bfe4ba5151d3
--- /dev/null
+++ b/include/cppuhelper/weakagg.hxx
@@ -0,0 +1,104 @@
+/* -*- 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 _CPPUHELPER_WEAKAGG_HXX_
+#define _CPPUHELPER_WEAKAGG_HXX_
+
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/uno/XAggregation.hpp>
+#include "cppuhelperdllapi.h"
+
+
+namespace cppu
+{
+
+/** Base class to implement an UNO object supporting weak references, i.e. the object can be held
+ weakly (by a ::com::sun::star::uno::WeakReference) and aggregation, i.e. the object can be
+ aggregated by another (delegator).
+ This implementation copes with reference counting. Upon last release(), the virtual dtor
+ is called.
+
+ @derive
+ Inherit from this class and delegate acquire()/ release() calls. Re-implement
+ XAggregation::queryInterface().
+*/
+class CPPUHELPER_DLLPUBLIC OWeakAggObject
+ : public ::cppu::OWeakObject
+ , public ::com::sun::star::uno::XAggregation
+{
+public:
+ /** Constructor. No delegator set.
+ */
+ inline OWeakAggObject() SAL_THROW(())
+ {}
+
+ /** If a delegator is set, then the delegators gets acquired. Otherwise call is delegated to
+ base class ::cppu::OWeakObject.
+ */
+ virtual void SAL_CALL acquire() throw();
+ /** If a delegator is set, then the delegators gets released. Otherwise call is delegated to
+ base class ::cppu::OWeakObject.
+ */
+ virtual void SAL_CALL release() throw();
+ /** If a delegator is set, then the delegator is queried for the demanded interface. If the
+ delegator cannot provide the demanded interface, it calls queryAggregation() on its
+ aggregated objects.
+
+ @param rType demanded interface type
+ @return demanded type or empty any
+ @see queryAggregation.
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /** Set the delegator. The delegator member reference is a weak reference.
+
+ @param Delegator the object that delegate its queryInterface to this aggregate.
+ */
+ virtual void SAL_CALL setDelegator( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & Delegator )
+ throw(::com::sun::star::uno::RuntimeException);
+ /** Called by the delegator or queryInterface. Re-implement this method instead of
+ queryInterface.
+
+ @see queryInterface
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ /** Virtual dtor. Called when reference count is 0.
+
+ @attention
+ Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any
+ exception upon destruction!
+ */
+ virtual ~OWeakAggObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+
+ /** weak reference to delegator.
+ */
+ ::com::sun::star::uno::WeakReferenceHelper xDelegator;
+private:
+ OWeakAggObject( const OWeakAggObject & rObj ) SAL_THROW(());
+ OWeakAggObject & operator = ( const OWeakAggObject & rObj ) SAL_THROW(());
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppuhelper/weakref.hxx b/include/cppuhelper/weakref.hxx
new file mode 100644
index 000000000000..0a9530608159
--- /dev/null
+++ b/include/cppuhelper/weakref.hxx
@@ -0,0 +1,164 @@
+/* -*- 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 _CPPUHELPER_WEAKREF_HXX_
+#define _CPPUHELPER_WEAKREF_HXX_
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include "cppuhelperdllapi.h"
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+class OWeakRefListener;
+
+/** The WeakReferenceHelper holds a weak reference to an object. This object must implement
+ the com::sun::star::uno::XWeak interface. The implementation is thread safe.
+*/
+class CPPUHELPER_DLLPUBLIC WeakReferenceHelper
+{
+public:
+ /** Default ctor. Creates an empty weak reference.
+ */
+ inline WeakReferenceHelper() SAL_THROW(())
+ : m_pImpl( 0 )
+ {}
+
+ /** Copy ctor. Initialize this reference with the same interface as in rWeakRef.
+
+ @param rWeakRef another weak ref
+ */
+ WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
+ /** Initialize this reference with the hard interface reference xInt. If the implementation
+ behind xInt does not support XWeak or XInt is null then this reference will be null.
+
+ @param xInt another hard interface reference
+ */
+ WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
+ SAL_THROW(());
+ /** Releases this reference.
+ */
+ ~WeakReferenceHelper() SAL_THROW(());
+
+ /** Releases this reference and takes over rWeakRef.
+
+ @param rWeakRef another weak ref
+ */
+ WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
+
+ /** Releases this reference and takes over hard reference xInt.
+ If the implementation behind xInt does not support XWeak
+ or XInt is null, then this reference is null.
+
+ @param xInt another hard reference
+ */
+ WeakReferenceHelper & SAL_CALL operator = (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW(());
+
+ /** Returns true if both weak refs reference to the same object.
+
+ @param rObj another weak ref
+ @return true, if both weak refs reference to the same object.
+ */
+ inline sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW(())
+ { return (get() == rObj.get()); }
+
+ /** Gets a hard reference to the object.
+
+ @return hard reference or null, if the weakly referenced interface has gone
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL get() const SAL_THROW(());
+ /** Gets a hard reference to the object.
+
+ @return hard reference or null, if the weakly referenced interface has gone
+ */
+ inline SAL_CALL operator Reference< XInterface > () const SAL_THROW(())
+ { return get(); }
+
+ /** Releases this reference.
+
+ @since UDK 3.2.12
+ */
+ void SAL_CALL clear() SAL_THROW(());
+
+protected:
+ /// @cond INTERNAL
+ OWeakRefListener * m_pImpl;
+ /// @endcond
+};
+
+/** The WeakReference<> holds a weak reference to an object. This object must implement
+ the com::sun::star::uno::XWeak interface. The implementation is thread safe.
+
+ @tparam interface_type type of interface
+*/
+template< class interface_type >
+class WeakReference : public WeakReferenceHelper
+{
+public:
+ /** Default ctor. Creates an empty weak reference.
+ */
+ inline WeakReference() SAL_THROW(())
+ : WeakReferenceHelper()
+ {}
+
+ /** Copy ctor. Initialize this reference with a hard reference.
+
+ @param rRef another hard ref
+ */
+ inline WeakReference( const Reference< interface_type > & rRef ) SAL_THROW(())
+ : WeakReferenceHelper( rRef )
+ {}
+
+ /** Releases this reference and takes over hard reference xInt.
+ If the implementation behind xInt does not support XWeak
+ or XInt is null, then this reference is null.
+
+ @param xInt another hard reference
+
+ @since UDK 3.2.12
+ */
+ WeakReference & SAL_CALL operator = (
+ const ::com::sun::star::uno::Reference< interface_type > & xInt )
+ SAL_THROW(())
+ { WeakReferenceHelper::operator=(xInt); return *this; }
+
+ /** Gets a hard reference to the object.
+
+ @return hard reference or null, if the weakly referenced interface has gone
+ */
+ inline SAL_CALL operator Reference< interface_type > () const SAL_THROW(())
+ { return Reference< interface_type >::query( get() ); }
+};
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/conditn.h b/include/osl/conditn.h
new file mode 100644
index 000000000000..8803ee85f2dd
--- /dev/null
+++ b/include/osl/conditn.h
@@ -0,0 +1,88 @@
+/* -*- 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 _OSL_CONDITION_H_
+#define _OSL_CONDITION_H_
+
+#include "sal/config.h"
+
+#include "osl/time.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* oslCondition;
+
+typedef enum {
+ osl_cond_result_ok, /* successful completion */
+ osl_cond_result_error, /* error occurred, check osl_getLastSocketError() for details */
+ osl_cond_result_timeout, /* blocking operation timed out */
+ osl_cond_result_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslConditionResult;
+
+/** Creates a condition.
+ The condition is in the reset-state.
+ @returns 0 if condition could not be created.
+*/
+SAL_DLLPUBLIC oslCondition SAL_CALL osl_createCondition(void);
+
+/** Free the memory used by the condition.
+ @param Condition the condition handle.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_destroyCondition(oslCondition Condition);
+
+/** Sets condition to True => wait() will not block, check() returns True.
+ NOTE: ALL threads waiting on this condition are unblocked!
+ @param Condition handle to a created condition.
+ @return False if system-call failed.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setCondition(oslCondition Condition);
+
+/** Sets condition to False => wait() will block, check() returns False
+ @param Condition handle to a created condition.
+ @return False if system-call failed.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition);
+
+/** Blocks if condition is not set<BR>
+ If condition has been destroyed prematurely, wait() will
+ return with False.
+ @param Condition handle to a created condition.
+ @param pTimeout Tiemout value or NULL for infinite waiting
+ @return False if system-call failed.
+*/
+SAL_DLLPUBLIC oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const TimeValue* pTimeout);
+
+/** Queries the state of the condition without blocking.
+ @param Condition handle to a created condition.
+ @return True: condition is set. <BR>
+ False: condition is not set. <BR>
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_CONDITION_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/conditn.hxx b/include/osl/conditn.hxx
new file mode 100644
index 000000000000..449242273a7f
--- /dev/null
+++ b/include/osl/conditn.hxx
@@ -0,0 +1,121 @@
+/* -*- 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 _OSL_CONDITN_HXX_
+#define _OSL_CONDITN_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/time.h>
+
+#include <osl/conditn.h>
+
+
+namespace osl
+{
+
+ class Condition
+ {
+ public:
+
+ enum Result
+ {
+ result_ok = osl_cond_result_ok,
+ result_error = osl_cond_result_error,
+ result_timeout = osl_cond_result_timeout
+ };
+
+ /* Create a condition.
+ */
+ Condition()
+ {
+ condition = osl_createCondition();
+ }
+
+ /* Release the OS-structures and free condition data-structure.
+ */
+ ~Condition()
+ {
+ osl_destroyCondition(condition);
+ }
+
+ /* Release all waiting threads, check returns sal_True.
+ */
+ void set()
+ {
+ osl_setCondition(condition);
+ }
+
+ /* Reset condition to false: wait() will block, check() returns sal_False.
+ */
+ void reset() {
+ osl_resetCondition(condition);
+ }
+
+ /** Blocks the calling thread until condition is set.
+ */
+ Result wait(const TimeValue *pTimeout = 0)
+ {
+ return (Result) osl_waitCondition(condition, pTimeout);
+ }
+
+ /** Checks if the condition is set without blocking.
+ */
+ sal_Bool check()
+ {
+ return osl_checkCondition(condition);
+ }
+
+
+ private:
+ oslCondition condition;
+
+ /** The underlying oslCondition has no reference count.
+
+ Since the underlying oslCondition is not a reference counted object, copy
+ constructed Condition may work on an already destructed oslCondition object.
+
+ */
+ Condition(const Condition&);
+
+ /** The underlying oslCondition has no reference count.
+
+ When destructed, the Condition object destroys the undelying oslCondition,
+ which might cause severe problems in case it's a temporary object.
+
+ */
+ Condition(oslCondition condition);
+
+ /** This assignment operator is private for the same reason as
+ the copy constructor.
+ */
+ Condition& operator= (const Condition&);
+
+ /** This assignment operator is private for the same reason as
+ the constructor taking a oslCondition argument.
+ */
+ Condition& operator= (oslCondition);
+ };
+
+}
+
+#endif /* __cplusplus */
+#endif /* _OSL_CONDITN_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/diagnose.h b/include/osl/diagnose.h
new file mode 100644
index 000000000000..b3bfee91ad25
--- /dev/null
+++ b/include/osl/diagnose.h
@@ -0,0 +1,204 @@
+/* -*- 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 _OSL_DIAGNOSE_H_
+#define _OSL_DIAGNOSE_H_
+
+#include "sal/config.h"
+
+#include "sal/detail/log.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+/** provides simple diagnostic support
+
+ The facilities provided by this header are deprecated. True assertions
+ (that detect broken program logic) should use standard assert (which aborts
+ if an assertion fails, and is controlled by the standard NDEBUG macro).
+ Logging of warnings (e.g., about malformed input) and traces (e.g., about
+ steps taken while executing some protocol) should use the facilities
+ provided by (C++ only) sal/log.hxx.
+
+ Because the assertion macros (OSL_ASSERT, OSL_ENSURE, OSL_FAIL, OSL_PRECOND,
+ and OSL_POSTCOND) have been used for true assertions as well as for logged
+ warnings, they map to SAL_WARN instead of standard assert. OSL_TRACE maps
+ to SAL_INFO.
+
+ The functions defined in this header are not intended to be used directly,
+ but through defined macros. The macros can be divided into three categories:
+ assertions, traces and other stuff .-) Their usability depends on the value
+ of OSL_DEBUG_LEVEL macro: assertions are only active if OSL_DEBUG_LEVEL is 1
+ or greater, traces if OSL_DEBUG_LEVEL is 2 or greater.
+
+ Assertions (cond is bool, msg is char*):
+ OSL_ASSERT(cond)
+ If cond is false, reports an error.
+
+ OSL_ENSURE(cond, msg)
+ If cond is false, reports an error with message msg.
+
+ OSL_FAIL(msg)
+ Reports an error with message msg unconditionally.
+
+ OSL_PRECOND(cond, msg)
+ OSL_POSTCOND(cond, msg)
+ These two are functionally equivalent to OSL_ENSURE(cond, msg). They are
+ intended to be used for checking pre- and postconditions of functions.
+
+ Traces:
+ OSL_TRACE(fmt, args...)
+ Prints trace message. The arguments have the same meaning as the
+ arguments of printf.
+
+ Other:
+ OSL_VERIFY(expr)
+ Evaluates the expression and if it is false, reports an error. The
+ expression is evaluated once without regard of the value of
+ OSL_DEBUG_LEVEL.
+
+ Example:
+
+ void extractBool(Any const& rAny, bool& rBool)
+ {
+ OSL_VERIFY(rAny >>= rBool);
+ }
+
+ OSL_DEBUG_ONLY(expr)
+ */
+
+#if !defined OSL_DEBUG_LEVEL
+#define OSL_DEBUG_LEVEL 0
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* //////////////////////////////////////////////////////////////////////////
+ Diagnostic support
+*/
+
+SAL_DLLPUBLIC void SAL_CALL osl_breakDebug(void);
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const sal_Char* pszMessage);
+SAL_DLLPUBLIC void SAL_CALL osl_trace(const sal_Char* pszFormat, ...);
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszErrorMessage);
+
+/*
+ For message delivery
+*/
+
+/** a message delivery function which receives a pre-formatted message string
+*/
+typedef void (SAL_CALL *pfunc_osl_printDebugMessage)( const sal_Char * pszMessage );
+
+/** a message delivery function which receives detailed information about where the message was triggered
+*/
+typedef void (SAL_CALL *pfunc_osl_printDetailedDebugMessage)( const sal_Char * pszFileName, sal_Int32 nLine, const sal_Char* pszMessage );
+
+/** sets a message delivery function
+
+ The function set here is ignored if a function for detailed message information
+ (pfunc_osl_printDetailedDebugMessage) has been set.
+
+ The given message handler must be able to cope with a null message.
+*/
+SAL_DLLPUBLIC pfunc_osl_printDebugMessage SAL_CALL osl_setDebugMessageFunc( pfunc_osl_printDebugMessage pNewFunc );
+
+/** sets a delivery function for detailed message information.
+
+ The given message handler must be able to cope with a null message.
+*/
+SAL_DLLPUBLIC pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pfunc_osl_printDetailedDebugMessage pNewFunc );
+
+#ifdef __cplusplus
+}
+#endif
+
+#define OSL_THIS_FILE __FILE__
+
+/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now
+
+ it is deprecated and superseded by (C++ only) SAL_WHERE
+*/
+#define OSL_LOG_PREFIX SAL_DETAIL_WHERE
+
+#define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
+
+#define OSL_TRACE(...) \
+ SAL_DETAIL_INFO_IF_FORMAT(OSL_DEBUG_LEVEL > 0, "legacy.osl", __VA_ARGS__)
+
+#if OSL_DEBUG_LEVEL > 0
+#define OSL_ASSERT(c) \
+ SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "OSL_ASSERT: %s", #c)
+#define OSL_ENSURE(c, m) SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "%s", m)
+#define OSL_FAIL(m) SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)
+#else
+#define OSL_ASSERT(c) ((void) 0)
+#define OSL_ENSURE(c, m) ((void) 0)
+#define OSL_FAIL(m) ((void) 0)
+#endif
+
+#define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
+#define OSL_PRECOND(c, m) OSL_ENSURE(c, m)
+#define OSL_POSTCOND(c, m) OSL_ENSURE(c, m)
+
+
+#ifdef __cplusplus
+#define _OSL_GLOBAL ::
+#else
+#define _OSL_GLOBAL
+#endif /* __cplusplus */
+
+#if OSL_DEBUG_LEVEL > 0
+
+#define _OSL_DEBUG_ONLY(f) (f)
+
+#else
+
+#define _OSL_DEBUG_ONLY(f) ((void)0)
+
+#endif /* OSL_DEBUG_LEVEL */
+
+/* the macro OSL_THIS_FUNC is intended to be an office internal macro for now */
+/* copied from boost/current_function.hpp to make it usable from C
+ * sources as well
+ *
+ * Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt) */
+#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600))
+#define OSL_THIS_FUNC __PRETTY_FUNCTION__
+#elif defined(__DMC__) && (__DMC__ >= 0x810)
+#define OSL_THIS_FUNC __PRETTY_FUNCTION__
+#elif defined(__FUNCSIG__)
+#define OSL_THIS_FUNC __FUNCSIG__
+#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
+#define OSL_THIS_FUNC __FUNCTION__
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
+#define OSL_THIS_FUNC __func__
+#else
+#define OSL_THIS_FUNC ""
+#endif
+
+#endif /* _OSL_DIAGNOSE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/diagnose.hxx b/include/osl/diagnose.hxx
new file mode 100644
index 000000000000..bbf1fa7231c4
--- /dev/null
+++ b/include/osl/diagnose.hxx
@@ -0,0 +1,209 @@
+/* -*- 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 OSL_DIAGNOSE_HXX_INCLUDED
+#define OSL_DIAGNOSE_HXX_INCLUDED
+
+#include "sal/config.h"
+
+#include <functional>
+#include <typeinfo>
+
+#ifndef HAVE_CXX0X
+#define BOOST_NO_0X_HDR_TYPEINDEX
+#endif
+#include "boost/unordered_set.hpp"
+#include "osl/diagnose.h"
+#include "osl/interlck.h"
+#include "osl/mutex.hxx"
+#include "rtl/allocator.hxx"
+#include "rtl/instance.hxx"
+#include "sal/log.hxx"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+/// @cond INTERNAL
+
+namespace osl {
+namespace detail {
+
+struct ObjectRegistryData;
+
+} // namespace detail
+} // namespace osl
+
+extern "C" {
+
+SAL_DLLPUBLIC bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses(
+ char const* pName )
+ SAL_THROW_EXTERN_C();
+
+SAL_DLLPUBLIC bool SAL_CALL osl_detail_ObjectRegistry_checkObjectCount(
+ ::osl::detail::ObjectRegistryData const& rData, ::std::size_t nExpected )
+ SAL_THROW_EXTERN_C();
+
+SAL_DLLPUBLIC void SAL_CALL osl_detail_ObjectRegistry_registerObject(
+ ::osl::detail::ObjectRegistryData & rData, void const* pObj )
+ SAL_THROW_EXTERN_C();
+
+SAL_DLLPUBLIC void SAL_CALL osl_detail_ObjectRegistry_revokeObject(
+ ::osl::detail::ObjectRegistryData & rData, void const* pObj )
+ SAL_THROW_EXTERN_C();
+
+// These functions presumably should not be extern "C", but changing
+// that would break binary compatibility.
+#ifdef __clang__
+#pragma clang diagnostic push
+// Guard against slightly older clang versions that don't have
+// -Wreturn-type-c-linkage...
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
+#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
+#endif
+
+SAL_DLLPUBLIC ::osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex()
+ SAL_THROW_EXTERN_C();
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+} // extern "C"
+
+namespace osl {
+
+namespace detail {
+
+struct VoidPtrHash : ::std::unary_function<void const*, ::std::size_t> {
+ ::std::size_t operator()( void const* p ) const {
+ ::std::size_t const d = static_cast< ::std::size_t >(
+ reinterpret_cast< ::std::ptrdiff_t >(p) );
+ return d + (d >> 3);
+ }
+};
+
+typedef ::boost::unordered_set<void const*, VoidPtrHash, ::std::equal_to<void const*>,
+ ::rtl::Allocator<void const*> > VoidPointerSet;
+
+struct ObjectRegistryData {
+ ObjectRegistryData( ::std::type_info const& rTypeInfo )
+ : m_pName(rTypeInfo.name()), m_nCount(0), m_addresses(),
+ m_bStoreAddresses(osl_detail_ObjectRegistry_storeAddresses(m_pName)){}
+
+ char const* const m_pName;
+ oslInterlockedCount m_nCount;
+ VoidPointerSet m_addresses;
+ bool const m_bStoreAddresses;
+};
+
+template <typename T>
+class ObjectRegistry
+{
+public:
+ ObjectRegistry() : m_data( typeid(T) ) {}
+ ~ObjectRegistry() { checkObjectCount(0); }
+
+ bool checkObjectCount( ::std::size_t nExpected ) const {
+ bool const bRet = osl_detail_ObjectRegistry_checkObjectCount(
+ m_data, nExpected );
+ if (!bRet && m_data.m_bStoreAddresses) {
+ MutexGuard const guard( osl_detail_ObjectRegistry_getMutex() );
+ // following loop is for debugging purposes, iterating over map:
+ VoidPointerSet::const_iterator iPos(m_data.m_addresses.begin());
+ VoidPointerSet::const_iterator const iEnd(m_data.m_addresses.end());
+ for ( ; iPos != iEnd; ++iPos ) {
+ SAL_WARN_IF( *iPos == 0, "sal.debug", "null pointer" );
+ }
+ }
+ return bRet;
+ }
+
+ void registerObject( void const* pObj ) {
+ osl_detail_ObjectRegistry_registerObject(m_data, pObj);
+ }
+
+ void revokeObject( void const* pObj ) {
+ osl_detail_ObjectRegistry_revokeObject(m_data, pObj);
+ }
+
+private:
+ // not impl:
+ ObjectRegistry( ObjectRegistry const& );
+ ObjectRegistry const& operator=( ObjectRegistry const& );
+
+ ObjectRegistryData m_data;
+};
+
+} // namespace detail
+
+/** Helper class which indicates leaking object(s) of a particular class in
+ non-pro builds; use e.g.
+
+ <pre>
+ class MyClass : private osl::DebugBase<MyClass> {...};
+ </pre>
+
+ Using the environment variable
+
+ OSL_DEBUGBASE_STORE_ADDRESSES=MyClass;YourClass;...
+
+ you can specify a ';'-separated list of strings matching to class names
+ (or "all" for all classes), for which DebugBase stores addresses to created
+ objects instead of just counting them. This enables you to iterate over
+ leaking objects in your debugger.
+
+ @tparam InheritingClassT binds the template instance to that class
+ @attention Use at own risk.
+ For now this is just public (yet unpublished) API and may change
+ in the future!
+*/
+template <typename InheritingClassT>
+class DebugBase
+{
+public:
+#if OSL_DEBUG_LEVEL <= 0
+ static bool checkObjectCount( ::std::size_t = 0 ) { return true; }
+#else // OSL_DEBUG_LEVEL > 0
+ /** @return whether the expected number of objects is alive,
+ else this function SAL_WARNs
+ */
+ static bool checkObjectCount( ::std::size_t nExpected = 0 ) {
+ return StaticObjectRegistry::get().checkObjectCount(nExpected);
+ }
+
+protected:
+ DebugBase() {
+ StaticObjectRegistry::get().registerObject( this );
+ }
+ ~DebugBase() {
+ StaticObjectRegistry::get().revokeObject( this );
+ }
+
+private:
+ struct StaticObjectRegistry
+ : ::rtl::Static<detail::ObjectRegistry<InheritingClassT>,
+ StaticObjectRegistry> {};
+#endif
+};
+
+} // namespace osl
+
+/// @endcond
+
+#endif // ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/doublecheckedlocking.h b/include/osl/doublecheckedlocking.h
new file mode 100644
index 000000000000..64b07d46cd6c
--- /dev/null
+++ b/include/osl/doublecheckedlocking.h
@@ -0,0 +1,75 @@
+/* -*- 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 INCLUDED_OSL_DOUBLECHECKEDLOCKING_H
+#define INCLUDED_OSL_DOUBLECHECKEDLOCKING_H
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** A platform specific macro needed to make double-checked locking work.
+
+ See
+ <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>
+ for a description of double-checked locking, why it is broken, and how it
+ can be fixed. On platforms where it is necessary, this macro will expand
+ to some memory barrier instruction. On many platforms, double-checked
+ locking works as it is, though, so on those platforms this macro will be
+ empty. This is a macro instead of a (C++ inline) function to allow for
+ maximum performance in both C and C++.
+
+ If possible, use the rtl_Instance template instead of explicitly spelling
+ out the double-checked locking pattern. There are few cases where you
+ will have to spell it out explicitly (e.g., the logic of a certain
+ instance of the pattern is too complex to be mapped to the template, or
+ some compiler refuses to compile a template instantiation due to internal
+ compiler errors), though, and you should always call this macro at the
+ right places then:
+
+ static T * pInstance = 0;
+
+ T * p = pInstance;
+ if (!p)
+ {
+ Guard aGuard(aMutex);
+ p = pInstance;
+ if (!p)
+ {
+ p = ...;
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ pInstance = p;
+ }
+ }
+ else
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ return p;
+
+ One extra advantage of this macro is that it makes it easier to find all
+ places where double-checked locking is used.
+ */
+#define OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER() /* empty */
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_OSL_DOUBLECHECKEDLOCKING_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/endian.h b/include/osl/endian.h
new file mode 100644
index 000000000000..82ec1eaca7b1
--- /dev/null
+++ b/include/osl/endian.h
@@ -0,0 +1,226 @@
+/* -*- 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 _OSL_ENDIAN_H_
+#define _OSL_ENDIAN_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Determine the platform byte order as _BIG_ENDIAN, _LITTLE_ENDIAN, ...
+ */
+#ifdef _WIN32
+# if defined(_M_IX86)
+# define _LITTLE_ENDIAN
+# elif defined(_M_AMD64)
+# define _LITTLE_ENDIAN
+# elif defined(_M_MRX000)
+# define _LITTLE_ENDIAN
+# elif defined(_M_ALPHA)
+# define _LITTLE_ENDIAN
+# elif defined(_M_PPC)
+# define _LITTLE_ENDIAN
+# endif
+#endif
+
+#ifdef LINUX
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# endif
+#endif
+
+#ifdef ANDROID
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# endif
+#endif
+
+#ifdef NETBSD
+# include <machine/endian.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# undef _BIG_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# undef _LITTLE_ENDIAN
+# endif
+#endif
+
+#ifdef FREEBSD
+# include <sys/param.h>
+# include <machine/endian.h>
+#if __FreeBSD_version < 500000
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+#endif
+#endif
+
+#ifdef AIX
+# include <sys/machine.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif BYTE_ORDER == BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# endif
+#endif
+
+#ifdef SOLARIS
+# include <sys/isa_defs.h>
+#endif
+
+#ifdef MACOSX
+# include <machine/endian.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif BYTE_ORDER == BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# endif
+#endif
+
+#ifdef IOS
+# include <machine/endian.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif BYTE_ORDER == BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# endif
+#endif
+
+/** Check supported platform.
+ */
+#if !defined(_WIN32) && \
+ !defined(LINUX) && !defined(NETBSD) && \
+ !defined(AIX) && !defined(OPENBSD) && \
+ !defined(SOLARIS) && !defined(MACOSX) && !defined(FREEBSD) && \
+ !defined(DRAGONFLY) && \
+ !defined(IOS) && !defined(ANDROID)
+# error "Target platform not specified !"
+#endif
+
+
+/** Define the determined byte order as OSL_BIGENDIAN or OSL_LITENDIAN.
+ */
+#if defined _LITTLE_ENDIAN
+# define OSL_LITENDIAN
+#elif defined _BIG_ENDIAN
+# define OSL_BIGENDIAN
+#else
+# error undetermined endianess
+#endif
+
+
+/** Define macros for byte order manipulation.
+ */
+#ifndef OSL_MAKEBYTE
+# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
+#endif
+#ifndef OSL_LONIBBLE
+# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
+#endif
+#ifndef OSL_HINIBBLE
+# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
+#endif
+
+#ifndef OSL_MAKEWORD
+# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8))
+#endif
+#ifndef OSL_LOBYTE
+# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
+#endif
+#ifndef OSL_HIBYTE
+# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
+#endif
+
+#ifndef OSL_MAKEDWORD
+# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
+#endif
+#ifndef OSL_LOWORD
+# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
+#endif
+#ifndef OSL_HIWORD
+# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
+#endif
+
+
+/** Define macros for swapping between host and network byte order.
+ */
+#ifdef OSL_BIGENDIAN
+#ifndef OSL_NETWORD
+# define OSL_NETWORD(w) (sal_uInt16)(w)
+#endif
+#ifndef OSL_NETDWORD
+# define OSL_NETDWORD(d) (sal_uInt32)(d)
+#endif
+#else /* OSL_LITENDIAN */
+#ifndef OSL_NETWORD
+# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
+#endif
+#ifndef OSL_NETDWORD
+# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
+#endif
+#endif /* OSL_BIGENDIAN */
+
+
+/** Define macros for swapping between byte orders.
+ */
+#ifndef OSL_SWAPWORD
+# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
+#endif
+#ifndef OSL_SWAPDWORD
+# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_OSL_ENDIAN_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/file.h b/include/osl/file.h
new file mode 100644
index 000000000000..e8277e21ebc3
--- /dev/null
+++ b/include/osl/file.h
@@ -0,0 +1,1639 @@
+/* -*- 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 _OSL_FILE_H_
+#define _OSL_FILE_H_
+
+#include "sal/config.h"
+
+#include "osl/time.h"
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @file
+
+Main goals and usage hints
+
+The main intentention of this interface is to provide an universal portable and
+high performance access to file system issues on any operating system.<p>
+
+There are a few main goals:<p>
+
+1.The path specifications always has to be absolut. Any usage of relative path
+specifications is forbidden. Exceptions are <code>osl_getSystemPathFromFileURL</code>,
+<code>osl_getFileURLFromSystemPath</code> and <code>osl_getAbsoluteFileURL</code>. Most operating systems
+provide a "Current Directory" per process. This is the reason why relative path
+specifications can cause problems in multithreading environments.<p>
+
+2.Proprietary notations of file paths are not supported. Every path notation
+must the file URL specification. File URLs must be encoded in UTF8 and
+after that escaped. Although the URL parameter is a unicode string, the must
+contain only ASCII characters<p>
+
+3.The caller cannot get any information whether a file system is case sensitive,
+case preserving or not. The operating system implementation itself should
+determine if it can map case-insensitive paths. The case correct notation of
+a filename or file path is part of the "File Info". This case correct name
+can be used as a unique key if neccessary.<p>
+
+4. Obtaining information about files or volumes is controlled by a
+bitmask which specifies which fields are of interest. Due to performance
+issues it is not recommended to obtain information which is not needed.
+But if the operating system provides more information anyway the
+implementation can set more fields on output as were requested. It is in the
+responsibility of the caller to decide if he uses this additional information
+or not. But he should do so to prevent further unnecessary calls if the information
+is already there.<br>
+
+The input bitmask supports a flag <code>osl_FileStatus_Mask_Validate</code> which
+can be used to force retrieving uncached validated information. Setting this flag
+when calling <code>osl_getFileStatus</code> in combination with no other flag is
+a synonym for a "FileExists". This should only be done when processing a single file
+(f.e. before opening) and NEVER during enumeration of directory contents on any step
+of information processing. This would change the runtime behaviour from O(n) to
+O(n*n/2) on nearly every file system.<br>
+On Windows NT reading the contents of an directory with 7000 entries and
+getting full information about every file only takes 0.6 seconds. Specifying the
+flag <code>osl_FileStatus_Mask_Validate</code> for each entry will increase the
+time to 180 seconds (!!!).
+
+*/
+
+
+
+/* Error codes according to errno */
+
+typedef enum {
+ osl_File_E_None,
+ osl_File_E_PERM,
+ osl_File_E_NOENT,
+ osl_File_E_SRCH,
+ osl_File_E_INTR,
+ osl_File_E_IO,
+ osl_File_E_NXIO,
+ osl_File_E_2BIG,
+ osl_File_E_NOEXEC,
+ osl_File_E_BADF,
+ osl_File_E_CHILD,
+ osl_File_E_AGAIN,
+ osl_File_E_NOMEM,
+ osl_File_E_ACCES,
+ osl_File_E_FAULT,
+ osl_File_E_BUSY,
+ osl_File_E_EXIST,
+ osl_File_E_XDEV,
+ osl_File_E_NODEV,
+ osl_File_E_NOTDIR,
+ osl_File_E_ISDIR,
+ osl_File_E_INVAL,
+ osl_File_E_NFILE,
+ osl_File_E_MFILE,
+ osl_File_E_NOTTY,
+ osl_File_E_FBIG,
+ osl_File_E_NOSPC,
+ osl_File_E_SPIPE,
+ osl_File_E_ROFS,
+ osl_File_E_MLINK,
+ osl_File_E_PIPE,
+ osl_File_E_DOM,
+ osl_File_E_RANGE,
+ osl_File_E_DEADLK,
+ osl_File_E_NAMETOOLONG,
+ osl_File_E_NOLCK,
+ osl_File_E_NOSYS,
+ osl_File_E_NOTEMPTY,
+ osl_File_E_LOOP,
+ osl_File_E_ILSEQ,
+ osl_File_E_NOLINK,
+ osl_File_E_MULTIHOP,
+ osl_File_E_USERS,
+ osl_File_E_OVERFLOW,
+ osl_File_E_NOTREADY,
+ osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
+ osl_File_E_TIMEDOUT,
+ osl_File_E_NETWORK,
+ osl_File_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslFileError;
+
+typedef void *oslDirectory;
+typedef void *oslDirectoryItem;
+
+
+/** Open a directory for enumerating its contents.
+
+ @param pustrDirectoryURL [in]
+ The full qualified URL of the directory.
+
+ @param pDirectory [out]
+ On success it receives a handle used for subsequent calls by osl_getNextDirectoryItem().
+ The handle has to be released by a call to osl_closeDirectory().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOENT the specified path doesn't exist<br>
+ osl_File_E_NOTDIR the specified path is not an directory <br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_NAMETOOLONG File name too long<br>
+ osl_File_E_LOOP Too many symbolic links encountered<p>
+
+ @see osl_getNextDirectoryItem()
+ @see osl_closeDirectory()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_openDirectory(
+ rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory);
+
+
+/** Retrieve the next item of a previously opened directory.
+
+ Retrieves the next item of a previously opened directory.
+ All handles have an initial refcount of 1.
+
+ @param Directory [in]
+ A directory handle received from a previous call to osl_openDirectory().
+
+ @param pItem [out]
+ On success it receives a handle that can be used for subsequent calls to osl_getFileStatus().
+ The handle has to be released by a call to osl_releaseDirectoryItem().
+
+ @param uHint [in]
+ With this parameter the caller can tell the implementation that (s)he
+ is going to call this function uHint times afterwards. This enables the implementation to
+ get the information for more than one file and cache it until the next calls.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_NOENT no more entries in this directory<br>
+ osl_File_E_BADF invalid oslDirectory parameter<br>
+ osl_File_E_OVERFLOW the value too large for defined data type
+
+ @see osl_releaseDirectoryItem()
+ @see osl_acquireDirectoryItem()
+ @see osl_getDirectoryItem()
+ @see osl_getFileStatus()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getNextDirectoryItem(
+ oslDirectory Directory,
+ oslDirectoryItem *pItem,
+ sal_uInt32 uHint
+ );
+
+
+/** Release a directory handle.
+
+ @param Directory [in]
+ A handle received by a call to osl_openDirectory().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures<br>
+ osl_File_E_BADF invalid oslDirectory parameter<br>
+ osl_File_E_INTR the function call was interrupted<p>
+
+ @see osl_openDirectory()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_closeDirectory(
+ oslDirectory Directory);
+
+
+/** Retrieve a single directory item.
+
+ Retrieves a single directory item. The returned handle has an initial refcount of 1.
+ Due to performance issues it is not recommended to use this function while
+ enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
+
+ @param pustrFileURL [in]
+ An absolute file URL.
+
+ @param pItem [out]
+ On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
+ The handle has to be released by a call to osl_releaseDirectoryItem().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_NAMETOOLONG the file name is too long<br>
+ osl_File_E_NOTDIR a component of the path prefix of path is not a directory<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_INTR the function call was interrupted<p>
+
+ @see osl_releaseDirectoryItem()
+ @see osl_acquireDirectoryItem()
+ @see osl_getFileStatus()
+ @see osl_getNextDirectoryItem()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getDirectoryItem(
+ rtl_uString *pustrFileURL,
+ oslDirectoryItem *pItem
+ );
+
+
+/** Increase the refcount of a directory item handle.
+
+ The caller responsible for releasing the directory item handle using osl_releaseDirectoryItem().
+
+ @param Item [in]
+ A handle received by a call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getDirectoryItem()
+ @see osl_getNextDirectoryItem()
+ @see osl_releaseDirectoryItem()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_acquireDirectoryItem(
+ oslDirectoryItem Item );
+
+
+/** Decrease the refcount of a directory item handle.
+
+ Decreases the refcount of a directory item handle.
+ If the refcount reaches 0 the data associated with
+ this directory item handle will be released.
+
+ @param Item [in]
+ A handle received by a call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getDirectoryItem()
+ @see osl_getNextDirectoryItem()
+ @see osl_acquireDirectoryItem()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_releaseDirectoryItem(
+ oslDirectoryItem Item );
+
+/** Determine if two directory items point the same underlying file
+
+ The comparison is done first by URL, and then by resolving links to
+ find the target, and finally by comparing inodes on unix.
+
+ @param pItemA [in]
+ A directory handle to compare with another handle
+
+ @param pItemB [in]
+ A directory handle to compare with pItemA
+
+ @return
+ sal_True: if the items point to an identical resource<br>
+ sal_False: if the items point to a different resource, or a fatal error occured<br>
+
+ @see osl_getDirectoryItem()
+
+ @since LibreOffice 3.6
+*/
+
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_identicalDirectoryItem(
+ oslDirectoryItem pItemA,
+ oslDirectoryItem pItemB );
+
+/* File types */
+
+typedef enum {
+ osl_File_Type_Directory,
+ osl_File_Type_Volume,
+ osl_File_Type_Regular,
+ osl_File_Type_Fifo,
+ osl_File_Type_Socket,
+ osl_File_Type_Link,
+ osl_File_Type_Special,
+ osl_File_Type_Unknown
+} oslFileType;
+
+/* File attributes */
+#define osl_File_Attribute_ReadOnly 0x00000001
+#define osl_File_Attribute_Hidden 0x00000002
+#define osl_File_Attribute_Executable 0x00000010
+#define osl_File_Attribute_GrpWrite 0x00000020
+#define osl_File_Attribute_GrpRead 0x00000040
+#define osl_File_Attribute_GrpExe 0x00000080
+#define osl_File_Attribute_OwnWrite 0x00000100
+#define osl_File_Attribute_OwnRead 0x00000200
+#define osl_File_Attribute_OwnExe 0x00000400
+#define osl_File_Attribute_OthWrite 0x00000800
+#define osl_File_Attribute_OthRead 0x00001000
+#define osl_File_Attribute_OthExe 0x00002000
+
+/* Flags specifying which fields to retrieve by osl_getFileStatus */
+
+#define osl_FileStatus_Mask_Type 0x00000001
+#define osl_FileStatus_Mask_Attributes 0x00000002
+#define osl_FileStatus_Mask_CreationTime 0x00000010
+#define osl_FileStatus_Mask_AccessTime 0x00000020
+#define osl_FileStatus_Mask_ModifyTime 0x00000040
+#define osl_FileStatus_Mask_FileSize 0x00000080
+#define osl_FileStatus_Mask_FileName 0x00000100
+#define osl_FileStatus_Mask_FileURL 0x00000200
+#define osl_FileStatus_Mask_LinkTargetURL 0x00000400
+#define osl_FileStatus_Mask_All 0x7FFFFFFF
+#define osl_FileStatus_Mask_Validate 0x80000000
+
+
+typedef
+
+/** Structure containing information about files and directories
+
+ @see osl_getFileStatus()
+ @see oslFileType
+*/
+
+struct _oslFileStatus {
+/** Must be initialized with the size in bytes of the structure before passing it to any function */
+ sal_uInt32 uStructSize;
+/** Determines which members of the structure contain valid data */
+ sal_uInt32 uValidFields;
+/** The type of the file (file, directory, volume). */
+ oslFileType eType;
+/** File attributes */
+ sal_uInt64 uAttributes;
+/** First creation time in nanoseconds since 1/1/1970. Can be the last modify time depending on
+ platform or file system. */
+ TimeValue aCreationTime;
+/** Last access time in nanoseconds since 1/1/1970. Can be the last modify time depending on
+ platform or file system. */
+ TimeValue aAccessTime;
+/** Last modify time in nanoseconds since 1/1/1970. */
+ TimeValue aModifyTime;
+/** Size in bytes of the file. Zero for directories and volumes. */
+ sal_uInt64 uFileSize;
+/** Case correct name of the file. Should be set to zero before calling <code>osl_getFileStatus</code>
+ and released after usage. */
+ rtl_uString *ustrFileName;
+/** Full URL of the file. Should be set to zero before calling <code>osl_getFileStatus</code>
+ and released after usage. */
+ rtl_uString *ustrFileURL;
+/** Full URL of the target file if the file itself is a link.
+ Should be set to zero before calling <code>osl_getFileStatus</code>
+ and released after usage. */
+ rtl_uString *ustrLinkTargetURL;
+} oslFileStatus;
+
+
+/** Retrieve information about a single file or directory.
+
+ @param Item [in]
+ A handle received by a previous call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
+
+ @param pStatus [in|out]
+ Points to a structure which receives the information of the file or directory
+ represented by the handle Item. The member uStructSize has to be initialized to
+ sizeof(oslFileStatus) before calling this function.
+
+ @param uFieldMask [in]
+ Specifies which fields of the structure pointed to by pStatus are of interest to the caller.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_BADF invalid oslDirectoryItem parameter<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_OVERFLOW value too large for defined data type<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_NXIO no such device or address<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_NOSYS function not implemented<p>
+
+ @see osl_getDirectoryItem()
+ @see osl_getNextDirectoryItem()
+ @see oslFileStatus
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFileStatus(
+ oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask );
+
+
+typedef void *oslVolumeDeviceHandle;
+
+/** Release a volume device handle.
+
+ Releases the given oslVolumeDeviceHandle which was acquired by a call to
+ osl_getVolumeInformation() or osl_acquireVolumeDeviceHandle().
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @return
+ osl_File_E_None on success<br>
+
+ @todo
+ specify all error codes that may be returned
+
+ @see osl_acquireVolumeDeviceHandle()
+ @see osl_getVolumeInformation()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_releaseVolumeDeviceHandle(
+ oslVolumeDeviceHandle Handle );
+
+/** Acquire a volume device handle.
+
+ Acquires the given oslVolumeDeviceHandle which was acquired by a call to
+ osl_getVolumeInformation(). The caller is responsible for releasing the
+ acquired handle by calling osl_releaseVolumeDeviceHandle().
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @return
+ osl_File_E_None on success<br>
+
+ @todo
+ specify all error codes that may be returned
+
+ @see osl_getVolumeInformation()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_acquireVolumeDeviceHandle(
+ oslVolumeDeviceHandle Handle );
+
+
+/** Get the full qualified URL where a device is mounted to.
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @param ppustrDirectoryURL [out]
+ Receives the full qualified URL where the device is mounted to.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NXIO no such device or address<br>
+ osl_File_E_NODEV no such device<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_FAULT bad address<br>
+ osl_FilE_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_EOVERFLOW value too large for defined data type<br>
+
+ @see osl_getVolumeInformation()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getVolumeDeviceMountPath(
+ oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL);
+
+/* Volume attributes */
+
+#define osl_Volume_Attribute_Removeable 0x00000001L
+#define osl_Volume_Attribute_Remote 0x00000002L
+#define osl_Volume_Attribute_CompactDisc 0x00000004L
+#define osl_Volume_Attribute_FixedDisk 0x00000008L
+#define osl_Volume_Attribute_RAMDisk 0x00000010L
+#define osl_Volume_Attribute_FloppyDisk 0x00000020L
+
+#define osl_Volume_Attribute_Case_Is_Preserved 0x00000040L
+#define osl_Volume_Attribute_Case_Sensitive 0x00000080L
+
+/* Flags specifying which fields to retrieve by osl_getVolumeInfo */
+
+#define osl_VolumeInfo_Mask_Attributes 0x00000001L
+#define osl_VolumeInfo_Mask_TotalSpace 0x00000002L
+#define osl_VolumeInfo_Mask_UsedSpace 0x00000004L
+#define osl_VolumeInfo_Mask_FreeSpace 0x00000008L
+#define osl_VolumeInfo_Mask_MaxNameLength 0x00000010L
+#define osl_VolumeInfo_Mask_MaxPathLength 0x00000020L
+#define osl_VolumeInfo_Mask_FileSystemName 0x00000040L
+#define osl_VolumeInfo_Mask_DeviceHandle 0x00000080L
+#define osl_VolumeInfo_Mask_FileSystemCaseHandling 0x00000100L
+
+typedef
+
+/** Structure containing information about volumes
+
+ @see osl_getVolumeInformation()
+ @see oslFileType
+*/
+
+struct _oslVolumeInfo {
+/** Must be initialized with the size in bytes of the structure before passing it to any function */
+ sal_uInt32 uStructSize;
+/** Determines which members of the structure contain valid data */
+ sal_uInt32 uValidFields;
+/** Attributes of the volume (remote and/or removable) */
+ sal_uInt32 uAttributes;
+/** Total availiable space on the volume for the current process/user */
+ sal_uInt64 uTotalSpace;
+/** Used space on the volume for the current process/user */
+ sal_uInt64 uUsedSpace;
+/** Free space on the volume for the current process/user */
+ sal_uInt64 uFreeSpace;
+/** Maximum length of file name of a single item */
+ sal_uInt32 uMaxNameLength;
+/** Maximum length of a full quallified path in system notation */
+ sal_uInt32 uMaxPathLength;
+/** Points to a string that receives the name of the file system type. String should be set to zero before calling <code>osl_getVolumeInformation</code>
+ and released after usage. */
+ rtl_uString *ustrFileSystemName;
+/** Pointer to handle the receives underlying device. Handle should be set to zero before calling <code>osl_getVolumeInformation</code>*/
+ oslVolumeDeviceHandle *pDeviceHandle;
+} oslVolumeInfo;
+
+
+/** Retrieve information about a volume.
+
+ Retrieves information about a volume. A volume can either be a mount point, a network
+ resource or a drive depending on Operating System and File System. Before calling this
+ function osl_getFileStatus() should be called to determine if the type is
+ osl_file_Type_Volume.
+
+ @param pustrDirectoryURL [in]
+ Full qualified URL of the volume
+
+ @param pInfo [out]
+ On success it receives information about the volume.
+
+ @param uFieldMask [in]
+ Specifies which members of the structure should be filled
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ ols_File_E_FAULT Bad address<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_NOSYS function not implemented<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_INTR function call was interrupted<br>
+
+ @see osl_getFileStatus()
+ @see oslVolumeInfo
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getVolumeInformation(
+ rtl_uString *pustrDirectoryURL,
+ oslVolumeInfo *pInfo,
+ sal_uInt32 uFieldMask );
+
+typedef void *oslFileHandle;
+
+/* Open flags */
+
+#define osl_File_OpenFlag_Read 0x00000001L
+#define osl_File_OpenFlag_Write 0x00000002L
+#define osl_File_OpenFlag_Create 0x00000004L
+#define osl_File_OpenFlag_NoLock 0x00000008L
+/* larger bit-fields reserved for internal use cf. detail/file.h */
+
+/** Open a regular file.
+
+ Open a file. Only regular files can be openend.
+
+ @param pustrFileURL [in]
+ The full qualified URL of the file to open.
+
+ @param pHandle [out]
+ On success it receives a handle to the open file.
+
+ @param uFlags [in]
+ Specifies the open mode.
+
+ On Android, if the file path is below the /assets folder, the file
+ exists only as a hopefully uncompressed element inside the app
+ package (.apk), which has been mapped into memory as a whole by
+ the LibreOffice Android bootstrapping code. So files "opened" from
+ there aren't actually files in the OS sense.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NAMETOOLONG pathname was too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_AGAIN a write lock could not be established<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NXIO no such device or address<br>
+ osl_File_E_NODEV no such device<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_TXTBSY text file busy<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_DQUOT quota exceeded<br>
+ osl_File_E_EXIST file exists<br>
+ osl_FilE_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_EOVERFLOW value too large for defined data type<br>
+
+ @see osl_closeFile()
+ @see osl_setFilePos()
+ @see osl_getFilePos()
+ @see osl_readFile()
+ @see osl_writeFile()
+ @see osl_setFileSize()
+ @see osl_getFileSize()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_openFile(
+ rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags );
+
+#define osl_Pos_Absolut 1
+#define osl_Pos_Current 2
+#define osl_Pos_End 3
+
+/** Set the internal position pointer of an open file.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param uHow [in]
+ Distance to move the internal position pointer (from uPos).
+
+ @param uPos [in]
+ Absolute position from the beginning of the file.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_getFilePos()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFilePos(
+ oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT;
+
+
+/** Retrieve the current position of the internal pointer of an open file.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pPos [out]
+ On success receives the current position of the file pointer.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_setFilePos()
+ @see osl_readFile()
+ @see osl_writeFile()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFilePos(
+ oslFileHandle Handle, sal_uInt64 *pPos );
+
+
+/** Set the file size of an open file.
+
+ Sets the file size of an open file. The file can be truncated or enlarged by the function.
+ The position of the file pointer is not affeced by this function.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param uSize [in]
+ New size in bytes.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_setFilePos()
+ @see osl_getFileStatus()
+ @see osl_getFileSize()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFileSize(
+ oslFileHandle Handle, sal_uInt64 uSize );
+
+
+/** Get the file size of an open file.
+
+ Gets the file size of an open file.
+ The position of the file pointer is not affeced by this function.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pSize [out]
+ Current size in bytes.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_setFilePos()
+ @see osl_getFileStatus()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFileSize(
+ oslFileHandle Handle, sal_uInt64 *pSize );
+
+
+/** Map flags.
+
+ @since UDK 3.2.10
+ */
+#define osl_File_MapFlag_RandomAccess ((sal_uInt32)(0x1))
+
+/** Map flag denoting that the mapped address space will be accessed by the
+ process soon (and it is advantageous for the operating system to already
+ start paging in the data).
+
+ @since UDK 3.2.12
+ */
+#define osl_File_MapFlag_WillNeed ((sal_uInt32)(0x2))
+
+/** Map a shared file into memory.
+
+ Don't know what the "shared" is supposed to mean there? Also,
+ obviously this API can be used to map *part* of a file into
+ memory, and different parts can be mapped separately even.
+
+ On Android, if the Handle refers to a file that is actually inside
+ the app package (.apk zip archive), no new mapping is created,
+ just a pointer to the file inside the already mapped .apk is
+ returned.
+
+ @since UDK 3.2.10
+ */
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_mapFile (
+ oslFileHandle Handle,
+ void** ppAddr,
+ sal_uInt64 uLength,
+ sal_uInt64 uOffset,
+ sal_uInt32 uFlags
+);
+
+
+#ifndef ANDROID
+
+/** Unmap a shared file from memory.
+
+ Ditto here, why do we need to mention "shared"?
+
+ This function just won't work on Android in general where for
+ (uncompressed) files inside the .apk, per SDK conventions in the
+ /assets folder, osl_mapFile() returns a pointer to the file inside
+ the already by LibreOffice Android-specific bootstrapping code
+ mmapped .apk archive. We can't go and randomly munmap part of the
+ .apk archive. So this function is not present on Android.
+
+ @since UDK 3.2.10
+ */
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_unmapFile (
+ void* pAddr,
+ sal_uInt64 uLength
+);
+
+#endif
+
+/** Unmap a file segment from memory.
+
+ Like osl_unmapFile(), but takes also the oslFileHandle argument
+ passed to osl_mapFile() when creating this mapping.
+
+ On Android, for files below /assets, i.e. located inside the app
+ archive (.apk), this won't actually unmap anything; all the .apk
+ stays mapped.
+
+ @since UDK 3.6
+ */
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_unmapMappedFile (
+ oslFileHandle Handle,
+ void* pAddr,
+ sal_uInt64 uLength
+);
+
+
+/** Read a number of bytes from a file.
+
+ Reads a number of bytes from a file. The internal file pointer is
+ increased by the number of bytes read.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pBuffer [out]
+ Points to a buffer which receives data. The buffer must be large enough
+ to hold uBytesRequested bytes.
+
+ @param uBytesRequested [in]
+ Number of bytes which should be retrieved.
+
+ @param pBytesRead [out]
+ On success the number of bytes which have actually been retrieved.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_openFile()
+ @see osl_writeFile()
+ @see osl_readLine()
+ @see osl_setFilePos()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_readFile(
+ oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead );
+
+
+/** Test if the end of a file is reached.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pIsEOF [out]
+ Points to a variable that receives the end-of-file status.
+
+ @return
+ osl_File_E_None on success <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_NOLINK link has been severed<p>
+
+ @see osl_openFile()
+ @see osl_readFile()
+ @see osl_readLine()
+ @see osl_setFilePos()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_isEndOfFile(
+ oslFileHandle Handle, sal_Bool *pIsEOF );
+
+
+/** Write a number of bytes to a file.
+
+ Writes a number of bytes to a file.
+ The internal file pointer is increased by the number of bytes read.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pBuffer [in]
+ Points to a buffer which contains the data.
+
+ @param uBytesToWrite [in]
+ Number of bytes which should be written.
+
+ @param pBytesWritten [out]
+ On success the number of bytes which have actually been written.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_FBIG file too large<br>
+ osl_File_E_DQUOT quota exceeded<p>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errosr<br>
+ osl_File_E_NOLCK no record locks available<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_NXIO no such device or address<br>
+
+ @see osl_openFile()
+ @see osl_readFile()
+ @see osl_setFilePos()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_writeFile(
+ oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten );
+
+/** Read a number of bytes from a specified offset in a file.
+
+ The current position of the internal file pointer may or may not be changed.
+
+ @since UDK 3.2.10
+ */
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_readFileAt(
+ oslFileHandle Handle,
+ sal_uInt64 uOffset,
+ void* pBuffer,
+ sal_uInt64 uBytesRequested,
+ sal_uInt64* pBytesRead
+);
+
+
+/** Write a number of bytes to a specified offset in a file.
+
+ The current position of the internal file pointer may or may not be changed.
+
+ @since UDK 3.2.10
+ */
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_writeFileAt(
+ oslFileHandle Handle,
+ sal_uInt64 uOffset,
+ const void* pBuffer,
+ sal_uInt64 uBytesToWrite,
+ sal_uInt64* pBytesWritten
+);
+
+
+/** Read a line from a file.
+
+ Reads a line from a file. The new line delimiter is NOT returned!
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param ppSequence [in/out]
+ A pointer pointer to a sal_Sequence that will hold the line read on success.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_NOLINK link has been severed<p>
+
+ @see osl_openFile()
+ @see osl_readFile()
+ @see osl_writeFile()
+ @see osl_setFilePos()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_readLine(
+ oslFileHandle Handle, sal_Sequence** ppSequence );
+
+/** Synchronize the memory representation of a file with that on the physical medium.
+
+ The function ensures that all modified data and attributes of the file associated with
+ the given file handle have been written to the physical medium.
+ In case the hard disk has a write cache enabled, the data may not really be on
+ permanent storage when osl_syncFile returns.
+
+ @param Handle
+ [in] Handle to a file received by a previous call to osl_openFile().
+
+ @return
+ <dl>
+ <dt>osl_File_E_None</dt>
+ <dd>On success</dd>
+ <dt>osl_File_E_INVAL</dt>
+ <dd>The value of the input parameter is invalid</dd>
+ </dl>
+ <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
+ <dl>
+ <dt>osl_File_E_BADF</dt>
+ <dd>The file associated with the given file handle is not open for writing</dd>
+ <dt>osl_File_E_IO</dt>
+ <dd>An I/O error occurred</dd>
+ <dt>osl_File_E_NOSPC</dt>
+ <dd>There is no enough space on the target device</dd>
+ <dt>osl_File_E_ROFS</dt>
+ <dd>The file associated with the given file handle is located on a read only file system</dd>
+ <dt>osl_File_E_TIMEDOUT</dt>
+ <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
+ </dl>
+
+ @see osl_openFile()
+ @see osl_writeFile()
+*/
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_syncFile( oslFileHandle Handle );
+
+/** Close an open file.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_BADF Bad file<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_IO on I/O errors<br>
+
+ @see osl_openFile()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_closeFile( oslFileHandle Handle );
+
+
+/** Create a directory.
+
+ @param pustrDirectoryURL [in]
+ Full qualified URL of the directory to create.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_EXIST file exists<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_DQUOT quota exceeded<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_FAULT bad address<br>
+ osl_FileE_IO on I/O errors<br>
+ osl_File_E_MLINK too many links<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_removeDirectory()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_createDirectory( rtl_uString* pustrDirectoryURL );
+
+
+/** Remove an empty directory.
+
+ @param pustrDirectoryURL [in]
+ Full qualified URL of the directory.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NOTEMPTY directory not empty<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_BUSY device or resource busy<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_BUSY device or resource busy<br>
+ osl_File_E_EXIST file exists<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_createDirectory()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_removeDirectory( rtl_uString* pustrDirectoryURL );
+
+/** Function pointer representing a function that will be called by osl_createDirectoryPath
+ if a directory has been created.
+
+ To avoid unpredictable results the callee must not access the directory whose
+ creation is just notified.
+
+ @param pData
+ [in] User specified data given in osl_createDirectoryPath.
+
+ @param aDirectoryUrl
+ [in] The absolute file URL of the directory that was just created by
+ osl_createDirectoryPath.
+
+ @see osl_createDirectoryPath
+*/
+typedef void (SAL_CALL *oslDirectoryCreationCallbackFunc)(void* pData, rtl_uString* aDirectoryUrl);
+
+/** Create a directory path.
+
+ The osl_createDirectoryPath function creates a specified directory path.
+ All nonexisting sub directories will be created.
+ <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
+ osl_File_E_EXIST for existing directories. Programming against this error
+ code is in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
+
+ @param aDirectoryUrl
+ [in] The absolute file URL of the directory path to create.
+ A relative file URL will not be accepted.
+
+ @param aDirectoryCreationCallbackFunc
+ [in] Pointer to a function that will be called synchronously
+ for each sub directory that was created. The value of this
+ parameter may be NULL, in this case notifications will not be
+ sent.
+
+ @param pData
+ [in] User specified data to be passed to the directory creation
+ callback function. The value of this parameter may be arbitrary
+ and will not be interpreted by osl_createDirectoryPath.
+
+ @return
+ <dl>
+ <dt>osl_File_E_None</dt>
+ <dd>On success</dd>
+ <dt>osl_File_E_INVAL</dt>
+ <dd>The format of the parameters was not valid</dd>
+ <dt>osl_File_E_ACCES</dt>
+ <dd>Permission denied</dd>
+ <dt>osl_File_E_EXIST</dt>
+ <dd>The final node of the specified directory path already exist</dd>
+ <dt>osl_File_E_NAMETOOLONG</dt>
+ <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
+ <dt>osl_File_E_NOTDIR</dt>
+ <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
+ <dt>osl_File_E_ROFS</dt>
+ <dd>Read-only file system</dd>
+ <dt>osl_File_E_NOSPC</dt>
+ <dd>No space left on device</dd>
+ <dt>osl_File_E_DQUOT</dt>
+ <dd>Quota exceeded</dd>
+ <dt>osl_File_E_FAULT</dt>
+ <dd>Bad address</dd>
+ <dt>osl_File_E_IO</dt>
+ <dd>I/O error</dd>
+ <dt>osl_File_E_LOOP</dt>
+ <dd>Too many symbolic links encountered</dd>
+ <dt>osl_File_E_NOLINK</dt>
+ <dd>Link has been severed</dd>
+ <dt>osl_File_E_invalidError</dt>
+ <dd>An unknown error occurred</dd>
+ </dl>
+
+ @see oslDirectoryCreationFunc
+ @see oslFileError
+ @see osl_createDirectory
+*/
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_createDirectoryPath(
+ rtl_uString* aDirectoryUrl,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData);
+
+/** Remove a regular file.
+
+ @param pustrFileURL [in]
+ Full qualified URL of the file to remove.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_BUSY device or resource busy<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_TXTBSY text file busy<br>
+
+ @see osl_openFile()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_removeFile(
+ rtl_uString* pustrFileURL );
+
+
+/** Copy a file to a new destination.
+
+ Copies a file to a new destination. Copies only files not directories.
+ No assumptions should be made about preserving attributes or file time.
+
+ @param pustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param pustrDestFileURL [in]
+ Full qualified URL of the destination file. A directory is NOT a valid destination file!
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_ROFS read-only file system<p>
+
+ @see osl_moveFile()
+ @see osl_removeFile()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_copyFile(
+ rtl_uString* pustrSourceFileURL, rtl_uString *pustrDestFileURL );
+
+
+/** Move a file or directory to a new destination or renames it.
+
+ Moves a file or directory to a new destination or renames it.
+ File time and attributes are preserved.
+
+ @param pustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param pustrDestFileURL [in]
+ Full qualified URL of the destination file. An existing directory is NOT a valid destination !
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ROFS read-only file system<br>
+
+ @see osl_copyFile()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_moveFile(
+ rtl_uString* pustrSourceFileURL, rtl_uString *pustrDestFileURL );
+
+
+/** Determine a valid unused canonical name for a requested name.
+
+ Determines a valid unused canonical name for a requested name.
+ Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
+ If a file or directory with the requested name already exists a new name is generated following
+ the common rules on the actual Operating System and File System.
+
+ @param pustrRequestedURL [in]
+ Requested name of a file or directory.
+
+ @param ppustrValidURL [out]
+ On success receives a name which is unused and valid on the actual Operating System and
+ File System.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getFileStatus()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getCanonicalName(
+ rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL);
+
+
+/** Convert a path relative to a given directory into an full qualified file URL.
+
+ Convert a path relative to a given directory into an full qualified file URL.
+ The function resolves symbolic links if possible and path ellipses, so on success
+ the resulting absolute path is fully resolved.
+
+ @param pustrBaseDirectoryURL [in]
+ Base directory URL to which the relative path is related to.
+
+ @param pustrRelativeFileURL [in]
+ An URL of a file or directory relative to the directory path specified by pustrBaseDirectoryURL
+ or an absolute path.
+ If pustrRelativeFileURL denotes an absolute path pustrBaseDirectoryURL will be ignored.
+
+ @param ppustrAbsoluteFileURL [out]
+ On success it receives the full qualified absoulte file URL.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_OVERFLOW value too large for defined data type<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_getFileStatus()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getAbsoluteFileURL(
+ rtl_uString* pustrBaseDirectoryURL,
+ rtl_uString *pustrRelativeFileURL,
+ rtl_uString **ppustrAbsoluteFileURL );
+
+
+/** Convert a system dependend path into a file URL.
+
+ @param pustrSystemPath [in]
+ A System dependent path of a file or directory.
+
+ @param ppustrFileURL [out]
+ On success it receives the file URL.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getSystemPathFromFileURL()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFileURLFromSystemPath(
+ rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL);
+
+
+/** Searche a full qualified system path or a file URL.
+
+ @param pustrFileName [in]
+ A system dependent path, a file URL, a file or relative directory.
+
+ @param pustrSearchPath [in]
+ A list of system paths, in which a given file has to be searched. The Notation of a path list is
+ system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
+ These paths are only for the search of a file or a relative path, otherwise it will be ignored.
+ If pustrSearchPath is NULL or while using the search path the search failed, the function searches for
+ a matching file in all system directories and in the directories listed in the PATH environment
+ variable.
+ The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
+ aware of the Operating System and so doesn't know which path list delimiter to use.
+
+ @param ppustrFileURL [out]
+ On success it receives the full qualified file URL.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NOENT no such file or directory not found<br>
+
+ @see osl_getFileURLFromSystemPath()
+ @see osl_getSystemPathFromFileURL()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_searchFileURL(
+ rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL );
+
+
+/** Convert a file URL into a system dependend path.
+
+ @param pustrFileURL [in]
+ A File URL.
+
+ @param ppustrSystemPath [out]
+ On success it receives the system path.
+
+ @return
+ osl_File_E_None on success
+ osl_File_E_INVAL the format of the parameters was not valid
+
+ @see osl_getFileURLFromSystemPath()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getSystemPathFromFileURL(
+ rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath);
+
+
+/** Function pointer representing the function called back from osl_abbreviateSystemPath
+
+ @param ustrText [in]
+ Text to calculate the width for
+
+ @return
+ The width of the text specified by ustrText, e.g. it can return the width in pixel
+ or the width in character count.
+
+ @see osl_abbreviateSystemPath()
+*/
+
+typedef sal_uInt32 (SAL_CALL *oslCalcTextWidthFunc)( rtl_uString *ustrText );
+
+
+/** Abbreviate a system notation path.
+
+ @param ustrSystemPath [in]
+ The full system path to abbreviate
+
+ @param pustrCompacted [out]
+ Receives the compacted system path on output
+
+ @param pCalcWidth [in]
+ Function ptr that calculates the width of a string. Can be zero.
+
+ @param uMaxWidth [in]
+ Maximum width allowed that is retunrned from pCalcWidth.
+ If pCalcWidth is zero the character count is assumed as width.
+
+ @return
+ osl_File_E_None on success<br>
+
+ @see oslCalcTextWidthFunc
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_abbreviateSystemPath(
+ rtl_uString *ustrSystemPath,
+ rtl_uString **pustrCompacted,
+ sal_uInt32 uMaxWidth,
+ oslCalcTextWidthFunc pCalcWidth );
+
+
+/** Set file attributes.
+
+ @param pustrFileURL [in]
+ The full qualified file URL.
+
+ @param uAttributes [in]
+ Attributes of the file to be set.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getFileStatus()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFileAttributes(
+ rtl_uString *pustrFileURL, sal_uInt64 uAttributes );
+
+
+/** Set the file time.
+
+ @param pustrFileURL [in]
+ The full qualified URL of the file.
+
+ @param aCreationTime [in]
+ Creation time of the given file.
+
+ @param aLastAccessTime [in]
+ Time of the last access of the given file.
+
+ @param aLastWriteTime [in]
+ Time of the last modifying of the given file.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOENT no such file or directory not found<br>
+
+ @see osl_getFileStatus()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFileTime(
+ rtl_uString *pustrFileURL,
+ const TimeValue *aCreationTime,
+ const TimeValue *aLastAccessTime,
+ const TimeValue *aLastWriteTime);
+
+
+/** Retrieves the file URL of the system's temporary directory path
+
+ @param[out] pustrTempDirURL
+ On success receives the URL of system's temporary directory path.
+
+ @return
+ osl_File_E_None on success
+ osl_File_E_NOENT no such file or directory not found
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_getTempDirURL(
+ rtl_uString **pustrTempDirURL );
+
+
+/** Creates a temporary file in the directory provided by the caller or the
+ directory returned by osl_getTempDirURL.
+
+ Creates a temporary file in the directory provided by the caller or the
+ directory returned by osl_getTempDirURL.
+ Under UNIX Operating Systems the file will be created with read and write
+ access for the user exclusively.
+ If the caller requests only a handle to the open file but not the name of
+ it, the file will be automatically removed on close else the caller is
+ responsible for removing the file on success.
+
+ Description of the different pHandle, ppustrTempFileURL parameter combinations.
+ pHandle is 0 and ppustrTempDirURL is 0 - this combination is invalid
+ pHandle is not 0 and ppustrTempDirURL is 0 - a handle to the open file
+ will be returned on success and the file will be automatically removed on close.
+ pHandle is 0 and ppustrTempDirURL is not 0 - the name of the file will be returned,
+ the caller is responsible for opening, closing and removing the file.
+ pHandle is not 0 and ppustrTempDirURL is not 0 - a handle to the open file as well as
+ the file name will be returned, the caller is responsible for closing and removing
+ the file.
+
+ @param pustrDirectoryURL [in]
+ Specifies the full qualified URL where the temporary file should be created.
+ If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
+
+ @param pHandle [out]
+ On success receives a handle to the open file. If pHandle is 0 the file will
+ be closed on return, in this case ppustrTempFileURL must not be 0.
+
+ @param ppustrTempFileURL [out]
+ On success receives the full qualified URL of the temporary file.
+ If ppustrTempFileURL is 0 the file will be automatically removed on close,
+ in this case pHandle must not be 0.
+ If ppustrTempFileURL is not 0 the caller receives the name of the created
+ file and is responsible for removing the file, in this case
+ *ppustrTempFileURL must be 0 or must point to a valid rtl_uString.
+
+ @return
+ osl_File_E_None on success
+ osl_File_E_INVAL the format of the parameter is invalid
+ osl_File_E_NOMEM not enough memory for allocating structures
+ osl_File_E_ACCES Permission denied
+ osl_File_E_NOENT No such file or directory
+ osl_File_E_NOTDIR Not a directory
+ osl_File_E_ROFS Read-only file system
+ osl_File_E_NOSPC No space left on device
+ osl_File_E_DQUOT Quota exceeded
+
+ @see osl_getTempDirURL()
+*/
+
+SAL_DLLPUBLIC oslFileError SAL_CALL osl_createTempFile(
+ rtl_uString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ rtl_uString** ppustrTempFileURL);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_FILE_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/file.hxx b/include/osl/file.hxx
new file mode 100644
index 000000000000..ee52cd570840
--- /dev/null
+++ b/include/osl/file.hxx
@@ -0,0 +1,1979 @@
+/* -*- 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 _OSL_FILE_HXX_
+#define _OSL_FILE_HXX_
+
+#include "sal/config.h"
+
+#include <string.h>
+
+#include <cassert>
+
+#include <osl/time.h>
+#include <rtl/ustring.hxx>
+
+#include <osl/file.h>
+#include <rtl/byteseq.hxx>
+
+#include <stdio.h>
+
+namespace osl
+{
+
+
+// -----------------------------------------------------------------------------
+/** Base class for all File System specific objects.
+
+ @see Directory
+ @see DirectoryItem
+ @see File
+ */
+
+class FileBase
+{
+public:
+
+ enum RC {
+ E_None = osl_File_E_None,
+ E_PERM = osl_File_E_PERM,
+ E_NOENT = osl_File_E_NOENT,
+ E_SRCH = osl_File_E_SRCH,
+ E_INTR = osl_File_E_INTR,
+ E_IO = osl_File_E_IO,
+ E_NXIO = osl_File_E_NXIO,
+ E_2BIG = osl_File_E_2BIG,
+ E_NOEXEC = osl_File_E_NOEXEC,
+ E_BADF = osl_File_E_BADF,
+ E_CHILD = osl_File_E_CHILD,
+ E_AGAIN = osl_File_E_AGAIN,
+ E_NOMEM = osl_File_E_NOMEM,
+ E_ACCES = osl_File_E_ACCES,
+ E_FAULT = osl_File_E_FAULT,
+ E_BUSY = osl_File_E_BUSY,
+ E_EXIST = osl_File_E_EXIST,
+ E_XDEV = osl_File_E_XDEV,
+ E_NODEV = osl_File_E_NODEV,
+ E_NOTDIR = osl_File_E_NOTDIR,
+ E_ISDIR = osl_File_E_ISDIR,
+ E_INVAL = osl_File_E_INVAL,
+ E_NFILE = osl_File_E_NFILE,
+ E_MFILE = osl_File_E_MFILE,
+ E_NOTTY = osl_File_E_NOTTY,
+ E_FBIG = osl_File_E_FBIG,
+ E_NOSPC = osl_File_E_NOSPC,
+ E_SPIPE = osl_File_E_SPIPE,
+ E_ROFS = osl_File_E_ROFS,
+ E_MLINK = osl_File_E_MLINK,
+ E_PIPE = osl_File_E_PIPE,
+ E_DOM = osl_File_E_DOM,
+ E_RANGE = osl_File_E_RANGE,
+ E_DEADLK = osl_File_E_DEADLK,
+ E_NAMETOOLONG = osl_File_E_NAMETOOLONG,
+ E_NOLCK = osl_File_E_NOLCK,
+ E_NOSYS = osl_File_E_NOSYS,
+ E_NOTEMPTY = osl_File_E_NOTEMPTY,
+ E_LOOP = osl_File_E_LOOP,
+ E_ILSEQ = osl_File_E_ILSEQ,
+ E_NOLINK = osl_File_E_NOLINK,
+ E_MULTIHOP = osl_File_E_MULTIHOP,
+ E_USERS = osl_File_E_USERS,
+ E_OVERFLOW = osl_File_E_OVERFLOW,
+ E_NOTREADY = osl_File_E_NOTREADY,
+ E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
+ E_TIMEDOUT = osl_File_E_TIMEDOUT,
+ E_NETWORK = osl_File_E_NETWORK
+ };
+
+
+public:
+
+ /** Determine a valid unused canonical name for a requested name.
+
+ Determines a valid unused canonical name for a requested name.
+ Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
+ If a file or directory with the requested name already exists a new name is generated following
+ the common rules on the actual Operating System and File System.
+
+ @param ustrRequestedURL [in]
+ Requested name of a file or directory.
+
+ @param ustrValidURL [out]
+ On success receives a name which is unused and valid on the actual Operating System and
+ File System.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see DirectoryItem::getFileStatus()
+ */
+
+ static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
+ {
+ return (RC) osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData );
+ }
+
+ /** Convert a path relative to a given directory into an full qualified file URL.
+
+ Convert a path relative to a given directory into an full qualified file URL.
+ The function resolves symbolic links if possible and path ellipses, so on success
+ the resulting absolute path is fully resolved.
+
+ @param ustrBaseDirectoryURL [in]
+ Base directory URL to which the relative path is related to.
+
+ @param ustrRelativeFileURL [in]
+ An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
+ or an absolute path.
+ If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
+
+ @param ustrAbsoluteFileURL [out]
+ On success it receives the full qualified absoulte file URL.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_NOTDIR not a directory
+ E_ACCES permission denied
+ E_NOENT no such file or directory
+ E_NAMETOOLONG file name too long
+ E_OVERFLOW value too large for defined data type
+ E_FAULT bad address
+ E_INTR function call was interrupted
+ E_LOOP too many symbolic links encountered
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+
+ @see DirectoryItem::getFileStatus()
+ */
+
+ static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
+ {
+ return (RC) osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData );
+ }
+
+ /** Convert a file URL into a system dependend path.
+
+ @param ustrFileURL [in]
+ A File URL.
+
+ @param ustrSystemPath [out]
+ On success it receives the system path.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see getFileURLFromSystemPath()
+ */
+
+ static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
+ {
+ return (RC) osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData );
+ }
+
+ /** Convert a system dependend path into a file URL.
+
+ @param ustrSystemPath [in]
+ A System dependent path of a file or directory.
+
+ @param ustrFileURL [out]
+ On success it receives the file URL.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see getSystemPathFromFileURL()
+ */
+
+ static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
+ {
+ return (RC) osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData );
+ }
+
+ /** Searche a full qualified system path or a file URL.
+
+ @param ustrFileName [in]
+ A system dependent path, a file URL, a file or relative directory
+
+ @param ustrSearchPath [in]
+ A list of system paths, in which a given file has to be searched. The Notation of a path list is
+ system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
+ These paths are only for the search of a file or a relative path, otherwise it will be ignored.
+ If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
+ a matching file in all system directories and in the directories listed in the PATH environment
+ variable.
+ The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
+ aware of the Operating System and so doesn't know which path list delimiter to use.
+
+ @param ustrFileURL [out]
+ On success it receives the full qualified file URL.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOTDIR not a directory
+ E_NOENT no such file or directory not found
+
+ @see getFileURLFromSystemPath()
+ @see getSystemPathFromFileURL()
+ */
+
+ static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
+ {
+ return (RC) osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData );
+ }
+
+ /** Retrieves the file URL of the system's temporary directory path.
+
+ @param[out] ustrTempDirURL
+ On success receives the URL of system's temporary directory path.
+
+ @return
+ E_None on success
+ E_NOENT no such file or directory not found
+ */
+
+ static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
+ {
+ return (RC) osl_getTempDirURL( &ustrTempDirURL.pData );
+ }
+
+ /** Creates a temporary file in the directory provided by the caller or the
+ directory returned by getTempDirURL.
+ Under UNIX Operating Systems the file will be created with read and write
+ access for the user exclusively.
+ If the caller requests only a handle to the open file but not the name of
+ it, the file will be automatically removed on close else the caller is
+ responsible for removing the file on success.<br><br>
+
+ @param pustrDirectoryURL [in]
+ Specifies the full qualified URL where the temporary file should be created.
+ If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
+
+ @param pHandle [out]
+ On success receives a handle to the open file.
+ If pHandle is 0 the file will be closed on return, in this case
+ pustrTempFileURL must not be 0.
+
+ @param pustrTempFileURL [out]
+ On success receives the full qualified URL of the temporary file.
+ If pustrTempFileURL is 0 the file will be automatically removed
+ on close, in this case pHandle must not be 0.
+ If pustrTempFileURL is not 0 the caller receives the name of the
+ created file and is responsible for removing the file.
+
+ Description of the different pHandle, ppustrTempFileURL parameter combinations.
+ pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
+ pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
+ will be returned on success and the file will be automatically removed on close<br>
+ pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
+ returned, the caller is responsible for opening, closing and removing the file.<br>
+ pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
+ the file name will be returned, the caller is responsible for closing and removing
+ the file.<br>
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameter is invalid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES Permission denied
+ E_NOENT No such file or directory
+ E_NOTDIR Not a directory
+ E_ROFS Read-only file system
+ E_NOSPC No space left on device
+ E_DQUOT Quota exceeded
+
+ @see getTempDirURL()
+ */
+
+ static inline RC createTempFile(
+ ::rtl::OUString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ ::rtl::OUString* pustrTempFileURL)
+ {
+ rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
+ rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
+
+ return (RC) osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url);
+ }
+};
+
+
+// -----------------------------------------------------------------------------
+/** The VolumeDevice class.
+
+ @see VolumeInfo
+*/
+
+class VolumeDevice : public FileBase
+{
+ oslVolumeDeviceHandle _aHandle;
+
+public:
+
+ /** Constructor.
+ */
+
+ VolumeDevice() : _aHandle( NULL )
+ {
+ }
+
+ /** Copy constructor.
+
+ @param rDevice
+ The other volume device.
+ */
+
+ VolumeDevice( const VolumeDevice & rDevice )
+ {
+ _aHandle = rDevice._aHandle;
+ if ( _aHandle )
+ osl_acquireVolumeDeviceHandle( _aHandle );
+ }
+
+ /** Destructor.
+ */
+
+ ~VolumeDevice()
+ {
+ if ( _aHandle )
+ osl_releaseVolumeDeviceHandle( _aHandle );
+ }
+
+ /** Assignment operator.
+
+ @param rDevice
+ The other volume device.
+ */
+
+ inline VolumeDevice & operator =( const VolumeDevice & rDevice )
+ {
+ oslVolumeDeviceHandle newHandle = rDevice._aHandle;
+
+ if ( newHandle )
+ osl_acquireVolumeDeviceHandle( newHandle );
+
+ if ( _aHandle )
+ osl_releaseVolumeDeviceHandle( _aHandle );
+
+ _aHandle = newHandle;
+
+ return *this;
+ }
+
+ /** Get the full qualified URL where a device is mounted to.
+
+ @return
+ The full qualified URL where the device is mounted to.
+ */
+ inline rtl::OUString getMountPath()
+ {
+ rtl::OUString aPath;
+ osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
+ return aPath;
+ }
+
+ friend class VolumeInfo;
+};
+
+// -----------------------------------------------------------------------------
+
+class Directory;
+
+/** The VolumeInfo class.
+
+ Neither copy nor assignment is allowed for this class.
+
+ @see Directory::getVolumeInfo
+*/
+
+
+class VolumeInfo
+{
+ oslVolumeInfo _aInfo;
+ sal_uInt32 _nMask;
+ VolumeDevice _aDevice;
+
+ /** Copy constructor.
+ */
+
+ VolumeInfo( VolumeInfo& );
+
+ /** Assginment operator.
+ */
+
+ VolumeInfo& operator = ( VolumeInfo& );
+
+public:
+
+ /** Constructor.
+
+ @param nMask
+ Set of flags decribing the demanded information.
+ */
+
+ VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
+ {
+ _aInfo.uStructSize = sizeof( oslVolumeInfo );
+ memset( &_aInfo.uValidFields, 0, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ) );
+ _aInfo.pDeviceHandle = &_aDevice._aHandle;
+ }
+
+ /** Destructor.
+ */
+
+ ~VolumeInfo()
+ {
+ if( _aInfo.ustrFileSystemName )
+ rtl_uString_release( _aInfo.ustrFileSystemName );
+ }
+
+ /** Check if specified fields are valid.
+
+ @param nMask
+ Set of flags for the fields to check.
+
+ @return sal_True if all fields are valid else sal_False.
+ */
+
+ inline sal_Bool isValid( sal_uInt32 nMask ) const
+ {
+ return ( nMask & _aInfo.uValidFields ) == nMask;
+ }
+
+ /** Check the remote flag.
+
+ @return
+ sal_True if Attributes are valid and the volume is remote else sal_False.
+ */
+
+ inline sal_Bool getRemoteFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
+ }
+
+ /** Check the removeable flag.
+
+ @return
+ sal_True if attributes are valid and the volume is removable else sal_False.
+ */
+
+ inline sal_Bool getRemoveableFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
+ }
+
+ /** Check the compact disc flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a CDROM else sal_False.
+ */
+
+ inline sal_Bool getCompactDiscFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
+ }
+
+ /** Check the floppy disc flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a floppy disk else sal_False.
+ */
+
+ inline sal_Bool getFloppyDiskFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
+ }
+
+ /** Check the fixed disk flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a fixed disk else sal_False.
+ */
+
+ inline sal_Bool getFixedDiskFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
+ }
+
+ /** Check the RAM disk flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a RAM disk else sal_False.
+ */
+
+ inline sal_Bool getRAMDiskFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
+ }
+
+ /** Determine the total space of a volume device.
+
+ @return
+ The total diskspace of this volume if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt64 getTotalSpace() const
+ {
+ return _aInfo.uTotalSpace;
+ }
+
+ /** Determine the free space of a volume device.
+
+ @return
+ The free diskspace of this volume if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt64 getFreeSpace() const
+ {
+ return _aInfo.uFreeSpace;
+ }
+
+ /** Determine the used space of a volume device.
+
+ @return
+ The used diskspace of this volume if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt64 getUsedSpace() const
+ {
+ return _aInfo.uUsedSpace;
+ }
+
+ /** Determine the maximal length of a file name.
+
+ @return
+ The maximal length of a file name if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt32 getMaxNameLength() const
+ {
+ return _aInfo.uMaxNameLength;
+ }
+
+ /** Determine the maximal length of a path name.
+
+ @return
+ The maximal length of a path if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt32 getMaxPathLength() const
+ {
+ return _aInfo.uMaxPathLength;
+ }
+
+ /** Determine the name of the volume device's File System.
+
+ @return
+ The name of the volume's fielsystem if this information is valid,
+ otherwise an empty string.
+ */
+
+ inline ::rtl::OUString getFileSystemName() const
+ {
+ return _aInfo.ustrFileSystemName ? ::rtl::OUString( _aInfo.ustrFileSystemName ) : ::rtl::OUString();
+ }
+
+
+ /** Get the volume device handle.
+
+ @return
+ The device handle of the volume if this information is valid,
+ otherwise returns NULL;
+ */
+
+ inline VolumeDevice getDeviceHandle() const
+ {
+ return _aDevice;
+ }
+
+ /** Return whether the file system is case sensitive or
+ case insensitive
+
+ @return
+ true if the file system is case sensitive false otherwise
+ */
+ bool isCaseSensitiveFileSystem() const
+ {
+ return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive);
+ }
+
+ /** Return whether the file system preserves the case of
+ file and directory names or not
+
+ @return
+ true if the file system preserves the case of file and
+ directory names false otherwise
+ */
+ bool isCasePreservingFileSystem() const
+ {
+ return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Is_Preserved);
+ }
+
+ friend class Directory;
+};
+
+// -----------------------------------------------------------------------------
+class DirectoryItem;
+
+/** The FileStatus class.
+
+ @see DirectoryItem::getFileStatus
+*/
+
+class FileStatus
+{
+ oslFileStatus _aStatus;
+ sal_uInt32 _nMask;
+
+ /** Copy constructor.
+ */
+
+ FileStatus( FileStatus& );
+
+ /** Assignment operator.
+ */
+
+ FileStatus& operator = ( FileStatus& );
+
+public:
+
+ enum Type {
+ Directory = osl_File_Type_Directory,
+ Volume = osl_File_Type_Volume,
+ Regular = osl_File_Type_Regular,
+ Fifo = osl_File_Type_Fifo,
+ Socket = osl_File_Type_Socket,
+ Link = osl_File_Type_Link,
+ Special = osl_File_Type_Special,
+ Unknown = osl_File_Type_Unknown
+ };
+
+ /** Constructor.
+
+ @param nMask
+ Set of flags decribing the demanded information.
+ */
+
+ FileStatus( sal_uInt32 nMask ): _nMask( nMask )
+ {
+ _aStatus.uStructSize = sizeof( oslFileStatus );
+ memset( &_aStatus.uValidFields, 0, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ) );
+ }
+
+ /** Destructor.
+ */
+
+ ~FileStatus()
+ {
+ if ( _aStatus.ustrFileURL )
+ rtl_uString_release( _aStatus.ustrFileURL );
+ if ( _aStatus.ustrLinkTargetURL )
+ rtl_uString_release( _aStatus.ustrLinkTargetURL );
+ if ( _aStatus.ustrFileName )
+ rtl_uString_release( _aStatus.ustrFileName );
+ }
+
+ /** Check if specified fields are valid.
+
+ @param nMask
+ Set of flags for the fields to check.
+
+ @return
+ sal_True if all fields are valid else sal_False.
+ */
+
+ inline sal_Bool isValid( sal_uInt32 nMask ) const
+ {
+ return ( nMask & _aStatus.uValidFields ) == nMask;
+ }
+
+ /** Get the file type.
+
+ @return
+ The file type.
+ */
+ inline Type getFileType() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_Type), "sal.osl",
+ "no FileStatus Type determined");
+ return isValid(osl_FileStatus_Mask_Type)
+ ? static_cast< Type >(_aStatus.eType) : Unknown;
+ }
+
+ /** Is it a directory?
+ This method returns True for both directories, and volumes.
+
+ @return
+ True if it's a directory, False otherwise.
+
+ @see getFileType
+ @since LibreOffice 3.6
+ */
+ inline sal_Bool isDirectory() const
+ {
+ return ( getFileType() == Directory || getFileType() == Volume );
+ }
+
+ /** Is it a regular file?
+
+ @return
+ True if it's a regular file, False otherwise.
+
+ @see getFileType
+ @see isFile
+ @see isLink
+ @since LibreOffice 3.6
+ */
+ inline sal_Bool isRegular() const
+ {
+ return ( getFileType() == Regular );
+ }
+
+ /** Is it a link?
+
+ @return
+ True if it's a link, False otherwise.
+
+ @see getFileType
+ @since LibreOffice 3.6
+ */
+ inline sal_Bool isLink() const
+ {
+ return ( getFileType() == Link );
+ }
+
+ /** Get the file attributes.
+
+ @return
+ The set of attribute flags of this file.
+ */
+
+ inline sal_uInt64 getAttributes() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
+ "no FileStatus Attributes determined");
+ return _aStatus.uAttributes;
+ }
+
+ /** Get the creation time of this file.
+
+ @return
+ The creation time if this information is valid, an uninitialized
+ TimeValue otherwise.
+ */
+
+ inline TimeValue getCreationTime() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
+ "no FileStatus CreationTime determined");
+ return _aStatus.aCreationTime;
+ }
+
+ /** Get the file access time.
+
+ @return
+ The last access time if this information is valid, an uninitialized
+ TimeValue otherwise.
+ */
+
+ inline TimeValue getAccessTime() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
+ "no FileStatus AccessTime determined");
+ return _aStatus.aAccessTime;
+ }
+
+ /** Get the file modification time.
+
+ @return
+ The last modified time if this information is valid, an uninitialized
+ TimeValue otherwise.
+ */
+
+ inline TimeValue getModifyTime() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
+ "no FileStatus ModifyTime determined");
+ return _aStatus.aModifyTime;
+ }
+
+ /** Get the size of the file.
+
+ @return
+ The actual file size if this information is valid, 0 otherwise.
+ */
+
+ inline sal_uInt64 getFileSize() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
+ "no FileStatus FileSize determined");
+ return _aStatus.uFileSize;
+ }
+
+ /** Get the file name.
+
+ @return
+ The file name if this information is valid, an empty string otherwise.
+ */
+
+ inline ::rtl::OUString getFileName() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
+ "no FileStatus FileName determined");
+ return isValid(osl_FileStatus_Mask_FileName)
+ ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
+ }
+
+
+ /** Get the URL of the file.
+
+ @return
+ The full qualified URL of the file if this information is valid, an
+ empty string otherwise.
+ */
+
+ inline ::rtl::OUString getFileURL() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
+ "no FileStatus FileURL determined");
+ return isValid(osl_FileStatus_Mask_FileURL)
+ ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
+ }
+
+ /** Get the link target URL.
+
+ @return
+ The link target URL if this information is valid, an empty string
+ otherwise.
+ */
+
+ inline ::rtl::OUString getLinkTargetURL() const
+ {
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
+ "no FileStatus LinkTargetURL determined");
+ return isValid(osl_FileStatus_Mask_LinkTargetURL)
+ ? rtl::OUString(_aStatus.ustrLinkTargetURL) : rtl::OUString();
+ }
+
+ friend class DirectoryItem;
+};
+
+
+// -----------------------------------------------------------------------------
+/** The file class object provides access to file contents and attributes.
+
+ @see Directory
+ @see DirectoryItem
+ */
+
+class File: public FileBase
+{
+ oslFileHandle _pData;
+ ::rtl::OUString _aPath;
+
+ /** Copy constructor.
+ */
+
+ File( File& );
+
+ /** Assginment operator.
+ */
+
+ File& operator = ( File& );
+
+public:
+
+ /** Constructor.
+
+ @param ustrFileURL [in]
+ The full qualified URL of the file. Relative paths are not allowed.
+ */
+
+ File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
+
+ /** Destructor
+ */
+
+ inline ~File()
+ {
+ close();
+ }
+
+ /** Obtain the URL.
+
+ @return
+ the URL with which this File instance was created.
+
+ @since LibreOffice 4.1
+ */
+ inline rtl::OUString getURL() const { return _aPath; }
+
+ /** Open a regular file.
+
+ Open a file. Only regular files can be openend.
+
+ @param uFlags [in]
+ Specifies the open mode.
+
+ @return
+ E_None on success
+ E_NOMEM not enough memory for allocating structures
+ E_INVAL the format of the parameters was not valid
+ E_NAMETOOLONG pathname was too long
+ E_NOENT no such file or directory
+ E_ACCES permission denied
+ E_AGAIN a write lock could not be established
+ E_NOTDIR not a directory
+ E_NXIO no such device or address
+ E_NODEV no such device
+ E_ROFS read-only file system
+ E_TXTBSY text file busy
+ E_FAULT bad address
+ E_LOOP too many symbolic links encountered
+ E_NOSPC no space left on device
+ E_ISDIR is a directory
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_DQUOT quota exceeded
+ E_EXIST file exists
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_EOVERFLOW value too large for defined data type
+
+ @see close()
+ @see setPos()
+ @see getPos()
+ @see read()
+ @see write()
+ @see getSize()
+ @see setSize()
+ */
+
+ inline RC open( sal_uInt32 uFlags )
+ {
+ return (RC) osl_openFile( _aPath.pData, &_pData, uFlags );
+ }
+
+ /** Close an open file.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_BADF Bad file
+ E_INTR function call was interrupted
+ E_NOLINK link has been severed
+ E_NOSPC no space left on device
+ E_IO on I/O errors
+
+ @see open()
+ */
+
+ inline RC close()
+ {
+ oslFileError Error = osl_File_E_BADF;
+
+ if( _pData )
+ {
+ Error=osl_closeFile( _pData );
+ _pData = NULL;
+ }
+
+ return (RC) Error;
+ }
+
+ /** Set the internal position pointer of an open file.
+
+ @param uHow [in]
+ Distance to move the internal position pointer (from uPos).
+
+ @param uPos [in]
+ Absolute position from the beginning of the file.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see getPos()
+ */
+
+ inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
+ {
+ return (RC) osl_setFilePos( _pData, uHow, uPos );
+ }
+
+ /** Retrieve the current position of the internal pointer of an open file.
+
+ @param uPos [out]
+ On success receives the current position of the file pointer.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see setPos()
+ @see read()
+ @see write()
+ */
+
+ inline RC getPos( sal_uInt64& uPos )
+ {
+ return (RC) osl_getFilePos( _pData, &uPos );
+ }
+
+ /** Test if the end of a file is reached.
+
+ @param pIsEOF [out]
+ Points to a variable that receives the end-of-file status.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_ISDIR is a directory
+ E_BADF bad file
+ E_FAULT bad address
+ E_AGAIN operation would block
+ E_NOLINK link has been severed
+
+ @see open()
+ @see read()
+ @see readLine()
+ @see setPos()
+ */
+
+ inline RC isEndOfFile( sal_Bool *pIsEOF )
+ {
+ return (RC) osl_isEndOfFile( _pData, pIsEOF );
+ }
+
+ /** Set the file size of an open file.
+
+ Sets the file size of an open file. The file can be truncated or enlarged by the function.
+ The position of the file pointer is not affeced by this function.
+
+ @param uSize [in]
+ New size in bytes.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see setPos()
+ @see getStatus()
+ */
+
+ inline RC setSize( sal_uInt64 uSize )
+ {
+ return (RC) osl_setFileSize( _pData, uSize );
+ }
+
+ /** Get the file size of an open file.
+
+ Gets the file size of an open file.
+ The position of the file pointer is not affeced by this function.
+
+ @param rSize [out]
+ Current size in bytes.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see setPos()
+ @see getSize()
+ @see setSize()
+ @see getStatus()
+ */
+
+ inline RC getSize( sal_uInt64 &rSize )
+ {
+ return (RC) osl_getFileSize( _pData, &rSize );
+ }
+
+ /** Read a number of bytes from a file.
+
+ Reads a number of bytes from a file. The internal file pointer is
+ increased by the number of bytes read.
+
+ @param pBuffer [out]
+ Points to a buffer which receives data. The buffer must be large enough
+ to hold uBytesRequested bytes.
+
+ @param uBytesRequested [in]
+ Number of bytes which should be retrieved.
+
+ @param rBytesRead [out]
+ On success the number of bytes which have actually been retrieved.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_ISDIR is a directory
+ E_BADF bad file
+ E_FAULT bad address
+ E_AGAIN operation would block
+ E_NOLINK link has been severed
+
+ @see open()
+ @see write()
+ @see readLine()
+ @see setPos()
+ */
+
+ inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
+ {
+ return (RC) osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead );
+ }
+
+ /** Write a number of bytes to a file.
+
+ Writes a number of bytes to a file.
+ The internal file pointer is increased by the number of bytes read.
+
+ @param pBuffer [in]
+ Points to a buffer which contains the data.
+
+ @param uBytesToWrite [in]
+ Number of bytes which should be written.
+
+ @param rBytesWritten [out]
+ On success the number of bytes which have actually been written.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_FBIG file too large
+ E_DQUOT quota exceeded
+ E_AGAIN operation would block
+ E_BADF bad file
+ E_FAULT bad address
+ E_INTR function call was interrupted
+ E_IO on I/O errosr
+ E_NOLCK no record locks available
+ E_NOLINK link has been severed
+ E_NOSPC no space left on device
+ E_NXIO no such device or address
+
+ @see open()
+ @see read()
+ @see setPos()
+ */
+
+ inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
+ {
+ return (RC) osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten );
+ }
+
+
+ /** Read a line from a file.
+
+ Reads a line from a file. The new line delimiter is NOT returned!
+
+ @param aSeq [in/out]
+ A reference to a ::rtl::ByteSequence that will hold the line read on success.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_ISDIR is a directory
+ E_BADF bad file
+ E_FAULT bad address
+ E_AGAIN operation would block
+ E_NOLINK link has been severed
+
+ @see open()
+ @see read()
+ @see write()
+ @see setPos()
+ */
+
+ inline RC readLine( ::rtl::ByteSequence& aSeq )
+ {
+ return (RC) osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) );
+ }
+
+ /** Synchronize the memory representation of a file with that on the physical medium.
+
+ The function ensures that all modified data and attributes of the file associated with
+ the given file handle have been written to the physical medium.
+ In case the hard disk has a write cache enabled, the data may not really be on
+ permanent storage when osl_syncFile returns.
+
+ @return
+ <dl>
+ <dt>E_None</dt>
+ <dd>On success</dd>
+ <dt>E_INVAL</dt>
+ <dd>The value of the input parameter is invalid</dd>
+ <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
+ <dt>E_BADF</dt>
+ <dd>The file is not open for writing</dd>
+ <dt>E_IO</dt>
+ <dd>An I/O error occurred</dd>
+ <dt>E_NOSPC</dt>
+ <dd>There is no enough space on the target device</dd>
+ <dt>E_ROFS</dt>
+ <dd>The file is located on a read only file system</dd>
+ <dt>E_TIMEDOUT</dt>
+ <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
+ </dl>
+
+ @see osl_syncFile()
+ @see open()
+ @see write()
+ */
+ inline RC sync() const
+ {
+ OSL_PRECOND(_pData, "File::sync(): File not open");
+ return (RC)osl_syncFile(_pData);
+ }
+
+ /** Copy a file to a new destination.
+
+ Copies a file to a new destination. Copies only files not directories.
+ No assumptions should be made about preserving attributes or file time.
+
+ @param ustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param ustrDestFileURL [in]
+ Full qualified URL of the destination file. A directory is NOT a valid destination file!
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_PERM operation not permitted
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ISDIR is a directory
+ E_ROFS read-only file system
+
+ @see move()
+ @see remove()
+ */
+
+ inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
+ {
+ return (RC) osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
+ }
+
+ /** Move a file or directory to a new destination or renames it.
+
+ Moves a file or directory to a new destination or renames it.
+ File time and attributes are preserved.
+
+ @param ustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param ustrDestFileURL [in]
+ Full qualified URL of the destination file. An existing directory is NOT a valid destination !
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_PERM operation not permitted
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ROFS read-only file system
+
+ @see copy()
+ */
+
+ inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
+ {
+ return (RC) osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
+ }
+
+ /** Remove a regular file.
+
+ @param ustrFileURL [in]
+ Full qualified URL of the file to remove.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_PERM operation not permitted
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ISDIR is a directory
+ E_ROFS read-only file system
+ E_FAULT bad address
+ E_LOOP too many symbolic links encountered
+ E_IO on I/O errors
+ E_BUSY device or resource busy
+ E_INTR function call was interrupted
+ E_LOOP too many symbolic links encountered
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_TXTBSY text file busy
+
+ @see open()
+ */
+
+ inline static RC remove( const ::rtl::OUString& ustrFileURL )
+ {
+ return (RC) osl_removeFile( ustrFileURL.pData );
+ }
+
+ /** Set file attributes.
+
+ @param ustrFileURL [in]
+ The full qualified file URL.
+
+ @param uAttributes [in]
+ Attributes of the file to be set.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see FileStatus
+ */
+
+ inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
+ {
+ return (RC) osl_setFileAttributes( ustrFileURL.pData, uAttributes );
+ }
+
+ /** Set the file time.
+
+ @param ustrFileURL [in]
+ The full qualified URL of the file.
+
+ @param rCreationTime [in]
+ Creation time of the given file.
+
+ @param rLastAccessTime [in]
+ Time of the last access of the given file.
+
+ @param rLastWriteTime [in]
+ Time of the last modifying of the given file.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOENT no such file or directory not found
+
+ @see FileStatus
+ */
+
+ inline static RC setTime(
+ const ::rtl::OUString& ustrFileURL,
+ const TimeValue& rCreationTime,
+ const TimeValue& rLastAccessTime,
+ const TimeValue& rLastWriteTime )
+ {
+ return (RC) osl_setFileTime(
+ ustrFileURL.pData,
+ &rCreationTime,
+ &rLastAccessTime,
+ &rLastWriteTime );
+ }
+
+ friend class DirectoryItem;
+};
+
+// -----------------------------------------------------------------------------
+/** The directory item class object provides access to file status information.
+
+ @see FileStatus
+ */
+
+class DirectoryItem: public FileBase
+{
+ oslDirectoryItem _pData;
+
+public:
+
+ /** Constructor.
+ */
+
+ DirectoryItem(): _pData( NULL )
+ {
+ }
+
+ /** Copy constructor.
+ */
+
+ DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
+ {
+ if( _pData )
+ osl_acquireDirectoryItem( _pData );
+ }
+
+ /** Destructor.
+ */
+
+ ~DirectoryItem()
+ {
+ if( _pData )
+ osl_releaseDirectoryItem( _pData );
+ }
+
+ /** Assignment operator.
+ */
+
+ DirectoryItem& operator=(const DirectoryItem& rItem )
+ {
+ if (&rItem != this)
+ {
+ if( _pData )
+ osl_releaseDirectoryItem( _pData );
+
+ _pData = rItem._pData;
+
+ if( _pData )
+ osl_acquireDirectoryItem( _pData );
+ }
+ return *this;
+ }
+
+ /** Check for validity of this instance.
+
+ @return
+ sal_True if object is valid directory item else sal_False.
+ */
+
+ inline sal_Bool is()
+ {
+ return _pData != NULL;
+ }
+
+ /** Retrieve a single directory item.
+
+ Retrieves a single directory item. The returned handle has an initial refcount of 1.
+ Due to performance issues it is not recommended to use this function while
+ enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
+
+ @param ustrFileURL [in]
+ An absolute file URL.
+
+ @param rItem [out]
+ On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
+ The handle has to be released by a call to osl_releaseDirectoryItem().
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NOENT no such file or directory
+ E_LOOP too many symbolic links encountered
+ E_NAMETOOLONG the file name is too long
+ E_NOTDIR a component of the path prefix of path is not a directory
+ E_IO on I/O errors
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_FAULT bad address
+ E_INTR the function call was interrupted
+
+ @see FileStatus
+ @see Directory::getNextItem()
+ */
+
+ static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
+ {
+ if( rItem._pData)
+ {
+ osl_releaseDirectoryItem( rItem._pData );
+ rItem._pData = NULL;
+ }
+
+ return (RC) osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData );
+ }
+
+ /** Retrieve information about a single file or directory.
+
+ @param rStatus [in|out]
+ Reference to a class which receives the information of the file or directory
+ represented by this directory item.
+
+ @return
+ E_None on success
+ E_NOMEM not enough memory for allocating structures
+ E_INVAL the format of the parameters was not valid
+ E_LOOP too many symbolic links encountered
+ E_ACCES permission denied
+ E_NOENT no such file or directory
+ E_NAMETOOLONG file name too long
+ E_BADF invalid oslDirectoryItem parameter
+ E_FAULT bad address
+ E_OVERFLOW value too large for defined data type
+ E_INTR function call was interrupted
+ E_NOLINK link has been severed
+ E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NOSPC no space left on device
+ E_NXIO no such device or address
+ E_IO on I/O errors
+ E_NOSYS function not implemented
+
+ @see get()
+ @see Directory::getNextItem()
+ @see FileStatus
+ */
+
+ inline RC getFileStatus( FileStatus& rStatus )
+ {
+ return (RC) osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask );
+ }
+
+/** Determine if a directory item point the same underlying file
+
+ The comparison is done first by URL, and then by resolving links to
+ find the target, and finally by comparing inodes on unix.
+
+ @param[in] pOther
+ A directory handle to compare with the underlying object's item
+
+ @return
+ sal_True: if the items point to an identical resource<br>
+ sal_False: if the items point to a different resource, or a fatal error occured<br>
+
+ @see osl_getDirectoryItem()
+
+ @since LibreOffice 3.6
+*/
+ inline sal_Bool isIdenticalTo( const DirectoryItem &pOther )
+ {
+ return osl_identicalDirectoryItem( _pData, pOther._pData );
+ }
+
+ friend class Directory;
+};
+
+//###########################################
+
+/** Base class for observers of directory creation notifications.
+
+ Clients which uses the method createDirectoryPath of the class
+ Directory may want to be informed about the directories that
+ have been created. This may be accomplished by deriving from
+ this base class and overwriting the virtual function
+ DirectoryCreated.
+
+ @see Directory::createPath
+*/
+class DirectoryCreationObserver
+{
+public:
+ virtual ~DirectoryCreationObserver() {}
+
+ /** This method will be called when a new directory has been
+ created and needs to be overwritten by derived classes.
+ You must not delete the directory that was just created
+ otherwise you will run into an endless loop.
+
+ @param aDirectoryUrl
+ [in]The absolute file URL of the directory that was just created by
+ ::osl::Directory::createPath.
+ */
+ virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
+};
+
+//###########################################
+// This just an internal helper function for
+// private use.
+extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
+{
+ (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
+}
+
+/** The directory class object provides a enumeration of DirectoryItems.
+
+ @see DirectoryItem
+ @see File
+ */
+
+class Directory: public FileBase
+{
+ oslDirectory _pData;
+ ::rtl::OUString _aPath;
+
+ /** Copy constructor.
+ */
+
+ Directory( Directory& );
+
+ /** Assignment operator.
+ */
+
+ Directory& operator = ( Directory& );
+
+public:
+
+ /** Constructor.
+
+ @param strPath [in]
+ The full qualified URL of the directory.
+ Relative URLs are not allowed.
+ */
+
+ Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
+ {
+ }
+
+ /** Destructor.
+ */
+
+ ~Directory()
+ {
+ close();
+ }
+
+ /** Obtain the URL.
+
+ @return
+ the URL with which this Directory instance was created.
+
+ @since LibreOffice 4.1
+ */
+ inline rtl::OUString getURL() const { return _aPath; }
+
+ /** Open a directory for enumerating its contents.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOENT the specified path doesn't exist
+ E_NOTDIR the specified path is not an directory
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NAMETOOLONG File name too long
+ E_LOOP Too many symbolic links encountered
+
+ @see getNextItem()
+ @see close()
+ */
+
+ inline RC open()
+ {
+ return (RC) osl_openDirectory( _aPath.pData, &_pData );
+ }
+
+ /** Query if directory is open.
+
+ Query if directory is open and so item enumeration is valid.
+
+ @return
+ sal_True if the directory is open else sal_False.
+
+ @see open()
+ @see close()
+ */
+
+ inline sal_Bool isOpen() { return _pData != NULL; }
+
+ /** Close a directory.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_BADF invalid oslDirectory parameter
+ E_INTR the function call was interrupted
+
+ @see open()
+ */
+
+ inline RC close()
+ {
+ oslFileError Error = osl_File_E_BADF;
+
+ if( _pData )
+ {
+ Error=osl_closeDirectory( _pData );
+ _pData = NULL;
+ }
+
+ return (RC) Error;
+ }
+
+
+ /** Resets the directory item enumeration to the beginning.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOENT the specified path doesn't exist
+ E_NOTDIR the specified path is not an directory
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NAMETOOLONG File name too long
+ E_LOOP Too many symbolic links encountered
+
+ @see open()
+ */
+
+ inline RC reset()
+ {
+ close();
+ return open();
+ }
+
+ /** Retrieve the next item of a previously opened directory.
+
+ Retrieves the next item of a previously opened directory.
+
+ @param rItem [out]
+ On success a valid DirectoryItem.
+
+ @param nHint [in]
+ With this parameter the caller can tell the implementation that (s)he
+ is going to call this function uHint times afterwards. This enables the implementation to
+ get the information for more than one file and cache it until the next calls.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_NOENT no more entries in this directory
+ E_BADF invalid oslDirectory parameter
+ E_OVERFLOW the value too large for defined data type
+
+ @see DirectoryItem
+ */
+
+ inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
+ {
+ if( rItem._pData )
+ {
+ osl_releaseDirectoryItem( rItem._pData );
+ rItem._pData = 0;
+ }
+ return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
+ }
+
+
+ /** Retrieve information about a volume.
+
+ Retrieves information about a volume. A volume can either be a mount point, a network
+ resource or a drive depending on Operating System and File System.
+
+ @param ustrDirectoryURL [in]
+ Full qualified URL of the volume
+
+ @param rInfo [out]
+ On success it receives information about the volume.
+
+ @return
+ E_None on success
+ E_NOMEM not enough memory for allocating structures
+ E_INVAL the format of the parameters was not valid
+ E_NOTDIR not a directory
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ACCES permission denied
+ E_LOOP too many symbolic links encountered
+ E_FAULT Bad address
+ E_IO on I/O errors
+ E_NOSYS function not implemented
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_INTR function call was interrupted
+
+ @see FileStatus
+ @see VolumeInfo
+ */
+
+ inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
+ {
+ return (RC) osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask );
+ }
+
+ /** Create a directory.
+
+ @param ustrDirectoryURL [in]
+ Full qualified URL of the directory to create.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_EXIST file exists
+ E_ACCES permission denied
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_NOTDIR not a directory
+ E_ROFS read-only file system
+ E_NOSPC no space left on device
+ E_DQUOT quota exceeded
+ E_LOOP too many symbolic links encountered
+ E_FAULT bad address
+ E_IO on I/O errors
+ E_MLINK too many links
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+
+ @see remove()
+ */
+
+ inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
+ {
+ return (RC) osl_createDirectory( ustrDirectoryURL.pData );
+ }
+
+ /** Remove an empty directory.
+
+ @param ustrDirectoryURL [in]
+ Full qualified URL of the directory.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_PERM operation not permitted
+ E_ACCES permission denied
+ E_NOENT no such file or directory
+ E_NOTDIR not a directory
+ E_NOTEMPTY directory not empty
+ E_FAULT bad address
+ E_NAMETOOLONG file name too long
+ E_BUSY device or resource busy
+ E_ROFS read-only file system
+ E_LOOP too many symbolic links encountered
+ E_BUSY device or resource busy
+ E_EXIST file exists
+ E_IO on I/O errors
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+
+ @see create()
+ */
+
+ inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
+ {
+ return (RC) osl_removeDirectory( ustrDirectoryURL.pData );
+ }
+
+ /** Create a directory path.
+
+ The osl_createDirectoryPath function creates a specified directory path.
+ All nonexisting sub directories will be created.
+ <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
+ E_EXIST for existing directories. Programming against this error code is
+ in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
+
+ @param aDirectoryUrl
+ [in] The absolute file URL of the directory path to create.
+ A relative file URL will not be accepted.
+
+ @param aDirectoryCreationObserver
+ [in] Pointer to an instance of type DirectoryCreationObserver that will
+ be informed about the creation of a directory. The value of this
+ parameter may be NULL, in this case notifications will not be sent.
+
+ @return
+ <dl>
+ <dt>E_None</dt>
+ <dd>On success</dd>
+ <dt>E_INVAL</dt>
+ <dd>The format of the parameters was not valid</dd>
+ <dt>E_ACCES</dt>
+ <dd>Permission denied</dd>
+ <dt>E_EXIST</dt>
+ <dd>The final node of the specified directory path already exist</dd>
+ <dt>E_NAMETOOLONG</dt>
+ <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
+ <dt>E_NOTDIR</dt>
+ <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
+ <dt>E_ROFS</dt>
+ <dd>Read-only file system</dd>
+ <dt>E_NOSPC</dt>
+ <dd>No space left on device</dd>
+ <dt>E_DQUOT</dt>
+ <dd>Quota exceeded</dd>
+ <dt>E_FAULT</dt>
+ <dd>Bad address</dd>
+ <dt>E_IO</dt>
+ <dd>I/O error</dd>
+ <dt>E_LOOP</dt>
+ <dd>Too many symbolic links encountered</dd>
+ <dt>E_NOLINK</dt>
+ <dd>Link has been severed</dd>
+ <dt>E_invalidError</dt>
+ <dd>An unknown error occurred</dd>
+ </dl>
+
+ @see DirectoryCreationObserver
+ @see create
+ */
+ static RC createPath(
+ const ::rtl::OUString& aDirectoryUrl,
+ DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
+ {
+ return (RC)osl_createDirectoryPath(
+ aDirectoryUrl.pData,
+ (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
+ aDirectoryCreationObserver);
+ }
+};
+
+} /* namespace osl */
+
+#endif /* _OSL_FILE_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/getglobalmutex.hxx b/include/osl/getglobalmutex.hxx
new file mode 100644
index 000000000000..4fbd32a3e4b5
--- /dev/null
+++ b/include/osl/getglobalmutex.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 INCLUDED_OSL_GETGLOBALMUTEX_HXX
+#define INCLUDED_OSL_GETGLOBALMUTEX_HXX
+
+#include "osl/mutex.hxx"
+
+namespace osl {
+
+/** A helper functor for the rtl_Instance template.
+
+ See the rtl_Instance template for examples of how this class is used.
+ */
+class GetGlobalMutex
+{
+public:
+ ::osl::Mutex * operator()()
+ {
+ return ::osl::Mutex::getGlobalMutex();
+ }
+};
+
+}
+
+#endif // INCLUDED_OSL_GETGLOBALMUTEX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/interlck.h b/include/osl/interlck.h
new file mode 100644
index 000000000000..31212deed274
--- /dev/null
+++ b/include/osl/interlck.h
@@ -0,0 +1,92 @@
+/* -*- 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 _OSL_INTERLOCK_H_
+#define _OSL_INTERLOCK_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef sal_Int32 oslInterlockedCount;
+
+/** Increments the count variable addressed by pCount.
+ @param pCount Address of count variable
+ @return The adjusted value of the count variable.
+*/
+SAL_DLLPUBLIC oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount);
+
+/** Decrement the count variable addressed by pCount.
+ @param pCount Address of count variable
+ @return The adjusted value of the count variable.
+*/
+SAL_DLLPUBLIC oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount);
+
+
+/// @cond INTERNAL
+
+/** Increments the count variable addressed by p.
+
+ @attention This functionality should only be used internally within
+ LibreOffice.
+
+ @param p Address of count variable
+ @return The adjusted value of the count variable.
+
+ @since LibreOffice 4.0
+*/
+#if HAVE_GCC_BUILTIN_ATOMIC
+# define osl_atomic_increment(p) __sync_add_and_fetch((p), 1)
+#else
+# define osl_atomic_increment(p) osl_incrementInterlockedCount((p))
+#endif
+
+
+/** Decrement the count variable addressed by p.
+
+ @attention This functionality should only be used internally within
+ LibreOffice.
+
+ @param p Address of count variable
+ @return The adjusted value of the count variable.
+
+ @since LibreOffice 4.0
+*/
+#if HAVE_GCC_BUILTIN_ATOMIC
+# define osl_atomic_decrement(p) __sync_sub_and_fetch((p), 1)
+#else
+# define osl_atomic_decrement(p) osl_decrementInterlockedCount((p))
+#endif
+
+/// @endcond
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _OSL_INTERLOCK_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/module.h b/include/osl/module.h
new file mode 100644
index 000000000000..09f2b17b401c
--- /dev/null
+++ b/include/osl/module.h
@@ -0,0 +1,251 @@
+/* -*- 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 _OSL_MODULE_H_
+#define _OSL_MODULE_H_
+
+#include "sal/config.h"
+
+#include "rtl/tencinfo.h"
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef SAL_DLLPREFIX
+#define SAL_MODULENAME(name) SAL_DLLPREFIX name SAL_DLLEXTENSION
+#else
+#define SAL_MODULENAME(name) name SAL_DLLEXTENSION
+#endif
+
+#if defined(SAL_W32)
+#define SAL_MODULENAME_WITH_VERSION(name, version) name version SAL_DLLEXTENSION
+
+#elif defined(SAL_UNX)
+#if defined(MACOSX)
+#define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name ".dylib." version
+#else
+#define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name SAL_DLLEXTENSION "." version
+#endif
+
+#endif
+
+#define SAL_LOADMODULE_DEFAULT 0x00000
+#define SAL_LOADMODULE_LAZY 0x00001
+#define SAL_LOADMODULE_NOW 0x00002
+#define SAL_LOADMODULE_GLOBAL 0x00100
+
+typedef void* oslModule;
+
+/** Generic Function pointer type that will be used as symbol address.
+ @see osl_getFunctionSymbol.
+ @see osl_getModuleURLFromFunctionAddress.
+*/
+typedef void ( SAL_CALL *oslGenericFunction )( void );
+
+#ifndef DISABLE_DYNLOADING
+
+/** Load a shared library or module.
+ @param strModuleName denotes the name of the module to be loaded.
+ @param nRtldMode denotes the mode.
+ @return NULL if the module could not be loaded, otherwise a handle to the module.
+*/
+SAL_DLLPUBLIC oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode);
+
+/** Load a shared library or module.
+ @param pModuleName denotes the name of the module to be loaded.
+ @param nRtldMode denotes the mode.
+ @return NULL if the module could not be loaded, otherwise a handle to the module.
+ @since UDK 3.6
+*/
+SAL_DLLPUBLIC oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nRtldMode);
+
+/** Load a module located relative to some other module.
+
+ @param baseModule
+ must point to a function that is part of the code of some loaded module;
+ must not be NULL.
+
+ @param relativePath
+ a relative URL; must not be NULL.
+
+ @param mode
+ the SAL_LOADMODULE_xxx flags.
+
+ @return
+ a non-NULL handle to the loaded module, or NULL if an error occurred.
+
+ @since UDK 3.2.8
+*/
+SAL_DLLPUBLIC oslModule SAL_CALL osl_loadModuleRelative(
+ oslGenericFunction baseModule, rtl_uString * relativePath, sal_Int32 mode);
+
+/** Load a module located relative to some other module.
+
+ @param baseModule
+ must point to a function that is part of the code of some loaded module;
+ must not be NULL.
+
+ @param relativePath
+ a relative URL containing only ASCII (0x01--7F) characters; must not be
+ NULL.
+
+ @param mode
+ the SAL_LOADMODULE_xxx flags.
+
+ @return
+ a non-NULL handle to the loaded module, or NULL if an error occurred.
+
+ @since LibreOffice 3.5
+*/
+SAL_DLLPUBLIC oslModule SAL_CALL osl_loadModuleRelativeAscii(
+ oslGenericFunction baseModule, char const * relativePath, sal_Int32 mode);
+ /* This function is guaranteed not to call into
+ FullTextEncodingDataSingleton in sal/textenc/textenc.cxx, so can be used
+ in its implementation without running into circles. */
+
+#endif
+
+/** Retrieve the handle of an already loaded module.
+
+ This function can be used to search for a function symbol in the process address space.
+ Do not use the returned handle as an argument to osl_unloadModule. On Unix platforms,
+ pModuleName gets ignored and the special handle RTLD_DEFAULT is returned.
+
+ @param pModuleName
+ [in] denotes the name of the module to search for. Ignored on Unix
+
+ @param pResult
+ [out] a pointer to a oslModule that is updated with the requested module handle
+ on success.
+
+ @return
+ sal_True if the module handle could be retrieved and has been copied to *pResult.
+ sal_False if the module has not been loaded yet.
+
+ @see osl_getFunctionSymbol
+ @see osl_getAsciiFunctionSymbol
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult);
+
+#ifndef DISABLE_DYNLOADING
+
+/** Release the module
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_unloadModule(oslModule Module);
+
+#endif
+
+/** lookup the specified symbol name.
+ @return address of the symbol or NULL if lookup failed.
+*/
+SAL_DLLPUBLIC void* SAL_CALL osl_getSymbol( oslModule Module, rtl_uString *strSymbolName);
+
+/** Lookup the specified function symbol name.
+
+ osl_getFunctionSymbol is an alternative function for osl_getSymbol.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param Module
+ [in] the handle of the Module.
+
+ @param ustrFunctionSymbolName
+ [in] Name of the function that will be looked up.
+
+ @return
+ <dl>
+ <dt>Function address.</dt>
+ <dd>on success</dd>
+ <dt>NULL</dt>
+ <dd>lookup failed or the parameter are invalid.</dd>
+ </dl>
+
+ @see osl_getSymbol
+ @see osl_getAsciiFunctionSymbol
+*/
+SAL_DLLPUBLIC oslGenericFunction SAL_CALL osl_getFunctionSymbol(
+ oslModule Module, rtl_uString *ustrFunctionSymbolName );
+
+/** Lookup the specified function symbol name.
+
+ osl_getAsciiFunctionSymbol is an alternative function for osl_getFunctionSymbol.
+ It expects the C-style function name string to contain ascii characters only.
+
+ @param Module
+ [in] a module handle as returned by osl_loadModule or osl_getModuleHandle
+
+ @param pSymbol
+ [in] Name of the function that will be looked up.
+
+ @return
+ <dl>
+ <dt>Function address.</dt>
+ <dd>on success</dd>
+ <dt>NULL</dt>
+ <dd>lookup failed or the parameter are invalid.</dd>
+ </dl>
+
+ @see osl_getModuleHandle
+ @see osl_getFunctionSymbol
+*/
+SAL_DLLPUBLIC oslGenericFunction SAL_CALL osl_getAsciiFunctionSymbol(
+ oslModule Module, const sal_Char *pSymbol );
+
+
+/** Lookup URL of module which is mapped at the specified address.
+ @param pv specifies an address in the process memory space.
+ @param pustrURL receives the URL of the module that is mapped at pv.
+ @return sal_True on success, sal_False if no module can be found at the specified address.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getModuleURLFromAddress(
+ void *pv, rtl_uString **pustrURL );
+
+/** Lookup URL of module which is mapped at the specified function address.
+
+ osl_getModuleURLFromFunctionAddress is an alternative function for osl_getModuleURLFromAddress.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param pf
+ [in] function address in oslGenericFunction format.
+
+ @param pustrFunctionURL
+ [out] receives the URL of the module that is mapped at pf.
+
+ @return
+ <dl>
+ <dt>sal_True</dt>
+ <dd>on success</dd>
+ <dt>sal_False</dt>
+ <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd>
+ </dl>
+
+ @see osl_getModuleURLFromAddress
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress(
+ oslGenericFunction pf, rtl_uString **pustrFunctionURL );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_MODULE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/module.hxx b/include/osl/module.hxx
new file mode 100644
index 000000000000..317579dc816b
--- /dev/null
+++ b/include/osl/module.hxx
@@ -0,0 +1,175 @@
+/* -*- 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 _OSL_MODULE_HXX_
+#define _OSL_MODULE_HXX_
+
+#include <rtl/ustring.hxx>
+#include <osl/module.h>
+
+namespace osl
+{
+
+class Module
+{
+ Module( const Module&);
+ Module& operator = ( const Module&);
+
+public:
+ static sal_Bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) {
+ return osl_getModuleURLFromAddress(addr, &libraryUrl.pData);
+ }
+
+ /** Get module URL from the specified function address in the module.
+
+ Similar to getUrlFromAddress, but use a function address to get URL of the Module.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param addr
+ [in] function address in oslGenericFunction format.
+
+ @param libraryUrl
+ [in|out] receives the URL of the module.
+
+ @return
+ <dl>
+ <dt>sal_True</dt>
+ <dd>on success</dd>
+ <dt>sal_False</dt>
+ <dd>can not get the URL from the specified function address or the parameter is invalid.</dd>
+ </dl>
+
+ @see getUrlFromAddress
+ */
+ static sal_Bool getUrlFromAddress( oslGenericFunction addr, ::rtl::OUString & libraryUrl){
+ return osl_getModuleURLFromFunctionAddress( addr, &libraryUrl.pData );
+ }
+
+ Module(): m_Module(0){}
+
+#ifndef DISABLE_DYNLOADING
+
+ Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(0)
+ {
+ load( strModuleName, nRtldMode);
+ }
+
+#endif
+
+ ~Module()
+ {
+#ifndef DISABLE_DYNLOADING
+ osl_unloadModule(m_Module);
+#endif
+ }
+
+#ifndef DISABLE_DYNLOADING
+
+ sal_Bool SAL_CALL load( const ::rtl::OUString& strModuleName,
+ sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
+ {
+ unload();
+ m_Module= osl_loadModule( strModuleName.pData, nRtldMode );
+ return is();
+ }
+
+ /// @since UDK 3.2.8
+ sal_Bool SAL_CALL loadRelative(
+ ::oslGenericFunction baseModule, ::rtl::OUString const & relativePath,
+ ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
+ {
+ unload();
+ m_Module = osl_loadModuleRelative(baseModule, relativePath.pData, mode);
+ return is();
+ }
+
+ /// @since LibreOffice 3.5
+ sal_Bool SAL_CALL loadRelative(
+ oslGenericFunction baseModule, char const * relativePath,
+ sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
+ {
+ unload();
+ m_Module = osl_loadModuleRelativeAscii(baseModule, relativePath, mode);
+ return is();
+ }
+
+ void SAL_CALL unload()
+ {
+ if (m_Module)
+ {
+ osl_unloadModule(m_Module);
+ m_Module = 0;
+ }
+ }
+
+#endif
+
+ sal_Bool SAL_CALL is() const
+ {
+ return m_Module != NULL;
+ }
+
+ void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
+ {
+ return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
+ }
+
+ /** Get function address by the function name in the module.
+
+ getFunctionSymbol is an alternative function for getSymbol.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param ustrFunctionSymbolName
+ [in] Function name to be looked up.
+
+ @return
+ <dl>
+ <dt>oslGenericFunction format function address</dt>
+ <dd>on success</dd>
+ <dt>NULL</dt>
+ <dd>lookup failed or parameter is somewhat invalid</dd>
+ </dl>
+
+ @see getSymbol
+ */
+ oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) const
+ {
+ return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
+ }
+
+ /// @since LibreOffice 3.5
+ oslGenericFunction SAL_CALL getFunctionSymbol(char const * name) const {
+ return osl_getAsciiFunctionSymbol(m_Module, name);
+ }
+
+ operator oslModule() const
+ {
+ return m_Module;
+ }
+
+private:
+ oslModule m_Module;
+
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/mutex.h b/include/osl/mutex.h
new file mode 100644
index 000000000000..1336d4fcea95
--- /dev/null
+++ b/include/osl/mutex.h
@@ -0,0 +1,74 @@
+/* -*- 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 _OSL_MUTEX_H_
+#define _OSL_MUTEX_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _oslMutexImpl;
+typedef struct _oslMutexImpl * oslMutex;
+
+/** Create a thread-local mutex.
+ @return 0 if the mutex could not be created, otherwise a handle to the mutex.
+*/
+SAL_DLLPUBLIC oslMutex SAL_CALL osl_createMutex(void);
+
+/** Release the OS-structures and free mutex data-structure.
+ @param Mutex the mutex-handle
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_destroyMutex(oslMutex Mutex);
+
+/** Acquire the mutex, block if already acquired by another thread.
+ @param Mutex handle to a created mutex.
+ @return False if system-call fails.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex);
+
+/** Try to acquire the mutex without blocking.
+ @param Mutex handle to a created mutex.
+ @return False if it could not be acquired.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex);
+
+/** Release the mutex.
+ @param Mutex handle to a created mutex.
+ @return False if system-call fails.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex);
+
+/** Returns a unique and global mutex.
+ @return the global mutex.
+*/
+SAL_DLLPUBLIC oslMutex * SAL_CALL osl_getGlobalMutex(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_MUTEX_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/mutex.hxx b/include/osl/mutex.hxx
new file mode 100644
index 000000000000..18ff44444223
--- /dev/null
+++ b/include/osl/mutex.hxx
@@ -0,0 +1,272 @@
+/* -*- 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 _OSL_MUTEX_HXX_
+#define _OSL_MUTEX_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/mutex.h>
+
+
+namespace osl
+{
+ /** A mutual exclusion synchronization object
+ */
+ class SAL_WARN_UNUSED Mutex {
+
+ public:
+ /** Create a thread-local mutex.
+ @return 0 if the mutex could not be created, otherwise a handle to the mutex.
+ @see ::osl_createMutex()
+ */
+ Mutex()
+ {
+ mutex = osl_createMutex();
+ }
+
+ /** Release the OS-structures and free mutex data-structure.
+ @see ::osl_destroyMutex()
+ */
+ ~Mutex()
+ {
+ osl_destroyMutex(mutex);
+ }
+
+ /** Acquire the mutex, block if already acquired by another thread.
+ @return sal_False if system-call fails.
+ @see ::osl_acquireMutex()
+ */
+ sal_Bool acquire()
+ {
+ return osl_acquireMutex(mutex);
+ }
+
+ /** Try to acquire the mutex without blocking.
+ @return sal_False if it could not be acquired.
+ @see ::osl_tryToAcquireMutex()
+ */
+ sal_Bool tryToAcquire()
+ {
+ return osl_tryToAcquireMutex(mutex);
+ }
+
+ /** Release the mutex.
+ @return sal_False if system-call fails.
+ @see ::osl_releaseMutex()
+ */
+ sal_Bool release()
+ {
+ return osl_releaseMutex(mutex);
+ }
+
+ /** Returns a global static mutex object.
+ The global and static mutex object can be used to initialize other
+ static objects in a thread safe manner.
+ @return the global mutex object
+ @see ::osl_getGlobalMutex()
+ */
+ static Mutex * getGlobalMutex()
+ {
+ return (Mutex *)osl_getGlobalMutex();
+ }
+
+ private:
+ oslMutex mutex;
+
+ /** The underlying oslMutex has no reference count.
+
+ Since the underlying oslMutex is not a reference counted object, copy
+ constructed Mutex may work on an already destructed oslMutex object.
+
+ */
+ Mutex(const Mutex&);
+
+ /** The underlying oslMutex has no reference count.
+
+ When destructed, the Mutex object destroys the undelying oslMutex,
+ which might cause severe problems in case it's a temporary object.
+
+ */
+ Mutex(oslMutex Mutex);
+
+ /** This assignment operator is private for the same reason as
+ the copy constructor.
+ */
+ Mutex& operator= (const Mutex&);
+
+ /** This assignment operator is private for the same reason as
+ the constructor taking a oslMutex argument.
+ */
+ Mutex& operator= (oslMutex);
+ };
+
+ /** A helper class for mutex objects and interfaces.
+ */
+ template<class T>
+ class Guard
+ {
+ private:
+ Guard( const Guard& );
+ const Guard& operator = ( const Guard& );
+
+ protected:
+ T * pT;
+ public:
+
+ /** Acquires the object specified as parameter.
+ */
+ Guard(T * pT_) : pT(pT_)
+ {
+ pT->acquire();
+ }
+
+ /** Acquires the object specified as parameter.
+ */
+ Guard(T & t) : pT(&t)
+ {
+ pT->acquire();
+ }
+
+ /** Releases the mutex or interface. */
+ ~Guard()
+ {
+ pT->release();
+ }
+ };
+
+ /** A helper class for mutex objects and interfaces.
+ */
+ template<class T>
+ class ClearableGuard
+ {
+ private:
+ ClearableGuard( const ClearableGuard& );
+ const ClearableGuard& operator = ( const ClearableGuard& );
+ protected:
+ T * pT;
+ public:
+
+ /** Acquires the object specified as parameter.
+ */
+ ClearableGuard(T * pT_) : pT(pT_)
+ {
+ pT->acquire();
+ }
+
+ /** Acquires the object specified as parameter.
+ */
+ ClearableGuard(T & t) : pT(&t)
+ {
+ pT->acquire();
+ }
+
+ /** Releases the mutex or interface if not already released by clear().
+ */
+ ~ClearableGuard()
+ {
+ if (pT)
+ pT->release();
+ }
+
+ /** Releases the mutex or interface.
+ */
+ void clear()
+ {
+ if(pT)
+ {
+ pT->release();
+ pT = NULL;
+ }
+ }
+ };
+
+ /** A helper class for mutex objects and interfaces.
+ */
+ template< class T >
+ class ResettableGuard : public ClearableGuard< T >
+ {
+ private:
+ ResettableGuard(ResettableGuard &); // not defined
+ void operator =(ResettableGuard &); // not defined
+
+ protected:
+ T* pResetT;
+ public:
+ /** Acquires the object specified as parameter.
+ */
+ ResettableGuard( T* pT_ ) :
+ ClearableGuard<T>( pT_ ),
+ pResetT( pT_ )
+ {}
+
+ /** Acquires the object specified as parameter.
+ */
+ ResettableGuard( T& rT ) :
+ ClearableGuard<T>( rT ),
+ pResetT( &rT )
+ {}
+
+ /** Re-aquires the mutex or interface.
+ */
+ void reset()
+ {
+ if( pResetT )
+ {
+ this->pT = pResetT;
+ this->pT->acquire();
+ }
+ }
+ };
+
+ typedef Guard<Mutex> MutexGuard;
+ typedef ClearableGuard<Mutex> ClearableMutexGuard;
+ typedef ResettableGuard< Mutex > ResettableMutexGuard;
+
+ /** SolarMutex interface, needed for SolarMutex.
+ Deprecated, used just for Application::GetSolarMutex().
+ */
+ class SolarMutex
+ {
+ public:
+ /** Blocks if mutex is already in use
+ */
+ virtual void SAL_CALL acquire() = 0;
+
+ /** Tries to get the mutex without blocking.
+ */
+ virtual sal_Bool SAL_CALL tryToAcquire() = 0;
+
+ /** Releases the mutex.
+ */
+ virtual void SAL_CALL release() = 0;
+
+ protected:
+ SolarMutex() {}
+ virtual ~SolarMutex() {}
+ };
+ typedef osl::Guard< SolarMutex > SolarGuard;
+ typedef osl::ClearableGuard< SolarMutex > ClearableSolarGuard;
+ typedef osl::ResettableGuard< SolarMutex > ResettableSolarGuard;
+}
+
+#endif /* __cplusplus */
+#endif /* _OSL_MUTEX_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/nlsupport.h b/include/osl/nlsupport.h
new file mode 100644
index 000000000000..9af93d9237ec
--- /dev/null
+++ b/include/osl/nlsupport.h
@@ -0,0 +1,57 @@
+/* -*- 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 _OSL_NLSUPPORT_H_
+#define _OSL_NLSUPPORT_H_
+
+#include "sal/config.h"
+
+#include "rtl/locale.h"
+#include "rtl/textenc.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ Determines the text encoding used by the underlying platform for the
+ specified locale.
+
+ @param pLocale
+ the locale to return the text encoding for. If this parameter is NULL,
+ the default locale of the current process is used.
+
+ @returns the rtl_TextEncoding that matches the platform specific encoding
+ description or RTL_TEXTENCODING_DONTKNOW if no mapping is available.
+*/
+
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale(
+ rtl_Locale * pLocale );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_NLSUPPORT_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/pipe.h b/include/osl/pipe.h
new file mode 100644
index 000000000000..52ba8b9813e6
--- /dev/null
+++ b/include/osl/pipe.h
@@ -0,0 +1,97 @@
+/* -*- 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 _OSL_PIPE_H_
+#define _OSL_PIPE_H_
+
+#include "sal/config.h"
+
+#include "osl/security.h"
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ osl_Pipe_E_None, /* no error */
+ osl_Pipe_E_NotFound, /* Pipe could not be found */
+ osl_Pipe_E_AlreadyExists, /* Pipe already exists */
+ osl_Pipe_E_NoProtocol, /* Protocol not available */
+ osl_Pipe_E_NetworkReset, /* Network dropped connection because of reset */
+ osl_Pipe_E_ConnectionAbort, /* Software caused connection abort */
+ osl_Pipe_E_ConnectionReset, /* Connection reset by peer */
+ osl_Pipe_E_NoBufferSpace, /* No buffer space available */
+ osl_Pipe_E_TimedOut, /* Connection timed out */
+ osl_Pipe_E_ConnectionRefused, /* Connection refused */
+ osl_Pipe_E_invalidError, /* unmapped error: always last entry in enum! */
+ osl_Pipe_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslPipeError;
+
+typedef sal_uInt32 oslPipeOptions;
+#define osl_Pipe_OPEN 0x0000 /* open existing pipe */
+#define osl_Pipe_CREATE 0x0001 /* create pipe and open it, fails if already existst */
+
+typedef struct oslPipeImpl * oslPipe;
+
+/**
+ */
+SAL_DLLPUBLIC oslPipe SAL_CALL osl_createPipe(
+ rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security);
+
+/** decreases the refcount of the pipe.
+ If the refcount drops to zero, the handle is destroyed.
+ */
+SAL_DLLPUBLIC void SAL_CALL osl_releasePipe( oslPipe );
+
+/** increases the refcount of the pipe.
+ */
+SAL_DLLPUBLIC void SAL_CALL osl_acquirePipe( oslPipe Pipe );
+
+/** closes the pipe, any read,write or accept actions stop immeadiatly.
+ */
+SAL_DLLPUBLIC void SAL_CALL osl_closePipe( oslPipe );
+
+
+SAL_DLLPUBLIC oslPipe SAL_CALL osl_acceptPipe(oslPipe Pipe);
+
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_sendPipe(oslPipe Pipe, const void* pBuffer, sal_Int32 BufferSize);
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_receivePipe(oslPipe Pipe, void* pBuffer, sal_Int32 BufferSize);
+
+/** Reads blocking from the pipe.
+ @return Number of read bytes. If less than BufferSize, the pipe was closed.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_readPipe( oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize );
+
+/** Writes blocking onto the pipe.
+ @return Number of written bytes. If less than BufferSize, the pipe was closed.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_writePipe( oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize );
+
+SAL_DLLPUBLIC oslPipeError SAL_CALL osl_getLastPipeError(oslPipe Pipe);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_PIPE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/pipe.hxx b/include/osl/pipe.hxx
new file mode 100644
index 000000000000..906ca8b08fb8
--- /dev/null
+++ b/include/osl/pipe.hxx
@@ -0,0 +1,206 @@
+/* -*- 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 _OSL_PIPE_HXX_
+#define _OSL_PIPE_HXX_
+
+#include <osl/pipe_decl.hxx>
+
+namespace osl
+{
+ //______________________________________________________________________________
+ inline Pipe::Pipe()
+ : m_handle( 0 )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
+ : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
+ : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(const Pipe& pipe )
+ : m_handle( pipe.m_handle )
+ {
+ if( m_handle )
+ osl_acquirePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
+ : m_handle ( pipe )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(oslPipe pipe)
+ : m_handle( pipe )
+ {
+ if( m_handle )
+ osl_acquirePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Pipe::~Pipe()
+ {
+ if( m_handle )
+ osl_releasePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
+ oslPipeOptions Options, const Security &rSec )
+ {
+ *this = Pipe( strName, Options, rSec );
+ return is();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
+ {
+ *this = Pipe( strName, Options );
+ return is();
+ }
+ //______________________________________________________________________________
+ inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
+ {
+ *this = pipe.getHandle();
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
+ {
+ if( pipe )
+ osl_acquirePipe( pipe );
+ if( m_handle )
+ osl_releasePipe( m_handle );
+ m_handle = pipe;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL Pipe::is() const
+ {
+ return m_handle != 0;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
+ {
+ return m_handle == rPipe.m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline void SAL_CALL Pipe::close()
+ {
+ osl_closePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline void SAL_CALL Pipe::clear()
+ {
+ if( m_handle )
+ {
+ osl_releasePipe( m_handle );
+ m_handle = 0;
+ }
+ }
+
+ //______________________________________________________________________________
+ inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
+ {
+ Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE);
+ if( Connection.is() )
+ return osl_Pipe_E_None;
+ else
+ return getError();
+ }
+
+ //______________________________________________________________________________
+ inline oslPipeError SAL_CALL Pipe::getError() const
+ {
+ return osl_getLastPipeError( 0 );
+ }
+
+ //______________________________________________________________________________
+ inline oslPipe SAL_CALL Pipe::getHandle() const
+ {
+ return m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(){}
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(oslPipe hPipe)
+ : Pipe( hPipe )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
+ : Pipe( strName, Options , rSec )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
+ : Pipe( strName, Options )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
+ : Pipe( aPipe )
+ {}
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire )
+ : Pipe( pipe , noacquire )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
+ {
+ return osl_readPipe( m_handle, pBuffer, n );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
+ {
+ return osl_writePipe( m_handle, pBuffer , n );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
+ {
+ return osl_receivePipe( m_handle, pBuffer , BytesToRead );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
+ {
+ return osl_sendPipe( m_handle, pBuffer , BytesToSend );
+ }
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/pipe_decl.hxx b/include/osl/pipe_decl.hxx
new file mode 100644
index 000000000000..21e07952b7ff
--- /dev/null
+++ b/include/osl/pipe_decl.hxx
@@ -0,0 +1,229 @@
+/* -*- 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 _OSL_PIPE_DECL_HXX_
+#define _OSL_PIPE_DECL_HXX_
+
+#include <osl/pipe.h>
+# include <osl/security.hxx>
+#include <rtl/ustring.hxx>
+
+namespace osl {
+
+class StreamPipe;
+
+/** Represents a pipe.
+*/
+class Pipe
+{
+protected:
+ oslPipe m_handle;
+
+public:
+
+ /** Does not create a pipe. Use assignment operator to
+ make this a useable pipe.
+ */
+ inline Pipe();
+
+ /** Creates an insecure pipe that is accessible for all users.
+ @param strName
+ @param Options
+ */
+ inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options);
+
+ /** Creates a secure pipe that access depends on the umask settings.
+ @param strName
+ @param Options
+ @param rSecurity
+ */
+ inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity);
+
+ /** Copy constructor.
+ */
+ inline Pipe(const Pipe& pipe);
+
+ /** Constructs a Pipe reference without acquiring the handle
+ */
+ inline Pipe( oslPipe pipe, __sal_NoAcquire noacquire );
+
+ /** Creates pipe as wrapper around the underlying oslPipe.
+ @param Pipe
+ */
+ inline Pipe(oslPipe Pipe);
+
+ /** Destructor. Destroys the underlying oslPipe.
+ */
+ inline ~Pipe();
+
+ inline sal_Bool SAL_CALL is() const;
+
+ /** Creates an insecure pipe that is accessible for all users
+ with the given attributes.
+ If the pipe was already created, the old one will be discarded.
+ @param strName
+ @param Options
+ @param rSec
+ @return True if socket was successfully created.
+ */
+ inline sal_Bool create( const ::rtl::OUString & strName,
+ oslPipeOptions Options, const Security &rSec );
+
+ /** Creates a secure that access rights depend on the umask settings
+ with the given attributes.
+
+ If socket was already created, the old one will be discarded.
+ @param strName
+ @param Options
+ @return True if socket was successfully created.
+ */
+ inline sal_Bool create( const ::rtl::OUString & strName, oslPipeOptions Options = osl_Pipe_OPEN );
+
+ /** releases the underlying handle
+ */
+ inline void SAL_CALL clear();
+
+ /** Assignment operator. If pipe was already created, the old one will
+ be discarded.
+ */
+ inline Pipe& SAL_CALL operator= (const Pipe& pipe);
+
+ /** Assignment operator. If pipe was already created, the old one will
+ be discarded.
+ */
+ inline Pipe& SAL_CALL operator= (const oslPipe pipe );
+
+ /** Checks if the pipe is valid.
+ @return True if the object represents a valid pipe.
+ */
+ inline sal_Bool SAL_CALL isValid() const;
+
+ inline sal_Bool SAL_CALL operator==( const Pipe& rPipe ) const;
+
+ /** Closes the pipe.
+ */
+ inline void SAL_CALL close();
+
+ /** Accept connection on an existing pipe
+ */
+ inline oslPipeError SAL_CALL accept(StreamPipe& Connection);
+
+
+ /** Delivers a constant decribing the last error for the pipe system.
+ @return ENONE if no error occurred, invalid_PipeError if
+ an unknown (unmapped) error occurred, otherwise an enum describing the
+ error.
+ */
+ inline oslPipeError SAL_CALL getError() const;
+
+ inline oslPipe SAL_CALL getHandle() const;
+};
+
+/** A pipe to send or receive a stream of data.
+*/
+class StreamPipe : public Pipe
+{
+public:
+
+ /** Creates an unattached pipe. You must attach the pipe to an oslPipe
+ e.g. by using the operator=(oslPipe), before you can use the stream-
+ functionality of the object.
+ */
+ inline StreamPipe();
+
+ /** Creates pipe as wrapper around the underlying oslPipe.
+ @param Pipe
+ */
+ inline StreamPipe(oslPipe Pipe);
+
+ /** Copy constructor.
+ @param Pipe
+ */
+ inline StreamPipe(const StreamPipe& Pipe);
+
+ /** Creates a pipe.
+ @param strName
+ @param Options
+ */
+ inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options = osl_Pipe_OPEN);
+
+ /** Creates a pipe.
+ @param strName
+ @param Options
+ @param rSec
+ */
+ inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec );
+
+ /** Constructs a Pipe reference without acquiring the handle
+ */
+ inline StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire );
+
+ /** Attaches the oslPipe to this object. If the object
+ already was attached to an oslPipe, the old one will
+ be closed and destroyed.
+ @param Pipe
+ */
+ inline StreamPipe & SAL_CALL operator=(oslPipe Pipe);
+
+ /** Assignment operator
+ */
+ inline StreamPipe& SAL_CALL operator=(const Pipe& pipe);
+
+ /** Tries to receives BytesToRead data from the connected pipe,
+
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ data.
+ @param BytesToRead [in] The number of bytes to read. pBuffer must have at least
+ this size.
+ @return the number of received bytes.
+ */
+ inline sal_Int32 SAL_CALL recv(void* pBuffer, sal_Int32 BytesToRead) const;
+
+ /** Tries to sends BytesToSend data from the connected pipe.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @return the number of transfered bytes.
+ */
+ inline sal_Int32 SAL_CALL send(const void* pBuffer, sal_Int32 BytesToSend) const;
+
+ /** Retrieves n bytes from the stream and copies them into pBuffer.
+ The method avoids incomplete reads due to packet boundaries.
+ @param pBuffer receives the read data.
+ @param n the number of bytes to read. pBuffer must be large enough
+ to hold the n bytes!
+ @return the number of read bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ inline sal_Int32 SAL_CALL read(void* pBuffer, sal_Int32 n) const;
+
+ /** Writes n bytes from pBuffer to the stream. The method avoids
+ incomplete writes due to packet boundaries.
+ @param pBuffer contains the data to be written.
+ @param n the number of bytes to write.
+ @return the number of written bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ sal_Int32 SAL_CALL write(const void* pBuffer, sal_Int32 n) const;
+};
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/process.h b/include/osl/process.h
new file mode 100644
index 000000000000..241f9a857552
--- /dev/null
+++ b/include/osl/process.h
@@ -0,0 +1,451 @@
+/* -*- 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 _OSL_PROCESS_H_
+#define _OSL_PROCESS_H_
+
+#include "sal/config.h"
+
+#include "osl/file.h"
+#include "osl/pipe.h"
+#include "osl/security.h"
+#include "osl/socket.h"
+#include "osl/time.h"
+#include "rtl/locale.h"
+#include "rtl/textenc.h"
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef sal_Int32 oslProcessOption;
+#define osl_Process_WAIT 0x0001 /* wait for completion */
+#define osl_Process_SEARCHPATH 0x0002 /* search path for executable */
+#define osl_Process_DETACHED 0x0004 /* run detached */
+#define osl_Process_NORMAL 0x0000 /* run in normal window */
+#define osl_Process_HIDDEN 0x0010 /* run hidden */
+#define osl_Process_MINIMIZED 0x0020 /* run in minimized window */
+#define osl_Process_MAXIMIZED 0x0040 /* run in maximized window */
+#define osl_Process_FULLSCREEN 0x0080 /* run in fullscreen window */
+
+typedef sal_Int32 oslProcessData;
+
+/* defines for osl_getProcessInfo , can be OR'ed */
+#define osl_Process_IDENTIFIER 0x0001 /* retrieves the process identifier */
+#define osl_Process_EXITCODE 0x0002 /* retrieves exit code of the process */
+#define osl_Process_CPUTIMES 0x0004 /* retrieves used cpu time */
+#define osl_Process_HEAPUSAGE 0x0008 /* retrieves the used size of heap */
+
+typedef sal_uInt32 oslProcessIdentifier;
+typedef sal_uInt32 oslProcessExitCode;
+
+typedef enum {
+ osl_Process_E_None, /* no error */
+ osl_Process_E_NotFound, /* image not found */
+ osl_Process_E_TimedOut, /* timout occurred */
+ osl_Process_E_NoPermission, /* permission denied */
+ osl_Process_E_Unknown, /* unknown error */
+ osl_Process_E_InvalidError, /* unmapped error */
+ osl_Process_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslProcessError;
+
+typedef enum {
+ osl_Process_TypeNone, /* no descriptor */
+ osl_Process_TypeSocket, /* socket */
+ osl_Process_TypeFile, /* file */
+ osl_Process_TypePipe, /* pipe */
+ osl_Process_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslDescriptorType;
+
+typedef sal_Int32 oslDescriptorFlag;
+#define osl_Process_DFNONE 0x0000
+#define osl_Process_DFWAIT 0x0001
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+typedef struct {
+ sal_uInt32 Size;
+ oslProcessData Fields;
+ oslProcessIdentifier Ident;
+ oslProcessExitCode Code;
+ TimeValue UserTime;
+ TimeValue SystemTime;
+ sal_uInt32 HeapUsage;
+} oslProcessInfo;
+
+#if defined( SAL_W32)
+# pragma pack(pop)
+#endif
+
+/** Process handle
+
+ @see osl_executeProcess
+ @see osl_terminateProcess
+ @see osl_freeProcessHandle
+ @see osl_getProcessInfo
+ @see osl_joinProcess
+*/
+typedef void* oslProcess;
+
+/** Execute a process.
+
+ Executes the program image provided in strImageName in a new process.
+
+ @param ustrImageName
+ [in] The file URL of the executable to be started.
+ Can be NULL in this case the file URL of the executable must be the first element
+ in ustrArguments.
+
+ @param ustrArguments
+ [in] An array of argument strings. Can be NULL if strImageName is not NULL.
+ If strImageName is NULL it is expected that the first element contains
+ the file URL of the executable to start.
+
+ @param nArguments
+ [in] The number of arguments provided. If this number is 0 strArguments will be ignored.
+
+ @param Options
+ [in] A combination of int-constants to describe the mode of execution.
+
+ @param Security
+ [in] The user and his rights for which the process is started. May be NULL in which case
+ the process will be started in the context of the current user.
+
+ @param ustrDirectory
+ [in] The file URL of the working directory of the new proces. If the specified directory
+ does not exist or is inaccessible the working directory of the newly created process
+ is undefined. If this parameter is NULL or the caller provides an empty string the
+ new process will have the same current working directory as the calling process.
+
+ @param ustrEnvironments
+ [in] An array of strings describing environment variables that should be merged into the
+ environment of the new process. Each string has to be in the form "variable=value".
+ This parameter can be NULL in which case the new process gets the same environment
+ as the parent process.
+
+ @param nEnvironmentVars
+ [in] The number of environment variables to set.
+
+ @param pProcess
+ [out] Pointer to a oslProcess variable, wich receives the handle of the newly created process.
+ This parameter must not be NULL.
+
+ @return
+ <dl>
+ <dt>osl_Process_E_None</dt>
+ <dd>on success</dd>
+ <dt>osl_Process_E_NotFound</dt>
+ <dd>if the specified executable could not be found</dd>
+ <dt>osl_Process_E_InvalidError</dt>
+ <dd>if invalid parameters will be detected</dd>
+ <dt>osl_Process_E_Unknown</dt>
+ <dd>if arbitrary other errors occur</dd>
+ </dl>
+
+ @see oslProcessOption
+ @see osl_executeProcess_WithRedirectedIO
+ @see osl_freeProcessHandle
+ @see osl_loginUser
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_executeProcess(
+ rtl_uString* ustrImageName,
+ rtl_uString* ustrArguments[],
+ sal_uInt32 nArguments,
+ oslProcessOption Options,
+ oslSecurity Security,
+ rtl_uString* ustrDirectory,
+ rtl_uString* ustrEnvironments[],
+ sal_uInt32 nEnvironmentVars,
+ oslProcess* pProcess);
+
+
+/** Execute a process and redirect child process standard IO.
+
+ @param strImageName
+ [in] The file URL of the executable to be started.
+ Can be NULL in this case the file URL of the executable must be the first element
+ in ustrArguments.
+
+ @param ustrArguments
+ [in] An array of argument strings. Can be NULL if strImageName is not NULL.
+ If strImageName is NULL it is expected that the first element contains
+ the file URL of the executable to start.
+
+ @param nArguments
+ [in] The number of arguments provided. If this number is 0 strArguments will be ignored.
+
+ @param Options
+ [in] A combination of int-constants to describe the mode of execution.
+
+ @param Security
+ [in] The user and his rights for which the process is started. May be NULL in which case
+ the process will be started in the context of the current user.
+
+ @param ustrDirectory
+ [in] The file URL of the working directory of the new proces. If the specified directory
+ does not exist or is inaccessible the working directory of the newly created process
+ is undefined. If this parameter is NULL or the caller provides an empty string the
+ new process will have the same current working directory as the calling process.
+
+ @param ustrEnvironments
+ [in] An array of strings describing environment variables that should be merged into the
+ environment of the new process. Each string has to be in the form "variable=value".
+ This parameter can be NULL in which case the new process gets the same environment
+ as the parent process.
+
+ @param nEnvironmentVars
+ [in] The number of environment variables to set.
+
+ @param pProcess
+ [out] Pointer to a oslProcess variable, wich receives the handle of the newly created process.
+ This parameter must not be NULL.
+
+ @param pChildInputWrite
+ [in] Pointer to a oslFileHandle variable that receives the handle which can be used to write
+ to the child process standard input device. The returned handle is not random accessible.
+ The handle has to be closed with osl_closeFile if no longer used. This parameter can be NULL.
+
+ @param pChildOutputRead
+ [in] Pointer to a oslFileHandle variable that receives the handle which can be used to read from
+ the child process standard output device. The returned handle is not random accessible.
+ The Handle has to be closed with osl_closeFile if no longer used. This parameter can be NULL.
+
+ @param pChildErrorRead
+ [in] Pointer to a oslFileHandle variable that receives the handle which can be used to read from
+ the child process standard error device. The returned handle is not random accessible.
+ The Handle has to be closed with osl_closeFile if no longer used. This parameter can be NULL.
+
+ @return
+ <dl>
+ <dt>osl_Process_E_None</dt>
+ <dd>on success</dd>
+ <dt>osl_Process_E_NotFound</dt>
+ <dd>if the specified executable could not be found</dd>
+ <dt>osl_Process_E_InvalidError</dt>
+ <dd>if invalid parameters will be detected</dd>
+ <dt>osl_Process_E_Unknown</dt>
+ <dd>if arbitrary other errors occur</dd>
+ </dl>
+
+ @see oslProcessOption
+ @see osl_executeProcess
+ @see osl_freeProcessHandle
+ @see osl_loginUser
+ @see osl_closeFile
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
+ rtl_uString* strImageName,
+ rtl_uString* ustrArguments[],
+ sal_uInt32 nArguments,
+ oslProcessOption Options,
+ oslSecurity Security,
+ rtl_uString* ustrDirectory,
+ rtl_uString* ustrEnvironments[],
+ sal_uInt32 nEnvironmentVars,
+ oslProcess* pProcess,
+ oslFileHandle* pChildInputWrite,
+ oslFileHandle* pChildOutputRead,
+ oslFileHandle* pChildErrorRead);
+
+/** Terminate a process
+ @param Process [in] the handle of the process to be terminated
+
+ @see osl_executeProcess
+ @see osl_getProcess
+ @see osl_joinProcess
+ */
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_terminateProcess(
+ oslProcess Process);
+
+
+/** @deprecated
+ Retrieve the process handle of a process identifier
+ @param Ident [in] a process identifier
+
+ @return the process handle on success, NULL in all other cases
+ */
+SAL_DLLPUBLIC oslProcess SAL_CALL osl_getProcess(
+ oslProcessIdentifier Ident);
+
+
+/** Free the specified proces-handle.
+ @param Process [in]
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_freeProcessHandle(
+ oslProcess Process);
+
+
+/** Wait for completation of the specified childprocess.
+ @param Process [in]
+ @return ols_Process_E_None
+ @see osl_executeProcess
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_joinProcess(
+ oslProcess Process);
+
+/** Wait with a timeout for the completion of the specified child
+ process.
+
+ @param Process [in]
+ A process identifier.
+
+ @param pTimeout [in]
+ A timeout value or NULL for infinite waiting.
+ The unit of resolution is second.
+
+ @return
+ osl_Process_E_None on success
+ osl_Process_E_TimedOut waiting for the child process timed out
+ osl_Process_E_Unknown an error occurred or the parameter are invalid
+
+ @see osl_executeProcess
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_joinProcessWithTimeout(
+ oslProcess Process, const TimeValue* pTimeout);
+
+/** Retrieves information about a Process
+ @param[in] Process the process handle of the process
+ @param[in] Fields the information which is to be retrieved
+ this can be one or more of
+ osl_Process_IDENTIFIER
+ osl_Process_EXITCODE
+ osl_Process_CPUTIMES
+ osl_Process_HEAPUSAGE
+ @param[out] pInfo a pointer to a vaid oslProcessInfo structure.
+ the Size field has to be initialized with the size
+ of the oslProcessInfo structure.
+ on success the Field member holds the (or'ed)
+ retrieved valid information fields.
+ @return osl_Process_E_None on success, osl_Process_E_Unknown on failure.
+ */
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getProcessInfo(
+ oslProcess Process, oslProcessData Fields, oslProcessInfo* pInfo);
+
+/** Get the filename of the executable.
+ @param strFile [out] the string that receives the executable file path.
+ @return osl_Process_E_None or does not return.
+ @see osl_executeProcess
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getExecutableFile(
+ rtl_uString **strFile);
+
+/** @return the number of commandline arguments passed to the main-function of
+ this process
+ @see osl_getCommandArg
+*/
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getCommandArgCount(void);
+
+/** Get the nArg-th command-line argument passed to the main-function of this process.
+ @param nArg [in] The number of the argument to return.
+ @param strCommandArg [out] The string receives the nArg-th command-line argument.
+ @return osl_Process_E_None or does not return.
+ @see osl_executeProcess
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getCommandArg(
+ sal_uInt32 nArg, rtl_uString **strCommandArg);
+
+/** Set the command-line arguments as passed to the main-function of this process.
+
+ Depricated: This function is only for internal use. Passing the args from main will
+ only work for Unix, on Windows there's no effect, the full command line will automtically
+ be taken. This is due to Windows 9x/ME limitation that don't allow UTF-16 wmain to provide
+ a osl_setCommandArgsU( int argc, sal_Unicode **argv );
+
+ @param argc [in] The number of elements in the argv array.
+ @param argv [in] The array of command-line arguments.
+ @see osl_getExecutableFile
+ @see osl_getCommandArgCount
+ @see osl_getCommandArg
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_setCommandArgs (int argc, char **argv);
+
+/** Get the value of one enviroment variable.
+ @param strVar [in] denotes the name of the variable to get.
+ @param strValue [out] string that receives the value of environment variable.
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getEnvironment(
+ rtl_uString *strVar, rtl_uString **strValue);
+
+/** Set the value of one enviroment variable.
+ @param strVar [in] denotes the name of the variable to set.
+ @param strValue [in] string of the new value of environment variable.
+
+ @since UDK 3.2.13
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_setEnvironment(
+ rtl_uString *strVar, rtl_uString *strValue);
+
+/** Unsets the value of one enviroment variable.
+ @param strVar [in] denotes the name of the variable to unset.
+
+ @since UDK 3.2.13
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_clearEnvironment(
+ rtl_uString *strVar);
+
+/** Get the working directory of the current process as a file URL.
+
+ The file URL is encoded as common for the OSL file API.
+ @param pustrWorkingDir [out] string that receives the working directory file URL.
+*/
+
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getProcessWorkingDir(
+ rtl_uString **pustrWorkingDir );
+
+/** Get the locale the process is currently running in.
+
+ The unix implementation caches the value it returns, so if you have to change the locale
+ your are running in, you will have to use osl_setProcessLocale therefor.
+
+ @param ppLocale [out] a pointer that receives the currently selected locale structure
+ @see osl_setProcessLocale
+*/
+
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getProcessLocale(
+ rtl_Locale ** ppLocale );
+
+/** Change the locale of the process.
+
+ @param pLocale [in] a pointer to the locale to be set
+ @see osl_getProcessLocale
+*/
+
+SAL_DLLPUBLIC oslProcessError SAL_CALL osl_setProcessLocale(
+ rtl_Locale * pLocale );
+
+
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_sendResourcePipe(
+ oslPipe Pipe, oslSocket Socket );
+
+SAL_DLLPUBLIC oslSocket SAL_CALL osl_receiveResourcePipe(
+ oslPipe Pipe );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_PROCESS_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/profile.h b/include/osl/profile.h
new file mode 100644
index 000000000000..fcbf898c5754
--- /dev/null
+++ b/include/osl/profile.h
@@ -0,0 +1,145 @@
+/* -*- 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 _OSL_PROFILE_H_
+#define _OSL_PROFILE_H_
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef sal_uInt32 oslProfileOption;
+
+#define osl_Profile_DEFAULT 0x0000
+#define osl_Profile_SYSTEM 0x0001 /* use system depended functinality */
+#define osl_Profile_READLOCK 0x0002 /* lock file for reading */
+#define osl_Profile_WRITELOCK 0x0004 /* lock file for writing */
+#define osl_Profile_FLUSHWRITE 0x0010 /* writing only with flush */
+
+
+typedef void* oslProfile;
+
+/** Deprecated API.
+ Open or create a configuration profile.
+ @return 0 if the profile could not be created, otherwise a handle to the profile.
+ @deprecated
+*/
+SAL_DLLPUBLIC oslProfile SAL_CALL osl_openProfile(
+ rtl_uString *strProfileName, oslProfileOption Options);
+
+/** Deprecated API.
+ Close the opened profile an flush all data to the disk.
+ @param Profile handle to a opened profile.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_closeProfile(
+ oslProfile Profile);
+
+
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_flushProfile(
+ oslProfile Profile);
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_readProfileString(
+ oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_Char* pszString, sal_uInt32 MaxLen,
+ const sal_Char* pszDefault);
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_readProfileBool(
+ oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_Bool Default);
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_readProfileIdent(
+ oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_uInt32 FirstId, const sal_Char* Strings[],
+ sal_uInt32 Default);
+
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_writeProfileString(
+ oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ const sal_Char* pszString);
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_writeProfileBool(
+ oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_Bool Value);
+/** Deprecated API.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_writeProfileIdent(
+ oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_uInt32 FirstId, const sal_Char* Strings[],
+ sal_uInt32 Value);
+
+/** Deprecated API.
+ Acquire the mutex, block if already acquired by another thread.
+ @return False if section or entry could not be found.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_removeProfileEntry(
+ oslProfile Profile,
+ const sal_Char *pszSection, const sal_Char *pszEntry);
+
+/** Deprecated API.
+ Get all entries belonging to the specified section.
+ @return Pointer to a array of pointers.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getProfileSectionEntries(
+ oslProfile Profile, const sal_Char *pszSection,
+ sal_Char* pszBuffer, sal_uInt32 MaxLen);
+
+/** Deprecated API.
+ Get all section entries
+ @return Pointer to a array of pointers.
+ @deprecated
+*/
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getProfileSections(
+ oslProfile Profile, sal_Char* pszBuffer, sal_uInt32 MaxLen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_PROFILE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/profile.hxx b/include/osl/profile.hxx
new file mode 100644
index 000000000000..452a37cbff39
--- /dev/null
+++ b/include/osl/profile.hxx
@@ -0,0 +1,196 @@
+/* -*- 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 _OSL_PROFILE_HXX_
+#define _OSL_PROFILE_HXX_
+
+#include "profile.h"
+#include <rtl/ustring.hxx>
+#include <string.h>
+#include <list>
+
+namespace osl {
+
+ typedef oslProfileOption ProfileOption;
+
+ const int Profile_DEFAULT = osl_Profile_DEFAULT;
+ const int Profile_SYSTEM = osl_Profile_SYSTEM; /* use system depended functinality */
+ const int Profile_READLOCK = osl_Profile_READLOCK; /* lock file for reading */
+ const int Profile_WRITELOCK = osl_Profile_WRITELOCK; /* lock file for writing */
+
+ /** Deprecated API.
+ @deprecated
+ */
+ class Profile {
+ oslProfile profile;
+
+ public:
+ /** Open or create a configuration profile.
+ @return 0 if the profile could not be created, otherwise a handle to the profile.
+ */
+ Profile(const rtl::OUString strProfileName, oslProfileOption Options = Profile_DEFAULT )
+ {
+ profile = osl_openProfile(strProfileName.pData, Options);
+ if( ! profile )
+ throw std::exception();
+ }
+
+
+ /** Close the opened profile an flush all data to the disk.
+ */
+ ~Profile()
+ {
+ osl_closeProfile(profile);
+ }
+
+
+ sal_Bool flush()
+ {
+ return osl_flushProfile(profile);
+ }
+
+ rtl::OString readString( const rtl::OString& rSection, const rtl::OString& rEntry,
+ const rtl::OString& rDefault)
+ {
+ sal_Char aBuf[1024];
+ return osl_readProfileString( profile,
+ rSection.getStr(),
+ rEntry.getStr(),
+ aBuf,
+ sizeof( aBuf ),
+ rDefault.getStr() ) ? rtl::OString( aBuf ) : rtl::OString();
+
+ }
+
+ sal_Bool readBool( const rtl::OString& rSection, const rtl::OString& rEntry, sal_Bool bDefault )
+ {
+ return osl_readProfileBool( profile, rSection.getStr(), rEntry.getStr(), bDefault );
+ }
+
+ sal_uInt32 readIdent(const rtl::OString& rSection, const rtl::OString& rEntry,
+ sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings,
+ sal_uInt32 nDefault)
+ {
+ int nItems = rStrings.size();
+ const sal_Char** pStrings = new const sal_Char*[ nItems+1 ];
+ std::list< rtl::OString >::const_iterator it = rStrings.begin();
+ nItems = 0;
+ while( it != rStrings.end() )
+ {
+ pStrings[ nItems++ ] = it->getStr();
+ ++it;
+ }
+ pStrings[ nItems ] = NULL;
+ sal_uInt32 nRet = osl_readProfileIdent(profile, rSection.getStr(), rEntry.getStr(), nFirstId, pStrings, nDefault);
+ delete pStrings;
+ return nRet;
+ }
+
+ sal_Bool writeString(const rtl::OString& rSection, const rtl::OString& rEntry,
+ const rtl::OString& rString)
+ {
+ return osl_writeProfileString(profile, rSection.getStr(), rEntry.getStr(), rString.getStr());
+ }
+
+ sal_Bool writeBool(const rtl::OString& rSection, const rtl::OString& rEntry, sal_Bool Value)
+ {
+ return osl_writeProfileBool(profile, rSection.getStr(), rEntry.getStr(), Value);
+ }
+
+ sal_Bool writeIdent(const rtl::OString& rSection, const rtl::OString& rEntry,
+ sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings,
+ sal_uInt32 nValue)
+ {
+ int nItems = rStrings.size();
+ const sal_Char** pStrings = new const sal_Char*[ nItems+1 ];
+ std::list< rtl::OString >::const_iterator it = rStrings.begin();
+ nItems = 0;
+ while( it != rStrings.end() )
+ {
+ pStrings[ nItems++ ] = it->getStr();
+ ++it;
+ }
+ pStrings[ nItems ] = NULL;
+ sal_Bool bRet =
+ osl_writeProfileIdent(profile, rSection.getStr(), rEntry.getStr(), nFirstId, pStrings, nValue );
+ delete pStrings;
+ return bRet;
+ }
+
+ /** Remove an entry from a section.
+ @param rSection Name of the section.
+ @param rEntry Name of the entry to remove.
+ @return False if section or entry could not be found.
+ */
+ sal_Bool removeEntry(const rtl::OString& rSection, const rtl::OString& rEntry)
+ {
+ return osl_removeProfileEntry(profile, rSection.getStr(), rEntry.getStr());
+ }
+
+ /** Get all entries belonging to the specified section.
+ @param rSection Name of the section.
+ @return Pointer to a array of pointers.
+ */
+ std::list< rtl::OString > getSectionEntries(const rtl::OString& rSection )
+ {
+ std::list< rtl::OString > aEntries;
+
+ // count buffer size necessary
+ int n = osl_getProfileSectionEntries( profile, rSection.getStr(), NULL, 0 );
+ if( n > 1 )
+ {
+ sal_Char* pBuf = new sal_Char[ n+1 ];
+ osl_getProfileSectionEntries( profile, rSection.getStr(), pBuf, n+1 );
+ int nLen;
+ for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 )
+ aEntries.push_back( rtl::OString( pBuf+n ) );
+ delete pBuf;
+ }
+
+ return aEntries;
+ }
+
+ /** Get all section entries
+ @return Pointer to a array of pointers.
+ */
+ std::list< rtl::OString > getSections()
+ {
+ std::list< rtl::OString > aSections;
+
+ // count buffer size necessary
+ int n = osl_getProfileSections( profile, NULL, 0 );
+ if( n > 1 )
+ {
+ sal_Char* pBuf = new sal_Char[ n+1 ];
+ osl_getProfileSections( profile, pBuf, n+1 );
+ int nLen;
+ for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 )
+ aSections.push_back( rtl::OString( pBuf+n ) );
+ delete pBuf;
+ }
+
+ return aSections;
+ }
+ };
+}
+
+#endif /* _OSL_PROFILE_HXX_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/security.h b/include/osl/security.h
new file mode 100644
index 000000000000..b24625761731
--- /dev/null
+++ b/include/osl/security.h
@@ -0,0 +1,163 @@
+/* -*- 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 _OSL_SECURITY_H_
+#define _OSL_SECURITY_H_
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ osl_Security_E_None,
+ osl_Security_E_UserUnknown,
+ osl_Security_E_WrongPassword,
+ osl_Security_E_Unknown,
+ osl_Security_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSecurityError;
+
+/** Process handle
+ @see osl_loginUser
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+*/
+typedef void* oslSecurity;
+
+/** Create a security handle for the current user.
+ @return a security handle or NULL on failure.
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+ @see osl_executeApplication
+*/
+SAL_DLLPUBLIC oslSecurity SAL_CALL osl_getCurrentSecurity(void);
+
+/** Deprecated API
+ Create a security handle for the denoted user.
+ Try to log in the user on the local system.
+ @param[in] strUserName denotes the name of the user to logg in.
+ @param[in] strPasswd the password for this user.
+ @param[out] pSecurity returns the security handle if user could be logged in.
+ @return osl_Security_E_None if user could be logged in, otherwise an error-code.
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+ @see osl_executeApplication
+*/
+SAL_DLLPUBLIC oslSecurityError SAL_CALL osl_loginUser(
+ rtl_uString *strUserName,
+ rtl_uString *strPasswd,
+ oslSecurity *pSecurity
+ );
+
+/** Create a security handle for the denoted user.
+ Try to log in the user on the denoted file server. On success the homedir will be
+ the maped drive on this server.
+ @param[in] strUserName denotes the name of the user to logg in.
+ @param[in] strPasswd the password for this user.
+ @param[in] strFileServer denotes the file server on wich the user is logged in.
+ @param[out] pSecurity returns the security handle if user could be logged in.
+ @return osl_Security_E_None if user could be logged in, otherwise an error-code.
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+ @see osl_executeApplication
+*/
+SAL_DLLPUBLIC oslSecurityError SAL_CALL osl_loginUserOnFileServer(
+ rtl_uString *strUserName,
+ rtl_uString *strPasswd,
+ rtl_uString *strFileServer,
+ oslSecurity *pSecurity
+ );
+
+/** Query if the user who is denotes by this security has administrator rigths.
+ @param[in] Security the security handle for th user.
+ @return True, if the user has adminsitrator rights, otherwise false.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isAdministrator(
+ oslSecurity Security);
+
+/** Free the security handle, created by osl_loginUser or osl_getCurrentSecurity.
+ @param[in] Security the security handle.
+ @see osl_loginUser
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_freeSecurityHandle(
+ oslSecurity Security);
+
+/** Get the login ident for the user of this security handle.
+ @param[in] Security the security handle.
+ @param[out] strIdent the string that receives the ident on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getUserIdent(
+ oslSecurity Security, rtl_uString **strIdent);
+
+/** Get the login name for the user of this security handle.
+ @param[in] Security the security handle.
+ @param[out] strName the string that receives the user name on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getUserName(
+ oslSecurity Security, rtl_uString **strName);
+
+/** Get the home directory of the user of this security handle.
+ @param[in] Security the security handle.
+ @param[out] strDirectory the string that receives the directory path on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getHomeDir(
+ oslSecurity Security, rtl_uString **strDirectory);
+
+/** Get the directory for configuration data of the user of this security handle.
+ @param[in] Security the security handle.
+ @param[out] strDirectory the string that receives the directory path on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getConfigDir(
+ oslSecurity Security, rtl_uString **strDirectory);
+
+
+/** Load Profile of the User
+ Implemented just for Windows
+ @param[in] Security previously fetch Security of the User
+ @return True if the Profile could successfully loaded, False otherwise.
+*/
+
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_loadUserProfile(
+ oslSecurity Security);
+
+
+/** Unload a User Profile
+ Implemented just for Windows
+ @param[in] Security previously fetch Security of the User
+ @return nothing is returned!
+*/
+
+SAL_DLLPUBLIC void SAL_CALL osl_unloadUserProfile(
+ oslSecurity Security);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SECURITY_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/security.hxx b/include/osl/security.hxx
new file mode 100644
index 000000000000..941b2c5980a8
--- /dev/null
+++ b/include/osl/security.hxx
@@ -0,0 +1,103 @@
+/* -*- 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 _OSL_SECURITY_HXX_
+#define _OSL_SECURITY_HXX_
+
+#include <rtl/ustring.hxx>
+
+#ifndef _OSL_SECURITY_DECL_HXX
+# include <osl/security_decl.hxx>
+#endif
+
+namespace osl
+{
+
+inline Security::Security()
+{
+ m_handle = osl_getCurrentSecurity();
+}
+
+inline Security::~Security()
+{
+ osl_freeSecurityHandle(m_handle);
+}
+
+inline sal_Bool Security::logonUser(const rtl::OUString& strName,
+ const rtl::OUString& strPasswd)
+{
+ osl_freeSecurityHandle(m_handle);
+
+ m_handle = 0;
+
+ return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
+ == osl_Security_E_None);
+}
+
+inline sal_Bool Security::logonUser( const rtl::OUString& strName,
+ const rtl::OUString& strPasswd,
+ const rtl::OUString& strFileServer )
+{
+ osl_freeSecurityHandle(m_handle);
+
+ m_handle = NULL;
+
+ return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
+ == osl_Security_E_None);
+}
+
+inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const
+{
+ return osl_getUserIdent( m_handle, &strIdent.pData );
+}
+
+
+inline sal_Bool Security::getUserName( rtl::OUString& strName ) const
+{
+ return osl_getUserName( m_handle, &strName.pData );
+}
+
+
+inline sal_Bool Security::getHomeDir( rtl::OUString& strDirectory) const
+{
+ return osl_getHomeDir(m_handle, &strDirectory.pData );
+}
+
+
+inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
+{
+ return osl_getConfigDir( m_handle, &strDirectory.pData );
+}
+
+inline sal_Bool Security::isAdministrator() const
+{
+ return osl_isAdministrator(m_handle);
+}
+
+inline oslSecurity Security::getHandle() const
+{
+ return m_handle;
+}
+
+
+}
+
+#endif // _OSL_SECURITY_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/security_decl.hxx b/include/osl/security_decl.hxx
new file mode 100644
index 000000000000..ba2f4195d769
--- /dev/null
+++ b/include/osl/security_decl.hxx
@@ -0,0 +1,110 @@
+/* -*- 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 _OSL_SECURITY_DECL_HXX_
+#define _OSL_SECURITY_DECL_HXX_
+
+#include <rtl/ustring.hxx>
+# include <osl/security.h>
+
+namespace osl
+{
+
+/** capsulate security information for one user.
+ A object of this class is used to execute a process with the rights an
+ security options of a scecified user.
+ @see Process::executeProcess
+*/
+class Security
+{
+protected:
+ oslSecurity m_handle;
+
+public:
+ /// constructor
+ inline Security();
+ /// destructor
+ inline ~Security();
+ /** get the security information for one user.
+ The underlying operating system is asked for this information.
+ @param[in] strName denotes the name of the user
+ @param[in] strPasswd denotes the password of this user
+ @return True, if the specified user is known by the underlying operating system,
+ otherwise False
+ */
+ inline sal_Bool SAL_CALL logonUser(const rtl::OUString& strName,
+ const rtl::OUString& strPasswd);
+ /** get the security information for one user.
+
+ @verbatim
+ This method will try to login the user at the denoted file server.
+ If a network resource named \\server\username exists and this resource
+ could be connected by this user, the methos will return true and getHomeDir
+ will return \\server\username.
+ @endverbatim
+ @param[in] strName denotes the name of the user
+ @param[in] strPasswd denotes the password of this user
+ @param[in] strFileServer denotes the file server to login to
+ @return True, if the specified user is known by file server and the
+ could be connected, otherwise False
+ */
+ inline sal_Bool SAL_CALL logonUser(const rtl::OUString & strName,
+ const rtl::OUString & strPasswd,
+ const rtl::OUString & strFileServer);
+
+ /** get the ident of the logged in user.
+ @param[out] strIdent is the OUString which returns the name
+ @return True, if any user is successfully logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getUserIdent( rtl::OUString& strIdent) const;
+
+ /** get the name of the logged in user.
+ @param[out] strName is the OUString which returns the name
+ @return True, if any user is successfully logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getUserName( rtl::OUString& strName) const;
+
+ /** get the home directory of the logged in user.
+ @param[out] strDirectory is the OUString which returns the directory name
+ @return True, if any user is successfully logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getHomeDir( rtl::OUString& strDirectory) const;
+
+ /** get the directory for configuration data of the logged in user.
+ @param[out] strDirectory is the OUString which returns the directory name
+ @return True, if any user is successfully logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getConfigDir( rtl::OUString & strDirectory) const;
+
+ /** Query if the user who is logged inhas administrator rigths.
+ @return True, if the user has administrator rights, otherwise false.
+ */
+ inline sal_Bool SAL_CALL isAdministrator() const;
+
+ /** Returns the underlying oslSecurity handle
+ */
+ inline oslSecurity getHandle() const;
+
+};
+
+}
+
+#endif // _OSL_SECURITY_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/signal.h b/include/osl/signal.h
new file mode 100644
index 000000000000..ca113308cf92
--- /dev/null
+++ b/include/osl/signal.h
@@ -0,0 +1,112 @@
+/* -*- 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 _OSL_SIGNAL_H_
+#define _OSL_SIGNAL_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OSL_SIGNAL_USER_RESERVED 0
+
+#define OSL_SIGNAL_USER_RESOURCEFAILURE (OSL_SIGNAL_USER_RESERVED - 1)
+#define OSL_SIGNAL_USER_X11SUBSYSTEMERROR (OSL_SIGNAL_USER_RESERVED - 2)
+#define OSL_SIGNAL_USER_RVPCONNECTIONERROR (OSL_SIGNAL_USER_RESERVED - 3)
+
+typedef void* oslSignalHandler;
+
+typedef enum
+{
+ osl_Signal_System,
+ osl_Signal_Terminate,
+ osl_Signal_AccessViolation,
+ osl_Signal_IntegerDivideByZero,
+ osl_Signal_FloatDivideByZero,
+ osl_Signal_DebugBreak,
+ osl_Signal_User,
+ osl_Signal_Alarm,
+ osl_Signal_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSignal;
+
+typedef enum
+{
+ osl_Signal_ActCallNextHdl,
+ osl_Signal_ActIgnore,
+ osl_Signal_ActAbortApp,
+ osl_Signal_ActKillApp,
+ osl_Signal_Act_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSignalAction;
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+typedef struct
+{
+ oslSignal Signal;
+ sal_Int32 UserSignal;
+ void* UserData;
+} oslSignalInfo;
+
+#if defined( SAL_W32)
+# pragma pack(pop)
+#endif
+
+/** the function-ptr. representing the signal handler-function.
+*/
+typedef oslSignalAction (SAL_CALL *oslSignalHandlerFunction)(void* pData, oslSignalInfo* pInfo);
+
+SAL_DLLPUBLIC oslSignalHandler SAL_CALL osl_addSignalHandler(
+ oslSignalHandlerFunction Handler, void* pData);
+
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_removeSignalHandler(
+ oslSignalHandler hHandler);
+
+SAL_DLLPUBLIC oslSignalAction SAL_CALL osl_raiseSignal(
+ sal_Int32 UserSignal, void* UserData);
+
+/** Enables or disables error reporting
+
+ On default error reporting is enabled after process startup.
+
+ @param bEnable [in]
+ Enables or disables error reporting.
+
+ @return
+ sal_True if previous state of error reporting was enabled<br>
+ sal_False if previous state of error reporting was disbaled<br>
+*/
+
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setErrorReporting(
+ sal_Bool bEnable );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SIGNAL_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/socket.h b/include/osl/socket.h
new file mode 100644
index 000000000000..8ccb2c740f53
--- /dev/null
+++ b/include/osl/socket.h
@@ -0,0 +1,920 @@
+/* -*- 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 _OSL_SOCKET_H_
+#define _OSL_SOCKET_H_
+
+#include <rtl/ustring.h>
+#include <rtl/byteseq.h>
+
+#include <osl/time.h>
+#include <rtl/tencinfo.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* error returns */
+#define OSL_INADDR_NONE 0xffffffff
+#define OSL_INVALID_PORT (-1)
+#define OSL_INVALID_IPX_SOCKET_NO 0xffffffff
+
+/**
+ Opaque datatype SocketAddr.
+*/
+typedef struct oslSocketAddrImpl * oslSocketAddr;
+
+
+/**
+ Represents the address-family of a socket
+*/
+typedef enum {
+ osl_Socket_FamilyInet, /* IP */
+ osl_Socket_FamilyIpx, /* Novell IPX/SPX */
+ osl_Socket_FamilyInvalid, /* always last entry in enum! */
+ osl_Socket_Family_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslAddrFamily;
+
+/**
+ represent a specific protocol within a address-family
+*/
+typedef enum {
+ osl_Socket_ProtocolIp, /* for all af_inet */
+ osl_Socket_ProtocolIpx, /* af_ipx datagram sockets (IPX) */
+ osl_Socket_ProtocolSpx, /* af_ipx seqpacket or stream for SPX */
+ osl_Socket_ProtocolSpxII, /* af_ipx seqpacket or stream for SPX II */
+ osl_Socket_ProtocolInvalid,
+ osl_Socket_Protocol_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslProtocol;
+
+
+/**
+ Represents the type of a socket
+*/
+typedef enum {
+ osl_Socket_TypeStream,
+ osl_Socket_TypeDgram,
+ osl_Socket_TypeRaw,
+ osl_Socket_TypeRdm,
+ osl_Socket_TypeSeqPacket,
+ osl_Socket_TypeInvalid, /* always last entry in enum! */
+ osl_Socket_Type_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketType;
+
+
+/**
+ Represents socket-options
+*/
+typedef enum {
+ osl_Socket_OptionDebug,
+ osl_Socket_OptionAcceptConn,
+ osl_Socket_OptionReuseAddr,
+ osl_Socket_OptionKeepAlive,
+ osl_Socket_OptionDontRoute,
+ osl_Socket_OptionBroadcast,
+ osl_Socket_OptionUseLoopback,
+ osl_Socket_OptionLinger,
+ osl_Socket_OptionOOBinLine,
+ osl_Socket_OptionSndBuf,
+ osl_Socket_OptionRcvBuf,
+ osl_Socket_OptionSndLowat,
+ osl_Socket_OptionRcvLowat,
+ osl_Socket_OptionSndTimeo,
+ osl_Socket_OptionRcvTimeo,
+ osl_Socket_OptionError,
+ osl_Socket_OptionType,
+ osl_Socket_OptionTcpNoDelay,
+ osl_Socket_OptionInvalid, /* always last entry in enum! */
+ osl_Socket_Option_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketOption;
+
+/**
+ Represents the different socket-option levels
+*/
+typedef enum {
+ osl_Socket_LevelSocket,
+ osl_Socket_LevelTcp,
+ osl_Socket_LevelInvalid, /* always last entry in enum! */
+ osl_Socket_Level_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketOptionLevel;
+
+
+/**
+ Represents flags to be used with send/recv-calls.
+*/
+typedef enum {
+ osl_Socket_MsgNormal,
+ osl_Socket_MsgOOB,
+ osl_Socket_MsgPeek,
+ osl_Socket_MsgDontRoute,
+ osl_Socket_MsgMaxIOVLen,
+ osl_Socket_MsgInvalid, /* always last entry in enum! */
+ osl_Socket_Msg_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketMsgFlag;
+
+/**
+ Used by shutdown to denote which end of the socket to "close".
+*/
+typedef enum {
+ osl_Socket_DirRead,
+ osl_Socket_DirWrite,
+ osl_Socket_DirReadWrite,
+ osl_Socket_DirInvalid, /* always last entry in enum! */
+ osl_Socket_Dir_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketDirection;
+
+/** Describes the various error socket error conditions, which may
+ occur */
+typedef enum {
+ osl_Socket_E_None, /* no error */
+ osl_Socket_E_NotSocket, /* Socket operation on non-socket */
+ osl_Socket_E_DestAddrReq, /* Destination address required */
+ osl_Socket_E_MsgSize, /* Message too long */
+ osl_Socket_E_Prototype, /* Protocol wrong type for socket */
+ osl_Socket_E_NoProtocol, /* Protocol not available */
+ osl_Socket_E_ProtocolNoSupport, /* Protocol not supported */
+ osl_Socket_E_TypeNoSupport, /* Socket type not supported */
+ osl_Socket_E_OpNotSupport, /* Operation not supported on socket */
+ osl_Socket_E_PfNoSupport, /* Protocol family not supported */
+ osl_Socket_E_AfNoSupport, /* Address family not supported by */
+ /* protocol family */
+ osl_Socket_E_AddrInUse, /* Address already in use */
+ osl_Socket_E_AddrNotAvail, /* Can't assign requested address */
+ osl_Socket_E_NetDown, /* Network is down */
+ osl_Socket_E_NetUnreachable, /* Network is unreachable */
+ osl_Socket_E_NetReset, /* Network dropped connection because */
+ /* of reset */
+ osl_Socket_E_ConnAborted, /* Software caused connection abort */
+ osl_Socket_E_ConnReset, /* Connection reset by peer */
+ osl_Socket_E_NoBufferSpace, /* No buffer space available */
+ osl_Socket_E_IsConnected, /* Socket is already connected */
+ osl_Socket_E_NotConnected, /* Socket is not connected */
+ osl_Socket_E_Shutdown, /* Can't send after socket shutdown */
+ osl_Socket_E_TooManyRefs, /* Too many references: can't splice */
+ osl_Socket_E_TimedOut, /* Connection timed out */
+ osl_Socket_E_ConnRefused, /* Connection refused */
+ osl_Socket_E_HostDown, /* Host is down */
+ osl_Socket_E_HostUnreachable, /* No route to host */
+ osl_Socket_E_WouldBlock, /* call would block on non-blocking socket */
+ osl_Socket_E_Already, /* operation already in progress */
+ osl_Socket_E_InProgress, /* operation now in progress */
+ osl_Socket_E_InvalidError, /* unmapped error: always last entry in enum! */
+ osl_Socket_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketError;
+
+/** Common return codes of socket related functions.
+ */
+typedef enum {
+ osl_Socket_Ok, /* successful completion */
+ osl_Socket_Error, /* error occurred, check osl_getLastSocketError() for details */
+ osl_Socket_TimedOut, /* blocking operation timed out */
+ osl_Socket_Interrupted, /* blocking operation was interrupted */
+ osl_Socket_InProgress, /* nonblocking operation is in progress */
+ osl_Socket_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketResult;
+
+typedef sal_uInt8 oslSocketIpxNetNumber[4];
+typedef sal_uInt8 oslSocketIpxNodeNumber[6];
+
+/**@} end section types
+*/
+
+/**@{ begin section oslSocketAddr
+*/
+
+/** Creates a socket-address for the given family.
+ @param Family If family == osl_Socket_FamilyInet the address is
+ set to INADDR_ANY port 0.
+ @return 0 if address could not be created.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_createEmptySocketAddr(
+ oslAddrFamily Family);
+
+
+/** Creates a new SocketAddress and fills it from Addr.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_copySocketAddr(
+ oslSocketAddr Addr);
+
+/** Compares the values of two SocketAddresses.
+ @return <code>sal_True</code> if both addresses denote the same socket address,
+ <code>sal_False</code> otherwise.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isEqualSocketAddr(
+ oslSocketAddr Addr1, oslSocketAddr Addr2);
+
+/** Uses the systems name-service interface to find an address for strHostname.
+ @param[in] strHostname The name for which you search for an address.
+ @return The desired address if one could be found, otherwise 0.
+ Don't forget to destroy the address if you don't need it any longer.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_resolveHostname(
+ rtl_uString *strHostname);
+
+/** Create an internet address usable for sending broadcast datagrams.
+ To limit the broadcast to your subnet, pass your hosts IP address
+ in dotted decimal notation as first argument.
+ @see osl_sendToSocket()
+ @see oslSocketAddr
+ @param[in] strDottedAddr dotted decimal internet address, may be 0.
+ @param[in] Port port number in host byte order.
+ @return 0 if address could not be created.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_createInetBroadcastAddr (
+ rtl_uString *strDottedAddr, sal_Int32 Port);
+
+
+/** Create an internet-address, consisting of hostaddress and port.
+ We interpret strDottedAddr as a dotted-decimal inet-addr
+ (e.g. "141.99.128.50").
+ @param strDottedAddr [in] String with dotted address.
+ @param Port [in] portnumber in host byte order.
+ @return 0 if address could not be created.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_createInetSocketAddr (
+ rtl_uString *strDottedAddr, sal_Int32 Port);
+
+
+/** Frees all resources allocated by Addr. The handle Addr must not
+ be used after the call anymore.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_destroySocketAddr(
+ oslSocketAddr Addr);
+
+/** Looks up the port-number designated to the specified service/protocol-pair.
+ (e.g. "ftp" "tcp").
+ @return OSL_INVALID_PORT if no appropriate entry was found, otherwise the port-number.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_getServicePort(
+ rtl_uString *strServicename, rtl_uString *strProtocol);
+
+
+
+/** Retrieves the address-family from the Addr.
+ @return the family of the socket-address.
+ In case of an unknown family you get <code>osl_Socket_FamilyInvalid</code>.
+*/
+SAL_DLLPUBLIC oslAddrFamily SAL_CALL osl_getFamilyOfSocketAddr(
+ oslSocketAddr Addr);
+
+
+/** Retrieves the internet port-number of Addr.
+ @return the port-number of the address in host-byte order. If Addr
+ is not an address of type <code>osl_Socket_FamilyInet</code>, it returns <code>OSL_INVALID_PORT</code>
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_getInetPortOfSocketAddr(
+ oslSocketAddr Addr);
+
+
+/** Sets the Port of Addr.
+ @param[in] Addr the SocketAddr to perfom the operation on.
+ @param[in] Port is expected in host byte-order.
+ @return <code>sal_False</code> if Addr is not an inet-addr.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setInetPortOfSocketAddr(
+ oslSocketAddr Addr, sal_Int32 Port);
+
+
+/** Returns the hostname represented by Addr.
+ @param[in] Addr The socket address from which to extract the hostname.
+ @param[out] strHostname The hostname represented by the address. If
+ there is no hostname to be found, it returns 0.
+*/
+SAL_DLLPUBLIC oslSocketResult SAL_CALL osl_getHostnameOfSocketAddr(
+ oslSocketAddr Addr, rtl_uString **strHostname);
+
+
+/** Gets the address in dotted decimal format.
+ @param[in] Addr The socket address from which to extract the dotted decimal address.
+ @param[out] strDottedInetAddr Contains the dotted decimal address
+ (e.g. 141.99.20.34) represented by the address.
+ If the address is invalid or not of type <code>osl_Socket_FamilyInet</code>,
+ it returns 0.
+ @return <code>osl_Socket_Ok</code> or <code>osl_Socket_Error</code>
+*/
+SAL_DLLPUBLIC oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr(
+ oslSocketAddr Addr, rtl_uString **strDottedInetAddr);
+
+/** Sets the addr field in the struct sockaddr with pByteSeq. pByteSeq must be in network byte order.
+ */
+SAL_DLLPUBLIC oslSocketResult SAL_CALL osl_setAddrOfSocketAddr(
+ oslSocketAddr Addr, sal_Sequence *pByteSeq );
+
+/** Returns the addr field in the struct sockaddr.
+ @param[in] Addr The socket address from which to extract the ipaddress.
+ @param[out] ppByteSeq After the call, *ppByteSeq contains the ipaddress
+ in network byteorder. *ppByteSeq may be 0 in case of an invalid socket handle.
+ @return <code>osl_Socket_Ok</code> or <code>osl_Socket_Error</code>
+ */
+SAL_DLLPUBLIC oslSocketResult SAL_CALL osl_getAddrOfSocketAddr(
+ oslSocketAddr Addr, sal_Sequence **ppByteSeq );
+
+/*
+ Opaque datatype HostAddr.
+*/
+typedef struct oslHostAddrImpl * oslHostAddr;
+
+
+/** Create an oslHostAddr from given hostname and socket address.
+ @param[in] strHostname The hostname to be stored.
+ @param[in] Addr The socket address to be stored.
+ @return The created address or 0 upon failure.
+*/
+SAL_DLLPUBLIC oslHostAddr SAL_CALL osl_createHostAddr(
+ rtl_uString *strHostname, const oslSocketAddr Addr);
+
+
+/** Create an oslHostAddr by resolving the given strHostname.
+ Successful name resolution should result in the fully qualified
+ domain name (FQDN) and it's address as hostname and socket address
+ members of the resulting oslHostAddr.
+ @param[in] strHostname The hostname to be resolved.
+ @return The resulting address or 0 upon failure.
+*/
+SAL_DLLPUBLIC oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname);
+
+
+/** Create an oslHostAddr by reverse resolution of the given Addr.
+ Successful name resolution should result in the fully qualified
+ domain name (FQDN) and it's address as hostname and socket address
+ members of the resulting oslHostAddr.
+ @param[in] Addr The socket address to be reverse resolved.
+ @return The resulting address or 0 upon failure.
+*/
+SAL_DLLPUBLIC oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr Addr);
+
+
+/** Create a copy of the given Addr.
+ @return The copied address or 0 upon failure.
+*/
+SAL_DLLPUBLIC oslHostAddr SAL_CALL osl_copyHostAddr(const oslHostAddr Addr);
+
+
+/** Frees all resources allocated by Addr. The handle Addr must not
+ be used after the call anymore.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_destroyHostAddr(oslHostAddr Addr);
+
+
+/** Get the hostname member of Addr.
+ @return The hostname or 0 upon failure.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_getHostnameOfHostAddr(const oslHostAddr Addr, rtl_uString **strHostname);
+
+
+/** Get the socket address member of Addr.
+ @return The socket address or 0 upon failure.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_getSocketAddrOfHostAddr(const oslHostAddr Addr);
+
+/** Retrieve this machines hostname.
+ May not always be a fully qualified domain name (FQDN).
+ @param strLocalHostname out-parameter. The string that receives the local host name.
+ @return <code>sal_True</code> upon success, <code>sal_False</code> otherwise.
+*/
+SAL_DLLPUBLIC oslSocketResult SAL_CALL osl_getLocalHostname(rtl_uString **strLocalHostname);
+
+
+/**@} end section oslHostAddr
+*/
+
+/**@{ begin section oslSocket
+*/
+
+
+/*-***************************************************************************/
+/* oslSocket */
+/*-***************************************************************************/
+
+typedef struct oslSocketImpl * oslSocket;
+
+/** increases the refcount of the socket handle by one
+ */
+SAL_DLLPUBLIC void SAL_CALL osl_acquireSocket( oslSocket Socket );
+
+/** decreases the refcount of the socket handle by one.
+
+ If the refcount drops to zero, the underlying socket handle
+ is destroyed and becomes invalid.
+ */
+SAL_DLLPUBLIC void SAL_CALL osl_releaseSocket( oslSocket Socket );
+
+/** Create a socket of the specified Family and Type. The semantic of
+ the Protocol parameter depends on the given family and type.
+ @return 0 if socket could not be created, otherwise you get a handle
+ to the allocated socket-datastructure.
+*/
+SAL_DLLPUBLIC oslSocket SAL_CALL osl_createSocket(
+ oslAddrFamily Family,
+ oslSocketType Type,
+ oslProtocol Protocol);
+
+/** Retrieves the Address of the local end of the socket.
+ Note that a socket must be bound or connected before
+ a vaild address can be returned.
+ @return 0 if socket-address could not be created, otherwise you get
+ the created Socket-Address.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_getLocalAddrOfSocket(oslSocket Socket);
+
+/** Retrieves the Address of the remote end of the socket.
+ Note that a socket must be connected before
+ a vaild address can be returned.
+ @return 0 if socket-address could not be created, otherwise you get
+ the created Socket-Address.
+*/
+SAL_DLLPUBLIC oslSocketAddr SAL_CALL osl_getPeerAddrOfSocket(oslSocket Socket);
+
+/** Binds the given address to the socket.
+ @param[in] Socket
+ @param[in] Addr
+ @return <code>sal_False</code> if the bind failed, <code> sal_True</code> if successful.
+ @see osl_getLastSocketError()
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_bindAddrToSocket(
+ oslSocket Socket,
+ oslSocketAddr Addr);
+
+/** Connects the socket to the given address.
+
+ @param[in] Socket a bound socket.
+ @param[in] Addr the peer address.
+ @param pTimeout Timeout value or NULL for blocking.
+
+ @return <code>osl_Socket_Ok</code> on successful connection,
+ <code>osl_Socket_TimedOut</code> if operation timed out,
+ <code>osl_Socket_Interrupted</code> if operation was interrupted
+ <code>osl_Socket_Error</code> if the connection failed.
+*/
+SAL_DLLPUBLIC oslSocketResult SAL_CALL osl_connectSocketTo(
+ oslSocket Socket,
+ oslSocketAddr Addr,
+ const TimeValue* pTimeout);
+
+
+/** Prepares the socket to act as an acceptor of incoming connections.
+ You should call "listen" before you use "accept".
+ @param[in] Socket The socket to listen on.
+ @param[in] MaxPendingConnections denotes the length of the queue of
+ pending connections for this socket. If MaxPendingConnections is
+ -1, the systems default value will be used (Usually 5).
+ @return <code>sal_False</code> if the listen failed.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_listenOnSocket(
+ oslSocket Socket,
+ sal_Int32 MaxPendingConnections);
+
+
+/** Waits for an ingoing connection on the socket.
+ This call blocks if there is no incoming connection present.
+ @param[in] Socket The socket to accept the connection on.
+ @param[in] pAddr if pAddr is != 0, the peers address is returned.
+ @return 0 if the accept-call failed, otherwise you get a socket
+ representing the new connection.
+*/
+SAL_DLLPUBLIC oslSocket SAL_CALL osl_acceptConnectionOnSocket
+ (oslSocket Socket,
+ oslSocketAddr* pAddr);
+
+/** Tries to receive BytesToRead data from the connected socket,
+ if no error occurs. Note that incomplete recvs due to
+ packet boundaries may occur.
+
+ @param[in] Socket A connected socket to be used to listen on.
+ @param[out] pBuffer Points to a buffer that will be filled with the received
+ data.
+ @param[in] BytesToRead The number of bytes to read. pBuffer must have at least
+ this size.
+ @param[in] Flag Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of received bytes.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_receiveSocket(
+ oslSocket Socket,
+ void* pBuffer,
+ sal_uInt32 BytesToRead,
+ oslSocketMsgFlag Flag);
+
+/** Tries to receives BufferSize data from the (usually unconnected)
+ (datagram-)socket, if no error occurs.
+
+ @param[in] Socket A bound socket to be used to listen for a datagram.
+ @param[out] SenderAddr A pointer to a created oslSocketAddr handle
+ or to a null handle. After the call, it will contain the constructed
+ oslSocketAddr of the datagrams sender. If pSenderAddr itself is 0,
+ it is ignored.
+ @param[out] pBuffer Points to a buffer that will be filled with the received
+ datagram.
+ @param[in] BufferSize The size of pBuffer.
+ @param[in] Flag Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of received bytes.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_receiveFromSocket(
+ oslSocket Socket,
+ oslSocketAddr SenderAddr,
+ void* pBuffer,
+ sal_uInt32 BufferSize,
+ oslSocketMsgFlag Flag);
+
+/** Tries to send BytesToSend data from the connected socket,
+ if no error occurs.
+
+ @param[in] Socket A connected socket.
+ @param[in] pBuffer Points to a buffer that contains the send-data.
+ @param[in] BytesToSend The number of bytes to send. pBuffer must have at least
+ this size.
+ @param[in] Flag Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_sendSocket(
+ oslSocket Socket,
+ const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag Flag);
+
+/** Tries to send one datagram with BytesToSend data to the given ReceiverAddr
+ via the (implicitly unconnected) datagram-socket.
+ Since there is only sent one packet, the function sends the data always complete
+ even with incomplete packet boundaries.
+
+ @param[in] Socket A bound or unbound socket. Socket will be bound
+ after a successful call.
+
+ @param[in] ReceiverAddr An initialized oslSocketAddress that contains
+ the destination address for this send.
+
+ @param[in] pBuffer Points to a buffer that contains the send-data.
+ @param[in] BytesToSend The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_sendToSocket(
+ oslSocket Socket,
+ oslSocketAddr ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag Flag);
+
+/** Checks if read operations will block.
+
+ You can specify a timeout-value in seconds/microseconds that denotes
+ how long the operation will block if the Socket is not ready.
+
+ @return <code>sal_True</code> if read operations (recv, recvFrom, accept) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occurred.
+
+ @param Socket the Socket to perfom the operation on.
+ @param pTimeout if NULL, the operation will block without a timeout.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isReceiveReady(
+ oslSocket Socket, const TimeValue* pTimeout);
+
+/** Checks if send operations will block.
+ You can specify a timeout-value in seconds/microseconds that denotes
+ how long the operation will block if the Socket is not ready.
+ @return <code>sal_True</code> if send operations (send, sendTo) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occurred.
+
+ @param Socket the Socket to perfom the operation on.
+ @param pTimeout if NULL, the operation will block without a timeout. Otherwise
+ the time define by timeout value.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isSendReady(
+ oslSocket Socket, const TimeValue* pTimeout);
+
+/** Checks if a request for out-of-band data will block.
+ You can specify a timeout-value in seconds/microseconds that denotes
+ how long the operation will block if the Socket has no pending OOB data.
+ @return <code>sal_True</code> if OOB-request operations (recv with appropriate flags)
+ on the Socket will NOT block; <code>sal_False</code> if it would block or if an error occurred.
+
+ @param Socket the Socket to perfom the operation on.
+ @param pTimeout if NULL, the operation will block without a timeout.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isExceptionPending(
+ oslSocket Socket, const TimeValue* pTimeout);
+
+/** Shuts down communication on a connected socket.
+ @param[in] Socket the Socket to perfom the operation on.
+ @param[in] Direction denotes which end of the socket
+ should be closed:
+ <ul>
+ <li> <code>osl_Socket_DirRead</code> closes read operations.
+ <li> <code>osl_Socket_DirReadWrite</code> closes write operations.
+ <li> <code>osl_Socket_DirWrite</code> closes read and write operations.
+ </ul>
+ @return <code>sal_True</code> if the socket could be closed down.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_shutdownSocket(oslSocket Socket,
+ oslSocketDirection Direction);
+
+/** Retrieves attributes associated with the socket.
+ @param Socket is the socket to query.
+
+ @param Level selects the level for which an option should be queried.
+ Valid values are:
+ <ul>
+ <li> osl_sol_socket: Socket Level
+ <li> osl_sol_tcp: Level of Transmission Control Protocol
+ </ul>
+
+ @param Option denotes the option to query.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> <code>osl_Socket_Option_Debug</code><br>
+ (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.
+
+ <li> <code>osl_Socket_OptionAcceptConn</code><br>
+ <li> <code>osl_Socket_OptionReuseAddr</code><br>
+ (sal_Bool) Allows the socket to be bound to an address that is
+ already in use.
+ 1 = multiple bound allowed, 0 = no multiple bounds allowed
+
+ <li><code>osl_Socket_OptionKeepAlive</code><br>
+ (sal_Bool) Keepalive packets are sent by the underlying socket.
+ 1 = enabled, 0 = disabled
+
+ <li><code>osl_Socket_OptionDontRoute</code><br>
+ (sal_Bool) Do not route: send directly to interface.
+ 1 = do not route , 0 = routing possible
+
+ <li><code>osl_Socket_OptionBroadcast</code><br>
+ (sal_Bool) Transmission of broadcast messages are allowed on the socket.
+ 1 = transmission allowed, 0 = transmission disallowed
+
+ <li><code>osl_Socket_OptionUseLoopback</code><br>
+
+ <li><code>osl_Socket_OptionLinger</code><br>
+ (sal_Int32) Linger on close if unsent data is present.
+ 0 = linger is off, > 0 = timeout in seconds.
+
+ <li><code>osl_Socket_OptionOOBinLine</code><br>
+
+
+ <li><code>osl_Socket_OptionSndBuf</code><br>
+ (sal_Int32) Size of the send buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket.
+
+ <li><code>osl_Socket_OptionRcvBuf</code><br>
+ (sal_Int32) Size of the receive buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket and larger packet sizes.
+
+ <li><code>osl_Socket_OptionSndLowat</code><br>
+
+ <li><code>osl_Socket_OptionRcvLowat</code><br>
+
+ <li><code>osl_Socket_OptionSndTimeo</code><br>
+ (sal_Int32) Data is sent after this timeout. This allows gathering
+ of data to send larger packages but increases latency times.
+
+ <li><code>osl_Socket_OptionRcvTimeo</code><br>
+
+ <li><code>osl_Socket_OptionError</code><br>
+ <li><code>osl_Socket_OptionType</code><br>
+
+ <li><code>osl_Socket_OptionTcpNoDelay</code><br>
+ Disables the Nagle algorithm for send coalescing. (Do not
+ collect data until a packet is full, instead send immediately.
+ This increases network traffic but might improve latency-times.)
+ 1 = disables the algorithm, 0 = keeps it enabled.
+ </ul>
+ If not above mentioned otherwise, the options are only valid for
+ level <code>osl_Socket_LevelSocket</code>.
+
+ @param pBuffer Pointer to a buffer large enough to take the desired
+ attribute-value.
+
+ @param BufferLen contains the length of the Buffer.
+
+ @return -1 if an error occurred or else the size of the data copied into
+ pBuffer.
+ @see osl_setSocketOption()
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_getSocketOption( oslSocket Socket,
+ oslSocketOptionLevel Level,
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen);
+
+/** Sets the sockets attributes.
+
+ @param Socket is the socket to modify.
+
+ @param Level selects the level for which an option should be changed.
+ Valid values are:
+ <ul>
+ <li> osl_sol_socket: Socket Level
+ <li> osl_sol_tcp: Level of Transmission Control Protocol
+ </ul>
+
+ @param Option denotes the option to modify. See osl_setSocketOption() for more
+ details.
+
+ @param pBuffer Pointer to a Buffer which contains the attribute-value.
+
+ @param BufferLen contains the length of the Buffer.
+
+ @return True if the option could be changed.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setSocketOption( oslSocket Socket,
+ oslSocketOptionLevel Level,
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen);
+
+/** Enables/disables non-blocking-mode of the socket.
+ @param Socket Change mode for this socket.
+ @param On <code>sal_True</code> enables non-blocking mode,
+ <code>sal_False</code> disables non-blocking mode.
+ @return <code>sal_True</code> if mode could be changed.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_enableNonBlockingMode(
+ oslSocket Socket, sal_Bool On);
+
+
+/** Query state of non-blocking-mode of the socket.
+ @param Socket Query mode for this socket.
+ @return True if non-blocking-mode is enabled.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isNonBlockingMode(
+ oslSocket Socket);
+
+
+/** Queries the socket for its type.
+ @param[in] Socket The socket to query.
+ @return one of:
+ <ul>
+ <li> osl_Socket_TypeStream
+ <li> osl_Socket_TypeDgram
+ <li> osl_Socket_TypeRaw
+ <li> osl_Socket_TypeRdm
+ <li> osl_Socket_TypeSeqPacket
+ <li> osl_invalid_SocketType, if an error occurred
+ </ul>
+*/
+SAL_DLLPUBLIC oslSocketType SAL_CALL osl_getSocketType(
+ oslSocket Socket);
+
+/** returns a string which describes the last socket error.
+ @param[in] Socket The socket to query.
+ @param[out] strError The string that receives the error message.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_getLastSocketErrorDescription(
+ oslSocket Socket, rtl_uString **strError);
+
+/** returns a constant decribing the last error for the socket system.
+ @return <code>osl_Socket_E_NONE</code> if no error occurred,
+ <code>osl_invalid_SocketError</code> if an unknown (unmapped)
+ error occurred, otherwise an enum describing the error.
+*/
+SAL_DLLPUBLIC oslSocketError SAL_CALL osl_getLastSocketError(
+ oslSocket Socket);
+
+/** Type for the representation of socket sets.
+*/
+typedef struct oslSocketSetImpl * oslSocketSet;
+
+/** Creates a set of sockets to be used with osl_demultiplexSocketEvents().
+ @return A oslSocketSet or 0 if creation failed.
+*/
+SAL_DLLPUBLIC oslSocketSet SAL_CALL osl_createSocketSet(void);
+
+/** Destroys a oslSocketSet.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_destroySocketSet(oslSocketSet Set);
+
+/** Clears the set from all previously added sockets.
+ @param Set the set to be cleared.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_clearSocketSet(oslSocketSet Set);
+
+
+/** Adds a socket to the set.
+ @param Set the set were the socket is added.
+ @param Socket the socket to be added.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_addToSocketSet(oslSocketSet Set, oslSocket Socket);
+
+/** Removes a socket from the set.
+ @param Set the set were the socket is removed from.
+ @param Socket the socket to be removed.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_removeFromSocketSet(oslSocketSet Set, oslSocket Socket);
+
+/** Checks if socket is in the set.
+ @param Set the set to be checked.
+ @param Socket check if this socket is in the set.
+ @return <code>sal_True</code> if socket is in the set.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isInSocketSet(oslSocketSet Set, oslSocket Socket);
+
+/** Checks multiple sockets for events.
+ @param IncomingSet Checks the sockets in this set
+ for incoming events (read, accept). If the set is 0,
+ it is just skipped.
+ @param OutgoingSet Checks the sockets in this set
+ for outgoing events (write, connect). If the set is 0,
+ it is just skipped.
+ @param OutOfBandSet Checks the sockets in this set
+ for out-of-band events. If the set is 0, it is just skipped.
+ @param pTimeout Address of the number of milliseconds to wait for events. If
+ *pTimeout is -1, the call will block until an event or an error
+ occurs.
+ @return -1 on errors, otherwise the number of sockets with
+ pending events. In case of timeout, the number might be 0.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet,
+ oslSocketSet OutgoingSet,
+ oslSocketSet OutOfBandSet,
+ const TimeValue* pTimeout);
+
+/** Closes the socket terminating any ongoing dataflow.
+ @param[in] Socket The socket to close.
+ */
+SAL_DLLPUBLIC void SAL_CALL osl_closeSocket(oslSocket Socket);
+
+
+/** Retrieves n bytes from the stream and copies them into pBuffer.
+ The function avoids incomplete reads due to packet boundaries.
+ @param[in] Socket The socket to read from.
+ @param[out] pBuffer receives the read data.
+ @param[out] nSize the number of bytes to read. pBuffer must be large enough
+ to hold the n bytes!
+ @return the number of read bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_readSocket( oslSocket Socket, void *pBuffer, sal_Int32 nSize );
+
+
+/** Writes n bytes from pBuffer to the stream. The method avoids
+ incomplete writes due to packet boundaries.
+ @param[out] Socket The socket to write to.
+ @param[in] pBuffer contains the data to be written.
+ @param[in] nSize the number of bytes to write.
+ @return the number of written bytes. The number will only be smaller than
+ nSize if an exceptional condition (e.g. connection closed) occurs.
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL osl_writeSocket( oslSocket Socket, const void *pBuffer, sal_Int32 nSize );
+
+/**@} end section oslSocket
+*/
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SOCKET_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/socket.hxx b/include/osl/socket.hxx
new file mode 100644
index 000000000000..f8246c48a448
--- /dev/null
+++ b/include/osl/socket.hxx
@@ -0,0 +1,559 @@
+/* -*- 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 _OSL_SOCKET_HXX_
+#define _OSL_SOCKET_HXX_
+
+#include <osl/socket_decl.hxx>
+
+namespace osl
+{
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr()
+ : m_handle( osl_createEmptySocketAddr( osl_Socket_FamilyInet ) )
+ {}
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr(const SocketAddr& Addr)
+ : m_handle( osl_copySocketAddr( Addr.m_handle ) )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr(oslSocketAddr Addr)
+ : m_handle( osl_copySocketAddr( Addr ) )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr(oslSocketAddr Addr, __osl_socket_NoCopy )
+ : m_handle( Addr )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort)
+ : m_handle( osl_createInetSocketAddr( strAddrOrHostName.pData, nPort ) )
+ {
+ if(! m_handle )
+ {
+ m_handle = osl_resolveHostname(strAddrOrHostName.pData);
+
+ // host found?
+ if(m_handle)
+ {
+ osl_setInetPortOfSocketAddr(m_handle, nPort);
+ }
+ else
+ {
+ osl_destroySocketAddr( m_handle );
+ m_handle = 0;
+ }
+ }
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::~SocketAddr()
+ {
+ if( m_handle )
+ osl_destroySocketAddr( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString SocketAddr::getHostname( oslSocketResult *pResult ) const
+ {
+ ::rtl::OUString hostname;
+ oslSocketResult result = osl_getHostnameOfSocketAddr( m_handle, &(hostname.pData) );
+ if( pResult )
+ *pResult = result;
+ return hostname;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL SocketAddr::getPort() const
+ {
+ return osl_getInetPortOfSocketAddr(m_handle);
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL SocketAddr::setPort( sal_Int32 nPort )
+ {
+ return osl_setInetPortOfSocketAddr(m_handle, nPort );
+ }
+
+ inline sal_Bool SAL_CALL SocketAddr::setHostname( const ::rtl::OUString &sDottedIpOrHostname )
+ {
+ *this = SocketAddr( sDottedIpOrHostname , getPort() );
+ return is();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL SocketAddr::setAddr( const ::rtl::ByteSequence & address )
+ {
+ return osl_setAddrOfSocketAddr( m_handle, address.getHandle() )
+ == osl_Socket_Ok;
+ }
+
+ inline ::rtl::ByteSequence SAL_CALL SocketAddr::getAddr( oslSocketResult *pResult ) const
+ {
+ ::rtl::ByteSequence sequence;
+ oslSocketResult result = osl_getAddrOfSocketAddr( m_handle,(sal_Sequence **) &sequence );
+ if( pResult )
+ *pResult = result;
+ return sequence;
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr & SAL_CALL SocketAddr::operator= (oslSocketAddr Addr)
+ {
+ oslSocketAddr pNewAddr = osl_copySocketAddr( Addr );
+ if( m_handle )
+ osl_destroySocketAddr( m_handle );
+ m_handle = pNewAddr;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr & SAL_CALL SocketAddr::operator= (const SocketAddr& Addr)
+ {
+ *this = (Addr.getHandle());
+ return *this;
+ }
+
+ inline SocketAddr & SAL_CALL SocketAddr::assign( oslSocketAddr Addr, __osl_socket_NoCopy )
+ {
+ if( m_handle )
+ osl_destroySocketAddr( m_handle );
+ m_handle = Addr;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL SocketAddr::operator== (oslSocketAddr Addr) const
+ {
+ return osl_isEqualSocketAddr( m_handle, Addr );
+ }
+
+ inline oslSocketAddr SocketAddr::getHandle() const
+ {
+ return m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SocketAddr::is() const
+ {
+ return m_handle != 0;
+ }
+
+ // (static method)______________________________________________________________
+ inline ::rtl::OUString SAL_CALL SocketAddr::getLocalHostname( oslSocketResult *pResult )
+ {
+ ::rtl::OUString hostname;
+ oslSocketResult result = osl_getLocalHostname( &(hostname.pData) );
+ if(pResult )
+ *pResult = result;
+ return hostname;
+ }
+
+ // (static method)______________________________________________________________
+ inline void SAL_CALL SocketAddr::resolveHostname(
+ const ::rtl::OUString & strHostName, SocketAddr &Addr)
+ {
+ Addr = SocketAddr( osl_resolveHostname( strHostName.pData ) , SAL_NO_COPY );
+ }
+
+ // (static method)______________________________________________________________
+ inline sal_Int32 SAL_CALL SocketAddr::getServicePort(
+ const ::rtl::OUString& strServiceName,
+ const ::rtl::OUString & strProtocolName )
+ {
+ return osl_getServicePort( strServiceName.pData, strProtocolName.pData );
+ }
+
+ //______________________________________________________________________________
+ inline Socket::Socket(oslSocketType Type,
+ oslAddrFamily Family,
+ oslProtocol Protocol)
+ : m_handle( osl_createSocket(Family, Type, Protocol) )
+ {}
+
+ //______________________________________________________________________________
+ inline Socket::Socket( oslSocket socketHandle, __sal_NoAcquire )
+ : m_handle( socketHandle )
+ {}
+
+ //______________________________________________________________________________
+ inline Socket::Socket( oslSocket socketHandle )
+ : m_handle( socketHandle )
+ {
+ osl_acquireSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Socket::Socket( const Socket & socket )
+ : m_handle( socket.getHandle() )
+ {
+ osl_acquireSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Socket::~Socket()
+ {
+ osl_releaseSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Socket& Socket::operator= ( oslSocket socketHandle)
+ {
+ osl_acquireSocket( socketHandle );
+ osl_releaseSocket( m_handle );
+ m_handle = socketHandle;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline Socket& Socket::operator= (const Socket& sock)
+ {
+ return (*this) = sock.getHandle();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::operator==( const Socket& rSocket ) const
+ {
+ return m_handle == rSocket.getHandle();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::operator==( const oslSocket socketHandle ) const
+ {
+ return m_handle == socketHandle;
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::shutdown( oslSocketDirection Direction )
+ {
+ osl_shutdownSocket( m_handle , Direction );
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::close()
+ {
+ osl_closeSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::getLocalAddr( SocketAddr & addr) const
+ {
+ addr.assign( osl_getLocalAddrOfSocket( m_handle ) , SAL_NO_COPY );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getLocalPort() const
+ {
+ SocketAddr addr( 0 );
+ getLocalAddr( addr );
+ return addr.getPort();
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString Socket::getLocalHost() const
+ {
+ SocketAddr addr( 0 );
+ getLocalAddr( addr );
+ return addr.getHostname();
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::getPeerAddr( SocketAddr &addr ) const
+ {
+ addr.assign( osl_getPeerAddrOfSocket( m_handle ), SAL_NO_COPY );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getPeerPort() const
+ {
+ SocketAddr addr( 0 );
+ getPeerAddr( addr );
+ return addr.getPort();
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString Socket::getPeerHost() const
+ {
+ SocketAddr addr( 0 );
+ getPeerAddr( addr );
+ return addr.getHostname();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::bind(const SocketAddr& LocalInterface)
+ {
+ return osl_bindAddrToSocket( m_handle , LocalInterface.getHandle() );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isRecvReady(const TimeValue *pTimeout ) const
+ {
+ return osl_isReceiveReady( m_handle , pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isSendReady(const TimeValue *pTimeout ) const
+ {
+ return osl_isSendReady( m_handle, pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isExceptionPending(const TimeValue *pTimeout ) const
+ {
+ return osl_isExceptionPending( m_handle, pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketType Socket::getType() const
+ {
+ return osl_getSocketType( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getOption(
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level) const
+ {
+ return osl_getSocketOption( m_handle, Level, Option, pBuffer , BufferLen );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::setOption( oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level ) const
+ {
+ return osl_setSocketOption( m_handle, Level, Option , pBuffer, BufferLen );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::setOption( oslSocketOption option, sal_Int32 nValue )
+ {
+ return setOption( option, &nValue, sizeof( nValue ) );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getOption( oslSocketOption option ) const
+ {
+ sal_Int32 n;
+ getOption( option, &n, sizeof( n ) );
+ return n;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::enableNonBlockingMode( sal_Bool bNonBlockingMode)
+ {
+ return osl_enableNonBlockingMode( m_handle , bNonBlockingMode );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isNonBlockingMode() const
+ {
+ return osl_isNonBlockingMode( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline void SAL_CALL Socket::clearError() const
+ {
+ sal_Int32 err = 0;
+ getOption(osl_Socket_OptionError, &err, sizeof(err));
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketError Socket::getError() const
+ {
+ return osl_getLastSocketError( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString Socket::getErrorAsString( ) const
+ {
+ ::rtl::OUString error;
+ osl_getLastSocketErrorDescription( m_handle, &(error.pData) );
+ return error;
+ }
+
+ //______________________________________________________________________________
+ inline oslSocket Socket::getHandle() const
+ {
+ return m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket(oslAddrFamily Family,
+ oslProtocol Protocol,
+ oslSocketType Type )
+ : Socket( Type, Family, Protocol )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket( oslSocket socketHandle, __sal_NoAcquire noacquire )
+ : Socket( socketHandle, noacquire )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket( oslSocket socketHandle )
+ : Socket( socketHandle )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket( const StreamSocket & socket )
+ : Socket( socket )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::read(void* pBuffer, sal_uInt32 n)
+ {
+ return osl_readSocket( m_handle, pBuffer, n );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::write(const void* pBuffer, sal_uInt32 n)
+ {
+ return osl_writeSocket( m_handle, pBuffer, n );
+ }
+
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::recv(void* pBuffer,
+ sal_uInt32 BytesToRead,
+ oslSocketMsgFlag Flag)
+ {
+ return osl_receiveSocket( m_handle, pBuffer,BytesToRead, Flag );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::send(const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag Flag)
+ {
+ return osl_sendSocket( m_handle, pBuffer, BytesToSend, Flag );
+ }
+
+ //______________________________________________________________________________
+ inline ConnectorSocket::ConnectorSocket(oslAddrFamily Family,
+ oslProtocol Protocol,
+ oslSocketType Type)
+ : StreamSocket( Family, Protocol ,Type )
+ {}
+
+ //______________________________________________________________________________
+ inline oslSocketResult ConnectorSocket::connect( const SocketAddr& TargetHost,
+ const TimeValue* pTimeout )
+ {
+ return osl_connectSocketTo( m_handle , TargetHost.getHandle(), pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline AcceptorSocket::AcceptorSocket(oslAddrFamily Family ,
+ oslProtocol Protocol ,
+ oslSocketType Type )
+ : Socket( Type, Family, Protocol )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Bool AcceptorSocket::listen(sal_Int32 MaxPendingConnections)
+ {
+ return osl_listenOnSocket( m_handle, MaxPendingConnections );
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketResult AcceptorSocket::acceptConnection( StreamSocket& Connection)
+ {
+ oslSocket o = osl_acceptConnectionOnSocket( m_handle, 0 );
+ oslSocketResult status = osl_Socket_Ok;
+ if( o )
+ {
+ Connection = StreamSocket( o , SAL_NO_ACQUIRE );
+ }
+ else
+ {
+ Connection = StreamSocket();
+ status = osl_Socket_Error;
+ }
+ return status;
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketResult AcceptorSocket::acceptConnection(
+ StreamSocket& Connection, SocketAddr & PeerAddr)
+ {
+ // TODO change in/OUT parameter
+ oslSocket o = osl_acceptConnectionOnSocket( m_handle, (oslSocketAddr *)&PeerAddr );
+ oslSocketResult status = osl_Socket_Ok;
+ if( o )
+ {
+ Connection = StreamSocket( o , SAL_NO_ACQUIRE );
+ }
+ else
+ {
+ Connection = StreamSocket();
+ status = osl_Socket_Error;
+ }
+ return status;
+ }
+
+ //______________________________________________________________________________
+ inline DatagramSocket::DatagramSocket(oslAddrFamily Family,
+ oslProtocol Protocol,
+ oslSocketType Type)
+ : Socket( Type, Family, Protocol )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Int32 DatagramSocket::recvFrom(void* pBuffer,
+ sal_uInt32 BufferSize,
+ SocketAddr* pSenderAddr,
+ oslSocketMsgFlag Flag )
+ {
+ sal_Int32 nByteRead;
+ if( pSenderAddr )
+ {
+ // TODO : correct the out-parameter pSenderAddr outparameter
+ nByteRead = osl_receiveFromSocket( m_handle, pSenderAddr->getHandle() , pBuffer,
+ BufferSize, Flag);
+// nByteRead = osl_receiveFromSocket( m_handle, *(oslSocketAddr**) &pSenderAddr , pBuffer,
+// BufferSize, Flag);
+ }
+ else
+ {
+ nByteRead = osl_receiveFromSocket( m_handle, 0 , pBuffer , BufferSize , Flag );
+ }
+ return nByteRead;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 DatagramSocket::sendTo( const SocketAddr& ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BufferSize,
+ oslSocketMsgFlag Flag )
+ {
+ return osl_sendToSocket( m_handle, ReceiverAddr.getHandle(), pBuffer, BufferSize, Flag );
+ }
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/socket_decl.hxx b/include/osl/socket_decl.hxx
new file mode 100644
index 000000000000..f51cca12e4c3
--- /dev/null
+++ b/include/osl/socket_decl.hxx
@@ -0,0 +1,721 @@
+/* -*- 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 _OSL_SOCKET_DECL_HXX_
+#define _OSL_SOCKET_DECL_HXX_
+
+#include <osl/socket.h>
+#include <rtl/ustring.hxx>
+#include <rtl/byteseq.hxx>
+
+namespace osl
+{
+ enum __osl_socket_NoCopy { SAL_NO_COPY };
+
+ /** The class should be understood as a reference to a socket address handle ( struct sockaddr ).
+
+ The handle is mutable.
+ */
+ class SocketAddr
+ {
+ protected:
+ oslSocketAddr m_handle;
+ public:
+
+ /** Creates socket address of unknown type.
+ */
+ inline SocketAddr();
+
+ /** Copy constructor.
+ */
+ inline SocketAddr(const SocketAddr& Addr);
+
+ /** The SocketAddr takes over the responsibility of the handle ( which means,
+ that the handle gets destructed by the destructor of this reference)
+ @param nocopy use SAL_NO_COPY
+ */
+ inline SocketAddr(const oslSocketAddr , __osl_socket_NoCopy nocopy );
+
+ /** Copyconstructs the oslSocketAddr handle.
+ */
+ inline SocketAddr(oslSocketAddr Addr);
+
+ /** tcpip-specif constructor.
+ @param strAddrOrHostName strAddrOrHostName hostname or dotted ip-number of the network
+ interface, the socket shall be created on.
+ @param nPort tcp-ip port number
+ */
+ inline SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort );
+
+ /** destroys underlying oslSocketAddress
+ */
+ inline ~SocketAddr();
+
+ /** checks, if the SocketAddr was created successful.
+ @return <code>sal_True</code> if there is a valid underlying handle,
+ otherwise sal_False.
+ */
+ inline sal_Bool is() const;
+
+ /** Converts the address to a (human readable) domain-name.
+
+ @param pResult 0, if you are not interested in errors,
+ otherwise *pResult contains an error code on failure
+ or osl_Socket_Ok on success
+ @return the hostname of this SocketAddr or an empty string on failure.
+ @see osl_getHostnameOfSocketAddr()
+ */
+ inline ::rtl::OUString SAL_CALL getHostname( oslSocketResult *pResult = 0 ) const;
+
+ /** Sets the ipaddress or hostname of the SocketAddress
+ */
+ inline sal_Bool SAL_CALL setHostname( const ::rtl::OUString &sDottedIpOrHostname );
+
+ /** Returns the port number of the address.
+ @return the port in host-byte order or or OSL_INVALID_PORT on errors.
+ */
+ inline sal_Int32 SAL_CALL getPort() const;
+
+ /** Sets the port number of the address.
+ @return true if successfule.
+ */
+ inline sal_Bool SAL_CALL setPort( sal_Int32 nPort );
+
+ /** Sets the address of the underlying socket address struct in network byte order.
+ @return true on success, false signales falure.
+ */
+ inline sal_Bool SAL_CALL setAddr( const ::rtl::ByteSequence & address );
+
+ /** Returns the address of the underlying socket in network byte order
+ */
+ inline ::rtl::ByteSequence SAL_CALL getAddr( oslSocketResult *pResult = 0 ) const;
+
+ /** assign the handle to this reference. The previous handle is released.
+ */
+ inline SocketAddr & SAL_CALL operator= (oslSocketAddr Addr);
+
+ /**
+ */
+ inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr);
+
+ /** Assigns the socket addr without copyconstructing it.
+ @param Addr the socket address.
+ @param nocopy use SAL_NO_COPY
+ */
+ inline SocketAddr & SAL_CALL assign( oslSocketAddr Addr, __osl_socket_NoCopy nocopy );
+
+ /** Returns true if the underlying handle is identical to the Addr handle.
+ */
+ inline sal_Bool SAL_CALL operator== (oslSocketAddr Addr) const;
+
+ /** Returns true if the underlying handle is identical to the Addr handle.
+ */
+ inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const;
+
+ /** Returns the underlying SocketAddr handle without copyconstructing it.
+ */
+ inline oslSocketAddr SAL_CALL getHandle() const;
+
+ /** Get the hostname for the local interface.
+ @param pResult after the call *pResult contains osl_Socket_Ok on success or
+ an error on failure.
+ @return the hostname
+ */
+ static inline ::rtl::OUString SAL_CALL getLocalHostname( oslSocketResult *pResult = 0);
+
+ /** Tries to find an address for a host.
+ @see osl_resolveHostname()
+ @return A new created socket-address or 0 if the name could not be found.
+ */
+ static inline void SAL_CALL resolveHostname(
+ const ::rtl::OUString & strHostName , SocketAddr & Addr );
+
+ /**
+ Tries to find the port associated with the given service/protocol-
+ pair (e.g. "ftp"/"tcp").
+ @return the port number in host-byte order or <code>OSL_INVALID_PORT</code>
+ if no service/protocol pair could be found.
+ */
+ static inline sal_Int32 SAL_CALL getServicePort(
+ const ::rtl::OUString& strServiceName,
+ const ::rtl::OUString & strProtocolName= ::rtl::OUString("tcp") );
+ };
+
+
+ class Socket
+ {
+ protected:
+ oslSocket m_handle;
+ protected:
+ /** Creates a socket. Note it's protected.
+ @param Type
+ @param Family
+ @param Protocol
+ */
+ inline Socket(oslSocketType Type,
+ oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp);
+ public:
+ inline Socket( );
+
+ inline Socket( const Socket & socket );
+
+ inline Socket( oslSocket socketHandle );
+
+ /** The instance takes over the handle's ownership without acquiring the
+ handle, but releases it within the dtor.
+ @param socketHandle the handle
+ @param noacquire use SAL_NO_ACQUIRE
+ */
+ inline Socket( oslSocket socketHandle, __sal_NoAcquire noacquire );
+
+ /** Destructor. Releases the underlying handle
+ */
+ inline ~Socket();
+
+ /** Assignment operator. If socket was already created, the old one will
+ be discarded.
+ */
+ inline Socket& SAL_CALL operator= ( oslSocket socketHandle);
+
+ /** Assignment operator. If socket was already created, the old one will
+ be discarded.
+ */
+ inline Socket& SAL_CALL operator= (const Socket& sock);
+
+ /**
+ @return <code>sal_True</code>, when the underlying handle of both
+ Socket instances are identical, <code>sal_False</code> otherwise.
+ */
+ inline sal_Bool SAL_CALL operator==( const Socket& rSocket ) const ;
+
+ /**
+ @return <code>sal_True</code>, when the underlying handle of both
+ Socket instances are identical, <code>sal_False</code> otherwise.
+ */
+ inline sal_Bool SAL_CALL operator==( const oslSocket socketHandle ) const;
+
+ /** Closes a definite or both directions of the bidirectional stream.
+
+ @param Direction
+ @see osl_shutdownSocket()
+ */
+ inline void SAL_CALL shutdown( oslSocketDirection Direction = osl_Socket_DirReadWrite );
+
+ /** Closes a socket.
+ Note that closing a socket is identical to shutdown( osl_Socket_DirReadWrite ),
+ as the operating system distinguish both cases, both functions or offered in this API.
+ @see osl_closeSocket()
+ */
+ inline void SAL_CALL close();
+
+ /** Retrieves the address of the local interface of this socket.
+ @param Addr [out] receives the address.
+ @see osl_getLocalAddrOfSocket()
+ */
+ inline void SAL_CALL getLocalAddr( SocketAddr &Addr ) const;
+
+ /** Get the local port of the socket. Usually used after bind().
+ @return the port number or OSL_INVALID_PORT on errors.
+ */
+ inline sal_Int32 SAL_CALL getLocalPort() const;
+
+ /** Get the hostname for the local interface.
+ @return the hostname or an empty string ("").
+ */
+ inline ::rtl::OUString SAL_CALL getLocalHost() const;
+
+ /** Retrieves the address of the remote host of this socket.
+ @param Addr [out] receives the address.
+ */
+ inline void SAL_CALL getPeerAddr( SocketAddr & Addr) const;
+
+ /** Get the remote port of the socket.
+ @return the port number or OSL_INVALID_PORT on errors.
+ */
+ inline sal_Int32 SAL_CALL getPeerPort() const;
+
+ /** Get the hostname for the remote interface.
+ @return the hostname or an empty string ("").
+ */
+ inline ::rtl::OUString SAL_CALL getPeerHost() const;
+
+ /** Binds the socket to the specified (local) interface.
+ @param LocalInterface Address of the Interface
+ @return True if bind was successful.
+ */
+ inline sal_Bool SAL_CALL bind(const SocketAddr& LocalInterface);
+
+ /** Checks if read operations will block.
+
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how the operation will block if the Socket is not ready.
+ @return <code>sal_True</code> if read operations (recv, recvFrom, accept) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occurred.
+
+ @param pTimeout if 0, the operation will block without a timeout. Otherwise
+ the specified amout of time.
+ */
+ inline sal_Bool SAL_CALL isRecvReady(const TimeValue *pTimeout = 0) const;
+
+ /** Checks if send operations will block.
+
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how the operation will block if the Socket is not ready.
+ @return <code>sal_True</code> if send operations (send, sendTo) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occurred.
+
+ @param pTimeout if 0, the operation will block without a timeout. Otherwise
+ the specified amout of time.
+ */
+ inline sal_Bool SAL_CALL isSendReady(const TimeValue *pTimeout = 0) const;
+
+
+ /** Checks if a request for out-of-band data will block.
+
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how the operation will block if the Socket has no pending OOB data.
+
+ @return <code>sal_True</code> if OOB-request operations (recv with appropriate flags)
+ on the Socket will NOT block; <code>sal_False</code> if it would block or if
+ an error occurred.
+
+ @param pTimeout if 0, the operation will block without a timeout. Otherwise
+ the specified amout of time.
+ */
+ inline sal_Bool SAL_CALL isExceptionPending(const TimeValue *pTimeout = 0) const;
+
+
+ /** Queries the socket for its type.
+ @return one of:
+ <ul>
+ <li> <code>osl_Socket_TypeStream</code>
+ <li> <code>osl_Socket_TypeDgram</code>
+ <li> <code>osl_Socket_TypeRaw</code>
+ <li> <code>osl_Socket_TypeRdm</code>
+ <li> <code>osl_Socket_TypeSeqPacket</code>
+ <li> <code>osl_invalid_SocketType</code>, if an error occurred
+ </ul>
+ */
+ inline oslSocketType SAL_CALL getType() const;
+
+ /** Retrieves option-attributes associated with the socket.
+ @param Option The attribute to query.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> <code>osl_Socket_Option_Debug</code><br>
+ (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.
+
+ <li> <code>osl_Socket_OptionAcceptConn</code><br>
+ <li> <code>osl_Socket_OptionReuseAddr</code><br>
+ (sal_Bool) Allows the socket to be bound to an address that is
+ already in use.
+ 1 = multiple bound allowed, 0 = no multiple bounds allowed
+
+ <li><code>osl_Socket_OptionKeepAlive</code><br>
+ (sal_Bool) Keepalive packets are sent by the underlying socket.
+ 1 = enabled, 0 = disabled
+
+ <li><code>osl_Socket_OptionDontRoute</code><br>
+ (sal_Bool) Do not route: send directly to interface.
+ 1 = do not route , 0 = routing possible
+
+ <li><code>osl_Socket_OptionBroadcast</code><br>
+ (sal_Bool) Transmission of broadcast messages are allowed on the socket.
+ 1 = transmission allowed, 0 = transmission disallowed
+
+ <li><code>osl_Socket_OptionUseLoopback</code><br>
+
+ <li><code>osl_Socket_OptionLinger</code><br>
+ (linger) Linger on close if unsent data is present.
+ linger has two members: l_onoff, l_linger
+ l_onoff = 0 is off, l_onoff > 0 and l_linger= timeout in seconds.
+
+ <li><code>osl_Socket_OptionOOBinLine</code><br>
+
+
+ <li><code>osl_Socket_OptionSndBuf</code><br>
+ (sal_Int32) Size of the send buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket.
+
+ <li><code>osl_Socket_OptionRcvBuf</code><br>
+ (sal_Int32) Size of the receive buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket and larger packet sizes.
+
+ <li><code>osl_Socket_OptionSndLowat</code><br>
+
+ <li><code>osl_Socket_OptionRcvLowat</code><br>
+
+ <li><code>osl_Socket_OptionSndTimeo</code><br>
+ (sal_Int32) Data is sent after this timeout. This allows gathering
+ of data to send larger packages but increases latency times.
+
+ <li><code>osl_Socket_OptionRcvTimeo</code><br>
+
+ <li><code>osl_Socket_OptionError</code><br>
+ <li><code>osl_Socket_OptionType</code><br>
+
+ <li><code>osl_Socket_OptionTcpNoDelay</code><br>
+ Disables the Nagle algorithm for send coalescing. (Do not
+ collect data until a packet is full, instead send immediately.
+ This increases network traffic but might improve latency-times.)
+ 1 = disables the algorithm, 0 = keeps it enabled.
+ </ul>
+
+ If not above mentioned otherwise, the options are only valid for
+ level <code>osl_Socket_LevelSocket</code>.
+ @param pBuffer The Buffer will be filled with the attribute.
+
+ @param BufferLen The size of pBuffer.
+
+ @param Level The option level.
+
+ Valid values are:
+ <ul>
+ <li><code>osl_Socket_LevelSocket</code> : Socket Level
+ <li><code>osl_Socket_LevelTcp</code> : Level of Transmission Control Protocol
+ </ul>
+ @return The size of the attribute copied into pBuffer or -1 if an error
+ occurred.
+ */
+ inline sal_Int32 SAL_CALL getOption(
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level= osl_Socket_LevelSocket) const;
+
+ /** Sets the sockets attributes.
+
+ @param Option denotes the option to modify.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> osl_Socket_Option_Debug
+ <li> osl_Socket_OptionAcceptConn
+ <li> osl_Socket_OptionReuseAddr
+ <li> osl_Socket_OptionKeepAlive
+ <li> osl_Socket_OptionDontRoute
+ <li> osl_Socket_OptionBroadcast
+ <li> osl_Socket_OptionUseLoopback
+ <li> osl_Socket_OptionLinger
+ <li> osl_Socket_OptionOOBinLine
+ <li> osl_Socket_OptionSndBuf
+ <li> osl_Socket_OptionRcvBuf
+ <li> osl_Socket_OptionSndLowat
+ <li> osl_Socket_OptionRcvLowat
+ <li> osl_Socket_OptionSndTimeo
+ <li> osl_Socket_OptionRcvTimeo
+ <li> osl_Socket_OptionError
+ <li> osl_Socket_OptionType
+ <li> osl_Socket_OptionTcpNoDelay
+ </ul>
+
+ If not above mentioned otherwise, the options are only valid for
+ level osl_Socket_LevelSocket.
+
+ @param pBuffer Pointer to a Buffer which contains the attribute-value.
+
+ @param BufferLen contains the length of the Buffer.
+
+ @param Level selects the level for which an option should be changed.
+ Valid values are:
+ <ul>
+ <li> osl_Socket_evel_Socket : Socket Level
+ <li> osl_Socket_Level_Tcp : Level of Transmission Control Protocol
+ </ul>
+
+ @return True if the option could be changed.
+ */
+ inline sal_Bool SAL_CALL setOption( oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level= osl_Socket_LevelSocket ) const;
+
+ /** Convenience function for setting sal_Bool and sal_Int32 option values.
+ @see setOption()
+ */
+ inline sal_Bool setOption( oslSocketOption option, sal_Int32 nValue );
+
+ /** Convenience function for retrieving sal_Bool and sal_Int32 option values.
+ @see setOption()
+ */
+ inline sal_Int32 getOption( oslSocketOption option ) const;
+
+ /** Enables/disables non-blocking mode of the socket.
+ @param bNonBlockingMode If <code>sal_True</code>, blocking mode will be switched off
+ If <code>sal_False</code>, the socket will become a blocking
+ socket (which is the default behaviour of a socket).
+ @return <code>sal_True</code> if mode could be set.
+ */
+ inline sal_Bool SAL_CALL enableNonBlockingMode( sal_Bool bNonBlockingMode);
+
+ /** Query blocking mode of the socket.
+ @return <code>sal_True</code> if non-blocking mode is set.
+ */
+ inline sal_Bool SAL_CALL isNonBlockingMode() const;
+
+
+ /** clears the error status
+ */
+ inline void SAL_CALL clearError() const;
+
+ /** returns a constant decribing the last error for the socket system.
+
+ @return osl_Socket_E_NONE if no error occurred, invalid_SocketError if
+ an unknown (unmapped) error occurred, otherwise an enum describing the
+ error.
+ @see osl_getLastSocketError()
+ */
+ inline oslSocketError getError() const;
+
+ /** Builds a string with the last error-message for the socket.
+ */
+ inline ::rtl::OUString getErrorAsString( ) const;
+
+ /** Returns the underlying handle unacquired (The caller must acquire it to keep it).
+ */
+ inline oslSocket getHandle() const;
+ };
+
+
+ class StreamSocket : public Socket
+ {
+ public:
+ /** Creates a socket.
+ @param Family the Family of the socket (Inet by default)
+ @param Protocol the Protocon of the socket (IP by default)
+ @param Type For some protocols it might be desirable to
+ use a different type than <code>osl_Socket_TypeStream</code>
+ (like <code>osl_Socket_TypeSeqPacket</code>).
+ Therefore this parameter is not hidden.
+ */
+ inline StreamSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp,
+ oslSocketType Type = osl_Socket_TypeStream);
+
+ inline StreamSocket( const StreamSocket & );
+
+ inline StreamSocket( oslSocket Socket , __sal_NoAcquire noacquire );
+
+ inline StreamSocket( oslSocket Socket );
+
+ /** Retrieves n bytes from the stream and copies them into pBuffer.
+ The method avoids incomplete reads due to packet boundaries and is thus
+ blocking.
+ @param pBuffer receives the read data. pBuffer must be large enough
+ to hold n bytes.
+ @param n the number of bytes to read.
+ @return the number of read bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ inline sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 n);
+
+ /** Writes n bytes from pBuffer to the stream. The method avoids
+ incomplete writes due to packet boundaries and is thus blocking.
+ @param pBuffer contains the data to be written.
+ @param n the number of bytes to write.
+ @return the number of written bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ inline sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
+
+
+ /** Tries to receive BytesToRead data from the connected socket,
+
+ @param[out] pBuffer Points to a buffer that will be filled with the received
+ data. pBuffer must have at least have a size of BytesToRead.
+ @param[in] BytesToRead The number of bytes to read.
+ @param[in] flags Modifier for the call. Valid values are:
+
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+ @return the number of received bytes, which may be less than BytesToRead.
+ */
+ inline sal_Int32 SAL_CALL recv(void* pBuffer,
+ sal_uInt32 BytesToRead,
+ oslSocketMsgFlag flags= osl_Socket_MsgNormal);
+
+ /** Tries to send BytesToSend data to the connected socket.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes. It may be less than BytesToSend.
+ */
+ sal_Int32 SAL_CALL send(const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag= osl_Socket_MsgNormal);
+ };
+
+ class ConnectorSocket : public StreamSocket
+ {
+ public:
+ /** Creates a socket that can connect to a (remote) host.
+ @param Family the Family of the socket (Inet by default)
+ @param Protocol the Protocon of the socket (IP by default)
+ @param Type For some protocols it might be desirable to
+ use a different type than sock_stream <code>osl_Socket_TypeSeqPacket</code>
+ (like <code>osl_Socket_TypeSeqPacket</code>).
+ Therefore we do not hide this parameter here.
+ */
+ ConnectorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp,
+ oslSocketType Type = osl_Socket_TypeStream);
+
+
+ /** Connects the socket to a (remote) host.
+ @param TargetHost The address of the target.
+ @param pTimeout The timeout for blocking. If 0, a default system dependent timeout
+ us used.
+ @return <code> osl_Socket_Ok</code> if connected successfully,
+ <code>osl_Socket_TimedOut</code> on timeout,
+ <code>osl_Socket_Interrupted</code> if unblocked forcefully (by osl::Socket::close()),
+ <code>osl_Socket_Error</code> if connect failed.
+ */
+ oslSocketResult SAL_CALL connect(const SocketAddr& TargetHost, const TimeValue* pTimeout = 0);
+ };
+
+ /** Allows to accept socket connections.
+ */
+ class AcceptorSocket : public Socket
+ {
+ public:
+ inline AcceptorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp,
+ oslSocketType Type = osl_Socket_TypeStream);
+
+ /** Prepare a socket for the accept-call. The socket must have been
+ bound before to the local address.
+ @param MaxPendingConnections The maximum number of pending
+ connections (waiting to be accepted) on this socket. If you use
+ -1, a system default value is used.
+ @return <code>sal_True</code> if call was successful.
+ */
+ inline sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
+
+ /** Accepts incoming connections on the socket. You must
+ precede this call with osl::Socket::bind() and listen().
+ @param Connection receives the incoming connection.
+ @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
+ <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
+ <code>osl_Socket_Error</code> on errors.
+ */
+ inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection);
+
+ /** Accepts incoming connections on the socket. You must
+ precede this call with osl::Socket::bind() and listen().
+ @param PeerAddr receives the address of the connecting entity
+ (your communication partner).
+ @param Connection receives the incoming connection.
+ @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
+ <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
+ <code>osl_Socket_Error</code> on errors.
+ */
+ inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection, SocketAddr & PeerAddr);
+ };
+
+
+
+ /** A connectionless socket to send and receive datagrams.
+ */
+ class DatagramSocket : public Socket
+ {
+ public:
+
+ /** Creates a datagram socket.
+ @param Family the Family of the socket (Inet by default)
+ @param Protocol the Protocon of the socket (IP by default)
+ @param Type is sock_dgram by default.
+ */
+ inline DatagramSocket(oslAddrFamily Family= osl_Socket_FamilyInet,
+ oslProtocol Protocol= osl_Socket_ProtocolIp,
+ oslSocketType Type= osl_Socket_TypeDgram);
+
+ /** Tries to receives BufferSize data from the socket, if no error occurs.
+
+ @param pSenderAddr [out] You must provide pointer to a SocketAddr.
+ It will be filled with the address of the datagrams sender.
+ If pSenderAddr is 0, it is ignored.
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ datagram.
+ @param BufferSize [in] The size of pBuffer.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of received bytes.
+ */
+ inline sal_Int32 SAL_CALL recvFrom(void* pBuffer,
+ sal_uInt32 BufferSize,
+ SocketAddr* pSenderAddr= 0,
+ oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
+
+ /** Tries to send one datagram with BytesToSend size to the given ReceiverAddr.
+ Since there is only send one packet, the function doesn't care about
+ packet boundaries.
+
+ @param ReceiverAddr [in] A SocketAddr that contains
+ the destination address for this send.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BufferSize [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes.
+ */
+ inline sal_Int32 SAL_CALL sendTo( const SocketAddr& ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BufferSize,
+ oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
+ };
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/thread.h b/include/osl/thread.h
new file mode 100644
index 000000000000..bc93a57b1735
--- /dev/null
+++ b/include/osl/thread.h
@@ -0,0 +1,196 @@
+/* -*- 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 _OSL_THREAD_H_
+#define _OSL_THREAD_H_
+
+#include "sal/config.h"
+
+#include "osl/time.h"
+#include "rtl/textenc.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ Opaque data type for threads. As with all other osl-handles
+ you can initialize and/or test it to/for 0.
+*/
+typedef void* oslThread;
+
+/** the function-ptr. representing the threads worker-function.
+*/
+typedef void (SAL_CALL *oslWorkerFunction)(void*);
+
+/** levels of thread-priority
+ Note that oslThreadPriorityUnknown might be returned
+ by getPriorityOfThread() (e.g. when it is terminated),
+ but mustn't be used with setPriority()!
+*/
+typedef enum
+{
+ osl_Thread_PriorityHighest,
+ osl_Thread_PriorityAboveNormal,
+ osl_Thread_PriorityNormal,
+ osl_Thread_PriorityBelowNormal,
+ osl_Thread_PriorityLowest,
+ osl_Thread_PriorityUnknown, /* don't use to set */
+ osl_Thread_Priority_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslThreadPriority;
+
+
+typedef sal_uInt32 oslThreadIdentifier;
+
+typedef void* oslThreadKey;
+
+/** Create the thread, using the function-ptr pWorker as
+ its main (worker) function. This functions receives in
+ its void* parameter the value supplied by pThreadData.
+ Once the OS-structures are initialized,the thread starts
+ running.
+ @return 0 if creation failed, otherwise a handle to the thread
+*/
+SAL_DLLPUBLIC oslThread SAL_CALL osl_createThread(oslWorkerFunction pWorker, void* pThreadData);
+
+/** Create the thread, using the function-ptr pWorker as
+ its main (worker) function. This functions receives in
+ its void* parameter the value supplied by pThreadData.
+ The thread will be created, but it won't start running.
+ To wake-up the thread, use resume().
+ @return 0 if creation failed, otherwise a handle to the thread
+*/
+SAL_DLLPUBLIC oslThread SAL_CALL osl_createSuspendedThread(oslWorkerFunction pWorker, void* pThreadData);
+
+/** Get the identifier for the specified thread or if parameter
+ Thread is NULL of the current active thread.
+ @return identifier of the thread
+*/
+SAL_DLLPUBLIC oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread);
+
+/** Release the thread handle.
+ If Thread is NULL, the function won't do anything.
+ Note that we do not interfere with the actual running of
+ the thread, we just free up the memory needed by the handle.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_destroyThread(oslThread Thread);
+
+/** Wake-up a thread that was suspended with suspend() or
+ createSuspended(). The oslThread must be valid!
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_resumeThread(oslThread Thread);
+
+/** Suspend the execution of the thread. If you want the thread
+ to continue, call resume(). The oslThread must be valid!
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_suspendThread(oslThread Thread);
+
+/** Changes the threads priority.
+ The oslThread must be valid!
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority);
+
+/** Retrieves the threads priority.
+ Returns oslThreadPriorityUnknown for invalid Thread-argument or
+ terminated thread. (I.e.: The oslThread might be invalid.)
+*/
+SAL_DLLPUBLIC oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread);
+
+/** Returns True if the thread was created and has not terminated yet.
+ Note that according to this definition a "running" thread might be
+ suspended! Also returns False is Thread is NULL.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread);
+
+/** Blocks the calling thread until Thread has terminated.
+ Returns immediately if Thread is NULL.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_joinWithThread(oslThread Thread);
+
+/** Blocks the calling thread at least for the given number
+ of time.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_waitThread(const TimeValue* pDelay);
+
+/** The requested thread will get terminate the next time
+ scheduleThread() is called.
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_terminateThread(oslThread Thread);
+
+/** Offers the rest of the threads time-slice to the OS.
+ scheduleThread() should be called in the working loop
+ of the thread, so any other thread could also get the
+ processor. Returns False if the thread should terminate, so
+ the thread could free any allocated resources.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread);
+
+/** Offers the rest of the threads time-slice to the OS.
+ Under POSIX you _need_ to yield(), otherwise, since the
+ threads are not preempted during execution, NO other thread
+ (even with higher priority) gets the processor. Control is
+ only given to another thread if the current thread blocks
+ or uses yield().
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_yieldThread(void);
+
+/** Attempts to set the name of the current thread.
+
+ The name of a thread is usually evaluated for debugging purposes. Not all
+ platforms support this. On Linux, a set thread name can be observed with
+ "ps -L". On Windows with the Microsoft compiler, a thread name set while a
+ debugger is attached can be observed within the debugger.
+
+ @param name the name of the thread; must not be null; on Linux, only the
+ first 16 characters are used
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_setThreadName(char const * name);
+
+/* Callback when data stored in a thread key is no longer needed */
+
+typedef void (SAL_CALL *oslThreadKeyCallbackFunction)(void *);
+
+/** Create a key to an associated thread local storage pointer. */
+SAL_DLLPUBLIC oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback);
+
+/** Destroy a key to an associated thread local storage pointer. */
+SAL_DLLPUBLIC void SAL_CALL osl_destroyThreadKey(oslThreadKey Key);
+
+/** Get to key associated thread specific data. */
+SAL_DLLPUBLIC void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key);
+
+/** Set to key associated thread specific data. */
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData);
+
+/** Get the current thread local text encoding. */
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void);
+
+/** Set the thread local text encoding.
+ @return the old text encoding.
+*/
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding(rtl_TextEncoding Encoding);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_THREAD_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/thread.hxx b/include/osl/thread.hxx
new file mode 100644
index 000000000000..3a1b73e829ef
--- /dev/null
+++ b/include/osl/thread.hxx
@@ -0,0 +1,238 @@
+/* -*- 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 _THREAD_HXX_
+#define _THREAD_HXX_
+
+#include "sal/config.h"
+
+#include <cassert>
+
+#include <osl/time.h>
+
+
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <rtl/alloc.h>
+
+namespace osl
+{
+/** threadFunc is the function which is executed by the threads
+ created by the osl::Thread class. The function's signature
+ matches the one of oslWorkerFunction which is declared in
+ osl/thread.h .
+*/
+extern "C" inline void SAL_CALL threadFunc( void* param);
+
+/**
+ A thread abstraction.
+
+ @deprecated use ::salhelper::Thread instead. Only the static member
+ functions ::osl::Thread::getCurrentIdentifier, ::osl::Thread::wait, and
+ ::osl::Thread::yield are not deprecated.
+ */
+class Thread
+{
+ Thread( const Thread& );
+ Thread& operator= ( const Thread& );
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW (())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW (())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW (())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW (())
+ {}
+
+ Thread(): m_hThread(0){}
+
+ virtual ~Thread()
+ {
+ osl_destroyThread( m_hThread);
+ }
+
+ sal_Bool SAL_CALL create()
+ {
+ assert(m_hThread == 0); // only one running thread per instance
+ m_hThread = osl_createSuspendedThread( threadFunc, (void*)this);
+ if (m_hThread == 0)
+ {
+ return false;
+ }
+ osl_resumeThread(m_hThread);
+ return true;
+ }
+
+ sal_Bool SAL_CALL createSuspended()
+ {
+ assert(m_hThread == 0); // only one running thread per instance
+ if( m_hThread)
+ return sal_False;
+ m_hThread= osl_createSuspendedThread( threadFunc,
+ (void*)this);
+ return m_hThread != 0;
+ }
+
+ virtual void SAL_CALL suspend()
+ {
+ if( m_hThread )
+ osl_suspendThread(m_hThread);
+ }
+
+ virtual void SAL_CALL resume()
+ {
+ if( m_hThread )
+ osl_resumeThread(m_hThread);
+ }
+
+ virtual void SAL_CALL terminate()
+ {
+ if( m_hThread )
+ osl_terminateThread(m_hThread);
+ }
+
+ virtual void SAL_CALL join()
+ {
+ osl_joinWithThread(m_hThread);
+ }
+
+ sal_Bool SAL_CALL isRunning() const
+ {
+ return osl_isThreadRunning(m_hThread);
+ }
+
+ void SAL_CALL setPriority( oslThreadPriority Priority)
+ {
+ if( m_hThread )
+ osl_setThreadPriority(m_hThread, Priority);
+ }
+
+ oslThreadPriority SAL_CALL getPriority() const
+ {
+ return m_hThread ? osl_getThreadPriority(m_hThread) : osl_Thread_PriorityUnknown;
+ }
+
+ oslThreadIdentifier SAL_CALL getIdentifier() const
+ {
+ return osl_getThreadIdentifier(m_hThread);
+ }
+
+ static oslThreadIdentifier SAL_CALL getCurrentIdentifier()
+ {
+ return osl_getThreadIdentifier(0);
+ }
+
+ static void SAL_CALL wait(const TimeValue& Delay)
+ {
+ osl_waitThread(&Delay);
+ }
+
+ static void SAL_CALL yield()
+ {
+ osl_yieldThread();
+ }
+
+ static inline void setName(char const * name) throw () {
+ osl_setThreadName(name);
+ }
+
+ virtual sal_Bool SAL_CALL schedule()
+ {
+ return m_hThread ? osl_scheduleThread(m_hThread) : sal_False;
+ }
+
+ SAL_CALL operator oslThread() const
+ {
+ return m_hThread;
+ }
+
+protected:
+
+ /** The thread functions calls the protected functions
+ run and onTerminated.
+ */
+ friend void SAL_CALL threadFunc( void* param);
+
+ virtual void SAL_CALL run() = 0;
+
+ virtual void SAL_CALL onTerminated()
+ {
+ }
+
+private:
+ oslThread m_hThread;
+};
+
+extern "C" inline void SAL_CALL threadFunc( void* param)
+{
+ Thread* pObj= (Thread*)param;
+ pObj->run();
+ pObj->onTerminated();
+}
+
+class ThreadData
+{
+ ThreadData( const ThreadData& );
+ ThreadData& operator= (const ThreadData& );
+public:
+ /// Create a thread specific local data key
+ ThreadData( oslThreadKeyCallbackFunction pCallback= 0 )
+ {
+ m_hKey = osl_createThreadKey( pCallback );
+ }
+
+ /// Destroy a thread specific local data key
+ ~ThreadData()
+ {
+ osl_destroyThreadKey(m_hKey);
+ }
+
+ /** Set the data associated with the data key.
+ @returns True if operation was successful
+ */
+ sal_Bool SAL_CALL setData(void *pData)
+ {
+ return (osl_setThreadKeyData(m_hKey, pData));
+ }
+
+ /** Get the data associated with the data key.
+ @returns The data asscoitaed with the data key or
+ NULL if no data was set
+ */
+ void* SAL_CALL getData()
+ {
+ return osl_getThreadKeyData(m_hKey);
+ }
+
+ operator oslThreadKey() const
+ {
+ return m_hKey;
+ }
+
+private:
+ oslThreadKey m_hKey;
+};
+
+} // end namespace osl
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/time.h b/include/osl/time.h
new file mode 100644
index 000000000000..4be9e7278419
--- /dev/null
+++ b/include/osl/time.h
@@ -0,0 +1,159 @@
+/* -*- 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 _OSL_TIME_H_
+#define _OSL_TIME_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****************************************************************************/
+/* TimeValue */
+/****************************************************************************/
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+/* Time since Jan-01-1970 */
+
+typedef struct {
+ sal_uInt32 Seconds;
+ sal_uInt32 Nanosec;
+} TimeValue;
+
+#if defined(SAL_W32)
+# pragma pack(pop)
+#endif
+
+
+/****************************************************************************/
+/* oslDateTime */
+/****************************************************************************/
+
+typedef struct _oslDateTime
+{
+ /*----------------------------------------------------------------------*/
+ /** contains the nanoseconds .
+ */
+ sal_uInt32 NanoSeconds;
+
+ /** contains the seconds (0-59).
+ */
+ sal_uInt16 Seconds;
+
+ /*----------------------------------------------------------------------*/
+ /** contains the minutes (0-59).
+ */
+ sal_uInt16 Minutes;
+
+ /*----------------------------------------------------------------------*/
+ /** contains the hour (0-23).
+ */
+ sal_uInt16 Hours;
+
+ /*----------------------------------------------------------------------*/
+ /** is the day of month (1-31).
+ */
+ sal_uInt16 Day;
+
+ /*----------------------------------------------------------------------*/
+ /** is the day of week (0-6 , 0 : Sunday).
+ */
+ sal_uInt16 DayOfWeek;
+
+ /*----------------------------------------------------------------------*/
+ /** is the month of year (1-12).
+ */
+ sal_uInt16 Month;
+
+ /*----------------------------------------------------------------------*/
+ /** is the year.
+ */
+ sal_uInt16 Year;
+
+} oslDateTime;
+
+
+/** Get the current system time as TimeValue.
+ @return false if any error occurs.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTime(
+ TimeValue* pTimeVal );
+
+
+/** Get the GMT from a TimeValue and fill a struct oslDateTime
+ @param[in] pTimeVal TimeValue
+ @param[out] pDateTime On success it receives a struct oslDateTime
+
+ @return sal_False if any error occurs else sal_True.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getDateTimeFromTimeValue(
+ TimeValue* pTimeVal, oslDateTime* pDateTime );
+
+
+/** Get the GMT from a oslDateTime and fill a TimeValue
+ @param[in] pDateTime oslDateTime
+ @param[out] pTimeVal On success it receives a TimeValue
+
+ @return sal_False if any error occurs else sal_True.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getTimeValueFromDateTime(
+ oslDateTime* pDateTime, TimeValue* pTimeVal );
+
+
+/** Convert GMT to local time
+ @param[in] pSystemTimeVal system time to convert
+ @param[out] pLocalTimeVal On success it receives the local time
+
+ @return sal_False if any error occurs else sal_True.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime(
+ TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
+
+
+/** Convert local time to GMT
+ @param[in] pLocalTimeVal local time to convert
+ @param[out] pSystemTimeVal On success it receives the system time
+
+ @return sal_False if any error occurs else sal_True.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime(
+ TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
+
+
+/** Get the value of the global timer
+ @return current timer value in milli seconds
+ */
+
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_TIME_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/osl/util.h b/include/osl/util.h
new file mode 100644
index 000000000000..e9afe39ac20f
--- /dev/null
+++ b/include/osl/util.h
@@ -0,0 +1,50 @@
+/* -*- 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 _OSL_UTIL_H_
+#define _OSL_UTIL_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @param pEthernetAddr 6 bytes of memory
+
+ @return sal_True if the ethernetaddress could be retrieved. <br>
+ sal_False if no address could be found. This may be either because
+ there is no ethernet card or there is no appropriate algorithm
+ implemented on the platform. In this case, pEthernetAddr is
+ unchanged.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 *pEthernetAddr );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/alloc.h b/include/rtl/alloc.h
new file mode 100644
index 000000000000..ef48d01719ee
--- /dev/null
+++ b/include/rtl/alloc.h
@@ -0,0 +1,257 @@
+/* -*- 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 _RTL_ALLOC_H_
+#define _RTL_ALLOC_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** Allocate memory.
+
+ A call to this function will return NULL upon the requested
+ memory size being either zero or larger than currently allocatable.
+
+ @param Bytes [in] memory size.
+ @return pointer to allocated memory.
+ */
+SAL_DLLPUBLIC void * SAL_CALL rtl_allocateMemory (
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Reallocate memory.
+
+ A call to this function with parameter 'Ptr' being NULL
+ is equivalent to a rtl_allocateMemory() call.
+ A call to this function with parameter 'Bytes' being 0
+ is equivalent to a rtl_freeMemory() call.
+
+ @see rtl_allocateMemory()
+ @see rtl_freeMemory()
+
+ @param Ptr [in] pointer to previously allocated memory.
+ @param Bytes [in] new memory size.
+ @return pointer to reallocated memory. May differ from Ptr.
+ */
+SAL_DLLPUBLIC void * SAL_CALL rtl_reallocateMemory (
+ void * Ptr,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Free memory.
+ @param Ptr [in] pointer to previously allocated memory.
+ @return none. Memory is released. Ptr is invalid.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_freeMemory (
+ void * Ptr
+) SAL_THROW_EXTERN_C();
+
+
+/** Allocate and zero memory.
+
+ A call to this function will return NULL upon the requested
+ memory size being either zero or larger than currently allocatable.
+
+ @param Bytes [in] memory size.
+ @return pointer to allocated and zero'ed memory.
+ */
+SAL_DLLPUBLIC void * SAL_CALL rtl_allocateZeroMemory (
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Zero and free memory.
+ @param Ptr [in] pointer to previously allocated memory.
+ @param Bytes [in] memory size.
+ @return none. Memory is zero'ed and released. Ptr is invalid.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_freeZeroMemory (
+ void * Ptr,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Opaque rtl_arena_type.
+ */
+typedef struct rtl_arena_st rtl_arena_type;
+
+#define RTL_ARENA_NAME_LENGTH 31
+
+
+/** rtl_arena_create()
+ *
+ * @param pName [in] descriptive name; for debugging purposes.
+ * @param quantum [in] resource allocation unit / granularity; rounded up to next power of 2.
+ * @param quantum_cache_max [in] max resources to cache; rounded up to next multiple of quantum; usually 0.
+ * @param source_arena [in] passed as argument to source_alloc, source_free; usually NULL.
+ * @param source_alloc [in] function to allocate resources; usually rtl_arena_alloc.
+ * @param source_free [in] function to free resources; usually rtl_arena_free.
+ * @param nFlags [in] flags; usually 0.
+ *
+ * @return pointer to rtl_arena_type, or NULL upon failure.
+ *
+ * @see rtl_arena_destroy()
+ */
+SAL_DLLPUBLIC rtl_arena_type * SAL_CALL rtl_arena_create (
+ const char * pName,
+ sal_Size quantum,
+ sal_Size quantum_cache_max,
+ rtl_arena_type * source_arena,
+ void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *),
+ void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size),
+ int nFlags
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_arena_destroy()
+ *
+ * @param pArena [in] the arena to destroy.
+ * @return None
+ *
+ * @see rtl_arena_create()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_arena_destroy (
+ rtl_arena_type * pArena
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_arena_alloc()
+ *
+ * @param pArena [in] arena from which resource is allocated.
+ * @param pBytes [inout] size of resource to allocate.
+ *
+ * @return allocated resource, or NULL upon failure.
+ *
+ * @see rtl_arena_free()
+ */
+SAL_DLLPUBLIC void * SAL_CALL rtl_arena_alloc (
+ rtl_arena_type * pArena,
+ sal_Size * pBytes
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_arena_free()
+ *
+ * @param pArena [in] arena from which resource was allocated.
+ * @param pAddr [in] resource to free.
+ * @param nBytes [in] size of resource.
+ *
+ * @return None.
+ *
+ * @see rtl_arena_alloc()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_arena_free (
+ rtl_arena_type * pArena,
+ void * pAddr,
+ sal_Size nBytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Opaque rtl_cache_type.
+ */
+typedef struct rtl_cache_st rtl_cache_type;
+
+#define RTL_CACHE_NAME_LENGTH 31
+
+#define RTL_CACHE_FLAG_BULKDESTROY 1
+
+/** rtl_cache_create()
+ *
+ * @param pName [in] descriptive name; for debugging purposes.
+ * @param nObjSize [in] object size.
+ * @param nObjAlign [in] object alignment; usually 0 for suitable default.
+ * @param constructor [in] object constructor callback function; returning 1 for success or 0 for failure.
+ * @param destructor [in] object destructor callback function.
+ * @param reclaim [in] reclaim callback function.
+ * @param pUserArg [in] opaque argument passed to callback functions.
+ * @param pSource [in] opaque argument passed to callback functions.
+ * @param nFlags [in] flags.
+ *
+ * @return pointer to rtl_cache_type, or NULL upon failure.
+ *
+ * @see rtl_cache_destroy()
+ */
+SAL_DLLPUBLIC rtl_cache_type * SAL_CALL rtl_cache_create (
+ const char * pName,
+ sal_Size nObjSize,
+ sal_Size nObjAlign,
+ int (SAL_CALL * constructor)(void * pObj, void * pUserArg),
+ void (SAL_CALL * destructor) (void * pObj, void * pUserArg),
+ void (SAL_CALL * reclaim) (void * pUserArg),
+ void * pUserArg,
+ rtl_arena_type * pSource,
+ int nFlags
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_cache_destroy()
+ *
+ * @param pCache [in] the cache to destroy.
+ *
+ * @return None.
+ *
+ * @see rtl_cache_create()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_cache_destroy (
+ rtl_cache_type * pCache
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_cache_alloc()
+ *
+ * @param pCache [in] cache from which object is allocated.
+ *
+ * @return pointer to allocated object, or NULL upon failure.
+ */
+SAL_DLLPUBLIC void * SAL_CALL rtl_cache_alloc (
+ rtl_cache_type * pCache
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_cache_free()
+ *
+ * @param pCache [in] cache from which object was allocated.
+ * @param pObj [in] object to free.
+ *
+ * @return None.
+ *
+ * @see rtl_cache_alloc()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_cache_free (
+ rtl_cache_type * pCache,
+ void * pObj
+) SAL_THROW_EXTERN_C();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_RTL_ALLOC_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/allocator.hxx b/include/rtl/allocator.hxx
new file mode 100644
index 000000000000..05575c247fe9
--- /dev/null
+++ b/include/rtl/allocator.hxx
@@ -0,0 +1,175 @@
+/* -*- 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 INCLUDED_RTL_ALLOCATOR_HXX
+#define INCLUDED_RTL_ALLOCATOR_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+#include "rtl/alloc.h"
+#include <cstddef>
+
+/// @cond INTERNAL
+
+//######################################################
+// This is no general purpose STL allocator but one
+// necessary to use STL for some implementation but
+// avoid linking sal against the STLPort library!!!
+// For more information on when and how to define a
+// custom stl allocator have a look at Scott Meyers:
+// "Effective STL", Nicolai M. Josuttis:
+// "The C++ Standard Library - A Tutorial and Reference"
+// and at http://www.josuttis.com/cppcode/allocator.html
+
+namespace rtl {
+
+template<class T>
+class Allocator
+{
+public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef ::std::size_t size_type;
+ typedef ::std::ptrdiff_t difference_type;
+
+ //-----------------------------------------
+ template<class U>
+ struct rebind
+ {
+ typedef Allocator<U> other;
+ };
+
+ //-----------------------------------------
+ pointer address (reference value) const
+ {
+ return &value;
+ }
+
+ //-----------------------------------------
+ const_pointer address (const_reference value) const
+ {
+ return &value;
+ }
+
+ //-----------------------------------------
+ Allocator() SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ template<class U>
+ Allocator (SAL_UNUSED_PARAMETER const Allocator<U>&) SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ Allocator(const Allocator&) SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ ~Allocator() SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ size_type max_size() const SAL_THROW(())
+ {
+ return size_type(-1)/sizeof(T);
+ }
+
+ //-----------------------------------------
+ /* Normally the code for allocate should
+ throw a std::bad_alloc exception if the
+ requested memory could not be allocated:
+ (C++ standard 20.4.1.1):
+
+ pointer allocate (size_type n, const void* hint = 0)
+ {
+ pointer p = reinterpret_cast<pointer>(
+ rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
+
+ if (NULL == p)
+ throw ::std::bad_alloc();
+
+ return p;
+ }
+
+ but some compilers do not compile it if exceptions
+ are not enabled, e.g. GCC under Linux and it is
+ in general not desired to compile sal with exceptions
+ enabled. */
+ pointer allocate (size_type n, SAL_UNUSED_PARAMETER const void* = 0)
+ {
+ return reinterpret_cast<pointer>(
+ rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
+ }
+
+ //-----------------------------------------
+ void deallocate (pointer p, SAL_UNUSED_PARAMETER size_type /* n */)
+ {
+ rtl_freeMemory(p);
+ }
+
+ //-----------------------------------------
+#if HAVE_CXX11_PERFECT_FORWARDING
+ template< typename... Args >
+ void construct (pointer p, Args &&... value)
+ {
+ new ((void*)p)T(std::forward< Args >(value)...);
+ }
+#else
+ void construct (pointer p, const T& value)
+ {
+ new ((void*)p)T(value);
+ }
+#endif
+
+ //-----------------------------------------
+ void destroy (pointer p)
+ {
+ p->~T();
+ (void)p; //MSVC2005 annoyingly warns this is unused
+ }
+};
+
+//######################################################
+// Custom STL allocators must be stateless (see
+// references above) that's why the operators below
+// return always true or false
+
+template<class T, class U> inline bool operator ==(
+ SAL_UNUSED_PARAMETER const Allocator<T>&,
+ SAL_UNUSED_PARAMETER const Allocator<U>&) SAL_THROW(())
+{
+ return true;
+}
+
+template<class T, class U>
+inline bool operator!= (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
+{
+ return false;
+}
+
+} /* namespace rtl */
+
+/// @endcond
+
+#endif /* INCLUDED_RTL_ALLOCATOR_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/bootstrap.h b/include/rtl/bootstrap.h
new file mode 100644
index 000000000000..67fed2d92660
--- /dev/null
+++ b/include/rtl/bootstrap.h
@@ -0,0 +1,234 @@
+/* -*- 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 _RTL_BOOTSTRAP_H_
+#define _RTL_BOOTSTRAP_H_
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @file
+
+ The described concept provides a platform independent way to access
+ minimum bootstrap settings for every application by excplitly or
+ implicitly passing the values to the application.<p>
+
+ MULTI-LEVEL STRATEGY FOR RETRIEVAL OF BOOTSTRAP VALUES :<p>
+
+ The 1st level is tried first. On failure,
+ the next level is tried. Every query starts at the first level again, so
+ that one setting may be taken from the 3rd and one from the 1st level.<p>
+
+ 1st level: explicitly set variables via rtl_bootstrap_set()
+
+ 2nd level: command line arguments. A "-env:SETTINGNAME=value" is given on
+ command line. This allows to give an application a certain setting, even
+ if an ini-file exists (espicially useful for e.g. daemons that want to
+ start an executable with dynamical changing settings).<p>
+
+ 3rd level: environment variables. The application tries to get the
+ setting from the environment.<p>
+
+ 4th level: executable ini-file. Every application looks for an ini-file.
+ The filename defaults to /absoulte/path/to/executable[rc|.ini]
+ (without .bin or .exe suffix). The ini-filename can be
+ set by the special command line parameter
+ '-env:INIFILENAME=/absolute/path/to/inifile' at runtime or it may
+ be set at compiletime by an API-call.<p>
+
+ 5th level: URE_BOOTSTRAP ini-file. If the bootstrap variable URE_BOOTSTRAP
+ expands to the URL of an ini-file, that ini-file is searched.<p>
+
+ 6th level: default. An application can have some default settings decided
+ at compile time, which allow the application to run even with no
+ deployment settings. <p>
+
+ If neither of the above levels leads to an successful retrieval of the value
+ (no default possible), the application may fail to start.<p>
+
+ NAMING CONVENTIONS <p>
+
+ Naming conventions for names of bootstrap values :
+ Names may only include characters, that are allowed characters for
+ environment variables. This excludes '.', ' ', ';', ':' and any non-ascii
+ character. Names are case insensitive.<p>
+
+ An ini-file is only allowed to have one section, which must be named '[Bootstrap]'.
+ The section may be omitted.
+ The section name does not appear in the name of the corresponding
+ environment variable or commandline arg.
+ Values maybe arbitrary unicode strings, they must be encoded in UTF8.<p>
+
+ Example:<p>
+
+ in an ini-file:
+ <code>
+ [Sectionname]
+ Name=value
+ </code><p>
+
+ as commandline arg:
+ <code>-env:Name=value</code><p>
+
+ as environment
+ <code>
+ setenv Name value
+ set Name=value
+ </code><p>
+
+ SPECIAL VARIABLES:
+
+ <ul>
+ <li> INIFILENAME<br>
+ This variable allows to set the inifilename. This makes only sense, if the filename
+ is different than the executable file name. It must be given on command line. If it is
+ given the executable ini-file is ignored.
+ </li>
+ </ul>
+*/
+
+/** may be called by an application to set an ini-filename.
+
+ <p>
+ Must be called before rtl_bootstrap_get(). May not be called twice.
+ If it is never called, the filename is based on the name of the executable,
+ with the suffix ".ini" on Windows or "rc" on Unix.
+
+ @param pFileUri URL of the inifile with path but WITHOUT suffix (.ini or rc)
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_setIniFileName( rtl_uString *pFileUri )
+ SAL_THROW_EXTERN_C();
+
+/**
+ @param ppValue
+ out parameter. Contains always a valid rtl_uString pointer.
+ @param pName
+ The name of the bootstrap setting to be retrieved.
+ @param pDefault
+ maybe NULL. If once the default is
+ returned, successive calls always return this
+ default value, even when called with different
+ defaults.
+
+ @return <code>sal_True</code>, when a value could be retrieved successfully,
+ <code>sal_False</code>, when none of the 4 methods gave a value. ppValue
+ then contains ane empty string.
+ When a pDefault value is given, the function returns always
+ <code>sal_True</code>.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_bootstrap_get(
+ rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault )
+ SAL_THROW_EXTERN_C();
+
+/** Sets a bootstrap parameter.
+
+ @param pName
+ name of bootstrap parameter
+ @param pValue
+ value of bootstrap parameter
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_set(
+ rtl_uString * pName, rtl_uString * pValue )
+ SAL_THROW_EXTERN_C();
+
+
+typedef void * rtlBootstrapHandle;
+
+/**
+ Opens a bootstrap argument container.
+ @param pIniName [in] The name of the ini-file to use, if <code>NULL</code> defaults
+ to the excutables name
+ @return Handle for a boostrap argument container
+*/
+SAL_DLLPUBLIC rtlBootstrapHandle SAL_CALL rtl_bootstrap_args_open(rtl_uString * pIniName)
+ SAL_THROW_EXTERN_C();
+
+/**
+ Closes a boostrap agument container.
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_args_close(rtlBootstrapHandle handle)
+ SAL_THROW_EXTERN_C();
+
+/**
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+ @param pName [in] The name of the variable to be retrieved
+ @param ppValue [out] The result of the retrieval. *ppValue may be null in case of failure.
+ @param pDefault [in] The default value for the retrieval, may be <code>NULL</code>
+
+ @return The status of the retrieval, <code>sal_True</code> on success.
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_bootstrap_get_from_handle(
+ rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
+ SAL_THROW_EXTERN_C();
+
+
+/** Returns the name of the inifile associated with this handle.
+
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+ @param ppIniName [out] contains after the call the name of the ini-filename.
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_get_iniName_from_handle(
+ rtlBootstrapHandle handle, rtl_uString ** ppIniName)
+ SAL_THROW_EXTERN_C();
+
+/** Expands a macro using bootstrap variables.
+
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+ @param macro [inout] The macro to be expanded
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_expandMacros_from_handle(
+ rtlBootstrapHandle handle, rtl_uString ** macro )
+ SAL_THROW_EXTERN_C();
+/** Expands a macro using default bootstrap variables.
+
+ @param macro [inout] The macro to be expanded
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_expandMacros(
+ rtl_uString ** macro )
+ SAL_THROW_EXTERN_C();
+
+/** Escapes special characters ("$" and "\").
+
+ @param value
+ an arbitrary, non-NULL value
+
+ @param encoded
+ non-NULL out parameter, receiving the given value with all occurrences of
+ special characters ("$" and "\") escaped
+
+ @since UDK 3.2.9
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_bootstrap_encode(
+ rtl_uString const * value, rtl_uString ** encoded )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/bootstrap.hxx b/include/rtl/bootstrap.hxx
new file mode 100644
index 000000000000..057e60625021
--- /dev/null
+++ b/include/rtl/bootstrap.hxx
@@ -0,0 +1,226 @@
+/* -*- 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 _RTL_BOOTSTRAP_HXX_
+#define _RTL_BOOTSTRAP_HXX_
+#include <rtl/ustring.hxx>
+#include <rtl/bootstrap.h>
+
+namespace rtl
+{
+ class Bootstrap
+ {
+ void * _handle;
+
+ inline Bootstrap( Bootstrap const & ); // not impl
+ inline Bootstrap & operator = ( Bootstrap const & ); // not impl
+
+ public:
+ /**
+ * @see rtl_bootstrap_setIniFileName()
+ */
+ static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
+
+ /** Retrieves a bootstrap parameter
+ @param sName name of the bootstrap value. case insensitive.
+ @param outValue (out parameter). On success contains the value, otherwise
+ an empty string.
+ @return sal_False, if no value could be retrieved, otherwise sal_True
+ @see rtl_bootstrap_get()
+ */
+ static inline sal_Bool get(
+ const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue );
+
+ /** Retrieves a bootstrap parameter
+
+ @param sName name of the bootstrap value. case insensitive.
+ @param outValue (out parameter). Contains the value associated with sName.
+ @param aDefault if none of the other methods retrieved a value, outValue
+ is assigned to a Default.
+
+ @see rtl_bootstrap_get()
+ */
+ static inline void get(
+ const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue,
+ const ::rtl::OUString &aDefault );
+
+ /** Sets a bootstrap parameter.
+
+ @param name
+ name of bootstrap parameter
+ @param value
+ value of bootstrap parameter
+
+ @see rtl_bootstrap_set()
+ */
+ static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
+ SAL_THROW(());
+
+ /** default ctor.
+ */
+ inline Bootstrap();
+
+ /** Opens a bootstrap argment container
+ @see rtl_bootstrap_args_open()
+ */
+ inline Bootstrap(const OUString & iniName);
+
+ /** Closes a bootstrap argument container
+ @see rtl_bootstrap_args_close()
+ */
+ inline ~Bootstrap();
+
+ /** Retrieves a bootstrap argument.
+
+ It is first tried to retrieve the value via the global function
+ and second via the special bootstrap container.
+ @see rtl_bootstrap_get_from_handle()
+ */
+
+ inline sal_Bool getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue) const;
+
+ /** Retrieves a bootstrap argument.
+
+ It is first tried to retrieve the value via the global function
+ and second via the special bootstrap container.
+ @see rtl_bootstrap_get_from_handle()
+ */
+ inline void getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue,
+ const ::rtl::OUString &aDefault) const;
+
+ /** Retrieves the name of the underlying ini-file.
+ @see rtl_bootstrap_get_iniName_from_handle()
+ */
+ inline void getIniName(::rtl::OUString & iniName) const;
+
+ /** Expands a macro using bootstrap variables.
+
+ @param macro [inout] The macro to be expanded
+ */
+ inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(())
+ { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
+
+ /** Expands a macro using default bootstrap variables.
+
+ @param macro [inout] The macro to be expanded
+ */
+ static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(())
+ { rtl_bootstrap_expandMacros( &macro.pData ); }
+
+ /** Provides the bootstrap internal handle.
+
+ @return bootstrap handle
+ */
+ inline rtlBootstrapHandle getHandle() const SAL_THROW(())
+ { return _handle; }
+
+ /** Escapes special characters ("$" and "\").
+
+ @param value
+ an arbitrary value
+
+ @return
+ the given value, with all occurrences of special characters ("$" and
+ "\") escaped
+
+ @since UDK 3.2.9
+ */
+ static inline ::rtl::OUString encode( ::rtl::OUString const & value )
+ SAL_THROW(());
+ };
+
+ //----------------------------------------------------------------------------
+ // IMPLEMENTATION
+ //----------------------------------------------------------------------------
+ inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
+ {
+ rtl_bootstrap_setIniFileName( sFile.pData );
+ }
+
+ inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName,
+ ::rtl::OUString & outValue )
+ {
+ return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
+ }
+
+ inline void Bootstrap::get( const ::rtl::OUString &sName,
+ ::rtl::OUString & outValue,
+ const ::rtl::OUString & sDefault )
+ {
+ rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
+ }
+
+ inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
+ SAL_THROW(())
+ {
+ rtl_bootstrap_set( name.pData, value.pData );
+ }
+
+ inline Bootstrap::Bootstrap()
+ {
+ _handle = 0;
+ }
+
+ inline Bootstrap::Bootstrap(const OUString & iniName)
+ {
+ if(!iniName.isEmpty())
+ _handle = rtl_bootstrap_args_open(iniName.pData);
+
+ else
+ _handle = 0;
+ }
+
+ inline Bootstrap::~Bootstrap()
+ {
+ rtl_bootstrap_args_close(_handle);
+ }
+
+
+ inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue) const
+ {
+ return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
+ }
+
+ inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue,
+ const ::rtl::OUString &aDefault) const
+ {
+ rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
+ }
+
+ inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
+ {
+ rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
+ }
+
+ inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
+ SAL_THROW(())
+ {
+ ::rtl::OUString encoded;
+ rtl_bootstrap_encode(value.pData, &encoded.pData);
+ return encoded;
+ }
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/byteseq.h b/include/rtl/byteseq.h
new file mode 100644
index 000000000000..99107143b601
--- /dev/null
+++ b/include/rtl/byteseq.h
@@ -0,0 +1,317 @@
+/* -*- 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 _RTL_BYTESEQ_H_
+#define _RTL_BYTESEQ_H_
+
+#include "sal/config.h"
+
+#include "rtl/alloc.h"
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Assures that the reference count of the given byte sequence is one. Otherwise a new copy
+ of the sequence is created with a reference count of one.
+
+ @param ppSequence sequence
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_reference2One(
+ sal_Sequence ** ppSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Reallocates length of byte sequence.
+
+ @param ppSequence sequence
+ @param nSize new size of sequence
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_realloc(
+ sal_Sequence ** ppSequence, sal_Int32 nSize )
+ SAL_THROW_EXTERN_C();
+
+/** Acquires the byte sequence
+
+ @param pSequence sequence, that is to be acquired
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_acquire(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Releases the byte sequence. If the refcount drops to zero, the sequence is freed.
+
+ @param pSequence sequence, that is to be released; invalid after call
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_release(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a bytes sequence with length nLength. All bytes are set to zero.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence contains the newly constructed sequence
+ @param nLength length of new sequence
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_construct(
+ sal_Sequence **ppSequence , sal_Int32 nLength )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a bytes sequence with length nLength. The data is not initialized.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence contains the newly constructed sequence
+ @param nLength length of new sequence
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_constructNoDefault(
+ sal_Sequence **ppSequence , sal_Int32 nLength )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a byte sequence with length nLength and copies nLength bytes from pData.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence contains the newly constructed sequence
+ @param pData initial data
+ @param nLength length of new sequence
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_constructFromArray(
+ sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength )
+ SAL_THROW_EXTERN_C();
+
+/** Assigns the byte sequence pSequence to *ppSequence.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence references pSequence
+ @param pSequence the source sequence
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_assign(
+ sal_Sequence **ppSequence , sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Compares two byte sequences.
+
+ @return true, if the data within the sequences are identical; false otherwise
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_byte_sequence_equals(
+ sal_Sequence *pSequence1 , sal_Sequence *pSequence2 )
+ SAL_THROW_EXTERN_C();
+
+/** Returns the data array pointer of the sequence.
+
+ @return read-pointer to the data array of the sequence. If rtl_byte_sequence_reference2One()
+ has been called before, the pointer may be casted to a non const pointer and
+ the sequence may be modified
+*/
+SAL_DLLPUBLIC const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Returns the length of the sequence
+
+ @param pSequence sequence handle
+ @return length of the sequence
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_byte_sequence_getLength(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+namespace rtl
+{
+
+enum __ByteSequence_NoDefault
+{
+ /** This enum value can be used to create a bytesequence with uninitalized data
+ */
+ BYTESEQ_NODEFAULT = 0xcafe
+};
+
+enum __ByteSequence_NoAcquire
+{
+ /** This enum value can be used to create a bytesequence from a C-Handle without
+ acquiring the handle.
+ */
+ BYTESEQ_NOACQUIRE = 0xcafebabe
+};
+
+/** C++ class representing a SAL byte sequence.
+ C++ Sequences are reference counted and shared, so the sequence keeps a handle to its data.
+ To keep value semantics, copies are only generated if the sequence is to be modified
+ (new handle).
+*/
+class SAL_WARN_UNUSED ByteSequence
+{
+ /** sequence handle
+ */
+ sal_Sequence * _pSequence;
+
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Default constructor: Creates an empty sequence.
+ */
+ inline ByteSequence() SAL_THROW(());
+ /** Copy constructor: Creates a copy of given sequence.
+
+ @param rSeq another byte sequence
+ */
+ inline ByteSequence( const ByteSequence & rSeq ) SAL_THROW(());
+ /** Copy constructor Creates a copy from the C-Handle.
+
+ @param pSequence another byte sequence handle
+ */
+ inline ByteSequence( sal_Sequence *pSequence ) SAL_THROW(());
+ /** Constructor: Creates a copy of given data bytes.
+
+ @param pElements an array of bytes
+ @param len number of bytes
+ */
+ inline ByteSequence( const sal_Int8 * pElements, sal_Int32 len );
+ /** Constructor: Creates sequence of given length and initializes all bytes to 0.
+
+ @param len initial sequence length
+ */
+ inline ByteSequence( sal_Int32 len );
+ /** Constructor: Creates sequence of given length and does NOT initialize data.
+ Use this ctor for performance optimization only.
+
+ @param len initial sequence length
+ @param nodefault dummy parameter forcing explicit BYTESEQ_NODEFAULT
+ */
+ inline ByteSequence( sal_Int32 len , enum __ByteSequence_NoDefault nodefault );
+ /** Constructor:
+ Creates a sequence from a C-Handle without acquiring the handle, thus taking
+ over owenership. Eitherway the handle is release by the destructor.
+ This ctor is useful, when working with a c-interface (it safes a pair of
+ acquire and release call and is thus a performance optimization only).
+
+ @param pSequence sequence handle to be taken over
+ @param noacquire dummy parameter forcing explicit BYTESEQ_NOACQUIRE
+ */
+ inline ByteSequence( sal_Sequence *pSequence , enum __ByteSequence_NoAcquire noacquire ) SAL_THROW(());
+ /** Destructor: Releases sequence handle. Last handle will free memory.
+ */
+ inline ~ByteSequence() SAL_THROW(());
+
+ /** Assignment operator: Acquires given sequence handle and releases a previously set handle.
+
+ @param rSeq another byte sequence
+ @return this sequence
+ */
+ inline ByteSequence & SAL_CALL operator = ( const ByteSequence & rSeq ) SAL_THROW(());
+
+ /** Gets the length of sequence.
+
+ @return length of sequence
+ */
+ inline sal_Int32 SAL_CALL getLength() const SAL_THROW(())
+ { return _pSequence->nElements; }
+
+ /** Gets a pointer to byte array for READING. If the sequence has a length of 0, then the
+ returned pointer is undefined.
+
+ @return pointer to byte array
+ */
+ inline const sal_Int8 * SAL_CALL getConstArray() const SAL_THROW(())
+ { return (const sal_Int8 *)_pSequence->elements; }
+ /** Gets a pointer to elements array for READING AND WRITING. In general if the sequence
+ has a handle acquired by other sequences (reference count > 1), then a new sequence is
+ created copying all bytes to keep value semantics!
+ If the sequence has a length of 0, then the returned pointer is undefined.
+
+ @return pointer to elements array
+ */
+ inline sal_Int8 * SAL_CALL getArray();
+
+ /** Non-const index operator:
+ Obtains a reference to byte indexed at given position.
+ In general if the sequence has a handle acquired by other
+ sequences (reference count > 1), then a new sequence is created
+ copying all bytes to keep value semantics!
+
+ @attention
+ The implementation does NOT check for array bounds!
+
+ @param nIndex index
+ @return non-const C++ reference to element at index nIndex
+ */
+ inline sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex );
+
+ /** Const index operator: Obtains a reference to byte indexed at given position.
+ The implementation does NOT check for array bounds!
+
+ @param nIndex index
+ @return const C++ reference to byte at element of indenx nIndex
+ */
+ inline const sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex ) const SAL_THROW(())
+ { return getConstArray()[ nIndex ]; }
+
+ /** Equality operator: Compares two sequences.
+
+ @param rSeq another byte sequence (right side)
+ @return true if both sequences are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const ByteSequence & rSeq ) const SAL_THROW(());
+ /** Unequality operator: Compares two sequences.
+
+ @param rSeq another byte sequence (right side)
+ @return false if both sequences are equal, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const ByteSequence & rSeq ) const SAL_THROW(());
+
+ /** Reallocates sequence to new length. If the sequence has a handle acquired by other sequences
+ (reference count > 1), then the remaining elements are copied to a new sequence handle to
+ keep value semantics!
+
+ @param nSize new size of sequence
+ */
+ inline void SAL_CALL realloc( sal_Int32 nSize );
+
+ /** Returns the UNnacquired C handle of the sequence
+
+ @return UNacquired handle of the sequence
+ */
+ inline sal_Sequence * SAL_CALL getHandle() const SAL_THROW(())
+ { return _pSequence; }
+ /** Returns the UNnacquired C handle of the sequence (for compatibility reasons)
+
+ @return UNacquired handle of the sequence
+ */
+ inline sal_Sequence * SAL_CALL get() const SAL_THROW(())
+ { return _pSequence; }
+};
+
+}
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/byteseq.hxx b/include/rtl/byteseq.hxx
new file mode 100644
index 000000000000..800447395178
--- /dev/null
+++ b/include/rtl/byteseq.hxx
@@ -0,0 +1,136 @@
+/* -*- 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 _RTL_BYTESEQ_HXX_
+#define _RTL_BYTESEQ_HXX_
+
+#include <osl/interlck.h>
+#include <rtl/byteseq.h>
+#include <rtl/alloc.h>
+
+#if ! defined EXCEPTIONS_OFF
+#include <new>
+#endif
+
+
+namespace rtl
+{
+
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence() SAL_THROW(())
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_construct( &_pSequence, 0 );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
+ : _pSequence( pSequence )
+{
+ ::rtl_byte_sequence_acquire( pSequence );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
+ : _pSequence( pSequence )
+{
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Int32 len )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_construct( &_pSequence, len );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::~ByteSequence() SAL_THROW(())
+{
+ ::rtl_byte_sequence_release( _pSequence );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
+{
+ ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
+{
+ return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
+}
+//__________________________________________________________________________________________________
+inline sal_Int8 * ByteSequence::getArray()
+{
+ ::rtl_byte_sequence_reference2One( &_pSequence );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+ return (sal_Int8 *)_pSequence->elements;
+}
+//__________________________________________________________________________________________________
+inline void ByteSequence::realloc( sal_Int32 nSize )
+{
+ ::rtl_byte_sequence_realloc( &_pSequence, nSize );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
+{
+ return getArray()[ nIndex ];
+}
+//__________________________________________________________________________________________________
+inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
+{
+ return (! operator == ( rSeq ));
+}
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx
new file mode 100644
index 000000000000..0ba86d6c065b
--- /dev/null
+++ b/include/rtl/character.hxx
@@ -0,0 +1,144 @@
+/* -*- 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 INCLUDED_RTL_CHARACTER_HXX
+#define INCLUDED_RTL_CHARACTER_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+namespace rtl
+{
+/** Check for ASCII character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a ASCII character (0x00--0x7F).
+
+ @since LibreOffice 4.1
+ */
+inline bool isAscii(sal_uInt32 nUtf32)
+{
+ return nUtf32 <= 0x7F;
+}
+
+/** Check for ASCII lower case character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a US-ASCII lower case alphabetic character
+ (ASCII 'a'--'z').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiLowerCase(sal_uInt32 nUtf32)
+{
+ return nUtf32 >= 'a' && nUtf32 <= 'z';
+}
+
+/** Check for US-ASCII upper case character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a US-ASCII upper case alphabetic character
+ (US-ASCII 'A'--'Z').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiUpperCase(sal_uInt32 nUtf32)
+{
+ return nUtf32 >= 'A' && nUtf32 <= 'Z';
+}
+
+/** Check for ASCII alphanumeric character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nUtf32 is a US-ASCII alphanumeric character
+ (ASCII '0'--'9', 'A'--'Z' or 'a'--'z').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiAlpha(sal_uInt32 nUtf32)
+{
+ return isAsciiLowerCase(nUtf32) || isAsciiUpperCase(nUtf32);
+}
+
+/** Check for ASCII digit character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a ASCII (decimal) digit character
+ (ASCII '0'--'9').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiDigit(sal_uInt32 nUtf32)
+{
+ return nUtf32 >= '0' && nUtf32 <= '9';
+}
+
+/** Check for US-ASCII alphanumeric character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a US-ASCII alphanumeric character (US-ASCII
+ '0'--'9', 'A'--'Z' or 'a'--'z').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiAlphanumeric(sal_uInt32 nUtf32)
+{
+ return isAsciiDigit(nUtf32) || isAsciiAlpha(nUtf32);
+}
+
+/** Check for US-ASCII canonic hexadecimal digit character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a US-ASCII canonic (i.e., upper case)
+ hexadecimal digit character (US-ASCII '0'--'9' or 'A'--'F').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiCanonicHexDigit(sal_uInt32 nUtf32)
+{
+ return isAsciiDigit(nUtf32) || (nUtf32 >= 'A' && nUtf32 <= 'F');
+}
+
+/** Check for US-ASCII hexadecimal digit character.
+
+ @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return True if nChar is a US-ASCII hexadecimal digit character (US-
+ ASCII '0'--'9', 'A'--'F', 'a'--'f').
+
+ @since LibreOffice 4.1
+ */
+inline bool isAsciiHexDigit(sal_uInt32 nUtf32)
+{
+ return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f');
+}
+
+}//rtl namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/cipher.h b/include/rtl/cipher.h
new file mode 100644
index 000000000000..a116e57ba071
--- /dev/null
+++ b/include/rtl/cipher.h
@@ -0,0 +1,317 @@
+/* -*- 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 _RTL_CIPHER_H_
+#define _RTL_CIPHER_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtlCipher interface.
+ *
+ *======================================================================*/
+/** Cipher Handle opaque type.
+ */
+typedef void* rtlCipher;
+
+
+/** Cipher Algorithm enumeration.
+ @see rtl_cipher_create()
+ */
+enum __rtl_CipherAlgorithm
+{
+ rtl_Cipher_AlgorithmBF,
+ rtl_Cipher_AlgorithmARCFOUR,
+ rtl_Cipher_AlgorithmInvalid,
+ rtl_Cipher_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Cipher Algorithm type.
+ */
+typedef enum __rtl_CipherAlgorithm rtlCipherAlgorithm;
+
+
+/** Cipher Mode enumeration.
+ @see rtl_cipher_create()
+ */
+enum __rtl_CipherMode
+{
+ rtl_Cipher_ModeECB,
+ rtl_Cipher_ModeCBC,
+ rtl_Cipher_ModeStream,
+ rtl_Cipher_ModeInvalid,
+ rtl_Cipher_Mode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Cipher Mode type.
+ */
+typedef enum __rtl_CipherMode rtlCipherMode;
+
+
+/** Cipher Direction enumeration.
+ @see rtl_cipher_init()
+ */
+enum __rtl_CipherDirection
+{
+ rtl_Cipher_DirectionBoth,
+ rtl_Cipher_DirectionDecode,
+ rtl_Cipher_DirectionEncode,
+ rtl_Cipher_DirectionInvalid,
+ rtl_Cipher_Direction_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Cipher Direction type.
+ */
+typedef enum __rtl_CipherDirection rtlCipherDirection;
+
+
+/** Error Code enumeration.
+ */
+enum __rtl_CipherError
+{
+ rtl_Cipher_E_None,
+ rtl_Cipher_E_Argument,
+ rtl_Cipher_E_Algorithm,
+ rtl_Cipher_E_Direction,
+ rtl_Cipher_E_Mode,
+ rtl_Cipher_E_BufferSize,
+ rtl_Cipher_E_Memory,
+ rtl_Cipher_E_Unknown,
+ rtl_Cipher_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Error Code type.
+ */
+typedef enum __rtl_CipherError rtlCipherError;
+
+
+/** Create a cipher handle for the given algorithm and mode.
+ @see rtlCipherAlgorithm
+ @see rtlCipherMode
+
+ @param Algorithm [in] cipher algorithm.
+ @param Mode [in] cipher mode.
+ @return Cipher handle, or 0 upon failure.
+ */
+SAL_DLLPUBLIC rtlCipher SAL_CALL rtl_cipher_create (
+ rtlCipherAlgorithm Algorithm,
+ rtlCipherMode Mode
+) SAL_THROW_EXTERN_C();
+
+
+/** Inititialize a cipher for the given direction.
+ @see rtlCipherDirection
+
+ @param Cipher [in] cipher handle.
+ @param Direction [in] cipher direction.
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length in bytes.
+ @param pArgData [in] initialization vector buffer.
+ @param nArgLen [in] initialization vector length in bytes.
+ @return rtl_Cipher_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_init (
+ rtlCipher Cipher,
+ rtlCipherDirection Direction,
+ const sal_uInt8 *pKeyData, sal_Size nKeyLen,
+ const sal_uInt8 *pArgData, sal_Size nArgLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Encode a buffer under a given cipher algorithm.
+ @pre Initialized for a compatible cipher direction.
+ @see rtl_cipher_init()
+
+ @param Cipher [in] cipher handle.
+ @param pData [in] plaintext buffer.
+ @param nDatLen [in] plaintext length in bytes.
+ @param pBuffer [out] ciphertext buffer.
+ @param nBufLen [in] ciphertext length in bytes.
+ @return rtl_Cipher_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_encode (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Decode a buffer under a given cipher algorithm.
+ @pre Initialized for a compatible cipher direction.
+ @see rtl_cipher_init()
+
+ @param Cipher [in] cipher handle.
+ @param pData [in] ciphertext buffer.
+ @param nDatLen [in] ciphertext length in bytes.
+ @param pBuffer [out] plaintext buffer.
+ @param nBufLen [in] plaintext length in bytes.
+ @return rtl_Cipher_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_decode (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a cipher handle.
+ @param Cipher [in] cipher handle to be destroyed.
+ @return None. Cipher handle destroyed and invalid.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_cipher_destroy (
+ rtlCipher Cipher
+) SAL_THROW_EXTERN_C();
+
+
+/*========================================================================
+ *
+ * rtl_cipherBF (Blowfish) interface.
+ *
+ *======================================================================*/
+/** Create a Blowfish cipher handle for the given mode.
+
+ The Blowfish block cipher algorithm is specified in
+ Bruce Schneier: Applied Cryptography, 2nd edition, ch. 14.3
+
+ @see rtl_cipher_create()
+ */
+SAL_DLLPUBLIC rtlCipher SAL_CALL rtl_cipher_createBF (
+ rtlCipherMode Mode
+) SAL_THROW_EXTERN_C();
+
+
+/** Inititialize a Blowfish cipher for the given direction.
+ @see rtl_cipher_init()
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_initBF (
+ rtlCipher Cipher,
+ rtlCipherDirection Direction,
+ const sal_uInt8 *pKeyData, sal_Size nKeyLen,
+ const sal_uInt8 *pArgData, sal_Size nArgLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Encode a buffer under the Blowfish cipher algorithm.
+ @see rtl_cipher_encode()
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_encodeBF (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Decode a buffer under the Blowfish cipher algorithm.
+ @see rtl_cipher_decode()
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_decodeBF (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a Blowfish cipher handle.
+ @see rtl_cipher_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_cipher_destroyBF (
+ rtlCipher Cipher
+) SAL_THROW_EXTERN_C();
+
+
+/*========================================================================
+ *
+ * rtl_cipherARCFOUR (RC4) interface.
+ *
+ *======================================================================*/
+/** Create a RC4 cipher handle for the given mode.
+
+ The RC4 symmetric stream cipher algorithm is specified in
+ Bruce Schneier: Applied Cryptography, 2nd edition, ch. 17.1
+
+ @see rtl_cipher_create()
+
+ @param Mode [in] cipher mode. Must be rtl_Cipher_ModeStream.
+ @return Cipher handle, or 0 upon failure.
+ */
+SAL_DLLPUBLIC rtlCipher SAL_CALL rtl_cipher_createARCFOUR (
+ rtlCipherMode Mode
+) SAL_THROW_EXTERN_C();
+
+
+/** Inititialize a RC4 cipher for the given direction.
+ @see rtl_cipher_init()
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_initARCFOUR (
+ rtlCipher Cipher,
+ rtlCipherDirection Direction,
+ const sal_uInt8 *pKeyData, sal_Size nKeyLen,
+ const sal_uInt8 *pArgData, sal_Size nArgLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Encode a buffer under the RC4 cipher algorithm.
+ @see rtl_cipher_encode()
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Decode a buffer under the RC4 cipher algorithm.
+ @see rtl_cipher_decode()
+ */
+SAL_DLLPUBLIC rtlCipherError SAL_CALL rtl_cipher_decodeARCFOUR (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a RC4 cipher handle.
+ @see rtl_cipher_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_cipher_destroyARCFOUR (
+ rtlCipher Cipher
+) SAL_THROW_EXTERN_C();
+
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_RTL_CIPHER_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/crc.h b/include/rtl/crc.h
new file mode 100644
index 000000000000..7fad87ef4f37
--- /dev/null
+++ b/include/rtl/crc.h
@@ -0,0 +1,63 @@
+/* -*- 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 _RTL_CRC_H_
+#define _RTL_CRC_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtl_crc32 interface.
+ *
+ *======================================================================*/
+/** Evaluate CRC32 over given data.
+
+ This function evaluates the CRC polynomial 0xEDB88320.
+
+ @param Crc [in] CRC32 over previous data or zero.
+ @param Data [in] data buffer.
+ @param DatLen [in] data buffer length.
+ @return new CRC32 value.
+ */
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_crc32 (
+ sal_uInt32 Crc,
+ const void *Data, sal_uInt32 DatLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_CRC_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/digest.h b/include/rtl/digest.h
new file mode 100644
index 000000000000..cc49838821f7
--- /dev/null
+++ b/include/rtl/digest.h
@@ -0,0 +1,643 @@
+/* -*- 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 _RTL_DIGEST_H_
+#define _RTL_DIGEST_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtlDigest.
+ *
+ *======================================================================*/
+/** Digest Handle opaque type.
+ */
+typedef void* rtlDigest;
+
+
+/** Digest Algorithm enumeration.
+ @see rtl_digest_create()
+ */
+enum __rtl_DigestAlgorithm
+{
+ rtl_Digest_AlgorithmMD2,
+ rtl_Digest_AlgorithmMD5,
+ rtl_Digest_AlgorithmSHA,
+ rtl_Digest_AlgorithmSHA1,
+
+ rtl_Digest_AlgorithmHMAC_MD5,
+ rtl_Digest_AlgorithmHMAC_SHA1,
+
+ rtl_Digest_AlgorithmInvalid,
+ rtl_Digest_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Digest Algorithm type.
+ */
+typedef enum __rtl_DigestAlgorithm rtlDigestAlgorithm;
+
+
+/** Error Code enumeration.
+ */
+enum __rtl_DigestError
+{
+ rtl_Digest_E_None,
+ rtl_Digest_E_Argument,
+ rtl_Digest_E_Algorithm,
+ rtl_Digest_E_BufferSize,
+ rtl_Digest_E_Memory,
+ rtl_Digest_E_Unknown,
+ rtl_Digest_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Error Code type.
+ */
+typedef enum __rtl_DigestError rtlDigestError;
+
+
+/** Create a digest handle for the given algorithm.
+ @see rtlDigestAlgorithm
+
+ @param Algorithm [in] digest algorithm.
+ @return Digest handle, or 0 upon failure.
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_create (
+ rtlDigestAlgorithm Algorithm
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a digest handle.
+ @post Digest handle destroyed and invalid.
+ @param Digest [in] digest handle to be destroyed.
+ @return None.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroy (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Query the algorithm of a given digest.
+ @param Digest [in] digest handle.
+ @return digest algorithm, or rtl_Digest_AlgorithmInvalid upon failure.
+ */
+SAL_DLLPUBLIC rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Query the length of a given digest.
+ @param Digest [in] digest handle.
+ @return digest length, or 0 upon failure.
+ */
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_digest_queryLength (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Initialize a digest with given data.
+ @param Digest [in] digest handle.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_init (
+ rtlDigest Digest,
+ const sal_uInt8 *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a digest with given data.
+ @param Digest [in] digest handle.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_update (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a digest and retrieve the digest value.
+ @pre Digest value length must not be less than digest length.
+ @post Digest initialized to accept another update sequence.
+ @see rtl_digest_queryLength()
+ @see rtl_digest_update()
+
+ @param Digest [in] digest handle.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_get (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_MD2 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_MD2 16
+
+/** Create a MD2 digest handle.
+
+ The MD2 digest algorithm is specified in
+ RFC 1319 (Informational)
+ The MD2 Message-Digest Algorithm
+
+ @see rtl_digest_create()
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createMD2 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a MD2 digest handle.
+ @see rtl_digest_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyMD2 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a MD2 digest with given data.
+ @see rtl_digest_update()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateMD2 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a MD2 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getMD2 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a MD2 digest value from given data.
+
+ This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateMD2()
+ @see rtl_digest_getMD2()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_MD2 (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_MD5 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_MD5 16
+
+/** Create a MD5 digest handle.
+
+ The MD5 digest algorithm is specified in
+ RFC 1321 (Informational)
+ The MD5 Message-Digest Algorithm
+
+ @see rtl_digest_create()
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createMD5 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a MD5 digest handle.
+ @see rtl_digest_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyMD5 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a MD5 digest with given data.
+ @see rtl_digest_update()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateMD5 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a MD5 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getMD5 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Retrieve the raw (not finalized) MD5 digest value.
+
+ This function is a non-standard replacement for
+ rtl_digest_getMD5() and must be used with caution.
+
+ @post Digest initialized to accept another update sequence.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_rawMD5 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a MD5 digest value from given data.
+
+ This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateMD5()
+ @see rtl_digest_getMD5()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_MD5 (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_SHA interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_SHA 20
+
+/** Create a SHA digest handle.
+
+ The SHA digest algorithm is specified in
+ FIPS PUB 180 (Superseded by FIPS PUB 180-1)
+ Secure Hash Standard
+
+ @see rtl_digest_create()
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a SHA digest handle.
+ @see rtl_digest_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a SHA digest with given data.
+ @see rtl_digest_update()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a SHA digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a SHA digest value from given data.
+
+ This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateSHA()
+ @see rtl_digest_getSHA()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_SHA1 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_SHA1 20
+
+/** Create a SHA1 digest handle.
+
+ The SHA1 digest algorithm is specified in
+ FIPS PUB 180-1 (Supersedes FIPS PUB 180)
+ Secure Hash Standard
+
+ @see rtl_digest_create()
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA1 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a SHA1 digest handle.
+ @see rtl_digest_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA1 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a SHA1 digest with given data.
+ @see rtl_digest_update()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA1 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a SHA1 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA1 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a SHA1 digest value from given data.
+
+ This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateSHA1()
+ @see rtl_digest_getSHA1()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA1 (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_HMAC_MD5 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_HMAC_MD5 RTL_DIGEST_LENGTH_MD5
+
+/** Create a HMAC_MD5 digest handle.
+
+ The HMAC_MD5 digest algorithm is specified in
+
+ RFC 2104 (Informational)
+ HMAC: Keyed-Hashing for Message Authentication
+
+ @see rtl_digest_create()
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_MD5 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a HMAC_MD5 digest handle.
+ @see rtl_digest_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyHMAC_MD5 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Initialize a HMAC_MD5 digest.
+ @see rtl_digest_init()
+
+ @param Digest [in] digest handle.
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 (
+ rtlDigest Digest,
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a HMAC_MD5 digest with given data.
+ @see rtl_digest_update()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a HMAC_MD5 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a HMAC_MD5 digest value from given data.
+
+ This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_initHMAC_MD5()
+ @see rtl_digest_updateHMAC_MD5()
+ @see rtl_digest_getHMAC_MD5()
+
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 (
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_HMAC_SHA1 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_HMAC_SHA1 RTL_DIGEST_LENGTH_SHA1
+
+/** Create a HMAC_SHA1 digest handle.
+
+ The HMAC_SHA1 digest algorithm is specified in
+ RFC 2104 (Informational)
+ HMAC: Keyed-Hashing for Message Authentication
+ RFC 2898 (Informational)
+ PKCS #5: Password-Based Cryptography Specification Version 2.0
+
+ @see rtl_digest_create()
+ */
+SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a HMAC_SHA1 digest handle.
+ @see rtl_digest_destroy()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyHMAC_SHA1 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Initialize a HMAC_SHA1 digest.
+ @see rtl_digest_init()
+
+ @param Digest [in] digest handle.
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 (
+ rtlDigest Digest,
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a HMAC_SHA1 digest with given data.
+ @see rtl_digest_update()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a HMAC_SHA1 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a HMAC_SHA1 digest value from given data.
+
+ This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_initHMAC_SHA1()
+ @see rtl_digest_updateHMAC_SHA1()
+ @see rtl_digest_getHMAC_SHA1()
+
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 (
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_PBKDF2 interface.
+ *
+ *======================================================================*/
+/** Password-Based Key Derivation Function.
+
+ The PBKDF2 key derivation function is specified in
+ RFC 2898 (Informational)
+ PKCS #5: Password-Based Cryptography Specification Version 2.0
+
+ @param pKeyData [out] derived key
+ @param nKeyLen [in] derived key length
+ @param pPassData [in] password
+ @param nPassLen [in] password length
+ @param pSaltData [in] salt
+ @param nSaltLen [in] salt length
+ @param nCount [in] iteration count
+
+ @return rtl_Digest_E_None upon success.
+*/
+SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_PBKDF2 (
+ sal_uInt8 *pKeyData , sal_uInt32 nKeyLen,
+ const sal_uInt8 *pPassData, sal_uInt32 nPassLen,
+ const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen,
+ sal_uInt32 nCount
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_DIGEST_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/instance.hxx b/include/rtl/instance.hxx
new file mode 100644
index 000000000000..1efda808abec
--- /dev/null
+++ b/include/rtl/instance.hxx
@@ -0,0 +1,637 @@
+/* -*- 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 INCLUDED_RTL_INSTANCE_HXX
+#define INCLUDED_RTL_INSTANCE_HXX
+
+#include "sal/config.h"
+
+#include "osl/doublecheckedlocking.h"
+#include "osl/getglobalmutex.hxx"
+
+namespace {
+
+/** A non-broken version of the double-checked locking pattern.
+
+ See
+ <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>
+ for a description of double-checked locking, why it is broken, and how it
+ can be fixed. Always use this template instead of spelling out the
+ double-checked locking pattern explicitly, and only in those rare cases
+ where that is not possible and you have to spell it out explicitly, at
+ least call OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER() at the right
+ places. That way, all platform-dependent code to make double-checked
+ locking work can be kept in one place.
+
+ Usage scenarios:
+
+ 1 Static instance (most common case)
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if (!pInstance)
+ {
+ static T aInstance;
+ pInstance = &aInstance;
+ }
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+ #include "osl/getglobalmutex.hxx"
+
+ namespace {
+ struct Init
+ {
+ T * operator()()
+ {
+ static T aInstance;
+ return &aInstance;
+ }
+ };
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, Init, ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(
+ Init(), ::osl::GetGlobalMutex());
+ }
+
+ 2 Dynamic instance
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if (!pInstance)
+ pInstance = new T;
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+ #include "osl/getglobalmutex.hxx"
+
+ namespace {
+ struct Init
+ {
+ T * operator()()
+ {
+ return new T;
+ }
+ };
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, Init, ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(
+ Init(), ::osl::GetGlobalMutex());
+ }
+
+ 3 Other guard/mutex
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ SomeGuard aGuard(pSomeMutex);
+ if (!pInstance)
+ {
+ static T aInstance;
+ pInstance = &aInstance;
+ }
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+
+ namespace {
+ struct InitInstance
+ {
+ T * operator()()
+ {
+ static T aInstance;
+ return &aInstance;
+ }
+ };
+
+ struct InitGuard
+ {
+ SomeMutex * operator()()
+ {
+ return pSomeMutex;
+ }
+ };
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, InitInstance,
+ SomeGuard, InitGuard >::create(
+ InitInstance(), InitMutex());
+ }
+
+ 4 Calculate extra data
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ Data aData(...);
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if (!pInstance)
+ {
+ static T aInstance(aData);
+ pInstance = &aInstance;
+ }
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+ #include "osl/getglobalmutex.hxx"
+
+ namespace {
+ struct InitInstance
+ {
+ T * operator()()
+ {
+ static T aInstance;
+ return &aInstance;
+ }
+ }
+
+ struct InitData
+ {
+ Data const & operator()()
+ {
+ return ...;
+ }
+ }
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, InitInstance,
+ ::osl::Mutex, ::osl::GetGlobalMutex,
+ Data, InitData >::create(
+ InitInstance(), ::osl::GetGlobalMutex(), InitData());
+ }
+
+ Some comments:
+
+ For any instantiation of rtl_Instance, at most one call to a create method
+ may occur in the program code: Each occurrence of a create method within
+ the program code is supposed to return a fresh object instance on the
+ first call, and that same object instance on subsequent calls; but
+ independent occurrences of create methods are supposed to return
+ independent object instances. Since there is a one-to-one correspondence
+ between object instances and instantiations of rtl_Instance, the
+ requirement should be clear. One measure to enforce the requirement is
+ that rtl_Instance lives in an unnamed namespace, so that instantiations of
+ rtl_Instance in different translation units will definitely be different
+ instantiations. A drawback of that measure is that the name of the class
+ needs a funny "hand coded" prefix "rtl_" instead of a proper namespace
+ prefix like "::rtl::".
+
+ A known problem with this template is when two occurrences of calls to
+ create methods with identical template arguments appear in one translation
+ unit. Those two places will share a single object instance. This can be
+ avoided by using different Init structs (see the above code samples) in
+ the two places.
+
+ There is no need to make m_pInstance volatile, in order to avoid usage of
+ stale copies of m_pInstance: At the first check, a thread will see that
+ m_pInstance contains either 0 or a valid pointer. If it contains a valid
+ pointer, it cannot be stale, and that pointer is used. If it contains 0,
+ acquiring the mutex will ensure that the second check sees a non-stale
+ value in all cases.
+
+ On some compilers, the create methods would not be inlined if they
+ contained any static variables, so m_pInstance is made a class member
+ instead (and the create methods are inlined). But on MSC, the definition
+ of the class member m_pInstance would cause compilation to fail with an
+ internal compiler error. Since MSC is able to inline methods containing
+ static variables, m_pInstance is moved into the methods there. Note that
+ this only works well because for any instantiation of rtl_Instance at most
+ one call to a create method should be present, anyway.
+ */
+template< typename Inst, typename InstCtor,
+ typename Guard, typename GuardCtor,
+ typename Data = int, typename DataCtor = int >
+class rtl_Instance
+{
+public:
+ static inline Inst * create(InstCtor aInstCtor, GuardCtor aGuardCtor)
+ {
+#if defined _MSC_VER
+ static Inst * m_pInstance = 0;
+#endif // _MSC_VER
+ Inst * p = m_pInstance;
+ if (!p)
+ {
+ Guard aGuard(aGuardCtor());
+ p = m_pInstance;
+ if (!p)
+ {
+ p = aInstCtor();
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ m_pInstance = p;
+ }
+ }
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+ return p;
+ }
+
+ static inline Inst * create(InstCtor aInstCtor, GuardCtor aGuardCtor,
+ DataCtor aDataCtor)
+ {
+#if defined _MSC_VER
+ static Inst * m_pInstance = 0;
+#endif // _MSC_VER
+ Inst * p = m_pInstance;
+ if (!p)
+ {
+ Data aData(aDataCtor());
+ Guard aGuard(aGuardCtor());
+ p = m_pInstance;
+ if (!p)
+ {
+ p = aInstCtor(aData);
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ m_pInstance = p;
+ }
+ }
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+ return p;
+ }
+
+ static inline Inst * create(InstCtor aInstCtor, GuardCtor aGuardCtor,
+ const Data &rData)
+ {
+#if defined _MSC_VER
+ static Inst * m_pInstance = 0;
+#endif // _MSC_VER
+ Inst * p = m_pInstance;
+ if (!p)
+ {
+ Guard aGuard(aGuardCtor());
+ p = m_pInstance;
+ if (!p)
+ {
+ p = aInstCtor(rData);
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ m_pInstance = p;
+ }
+ }
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+ return p;
+ }
+
+private:
+#if !defined _MSC_VER
+ static Inst * m_pInstance;
+#endif // _MSC_VER
+};
+
+#if !defined _MSC_VER
+template< typename Inst, typename InstCtor,
+ typename Guard, typename GuardCtor,
+ typename Data, typename DataCtor >
+Inst *
+rtl_Instance< Inst, InstCtor, Guard, GuardCtor, Data, DataCtor >::m_pInstance
+= 0;
+#endif // _MSC_VER
+
+}
+
+namespace rtl {
+
+/** Helper base class for a late-initialized (default-constructed)
+ static variable, implementing the double-checked locking pattern correctly.
+
+ @derive
+ Derive from this class (common practice), e.g.
+ <pre>
+ struct MyStatic : public rtl::Static<MyType, MyStatic> {};
+ ...
+ MyType & rStatic = MyStatic::get();
+ ...
+ </pre>
+
+ @tparam T
+ variable's type
+ @tparam Unique
+ Implementation trick to make the inner static holder unique,
+ using the outer class
+ (the one that derives from this base class)
+*/
+#if HAVE_THREADSAFE_STATICS
+template<typename T, typename Unique>
+class Static {
+public:
+ /** Gets the static. Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ static variable
+ */
+ static T & get() {
+ static T instance;
+ return instance;
+ }
+};
+#else
+template<typename T, typename Unique>
+class Static {
+public:
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get() {
+ return *rtl_Instance<
+ T, StaticInstance,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex >::create(
+ StaticInstance(), ::osl::GetGlobalMutex() );
+ }
+private:
+ struct StaticInstance {
+ T * operator () () {
+ static T instance;
+ return &instance;
+ }
+ };
+};
+#endif
+
+/** Helper base class for a late-initialized (default-constructed)
+ static variable, implementing the double-checked locking pattern correctly.
+
+ @derive
+ Derive from this class (common practice), e.g.
+ <pre>
+ struct MyStatic : public rtl::Static<MyType, MyStatic> {};
+ ...
+ MyType & rStatic = MyStatic::get();
+ ...
+ </pre>
+
+ @tparam T
+ variable's type
+ @tparam Unique
+ Implementation trick to make the inner static holder unique,
+ using the outer class
+ (the one that derives from this base class)
+*/
+#if HAVE_THREADSAFE_STATICS
+template<typename T, typename Data, typename Unique>
+class StaticWithArg {
+public:
+ /** Gets the static. Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ static variable
+ */
+ static T & get(const Data& rData) {
+ static T instance(rData);
+ return instance;
+ }
+
+ /** Gets the static. Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ static variable
+ */
+ static T & get(Data& rData) {
+ static T instance(rData);
+ return instance;
+ }
+};
+#else
+template<typename T, typename Data, typename Unique>
+class StaticWithArg {
+public:
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get(const Data& rData) {
+ return *rtl_Instance<
+ T, StaticInstanceWithArg,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex,
+ Data >::create( StaticInstanceWithArg(),
+ ::osl::GetGlobalMutex(),
+ rData );
+ }
+
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get(Data& rData) {
+ return *rtl_Instance<
+ T, StaticInstanceWithArg,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex,
+ Data >::create( StaticInstanceWithArg(),
+ ::osl::GetGlobalMutex(),
+ rData );
+ }
+private:
+ struct StaticInstanceWithArg {
+ T * operator () (const Data& rData) {
+ static T instance(rData);
+ return &instance;
+ }
+
+ T * operator () (Data& rData) {
+ static T instance(rData);
+ return &instance;
+ }
+ };
+};
+#endif
+
+/** Helper class for a late-initialized static aggregate, e.g. an array,
+ implementing the double-checked locking pattern correctly.
+
+ @tparam T
+ aggregate's element type
+ @tparam InitAggregate
+ initializer functor class
+*/
+#if HAVE_THREADSAFE_STATICS
+template<typename T, typename InitAggregate>
+class StaticAggregate {
+public:
+ /** Gets the static aggregate, late-initializing.
+ Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ aggregate
+ */
+ static T * get() {
+ static T *instance = InitAggregate()();
+ return instance;
+ }
+};
+#else
+template<typename T, typename InitAggregate>
+class StaticAggregate {
+public:
+ /** Gets the static aggregate, late-initializing.
+ Mutual exclusion is performed using the osl global mutex.
+
+ @return
+ aggregate
+ */
+ static T * get() {
+ return rtl_Instance<
+ T, InitAggregate,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex >::create(
+ InitAggregate(), ::osl::GetGlobalMutex() );
+ }
+};
+#endif
+/** Helper base class for a late-initialized static variable,
+ implementing the double-checked locking pattern correctly.
+
+ @derive
+ Derive from this class (common practice),
+ providing an initializer functor class, e.g.
+ <pre>
+ struct MyStatic : public rtl::StaticWithInit<MyType, MyStatic> {
+ MyType operator () () {
+ ...
+ return MyType( ... );
+ }
+ };
+ ...
+ MyType & rStatic = MyStatic::get();
+ ...
+ </pre>
+
+ @tparam T
+ variable's type
+ @tparam InitData
+ initializer functor class
+ @tparam Unique
+ Implementation trick to make the inner static holder unique,
+ using the outer class
+ (the one that derives from this base class).
+ Default is InitData (common practice).
+ @tparam Data
+ Initializer functor's return type.
+ Default is T (common practice).
+*/
+#if HAVE_THREADSAFE_STATICS
+template<typename T, typename InitData,
+ typename Unique = InitData, typename Data = T>
+class StaticWithInit {
+public:
+ /** Gets the static. Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ static variable
+ */
+ static T & get() {
+ static T instance = InitData()();
+ return instance;
+ }
+};
+#else
+template<typename T, typename InitData,
+ typename Unique = InitData, typename Data = T>
+class StaticWithInit {
+public:
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get() {
+ return *rtl_Instance<
+ T, StaticInstanceWithInit,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex,
+ Data, InitData >::create( StaticInstanceWithInit(),
+ ::osl::GetGlobalMutex(),
+ InitData() );
+ }
+private:
+ struct StaticInstanceWithInit {
+ T * operator () ( Data d ) {
+ static T instance(d);
+ return &instance;
+ }
+ };
+};
+#endif
+} // namespace rtl
+
+#endif // INCLUDED_RTL_INSTANCE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/locale.h b/include/rtl/locale.h
new file mode 100644
index 000000000000..197a9152284d
--- /dev/null
+++ b/include/rtl/locale.h
@@ -0,0 +1,136 @@
+/* -*- 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 _RTL_LOCALE_H_
+#define _RTL_LOCALE_H_
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+/**
+ The implementation structur of a locale. Do not create this structure
+ direct. Only use the functions rtl_locale_register and
+ rtl_locale_setDefault. The strings Language, Country and Variant
+ are constants, so it is not necessary to acquire and release them.
+ */
+typedef struct _rtl_Locale
+{
+ /**
+ Lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ */
+ rtl_uString * Language;
+ /**
+ uppercase two-letter ISO-3166 code.
+ */
+ rtl_uString * Country;
+ /**
+ Lowercase vendor and browser specific code.
+ */
+ rtl_uString * Variant;
+ /**
+ The merged hash value of the Language, Country and Variant strings.
+ */
+ sal_Int32 HashCode;
+} rtl_Locale;
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+/**
+ Register a locale from language, country and variant.
+ @param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ @param country uppercase two-letter ISO-3166 code. May be null.
+ @param variant vendor and browser specific code. May be null.
+ */
+SAL_DLLPUBLIC rtl_Locale * SAL_CALL rtl_locale_register(
+ const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
+
+/**
+ Common method of getting the current default Locale.
+ Used for the presentation: menus, dialogs, etc.
+ Generally set once when your applet or application is initialized,
+ then never reset. (If you do reset the default locale, you
+ probably want to reload your GUI, so that the change is reflected
+ in your interface.)
+ <p>More advanced programs will allow users to use different locales
+ for different fields, e.g. in a spreadsheet.
+ <BR>Note that the initial setting will match the host system.
+ */
+SAL_DLLPUBLIC rtl_Locale * SAL_CALL rtl_locale_getDefault();
+
+/**
+ Sets the default.
+ Normally set once at the beginning of applet or application,
+ then never reset. <code>setDefault</code> does not reset the host locale.
+ @param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ @param country uppercase two-letter ISO-3166 code.
+ @param variant vendor and browser specific code. See class description.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_locale_setDefault(
+ const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
+
+/**
+ Getter for programmatic name of field,
+ a lowercased two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ @see getDisplayLanguage
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This );
+
+/**
+ Getter for programmatic name of field,
+ an uppercased two-letter ISO-3166 code.
+ @see getDisplayCountry
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This );
+
+/**
+ Getter for programmatic name of field.
+ @see getDisplayVariant
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This );
+
+/**
+ Returns the hash code of the locale This.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This );
+
+/**
+ Returns true if the locals are equal, otherwis false.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_LOCALE_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/logfile.h b/include/rtl/logfile.h
new file mode 100644
index 000000000000..c14c5c118abd
--- /dev/null
+++ b/include/rtl/logfile.h
@@ -0,0 +1,131 @@
+/* -*- 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 _RTL_LOGFILE_H_
+#define _RTL_LOGFILE_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** This function allows to log arbitrary messages even in a product-environment.
+
+ The logfile is created on first access and closed, when the sal-library gets unloaded.
+ The file is line buffered. A log file is not created if no log messages are
+ written.
+
+ The first time, rtl_logfile_trace is called, it checks for the bootstrap variable
+ RTL_LOGFILE. If the variable is not empty, it creates a file with the name
+ $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
+
+ @param pszFormat A format string with fprintf-syntax
+ @param ... An arbitrary number of arguments for fprintf, matching the
+ format string.
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... );
+
+/** Like rtl_logfile_trace, but prefixing every log entry with the current time
+ and thread ID.
+
+ @param format
+ a format string with fprintf-like syntax
+
+ @param ...
+ an arbitrary number of arguments for fprintf, matching the given format
+ string
+
+ @since UDK 3.2.0
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_logfile_longTrace(char const * format, ...);
+
+/** Return if a log file is written.
+
+ @return true if a log file is written
+
+ @since UDK 3.2.11
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_logfile_hasLogFile( void );
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef TIMELOG
+#define RTL_LOGFILE_TRACE( string ) \
+ rtl_logfile_longTrace( "| : %s\n", string )
+#define RTL_LOGFILE_TRACE1( frmt, arg1 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+
+#define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
+ rtl_logfile_trace( "\n" )
+
+// Now the macros with project and author arguments. The strings
+// are formatted in a way, so that the log file can be parsed by
+// post processing scripts.
+#define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) \
+ rtl_logfile_longTrace( "| %s (%s) : %s\n", \
+ project,\
+ author,\
+ string )
+#define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
+ rtl_logfile_longTrace( "| %s (%s) : ", \
+ project,\
+ author );\
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+
+#define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \
+ rtl_logfile_longTrace( "| %s (%s) : ", \
+ project,\
+ author ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \
+ rtl_logfile_longTrace( "| %s (%s) : ", \
+ project,\
+ author ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
+ rtl_logfile_trace( "\n" )
+#else
+#define RTL_LOGFILE_TRACE( string ) ((void)0)
+#define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0)
+#define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0)
+#define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0)
+
+#define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) ((void)0)
+#define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0)
+#define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0)
+#define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0)
+#endif // TIMELOG
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/logfile.hxx b/include/rtl/logfile.hxx
new file mode 100644
index 000000000000..d911f5664f92
--- /dev/null
+++ b/include/rtl/logfile.hxx
@@ -0,0 +1,205 @@
+/* -*- 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 _RTL_LOGFILE_HXX_
+#define _RTL_LOGFILE_HXX_
+
+#include <rtl/logfile.h>
+#include <rtl/string.hxx>
+#include <sal/detail/log.h>
+
+namespace rtl
+{
+/**
+@brief The intended use for class Logfile is to write time stamp information
+ for profiling purposes.
+
+ Profiling output should only be generated for a special product version of OpenOffice
+ which is compiled with a defined preprocessor symbol 'TIMELOG'.
+ Therefore we have provided a set of macros that uses the class Logfile only if
+ this symbol is defined. If the macros are not sufficient, i.e. you need more
+ then three arguments for a printf style message, then you have to insert an
+ \#ifdef TIMELOG/\#endif brace yourself.
+
+ Additionally the environment variable RTL_LOGFILE has to be defined in order to generate
+ logging information. If the variable is not empty, it creates a file with the name
+ $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
+ It can be used as a run time switch for enabling or disabling the logging.
+ Note that this variable is evaluated only once at the first attempt to write a message.
+
+ The class LogFile collects runtime data within its constructor and destructor. It can be
+ used for timing whole functions.
+ If you want to write timing data without context you can use the RTL_LOGFILE_TRACE-macros
+ which are defined inside <rtl/logfile.h>.
+
+ The class LogFile should not be used directly, instead use the RTL_LOGFILE_CONTEXT/
+ RTL_LOGFILE_TRACE-macros.
+
+ Macro usage:
+ ------------
+ RTL_LOGFILE_CONTEXT( instance, name );
+ This macro creates an instance of class LogFile with the name "instance" and writes the current time,
+ thread id and "name" to the log file.
+
+ Example: RTL_LOGFILE_CONTEXT( aLog, "Timing for foo-method" );
+
+ RTL_LOGFILE_CONTEXT_TRACE( instance, message );
+ RTL_LOGFILE_CONTEXT_TRACEn( instance, frmt, arg1, .., arg3 );
+ These macros can be used to log information in a "instance" context. The "instance" object
+ is used to log message information. All macros with "frmt" uses printf notation to log timing infos.
+
+ Example: RTL_LOGFILE_CONTEXT_TRACE( aLog, "Now we call an expensive function" );
+ RTL_LOGFIlE_CONTEXT_TRACE1( aLog, "Config entries read: %u", (unsigned short)i );
+
+ RTL_LOGFILE_TRACE( string );
+ RTL_LOGFILE_TRACEn( frmt, arg1, .., arg3 );
+ These macros can be used to log information outside a context. The macro directly calls
+ rtl_logfile_trace to write the info to the log file. All macros with "frmt" uses printf
+ notation to log timing infos.
+
+ Example: RTL_LOGFILE_TRACE( "Timing for loading a file" );
+ RTL_LOGFILE_TRACE1( aLog, "Timing for loading file: %s", aFileName );
+
+ The lines written to the log file consist of the following space separated elements:
+ 1. The time relative to the start of the global timer in milliseconds. The times is
+ started typically for the first logged line.
+ 2. Thread id. It's absolut value is probably of less interest than providing a way to
+ distinguish different threads.
+ 3. a. An opening or closing curly brace indicating the start or end of a scope.
+ 4a. Function name or general scope identifier.
+ b. A vertical line indicating an arbitrary message.
+ 4b optional function name or general scope identifier.
+ 5b A colon followed by a space and a free form message terminated by a newline.
+
+ There is a second version of creating a context. RTL_LOGFILE_CONTEXT_AUTHOR takes
+ two more arguments, the name of the project and the author's sign who is responsible
+ for the code in which the macro is used.
+*/
+ class Logfile
+ {
+ public:
+ inline Logfile( const sal_Char *name );
+ /** Create a log file context
+
+ Create a log file context where the message field consists of a project
+ name, the author's shortcut, and the actual message. These three strings
+ are written in a format that is understood by script that later parses the
+ log file and that so can extract the three strings.
+ @param project Short name of the project, like sw for writer or sc for calc.
+ @param author The sign of the person responsible for the code.
+ @param name The actual message, typically a method name.
+ */
+ inline Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name );
+ inline ~Logfile();
+ inline const sal_Char *getName();
+ private:
+ ::rtl::OString m_sName;
+ };
+
+ inline Logfile::Logfile( const sal_Char *name )
+ : m_sName( name )
+ {
+ rtl_logfile_longTrace( "{ %s\n", name );
+ }
+
+ inline Logfile::Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name )
+ : m_sName( project)
+ {
+ m_sName += " (";
+ m_sName += author;
+ m_sName += ") ";
+ m_sName += name;
+ rtl_logfile_longTrace( "{ %s\n", m_sName.pData->buffer );
+ }
+
+ inline Logfile::~Logfile()
+ {
+ rtl_logfile_longTrace( "} %s\n", m_sName.pData->buffer );
+ }
+
+ inline const sal_Char * Logfile::getName()
+ {
+ return m_sName.getStr();
+ }
+}
+
+#ifdef TIMELOG
+#define RTL_LOGFILE_CONTEXT( instance, name ) ::rtl::Logfile instance( name )
+#define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ::rtl::Logfile instance(project, author, name )
+#define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) \
+ rtl_logfile_longTrace( "| %s : %s\n", \
+ instance.getName(), \
+ message )
+#define RTL_LOGFILE_CONTEXT_TRACE1( instance , frmt, arg1 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt , arg1 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_CONTEXT_TRACE2( instance , frmt, arg1 , arg2 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt , arg1 , arg2 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_CONTEXT_TRACE3( instance , frmt, arg1 , arg2 , arg3 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt , arg1 , arg2 , arg3 ); \
+ rtl_logfile_trace( "\n" )
+
+#else
+
+#define RTL_LOGFILE_FORWARD_VIA_SAL_LOG(area, message) \
+ SAL_DETAIL_INFO_IF_FORMAT(SAL_DETAIL_ENABLE_LOG_INFO, area, "%s", message)
+
+#define RTL_LOGFILE_CONTEXT( instance, name ) RTL_LOGFILE_FORWARD_VIA_SAL_LOG("logfile", name)
+#define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) RTL_LOGFILE_FORWARD_VIA_SAL_LOG(project ".logfile", name)
+#define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) RTL_LOGFILE_FORWARD_VIA_SAL_LOG("logfile", message)
+#define RTL_LOGFILE_CONTEXT_TRACE1( instance, frmt, arg1 ) ((void)arg1,(void)0)
+#define RTL_LOGFILE_CONTEXT_TRACE2( instance, frmt, arg1, arg2 ) ((void)arg1,(void)arg2,(void)0)
+#define RTL_LOGFILE_CONTEXT_TRACE3( instance, frmt, arg1, arg2 , arg3 ) ((void)arg1,(void)arg2,(void)arg3,(void)0)
+#endif
+
+// Normal RTL_LOGFILE_* entries will not make it into release versions,
+// TIMELOG is disabled a few versions prior relase build.
+//
+// We need some logs also in these builds, eg. for making performance regression tests.
+//
+// POLICY: Don't use RTL_LOGFILE_PRODUCT_* for your personal logging information.
+// Be aware that these logs make it into the product shipped to customers.
+// If you have good reasons for doing this, please contact product management.
+
+#define RTL_LOGFILE_PRODUCT_TRACE( string ) \
+ rtl_logfile_longTrace( "| : %s\n", string )
+#define RTL_LOGFILE_PRODUCT_TRACE1( frmt, arg1 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \
+ ::rtl::Logfile instance( name )
+#define RTL_LOGFILE_PRODUCT_CONTEXT_TRACE1( instance, frmt, arg1 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_HASLOGFILE() \
+ rtl_logfile_hasLogFile()
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/malformeduriexception.hxx b/include/rtl/malformeduriexception.hxx
new file mode 100644
index 000000000000..24635ed26c2e
--- /dev/null
+++ b/include/rtl/malformeduriexception.hxx
@@ -0,0 +1,68 @@
+/* -*- 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 INCLUDED_RTL_MALFORMEDURIEXCEPTION_HXX
+#define INCLUDED_RTL_MALFORMEDURIEXCEPTION_HXX
+
+#include "rtl/ustring.hxx"
+
+namespace rtl {
+
+/** An exception indicating a malformed URI.
+
+ <P>Used when parsing (part of) a URI fails for syntactical reasons.</P>
+ */
+class SAL_EXCEPTION_DLLPUBLIC_EXPORT MalformedUriException
+{
+public:
+ /** Create a MalformedUriException.
+
+ @param rMessage
+ A message containing any details about the exception.
+ */
+ inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException(
+ rtl::OUString const & rMessage): m_aMessage(rMessage) {}
+
+ inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException(
+ MalformedUriException const & other): m_aMessage(other.m_aMessage) {}
+
+ inline SAL_EXCEPTION_DLLPRIVATE ~MalformedUriException() {}
+
+ inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException operator =(
+ MalformedUriException const & rOther)
+ { m_aMessage = rOther.m_aMessage; return *this; }
+
+ /** Get the message.
+
+ @return
+ A reference to the message. The reference is valid for the lifetime of
+ this MalformedUriException.
+ */
+ inline SAL_EXCEPTION_DLLPRIVATE rtl::OUString const & getMessage() const
+ { return m_aMessage; }
+
+private:
+ rtl::OUString m_aMessage;
+};
+
+}
+
+#endif // INCLUDED_RTL_MALFORMEDURIEXCEPTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/math.h b/include/rtl/math.h
new file mode 100644
index 000000000000..ebe0a84003bd
--- /dev/null
+++ b/include/rtl/math.h
@@ -0,0 +1,475 @@
+/* -*- 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 INCLUDED_RTL_MATH_H
+#define INCLUDED_RTL_MATH_H
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** Formatting modes for rtl_math_doubleToString and rtl_math_doubleToUString
+ and rtl_math_doubleToUStringBuffer.
+ */
+enum rtl_math_StringFormat
+{
+ /** Like sprintf() %E.
+ */
+ rtl_math_StringFormat_E,
+
+ /** Like sprintf() %f.
+ */
+ rtl_math_StringFormat_F,
+
+ /** Like sprintf() %G, 'F' or 'E' format is used depending on which one is
+ more compact.
+ */
+ rtl_math_StringFormat_G,
+
+ /** Automatic, 'F' or 'E' format is used depending on the numeric value to
+ be formatted.
+ */
+ rtl_math_StringFormat_Automatic,
+
+ /** @cond INTERNAL */
+ rtl_math_StringFormat_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+ /** @endcond */
+};
+
+/** Status for rtl_math_stringToDouble and rtl_math_uStringToDouble.
+ */
+enum rtl_math_ConversionStatus
+{
+ /** Conversion was successful.
+ */
+ rtl_math_ConversionStatus_Ok,
+
+ /** Conversion caused overflow or underflow.
+ */
+ rtl_math_ConversionStatus_OutOfRange,
+
+ /** @cond INTERNAL */
+ rtl_math_ConversionStatus_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+ /** @endcond */
+};
+
+/** Rounding modes for rtl_math_round.
+ */
+enum rtl_math_RoundingMode
+{
+ /** Like HalfUp, but corrects roundoff errors, preferred.
+ */
+ rtl_math_RoundingMode_Corrected,
+
+ /** Floor of absolute value, signed return (commercial).
+ */
+ rtl_math_RoundingMode_Down,
+
+ /** Ceil of absolute value, signed return (commercial).
+ */
+ rtl_math_RoundingMode_Up,
+
+ /** Floor of signed value.
+ */
+ rtl_math_RoundingMode_Floor,
+
+ /** Ceil of signed value.
+ */
+ rtl_math_RoundingMode_Ceiling,
+
+ /** Frac <= 0.5 ? floor of abs : ceil of abs, signed return.
+ */
+ rtl_math_RoundingMode_HalfDown,
+
+ /** Frac < 0.5 ? floor of abs : ceil of abs, signed return (mathematical).
+ */
+ rtl_math_RoundingMode_HalfUp,
+
+ /** IEEE rounding mode (statistical).
+ */
+ rtl_math_RoundingMode_HalfEven,
+
+ /** @cond INTERNAL */
+ rtl_math_RoundingMode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+ /** @endcond */
+};
+
+/** Special decimal places constants for rtl_math_doubleToString and
+ rtl_math_doubleToUString and rtl_math_doubleToUStringBuffer.
+ */
+enum rtl_math_DecimalPlaces
+{
+ /** Value to be used with rtl_math_StringFormat_Automatic.
+ */
+ rtl_math_DecimalPlaces_Max = 0x7ffffff,
+
+ /** Value to be used with rtl_math_StringFormat_G.
+ In fact the same value as rtl_math_DecimalPlaces_Max, just an alias for
+ better understanding.
+ */
+ rtl_math_DecimalPlaces_DefaultSignificance = rtl_math_DecimalPlaces_Max
+};
+
+
+/** Conversions analogous to sprintf() using internal rounding.
+
+ +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are
+ converted to "NaN".
+
+ @param pResult
+ Returns the resulting byte string. Must itself not be null, and must point
+ to either null or a valid string.
+
+ @param pResultCapacity
+ If null, pResult is considered to point to immutable strings, and a new
+ string will be allocated in pResult.
+ If non-null, it points to the current capacity of pResult, which is
+ considered to point to a string buffer (pResult must not itself be null in
+ this case, and must point to a string that has room for the given capacity).
+ The string representation of the given double value is inserted into pResult
+ at position nResultOffset. If pResult's current capacity is too small, a
+ new string buffer will be allocated in pResult as necessary, and
+ pResultCapacity will contain the new capacity on return.
+
+ @param nResultOffset
+ If pResult is used as a string buffer (i.e., pResultCapacity is non-null),
+ nResultOffset specifies the insertion offset within the buffer. Ignored
+ otherwise.
+
+ @param fValue
+ The value to convert.
+
+ @param eFormat
+ The format to use, one of rtl_math_StringFormat.
+
+ @param nDecPlaces
+ The number of decimals to be generated. Effectively fValue is rounded at
+ this position, specifying nDecPlaces <= 0 accordingly rounds the value
+ before the decimal point and fills with zeros.
+ If eFormat == rtl_math_StringFormat_Automatic and nDecPlaces ==
+ rtl_math_DecimalPlaces_Max, the highest number of significant decimals
+ possible is generated.
+ If eFormat == rtl_math_StringFormat_G, nDecPlaces specifies the number of
+ significant digits instead. If nDecPlaces ==
+ rtl_math_DecimalPlaces_DefaultSignificance, the default number (currently 6
+ as implemented by most libraries) of significant digits is generated.
+ According to the ANSI C90 standard the E style will be used only if the
+ exponent resulting from the conversion is less than -4 or greater than or
+ equal to the precision. However, as opposed to the ANSI standard, trailing
+ zeros are not necessarily removed from the fractional portion of the result
+ unless bEraseTrailingDecZeros == true was specified.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param pGroups
+ Either null (no grouping is used), or a null-terminated list of group
+ lengths. Each group length must be strictly positive. If the number of
+ digits in a conversion exceeds the specified range, the last (highest) group
+ length is repeated as needed. Values are applied from right to left, for a
+ grouping of 1,00,00,000 you'd have to specify pGroups={3,2,0}.
+
+ @param cGroupSeparator
+ The group separator. Ignored if pGroups is null.
+
+ @param bEraseTrailingDecZeros
+ Trailing zeros in decimal places are erased.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult,
+ sal_Int32 * pResultCapacity,
+ sal_Int32 nResultOffset, double fValue,
+ enum rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Char cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Char cGroupSeparator,
+ sal_Bool bEraseTrailingDecZeros)
+ SAL_THROW_EXTERN_C();
+
+/** Conversions analogous to sprintf() using internal rounding.
+
+ +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are
+ converted to "NaN".
+
+ @param pResult
+ Returns the resulting Unicode string. Must itself not be null, and must
+ point to either null or a valid string.
+
+ @param pResultCapacity
+ If null, pResult is considered to point to immutable strings, and a new
+ string will be allocated in pResult.
+ If non-null, it points to the current capacity of pResult, which is
+ considered to point to a string buffer (pResult must not itself be null in
+ this case, and must point to a string that has room for the given capacity).
+ The string representation of the given double value is inserted into pResult
+ at position nResultOffset. If pResult's current capacity is too small, a
+ new string buffer will be allocated in pResult as necessary, and
+ pResultCapacity will contain the new capacity on return.
+
+ @param nResultOffset
+ If pResult is used as a string buffer (i.e., pResultCapacity is non-null),
+ nResultOffset specifies the insertion offset within the buffer. Ignored
+ otherwise.
+
+ @param fValue
+ The value to convert.
+
+ @param eFormat
+ The format to use, one of rtl_math_StringFormat.
+
+ @param nDecPlaces
+ The number of decimals to be generated. Effectively fValue is rounded at
+ this position, specifying nDecPlaces <= 0 accordingly rounds the value
+ before the decimal point and fills with zeros.
+ If eFormat == rtl_math_StringFormat_Automatic and nDecPlaces ==
+ rtl_math_DecimalPlaces_Max, the highest number of significant decimals
+ possible is generated.
+ If eFormat == rtl_math_StringFormat_G, nDecPlaces specifies the number of
+ significant digits instead. If nDecPlaces ==
+ rtl_math_DecimalPlaces_DefaultSignificance, the default number (currently 6
+ as implemented by most libraries) of significant digits is generated.
+ According to the ANSI C90 standard the E style will be used only if the
+ exponent resulting from the conversion is less than -4 or greater than or
+ equal to the precision. However, as opposed to the ANSI standard, trailing
+ zeros are not necessarily removed from the fractional portion of the result
+ unless bEraseTrailingDecZeros == true was specified.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param pGroups
+ Either null (no grouping is used), or a null-terminated list of group
+ lengths. Each group length must be strictly positive. If the number of
+ digits in a conversion exceeds the specified range, the last (highest) group
+ length is repeated as needed. Values are applied from right to left, for a
+ grouping of 1,00,00,000 you'd have to specify pGroups={3,2,0}.
+
+ @param cGroupSeparator
+ The group separator. Ignored if pGroups is null.
+
+ @param bEraseTrailingDecZeros
+ Trailing zeros in decimal places are erased.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult,
+ sal_Int32 * pResultCapacity,
+ sal_Int32 nResultOffset, double fValue,
+ enum rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Unicode cGroupSeparator,
+ sal_Bool bEraseTrailingDecZeros)
+ SAL_THROW_EXTERN_C();
+
+/** Conversion analogous to strtod(), convert a string representing a
+ decimal number into a double value.
+
+ Leading tabs (0x09) and spaces (0x20) are eaten. Overflow returns
+ +/-HUGE_VAL, underflow 0. In both cases pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange, otherwise to
+ rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are
+ recognized as +/-HUGE_VAL, pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are
+ recognized and the value is set to +/-NAN, pStatus is set to
+ rtl_math_ConversionStatus_Ok.
+
+ @param pBegin
+ Points to the start of the byte string to convert. Must not be null.
+
+ @param pEnd
+ Points one past the end of the byte string to convert. The condition
+ pEnd >= pBegin must hold.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param cGroupSeparator
+ The group (aka thousands) separator.
+
+ @param pStatus
+ If non-null, returns the status of the conversion.
+
+ @param pParsedEnd
+ If non-null, returns one past the position of the last character parsed
+ away. Thus if [pBegin..pEnd) only contains the numerical string to be
+ parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is
+ found, *pParsedEnd == pBegin on return, even if there was leading
+ whitespace.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_stringToDouble(
+ sal_Char const * pBegin, sal_Char const * pEnd, sal_Char cDecSeparator,
+ sal_Char cGroupSeparator, enum rtl_math_ConversionStatus * pStatus,
+ sal_Char const ** pParsedEnd) SAL_THROW_EXTERN_C();
+
+/** Conversion analogous to strtod(), convert a string representing a
+ decimal number into a double value.
+
+ Leading tabs (U+0009) and spaces (U+0020) are eaten. Overflow returns
+ +/-HUGE_VAL, underflow 0. In both cases pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange, otherwise to
+ rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are
+ recognized as +/-HUGE_VAL, pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are
+ recognized and the value is set to +/-NAN, pStatus is set to
+ rtl_math_ConversionStatus_Ok.
+
+ @param pBegin
+ Points to the start of the Unicode string to convert. Must not be null.
+
+ @param pEnd
+ Points one past the end of the Unicode string to convert. The condition
+ pEnd >= pBegin must hold.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param cGroupSeparator
+ The group (aka thousands) separator.
+
+ @param pStatus
+ If non-null, returns the status of the conversion.
+
+ @param pParsedEnd
+ If non-null, returns one past the position of the last character parsed
+ away. Thus if [pBegin..pEnd) only contains the numerical string to be
+ parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is
+ found, *pParsedEnd == pBegin on return, even if there was leading
+ whitespace.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_uStringToDouble(
+ sal_Unicode const * pBegin, sal_Unicode const * pEnd,
+ sal_Unicode cDecSeparator, sal_Unicode cGroupSeparator,
+ enum rtl_math_ConversionStatus * pStatus, sal_Unicode const ** pParsedEnd)
+ SAL_THROW_EXTERN_C();
+
+/** Rounds a double value.
+
+ @param fValue
+ Specifies the value to be rounded.
+
+ @param nDecPlaces
+ Specifies the decimal place where rounding occurs. Must be in the range
+ -20 to +20, inclusive. Negative if rounding occurs before the decimal
+ point.
+
+ @param eMode
+ Specifies the rounding mode.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
+ enum rtl_math_RoundingMode eMode)
+ SAL_THROW_EXTERN_C();
+
+/** Scales fVal to a power of 10 without calling pow() or div() for nExp values
+ between -16 and +16, providing a faster method.
+
+ @param fValue
+ The value to be raised.
+
+ @param nExp
+ The exponent.
+
+ @return
+ fVal * pow(10.0, nExp)
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
+
+/** Rounds value to 15 significant decimal digits.
+
+ @param fValue
+ The value to be rounded.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns more accurate e^x-1 for x near 0 than calculating directly.
+
+ expm1 is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term e^x-1.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_expm1(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns more accurate log(1+x) for x near 0 than calculating directly.
+
+ log1p is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term log(1+x).
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns more accurate atanh(x) for x near 0 than calculating
+ 0.5*log((1+x)/(1-x)).
+
+ atanh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term atanh(x).
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the Errorfunction erf.
+
+ erf is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term erf(x).
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the complement Errorfunction erfc.
+
+ erfc is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term erfc(x).
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the inverse hyperbolic sine.
+
+ asinh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term asinh(x).
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the inverse hyperbolic cosine.
+
+ acosh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term acosh(x).
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C();
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_RTL_MATH_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx
new file mode 100644
index 000000000000..d0055c0c66e9
--- /dev/null
+++ b/include/rtl/math.hxx
@@ -0,0 +1,439 @@
+/* -*- 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 INCLUDED_RTL_MATH_HXX
+#define INCLUDED_RTL_MATH_HXX
+
+#include "rtl/math.h"
+#include "rtl/string.hxx"
+#include "rtl/ustring.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "sal/mathconf.h"
+#include "sal/types.h"
+
+#include <math.h>
+
+namespace rtl {
+
+namespace math {
+
+/** A wrapper around rtl_math_doubleToString.
+ */
+inline rtl::OString doubleToString(double fValue, rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Char cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Char cGroupSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OString aResult;
+ rtl_math_doubleToString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, pGroups, cGroupSeparator,
+ bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToString, with no grouping.
+ */
+inline rtl::OString doubleToString(double fValue, rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Char cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OString aResult;
+ rtl_math_doubleToString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, 0, 0, bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToUString.
+ */
+inline rtl::OUString doubleToUString(double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Unicode cGroupSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OUString aResult;
+ rtl_math_doubleToUString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, pGroups, cGroupSeparator,
+ bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToUString, with no grouping.
+ */
+inline rtl::OUString doubleToUString(double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OUString aResult;
+ rtl_math_doubleToUString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, 0, 0, bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToUString that appends to an
+ rtl::OUStringBuffer.
+ */
+inline void doubleToUStringBuffer( rtl::OUStringBuffer& rBuffer, double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Unicode cGroupSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl_uString ** pData;
+ sal_Int32 * pCapacity;
+ rBuffer.accessInternals( &pData, &pCapacity );
+ rtl_math_doubleToUString( pData, pCapacity, rBuffer.getLength(), fValue,
+ eFormat, nDecPlaces, cDecSeparator, pGroups,
+ cGroupSeparator, bEraseTrailingDecZeros);
+}
+
+/** A wrapper around rtl_math_doubleToUString that appends to an
+ rtl::OUStringBuffer, with no grouping.
+ */
+inline void doubleToUStringBuffer( rtl::OUStringBuffer& rBuffer, double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl_uString ** pData;
+ sal_Int32 * pCapacity;
+ rBuffer.accessInternals( &pData, &pCapacity );
+ rtl_math_doubleToUString( pData, pCapacity, rBuffer.getLength(), fValue,
+ eFormat, nDecPlaces, cDecSeparator, 0, 0,
+ bEraseTrailingDecZeros);
+}
+
+/** A wrapper around rtl_math_stringToDouble.
+ */
+inline double stringToDouble(rtl::OString const & rString,
+ sal_Char cDecSeparator, sal_Char cGroupSeparator,
+ rtl_math_ConversionStatus * pStatus = 0,
+ sal_Int32 * pParsedEnd = 0)
+{
+ sal_Char const * pBegin = rString.getStr();
+ sal_Char const * pEnd;
+ double fResult = rtl_math_stringToDouble(pBegin,
+ pBegin + rString.getLength(),
+ cDecSeparator, cGroupSeparator,
+ pStatus, &pEnd);
+ if (pParsedEnd != 0)
+ *pParsedEnd = (sal_Int32)(pEnd - pBegin);
+ return fResult;
+}
+
+/** A wrapper around rtl_math_uStringToDouble.
+ */
+inline double stringToDouble(rtl::OUString const & rString,
+ sal_Unicode cDecSeparator,
+ sal_Unicode cGroupSeparator,
+ rtl_math_ConversionStatus * pStatus = 0,
+ sal_Int32 * pParsedEnd = 0)
+{
+ sal_Unicode const * pBegin = rString.getStr();
+ sal_Unicode const * pEnd;
+ double fResult = rtl_math_uStringToDouble(pBegin,
+ pBegin + rString.getLength(),
+ cDecSeparator, cGroupSeparator,
+ pStatus, &pEnd);
+ if (pParsedEnd != 0)
+ *pParsedEnd = (sal_Int32)(pEnd - pBegin);
+ return fResult;
+}
+
+/** A wrapper around rtl_math_round.
+ */
+inline double round(
+ double fValue, int nDecPlaces = 0,
+ rtl_math_RoundingMode eMode = rtl_math_RoundingMode_Corrected)
+{
+ return rtl_math_round(fValue, nDecPlaces, eMode);
+}
+
+/** A wrapper around rtl_math_pow10Exp.
+ */
+inline double pow10Exp(double fValue, int nExp)
+{
+ return rtl_math_pow10Exp(fValue, nExp);
+}
+
+/** A wrapper around rtl_math_approxValue.
+ */
+inline double approxValue(double fValue)
+{
+ return rtl_math_approxValue(fValue);
+}
+
+/** A wrapper around rtl_math_expm1.
+ */
+inline double expm1(double fValue)
+{
+ return rtl_math_expm1(fValue);
+}
+
+/** A wrapper around rtl_math_log1p.
+ */
+inline double log1p(double fValue)
+{
+ return rtl_math_log1p(fValue);
+}
+
+/** A wrapper around rtl_math_atanh.
+ */
+inline double atanh(double fValue)
+{
+ return rtl_math_atanh(fValue);
+}
+
+/** A wrapper around rtl_math_erf.
+ */
+inline double erf(double fValue)
+{
+ return rtl_math_erf(fValue);
+}
+
+/** A wrapper around rtl_math_erfc.
+ */
+inline double erfc(double fValue)
+{
+ return rtl_math_erfc(fValue);
+}
+
+/** A wrapper around rtl_math_asinh.
+ */
+inline double asinh(double fValue)
+{
+ return rtl_math_asinh(fValue);
+}
+
+/** A wrapper around rtl_math_acosh.
+ */
+inline double acosh(double fValue)
+{
+ return rtl_math_acosh(fValue);
+}
+
+
+/** Test equality of two values with an accuracy of the magnitude of the
+ given values scaled by 2^-48 (4 bits roundoff stripped).
+
+ @attention
+ approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+ */
+inline bool approxEqual(double a, double b)
+{
+ if ( a == b )
+ return true;
+ double x = a - b;
+ return (x < 0.0 ? -x : x)
+ < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
+}
+
+/** Test equality of two values with an accuracy defined by nPrec
+
+ @attention
+ approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+ */
+inline bool approxEqual(double a, double b, sal_Int16 nPrec)
+{
+ if ( a == b )
+ return true;
+ double x = a - b;
+ return (x < 0.0 ? -x : x)
+ < ((a < 0.0 ? -a : a) * (1.0 / (pow(static_cast<double>(2.0), nPrec))));
+}
+/** Add two values.
+
+ If signs differ and the absolute values are equal according to approxEqual()
+ the method returns 0.0 instead of calculating the sum.
+
+ If you wanted to sum up multiple values it would be convenient not to call
+ approxAdd() for each value but instead remember the first value not equal to
+ 0.0, add all other values using normal + operator, and with the result and
+ the remembered value call approxAdd().
+ */
+inline double approxAdd(double a, double b)
+{
+ if ( ((a < 0.0 && b > 0.0) || (b < 0.0 && a > 0.0))
+ && approxEqual( a, -b ) )
+ return 0.0;
+ return a + b;
+}
+
+/** Substract two values (a-b).
+
+ If signs are identical and the values are equal according to approxEqual()
+ the method returns 0.0 instead of calculating the substraction.
+ */
+inline double approxSub(double a, double b)
+{
+ if ( ((a < 0.0 && b < 0.0) || (a > 0.0 && b > 0.0)) && approxEqual( a, b ) )
+ return 0.0;
+ return a - b;
+}
+
+/** floor() method taking approxValue() into account.
+
+ Use for expected integer values being calculated by double functions.
+ */
+inline double approxFloor(double a)
+{
+ return floor( approxValue( a ));
+}
+
+/** ceil() method taking approxValue() into account.
+
+ Use for expected integer values being calculated by double functions.
+ */
+inline double approxCeil(double a)
+{
+ return ceil( approxValue( a ));
+}
+
+/** Tests whether a value is neither INF nor NAN.
+ */
+inline bool isFinite(double d)
+{
+ return SAL_MATH_FINITE(d) != 0;
+}
+
+/** If a value represents +INF or -INF.
+
+ The sign bit may be queried with isSignBitSet().
+
+ If isFinite(d)==false and isInf(d)==false then NAN.
+ */
+inline bool isInf(double d)
+{
+ // exponent==0x7ff fraction==0
+ return (SAL_MATH_FINITE(d) == 0) &&
+ (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_hi == 0)
+ && (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_lo
+ == 0);
+}
+
+/** Test on any QNAN or SNAN.
+ */
+inline bool isNan(double d)
+{
+ // exponent==0x7ff fraction!=0
+ return (SAL_MATH_FINITE(d) == 0) && (
+ (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_hi != 0)
+ || (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_lo
+ != 0) );
+}
+
+/** If the sign bit is set.
+ */
+inline bool isSignBitSet(double d)
+{
+ return reinterpret_cast< sal_math_Double * >(&d)->inf_parts.sign != 0;
+}
+
+/** Set to +INF if bNegative==false or -INF if bNegative==true.
+ */
+inline void setInf(double * pd, bool bNegative)
+{
+ union
+ {
+ double sd;
+ sal_math_Double md;
+ };
+ md.w32_parts.msw = bNegative ? 0xFFF00000 : 0x7FF00000;
+ md.w32_parts.lsw = 0;
+ *pd = sd;
+}
+
+/** Set a QNAN.
+ */
+inline void setNan(double * pd)
+{
+ union
+ {
+ double sd;
+ sal_math_Double md;
+ };
+ md.w32_parts.msw = 0x7FFFFFFF;
+ md.w32_parts.lsw = 0xFFFFFFFF;
+ *pd = sd;
+}
+
+/** If a value is a valid argument for sin(), cos(), tan().
+
+ IEEE 754 specifies that absolute values up to 2^64 (=1.844e19) for the
+ radian must be supported by trigonometric functions. Unfortunately, at
+ least on x86 architectures, the FPU doesn't generate an error pattern for
+ values >2^64 but produces erroneous results instead and sets only the
+ "invalid operation" (IM) flag in the status word :-( Thus the application
+ has to handle it itself.
+ */
+inline bool isValidArcArg(double d)
+{
+ return fabs(d)
+ <= (static_cast< double >(static_cast< unsigned long >(0x80000000))
+ * static_cast< double >(static_cast< unsigned long >(0x80000000))
+ * 2);
+}
+
+/** Safe sin(), returns NAN if not valid.
+ */
+inline double sin(double d)
+{
+ if ( isValidArcArg( d ) )
+ return ::sin( d );
+ setNan( &d );
+ return d;
+}
+
+/** Safe cos(), returns NAN if not valid.
+ */
+inline double cos(double d)
+{
+ if ( isValidArcArg( d ) )
+ return ::cos( d );
+ setNan( &d );
+ return d;
+}
+
+/** Safe tan(), returns NAN if not valid.
+ */
+inline double tan(double d)
+{
+ if ( isValidArcArg( d ) )
+ return ::tan( d );
+ setNan( &d );
+ return d;
+}
+
+}
+
+}
+
+#endif // INCLUDED_RTL_MATH_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/process.h b/include/rtl/process.h
new file mode 100644
index 000000000000..fa8fdda62e9d
--- /dev/null
+++ b/include/rtl/process.h
@@ -0,0 +1,79 @@
+/* -*- 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 _RTL_PROCESS_H_
+#define _RTL_PROCESS_H_
+
+#include "sal/config.h"
+
+#include "osl/process.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ gets a 16-byte fixed size identifier which is guaranteed not to change
+ during the current process.
+
+ The current implementation creates a 16-byte uuid without using
+ the ethernet address of system. Thus the
+ identifier is different from identifiers created
+ in other processes with a very probability.
+
+ @param pTargetUUID 16 byte of memory
+ @see rtl_createUiid()
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_getGlobalProcessId( sal_uInt8 *pTargetUUID );
+
+/** Get the nArg-th command-line argument passed to the main-function of this process.
+
+ This functions differs from osl_getCommandArg() in filtering any bootstrap values
+ given by command args, that means that all arguments starting with "-env:" will be
+ ignored by this function.
+
+ @param nArg [in] The number of the argument to return.
+ @param strCommandArg [out] The string receives the nArg-th command-line argument.
+ @return osl_Process_E_None or does not return.
+ @see osl_getCommandArg()
+ @see rtl_getCommandArgCount()
+*/
+SAL_DLLPUBLIC oslProcessError SAL_CALL rtl_getAppCommandArg(sal_uInt32 nArg, rtl_uString **strCommandArg);
+
+/** Returns the number of command line arguments at process start.
+
+ This functions differs from osl_getCommandArg() in filtering any bootstrap values
+ given by command args, that means that all arguments starting with "-env:" will be
+ ignored by this function.
+
+ @return the number of commandline arguments passed to the main-function of this process.
+ @see osl_getCommandArgCount()
+ @see rtl_getCommandArg()
+*/
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_getAppCommandArgCount();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/random.h b/include/rtl/random.h
new file mode 100644
index 000000000000..80c9c15a2c52
--- /dev/null
+++ b/include/rtl/random.h
@@ -0,0 +1,110 @@
+/* -*- 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 _RTL_RANDOM_H_
+#define _RTL_RANDOM_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtlRandom interface.
+ *
+ *======================================================================*/
+/** Random Pool opaque type.
+ */
+typedef void* rtlRandomPool;
+
+
+/** Error Code enumeration.
+ */
+enum __rtl_RandomError
+{
+ rtl_Random_E_None,
+ rtl_Random_E_Argument,
+ rtl_Random_E_Memory,
+ rtl_Random_E_Unknown,
+ rtl_Random_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Error Code type.
+ */
+typedef enum __rtl_RandomError rtlRandomError;
+
+
+/** Create a Random Pool.
+ @return initialized Random Pool, or NULL upon failure.
+ */
+SAL_DLLPUBLIC rtlRandomPool SAL_CALL rtl_random_createPool (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a Random Pool.
+ @param Pool [in] a Random Pool.
+ @return none. Pool is invalid.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_random_destroyPool (
+ rtlRandomPool Pool
+) SAL_THROW_EXTERN_C();
+
+
+/** Add bytes to a Random Pool.
+ @param[in] Pool a Random Pool.
+ @param[in] Buffer a buffer containing the bytes to add.
+ @param[in] Bytes the number of bytes to read from the buffer.
+ @return rtl_Random_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_addBytes (
+ rtlRandomPool Pool,
+ const void *Buffer,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Retrieve bytes from a Random Pool.
+ @param[in] Pool a Random Pool.
+ @param[in,out] Buffer a buffer to receive the random bytes.
+ @param[in] Bytes the number of bytes to write to the buffer.
+ @return rtl_Random_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_getBytes (
+ rtlRandomPool Pool,
+ void *Buffer,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_RANDOM_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx
new file mode 100644
index 000000000000..8306a839da46
--- /dev/null
+++ b/include/rtl/ref.hxx
@@ -0,0 +1,243 @@
+/* -*- 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 _RTL_REF_HXX_
+#define _RTL_REF_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+namespace rtl
+{
+
+/** Interface for a reference type.
+*/
+class IReference
+{
+public:
+ /** @see osl_incrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL acquire() = 0;
+
+ /** @see osl_decrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL release() = 0;
+
+#if !defined _MSC_VER // public -> protected changes mangled names there
+protected:
+#endif
+ ~IReference() {}
+ // avoid warnings about virtual members and non-virtual dtor
+};
+
+
+/** Template reference class for reference type derived from IReference.
+*/
+template <class reference_type>
+class Reference
+{
+ /** The <b>reference_type</b> body pointer.
+ */
+ reference_type * m_pBody;
+
+
+public:
+ /** Constructor...
+ */
+ inline Reference()
+ : m_pBody (0)
+ {}
+
+
+ /** Constructor...
+ */
+ inline Reference (reference_type * pBody)
+ : m_pBody (pBody)
+ {
+ if (m_pBody)
+ m_pBody->acquire();
+ }
+
+
+ /** Copy constructor...
+ */
+ inline Reference (const Reference<reference_type> & handle)
+ : m_pBody (handle.m_pBody)
+ {
+ if (m_pBody)
+ m_pBody->acquire();
+ }
+
+
+ /** Destructor...
+ */
+ inline ~Reference()
+ {
+ if (m_pBody)
+ m_pBody->release();
+ }
+
+ /** Set...
+ Similar to assignment.
+ */
+ inline Reference<reference_type> &
+ SAL_CALL set (reference_type * pBody)
+ {
+ if (pBody)
+ pBody->acquire();
+ reference_type * const pOld = m_pBody;
+ m_pBody = pBody;
+ if (pOld)
+ pOld->release();
+ return *this;
+ }
+
+ /** Assignment.
+ Unbinds this instance from its body (if bound) and
+ bind it to the body represented by the handle.
+ */
+ inline Reference<reference_type> &
+ SAL_CALL operator= (const Reference<reference_type> & handle)
+ {
+ return set( handle.m_pBody );
+ }
+
+ /** Assignment...
+ */
+ inline Reference<reference_type> &
+ SAL_CALL operator= (reference_type * pBody)
+ {
+ return set( pBody );
+ }
+
+ /** Unbind the body from this handle.
+ Note that for a handle representing a large body,
+ "handle.clear().set(new body());" _might_
+ perform a little bit better than "handle.set(new body());",
+ since in the second case two large objects exist in memory
+ (the old body and the new body).
+ */
+ inline Reference<reference_type> & SAL_CALL clear()
+ {
+ if (m_pBody)
+ {
+ reference_type * const pOld = m_pBody;
+ m_pBody = 0;
+ pOld->release();
+ }
+ return *this;
+ }
+
+
+ /** Get the body. Can be used instead of operator->().
+ I.e. handle->someBodyOp() and handle.get()->someBodyOp()
+ are the same.
+ */
+ inline reference_type * SAL_CALL get() const
+ {
+ return m_pBody;
+ }
+
+
+ /** Probably most common used: handle->someBodyOp().
+ */
+ inline reference_type * SAL_CALL operator->() const
+ {
+ OSL_PRECOND(m_pBody, "Reference::operator->() : null body");
+ return m_pBody;
+ }
+
+
+ /** Allows (*handle).someBodyOp().
+ */
+ inline reference_type & SAL_CALL operator*() const
+ {
+ OSL_PRECOND(m_pBody, "Reference::operator*() : null body");
+ return *m_pBody;
+ }
+
+
+ /** Returns True if the handle does point to a valid body.
+ */
+ inline sal_Bool SAL_CALL is() const
+ {
+ return (m_pBody != 0);
+ }
+
+
+ /** Returns True if this points to pBody.
+ */
+ inline sal_Bool SAL_CALL operator== (const reference_type * pBody) const
+ {
+ return (m_pBody == pBody);
+ }
+
+
+ /** Returns True if handle points to the same body.
+ */
+ inline sal_Bool
+ SAL_CALL operator== (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody == handle.m_pBody);
+ }
+
+
+ /** Needed to place References into STL collection.
+ */
+ inline sal_Bool
+ SAL_CALL operator!= (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody != handle.m_pBody);
+ }
+
+
+ /** Needed to place References into STL collection.
+ */
+ inline sal_Bool
+ SAL_CALL operator< (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody < handle.m_pBody);
+ }
+
+
+ /** Needed to place References into STL collection.
+ */
+ inline sal_Bool
+ SAL_CALL operator> (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody > handle.m_pBody);
+ }
+};
+
+/// @cond INTERNAL
+/** Enables boost::mem_fn and boost::bind to recognize Reference.
+*/
+template <typename T>
+inline T * get_pointer( Reference<T> const& r )
+{
+ return r.get();
+}
+/// @endcond
+
+} // namespace rtl
+
+#endif /* !_RTL_REF_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/strbuf.h b/include/rtl/strbuf.h
new file mode 100644
index 000000000000..05dd2de8c61c
--- /dev/null
+++ b/include/rtl/strbuf.h
@@ -0,0 +1,137 @@
+/* -*- 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 _RTL_STRBUF_H_
+#define _RTL_STRBUF_H_
+
+#include "sal/config.h"
+
+#include "rtl/string.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Allocates a new <code>String</code> that contains characters from
+ the character array argument.
+
+ The <code>count</code> argument specifies
+ the length of the array. The initial capacity of the string buffer is
+ <code>16</code> plus the length of the string argument.
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param value the initial value of the string.
+ @param count the length of value.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_stringbuffer_newFromStr_WithLength(
+ rtl_String ** newStr,
+ const sal_Char * value,
+ sal_Int32 count);
+
+/**
+ Allocates a new <code>String</code> that contains the same sequence of
+ characters as the string argument.
+
+ The initial capacity is the larger of:
+ <ul>
+ <li> The <code>bufferLen</code> argument.
+ <li> The <code>length</code> of the string argument.
+ </ul>
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param capacity the initial len of the string buffer.
+ @param oldStr the initial value of the string.
+ @return the new capacity of the string buffer
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer(
+ rtl_String ** newStr,
+ sal_Int32 capacity,
+ rtl_String * oldStr );
+
+/**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ If the current capacity of this string buffer is less than the
+ argument, then a new internal buffer is allocated with greater
+ capacity. The new capacity is the larger of:
+ <ul>
+ <li>The <code>minimumCapacity</code> argument.
+ <li>Twice the old capacity, plus <code>2</code>.
+ </ul>
+ If the <code>minimumCapacity</code> argument is nonpositive, this
+ method takes no action and simply returns.
+
+ @param[in,out] This the String to operate on.
+ @param[in,out] capacity in: old capacity, out: new capacity.
+ @param[in] minimumCapacity the minimum desired capacity.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_stringbuffer_ensureCapacity(
+ rtl_String ** This,
+ sal_Int32* capacity,
+ sal_Int32 minimumCapacity);
+
+
+/**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+
+ @param[in,out] This the String to operate on.
+ @param[in,out] capacity the capacity of the string buffer
+ @param[in] offset the offset.
+ @param[in] str a character array.
+ @param[in] len the number of characters to append.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_stringbuffer_insert(
+ rtl_String ** This,
+ sal_Int32 * capacity,
+ sal_Int32 offset,
+ const sal_Char * str,
+ sal_Int32 len);
+
+/**
+ Removes the characters in a substring of this sequence.
+
+ The substring begins at the specified <code>start</code> and
+ is <code>len</code> characters long.
+
+ start must be >= 0 && <= This->length
+
+ @param[in,out] This The String to operate on.
+ @param[in] start The beginning index, inclusive
+ @param[in] len The substring length
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_stringbuffer_remove(
+ rtl_String ** This,
+ sal_Int32 start,
+ sal_Int32 len );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_STRBUF_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
new file mode 100644
index 000000000000..9ebd495239cd
--- /dev/null
+++ b/include/rtl/strbuf.hxx
@@ -0,0 +1,922 @@
+/* -*- 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 _RTL_STRBUF_HXX_
+#define _RTL_STRBUF_HXX_
+
+#include "sal/config.h"
+
+#include <cassert>
+#include <string.h>
+
+#include <rtl/strbuf.h>
+#include <rtl/string.hxx>
+#include <rtl/stringutils.hxx>
+
+#ifdef RTL_FAST_STRING
+#include <rtl/stringconcat.hxx>
+#endif
+
+#ifdef __cplusplus
+
+// The unittest uses slightly different code to help check that the proper
+// calls are made. The class is put into a different namespace to make
+// sure the compiler generates a different (if generating also non-inline)
+// copy of the function and does not merge them together. The class
+// is "brought" into the proper rtl namespace by a typedef below.
+#ifdef RTL_STRING_UNITTEST
+#define rtl rtlunittest
+#endif
+
+namespace rtl
+{
+
+#ifdef RTL_STRING_UNITTEST
+#undef rtl
+// helper macro to make functions appear more readable
+#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
+#else
+#define RTL_STRING_CONST_FUNCTION
+#endif
+
+/** A string buffer implements a mutable sequence of characters.
+ <p>
+ String buffers are safe for use by multiple threads. The methods
+ are synchronized where necessary so that all the operations on any
+ particular instance behave as if they occur in some serial order.
+ <p>
+ String buffers are used by the compiler to implement the binary
+ string concatenation operator <code>+</code>. For example, the code:
+ <p><blockquote><pre>
+ x = "a" + 4 + "c"
+ </pre></blockquote><p>
+ is compiled to the equivalent of:
+ <p><blockquote><pre>
+ x = new OStringBuffer().append("a").append(4).append("c")
+ .makeStringAndClear()
+ </pre></blockquote><p>
+ The principal operations on a <code>OStringBuffer</code> are the
+ <code>append</code> and <code>insert</code> methods, which are
+ overloaded so as to accept data of any type. Each effectively
+ converts a given datum to a string and then appends or inserts the
+ characters of that string to the string buffer. The
+ <code>append</code> method always adds these characters at the end
+ of the buffer; the <code>insert</code> method adds the characters at
+ a specified point.
+ <p>
+ For example, if <code>z</code> refers to a string buffer object
+ whose current contents are "<code>start</code>", then
+ the method call <code>z.append("le")</code> would cause the string
+ buffer to contain "<code>startle</code>", whereas
+ <code>z.insert(4, "le")</code> would alter the string buffer to
+ contain "<code>starlet</code>".
+ <p>
+ Every string buffer has a capacity. As long as the length of the
+ character sequence contained in the string buffer does not exceed
+ the capacity, it is not necessary to allocate a new internal
+ buffer array. If the internal buffer overflows, it is
+ automatically made larger.
+ */
+class SAL_WARN_UNUSED OStringBuffer
+{
+public:
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity of 16 characters.
+ */
+ OStringBuffer()
+ : pData(NULL)
+ , nCapacity( 16 )
+ {
+ rtl_string_new_WithLength( &pData, nCapacity );
+ }
+
+ /**
+ Allocates a new string buffer that contains the same sequence of
+ characters as the string buffer argument.
+
+ @param value a <code>OStringBuffer</code>.
+ */
+ OStringBuffer( const OStringBuffer & value )
+ : pData(NULL)
+ , nCapacity( value.nCapacity )
+ {
+ rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
+ }
+
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity specified by the <code>length</code> argument.
+
+ @param length the initial capacity.
+ */
+ explicit OStringBuffer(int length)
+ : pData(NULL)
+ , nCapacity( length )
+ {
+ rtl_string_new_WithLength( &pData, length );
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string argument.
+
+ The initial
+ capacity of the string buffer is <code>16</code> plus the length
+ of the string argument.
+
+ @param value the initial string value.
+ */
+ OStringBuffer(const OString& value)
+ : pData(NULL)
+ , nCapacity( value.getLength() + 16 )
+ {
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
+ }
+
+ /**
+ @overload
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ OStringBuffer( const T& value, typename internal::CharPtrDetector< T, internal::Dummy >::Type = internal::Dummy())
+ : pData(NULL)
+ {
+ sal_Int32 length = rtl_str_getLength( value );
+ nCapacity = length + 16;
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
+ }
+
+ template< typename T >
+ OStringBuffer( T& value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy())
+ : pData(NULL)
+ {
+ sal_Int32 length = rtl_str_getLength( value );
+ nCapacity = length + 16;
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string literal.
+
+ If there are any embedded \0's in the string literal, the result is undefined.
+ Use the overload that explicitly accepts length.
+
+ @since LibreOffice 3.6
+
+ @param literal a string literal
+ */
+ template< typename T >
+ OStringBuffer( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy())
+ : pData(NULL)
+ , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
+#ifdef RTL_STRING_UNITTEST
+ rtl_string_unittest_const_literal = true;
+#endif
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string argument.
+
+ The initial
+ capacity of the string buffer is <code>16</code> plus length
+
+ @param value a character array.
+ @param length the number of character which should be copied.
+ The character array length must be greater or
+ equal than this value.
+ */
+ OStringBuffer(const sal_Char * value, sal_Int32 length)
+ : pData(NULL)
+ , nCapacity( length + 16 )
+ {
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OStringBuffer( const OStringConcat< T1, T2 >& c )
+ {
+ const sal_Int32 l = c.length();
+ nCapacity = l + 16;
+ pData = rtl_string_alloc( nCapacity );
+ char* end = c.addData( pData->buffer );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ }
+#endif
+
+ /** Assign to this a copy of value.
+ */
+ OStringBuffer& operator = ( const OStringBuffer& value )
+ {
+ if (this != &value)
+ {
+ rtl_stringbuffer_newFromStringBuffer(&pData,
+ value.nCapacity,
+ value.pData);
+ nCapacity = value.nCapacity;
+ }
+ return *this;
+ }
+
+ /**
+ Release the string data.
+ */
+ ~OStringBuffer()
+ {
+ rtl_string_release( pData );
+ }
+
+ /**
+ Fill the string data in the new string and clear the buffer.
+
+ This method is more efficient than the contructor of the string. It does
+ not copy the buffer.
+
+ @return the string previously contained in the buffer.
+ */
+ OString makeStringAndClear()
+ {
+ OString aRet( pData );
+ rtl_string_new(&pData);
+ nCapacity = 0;
+ return aRet;
+ }
+
+ /**
+ Returns the length (character count) of this string buffer.
+
+ @return the number of characters in this string buffer.
+ */
+ sal_Int32 getLength() const
+ {
+ return pData->length;
+ }
+
+ /**
+ Checks if a string buffer is empty.
+
+ @return true if the string buffer is empty;
+ false, otherwise.
+
+ @since LibreOffice 4.1
+ */
+ bool isEmpty() const SAL_THROW(())
+ {
+ return pData->length == 0;
+ }
+
+ /**
+ Returns the current capacity of the String buffer.
+
+ The capacity
+ is the amount of storage available for newly inserted
+ characters. The real buffer size is 2 bytes longer, because
+ all strings are 0 terminated.
+
+ @return the current capacity of this string buffer.
+ */
+ sal_Int32 getCapacity() const
+ {
+ return nCapacity;
+ }
+
+ /**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ The new capacity will be at least as large as the maximum of the current
+ length (so that no contents of the buffer is destroyed) and the given
+ minimumCapacity. If the given minimumCapacity is negative, nothing is
+ changed.
+
+ @param minimumCapacity the minimum desired capacity.
+ */
+ void ensureCapacity(sal_Int32 minimumCapacity)
+ {
+ rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
+ }
+
+ /**
+ Sets the length of this String buffer.
+
+ If the <code>newLength</code> argument is less than the current
+ length of the string buffer, the string buffer is truncated to
+ contain exactly the number of characters given by the
+ <code>newLength</code> argument.
+ <p>
+ If the <code>newLength</code> argument is greater than or equal
+ to the current length, sufficient null characters
+ (<code>'&#92;u0000'</code>) are appended to the string buffer so that
+ length becomes the <code>newLength</code> argument.
+ <p>
+ The <code>newLength</code> argument must be greater than or equal
+ to <code>0</code>.
+
+ @param newLength the new length of the buffer.
+ */
+ void setLength(sal_Int32 newLength)
+ {
+ assert(newLength >= 0);
+ // Avoid modifications if pData points to const empty string:
+ if( newLength != pData->length )
+ {
+ if( newLength > nCapacity )
+ rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
+ else
+ pData->buffer[newLength] = '\0';
+ pData->length = newLength;
+ }
+ }
+
+ /**
+ Returns the character at a specific index in this string buffer.
+
+ The first character of a string buffer is at index
+ <code>0</code>, the next at index <code>1</code>, and so on, for
+ array indexing.
+ <p>
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the desired character.
+ @return the character at the specified index of this string buffer.
+ */
+ SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
+ sal_Char charAt( sal_Int32 index )
+ {
+ assert(index >= 0 && index < pData->length);
+ return pData->buffer[ index ];
+ }
+
+ /**
+ The character at the specified index of this string buffer is set
+ to <code>ch</code>.
+
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the character to modify.
+ @param ch the new character.
+ */
+ SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
+ OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch)
+ {
+ assert(index >= 0 && index < pData->length);
+ pData->buffer[ index ] = ch;
+ return *this;
+ }
+
+ /**
+ Return a null terminated character array.
+ */
+ const sal_Char* getStr() const { return pData->buffer; }
+
+ /**
+ Access to individual characters.
+
+ @param index must be non-negative and less than length.
+
+ @return a reference to the character at the given index.
+
+ @since LibreOffice 3.5
+ */
+ sal_Char & operator [](sal_Int32 index)
+ {
+ assert(index >= 0 && index < pData->length);
+ return pData->buffer[index];
+ }
+
+ /**
+ Return a OString instance reflecting the current content
+ of this OStringBuffer.
+ */
+ const OString toString() const
+ {
+ return OString(pData->buffer, pData->length);
+ }
+
+ /**
+ Appends the string to this string buffer.
+
+ The characters of the <code>String</code> argument are appended, in
+ order, to the contents of this string buffer, increasing the
+ length of this string buffer by the length of the argument.
+
+ @param str a string.
+ @return this string buffer.
+ */
+ OStringBuffer & append(const OString &str)
+ {
+ return append( str.getStr(), str.getLength() );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ The characters of the array argument are appended, in order, to
+ the contents of this string buffer. The length of this string
+ buffer increases by the length of the argument.
+
+ @param str the characters to be appended.
+ @return this string buffer.
+ */
+ template< typename T >
+ typename internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
+ {
+ return append( str, rtl_str_getLength( str ) );
+ }
+
+ template< typename T >
+ typename internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
+ {
+ return append( str, rtl_str_getLength( str ) );
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ return *this;
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ Characters of the character array <code>str</code> are appended,
+ in order, to the contents of this string buffer. The length of this
+ string buffer increases by the value of <code>len</code>.
+
+ @param str the characters to be appended; must be non-null, and must
+ point to at least len characters
+ @param len the number of characters to append; must be non-negative
+ @return this string buffer.
+ */
+ OStringBuffer & append( const sal_Char * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
+ return *this;
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OStringBuffer& append( const OStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
+ char* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+
+ /**
+ Appends the string representation of the <code>sal_Bool</code>
+ argument to the string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Bool b)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
+ return append( sz, rtl_str_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code>
+ argument to this string buffer.
+
+ The argument is appended to the contents of this string buffer.
+ The length of this string buffer increases by <code>1</code>.
+
+ @param c a <code>char</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Char c)
+ {
+ return append( &c, 1 );
+ }
+
+ /**
+ Appends the string representation of the <code>sal_Int32</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param i an <code>sal_Int32</code>.
+ @param radix the radix
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
+ return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>long</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param l a <code>long</code>.
+ @param radix the radix
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
+ return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>float</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param f a <code>float</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(float f)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
+ return append( sz, rtl_str_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Appends the string representation of the <code>double</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param d a <code>double</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(double d)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
+ return append( sz, rtl_str_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Inserts the string into this string buffer.
+
+ The characters of the <code>String</code> argument are inserted, in
+ order, into this string buffer at the indicated offset. The length
+ of this string buffer is increased by the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a string.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, const OString & str)
+ {
+ return insert( offset, str.getStr(), str.getLength() );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a character array.
+ @return this string buffer.
+ */
+ template< typename T >
+ typename internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
+ {
+ return insert( offset, str, rtl_str_getLength( str ) );
+ }
+
+ template< typename T >
+ typename internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
+ {
+ return insert( offset, str, rtl_str_getLength( str ) );
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_stringbuffer_insert( &pData, &nCapacity, offset, literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ return *this;
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a character array.
+ @param len the number of characters to append.
+ @return this string buffer.
+ */
+ OStringBuffer & insert( sal_Int32 offset, const sal_Char * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
+ return *this;
+ }
+
+ /**
+ Inserts the string representation of the <code>sal_Bool</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
+ return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code>
+ argument into this string buffer.
+
+ The second argument is inserted into the contents of this string
+ buffer at the position indicated by <code>offset</code>. The length
+ of this string buffer increases by one.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param c a <code>char</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Char c)
+ {
+ return insert( offset, &c, 1 );
+ }
+
+ /**
+ Inserts the string representation of the second <code>sal_Int32</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param i an <code>sal_Int32</code>.
+ @param radix the radix
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
+ return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>long</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param l a <code>long</code>.
+ @param radix the radix
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
+ return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>float</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param f a <code>float</code>.
+ @return this string buffer.
+ */
+ OStringBuffer insert(sal_Int32 offset, float f)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
+ return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>double</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param d a <code>double</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, double d)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
+ return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Removes the characters in a substring of this sequence.
+
+ The substring begins at the specified <code>start</code> and
+ is <code>len</code> characters long.
+
+ start must be >= 0 && <= getLength() && <= end
+
+ @param start The beginning index, inclusive
+ @param len The substring length
+ @return this string buffer.
+ */
+ OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
+ {
+ rtl_stringbuffer_remove( &pData, start, len );
+ return *this;
+ }
+
+#ifdef LIBO_INTERNAL_ONLY
+ // This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
+ // even two buffers. It's intentional it returns OString, just like the operator+ would in the fast variant.
+#ifndef RTL_FAST_STRING
+ /**
+ @internal
+ @since LibreOffice 4.1
+ */
+ friend OString operator+( const OStringBuffer& str1, const OStringBuffer& str2 ) SAL_THROW(())
+ {
+ return OString( str1.pData ).concat( str2.pData );
+ }
+#endif
+#endif
+
+private:
+ /**
+ A pointer to the data structur which contains the data.
+ */
+ rtl_String * pData;
+
+ /**
+ The len of the pData->buffer.
+ */
+ sal_Int32 nCapacity;
+};
+
+#ifdef RTL_FAST_STRING
+/**
+ @internal
+*/
+template<>
+struct ToStringHelper< OStringBuffer >
+ {
+ static int length( const OStringBuffer& s ) { return s.getLength(); }
+ static char* addData( char* buffer, const OStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+#endif
+
+
+}
+
+#ifdef RTL_STRING_UNITTEST
+namespace rtl
+{
+typedef rtlunittest::OStringBuffer OStringBuffer;
+}
+#undef RTL_STRING_CONST_FUNCTION
+#endif
+
+#ifdef RTL_USING
+using ::rtl::OStringBuffer;
+#endif
+
+#endif /* __cplusplus */
+#endif /* _RTL_STRBUF_HXX_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/string.h b/include/rtl/string.h
new file mode 100644
index 000000000000..93cffa1a17b4
--- /dev/null
+++ b/include/rtl/string.h
@@ -0,0 +1,1408 @@
+/* -*- 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 _RTL_STRING_H_
+#define _RTL_STRING_H_
+
+#include "sal/config.h"
+
+#include "osl/interlck.h"
+#include "rtl/textcvt.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ======================================================================= */
+
+/** Return the length of a string.
+
+ The length is equal to the number of 8-bit characters in the string,
+ without the terminating NUL character.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the length of the sequence of characters represented by this string,
+ excluding the terminating NUL character.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_getLength(
+ const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting. Both strings must be
+ null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare(
+ const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare_WithLength(
+ const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_shortenedCompare_WithLength(
+ const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string
+ compares less than the second string, and a value greater than 0 if the
+ first string compares greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_reverseCompare_WithLength(
+ const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting. Both strings must be null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase(
+ const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase_WithLength(
+ const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters, ignoring the case
+ of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
+ const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes. The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ a hash code for the given string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
+ const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @return
+ a hash code for the given string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
+ const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfChar(
+ const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfChar_WithLength(
+ const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfChar(
+ const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfChar_WithLength(
+ const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfStr(
+ const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfStr_WithLength(
+ const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfStr(
+ const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfStr_WithLength(
+ const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_str_replaceChar(
+ sal_Char * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_str_replaceChar_WithLength(
+ sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiLowerCase(
+ sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiLowerCase_WithLength(
+ sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiUpperCase(
+ sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiUpperCase_WithLength(
+ sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of a string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the new length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim(
+ sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of the string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the original length of the string.
+
+ @return
+ the new length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim_WithLength(
+ sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Create the string representation of a boolean.
+
+ If b is true, the buffer is filled with the string "true" and 5 is
+ returned. If b is false, the buffer is filled with the string "false" and
+ 6 is returned. This function cannot be used for language-specific
+ operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFBOOLEAN define to create
+ a buffer that is big enough.
+
+ @param b
+ a boolean value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfBoolean(
+ sal_Char * str, sal_Bool b ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFBOOLEAN 6
+
+/** Create the string representation of a character.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFCHAR define to create a
+ buffer that is big enough.
+
+ @param ch
+ a character value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfChar(
+ sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFCHAR 2
+
+/** Create the string representation of an integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFINT32 define to create a
+ buffer that is big enough.
+
+ @param i
+ an integer value.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt32(
+ sal_Char * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MIN_RADIX 2
+#define RTL_STR_MAX_RADIX 36
+#define RTL_STR_MAX_VALUEOFINT32 33
+
+/** Create the string representation of a long integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFINT64 define to create a
+ buffer that is big enough.
+
+ @param l
+ a long integer value.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt64(
+ sal_Char * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFINT64 65
+
+/** Create the string representation of an unsigned long integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFUINT64 define to create a
+ buffer that is big enough.
+
+ @param l
+ a long integer value.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfUInt64(
+ sal_Char * str, sal_uInt64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFUINT64 65
+
+/** Create the string representation of a float.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFFLOAT define to create a
+ buffer that is big enough.
+
+ @param f
+ a float value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfFloat(
+ sal_Char * str, float f ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFFLOAT 15
+
+/** Create the string representation of a double.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFDOUBLE define to create
+ a buffer that is big enough.
+
+ @param d
+ a double value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfDouble(
+ sal_Char * str, double d ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFDOUBLE 25
+
+/** Interpret a string as a boolean.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ true if the string is "1" or "true" in any ASCII case, false otherwise.
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_str_toBoolean(
+ const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as an integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the integer value represented by the string, or 0 if the string does not
+ represent an integer.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32(
+ const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a long integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the long integer value represented by the string, or 0 if the string does
+ not represent a long integer.
+ */
+SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_str_toInt64(
+ const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as an unsigned long integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the unsigned long integer value represented by the string, or 0 if the
+ string does not represent an unsigned long integer.
+
+ @since LibreOffice 4.1
+ */
+SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_str_toUInt64(
+ const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a float.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a float.
+ */
+SAL_DLLPUBLIC float SAL_CALL rtl_str_toFloat(
+ const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a double.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a double.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_str_toDouble(
+ const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+/** @cond INTERNAL */
+/** The implementation of a byte string.
+ */
+typedef struct _rtl_String
+{
+ oslInterlockedCount refCount; /* opaque */
+ sal_Int32 length;
+ sal_Char buffer[1];
+} rtl_String;
+/** @endcond */
+
+#if defined(SAL_W32)
+#pragma pack(pop)
+#endif
+
+/* ----------------------------------------------------------------------- */
+
+/** Increment the reference count of a string.
+
+ @param str
+ a string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_acquire( rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Decrement the reference count of a string.
+
+ If the count goes to zero than the string data is deleted.
+
+ @param str
+ a string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_release( rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing no characters.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
+ The reference count of the new string will be 1. The length of the string
+ will be nLen. This function does not handle out-of-memory conditions.
+
+ For nLen < 0 or failed allocation this method returns NULL.
+
+ The characters of the capacity are not cleared, and the length is set to
+ nLen, unlike the similar method of rtl_String_new_WithLength which
+ zeros out the buffer, and sets the length to 0. So should be somewhat
+ more efficient for allocating a new string.
+
+ call rtl_String_release to release the string
+ alternatively pass ownership to an OUString with
+ rtl::OUString(newStr, SAL_NO_ACQUIRE);
+
+ @param[out] nLen the number of characters.
+ @return pointer to the new string.
+
+ @since LibreOffice 4.1
+ */
+SAL_DLLPUBLIC rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
+ If len is greater than zero, the reference count of the new string will be
+ 1. The values of all characters are set to 0 and the length of the string
+ is 0. This function does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param len
+ the number of characters.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of another string.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, const rtl_String * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a null-terminated character array.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a character array. Need not be null-terminated, but must be at least as
+ long as the specified len.
+
+ @param len
+ the length of the character array.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. Meaningless combinations such as negative beginIndex,
+ or beginIndex + count greater than the length of the string have
+ undefined behaviour.
+
+ @param[out] newStr the specified substring.
+ @param[in] from the String to take the substring from.
+ @param[in] beginIndex the beginning index, inclusive.
+ @param[in] count the number of characters.
+
+ @since LibreOffice 4.0
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromSubString(
+ rtl_String ** newStr, const rtl_String * from,
+ sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
+
+/**
+ @internal
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromLiteral( rtl_String ** newStr, const sal_Char * value, sal_Int32 len, sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
+
+/** Assign a new value to a string.
+
+ First releases any value str might currently hold, then acquires
+ rightValue.
+
+ @param str
+ pointer to the string. The pointed-to data must be null or a valid
+ string.
+
+ @param rightValue
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ) SAL_THROW_EXTERN_C();
+
+/** Return the length of a string.
+
+ The length is equal to the number of characters in the string.
+
+ @param str
+ a valid string.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getLength( const rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Return a pointer to the underlying character array of a string.
+
+ @param str
+ a valid string.
+
+ @return
+ a pointer to the null-terminated character array.
+ */
+SAL_DLLPUBLIC sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string that is the concatenation of two other strings.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where one of the two other strings is empty), so it must not be modified
+ without checking the reference count. This function does not handle
+ out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param left
+ a valid string.
+
+ @param right
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing a substring of another string.
+
+ The new string results from replacing a number of characters (count),
+ starting at the specified position (index) in the original string (str),
+ with some new substring (subStr). If subStr is null, than only a number
+ of characters is deleted.
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param idx
+ the index into str at which to start replacement. Must be between 0 and
+ the length of str, inclusive.
+
+ @param count
+ the number of characters to remove. Must not be negative, and the sum of
+ index and count must not exceed the length of str.
+
+ @param subStr
+ either null or a valid string to be inserted.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplaceStrAt(
+ rtl_String ** newStr, rtl_String * str, sal_Int32 idx, sal_Int32 count, rtl_String * subStr ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a single character
+ within another string.
+
+ The new string results from replacing all occurrences of oldChar in str
+ with newChar.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where oldChar does not occur in str), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplace(
+ rtl_String ** newStr, rtl_String * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing the first occurrence of a given substring
+ with another substring.
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_String
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p fromLength bytes
+
+ @param fromLength the length of the \p from substring; must be non-negative
+
+ @param to pointer to the replacing substring; must not be null and must
+ point to memory of at least \p toLength bytes
+
+ @param toLength the length of the \p to substring; must be non-negative
+
+ @param[in,out] index pointer to a start index, must not be null; upon entry
+ to the function its value is the index into the original string at which to
+ start searching for the \p from substring, the value must be non-negative
+ and not greater than the original string's length; upon exit from the
+ function its value is the index into the original string at which the
+ replacement took place or -1 if no replacement took place
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplaceFirst(
+ rtl_String ** newStr, rtl_String * str, char const * from,
+ sal_Int32 fromLength, char const * to, sal_Int32 toLength,
+ sal_Int32 * index) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a given substring with
+ another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_String
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p fromLength bytes
+
+ @param fromLength the length of the \p from substring; must be non-negative
+
+ @param to pointer to the replacing substring; must not be null and must
+ point to memory of at least \p toLength bytes
+
+ @param toLength the length of the \p to substring; must be non-negative
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplaceAll(
+ rtl_String ** newStr, rtl_String * str, char const * from,
+ sal_Int32 fromLength, char const * to, sal_Int32 toLength)
+ SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII uppercase letters to lowercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newToAsciiLowerCase(
+ rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII lowercase letters to uppercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newToAsciiUpperCase(
+ rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by removing white space from both ends of another
+ string.
+
+ The new string results from removing all characters with values less than
+ or equal to 32 (the space character) form both ends of str.
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be removed), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim(
+ rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by extracting a single token from another string.
+
+ Starting at index, the token's next token is searched for. If there is no
+ such token, the result is an empty string. Otherwise, all characters from
+ the start of that token and up to, but not including the next occurrence
+ of cTok make up the resulting token. The return value is the position of
+ the next token, or -1 if no more tokens follow.
+
+ Example code could look like
+ rtl_String * pToken = NULL;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ nIndex = rtl_string_getToken(&pToken, pStr, 0, ';', nIndex);
+ ...
+ }
+ while (nIndex >= 0);
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string. If either token or index is negative, an empty token is stored in
+ newStr (and -1 is returned).
+
+ @param str
+ a valid string.
+
+ @param token
+ the number of the token to return, starting at index.
+
+ @param cTok
+ the character that seperates the tokens.
+
+ @param idx
+ the position at which searching for the token starts. Must not be greater
+ than the length of str.
+
+ @return
+ the index of the next token, or -1 if no more tokens follow.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken(
+ rtl_String ** newStr , rtl_String * str, sal_Int32 token, sal_Char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+/** Supply an ASCII string literal together with its length.
+
+ This macro can be used to compute (some of) the arguments in function calls
+ like rtl::OString(RTL_CONSTASCII_STRINGPARAM("foo")) or
+ rtl::OUString::equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("foo")).
+
+ @param constAsciiStr
+ must be an expression of type "(possibly cv-qualified reference to) array of
+ (possibly cv-qualified) char." Each element of the referenced array must
+ represent an ASCII value in the range 0x00--0x7F. The last element of the
+ referenced array is not considered part of the represented ASCII string, and
+ its value should be 0x00. Depending on where this macro is used, the nature
+ of the supplied expression might be further restricted.
+*/
+// The &foo[0] trick is intentional, it makes sure the type is char* or const char*
+// (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
+// This is to avoid mistaken use with functions that accept string literals
+// (i.e. const char (&)[N]) where usage of this macro otherwise could match
+// the argument and a following int argument with a default value (e.g. OString::match()).
+#define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
+ ((sal_Int32)SAL_N_ELEMENTS(constAsciiStr)-1)
+
+/** Supply the length of an ASCII string literal.
+
+ This macro can be used to compute arguments in function calls like
+ rtl::OUString::match(other, RTL_CONSTASCII_LENGTH("prefix")).
+
+ @param constAsciiStr
+ must be an expression of type "(possibly cv-qualified reference to) array of
+ (possibly cv-qualified) char." Each element of the referenced array must
+ represent an ASCII value in the range 0x00--0x7F. The last element of the
+ referenced array is not considered part of the represented ASCII string, and
+ its value should be 0x00. Depending on where this macro is used, the nature
+ of the supplied expression might be further restricted.
+*/
+#define RTL_CONSTASCII_LENGTH( constAsciiStr ) ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1))
+
+/* ======================================================================= */
+
+/* predefined constants for String-Conversion */
+#define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\
+ RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\
+ RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\
+ RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE)
+
+/* ----------------------------------------------------------------------- */
+
+/** Create a new byte string by converting a Unicode string, using a specific
+ text encoding.
+
+ The lengths of the byte string and the Unicode string may differ (e.g.,
+ for double-byte encodings, UTF-7, UTF-8).
+
+ If the length of the Unicode string is greater than zero, the reference
+ count of the new string will be 1.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a Unicode character array. Need not be null-terminated, but must be at
+ least as long as the specified len.
+
+ @param len
+ the length of the Unicode character array.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OUSTRING_TO_OSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString2String(
+ rtl_String ** newStr, const sal_Unicode * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
+
+/**
+ Converts a Unicode string to a byte string, signalling failure.
+
+ @param pTarget
+ An out parameter receiving the converted string. Must not be null itself, and
+ must contain either null or a pointer to a valid rtl_String; the contents are
+ not modified if conversion fails (rtl_convertUStringToString returns false).
+
+ @param pSource
+ The Unicode string. May only be null if nLength is zero.
+
+ @param nLength
+ The length of the Unicode string. Must be non-negative.
+
+ @param nEncoding
+ The text encoding to convert into. Must be an octet encoding (i.e.,
+ rtl_isOctetTextEncoding(nEncoding) must return true).
+
+ @param nFlags
+ A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the conversion
+ (see rtl_convertUnicodeToText). RTL_UNICODETOTEXT_FLAGS_FLUSH need not be
+ included, it is implicitly assumed. Typical uses are either
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot be
+ converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS (make a
+ best efforts conversion).
+
+ @return
+ True if the conversion succeeded, false otherwise.
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertUStringToString(
+ rtl_String ** pTarget,
+ sal_Unicode const * pSource,
+ sal_Int32 nLength,
+ rtl_TextEncoding nEncoding,
+ sal_uInt32 nFlags)
+ SAL_THROW_EXTERN_C();
+
+/** Ensure a string has enough space for a given number of characters.
+
+ If the given string is large enough and has refcount of 1, it is not altered in any way.
+ Otherwise it is replaced by a copy that has enough space for the given number of characters,
+ data from the source string is copied to the beginning of it, the content of the remaining
+ capacity undefined, the string has refcount of 1, and refcount of the original string is decreased.
+
+ @param str
+ pointer to the string. The pointed-to data must be a valid string.
+
+ @param size
+ the number of characters
+
+ @since LibreOffice 4.1
+ @internal
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_ensureCapacity( rtl_String ** str, sal_Int32 size ) SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_STRING_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
new file mode 100644
index 000000000000..e3d5afbc895a
--- /dev/null
+++ b/include/rtl/string.hxx
@@ -0,0 +1,1709 @@
+/* -*- 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 _RTL_STRING_HXX_
+#define _RTL_STRING_HXX_
+
+#include "sal/config.h"
+
+#include <cassert>
+#include <ostream>
+#include <string.h>
+
+#include <osl/diagnose.h>
+#include <rtl/textenc.h>
+#include <rtl/string.h>
+#include <rtl/stringutils.hxx>
+
+#ifdef RTL_FAST_STRING
+#include <rtl/stringconcat.hxx>
+#endif
+
+#include "sal/log.hxx"
+
+#if !defined EXCEPTIONS_OFF
+#include <new>
+#endif
+
+// The unittest uses slightly different code to help check that the proper
+// calls are made. The class is put into a different namespace to make
+// sure the compiler generates a different (if generating also non-inline)
+// copy of the function and does not merge them together. The class
+// is "brought" into the proper rtl namespace by a typedef below.
+#ifdef RTL_STRING_UNITTEST
+#define rtl rtlunittest
+#endif
+
+namespace rtl
+{
+
+#ifdef RTL_STRING_UNITTEST
+#undef rtl
+// helper macro to make functions appear more readable
+#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
+#else
+#define RTL_STRING_CONST_FUNCTION
+#endif
+
+/* ======================================================================= */
+
+/**
+ This String class provide base functionality for C++ like 8-Bit
+ character array handling. The advantage of this class is, that it
+ handle all the memory managament for you - and it do it
+ more efficient. If you assign a string to another string, the
+ data of both strings are shared (without any copy operation or
+ memory allocation) as long as you do not change the string. This class
+ stores also the length of the string, so that many operations are
+ faster as the C-str-functions.
+
+ This class provide only readonly string handling. So you could create
+ a string and you could only query the content from this string.
+ It provide also functionality to change the string, but this results
+ in every case in a new string instance (in the most cases with an
+ memory allocation). You don't have functionality to change the
+ content of the string. If you want change the string content, than
+ you should us the OStringBuffer class, which provide these
+ functionality and avoid to much memory allocation.
+
+ The design of this class is similar to the string classes in Java
+ and so more people should have fewer understanding problems when they
+ use this class.
+*/
+
+class SAL_WARN_UNUSED OString
+{
+public:
+ /// @cond INTERNAL
+ rtl_String * pData;
+ /// @endcond
+
+private:
+ class DO_NOT_ACQUIRE;
+
+ OString( rtl_String * value, SAL_UNUSED_PARAMETER DO_NOT_ACQUIRE * )
+ {
+ pData = value;
+ }
+
+public:
+ /**
+ New string containing no characters.
+ */
+ OString() SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_new( &pData );
+ }
+
+ /**
+ New string from OString.
+
+ @param str a OString.
+ */
+ OString( const OString & str ) SAL_THROW(())
+ {
+ pData = str.pData;
+ rtl_string_acquire( pData );
+ }
+
+ /**
+ New string from OString data.
+
+ @param str a OString data.
+ */
+ OString( rtl_String * str ) SAL_THROW(())
+ {
+ pData = str;
+ rtl_string_acquire( pData );
+ }
+
+ /** New string from OString data without acquiring it. Takeover of ownership.
+
+ The SAL_NO_ACQUIRE dummy parameter is only there to distinguish this
+ from other constructors.
+
+ @param str a OString data.
+ */
+ inline OString( rtl_String * str, __sal_NoAcquire ) SAL_THROW(())
+ {
+ pData = str;
+ }
+
+ /**
+ New string from a single character.
+
+ @param value a character.
+ */
+ explicit OString( sal_Char value ) SAL_THROW(())
+ : pData (0)
+ {
+ rtl_string_newFromStr_WithLength( &pData, &value, 1 );
+ }
+
+ /**
+ New string from a character buffer array.
+
+ Note: The argument type is always either char* or const char*. The template is
+ used only for technical reasons, as is the second argument.
+
+ @param value a NULL-terminated character array.
+ */
+ template< typename T >
+ OString( const T& value, typename internal::CharPtrDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_newFromStr( &pData, value );
+ }
+
+ template< typename T >
+ OString( T& value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_newFromStr( &pData, value );
+ }
+
+ /**
+ New string from a string literal.
+
+ If there are any embedded \0's in the string literal, the result is undefined.
+ Use the overload that explicitly accepts length.
+
+ @since LibreOffice 3.6
+
+ @param literal a string literal
+ */
+ template< typename T >
+ OString( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ pData = 0;
+ if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
+ rtl_string_new( &pData );
+ else
+ rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+#ifdef RTL_STRING_UNITTEST
+ rtl_string_unittest_const_literal = true;
+#endif
+ }
+
+ /**
+ New string from a character buffer array.
+
+ @param value a character array.
+ @param length the number of character which should be copied.
+ The character array length must be greater or
+ equal than this value.
+ */
+ OString( const sal_Char * value, sal_Int32 length ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_newFromStr_WithLength( &pData, value, length );
+ }
+
+ /**
+ New string from a Unicode character buffer array.
+
+ @param value a Unicode character array.
+ @param length the number of character which should be converted.
+ The Unicode character array length must be
+ greater or equal than this value.
+ @param encoding the text encoding in which the Unicode character
+ sequence should be converted.
+ @param convertFlags flags which controls the conversion.
+ see RTL_UNICODETOTEXT_FLAGS_...
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+ */
+ OString( const sal_Unicode * value, sal_Int32 length,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
+ {
+ pData = 0;
+ rtl_uString2String( &pData, value, length, encoding, convertFlags );
+ if (pData == 0) {
+#if defined EXCEPTIONS_OFF
+ abort();
+#else
+ throw std::bad_alloc();
+#endif
+ }
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OString( const OStringConcat< T1, T2 >& c )
+ {
+ const sal_Int32 l = c.length();
+ pData = rtl_string_alloc( l );
+ if (l != 0)
+ {
+ char* end = c.addData( pData->buffer );
+ pData->length = end - pData->buffer;
+ *end = '\0';
+ }
+ }
+#endif
+
+ /**
+ Release the string data.
+ */
+ ~OString() SAL_THROW(())
+ {
+ rtl_string_release( pData );
+ }
+
+ /**
+ Assign a new string.
+
+ @param str a OString.
+ */
+ OString & operator=( const OString & str ) SAL_THROW(())
+ {
+ rtl_string_assign( &pData, str.pData );
+ return *this;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, OString& >::Type operator=( T& literal ) SAL_THROW(())
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
+ rtl_string_new( &pData );
+ else
+ rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+ return *this;
+ }
+
+ /**
+ Append a string to this string.
+
+ @param str a OString.
+ */
+ OString & operator+=( const OString & str ) SAL_THROW(())
+ {
+ rtl_string_newConcat( &pData, pData, str.pData );
+ return *this;
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OString& operator+=( const OStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_string_ensureCapacity( &pData, pData->length + l );
+ char* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+ /**
+ Returns the length of this string.
+
+ The length is equal to the number of characters in this string.
+
+ @return the length of the sequence of characters represented by this
+ object.
+ */
+ sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
+
+ /**
+ Checks if a string is empty.
+
+ @return true if the string is empty;
+ false, otherwise.
+
+ @since LibreOffice 3.4
+ */
+ bool isEmpty() const SAL_THROW(())
+ {
+ return pData->length == 0;
+ }
+
+ /**
+ Returns a pointer to the characters of this string.
+
+ <p>The returned pointer is guaranteed to point to a null-terminated byte
+ string. But note that this string object may contain embedded null
+ characters, which will thus also be embedded in the returned
+ null-terminated byte string.</p>
+
+ @return a pointer to a null-terminated byte string representing the
+ characters of this string object.
+ */
+ const sal_Char * getStr() const SAL_THROW(()) { return pData->buffer; }
+
+ /**
+ Access to individual characters.
+
+ @param index must be non-negative and less than length.
+
+ @return the character at the given index.
+
+ @since LibreOffice 3.5
+ */
+ sal_Char operator [](sal_Int32 index) const {
+ assert(index >= 0 && index <= getLength());
+ //TODO: should really check for < getLength(), but there is quite
+ // some clever code out there that violates this function's
+ // documented precondition and relies on s[s.getLength()] == 0 and
+ // that would need to be fixed first
+ return getStr()[index];
+ }
+
+ /**
+ Compares two strings.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OString & str ) const SAL_THROW(())
+ {
+ return rtl_str_compare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Compares two strings with an maximum count of characters.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param rObj the object to be compared.
+ @param maxLength the maximum count of characters to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const SAL_THROW(())
+ {
+ return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
+ rObj.pData->buffer, rObj.pData->length, maxLength );
+ }
+
+ /**
+ Compares two strings in reverse order.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 reverseCompareTo( const OString & str ) const SAL_THROW(())
+ {
+ return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equals( const OString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ The ASCII string must be NULL-terminated and must be greater or
+ equal as length.
+ This function can't be used for language specific comparison.
+
+
+ @param value a character array.
+ @param length the length of the character array.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsL( const sal_Char* value, sal_Int32 length ) const SAL_THROW(())
+ {
+ if ( pData->length != length )
+ return sal_False;
+
+ return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
+ value, length ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCase( const OString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific comparison.
+
+ Note: The argument type is always either char* or const char*, the return type is bool.
+ The template is used only for technical reasons.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ template< typename T >
+ typename internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase( const T& asciiStr ) const SAL_THROW(())
+ {
+ return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
+ }
+
+ template< typename T >
+ typename internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& asciiStr ) const SAL_THROW(())
+ {
+ return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const SAL_THROW(())
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ if ( pData->length != internal::ConstCharArrayDetector< T, void >::size - 1 )
+ return false;
+ return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be greater or equal in length as asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ if ( pData->length != asciiStrLength )
+ return sal_False;
+
+ return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ asciiStr, asciiStrLength ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool match( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length, str.pData->length ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_str_shortenedCompare_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex,
+ literal, internal::ConstCharArrayDetector< T, void >::size - 1, internal::ConstCharArrayDetector< T, void >::size - 1) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ @param str the substring to be compared; must not be null and must point
+ to memory of at least strLength bytes
+
+ @param strLength the length of the substring; must be non-negative
+
+ @param fromIndex the index into this string to start the comparison at;
+ must be non-negative and not greater than this string's length
+
+ @return true if and only if the given str is contained as a substring of
+ this string at the given fromIndex
+
+ @since LibreOffice 3.6
+ */
+ bool matchL(
+ char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
+ const
+ {
+ return rtl_str_shortenedCompare_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex,
+ str, strLength, strLength) == 0;
+ }
+
+ // This overload is left undefined, to detect calls of matchL that
+ // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
+ // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
+ // platforms):
+#if SAL_TYPES_SIZEOFLONG == 8
+ void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
+#endif
+
+ /**
+ Match against a substring appearing in this string, ignoring the case of
+ ASCII letters.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length,
+ str.pData->length ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ literal, internal::ConstCharArrayDetector< T, void >::size - 1, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ }
+
+ /**
+ Check whether this string starts with a given substring.
+
+ @param str the substring to be compared
+
+ @return true if and only if the given str appears as a substring at the
+ start of this string
+
+ @since LibreOffice 4.0
+ */
+ bool startsWith(OString const & str) const {
+ return match(str, 0);
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 4.0
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type startsWith( T& literal ) const
+ {
+ RTL_STRING_CONST_FUNCTION
+ return match(literal, 0);
+ }
+
+ /**
+ Check whether this string ends with a given substring.
+
+ @param str the substring to be compared
+
+ @return true if and only if the given str appears as a substring at the
+ end of this string
+
+ @since LibreOffice 3.6
+ */
+ bool endsWith(OString const & str) const {
+ return str.getLength() <= getLength()
+ && match(str, getLength() - str.getLength());
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type endsWith( T& literal ) const
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return internal::ConstCharArrayDetector< T, void >::size - 1 <= getLength()
+ && match(literal, getLength() - ( internal::ConstCharArrayDetector< T, void >::size - 1 ));
+ }
+
+ /**
+ Check whether this string ends with a given substring.
+
+ @param str the substring to be compared; must not be null and must point
+ to memory of at least strLength bytes
+
+ @param strLength the length of the substring; must be non-negative
+
+ @return true if and only if the given str appears as a substring at the
+ end of this string
+
+ @since LibreOffice 3.6
+ */
+ bool endsWithL(char const * str, sal_Int32 strLength) const {
+ return strLength <= getLength()
+ && matchL(str, strLength, getLength() - strLength);
+ }
+
+ friend sal_Bool operator == ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.equals(rStr2); }
+ friend sal_Bool operator != ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, rStr2 )); }
+ friend sal_Bool operator < ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) < 0; }
+ friend sal_Bool operator > ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) > 0; }
+ friend sal_Bool operator <= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) <= 0; }
+ friend sal_Bool operator >= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) >= 0; }
+
+ template< typename T >
+ friend typename internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value ) SAL_THROW(())
+ {
+ return rStr1.compareTo( value ) == 0;
+ }
+
+ template< typename T >
+ friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr1, T& value ) SAL_THROW(())
+ {
+ return rStr1.compareTo( value ) == 0;
+ }
+
+ template< typename T >
+ friend typename internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 ) SAL_THROW(())
+ {
+ return rStr2.compareTo( value ) == 0;
+ }
+
+ template< typename T >
+ friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator==( T& value, const OString& rStr2 ) SAL_THROW(())
+ {
+ return rStr2.compareTo( value ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend typename internal::ConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr, T& literal ) SAL_THROW(())
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rStr.getLength() == internal::ConstCharArrayDetector< T, void >::size - 1
+ && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend typename internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OString& rStr ) SAL_THROW(())
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rStr.getLength() == internal::ConstCharArrayDetector< T, void >::size - 1
+ && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ }
+
+ template< typename T >
+ friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value ) SAL_THROW(())
+ {
+ return !(operator == ( rStr1, value ));
+ }
+
+ template< typename T >
+ friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr1, T& value ) SAL_THROW(())
+ {
+ return !(operator == ( rStr1, value ));
+ }
+
+ template< typename T >
+ friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 ) SAL_THROW(())
+ {
+ return !(operator == ( value, rStr2 ));
+ }
+
+ template< typename T >
+ friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator!=( T& value, const OString& rStr2 ) SAL_THROW(())
+ {
+ return !(operator == ( value, rStr2 ));
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr, T& literal ) SAL_THROW(())
+ {
+ return !( rStr == literal );
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OString& rStr ) SAL_THROW(())
+ {
+ return !( literal == rStr );
+ }
+
+ /**
+ Returns a hashcode for this string.
+
+ @return a hash code value for this object.
+
+ @see rtl::OStringHash for convenient use of boost::unordered_map
+ */
+ sal_Int32 hashCode() const SAL_THROW(())
+ {
+ return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified character, starting the search at the specified index.
+
+ @param ch character to be located.
+ @param fromIndex the index to start the search from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return the index of the first occurrence of the character in the
+ character sequence represented by this string that is
+ greater than or equal to fromIndex, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting at the end.
+
+ @param ch character to be located.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 lastIndexOf( sal_Char ch ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting before the specified
+ index.
+
+ @param ch character to be located.
+ @param fromIndex the index before which to start the search.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string that
+ is less than fromIndex, or -1
+ if the character does not occur before that point.
+ */
+ sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified substring, starting at the specified index.
+
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index to start the search from.
+ @return If the string argument occurs one or more times as a substring
+ within this string at the starting index, then the index
+ of the first character of the first such substring is
+ returned. If it does not occur as a substring starting
+ at fromIndex or beyond, -1 is returned.
+ */
+ sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ RTL_STRING_CONST_FUNCTION
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ sal_Int32 n = rtl_str_indexOfStr_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
+ return n < 0 ? n : n + fromIndex;
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified substring, starting at the specified index.
+
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param len the length of the substring.
+ @param fromIndex the index to start the search from.
+ @return If the string argument occurs one or more times as a substring
+ within this string at the starting index, then the index
+ of the first character of the first such substring is
+ returned. If it does not occur as a substring starting
+ at fromIndex or beyond, -1 is returned.
+
+ @since LibreOffice 3.6
+ */
+ sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
+ const SAL_THROW(())
+ {
+ sal_Int32 n = rtl_str_indexOfStr_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex, str, len);
+ return n < 0 ? n : n + fromIndex;
+ }
+
+ // This overload is left undefined, to detect calls of indexOfL that
+ // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
+ // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
+ // platforms):
+#if SAL_TYPES_SIZEOFLONG == 8
+ void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
+#endif
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting at the end.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @return If the string argument occurs one or more times as a substring
+ within this string, then the index of the first character of
+ the last such substring is returned. If it does not occur as
+ a substring, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OString & str ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting before the specified
+ index.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index before which to start the search.
+ @return If the string argument occurs one or more times as a substring
+ within this string before the starting index, then the index
+ of the first character of the last such substring is
+ returned. Otherwise, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex. If
+ beginIndex is negative or be greater than the length of
+ this string, behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @return the specified substring.
+ */
+ SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const SAL_THROW(())
+ {
+ rtl_String *pNew = 0;
+ rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. If either beginIndex or count are negative,
+ or beginIndex + count are greater than the length of this string
+ then behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @param count the number of characters.
+ @return the specified substring.
+ */
+ SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
+ {
+ rtl_String *pNew = 0;
+ rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Concatenates the specified string to the end of this string.
+
+ @param str the string that is concatenated to the end
+ of this string.
+ @return a string that represents the concatenation of this string
+ followed by the string argument.
+ */
+ SAL_WARN_UNUSED_RESULT OString concat( const OString & str ) const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newConcat( &pNew, pData, str.pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+#ifndef RTL_FAST_STRING
+ friend OString operator+( const OString & str1, const OString & str2 ) SAL_THROW(())
+ {
+ return str1.concat( str2 );
+ }
+#endif
+
+ /**
+ Returns a new string resulting from replacing n = count characters
+ from position index in this string with newStr.
+
+ @param index the replacing index in str.
+ The index must be greater or equal as 0 and
+ less or equal as the length of the string.
+ @param count the count of characters that will replaced
+ The count must be greater or equal as 0 and
+ less or equal as the length of the string minus index.
+ @param newStr the new substring.
+ @return the new string.
+ */
+ SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of
+ oldChar in this string with newChar.
+
+ If the character oldChar does not occur in the character sequence
+ represented by this object, then the string is assigned with
+ str.
+
+ @param oldChar the old character.
+ @param newChar the new character.
+ @return a string derived from this string by replacing every
+ occurrence of oldChar with newChar.
+ */
+ SAL_WARN_UNUSED_RESULT OString replace( sal_Char oldChar, sal_Char newChar ) const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newReplace( &pNew, pData, oldChar, newChar );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from replacing the first occurrence of a
+ given substring with another substring.
+
+ @param from the substring to be replaced
+
+ @param to the replacing substring
+
+ @param[in,out] index pointer to a start index; if the pointer is
+ non-null: upon entry to the function, its value is the index into the this
+ string at which to start searching for the \p from substring, the value
+ must be non-negative and not greater than this string's length; upon exit
+ from the function its value is the index into this string at which the
+ replacement took place or -1 if no replacement took place; if the pointer
+ is null, searching always starts at index 0
+
+ @since LibreOffice 3.6
+ */
+ SAL_WARN_UNUSED_RESULT OString replaceFirst(
+ OString const & from, OString const & to, sal_Int32 * index = 0) const
+ {
+ rtl_String * s = 0;
+ sal_Int32 i = 0;
+ rtl_string_newReplaceFirst(
+ &s, pData, from.pData->buffer, from.pData->length,
+ to.pData->buffer, to.pData->length, index == 0 ? &i : index);
+ return OString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of a given
+ substring with another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param from the substring to be replaced
+
+ @param to the replacing substring
+
+ @since LibreOffice 3.6
+ */
+ SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
+ rtl_String * s = 0;
+ rtl_string_newReplaceAll(
+ &s, pData, from.pData->buffer, from.pData->length,
+ to.pData->buffer, to.pData->length);
+ return OString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Converts from this string all ASCII uppercase characters (65-90)
+ to ASCII lowercase characters (97-122).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII lowercase.
+ */
+ SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newToAsciiLowerCase( &pNew, pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Converts from this string all ASCII lowercase characters (97-122)
+ to ASCII uppercase characters (65-90).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII uppercase.
+ */
+ SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newToAsciiUpperCase( &pNew, pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from removing white space from both ends
+ of the string.
+
+ All characters that have codes less than or equal to
+ 32 (the space character) are considered to be white space.
+ If the string doesn't contain white spaces at both ends,
+ then the new string is assigned with str.
+
+ @return the string, with white space removed from the front and end.
+ */
+ SAL_WARN_UNUSED_RESULT OString trim() const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newTrim( &pNew, pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a token in the string.
+
+ Example:
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ OString aToken = aStr.getToken( 0, ';', nIndex );
+ ...
+ }
+ while ( nIndex >= 0 );
+
+ @param token the number of the token to return.
+ @param cTok the character which seperate the tokens.
+ @param index the position at which the token is searched in the
+ string.
+ The index must not be greater thanthe length of the
+ string.
+ This param is set to the position of the
+ next token or to -1, if it is the last token.
+ @return the token; if either token or index is negative, an empty token
+ is returned (and index is set to -1)
+ */
+ OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const SAL_THROW(())
+ {
+ rtl_String * pNew = 0;
+ index = rtl_string_getToken( &pNew, pData, token, cTok, index );
+ return OString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Returns a token from the string.
+
+ The same as getToken(sal_Int32, sal_Char, sal_Int32 &), but always passing
+ in 0 as the start index in the third argument.
+
+ @param count the number of the token to return, starting with 0
+ @param separator the character which separates the tokens
+
+ @return the given token, or an empty string
+
+ @since LibreOffice 3.6
+ */
+ OString getToken(sal_Int32 count, char separator) const {
+ sal_Int32 n = 0;
+ return getToken(count, separator, n);
+ }
+
+ /**
+ Returns the Boolean value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return sal_True, if the string is 1 or "True" in any ASCII case.
+ sal_False in any other case.
+ */
+ sal_Bool toBoolean() const SAL_THROW(())
+ {
+ return rtl_str_toBoolean( pData->buffer );
+ }
+
+ /**
+ Returns the first character from this string.
+
+ @return the first character from this string or 0, if this string
+ is emptry.
+ */
+ sal_Char toChar() const SAL_THROW(())
+ {
+ return pData->buffer[0];
+ }
+
+ /**
+ Returns the int32 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int32 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+ */
+ sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_str_toInt32( pData->buffer, radix );
+ }
+
+ /**
+ Returns the int64 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int64 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+ */
+ sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_str_toInt64( pData->buffer, radix );
+ }
+
+ /**
+ Returns the uint64 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the uint64 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+
+ @since LibreOffice 4.1
+ */
+ sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_str_toUInt64( pData->buffer, radix );
+ }
+
+ /**
+ Returns the float value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the float represented from this string.
+ 0.0 if this string represents no number.
+ */
+ float toFloat() const SAL_THROW(())
+ {
+ return rtl_str_toFloat( pData->buffer );
+ }
+
+ /**
+ Returns the double value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the double represented from this string.
+ 0.0 if this string represents no number.
+ */
+ double toDouble() const SAL_THROW(())
+ {
+ return rtl_str_toDouble( pData->buffer );
+ }
+
+ /**
+ Returns the string representation of the integer argument.
+
+ This function can't be used for language specific conversion.
+
+ @param i an integer value
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OString number( int i, sal_Int16 radix = 10 )
+ {
+ return number( static_cast< long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OString number( unsigned int i, sal_Int16 radix = 10 )
+ {
+ return number( static_cast< unsigned long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OString number( long i, sal_Int16 radix = 10 )
+ {
+ return number( static_cast< long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OString number( unsigned long i, sal_Int16 radix = 10 )
+ {
+ return number( static_cast< unsigned long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OString number( long long ll, sal_Int16 radix = 10 )
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OString number( unsigned long long ll, sal_Int16 radix = 10 )
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFUINT64];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the float argument.
+
+ This function can't be used for language specific conversion.
+
+ @param f a float.
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OString number( float f )
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFFLOAT];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the double argument.
+
+ This function can't be used for language specific conversion.
+
+ @param d a double.
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OString number( double d )
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFDOUBLE];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the sal_Bool argument.
+
+ If the sal_Bool is true, the string "true" is returned.
+ If the sal_Bool is false, the string "false" is returned.
+ This function can't be used for language specific conversion.
+
+ @param b a sal_Bool.
+ @return a string with the string representation of the argument.
+ @deprecated use boolean()
+ */
+ SAL_DEPRECATED_INTERNAL("use boolean()") static OString valueOf( sal_Bool b ) SAL_THROW(())
+ {
+ return boolean(b);
+ }
+
+ /**
+ Returns the string representation of the boolean argument.
+
+ If the argument is true, the string "true" is returned.
+ If the argument is false, the string "false" is returned.
+ This function can't be used for language specific conversion.
+
+ @param b a bool.
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OString boolean( bool b ) SAL_THROW(())
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the char argument.
+
+ @param c a character.
+ @return a string with the string representation of the argument.
+ @deprecated use operator, function or constructor taking char or sal_Unicode argument
+ */
+ SAL_DEPRECATED_INTERNAL("convert to OString or use directly") static OString valueOf( sal_Char c ) SAL_THROW(())
+ {
+ return OString( &c, 1 );
+ }
+
+ /**
+ Returns the string representation of the int argument.
+
+ This function can't be used for language specific conversion.
+
+ @param i a int32.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ return number( i, radix );
+ }
+
+ /**
+ Returns the string representation of the long argument.
+
+ This function can't be used for language specific conversion.
+
+ @param ll a int64.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ return number( ll, radix );
+ }
+
+ /**
+ Returns the string representation of the float argument.
+
+ This function can't be used for language specific conversion.
+
+ @param f a float.
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( float f ) SAL_THROW(())
+ {
+ return number(f);
+ }
+
+ /**
+ Returns the string representation of the double argument.
+
+ This function can't be used for language specific conversion.
+
+ @param d a double.
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( double d ) SAL_THROW(())
+ {
+ return number(d);
+ }
+
+};
+
+/* ======================================================================= */
+
+#ifdef RTL_FAST_STRING
+/**
+A simple wrapper around string literal. It is usually not necessary to use, can
+be mostly used to force OString operator+ working with operands that otherwise would
+not trigger it.
+
+This class is not part of public API and is meant to be used only in LibreOffice code.
+@since LibreOffice 4.0
+*/
+struct SAL_WARN_UNUSED OStringLiteral
+{
+ template< int N >
+ OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
+ int size;
+ const char* data;
+};
+
+/**
+ @internal
+*/
+template<>
+struct ToStringHelper< OString >
+ {
+ static int length( const OString& s ) { return s.getLength(); }
+ static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+
+/**
+ @internal
+*/
+template<>
+struct ToStringHelper< OStringLiteral >
+ {
+ static int length( const OStringLiteral& str ) { return str.size; }
+ static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+
+/**
+ @internal
+*/
+template< typename charT, typename traits, typename T1, typename T2 >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
+{
+ return stream << OString( concat );
+}
+#else
+// non-RTL_FAST_CODE needs this to compile
+typedef OString OStringLiteral;
+#endif
+
+
+/** A helper to use OStrings with hash maps.
+
+ Instances of this class are unary function objects that can be used as
+ hash function arguments to boost::unordered_map and similar constructs.
+ */
+struct OStringHash
+{
+ /** Compute a hash code for a string.
+
+ @param rString
+ a string.
+
+ @return
+ a hash code for the string. This hash code should not be stored
+ persistently, as its computation may change in later revisions.
+ */
+ size_t operator()( const OString& rString ) const
+ { return (size_t)rString.hashCode(); }
+};
+
+/* ======================================================================= */
+
+/**
+ Support for rtl::OString in std::ostream (and thus in
+ CPPUNIT_ASSERT or SAL_INFO macros, for example).
+
+ @since LibreOffice 4.0
+ */
+template< typename charT, typename traits > std::basic_ostream<charT, traits> &
+operator <<(
+ std::basic_ostream<charT, traits> & stream, OString const & string)
+{
+ return stream << string.getStr();
+ // best effort; potentially loses data due to embedded null characters
+}
+
+} /* Namespace */
+
+#ifdef RTL_STRING_UNITTEST
+namespace rtl
+{
+typedef rtlunittest::OString OString;
+}
+#undef RTL_STRING_CONST_FUNCTION
+#endif
+
+#ifdef RTL_USING
+using ::rtl::OString;
+using ::rtl::OStringHash;
+using ::rtl::OStringLiteral;
+#endif
+
+#endif /* _RTL_STRING_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
new file mode 100644
index 000000000000..a6e3467209e3
--- /dev/null
+++ b/include/rtl/stringconcat.hxx
@@ -0,0 +1,284 @@
+/* -*- 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/.
+ */
+
+#ifndef RTL_STRINGCONCAT_HXX
+#define RTL_STRINGCONCAT_HXX
+
+#include <rtl/stringutils.hxx>
+
+#include <string.h>
+
+#ifdef RTL_FAST_STRING
+
+#ifdef RTL_STRING_UNITTEST
+#define rtl rtlunittest
+#endif
+namespace rtl
+{
+#ifdef RTL_STRING_UNITTEST
+#undef rtl
+#endif
+
+/*
+Implementation of efficient string concatenation.
+
+The whole system is built around two basic template classes:
+- ToStringHelper< T > - for each T it can give the length of the resulting string representation and can write
+ this string representation to a buffer
+- O(U)StringConcat< T1, T2 > - operator+ now, instead of creating O(U)String object, returns only this helper object,
+ that keeps a reference to both operator+ operands; only when converted to O(U)String it will actually create
+ the resulting string object using ToStringHelper, creating directly the resulting object without any string
+ intermediate objects
+As all the code is inline methods, it allows for extensive optimization and will usually result in very effective code
+(even surpassing strlen/strcat and equalling handwritten), while allowing for very easy and intuitive syntax.
+*/
+
+/**
+@internal
+
+Helper class for converting a given type to a string representation.
+*/
+template< typename T >
+struct ToStringHelper
+ {
+ /// Return length of the string representation of the given object (if not known exactly, it needs to be the maximum).
+ static int length( const T& );
+ /// Add 8-bit representation of the given object to the given buffer and return position right after the added data.
+ static char* addData( char* buffer, const T& );
+ /// Add Unicode representation of the given object to the given buffer and return position right after the added data.
+ static sal_Unicode* addData( sal_Unicode* buffer, const T& );
+ /// If true, T can be used in concatenation resulting in OString.
+ static const bool allowOStringConcat = false;
+ /// If true, T can be used in concatenation resulting in OUString.
+ static const bool allowOUStringConcat = false;
+ };
+
+inline
+char* addDataHelper( char* buffer, const char* data, int length )
+ {
+ memcpy( buffer, data, length );
+ return buffer + length;
+ }
+
+inline
+sal_Unicode* addDataHelper( sal_Unicode* buffer, const sal_Unicode* data, int length )
+ {
+ memcpy( buffer, data, length * sizeof( sal_Unicode ));
+ return buffer + length;
+ }
+
+inline
+sal_Unicode* addDataLiteral( sal_Unicode* buffer, const char* data, int length )
+ {
+ while( length-- > 0 )
+ *buffer++ = *data++;
+ return buffer;
+ }
+
+inline
+char* addDataCString( char* buffer, const char* str )
+ {
+ while( *str != '\0' )
+ *buffer++ = *str++;
+ return buffer;
+ }
+
+inline
+sal_Unicode* addDataUString( sal_Unicode* buffer, const sal_Unicode* str )
+ {
+ while( *str != '\0' )
+ *buffer++ = *str++;
+ return buffer;
+ }
+
+template<>
+struct ToStringHelper< const char* >
+ {
+ static int length( const char* str ) {
+ return sal::static_int_cast<int>(strlen( str ));
+ }
+ static char* addData( char* buffer, const char* str ) { return addDataCString( buffer, str ); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+
+template<>
+struct ToStringHelper< char* >
+ {
+ static int length( const char* str ) {
+ return sal::static_int_cast<int>(strlen( str ));
+ }
+ static char* addData( char* buffer, const char* str ) { return addDataCString( buffer, str ); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+
+template< int N >
+struct ToStringHelper< char[ N ] >
+ {
+ static int length( const char str[ N ] ) {
+ return sal::static_int_cast<int>(strlen( str ));
+ }
+ static char* addData( char* buffer, const char str[ N ] ) { return addDataCString( buffer, str ); }
+ static sal_Unicode* addData( sal_Unicode* buffer, const char str[ N ] ) { return addDataLiteral( buffer, str, N - 1 ); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+
+template< int N >
+struct ToStringHelper< const char[ N ] >
+ {
+ static int length( const char str[ N ] ) { (void)str; assert( strlen( str ) == N - 1 ); return N - 1; }
+ static char* addData( char* buffer, const char str[ N ] ) { return addDataHelper( buffer, str, N - 1 ); }
+ static sal_Unicode* addData( sal_Unicode* buffer, const char str[ N ] ) { return addDataLiteral( buffer, str, N - 1 ); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = true;
+ };
+
+/**
+@internal
+
+Objects returned by operator+, instead of OString. These objects (possibly recursively) keep a representation of the whole
+concatenation operation.
+*/
+template< typename T1, typename T2 >
+struct OStringConcat
+ {
+ public:
+ OStringConcat( const T1& left_, const T2& right_ ) : left( left_ ), right( right_ ) {}
+ int length() const { return ToStringHelper< T1 >::length( left ) + ToStringHelper< T2 >::length( right ); }
+ char* addData( char* buffer ) const { return ToStringHelper< T2 >::addData( ToStringHelper< T1 >::addData( buffer, left ), right ); }
+ // NOTE here could be functions that would forward to the "real" temporary OString. Note however that e.g. getStr()
+ // is not so simple, as the OString temporary must live long enough (i.e. can't be created here in a function, a wrapper
+ // temporary object containing it must be returned instead).
+ private:
+ const T1& left;
+ const T2& right;
+ };
+
+/**
+@internal
+
+Objects returned by operator+, instead of OUString. These objects (possibly recursively) keep a representation of the whole
+concatenation operation.
+*/
+template< typename T1, typename T2 >
+struct OUStringConcat
+ {
+ public:
+ OUStringConcat( const T1& left_, const T2& right_ ) : left( left_ ), right( right_ ) {}
+ int length() const { return ToStringHelper< T1 >::length( left ) + ToStringHelper< T2 >::length( right ); }
+ sal_Unicode* addData( sal_Unicode* buffer ) const { return ToStringHelper< T2 >::addData( ToStringHelper< T1 >::addData( buffer, left ), right ); }
+ private:
+ const T1& left;
+ const T2& right;
+ };
+
+template< typename T1, typename T2 >
+struct ToStringHelper< OStringConcat< T1, T2 > >
+ {
+ static int length( const OStringConcat< T1, T2 >& c ) { return c.length(); }
+ static char* addData( char* buffer, const OStringConcat< T1, T2 >& c ) { return c.addData( buffer ); }
+ static const bool allowOStringConcat = ToStringHelper< T1 >::allowOStringConcat && ToStringHelper< T2 >::allowOStringConcat;
+ static const bool allowOUStringConcat = false;
+ };
+
+template< typename T1, typename T2 >
+struct ToStringHelper< OUStringConcat< T1, T2 > >
+ {
+ static int length( const OUStringConcat< T1, T2 >& c ) { return c.length(); }
+ static sal_Unicode* addData( sal_Unicode* buffer, const OUStringConcat< T1, T2 >& c ) { return c.addData( buffer ); }
+ static const bool allowOStringConcat = false;
+ static const bool allowOUStringConcat = ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat;
+ };
+
+template< typename T1, typename T2 >
+inline
+SAL_WARN_UNUSED_RESULT
+typename internal::Enable< OStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOStringConcat && ToStringHelper< T2 >::allowOStringConcat >::Type operator+( const T1& left, const T2& right )
+ {
+ return OStringConcat< T1, T2 >( left, right );
+ }
+
+// char[N] and const char[N] need to be done explicitly, otherwise the compiler likes to treat them the same way for some reason
+template< typename T, int N >
+inline
+SAL_WARN_UNUSED_RESULT
+typename internal::Enable< OStringConcat< T, const char[ N ] >, ToStringHelper< T >::allowOStringConcat >::Type operator+( const T& left, const char (&right)[ N ] )
+ {
+ return OStringConcat< T, const char[ N ] >( left, right );
+ }
+
+template< typename T, int N >
+inline
+SAL_WARN_UNUSED_RESULT
+typename internal::Enable< OStringConcat< const char[ N ], T >, ToStringHelper< T >::allowOStringConcat >::Type operator+( const char (&left)[ N ], const T& right )
+ {
+ return OStringConcat< const char[ N ], T >( left, right );
+ }
+
+template< typename T, int N >
+inline
+SAL_WARN_UNUSED_RESULT
+typename internal::Enable< OStringConcat< T, char[ N ] >, ToStringHelper< T >::allowOStringConcat >::Type operator+( const T& left, char (&right)[ N ] )
+ {
+ return OStringConcat< T, char[ N ] >( left, right );
+ }
+
+template< typename T, int N >
+inline
+SAL_WARN_UNUSED_RESULT
+typename internal::Enable< OStringConcat< char[ N ], T >, ToStringHelper< T >::allowOStringConcat >::Type operator+( char (&left)[ N ], const T& right )
+ {
+ return OStringConcat< char[ N ], T >( left, right );
+ }
+
+template< typename T1, typename T2 >
+inline
+typename internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat >::Type operator+( const T1& left, const T2& right )
+ {
+ return OUStringConcat< T1, T2 >( left, right );
+ }
+
+template< typename T1, typename T2 >
+inline
+typename internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat && internal::ConstCharArrayDetector< T1, void >::ok >::Type operator+( T1& left, const T2& right )
+ {
+ return OUStringConcat< T1, T2 >( left, right );
+ }
+
+template< typename T1, typename T2 >
+inline
+typename internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat && internal::ConstCharArrayDetector< T2, void >::ok >::Type operator+( const T1& left, T2& right )
+ {
+ return OUStringConcat< T1, T2 >( left, right );
+ }
+
+#ifdef RTL_STRING_UNITTEST_CONCAT
+// Special overload to catch the remaining invalid combinations. The helper struct must
+// be used to make this operator+ overload a worse choice than all the existing overloads above.
+struct StringConcatInvalid
+ {
+ template< typename T >
+ StringConcatInvalid( const T& ) {}
+ };
+template< typename T >
+inline
+int operator+( const StringConcatInvalid&, const T& )
+ {
+ rtl_string_unittest_invalid_concat = true;
+ return 0; // doesn't matter
+ }
+#endif
+
+} // namespace
+
+#endif
+
+#endif
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
new file mode 100644
index 000000000000..fc47a248cde7
--- /dev/null
+++ b/include/rtl/stringutils.hxx
@@ -0,0 +1,187 @@
+/* -*- 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/.
+ */
+
+#ifndef _RTL_STRINGUTILS_HXX_
+#define _RTL_STRINGUTILS_HXX_
+
+#include "sal/config.h"
+
+// Manually defining RTL_DISABLE_FAST_STRING allows to force turning fast string concatenation off
+// (e.g. for debugging).
+#ifndef RTL_DISABLE_FAST_STRING
+// This feature is not part of public API and is meant to be used only internally by LibreOffice.
+#ifdef LIBO_INTERNAL_ONLY
+// Enable fast string concatenation.
+#define RTL_FAST_STRING
+#endif
+#endif
+
+// The unittest uses slightly different code to help check that the proper
+// calls are made. The class is put into a different namespace to make
+// sure the compiler generates a different (if generating also non-inline)
+// copy of the function and does not merge them together. The class
+// is "brought" into the proper rtl namespace by a typedef below.
+#ifdef RTL_STRING_UNITTEST
+#define rtl rtlunittest
+#endif
+
+namespace rtl
+{
+
+#ifdef RTL_STRING_UNITTEST
+#undef rtl
+#endif
+
+namespace internal
+{
+/*
+These templates use SFINAE (Substitution failure is not an error) to help distinguish the various
+plain C string types: char*, const char*, char[N], const char[N], char[] and const char[].
+There are 2 cases:
+1) Only string literal (i.e. const char[N]) is wanted, not any of the others.
+ In this case it is necessary to distinguish between const char[N] and char[N], as the latter
+ would be automatically converted to the const variant, which is not wanted (not a string literal
+ with known size of the content). In this case ConstCharArrayDetector is used to ensure the function
+ is called only with const char[N] arguments. There's no other plain C string type overload.
+2) All plain C string types are wanted, and const char[N] needs to be handled differently.
+ In this case const char[N] would match const char* argument type (not exactly sure why, but it's
+ consistent in all of gcc, clang and msvc). Using a template with a reference to const of the type
+ avoids this problem, and CharPtrDetector ensures that the function is called only with char pointer
+ arguments. The const in the argument is necessary to handle the case when something is explicitly
+ cast to const char*. Additionally (non-const) char[N] needs to be handled, but with the reference
+ being const, it would also match const char[N], so another overload with a reference to non-const
+ and NonConstCharArrayDetector are used to ensure the function is called only with (non-const) char[N].
+Additionally, char[] and const char[] (i.e. size unknown) are rather tricky. Their usage with 'T&' would
+mean it would be 'char(&)[]', which seems to be invalid. But gcc and clang somehow manage when it is
+a template. while msvc complains about no conversion from char[] to char[1]. And the reference cannot
+be avoided, because 'const char[]' as argument type would match also 'const char[N]'
+So char[] and const char[] should always be used with their contents specified (which automatically
+turns them into char[N] or const char[N]), or char* and const char* should be used.
+*/
+struct Dummy {};
+template< typename T1, typename T2 = void >
+struct CharPtrDetector
+{
+ static const bool ok = false;
+};
+template< typename T >
+struct CharPtrDetector< const char*, T >
+{
+ typedef T Type;
+ static const bool ok = true;
+};
+template< typename T >
+struct CharPtrDetector< char*, T >
+{
+ typedef T Type;
+ static const bool ok = true;
+};
+
+template< typename T1, typename T2 >
+struct NonConstCharArrayDetector
+{
+};
+template< typename T, int N >
+struct NonConstCharArrayDetector< char[ N ], T >
+{
+ typedef T Type;
+};
+#ifdef RTL_STRING_UNITTEST
+// never use, until all compilers handle this
+template< typename T >
+struct NonConstCharArrayDetector< char[], T >
+{
+ typedef T Type;
+};
+template< typename T >
+struct NonConstCharArrayDetector< const char[], T >
+{
+ typedef T Type;
+};
+#endif
+
+template< typename T1, typename T2 = void >
+struct ConstCharArrayDetector
+{
+ static const bool ok = false;
+};
+template< int N, typename T >
+struct ConstCharArrayDetector< const char[ N ], T >
+{
+ typedef T Type;
+ static const int size = N;
+ static const bool ok = true;
+};
+
+// this one is used to rule out only const char[N]
+template< typename T >
+struct ExceptConstCharArrayDetector
+{
+ typedef Dummy Type;
+};
+template< int N >
+struct ExceptConstCharArrayDetector< const char[ N ] >
+{
+};
+// this one is used to rule out only const char[N]
+// (const will be brought in by 'const T&' in the function call)
+// msvc needs const char[N] here (not sure whether gcc or msvc
+// are right, it doesn't matter).
+template< typename T >
+struct ExceptCharArrayDetector
+{
+ typedef Dummy Type;
+};
+template< int N >
+struct ExceptCharArrayDetector< char[ N ] >
+{
+};
+template< int N >
+struct ExceptCharArrayDetector< const char[ N ] >
+{
+};
+
+template< typename T1, typename T2 = void >
+struct SalUnicodePtrDetector
+{
+ static const bool ok = false;
+};
+template< typename T >
+struct SalUnicodePtrDetector< const sal_Unicode*, T >
+{
+ typedef T Type;
+ static const bool ok = true;
+};
+template< typename T >
+struct SalUnicodePtrDetector< sal_Unicode*, T >
+{
+ typedef T Type;
+ static const bool ok = true;
+};
+
+// SFINAE helper class
+template< typename T, bool >
+struct Enable
+ {
+ };
+
+template< typename T >
+struct Enable< T, true >
+ {
+ typedef T Type;
+ };
+
+
+} /* Namespace */
+
+} /* Namespace */
+
+#endif /* _RTL_STRINGUTILS_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/tencinfo.h b/include/rtl/tencinfo.h
new file mode 100644
index 000000000000..34ba34f17374
--- /dev/null
+++ b/include/rtl/tencinfo.h
@@ -0,0 +1,278 @@
+/* -*- 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 _RTL_TENCINFO_H
+#define _RTL_TENCINFO_H
+
+#include "sal/config.h"
+
+#include "rtl/textenc.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// See rtl_TextEncodingInfo.Flags below for documentation on these values:
+#define RTL_TEXTENCODING_INFO_CONTEXT ((sal_uInt32)0x00000001)
+#define RTL_TEXTENCODING_INFO_ASCII ((sal_uInt32)0x00000002)
+#define RTL_TEXTENCODING_INFO_UNICODE ((sal_uInt32)0x00000004)
+#define RTL_TEXTENCODING_INFO_MULTIBYTE ((sal_uInt32)0x00000008)
+#define RTL_TEXTENCODING_INFO_R2L ((sal_uInt32)0x00000010)
+#define RTL_TEXTENCODING_INFO_7BIT ((sal_uInt32)0x00000020)
+#define RTL_TEXTENCODING_INFO_SYMBOL ((sal_uInt32)0x00000040)
+#define RTL_TEXTENCODING_INFO_MIME ((sal_uInt32)0x00000080)
+
+/** Information about a text encoding.
+ */
+typedef struct _rtl_TextEncodingInfo
+{
+ /** The size (in bytes) of this structure. Should be 12.
+ */
+ sal_uInt32 StructSize;
+
+ /** The minimum number of bytes needed to encode any character in the
+ given encoding.
+
+ Can be rather meaningless for encodings that encode global state along
+ with the characters (e.g., ISO-2022 encodings).
+ */
+ sal_uInt8 MinimumCharSize;
+
+ /** The maximum number of bytes needed to encode any character in the
+ given encoding.
+
+ Can be rather meaningless for encodings that encode global state along
+ with the characters (e.g., ISO-2022 encodings).
+ */
+ sal_uInt8 MaximumCharSize;
+
+ /** The average number of bytes needed to encode a character in the given
+ encoding.
+ */
+ sal_uInt8 AverageCharSize;
+
+ /** An unused byte, for padding.
+ */
+ sal_uInt8 Reserved;
+
+ /** Any combination of the RTL_TEXTENCODING_INFO flags.
+
+ RTL_TEXTENCODING_INFO_CONTEXT: The encoding uses some mechanism (like
+ state-changing byte sequences) to switch between different modes (e.g.,
+ to encode multiple character repertoires within the same byte ranges).
+
+ Even if an encoding does not have the CONTEXT property, interpretation
+ of certain byte values within that encoding can depend on context (e.g.,
+ a certain byte value could be either a single-byte character or a
+ subsequent byte of a multi-byte character). Likewise, the single shift
+ characters (SS2 and SS3) used by some of the EUC encodings (to denote
+ that the following bytes constitute a character from another character
+ repertoire) do not imply that encodings making use of these characters
+ have the CONTEXT property. Examples of encodings that do have the
+ CONTEXT property are the ISO-2022 encodings and UTF-7.
+
+ RTL_TEXTENCODING_INFO_ASCII: The encoding is a superset of ASCII. More
+ specifically, any appearance of a byte in the range 0x20--7F denotes the
+ corresponding ASCII character (from SPACE to DELETE); in particular,
+ such a byte cannot be part of a multi-byte character. Note that the
+ ASCII control codes 0x00--1F are not included here, as they are used for
+ special purposes in some encodings.
+
+ If an encoding has this property, it is easy to search for occurrences of
+ ASCII characters within strings of this encoding---you do not need to
+ keep track whether a byte in the range 0x20--7F really represents an
+ ASCII character or rather is part of some multi-byte character.
+
+ The guarantees when mapping between Unicode and a given encoding with
+ the ASCII property are as follows: When mapping from Unicode to the
+ given encoding, U+0020--007F map to 0x20--7F (but there can also be
+ other Unicode characters mapping into the range 0x20--7F), and when
+ mapping from the given encoding to Unicode, 0x20--7F map to U+0020--007F
+ (again, there can also be other characters mapping into the range
+ U+0020--007F). In particular, this ensures round-trip conversion for
+ the ASCII range.
+
+ In principle, the ASCII property is orthogonal to the CONTEXT property.
+ In practice, however, an encoding that has the ASCII property will most
+ likely not also have the CONTEXT property.
+
+ RTL_TEXTENCODING_INFO_UNICODE: The encoding is based on the Unicode
+ character repertoire.
+
+ RTL_TEXTENCODING_INFO_MULTIBYTE: A multi-byte encoding.
+
+ RTL_TEXTENCODING_INFO_R2L: An encoding used mainly or exclusively for
+ languages written from right to left.
+
+ RTL_TEXTENCODING_INFO_7BIT: A 7-bit instead of an 8-bit encoding.
+
+ RTL_TEXTENCODING_INFO_SYMBOL: A (generic) encoding for symbol character
+ sets.
+
+ RTL_TEXTENCODING_INFO_MIME: The encoding is registered as a MIME
+ charset.
+ */
+ sal_uInt32 Flags;
+} rtl_TextEncodingInfo;
+
+/** Determine whether a text encoding uses single octets as basic units of
+ information (and can thus be used with the conversion routines in
+ rtl/textcvt.h).
+
+ @param nEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ True if the given encoding uses single octets as basic units of
+ information, false otherwise.
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding);
+
+/** Return information about a text encoding.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @param pEncInfo
+ Returns information about the given encoding. Must not be null, and the
+ StructSize member must be set correctly.
+
+ @return
+ True if information about the given encoding is available, false
+ otherwise.
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_getTextEncodingInfo(
+ rtl_TextEncoding eTextEncoding, rtl_TextEncodingInfo* pEncInfo );
+
+/** Map from a numeric Windows charset to a text encoding.
+
+ @param nWinCharset
+ Any numeric Windows charset.
+
+ @return
+ The corresponding rtl_TextEncoding value, or RTL_TEXTENCODING_DONTKNOW if
+ no mapping is applicable.
+ */
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromWindowsCharset(
+ sal_uInt8 nWinCharset );
+
+/** Map from a MIME charset to a text encoding.
+
+ @param pMimeCharset
+ Any MIME charset string. Must not be null.
+
+ @return
+ The corresponding rtl_TextEncoding value, or RTL_TEXTENCODING_DONTKNOW if
+ no mapping is applicable.
+ */
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset(
+ const sal_Char* pMimeCharset );
+
+/** Map from a Unix charset to a text encoding.
+
+ @param pUnixCharset
+ Any Unix charset string. Must not be null.
+
+ @return
+ The corresponding rtl_TextEncoding value, or RTL_TEXTENCODING_DONTKNOW if
+ no mapping is applicable.
+ */
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset(
+ const sal_Char* pUnixCharset );
+
+/** Map from a text encoding to the best matching numeric Windows charset.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The best matching numeric Windows charset, or 1 if none matches.
+ */
+SAL_DLLPUBLIC sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding(
+ rtl_TextEncoding eTextEncoding );
+
+/** Map from a text encoding to a corresponding MIME charset name, if
+ available (see <http://www.iana.org/assignments/character-sets>).
+
+ @param nEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The (preferred) MIME charset name corresponding to the given encoding, or
+ NULL if none is available.
+ */
+SAL_DLLPUBLIC char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(
+ rtl_TextEncoding nEncoding );
+
+/** Map from a text encoding to the best matching MIME charset.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The best matching MIME charset string, or null if none matches.
+ */
+SAL_DLLPUBLIC const sal_Char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding(
+ rtl_TextEncoding eTextEncoding );
+
+/** Map from a text encoding to the best matching Unix charset.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The best matching Unix charset string, or null if none matches.
+ */
+SAL_DLLPUBLIC const sal_Char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding(
+ rtl_TextEncoding eTextEncoding );
+
+/** Map from a Windows code page to a text encoding.
+
+ @param nCodePage
+ Any Windows code page number.
+
+ @return
+ The corresponding rtl_TextEncoding value (which will be an octet text
+ encoding, see rtl_isOctetTextEncoding), or RTL_TEXTENCODING_DONTKNOW if no
+ mapping is applicable.
+ */
+SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL
+rtl_getTextEncodingFromWindowsCodePage(sal_uInt32 nCodePage);
+
+/** Map from a text encoding to a Windows code page.
+
+ @param nEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The corresponding Windows code page number, or 0 if no mapping is
+ applicable.
+ */
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL
+rtl_getWindowsCodePageFromTextEncoding(rtl_TextEncoding nEncoding);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_TENCINFO_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/textcvt.h b/include/rtl/textcvt.h
new file mode 100644
index 000000000000..a67b2416ee7a
--- /dev/null
+++ b/include/rtl/textcvt.h
@@ -0,0 +1,177 @@
+/* -*- 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 _RTL_TEXTCVT_H
+#define _RTL_TEXTCVT_H
+
+#include "sal/config.h"
+
+#include "rtl/textenc.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Documentation about this file can be found at
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html>. */
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_TextToUnicodeConverter;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_TextToUnicodeContext;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC rtl_TextToUnicodeConverter SAL_CALL rtl_createTextToUnicodeConverter( rtl_TextEncoding eTextEncoding );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_destroyTextToUnicodeConverter( rtl_TextToUnicodeConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC rtl_TextToUnicodeContext SAL_CALL rtl_createTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_destroyTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_resetTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext );
+
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR ((sal_uInt32)0x0001)
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE ((sal_uInt32)0x0002)
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE ((sal_uInt32)0x0003)
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT ((sal_uInt32)0x0004)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR ((sal_uInt32)0x0010)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE ((sal_uInt32)0x0020)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT ((sal_uInt32)0x0030)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR ((sal_uInt32)0x0100)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE ((sal_uInt32)0x0200)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT ((sal_uInt32)0x0300)
+#define RTL_TEXTTOUNICODE_FLAGS_FLUSH ((sal_uInt32)0x8000)
+#define RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE 0x10000
+ /* Accept any global document signatures (for example, in UTF-8, a leading
+ EF BB BF encoding the Byte Order Mark U+FEFF) */
+
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK ((sal_uInt32)0x000F)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK ((sal_uInt32)0x00F0)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK ((sal_uInt32)0x0F00)
+
+#define RTL_TEXTTOUNICODE_INFO_ERROR ((sal_uInt32)0x0001)
+#define RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL ((sal_uInt32)0x0002)
+#define RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL ((sal_uInt32)0x0004)
+#define RTL_TEXTTOUNICODE_INFO_UNDEFINED ((sal_uInt32)0x0008)
+#define RTL_TEXTTOUNICODE_INFO_MBUNDEFINED ((sal_uInt32)0x0010)
+#define RTL_TEXTTOUNICODE_INFO_INVALID ((sal_uInt32)0x0020)
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC sal_Size SAL_CALL rtl_convertTextToUnicode(
+ rtl_TextToUnicodeConverter hConverter,
+ rtl_TextToUnicodeContext hContext,
+ const sal_Char* pSrcBuf, sal_Size nSrcBytes,
+ sal_Unicode* pDestBuf, sal_Size nDestChars,
+ sal_uInt32 nFlags, sal_uInt32* pInfo,
+ sal_Size* pSrcCvtBytes );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_UnicodeToTextConverter;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_UnicodeToTextContext;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC rtl_UnicodeToTextConverter SAL_CALL rtl_createUnicodeToTextConverter( rtl_TextEncoding eTextEncoding );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_destroyUnicodeToTextConverter( rtl_UnicodeToTextConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC rtl_UnicodeToTextContext SAL_CALL rtl_createUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_destroyUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_resetUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext );
+
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR ((sal_uInt32)0x0001)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE ((sal_uInt32)0x0002)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0 ((sal_uInt32)0x0003)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK ((sal_uInt32)0x0004)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE ((sal_uInt32)0x0005)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT ((sal_uInt32)0x0006)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR ((sal_uInt32)0x0010)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE ((sal_uInt32)0x0020)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_0 ((sal_uInt32)0x0030)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_QUESTIONMARK ((sal_uInt32)0x0040)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE ((sal_uInt32)0x0050)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT ((sal_uInt32)0x0060)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE ((sal_uInt32)0x0100)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR ((sal_uInt32)0x0200)
+#define RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ((sal_uInt32)0x0400)
+#define RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE ((sal_uInt32)0x0800)
+#define RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE ((sal_uInt32)0x1000)
+#define RTL_UNICODETOTEXT_FLAGS_PRIVATE_IGNORE ((sal_uInt32)0x2000)
+#define RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE ((sal_uInt32)0x4000)
+#define RTL_UNICODETOTEXT_FLAGS_FLUSH ((sal_uInt32)0x8000)
+#define RTL_UNICODETOTEXT_FLAGS_GLOBAL_SIGNATURE 0x10000
+ /* Write any global document signatures (for example, in UTF-8, a leading
+ EF BB BF encoding the Byte Order Mark U+FEFF) */
+
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK ((sal_uInt32)0x000F)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_MASK ((sal_uInt32)0x00F0)
+
+#define RTL_UNICODETOTEXT_INFO_ERROR ((sal_uInt32)0x0001)
+#define RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL ((sal_uInt32)0x0002)
+#define RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL ((sal_uInt32)0x0004)
+#define RTL_UNICODETOTEXT_INFO_UNDEFINED ((sal_uInt32)0x0008)
+#define RTL_UNICODETOTEXT_INFO_INVALID ((sal_uInt32)0x0010)
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+SAL_DLLPUBLIC sal_Size SAL_CALL rtl_convertUnicodeToText(
+ rtl_UnicodeToTextConverter hConverter,
+ rtl_UnicodeToTextContext hContext,
+ const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
+ sal_Char* pDestBuf, sal_Size nDestBytes,
+ sal_uInt32 nFlags, sal_uInt32* pInfo,
+ sal_Size* pSrcCvtChars );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_TEXTCVT_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/textenc.h b/include/rtl/textenc.h
new file mode 100644
index 000000000000..676f8c23186a
--- /dev/null
+++ b/include/rtl/textenc.h
@@ -0,0 +1,270 @@
+/* -*- 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 _RTL_TEXTENC_H
+#define _RTL_TEXTENC_H
+
+#ifdef _SOLAR_RSC_INVOKED
+/* Enable resources to use these values, rsc can't handle casts */
+#define RTL_TEXTENC_CAST( val ) (val)
+
+#else /* !_SOLAR_RSC_INVOKED */
+
+#include <sal/types.h>
+
+/** The various supported text encodings.
+
+ Possible values include a wide range of single- and multi-byte encodings
+ (ranging from RTL_TEXTENCODING_MS_1252 to RTL_TEXTENCODING_GB_18030),
+ the ISO 10646 (Unicode) specific encodings RTL_TEXTENCODING_UCS4 and
+ RTL_TEXTENCODING_UCS2 (aka RTL_TEXTENCODING_UNICODE), and
+ RTL_TEXTENCODING_DONTKNOW to indicate an unknown or missing encoding.
+ */
+typedef sal_uInt16 rtl_TextEncoding;
+
+#define RTL_TEXTENC_CAST( val ) ((rtl_TextEncoding) val)
+
+#endif /* _SOLAR_RSC_INVOKED */
+
+#define RTL_TEXTENCODING_DONTKNOW (RTL_TEXTENC_CAST( 0 ))
+#define RTL_TEXTENCODING_MS_1252 (RTL_TEXTENC_CAST( 1 ))
+#define RTL_TEXTENCODING_APPLE_ROMAN (RTL_TEXTENC_CAST( 2 ))
+#define RTL_TEXTENCODING_IBM_437 (RTL_TEXTENC_CAST( 3 ))
+#define RTL_TEXTENCODING_IBM_850 (RTL_TEXTENC_CAST( 4 ))
+#define RTL_TEXTENCODING_IBM_860 (RTL_TEXTENC_CAST( 5 ))
+#define RTL_TEXTENCODING_IBM_861 (RTL_TEXTENC_CAST( 6 ))
+#define RTL_TEXTENCODING_IBM_863 (RTL_TEXTENC_CAST( 7 ))
+#define RTL_TEXTENCODING_IBM_865 (RTL_TEXTENC_CAST( 8 ))
+/* Reserved: RTL_TEXTENCODING_SYSTEM (RTL_TEXTENC_CAST( 9 )) */
+#define RTL_TEXTENCODING_SYMBOL (RTL_TEXTENC_CAST( 10 ))
+#define RTL_TEXTENCODING_ASCII_US (RTL_TEXTENC_CAST( 11 ))
+#define RTL_TEXTENCODING_ISO_8859_1 (RTL_TEXTENC_CAST( 12 ))
+#define RTL_TEXTENCODING_ISO_8859_2 (RTL_TEXTENC_CAST( 13 ))
+#define RTL_TEXTENCODING_ISO_8859_3 (RTL_TEXTENC_CAST( 14 ))
+#define RTL_TEXTENCODING_ISO_8859_4 (RTL_TEXTENC_CAST( 15 ))
+#define RTL_TEXTENCODING_ISO_8859_5 (RTL_TEXTENC_CAST( 16 ))
+#define RTL_TEXTENCODING_ISO_8859_6 (RTL_TEXTENC_CAST( 17 ))
+#define RTL_TEXTENCODING_ISO_8859_7 (RTL_TEXTENC_CAST( 18 ))
+#define RTL_TEXTENCODING_ISO_8859_8 (RTL_TEXTENC_CAST( 19 ))
+#define RTL_TEXTENCODING_ISO_8859_9 (RTL_TEXTENC_CAST( 20 ))
+#define RTL_TEXTENCODING_ISO_8859_14 (RTL_TEXTENC_CAST( 21 ))
+#define RTL_TEXTENCODING_ISO_8859_15 (RTL_TEXTENC_CAST( 22 ))
+#define RTL_TEXTENCODING_IBM_737 (RTL_TEXTENC_CAST( 23 ))
+#define RTL_TEXTENCODING_IBM_775 (RTL_TEXTENC_CAST( 24 ))
+#define RTL_TEXTENCODING_IBM_852 (RTL_TEXTENC_CAST( 25 ))
+#define RTL_TEXTENCODING_IBM_855 (RTL_TEXTENC_CAST( 26 ))
+#define RTL_TEXTENCODING_IBM_857 (RTL_TEXTENC_CAST( 27 ))
+#define RTL_TEXTENCODING_IBM_862 (RTL_TEXTENC_CAST( 28 ))
+#define RTL_TEXTENCODING_IBM_864 (RTL_TEXTENC_CAST( 29 ))
+#define RTL_TEXTENCODING_IBM_866 (RTL_TEXTENC_CAST( 30 ))
+#define RTL_TEXTENCODING_IBM_869 (RTL_TEXTENC_CAST( 31 ))
+#define RTL_TEXTENCODING_MS_874 (RTL_TEXTENC_CAST( 32 ))
+#define RTL_TEXTENCODING_MS_1250 (RTL_TEXTENC_CAST( 33 ))
+#define RTL_TEXTENCODING_MS_1251 (RTL_TEXTENC_CAST( 34 ))
+#define RTL_TEXTENCODING_MS_1253 (RTL_TEXTENC_CAST( 35 ))
+#define RTL_TEXTENCODING_MS_1254 (RTL_TEXTENC_CAST( 36 ))
+#define RTL_TEXTENCODING_MS_1255 (RTL_TEXTENC_CAST( 37 ))
+#define RTL_TEXTENCODING_MS_1256 (RTL_TEXTENC_CAST( 38 ))
+#define RTL_TEXTENCODING_MS_1257 (RTL_TEXTENC_CAST( 39 ))
+#define RTL_TEXTENCODING_MS_1258 (RTL_TEXTENC_CAST( 40 ))
+#define RTL_TEXTENCODING_APPLE_ARABIC (RTL_TEXTENC_CAST( 41 ))
+#define RTL_TEXTENCODING_APPLE_CENTEURO (RTL_TEXTENC_CAST( 42 ))
+#define RTL_TEXTENCODING_APPLE_CROATIAN (RTL_TEXTENC_CAST( 43 ))
+#define RTL_TEXTENCODING_APPLE_CYRILLIC (RTL_TEXTENC_CAST( 44 ))
+#define RTL_TEXTENCODING_APPLE_DEVANAGARI (RTL_TEXTENC_CAST( 45 ))
+#define RTL_TEXTENCODING_APPLE_FARSI (RTL_TEXTENC_CAST( 46 ))
+#define RTL_TEXTENCODING_APPLE_GREEK (RTL_TEXTENC_CAST( 47 ))
+#define RTL_TEXTENCODING_APPLE_GUJARATI (RTL_TEXTENC_CAST( 48 ))
+#define RTL_TEXTENCODING_APPLE_GURMUKHI (RTL_TEXTENC_CAST( 49 ))
+#define RTL_TEXTENCODING_APPLE_HEBREW (RTL_TEXTENC_CAST( 50 ))
+#define RTL_TEXTENCODING_APPLE_ICELAND (RTL_TEXTENC_CAST( 51 ))
+#define RTL_TEXTENCODING_APPLE_ROMANIAN (RTL_TEXTENC_CAST( 52 ))
+#define RTL_TEXTENCODING_APPLE_THAI (RTL_TEXTENC_CAST( 53 ))
+#define RTL_TEXTENCODING_APPLE_TURKISH (RTL_TEXTENC_CAST( 54 ))
+#define RTL_TEXTENCODING_APPLE_UKRAINIAN (RTL_TEXTENC_CAST( 55 ))
+#define RTL_TEXTENCODING_APPLE_CHINSIMP (RTL_TEXTENC_CAST( 56 ))
+#define RTL_TEXTENCODING_APPLE_CHINTRAD (RTL_TEXTENC_CAST( 57 ))
+#define RTL_TEXTENCODING_APPLE_JAPANESE (RTL_TEXTENC_CAST( 58 ))
+#define RTL_TEXTENCODING_APPLE_KOREAN (RTL_TEXTENC_CAST( 59 ))
+#define RTL_TEXTENCODING_MS_932 (RTL_TEXTENC_CAST( 60 ))
+#define RTL_TEXTENCODING_MS_936 (RTL_TEXTENC_CAST( 61 ))
+#define RTL_TEXTENCODING_MS_949 (RTL_TEXTENC_CAST( 62 ))
+#define RTL_TEXTENCODING_MS_950 (RTL_TEXTENC_CAST( 63 ))
+#define RTL_TEXTENCODING_SHIFT_JIS (RTL_TEXTENC_CAST( 64 ))
+#define RTL_TEXTENCODING_GB_2312 (RTL_TEXTENC_CAST( 65 ))
+#define RTL_TEXTENCODING_GBT_12345 (RTL_TEXTENC_CAST( 66 ))
+#define RTL_TEXTENCODING_GBK (RTL_TEXTENC_CAST( 67 ))
+#define RTL_TEXTENCODING_BIG5 (RTL_TEXTENC_CAST( 68 ))
+#define RTL_TEXTENCODING_EUC_JP (RTL_TEXTENC_CAST( 69 ))
+#define RTL_TEXTENCODING_EUC_CN (RTL_TEXTENC_CAST( 70 ))
+#define RTL_TEXTENCODING_EUC_TW (RTL_TEXTENC_CAST( 71 ))
+#define RTL_TEXTENCODING_ISO_2022_JP (RTL_TEXTENC_CAST( 72 ))
+#define RTL_TEXTENCODING_ISO_2022_CN (RTL_TEXTENC_CAST( 73 ))
+#define RTL_TEXTENCODING_KOI8_R (RTL_TEXTENC_CAST( 74 ))
+#define RTL_TEXTENCODING_UTF7 (RTL_TEXTENC_CAST( 75 ))
+#define RTL_TEXTENCODING_UTF8 (RTL_TEXTENC_CAST( 76 ))
+#define RTL_TEXTENCODING_ISO_8859_10 (RTL_TEXTENC_CAST( 77 ))
+#define RTL_TEXTENCODING_ISO_8859_13 (RTL_TEXTENC_CAST( 78 ))
+#define RTL_TEXTENCODING_EUC_KR (RTL_TEXTENC_CAST( 79 ))
+#define RTL_TEXTENCODING_ISO_2022_KR (RTL_TEXTENC_CAST( 80 ))
+#define RTL_TEXTENCODING_JIS_X_0201 (RTL_TEXTENC_CAST( 81 ))
+#define RTL_TEXTENCODING_JIS_X_0208 (RTL_TEXTENC_CAST( 82 ))
+#define RTL_TEXTENCODING_JIS_X_0212 (RTL_TEXTENC_CAST( 83 ))
+#define RTL_TEXTENCODING_MS_1361 (RTL_TEXTENC_CAST( 84 ))
+#define RTL_TEXTENCODING_GB_18030 (RTL_TEXTENC_CAST( 85 ))
+#define RTL_TEXTENCODING_BIG5_HKSCS (RTL_TEXTENC_CAST( 86 ))
+#define RTL_TEXTENCODING_TIS_620 (RTL_TEXTENC_CAST( 87 ))
+#define RTL_TEXTENCODING_KOI8_U (RTL_TEXTENC_CAST( 88 ))
+#define RTL_TEXTENCODING_ISCII_DEVANAGARI (RTL_TEXTENC_CAST( 89 ))
+#define RTL_TEXTENCODING_JAVA_UTF8 (RTL_TEXTENC_CAST( 90 ))
+#define RTL_TEXTENCODING_ADOBE_STANDARD (RTL_TEXTENC_CAST( 91 ))
+#define RTL_TEXTENCODING_ADOBE_SYMBOL (RTL_TEXTENC_CAST( 92 ))
+#define RTL_TEXTENCODING_PT154 (RTL_TEXTENC_CAST( 93 ))
+#define RTL_TEXTENCODING_ADOBE_DINGBATS (RTL_TEXTENC_CAST( 94 ))
+/* ATTENTION! Whenever some encoding is added here, make sure to update
+ * rtl_isOctetTextEncoding in tencinfo.c.
+ */
+
+#define RTL_TEXTENCODING_USER_START (RTL_TEXTENC_CAST( 0x8000 ))
+#define RTL_TEXTENCODING_USER_END (RTL_TEXTENC_CAST( 0xEFFF ))
+
+#define RTL_TEXTENCODING_UCS4 (RTL_TEXTENC_CAST( 0xFFFE ))
+#define RTL_TEXTENCODING_UCS2 (RTL_TEXTENC_CAST( 0xFFFF ))
+#define RTL_TEXTENCODING_UNICODE RTL_TEXTENCODING_UCS2
+
+/****** Overview over the TextEncodings *****
+# Arabic (Apple Macintosh) RTL_TEXTENCODING_APPLE_ARABIC
+Arabic (DOS/OS2-864) RTL_TEXTENCODING_IBM_864
+Arabic (ISO-8859-6) RTL_TEXTENCODING_ISO_8859_6
+Arabic (Windows-1256) RTL_TEXTENCODING_MS_1256
+
+Baltic (DOS/OS2-775) RTL_TEXTENCODING_IBM_775
+Baltic (ISO-8859-4) RTL_TEXTENCODING_ISO_8859_4
+Baltic (Windows-1257) RTL_TEXTENCODING_MS_1257
+
+Central European (Apple Macintosh) RTL_TEXTENCODING_APPLE_CENTEURO
+Central European (Apple Macintosh/Croatian) RTL_TEXTENCODING_APPLE_CROATIAN
+Central European (Apple Macintosh/Romanian) RTL_TEXTENCODING_APPLE_ROMANIAN
+Central European (DOS/OS2-852) RTL_TEXTENCODING_IBM_852
+Central European (ISO-8859-2) RTL_TEXTENCODING_ISO_8859_2
+Central European (ISO-8859-10) RTL_TEXTENCODING_ISO_8859_10
+Central European (ISO-8859-13) RTL_TEXTENCODING_ISO_8859_13
+Central European (Windows-1250/WinLatin 2) RTL_TEXTENCODING_MS_1250
+
+Chinese Simplified (Apple Macintosh) RTL_TEXTENCODING_APPLE_CHINSIMP
+Chinese Simplified (EUC-CN) RTL_TEXTENCODING_EUC_CN
+Chinese Simplified (GB-2312) RTL_TEXTENCODING_GB_2312
+Chinese Simplified (GBK/GB-2312-80) RTL_TEXTENCODING_GBK
+# Chinese Simplified (ISO-2022-CN) RTL_TEXTENCODING_ISO_2022_CN
+Chinese Simplified (Windows-936) RTL_TEXTENCODING_MS_936
+# Chinese Simplified (GB-18030) RTL_TEXTENCODING_GB_18030
+
+Chinese Traditional (Apple Macintosh) RTL_TEXTENCODING_APPLE_CHINTRAD
+Chinese Traditional (BIG5) RTL_TEXTENCODING_BIG5
+# Chinese Traditional (EUC-TW) RTL_TEXTENCODING_EUC_TW
+Chinese Traditional (GBT-12345) RTL_TEXTENCODING_GBT_12345
+Chinese Traditional (Windows-950) RTL_TEXTENCODING_MS_950
+Chinese Traditional (BIG5-HKSCS) RTL_TEXTENCODING_BIG5_HKSCS
+
+Cyrillic (Apple Macintosh) RTL_TEXTENCODING_APPLE_CYRILLIC
+Cyrillic (Apple Macintosh/Ukrainian) RTL_TEXTENCODING_APPLE_UKRAINIAN
+Cyrillic (DOS/OS2-855) RTL_TEXTENCODING_IBM_855
+Cyrillic (DOS/OS2-866/Russian) RTL_TEXTENCODING_IBM_866
+Cyrillic (ISO-8859-5) RTL_TEXTENCODING_ISO_8859_5
+Cyrillic (KOI8-R) RTL_TEXTENCODING_KOI8_R
+Cyrillic (KOI8-U) RTL_TEXTENCODING_KOI8_U
+Cyrillic (Windows-1251) RTL_TEXTENCODING_MS_1251
+
+Greek (Apple Macintosh) RTL_TEXTENCODING_APPLE_GREEK
+Greek (DOS/OS2-737) RTL_TEXTENCODING_IBM_737
+Greek (DOS/OS2-869/Modern) RTL_TEXTENCODING_IBM_869
+Greek (ISO-8859-7) RTL_TEXTENCODING_ISO_8859_7
+Greek (Windows-1253) RTL_TEXTENCODING_MS_1253
+
+# Hebrew (Apple Macintosh) RTL_TEXTENCODING_APPLE_HEBREW
+Hebrew (DOS/OS2-862) RTL_TEXTENCODING_IBM_862
+Hebrew (ISO-8859-8) RTL_TEXTENCODING_ISO_8859_8
+Hebrew (Windows-1255) RTL_TEXTENCODING_MS_1255
+
+Korean (Apple Macintosh) RTL_TEXTENCODING_APPLE_KOREAN
+Korean (EUC-KR) RTL_TEXTENCODING_EUC_KR
+# Korean (ISO-2022-KR) RTL_TEXTENCODING_ISO_2022_KR
+Korean (Windows-Wansung-949) RTL_TEXTENCODING_MS_949
+Korean (Windows-Johab-1361) RTL_TEXTENCODING_MS_1361
+
+Latin 3 (ISO-8859-3) RTL_TEXTENCODING_ISO_8859_3
+
+Indian (ISCII Devanagari) RTL_TEXTENCODING_ISCII_DEVANAGARI
+
+Japanese (Apple Macintosh) RTL_TEXTENCODING_APPLE_JAPANESE
+Japanese (EUC-JP) RTL_TEXTENCODING_EUC_JP
+# Japanese (ISO-2022-JP) RTL_TEXTENCODING_ISO_2022_JP
+Japanese (Shift-JIS) RTL_TEXTENCODING_SHIFT_JIS
+Japanese (Windows-932) RTL_TEXTENCODING_MS_932
+
+Symbol RTL_TEXTENCODING_SYMBOL
+
+# Thai (Apple Macintosh) RTL_TEXTENCODING_APPLE_THAI
+Thai (Dos/Windows-874) RTL_TEXTENCODING_MS_874
+Thai (TIS 620) RTL_TEXTENCODING_TIS_620
+
+Turkish (Apple Macintosh) RTL_TEXTENCODING_APPLE_TURKISH
+Turkish (DOS/OS2-857) RTL_TEXTENCODING_IBM_857
+Turkish (ISO-8859-9) RTL_TEXTENCODING_ISO_8859_9
+Turkish (Windows-1254) RTL_TEXTENCODING_MS_1254
+
+Unicode (UTF-7) RTL_TEXTENCODING_UTF7
+Unicode (UTF-8) RTL_TEXTENCODING_UTF8
+Unicode (Java's modified UTF-8) RTL_TEXTENCODING_JAVA_UTF8
+
+Vietnamese (Windows-1258) RTL_TEXTENCODING_MS_1258
+
+Western (Apple Macintosh) RTL_TEXTENCODING_APPLE_ROMAN
+Western (Apple Macintosh/Icelandic) RTL_TEXTENCODING_APPLE_ICELAND
+Western (ASCII/US) RTL_TEXTENCODING_ASCII_US
+Western (DOS/OS2-437/US) RTL_TEXTENCODING_IBM_437
+Western (DOS/OS2-850/International) RTL_TEXTENCODING_IBM_850
+Western (DOS/OS2-860/Portugese) RTL_TEXTENCODING_IBM_860
+Western (DOS/OS2-861/Icelandic) RTL_TEXTENCODING_IBM_861
+Western (DOS/OS2-863/Canadian-French) RTL_TEXTENCODING_IBM_863
+Western (DOS/OS2-865/Nordic) RTL_TEXTENCODING_IBM_865
+Western (ISO-8859-1) RTL_TEXTENCODING_ISO_8859_1
+Western (ISO-8859-14) RTL_TEXTENCODING_ISO_8859_14
+Western (ISO-8859-15/EURO) RTL_TEXTENCODING_ISO_8859_15
+Western (Window-1252/WinLatin 1) RTL_TEXTENCODING_MS_1252
+
+Not known and currently not supported
+# RTL_TEXTENCODING_APPLE_DEVANAGARI
+# RTL_TEXTENCODING_APPLE_FARSI
+# RTL_TEXTENCODING_APPLE_GUJARATI
+# RTL_TEXTENCODING_APPLE_GURMUKHI
+
+Only for internal implementations and not useful for user interface.
+These encodings are not used for text encodings, only used for
+font-/textoutput encodings.
+Japanese (JIS 0201) RTL_TEXTENCODING_JISX_0201
+Japanese (JIS 0208) RTL_TEXTENCODING_JISX_0208
+Japanese (JIS 0212) RTL_TEXTENCODING_JISX_0212
+
+# Currently not implemented
+*/
+
+#endif /* _RTL_TEXTENC_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/unload.h b/include/rtl/unload.h
new file mode 100644
index 000000000000..118b5cce9127
--- /dev/null
+++ b/include/rtl/unload.h
@@ -0,0 +1,92 @@
+/* -*- 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 _RTL_UNLOAD_H_
+#define _RTL_UNLOAD_H_
+
+#include "sal/config.h"
+
+#include "osl/interlck.h"
+#include "osl/time.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+/** @file
+ Backwards-compatibility remainders of a removed library unloading feature.
+*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Backwards-compatibility remainder of a removed library unloading feature.
+
+ @deprecated Do not use.
+*/
+typedef struct _rtl_ModuleCount
+{
+ void ( SAL_CALL * acquire ) ( struct _rtl_ModuleCount * that );
+ void ( SAL_CALL * release ) ( struct _rtl_ModuleCount * that );
+}rtl_ModuleCount;
+
+/** Backwards-compatibility remainder of a removed library unloading feature.
+
+ @deprecated Do not use.
+*/
+#define MODULE_COUNT_INIT \
+{ {rtl_moduleCount_acquire,rtl_moduleCount_release}, rtl_moduleCount_canUnload, 0, {0, 0}}
+
+/** Backwards-compatibility remainder of a removed library unloading feature.
+
+ @deprecated Do not use.
+*/
+typedef struct _rtl_StandardModuleCount
+{
+ rtl_ModuleCount modCnt;
+ sal_Bool ( *canUnload ) ( struct _rtl_StandardModuleCount* a, TimeValue* libUnused);
+ oslInterlockedCount counter;
+ TimeValue unusedSince;
+} rtl_StandardModuleCount;
+
+/** Backwards-compatibility remainder of a removed library unloading feature.
+
+ @deprecated Do not use.
+*/
+SAL_DLLPUBLIC void rtl_moduleCount_acquire(rtl_ModuleCount * that );
+
+/** Backwards-compatibility remainder of a removed library unloading feature.
+
+ @deprecated Do not use.
+*/
+SAL_DLLPUBLIC void rtl_moduleCount_release( rtl_ModuleCount * that );
+
+/** Backwards-compatibility remainder of a removed library unloading feature.
+
+ @deprecated Do not use.
+*/
+SAL_DLLPUBLIC sal_Bool rtl_moduleCount_canUnload( rtl_StandardModuleCount * that, TimeValue* libUnused);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/uri.h b/include/rtl/uri.h
new file mode 100644
index 000000000000..251af025ef82
--- /dev/null
+++ b/include/rtl/uri.h
@@ -0,0 +1,352 @@
+/* -*- 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 _RTL_URI_H_
+#define _RTL_URI_H_
+
+#include "sal/config.h"
+
+#include "rtl/textenc.h"
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** Various predefined URI 'char classes.'
+
+ A 'char class' defines which (ASCII) characters can be written 'as they
+ are' in a part of a Uri, and which characters have to be written using
+ escape sequences ('%' followed by two hex digits). Characters outside
+ the ASCII range are always written using escape sequences.
+
+ If there are other frequently used char classes, they can be added to
+ this enumeration; the function rtl_getUriCharClass() has to be adapted
+ then, too.
+ */
+typedef enum
+{
+ /** The empty char class.
+
+ All characters are written using escape sequences.
+ */
+ rtl_UriCharClassNone,
+
+ /** The RFC 2732 @<uric> char class.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+,-./:;=?@[]_~ plus digits and
+ letters.
+ @endverbatim
+ */
+ rtl_UriCharClassUric,
+
+ /** The RFC 2396 @<uric_no_slash> char class.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+,-.:;=?@_~ plus digits and letters.
+ @endverbatim
+ */
+ rtl_UriCharClassUricNoSlash,
+
+ /** The RFC 2396 @<rel_segment> char class.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+,-.;=@_~ plus digits and letters.
+ @endverbatim
+ */
+ rtl_UriCharClassRelSegment,
+
+ /** The RFC 2396 @<reg_name> char class.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+,-.:;=@_~ plus digits and letters.
+ @endverbatim
+ */
+ rtl_UriCharClassRegName,
+
+ /** The RFC 2396 @<userinfo> char class.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+,-.:;=_~ plus digits and letters.
+ @endverbatim
+ */
+ rtl_UriCharClassUserinfo,
+
+ /** The RFC 2396 @<pchar> char class.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+,-.:=@_~ plus digits and letters.
+ @endverbatim
+ */
+ rtl_UriCharClassPchar,
+
+ /** The char class for the values of uno URL parameters.
+
+ @verbatim
+ The 'valid' characters are !$&'()*+-./:?@_~ plus digits and letters.
+ @endverbatim
+ */
+ rtl_UriCharClassUnoParamValue,
+
+ rtl_UriCharClass_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+}
+rtl_UriCharClass;
+
+/** The mechanism describing how escape sequences in the input of
+ rtl_uriEncode() are handled.
+ */
+typedef enum
+{
+ /** The special meaning of '%' is ignored (i.e., there are by definition
+ no escape sequences in the input).
+
+ This mechanism is useful to encode user input as part of a URI (e.g.,
+ the user-supplied password in an ftp URL---'%20abcde' is a valid
+ password, so do not assume that the '%20' is an escaped space).
+ */
+ rtl_UriEncodeIgnoreEscapes,
+
+ /** All escape sequences ('%' followed by two hex digits) are kept intact,
+ even if they represent characters that need not be escaped or if they
+ do not even map to characters in the given charset.
+
+ This mechanism is useful when passing on complete URIs more or less
+ unmodified (e.g., within an HTTP proxy): missing escape sequences are
+ added, but existing escape sequences are not touched (except that any
+ lower case hex digits are replaced by upper case hex digits).
+ */
+ rtl_UriEncodeKeepEscapes,
+
+ /** All escape sequences ('%' followed by two hex digits) are resolved in
+ a first step; only those that represent characters that need to be
+ escaped are kept intact.
+
+ This mechanism is useful to properly encode complete URIs entered by
+ the user: the URI is brought into a 'canonic form,' but care is taken
+ not to damage (valid) escape sequences the (careful) user already
+ entered as such.
+ */
+ rtl_UriEncodeCheckEscapes,
+
+ /** Like rtl_UriEncodeIgnoreEscapes, but indicating failure when converting
+ unmappable characters.
+
+ @since UDK 3.2.0
+ */
+ rtl_UriEncodeStrict,
+
+ /** Like rtl_UriEncodeKeepEscapes, but indicating failure when converting
+ unmappable characters.
+
+ @since UDK 3.2.7
+ */
+ rtl_UriEncodeStrictKeepEscapes,
+
+ rtl_UriEncode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+}
+rtl_UriEncodeMechanism;
+
+/** The mechanism describing how rtl_uriDecode() translates (part of) a URI
+ into a Unicode string.
+ */
+typedef enum
+{
+ /** The text is returned completely unmodified.
+ */
+ rtl_UriDecodeNone,
+
+ /** The text is returned in the form of an IURI (cf.
+ draft-masinter-url-i18n-05.txt).
+
+ All escape sequences representing ASCII characters (%00--%7F) are
+ kept, all other escape sequences are interpreted as UTF-8 characters
+ and translated to Unicode, if possible.
+ */
+ rtl_UriDecodeToIuri,
+
+ /** The text is decoded.
+
+ All escape sequences representing characters from the given charset
+ are decoded and translated to Unicode, if possible.
+ */
+ rtl_UriDecodeWithCharset,
+
+ /** Like rtl_UriDecodeWithCharset, but indicating failure when converting
+ unmappable characters.
+
+ @since UDK 3.2.0
+ */
+ rtl_UriDecodeStrict,
+
+ rtl_UriDecode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+}
+rtl_UriDecodeMechanism;
+
+/** Map a predefined rtl_UriCharClass to a form usable by rtl_uriEncode().
+
+ The function rtl_uriEncode() expects an array of 128 booleans, and this
+ function maps rtl_UriCharClass enumeration members to such arrays.
+
+ @param eCharClass
+ Any valid member of rtl_UriCharClass.
+
+ @return
+ An array of 128 booleans, to be used in calls to rtl_uriEncode().
+ */
+SAL_DLLPUBLIC sal_Bool const * SAL_CALL rtl_getUriCharClass(rtl_UriCharClass eCharClass)
+ SAL_THROW_EXTERN_C();
+
+/** Encode a text as (part of) a URI.
+
+ @param pText
+ Any Unicode string. Must not be null.
+
+ @param pCharClass
+ A char class, represented as an array of 128 booleans (true means keep the
+ corresponding ASCII character unencoded, false means encode it). Must not
+ be null, and the boolean corresponding to the percent sign (0x25) must be
+ false. (See rtl_getUriCharClass() for a function mapping from
+ rtl_UriCharClass to such arrays.)
+
+ @param eMechanism
+ The mechanism describing how escape sequences in the input text are
+ handled.
+
+ @param eCharset
+ When Unicode characters from the input text have to be written using
+ escape sequences (because they are either outside the ASCII range or do
+ not belong to the given char class), they are first translated into this
+ charset before being encoded using escape sequences.
+
+ Also, if the encode mechanism is rtl_UriEncodeCheckEscapes, all escape
+ sequences already present in the input text are interpreted as characters
+ from this charset.
+
+ @param pResult
+ Returns an encoded representation of the input text. Must itself not be
+ null, and must point to either null or a valid string.
+
+ If the encode mechanism is rtl_UriEncodeStrict, and pText cannot be
+ converted to eCharset because it contains unmappable characters (which
+ implies that pText is not empty), then an empty string is returned.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uriEncode(
+ rtl_uString * pText,
+ sal_Bool const * pCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset,
+ rtl_uString ** pResult)
+ SAL_THROW_EXTERN_C();
+
+/** Decode (a part of) a URI.
+
+ @param pText
+ Any Unicode string. Must not be null. (If the input is indeed part of a
+ valid URI, this string will only contain a subset of the ASCII characters,
+ but this function also handles other Unicode characters properly.)
+
+ @param eMechanism
+ The mechanism describing how the input text is translated into a Unicode
+ string.
+
+ @param eCharset
+ When the decode mechanism is rtl_UriDecodeWithCharset, all escape
+ sequences in the input text are interpreted as characters from this
+ charset. Those characters are translated to Unicode characters in the
+ resulting output, if possible.
+
+ When the decode mechanism is rtl_UriDecodeNone or rtl_UriDecodeToIuri,
+ this parameter is ignored (and is best specified as
+ RTL_TEXTENCODING_UTF8).
+
+ @param pResult
+ Returns a decoded representation of the input text. Must itself not be
+ null, and must point to either null or a valid string.
+
+ If the decode mechanism is rtl_UriDecodeStrict, and pText cannot be
+ converted to eCharset because it contains (encodings of) unmappable
+ characters (which implies that pText is not empty), then an empty string is
+ returned.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uriDecode(
+ rtl_uString * pText,
+ rtl_UriDecodeMechanism eMechanism,
+ rtl_TextEncoding eCharset,
+ rtl_uString ** pResult)
+ SAL_THROW_EXTERN_C();
+
+/** Convert a relative URI reference into an absolute one.
+
+ A URI reference is a URI plus an optional @<"#" fragment> part.
+
+ This function uses the algorithm described in RFC 2396, section 5.2, with
+ the following clarifications: (1) Backwards-compatible relative URIs
+ starting with a scheme component (see RFC 2396, section 5.2, step 3) are not
+ supported. (2) Segments "." and ".." within the path of the base URI are
+ not considered special, RFC 2396 seems a bit unlcear about that point.
+ (3) Erroneous excess segments ".." within the path of the relative URI (if
+ it is indeed relative) are left intact, as the examples in RFC 2396,
+ section C.2, suggest. (4) If the relative URI is a reference to the
+ "current document," the "current document" is taken to be the base URI.
+
+ This function signals exceptions by returning false and letting pException
+ point to a message explaining the exception.
+
+ @param pBaseUriRef
+ An absolute, hierarchical URI reference that serves as the base URI. If it
+ has to be inspected (i.e., pRelUriRef is not an absolute URI already), and
+ if it either is not an absolute URI (i.e., does not begin with a
+ @<scheme ":"> part) or has a path that is non-empty but does not start
+ with "/", an exception will be signaled.
+
+ @param pRelUriRef
+ An URI reference that may be either absolute or relative. If it is
+ absolute, it will be returned unmodified (and it need not be hierarchical
+ then).
+
+ @param pResult
+ Returns an absolute URI reference. Must itself not be null, and must point
+ to either null or a valid string. If an exception is signalled, it is left
+ unchanged.
+
+ @param pException
+ Returns an explanatory message in case an exception is signalled. Must
+ itself not be null, and must point to either null or a valid string. If no
+ exception is signalled, it is left unchanged.
+
+ @return
+ True if no exception is signalled, otherwise false.
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_uriConvertRelToAbs(
+ rtl_uString * pBaseUriRef,
+ rtl_uString * pRelUriRef,
+ rtl_uString ** pResult,
+ rtl_uString ** pException)
+ SAL_THROW_EXTERN_C();
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTL_URI_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/uri.hxx b/include/rtl/uri.hxx
new file mode 100644
index 000000000000..6e9ca00281c3
--- /dev/null
+++ b/include/rtl/uri.hxx
@@ -0,0 +1,144 @@
+/* -*- 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 _RTL_URI_HXX_
+#define _RTL_URI_HXX_
+
+#include "rtl/malformeduriexception.hxx"
+#include "rtl/uri.h"
+#include "rtl/textenc.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+namespace rtl {
+
+/** A wrapper around the C functions from <rtl/uri.h>.
+ */
+class Uri
+{
+public:
+ /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
+ an array of 128 booleans as char class.
+ */
+ static inline rtl::OUString encode(rtl::OUString const & rText,
+ sal_Bool const * pCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(());
+
+ /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
+ a predefined rtl_UriCharClass enumeration member.
+ */
+ static inline rtl::OUString encode(rtl::OUString const & rText,
+ rtl_UriCharClass eCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(());
+
+ /** A wrapper around rtl_uriDecode() from <rtl/uri.h> (see there).
+ */
+ static inline rtl::OUString decode(rtl::OUString const & rText,
+ rtl_UriDecodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(());
+
+ /** A wrapper around rtl_uriConvertRelToAbs() from <rtl/uri.h> (see there).
+
+ @exception MalformedUriException
+ Thrown in case rtl_uriConvertRelToAbs() signals an exception due to a
+ malformed base URI.
+ */
+ static inline rtl::OUString convertRelToAbs(
+ rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
+
+private:
+ /** not implemented */
+ Uri();
+
+ /** not implemented */
+ Uri(Uri &);
+
+ /** not implemented */
+ ~Uri();
+
+ /** not implemented */
+ void operator =(Uri);
+};
+
+inline rtl::OUString Uri::encode(rtl::OUString const & rText,
+ sal_Bool const * pCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(())
+{
+ rtl::OUString aResult;
+ rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
+ pCharClass,
+ eMechanism,
+ eCharset,
+ &aResult.pData);
+ return aResult;
+}
+
+inline rtl::OUString Uri::encode(rtl::OUString const & rText,
+ rtl_UriCharClass eCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(())
+{
+ rtl::OUString aResult;
+ rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
+ rtl_getUriCharClass(eCharClass),
+ eMechanism,
+ eCharset,
+ &aResult.pData);
+ return aResult;
+}
+
+inline rtl::OUString Uri::decode(rtl::OUString const & rText,
+ rtl_UriDecodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(())
+{
+ rtl::OUString aResult;
+ rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
+ eMechanism,
+ eCharset,
+ &aResult.pData);
+ return aResult;
+}
+
+inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
+ rtl::OUString const & rRelUriRef)
+{
+ rtl::OUString aResult;
+ rtl::OUString aException;
+ if (!rtl_uriConvertRelToAbs(
+ const_cast< rtl::OUString & >(rBaseUriRef).pData,
+ const_cast< rtl::OUString & >(rRelUriRef).pData, &aResult.pData,
+ &aException.pData))
+ throw MalformedUriException(aException);
+ return aResult;
+}
+
+}
+
+#endif // _RTL_URI_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/ustrbuf.h b/include/rtl/ustrbuf.h
new file mode 100644
index 000000000000..7df10c18cc40
--- /dev/null
+++ b/include/rtl/ustrbuf.h
@@ -0,0 +1,212 @@
+/* -*- 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 _RTL_USTRBUF_H_
+#define _RTL_USTRBUF_H_
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "sal/saldllapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Allocates a new <code>String</code> that contains characters from
+ the character array argument.
+
+ The <code>count</code> argument specifies
+ the length of the array. The initial capacity of the string buffer is
+ <code>16</code> plus the length of the string argument.
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param value the initial value of the string.
+ @param count the length of value.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength(
+ rtl_uString ** newStr,
+ const sal_Unicode * value,
+ sal_Int32 count );
+
+/**
+ Allocates a new <code>String</code> that contains the same sequence of
+ characters as the string argument.
+
+ The initial capacity is the larger of:
+ <ul>
+ <li> The <code>bufferLen</code> argument.
+ <li> The <code>length</code> of the string argument.
+ </ul>
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param capacity the initial len of the string buffer.
+ @param oldStr the initial value of the string.
+ @return the new capacity of the string buffer
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer(
+ rtl_uString ** newStr,
+ sal_Int32 capacity,
+ rtl_uString * oldStr );
+
+/**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ If the current capacity of this string buffer is less than the
+ argument, then a new internal buffer is allocated with greater
+ capacity. The new capacity is the larger of:
+ <ul>
+ <li>The <code>minimumCapacity</code> argument.
+ <li>Twice the old capacity, plus <code>2</code>.
+ </ul>
+ If the <code>minimumCapacity</code> argument is nonpositive, this
+ method takes no action and simply returns.
+
+ @param[in,out] This the String to operate on.
+ @param[in,out] capacity in: old capacity, out: new capacity.
+ @param[in] minimumCapacity the minimum desired capacity.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_ensureCapacity(
+ rtl_uString ** This,
+ sal_Int32* capacity,
+ sal_Int32 minimumCapacity);
+
+/**
+ Inserts the string representation of the <code>str</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+
+ @param This The string, on that the operation should take place
+ @param capacity the capacity of the string buffer
+ @param offset the offset.
+ @param str a character array.
+ @param len the number of characters to append.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_insert(
+ /*inout*/rtl_uString ** This,
+ /*inout*/sal_Int32 * capacity,
+ sal_Int32 offset,
+ const sal_Unicode * str,
+ sal_Int32 len);
+
+/**
+ Inserts a single UTF-32 character into this string buffer.
+
+ <p>The single UTF-32 character will be represented within the string buffer
+ as either one or two UTF-16 code units.</p>
+
+ @param pThis the string buffer on which the operation is performed
+
+ @param capacity the capacity of the string buffer
+
+ @param offset the offset into this string buffer (from zero to the length
+ of this string buffer, inclusive)
+
+ @param c a well-formed UTF-32 code unit (that is, a value in the range
+ <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
+ <code>0xD800</code>&ndash;<code>0xDFFF</code>)
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_insertUtf32(
+ rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c)
+ SAL_THROW_EXTERN_C();
+
+/**
+ Inserts the 8-Bit ASCII string representation of the <code>str</code>
+ array argument into this string buffer.
+
+ Since this function is optimized
+ for performance, the ASCII character values are not converted in any way.
+ The caller has to make sure that all ASCII characters are in the allowed
+ range between 0 and 127.
+ <p>
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+
+ @param This The string, on that the operation should take place
+ @param capacity the capacity of the string buffer
+ @param offset the offset.
+ @param str a character array.
+ @param len the number of characters to append.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_insert_ascii(
+ /*inout*/rtl_uString ** This,
+ /*inout*/sal_Int32 * capacity,
+ sal_Int32 offset,
+ const sal_Char * str,
+ sal_Int32 len);
+
+/**
+ Removes the characters in a substring of this sequence.
+
+ The substring begins at the specified <code>start</code> and
+ is <code>len</code> characters long.
+
+ start must be >= 0 && <= This->length
+
+ @param[in,out] This The String to operate on.
+ @param[in] start The beginning index, inclusive
+ @param[in] len The substring length
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_remove(
+ rtl_uString ** This,
+ sal_Int32 start,
+ sal_Int32 len );
+
+/**
+ Returns an immutable rtl_uString object, while clearing the string buffer.
+
+ This method is primarily used to allow these completed
+ string allocation events to be traced.
+
+ @param ppThis The string, on that the operation should take place
+ @param nCapacity pointer to the capacity of the string buffer
+
+ @since LibreOffice 3.6
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_uStringBuffer_makeStringAndClear(
+ /*inout*/ rtl_uString ** ppThis,
+ sal_Int32 *nCapacity );
+
+/**
+ References and returns an immutable rtl_uString object, from a mutable
+ string-buffer object.
+
+ This method is primarily used to allow legacy 'String' class
+ conversions to OUString to be accurately traced.
+
+ @param pThis The string, on that the operation should take place
+
+ @since LibreOffice 3.6
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_uStringBuffer_refReturn( rtl_uString *pThis );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_USTRBUF_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
new file mode 100644
index 000000000000..b648714aad97
--- /dev/null
+++ b/include/rtl/ustrbuf.hxx
@@ -0,0 +1,1386 @@
+/* -*- 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 _RTL_USTRBUF_HXX_
+#define _RTL_USTRBUF_HXX_
+
+#include "sal/config.h"
+
+#include <cassert>
+#include <string.h>
+
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.h>
+#include <rtl/ustring.hxx>
+#include <rtl/stringutils.hxx>
+#include <sal/types.h>
+
+#ifdef RTL_FAST_STRING
+#include <rtl/stringconcat.hxx>
+#endif
+
+// The unittest uses slightly different code to help check that the proper
+// calls are made. The class is put into a different namespace to make
+// sure the compiler generates a different (if generating also non-inline)
+// copy of the function and does not merge them together. The class
+// is "brought" into the proper rtl namespace by a typedef below.
+#ifdef RTL_STRING_UNITTEST
+#define rtl rtlunittest
+#endif
+
+namespace rtl
+{
+
+#ifdef RTL_STRING_UNITTEST
+#undef rtl
+#endif
+
+/** A string buffer implements a mutable sequence of characters.
+ <p>
+ String buffers are safe for use by multiple threads. The methods
+ are synchronized where necessary so that all the operations on any
+ particular instance behave as if they occur in some serial order.
+ <p>
+ String buffers are used by the compiler to implement the binary
+ string concatenation operator <code>+</code>. For example, the code:
+ <p><blockquote><pre>
+ x = "a" + 4 + "c"
+ </pre></blockquote><p>
+ is compiled to the equivalent of:
+ <p><blockquote><pre>
+ x = new OUStringBuffer().append("a").append(4).append("c")
+ .makeStringAndClear()
+ </pre></blockquote><p>
+ The principal operations on a <code>OUStringBuffer</code> are the
+ <code>append</code> and <code>insert</code> methods, which are
+ overloaded so as to accept data of any type. Each effectively
+ converts a given datum to a string and then appends or inserts the
+ characters of that string to the string buffer. The
+ <code>append</code> method always adds these characters at the end
+ of the buffer; the <code>insert</code> method adds the characters at
+ a specified point.
+ <p>
+ For example, if <code>z</code> refers to a string buffer object
+ whose current contents are "<code>start</code>", then
+ the method call <code>z.append("le")</code> would cause the string
+ buffer to contain "<code>startle</code>", whereas
+ <code>z.insert(4, "le")</code> would alter the string buffer to
+ contain "<code>starlet</code>".
+ <p>
+ Every string buffer has a capacity. As long as the length of the
+ character sequence contained in the string buffer does not exceed
+ the capacity, it is not necessary to allocate a new internal
+ buffer array. If the internal buffer overflows, it is
+ automatically made larger.
+ */
+class SAL_WARN_UNUSED OUStringBuffer
+{
+public:
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity of 16 characters.
+ */
+ OUStringBuffer()
+ : pData(NULL)
+ , nCapacity( 16 )
+ {
+ rtl_uString_new_WithLength( &pData, nCapacity );
+ }
+
+ /**
+ Allocates a new string buffer that contains the same sequence of
+ characters as the string buffer argument.
+
+ @param value a <code>OUStringBuffer</code>.
+ */
+ OUStringBuffer( const OUStringBuffer & value )
+ : pData(NULL)
+ , nCapacity( value.nCapacity )
+ {
+ rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
+ }
+
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity specified by the <code>length</code> argument.
+
+ @param length the initial capacity.
+ */
+ explicit OUStringBuffer(int length)
+ : pData(NULL)
+ , nCapacity( length )
+ {
+ rtl_uString_new_WithLength( &pData, length );
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string argument.
+
+ The initial
+ capacity of the string buffer is <code>16</code> plus the length
+ of the string argument.
+
+ @param value the initial contents of the buffer.
+ */
+ OUStringBuffer(const OUString& value)
+ : pData(NULL)
+ , nCapacity( value.getLength() + 16 )
+ {
+ rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
+ }
+
+ template< typename T >
+ OUStringBuffer( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() )
+ : pData(NULL)
+ , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
+#ifdef RTL_STRING_UNITTEST
+ rtl_string_unittest_const_literal = true;
+#endif
+ }
+
+#ifdef RTL_STRING_UNITTEST
+ /**
+ * Only used by unittests to detect incorrect conversions.
+ * @internal
+ */
+ template< typename T >
+ OUStringBuffer( T&, typename internal::ExceptConstCharArrayDetector< T >::Type = internal::Dummy() )
+ {
+ pData = 0;
+ nCapacity = 10;
+ rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
+ rtl_string_unittest_invalid_conversion = true;
+ }
+ /**
+ * Only used by unittests to detect incorrect conversions.
+ * @internal
+ */
+ template< typename T >
+ OUStringBuffer( const T&, typename internal::ExceptCharArrayDetector< T >::Type = internal::Dummy() )
+ {
+ pData = 0;
+ nCapacity = 10;
+ rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
+ rtl_string_unittest_invalid_conversion = true;
+ }
+#endif
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OUStringBuffer( const OUStringConcat< T1, T2 >& c )
+ {
+ const sal_Int32 l = c.length();
+ nCapacity = l + 16;
+ pData = rtl_uString_alloc( nCapacity );
+ sal_Unicode* end = c.addData( pData->buffer );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ // TODO realloc in case pData->>length is noticeably smaller than l ?
+ }
+#endif
+ /** Assign to this a copy of value.
+ */
+ OUStringBuffer& operator = ( const OUStringBuffer& value )
+ {
+ if (this != &value)
+ {
+ rtl_uStringbuffer_newFromStringBuffer(&pData,
+ value.nCapacity,
+ value.pData);
+ nCapacity = value.nCapacity;
+ }
+ return *this;
+ }
+
+ /**
+ Release the string data.
+ */
+ ~OUStringBuffer()
+ {
+ rtl_uString_release( pData );
+ }
+
+ /**
+ Fill the string data in the new string and clear the buffer.
+
+ This method is more efficient than the contructor of the string. It does
+ not copy the buffer.
+
+ @return the string previously contained in the buffer.
+ */
+ OUString makeStringAndClear()
+ {
+ return OUString(
+ rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
+ SAL_NO_ACQUIRE );
+ }
+
+ /**
+ Returns the length (character count) of this string buffer.
+
+ @return the number of characters in this string buffer.
+ */
+ sal_Int32 getLength() const
+ {
+ return pData->length;
+ }
+
+ /**
+ Checks if a string buffer is empty.
+
+ @return true if the string buffer is empty;
+ false, otherwise.
+
+ @since LibreOffice 4.1
+ */
+ bool isEmpty() const SAL_THROW(())
+ {
+ return pData->length == 0;
+ }
+
+ /**
+ Returns the current capacity of the String buffer.
+
+ The capacity
+ is the amount of storage available for newly inserted
+ characters. The real buffer size is 2 bytes longer, because
+ all strings are 0 terminated.
+
+ @return the current capacity of this string buffer.
+ */
+ sal_Int32 getCapacity() const
+ {
+ return nCapacity;
+ }
+
+ /**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ The new capacity will be at least as large as the maximum of the current
+ length (so that no contents of the buffer is destroyed) and the given
+ minimumCapacity. If the given minimumCapacity is negative, nothing is
+ changed.
+
+ @param minimumCapacity the minimum desired capacity.
+ */
+ void ensureCapacity(sal_Int32 minimumCapacity)
+ {
+ rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
+ }
+
+ /**
+ Sets the length of this String buffer.
+
+ If the <code>newLength</code> argument is less than the current
+ length of the string buffer, the string buffer is truncated to
+ contain exactly the number of characters given by the
+ <code>newLength</code> argument.
+ <p>
+ If the <code>newLength</code> argument is greater than or equal
+ to the current length, sufficient null characters
+ (<code>'&#92;u0000'</code>) are appended to the string buffer so that
+ length becomes the <code>newLength</code> argument.
+ <p>
+ The <code>newLength</code> argument must be greater than or equal
+ to <code>0</code>.
+
+ @param newLength the new length of the buffer.
+ */
+ void setLength(sal_Int32 newLength)
+ {
+ assert(newLength >= 0);
+ // Avoid modifications if pData points to const empty string:
+ if( newLength != pData->length )
+ {
+ if( newLength > nCapacity )
+ rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
+ else
+ pData->buffer[newLength] = 0;
+ pData->length = newLength;
+ }
+ }
+
+ /**
+ Returns the character at a specific index in this string buffer.
+
+ The first character of a string buffer is at index
+ <code>0</code>, the next at index <code>1</code>, and so on, for
+ array indexing.
+ <p>
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the desired character.
+ @return the character at the specified index of this string buffer.
+ */
+ SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
+ sal_Unicode charAt( sal_Int32 index ) const
+ {
+ assert(index >= 0 && index < pData->length);
+ return pData->buffer[ index ];
+ }
+
+ /**
+ The character at the specified index of this string buffer is set
+ to <code>ch</code>.
+
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the character to modify.
+ @param ch the new character.
+ */
+ SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
+ OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
+ {
+ assert(index >= 0 && index < pData->length);
+ pData->buffer[ index ] = ch;
+ return *this;
+ }
+
+ /**
+ Return a null terminated unicode character array.
+ */
+ const sal_Unicode* getStr() const { return pData->buffer; }
+
+ /**
+ Access to individual characters.
+
+ @param index must be non-negative and less than length.
+
+ @return a reference to the character at the given index.
+
+ @since LibreOffice 3.5
+ */
+ sal_Unicode & operator [](sal_Int32 index)
+ {
+ assert(index >= 0 && index < pData->length);
+ return pData->buffer[index];
+ }
+
+ /**
+ Return a OUString instance reflecting the current content
+ of this OUStringBuffer.
+ */
+ const OUString toString() const
+ {
+ return OUString(pData->buffer, pData->length);
+ }
+
+ /**
+ Appends the string to this string buffer.
+
+ The characters of the <code>OUString</code> argument are appended, in
+ order, to the contents of this string buffer, increasing the
+ length of this string buffer by the length of the argument.
+
+ @param str a string.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(const OUString &str)
+ {
+ return append( str.getStr(), str.getLength() );
+ }
+
+ /**
+ Appends the content of a stringbuffer to this string buffer.
+
+ The characters of the <code>OUStringBuffer</code> argument are appended, in
+ order, to the contents of this string buffer, increasing the
+ length of this string buffer by the length of the argument.
+
+ @param str a string.
+ @return this string buffer.
+
+ @since LibreOffice 4.0
+ */
+ OUStringBuffer & append(const OUStringBuffer &str)
+ {
+ if(str.getLength() > 0)
+ {
+ append( str.getStr(), str.getLength() );
+ }
+ return *this;
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ The characters of the array argument are appended, in order, to
+ the contents of this string buffer. The length of this string
+ buffer increases by the length of the argument.
+
+ @param str the characters to be appended.
+ @return this string buffer.
+ */
+ OUStringBuffer & append( const sal_Unicode * str )
+ {
+ return append( str, rtl_ustr_getLength( str ) );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ Characters of the character array <code>str</code> are appended,
+ in order, to the contents of this string buffer. The length of this
+ string buffer increases by the value of <code>len</code>.
+
+ @param str the characters to be appended; must be non-null, and must
+ point to at least len characters
+ @param len the number of characters to append; must be non-negative
+ @return this string buffer.
+ */
+ OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
+ return *this;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1 );
+ return *this;
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
+ sal_Unicode* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+
+ /**
+ Appends a 8-Bit ASCII character string to this string buffer.
+
+ Since this method is optimized for performance. the ASCII
+ character values are not converted in any way. The caller
+ has to make sure that all ASCII characters are in the
+ allowed range between 0 and 127. The ASCII string must be
+ NULL-terminated.
+ <p>
+ The characters of the array argument are appended, in order, to
+ the contents of this string buffer. The length of this string
+ buffer increases by the length of the argument.
+
+ @param str the 8-Bit ASCII characters to be appended.
+ @return this string buffer.
+ */
+ OUStringBuffer & appendAscii( const sal_Char * str )
+ {
+ return appendAscii( str, rtl_str_getLength( str ) );
+ }
+
+ /**
+ Appends a 8-Bit ASCII character string to this string buffer.
+
+ Since this method is optimized for performance. the ASCII
+ character values are not converted in any way. The caller
+ has to make sure that all ASCII characters are in the
+ allowed range between 0 and 127. The ASCII string must be
+ NULL-terminated.
+ <p>
+ Characters of the character array <code>str</code> are appended,
+ in order, to the contents of this string buffer. The length of this
+ string buffer increases by the value of <code>len</code>.
+
+ @param str the 8-Bit ASCII characters to be appended; must be non-null,
+ and must point to at least len characters
+ @param len the number of characters to append; must be non-negative
+ @return this string buffer.
+ */
+ OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
+ {
+ rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
+ return *this;
+ }
+
+ /**
+ Appends the string representation of the <code>bool</code>
+ argument to the string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param b a <code>bool</code>.
+ @return this string buffer.
+
+ @since LibreOffice 4.1
+ */
+ OUStringBuffer & append(bool b)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
+ }
+
+ // Pointer can be automatically converted to bool, which is unwanted here.
+ // Explicitly delete all pointer append() overloads to prevent this
+ // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
+ template< typename T >
+ typename internal::Enable< void,
+ !internal::CharPtrDetector< T* >::ok && !internal::SalUnicodePtrDetector< T* >::ok >::Type
+ append( T* ) SAL_DELETED_FUNCTION;
+
+ // This overload is needed because OUString has a ctor from rtl_uString*, but
+ // the bool overload above would be prefered to the conversion.
+ /**
+ @internal
+ */
+ OUStringBuffer & append(rtl_uString* str)
+ {
+ return append( OUString( str ));
+ }
+
+ /**
+ Appends the string representation of the <code>sal_Bool</code>
+ argument to the string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Bool b)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Appends the string representation of the ASCII <code>char</code>
+ argument to this string buffer.
+
+ The argument is appended to the contents of this string buffer.
+ The length of this string buffer increases by <code>1</code>.
+
+ @param c an ASCII <code>char</code>.
+ @return this string buffer.
+
+ @since LibreOffice 3.5
+ */
+ OUStringBuffer & append(char c)
+ {
+ assert(static_cast< unsigned char >(c) <= 0x7F);
+ return append(sal_Unicode(c));
+ }
+
+ /**
+ Appends the string representation of the <code>char</code>
+ argument to this string buffer.
+
+ The argument is appended to the contents of this string buffer.
+ The length of this string buffer increases by <code>1</code>.
+
+ @param c a <code>char</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Unicode c)
+ {
+ return append( &c, 1 );
+ }
+
+ /**
+ Appends the string representation of the <code>sal_Int32</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param i an <code>sal_Int32</code>.
+ @param radix the radix
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
+ return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>long</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param l a <code>long</code>.
+ @param radix the radix
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
+ return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>float</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param f a <code>float</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(float f)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
+ return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Appends the string representation of the <code>double</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param d a <code>double</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(double d)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
+ return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Appends a single UTF-32 character to this string buffer.
+
+ <p>The single UTF-32 character will be represented within the string
+ buffer as either one or two UTF-16 code units.</p>
+
+ @param c a well-formed UTF-32 code unit (that is, a value in the range
+ <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
+ <code>0xD800</code>&ndash;<code>0xDFFF</code>)
+
+ @return
+ this string buffer
+ */
+ OUStringBuffer & appendUtf32(sal_uInt32 c) {
+ return insertUtf32(getLength(), c);
+ }
+
+ /**
+ Inserts the string into this string buffer.
+
+ The characters of the <code>String</code> argument are inserted, in
+ order, into this string buffer at the indicated offset. The length
+ of this string buffer is increased by the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a string.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
+ {
+ return insert( offset, str.getStr(), str.getLength() );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a character array.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
+ {
+ return insert( offset, str, rtl_ustr_getLength( str ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a character array.
+ @param len the number of characters to append.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
+ return *this;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1 );
+ return *this;
+ }
+
+ /**
+ Inserts the string representation of the <code>sal_Bool</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code>
+ argument into this string buffer.
+
+ The second argument is inserted into the contents of this string
+ buffer at the position indicated by <code>offset</code>. The length
+ of this string buffer increases by one.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param c a <code>char</code>.
+ @return this string buffer.
+
+ @since LibreOffice 3.6
+ */
+ OUStringBuffer & insert(sal_Int32 offset, char c)
+ {
+ sal_Unicode u = c;
+ return insert( offset, &u, 1 );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code>
+ argument into this string buffer.
+
+ The second argument is inserted into the contents of this string
+ buffer at the position indicated by <code>offset</code>. The length
+ of this string buffer increases by one.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param c a <code>char</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
+ {
+ return insert( offset, &c, 1 );
+ }
+
+ /**
+ Inserts the string representation of the second <code>sal_Int32</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param i an <code>sal_Int32</code>.
+ @param radix the radix.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
+ return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>long</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param l a <code>long</code>.
+ @param radix the radix.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
+ return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>float</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param f a <code>float</code>.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer insert(sal_Int32 offset, float f)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
+ return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>double</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param d a <code>double</code>.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, double d)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
+ return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Inserts a single UTF-32 character into this string buffer.
+
+ <p>The single UTF-32 character will be represented within the string
+ buffer as either one or two UTF-16 code units.</p>
+
+ @param offset the offset into this string buffer (from zero to the length
+ of this string buffer, inclusive)
+
+ @param c a well-formed UTF-32 code unit (that is, a value in the range
+ <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
+ <code>0xD800</code>&ndash;<code>0xDFFF</code>)
+
+ @return this string buffer
+ */
+ OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
+ rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
+ return *this;
+ }
+
+ /**
+ Removes the characters in a substring of this sequence.
+
+ The substring begins at the specified <code>start</code> and
+ is <code>len</code> characters long.
+
+ start must be >= 0 && <= This->length
+
+ @param start The beginning index, inclusive
+ @param len The substring length
+ @return this string buffer.
+ */
+ OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
+ {
+ rtl_uStringbuffer_remove( &pData, start, len );
+ return *this;
+ }
+
+ /**
+ Removes the tail of a string buffer start at the indicate position
+
+ start must be >= 0 && <= This->length
+
+ @param start The beginning index, inclusive. default to 0
+ @return this string buffer.
+
+ @since LibreOffice 4.0
+ */
+ OUStringBuffer & truncate( sal_Int32 start = 0 )
+ {
+ rtl_uStringbuffer_remove( &pData, start, getLength() - start );
+ return *this;
+ }
+
+ /**
+ Replace all occurrences of
+ oldChar in this string buffer with newChar.
+
+ @since LibreOffice 4.0
+
+ @param oldChar the old character.
+ @param newChar the new character.
+ @return this string buffer
+ */
+ OUStringBuffer& replace( sal_Unicode oldChar, sal_Unicode newChar )
+ {
+ sal_Int32 index = 0;
+ while((index = indexOf(oldChar, index)) >= 0)
+ {
+ pData->buffer[ index ] = newChar;
+ }
+ return *this;
+ }
+
+ /** Allows access to the internal data of this OUStringBuffer, for effective
+ manipulation.
+
+ This method should be used with care. After you have called this
+ method, you may use the returned pInternalData or pInternalCapacity only
+ as long as you make no other method call on this OUStringBuffer.
+
+ @param pInternalData
+ This output parameter receives a pointer to the internal data
+ (rtl_uString pointer). pInternalData itself must not be null.
+
+ @param pInternalCapacity
+ This output parameter receives a pointer to the internal capacity.
+ pInternalCapacity itself must not be null.
+ */
+ inline void accessInternals(rtl_uString *** pInternalData,
+ sal_Int32 ** pInternalCapacity)
+ {
+ *pInternalData = &pData;
+ *pInternalCapacity = &nCapacity;
+ }
+
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified character, starting the search at the specified index.
+
+ @since LibreOffice 4.0
+
+ @param ch character to be located.
+ @param fromIndex the index to start the search from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return the index of the first occurrence of the character in the
+ character sequence represented by this string that is
+ greater than or equal to fromIndex, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting at the end.
+
+ @since LibreOffice 4.0
+
+ @param ch character to be located.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting before the specified
+ index.
+
+ @since LibreOffice 4.0
+
+ @param ch character to be located.
+ @param fromIndex the index before which to start the search.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string that
+ is less than fromIndex, or -1
+ if the character does not occur before that point.
+ */
+ sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified substring, starting at the specified index.
+
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @since LibreOffice 4.0
+
+ @param str the substring to search for.
+ @param fromIndex the index to start the search from.
+ @return If the string argument occurs one or more times as a substring
+ within this string at the starting index, then the index
+ of the first character of the first such substring is
+ returned. If it does not occur as a substring starting
+ at fromIndex or beyond, -1 is returned.
+ */
+ sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+
+ @since LibreOffice 4.0
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1);
+ return ret < 0 ? ret : ret + fromIndex;
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting at the end.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @since LibreOffice 4.0
+
+ @param str the substring to search for.
+ @return If the string argument occurs one or more times as a substring
+ within this string, then the index of the first character of
+ the last such substring is returned. If it does not occur as
+ a substring, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting before the specified
+ index.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @since LibreOffice 4.0
+
+ @param str the substring to search for.
+ @param fromIndex the index before which to start the search.
+ @return If the string argument occurs one or more times as a substring
+ within this string before the starting index, then the index
+ of the first character of the last such substring is
+ returned. Otherwise, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 4.0
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_ustr_lastIndexOfAscii_WithLength(
+ pData->buffer, pData->length, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
+ }
+
+ /**
+ Strip the given character from the start of the buffer.
+
+ @since LibreOffice 4.0
+
+ @param c the character to strip
+ @return The number of characters stripped
+
+ */
+ sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
+ {
+ sal_Int32 index;
+ for(index = 0; index < getLength() ; index++)
+ {
+ if(pData->buffer[ index ] != c)
+ {
+ break;
+ }
+ }
+ if(index)
+ {
+ remove(0, index);
+ }
+ return index;
+ }
+
+ /**
+ Strip the given character from the end of the buffer.
+
+ @since LibreOffice 4.0
+
+ @param c the character to strip
+ @return The number of characters stripped
+
+ */
+ sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
+ {
+ sal_Int32 result = getLength();
+ sal_Int32 index;
+ for(index = getLength(); index > 0 ; index--)
+ {
+ if(pData->buffer[ index - 1 ] != c)
+ {
+ break;
+ }
+ }
+ if(index < getLength())
+ {
+ truncate(index);
+ }
+ return result - getLength();
+ }
+ /**
+ Strip the given character from the both end of the buffer.
+
+ @since LibreOffice 4.0
+
+ @param c the character to strip
+ @return The number of characters stripped
+
+ */
+ sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
+ {
+ return stripStart(c) + stripEnd(c);
+ }
+ /**
+ Returns a new string buffer that is a substring of this string.
+
+ The substring begins at the specified beginIndex. If
+ beginIndex is negative or be greater than the length of
+ this string, behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @return the specified substring.
+ @since LibreOffice 4.1
+ */
+ OUStringBuffer copy( sal_Int32 beginIndex ) const SAL_THROW(())
+ {
+ assert(beginIndex >= 0 && beginIndex <= getLength());
+ return copy( beginIndex, getLength() - beginIndex );
+ }
+
+ /**
+ Returns a new string buffer that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. If either beginIndex or count are negative,
+ or beginIndex + count are greater than the length of this string
+ then behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @param count the number of characters.
+ @return the specified substring.
+ @since LibreOffice 4.1
+ */
+ OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
+ {
+ assert(beginIndex >= 0 && beginIndex <= getLength());
+ assert(count >= 0 && count <= getLength() - beginIndex);
+ rtl_uString *pNew = 0;
+ rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
+ return OUStringBuffer( pNew, count + 16 );
+ }
+
+#ifdef LIBO_INTERNAL_ONLY
+ // This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
+ // even two buffers. It's intentional it returns OUString, just like the operator+ would in the fast variant.
+#ifndef RTL_FAST_STRING
+ /**
+ @internal
+ @since LibreOffice 4.1
+ */
+ friend OUString operator+( const OUStringBuffer& str1, const OUStringBuffer& str2 ) SAL_THROW(())
+ {
+ return OUString( str1.pData ).concat( str2.pData );
+ }
+#endif
+#endif
+
+private:
+ OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
+ {
+ pData = value;
+ nCapacity = capacity;
+ }
+
+ /**
+ A pointer to the data structur which contains the data.
+ */
+ rtl_uString * pData;
+
+ /**
+ The len of the pData->buffer.
+ */
+ sal_Int32 nCapacity;
+};
+
+#ifdef RTL_FAST_STRING
+/**
+ @internal
+*/
+template<>
+struct ToStringHelper< OUStringBuffer >
+ {
+ static int length( const OUStringBuffer& s ) { return s.getLength(); }
+ static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
+ static const bool allowOStringConcat = false;
+ static const bool allowOUStringConcat = true;
+ };
+#endif
+
+}
+
+#ifdef RTL_STRING_UNITTEST
+namespace rtl
+{
+typedef rtlunittest::OUStringBuffer OUStringBuffer;
+}
+#endif
+
+#ifdef RTL_USING
+using ::rtl::OUStringBuffer;
+#endif
+
+#endif /* _RTL_USTRBUF_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
new file mode 100644
index 000000000000..da6720b3bcf6
--- /dev/null
+++ b/include/rtl/ustring.h
@@ -0,0 +1,2022 @@
+/* -*- 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 _RTL_USTRING_H_
+#define _RTL_USTRING_H_
+
+#include "sal/config.h"
+
+#include "osl/interlck.h"
+#include "rtl/string.h"
+#include "rtl/textenc.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ======================================================================= */
+
+/** Return the length of a string.
+
+ The length is equal to the number of 16-bit Unicode characters in the
+ string, without the terminating NUL character.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the length of the sequence of characters represented by this string,
+ excluding the terminating NUL character.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_getLength(
+ const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting. Both strings must be
+ null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare(
+ const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string
+ compares less than the second string, and a value greater than 0 if the
+ first string compares greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_reverseCompare_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front for equality.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns 'true' if, ans only if, both strings are equal.
+ This function cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified len.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified len.
+
+ @param len
+ the length of both strings.
+
+ @return
+ true if both strings are equal, false if they are not equal.
+ */
+
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength(
+ const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting. Both strings must be null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase(
+ const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters, ignoring the case
+ of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting. Both strings must be
+ null-terminated.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare(
+ const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second ASCII string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string
+ compares less than the second string, and a value greater than 0 if the
+ first string compares greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting. Both strings must be null-terminated.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase(
+ const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ sal_Unicode const * first, sal_Int32 firstLen,
+ char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters, ignoring the case
+ of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+ const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes. The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ a hash code for the given string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
+ const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @return
+ a hash code for the given string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
+ const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar(
+ const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength(
+ const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar(
+ const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength(
+ const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr(
+ const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength(
+ const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of an ASCII substring within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string; must be non-negative.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param subLen
+ the length of the substring; must be non-negative.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ If subLen is zero, -1 is returned.
+
+ @since UDK 3.2.7
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfAscii_WithLength(
+ sal_Unicode const * str, sal_Int32 len,
+ char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr(
+ const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength(
+ const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of an ASCII substring within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string; must be non-negative.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param subLen
+ the length of the substring; must be non-negative.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ If subLen is zero, -1 is returned.
+
+ @since UDK 3.2.7
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfAscii_WithLength(
+ sal_Unicode const * str, sal_Int32 len,
+ char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar(
+ sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar_WithLength(
+ sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase(
+ sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength(
+ sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase(
+ sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength(
+ sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of a string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the new length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim(
+ sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of the string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the original length of the string.
+
+ @return
+ the new length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim_WithLength(
+ sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Create the string representation of a boolean.
+
+ If b is true, the buffer is filled with the string "true" and 5 is
+ returned. If b is false, the buffer is filled with the string "false" and
+ 6 is returned. This function cannot be used for language-specific
+ operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFBOOLEAN define to
+ create a buffer that is big enough.
+
+ @param b
+ a boolean value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean(
+ sal_Unicode * str, sal_Bool b ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
+
+/** Create the string representation of a character.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFCHAR define to create a
+ buffer that is big enough.
+
+ @param ch
+ a character value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfChar(
+ sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
+
+/** Create the string representation of an integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFINT32 define to create
+ a buffer that is big enough.
+
+ @param i
+ an integer value.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(
+ sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MIN_RADIX RTL_STR_MIN_RADIX
+#define RTL_USTR_MAX_RADIX RTL_STR_MAX_RADIX
+#define RTL_USTR_MAX_VALUEOFINT32 RTL_STR_MAX_VALUEOFINT32
+
+/** Create the string representation of a long integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFINT64 define to create
+ a buffer that is big enough.
+
+ @param l
+ a long integer value.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(
+ sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
+
+/** Create the string representation of an unsigned long integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFUINT64 define to create
+ a buffer that is big enough.
+
+ @param l
+ a long integer value.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfUInt64(
+ sal_Unicode * str, sal_uInt64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
+
+/** Create the string representation of a float.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFFLOAT define to create
+ a buffer that is big enough.
+
+ @param f
+ a float value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(
+ sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
+
+/** Create the string representation of a double.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFDOUBLE define to create
+ a buffer that is big enough.
+
+ @param d
+ a double value.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(
+ sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
+
+/** Interpret a string as a boolean.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ true if the string is "1" or "true" in any ASCII case, false otherwise.
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_toBoolean(
+ const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as an integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the integer value represented by the string, or 0 if the string does not
+ represent an integer.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
+ const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a long integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the long integer value represented by the string, or 0 if the string does
+ not represent a long integer.
+ */
+SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64(
+ const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as an unsigned long integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the unsigned long integer value represented by the string, or 0 if the
+ string does not represent an unsigned long integer.
+
+ @since LibreOffice 4.1
+ */
+SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_toUInt64(
+ const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a float.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a float.
+ */
+SAL_DLLPUBLIC float SAL_CALL rtl_ustr_toFloat(
+ const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a double.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a double.
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
+ const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+#if defined(SAL_W32)
+#pragma pack(push, 4)
+#endif
+
+/** @cond INTERNAL */
+/** The implementation of a Unicode string.
+*/
+typedef struct _rtl_uString
+{
+ oslInterlockedCount refCount; /* opaque */
+ sal_Int32 length;
+ sal_Unicode buffer[1];
+} rtl_uString;
+/** @endcond */
+
+#if defined(SAL_W32)
+#pragma pack(pop)
+#endif
+
+/* ----------------------------------------------------------------------- */
+
+/** Increment the reference count of a string.
+
+ @param str
+ a string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_acquire(
+ rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Decrement the reference count of a string.
+
+ If the count goes to zero than the string data is deleted.
+
+ @param str
+ a string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_release(
+ rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing no characters.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
+ rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
+ The reference count of the new string will be 1. The length of the string
+ will be nLen. This function does not handle out-of-memory conditions.
+
+ For nLen < 0 or failed allocation this method returns NULL.
+
+ The characters of the capacity are not cleared, and the length is set to
+ nLen, unlike the similar method of rtl_uString_new_WithLength which
+ zeros out the buffer, and sets the length to 0. So should be somewhat
+ more efficient for allocating a new string.
+
+ call rtl_uString_release to release the string
+ alternatively pass ownership to an OUString with
+ rtl::OUString(newStr, SAL_NO_ACQUIRE);
+
+ @param[in] nLen the number of characters.
+ @return pointer to the new string.
+
+ @since LibreOffice 4.1
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
+ If len is greater than zero, the reference count of the new string will be
+ 1. The values of all characters are set to 0 and the length of the string
+ is 0. This function does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param nLen
+ the number of characters.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_new_WithLength(
+ rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of another string.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromString(
+ rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a null-terminated character array.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr(
+ rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a character array. Need not be null-terminated, but must be at least as
+ long as the specified len.
+
+ @param len
+ the length of the character array.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr_WithLength(
+ rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. Meaningless combinations such as negative beginIndex,
+ or beginIndex + count greater than the length of the string have
+ undefined behaviour.
+
+ @param[out] newStr the specified substring.
+ @param[in] from the String to take the substring from.
+ @param[in] beginIndex the beginning index, inclusive.
+ @param[in] count the number of characters.
+ @return the specified substring.
+
+ @since LibreOffice 4.0
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromSubString(
+ rtl_uString ** newStr, const rtl_uString * from,
+ sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a null-terminated ASCII character array.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromAscii(
+ rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
+
+/**
+ @internal
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromLiteral(
+ rtl_uString ** newStr, const sal_Char * value, sal_Int32 len,
+ sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string from an array of Unicode code points.
+
+ @param newString
+ a non-null pointer to a (possibly null) rtl_uString pointer, which (if
+ non-null) will have been passed to rtl_uString_release before the function
+ returns. Upon return, points to the newly allocated string or to null if
+ there was either an out-of-memory condition or the resulting number of
+ UTF-16 code units would have been larger than SAL_MAX_INT32. The newly
+ allocated string (if any) must ultimately be passed to rtl_uString_release.
+
+ @param codePoints
+ an array of at least codePointCount code points, which each must be in the
+ range from 0 to 0x10FFFF, inclusive. May be null if codePointCount is zero.
+
+ @param codePointCount
+ the non-negative number of code points.
+
+ @since UDK 3.2.7
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromCodePoints(
+ rtl_uString ** newString, sal_uInt32 const * codePoints,
+ sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
+
+/** Assign a new value to a string.
+
+ First releases any value str might currently hold, then acquires
+ rightValue.
+
+ @param str
+ pointer to the string. The pointed-to data must be null or a valid
+ string.
+
+ @param rightValue
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_assign(
+ rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
+
+/** Return the length of a string.
+
+ The length is equal to the number of characters in the string.
+
+ @param str
+ a valid string.
+
+ @return
+ the length of the string.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getLength(
+ const rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Return a pointer to the underlying character array of a string.
+
+ @param str
+ a valid string.
+
+ @return
+ a pointer to the null-terminated character array.
+ */
+SAL_DLLPUBLIC sal_Unicode * SAL_CALL rtl_uString_getStr(
+ rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string that is the concatenation of two other strings.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where one of the two other strings is empty), so it must not be modified
+ without checking the reference count. This function does not handle
+ out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param left
+ a valid string.
+
+ @param right
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
+ rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing a substring of another string.
+
+ The new string results from replacing a number of characters (count),
+ starting at the specified position (index) in the original string (str),
+ with some new substring (subStr). If subStr is null, than only a number
+ of characters is deleted.
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param idx
+ the index into str at which to start replacement. Must be between 0 and
+ the length of str, inclusive.
+
+ @param count
+ the number of characters to remove. Must not be negative, and the sum of
+ index and count must not exceed the length of str.
+
+ @param subStr
+ either null or a valid string to be inserted.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceStrAt(
+ rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a single character
+ within another string.
+
+ The new string results from replacing all occurrences of oldChar in str
+ with newChar.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where oldChar does not occur in str), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplace(
+ rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing the first occurrence of a given substring
+ with another substring.
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null
+
+ @param to pointer to the replacing substring; must not be null
+
+ @param[in,out] index pointer to a start index, must not be null; upon entry
+ to the function its value is the index into the original string at which to
+ start searching for the \p from substring, the value must be non-negative
+ and not greater than the original string's length; upon exit from the
+ function its value is the index into the original string at which the
+ replacement took place or -1 if no replacement took place
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirst(
+ rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
+ rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing the first occurrence of a given substring
+ with another substring.
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p fromLength ASCII bytes
+
+ @param fromLength the length of the \p from substring; must be non-negative
+
+ @param to pointer to the replacing substring; must not be null
+
+ @param[in,out] index pointer to a start index, must not be null; upon entry
+ to the function its value is the index into the original string at which to
+ start searching for the \p from substring, the value must be non-negative
+ and not greater than the original string's length; upon exit from the
+ function its value is the index into the original string at which the
+ replacement took place or -1 if no replacement took place
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiL(
+ rtl_uString ** newStr, rtl_uString * str, char const * from,
+ sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index)
+ SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing the first occurrence of a given substring
+ with another substring.
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p fromLength ASCII bytes
+
+ @param fromLength the length of the \p from substring; must be non-negative
+
+ @param to pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p toLength ASCII bytes
+
+ @param toLength the length of the \p to substring; must be non-negative
+
+ @param[in,out] index pointer to a start index, must not be null; upon entry
+ to the function its value is the index into the original string at which to
+ start searching for the \p from substring, the value must be non-negative
+ and not greater than the original string's length; upon exit from the
+ function its value is the index into the original string at which the
+ replacement took place or -1 if no replacement took place
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiLAsciiL(
+ rtl_uString ** newStr, rtl_uString * str, char const * from,
+ sal_Int32 fromLength, char const * to, sal_Int32 toLength,
+ sal_Int32 * index) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a given substring with
+ another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null
+
+ @param to pointer to the replacing substring; must not be null
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAll(
+ rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
+ rtl_uString const * to) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a given substring with
+ another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null
+
+ @param to pointer to the replacing substring; must not be null
+
+ @param fromIndex the position in the string where we will begin searching
+
+ @since LibreOffice 4.0
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllFromIndex(
+ rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
+ rtl_uString const * to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a given substring with
+ another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p fromLength ASCII bytes
+
+ @param fromLength the length of the \p from substring; must be non-negative
+
+ @param to pointer to the replacing substring; must not be null
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiL(
+ rtl_uString ** newStr, rtl_uString * str, char const * from,
+ sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a given substring with
+ another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param[in, out] newStr pointer to the new string; must not be null; must
+ point to null or a valid rtl_uString
+
+ @param str pointer to the original string; must not be null
+
+ @param from pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p fromLength ASCII bytes
+
+ @param fromLength the length of the \p from substring; must be non-negative
+
+ @param to pointer to the substring to be replaced; must not be null and
+ must point to memory of at least \p toLength ASCII bytes
+
+ @param toLength the length of the \p to substring; must be non-negative
+
+ @since LibreOffice 3.6
+*/
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiLAsciiL(
+ rtl_uString ** newStr, rtl_uString * str, char const * from,
+ sal_Int32 fromLength, char const * to, sal_Int32 toLength)
+ SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII uppercase letters to lowercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiLowerCase(
+ rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII lowercase letters to uppercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiUpperCase(
+ rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by removing white space from both ends of another
+ string.
+
+ The new string results from removing all characters with values less than
+ or equal to 32 (the space character) form both ends of str.
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be removed), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
+ rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by extracting a single token from another string.
+
+ Starting at index, the token's next token is searched for. If there is no
+ such token, the result is an empty string. Otherwise, all characters from
+ the start of that token and up to, but not including the next occurrence
+ of cTok make up the resulting token. The return value is the position of
+ the next token, or -1 if no more tokens follow.
+
+ Example code could look like
+ rtl_uString * pToken = NULL;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
+ ...
+ }
+ while (nIndex >= 0);
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string. If either token or index is negative, an empty token is stored in
+ newStr (and -1 is returned).
+
+ @param str
+ a valid string.
+
+ @param token
+ the number of the token to return, starting at index.
+
+ @param cTok
+ the character that separates the tokens.
+
+ @param idx
+ the position at which searching for the token starts. Must not be greater
+ than the length of str.
+
+ @return
+ the index of the next token, or -1 if no more tokens follow.
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getToken(
+ rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+/** Supply an ASCII string literal together with its length and text encoding.
+
+ This macro can be used to compute (some of) the arguments in function calls
+ like rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).
+
+ @param constAsciiStr
+ must be an expression of type "(possibly cv-qualified reference to) array of
+ (possibly cv-qualified) char." Each element of the referenced array must
+ represent an ASCII value in the range 0x00--0x7F. The last element of the
+ referenced array is not considered part of the represented ASCII string, and
+ its value should be 0x00. Depending on where this macro is used, the nature
+ of the supplied expression might be further restricted.
+*/
+// The &foo[0] trick is intentional, it makes sure the type is char* or const char*
+// (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
+// This is to avoid mistaken use with functions that accept string literals
+// (i.e. const char (&)[N]) where usage of this macro otherwise could match
+// the argument and a following int argument with a default value (e.g. OUString::match()).
+#define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
+ ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
+
+/* ======================================================================= */
+
+/* predefined constants for String-Conversion */
+#define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
+
+/* ----------------------------------------------------------------------- */
+
+/** Create a new Unicode string by converting a byte string, using a specific
+ text encoding.
+
+ The lengths of the byte string and the Unicode string may differ (e.g.,
+ for double-byte encodings, UTF-7, UTF-8).
+
+ If the length of the byte string is greater than zero, the reference count
+ of the new string will be 1.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a byte character array. Need not be null-terminated, but must be at
+ least as long as the specified len.
+
+ @param len
+ the length of the byte character array.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OSTRING_TO_OUSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string2UString(
+ rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+/* Interning methods */
+
+/** Return a canonical representation for a string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param str
+ pointer to the string to be interned.
+
+ @since UDK 3.2.7
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_intern(
+ rtl_uString ** newStr, rtl_uString * str) SAL_THROW_EXTERN_C();
+
+/** Return a canonical representation for a string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param str
+ a byte character array. Need not be null-terminated, but must be at
+ least as long as the specified len.
+
+ @param len
+ the length of the byte character array.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OSTRING_TO_OUSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+
+ @param pInfo
+ pointer to return conversion status in, or NULL.
+
+ @since UDK 3.2.7
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_internConvert(
+ rtl_uString ** newStr,
+ const sal_Char * str,
+ sal_Int32 len,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags,
+ sal_uInt32 *pInfo) SAL_THROW_EXTERN_C();
+
+/** Iterate through a string based on code points instead of UTF-16 code units.
+
+ See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
+ definitions of the various terms used in this description.
+
+ The given string is interpreted as a sequence of zero or more UTF-16 code
+ units. For each index into this sequence (from zero to one less than the
+ length of the sequence, inclusive), a code point represented starting at the
+ given index is computed as follows:
+
+ - If the UTF-16 code unit addressed by the index constitutes a well-formed
+ UTF-16 code unit sequence, the computed code point is the scalar value
+ encoded by that UTF-16 code unit sequence.
+
+ - Otherwise, if the index is at least two UTF-16 code units away from the
+ end of the sequence, and the sequence of two UTF-16 code units addressed by
+ the index constitutes a well-formed UTF-16 code unit sequence, the computed
+ code point is the scalar value encoded by that UTF-16 code unit sequence.
+
+ - Otherwise, the computed code point is the UTF-16 code unit addressed by
+ the index. (This last case catches unmatched surrogates as well as indices
+ pointing into the middle of surrogate pairs.)
+
+ @param string
+ pointer to a valid string; must not be null.
+
+ @param indexUtf16
+ pointer to a UTF-16 based index into the given string; must not be null. On
+ entry, the index must be in the range from zero to the length of the string
+ (in UTF-16 code units), inclusive. Upon successful return, the index will
+ be updated to address the UTF-16 code unit that is the given
+ incrementCodePoints away from the initial index.
+
+ @param incrementCodePoints
+ the number of code points to move the given *indexUtf16. If non-negative,
+ moving is done after determining the code point at the index. If negative,
+ moving is done before determining the code point at the (then updated)
+ index. The value must be such that the resulting UTF-16 based index is in
+ the range from zero to the length of the string (in UTF-16 code units),
+ inclusive.
+
+ @return
+ the code point (an integer in the range from 0 to 0x10FFFF, inclusive) that
+ is represented within the string starting at the index computed as follows:
+ If incrementCodePoints is non-negative, the index is the initial value of
+ *indexUtf16; if incrementCodePoints is negative, the index is the updated
+ value of *indexUtf16. In either case, the computed index must be in the
+ range from zero to one less than the length of the string (in UTF-16 code
+ units), inclusive.
+
+ @since UDK 3.2.7
+*/
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
+ rtl_uString const * string, sal_Int32 * indexUtf16,
+ sal_Int32 incrementCodePoints);
+
+/** Converts a byte string to a Unicode string, signalling failure.
+
+ @param target
+ An out parameter receiving the converted string. Must not be null itself,
+ and must contain either null or a pointer to a valid rtl_uString; the
+ contents are unspecified if conversion fails (rtl_convertStringToUString
+ returns false).
+
+ @param source
+ The byte string. May only be null if length is zero.
+
+ @param length
+ The length of the byte string. Must be non-negative.
+
+ @param encoding
+ The text encoding to convert from. Must be an octet encoding (i.e.,
+ rtl_isOctetTextEncoding(encoding) must return true).
+
+ @param flags
+ A combination of RTL_TEXTTOUNICODE_FLAGS that detail how to do the
+ conversion (see rtl_convertTextToUnicode). RTL_TEXTTOUNICODE_FLAGS_FLUSH
+ need not be included, it is implicitly assumed. Typical uses are either
+ RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR (fail if a byte or multi-byte sequence
+ cannot be converted from the source encoding) or
+ OSTRING_TO_OUSTRING_CVTFLAGS (make a best efforts conversion).
+
+ @return
+ True if the conversion succeeded, false otherwise.
+
+ @since UDK 3.2.9
+*/
+SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertStringToUString(
+ rtl_uString ** target, char const * source, sal_Int32 length,
+ rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
+
+/** Ensure a string has enough space for a given number of characters.
+
+ If the given string is large enough and has refcount of 1, it is not altered in any way.
+ Otherwise it is replaced by a copy that has enough space for the given number of characters,
+ data from the source string is copied to the beginning of it, the content of the remaining
+ capacity undefined, the string has refcount of 1, and refcount of the original string is decreased.
+
+ @param str
+ pointer to the string. The pointed-to data must be a valid string.
+
+ @param size
+ the number of characters
+
+ @since LibreOffice 4.1
+ @internal
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_ensureCapacity( rtl_uString ** str, sal_Int32 size ) SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_USTRING_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
new file mode 100644
index 000000000000..13756f868198
--- /dev/null
+++ b/include/rtl/ustring.hxx
@@ -0,0 +1,2416 @@
+/* -*- 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 _RTL_USTRING_HXX_
+#define _RTL_USTRING_HXX_
+
+#include "sal/config.h"
+
+#include <cassert>
+#include <ostream>
+#include <string.h>
+
+#include "osl/diagnose.h"
+#include <rtl/ustring.h>
+#include <rtl/string.hxx>
+#include <rtl/stringutils.hxx>
+#include <rtl/textenc.h>
+#include "sal/log.hxx"
+
+#ifdef RTL_FAST_STRING
+#include <rtl/stringconcat.hxx>
+#endif
+
+#if defined EXCEPTIONS_OFF
+#include <stdlib.h>
+#else
+#include <new>
+#endif
+
+// The unittest uses slightly different code to help check that the proper
+// calls are made. The class is put into a different namespace to make
+// sure the compiler generates a different (if generating also non-inline)
+// copy of the function and does not merge them together. The class
+// is "brought" into the proper rtl namespace by a typedef below.
+#ifdef RTL_STRING_UNITTEST
+#define rtl rtlunittest
+#endif
+
+namespace rtl
+{
+
+#ifdef RTL_STRING_UNITTEST
+#undef rtl
+#endif
+
+/* ======================================================================= */
+
+/**
+ This String class provides base functionality for C++ like Unicode
+ character array handling. The advantage of this class is that it
+ handles all the memory management for you - and it does it
+ more efficiently. If you assign a string to another string, the
+ data of both strings are shared (without any copy operation or
+ memory allocation) as long as you do not change the string. This class
+ also stores the length of the string, so that many operations are
+ faster than the C-str-functions.
+
+ This class provides only readonly string handling. So you could create
+ a string and you could only query the content from this string.
+ It provides also functionality to change the string, but this results
+ in every case in a new string instance (in the most cases with a
+ memory allocation). You don't have functionality to change the
+ content of the string. If you want to change the string content, then
+ you should use the OStringBuffer class, which provides these
+ functionalities and avoids too much memory allocation.
+
+ The design of this class is similar to the string classes in Java so
+ less people should have understanding problems when they use this class.
+*/
+
+class SAL_WARN_UNUSED OUString
+{
+public:
+ /// @cond INTERNAL
+ rtl_uString * pData;
+ /// @endcond
+
+private:
+ class DO_NOT_ACQUIRE{};
+
+ OUString( rtl_uString * value, SAL_UNUSED_PARAMETER DO_NOT_ACQUIRE * )
+ {
+ pData = value;
+ }
+
+public:
+ /**
+ New string containing no characters.
+ */
+ OUString() SAL_THROW(())
+ {
+ pData = 0;
+ rtl_uString_new( &pData );
+ }
+
+ /**
+ New string from OUString.
+
+ @param str a OUString.
+ */
+ OUString( const OUString & str ) SAL_THROW(())
+ {
+ pData = str.pData;
+ rtl_uString_acquire( pData );
+ }
+
+ /**
+ New string from OUString data.
+
+ @param str a OUString data.
+ */
+ OUString( rtl_uString * str ) SAL_THROW(())
+ {
+ pData = str;
+ rtl_uString_acquire( pData );
+ }
+
+ /** New OUString from OUString data without acquiring it. Takeover of ownership.
+
+ The SAL_NO_ACQUIRE dummy parameter is only there to distinguish this
+ from other constructors.
+
+ @param str
+ OUString data
+ */
+ inline OUString( rtl_uString * str, __sal_NoAcquire ) SAL_THROW(())
+ { pData = str; }
+
+ /**
+ New string from a single Unicode character.
+
+ @param value a Unicode character.
+ */
+ explicit OUString( sal_Unicode value ) SAL_THROW(())
+ : pData (0)
+ {
+ rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
+ }
+
+ /**
+ New string from a Unicode character buffer array.
+
+ @param value a NULL-terminated Unicode character array.
+ */
+ OUString( const sal_Unicode * value ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_uString_newFromStr( &pData, value );
+ }
+
+ /**
+ New string from a Unicode character buffer array.
+
+ @param value a Unicode character array.
+ @param length the number of character which should be copied.
+ The character array length must be greater than
+ or equal to this value.
+ */
+ OUString( const sal_Unicode * value, sal_Int32 length ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_uString_newFromStr_WithLength( &pData, value, length );
+ }
+
+ /**
+ New string from an 8-Bit string literal that is expected to contain only
+ characters in the ASCII set (i.e. first 128 characters). This constructor
+ allows an efficient and convenient way to create OUString
+ instances from ASCII literals. When creating strings from data that
+ is not pure ASCII, it needs to be converted to OUString by explicitly
+ providing the encoding to use for the conversion.
+
+ If there are any embedded \0's in the string literal, the result is undefined.
+ Use the overload that explicitly accepts length.
+
+ @param literal the 8-bit ASCII string literal
+
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ OUString( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ pData = 0;
+ if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
+ rtl_uString_new( &pData );
+ else
+ rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+#ifdef RTL_STRING_UNITTEST
+ rtl_string_unittest_const_literal = true;
+#endif
+ }
+
+#ifdef RTL_STRING_UNITTEST
+ /**
+ * Only used by unittests to detect incorrect conversions.
+ * @internal
+ */
+ template< typename T >
+ OUString( T&, typename internal::ExceptConstCharArrayDetector< T >::Type = internal::Dummy() )
+ {
+ pData = 0;
+ rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
+ rtl_string_unittest_invalid_conversion = true;
+ }
+ /**
+ * Only used by unittests to detect incorrect conversions.
+ * @internal
+ */
+ template< typename T >
+ OUString( const T&, typename internal::ExceptCharArrayDetector< T >::Type = internal::Dummy() )
+ {
+ pData = 0;
+ rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
+ rtl_string_unittest_invalid_conversion = true;
+ }
+#endif
+
+ /**
+ New string from an 8-Bit character buffer array.
+
+ @param value An 8-Bit character array.
+ @param length The number of character which should be converted.
+ The 8-Bit character array length must be
+ greater than or equal to this value.
+ @param encoding The text encoding from which the 8-Bit character
+ sequence should be converted.
+ @param convertFlags Flags which control the conversion.
+ see RTL_TEXTTOUNICODE_FLAGS_...
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+ */
+ OUString( const sal_Char * value, sal_Int32 length,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
+ {
+ pData = 0;
+ rtl_string2UString( &pData, value, length, encoding, convertFlags );
+ if (pData == 0) {
+#if defined EXCEPTIONS_OFF
+ abort();
+#else
+ throw std::bad_alloc();
+#endif
+ }
+ }
+
+ /** Create a new string from an array of Unicode code points.
+
+ @param codePoints
+ an array of at least codePointCount code points, which each must be in
+ the range from 0 to 0x10FFFF, inclusive. May be null if codePointCount
+ is zero.
+
+ @param codePointCount
+ the non-negative number of code points.
+
+ @exception std::bad_alloc
+ is thrown if either an out-of-memory condition occurs or the resulting
+ number of UTF-16 code units would have been larger than SAL_MAX_INT32.
+
+ @since UDK 3.2.7
+ */
+ inline explicit OUString(
+ sal_uInt32 const * codePoints, sal_Int32 codePointCount):
+ pData(NULL)
+ {
+ rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
+ if (pData == NULL) {
+#if defined EXCEPTIONS_OFF
+ abort();
+#else
+ throw std::bad_alloc();
+#endif
+ }
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OUString( const OUStringConcat< T1, T2 >& c )
+ {
+ const sal_Int32 l = c.length();
+ pData = rtl_uString_alloc( l );
+ if (l != 0)
+ {
+ sal_Unicode* end = c.addData( pData->buffer );
+ pData->length = end - pData->buffer;
+ *end = '\0';
+ // TODO realloc in case pData->length is noticeably smaller than l?
+ }
+ }
+#endif
+
+ /**
+ Release the string data.
+ */
+ ~OUString() SAL_THROW(())
+ {
+ rtl_uString_release( pData );
+ }
+
+ /** Provides an OUString const & passing a storage pointer of an
+ rtl_uString * handle.
+ It is more convenient to use C++ OUString member functions when dealing
+ with rtl_uString * handles. Using this function avoids unnecessary
+ acquire()/release() calls for a temporary OUString object.
+
+ @param ppHandle
+ pointer to storage
+ @return
+ OUString const & based on given storage
+ */
+ static inline OUString const & unacquired( rtl_uString * const * ppHandle )
+ { return * reinterpret_cast< OUString const * >( ppHandle ); }
+
+ /**
+ Assign a new string.
+
+ @param str a OUString.
+ */
+ OUString & operator=( const OUString & str ) SAL_THROW(())
+ {
+ rtl_uString_assign( &pData, str.pData );
+ return *this;
+ }
+
+ /**
+ Assign a new string from an 8-Bit string literal that is expected to contain only
+ characters in the ASCII set (i.e. first 128 characters). This operator
+ allows an efficient and convenient way to assign OUString
+ instances from ASCII literals. When assigning strings from data that
+ is not pure ASCII, it needs to be converted to OUString by explicitly
+ providing the encoding to use for the conversion.
+
+ @param literal the 8-bit ASCII string literal
+
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
+ rtl_uString_new( &pData );
+ else
+ rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+ return *this;
+ }
+
+ /**
+ Append a string to this string.
+
+ @param str a OUString.
+ */
+ OUString & operator+=( const OUString & str ) SAL_THROW(())
+ {
+ rtl_uString_newConcat( &pData, pData, str.pData );
+ return *this;
+ }
+
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OUString& operator+=( const OUStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_uString_ensureCapacity( &pData, pData->length + l );
+ sal_Unicode* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+
+ /**
+ Returns the length of this string.
+
+ The length is equal to the number of Unicode characters in this string.
+
+ @return the length of the sequence of characters represented by this
+ object.
+ */
+ sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
+
+ /**
+ Checks if a string is empty.
+
+ @return true if the string is empty;
+ false, otherwise.
+
+ @since LibreOffice 3.4
+ */
+ bool isEmpty() const SAL_THROW(())
+ {
+ return pData->length == 0;
+ }
+
+ /**
+ Returns a pointer to the Unicode character buffer for this string.
+
+ It isn't necessarily NULL terminated.
+
+ @return a pointer to the Unicode characters buffer for this object.
+ */
+ const sal_Unicode * getStr() const SAL_THROW(()) { return pData->buffer; }
+
+ /**
+ Access to individual characters.
+
+ @param index must be non-negative and less than length.
+
+ @return the character at the given index.
+
+ @since LibreOffice 3.5
+ */
+ sal_Unicode operator [](sal_Int32 index) const {
+ assert(index >= 0 && index <= getLength());
+ //TODO: should really check for < getLength(), but there is quite
+ // some clever code out there that violates this function's
+ // documented precondition and relies on s[s.getLength()] == 0 and
+ // that would need to be fixed first
+ return getStr()[index];
+ }
+
+ /**
+ Compares two strings.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Compares two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @param maxLength the maximum count of characters to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+
+ @since UDK 3.2.7
+ */
+ sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const SAL_THROW(())
+ {
+ return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length, maxLength );
+ }
+
+ /**
+ Compares two strings in reverse order.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 reverseCompareTo( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 4.1
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
+ literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equals( const OUString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ Compare the two strings with uppercase ASCII
+ character values between 65 and 90 (ASCII A-Z) interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+
+ @since LibreOffice 4.0
+ */
+ sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ if ( pData->length != internal::ConstCharArrayDetector< T, void >::size - 1 )
+ return sal_False;
+
+ return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, literal ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater than or equal to 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length, str.pData->length ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string, ignoring the case of
+ ASCII letters.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater than or equal to 0
+ and less than or equal to the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length,
+ str.pData->length ) == 0;
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ }
+
+ /**
+ Compares two strings.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific sorting.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareToAscii( const sal_Char* asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
+ }
+
+ /**
+ Compares two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific sorting.
+
+ @deprecated This is a confusing overload with unexpectedly different
+ semantics from the one-parameter form, so it is marked as deprecated.
+ Practically all uses compare the return value against zero and can thus
+ be replaced with uses of startsWith.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param maxLength the maximum count of characters to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ SAL_DEPRECATED(
+ "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
+ sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
+ asciiStr, maxLength );
+ }
+
+ /**
+ Compares two strings in reverse order.
+
+ This could be useful, if normally both strings start with the same
+ content. The comparison is based on the numeric value of each character
+ in the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and 127.
+ The ASCII string must be NULL-terminated and must be greater than
+ or equal to asciiStrLength.
+ This function can't be used for language specific sorting.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
+ asciiStr, asciiStrLength );
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsAscii( const sal_Char* asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
+ asciiStr ) == 0;
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater than
+ or equal to asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ if ( pData->length != asciiStrLength )
+ return sal_False;
+
+ return rtl_ustr_asciil_reverseEquals_WithLength(
+ pData->buffer, asciiStr, asciiStrLength );
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
+ }
+
+ /**
+ Compares two ASCII strings ignoring case
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific sorting.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+
+ @since LibreOffice 3.5
+ */
+ sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
+ }
+
+ /**
+ Perform an ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and 127.
+ The ASCII string must be NULL-terminated and must be greater than
+ or equal to asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ if ( pData->length != asciiStrLength )
+ return sal_False;
+
+ return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater than or
+ equal to asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the object (substring) to be compared.
+ @param asciiStrLength the length of asciiStr.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater than or equal to 0
+ and less than or equal to the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ asciiStr, asciiStrLength ) == 0;
+ }
+
+ // This overload is left undefined, to detect calls of matchAsciiL that
+ // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
+ // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
+ // platforms):
+#if SAL_TYPES_SIZEOFLONG == 8
+ void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
+#endif
+
+ /**
+ Match against a substring appearing in this string, ignoring the case of
+ ASCII letters.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater than or
+ equal to asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @param fromIndex the index to start the comparion from.
+ The index must be greater than or equal to 0
+ and less than or equal to the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ asciiStr, asciiStrLength ) == 0;
+ }
+
+ // This overload is left undefined, to detect calls of
+ // matchIgnoreAsciiCaseAsciiL that erroneously use
+ // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
+ // would lead to ambiguities on 32 bit platforms):
+#if SAL_TYPES_SIZEOFLONG == 8
+ void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
+ const;
+#endif
+
+ /**
+ Check whether this string starts with a given substring.
+
+ @param str the substring to be compared
+
+ @return true if and only if the given str appears as a substring at the
+ start of this string
+
+ @since LibreOffice 4.0
+ */
+ bool startsWith(OUString const & str) const {
+ return match(str, 0);
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 4.0
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type startsWith( T& literal ) const
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+ && rtl_ustr_asciil_reverseEquals_WithLength( pData->buffer, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1);
+ }
+
+ /**
+ Check whether this string starts with a given string, ignoring the case of
+ ASCII letters.
+
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @return true if this string starts with str, ignoring the case of ASCII
+ letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
+ @since LibreOffice 4.0
+ */
+ sal_Bool startsWithIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+ {
+ return matchIgnoreAsciiCase(str, 0);
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 4.0
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase( T& literal ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ pData->buffer,
+ internal::ConstCharArrayDetector< T, void >::size - 1, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1)
+ == 0);
+ }
+
+ /**
+ Check whether this string ends with a given substring.
+
+ @param str the substring to be compared
+
+ @return true if and only if the given str appears as a substring at the
+ end of this string
+
+ @since LibreOffice 3.6
+ */
+ bool endsWith(OUString const & str) const {
+ return str.getLength() <= getLength()
+ && match(str, getLength() - str.getLength());
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type endsWith( T& literal ) const
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+ && rtl_ustr_asciil_reverseEquals_WithLength(
+ pData->buffer + pData->length - ( internal::ConstCharArrayDetector< T, void >::size - 1 ), literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1);
+ }
+
+ /**
+ Check whether this string ends with a given ASCII string.
+
+ @param asciiStr a sequence of at least asciiStrLength ASCII characters
+ (bytes in the range 0x00--0x7F)
+ @param asciiStrLength the length of asciiStr; must be non-negative
+ @return true if this string ends with asciiStr; otherwise, false is
+ returned
+
+ @since UDK 3.2.7
+ */
+ inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
+ const
+ {
+ return asciiStrLength <= pData->length
+ && rtl_ustr_asciil_reverseEquals_WithLength(
+ pData->buffer + pData->length - asciiStrLength, asciiStr,
+ asciiStrLength);
+ }
+
+ /**
+ Check whether this string ends with a given string, ignoring the case of
+ ASCII letters.
+
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @return true if this string ends with str, ignoring the case of ASCII
+ letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
+ @since LibreOffice 3.6
+ */
+ sal_Bool endsWithIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+ {
+ return str.getLength() <= getLength()
+ && matchIgnoreAsciiCase(str, getLength() - str.getLength());
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase( T& literal ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+ && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ pData->buffer + pData->length - ( internal::ConstCharArrayDetector< T, void >::size - 1 ),
+ internal::ConstCharArrayDetector< T, void >::size - 1, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1)
+ == 0);
+ }
+
+ /**
+ Check whether this string ends with a given ASCII string, ignoring the
+ case of ASCII letters.
+
+ @param asciiStr a sequence of at least asciiStrLength ASCII characters
+ (bytes in the range 0x00--0x7F)
+ @param asciiStrLength the length of asciiStr; must be non-negative
+ @return true if this string ends with asciiStr, ignoring the case of ASCII
+ letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
+ */
+ inline bool endsWithIgnoreAsciiCaseAsciiL(
+ char const * asciiStr, sal_Int32 asciiStrLength) const
+ {
+ return asciiStrLength <= pData->length
+ && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ pData->buffer + pData->length - asciiStrLength,
+ asciiStrLength, asciiStr, asciiStrLength)
+ == 0);
+ }
+
+ friend sal_Bool operator == ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.equals(rStr2); }
+ friend sal_Bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( pStr2 ) == 0; }
+ friend sal_Bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
+
+ friend sal_Bool operator != ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, rStr2 )); }
+ friend sal_Bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, pStr2 )); }
+ friend sal_Bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( pStr1, rStr2 )); }
+
+ friend sal_Bool operator < ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) < 0; }
+ friend sal_Bool operator > ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) > 0; }
+ friend sal_Bool operator <= ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) <= 0; }
+ friend sal_Bool operator >= ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) >= 0; }
+
+ /**
+ * Compare string to an ASCII string literal.
+ *
+ * This operator is equal to calling equalsAsciiL().
+ *
+ * @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ }
+ /**
+ * Compare string to an ASCII string literal.
+ *
+ * This operator is equal to calling equalsAsciiL().
+ *
+ * @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ }
+ /**
+ * Compare string to an ASCII string literal.
+ *
+ * This operator is equal to calling !equalsAsciiL().
+ *
+ * @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return !string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ }
+ /**
+ * Compare string to an ASCII string literal.
+ *
+ * This operator is equal to calling !equalsAsciiL().
+ *
+ * @since LibreOffice 3.6
+ */
+ template< typename T >
+ friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return !string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
+ }
+
+ /**
+ Returns a hashcode for this string.
+
+ @return a hash code value for this object.
+
+ @see rtl::OUStringHash for convenient use of boost::unordered_map
+ */
+ sal_Int32 hashCode() const SAL_THROW(())
+ {
+ return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified character, starting the search at the specified index.
+
+ @param ch character to be located.
+ @param fromIndex the index to start the search from.
+ The index must be greater than or equal to 0
+ and less than or equal to the string length.
+ @return the index of the first occurrence of the character in the
+ character sequence represented by this string that is
+ greater than or equal to fromIndex, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting at the end.
+
+ @param ch character to be located.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting before the specified
+ index.
+
+ @param ch character to be located.
+ @param fromIndex the index before which to start the search.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string that
+ is less than fromIndex, or -1
+ if the character does not occur before that point.
+ */
+ sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified substring, starting at the specified index.
+
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index to start the search from.
+ @return If the string argument occurs one or more times as a substring
+ within this string at the starting index, then the index
+ of the first character of the first such substring is
+ returned. If it does not occur as a substring starting
+ at fromIndex or beyond, -1 is returned.
+ */
+ sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex, literal,
+ internal::ConstCharArrayDetector< T, void >::size - 1);
+ return ret < 0 ? ret : ret + fromIndex;
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified ASCII substring, starting at the specified index.
+
+ @param str
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified len. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param len
+ the length of the substring; must be non-negative.
+
+ @param fromIndex
+ the index to start the search from. Must be in the range from zero to
+ the length of this string, inclusive.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within this string starting at the given fromIndex, or
+ -1 if the substring does not occur. If len is zero, -1 is returned.
+
+ @since UDK 3.2.7
+ */
+ sal_Int32 indexOfAsciiL(
+ char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
+ SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex, str, len);
+ return ret < 0 ? ret : ret + fromIndex;
+ }
+
+ // This overload is left undefined, to detect calls of indexOfAsciiL that
+ // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
+ // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
+ // platforms):
+#if SAL_TYPES_SIZEOFLONG == 8
+ void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
+#endif
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting at the end.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @return If the string argument occurs one or more times as a substring
+ within this string, then the index of the first character of
+ the last such substring is returned. If it does not occur as
+ a substring, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting before the specified
+ index.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index before which to start the search.
+ @return If the string argument occurs one or more times as a substring
+ within this string before the starting index, then the index
+ of the first character of the last such substring is
+ returned. Otherwise, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ @overload
+ This function accepts an ASCII string literal as its argument.
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const SAL_THROW(())
+ {
+ assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ return rtl_ustr_lastIndexOfAscii_WithLength(
+ pData->buffer, pData->length, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified ASCII substring.
+
+ @param str
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified len. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param len
+ the length of the substring; must be non-negative.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within this string, or -1 if the substring does not
+ occur. If len is zero, -1 is returned.
+
+ @since UDK 3.2.7
+ */
+ sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
+ SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfAscii_WithLength(
+ pData->buffer, pData->length, str, len);
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex. If
+ beginIndex is negative or be greater than the length of
+ this string, behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @return the specified substring.
+ */
+ SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const SAL_THROW(())
+ {
+ rtl_uString *pNew = 0;
+ rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. If either beginIndex or count are negative,
+ or beginIndex + count are greater than the length of this string
+ then behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @param count the number of characters.
+ @return the specified substring.
+ */
+ SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
+ {
+ rtl_uString *pNew = 0;
+ rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Concatenates the specified string to the end of this string.
+
+ @param str the string that is concatenated to the end
+ of this string.
+ @return a string that represents the concatenation of this string
+ followed by the string argument.
+ */
+ SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newConcat( &pNew, pData, str.pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+#ifndef RTL_FAST_STRING
+ friend OUString operator+( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ {
+ return rStr1.concat( rStr2 );
+ }
+#endif
+
+ /**
+ Returns a new string resulting from replacing n = count characters
+ from position index in this string with newStr.
+
+ @param index the replacing index in str.
+ The index must be greater than or equal to 0 and
+ less than or equal to the length of the string.
+ @param count the count of characters that will be replaced
+ The count must be greater than or equal to 0 and
+ less than or equal to the length of the string minus index.
+ @param newStr the new substring.
+ @return the new string.
+ */
+ SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of
+ oldChar in this string with newChar.
+
+ If the character oldChar does not occur in the character sequence
+ represented by this object, then the string is assigned with
+ str.
+
+ @param oldChar the old character.
+ @param newChar the new character.
+ @return a string derived from this string by replacing every
+ occurrence of oldChar with newChar.
+ */
+ SAL_WARN_UNUSED_RESULT OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from replacing the first occurrence of a
+ given substring with another substring.
+
+ @param from the substring to be replaced
+
+ @param to the replacing substring
+
+ @param[in,out] index pointer to a start index; if the pointer is
+ non-null: upon entry to the function, its value is the index into this
+ string at which to start searching for the \p from substring, the value
+ must be non-negative and not greater than this string's length; upon exiting
+ the function its value is the index into this string at which the
+ replacement took place or -1 if no replacement took place; if the pointer
+ is null, searching always starts at index 0
+
+ @since LibreOffice 3.6
+ */
+ SAL_WARN_UNUSED_RESULT OUString replaceFirst(
+ OUString const & from, OUString const & to, sal_Int32 * index = 0) const
+ {
+ rtl_uString * s = 0;
+ sal_Int32 i = 0;
+ rtl_uString_newReplaceFirst(
+ &s, pData, from.pData, to.pData, index == 0 ? &i : index);
+ return OUString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Returns a new string resulting from replacing the first occurrence of a
+ given substring with another substring.
+
+ @param from ASCII string literal, the substring to be replaced
+
+ @param to the replacing substring
+
+ @param[in,out] index pointer to a start index; if the pointer is
+ non-null: upon entry to the function, its value is the index into the this
+ string at which to start searching for the \p from substring, the value
+ must be non-negative and not greater than this string's length; upon exiting
+ the function its value is the index into this string at which the
+ replacement took place or -1 if no replacement took place; if the pointer
+ is null, searching always starts at index 0
+
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( T& from, OUString const & to,
+ sal_Int32 * index = 0) const
+ {
+ rtl_uString * s = 0;
+ sal_Int32 i = 0;
+ assert( strlen( from ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_uString_newReplaceFirstAsciiL(
+ &s, pData, from, internal::ConstCharArrayDetector< T, void >::size - 1, to.pData, index == 0 ? &i : index);
+ return OUString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Returns a new string resulting from replacing the first occurrence of a
+ given substring with another substring.
+
+ @param from ASCII string literal, the substring to be replaced
+
+ @param to ASCII string literal, the substring to be replaced
+
+ @param[in,out] index pointer to a start index; if the pointer is
+ non-null: upon entry to the function, its value is the index into the this
+ string at which to start searching for the \p from substring, the value
+ must be non-negative and not greater than this string's length; upon exiting
+ the function its value is the index into this string at which the
+ replacement took place or -1 if no replacement took place; if the pointer
+ is null, searching always starts at index 0
+
+ @since LibreOffice 3.6
+ */
+ template< typename T1, typename T2 >
+ SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T1, typename internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
+ replaceFirst( T1& from, T2& to, sal_Int32 * index = 0) const
+ {
+ rtl_uString * s = 0;
+ sal_Int32 i = 0;
+ assert( strlen( from ) == internal::ConstCharArrayDetector< T1 >::size - 1 );
+ assert( strlen( to ) == internal::ConstCharArrayDetector< T2 >::size - 1 );
+ rtl_uString_newReplaceFirstAsciiLAsciiL(
+ &s, pData, from, internal::ConstCharArrayDetector< T1, void >::size - 1, to,
+ internal::ConstCharArrayDetector< T2, void >::size - 1, index == 0 ? &i : index);
+ return OUString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of a given
+ substring with another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param from the substring to be replaced
+
+ @param to the replacing substring
+
+ @param fromIndex the position in the string where we will begin searching
+
+ @since LibreOffice 4.0
+ */
+ SAL_WARN_UNUSED_RESULT OUString replaceAll(
+ OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
+ {
+ rtl_uString * s = 0;
+ rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
+ return OUString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of a given
+ substring with another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param from ASCII string literal, the substring to be replaced
+
+ @param to the replacing substring
+
+ @since LibreOffice 3.6
+ */
+ template< typename T >
+ SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T, OUString >::Type replaceAll( T& from, OUString const & to) const
+ {
+ rtl_uString * s = 0;
+ assert( strlen( from ) == internal::ConstCharArrayDetector< T >::size - 1 );
+ rtl_uString_newReplaceAllAsciiL(&s, pData, from, internal::ConstCharArrayDetector< T, void >::size - 1, to.pData);
+ return OUString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of a given
+ substring with another substring.
+
+ Replacing subsequent occurrences picks up only after a given replacement.
+ That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
+
+ @param from ASCII string literal, the substring to be replaced
+
+ @param to ASCII string literal, the substring to be replaced
+
+ @since LibreOffice 3.6
+ */
+ template< typename T1, typename T2 >
+ SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T1, typename internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
+ replaceAll( T1& from, T2& to ) const
+ {
+ rtl_uString * s = 0;
+ assert( strlen( from ) == internal::ConstCharArrayDetector< T1 >::size - 1 );
+ assert( strlen( to ) == internal::ConstCharArrayDetector< T2 >::size - 1 );
+ rtl_uString_newReplaceAllAsciiLAsciiL(
+ &s, pData, from, internal::ConstCharArrayDetector< T1, void >::size - 1,
+ to, internal::ConstCharArrayDetector< T2, void >::size - 1);
+ return OUString(s, SAL_NO_ACQUIRE);
+ }
+
+ /**
+ Converts from this string all ASCII uppercase characters (65-90)
+ to ASCII lowercase characters (97-122).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII lowercase.
+ */
+ SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newToAsciiLowerCase( &pNew, pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Converts from this string all ASCII lowercase characters (97-122)
+ to ASCII uppercase characters (65-90).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII uppercase.
+ */
+ SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newToAsciiUpperCase( &pNew, pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from removing white space from both ends
+ of the string.
+
+ All characters that have codes less than or equal to
+ 32 (the space character) are considered to be white space.
+ If the string doesn't contain white spaces at both ends,
+ then the new string is assigned with str.
+
+ @return the string, with white space removed from the front and end.
+ */
+ SAL_WARN_UNUSED_RESULT OUString trim() const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newTrim( &pNew, pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a token in the string.
+
+ Example:
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ OUString aToken = aStr.getToken( 0, ';', nIndex );
+ ...
+ }
+ while ( nIndex >= 0 );
+
+ @param token the number of the token to return
+ @param cTok the character which seperate the tokens.
+ @param index the position at which the token is searched in the
+ string.
+ The index must not be greater than the length of the
+ string.
+ This param is set to the position of the
+ next token or to -1, if it is the last token.
+ @return the token; if either token or index is negative, an empty token
+ is returned (and index is set to -1)
+ */
+ OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(())
+ {
+ rtl_uString * pNew = 0;
+ index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
+ return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Returns a token from the string.
+
+ The same as getToken(sal_Int32, sal_Unicode, sal_Int32 &), but always
+ passing in 0 as the start index in the third argument.
+
+ @param count the number of the token to return, starting with 0
+ @param separator the character which separates the tokens
+
+ @return the given token, or an empty string
+
+ @since LibreOffice 3.6
+ */
+ OUString getToken(sal_Int32 count, sal_Unicode separator) const {
+ sal_Int32 n = 0;
+ return getToken(count, separator, n);
+ }
+
+ /**
+ Returns the Boolean value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return sal_True, if the string is 1 or "True" in any ASCII case.
+ sal_False in any other case.
+ */
+ sal_Bool toBoolean() const SAL_THROW(())
+ {
+ return rtl_ustr_toBoolean( pData->buffer );
+ }
+
+ /**
+ Returns the first character from this string.
+
+ @return the first character from this string or 0, if this string
+ is emptry.
+ */
+ sal_Unicode toChar() const SAL_THROW(())
+ {
+ return pData->buffer[0];
+ }
+
+ /**
+ Returns the int32 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int32 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+ */
+ sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_ustr_toInt32( pData->buffer, radix );
+ }
+
+ /**
+ Returns the int64 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int64 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+ */
+ sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_ustr_toInt64( pData->buffer, radix );
+ }
+
+ /**
+ Returns the uint64 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the uint64 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+
+ @since LibreOffice 4.1
+ */
+ sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_ustr_toUInt64( pData->buffer, radix );
+ }
+
+ /**
+ Returns the float value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the float represented from this string.
+ 0.0 if this string represents no number.
+ */
+ float toFloat() const SAL_THROW(())
+ {
+ return rtl_ustr_toFloat( pData->buffer );
+ }
+
+ /**
+ Returns the double value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the double represented from this string.
+ 0.0 if this string represents no number.
+ */
+ double toDouble() const SAL_THROW(())
+ {
+ return rtl_ustr_toDouble( pData->buffer );
+ }
+
+
+ /**
+ Return a canonical representation for a string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @return
+ a version of the string from the pool.
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+
+ @since UDK 3.2.7
+ */
+ OUString intern() const
+ {
+ rtl_uString * pNew = 0;
+ rtl_uString_intern( &pNew, pData );
+ if (pNew == 0) {
+#if defined EXCEPTIONS_OFF
+ abort();
+#else
+ throw std::bad_alloc();
+#endif
+ }
+ return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Return a canonical representation for a converted string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @param value a 8-Bit character array.
+ @param length the number of character which should be converted.
+ The 8-Bit character array length must be
+ greater than or equal to this value.
+ @param encoding the text encoding from which the 8-Bit character
+ sequence should be converted.
+ @param convertFlags flags which controls the conversion.
+ see RTL_TEXTTOUNICODE_FLAGS_...
+ @param pInfo pointer to return conversion status or NULL.
+
+ @return
+ a version of the converted string from the pool.
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+
+ @since UDK 3.2.7
+ */
+ static OUString intern( const sal_Char * value, sal_Int32 length,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
+ sal_uInt32 *pInfo = NULL )
+ {
+ rtl_uString * pNew = 0;
+ rtl_uString_internConvert( &pNew, value, length, encoding,
+ convertFlags, pInfo );
+ if (pNew == 0) {
+#if defined EXCEPTIONS_OFF
+ abort();
+#else
+ throw std::bad_alloc();
+#endif
+ }
+ return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Converts to an OString, signalling failure.
+
+ @param pTarget
+ An out parameter receiving the converted OString. Must not be null; the
+ contents are not modified if conversion fails (convertToOString returns
+ false).
+
+ @param nEncoding
+ The text encoding to convert into. Must be an octet encoding (i.e.,
+ rtl_isOctetTextEncoding(nEncoding) must return true).
+
+ @param nFlags
+ A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the
+ conversion (see rtl_convertUnicodeToText). RTL_UNICODETOTEXT_FLAGS_FLUSH
+ need not be included, it is implicitly assumed. Typical uses are either
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot
+ be converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS
+ (make a best efforts conversion).
+
+ @return
+ True if the conversion succeeded, false otherwise.
+ */
+ inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
+ sal_uInt32 nFlags) const
+ {
+ return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
+ pData->length, nEncoding, nFlags);
+ }
+
+ /** Iterate through this string based on code points instead of UTF-16 code
+ units.
+
+ See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
+ definitions of the various terms used in this description.
+
+ This string is interpreted as a sequence of zero or more UTF-16 code
+ units. For each index into this sequence (from zero to one less than
+ the length of the sequence, inclusive), a code point represented
+ starting at the given index is computed as follows:
+
+ - If the UTF-16 code unit addressed by the index constitutes a
+ well-formed UTF-16 code unit sequence, the computed code point is the
+ scalar value encoded by that UTF-16 code unit sequence.
+
+ - Otherwise, if the index is at least two UTF-16 code units away from
+ the end of the sequence, and the sequence of two UTF-16 code units
+ addressed by the index constitutes a well-formed UTF-16 code unit
+ sequence, the computed code point is the scalar value encoded by that
+ UTF-16 code unit sequence.
+
+ - Otherwise, the computed code point is the UTF-16 code unit addressed
+ by the index. (This last case catches unmatched surrogates as well as
+ indices pointing into the middle of surrogate pairs.)
+
+ @param indexUtf16
+ pointer to a UTF-16 based index into this string; must not be null. On
+ entry, the index must be in the range from zero to the length of this
+ string (in UTF-16 code units), inclusive. Upon successful return, the
+ index will be updated to address the UTF-16 code unit that is the given
+ incrementCodePoints away from the initial index.
+
+ @param incrementCodePoints
+ the number of code points to move the given *indexUtf16. If
+ non-negative, moving is done after determining the code point at the
+ index. If negative, moving is done before determining the code point
+ at the (then updated) index. The value must be such that the resulting
+ UTF-16 based index is in the range from zero to the length of this
+ string (in UTF-16 code units), inclusive.
+
+ @return
+ the code point (an integer in the range from 0 to 0x10FFFF, inclusive)
+ that is represented within this string starting at the index computed as
+ follows: If incrementCodePoints is non-negative, the index is the
+ initial value of *indexUtf16; if incrementCodePoints is negative, the
+ index is the updated value of *indexUtf16. In either case, the computed
+ index must be in the range from zero to one less than the length of this
+ string (in UTF-16 code units), inclusive.
+
+ @since UDK 3.2.7
+ */
+ inline sal_uInt32 iterateCodePoints(
+ sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
+ {
+ return rtl_uString_iterateCodePoints(
+ pData, indexUtf16, incrementCodePoints);
+ }
+
+ /**
+ Returns the string representation of the integer argument.
+
+ This function can't be used for language specific conversion.
+
+ @param i an integer value
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OUString number( int i, sal_Int16 radix = 10 )
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OUString number( unsigned int i, sal_Int16 radix = 10 )
+ {
+ return number( static_cast< unsigned long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OUString number( long i, sal_Int16 radix = 10)
+ {
+ return number( static_cast< long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OUString number( unsigned long i, sal_Int16 radix = 10 )
+ {
+ return number( static_cast< unsigned long long >( i ), radix );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OUString number( long long ll, sal_Int16 radix = 10 )
+ {
+ sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+ /// @overload
+ /// @since LibreOffice 4.1
+ static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
+ {
+ sal_Unicode aBuf[RTL_STR_MAX_VALUEOFUINT64];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the float argument.
+
+ This function can't be used for language specific conversion.
+
+ @param f a float.
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OUString number( float f )
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the double argument.
+
+ This function can't be used for language specific conversion.
+
+ @param d a double.
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OUString number( double d )
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the sal_Bool argument.
+
+ If the sal_Bool is true, the string "true" is returned.
+ If the sal_Bool is false, the string "false" is returned.
+ This function can't be used for language specific conversion.
+
+ @param b a sal_Bool.
+ @return a string with the string representation of the argument.
+ @deprecated use boolean()
+ */
+ SAL_DEPRECATED_INTERNAL("use boolean()") static OUString valueOf( sal_Bool b ) SAL_THROW(())
+ {
+ return boolean(b);
+ }
+
+ /**
+ Returns the string representation of the boolean argument.
+
+ If the argument is true, the string "true" is returned.
+ If the argument is false, the string "false" is returned.
+ This function can't be used for language specific conversion.
+
+ @param b a bool.
+ @return a string with the string representation of the argument.
+ @since LibreOffice 4.1
+ */
+ static OUString boolean( bool b ) SAL_THROW(())
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the char argument.
+
+ @param c a character.
+ @return a string with the string representation of the argument.
+ @deprecated use operator, function or constructor taking char or sal_Unicode argument
+ */
+ SAL_DEPRECATED_INTERNAL("convert to OUString or use directly") static OUString valueOf( sal_Unicode c ) SAL_THROW(())
+ {
+ return OUString( &c, 1 );
+ }
+
+ /**
+ Returns the string representation of the int argument.
+
+ This function can't be used for language specific conversion.
+
+ @param i a int32.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ return number( i, radix );
+ }
+
+ /**
+ Returns the string representation of the long argument.
+
+ This function can't be used for language specific conversion.
+
+ @param ll a int64.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ return number( ll, radix );
+ }
+
+ /**
+ Returns the string representation of the float argument.
+
+ This function can't be used for language specific conversion.
+
+ @param f a float.
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OUString valueOf( float f ) SAL_THROW(())
+ {
+ return number(f);
+ }
+
+ /**
+ Returns the string representation of the double argument.
+
+ This function can't be used for language specific conversion.
+
+ @param d a double.
+ @return a string with the string representation of the argument.
+ @deprecated use number()
+ */
+ SAL_DEPRECATED_INTERNAL("use number()") static OUString valueOf( double d ) SAL_THROW(())
+ {
+ return number(d);
+ }
+
+ /**
+ Returns a OUString copied without conversion from an ASCII
+ character string.
+
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+
+ Note that for string literals it is simpler and more efficient
+ to directly use the OUString constructor.
+
+ @param value the 8-Bit ASCII character string
+ @return a string with the string representation of the argument.
+ */
+ static OUString createFromAscii( const sal_Char * value ) SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newFromAscii( &pNew, value );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+};
+
+/* ======================================================================= */
+
+#ifdef RTL_FAST_STRING
+/**
+A simple wrapper around string literal. It is usually not necessary to use, can
+be mostly used to force OUString operator+ working with operands that otherwise would
+not trigger it.
+
+This class is not part of public API and is meant to be used only in LibreOffice code.
+@since LibreOffice 4.0
+*/
+struct SAL_WARN_UNUSED OUStringLiteral
+{
+ template< int N >
+ OUStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
+ int size;
+ const char* data;
+};
+
+/**
+ @internal
+*/
+template<>
+struct ToStringHelper< OUString >
+ {
+ static int length( const OUString& s ) { return s.getLength(); }
+ static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
+ static const bool allowOStringConcat = false;
+ static const bool allowOUStringConcat = true;
+ };
+
+/**
+ @internal
+*/
+template<>
+struct ToStringHelper< OUStringLiteral >
+ {
+ static int length( const OUStringLiteral& str ) { return str.size; }
+ static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
+ static const bool allowOStringConcat = false;
+ static const bool allowOUStringConcat = true;
+ };
+
+/**
+ @internal
+*/
+template< typename charT, typename traits, typename T1, typename T2 >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
+{
+ return stream << OUString( concat );
+}
+#else
+// non-RTL_FAST_CODE needs this to compile
+typedef OUString OUStringLiteral;
+#endif
+
+/** A helper to use OUStrings with hash maps.
+
+ Instances of this class are unary function objects that can be used as
+ hash function arguments to boost::unordered_map and similar constructs.
+ */
+struct OUStringHash
+{
+ /** Compute a hash code for a string.
+
+ @param rString
+ a string.
+
+ @return
+ a hash code for the string. This hash code should not be stored
+ persistently, as its computation may change in later revisions.
+ */
+ size_t operator()(const OUString& rString) const
+ { return (size_t)rString.hashCode(); }
+};
+
+/* ======================================================================= */
+
+/** Convert an OString to an OUString, using a specific text encoding.
+
+ The lengths of the two strings may differ (e.g., for double-byte
+ encodings, UTF-7, UTF-8).
+
+ @param rStr
+ an OString to convert.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OSTRING_TO_OUSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+inline OUString OStringToOUString( const OString & rStr,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
+{
+ return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
+}
+
+/** Convert an OUString to an OString, using a specific text encoding.
+
+ The lengths of the two strings may differ (e.g., for double-byte
+ encodings, UTF-7, UTF-8).
+
+ @param rUnicode
+ an OUString to convert.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OUSTRING_TO_OSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+inline OString OUStringToOString( const OUString & rUnicode,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
+{
+ return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
+}
+
+/* ======================================================================= */
+
+/**
+ Support for rtl::OUString in std::ostream (and thus in
+ CPPUNIT_ASSERT or SAL_INFO macros, for example).
+
+ The rtl::OUString is converted to UTF-8.
+
+ @since LibreOffice 3.5.
+*/
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, OUString const & string)
+{
+ return stream <<
+ OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
+ // best effort; potentially loses data due to conversion failures
+ // (stray surrogate halves) and embedded null characters
+}
+
+} // namespace
+
+#ifdef RTL_STRING_UNITTEST
+namespace rtl
+{
+typedef rtlunittest::OUString OUString;
+}
+#endif
+
+// RTL_USING is defined by gbuild for all modules except those with stable public API
+// (as listed in ure/source/README). It allows to use classes like OUString without
+// having to explicitly refer to the rtl namespace, which is kind of superfluous
+// given that OUString itself is namespaced by its OU prefix.
+#ifdef RTL_USING
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+using ::rtl::OStringToOUString;
+using ::rtl::OUStringToOString;
+using ::rtl::OUStringLiteral;
+#endif
+
+#endif /* _RTL_USTRING_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/uuid.h b/include/rtl/uuid.h
new file mode 100644
index 000000000000..31d50968110a
--- /dev/null
+++ b/include/rtl/uuid.h
@@ -0,0 +1,182 @@
+/* -*- 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 _RTL_UUID_H_
+#define _RTL_UUID_H_
+
+#include "sal/config.h"
+
+#include "rtl/string.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+/**
+ @file
+ Specification (from draft-leach-uuids-guids-01.txt )
+
+ <p>
+ A UUID is an identifier that is unique across both space and time,
+ with respect to the space of all UUIDs. To be precise, the UUID
+ consists of a finite bit space. Thus, collision cannot be avoided in
+ principle. A UUID can be used for multiple purposes, from tagging objects
+ with an extremely short lifetime, to reliably identifying very persistent
+ objects across a network.
+
+ <p>
+ The generation of UUIDs does not require that a registration
+ authority be contacted for each identifier. Instead, Version 4 UUIDs are
+ generated from (pseudo unique) sequences of (pseudo) random bits.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Generates a new Version 4 (random number based) UUID (Universally Unique
+ IDentifier).
+
+ @param pTargetUUID pointer to at least 16 bytes of memory. After the call it contains
+ the newly generated uuid in network byte order.
+ @param pPredecessorUUID ignored (was used when this function returned
+ Version 1 instead of Version 4 UUIDs).
+ @param bUseEthernetAddress ignored (was used when this function returned
+ Version 1 instead of Version 4 UUIDs).
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_createUuid(
+ sal_uInt8 *pTargetUUID,
+ const sal_uInt8 *pPredecessorUUID,
+ sal_Bool bUseEthernetAddress );
+
+/** Compare two UUID's lexically
+
+ <p>
+ Note: lexical ordering is not temporal ordering!
+ <p>
+ Note: For equalnesschecking, a memcmp(pUUID1,pUUID2,16) is more efficient
+
+ @return
+ <ul>
+ <li>-1 u1 is lexically before u2
+ <li>0 u1 is equal to u2
+ <li>1 u1 is lexically after u2
+ </ul>
+
+ */
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_compareUuid(
+ const sal_uInt8 *pUUID1 , const sal_uInt8 *pUUID2 );
+
+/** Creates named UUIDs.
+
+ <p>
+ The version 3 UUID is meant for generating UUIDs from <em>names</em> that
+ are drawn from, and unique within, some <em>name space</em>. Some examples
+ of names (and, implicitly, name spaces) might be DNS names, URLs, ISO
+ Object IDs (OIDs), reserved words in a programming language, or X.500
+ Distinguished Names (DNs); thus, the concept of name and name space
+ should be broadly construed, and not limited to textual names.
+
+ <p>
+ The requirements for such UUIDs are as follows:
+
+ <ul>
+ <li> The UUIDs generated at different times from the same name in the
+ same namespace MUST be equal
+
+ <li> The UUIDs generated from two different names in the same namespace
+ should be different (with very high probability)
+
+ <li> The UUIDs generated from the same name in two different namespaces
+ should be different with (very high probability)
+
+ <li> If two UUIDs that were generated from names are equal, then they
+ were generated from the same name in the same namespace (with very
+ high probability).
+ </ul>
+
+ @param pTargetUUID pointer to at least 16 bytes of memory. After the call
+ it contains the newly generated uuid in network byte order.
+ @param pNameSpaceUUID The namespace uuid. Below are some predefined ones,
+ but any arbitray uuid can be used as namespace.
+
+ @param pName the name
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_createNamedUuid(
+ sal_uInt8 *pTargetUUID,
+ const sal_uInt8 *pNameSpaceUUID,
+ const rtl_String *pName
+ );
+
+
+
+/*
+ Predefined Namespaces
+ (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
+ */
+/** namesapce DNS
+
+ <p>
+ (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
+ <p>
+ 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_DNS {\
+ 0x6b,0xa7,0xb8,0x10,\
+ 0x9d,0xad,\
+ 0x11,0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+/** namespace URL
+
+ <p>
+ 6ba7b811-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_URL { \
+ 0x6b, 0xa7, 0xb8, 0x11,\
+ 0x9d, 0xad,\
+ 0x11, 0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+/** namespace oid
+
+ <p>
+ 6ba7b812-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_OID {\
+ 0x6b, 0xa7, 0xb8, 0x12,\
+ 0x9d, 0xad,\
+ 0x11, 0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+/** namespace X500
+
+ <p>
+ 6ba7b814-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_X500 {\
+ 0x6b, 0xa7, 0xb8, 0x14,\
+ 0x9d, 0xad,\
+ 0x11, 0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/ByteBufferWrapper.hxx b/include/sal/ByteBufferWrapper.hxx
new file mode 100644
index 000000000000..63bb618278d6
--- /dev/null
+++ b/include/sal/ByteBufferWrapper.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+#ifndef _SAL_BYTEBUFFERWRAPPER_HXX
+#define _SAL_BYTEBUFFERWRAPPER_HXX
+
+#ifdef ANDROID
+
+#include <jni.h>
+
+#include <sal/types.h>
+
+namespace org { namespace libreoffice { namespace touch {
+
+class ByteBufferWrapper
+{
+private:
+ jobject object;
+
+public:
+ ByteBufferWrapper(JNIEnv *env, jobject o);
+
+ sal_uInt8* pointer();
+
+ void operator()(sal_uInt8 *p);
+};
+
+}; }; };
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/alloca.h b/include/sal/alloca.h
new file mode 100644
index 000000000000..c42f723f4af3
--- /dev/null
+++ b/include/sal/alloca.h
@@ -0,0 +1,66 @@
+/* -*- 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 INCLUDED_SAL_ALLOCA_H
+#define INCLUDED_SAL_ALLOCA_H
+
+#if defined (SOLARIS) || defined (LINUX) || defined(__EMX__) || defined(AIX) || defined(ANDROID)
+
+#ifndef INCLUDED_ALLOCA_H
+#include <alloca.h>
+#define INCLUDED_ALLOCA_H
+#endif
+
+#elif defined (FREEBSD) || defined(NETBSD) || defined(OPENBSD) || defined(DRAGONFLY)
+
+#ifndef INCLUDED_STDLIB_H
+#include <stdlib.h>
+#define INCLUDED_STDLIB_H
+#endif
+
+#elif defined (MACOSX)
+
+#ifndef INCLUDED_SYS_TYPES_H
+#include <sys/types.h>
+#define INCLUDED_SYS_TYPES_H
+#endif
+
+#elif defined (IOS)
+
+#ifndef INCLUDED_SYS_TYPES_H
+#include <sys/types.h>
+#define INCLUDED_SYS_TYPES_H
+#endif
+
+#elif defined (WNT)
+
+#ifndef INCLUDED_MALLOC_H
+#include <malloc.h>
+#define INCLUDED_MALLOC_H
+#endif
+
+#else
+
+#error "unknown platform: please check for alloca"
+
+#endif
+
+#endif /* INCLUDED_SAL_ALLOCA_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/config.h b/include/sal/config.h
new file mode 100644
index 000000000000..ee230fe49d69
--- /dev/null
+++ b/include/sal/config.h
@@ -0,0 +1,100 @@
+/* -*- 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 _SAL_CONFIG_H_
+#define _SAL_CONFIG_H_
+
+#if defined LIBO_INTERNAL_ONLY
+#include "config_global.h"
+#endif
+
+#include <stdlib.h>
+
+#ifdef WIN32
+#define SAL_W32
+#define SAL_DLLEXTENSION ".dll"
+#define SAL_PRGEXTENSION ".exe"
+#define SAL_PATHSEPARATOR ';'
+#define SAL_PATHDELIMITER '\\'
+#define SAL_CONFIGFILE( name ) name ".ini"
+
+#ifdef _MSC_VER
+
+#ifndef _USE_MATH_DEFINES
+#define _USE_MATH_DEFINES // needed by Visual C++ for math constants
+#endif
+
+#endif /* defined _MSC_VER */
+
+/* Provide ISO C99 compatible versions of snprint and vsnprintf */
+#ifdef __MINGW32__
+#define _SNPRINTF_DLLIMPORT
+#endif
+#ifndef _SNPRINTF_H
+#include <systools/win32/snprintf.h>
+#endif
+
+#endif /* defined WIN32 */
+
+#if defined(SOLARIS) || defined(LINUX) || defined(NETBSD) || defined(FREEBSD) || \
+ defined(AIX) || defined(OPENBSD) || defined(DRAGONFLY) || defined(ANDROID)
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".so"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#endif
+
+#ifdef MACOSX
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".dylib"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#endif
+
+#ifdef IOS
+#define SAL_UNX
+/* SAL_DLLEXTENSION should not really be used on iOS, as iOS apps are
+ * not allowed to load own dynamic libraries.
+ */
+#define SAL_DLLEXTENSION ".dylib"
+#define SAL_DLLPREFIX "lib"
+/* This is fairly pointless too, an iOS app consists of a single
+ * executable (plus data files).
+ */
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#endif
+
+#ifdef sun
+#undef sun
+#define sun sun
+#endif
+
+#endif /*_SAL_CONFIG_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/detail/log.h b/include/sal/detail/log.h
new file mode 100644
index 000000000000..5cfc5e5fc0cc
--- /dev/null
+++ b/include/sal/detail/log.h
@@ -0,0 +1,106 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SAL_DETAIL_LOG_H
+#define INCLUDED_SAL_DETAIL_LOG_H
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+/** @cond INTERNAL */
+
+/* This header makes available replacements working in both C and C++ for the
+ obsolete osl/diagnose.h functionality that in turn is used from both C and
+ C++ code and the obsolete tools/debug.hxx and
+ canvas/inc/canvas/verbosetrace.hxx functionality that uses printf-style
+ formatting. Once that obsolete functionality is removed, this header can be
+ removed, too.
+
+ This header uses variadic macros in both C (where they are officially only
+ supported since C99) and C++ (where they are officially only supported since
+ C++11). It appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
+ Express) already support them in their C and C++ dialects. See also
+ <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>.
+
+ Avoid the use of other sal code in this header as much as possible, so that
+ this code can be called from other sal code without causing endless
+ recursion.
+*/
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/*
+ Clang warns about 'sal_True && sal_True' (those being integers and not booleans)
+ when it sees preprocessed source (-save-temps or using icecream)
+*/
+#if defined __cplusplus
+#define SAL_LOG_TRUE true
+#define SAL_LOG_FALSE false
+#else
+#define SAL_LOG_TRUE sal_True
+#define SAL_LOG_FALSE sal_False
+#endif
+
+enum sal_detail_LogLevel {
+ SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
+ SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM
+};
+
+SAL_DLLPUBLIC void SAL_CALL sal_detail_logFormat(
+ enum sal_detail_LogLevel level, char const * area, char const * where,
+ char const * format, ...)
+/* TODO: enabling this will produce a huge amount of -Werror=format errors: */
+#if defined __GNUC__ && 0
+ __attribute__((format(printf, 4, 5)))
+#endif
+ ;
+
+#if defined __cplusplus
+}
+#endif
+
+#define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
+ do { \
+ if (condition) { \
+ sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
+ } \
+ } while (SAL_LOG_FALSE)
+
+#if defined SAL_LOG_INFO
+#define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE
+#else
+#define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE
+#endif
+#if defined SAL_LOG_WARN
+#define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE
+#else
+#define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE
+#endif
+
+#define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
+
+#define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
+ area, SAL_DETAIL_WHERE, __VA_ARGS__)
+
+#define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
+ area, SAL_DETAIL_WHERE, __VA_ARGS__)
+
+/** @endcond */
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
new file mode 100644
index 000000000000..d21f14388d96
--- /dev/null
+++ b/include/sal/log-areas.dox
@@ -0,0 +1,355 @@
+// NOTE: This file is also parsed by a compiler plugin. Make sure all
+// areas are marked with '@li @c'.
+
+/**
+@page sal_log_areas SAL debug areas
+
+@short List and description of areas for the SAL debug macros
+
+This is a list of areas that are used by the SAL_INFO family of macros. See
+@ref sal_log "basic log functionality" for details about this functionality.
+
+If you need a debug area in some code, first check this list and use the
+appropriate area if it exists. This list is not definite, if you need a new
+area, use it and add it to an appropriate section with an explanation.
+Generally, use the name of the relevant code module as the first area segment.
+Please keep all entries sorted.
+
+This list should give you an overview of which areas to enable when debugging
+certain functionality.
+
+@section SAL
+
+@li @c sal.debug - SAL debugging functionality
+@li @c sal.osl - SAL OSL library
+@li @c sal.rtl - SAL RTL library
+@li @c sal.textenc - the textencoding SAL library
+
+@section basctl
+
+@li @c basctl.basicide
+
+@section basebmp
+
+@li @c basebmp.bitmapdevice
+
+@section basic
+
+@li @c basic
+@li @c basic.sbx
+
+@section canvas
+
+@li @c canvas
+@li @c canvas.cairo
+@li @c canvas.null
+
+@section chart2
+
+@li @c chart2
+@li @c chart2.areachart
+
+@section connectivity
+
+@li @c connectivity.cpool
+@li @c connectivity.commontools
+@li @c connectivity.mork
+@li @c connectivity.parse
+@li @c connectivity.postgresql
+
+@section cui
+
+@li @c cui.customize
+@li @c cui.dialogs
+@li @c cui.factory
+@li @c cui.options
+@li @c cui.tabpages
+
+@section Calc
+
+@li @c sc
+@li @c sc.core
+@li @c sc.ui - Calc UI
+
+@section desktop
+
+@li @c desktop
+@li @c desktop.deployment
+@li @c desktop.migration
+
+@section Draw
+
+@li @c sd
+@li @c sd.fwk
+@li @c sd.sls - slidesorter
+@li @c sd.tools
+@li @c sd.ui
+@li @c sd.view
+@li @c sd.slideshow
+@li @c sdremote
+@li @c sdremote.bluetooth
+
+@section editeng
+
+@li @c editeng
+@li @c editeng.items
+
+@section embeddedobj
+
+@li @c embeddedobj - embedded objects
+@li @c embeddedobj.ole - OLE embedded objects
+
+@section extensions
+
+@li @c extensions.dbpilots
+@li @c extensions.plugin
+@li @c extensions.scanner
+@li @c extensions.update
+
+@section Filter
+
+@li @c filter.ms - escher import/export
+@li @c filter.xslt - xslt import/export
+@li @c oox.xmlstream - XmlStream class
+@li @c oox.storage - ZipStorage class
+@li @c oox.ppt - pptx filter
+
+@section formula
+
+@li @c formula.core
+
+@section fpicker
+
+@li @c fpicker.aqua
+@li @c fpicker.office
+
+@section framework
+
+@li @c fwk - framework
+@li @c fwk.desktop
+@li @c fwk.session
+
+@section i18nlangtag
+
+@li @c i18nlangtag - language tags
+
+@section i18npool
+
+@li @c i18npool - general i18npool
+
+@section i18n
+
+@li @c i18n - module independent i18n related, e.g. language tag usage
+
+@section io
+
+@li @c io.streams
+
+@section jvmfwk
+
+@li @c jfw
+@li @c jfw.level1
+@li @c jfw.level2
+
+@section Math
+
+@li @c starmath.rtf
+@li @c starmath.ooxml - OOXML import/export
+@li @c starmath.wordbase
+
+@section sdext
+
+@li @c sdext.minimizer
+@li @c sdext.pdfimport
+@li @c sdext.pdfimport.pdfparse
+@li @c sdext.presenter
+
+@section sfx2
+
+@li @c sfx2
+@li @c sfx2.appl
+@li @c sfx2.bastyp
+@li @c sfx2.config
+@li @c sfx2.control
+@li @c sfx2.dialog
+@li @c sfx2.doc
+@li @c sfx2.notify
+@li @c sfx2.view
+
+@section slideshow
+
+@li @c slideshow.opengl
+@li @c slideshow.eventqueue
+
+@section svl
+
+@li @c svl
+@li @c svl.numbers
+
+@section svtools
+
+@li @c svtools.config
+@li @c svtools.contnr
+@li @c svtools.control
+@li @c svtools.dialogs
+@li @c svtools.filter
+@li @c svtools.misc
+@li @c svtools.table
+@li @c svtools.uno
+
+@section svx
+
+@li @c svx.dialog
+@li @c svx.fmcomp
+@li @c svx.form
+@li @c svx.stbcrtls - StatusBarControl
+@li @c svx.table
+@li @c svx.tbxcrtls - ToolboxControl
+@li @c svx.sdr
+@li @c svx.uno
+
+@section toolkit
+
+@li @c toolkit.controls
+
+@section tools
+
+@li @c tools.debug
+@li @c tools.datetime
+@li @c tools.generic
+@li @c tools.memtools
+@li @c tools.rc - resource manager
+@li @c tools.stream - SvStream class
+
+@section ucb
+
+@li @c cmisucp
+@li @c ucb.ucp
+@li @c ucb.ucp.gio
+@li @c ucb.ucp.webdav
+
+@section unotools
+
+@li @c unotools.config
+@li @c unotools.i18n
+@li @c unotools.misc
+@li @c unotools.ucbhelper
+
+@section URE
+
+@li @c rtl.string - ::rtl::OString, ::rtl::OUString, and related functionality
+@li @c salhelper.thread - ::salhelper::Thread class
+
+@section sax
+
+@li @c sax.cppunit
+
+@section stoc
+
+@li @c stoc.corerefl - CoreReflection
+@li @c stoc.tdmanager - TypeDescriptionManager
+
+@section svl
+
+@li @c svl.items
+
+@section VCL
+
+@li @c vcl
+@li @c vcl.a11y
+@li @c vcl.atsui - ATSUI (obsolete) -using code for Mac OS X
+@li @c vcl.control
+@li @c vcl.coretext - CoreText-using code for Mac OS X and iOS
+@li @c vcl.fonts - font-specific code
+@li @c vcl.gdi - the GDI part of VCL, devices, bitmaps, etc.
+@li @c vcl.gtk - Gtk+ 2/3 plugin
+@li @c vcl.headless - bitmap-based backend
+@li @c vcl.kde - KDE
+@li @c vcl.kde4 - KDE4
+@li @c vcl.layout - Widget layout
+@li @c vcl.scrollbar - Scroll Bars
+@li @c vcl.sm - Session Manager
+@li @c vcl.window
+@li @c vcl.unity
+@li @c vcl.virdev
+
+@section Writer
+
+@li @c sw
+@li @c sw.core - Writer core
+@li @c sw.docx
+@li @c sw.envelp
+@li @c sw.level2
+@li @c sw.rtf - .rtf export filter
+@li @c sw.uno - Writer UNO interfaces
+@li @c sw.ww8 - .doc/.docx export filter, .doc import filter (not writerfilter)
+@li @c sw.ww8.level2 - further info for sw.ww8
+
+@section writerfilter
+
+@li @c writerfilter
+@li @c writerfilter.profile - load times of filters
+
+@section xmloff
+
+@li @c xmloff.core
+@li @c xmloff.forms
+@li @c xmloff.chart
+@li @c xmloff.style
+
+@section xmlsecurity
+
+@li @c xmlsecurity.dialogs - xml security dialogs
+@li @c xmlsecurity.helper
+@li @c xmlsecurity.xmlsec - xmlsec wrapper
+
+@section xmlscript
+
+@li @c xmlscript.xmlhelper
+@li @c xmlscript.xmldlg
+@li @c xmlscript.xmlflat
+@li @c xmlscript.xmllib
+@li @c xmlscript.xmlmod
+
+@section dbaccess
+
+@li @c dbaccess
+@li @c dbaccess.ui
+
+@section svx
+
+@li @c svx
+@li @c svx.fmcmop
+
+@section other
+
+@li @c accessibility
+@li @c avmedia
+@li @c basebmp
+@li @c binaryurp
+@li @c bridges
+@li @c comphelper
+@li @c configmgr
+@li @c cppcanvas
+@li @c cppuhelper
+@li @c cppu
+@li @c forms
+@li @c helpcompiler
+@li @c linguistic
+@li @c oox
+@li @c package
+@li @c rsc
+@li @c sax
+@li @c shell
+@li @c stoc
+@li @c svg
+@li @c ucbhelper
+@li @c unoidl
+@li @c uui
+@li @c vbahelper
+@li @c xmlhelp
+@li @c xmloff
+@li @c xmlreader
+
+*/
+/* vim:set ft=cpp shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/log.hxx b/include/sal/log.hxx
new file mode 100644
index 000000000000..6eae1b59d43c
--- /dev/null
+++ b/include/sal/log.hxx
@@ -0,0 +1,317 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SAL_LOG_HXX
+#define INCLUDED_SAL_LOG_HXX
+
+#include "sal/config.h"
+
+#include <cstdlib>
+#include <sstream>
+#include <string>
+
+#include "sal/detail/log.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+// Avoid the use of other sal code in this header as much as possible, so that
+// this code can be called from other sal code without causing endless
+// recursion.
+
+/// @cond INTERNAL
+
+extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log(
+ enum sal_detail_LogLevel level, char const * area, char const * where,
+ char const * message);
+
+namespace sal { namespace detail {
+
+inline void SAL_CALL log(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ std::ostringstream const & stream)
+{
+ // An alternative would be to have sal_detail_log take a std::ostringstream
+ // pointer (via a C void pointer); the advantage would be smaller client
+ // code (the ".str().c_str()" part would move into the implementation of
+ // sal_detail_log) and potential for proper support of embedded null
+ // characters within the message, but the disadvantage would be dependence
+ // on the C++ ABI; as a compromise, the ".str().c_str()" part has been moved
+ // to this inline function so that it is potentially only emitted once per
+ // dynamic library:
+ sal_detail_log(level, area, where, stream.str().c_str());
+}
+
+// Special handling of the common case where the message consists of just a
+// string literal, to produce smaller call-site code:
+
+struct StreamStart {};
+
+struct StreamString {
+ StreamString(char const * s): string(s) {}
+
+ char const * string;
+
+ typedef char Result;
+};
+
+struct StreamIgnore {
+ typedef struct { char a[2]; } Result;
+};
+
+inline StreamString operator <<(
+ SAL_UNUSED_PARAMETER StreamStart const &, char const * s)
+{
+ return StreamString(s);
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ SAL_UNUSED_PARAMETER StreamStart const &, SAL_UNUSED_PARAMETER T const &)
+{
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return StreamIgnore();
+#endif
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ SAL_UNUSED_PARAMETER StreamString const &, SAL_UNUSED_PARAMETER T const &)
+{
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return StreamIgnore();
+#endif
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ SAL_UNUSED_PARAMETER StreamIgnore const &, SAL_UNUSED_PARAMETER T const &)
+{
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return StreamIgnore();
+#endif
+}
+
+template< typename T > typename T::Result getResult(T const &);
+
+inline char const * unwrapStream(StreamString const & s) { return s.string; }
+
+inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) {
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return 0;
+#endif
+}
+
+} }
+
+#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
+ do { \
+ if (condition) { \
+ if (sizeof ::sal::detail::getResult( \
+ ::sal::detail::StreamStart() << stream) == 1) \
+ { \
+ ::sal_detail_log( \
+ (level), (area), (where), \
+ ::sal::detail::unwrapStream( \
+ ::sal::detail::StreamStart() << stream)); \
+ } else { \
+ ::std::ostringstream sal_detail_stream; \
+ sal_detail_stream << stream; \
+ ::sal::detail::log( \
+ (level), (area), (where), sal_detail_stream); \
+ } \
+ } \
+ } while (false)
+
+/// @endcond
+
+/** A simple macro to create a "file and line number" string.
+
+ Potentially not only useful within the log framework (where it is used
+ automatically), but also when creating exception messages.
+
+ @attention For now, this functionality should only be used internally within
+ LibreOffice. It may change again in a future version.
+
+ @since LibreOffice 3.5
+*/
+#define SAL_WHERE SAL_DETAIL_WHERE
+
+/** A facility for generating temporary string messages by piping items into a
+ C++ std::ostringstream.
+
+ This can be useful for example in a call to SAL_INFO when depending on some
+ boolean condition data of incompatible types shall be streamed into the
+ message, as in:
+
+ SAL_INFO("foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));
+
+ @attention For now, this functionality should only be used internally within
+ LibreOffice. It may change again in a future version.
+
+ @since LibreOffice 3.5
+*/
+#define SAL_STREAM(stream) \
+ (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream). \
+ str())
+
+/**
+ @page sal_log Basic logging functionality.
+
+ @short Macros for logging.
+
+ SAL_INFO(char const * area, expr),
+ SAL_INFO_IF(bool condition, char const * area, expr),
+ SAL_WARN(char const * area, expr),
+ SAL_WARN_IF(bool condition, char const * area, expr), and SAL_DEBUG(expr)
+ produce an info, warning, or debug log entry with a message produced by
+ piping items into a C++ std::ostringstream. The given expr must be so that
+ the full expression "stream << expr" is valid, where stream is a variable of
+ type std::ostringstream.
+
+ SAL_INFO("foo", "string " << s << " of length " << n)
+
+ would be an example of such a call.
+
+ The composed message should be in UTF-8 and it should contain no vertical
+ formatting characters and no null characters
+
+ For the _IF variants, log output is only generated if the given condition is
+ true (in addition to the other conditions that have to be met).
+
+ The SAL_DEBUG macro is for temporary debug statements that are used while
+ working on code. It is never meant to remain in the code. It will always
+ simply output the given expression in debug builds.
+
+ For all the other macros, the given area argument must be non-null and must
+ match the regular expression
+
+ @verbatim
+ <area> ::= <segment>("."<segment>)*
+ @endverbatim
+
+ with
+
+ @verbatim
+ <segment> ::= [0-9a-z]+
+ @endverbatim
+
+ For a list of areas used see @ref sal_log_areas "SAL debug areas". Whenever
+ you use a new log area, add it to the file sal/inc/sal/log-areas.dox .
+
+ Whether these macros generate any log output is controlled in a two-stage
+ process.
+
+ First, at compile time the macros SAL_LOG_INFO and SAL_LOG_WARN,
+ respectively, control whether the INFO and WARN macros, respectively,
+ expand to actual code (in case the macro is defined, to any value) or to
+ no-ops (in case the macro is not defined).
+
+ Second, at runtime the environment variable SAL_LOG further limits which
+ macro calls actually generate log output. The environment variable SAL_LOG
+ must either be unset or must match the regular expression
+
+ @verbatim
+ <env> ::= <switch>*
+ @endverbatim
+
+ with
+
+ @verbatim
+ <switch> ::= <sense><level>("."<area>)?
+ <sense> ::= "+"|"-"
+ <level> ::= "INFO"|"WARN"
+ @endverbatim
+
+ If the environment variable is unset, "+WARN" is used instead (which results
+ in all warnings being output but no infos). If the given value does not
+ match the regular expression, "+INFO+WARN" is used instead (which in turn
+ results in everything being output).
+
+ A given macro call's level (INFO or WARN) and area is matched against the
+ given switches as follows: Only those switches for which the level matches
+ the given level and for which the area is a prefix (including both empty and
+ full prefixes) of the given area are considered. Log output is generated if
+ and only if among the longest such switches (if any), there is at least one
+ that has a sense of "+". (That is, if both +INFO.foo and -INFO.foo are
+ present, +INFO.foo wins.)
+
+ For example, if SAL_LOG is "+INFO-INFO.foo+INFO.foo.bar", then calls like
+ SAL_INFO("foo.bar", ...), SAL_INFO("foo.bar.baz", ...), or
+ SAL_INFO("other", ...) generate output, while calls like
+ SAL_INFO("foo", ...) or SAL_INFO("foo.barzzz", ...) do not.
+
+ The generated log output consists of the given level ("info" or "warn"), the
+ given area, the process ID, the thread ID, the source file, and the source
+ line number, each followed by a colon, followed by a space, the given
+ message, and a newline. The precise format of the log output is subject to
+ change. The log output is printed to stderr without further text encoding
+ conversion.
+
+ @see @ref sal_log_areas
+
+ @attention For now, this functionality should only be used internally within
+ LibreOffice. It may change again in a future version.
+
+ @since LibreOffice 3.5
+*/
+
+/**
+ Produce log entry from stream in the given log area.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_INFO(area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, area, \
+ SAL_WHERE, stream)
+
+/**
+ Produce log entry from stream in the given log area if condition is true.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_INFO_IF(condition, area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_INFO && (condition), \
+ ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
+
+/**
+ Produce warning entry from stream in the given log area.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_WARN(area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN, area, \
+ SAL_WHERE, stream)
+
+/**
+ Produce warning entry from stream in the given log area if condition is true.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_WARN_IF(condition, area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_WARN && (condition), \
+ ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
+
+/**
+ Produce temporary debugging output from stream. This macro is meant to be
+ used only while working on code and should never exist in production code.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_DEBUG(stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG, 0, 0, stream)
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/macros.h b/include/sal/macros.h
new file mode 100644
index 000000000000..262f81996657
--- /dev/null
+++ b/include/sal/macros.h
@@ -0,0 +1,66 @@
+/* -*- 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 _SAL_MACROS_H_
+#define _SAL_MACROS_H_
+
+#include <stddef.h>
+
+#ifndef SAL_N_ELEMENTS
+# if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
+ /*
+ * Magic template to calculate at compile time the number of elements
+ * in an array. Enforcing that the argument must be a array and not
+ * a pointer, e.g.
+ * char *pFoo="foo";
+ * SAL_N_ELEMENTS(pFoo);
+ * fails while
+ * SAL_N_ELEMENTS("foo");
+ * or
+ * char aFoo[]="foo";
+ * SAL_N_ELEMENTS(aFoo);
+ * pass
+ *
+ * Unfortunately if arr is an array of an anonymous class then we need
+ * C++0x, i.e. see
+ * http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#757
+ */
+ template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
+# define SAL_N_ELEMENTS(arr) (sizeof(sal_n_array_size(arr)))
+# else
+# define SAL_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
+# endif
+#endif
+
+#ifndef SAL_BOUND
+# define SAL_BOUND(x,l,h) ((x) <= (l) ? (l) : ((x) >= (h) ? (h) : (x)))
+#endif
+
+#ifndef SAL_ABS
+# define SAL_ABS(a) (((a) < 0) ? (-(a)) : (a))
+#endif
+
+#ifndef SAL_STRINGIFY
+# define SAL_STRINGIFY_ARG(x) #x
+# define SAL_STRINGIFY(x) SAL_STRINGIFY_ARG(x)
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/main.h b/include/sal/main.h
new file mode 100644
index 000000000000..634b57cac534
--- /dev/null
+++ b/include/sal/main.h
@@ -0,0 +1,149 @@
+/* -*- 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 _SAL_MAIN_H_
+#define _SAL_MAIN_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#if defined AIX
+#include <unistd.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
+SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize();
+
+#if defined IOS || defined ANDROID
+
+#error No code that includes this should be built for iOS or Android
+
+#else
+
+#define SAL_MAIN_WITH_ARGS_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ int ret; \
+ sal_detail_initialize(argc, argv); \
+ ret = sal_main_with_args(argc, argv); \
+ sal_detail_deinitialize(); \
+ return ret; \
+}
+
+#define SAL_MAIN_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ int ret; \
+ sal_detail_initialize(argc, argv); \
+ ret = sal_main(); \
+ sal_detail_deinitialize(); \
+ return ret; \
+}
+
+#endif
+
+
+/* Definition macros for CRT entries */
+
+#ifdef SAL_W32
+
+#include <stdlib.h>
+
+/* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
+
+#ifndef WINAPI
+# define WINAPI __stdcall
+#endif
+
+#if !defined(DECLARE_HANDLE)
+# ifdef STRICT
+ typedef void *HANDLE;
+# define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
+# else
+ typedef void *PVOID;
+ typedef PVOID HANDLE;
+# define DECLARE_HANDLE(name) typedef HANDLE name
+# endif
+DECLARE_HANDLE(HINSTANCE);
+#endif
+
+
+
+#define SAL_WIN_WinMain \
+int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
+{ \
+ int argc = __argc; char ** argv = __argv; \
+ (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
+ return main(argc, argv); \
+}
+
+#else /* ! SAL_W32 */
+
+# define SAL_WIN_WinMain
+
+#endif /* ! SAL_W32 */
+
+/* Implementation macro */
+
+#define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
+ static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
+ SAL_MAIN_WITH_ARGS_IMPL \
+ SAL_WIN_WinMain \
+ static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
+
+#define SAL_IMPLEMENT_MAIN() \
+ static int SAL_CALL sal_main(void); \
+ SAL_MAIN_IMPL \
+ SAL_WIN_WinMain \
+ static int SAL_CALL sal_main(void)
+
+/*
+ "How to use" Examples:
+
+ #include <sal/main.h>
+
+ SAL_IMPLEMENT_MAIN()
+ {
+ DoSomething();
+
+ return 0;
+ }
+
+ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+ {
+ DoSomethingWithArgs(argc, argv);
+
+ return 0;
+ }
+
+*/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _SAL_MAIN_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/mathconf.h b/include/sal/mathconf.h
new file mode 100644
index 000000000000..fefd213e3684
--- /dev/null
+++ b/include/sal/mathconf.h
@@ -0,0 +1,156 @@
+/* -*- 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 INCLUDED_SAL_MATHCONF_H
+#define INCLUDED_SAL_MATHCONF_H
+
+#include "osl/endian.h"
+
+#include <float.h>
+
+#if defined SOLARIS
+#include <ieeefp.h>
+#endif /* SOLARIS */
+
+#if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
+#include <cmath>
+#endif
+
+#if defined(IOS)
+#if defined(__cplusplus)
+#include <cmath>
+#else
+#include <math.h>
+#endif
+#endif
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Generally, the C standard guarantees that at program startup, "trapping or
+ stopping (if supported) is disabled on all [floating-point] exceptions"
+ (F.7.3/1 of the August 3, 1998 draft of C99), and that during program
+ execution, "a programmer can safely assume default modes (or be unaware of
+ them)" (7.6/2, footnote 161 of the August 3, 1998 draft of C99). Reportedly,
+ on Windows there are printer drivers that switch on exceptions. To avoid
+ problems, the SAL_MATH_FPEXCEPTIONS_OFF macro can be used to explicitly
+ switch off exceptions (on Windows).
+ */
+#if defined WNT
+#define SAL_MATH_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
+#else /* WNT */
+#define SAL_MATH_FPEXCEPTIONS_OFF()
+#endif /* WNT */
+
+
+/* SAL_MATH_FINITE(d): test double d on INFINITY, NaN et al. */
+#if !defined SOLARIS && !defined ANDROID \
+ && defined(__cplusplus) \
+ && ( defined(__GXX_EXPERIMENTAL_CXX0X__) \
+ || __cplusplus >= 201103L \
+ || defined(IOS) )
+#define SAL_MATH_FINITE(d) std::isfinite(d)
+#elif defined( IOS )
+#define SAL_MATH_FINITE(d) isfinite(d)
+#elif defined( WNT)
+#define SAL_MATH_FINITE(d) _finite(d)
+#elif defined LINUX || defined UNX
+#define SAL_MATH_FINITE(d) finite(d)
+#else /* WNT, LINUX, UNX */
+#error "SAL_MATH_FINITE not defined"
+#endif /* WNT, LINUX, UNX */
+
+
+/* This needs to be fixed for non--IEEE-754 platforms: */
+#if 1 /* IEEE 754 supported */
+#if defined OSL_BIGENDIAN
+
+/* IEEE 754 double structures for BigEndian */
+union sal_math_Double
+{
+ struct
+ {
+ unsigned sign : 1;
+ unsigned exponent :11;
+ unsigned fraction_hi :20;
+ unsigned fraction_lo :32;
+ } inf_parts;
+ struct
+ {
+ unsigned sign : 1;
+ unsigned exponent :11;
+ unsigned qnan_bit : 1;
+ unsigned bits :19;
+ unsigned fraction_lo :32;
+ } nan_parts;
+ struct
+ {
+ unsigned msw :32;
+ unsigned lsw :32;
+ } w32_parts;
+ double value;
+};
+
+#elif defined OSL_LITENDIAN
+
+/* IEEE 754 double structures for LittleEndian */
+union sal_math_Double
+{
+ struct {
+ unsigned fraction_lo :32;
+ unsigned fraction_hi :20;
+ unsigned exponent :11;
+ unsigned sign : 1;
+ } inf_parts;
+ struct {
+ unsigned fraction_lo :32;
+ unsigned bits :19;
+ unsigned qnan_bit : 1;
+ unsigned exponent :11;
+ unsigned sign : 1;
+ } nan_parts;
+ struct
+ {
+ unsigned lsw :32;
+ unsigned msw :32;
+ } w32_parts;
+ double value;
+};
+
+#else /* OSL_BIGENDIAN, OSL_LITENDIAN */
+
+#error "neither OSL_BIGENDIAN nor OSL_LITENDIAN"
+
+#endif /* OSL_BIGENDIAN, OSL_LITENDIAN */
+#else /* IEEE 754 supported */
+
+#error "don't know how to handle IEEE 754"
+
+#endif /* IEEE 754 supported */
+
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_SAL_MATHCONF_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/saldllapi.h b/include/sal/saldllapi.h
new file mode 100644
index 000000000000..f45e50e1cc5b
--- /dev/null
+++ b/include/sal/saldllapi.h
@@ -0,0 +1,35 @@
+/* -*- 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 INCLUDED_SALDLLAPI_H
+#define INCLUDED_SALDLLAPI_H
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined(SAL_DLLIMPLEMENTATION)
+#define SAL_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define SAL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif /* INCLUDED_SALDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/types.h b/include/sal/types.h
new file mode 100644
index 000000000000..55f2e729ac8b
--- /dev/null
+++ b/include/sal/types.h
@@ -0,0 +1,566 @@
+/* -*- 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 _SAL_TYPES_H_
+#define _SAL_TYPES_H_
+
+#include <sal/config.h>
+#include <sal/macros.h>
+
+#include <sal/typesizes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************************************************************************/
+/* Data types
+*/
+
+/* Boolean */
+typedef unsigned char sal_Bool;
+# define sal_False ((sal_Bool)0)
+# define sal_True ((sal_Bool)1)
+
+/* char is assumed to always be 1 byte long */
+typedef signed char sal_Int8;
+typedef unsigned char sal_uInt8;
+
+#if SAL_TYPES_SIZEOFSHORT == 2
+ typedef signed short sal_Int16;
+ typedef unsigned short sal_uInt16;
+#else
+ #error "Could not find 16-bit type, add support for your architecture"
+#endif
+
+#if SAL_TYPES_SIZEOFLONG == 4
+ typedef signed long sal_Int32;
+ typedef unsigned long sal_uInt32;
+ #define SAL_PRIdINT32 "ld"
+ #define SAL_PRIuUINT32 "lu"
+ #define SAL_PRIxUINT32 "lx"
+ #define SAL_PRIXUINT32 "lX"
+#elif SAL_TYPES_SIZEOFINT == 4
+ typedef signed int sal_Int32;
+ typedef unsigned int sal_uInt32;
+ #define SAL_PRIdINT32 "d"
+ #define SAL_PRIuUINT32 "u"
+ #define SAL_PRIxUINT32 "x"
+ #define SAL_PRIXUINT32 "X"
+#else
+ #error "Could not find 32-bit type, add support for your architecture"
+#endif
+
+#ifdef _MSC_VER
+ typedef __int64 sal_Int64;
+ typedef unsigned __int64 sal_uInt64;
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##i64
+ #define SAL_CONST_UINT64(x) x##ui64
+
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (sgi)
+ #if SAL_TYPES_SIZEOFLONG == 8
+ typedef signed long int sal_Int64;
+ typedef unsigned long int sal_uInt64;
+
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##l
+ #define SAL_CONST_UINT64(x) x##ul
+
+ #define SAL_PRIdINT64 "ld"
+ #define SAL_PRIuUINT64 "lu"
+ #define SAL_PRIxUINT64 "lx"
+ #define SAL_PRIXUINT64 "lX"
+ #elif SAL_TYPES_SIZEOFLONGLONG == 8
+ typedef signed long long sal_Int64;
+ typedef unsigned long long sal_uInt64;
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##ll
+ #define SAL_CONST_UINT64(x) x##ull
+
+ #ifdef __MINGW32__
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+ #else
+ #define SAL_PRIdINT64 "lld"
+ #define SAL_PRIuUINT64 "llu"
+ #define SAL_PRIxUINT64 "llx"
+ #define SAL_PRIXUINT64 "llX"
+ #endif
+ #else
+ #error "Could not find 64-bit type, add support for your architecture"
+ #endif
+#else
+ #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
+#endif
+
+typedef char sal_Char;
+typedef signed char sal_sChar;
+typedef unsigned char sal_uChar;
+
+#if ( defined(SAL_W32) && !defined(__MINGW32__) )
+ // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
+ // "By default wchar_t is a typedef for unsigned short."
+ // But MinGW has a native wchar_t, and on many places, we cannot deal with
+ // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
+ typedef wchar_t sal_Unicode;
+#else
+ #define SAL_UNICODE_NOTEQUAL_WCHAR_T
+ typedef sal_uInt16 sal_Unicode;
+#endif
+
+typedef void * sal_Handle;
+
+/* sal_Size should currently be the native width of the platform */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_uInt32 sal_Size;
+ typedef sal_Int32 sal_sSize;
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_uInt64 sal_Size;
+ typedef sal_Int64 sal_sSize;
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/* sal_PtrDiff holds the result of a pointer subtraction */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_Int32 sal_PtrDiff;
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_Int64 sal_PtrDiff;
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/* printf-style conversion specification length modifiers for size_t and
+ ptrdiff_t (most platforms support C99, MSC has its own extension) */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ #define SAL_PRI_SIZET "I"
+ #define SAL_PRI_PTRDIFFT "I"
+#else
+ #define SAL_PRI_SIZET "z"
+ #define SAL_PRI_PTRDIFFT "t"
+#endif
+
+/* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
+ * pointer to void can be converted to this type and back to a pointer to void and the
+ * result will compare to the original pointer */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_Int32 sal_IntPtr;
+ typedef sal_uInt32 sal_uIntPtr;
+ #define SAL_PRIdINTPTR SAL_PRIdINT32
+ #define SAL_PRIuUINTPTR SAL_PRIuUINT32
+ #define SAL_PRIxUINTPTR SAL_PRIxUINT32
+ #define SAL_PRIXUINTPTR SAL_PRIXUINT32
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_Int64 sal_IntPtr;
+ typedef sal_uInt64 sal_uIntPtr;
+ #define SAL_PRIdINTPTR SAL_PRIdINT64
+ #define SAL_PRIuUINTPTR SAL_PRIuUINT64
+ #define SAL_PRIxUINTPTR SAL_PRIxUINT64
+ #define SAL_PRIXUINTPTR SAL_PRIXUINT64
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/********************************************************************************/
+/* Useful defines
+ */
+
+/* The following SAL_MIN_INTn defines codify the assumption that the signed
+ * sal_Int types use two's complement representation. Defining them as
+ * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
+ * unary minus operator to unsigned quantities.
+ */
+#define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
+#define SAL_MAX_INT8 ((sal_Int8) 0x7F)
+#define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
+#define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
+#define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
+#define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
+#define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
+#define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
+#define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
+#define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
+#define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
+#define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
+
+#if SAL_TYPES_SIZEOFLONG == 4
+#define SAL_MAX_SSIZE SAL_MAX_INT32
+#define SAL_MAX_SIZE SAL_MAX_UINT32
+#elif SAL_TYPES_SIZEOFLONG == 8
+#define SAL_MAX_SSIZE SAL_MAX_INT64
+#define SAL_MAX_SIZE SAL_MAX_UINT64
+#endif
+
+#if defined(SAL_W32) || defined(SAL_UNX)
+# define SAL_MAX_ENUM 0x7fffffff
+#endif
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+# define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
+# define SAL_JNI_EXPORT __declspec(dllexport)
+#if defined(_MSC_VER)
+# define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
+#else
+# define SAL_DLLPUBLIC_IMPORT
+#endif // defined(_MSC_VER)
+# define SAL_DLLPRIVATE
+# define SAL_DLLPUBLIC_TEMPLATE
+# define SAL_CALL __cdecl
+# define SAL_CALL_ELLIPSE __cdecl
+#elif defined SAL_UNX
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
+# define SAL_DLLPUBLIC_EXPORT __global
+# define SAL_JNI_EXPORT __global
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __hidden
+# define SAL_DLLPUBLIC_TEMPLATE
+# elif defined(__SUNPRO_C ) && (__SUNPRO_C >= 0x550)
+# define SAL_DLLPUBLIC_EXPORT __global
+# define SAL_JNI_EXPORT __global
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __hidden
+# define SAL_DLLPUBLIC_TEMPLATE
+# elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
+# if defined(DISABLE_DYNLOADING)
+# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
+# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
+# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
+# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
+# else
+# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
+# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
+# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
+# endif
+# else
+# define SAL_DLLPUBLIC_EXPORT
+# define SAL_JNI_EXPORT
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE
+# define SAL_DLLPUBLIC_TEMPLATE
+# endif
+# define SAL_CALL
+# define SAL_CALL_ELLIPSE
+#else
+# error("unknown platform")
+#endif
+
+/**
+ Exporting the symbols necessary for exception handling on GCC.
+
+ These macros are used for inline declarations of exception classes, as in
+ rtl/malformeduriexception.hxx.
+*/
+#if defined(__GNUC__) && ! defined(__MINGW32__)
+# if defined(DISABLE_DYNLOADING)
+# define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
+# else
+# define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
+# endif
+# define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
+#else
+# define SAL_EXCEPTION_DLLPUBLIC_EXPORT
+# define SAL_EXCEPTION_DLLPRIVATE
+#endif
+
+/** Use this as markup for functions and methods whose return value must be
+ checked.
+
+ Compilers that support a construct of this nature will emit a compile
+ time warning on unchecked return value.
+*/
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+# define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+# define SAL_WARN_UNUSED_RESULT
+#endif
+
+/** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
+ This hinders the compiler from setting a generic vtable stating that
+ a pure virtual function was called and thus slightly reduces code size.
+*/
+#ifdef _MSC_VER
+# define SAL_NO_VTABLE __declspec(novtable)
+#else
+# define SAL_NO_VTABLE
+#endif
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+/** This is the binary specification of a SAL sequence.
+ <br>
+*/
+typedef struct _sal_Sequence
+{
+ /** reference count of sequence<br>
+ */
+ sal_Int32 nRefCount;
+ /** element count<br>
+ */
+ sal_Int32 nElements;
+ /** elements array<br>
+ */
+ char elements[1];
+} sal_Sequence;
+
+#define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+/** Definition of function throw clause macros. These have been introduced
+ to reduce code size by balancing out compiler bugs.
+
+ These macros are ONLY for function declarations,
+ use common C++ throw statement for throwing exceptions, e.g.
+ throw RuntimeException();
+
+ SAL_THROW() should be used for all C++ functions, e.g. SAL_THROW(())
+ SAL_THROW_EXTERN_C() should be used for all C functions
+*/
+#ifdef __cplusplus
+#if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi)
+#define SAL_THROW( exc )
+#else /* MSVC, all other */
+#define SAL_THROW( exc ) throw exc
+#endif /* __GNUC__, __SUNPRO_CC */
+#define SAL_THROW_EXTERN_C() throw ()
+#else /* ! __cplusplus */
+/* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */
+#define SAL_THROW_EXTERN_C()
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+
+enum __sal_NoAcquire
+{
+ /** definition of a no acquire enum for ctors
+ */
+ SAL_NO_ACQUIRE
+};
+
+namespace com { namespace sun { namespace star { } } }
+
+/** short-circuit extra-verbose API namespaces
+
+ @since LibreOffice 4.0
+*/
+namespace css = ::com::sun::star;
+
+/** C++11 "= delete" feature.
+
+ With HAVE_CXX11_DELETE, calling a deleted function will cause a compile-time
+ error, while otherwise it will only cause a link-time error as the declared
+ function is not defined.
+
+ @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_DELETE
+#define SAL_DELETED_FUNCTION = delete
+#else
+#define SAL_DELETED_FUNCTION
+#endif
+
+/** C++11 "override" feature.
+
+ With HAVE_CXX11_OVERRIDE, force the method to override a existing method in
+ parent, error out if the method with the correct signature does not exist.
+
+ @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_OVERRIDE
+#define SAL_OVERRIDE override
+#else
+#define SAL_OVERRIDE
+#endif
+
+/** C++11 "final" feature.
+
+ With HAVE_CXX11_FINAL, mark a class as non-derivable or a method as non-overridable.
+
+ @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_FINAL
+#define SAL_FINAL final
+#else
+#define SAL_FINAL
+#endif
+
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+
+namespace sal {
+
+/**
+ A static_cast between integral types, to avoid C++ compiler warnings.
+
+ In C++ source code, use sal::static_int_cast<T>(n) instead of
+ static_cast<T>(n) whenever a compiler warning about integral type problems
+ shall be silenced. That way, source code that needs to be modified when the
+ type of any of the expressions involved in the compiler warning is changed
+ can be found more easily.
+
+ Both template arguments T1 and T2 must be integral types.
+*/
+template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
+ return static_cast< T1 >(n);
+}
+
+}
+
+#else /* __cplusplus */
+
+/**
+ A cast between integer types, to avoid C compiler warnings.
+
+ In C source code, use SAL_INT_CAST(type, expr) instead of ((type) (expr))
+ whenever a compiler warning about integer type problems shall be silenced.
+ That way, source code that needs to be modified when the type of any of the
+ expressions involved in the compiler warning is changed can be found more
+ easily.
+
+ The argument 'type' must be an integer type and the argument 'expr' must be
+ an integer expression. Both arguments are evaluated exactly once.
+*/
+#define SAL_INT_CAST(type, expr) ((type) (expr))
+
+#endif /* __cplusplus */
+
+/**
+ Use as follows:
+ SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);
+*/
+
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+# define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
+#elif (__GNUC__)
+# define SAL_DEPRECATED(message) __attribute__((deprecated))
+#elif defined(_MSC_VER)
+# define SAL_DEPRECATED(message) __declspec(deprecated(message))
+#else
+# define SAL_DEPRECATED(message)
+#endif
+
+/**
+ This macro is used to tag interfaces that are deprecated for both
+ internal and external API users, but where we are still writing
+ out the internal usage. Ultimately these should be replaced by
+ SAL_DEPRECATED, and then removed.
+
+ Use as follows:
+ SAL_DEPRECATED_INTERNAL("Dont use, its evil.") void doit(int nPara);
+ */
+#ifdef LIBO_INTERNAL_ONLY
+# define SAL_DEPRECATED_INTERNAL(message)
+#else
+# define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
+#endif
+
+/**
+ Use as follows:
+ SAL_WNODEPRECATED_DECLARATIONS_PUSH
+ \::std::auto_ptr<X> ...
+ SAL_WNODEPRECATED_DECLARATIONS_POP
+*/
+
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
+#define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
+ _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
+ _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
+#define SAL_WNODEPRECATED_DECLARATIONS_POP \
+ _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
+#else
+# define SAL_WNODEPRECATED_DECLARATIONS_PUSH
+# define SAL_WNODEPRECATED_DECLARATIONS_POP
+#endif
+
+/** Annotate unused but required C++ function parameters.
+
+ An unused parameter is required if the function needs to adhere to a given
+ type (e.g., if its address is assigned to a function pointer of a specific
+ type, or if it is called from template code). This annotation helps static
+ analysis tools suppress false warnings. In the case of virtual functions
+ (where unused required parameters are common, too), the annotation is not
+ required (as static analysis tools can themselves derive the information
+ whether a function is virtual).
+
+ Use the annotation in function definitions like
+
+ void f(SAL_UNUSED_PARAMETER int) {}
+
+ C does not allow unnamed parameters, anyway, so a function definition like
+ the above needs to be written there as
+
+ void f(int dummy) { (void) dummy; / * avoid warnings * / }
+
+ without a SAL_UNUSED_PARAMETER annotation.
+
+ @since LibreOffice 3.6
+ */
+#if defined __cplusplus
+#if defined __GNUC__
+#define SAL_UNUSED_PARAMETER __attribute__ ((unused))
+#else
+#define SAL_UNUSED_PARAMETER
+#endif
+#endif
+
+/**
+
+ Annotate classes where a compiler should warn if an instance is unused.
+
+ The compiler cannot warn about unused instances if they have non-trivial
+ or external constructors or destructors. Classes marked with SAL_WARN_UNUSED
+ will be warned about.
+
+ Currently implemented by a Clang compiler plugin.
+
+ @since LibreOffice 4.0
+
+*/
+
+#if defined __clang__
+#define SAL_WARN_UNUSED __attribute__((annotate("lo_warn_unused")))
+#else
+#define SAL_WARN_UNUSED
+#endif
+
+#endif /*_SAL_TYPES_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/typesizes.h b/include/sal/typesizes.h
new file mode 100644
index 000000000000..e981818b9ced
--- /dev/null
+++ b/include/sal/typesizes.h
@@ -0,0 +1,20 @@
+/* -*- 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/.
+ */
+
+/* DO NOT INCLUDE THIS HEADER DIRECTLY!
+ *
+ * It is only needed to make the build work. config_typesizes.h is
+ * copied to SDK as sal/typesizes.h and this is how sal/types.h includes
+ * it. This means we need to have sal/typesizes.h available for build
+ * too.
+ */
+
+#include "config_typesizes.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/condition.hxx b/include/salhelper/condition.hxx
new file mode 100644
index 000000000000..459f39d354bc
--- /dev/null
+++ b/include/salhelper/condition.hxx
@@ -0,0 +1,118 @@
+/* -*- 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 _SALHELPER_CONDITION_HXX_
+#define _SALHELPER_CONDITION_HXX_
+
+
+#include <osl/conditn.h>
+#include <osl/mutex.hxx>
+#include "salhelperdllapi.h"
+
+namespace salhelper
+{
+ class ConditionModifier;
+ class ConditionWaiter;
+
+
+ class SALHELPER_DLLPUBLIC Condition
+ {
+ friend class ConditionModifier;
+ friend class ConditionWaiter;
+
+ public:
+
+ Condition(osl::Mutex& aMutex);
+
+ virtual ~Condition();
+
+
+ protected:
+
+ virtual bool applies() const = 0;
+
+
+ private:
+ SALHELPER_DLLPRIVATE Condition(Condition &); // not defined
+ SALHELPER_DLLPRIVATE void operator =(Condition &); // not defined
+
+ osl::Mutex& m_aMutex;
+ oslCondition m_aCondition;
+ };
+
+
+
+ class SALHELPER_DLLPUBLIC ConditionModifier
+ {
+ public:
+
+ ConditionModifier(Condition& aCond);
+
+ ~ConditionModifier();
+
+
+ private:
+ SALHELPER_DLLPRIVATE ConditionModifier(ConditionModifier &); // not defined
+ SALHELPER_DLLPRIVATE void operator =(ConditionModifier &); // not defined
+
+ Condition& m_aCond;
+ };
+
+
+
+ class SALHELPER_DLLPUBLIC ConditionWaiter
+ {
+ public:
+
+ ConditionWaiter(Condition& aCond);
+
+ struct SALHELPER_DLLPUBLIC timedout {
+ timedout();
+
+ timedout(timedout const &);
+
+ virtual ~timedout();
+
+ timedout & operator =(timedout const &);
+ };
+
+ ConditionWaiter(Condition& aCond,sal_uInt32 milliSec)
+ throw(
+ timedout
+ );
+
+
+ ~ConditionWaiter();
+
+
+ private:
+ SALHELPER_DLLPRIVATE ConditionWaiter(ConditionWaiter &); // not defined
+ SALHELPER_DLLPRIVATE void operator =(ConditionWaiter &); // not defined
+
+ Condition& m_aCond;
+ };
+
+
+} // namespace salhelper
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/dynload.hxx b/include/salhelper/dynload.hxx
new file mode 100644
index 000000000000..f79bb2277987
--- /dev/null
+++ b/include/salhelper/dynload.hxx
@@ -0,0 +1,204 @@
+/* -*- 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 _SALHELPER_DYNLOAD_HXX_
+#define _SALHELPER_DYNLOAD_HXX_
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <osl/module.h>
+#include "salhelperdllapi.h"
+
+namespace salhelper
+{
+
+/** The ORealDynamicLoader is an implementation helper class for the template loader ODynamicLoader.
+ */
+class SALHELPER_DLLPUBLIC ORealDynamicLoader
+{
+public:
+ /** initializes the loader, loads the library and call the initialization function.
+
+ @param ppSetToZeroInDestructor points to the loader instance which must be set to NULL
+ if the loader will be destroyed.
+ @param strModuleName specifies the library name.
+ @param strInitFunction specifies the name of the initialization function.
+ */
+ static ORealDynamicLoader* SAL_CALL newInstance(
+ ORealDynamicLoader ** ppSetToZeroInDestructor,
+ const ::rtl::OUString& strModuleName,
+ const ::rtl::OUString& strInitFunction );
+
+ /// increase the reference count.
+ sal_uInt32 SAL_CALL acquire();
+ /// decrease the reference count and delete the last instance.
+ sal_uInt32 SAL_CALL release();
+
+ /// returns a poiner to the initialized API function structure.
+ void* SAL_CALL getApi() const;
+
+protected:
+ /** Constructor.
+
+ @param ppSetToZeroInDestructor points to the loader instance which must be set to NULL
+ if the loader will be destroyed.
+ @param strModuleName specifies the library name.
+ @param strInitFunction specifies the name of the initialization function.
+ @param pApi points to a structure with the initialized API function pointers.
+ @param pModule points to the loaded library handle.
+ */
+ ORealDynamicLoader( ORealDynamicLoader ** ppSetToZeroInDestructor,
+ const ::rtl::OUString& strModuleName,
+ const ::rtl::OUString& strInitFunction,
+ void* pApi,
+ oslModule pModule );
+
+ /// Destructor, try to unload the library.
+ virtual ~ORealDynamicLoader();
+
+ /// points to the structure with the initialzed API function pointers.
+ void* m_pApi;
+ /// stores the reference count.
+ sal_uInt32 m_refCount;
+ /// stores the library handle.
+ oslModule m_pModule;
+ /// stores the library name.
+ ::rtl::OUString m_strModuleName;
+ /// stores the name of the initialization function.
+ ::rtl::OUString m_strInitFunction;
+ /** stores a pointer to itself, which must be reset in the destructor to signal
+ that the loader is invalid.
+ */
+ ORealDynamicLoader ** ppSetToZeroInDestructor;
+};
+
+
+/** The ODynmaicLoader provides a special load on call mechanism for dynamic libraries
+ which support a C-API.
+
+ The libraries must provide a struct with function pointers for all supported C functions.
+ The loader loads the specified library and call the specified initialization function
+ to initialize the function pointers with the real functions. Furthermore provides the
+ loader a reference counter for the library. When the last instance of the laoder will
+ be destroyed the loader will unload the library.
+
+ @deprecated
+ Do not use.
+ */
+template<class API>
+class ODynamicLoader
+{
+public:
+ /// Default constructor
+ ODynamicLoader() SAL_THROW(())
+ {
+ m_pLoader = 0;
+ }
+
+ /** Constructor, loads the library if necessary otherwise the refernece count will
+ be increased.
+
+ @param strModuleName specifies the library name.
+ @param strInitFunction specifies the name of the initialization function.
+ */
+ ODynamicLoader( const ::rtl::OUString& strModuleName,
+ const ::rtl::OUString& strInitFunction ) SAL_THROW(())
+ {
+ if (!m_pStaticLoader)
+ {
+ m_pStaticLoader = ORealDynamicLoader::newInstance(
+ &m_pStaticLoader,
+ strModuleName,
+ strInitFunction);
+ }
+ else
+ {
+ m_pStaticLoader->acquire();
+ }
+
+ m_pLoader = m_pStaticLoader;
+ }
+
+ /// Copy constructor
+ ODynamicLoader(const ODynamicLoader<API>& toCopy) SAL_THROW(())
+ {
+ m_pLoader = toCopy.m_pLoader;
+ if( m_pLoader )
+ m_pLoader->acquire();
+ }
+
+ /// Destructor, decrease the reference count and unload the library if it is tha last instance.
+ ~ODynamicLoader() SAL_THROW(())
+ {
+ if( m_pLoader )
+ m_pLoader->release();
+ }
+
+ /// Assign operator
+ ODynamicLoader<API>& SAL_CALL operator = (const ODynamicLoader<API>& toAssign) SAL_THROW(())
+ {
+ if( m_pLoader != toAssign.m_pLoader )
+ {
+ if( toAssign.m_pLoader )
+ {
+ toAssign.m_pLoader->acquire();
+ }
+ if( m_pLoader )
+ {
+ m_pLoader->release();
+ }
+ m_pLoader = toAssign.m_pLoader;
+ }
+
+ return (*this);
+ }
+
+ /// returns a poiner to the initialized API function structure.
+ API* SAL_CALL getApi() const SAL_THROW(())
+ {
+ return (API*)m_pLoader->getApi();
+ }
+
+ /// cast operator, which cast to a poiner with the initialized API function structure.
+ API* SAL_CALL operator->() const SAL_THROW(())
+ {
+ return (API*)m_pLoader->getApi();
+ }
+
+ /// checks if the loader works on a loaded and initialized library.
+ sal_Bool SAL_CALL isLoaded() const SAL_THROW(())
+ {
+ return (m_pLoader != NULL);
+ }
+
+protected:
+ /// stores the real loader helper instance
+ static ORealDynamicLoader* m_pStaticLoader;
+ ORealDynamicLoader* m_pLoader;
+};
+
+
+template<class API>
+ORealDynamicLoader* ODynamicLoader<API>::m_pStaticLoader = NULL;
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/linkhelper.hxx b/include/salhelper/linkhelper.hxx
new file mode 100644
index 000000000000..ef185c078908
--- /dev/null
+++ b/include/salhelper/linkhelper.hxx
@@ -0,0 +1,75 @@
+/* -*- 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/.
+ */
+
+#ifndef _SALHELPER_LINKHELPER_HXX
+#define _SALHELPER_LINKHELPER_HXX
+
+#include <rtl/ustring.hxx>
+#include <osl/file.hxx>
+
+namespace salhelper
+{
+ class LinkResolver
+ {
+ public:
+ osl::FileStatus m_aStatus;
+
+ LinkResolver(sal_uInt32 nMask)
+ : m_aStatus(nMask |
+ osl_FileStatus_Mask_FileURL |
+ osl_FileStatus_Mask_Type |
+ osl_FileStatus_Mask_LinkTargetURL)
+ {
+ }
+
+ /** Resolve a file url if its a symbolic link, to a maximum depth of
+ * nDepth and fill in m_aStatus with the requested ctor flags
+ *
+ * @return osl::FileBase::E_None on success
+ *
+ * @see DirectoryItem::getFileStatus
+ */
+ osl::FileBase::RC fetchFileStatus(const rtl::OUString &rURL,
+ int nDepth = 128)
+ {
+ //In an ideal world this wouldn't be inline, but I want to use this
+ //in jvmfwk hence salhelper, but salhelper is .map controlled and
+ //getting all the mangled names right is a misery, moving it over
+ //to visibility markup would drop per-symbol versioning
+ osl::FileBase::RC eReturn;
+
+ osl::DirectoryItem item;
+ rtl::OUString sURL(rURL);
+ while ((eReturn = osl::DirectoryItem::get(sURL, item))
+ == osl::File::E_None)
+ {
+ if (--nDepth == 0)
+ {
+ eReturn = osl::FileBase::E_MULTIHOP;
+ break;
+ }
+ eReturn = item.getFileStatus(m_aStatus);
+ if (eReturn != osl::File::E_None)
+ break;
+ if (m_aStatus.getFileType() != osl::FileStatus::Link)
+ {
+ eReturn = osl::FileBase::E_None;
+ break;
+ }
+ sURL = m_aStatus.getLinkTargetURL();
+ }
+
+ return eReturn;
+ }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/refobj.hxx b/include/salhelper/refobj.hxx
new file mode 100644
index 000000000000..5d7d322b6140
--- /dev/null
+++ b/include/salhelper/refobj.hxx
@@ -0,0 +1,104 @@
+/* -*- 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 _SALHELPER_REFOBJ_HXX_
+#define _SALHELPER_REFOBJ_HXX_
+
+#include <sal/types.h>
+#include <rtl/alloc.h>
+#include <rtl/ref.hxx>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+namespace salhelper
+{
+
+//----------------------------------------------------------------------------
+
+class ReferenceObject : public rtl::IReference
+{
+ /** Representation.
+ */
+ oslInterlockedCount m_nReferenceCount;
+
+ /** Not implemented.
+ */
+ ReferenceObject (const ReferenceObject&);
+ ReferenceObject& operator= (const ReferenceObject&);
+
+public:
+ /** Allocation.
+ */
+ static void* operator new (size_t n) SAL_THROW(())
+ {
+ return ::rtl_allocateMemory (n);
+ }
+ static void operator delete (void* p) SAL_THROW(())
+ {
+ ::rtl_freeMemory (p);
+ }
+ static void* operator new (size_t, void* p) SAL_THROW(())
+ {
+ return (p);
+ }
+ static void operator delete (void*, void*) SAL_THROW(())
+ {}
+
+public:
+ /** Construction.
+ */
+ inline ReferenceObject() SAL_THROW(()) : m_nReferenceCount (0)
+ {}
+
+
+ /** IReference.
+ */
+ virtual oslInterlockedCount SAL_CALL acquire() SAL_THROW(())
+ {
+ return ::osl_incrementInterlockedCount (&m_nReferenceCount);
+ }
+
+ virtual oslInterlockedCount SAL_CALL release() SAL_THROW(())
+ {
+ oslInterlockedCount result;
+ result = ::osl_decrementInterlockedCount (&m_nReferenceCount);
+ if (result == 0)
+ {
+ // Last reference released.
+ delete this;
+ }
+ return (result);
+ }
+
+protected:
+ /** Destruction.
+ */
+ virtual ~ReferenceObject() SAL_THROW(())
+ {
+ OSL_ASSERT(m_nReferenceCount == 0);
+ }
+};
+
+//----------------------------------------------------------------------------
+
+} // namespace salhelper
+
+#endif /* !_SALHELPER_REFOBJ_HXX_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/salhelperdllapi.h b/include/salhelper/salhelperdllapi.h
new file mode 100644
index 000000000000..d80cf8b0ec56
--- /dev/null
+++ b/include/salhelper/salhelperdllapi.h
@@ -0,0 +1,34 @@
+/* -*- 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 INCLUDED_SALHELPERDLLAPI_H
+#define INCLUDED_SALHELPERDLLAPI_H
+
+#include "sal/types.h"
+
+#if defined(SALHELPER_DLLIMPLEMENTATION)
+#define SALHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define SALHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define SALHELPER_DLLPRIVATE SAL_DLLPRIVATE
+
+#endif /* INCLUDED_SALHELPERDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/simplereferenceobject.hxx b/include/salhelper/simplereferenceobject.hxx
new file mode 100644
index 000000000000..12886e111128
--- /dev/null
+++ b/include/salhelper/simplereferenceobject.hxx
@@ -0,0 +1,131 @@
+/* -*- 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 _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
+#define _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
+
+#include "osl/interlck.h"
+#include "sal/types.h"
+#include "salhelperdllapi.h"
+
+#include <cstddef>
+#include <new>
+
+namespace salhelper {
+
+/** A simple base implementation for reference-counted objects.
+
+ Classes that want to implement a reference-counting mechanism based on the
+ acquire()/release() interface should derive from this class.
+
+ The reason to have class local operators new and delete here is technical.
+ Imagine a class D derived from SimpleReferenceObject, but implemented in
+ another shared library that happens to use different global operators new
+ and delete from those used in this shared library (which, sadly, seems to
+ be possible with shared libraries). Now, without the class local
+ operators new and delete here, a code sequence like "new D" would use the
+ global operator new as found in the other shared library, while the code
+ sequence "delete this" in release() would use the global operator delete
+ as found in this shared library---and these two operators would not be
+ guaranteed to match.
+
+ There are no overloaded operators new and delete for placement new here,
+ because it is felt that the concept of placement new does not work well
+ with the concept of reference-counted objects; so it seems best to simply
+ leave those operators out.
+
+ The same problem as with operators new and delete would also be there with
+ operators new[] and delete[]. But since arrays of reference-counted
+ objects are of no use, anyway, it seems best to simply declare and not
+ define (private) operators new[] and delete[].
+ */
+class SALHELPER_DLLPUBLIC SimpleReferenceObject
+{
+public:
+ inline SimpleReferenceObject() SAL_THROW(()): m_nCount(0) {}
+
+ /** @attention
+ The results are undefined if, for any individual instance of
+ SimpleReferenceObject, the total number of calls to acquire() exceeds
+ the total number of calls to release() by a platform dependent amount
+ (which, hopefully, is quite large).
+ */
+ inline void acquire() SAL_THROW(())
+ { osl_atomic_increment(&m_nCount); }
+
+ inline void release() SAL_THROW(())
+ { if (osl_atomic_decrement(&m_nCount) == 0) delete this; }
+
+ /** see general class documentation
+ */
+ static void * operator new(std::size_t nSize) SAL_THROW((std::bad_alloc));
+
+ /** see general class documentation
+ */
+ static void * operator new(std::size_t nSize,
+ std::nothrow_t const & rNothrow)
+ SAL_THROW(());
+
+ /** see general class documentation
+ */
+ static void operator delete(void * pPtr) SAL_THROW(());
+
+ /** see general class documentation
+ */
+ static void operator delete(void * pPtr, std::nothrow_t const & rNothrow)
+ SAL_THROW(());
+
+protected:
+ virtual ~SimpleReferenceObject() SAL_THROW(());
+
+private:
+ oslInterlockedCount m_nCount;
+
+ /** not implemented
+ */
+ SALHELPER_DLLPRIVATE SimpleReferenceObject(SimpleReferenceObject &);
+
+ /** not implemented
+ */
+ SALHELPER_DLLPRIVATE void operator =(SimpleReferenceObject);
+
+ /// @cond INTERNAL
+
+#ifdef _MSC_VER
+/* We can't now have these private with MSVC2008 at least, it leads to
+ compilation errors in xmloff and other places.
+*/
+protected:
+#endif
+ /** not implemented (see general class documentation)
+ */
+ static void * operator new[](std::size_t);
+
+ /** not implemented (see general class documentation)
+ */
+ static void operator delete[](void * pPtr);
+
+ /// @endcond
+};
+
+}
+
+#endif // _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/singletonref.hxx b/include/salhelper/singletonref.hxx
new file mode 100644
index 000000000000..a602e50cc4bf
--- /dev/null
+++ b/include/salhelper/singletonref.hxx
@@ -0,0 +1,197 @@
+/* -*- 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 _SALHELPER_SINGLETONREF_HXX_
+#define _SALHELPER_SINGLETONREF_HXX_
+
+#include <osl/mutex.hxx>
+#include "rtl/instance.hxx"
+#include "osl/diagnose.h"
+#include "osl/getglobalmutex.hxx"
+
+
+namespace salhelper{
+
+
+/** @short template for implementing singleton classes.
+
+ Such classes can be instanciated everytimes they
+ are needed. But the internal wrapped object will
+ be created one times only. Of course its used
+ resources are referenced one times only too.
+ This template hold it alive till the last
+ reference is gone. Further all operations
+ on this reference are threadsafe. Only
+ calls directly to the internal object (which modify
+ its state) must be made threadsafe by the object itself
+ or from outside.
+
+ @attention To prevent the code against race conditions, its not
+ allowed to start operations inside the ctor
+ of the internal wrapped object - especialy operations
+ which needs a reference to the same singleton too.
+
+ The only chance to supress such strange constellations
+ is a lazy-init mechanism.
+
+ <ul>
+ <li>a) The singleton class can provide a special init()
+ method, which must be called as first after creation.</li>
+ <li>b) The singleton class can call a special impl_init()
+ method implicit for every called interface method.</li>
+ </ul>
+
+ Note further that this singleton pattern can work only, if
+ all user of such singleton are located inside the same library!
+ Because static values cant be exported - e.g. from windows libraries.
+ */
+template< class SingletonClass >
+class SingletonRef
+{
+ //-------------------------------------------
+ // member
+
+ private :
+
+ /** @short pointer to the internal wrapped singleton. */
+ static SingletonClass* m_pInstance;
+
+ /** @short ref count, which regulate creation and removing of m_pInstance. */
+ static sal_Int32 m_nRef;
+
+ //-------------------------------------------
+ // interface
+
+ public :
+
+ //---------------------------------------
+
+ /** @short standard ctor.
+
+ The internal wrapped object is created only,
+ if its ref count was 0. Otherwhise this method
+ does nothing ... except increasing of the internal
+ ref count!
+ */
+ SingletonRef()
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+
+ // must be increased before(!) the check is done.
+ // Otherwhise this check can fail inside the same thread ...
+ ++m_nRef;
+ if (m_nRef == 1)
+ m_pInstance = new SingletonClass();
+
+ OSL_ENSURE(m_nRef>0 && m_pInstance, "Race? Ref count of singleton >0, but instance is NULL!");
+ // <- GLOBAL SAFE
+ }
+
+ //---------------------------------------
+
+ /** @short standard dtor.
+
+ The internal wrapped object is removed only,
+ if its ref count wil be 0. Otherwhise this method
+ does nothing ... except decreasing of the internal
+ ref count!
+ */
+ ~SingletonRef()
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+
+ // must be decreased before(!) the check is done.
+ // Otherwhise this check can fail inside the same thread ...
+ --m_nRef;
+ if (m_nRef == 0)
+ {
+ delete m_pInstance;
+ m_pInstance = 0;
+ }
+ // <- GLOBAL SAFE
+ }
+
+ //---------------------------------------
+
+ /** @short Allows rSingle->someBodyOp().
+ */
+ SingletonClass* operator->() const
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+ return m_pInstance;
+ // <- GLOBAL SAFE
+ }
+
+ //---------------------------------------
+
+ /** @short Allows (*rSingle).someBodyOp().
+ */
+ SingletonClass& operator*() const
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+ return *m_pInstance;
+ // <- GLOBAL SAFE
+ }
+
+ //-------------------------------------------
+ // helper
+
+ private :
+
+ //---------------------------------------
+
+ /** @short creates an own mutex for guarding static contents.
+
+ The global mutex the osl library is used one times
+ only to create an own static mutex, which can be used
+ next time to guard own static member operations.
+ */
+ struct SingletonLockInit
+ {
+ ::osl::Mutex* operator()()
+ {
+ static ::osl::Mutex aInstance;
+ return &aInstance;
+ }
+ };
+
+ ::osl::Mutex& ownStaticLock() const
+ {
+ return *rtl_Instance< ::osl::Mutex,
+ SingletonLockInit,
+ ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(SingletonLockInit(), ::osl::GetGlobalMutex());
+ }
+};
+
+template< class SingletonClass >
+SingletonClass* SingletonRef< SingletonClass >::m_pInstance = 0;
+
+template< class SingletonClass >
+sal_Int32 SingletonRef< SingletonClass >::m_nRef = 0;
+
+} // namespace salhelper
+
+#endif // _SALHELPER_SINGLETONREF_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/thread.hxx b/include/salhelper/thread.hxx
new file mode 100644
index 000000000000..b160b2d1eb6a
--- /dev/null
+++ b/include/salhelper/thread.hxx
@@ -0,0 +1,93 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SALHELPER_THREAD_HXX
+#define INCLUDED_SALHELPER_THREAD_HXX
+
+#include "sal/config.h"
+
+#include <cstddef>
+
+#include "osl/thread.hxx"
+#include "sal/types.h"
+#include "salhelper/salhelperdllapi.h"
+#include "salhelper/simplereferenceobject.hxx"
+
+namespace salhelper {
+
+/**
+ A safe encapsulation of ::osl::Thread.
+
+ @since LibreOffice 3.6
+*/
+class SALHELPER_DLLPUBLIC Thread:
+ public salhelper::SimpleReferenceObject, private osl::Thread
+{
+public:
+ /**
+ @param name the thread name, see ::osl_setThreadName; must be a non-null
+ null terminated string
+ */
+ Thread(char const * name);
+
+ /**
+ Launch the thread.
+
+ This function must be called at most once.
+
+ Each call of this function should eventually be followed by a call to
+ ::osl::Thread::join before exit(3), to ensure the thread is no longer
+ relying on any infrastructure while that infrastructure is being shut
+ down in atexit handlers.
+ */
+ void launch();
+
+ using osl::Thread::getIdentifier;
+ using osl::Thread::join;
+ using osl::Thread::schedule;
+ using osl::Thread::terminate;
+
+ // While the below static member functions should arguably always be called
+ // with qualified (osl::Thread) names, compilers would still complain that
+ // they are inaccessible from within derivations of salhelper::Thread (an
+ // alternative would be to force such derivations to use global names,
+ // prefixed with ::osl::Thread):
+ using osl::Thread::getCurrentIdentifier;
+ using osl::Thread::wait;
+ using osl::Thread::yield;
+
+ static inline void * operator new(std::size_t size)
+ { return SimpleReferenceObject::operator new(size); }
+
+ static inline void operator delete(void * pointer)
+ { SimpleReferenceObject::operator delete(pointer); }
+
+protected:
+ virtual ~Thread();
+
+ /**
+ The main function executed by the thread.
+
+ Any uncaught exceptions lead to std::terminate.
+ */
+ virtual void execute() = 0;
+
+private:
+ virtual void SAL_CALL run();
+
+ virtual void SAL_CALL onTerminated();
+
+ char const * name_;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/salhelper/timer.hxx b/include/salhelper/timer.hxx
new file mode 100644
index 000000000000..0afd593b8c2b
--- /dev/null
+++ b/include/salhelper/timer.hxx
@@ -0,0 +1,230 @@
+/* -*- 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 _SALHELPER_TIMER_HXX_
+#define _SALHELPER_TIMER_HXX_
+
+#include <salhelper/simplereferenceobject.hxx>
+#include <osl/time.h>
+#include "salhelperdllapi.h"
+
+namespace salhelper
+{
+
+/** Helper class for easier manipulation with TimeValue.
+ *
+ * Times are seconds in UTC since 01.01.1970
+ */
+struct TTimeValue : public TimeValue
+{
+ TTimeValue()
+ {
+ Seconds = 0;
+ Nanosec = 0;
+ }
+
+ TTimeValue( sal_uInt32 Secs, sal_uInt32 Nano )
+ {
+ Seconds = Secs;
+ Nanosec = Nano;
+
+ normalize();
+ }
+
+ TTimeValue(sal_uInt32 MilliSecs)
+ {
+ Seconds = MilliSecs / 1000L;
+ Nanosec = (MilliSecs % 1000) * 1000000L;
+
+ normalize();
+ }
+
+ TTimeValue( const TTimeValue& rTimeValue )
+ {
+ Seconds = rTimeValue.Seconds;
+ Nanosec = rTimeValue.Nanosec;
+
+ normalize();
+ }
+
+ TTimeValue( const TimeValue& rTimeValue )
+ {
+ Seconds = rTimeValue.Seconds;
+ Nanosec = rTimeValue.Nanosec;
+
+ normalize();
+ }
+
+ void SAL_CALL normalize()
+ {
+ if ( Nanosec > 1000000000 )
+ {
+ Seconds += Nanosec / 1000000000;
+ Nanosec %= 1000000000;
+ }
+ }
+
+ void SAL_CALL addTime( const TTimeValue& Delta )
+ {
+ Seconds += Delta.Seconds;
+ Nanosec += Delta.Nanosec;
+
+ normalize();
+ }
+
+ sal_Bool SAL_CALL isEmpty() const
+ {
+ return ( ( Seconds == 0 ) && ( Nanosec == 0 ) );
+ }
+};
+
+inline sal_Bool operator<( const TTimeValue& rTimeA, const TTimeValue& rTimeB )
+{
+ if ( rTimeA.Seconds < rTimeB.Seconds )
+ return sal_True;
+ else if ( rTimeA.Seconds > rTimeB.Seconds )
+ return sal_False;
+ else
+ return ( rTimeA.Nanosec < rTimeB.Nanosec );
+}
+
+inline sal_Bool operator>( const TTimeValue& rTimeA, const TTimeValue& rTimeB )
+{
+ if ( rTimeA.Seconds > rTimeB.Seconds )
+ return sal_True;
+ else if ( rTimeA.Seconds < rTimeB.Seconds )
+ return sal_False;
+ else
+ return ( rTimeA.Nanosec > rTimeB.Nanosec );
+}
+
+inline sal_Bool operator==( const TTimeValue& rTimeA, const TTimeValue& rTimeB )
+{
+ return ( ( rTimeA.Seconds == rTimeB.Seconds ) &&
+ ( rTimeA.Nanosec == rTimeB.Nanosec ) );
+}
+
+class TimerManager;
+
+/** Interface for the Timer and handling the event
+*/
+class SALHELPER_DLLPUBLIC Timer : public salhelper::SimpleReferenceObject
+{
+public:
+
+ /** Constructor.
+ */
+ Timer();
+
+ /** Constructor.
+ */
+ Timer( const TTimeValue& Time );
+
+ /** Constructor.
+ */
+ Timer( const TTimeValue& Time, const TTimeValue& RepeatTime );
+
+ /** Start timer.
+ */
+ void SAL_CALL start();
+
+ /** Abort timer prematurely.
+ */
+ void SAL_CALL stop();
+
+ /** Returns sal_True if timer is running.
+ */
+ sal_Bool SAL_CALL isTicking() const;
+
+ /** Is the timer expired?
+ */
+ sal_Bool SAL_CALL isExpired() const;
+
+ /** Does pTimer expires before us?
+ */
+ sal_Bool SAL_CALL expiresBefore( const Timer* pTimer ) const;
+
+ /** Set the absolute time when the timer should fire.
+ */
+ void SAL_CALL setAbsoluteTime( const TTimeValue& Time );
+
+ /** Set the time to fire to 'now' + Remaining.
+ */
+ void SAL_CALL setRemainingTime( const TTimeValue& Remaining );
+
+ /** Set the time to fire to 'now' + Remaining with repeat interveal
+ * Repeat.
+ */
+ void SAL_CALL setRemainingTime( const TTimeValue& Remaining, const TTimeValue& Repeat );
+
+ /** Adds Time to the 'fire time'.
+ */
+ void SAL_CALL addTime( const TTimeValue& Time );
+
+ /** Returns the remaining time before timer expiration relative to now.
+ */
+ TTimeValue SAL_CALL getRemainingTime() const;
+
+protected:
+
+ /** Destructor.
+ */
+ virtual ~Timer();
+
+ /** What should be done when the 'timer fires'.
+ */
+ virtual void SAL_CALL onShot() = 0;
+
+protected:
+
+ /** holds (initial) exparation time of this timer.
+ */
+ TTimeValue m_aTimeOut;
+
+ /** holds the time of exparation of this timer.
+ */
+ TTimeValue m_aExpired;
+
+ /** holds the time interveal of successive expirations.
+ */
+ TTimeValue m_aRepeatDelta;
+
+ /** Pointer to the next timer (to fire).
+ */
+ Timer* m_pNext;
+
+private:
+
+ /** Copy constructor disabled.
+ */
+ SALHELPER_DLLPRIVATE Timer( const Timer& rTimer );
+
+ /** Assignment operator disabled.
+ */
+ SALHELPER_DLLPRIVATE void SAL_CALL operator=( const Timer& rTimer );
+
+ friend class TimerManager;
+};
+
+}
+
+#endif //_SALHELPER_TIMER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/systools/win32/snprintf.h b/include/systools/win32/snprintf.h
new file mode 100644
index 000000000000..e5e60eaa9ada
--- /dev/null
+++ b/include/systools/win32/snprintf.h
@@ -0,0 +1,88 @@
+/* -*- 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 _SNPRINTF_H
+#define _SNPRINTF_H
+
+#if !defined(_WIN32)
+#error ERROR: Only Win32 target supported!
+#endif
+
+/* Macros for Unicode/ANSI support like in TCHAR.H */
+
+#ifdef _UNICODE
+#define sntprintf snwprintf
+#define vsntprintf vsnwprintf
+#else
+#define sntprintf snprintf
+#define vsntprintf vsnprintf
+#endif
+
+/* Define needed types if they are not yet defined */
+
+
+# ifndef _VA_LIST_DEFINED
+ typedef char * va_list;
+# define _VA_LIST_DEFINED
+# endif
+
+
+# ifndef _WCHAR_T_DEFINED
+ typedef unsigned short wchar_t;
+# define _WCHAR_T_DEFINED
+# endif
+
+
+#ifndef _SNPRINTF_DLLIMPORT
+#define _SNPRINTF_DLLIMPORT __declspec( dllimport )
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Implementations of snprintf following the ISO/IEC 9899:1999 (ISO C99)
+ standard.
+ The difference compared to _snprintf is that the buffer always is zero
+ terminated (unless count is zero) and the return value is the number of
+ characters (not including terminating zero) that would have been written
+ even if the buffer wasn't large
+ enough to hold the string. */
+
+
+#if !defined(__MINGW32__) || defined (__NO_ISOCEXT)
+
+/* UNICODE version */
+_SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
+
+/* SBCS and MBCS version */
+_SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
+
+#endif
+
+/* Conflict with STL_port inline implementation */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNPRINTF_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/typelib/typeclass.h b/include/typelib/typeclass.h
new file mode 100644
index 000000000000..b3eeb5ddff52
--- /dev/null
+++ b/include/typelib/typeclass.h
@@ -0,0 +1,98 @@
+/* -*- 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 _TYPELIB_TYPECLASS_H_
+#define _TYPELIB_TYPECLASS_H_
+
+#include <sal/types.h>
+
+/** This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
+*/
+typedef enum _typelib_TypeClass
+{
+ /** type class of void */
+ typelib_TypeClass_VOID = 0,
+ /** type class of char */
+ typelib_TypeClass_CHAR = 1,
+ /** type class of boolean */
+ typelib_TypeClass_BOOLEAN = 2,
+ /** type class of byte */
+ typelib_TypeClass_BYTE = 3,
+ /** type class of short */
+ typelib_TypeClass_SHORT = 4,
+ /** type class of unsigned short */
+ typelib_TypeClass_UNSIGNED_SHORT = 5,
+ /** type class of long */
+ typelib_TypeClass_LONG = 6,
+ /** type class of unsigned long */
+ typelib_TypeClass_UNSIGNED_LONG = 7,
+ /** type class of hyper */
+ typelib_TypeClass_HYPER = 8,
+ /** type class of unsigned hyper */
+ typelib_TypeClass_UNSIGNED_HYPER = 9,
+ /** type class of float */
+ typelib_TypeClass_FLOAT = 10,
+ /** type class of double */
+ typelib_TypeClass_DOUBLE = 11,
+ /** type class of string */
+ typelib_TypeClass_STRING = 12,
+ /** type class of type */
+ typelib_TypeClass_TYPE = 13,
+ /** type class of any */
+ typelib_TypeClass_ANY = 14,
+ /** type class of enum */
+ typelib_TypeClass_ENUM = 15,
+ /** type class of typedef */
+ typelib_TypeClass_TYPEDEF = 16,
+ /** type class of struct */
+ typelib_TypeClass_STRUCT = 17,
+ /** type class of union (not implemented) */
+ typelib_TypeClass_UNION = 18,
+ /** type class of exception */
+ typelib_TypeClass_EXCEPTION = 19,
+ /** type class of sequence */
+ typelib_TypeClass_SEQUENCE = 20,
+ /** type class of array (not implemented) */
+ typelib_TypeClass_ARRAY = 21,
+ /** type class of interface */
+ typelib_TypeClass_INTERFACE = 22,
+ /** type class of service (not implemented) */
+ typelib_TypeClass_SERVICE = 23,
+ /** type class of module (not implemented) */
+ typelib_TypeClass_MODULE = 24,
+ /** type class of interface method */
+ typelib_TypeClass_INTERFACE_METHOD = 25,
+ /** type class of interface attribute */
+ typelib_TypeClass_INTERFACE_ATTRIBUTE = 26,
+ /** type class of unknown type */
+ typelib_TypeClass_UNKNOWN = 27,
+ /** type class of properties */
+ typelib_TypeClass_PROPERTY = 28,
+ /** type class of constants */
+ typelib_TypeClass_CONSTANT = 29,
+ /** type class of constants groups */
+ typelib_TypeClass_CONSTANTS = 30,
+ /** type class of singletons */
+ typelib_TypeClass_SINGLETON = 31,
+ /** fixing enum size */
+ typelib_TypeClass_MAKE_FIXED_SIZE = SAL_MAX_ENUM
+} typelib_TypeClass;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/typelib/typedescription.h b/include/typelib/typedescription.h
new file mode 100644
index 000000000000..89d718f58433
--- /dev/null
+++ b/include/typelib/typedescription.h
@@ -0,0 +1,1148 @@
+/* -*- 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 _TYPELIB_TYPEDESCRIPTION_H_
+#define _TYPELIB_TYPEDESCRIPTION_H_
+
+#include <cppu/cppudllapi.h>
+#include <typelib/uik.h>
+#include <typelib/typeclass.h>
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _typelib_TypeDescription;
+
+#if defined( SAL_W32)
+#pragma pack(push, 8)
+#endif
+
+/** Holds a weak reference to a type description.
+*/
+typedef struct _typelib_TypeDescriptionReference
+{
+ /** reference count of type; don't ever modify this by yourself, use
+ typelib_typedescriptionreference_acquire() and typelib_typedescriptionreference_release()
+ */
+ sal_Int32 nRefCount;
+ /** number of static references of type, because of the fact that some types are needed
+ until program termination and are commonly held static.
+ */
+ sal_Int32 nStaticRefCount;
+ /** type class of type
+ */
+ typelib_TypeClass eTypeClass;
+ /** fully qualified name of type
+ */
+ rtl_uString * pTypeName;
+ /** pointer to full typedescription; this value is only valid if the type is never swapped out
+ */
+ struct _typelib_TypeDescription * pType;
+ /** pointer to optimize the runtime; not for public use
+ */
+ void * pUniqueIdentifier;
+ /** reserved for future use; 0 if not used
+ */
+ void * pReserved;
+} typelib_TypeDescriptionReference;
+
+/** Full type description of a type. Memory layout of this struct is identical to the
+ typelib_TypeDescriptionReference for the first six members.
+ So a typedescription can be used as type reference.
+*/
+typedef struct _typelib_TypeDescription
+{
+ /** reference count; don't ever modify this by yourself, use
+ typelib_typedescription_acquire() and typelib_typedescription_release()
+ */
+ sal_Int32 nRefCount;
+ /** number of static references of type, because of the fact that some types are needed
+ until program termination and are commonly held static.
+ */
+ sal_Int32 nStaticRefCount;
+ /** type class of type
+ */
+ typelib_TypeClass eTypeClass;
+ /** fully qualified name of type
+ */
+ rtl_uString * pTypeName;
+ /** pointer to self to distinguish reference from description; for internal use only
+ */
+ struct _typelib_TypeDescription * pSelf;
+ /** pointer to optimize the runtime; not for public use
+ */
+ void * pUniqueIdentifier;
+ /** reserved for future use; 0 if not used
+ */
+ void * pReserved;
+
+ /** flag to determine whether the description is complete:
+ compound and union types lack of member names, enums lack of member types and names,
+ interfaces lack of members and table init.
+ Call typelib_typedescription_complete() if false.
+ */
+ sal_Bool bComplete;
+ /** size of type
+ */
+ sal_Int32 nSize;
+ /** alignment of type
+ */
+ sal_Int32 nAlignment;
+ /** pointer to weak reference
+ */
+ typelib_TypeDescriptionReference * pWeakRef;
+ /** determines, if type can be unloaded (and it is possible to reloaded it)
+ */
+ sal_Bool bOnDemand;
+} typelib_TypeDescription;
+
+/** Type description for exception types.
+*/
+typedef struct _typelib_CompoundTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription
+ */
+ typelib_TypeDescription aBase;
+
+ /** pointer to base type description, else 0
+ */
+ struct _typelib_CompoundTypeDescription * pBaseTypeDescription;
+
+ /** number of members
+ */
+ sal_Int32 nMembers;
+ /** byte offsets of each member including the size the base type
+ */
+ sal_Int32 * pMemberOffsets;
+ /** members of the struct or exception
+ */
+ typelib_TypeDescriptionReference ** ppTypeRefs;
+ /** member names of the struct or exception
+ */
+ rtl_uString ** ppMemberNames;
+} typelib_CompoundTypeDescription;
+
+/**
+ Type description for struct types.
+
+ This is only used to represent plain struct types and instantiated
+ polymorphic struct types; there is no representation of polymorphic struct
+ type templates at this level.
+
+ @since UDK 3.2.0
+ */
+typedef struct _typelib_StructTypeDescription
+{
+ /**
+ Derived from typelib_CompoundTypeDescription.
+ */
+ typelib_CompoundTypeDescription aBase;
+
+ /**
+ Flags for direct members, specifying whether they are of parameterized
+ type (true) or explict type (false).
+
+ For a plain struct type, this is a null pointer.
+ */
+ sal_Bool * pParameterizedTypes;
+} typelib_StructTypeDescription;
+
+/** Type description of a union. The type class of this description is typelib_TypeClass_UNION.
+*/
+typedef struct _typelib_UnionTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription
+ */
+ typelib_TypeDescription aBase;
+
+ /** type of the discriminant
+ */
+ typelib_TypeDescriptionReference * pDiscriminantTypeRef;
+
+ /** union default descriminant
+ */
+ sal_Int64 nDefaultDiscriminant;
+ /** union default member type (may be 0)
+ */
+ typelib_TypeDescriptionReference * pDefaultTypeRef;
+ /** number of union member types
+ */
+ sal_Int32 nMembers;
+ /** union member discriminant values (same order as idl declaration)
+ */
+ sal_Int64 * pDiscriminants;
+ /** union member value types (same order as idl declaration)
+ */
+ typelib_TypeDescriptionReference ** ppTypeRefs;
+ /** union member value names (same order as idl declaration)
+ */
+ rtl_uString ** ppMemberNames;
+ /** union value offset for data access
+ */
+ sal_Int32 nValueOffset;
+} typelib_UnionTypeDescription;
+
+/** Type description of an array or sequence.
+*/
+typedef struct _typelib_IndirectTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription
+ */
+ typelib_TypeDescription aBase;
+
+ /** array, sequence: pointer to element type
+ */
+ typelib_TypeDescriptionReference * pType;
+} typelib_IndirectTypeDescription;
+
+/** Type description of an array.
+*/
+typedef struct _typelib_ArrayTypeDescription
+{
+ /** inherits all members of typelib_IndirectTypeDescription
+ */
+ typelib_IndirectTypeDescription aBase;
+
+ /** number of dimensions
+ */
+ sal_Int32 nDimensions;
+ /** number of total array elements
+ */
+ sal_Int32 nTotalElements;
+ /** array of dimensions
+ */
+ sal_Int32 * pDimensions;
+} typelib_ArrayTypeDescription;
+
+/** Type description of an enum. The type class of this description is typelib_TypeClass_ENUM.
+*/
+typedef struct _typelib_EnumTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription
+ */
+ typelib_TypeDescription aBase;
+
+ /** first value of the enum
+ */
+ sal_Int32 nDefaultEnumValue;
+ /** number of enum values
+ */
+ sal_Int32 nEnumValues;
+ /** names of enum values
+ */
+ rtl_uString ** ppEnumNames;
+ /** values of enum (corresponding to names in similar order)
+ */
+ sal_Int32 * pEnumValues;
+} typelib_EnumTypeDescription;
+
+/** Description of an interface method parameter.
+*/
+typedef struct _typelib_MethodParameter
+{
+ /** name of parameter
+ */
+ rtl_uString * pName;
+ /** type of parameter
+ */
+ typelib_TypeDescriptionReference * pTypeRef;
+ /** true: the call type of this parameter is [in] or [inout]
+ false: the call type of this parameter is [out]
+ */
+ sal_Bool bIn;
+ /** true: the call type of this parameter is [out] or [inout]
+ false: the call type of this parameter is [in]
+ */
+ sal_Bool bOut;
+} typelib_MethodParameter;
+
+/** Common base type description of typelib_InterfaceMethodTypeDescription and
+ typelib_InterfaceAttributeTypeDescription.
+*/
+typedef struct _typelib_InterfaceMemberTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription
+ */
+ typelib_TypeDescription aBase;
+
+ /** position of member in the interface including the number of members of
+ any base interfaces
+ */
+ sal_Int32 nPosition;
+ /** name of member
+ */
+ rtl_uString * pMemberName;
+} typelib_InterfaceMemberTypeDescription;
+
+/** Type description of an interface method. The type class of this description is
+ typelib_TypeClass_INTERFACE_METHOD. The size and the alignment are 0.
+*/
+typedef struct _typelib_InterfaceMethodTypeDescription
+{
+ /** inherits all members of typelib_InterfaceMemberTypeDescription
+ */
+ typelib_InterfaceMemberTypeDescription aBase;
+
+ /** type of the return value
+ */
+ typelib_TypeDescriptionReference * pReturnTypeRef;
+ /** number of parameters
+ */
+ sal_Int32 nParams;
+ /** array of parameters
+ */
+ typelib_MethodParameter * pParams;
+ /** number of exceptions
+ */
+ sal_Int32 nExceptions;
+ /** array of exception types
+ */
+ typelib_TypeDescriptionReference ** ppExceptions;
+ /** determines whether method is declared oneway
+ */
+ sal_Bool bOneWay;
+
+ /** the interface description this method is a member of
+ */
+ struct _typelib_InterfaceTypeDescription * pInterface;
+ /** the inherited direct base method (null for a method that is not
+ inherited)
+
+ @since UDK 3.2.0
+ */
+ typelib_TypeDescriptionReference * pBaseRef;
+ /** if pBaseRef is null, the member position of this method within
+ pInterface, not counting members inherited from bases; if pBaseRef is
+ not null, the index of the direct base within pInterface from which this
+ method is inherited
+
+ @since UDK 3.2.0
+ */
+ sal_Int32 nIndex;
+} typelib_InterfaceMethodTypeDescription;
+
+/** The description of an interface attribute. The type class of this description is
+ typelib_TypeClass_INTERFACE_ATTRIBUTE. The size and the alignment are 0.
+*/
+typedef struct _typelib_InterfaceAttributeTypeDescription
+{
+ /** inherits all members of typelib_InterfaceMemberTypeDescription
+ */
+ typelib_InterfaceMemberTypeDescription aBase;
+
+ /** determines whether attribute is read only
+ */
+ sal_Bool bReadOnly;
+ /** type of the attribute
+ */
+ typelib_TypeDescriptionReference * pAttributeTypeRef;
+
+ /** the interface description this attribute is a member of
+ */
+ struct _typelib_InterfaceTypeDescription * pInterface;
+ /** the inherited direct base attribute (null for an attribute that is not
+ inherited)
+
+ @since UDK 3.2.0
+ */
+ typelib_TypeDescriptionReference * pBaseRef;
+ /** if pBaseRef is null, the member position of this attribute within
+ pInterface, not counting members inherited from bases; if pBaseRef is
+ not null, the index of the direct base within pInterface from which this
+ attribute is inherited
+
+ @since UDK 3.2.0
+ */
+ sal_Int32 nIndex;
+ /** number of getter exceptions
+
+ @since UDK 3.2.0
+ */
+ sal_Int32 nGetExceptions;
+ /** array of getter exception types
+
+ @since UDK 3.2.0
+ */
+ typelib_TypeDescriptionReference ** ppGetExceptions;
+ /** number of setter exceptions
+
+ @since UDK 3.2.0
+ */
+ sal_Int32 nSetExceptions;
+ /** array of setter exception types
+
+ @since UDK 3.2.0
+ */
+ typelib_TypeDescriptionReference ** ppSetExceptions;
+} typelib_InterfaceAttributeTypeDescription;
+
+/** Type description of an interface.
+
+ <p>Not all members are always initialized (not yet initialized members being
+ null); there are three levels:</p>
+ <ul>
+ <li>Minimally, only <code>aBase</code>,
+ <code>pBaseTypeDescription</code>, <code>aUik</code>,
+ <code>nBaseTypes</code>, and <code>ppBaseTypes</code> are initialized;
+ <code>aBase.bComplete</code> is false. This only happens when an
+ interface type description is created with
+ <code>typelib_static_mi_interface_type_init</code> or
+ <code>typelib_static_interface_type_init</code>.</li>
+
+ <li>At the next level, <code>nMembers</code>, <code>ppMembers</code>,
+ <code>nAllMembers</code>, <code>ppAllMembers</code> are also
+ initialized; <code>aBase.bComplete</code> is still false. This happens
+ when an interface type description is created with
+ <code>typelib_typedescription_newMIInterface</code> or
+ <code>typelib_typedescription_newInterface</code>.</li>
+
+ <li>At the final level, <code>pMapMemberIndexToFunctionIndex</code>,
+ <code>nMapFunctionIndexToMemberIndex</code>, and
+ <code>pMapFunctionIndexToMemberIndex</code> are also initialized;
+ <code>aBase.bComplete</code> is true. This happens after a call to
+ <code>typelib_typedescription_complete</code>.</li>
+ </ul>
+*/
+typedef struct _typelib_InterfaceTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription
+ */
+ typelib_TypeDescription aBase;
+
+ /** pointer to base type description, else 0
+
+ @deprecated
+ use nBaseTypes and ppBaseTypes instead
+ */
+ struct _typelib_InterfaceTypeDescription * pBaseTypeDescription;
+ /** unique identifier of interface
+ */
+ typelib_Uik aUik;
+ /** number of members
+ */
+ sal_Int32 nMembers;
+ /** array of members; references attributes or methods
+ */
+ typelib_TypeDescriptionReference ** ppMembers;
+ /** number of members including members of base interface
+ */
+ sal_Int32 nAllMembers;
+ /** array of members including members of base interface; references attributes or methods
+ */
+ typelib_TypeDescriptionReference ** ppAllMembers;
+ /** array mapping index of the member description to an index doubling for read-write
+ attributes (called function index); size of array is nAllMembers
+ */
+ sal_Int32 * pMapMemberIndexToFunctionIndex;
+ /** number of members plus number of read-write attributes
+ */
+ sal_Int32 nMapFunctionIndexToMemberIndex;
+ /** array mapping function index to member index; size of arry is nMapFunctionIndexToMemberIndex
+ */
+ sal_Int32 * pMapFunctionIndexToMemberIndex;
+ /** number of base types
+
+ @since UDK 3.2.0
+ */
+ sal_Int32 nBaseTypes;
+ /** array of base type descriptions
+
+ @since UDK 3.2.0
+ */
+ struct _typelib_InterfaceTypeDescription ** ppBaseTypes;
+} typelib_InterfaceTypeDescription;
+
+/** Init struct of compound members for typelib_typedescription_new().
+*/
+typedef struct _typelib_CompoundMember_Init
+{
+ /** type class of compound member
+ */
+ typelib_TypeClass eTypeClass;
+ /** name of type of compound member
+
+ For a member of an instantiated polymorphic struct type that is of
+ parameterized type, this will be a null pointer.
+ */
+ rtl_uString * pTypeName;
+ /** name of compound member
+ */
+ rtl_uString * pMemberName;
+} typelib_CompoundMember_Init;
+
+/**
+ Init struct of members for typelib_typedescription_newStruct().
+
+ @since UDK 3.2.0
+ */
+typedef struct _typelib_StructMember_Init
+{
+ /**
+ Derived from typelib_CompoundMember_Init;
+ */
+ typelib_CompoundMember_Init aBase;
+
+ /**
+ Flag specifying whether the member is of parameterized type (true) or
+ explict type (false).
+ */
+ sal_Bool bParameterizedType;
+} typelib_StructMember_Init;
+
+/** Init struct of interface methods for typelib_typedescription_new().
+*/
+typedef struct _typelib_Parameter_Init
+{
+ /** type class of parameter
+ */
+ typelib_TypeClass eTypeClass;
+ /** name of parameter
+ */
+ rtl_uString * pTypeName;
+ /** name of parameter
+ */
+ rtl_uString * pParamName;
+ /** true, if parameter is [in] or [inout]
+ */
+ sal_Bool bIn;
+ /** true, if parameter is [out] or [inout]
+ */
+ sal_Bool bOut;
+} typelib_Parameter_Init;
+
+/** Init struct of union types for typelib_typedescription_newUnion().
+*/
+typedef struct _typelib_Union_Init
+{
+ /** union member discriminant
+ */
+ sal_Int64 nDiscriminant;
+ /** union member name
+ */
+ rtl_uString * pMemberName;
+ /** union member type
+ */
+ typelib_TypeDescriptionReference* pTypeRef;
+} typelib_Union_Init;
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+
+/** Creates a union type description. All discriminants are handled as int64 values.
+ The pDiscriminantTypeRef must be of type byte, short, ..., up to hyper.
+
+ @param ppRet inout union type description
+ @param pTypeName name of union type
+ @param pDiscriminantTypeRef discriminant type
+ @param nDefaultDiscriminant default discriminant
+ @param pDefaultTypeRef default value type of union
+ @param nMembers number of union members
+ @param pMembers init members
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newUnion(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pDiscriminantTypeRef,
+ sal_Int64 nDefaultDiscriminant,
+ typelib_TypeDescriptionReference * pDefaultTypeRef,
+ sal_Int32 nMembers,
+ typelib_Union_Init * pMembers )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an enum type description.
+
+ @param ppRet inout enum type description
+ @param pTypeName name of enum
+ @param nDefaultValue default enum value
+ @param nEnumValues number of enum values
+ @param ppEnumNames names of enum values
+ @param pEnumValues enum values
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newEnum(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_Int32 nDefaultValue,
+ sal_Int32 nEnumValues,
+ rtl_uString ** ppEnumNames,
+ sal_Int32 * pEnumValues )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an array type description.
+
+ @param ppRet inout enum type description
+ @param pElementTypeRef element type
+ @param nDimensions number of dimensions
+ @param pDimensions dimensions
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newArray(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeDescriptionReference * pElementTypeRef,
+ sal_Int32 nDimensions,
+ sal_Int32 * pDimensions )
+ SAL_THROW_EXTERN_C ();
+
+/** Creates a new type description.
+
+ Since this function can only be used to create type descriptions for plain
+ struct types, not for instantiated polymorphic struct types, the function
+ typelib_typedescription_newStruct should be used instead for all struct
+ types.
+
+ @param ppRet inout type description
+ @param eTypeClass type class
+ @param pTypeName name of type
+ @param pType sequence, array: element type;
+ struct, Exception: base type;
+ @param nMembers number of members if struct, exception
+ @param pMembers array of members if struct, exception
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_new(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pType,
+ sal_Int32 nMembers,
+ typelib_CompoundMember_Init * pMembers )
+ SAL_THROW_EXTERN_C();
+
+/** Creates a new struct type description.
+
+ @param ppRet inout type description
+ @param pTypeName name of type
+ @param pType base type;
+ @param nMembers number of members
+ @param pMembers array of members
+
+ @since UDK 3.2.0
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newStruct(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pType,
+ sal_Int32 nMembers,
+ typelib_StructMember_Init * pMembers )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an interface type description.
+
+ @param ppRet inout interface type description
+ @param pTypeName the fully qualified name of the interface.
+ @param nUik1 uik part
+ @param nUik2 uik part
+ @param nUik3 uik part
+ @param nUik4 uik part
+ @param nUik5 uik part
+ @param pBaseInterface base interface type, else 0
+ @param nMembers number of members
+ @param ppMembers members; attributes or methods
+
+ @deprecated
+ use typelib_typedescription_newMIInterface instead
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterface(
+ typelib_InterfaceTypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5,
+ typelib_TypeDescriptionReference * pBaseInterface,
+ sal_Int32 nMembers,
+ typelib_TypeDescriptionReference ** ppMembers )
+ SAL_THROW_EXTERN_C();
+
+/** Creates a multiple-inheritance interface type description.
+
+ @param ppRet inout interface type description
+ @param pTypeName the fully qualified name of the interface.
+ @param nUik1 uik part
+ @param nUik2 uik part
+ @param nUik3 uik part
+ @param nUik4 uik part
+ @param nUik5 uik part
+ @param nBaseInterfaces number of base interface types
+ @param ppBaseInterfaces base interface types
+ @param nMembers number of members
+ @param ppMembers members; attributes or methods
+
+ @since UDK 3.2.0
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newMIInterface(
+ typelib_InterfaceTypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5,
+ sal_Int32 nBaseInterfaces,
+ typelib_TypeDescriptionReference ** ppBaseInterfaces,
+ sal_Int32 nMembers,
+ typelib_TypeDescriptionReference ** ppMembers )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an interface method type description.
+
+ @param ppRet inout method type description
+ @param nAbsolutePosition position of member including all members of base interfaces
+ @param bOneWay determines whether method is declared oneway
+ @param pMethodName fully qualified name of method including interface name
+ @param eReturnTypeClass type class of return type
+ @param pReturnTypeName type name of the return type
+ @param nParams number of parameters
+ @param pParams parameter types
+ @param nExceptions number of exceptions
+ @param ppExceptionNames type names of exceptions
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterfaceMethod(
+ typelib_InterfaceMethodTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ sal_Bool bOneWay,
+ rtl_uString * pMethodName,
+ typelib_TypeClass eReturnTypeClass,
+ rtl_uString * pReturnTypeName,
+ sal_Int32 nParams,
+ typelib_Parameter_Init * pParams,
+ sal_Int32 nExceptions,
+ rtl_uString ** ppExceptionNames )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an interface attribute type description.
+
+ @param ppRet inout attribute type description
+ @param nAbsolutePosition position of this attribute including all members of base interfaces
+ @param pAttributeName fully qualified name of attribute including interface
+ name
+ @param eAttributeTypeClass type class of attribute type
+ @param pAttributeTypeName type name of attribute type
+ @param bReadOnly determines whether attribute is read-only
+
+ @deprecated
+ use typelib_typedescription_newExtendedInterfaceAttribute instead
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterfaceAttribute(
+ typelib_InterfaceAttributeTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ rtl_uString * pAttributeName,
+ typelib_TypeClass eAttributeTypeClass,
+ rtl_uString * pAttributeTypeName,
+ sal_Bool bReadOnly )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an extended interface attribute type description.
+
+ @param ppRet inout attribute type description
+ @param nAbsolutePosition position of this attribute including all members of
+ base interfaces
+ @param pAttributeName fully qualified name of attribute including interface
+ name
+ @param eAttributeTypeClass type class of attribute type
+ @param pAttributeTypeName type name of attribute type
+ @param bReadOnly determines whether attribute is read-only
+ @param nGetExceptions number of getter exceptions
+ @param ppGetExceptionNames type names of getter exceptions
+ @param nSetExceptions number of setter exceptions
+ @param ppSetExceptionNames type names of setter exceptions
+
+ @since UDK 3.2.0
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newExtendedInterfaceAttribute(
+ typelib_InterfaceAttributeTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ rtl_uString * pAttributeName,
+ typelib_TypeClass eAttributeTypeClass,
+ rtl_uString * pAttributeTypeName,
+ sal_Bool bReadOnly,
+ sal_Int32 nGetExceptions, rtl_uString ** ppGetExceptionNames,
+ sal_Int32 nSetExceptions, rtl_uString ** ppSetExceptionNames )
+ SAL_THROW_EXTERN_C();
+
+/** Increments reference count of given type description.
+
+ @param pDesc type description
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_acquire(
+ typelib_TypeDescription * pDesc )
+ SAL_THROW_EXTERN_C();
+
+/** Decrements reference count of given type. If reference count reaches 0, the trype description
+ is deleted.
+
+ @param pDesc type description
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_release(
+ typelib_TypeDescription * pDesc )
+ SAL_THROW_EXTERN_C();
+
+/** Registers a type description and creates a type description reference. Type descriptions
+ will be registered automatically if they are provided via the callback chain.
+
+ @param ppNewDescription inout description to be registered;
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_register(
+ typelib_TypeDescription ** ppNewDescription )
+ SAL_THROW_EXTERN_C();
+
+/** Tests whether two types descriptions are equal, i.e. type class and names are equal.
+
+ @param p1 a type description
+ @param p2 another type description
+ @return true, if type descriptions are equal
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescription_equals(
+ const typelib_TypeDescription * p1, const typelib_TypeDescription * p2 )
+ SAL_THROW_EXTERN_C();
+
+/** Retrieves a type description via its fully qualified name.
+
+ @param ppRet inout type description; *ppRet is 0, if type description was not found
+ @param pName name demanded type description
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_getByName(
+ typelib_TypeDescription ** ppRet, rtl_uString * pName )
+ SAL_THROW_EXTERN_C();
+
+/** Sets size of type description cache.
+
+ @param nNewSize new size of cache
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_setCacheSize(
+ sal_Int32 nNewSize )
+ SAL_THROW_EXTERN_C();
+
+/** Function pointer declaration of callback function get additional descriptions. Callbacks
+ must provide complete type descriptions (see typelib_typedescription_complete())!
+
+ @param pContext callback context
+ @param ppRet inout type description
+ @param pTypeName name of demanded type description
+*/
+typedef void (SAL_CALL * typelib_typedescription_Callback)(
+ void * pContext, typelib_TypeDescription ** ppRet, rtl_uString * pTypeName );
+
+/** Registers callback function providing additional type descriptions.
+
+ @param pContext callback context
+ @param pCallback callback function
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_registerCallback(
+ void * pContext, typelib_typedescription_Callback pCallback )
+ SAL_THROW_EXTERN_C();
+
+/** Revokes a previously registered callback function.
+
+ @param pContext callback context
+ @param pCallback registered callback function
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_revokeCallback(
+ void * pContext, typelib_typedescription_Callback pCallback )
+ SAL_THROW_EXTERN_C();
+
+
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+
+/// @cond INTERNAL
+
+/** Returns true, if the type description reference may lose the type description. Otherwise
+ pType is a valid pointer and cannot be discarded through the lifetime of this reference.
+ Remark: If the pWeakObj of the type is set too, you can avoid the call of
+ ...getDescription(...) and use the description directly. pWeakObj == 0 means, that the
+ description is not initialized.
+*/
+#define TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( eTypeClass ) \
+ ((eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || \
+ (eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE)
+
+/** Gets a description from the reference. The description may not be locked by this call.
+ You must use the TYPELIB_DANGER_RELEASE macro to release the description fetched with
+ this macro.
+*/
+#define TYPELIB_DANGER_GET( ppDescription, pTypeRef ) \
+{ \
+ typelib_TypeDescriptionReference * pMacroTypeRef = (pTypeRef); \
+ typelib_TypeDescription ** ppMacroTypeDescr = (ppDescription); \
+ if (TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pMacroTypeRef->eTypeClass )) \
+ { \
+ typelib_typedescriptionreference_getDescription( ppMacroTypeDescr, pMacroTypeRef ); \
+ } \
+ else if (!pMacroTypeRef->pType || !pMacroTypeRef->pType->pWeakRef) \
+ { \
+ typelib_typedescriptionreference_getDescription( ppMacroTypeDescr, pMacroTypeRef ); \
+ if (*ppMacroTypeDescr) \
+ typelib_typedescription_release( *ppMacroTypeDescr ); \
+ } \
+ else \
+ { \
+ *ppMacroTypeDescr = pMacroTypeRef->pType; \
+ } \
+}
+
+/** Releases the description previouse fetched by TYPELIB_DANGER_GET.
+*/
+#define TYPELIB_DANGER_RELEASE( pDescription ) \
+{ \
+ if (TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (pDescription)->eTypeClass )) \
+ typelib_typedescription_release( pDescription ); \
+}
+
+/// @endcond
+
+/** Creates a type description reference. This is a weak reference not holding the description.
+ If the description is already registered, the previous one is returned.
+
+ @param ppTDR inout type description reference
+ @param eTypeClass type class of type
+ @param pTypeName name of type
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
+ typelib_TypeDescriptionReference ** ppTDR,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName )
+ SAL_THROW_EXTERN_C();
+
+/** Creates a type description reference. This is a weak reference not holding the description.
+ If the description is already registered, the previous one is returned.
+
+ @param ppTDR inout type description reference
+ @param eTypeClass type class of type
+ @param pTypeName ascii name of type
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_newByAsciiName(
+ typelib_TypeDescriptionReference ** ppTDR,
+ typelib_TypeClass eTypeClass,
+ const sal_Char * pTypeName )
+ SAL_THROW_EXTERN_C();
+
+/** Increments reference count of type description reference.
+
+ @param pRef type description reference
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_acquire(
+ typelib_TypeDescriptionReference * pRef )
+ SAL_THROW_EXTERN_C();
+
+/** Increments reference count of type description reference. If the reference count reaches 0,
+ then the reference is deleted.
+
+ @param pRef type description reference
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_release(
+ typelib_TypeDescriptionReference * pRef )
+ SAL_THROW_EXTERN_C();
+
+/** Retrieves the type description for a given reference. If it is not possible to resolve the
+ reference, null is returned.
+
+ @param[in,out] ppRet type description
+ @param[in] pRef type description reference
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_getDescription(
+ typelib_TypeDescription ** ppRet, typelib_TypeDescriptionReference * pRef )
+ SAL_THROW_EXTERN_C();
+
+/** Tests whether two types description references are equal, i.e. type class and names are equal.
+
+ @param p1 a type description reference
+ @param p2 another type description reference
+ @return true, if type description references are equal
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescriptionreference_equals(
+ const typelib_TypeDescriptionReference * p1, const typelib_TypeDescriptionReference * p2 )
+ SAL_THROW_EXTERN_C();
+
+/** Assigns a type.
+
+ @param ppDest destination type
+ @param pSource source type
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_assign(
+ typelib_TypeDescriptionReference ** ppDest,
+ typelib_TypeDescriptionReference * pSource )
+ SAL_THROW_EXTERN_C();
+
+/** Tests if values of type pAssignable can be assigned by values of type pFrom. This includes
+ widening conversion (e.g., long assignable from short), as long as there is no data loss.
+
+ @param pAssignable type description of value to be assigned
+ @param pFrom type description of value
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom(
+ typelib_TypeDescription * pAssignable,
+ typelib_TypeDescription * pFrom )
+ SAL_THROW_EXTERN_C();
+
+/** Tests if values of type pAssignable can be assigned by values of type pFrom. This includes
+ widening conversion (e.g., long assignable from short), as long as there is no data loss.
+
+ @param pAssignable type of value to be assigned
+ @param pFrom type of value
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
+ typelib_TypeDescriptionReference * pAssignable,
+ typelib_TypeDescriptionReference * pFrom )
+ SAL_THROW_EXTERN_C();
+
+/** Gets static type reference of standard types by type class.
+ ADDITIONAL OPT: provides Type com.sun.star.uno.Exception for typelib_TypeClass_EXCEPTION
+ and com.sun.star.uno.XInterface for typelib_TypeClass_INTERFACE.
+
+ Thread synchronizes on typelib mutex.
+
+ @param eTypeClass type class of basic type
+ @return pointer to type reference pointer
+*/
+CPPU_DLLPUBLIC typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass(
+ typelib_TypeClass eTypeClass )
+ SAL_THROW_EXTERN_C();
+
+/** Inits static type reference. Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param eTypeClass type class of type
+ @param pTypeName ascii name of type
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeClass eTypeClass, const sal_Char * pTypeName )
+ SAL_THROW_EXTERN_C();
+
+/** Inits static sequence type reference. Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param pElementType element type of sequence
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_sequence_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeDescriptionReference * pElementType )
+ SAL_THROW_EXTERN_C ();
+
+/** Inits static array type reference. Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param pElementType element type of sequence
+ @param nDimensions number of dimensions
+ @param ... additional sal_Int32 parameter for each dimension
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_array_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeDescriptionReference * pElementType,
+ sal_Int32 nDimensions, ... )
+ SAL_THROW_EXTERN_C ();
+
+/** Inits incomplete static compound type reference. Thread synchronizes on typelib init mutex.
+
+ Since this function can only be used to create type descriptions for plain
+ struct types, not for instantiated polymorphic struct types, the function
+ typelib_static_struct_type_init should be used instead for all struct types.
+
+ @param ppRef pointer to type reference pointer
+ @param eTypeClass typelib_TypeClass_STRUCT or typelib_TypeClass_EXCEPTION
+ @param pTypeName name of type
+ @param pBaseType base type
+ @param nMembers number of members
+ @param ppMembers member types
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_compound_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeClass eTypeClass, const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType,
+ sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers )
+ SAL_THROW_EXTERN_C();
+
+/** Inits incomplete static struct type reference.
+
+ Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of type
+ @param pBaseType base type
+ @param nMembers number of members
+ @param ppMembers member types
+ @param pParameterizedTypes flags for direct members, specifying whether they
+ are of parameterized type (true) or explict type (false); must be null
+ for a plain struct type
+
+ @since UDK 3.2.0
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_struct_type_init(
+ typelib_TypeDescriptionReference ** ppRef, const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType,
+ sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers,
+ sal_Bool const * pParameterizedTypes )
+ SAL_THROW_EXTERN_C();
+
+/** Inits incomplete static interface type reference. Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of interface
+ @param pBaseType base type
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_interface_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType )
+ SAL_THROW_EXTERN_C();
+
+/** Inits incomplete static multiple-inheritance interface type reference.
+ Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of interface
+ @param nBaseTypes number of base types
+ @param ppBaseTypes base types
+
+ @since UDK 3.2.0
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_mi_interface_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ sal_Int32 nBaseTypes,
+ typelib_TypeDescriptionReference ** ppBaseTypes )
+ SAL_THROW_EXTERN_C();
+
+/** Inits incomplete static enum type reference. Thread synchronizes on typelib init mutex.
+
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of enum
+ @param nDefaultValue default enum value
+*/
+CPPU_DLLPUBLIC void SAL_CALL typelib_static_enum_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ sal_Int32 nDefaultValue )
+ SAL_THROW_EXTERN_C();
+
+/** Completes a typedescription to be used for, e.g., marshalling values. COMPOUND, UNION,
+ INTERFACE and ENUM type descriptions may be partly initialized (see typelib_static_...(),
+ typelib_TypeDescription::bComplete). For interface type descriptions, this will also
+ init index tables.
+
+ @param ppTypeDescr [inout] type description to be completed (may be exchanged!)
+ @return true, if type description is complete
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescription_complete(
+ typelib_TypeDescription ** ppTypeDescr )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/typelib/typedescription.hxx b/include/typelib/typedescription.hxx
new file mode 100644
index 000000000000..1026755749f7
--- /dev/null
+++ b/include/typelib/typedescription.hxx
@@ -0,0 +1,216 @@
+/* -*- 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 _TYPELIB_TYPEDESCRIPTION_HXX_
+#define _TYPELIB_TYPEDESCRIPTION_HXX_
+
+#include <rtl/alloc.h>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Type.h>
+#include <typelib/typedescription.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** C++ wrapper for typelib_TypeDescription.
+ Constructors by name, type, type description reference will get the full type description.
+
+ @see typelib_TypeDescription
+*/
+class TypeDescription
+{
+ /** C typelib type description
+ */
+ mutable typelib_TypeDescription * _pTypeDescr;
+
+public:
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Constructor:
+
+ @param pTypeDescr a type description
+ */
+ inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 ) SAL_THROW(());
+ /** Constructor:
+
+ @param pTypeDescrRef a type description reference
+ */
+ inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(());
+ /** Constructor:
+
+ @param rType a type
+ */
+ inline TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(());
+ /** Copy constructor:
+
+ @param rDescr another TypeDescription
+ */
+ inline TypeDescription( const TypeDescription & rDescr ) SAL_THROW(());
+ /** Constructor:
+
+ @param pTypeName a type name
+ */
+ inline TypeDescription( rtl_uString * pTypeName ) SAL_THROW(());
+ /** Constructor:
+
+ @param rTypeName a type name
+ */
+ inline TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(());
+ /** Destructor: releases type description
+ */
+ inline ~TypeDescription() SAL_THROW(());
+
+ /** Assignment operator: acquires given type description and releases a set one.
+
+ @param pTypeDescr another type description
+ @return this TypeDescription
+ */
+ inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
+ /** Assignment operator: acquires given type description and releases a set one.
+
+ @param rTypeDescr another type description
+ @return this TypeDescription
+ */
+ inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr ) SAL_THROW(())
+ { return this->operator =( rTypeDescr.get() ); }
+
+ /** Tests whether two type descriptions are equal.
+
+ @param pTypeDescr another type description
+ @return true, if both type descriptions are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(());
+ /** Tests whether two type descriptions are equal.
+
+ @param rTypeDescr another type description
+ @return true, if both type descriptions are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const SAL_THROW(())
+ { return equals( rTypeDescr._pTypeDescr ); }
+
+ /** Makes stored type description complete.
+ */
+ inline void SAL_CALL makeComplete() const SAL_THROW(());
+
+ /** Gets the UNacquired type description pointer.
+
+ @return stored pointer of type description
+ */
+ inline typelib_TypeDescription * SAL_CALL get() const SAL_THROW(())
+ { return _pTypeDescr; }
+ /** Tests if a type description is set.
+
+ @return true, if a type description is set, false otherwise
+ */
+ inline sal_Bool SAL_CALL is() const SAL_THROW(())
+ { return (_pTypeDescr != 0); }
+};
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
+ : _pTypeDescr( pTypeDescr )
+{
+ if (_pTypeDescr)
+ typelib_typedescription_acquire( _pTypeDescr );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(())
+ : _pTypeDescr( 0 )
+{
+ if (pTypeDescrRef)
+ typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(())
+ : _pTypeDescr( 0 )
+{
+ if (rType.getTypeLibType())
+ typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr ) SAL_THROW(())
+ : _pTypeDescr( rTypeDescr._pTypeDescr )
+{
+ if (_pTypeDescr)
+ typelib_typedescription_acquire( _pTypeDescr );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( rtl_uString * pTypeName ) SAL_THROW(())
+ : _pTypeDescr( 0 )
+{
+ typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(())
+ : _pTypeDescr( 0 )
+{
+ typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::~TypeDescription() SAL_THROW(())
+{
+ if (_pTypeDescr)
+ typelib_typedescription_release( _pTypeDescr );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
+{
+ if (pTypeDescr)
+ typelib_typedescription_acquire( pTypeDescr );
+ if (_pTypeDescr)
+ typelib_typedescription_release( _pTypeDescr );
+ _pTypeDescr = pTypeDescr;
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(())
+{
+ return (_pTypeDescr && pTypeDescr &&
+ typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
+}
+//__________________________________________________________________________________________________
+inline void TypeDescription::makeComplete() const SAL_THROW(())
+{
+ if (_pTypeDescr && !_pTypeDescr->bComplete)
+ ::typelib_typedescription_complete( &_pTypeDescr );
+}
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/typelib/uik.h b/include/typelib/uik.h
new file mode 100644
index 000000000000..097f23793ba7
--- /dev/null
+++ b/include/typelib/uik.h
@@ -0,0 +1,45 @@
+/* -*- 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 _TYPELIB_UIK_H_
+#define _TYPELIB_UIK_H_
+
+#include <sal/types.h>
+
+#if defined( SAL_W32)
+#pragma pack(push, 8)
+#endif
+
+/** Binary typelib uik struct. Internally not used anymore.
+*/
+typedef struct _typelib_Uik
+{
+ sal_uInt32 m_Data1;
+ sal_uInt16 m_Data2;
+ sal_uInt16 m_Data3;
+ sal_uInt32 m_Data4;
+ sal_uInt32 m_Data5;
+} typelib_Uik;
+
+#if defined( SAL_W32)
+# pragma pack(pop)
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/Enterable.h b/include/uno/Enterable.h
new file mode 100644
index 000000000000..29b51f41bb29
--- /dev/null
+++ b/include/uno/Enterable.h
@@ -0,0 +1,106 @@
+/* -*- 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 INCLUDED_uno_Enterable_h
+#define INCLUDED_uno_Enterable_h
+
+#include "uno/environment.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/** Generic function type declaration for entering an Environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Stack)
+
+ @param context
+ @since UDK 3.2.7
+*/
+typedef void uno_Enterable_enter (void * context);
+
+
+/** Generic function type declaration for levaing an Environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Stack)
+
+ @param context
+ @since UDK 3.2.7
+*/
+typedef void uno_Enterable_leave (void * context);
+
+
+/** Generic function type declaration for calling into an Environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Stack)
+
+ @param context
+ @param pCallee the function to be called
+ @param pParam the parameter pointer to be passed to the function
+ @since UDK 3.2.7
+*/
+typedef void uno_Enterable_callInto_v(void * context, uno_EnvCallee * pCallee, va_list * pParam);
+
+
+/** Generic function type declaration for calling out of an Environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Stack)
+
+ @param context
+ @param pCallee the function to be called
+ @param pParam the parameter pointer to be passed to the function
+ @since UDK 3.2.7
+*/
+typedef void uno_Enterable_callOut_v (void * context, uno_EnvCallee * pCallee, va_list * pParam);
+
+
+/** Generic function type declaration for checking if calling on managed object is
+ valid.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Stack)
+
+ @param context
+ @param ppReason the reason, in case calling is not valid
+ @return 0 == calling is not valid, 1 == calling is valid
+ @since UDK 3.2.7
+*/
+typedef int uno_Enterable_isValid_v (void * context, rtl_uString ** ppReason);
+
+
+/** A struct pReserved needs to point to, if implementing a purpose environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Stack)
+
+ @since UDK 3.2.7
+*/
+typedef struct
+{
+ uno_Enterable_enter * m_enter;
+ uno_Enterable_leave * m_leave;
+ uno_Enterable_callInto_v * m_callInto_v;
+ uno_Enterable_callOut_v * m_callOut_v;
+ uno_Enterable_isValid_v * m_isValid;
+}
+uno_Enterable;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/EnvDcp.h b/include/uno/EnvDcp.h
new file mode 100644
index 000000000000..0dd327dea4c6
--- /dev/null
+++ b/include/uno/EnvDcp.h
@@ -0,0 +1,58 @@
+/* -*- 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 INCLUDED_uno_EnvDcp_h
+#define INCLUDED_uno_EnvDcp_h
+
+#include <cppu/cppudllapi.h>
+#include "rtl/ustring.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Get the OBI type part of an environment descriptor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Descriptor)
+
+ @param pEnvDcp the Environment Descriptor
+ @param ppEnvTypeName the OBI type
+ @since UDK 3.2.7
+*/
+CPPU_DLLPUBLIC void uno_EnvDcp_getTypeName(rtl_uString const * pEnvDcp, rtl_uString ** ppEnvTypeName);
+
+
+/** Get the purpose part of an environment descriptor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Descriptor)
+
+ @param pEnvDcp the Environment Descriptor
+ @param ppEnvPurpose the purpose
+ @since UDK 3.2.7
+*/
+CPPU_DLLPUBLIC void uno_EnvDcp_getPurpose (rtl_uString const * pEnvDcp, rtl_uString ** ppEnvPurpose);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/any2.h b/include/uno/any2.h
new file mode 100644
index 000000000000..e18087a165e5
--- /dev/null
+++ b/include/uno/any2.h
@@ -0,0 +1,170 @@
+/* -*- 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 _UNO_ANY2_H_
+#define _UNO_ANY2_H_
+
+#include <cppu/cppudllapi.h>
+#include <uno/data.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#if defined( SAL_W32)
+#pragma pack(push, 8)
+#endif
+
+struct _typelib_TypeDescriptionReference;
+struct _typelib_TypeDescription;
+struct _uno_Mapping;
+
+/** This is the binary specification of an UNO any.
+*/
+typedef struct _uno_Any
+{
+ /** type of value
+ */
+ struct _typelib_TypeDescriptionReference * pType;
+ /** pointer to value; this may point to pReserved and thus the uno_Any is not anytime
+ mem-copyable! You may have to correct the pData pointer to pReserved. Otherwise you need
+ not, because the data is stored in heap space.
+ */
+ void * pData;
+ /** reserved space for storing value
+ */
+ void * pReserved;
+} uno_Any;
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+/** Assign an any with a given value. Interfaces are acquired or released by the given callback
+ functions.
+
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pTypeDescr type description of value; defaults (0) to void
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_any_assign(
+ uno_Any * pDest, void * pSource,
+ struct _typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Assign an any with a given value. Interfaces are acquired or released by the given callback
+ functions.
+
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pType type description of value; defaults (0) to void
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_any_assign(
+ uno_Any * pDest, void * pSource,
+ struct _typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs an any with a given value. Interfaces are acquired by the given callback function.
+
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pTypeDescr type description of value; defaults (0) to void
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_any_construct(
+ uno_Any * pDest, void * pSource,
+ struct _typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire )
+ SAL_THROW_EXTERN_C();
+/** Constructs an any with a given value. Interfaces are acquired by the given callback function.
+
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pType type of value; defaults (0) to void
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_any_construct(
+ uno_Any * pDest, void * pSource,
+ struct _typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs an any with a given value and converts/ maps interfaces.
+
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pTypeDescr type description of value; defaults (0) to void
+ @param mapping mapping to convert/ map interfaces
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_any_constructAndConvert(
+ uno_Any * pDest, void * pSource,
+ struct _typelib_TypeDescription * pTypeDescr,
+ struct _uno_Mapping * mapping )
+ SAL_THROW_EXTERN_C();
+/** Constructs an any with a given value and converts/ maps interfaces.
+
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pType type of value; defaults (0) to void
+ @param mapping mapping to convert/ map interfaces
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_any_constructAndConvert(
+ uno_Any * pDest, void * pSource,
+ struct _typelib_TypeDescriptionReference * pType,
+ struct _uno_Mapping * mapping )
+ SAL_THROW_EXTERN_C();
+
+/** Destructs an any.
+
+ @param pValue pointer to any
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_any_destruct(
+ uno_Any * pValue, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Sets value to void.
+
+ @param pValue pointer to any
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_any_clear(
+ uno_Any * pValue, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/current_context.h b/include/uno/current_context.h
new file mode 100644
index 000000000000..18adfe84b45e
--- /dev/null
+++ b/include/uno/current_context.h
@@ -0,0 +1,63 @@
+/* -*- 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 _UNO_CURRENT_CONTEXT_H_
+#define _UNO_CURRENT_CONTEXT_H_
+
+#include <cppu/cppudllapi.h>
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Gets the current task's context.
+ @attention
+ Don't spread the returned interface around to other threads. Every thread has its own
+ current context.
+
+ @param ppCurrentContext inout param current context of type com.sun.star.uno.XCurrentContext
+ @param pEnvDcp descriptor of returned interface's environment
+ @param pEnvContext context of returned interface's environment (commonly 0)
+ @return true, if context ref was transferred (even if null ref)
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_getCurrentContext(
+ void ** ppCurrentContext,
+ rtl_uString * pEnvDcp, void * pEnvContext )
+ SAL_THROW_EXTERN_C();
+
+/** Sets the current task's context.
+
+ @param pCurrentContext in param current context of type com.sun.star.uno.XCurrentContext
+ @param pEnvDcp descriptor of interface's environment
+ @param pEnvContext context of interface's environment (commonly 0)
+ @return true, if context ref was transferred (even if null ref)
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_setCurrentContext(
+ void * pCurrentContext,
+ rtl_uString * pEnvDcp, void * pEnvContext )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/current_context.hxx b/include/uno/current_context.hxx
new file mode 100644
index 000000000000..5812db74700c
--- /dev/null
+++ b/include/uno/current_context.hxx
@@ -0,0 +1,119 @@
+/* -*- 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 _UNO_CURRENT_CONTEXT_HXX_
+#define _UNO_CURRENT_CONTEXT_HXX_
+
+#include <uno/current_context.h>
+
+#include <com/sun/star/uno/XCurrentContext.hpp>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Getting the current context.
+ @attention
+ Don't spread the returned interface around to other threads. Every thread has its own
+ current context.
+
+ @return current context or null ref, if none is set
+*/
+inline Reference< XCurrentContext > SAL_CALL getCurrentContext()
+ SAL_THROW(())
+{
+ Reference< XCurrentContext > xRet;
+ ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ ::uno_getCurrentContext( (void **)&xRet, aEnvTypeName.pData, 0 );
+ return xRet;
+}
+/** Setting the current context.
+
+ @param xContext current context to be set
+ @return true, if context has been successfully set
+*/
+inline bool SAL_CALL setCurrentContext(
+ Reference< XCurrentContext > const & xContext )
+ SAL_THROW(())
+{
+ ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ return (::uno_setCurrentContext( xContext.get(), aEnvTypeName.pData, 0 ) != sal_False);
+}
+
+/** Objects of this class are used for applying a current context until they are destructed, i.e.
+ the ctor of this class saves the previous and sets the given context while the dtor restores
+ the previous one upon destruction.
+*/
+class ContextLayer
+{
+ /** this C++ environment type name.
+ */
+ ::rtl::OUString m_aEnvTypeName;
+ /** previous context
+ */
+ Reference< XCurrentContext > m_xPreviousContext;
+
+public:
+ /** Constructor: Saves the previous context and sets the new (given) one.
+
+ @param xNewContext new context to be set
+ */
+ inline ContextLayer(
+ Reference< XCurrentContext > const & xNewContext = Reference< XCurrentContext >() )
+ SAL_THROW(());
+ /** Destructor: restores the previous context.
+ */
+ inline ~ContextLayer() SAL_THROW(());
+
+ /** Gets the previously set context.
+
+ @return the previously set context
+ */
+ inline Reference< XCurrentContext > SAL_CALL getPreviousContext() const
+ SAL_THROW(())
+ { return m_xPreviousContext; }
+};
+//__________________________________________________________________________________________________
+inline ContextLayer::ContextLayer( Reference< XCurrentContext > const & xNewContext )
+ SAL_THROW(())
+ : m_aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) )
+{
+ ::uno_getCurrentContext( (void **)&m_xPreviousContext, m_aEnvTypeName.pData, 0 );
+ ::uno_setCurrentContext( xNewContext.get(), m_aEnvTypeName.pData, 0 );
+}
+//__________________________________________________________________________________________________
+inline ContextLayer::~ContextLayer()
+ SAL_THROW(())
+{
+ ::uno_setCurrentContext( m_xPreviousContext.get(), m_aEnvTypeName.pData, 0 );
+}
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/data.h b/include/uno/data.h
new file mode 100644
index 000000000000..9454ba9012d5
--- /dev/null
+++ b/include/uno/data.h
@@ -0,0 +1,251 @@
+/* -*- 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 _UNO_DATA_H_
+#define _UNO_DATA_H_
+
+#include <cppu/cppudllapi.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _typelib_TypeDescriptionReference;
+struct _typelib_TypeDescription;
+struct _typelib_InterfaceTypeDescription;
+struct _uno_Mapping;
+
+/** Generic function pointer declaration to query for an interface.
+
+ @param pInterface interface
+ @param pTypedemanded interface type
+ @return interface pointer
+*/
+typedef void * (SAL_CALL * uno_QueryInterfaceFunc)(
+ void * pInterface, struct _typelib_TypeDescriptionReference * pType );
+/** Generic function pointer declaration to acquire an interface.
+
+ @param pInterface interface to be acquired
+*/
+typedef void (SAL_CALL * uno_AcquireFunc)(
+ void * pInterface );
+/** Generic function pointer declaration to release an interface.
+
+ @param pInterface interface to be release
+*/
+typedef void (SAL_CALL * uno_ReleaseFunc)(
+ void * pInterface );
+
+/** Tests if two values are equal. May compare different types (e.g., short to long).
+
+ @param pVal1 pointer to a value
+ @param pVal1TypeDescr type description of pVal1
+ @param pVal2 pointer to another value
+ @param pVal2TypeDescr type description of pVal2
+ @param queryInterface function called each time two interfaces are tested whether they belong
+ to the same object; defaults (0) to uno
+ @param release function to release queried interfaces; defaults (0) to uno
+ @return true if values are equal
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_equalData(
+ void * pVal1, struct _typelib_TypeDescription * pVal1TypeDescr,
+ void * pVal2, struct _typelib_TypeDescription * pVal2TypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Tests if two values are equal. May compare different types (e.g., short to long).
+
+ @param pVal1 pointer to a value
+ @param pVal1Type type of pVal1
+ @param pVal2 pointer to another value
+ @param pVal2Type type of pVal2
+ @param queryInterface function called each time two interfaces are tested whether they belong
+ to the same object; defaults (0) to uno
+ @param release function to release queried interfaces; defaults (0) to uno
+ @return true if values are equal
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_equalData(
+ void * pVal1, struct _typelib_TypeDescriptionReference * pVal1Type,
+ void * pVal2, struct _typelib_TypeDescriptionReference * pVal2Type,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Copy construct memory with given value. The size of the destination value must be larger
+ or equal to the size of the source value.
+
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pTypeDescr type description of source
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_copyData(
+ void * pDest, void * pSource,
+ struct _typelib_TypeDescription * pTypeDescr, uno_AcquireFunc acquire )
+ SAL_THROW_EXTERN_C();
+/** Copy construct memory with given value. The size of the destination value must be larger
+ or equal to the size of the source value.
+
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pType type of source
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_copyData(
+ void * pDest, void * pSource,
+ struct _typelib_TypeDescriptionReference * pType, uno_AcquireFunc acquire )
+ SAL_THROW_EXTERN_C();
+
+/** Copy construct memory with given value. The size of the destination value must be larger
+ or equal to the size of the source value. Interfaces are converted/ mapped by mapping parameter.
+
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pTypeDescr type description of source
+ @param mapping mapping to convert/ map interfaces
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_copyAndConvertData(
+ void * pDest, void * pSource,
+ struct _typelib_TypeDescription * pTypeDescr, struct _uno_Mapping * mapping )
+ SAL_THROW_EXTERN_C();
+/** Copy construct memory with given value. The size of the destination value must be larger
+ or equal to the size of the source value. Interfaces are converted/ mapped by mapping parameter.
+
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pType type of source
+ @param mapping mapping to convert/ map interfaces
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_copyAndConvertData(
+ void * pDest, void * pSource,
+ struct _typelib_TypeDescriptionReference * pType, struct _uno_Mapping * mapping )
+ SAL_THROW_EXTERN_C();
+
+/** Destructs a given value; does NOT free its memory!
+
+ @param pValue value to be destructed
+ @param pTypeDescr type description of value
+ @param release function called each time an interface pointer needs to be released;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_destructData(
+ void * pValue, struct _typelib_TypeDescription * pTypeDescr, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Destructs a given value; does NOT free its memory!
+
+ @param pValue value to be destructed
+ @param pType type of value
+ @param release function called each time an interface pointer needs to be released;
+ defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_destructData(
+ void * pValue, struct _typelib_TypeDescriptionReference * pType, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Default constructs a value. All simple types are set to 0, enums are set to their default value.
+
+ @param pMem pointer to memory of value to be constructed
+ @param pTypeDescr type description of value to be constructed
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_constructData(
+ void * pMem, struct _typelib_TypeDescription * pTypeDescr )
+ SAL_THROW_EXTERN_C();
+/** Default constructs a value. All simple types are set to 0, enums are set to their default value.
+
+ @param pMem pointer to memory of value to be constructed
+ @param pType type of value to be constructed
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_constructData(
+ void * pMem, struct _typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+
+/** Assigns a destination value with a source value.
+ Widening conversion WITHOUT data loss is allowed (e.g., assigning a long with a short).
+ Querying for demanded interface type is allowed.
+ Assignment from any value to a value of type Any and vice versa is allowed.
+
+ @param pDest pointer to destination value
+ @param pDestTypeDescr type description of destination value
+ @param pSource pointer to source value; if 0, then destination value will be assigned
+ to default value
+ @param pSourceTypeDescr type destination of source value
+ @param queryInterface function called each time an interface needs to be queried;
+ defaults (0) to uno
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+ @return true if destination has been successfully assigned
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_assignData(
+ void * pDest, struct _typelib_TypeDescription * pDestTypeDescr,
+ void * pSource, struct _typelib_TypeDescription * pSourceTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Assigns a destination value with a source value.
+ Widening conversion WITHOUT data loss is allowed (e.g., assigning a long with a short).
+ Querying for demanded interface type is allowed.
+ Assignment from any value to a value of type Any and vice versa is allowed.
+
+ @param pDest pointer to destination value
+ @param pDestType type of destination value
+ @param pSource pointer to source value; if 0, then destination value will be assigned
+ to default value
+ @param pSourceType type of source value
+ @param queryInterface function called each time an interface needs to be queried;
+ defaults (0) to uno
+ @param acquire function called each time an interface needs to be acquired;
+ defaults (0) to uno
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+ @return true if destination has been successfully assigned
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_assignData(
+ void * pDest, struct _typelib_TypeDescriptionReference * pDestType,
+ void * pSource, struct _typelib_TypeDescriptionReference * pSourceType,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Tests whether a value of given type is assignable from given value.
+ Widening conversion WITHOUT data loss is allowed (e.g., assigning a long with a short).
+ Querying for demanded interface type is allowed.
+ Assignment from any value to a value of type Any and vice versa is allowed.
+
+ @param pAssignable type
+ @param pFrom pointer to value
+ @param pFromType type of value
+ @param queryInterface function called each time an interface needs to be queried;
+ defaults (0) to uno
+ @param release function called each time an interface needs to be released;
+ defaults (0) to uno
+ @return true if value is destination has been successfully assigned
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_isAssignableFromData(
+ struct _typelib_TypeDescriptionReference * pAssignable,
+ void * pFrom, struct _typelib_TypeDescriptionReference * pFromType,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/dispatcher.h b/include/uno/dispatcher.h
new file mode 100644
index 000000000000..4008f7c1e360
--- /dev/null
+++ b/include/uno/dispatcher.h
@@ -0,0 +1,89 @@
+/* -*- 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 _UNO_DISPATCHER_H_
+#define _UNO_DISPATCHER_H_
+
+#include <sal/types.h>
+#include <rtl/ustring.h>
+#include <uno/any2.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _typelib_TypeDescription;
+struct _uno_Interface;
+
+/** Function pointer declaration for the binary C uno dispatch function. Any pure out or return
+ value will be constructed by the callee, iff no exception is signalled.
+ If an exception is signalled, the any *ppException is properly constructed by the callee,
+ otherwise the pointer *ppException is set to 0.
+ An attribute get call is indicated by a non-null return pointer.
+
+ @param pUnoI uno interface the call is performed on
+ @param pMemberType member type description of a method or attribute
+ @param pReturn pointer to return value memory;
+ pointer may be undefined if void method, null if attribute set call.
+ @param pArgs an array of pointers to arguments values.
+ (remark: the value of an interface reference stores a
+ uno_interface *, so you get it by *(uno_Interface **)pArgs[n])
+ @param ppException pointer to pointer to unconstructed any to signal an exception.
+*/
+typedef void (SAL_CALL * uno_DispatchMethod)(
+ struct _uno_Interface * pUnoI,
+ const struct _typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+
+#if defined( SAL_W32)
+#pragma pack(push, 8)
+#endif
+
+/** The binary C uno interface description.
+*/
+typedef struct _uno_Interface
+{
+ /** Acquires uno interface.
+
+ @param pInterface uno interface
+ */
+ void (SAL_CALL * acquire)( struct _uno_Interface * pInterface );
+ /** Releases uno interface.
+
+ @param pInterface uno interface
+ */
+ void (SAL_CALL * release)( struct _uno_Interface * pInterface );
+ /** dispatch function
+ */
+ uno_DispatchMethod pDispatcher;
+} uno_Interface;
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/dispatcher.hxx b/include/uno/dispatcher.hxx
new file mode 100644
index 000000000000..4fb7cced4626
--- /dev/null
+++ b/include/uno/dispatcher.hxx
@@ -0,0 +1,171 @@
+/* -*- 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 INCLUDED_UNO_DISPATCHER_HXX
+#define INCLUDED_UNO_DISPATCHER_HXX
+
+#include "uno/dispatcher.h"
+
+/// @cond INTERNAL
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** C++ holder reference for binary C uno_Interface. Not for public use, may be
+ subject to changes.
+
+ @see uno_Interface
+ @attention
+ not for public use!
+*/
+class UnoInterfaceReference
+{
+public:
+ uno_Interface * m_pUnoI;
+
+ inline bool is() const
+ { return m_pUnoI != 0; }
+
+ inline ~UnoInterfaceReference();
+ inline UnoInterfaceReference();
+ inline UnoInterfaceReference( uno_Interface * pUnoI, __sal_NoAcquire );
+ inline UnoInterfaceReference( uno_Interface * pUnoI );
+ inline UnoInterfaceReference( UnoInterfaceReference const & ref );
+
+ inline uno_Interface * get() const
+ { return m_pUnoI; }
+
+ inline UnoInterfaceReference & set(
+ uno_Interface * pUnoI );
+ inline UnoInterfaceReference & set(
+ uno_Interface * pUnoI, __sal_NoAcquire );
+ inline void clear();
+
+ inline UnoInterfaceReference & operator = (
+ UnoInterfaceReference const & ref )
+ { return set( ref.m_pUnoI ); }
+ inline UnoInterfaceReference & operator = (
+ uno_Interface * pUnoI )
+ { return set( pUnoI ); }
+
+ inline void dispatch(
+ struct _typelib_TypeDescription const * pMemberType,
+ void * pReturn, void * pArgs [], uno_Any ** ppException ) const;
+
+private:
+ inline bool operator == ( UnoInterfaceReference const & ); // not impl
+ inline bool operator != ( UnoInterfaceReference const & ); // not impl
+ inline bool operator == ( uno_Interface * ); // not impl
+ inline bool operator != ( uno_Interface * ); // not impl
+};
+
+//______________________________________________________________________________
+inline UnoInterfaceReference::~UnoInterfaceReference()
+{
+ if (m_pUnoI != 0)
+ (*m_pUnoI->release)( m_pUnoI );
+}
+
+//______________________________________________________________________________
+inline UnoInterfaceReference::UnoInterfaceReference()
+ : m_pUnoI( 0 )
+{
+}
+
+//______________________________________________________________________________
+inline UnoInterfaceReference::UnoInterfaceReference(
+ uno_Interface * pUnoI, __sal_NoAcquire )
+ : m_pUnoI( pUnoI )
+{
+}
+
+//______________________________________________________________________________
+inline UnoInterfaceReference::UnoInterfaceReference( uno_Interface * pUnoI )
+ : m_pUnoI( pUnoI )
+{
+ if (m_pUnoI != 0)
+ (*m_pUnoI->acquire)( m_pUnoI );
+}
+
+//______________________________________________________________________________
+inline UnoInterfaceReference::UnoInterfaceReference(
+ UnoInterfaceReference const & ref )
+ : m_pUnoI( ref.m_pUnoI )
+{
+ if (m_pUnoI != 0)
+ (*m_pUnoI->acquire)( m_pUnoI );
+}
+
+//______________________________________________________________________________
+inline UnoInterfaceReference & UnoInterfaceReference::set(
+ uno_Interface * pUnoI )
+{
+ if (pUnoI != 0)
+ (*pUnoI->acquire)( pUnoI );
+ if (m_pUnoI != 0)
+ (*m_pUnoI->release)( m_pUnoI );
+ m_pUnoI = pUnoI;
+ return *this;
+}
+
+//______________________________________________________________________________
+inline UnoInterfaceReference & UnoInterfaceReference::set(
+ uno_Interface * pUnoI, __sal_NoAcquire )
+{
+ if (m_pUnoI != 0)
+ (*m_pUnoI->release)( m_pUnoI );
+ m_pUnoI = pUnoI;
+ return *this;
+}
+
+//______________________________________________________________________________
+inline void UnoInterfaceReference::clear()
+{
+ if (m_pUnoI != 0)
+ {
+ (*m_pUnoI->release)( m_pUnoI );
+ m_pUnoI = 0;
+ }
+}
+
+//______________________________________________________________________________
+inline void UnoInterfaceReference::dispatch(
+ struct _typelib_TypeDescription const * pMemberType,
+ void * pReturn, void * pArgs [], uno_Any ** ppException ) const
+{
+ (*m_pUnoI->pDispatcher)(
+ m_pUnoI, pMemberType, pReturn, pArgs, ppException );
+}
+
+}
+}
+}
+}
+
+/// @endcond
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/environment.h b/include/uno/environment.h
new file mode 100644
index 000000000000..e76ed2fc7ba6
--- /dev/null
+++ b/include/uno/environment.h
@@ -0,0 +1,386 @@
+/* -*- 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 _UNO_ENVIRONMENT_H_
+#define _UNO_ENVIRONMENT_H_
+
+#include <cppu/cppudllapi.h>
+#include <rtl/ustring.h>
+
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _uno_ExtEnvironment;
+struct _typelib_InterfaceTypeDescription;
+
+#if defined( SAL_W32)
+#pragma pack(push, 8)
+#endif
+
+/** The binary specification of an UNO environment.
+*/
+typedef struct _uno_Environment
+{
+ /** reserved for future use (0 if not used)
+ */
+ void * pReserved;
+
+ /** type name of environment
+ */
+ rtl_uString * pTypeName;
+
+ /** free context pointer to be used for specific classes of environments (e.g., a jvm pointer)
+ */
+ void * pContext;
+
+ /** pointer to extended environment (interface registration functionality), if supported
+ */
+ struct _uno_ExtEnvironment * pExtEnv;
+
+ /** Acquires this environment.
+
+ @param pEnv this environment
+ */
+ void (SAL_CALL * acquire)( struct _uno_Environment * pEnv );
+
+ /** Releases this environment; last release of environment will revoke the environment from
+ runtime.
+
+ @param pEnv this environment
+ */
+ void (SAL_CALL * release)( struct _uno_Environment * pEnv );
+
+ /** Acquires this environment weakly. You can only harden a weakly held environment if it
+ is still acquired hard (acquire()).
+
+ @param pEnv this environment
+ */
+ void (SAL_CALL * acquireWeak)( struct _uno_Environment * pEnv );
+
+ /** Releases this environment weakly in correspondence to acquireWeak().
+
+ @param pEnv this environment
+ */
+ void (SAL_CALL * releaseWeak)( struct _uno_Environment * pEnv );
+
+ /** Makes hard reference out of weak referenced environment. You can only harden a weakly
+ held environment if it is still acquired hard (acquire()).
+
+ @param ppHardEnv inout hard referenced environment (has to be released via release())
+ @param pEnv environment (may be weak referenced)
+ */
+ void (SAL_CALL * harden)(
+ struct _uno_Environment ** ppHardEnv,
+ struct _uno_Environment * pEnv );
+
+ /** Call this function to EXPLICITLY dispose this environment (e.g., release all
+ interfaces). You may want to call this function before shutting down due to a runtime error.
+
+ @param pEnv this environment
+ */
+ void (SAL_CALL * dispose)( struct _uno_Environment * pEnv );
+
+ /* ===== the following part will be late initialized by a matching bridge ===== *
+ * ===== and is NOT for public use. ===== */
+
+ /** CALLBACK function pointer: Disposing callback function pointer that can be set to get
+ signalled before the environment is destroyed.
+
+ @param pEnv environment that is being disposed
+ */
+ void (SAL_CALL * environmentDisposing)( struct _uno_Environment * pEnv );
+} uno_Environment;
+
+/** Generic function pointer declaration to free a proxy object if it is not needed by the
+ environment anymore.
+ Any proxy object must register itself on first acquire() call and revoke itself on last
+ release() call. This can happen several times because the environment caches proxy objects
+ until the environment explicitly frees the proxy object calling this function.
+
+ @param pEnv environment
+ @param pProxy proxy pointer
+*/
+typedef void (SAL_CALL * uno_freeProxyFunc)( struct _uno_ExtEnvironment * pEnv, void * pProxy );
+
+/** Generic function pointer declaration to allocate memory. Used with getRegisteredInterfaces().
+
+ @param nBytes amount of memory in bytes
+ @return pointer to allocated memory
+*/
+typedef void * (SAL_CALL * uno_memAlloc)( sal_Size nBytes );
+
+/** The binary specification of an UNO environment supporting interface registration.
+*/
+typedef struct _uno_ExtEnvironment
+{
+ /** inherits all members of an uno_Environment
+ */
+ uno_Environment aBase;
+
+ /** Registers an interface of this environment.
+
+ @param pEnv this environment
+ @param ppInterface inout parameter of interface to be registered
+ @param pOId object id of interface
+ @param pTypeDescr type description of interface
+ */
+ void (SAL_CALL * registerInterface)(
+ struct _uno_ExtEnvironment * pEnv,
+ void ** ppInterface,
+ rtl_uString * pOId,
+ struct _typelib_InterfaceTypeDescription * pTypeDescr );
+
+ /** Registers a proxy interface of this environment that can be reanimated and is freed
+ explicitly by this environment.
+
+ @param pEnv this environment
+ @param ppInterface inout parameter of interface to be registered
+ @param freeProxy function to free proxy object
+ @param pOId object id of interface
+ @param pTypeDescr type description of interface
+ */
+ void (SAL_CALL * registerProxyInterface)(
+ struct _uno_ExtEnvironment * pEnv,
+ void ** ppProxy,
+ uno_freeProxyFunc freeProxy,
+ rtl_uString * pOId,
+ struct _typelib_InterfaceTypeDescription * pTypeDescr );
+
+ /** Revokes an interface from this environment. You have to revoke any interface that has
+ been registered via this method.
+
+ @param pEnv this environment
+ @param pInterface interface to be revoked
+ */
+ void (SAL_CALL * revokeInterface)(
+ struct _uno_ExtEnvironment * pEnv,
+ void * pInterface );
+
+ /** Provides the object id of a given interface.
+
+ @param ppOut inout oid
+ @param pInterface interface of object
+ */
+ void (SAL_CALL * getObjectIdentifier)(
+ struct _uno_ExtEnvironment * pEnv,
+ rtl_uString ** ppOId,
+ void * pInterface );
+
+ /** Retrieves an interface identified by its object id and type from this environment.
+ Interfaces are retrieved in the same order as they are registered.
+
+ @param pEnv this environment
+ @param ppInterface inout parameter for the registered interface; (0) if none was found
+ @param pOId object id of interface to be retrieved
+ @param pTypeDescr type description of interface to be retrieved
+ */
+ void (SAL_CALL * getRegisteredInterface)(
+ struct _uno_ExtEnvironment * pEnv,
+ void ** ppInterface,
+ rtl_uString * pOId,
+ struct _typelib_InterfaceTypeDescription * pTypeDescr );
+
+ /** Returns all currently registered interfaces of this environment. The memory block
+ allocated might be slightly larger than (*pnLen * sizeof(void *)).
+
+ @param pEnv this environment
+ @param pppInterfaces out param; pointer to array of interface pointers
+ @param pnLen out param; length of array
+ @param memAlloc function for allocating memory that is passed back
+ */
+ void (SAL_CALL * getRegisteredInterfaces)(
+ struct _uno_ExtEnvironment * pEnv,
+ void *** pppInterfaces,
+ sal_Int32 * pnLen,
+ uno_memAlloc memAlloc );
+
+ /* ===== the following part will be late initialized by a matching bridge ===== */
+
+ /** Computes an object id of the given interface; is called by the environment implementation.
+
+ @param pEnv corresponding environment
+ @param ppOId out param: computed id
+ @param pInterface an interface
+ */
+ void (SAL_CALL * computeObjectIdentifier)(
+ struct _uno_ExtEnvironment * pEnv,
+ rtl_uString ** ppOId, void * pInterface );
+
+ /** Function to acquire an interface.
+
+ @param pEnv corresponding environment
+ @param pInterface an interface
+ */
+ void (SAL_CALL * acquireInterface)(
+ struct _uno_ExtEnvironment * pEnv,
+ void * pInterface );
+
+ /** Function to release an interface.
+
+ @param pEnv corresponding environment
+ @param pInterface an interface
+ */
+ void (SAL_CALL * releaseInterface)(
+ struct _uno_ExtEnvironment * pEnv,
+ void * pInterface );
+
+} uno_ExtEnvironment;
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+/** Function exported by some bridge library providing acquireInterface(), releaseInterface();
+ may set a disposing callback.
+
+ @param pEnv environment to be initialized
+*/
+typedef void (SAL_CALL * uno_initEnvironmentFunc)( uno_Environment * pEnv );
+#define UNO_INIT_ENVIRONMENT "uno_initEnvironment"
+
+#ifdef DISABLE_DYNLOADING
+/* We link statically and have just the C++ environment */
+void SAL_CALL CPPU_ENV_uno_initEnvironment( uno_Environment * Env )
+ SAL_THROW_EXTERN_C();
+#ifdef SOLAR_JAVA
+/* We also have the Java environment */
+void SAL_CALL java_uno_initEnvironment( uno_Environment * Env )
+ SAL_THROW_EXTERN_C();
+#endif
+#endif
+
+/** Gets a specific environment. If the specified environment does not exist, then a default one
+ is created and registered. The environment revokes itself on last release() call.
+
+ @param ppEnv inout parameter of environment; given environment will be released
+ @param pEnvDcp descriptor of environment
+ @param pContext some context pointer (e.g., to distinguish java vm; set 0 if not needed)
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_getEnvironment(
+ uno_Environment ** ppEnv, rtl_uString * pEnvDcp, void * pContext )
+ SAL_THROW_EXTERN_C();
+
+/** Gets all specified environments. Caller has to release returned environments and free allocated
+ memory.
+
+ @param pppEnvs out param; pointer to array of environments
+ @param pnLen out param; length of array
+ @param memAlloc function for allocating memory that is passed back
+ @param pEnvDcp descriptor of environments; 0 defaults to all
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_getRegisteredEnvironments(
+ uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc,
+ rtl_uString * pEnvDcp )
+ SAL_THROW_EXTERN_C();
+
+/** Creates an environment. The new environment is anonymous (NOT publicly registered/ accessible).
+
+ @param ppEnv out parameter of environment; given environment will be released
+ @param pEnvDcp descriptor of environment
+ @param pContext context pointer (e.g., to distinguish java vm); set 0 if not needed
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_createEnvironment(
+ uno_Environment ** ppEnv, rtl_uString * pEnvDcp, void * pContext )
+ SAL_THROW_EXTERN_C();
+
+/** Dumps out environment information, i.e. registered interfaces.
+
+ @param stream output stream (FILE *)
+ @param pEnv environment to be dumped
+ @param pFilter if not null, filters output
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_dumpEnvironment(
+ void * stream, uno_Environment * pEnv, const sal_Char * pFilter )
+ SAL_THROW_EXTERN_C();
+/** Dumps out environment information, i.e. registered interfaces.
+
+ @param stream output stream (FILE *)
+ @param pEnvDcp descritpro of environment to be dumped
+ @param pFilter if not null, filters output
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_dumpEnvironmentByName(
+ void * stream, rtl_uString * pEnvDcp, const sal_Char * pFilter )
+ SAL_THROW_EXTERN_C();
+
+
+
+/** Returns the current Environment.
+ In case no Environment has explicitly been entered, a purpose free
+ default environment gets returned (e.g. the "uno" or "gcc3" Environment).
+
+ @param ppEnv inout parameter; a given environment will be released
+ @param pTypeName the optional type of the environment, falls back to "uno"
+ @since UDK 3.2.7
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_getCurrentEnvironment(uno_Environment ** ppEnv, rtl_uString * pTypeName)
+ SAL_THROW_EXTERN_C();
+
+/** Typedef for variable argument function.
+ */
+typedef void SAL_CALL uno_EnvCallee(va_list * pParam);
+
+/** Invoke the passed function in the given environment.
+
+ @param pEnv the target environment
+ @param pCallee the function to call
+ @param pParam the parameter pointer passed to the function
+ @since UDK 3.2.7
+ */
+CPPU_DLLPUBLIC void SAL_CALL uno_Environment_invoke_v(uno_Environment * pEnv, uno_EnvCallee * pCallee, va_list * pParam)
+ SAL_THROW_EXTERN_C();
+
+/** Invoke the passed function in the given environment.
+
+ @param pEnv the target environment
+ @param pCallee the function to call
+ @param ... the parameters passed to the function
+ @since UDK 3.2.7
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_Environment_invoke (uno_Environment * pEnv, uno_EnvCallee * pCallee, ...)
+ SAL_THROW_EXTERN_C();
+
+/** Enter an environment explicitly.
+
+ @param pEnv the environment to enter; NULL leaves all environments
+ @since UDK 3.2.7
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_Environment_enter(uno_Environment * pEnv)
+ SAL_THROW_EXTERN_C();
+
+/** Check if a particular environment is currently valid, so
+ that objects of that environment might be called.
+
+ @param pEnv the environment
+ @param pReason the reason, if it is not valid
+ @return 1 == valid, 0 == invalid
+ @since UDK 3.2.7
+*/
+CPPU_DLLPUBLIC int SAL_CALL uno_Environment_isValid(uno_Environment * pEnv, rtl_uString ** pReason)
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/environment.hxx b/include/uno/environment.hxx
new file mode 100644
index 000000000000..5fd8633c6e9f
--- /dev/null
+++ b/include/uno/environment.hxx
@@ -0,0 +1,270 @@
+/* -*- 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 _UNO_ENVIRONMENT_HXX_
+#define _UNO_ENVIRONMENT_HXX_
+
+#include <rtl/alloc.h>
+#include <rtl/ustring.hxx>
+#include <uno/environment.h>
+
+#include "uno/lbnames.h"
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** C++ wrapper for binary C uno_Environment.
+
+ @see uno_Environment
+*/
+class Environment
+{
+ /** binary C uno_Environment
+ */
+ uno_Environment * _pEnv;
+
+public:
+ /** Returns the current Environment.
+
+ @param typeName the optional type of the Environment, falls back to "uno" in case being empty,
+ respectively to current C++ Environment.
+ @since UDK 3.2.7
+ */
+ inline static Environment getCurrent(rtl::OUString const & typeName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV)))) SAL_THROW(());
+
+ /// @cond INTERNAL
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Constructor: acquires given environment
+
+ @param pEnv environment
+ */
+ inline Environment( uno_Environment * pEnv = 0 ) SAL_THROW(());
+
+ /** Gets a specific environment. If the specified environment does not exist, then a default one
+ is created and registered.
+
+ @param envDcp descriptor of the environment
+ @param pContext context pointer
+ */
+ inline explicit Environment( rtl::OUString const & envDcp, void * pContext = NULL ) SAL_THROW(());
+
+
+ /** Copy constructor: acquires given environment
+
+ @param rEnv another environment
+ */
+ inline Environment( const Environment & rEnv ) SAL_THROW(());
+
+ /** Destructor: releases a set environment.
+ */
+ inline ~Environment() SAL_THROW(());
+
+ /** Sets a given environment, i.e. acquires given one and releases a set one.
+
+ @param pEnv another environment
+ @return this environment
+ */
+ inline Environment & SAL_CALL operator = ( uno_Environment * pEnv ) SAL_THROW(());
+ /** Sets a given environment, i.e. acquires given one and releases a set one.
+
+ @param rEnv another environment
+ @return this environment
+ */
+ inline Environment & SAL_CALL operator = ( const Environment & rEnv ) SAL_THROW(())
+ { return operator = ( rEnv._pEnv ); }
+
+ /** Provides UNacquired pointer to the set C environment.
+
+ @return UNacquired pointer to the C environment struct
+ */
+ inline uno_Environment * SAL_CALL get() const SAL_THROW(())
+ { return _pEnv; }
+
+ /** Gets type name of set environment.
+
+ @return type name of set environment
+ */
+ inline ::rtl::OUString SAL_CALL getTypeName() const SAL_THROW(())
+ { return _pEnv->pTypeName; }
+
+ /** Gets free context pointer of set environment.
+
+ @return free context pointer of set environment
+ */
+ inline void * SAL_CALL getContext() const SAL_THROW(())
+ { return _pEnv->pContext; }
+
+ /** Tests if a environment is set.
+
+ @return true, if a environment is set, false otherwise
+ */
+ inline sal_Bool SAL_CALL is() const SAL_THROW(())
+ { return (_pEnv != 0); }
+
+ /** Releases a set environment.
+ */
+ inline void SAL_CALL clear() SAL_THROW(());
+
+ /** Invoke the passed function in this environment.
+
+ @param pCallee the function to call
+ @param pParam the parameter pointer to be passed to the function
+ @since UDK 3.2.7
+ */
+ inline void SAL_CALL invoke_v(uno_EnvCallee * pCallee, va_list * pParam) const SAL_THROW(());
+
+ /** Invoke the passed function in this environment.
+
+ @param pCallee the function to call
+ @param ... the parameters to be passed to the function
+ @since UDK 3.2.7
+ */
+ inline void SAL_CALL invoke(uno_EnvCallee * pCallee, ...) const SAL_THROW(());
+
+ /** Enter this environment explicitly.
+
+ @since UDK 3.2.7
+ */
+ inline void SAL_CALL enter() const SAL_THROW(());
+
+ /** Checks, if it is valid to currently call objects
+ belonging to this environment.
+
+ @since UDK 3.2.7
+ */
+ inline int SAL_CALL isValid(rtl::OUString * pReason) const SAL_THROW(());
+};
+//__________________________________________________________________________________________________
+inline Environment::Environment( uno_Environment * pEnv ) SAL_THROW(())
+ : _pEnv( pEnv )
+{
+ if (_pEnv)
+ (*_pEnv->acquire)( _pEnv );
+}
+//__________________________________________________________________________________________________
+inline Environment::Environment( rtl::OUString const & rEnvDcp, void * pContext ) SAL_THROW(())
+ : _pEnv(NULL)
+{
+ uno_getEnvironment(&_pEnv, rEnvDcp.pData, pContext);
+}
+//__________________________________________________________________________________________________
+inline Environment::Environment( const Environment & rEnv ) SAL_THROW(())
+ : _pEnv( rEnv._pEnv )
+{
+ if (_pEnv)
+ (*_pEnv->acquire)( _pEnv );
+}
+//__________________________________________________________________________________________________
+inline Environment::~Environment() SAL_THROW(())
+{
+ if (_pEnv)
+ (*_pEnv->release)( _pEnv );
+}
+//__________________________________________________________________________________________________
+inline void Environment::clear() SAL_THROW(())
+{
+ if (_pEnv)
+ {
+ (*_pEnv->release)( _pEnv );
+ _pEnv = 0;
+ }
+}
+//__________________________________________________________________________________________________
+inline Environment & Environment::operator = ( uno_Environment * pEnv ) SAL_THROW(())
+{
+ if (pEnv != _pEnv)
+ {
+ if (pEnv)
+ (*pEnv->acquire)( pEnv );
+ if (_pEnv)
+ (*_pEnv->release)( _pEnv );
+ _pEnv = pEnv;
+ }
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline void SAL_CALL Environment::invoke_v(uno_EnvCallee * pCallee, va_list * pParam) const SAL_THROW(())
+{
+ if (_pEnv)
+ uno_Environment_invoke_v(_pEnv, pCallee, pParam);
+}
+//__________________________________________________________________________________________________
+inline void SAL_CALL Environment::invoke(uno_EnvCallee * pCallee, ...) const SAL_THROW(())
+{
+ if (_pEnv)
+ {
+ va_list param;
+
+ va_start(param, pCallee);
+ uno_Environment_invoke_v(_pEnv, pCallee, &param);
+ va_end(param);
+ }
+
+}
+//__________________________________________________________________________________________________
+inline void SAL_CALL Environment::enter() const SAL_THROW(())
+{
+ uno_Environment_enter(_pEnv);
+}
+//__________________________________________________________________________________________________
+inline int SAL_CALL Environment::isValid(rtl::OUString * pReason) const SAL_THROW(())
+{
+ return uno_Environment_isValid(_pEnv, (rtl_uString **)pReason);
+}
+//__________________________________________________________________________________________________
+inline Environment Environment::getCurrent(rtl::OUString const & typeName) SAL_THROW(())
+{
+ Environment environment;
+
+ uno_Environment * pEnv = NULL;
+ uno_getCurrentEnvironment(&pEnv, typeName.pData);
+ environment = pEnv;
+ if (pEnv)
+ pEnv->release(pEnv);
+
+ return environment;
+}
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/lbnames.h b/include/uno/lbnames.h
new file mode 100644
index 000000000000..dcae196ece60
--- /dev/null
+++ b/include/uno/lbnames.h
@@ -0,0 +1,54 @@
+/* -*- 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 _UNO_LBNAMES_H_
+#define _UNO_LBNAMES_H_
+
+/* I assume "LB" means "Language Binding" */
+
+#ifdef __cplusplus
+
+#ifdef CPPU_ENV
+
+#define CPPU_STRINGIFY_EX( x ) #x
+#define CPPU_STRINGIFY( x ) CPPU_STRINGIFY_EX( x )
+
+/** Name for C++ compiler/ platform, e.g. "gcc3", "msci" */
+#define CPPU_CURRENT_LANGUAGE_BINDING_NAME CPPU_STRINGIFY( CPPU_ENV )
+
+#else
+
+#error "No supported C++ compiler environment."
+provoking error here, because PP ignores #error
+
+#endif /* CPPU_ENV */
+
+#endif /* __cplusplus */
+
+/** Environment type name for binary C UNO. */
+#define UNO_LB_UNO "uno"
+/** Environment type name for ANSI C compilers. */
+#define UNO_LB_C "c"
+/** Environment type name for Java 1.3.1 compatible virtual machine. */
+#define UNO_LB_JAVA "java"
+/** Environment type name for CLI (Common Language Infrastructure). */
+#define UNO_LB_CLI "cli"
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/mapping.h b/include/uno/mapping.h
new file mode 100644
index 000000000000..179f41f869c9
--- /dev/null
+++ b/include/uno/mapping.h
@@ -0,0 +1,214 @@
+/* -*- 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 _UNO_MAPPING_H_
+#define _UNO_MAPPING_H_
+
+#include <cppu/cppudllapi.h>
+#include <rtl/ustring.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _typelib_InterfaceTypeDescription;
+struct _uno_Mapping;
+struct _uno_Environment;
+
+/**
+ Function pointer declaration to acquire a UNO mapping.
+*/
+typedef void (SAL_CALL * uno_AcquireMappingFunc)(struct _uno_Mapping *);
+
+/**
+ Function pointer declaration to release a UNO mapping.
+*/
+typedef void (SAL_CALL * uno_ReleaseMappingFunc)(struct _uno_Mapping *);
+
+/** Function pointer declaration to map an interface from one environment to another.
+
+ @param pMapping mapping
+ @param ppOut [inout] destination interface; existing interfaces are released
+ @param pInterface source interface
+ @param pInterfaceTypeDescr type description of the interface
+*/
+typedef void (SAL_CALL * uno_MapInterfaceFunc)(
+ struct _uno_Mapping * pMapping,
+ void ** ppOut, void * pInterface,
+ struct _typelib_InterfaceTypeDescription * pInterfaceTypeDescr );
+
+
+#if defined( SAL_W32)
+#pragma pack(push, 8)
+#endif
+
+/** This is the binary specification of a mapping.
+*/
+typedef struct _uno_Mapping
+{
+ /** Acquires mapping
+ */
+ uno_AcquireMappingFunc acquire;
+
+ /** Releases mapping. The last release may unload bridges.
+ */
+ uno_ReleaseMappingFunc release;
+
+ /** mapping function
+ */
+ uno_MapInterfaceFunc mapInterface;
+} uno_Mapping;
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+/** Gets an interface mapping from one environment to another.
+
+ @param ppMapping [inout] mapping; existing mapping will be released
+ @param pFrom source environment
+ @param pTo destination environment
+ (interfaces resulting in mapInterface() call can be used
+ in this language environment)
+ @param pAddPurpose additional purpose of mapping (e.g., protocolling); defaults to 0 (none)
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_getMapping(
+ struct _uno_Mapping ** ppMapping,
+ struct _uno_Environment * pFrom,
+ struct _uno_Environment * pTo,
+ rtl_uString * pAddPurpose )
+ SAL_THROW_EXTERN_C();
+
+/** Callback function pointer declaration to get a mapping.
+
+ @param ppMapping inout mapping
+ @param pFrom source environment
+ @param pTo destination environment
+ @param pAddPurpose additional purpose
+*/
+typedef void (SAL_CALL * uno_getMappingFunc)(
+ struct _uno_Mapping ** ppMapping,
+ struct _uno_Environment * pFrom,
+ struct _uno_Environment * pTo,
+ rtl_uString * pAddPurpose );
+
+/** Registers a callback being called each time a mapping is demanded.
+
+ @param pCallback callback function
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_registerMappingCallback(
+ uno_getMappingFunc pCallback )
+ SAL_THROW_EXTERN_C();
+
+/** Revokes a mapping callback registration.
+
+ @param pCallback callback function
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_revokeMappingCallback(
+ uno_getMappingFunc pCallback )
+ SAL_THROW_EXTERN_C();
+
+/** Function pointer declaration to free a mapping.
+
+ @param pMapping mapping to be freed
+*/
+typedef void (SAL_CALL * uno_freeMappingFunc)( struct _uno_Mapping * pMapping );
+
+/** Registers a mapping. A mapping registers itself on first acquire and revokes itself on last
+ release. The given freeMapping function is called by the runtime to cleanup any resources.
+
+ @param ppMapping inout mapping to be registered
+ @param freeMapping called by runtime to delete mapping
+ @param pFrom source environment
+ @param pTo destination environment
+ @param pAddPurpose additional purpose string; defaults to 0
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_registerMapping(
+ struct _uno_Mapping ** ppMapping, uno_freeMappingFunc freeMapping,
+ struct _uno_Environment * pFrom, struct _uno_Environment * pTo, rtl_uString * pAddPurpose )
+ SAL_THROW_EXTERN_C();
+
+/** Revokes a mapping. A mapping registers itself on first acquire and revokes itself on last
+ release.
+
+ @param pMapping mapping to be revoked
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_revokeMapping(
+ struct _uno_Mapping * pMapping )
+ SAL_THROW_EXTERN_C();
+
+/** Gets an interface mapping from one language environment to another by corresponding environment
+ type names.
+
+ @param ppMapping [inout] mapping; existing mapping will be released
+ @param pFrom source environment type name
+ @param pTo destination environment type name
+ (interfaces resulting in mapInterface() call can be used
+ in this language environment)
+ @param pAddPurpose additional purpose of mapping (e.g., protocolling); defaults to 0 (none)
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_getMappingByName(
+ struct _uno_Mapping ** ppMapping,
+ rtl_uString * pFrom,
+ rtl_uString * pTo,
+ rtl_uString * pAddPurpose )
+ SAL_THROW_EXTERN_C();
+
+/* symbol exported by each language binding library */
+#define UNO_EXT_GETMAPPING "uno_ext_getMapping"
+
+/** Function pointer declaration to get a mapping from a loaded bridge. Bridges export a function
+ called uno_ext_getMapping() of this signature.
+
+ @param[in,out] ppMapping mapping; existing mapping will be released
+ @param[in] pFrom source environment
+ @param[in] pTo destination environment
+*/
+typedef void (SAL_CALL * uno_ext_getMappingFunc)(
+ struct _uno_Mapping ** ppMapping,
+ struct _uno_Environment * pFrom,
+ struct _uno_Environment * pTo );
+
+#ifdef DISABLE_DYNLOADING
+/* Static linking, this is the uno_ext_getMapping function in the C++/UNO bridge */
+void SAL_CALL CPPU_ENV_uno_ext_getMapping(
+ struct _uno_Mapping ** ppMapping,
+ struct _uno_Environment * pFrom,
+ struct _uno_Environment * pTo )
+ SAL_THROW_EXTERN_C();
+
+#ifdef SOLAR_JAVA
+/* This is the uno_ext_getMapping function in the Java/UNO bridge */
+void SAL_CALL java_uno_ext_getMapping(
+ struct _uno_Mapping ** ppMapping,
+ struct _uno_Environment * pFrom,
+ struct _uno_Environment * pTo )
+ SAL_THROW_EXTERN_C();
+#endif
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/mapping.hxx b/include/uno/mapping.hxx
new file mode 100644
index 000000000000..13a042833ad6
--- /dev/null
+++ b/include/uno/mapping.hxx
@@ -0,0 +1,346 @@
+/* -*- 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 _UNO_MAPPING_HXX_
+#define _UNO_MAPPING_HXX_
+
+#include <cppu/macros.hxx>
+#include <rtl/alloc.h>
+#include <rtl/ustring.hxx>
+#include <uno/mapping.h>
+#include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include "cppu/unotype.hxx"
+#include "uno/environment.hxx"
+
+typedef struct _typelib_TypeDescription typelib_TypeDescription;
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+typedef struct _uno_Interface uno_Interface;
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** C++ wrapper for C uno_Mapping.
+
+ @see uno_Mapping
+*/
+class Mapping
+{
+ uno_Mapping * _pMapping;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ /// @cond INTERNAL
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
+ { return pMem; }
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
+ {}
+ /// @endcond
+
+ /** Holds a mapping from the specified source to the specified destination by environment
+ type names.
+
+ @param rFrom type name of source environment
+ @param rTo type name of destination environment
+ @param rAddPurpose additional purpose
+ */
+ inline Mapping(
+ const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo,
+ const ::rtl::OUString & rAddPurpose = ::rtl::OUString() )
+ SAL_THROW(());
+
+ /** Holds a mapping from the specified source to the specified destination.
+
+ @param pFrom source environment
+ @param pTo destination environment
+ @param rAddPurpose additional purpose
+ */
+ inline Mapping(
+ uno_Environment * pFrom, uno_Environment * pTo,
+ const ::rtl::OUString & rAddPurpose = ::rtl::OUString() )
+ SAL_THROW(());
+
+ /** Holds a mapping from the specified source to the specified destination
+ environment.
+
+ @param rFrom source environment
+ @param rTo destination environment
+ @param rAddPurpose additional purpose
+ */
+ inline Mapping(const Environment & rFrom, const Environment & rTo,
+ const ::rtl::OUString & rAddPurpose = ::rtl::OUString() )
+ SAL_THROW(());
+
+ /** Constructor.
+
+ @param pMapping another mapping
+ */
+ inline Mapping( uno_Mapping * pMapping = 0 ) SAL_THROW(());
+
+ /** Copy constructor.
+
+ @param rMapping another mapping
+ */
+ inline Mapping( const Mapping & rMapping ) SAL_THROW(());
+
+ /** Destructor.
+ */
+ inline ~Mapping() SAL_THROW(());
+
+ /** Sets a given mapping.
+
+ @param pMapping another mapping
+ @return this mapping
+ */
+ inline Mapping & SAL_CALL operator = ( uno_Mapping * pMapping ) SAL_THROW(());
+ /** Sets a given mapping.
+
+ @param rMapping another mapping
+ @return this mapping
+ */
+ inline Mapping & SAL_CALL operator = ( const Mapping & rMapping ) SAL_THROW(())
+ { return operator = ( rMapping._pMapping ); }
+
+ /** Provides a pointer to the C mapping. The returned mapping is NOT acquired!
+
+ @return UNacquired C mapping
+ */
+ inline uno_Mapping * SAL_CALL get() const SAL_THROW(())
+ { return _pMapping; }
+
+ /** Tests if a mapping is set.
+
+ @return true if a mapping is set
+ */
+ inline sal_Bool SAL_CALL is() const SAL_THROW(())
+ { return (_pMapping != 0); }
+
+ /** Releases a set mapping.
+ */
+ inline void SAL_CALL clear() SAL_THROW(());
+
+ /** Maps an interface from one environment to another.
+
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ @return mapped interface
+ */
+ inline void * SAL_CALL mapInterface( void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const SAL_THROW(());
+ /** Maps an interface from one environment to another.
+
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ @return mapped interface
+ */
+ inline void * SAL_CALL mapInterface( void * pInterface, typelib_TypeDescription * pTypeDescr ) const SAL_THROW(())
+ { return mapInterface( pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); }
+
+ /** Maps an interface from one environment to another.
+
+ @param pInterface source interface
+ @param rType type of interface
+ @return mapped interface
+ */
+ inline void * SAL_CALL mapInterface(
+ void * pInterface, const ::com::sun::star::uno::Type & rType ) const SAL_THROW(());
+
+ /** Maps an interface from one environment to another.
+
+ @param ppOut inout mapped interface
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ */
+ inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const SAL_THROW(())
+ { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, pTypeDescr ); }
+ /** Maps an interface from one environment to another.
+
+ @param ppOut inout mapped interface
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ */
+ inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_TypeDescription * pTypeDescr ) const SAL_THROW(())
+ { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); }
+
+ /** Maps an interface from one environment to another.
+
+ @param ppOut inout mapped interface
+ @param pInterface source interface
+ @param rType type of interface to be mapped
+ */
+ inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, const ::com::sun::star::uno::Type & rType ) const SAL_THROW(());
+};
+//__________________________________________________________________________________________________
+inline Mapping::Mapping(
+ const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo, const ::rtl::OUString & rAddPurpose )
+ SAL_THROW(())
+ : _pMapping( 0 )
+{
+ uno_getMappingByName( &_pMapping, rFrom.pData, rTo.pData, rAddPurpose.pData );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping(
+ uno_Environment * pFrom, uno_Environment * pTo, const ::rtl::OUString & rAddPurpose )
+ SAL_THROW(())
+ : _pMapping( 0 )
+{
+ uno_getMapping( &_pMapping, pFrom, pTo, rAddPurpose.pData );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping(
+ const Environment & rFrom, const Environment & rTo, const ::rtl::OUString & rAddPurpose )
+ SAL_THROW(())
+ : _pMapping(0)
+{
+ uno_getMapping( &_pMapping, rFrom.get(), rTo.get(), rAddPurpose.pData );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping( uno_Mapping * pMapping ) SAL_THROW(())
+ : _pMapping( pMapping )
+{
+ if (_pMapping)
+ (*_pMapping->acquire)( _pMapping );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping( const Mapping & rMapping ) SAL_THROW(())
+ : _pMapping( rMapping._pMapping )
+{
+ if (_pMapping)
+ (*_pMapping->acquire)( _pMapping );
+}
+//__________________________________________________________________________________________________
+inline Mapping::~Mapping() SAL_THROW(())
+{
+ if (_pMapping)
+ (*_pMapping->release)( _pMapping );
+}
+//__________________________________________________________________________________________________
+inline void Mapping::clear() SAL_THROW(())
+{
+ if (_pMapping)
+ {
+ (*_pMapping->release)( _pMapping );
+ _pMapping = 0;
+ }
+}
+//__________________________________________________________________________________________________
+inline Mapping & Mapping::operator = ( uno_Mapping * pMapping ) SAL_THROW(())
+{
+ if (pMapping)
+ (*pMapping->acquire)( pMapping );
+ if (_pMapping)
+ (*_pMapping->release)( _pMapping );
+ _pMapping = pMapping;
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline void Mapping::mapInterface(
+ void ** ppOut, void * pInterface, const ::com::sun::star::uno::Type & rType ) const
+ SAL_THROW(())
+{
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
+ if (pTD)
+ {
+ (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+}
+//__________________________________________________________________________________________________
+inline void * Mapping::mapInterface(
+ void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const
+ SAL_THROW(())
+{
+ void * pOut = 0;
+ (*_pMapping->mapInterface)( _pMapping, &pOut, pInterface, pTypeDescr );
+ return pOut;
+}
+//__________________________________________________________________________________________________
+inline void * Mapping::mapInterface(
+ void * pInterface, const ::com::sun::star::uno::Type & rType ) const
+ SAL_THROW(())
+{
+ void * pOut = 0;
+ mapInterface( &pOut, pInterface, rType );
+ return pOut;
+}
+
+/** Deprecated. This function DOES NOT WORK with Purpose Environments
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Purpose Environments)
+
+ Maps an binary C UNO interface to be used in the currently used compiler environment.
+
+ @tparam C interface type
+ @param ppRet inout returned interface pointer
+ @param pUnoI binary C UNO interface
+ @return true if successful, false otherwise
+
+ @deprecated
+*/
+template< class C >
+inline sal_Bool mapToCpp( Reference< C > * ppRet, uno_Interface * pUnoI ) SAL_THROW(())
+{
+ Mapping aMapping(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) );
+ OSL_ASSERT( aMapping.is() );
+ aMapping.mapInterface(
+ (void **)ppRet, pUnoI, ::cppu::getTypeFavourUnsigned( ppRet ) );
+ return (0 != *ppRet);
+}
+/** Deprecated. This function DOES NOT WORK with Purpose Environments
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Purpose Environments)
+
+ Maps an UNO interface of the currently used compiler environment to binary C UNO.
+
+ @tparam C interface type
+ @param ppRet inout returned interface pointer
+ @param x interface reference
+ @return true if successful, false otherwise
+
+ @deprecated
+*/
+template< class C >
+inline sal_Bool mapToUno( uno_Interface ** ppRet, const Reference< C > & x ) SAL_THROW(())
+{
+ Mapping aMapping(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) );
+ OSL_ASSERT( aMapping.is() );
+ aMapping.mapInterface(
+ (void **)ppRet, x.get(), ::cppu::getTypeFavourUnsigned( &x ) );
+ return (0 != *ppRet);
+}
+
+}
+}
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/sequence2.h b/include/uno/sequence2.h
new file mode 100644
index 000000000000..304eefc9f746
--- /dev/null
+++ b/include/uno/sequence2.h
@@ -0,0 +1,181 @@
+/* -*- 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 _UNO_SEQUENCE2_H_
+#define _UNO_SEQUENCE2_H_
+
+#include <cppu/cppudllapi.h>
+#include <uno/data.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _typelib_TypeDescriptionReference;
+struct _typelib_TypeDescription;
+typedef sal_Sequence uno_Sequence;
+
+/** Assigns a sequence.
+
+ @param ppDest destinstaion sequence
+ @param pSource source sequence
+ @param pTypeDescr type description of the sequence and NOT of an element
+ @param release function called each time an interface needs to
+ be released; defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_sequence_assign(
+ uno_Sequence ** ppDest,
+ uno_Sequence * pSource,
+ struct _typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Assigns a sequence.
+
+ @param ppDest destinstaion sequence
+ @param pSource source sequence
+ @param pType type of the sequence and NOT of an element
+ @param release function called each time an interface needs to
+ be released; defaults (0) to uno
+*/
+CPPU_DLLPUBLIC void SAL_CALL uno_type_sequence_assign(
+ uno_Sequence ** ppDest,
+ uno_Sequence * pSource,
+ struct _typelib_TypeDescriptionReference * pType,
+ uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a new sequence with given elements.
+
+ @param ppSequence out parameter sequence;
+ 0 if memory allocation has failed
+ @param pTypeDescr type description of the sequence and NOT of an
+ element
+ @param pElements if 0, then all elements are default constructed
+ @param len number of elements
+ @param acquire function called each time an interface needs to
+ be acquired; defaults (0) to uno
+ @return false, if memoray allocation has failed
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_sequence_construct(
+ uno_Sequence ** ppSequence,
+ struct _typelib_TypeDescription * pTypeDescr,
+ void * pElements, sal_Int32 len,
+ uno_AcquireFunc acquire )
+ SAL_THROW_EXTERN_C();
+/** Constructs a new sequence with given elements.
+
+ @param ppSequence out parameter sequence;
+ 0 if memory allocation has failed
+ @param pType type of the sequence and NOT of an element
+ @param pElements if 0, then all elements are default constructed
+ @param len number of elements
+ @param acquire function called each time an interface needs to
+ be acquired; defaults (0) to uno
+ @return false, if memoray allocation has failed
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_sequence_construct(
+ uno_Sequence ** ppSequence,
+ struct _typelib_TypeDescriptionReference * pType,
+ void * pElements, sal_Int32 len,
+ uno_AcquireFunc acquire )
+ SAL_THROW_EXTERN_C();
+
+/** Assures that the reference count of the given sequence is one.
+ Otherwise a new copy of the sequence is created with a reference count
+ of one.
+
+ @param ppSequence inout sequence
+ @param pTypeDescr type description of sequence
+ @param acquire function called each time an interface needs to
+ be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to
+ be released; defaults (0) to uno
+ @return false, if memoray allocation has failed
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_sequence_reference2One(
+ uno_Sequence ** ppSequence,
+ struct _typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Assures that the reference count of the given sequence is one.
+ Otherwise a new copy of the sequence is created with a reference count
+ of one.
+
+ @param ppSequence inout sequence
+ @param pType type of sequence
+ @param acquire function called each time an interface needs to
+ be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to
+ be released; defaults (0) to uno
+ @return false, if memoray allocation has failed
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_sequence_reference2One(
+ uno_Sequence ** ppSequence,
+ struct _typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+/** Reallocates length of a sequence. This truncates a sequence or enlarges
+ it default constructing appended elements.
+
+ @param ppSequence inout sequence
+ @param pTypeDescr type description of sequence
+ @param nSize new size of sequence
+ @param acquire function called each time an interface needs to
+ be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to
+ be released; defaults (0) to uno
+ @return false, if memoray allocation has failed
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_sequence_realloc(
+ uno_Sequence ** ppSequence,
+ struct _typelib_TypeDescription * pTypeDescr,
+ sal_Int32 nSize,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+/** Reallocates length of a sequence. This truncates a sequence or enlarges
+ it default constructing appended elements.
+
+ @param ppSequence inout sequence
+ @param pType type of sequence
+ @param nSize new size of sequence
+ @param acquire function called each time an interface needs to
+ be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to
+ be released; defaults (0) to uno
+ @return false, if memoray allocation has failed
+*/
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_sequence_realloc(
+ uno_Sequence ** ppSequence,
+ struct _typelib_TypeDescriptionReference * pType,
+ sal_Int32 nSize,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/uno/threadpool.h b/include/uno/threadpool.h
new file mode 100644
index 000000000000..6e880e55b144
--- /dev/null
+++ b/include/uno/threadpool.h
@@ -0,0 +1,185 @@
+/* -*- 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 .
+ */
+
+#include <cppu/cppudllapi.h>
+#include <rtl/byteseq.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***
+ * Thread identifier administration.
+ ***/
+/**
+ Establishs an association between the current thread and the given thread identifier.
+ There can be only one association at a time. The association must be broken by
+ uno_releaseIdFromCurrentThread().
+ This method is in general called by a bridge, that wants to bind a remote threadId
+ to a new thread.
+
+ @param pThreadId a byte sequence, that contains the identifier of the current thread.
+ @return true, when the identifier was registered.
+ false, when the thread has already an identifier. The identifier was not
+ altered. ( This is in general a bug ).
+
+ @see uno_releaseIdFromCurrentThread()
+ */
+CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_bindIdToCurrentThread( sal_Sequence *pThreadId )
+ SAL_THROW_EXTERN_C();
+
+
+/**
+ Get the identifier of the current thread.
+ If no id has been bound for the thread before, a new one is generated and bound
+ to the thread.
+ For each call to uno_getIdOfCurrentThread(), a call to uno_releaseIdFromCurrentThread()
+ must be done.
+
+ @param ppThreadId [out] Contains the (acquired) ThreadId.
+ @see uno_releaseIdFromCurrentThread()
+ */
+CPPU_DLLPUBLIC void SAL_CALL uno_getIdOfCurrentThread( sal_Sequence **ppThreadId )
+ SAL_THROW_EXTERN_C();
+
+
+/**
+ If the internal refcount drops to zero, the association between threadId and
+ thread is broken.
+ */
+CPPU_DLLPUBLIC void SAL_CALL uno_releaseIdFromCurrentThread()
+ SAL_THROW_EXTERN_C();
+
+
+struct _uno_ThreadPool;
+typedef struct _uno_ThreadPool * uno_ThreadPool;
+
+/**
+ Creates a threadpool handle. Typically each remote bridge instances creates one
+ handle.
+ */
+CPPU_DLLPUBLIC uno_ThreadPool SAL_CALL
+uno_threadpool_create() SAL_THROW_EXTERN_C();
+
+
+/**
+ Makes the current thread known to the threadpool. This function must be
+ called, BEFORE uno_threadpool_enter() is called and BEFORE a job for this
+ thread is put into the threadpool (avoid a race between this thread and
+ an incoming request/reply).
+ For every call to uno_threadpool_attach, a corrosponding call to
+ uno_threadpool_detach must be done.
+
+ @param hPool The bridge threadpool handle previously created by uno_threadpool_create.
+
+*/
+CPPU_DLLPUBLIC void SAL_CALL
+uno_threadpool_attach( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C();
+
+/**
+ This method is called to wait for a reply of a previously sent request. This is a
+ blocking method. uno_threadpool_attach() must have been called before.
+
+ @param hPool the handle that was previously created by uno_threadpool_create().
+ @param ppJob [out] the pointer, that was given by uno_threadpool_putJob
+ 0, when uno_threadpool_dispose() was the reason to fall off from threadpool.
+ @see uno_threadpool_dispose()
+ **/
+CPPU_DLLPUBLIC void SAL_CALL
+uno_threadpool_enter( uno_ThreadPool hPool , void **ppJob )
+ SAL_THROW_EXTERN_C();
+
+/**
+ Detaches the current thread from the threadpool. Must be called for
+ every call to uno_threadpool_attach.
+ @param hPool the handle that was previously created by uno_threadpool_create().
+*/
+CPPU_DLLPUBLIC void SAL_CALL
+uno_threadpool_detach( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C();
+
+/**
+ Puts a job into the pool. A job may eiter be a request or a reply
+ (replies have a 0 in the doRequest parameter). This function is non-blocking.
+
+ A request may either be synchronous or asynchronous.
+ If the request is synchronous, it is first looked up,
+ if there exists a handle with the given
+ identifier. If this is the case, the thread is woken up and the doRequest
+ function is called with the given pJob. If no handle exists,
+ a new thread is created and the given threadId is bound to the new thread.
+
+ If the request is asynchronous, it is put into the queue of asynchronous
+ requests for the current threadid. The requests are always executed in a new
+ thread, even if the thread with the given id is waiting in the pool. No id is bound
+ to the newly created thread. The responsibilty is left to the bridge ( if it
+ wishes to bind a name).
+
+ If pJob is a reply, there MUST be a thread with the given threadId waiting
+ for this reply.
+
+ @param hPool the handle that was previously created by uno_threadpool_create().
+ @param pThreadId The Id of the thread, that initialized this request. (In general a
+ remote threadid).
+ @param pJob The argument, that doRequest will get or that will be returned by
+ uno_threadpool_enter().
+ @param doRequest The function, that shall be called to execute the request.
+ 0 if pJob is a reply.
+ @param bIsOneway True, if the request is asynchrons. False, if it is synchronous.
+ Set to sal_False, if pJob is a reply.
+ */
+CPPU_DLLPUBLIC void SAL_CALL
+uno_threadpool_putJob(
+ uno_ThreadPool hPool,
+ sal_Sequence *pThreadId,
+ void *pJob,
+ void ( SAL_CALL * doRequest ) ( void *pThreadSpecificData ),
+ sal_Bool bIsOneway ) SAL_THROW_EXTERN_C();
+
+/**
+ All threads, that are waiting on the hPool handle, are forced out of the pool.
+ The threads waiting with uno_threadpool_enter() will return with *ppJob == 0
+
+ Later calls to uno_threadpool_enter() using the hPool handle will also
+ return immeadiatly with *ppJob == 0.
+
+ @param hPool The handle to be disposed.
+
+ This function is called i.e. by a bridge, that is forced to dispose itself.
+ */
+CPPU_DLLPUBLIC void SAL_CALL
+uno_threadpool_dispose( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C();
+
+
+/** Releases the previously with uno_threadpool_create() created handle.
+ The handle thus becomes invalid. It is an error to use the handle after
+ uno_threadpool_destroy().
+
+ A call to uno_threadpool_destroy can synchronously join on spawned worker
+ threads, so this function must never be called from such a worker thread.
+
+ @see uno_threadpool_create()
+ */
+CPPU_DLLPUBLIC void SAL_CALL
+uno_threadpool_destroy( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */