[Libreoffice-commits] core.git: compilerplugins/clang include/tools tools/source

Noel Grandin noel at peralex.com
Fri Mar 4 11:20:34 UTC 2016


 compilerplugins/clang/unuseddefaultparams.cxx |    2 
 include/tools/multisel.hxx                    |    2 
 include/tools/stream.hxx                      |    2 
 include/tools/urlobj.hxx                      |   65 +++++++++-----------------
 tools/source/fsys/urlobj.cxx                  |   37 ++++++--------
 tools/source/memtools/multisel.cxx            |   22 ++------
 tools/source/stream/stream.cxx                |    5 +-
 7 files changed, 52 insertions(+), 83 deletions(-)

New commits:
commit 46c67c43236a8250e56d6af1a1caada73e8abb70
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Mar 4 12:20:58 2016 +0200

    loplugin:unuseddefaultparam in tools
    
    Change-Id: I027f4d53e3aa793bd61bf110899e464a9b6430ec
    Reviewed-on: https://gerrit.libreoffice.org/22891
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/compilerplugins/clang/unuseddefaultparams.cxx b/compilerplugins/clang/unuseddefaultparams.cxx
index e8b99d3..8074e51 100644
--- a/compilerplugins/clang/unuseddefaultparams.cxx
+++ b/compilerplugins/clang/unuseddefaultparams.cxx
@@ -240,7 +240,7 @@ bool UnusedDefaultParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
     return true;
 }
 
-loplugin::Plugin::Registration< UnusedDefaultParams > X("unuseddefaultparams", false);
+loplugin::Plugin::Registration< UnusedDefaultParams > X("unuseddefaultparams", true);
 
 }
 
diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index a2b785e..9f270eb 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -68,7 +68,7 @@ public:
     void            Remove( long nIndex );
 
     const Range&    GetTotalRange() const { return aTotRange; }
-    long            FirstSelected( bool bInverse = false );
+    long            FirstSelected();
     long            LastSelected();
     long            NextSelected();
 
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index ab905ec..4edadde 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -689,7 +689,7 @@ public:
     sal_Size        GetEndOfData() const { return nEndOfData; }
     const void*     GetData() { Flush(); return pBuf; }
 
-    void*           SwitchBuffer( sal_Size nInitSize=512 );
+    void*           SwitchBuffer();
     void            SetBuffer( void* pBuf, sal_Size nSize,
                                bool bOwnsData=true, sal_Size nEOF=0 );
 
diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index add0673..e85d50f 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -203,8 +203,7 @@ public:
     bool ConcatData(INetProtocol eTheScheme, OUString const & rTheUser,
                     OUString const & rThePassword,
                     OUString const & rTheHost, sal_uInt32 nThePort,
-                    OUString const & rThePath,
-                    EncodeMechanism eMechanism = WAS_ENCODED);
+                    OUString const & rThePath);
 
     // Smart Parsing:
 
