diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-15 19:37:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-16 08:16:13 +0200 |
commit | f98b3b5b9f1b05259405833e6e528e734ded4512 (patch) | |
tree | 85027ec17bd36a17ade869644400843791d3b2bf /svtools | |
parent | cd7471335a05e7dd7eca16ac0b181d96cfa7912b (diff) |
loplugin:buriedassign in svtools..svx
Change-Id: I04bc97effddb213e9c1ac613b61d3a0bc38522ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92314
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/dialogs/insdlg.cxx | 97 | ||||
-rw-r--r-- | svtools/source/hatchwindow/ipwin.cxx | 2 | ||||
-rw-r--r-- | svtools/source/svhtml/htmlsupp.cxx | 38 | ||||
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 34 |
4 files changed, 100 insertions, 71 deletions
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx index 9696a958f18d..4c0701406ed8 100644 --- a/svtools/source/dialogs/insdlg.cxx +++ b/svtools/source/dialogs/insdlg.cxx @@ -279,59 +279,60 @@ OUString SvPasteObjectHelper::GetSotFormatUIName( SotClipboardFormatId nId ) bool SvPasteObjectHelper::GetEmbeddedName(const TransferableDataHelper& rData, OUString& _rName, OUString& _rSource, SotClipboardFormatId const & _nFormat) { - bool bRet = false; - if( _nFormat == SotClipboardFormatId::EMBED_SOURCE_OLE || _nFormat == SotClipboardFormatId::EMBEDDED_OBJ_OLE ) - { - datatransfer::DataFlavor aFlavor; - SotExchange::GetFormatDataFlavor( SotClipboardFormatId::OBJECTDESCRIPTOR_OLE, aFlavor ); + if( _nFormat != SotClipboardFormatId::EMBED_SOURCE_OLE && _nFormat != SotClipboardFormatId::EMBEDDED_OBJ_OLE ) + return false; - uno::Any aAny; - if( rData.HasFormat( aFlavor ) && - ( aAny = rData.GetAny(aFlavor, OUString()) ).hasValue() ) - { - uno::Sequence< sal_Int8 > anySequence; - aAny >>= anySequence; + datatransfer::DataFlavor aFlavor; + SotExchange::GetFormatDataFlavor( SotClipboardFormatId::OBJECTDESCRIPTOR_OLE, aFlavor ); - OleObjectDescriptor* pOleObjDescr = - reinterpret_cast< OleObjectDescriptor* >( anySequence.getArray( ) ); + if( !rData.HasFormat( aFlavor ) ) + return false; - // determine the user friendly description of the embedded object - if ( pOleObjDescr->dwFullUserTypeName ) - { - // we set the pointer to the start of user friendly description - // string. it starts at &OleObjectDescriptor + dwFullUserTypeName. - // dwFullUserTypeName is the offset in bytes. - // the user friendly description string is '\0' terminated. - const sal_Unicode* pUserTypeName = - reinterpret_cast< sal_Unicode* >( - reinterpret_cast< char* >( pOleObjDescr ) + - pOleObjDescr->dwFullUserTypeName ); - - _rName += pUserTypeName; - // the following statement was here for historical reasons, it is commented out since it causes bug i49460 - // _nFormat = SotClipboardFormatId::EMBED_SOURCE_OLE; - } + uno::Any aAny = rData.GetAny(aFlavor, OUString()); + if (!aAny.hasValue()) + return false; - // determine the source of the embedded object - if ( pOleObjDescr->dwSrcOfCopy ) - { - // we set the pointer to the start of source string - // it starts at &OleObjectDescriptor + dwSrcOfCopy. - // dwSrcOfCopy is the offset in bytes. - // the source string is '\0' terminated. - const sal_Unicode* pSrcOfCopy = - reinterpret_cast< sal_Unicode* >( - reinterpret_cast< char* >( pOleObjDescr ) + - pOleObjDescr->dwSrcOfCopy ); - - _rSource += pSrcOfCopy; - } - else - _rSource = SvtResId(STR_UNKNOWN_SOURCE); - } - bRet = true; + uno::Sequence< sal_Int8 > anySequence; + aAny >>= anySequence; + + OleObjectDescriptor* pOleObjDescr = + reinterpret_cast< OleObjectDescriptor* >( anySequence.getArray( ) ); + + // determine the user friendly description of the embedded object + if ( pOleObjDescr->dwFullUserTypeName ) + { + // we set the pointer to the start of user friendly description + // string. it starts at &OleObjectDescriptor + dwFullUserTypeName. + // dwFullUserTypeName is the offset in bytes. + // the user friendly description string is '\0' terminated. + const sal_Unicode* pUserTypeName = + reinterpret_cast< sal_Unicode* >( + reinterpret_cast< char* >( pOleObjDescr ) + + pOleObjDescr->dwFullUserTypeName ); + + _rName += pUserTypeName; + // the following statement was here for historical reasons, it is commented out since it causes bug i49460 + // _nFormat = SotClipboardFormatId::EMBED_SOURCE_OLE; } - return bRet; + + // determine the source of the embedded object + if ( pOleObjDescr->dwSrcOfCopy ) + { + // we set the pointer to the start of source string + // it starts at &OleObjectDescriptor + dwSrcOfCopy. + // dwSrcOfCopy is the offset in bytes. + // the source string is '\0' terminated. + const sal_Unicode* pSrcOfCopy = + reinterpret_cast< sal_Unicode* >( + reinterpret_cast< char* >( pOleObjDescr ) + + pOleObjDescr->dwSrcOfCopy ); + + _rSource += pSrcOfCopy; + } + else + _rSource = SvtResId(STR_UNKNOWN_SOURCE); + + return true; } diff --git a/svtools/source/hatchwindow/ipwin.cxx b/svtools/source/hatchwindow/ipwin.cxx index f32fb9c4245a..751f3efa5e83 100644 --- a/svtools/source/hatchwindow/ipwin.cxx +++ b/svtools/source/hatchwindow/ipwin.cxx @@ -257,7 +257,7 @@ Point SvResizeHelper::GetTrackPosPixel( const tools::Rectangle & rRect ) const aPos = aRect.TopLeft() - aOuter.TopLeft(); break; } - return aPos += aSelPos; + return aPos + aSelPos; } /************************************************************************* diff --git a/svtools/source/svhtml/htmlsupp.cxx b/svtools/source/svhtml/htmlsupp.cxx index 6e4f4ffb81cc..cdff0f352029 100644 --- a/svtools/source/svhtml/htmlsupp.cxx +++ b/svtools/source/svhtml/htmlsupp.cxx @@ -81,24 +81,42 @@ void HTMLParser::ParseScriptOptions( OUString& rLangString, const OUString& rBas void HTMLParser::RemoveSGMLComment( OUString &rString ) { sal_Unicode c = 0; - while( !rString.isEmpty() && - ( ' '==(c=rString[0]) || '\t'==c || '\r'==c || '\n'==c ) ) - rString = rString.copy( 1 ); - - while( !rString.isEmpty() && - ( ' '==(c=rString[rString.getLength()-1]) - || '\t'==c || '\r'==c || '\n'==c ) ) - rString = rString.copy( 0, rString.getLength()-1 ); + sal_Int32 idx = 0; + while (idx < rString.getLength()) + { + c = rString[idx]; + if (!( c==' ' || c=='\t' || c=='\r' || c=='\n' ) ) + break; + idx++; + } + if (idx) + rString = rString.copy( idx ); + idx = rString.getLength() - 1; + while (idx > 0) + // Can never get to 0 because that would mean the string contains only whitespace, and the first + // loop would already have removed all of those. + { + c = rString[idx]; + if (!( c==' ' || c=='\t' || c=='\r' || c=='\n' ) ) + break; + idx--; + } + if (idx != rString.getLength() - 1) + rString = rString.copy( 0, idx + 1 ); // remove SGML comments if( rString.startsWith( "<!--" ) ) { // the whole line sal_Int32 nPos = 4; - while( nPos < rString.getLength() && - ( ( c = rString[nPos] ) != '\r' && c != '\n' ) ) + while( nPos < rString.getLength() ) + { + c = rString[nPos]; + if (c == '\r' || c == '\n') + break; ++nPos; + } if( c == '\r' && nPos+1 < rString.getLength() && '\n' == rString[nPos+1] ) ++nPos; diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 6af8a3e73532..eb6b22a84f17 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -727,8 +727,8 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) { // Reduce sequences of Blanks/Tabs/CR/LF to a single blank do { - if( sal_Unicode(EOF) == (nNextCh = GetNextChar()) && - rInput.eof() ) + nNextCh = GetNextChar(); + if( sal_Unicode(EOF) == nNextCh && rInput.eof() ) { if( !aToken.isEmpty() || sTmpBuffer.getLength() > 1 ) { @@ -766,8 +766,8 @@ HtmlTokenId HTMLParser::ScanText( const sal_Unicode cBreak ) aToken += sTmpBuffer; sTmpBuffer.setLength(0); } - if( ( sal_Unicode(EOF) == (nNextCh = GetNextChar()) && - rInput.eof() ) || + nNextCh = GetNextChar(); + if( ( sal_Unicode(EOF) == nNextCh && rInput.eof() ) || !IsParserWorking() ) { if( !sTmpBuffer.isEmpty() ) @@ -1451,9 +1451,13 @@ const HTMLOptions& HTMLParser::GetOptions( HtmlOptionId const *pNoConvertToken ) // Actually only certain characters allowed. // Netscape only looks for "=" and white space (c.f. // Mozilla: PA_FetchRequestedNameValues in libparse/pa_mdl.c) - while( nPos < aToken.getLength() && '=' != (cChar=aToken[nPos]) && - HTML_ISPRINTABLE(cChar) && !rtl::isAsciiWhiteSpace(cChar) ) + while( nPos < aToken.getLength() ) + { + cChar = aToken[nPos]; + if ( '=' == cChar ||!HTML_ISPRINTABLE(cChar) || rtl::isAsciiWhiteSpace(cChar) ) + break; nPos++; + } OUString sName( aToken.copy( nStt, nPos-nStt ) ); @@ -1465,20 +1469,26 @@ const HTMLOptions& HTMLParser::GetOptions( HtmlOptionId const *pNoConvertToken ) nToken >= HtmlOptionId::SCRIPT_END) && (!pNoConvertToken || nToken != *pNoConvertToken); - while( nPos < aToken.getLength() && - ( !HTML_ISPRINTABLE( (cChar=aToken[nPos]) ) || - rtl::isAsciiWhiteSpace(cChar) ) ) + while( nPos < aToken.getLength() ) + { + cChar = aToken[nPos]; + if ( HTML_ISPRINTABLE(cChar) && !rtl::isAsciiWhiteSpace(cChar) ) + break; nPos++; + } // Option with value? if( nPos!=aToken.getLength() && '='==cChar ) { nPos++; - while( nPos < aToken.getLength() && - ( !HTML_ISPRINTABLE( (cChar=aToken[nPos]) ) || - ' '==cChar || '\t'==cChar || '\r'==cChar || '\n'==cChar ) ) + while( nPos < aToken.getLength() ) + { + cChar = aToken[nPos]; + if ( HTML_ISPRINTABLE(cChar) && ' ' != cChar && '\t' != cChar && '\r' != cChar && '\n' != cChar ) + break; nPos++; + } if( nPos != aToken.getLength() ) { |