[Libreoffice-commits] .: 3 commits - comphelper/inc comphelper/source tools/inc tools/source unusedcode.easy vcl/inc vcl/unx

Caolán McNamara caolan at kemper.freedesktop.org
Wed Feb 29 02:10:26 PST 2012


 comphelper/inc/comphelper/string.hxx |   26 +--------------------
 comphelper/source/misc/string.cxx    |   37 ++++++++++++++++++++++++++++++
 tools/inc/tools/stream.hxx           |    2 -
 tools/inc/tools/unqidx.hxx           |    6 ++---
 tools/source/memtools/unqidx.cxx     |   15 ------------
 tools/source/stream/strmunx.cxx      |   42 -----------------------------------
 unusedcode.easy                      |    6 -----
 vcl/inc/unx/sm.hxx                   |    1 
 vcl/unx/generic/app/sm.cxx           |   16 ++++++-------
 9 files changed, 51 insertions(+), 100 deletions(-)

New commits:
commit ab02fa6552fb098990e74f2787cf02b01c0e532b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 29 10:08:18 2012 +0000

    callcatcher: update list

diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index 82d322a..6482fdd 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -639,9 +639,9 @@ private:
     SvFileStream & operator= (const SvFileStream&);
 
     sal_Bool LockRange( sal_Size nByteOffset, sal_Size nBytes );
-    sal_Bool UnlockRange( sal_Size nByteOffset, sal_Size nBytes );
     sal_Bool LockFile();
 #ifdef WNT
+    sal_Bool UnlockRange( sal_Size nByteOffset, sal_Size nBytes );
     sal_Bool UnlockFile();
 #endif
 protected:
diff --git a/tools/inc/tools/unqidx.hxx b/tools/inc/tools/unqidx.hxx
index 715341c..1f806f9 100644
--- a/tools/inc/tools/unqidx.hxx
+++ b/tools/inc/tools/unqidx.hxx
@@ -46,6 +46,8 @@ private:
     sal_uIntPtr           nUniqIndex;
     sal_uIntPtr           nCount;
 
+    void*           Seek( sal_uIntPtr nIndex ); //not implemented
+
 public:
                     using Container::GetCurObject;
 
@@ -66,7 +68,6 @@ public:
     sal_uIntPtr           GetIndex( const void* p ) const;
     sal_Bool            IsIndexValid( sal_uIntPtr nIndex ) const;
 
-    void*           Seek( sal_uIntPtr nIndex );
     void*           Seek( void* p );
     void*           First();
     void*           Last();