@@ -330,8 +329,7 @@ public:
     GetNewAbsURL(OUString const & rTheRelURIRef,
                  INetURLObject * pTheAbsURIRef,
                  EncodeMechanism eMechanism = WAS_ENCODED,
-                 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
-                 FSysStyle eStyle = FSYS_DETECT)
+                 rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8)
         const;
 
     /** @descr  If rTheRelURIRef cannot be converted to an absolute URL
@@ -359,7 +357,7 @@ public:
 
     // External URLs:
 
-    OUString getExternalURL(DecodeMechanism eMechanism = DECODE_TO_IURI) const;
+    OUString getExternalURL() const;
 
     static inline bool translateToExternal(OUString const & rTheIntURIRef,
                                            OUString & rTheExtURIRef,
@@ -425,16 +423,13 @@ public:
                                  = RTL_TEXTENCODING_UTF8) const
     { return decode(m_aAuth, eMechanism, eCharset); }
 
-    inline bool SetUser(OUString const & rTheUser,
-                        EncodeMechanism eMechanism = WAS_ENCODED)
-    { return setUser(rTheUser, false, eMechanism, RTL_TEXTENCODING_UTF8); }
+    inline bool SetUser(OUString const & rTheUser)
+    { return setUser(rTheUser, false, WAS_ENCODED, RTL_TEXTENCODING_UTF8); }
 
-    inline bool SetPass(OUString const & rThePassword,
-                        EncodeMechanism eMechanism = WAS_ENCODED);
+    inline bool SetPass(OUString const & rThePassword);
 
     inline bool SetUserAndPass(OUString const & rTheUser,
-                               OUString const & rThePassword,
-                               EncodeMechanism eMechanism = WAS_ENCODED);
+                               OUString const & rThePassword);
 
     // Host and Port:
 
@@ -450,9 +445,8 @@ public:
 
     sal_uInt32 GetPort() const;
 
-    inline bool SetHost(OUString const & rTheHost,
-                        EncodeMechanism eMechanism = WAS_ENCODED)
-    { return setHost(rTheHost, false, eMechanism, RTL_TEXTENCODING_UTF8); }
+    inline bool SetHost(OUString const & rTheHost)
+    { return setHost(rTheHost, false, WAS_ENCODED, RTL_TEXTENCODING_UTF8); }
 
     bool SetPort(sal_uInt32 nThePort);
 
@@ -588,8 +582,6 @@ public:
         @param bIgnoreFinalSlash  If true, a final slash at the end of the
         hierarchical path does not denote an empty segment, but is ignored.
 
-        @param eMechanism  See the general discussion for set-methods.
-
         @return  True if the name has successfully been modified (and the
         resulting URI is still valid).  If the path is not hierarchical, or
         the specified segment does not exist, false is returned.  If false is
@@ -597,8 +589,7 @@ public:
      */
     bool setName(OUString const & rTheName,
                  sal_Int32 nIndex = LAST_SEGMENT,
-                 bool bIgnoreFinalSlash = true,
-                 EncodeMechanism eMechanism = WAS_ENCODED);
+                 bool bIgnoreFinalSlash = true);
 
     /** Get the base of the name of a segment.
 
@@ -647,16 +638,13 @@ public:
                  EncodeMechanism eMechanism = WAS_ENCODED,
                  rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
 
-    /** Determine whether the name of a segment has an extension.
-
-        @param nIndex  The non-negative index of the segment, or LAST_SEGMENT
-        if addressing the last segment.
+    /** Determine whether the name of the last segment has an extension.
 
         @return  True if the name of the specified segment has an extension.
         If the path is not hierarchical, or the specified segment does not
         exist, false is returned.
      */
-    bool hasExtension(sal_Int32 nIndex = LAST_SEGMENT) const;
+    bool hasExtension() const;
 
     /** Get the extension of the name of a segment.
 
@@ -916,8 +904,7 @@ public:
 
     // OBSOLETE Hierarchical Path:
 
-    OUString GetPartBeforeLastName(DecodeMechanism eMechanism
-                                        = DECODE_TO_IURI) const;
+    OUString GetPartBeforeLastName() const;
 
     /** Get the last segment in the path.
 
@@ -976,13 +963,12 @@ public:
                                  = RTL_TEXTENCODING_UTF8) const
     { return GetLastName(eMechanism, eCharset); }
 
-    void SetExtension(OUString const & rTheExtension,
-                      EncodeMechanism eMechanism = WAS_ENCODED);
+    void SetExtension(OUString const & rTheExtension);
 
-    inline OUString GetExtension( DecodeMechanism eMechanism = DECODE_TO_IURI ) const
-    { return GetFileExtension(eMechanism); }
+    inline OUString GetExtension() const
+    { return GetFileExtension(); }
 
-    OUString CutExtension(DecodeMechanism eMechanism = DECODE_TO_IURI);
+    OUString CutExtension();
 
     static bool IsCaseSensitive() { return true; }
 
@@ -1280,15 +1266,14 @@ INetURLObject::smartRel2Abs(OUString const & rTheRelURIRef,
 inline bool INetURLObject::GetNewAbsURL(OUString const & rTheRelURIRef,
                                         INetURLObject * pTheAbsURIRef,
                                         EncodeMechanism eMechanism,
-                                        rtl_TextEncoding eCharset,
-                                        FSysStyle eStyle)
+                                        rtl_TextEncoding eCharset)
     const
 {
     INetURLObject aTheAbsURIRef;
     bool bWasAbsolute;
     if (!convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, bWasAbsolute,
                          eMechanism, eCharset, false/*bIgnoreFragment*/, false, false,
-                         eStyle))
+                         FSYS_DETECT))
         return false;
     if (pTheAbsURIRef)
         *pTheAbsURIRef = aTheAbsURIRef;
@@ -1334,22 +1319,20 @@ inline bool INetURLObject::translateToInternal(OUString const &
                            eDecodeMechanism, eCharset);
 }
 
