diff options
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/processfactory.hxx | 11 | ||||
-rw-r--r-- | comphelper/inc/comphelper/stl_types.hxx | 54 | ||||
-rw-r--r-- | comphelper/inc/comphelper/stlunosequence.hxx | 6 | ||||
-rw-r--r-- | comphelper/inc/comphelper/storagehelper.hxx | 3 | ||||
-rw-r--r-- | comphelper/source/misc/documentiologring.cxx | 175 | ||||
-rw-r--r-- | comphelper/source/misc/documentiologring.hxx | 92 | ||||
-rw-r--r-- | comphelper/source/misc/makefile.mk | 1 | ||||
-rw-r--r-- | comphelper/source/misc/string.cxx | 27 | ||||
-rw-r--r-- | comphelper/source/misc/types.cxx | 11 | ||||
-rw-r--r-- | comphelper/source/misc/uieventslogger.cxx | 3 | ||||
-rw-r--r-- | comphelper/source/processfactory/processfactory.cxx | 20 | ||||
-rw-r--r-- | comphelper/source/property/propertybag.cxx | 5 | ||||
-rw-r--r-- | comphelper/source/property/propertycontainerhelper.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/streaming/memorystream.cxx | 29 |
14 files changed, 397 insertions, 44 deletions
diff --git a/comphelper/inc/comphelper/processfactory.hxx b/comphelper/inc/comphelper/processfactory.hxx index d2ae887ba341..9b24f8e784ac 100644 --- a/comphelper/inc/comphelper/processfactory.hxx +++ b/comphelper/inc/comphelper/processfactory.hxx @@ -79,10 +79,19 @@ COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XI const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArgs ) SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) ); +/** + * This function gets the process service factory's default component context. + * If no service factory is set the function returns a null interface. + */ +COMPHELPER_DLLPUBLIC +::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > +getProcessComponentContext(); + } + extern "C" { -/// @internal +/// @internal ATTENTION returns ACQUIRED pointer! release it explicitly! COMPHELPER_DLLPUBLIC ::com::sun::star::uno::XComponentContext * comphelper_getProcessComponentContext(); diff --git a/comphelper/inc/comphelper/stl_types.hxx b/comphelper/inc/comphelper/stl_types.hxx index aeb6342048c9..4b3126043a08 100644 --- a/comphelper/inc/comphelper/stl_types.hxx +++ b/comphelper/inc/comphelper/stl_types.hxx @@ -49,6 +49,7 @@ #include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -192,6 +193,59 @@ inline mem_fun1_t<_Tp,_Arg> mem_fun(void (_Tp::*__f)(_Arg)) } //......................................................................... +/** output iterator that appends OUStrings into an OUStringBuffer. + */ +class OUStringBufferAppender : + public ::std::iterator< ::std::output_iterator_tag, void, void, void, void> +{ +public: + typedef OUStringBufferAppender Self; + typedef ::std::output_iterator_tag iterator_category; + typedef void value_type; + typedef void reference; + typedef void pointer; + typedef size_t difference_type; + + OUStringBufferAppender(::rtl::OUStringBuffer & i_rBuffer) + : m_rBuffer(i_rBuffer) { } + Self & operator=(::rtl::OUString const & i_rStr) + { + m_rBuffer.append( i_rStr ); + return *this; + } + Self & operator*() { return *this; } // so operator= works + Self & operator++() { return *this; } + Self & operator++(int) { return *this; } + +private: + ::rtl::OUStringBuffer & m_rBuffer; +}; + +//......................................................................... +/** algorithm similar to std::copy, but inserts a separator between elements. + */ +template< typename ForwardIter, typename OutputIter, typename T > +OutputIter intersperse( + ForwardIter start, ForwardIter end, OutputIter out, T const & separator) +{ + if (start != end) { + *out = *start; + ++start; + ++out; + } + + while (start != end) { + *out = separator; + ++out; + *out = *start; + ++start; + ++out; + } + + return out; +} + +//......................................................................... } //... namespace comphelper ................................................ diff --git a/comphelper/inc/comphelper/stlunosequence.hxx b/comphelper/inc/comphelper/stlunosequence.hxx index 2ffe08cb6b75..a0ace84e8a6e 100644 --- a/comphelper/inc/comphelper/stlunosequence.hxx +++ b/comphelper/inc/comphelper/stlunosequence.hxx @@ -312,7 +312,8 @@ namespace comphelper { namespace stlunosequence { template<typename S, typename V> inline typename StlSequence<S,V>::iterator StlSequence<S,V>::begin() { - return typename StlSequence<S,V>::iterator(m_UnoSequence, begin_of_sequence); + return typename StlSequence<S,V>::iterator(m_UnoSequence, + size() ? begin_of_sequence : end_of_sequence); } template<typename S, typename V> @@ -324,7 +325,8 @@ namespace comphelper { namespace stlunosequence { template<typename S, typename V> inline typename StlSequence<S,V>::const_iterator StlSequence<S,V>::begin() const { - return typename StlSequence<S,V>::const_iterator(m_UnoSequence, begin_of_sequence); + return typename StlSequence<S,V>::const_iterator(m_UnoSequence, + size() ? begin_of_sequence : end_of_sequence); } template<typename S, typename V> diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx index b99f7e1233ca..efb5431959ba 100644 --- a/comphelper/inc/comphelper/storagehelper.hxx +++ b/comphelper/inc/comphelper/storagehelper.hxx @@ -48,9 +48,6 @@ namespace comphelper { -sal_Bool COMPHELPER_DLLPUBLIC IsValidZipEntryFileName( - const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed ); - class COMPHELPER_DLLPUBLIC OStorageHelper { public: diff --git a/comphelper/source/misc/documentiologring.cxx b/comphelper/source/misc/documentiologring.cxx new file mode 100644 index 000000000000..7969b938e108 --- /dev/null +++ b/comphelper/source/misc/documentiologring.cxx @@ -0,0 +1,175 @@ +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: documentiologring.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_comphelper.hxx"
+
+#include <com/sun/star/frame/DoubleInitializationException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+#include "documentiologring.hxx"
+
+using namespace ::com::sun::star;
+
+namespace comphelper
+{
+
+// ----------------------------------------------------------
+OSimpleLogRing::OSimpleLogRing( const uno::Reference< uno::XComponentContext >& /*xContext*/ )
+: m_aMessages( SIMPLELOGRING_SIZE )
+, m_bInitialized( sal_False )
+, m_bFull( sal_False )
+, m_nPos( 0 )
+{
+}
+
+// ----------------------------------------------------------
+OSimpleLogRing::~OSimpleLogRing()
+{
+}
+
+// ----------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::impl_staticGetSupportedServiceNames()
+{
+ uno::Sequence< rtl::OUString > aResult( 1 );
+ aResult[0] = impl_staticGetServiceName();
+ return aResult;
+}
+
+// ----------------------------------------------------------
+::rtl::OUString SAL_CALL OSimpleLogRing::impl_staticGetImplementationName()
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.logging.SimpleLogRing" ) );
+}
+
+// ----------------------------------------------------------
+::rtl::OUString SAL_CALL OSimpleLogRing::impl_staticGetSingletonName()
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.DocumentIOLogRing" ) );
+}
+
+// ----------------------------------------------------------
+::rtl::OUString SAL_CALL OSimpleLogRing::impl_staticGetServiceName()
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.SimpleLogRing" ) );
+}
+
+// ----------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL OSimpleLogRing::impl_staticCreateSelfInstance( const uno::Reference< uno::XComponentContext >& rxContext )
+{
+ return static_cast< cppu::OWeakObject* >( new OSimpleLogRing( rxContext ) );
+}
+
+// XSimpleLogRing
+// ----------------------------------------------------------
+void SAL_CALL OSimpleLogRing::logString( const ::rtl::OUString& aMessage ) throw (uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_aMessages[m_nPos] = aMessage;
+ if ( ++m_nPos >= m_aMessages.getLength() )
+ {
+ m_nPos = 0;
+ m_bFull = sal_True;
+ }
+
+ // if used once then default initialized
+ m_bInitialized = sal_True;
+}
+
+// ----------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getCollectedLog() throw (uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Int32 nResLen = m_bFull ? m_aMessages.getLength() : m_nPos;
+ sal_Int32 nStart = m_bFull ? m_nPos : 0;
+ uno::Sequence< ::rtl::OUString > aResult( nResLen );
+
+ for ( sal_Int32 nInd = 0; nInd < nResLen; nInd++ )
+ aResult[nInd] = m_aMessages[ ( nStart + nInd ) % m_aMessages.getLength() ];
+
+ // if used once then default initialized
+ m_bInitialized = sal_True;
+
+ return aResult;
+}
+
+// XInitialization
+// ----------------------------------------------------------
+void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_bInitialized )
+ throw frame::DoubleInitializationException();
+
+ if ( !m_refCount )
+ throw uno::RuntimeException(); // the object must be refcounted already!
+
+ sal_Int32 nLen = 0;
+ if ( aArguments.getLength() == 1 && ( aArguments[0] >>= nLen ) && nLen )
+ m_aMessages.realloc( nLen );
+ else
+ throw lang::IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Nonnull size is expected as the first argument!" ) ),
+ uno::Reference< uno::XInterface >(),
+ 0 );
+
+ m_bInitialized = sal_True;
+}
+
+// XServiceInfo
+// ----------------------------------------------------------
+::rtl::OUString SAL_CALL OSimpleLogRing::getImplementationName() throw (uno::RuntimeException)
+{
+ return impl_staticGetImplementationName();
+}
+
+// ----------------------------------------------------------
+::sal_Bool SAL_CALL OSimpleLogRing::supportsService( const ::rtl::OUString& aServiceName ) throw (uno::RuntimeException)
+{
+ const uno::Sequence< rtl::OUString > & aSupportedNames = impl_staticGetSupportedServiceNames();
+ for ( sal_Int32 nInd = 0; nInd < aSupportedNames.getLength(); nInd++ )
+ {
+ if ( aSupportedNames[ nInd ].equals( aServiceName ) )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+// ----------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return impl_staticGetSupportedServiceNames();
+}
+
+} // namespace comphelper
+
diff --git a/comphelper/source/misc/documentiologring.hxx b/comphelper/source/misc/documentiologring.hxx new file mode 100644 index 000000000000..ae7d2a6eaf19 --- /dev/null +++ b/comphelper/source/misc/documentiologring.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: documentiologring.hxx,v $ + * $Revision: 1.0 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __DOCUMENTIOLOGRING_HXX_ +#define __DOCUMENTIOLOGRING_HXX_ + +#include <com/sun/star/logging/XSimpleLogRing.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> + +#include <osl/mutex.hxx> +#include <cppuhelper/implbase3.hxx> + +#define SIMPLELOGRING_SIZE 256 + +namespace comphelper +{ + +class OSimpleLogRing : public ::cppu::WeakImplHelper3< ::com::sun::star::logging::XSimpleLogRing, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::lang::XServiceInfo > +{ + ::osl::Mutex m_aMutex; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aMessages; + + sal_Bool m_bInitialized; + sal_Bool m_bFull; + sal_Int32 m_nPos; + +public: + OSimpleLogRing( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); + virtual ~OSimpleLogRing(); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + impl_staticGetSupportedServiceNames(); + + static ::rtl::OUString SAL_CALL impl_staticGetImplementationName(); + + static ::rtl::OUString SAL_CALL impl_staticGetSingletonName(); + + static ::rtl::OUString SAL_CALL impl_staticGetServiceName(); + + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + impl_staticCreateSelfInstance( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); + +// XSimpleLogRing + virtual void SAL_CALL logString( const ::rtl::OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCollectedLog() throw (::com::sun::star::uno::RuntimeException); + +// XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + +// XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + +}; + +} // namespace comphelper + +#endif + diff --git a/comphelper/source/misc/makefile.mk b/comphelper/source/misc/makefile.mk index 1d473e6c5365..f50f57c47eb3 100644 --- a/comphelper/source/misc/makefile.mk +++ b/comphelper/source/misc/makefile.mk @@ -58,6 +58,7 @@ SLOFILES= \ $(SLO)$/componentmodule.obj \ $(SLO)$/configurationhelper.obj \ $(SLO)$/documentinfo.obj \ + $(SLO)$/documentiologring.obj \ $(SLO)$/evtlistenerhlp.obj \ $(SLO)$/ihwrapnofilter.obj \ $(SLO)$/instancelocker.obj \ diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index 77a251372d85..e9437528b0de 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -36,10 +36,13 @@ #include <vector> #include <algorithm> -#include "comphelper/string.hxx" -#include "rtl/ustring.hxx" -#include "sal/types.h" -#include "comphelper/stlunosequence.hxx" +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include <sal/types.h> + +#include <comphelper/string.hxx> +#include <comphelper/stlunosequence.hxx> +#include <comphelper/stl_types.hxx> namespace comphelper { namespace string { @@ -96,12 +99,12 @@ rtl::OUString searchAndReplaceAsciiL( ::rtl::OUString convertCommaSeparated( ::com::sun::star::uno::Sequence< ::rtl::OUString > const& i_rSeq) { - ::rtl::OUString ret; - for (sal_Int32 i = 0; i < i_rSeq.getLength(); ++i) { - if (i != 0) ret += ::rtl::OUString::createFromAscii(", "); - ret += i_rSeq[i]; - } - return ret; + ::rtl::OUStringBuffer buf; + ::comphelper::intersperse( + ::comphelper::stl_begin(i_rSeq), ::comphelper::stl_end(i_rSeq), + ::comphelper::OUStringBufferAppender(buf), + ::rtl::OUString::createFromAscii(", ")); + return buf.makeStringAndClear(); } ::com::sun::star::uno::Sequence< ::rtl::OUString > @@ -119,10 +122,6 @@ rtl::OUString searchAndReplaceAsciiL( } while (idx >= 0); ::com::sun::star::uno::Sequence< ::rtl::OUString > kws(vec.size()); std::copy(vec.begin(), vec.end(), stl_begin(kws)); - /* - for (size_t i = 0; i < vec.size(); ++i) { - kws[i] = vec.at(i); - }*/ return kws; } diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx index 2b20fd9acca3..2a9180c038b0 100644 --- a/comphelper/source/misc/types.cxx +++ b/comphelper/source/misc/types.cxx @@ -87,8 +87,7 @@ sal_Bool operator ==(const Time& _rLeft, const Time& _rRight) sal_Int32 getINT32(const Any& _rAny) { sal_Int32 nReturn = 0; - _rAny >>= nReturn; - + OSL_VERIFY( _rAny >>= nReturn ); return nReturn; } @@ -96,7 +95,7 @@ sal_Int32 getINT32(const Any& _rAny) sal_Int16 getINT16(const Any& _rAny) { sal_Int16 nReturn = 0; - _rAny >>= nReturn; + OSL_VERIFY( _rAny >>= nReturn ); return nReturn; } @@ -104,7 +103,7 @@ sal_Int16 getINT16(const Any& _rAny) double getDouble(const Any& _rAny) { double nReturn = 0.0; - _rAny >>= nReturn; + OSL_VERIFY( _rAny >>= nReturn ); return nReturn; } @@ -112,7 +111,7 @@ double getDouble(const Any& _rAny) float getFloat(const Any& _rAny) { float nReturn = 0.0; - _rAny >>= nReturn; + OSL_VERIFY( _rAny >>= nReturn ); return nReturn; } @@ -120,7 +119,7 @@ float getFloat(const Any& _rAny) ::rtl::OUString getString(const Any& _rAny) { ::rtl::OUString nReturn; - _rAny >>= nReturn; + OSL_VERIFY( _rAny >>= nReturn ); return nReturn; } diff --git a/comphelper/source/misc/uieventslogger.cxx b/comphelper/source/misc/uieventslogger.cxx index 3ff875a4e67d..a55d5b58854d 100644 --- a/comphelper/source/misc/uieventslogger.cxx +++ b/comphelper/source/misc/uieventslogger.cxx @@ -375,9 +375,10 @@ namespace comphelper } else logdata[2] = UNKNOWN_ORIGIN; - logdata[3] = url.Complete; if(url.Complete.match(URL_FILE)) logdata[3] = URL_FILE; + else + logdata[3] = url.Main; m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata)); m_SessionLogEventCount++; } diff --git a/comphelper/source/processfactory/processfactory.cxx b/comphelper/source/processfactory/processfactory.cxx index 0f50f4a4cb01..c4eac583e3c0 100644 --- a/comphelper/source/processfactory/processfactory.cxx +++ b/comphelper/source/processfactory/processfactory.cxx @@ -98,24 +98,30 @@ Reference< XInterface > createProcessComponentWithArguments( const ::rtl::OUStri return xComponent; } -} // namesapce comphelper - -extern "C" { -uno::XComponentContext * comphelper_getProcessComponentContext() +Reference< XComponentContext > getProcessComponentContext() { - uno::Reference<uno::XComponentContext> xRet; + Reference< XComponentContext > xRet; uno::Reference<beans::XPropertySet> const xProps( comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); if (xProps.is()) { try { - xRet.set( xProps->getPropertyValue( - rtl::OUString( + xRet.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ), uno::UNO_QUERY ); } catch (beans::UnknownPropertyException const&) { } } + return xRet; +} + +} // namespace comphelper + +extern "C" { +uno::XComponentContext * comphelper_getProcessComponentContext() +{ + uno::Reference<uno::XComponentContext> xRet; + xRet = ::comphelper::getProcessComponentContext(); if (xRet.is()) xRet->acquire(); return xRet.get(); diff --git a/comphelper/source/property/propertybag.cxx b/comphelper/source/property/propertybag.cxx index a56793e05769..383e1cc2c5aa 100644 --- a/comphelper/source/property/propertybag.cxx +++ b/comphelper/source/property/propertybag.cxx @@ -168,10 +168,11 @@ namespace comphelper // will throw an UnknownPropertyException if necessary if ( ( rProp.Attributes & PropertyAttribute::REMOVEABLE ) == 0 ) throw NotRemoveableException( ::rtl::OUString(), NULL ); + const sal_Int32 nHandle = rProp.Handle; - revokeProperty( rProp.Handle ); + revokeProperty( nHandle ); - m_pImpl->aDefaults.erase( rProp.Handle ); + m_pImpl->aDefaults.erase( nHandle ); } //-------------------------------------------------------------------- diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index 9d1662d1ecf2..7f5db1d6cf7e 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -76,12 +76,12 @@ namespace // comparing two property descriptions (by name) struct PropertyDescriptionNameMatch : public ::std::unary_function< PropertyDescription, bool > { - const ::rtl::OUString& m_rCompare; + ::rtl::OUString m_rCompare; PropertyDescriptionNameMatch( const ::rtl::OUString& _rCompare ) : m_rCompare( _rCompare ) { } bool operator() (const PropertyDescription& x ) const { - return x.aProperty.Name == m_rCompare; + return x.aProperty.Name.equals(m_rCompare); } }; } diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx index 3afd9b555a84..a2baef21010e 100644 --- a/comphelper/source/streaming/memorystream.cxx +++ b/comphelper/source/streaming/memorystream.cxx @@ -35,15 +35,16 @@ #include <com/sun/star/io/XStream.hpp> #include <com/sun/star/io/XSeekableInputStream.hpp> +#include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> #include <string.h> #include <vector> using ::rtl::OUString; using ::cppu::OWeakObject; -using ::cppu::WeakImplHelper3; +using ::cppu::WeakImplHelper4; using namespace ::com::sun::star::io; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -52,7 +53,7 @@ using namespace ::osl; namespace comphelper { -class UNOMemoryStream : public WeakImplHelper3 < XStream, XSeekableInputStream, XOutputStream > +class UNOMemoryStream : public WeakImplHelper4 < XStream, XSeekableInputStream, XOutputStream, XTruncate > { public: UNOMemoryStream(); @@ -79,6 +80,9 @@ public: virtual void SAL_CALL flush() throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException); virtual void SAL_CALL closeOutput() throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException); + // XTruncate + virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + // XServiceInfo - static versions (used for component registration) static ::rtl::OUString SAL_CALL getImplementationName_static(); static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static(); @@ -116,8 +120,7 @@ sal_Int32 SAL_CALL UNOMemoryStream::readBytes( Sequence< sal_Int8 >& aData, sal_ throw IOException(); nBytesToRead = std::min( nBytesToRead, available() ); - if( aData.getLength() < nBytesToRead ) - aData.realloc( nBytesToRead ); + aData.realloc( nBytesToRead ); if( nBytesToRead ) { @@ -157,9 +160,16 @@ void SAL_CALL UNOMemoryStream::closeInput() throw (NotConnectedException, IOExce // XSeekable void SAL_CALL UNOMemoryStream::seek( sal_Int64 location ) throw (IllegalArgumentException, IOException, RuntimeException) { - if( (location < 0) || (location > SAL_MAX_INT32) || (location > static_cast< sal_Int64 >( maData.size() )) ) + if( (location < 0) || (location > SAL_MAX_INT32) ) throw IllegalArgumentException( OUString(RTL_CONSTASCII_USTRINGPARAM("this implementation does not support more than 2GB!")), Reference< XInterface >(static_cast<OWeakObject*>(this)), 0 ); + // seek operation should be able to resize the stream + if ( location > static_cast< sal_Int64 >( maData.size() ) ) + maData.resize( static_cast< sal_Int32 >( location ) ); + + if ( location > static_cast< sal_Int64 >( maData.size() ) ) + maData.resize( static_cast< sal_Int32 >( location ) ); + mnCursor = static_cast< sal_Int32 >( location ); } @@ -206,6 +216,13 @@ void SAL_CALL UNOMemoryStream::closeOutput() throw (NotConnectedException, Buffe mnCursor = 0; } +//XTruncate +void SAL_CALL UNOMemoryStream::truncate() throw (IOException, RuntimeException) +{ + maData.resize( 0 ); + mnCursor = 0; +} + ::rtl::OUString SAL_CALL UNOMemoryStream::getImplementationName_static() { static const OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.MemoryStream" ) ); |