@@ -98,6 +99,7 @@ inline void UniqueIndex::Clear()
 #define DECLARE_UNIQUEINDEX( ClassName, Type )                          \
 class ClassName : private UniqueIndex                                   \
 {                                                                       \
+    Type        Seek( sal_uIntPtr nKey );                               \
 public:                                                                 \
                 using UniqueIndex::Clear;                                       \
                 using UniqueIndex::Count;                                       \
@@ -126,8 +128,6 @@ public:                                                                 \
     sal_uIntPtr       GetIndex( const Type p ) const                          \
                     { return UniqueIndex::GetIndex( (const void*)p ); } \
                                                                         \
-    Type        Seek( sal_uIntPtr nKey )                                      \
-                    { return (Type)UniqueIndex::Seek( nKey ); }         \
     Type        Seek( Type p )                                          \
                     { return (Type)UniqueIndex::Seek( (void*)p ); }     \
     Type        First()  { return (Type)UniqueIndex::First(); }         \
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 6c5dc67..64e0b39 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -221,21 +221,6 @@ sal_Bool UniqueIndex::IsIndexValid( sal_uIntPtr nIndex ) const
 |*
 *************************************************************************/
 
-void* UniqueIndex::Seek( sal_uIntPtr nIndex )
-{
-    // Index-Eintrag als aktuellen setzten, wenn er gueltig ist
-    if ( IsIndexValid( nIndex ) )
-        return Container::Seek( nIndex-nStartIndex );
-    else
-        return NULL;
-}
-
-/*************************************************************************
-|*
-|*    UniqueIndex::Seek()
-|*
-*************************************************************************/
-
 void* UniqueIndex::Seek( void* p )
 {
     // Wird ein NULL-Pointer uebergeben, dann wurde Pointer nicht gefunden
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 9eb6b38..d001c6f 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -605,48 +605,6 @@ sal_Bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes )
 
 /*************************************************************************
 |*
-|*    SvFileStream::UnlockRange()
-|*
-*************************************************************************/
-
-sal_Bool SvFileStream::UnlockRange( sal_Size nByteOffset, sal_Size nBytes )
-{
-
-    struct flock aflock;
-    aflock.l_type = F_UNLCK;
-    aflock.l_start = nByteOffset;
-    aflock.l_whence = SEEK_SET;
-    aflock.l_len = nBytes;
-
-    if ( ! IsOpen() )
-        return sal_False;
-
-    InternalStreamLock::UnlockFile( nByteOffset, nByteOffset+nBytes, this );
-
-    if ( ! (eStreamMode &
-        (STREAM_SHARE_DENYALL | STREAM_SHARE_DENYREAD | STREAM_SHARE_DENYWRITE)))
-        return sal_True;
-
-    // wenn File Locking ausgeschaltet, siehe SvFileStream::LockRange
-    if ( ! pFileLockEnvVar )
-        return sal_True;
-
-    sal_IntPtr iFileHandle;
-    oslFileError rc = osl_getFileOSHandle(pInstanceData->rHandle, &iFileHandle);
-    if (rc != osl_File_E_None)
-    {
-        SetError( ::GetSvError( rc ));
-        return sal_False;
-    }
-    if (fcntl((int)iFileHandle, F_SETLK, &aflock) != -1)
-        return sal_True;
-
-    SetError( ::GetSvError( errno ));
-    return sal_False;
-}
-
-/*************************************************************************
-|*
 |*    SvFileStream::LockFile()
 |*
 *************************************************************************/
diff --git a/unusedcode.easy b/unusedcode.easy
index 14cd110..90cd389 100755
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -849,9 +849,6 @@ binfilter::SwpHtStart::Insert(binfilter::SwTxtAttr const*&, unsigned short&)
 binfilter::SwpHtStart::Insert(binfilter::SwTxtAttr const**, unsigned short)
 binfilter::SwpHtStart::Insert(binfilter::SwpHtStart const*, unsigned short, unsigned short)
 binfilter::SwpHtStart::Remove(binfilter::SwTxtAttr const*&, unsigned short)
-binfilter::UniqueIndex::Get(unsigned long) const
-binfilter::UniqueIndex::Insert(unsigned long, void*)
-binfilter::UniqueIndex::Seek(void*)
 binfilter::WritingDirectionInfos::Insert(binfilter::WritingDirectionInfos const*, unsigned short, unsigned short, unsigned short)
 binfilter::WritingDirectionInfos::Replace(binfilter::WritingDirectionInfo const&, unsigned short)
 binfilter::WritingDirectionInfos::Replace(binfilter::WritingDirectionInfo const*, unsigned short, unsigned short)
@@ -1057,9 +1054,6 @@ oox::xls::BiffDrawingBase::setSkipObj(unsigned short)
 oox::xls::BiffDrawingObjectBase::importObjBiff8(oox::xls::WorksheetHelper const&, oox::xls::BiffInputStream&)
 oox::xls::BiffHelper::calcCodePageFromTextEncoding(unsigned short)
 oox::xls::BiffHelper::calcRkFromDouble(int&, double)
-oox::xls::BiffInputStream::sizeBase() const
-oox::xls::BiffInputStream::skipByteString(bool)
-oox::xls::BiffInputStream::skipUniString()
 oox::xls::BiffOutputStream::BiffOutputStream(oox::BinaryOutputStream&, unsigned short)
 oox::xls::BiffOutputStream::endRecord()
 oox::xls::BiffOutputStream::fill(unsigned char, int, unsigned long)
commit f57cd61004e5a36749f54a5e368becd756d17668
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 29 09:06:13 2012 +0000

    SessionManagerClient is never instantiated
    
    the "pThis" is a hack to smuggle an argument into a static method,
    its not actually a SessionManagerClient instance, clarify the code
    around that

diff --git a/vcl/inc/unx/sm.hxx b/vcl/inc/unx/sm.hxx
index 3af55f5..0dfc463 100644
--- a/vcl/inc/unx/sm.hxx
+++ b/vcl/inc/unx/sm.hxx
@@ -64,7 +64,6 @@ class SessionManagerClient
     DECL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void* );
     DECL_STATIC_LINK( SessionManagerClient, InteractionHdl, void* );
 public:
-    SessionManagerClient();
     static VCLPLUG_GEN_PUBLIC void open(); // needed by other plugins, so export
     static void close();
 
diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx
index 75af64c..82fd4b1 100644
--- a/vcl/unx/generic/app/sm.cxx
+++ b/vcl/unx/generic/app/sm.cxx
@@ -242,11 +242,6 @@ static void BuildSmPropertyList()
     }
 }
 