-inline bool INetURLObject::SetPass(OUString const & rThePassword,
-                                   EncodeMechanism eMechanism)
+inline bool INetURLObject::SetPass(OUString const & rThePassword)
 {
     return rThePassword.isEmpty() ?
                clearPassword() :
-               setPassword(rThePassword, false, eMechanism, RTL_TEXTENCODING_UTF8);
+               setPassword(rThePassword, false, WAS_ENCODED, RTL_TEXTENCODING_UTF8);
 }
 
 inline bool INetURLObject::SetUserAndPass(OUString const & rTheUser,
-                                          OUString const & rThePassword,
-                                          EncodeMechanism eMechanism)
+                                          OUString const & rThePassword)
 {
-    return setUser(rTheUser, false, eMechanism, RTL_TEXTENCODING_UTF8)
+    return setUser(rTheUser, false, WAS_ENCODED, RTL_TEXTENCODING_UTF8)
            && (rThePassword.isEmpty() ?
                    clearPassword() :
-                   setPassword(rThePassword, false, eMechanism, RTL_TEXTENCODING_UTF8));
+                   setPassword(rThePassword, false, WAS_ENCODED, RTL_TEXTENCODING_UTF8));
 }
 
 inline bool INetURLObject::insertName(OUString const & rTheName,
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 597ecfd..083c8e2 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -3700,8 +3700,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
                                OUString const & rThePassword,
                                OUString const & rTheHost,
                                sal_uInt32 nThePort,
-                               OUString const & rThePath,
-                               EncodeMechanism eMechanism)
+                               OUString const & rThePath)
 {
     setInvalid();
     m_eScheme = eTheScheme;
@@ -3720,7 +3719,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
             {
                 m_aUser.set(m_aAbsURIRef,
                             encodeText(rTheUser, false, PART_USER_PASSWORD,
-                                       eMechanism, RTL_TEXTENCODING_UTF8, false),
+                                       WAS_ENCODED, RTL_TEXTENCODING_UTF8, false),
                             m_aAbsURIRef.getLength());
                 bUserInfo = true;
             }
@@ -3737,7 +3736,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
                 m_aAbsURIRef.append(':');
                 m_aAuth.set(m_aAbsURIRef,
                             encodeText(rThePassword, false, PART_USER_PASSWORD,
-                                       eMechanism, RTL_TEXTENCODING_UTF8, false),
+                                       WAS_ENCODED, RTL_TEXTENCODING_UTF8, false),
                             m_aAbsURIRef.getLength());
                 bUserInfo = true;
             }
