comphelper/source/streaming/seqinputstreamserv.cxx |   39 ++++++++++++---------
 cppuhelper/source/propshlp.cxx                     |    4 +-
 2 files changed, 27 insertions(+), 16 deletions(-)

New commits:
commit f8deb64c3c1d5baa8532a92bc16d1712f42aaa12
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Sep 5 11:38:27 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Sep 5 13:51:34 2024 +0200

    throw more useful exception from OPropertySetHelper::getPropertyValue
    
    Change-Id: I90e7ab5763bf368cec795a8c39ece17579dd851d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172905
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx
index fd4e4808da35..8a864e1bad6a 100644
--- a/cppuhelper/source/propshlp.cxx
+++ b/cppuhelper/source/propshlp.cxx
@@ -273,6 +273,8 @@ Any OPropertySetHelper::getPropertyValue(
     IPropertyArrayHelper & rPH = getInfoHelper();
     // map the name to the handle
     sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+    if (nHandle == -1)
+        throw UnknownPropertyException(rPropertyName);
     // call the method of the XFastPropertySet interface
     return getFastPropertyValue( nHandle );
 }
@@ -545,8 +547,8 @@ void OPropertySetHelper::setFastPropertyValue( sal_Int32 
nHandle, const Any& rVa
 
 // XFastPropertySet
 Any OPropertySetHelper::getFastPropertyValue( sal_Int32 nHandle )
-
 {
+    assert(nHandle != -1 && "passing -1 here indicates that the caller knows 
this is not a valid handle");
     IPropertyArrayHelper & rInfo = getInfoHelper();
     if( !rInfo.fillPropertyMembersByHandle( nullptr, nullptr, nHandle ) )
         // unknown property
commit 6d6422b3ff0c3b252f87f76f1777a357aafeaea7
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Sep 5 12:10:50 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Sep 5 13:51:25 2024 +0200

    tdf#162772 Crash in "Target in Document" in Hyperlink dialog
    
    regression from
        commit a6ad198d097fb4a503c8d5831d484ff46721134b
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Sat Aug 17 13:19:54 2024 +0200
        tdf#158556 use more comphelper::ByteReader
    
    Change-Id: I7343159d5e3ec7619ba95a98417fd3b4e25dbf6c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172906
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/comphelper/source/streaming/seqinputstreamserv.cxx 
b/comphelper/source/streaming/seqinputstreamserv.cxx
index 93d421f40fe6..29b5cbbe3e7e 100644
--- a/comphelper/source/streaming/seqinputstreamserv.cxx
+++ b/comphelper/source/streaming/seqinputstreamserv.cxx
@@ -28,6 +28,8 @@
 #include <com/sun/star/io/XSeekableInputStream.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/frame/DoubleInitializationException.hpp>
+#include <comphelper/bytereader.hxx>
+#include <rtl/ref.hxx>
 #include <mutex>
 
 namespace com::sun::star::uno { class XComponentContext; }
@@ -40,7 +42,8 @@ class SequenceInputStreamService:
     public ::cppu::WeakImplHelper<
         lang::XServiceInfo,
         io::XSeekableInputStream,
-        lang::XInitialization>
+        lang::XInitialization>,
+    public comphelper::ByteReader
 {
 public:
     explicit SequenceInputStreamService();
@@ -69,14 +72,16 @@ public:
     // css::lang::XInitialization:
     virtual void SAL_CALL initialize( const uno::Sequence< css::uno::Any > & 
aArguments ) override;
 
+    // comphelper::ByteReader
+    virtual sal_Int32 readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead) 
override;
+
 private:
     virtual ~SequenceInputStreamService() override {}
 
 
     std::mutex m_aMutex;
     bool m_bInitialized;
-    uno::Reference< io::XInputStream > m_xInputStream;
-    uno::Reference< io::XSeekable > m_xSeekable;
+    rtl::Reference< comphelper::SequenceInputStream > m_xInputStream;
 };
 
 SequenceInputStreamService::SequenceInputStreamService()
@@ -118,6 +123,15 @@ uno::Sequence< OUString > SAL_CALL 
SequenceInputStreamService::getSupportedServi
     return m_xInputStream->readSomeBytes( aData, nMaxBytesToRead );
 }
 
+::sal_Int32 SequenceInputStreamService::readSomeBytes( sal_Int8* aData, 
sal_Int32 nMaxBytesToRead )
+{
+    std::scoped_lock aGuard( m_aMutex );
+    if ( !m_xInputStream.is() )
+        throw io::NotConnectedException();
+
+    return m_xInputStream->readSomeBytes( aData, nMaxBytesToRead );
+}
+
 void SAL_CALL SequenceInputStreamService::skipBytes( ::sal_Int32 nBytesToSkip )
 {
     std::scoped_lock aGuard( m_aMutex );
@@ -144,35 +158,34 @@ void SAL_CALL SequenceInputStreamService::closeInput()
 
     m_xInputStream->closeInput();
     m_xInputStream.clear();
-    m_xSeekable.clear();
 }
 
 // css::io::XSeekable:
 void SAL_CALL SequenceInputStreamService::seek( ::sal_Int64 location )
 {
     std::scoped_lock aGuard( m_aMutex );
-    if ( !m_xSeekable.is() )
+    if ( !m_xInputStream.is() )
         throw io::NotConnectedException();
 
-    m_xSeekable->seek( location );
+    m_xInputStream->seek( location );
 }
 
 ::sal_Int64 SAL_CALL SequenceInputStreamService::getPosition()
 {
     std::scoped_lock aGuard( m_aMutex );
-    if ( !m_xSeekable.is() )
+    if ( !m_xInputStream.is() )
         throw io::NotConnectedException();
 
-    return m_xSeekable->getPosition();
+    return m_xInputStream->getPosition();
 }
 
 ::sal_Int64 SAL_CALL SequenceInputStreamService::getLength()
 {
     std::scoped_lock aGuard( m_aMutex );
-    if ( !m_xSeekable.is() )
+    if ( !m_xInputStream.is() )
         throw io::NotConnectedException();
 
-    return m_xSeekable->getLength();
+    return m_xInputStream->getLength();
 }
 
 // css::lang::XInitialization:
@@ -193,11 +206,7 @@ void SAL_CALL SequenceInputStreamService::initialize( 
const uno::Sequence< css::
                                             static_cast< ::cppu::OWeakObject* 
>(this),
                                             1 );
 
-    uno::Reference< io::XInputStream > xInputStream(
-                    static_cast< ::cppu::OWeakObject* >( new 
::comphelper::SequenceInputStream( aSeq ) ),
-                    uno::UNO_QUERY_THROW );
-    m_xSeekable.set(xInputStream, uno::UNO_QUERY_THROW);
-    m_xInputStream = xInputStream;
+    m_xInputStream = new ::comphelper::SequenceInputStream( aSeq );
     m_bInitialized = true;
 }
 

Reply via email to