-SessionManagerClient::SessionManagerClient()
-{
-    SAL_INFO("vcl.sm","SessionManagerClient::SessionManagerClient()");
-}
-
 bool SessionManagerClient::checkDocumentsSaved()
 {
     return bDocSaveDone;
@@ -254,10 +249,14 @@ bool SessionManagerClient::checkDocumentsSaved()
 
 IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG )
 {
-    SAL_INFO("vcl.sm", "posting save documents event shutdown = " << ((pThis!=0) ? "true" : "false" ));
+    //decode argument smuggled in by abusing pThis member of SessionManagerClient
+    sal_uIntPtr nStateVal = (sal_uIntPtr)pThis;
+    Bool shutdown = nStateVal != 0;
+
+    SAL_INFO("vcl.sm", "posting save documents event shutdown = " << (shutdown ? "true" : "false" ));
 
     static bool bFirstShutdown=true;
-    if (pThis != 0 && bFirstShutdown) //first shutdown request
+    if (shutdown && bFirstShutdown) //first shutdown request
     {
         bFirstShutdown = false;
         /*
@@ -282,7 +281,7 @@ IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG )
 
     if( pOneInstance )
     {
-        SalSessionSaveRequestEvent aEvent( pThis != 0, false );
+        SalSessionSaveRequestEvent aEvent( shutdown, false );
         pOneInstance->CallCallback( &aEvent );
     }
     else
@@ -348,6 +347,7 @@ void SessionManagerClient::SaveYourselfProc(
         SessionManagerClient::saveDone();
         return;
     }
+    //Smuggle argument in by abusing pThis member of SessionManagerClient
     sal_uIntPtr nStateVal = shutdown ? 0xffffffff : 0x0;
     Application::PostUserEvent( STATIC_LINK( (void*)nStateVal, SessionManagerClient, SaveYourselfHdl ) );
     SAL_INFO("vcl.sm", "waiting for save yourself event to be processed" );
commit 53294e814bb8ac5f28a57f1f325311fa05112d12
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 28 21:07:40 2012 +0000

    move template out of header

diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index f52021d..a64bad2 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -46,22 +46,6 @@
 // go into the stable URE API:
 namespace comphelper { namespace string {
 
-namespace detail
-{
-    template <typename T, typename U> T* string_alloc(sal_Int32 nLen)
-    {
-        //Clearly this is somewhat cosy with the sal implmentation
-
-        //rtl_[u]String contains U buffer[1], so an input of nLen
-        //allocates a buffer of nLen + 1 and we'll ensure a null termination
-        T *newStr = (T*)rtl_allocateMemory(sizeof(T) + sizeof(U) * nLen);
-        newStr->refCount = 1;
-        newStr->length = nLen;
-        newStr->buffer[nLen]=0;
-        return newStr;
-    }
-}
-
 /** 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
@@ -82,10 +66,7 @@ namespace detail
     @param len
     the number of characters.
  */
-COMPHELPER_DLLPUBLIC inline rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen)
-{
-    return detail::string_alloc<rtl_uString, sal_Unicode>(nLen);
-}
+COMPHELPER_DLLPUBLIC rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen);
 
 /** Allocate a new string containing space for a given number of characters.
 
@@ -107,10 +88,7 @@ COMPHELPER_DLLPUBLIC inline rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 n
     @param len
     the number of characters.
  */
-COMPHELPER_DLLPUBLIC inline rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen)
-{
-    return detail::string_alloc<rtl_String, sal_Char>(nLen);
-}
+COMPHELPER_DLLPUBLIC rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen);
 
 /** Removes all occurrences of a character from within the source string
 
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 3547de6..6eb744f 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -401,6 +401,43 @@ bool isdigitAsciiString(const rtl::OUString &rString)
     return tmpl_is_OPER_AsciiString<isdigitAscii>(rString);
 }
 
+namespace
+{
+    template <typename T, typename U> T* string_alloc(sal_Int32 nLen)
+    {
+        //Clearly this is somewhat cosy with the sal implmentation
+
+        //rtl_[u]String contains U buffer[1], so an input of nLen
+        //allocates a buffer of nLen + 1 and we'll ensure a null termination
+
+        T* newStr =
+            (sal::static_int_cast< sal_uInt32 >(nLen)
+               <= ((SAL_MAX_UINT32 - sizeof (T))
+                   / sizeof (U)))
+            ? (T*) rtl_allocateMemory(
+                sizeof (T) + nLen * sizeof (U))
+            : NULL;
+
+        if (!newStr)
+            throw std::bad_alloc();
+
+        newStr->refCount = 1;
+        newStr->length = nLen;
+        newStr->buffer[nLen] = 0;
+        return newStr;
+    }
+}
+
+rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen)
+{
+    return string_alloc<rtl_uString, sal_Unicode>(nLen);
+}
+
+rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen)
+{
+    return string_alloc<rtl_String, sal_Char>(nLen);
+}
+
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list