@@ -3784,7 +3783,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
             }
             if (!parseHostOrNetBiosName(
                     aSynHost.getStr(), aSynHost.getStr() + aSynHost.getLength(),
-                    false, eMechanism, RTL_TEXTENCODING_UTF8, bNetBiosName, &aSynHost))
+                    false, WAS_ENCODED, RTL_TEXTENCODING_UTF8, bNetBiosName, &aSynHost))
             {
                 setInvalid();
                 return false;
@@ -3816,7 +3815,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
     OUStringBuffer aSynPath;
     sal_Unicode const * p = rThePath.getStr();
     sal_Unicode const * pEnd = p + rThePath.getLength();
-    if (!parsePath(m_eScheme, &p, pEnd, false, eMechanism, RTL_TEXTENCODING_UTF8, false, '/',
+    if (!parsePath(m_eScheme, &p, pEnd, false, WAS_ENCODED, RTL_TEXTENCODING_UTF8, false, '/',
                    0x80000000, 0x80000000, 0x80000000, aSynPath)
         || p != pEnd)
     {
@@ -3854,11 +3853,11 @@ OUString INetURLObject::GetAbsURL(OUString const & rTheBaseURIRef,
                rTheRelURIRef;
 }
 
-OUString INetURLObject::getExternalURL(DecodeMechanism eMechanism) const
+OUString INetURLObject::getExternalURL() const
 {
     OUString aTheExtURIRef;
     translateToExternal(
-        m_aAbsURIRef.toString(), aTheExtURIRef, eMechanism);
+        m_aAbsURIRef.toString(), aTheExtURIRef);
     return aTheExtURIRef;
 }
 
@@ -4012,8 +4011,7 @@ OUString INetURLObject::getName(sal_Int32 nIndex, bool bIgnoreFinalSlash,
 }
 
 bool INetURLObject::setName(OUString const & rTheName, sal_Int32 nIndex,
-                            bool bIgnoreFinalSlash,
-                            EncodeMechanism eMechanism)
+                            bool bIgnoreFinalSlash)
 {
     SubString aSegment(getSegment(nIndex, bIgnoreFinalSlash));
     if (!aSegment.isPresent())
@@ -4035,17 +4033,17 @@ bool INetURLObject::setName(OUString const & rTheName, sal_Int32 nIndex,
     OUStringBuffer aNewPath;
     aNewPath.append(pPathBegin, pSegBegin - pPathBegin);
     aNewPath.append(encodeText(rTheName, false, PART_PCHAR,
-        eMechanism, RTL_TEXTENCODING_UTF8, true));
+        WAS_ENCODED, RTL_TEXTENCODING_UTF8, true));
     aNewPath.append(p, pPathEnd - p);
 
     return setPath(aNewPath.makeStringAndClear(), false, NOT_CANONIC,
         RTL_TEXTENCODING_UTF8);
 }
 
-bool INetURLObject::hasExtension(sal_Int32 nIndex)
+bool INetURLObject::hasExtension()
     const
 {
-    SubString aSegment(getSegment(nIndex, true/*bIgnoreFinalSlash*/));
+    SubString aSegment(getSegment(LAST_SEGMENT, true/*bIgnoreFinalSlash*/));
     if (!aSegment.isPresent())
         return false;
 
@@ -4862,7 +4860,7 @@ bool INetURLObject::scanIPv6reference(sal_Unicode const *& rBegin,
     return false;
 }
 
-OUString INetURLObject::GetPartBeforeLastName(DecodeMechanism eMechanism)
+OUString INetURLObject::GetPartBeforeLastName()
     const
 {
     if (!checkHierarchical())
@@ -4872,7 +4870,7 @@ OUString INetURLObject::GetPartBeforeLastName(DecodeMechanism eMechanism)
     aTemp.clearQuery();
     aTemp.removeSegment(LAST_SEGMENT, false);
     aTemp.setFinalSlash();
-    return aTemp.GetMainURL(eMechanism);
+    return aTemp.GetMainURL(DECODE_TO_IURI);
 }
 
 OUString INetURLObject::GetLastName(DecodeMechanism eMechanism,
@@ -4948,15 +4946,14 @@ void INetURLObject::SetName(OUString const & rTheName,
         *this = aTemp;
 }
 
-void INetURLObject::SetExtension(OUString const & rTheExtension,
-                                 EncodeMechanism eMechanism)
+void INetURLObject::SetExtension(OUString const & rTheExtension)
 {
-    setExtension(rTheExtension, LAST_SEGMENT, false, eMechanism);
+    setExtension(rTheExtension, LAST_SEGMENT, false);
 }
 
-OUString INetURLObject::CutExtension(DecodeMechanism eMechanism)
+OUString INetURLObject::CutExtension()
 {
-    OUString aTheExtension(getExtension(LAST_SEGMENT, false, eMechanism));
+    OUString aTheExtension(getExtension(LAST_SEGMENT, false));
     return removeExtension(LAST_SEGMENT, false)
         ? aTheExtension : OUString();
 }
diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx
index e0b7207..2559921 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -432,26 +432,14 @@ long MultiSelection::ImplFwdUnselected()
         return SFX_ENDOFSELECTION;
 }
 
-long MultiSelection::FirstSelected( bool bInverse )
+long MultiSelection::FirstSelected()
 {
-    bInverseCur = bInverse;
+    bInverseCur = false;
     nCurSubSel = 0;
 
-    if ( bInverseCur )
-    {
-        bCurValid = nSelCount < sal_uIntPtr(aTotRange.Len());
-        if ( bCurValid )
-        {
-            nCurIndex = 0;
-            return ImplFwdUnselected();
-        }
-    }
-    else
-    {
-        bCurValid = !aSels.empty();
-        if ( bCurValid )
-            return nCurIndex = aSels[ 0 ]->Min();
-    }
+    bCurValid = !aSels.empty();
+    if ( bCurValid )
+        return nCurIndex = aSels[ 0 ]->Min();
 
     return SFX_ENDOFSELECTION;
 }
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index cdf59a6..26b2e2f 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1937,7 +1937,7 @@ void SvMemoryStream::FreeMemory()
     delete[] pBuf;
 }
 
-void* SvMemoryStream::SwitchBuffer( sal_Size nInitSize)
+void* SvMemoryStream::SwitchBuffer()
 {
     Flush();
     if( !bOwnsData )
@@ -1955,7 +1955,8 @@ void* SvMemoryStream::SwitchBuffer( sal_Size nInitSize)
 
     ResetError();
 
-    if( nInitSize && !AllocateMemory(nInitSize) )
+    sal_Size nInitSize = 512;
+    if( !AllocateMemory(nInitSize) )
     {
         SetError( SVSTREAM_OUTOFMEMORY );
         nSize = 0;


More information about the Libreoffice-commits mailing list