[Libreoffice-commits] core.git: svtools/source svx/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 16 06:16:50 UTC 2020
svtools/source/dialogs/insdlg.cxx | 97 +++++++++++++++++------------------
svtools/source/hatchwindow/ipwin.cxx | 2
svtools/source/svhtml/htmlsupp.cxx | 38 ++++++++++---
svtools/source/svhtml/parhtml.cxx | 34 +++++++-----
svx/source/dialog/hyperdlg.cxx | 33 ++++++-----
svx/source/dialog/imapwnd.cxx | 28 ++++++----
svx/source/dialog/srchdlg.cxx | 19 +++---
svx/source/form/fmshimp.cxx | 12 ++--
svx/source/gallery2/gallery1.cxx | 9 ++-
svx/source/gallery2/galtheme.cxx | 8 +-
10 files changed, 162 insertions(+), 118 deletions(-)
New commits:
commit f98b3b5b9f1b05259405833e6e528e734ded4512
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Apr 15 19:37:27 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Apr 16 08:16:13 2020 +0200
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 at collabora.co.uk>
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() )
{
diff --git a/svx/source/dialog/hyperdlg.cxx b/svx/source/dialog/hyperdlg.cxx
index c94fb35c1239..1bbc40e759d9 100644
--- a/svx/source/dialog/hyperdlg.cxx
+++ b/svx/source/dialog/hyperdlg.cxx
@@ -44,23 +44,26 @@ SvxHlinkDlgWrapper::SvxHlinkDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
SetVisible_Impl(false);
vcl::Window* pTopWindow = nullptr;
- if ( !pInfo->aSize.IsEmpty() && (nullptr != (pTopWindow = SfxGetpApp()->GetTopWindow())))
+ if ( !pInfo->aSize.IsEmpty() )
{
- weld::Dialog* pDialog = GetController()->getDialog();
-
- Size aParentSize( pTopWindow->GetSizePixel() );
- Size aDlgSize(pDialog->get_size());
-
- if( aParentSize.Width() < pInfo->aPos.X() )
- pInfo->aPos.setX( aParentSize.Width()-aDlgSize.Width() < long(0.1*aParentSize.Width()) ?
- long(0.1*aParentSize.Width()) : aParentSize.Width()-aDlgSize.Width() );
- if( aParentSize.Height() < pInfo->aPos. Y() )
- pInfo->aPos.setY( aParentSize.Height()-aDlgSize.Height() < long(0.1*aParentSize.Height()) ?
- long(0.1*aParentSize.Height()) : aParentSize.Height()-aDlgSize.Height() );
-
- pDialog->window_move(pInfo->aPos.X(), pInfo->aPos.Y());
+ pTopWindow = SfxGetpApp()->GetTopWindow();
+ if (pTopWindow)
+ {
+ weld::Dialog* pDialog = GetController()->getDialog();
+
+ Size aParentSize( pTopWindow->GetSizePixel() );
+ Size aDlgSize(pDialog->get_size());
+
+ if( aParentSize.Width() < pInfo->aPos.X() )
+ pInfo->aPos.setX( aParentSize.Width()-aDlgSize.Width() < long(0.1*aParentSize.Width()) ?
+ long(0.1*aParentSize.Width()) : aParentSize.Width()-aDlgSize.Width() );
+ if( aParentSize.Height() < pInfo->aPos. Y() )
+ pInfo->aPos.setY( aParentSize.Height()-aDlgSize.Height() < long(0.1*aParentSize.Height()) ?
+ long(0.1*aParentSize.Height()) : aParentSize.Height()-aDlgSize.Height() );
+
+ pDialog->window_move(pInfo->aPos.X(), pInfo->aPos.Y());
+ }
}
-
SetHideNotDelete( true );
}
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 8ba770aa11b0..3c6270df9086 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -124,13 +124,17 @@ void IMapWindow::ReplaceActualIMapInfo( const NotifyInfo& rNewInfo )
const SdrObject* pSdrObj = GetSelectedSdrObject();
IMapObject* pIMapObj;
- if ( pSdrObj && ( ( pIMapObj = GetIMapObj( pSdrObj ) ) != nullptr ) )
+ if ( pSdrObj )
{
- pIMapObj->SetURL( rNewInfo.aMarkURL );
- pIMapObj->SetAltText( rNewInfo.aMarkAltText );
- pIMapObj->SetTarget( rNewInfo.aMarkTarget );
- pModel->SetChanged();
- UpdateInfo( false );
+ pIMapObj = GetIMapObj( pSdrObj );
+ if (pIMapObj)
+ {
+ pIMapObj->SetURL( rNewInfo.aMarkURL );
+ pIMapObj->SetAltText( rNewInfo.aMarkAltText );
+ pIMapObj->SetTarget( rNewInfo.aMarkTarget );
+ pModel->SetChanged();
+ UpdateInfo( false );
+ }
}
}
@@ -579,12 +583,14 @@ OUString IMapWindow::RequestHelp(tools::Rectangle& rHelpArea)
if (pSdrObj)
{
const IMapObject* pIMapObj = GetIMapObj( pSdrObj );
- OUString aStr;
-
- if ( pIMapObj && !( aStr = pIMapObj->GetURL() ).isEmpty() )
+ if ( pIMapObj )
{
- rHelpArea = rDevice.LogicToPixel(tools::Rectangle( Point(), GetGraphicSize()));
- return aStr;
+ OUString aStr = pIMapObj->GetURL();
+ if ( !aStr.isEmpty() )
+ {
+ rHelpArea = rDevice.LogicToPixel(tools::Rectangle( Point(), GetGraphicSize()));
+ return aStr;
+ }
}
}
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index ba2a2a09ce9d..15204847d528 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -438,15 +438,14 @@ void SvxSearchDialog::Construct_Impl()
bool bSearchComponent1 = false;
bool bSearchComponent2 = false;
- if(xDispatchProv.is() &&
- (pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0)).is())
+ if(xDispatchProv.is())
{
- bSearchComponent1 = true;
- }
- if(xDispatchProv.is() &&
- (pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0)).is())
- {
- bSearchComponent2 = true;
+ pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0);
+ if (pImpl->xCommand1Dispatch.is())
+ bSearchComponent1 = true;
+ pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0);
+ if (pImpl->xCommand2Dispatch.is())
+ bSearchComponent2 = true;
}
if( bSearchComponent1 || bSearchComponent2 )
@@ -1976,8 +1975,8 @@ IMPL_LINK_NOARG(SvxSearchDialog, FormatHdl_Impl, weld::Button&, void)
const SfxPoolItem* pItem;
for( sal_uInt16 n = 0; n < pList->Count(); ++n )
{
- SearchAttrItem* pAItem;
- if( !IsInvalidItem( (pAItem = &pList->GetObject(n))->pItem ) &&
+ SearchAttrItem* pAItem = &pList->GetObject(n);
+ if( !IsInvalidItem( pAItem->pItem ) &&
SfxItemState::SET == aOutSet.GetItemState(
pAItem->pItem->Which(), false, &pItem ) )
{
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index a4c9357c3457..6407f74e9fbf 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -3097,10 +3097,12 @@ void FmXFormShell::CreateExternalView_Lock()
// FS - 21.10.99 - 69219
{
FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
- Reference< XPropertySet> xCurrentModelSet;
bool bHaveUsableControls = false;
- while ((xCurrentModelSet = Reference< XPropertySet>(aModelIterator.Next(), UNO_QUERY)).is())
+ for (;;)
{
+ Reference< XPropertySet> xCurrentModelSet(aModelIterator.Next(), UNO_QUERY);
+ if (!xCurrentModelSet.is())
+ break;
// the FmXBoundFormFieldIterator only supplies controls with a valid control source
// so we just have to check the field type
sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
@@ -3213,11 +3215,13 @@ void FmXFormShell::CreateExternalView_Lock()
FmMapUString2Int16 aRadioPositions;
FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
- Reference< XPropertySet> xCurrentModelSet;
OUString sColumnType,aGroupName,sControlSource;
Sequence< Property> aProps;
- while ((xCurrentModelSet = Reference< XPropertySet>(aModelIterator.Next(), UNO_QUERY)).is())
+ for (;;)
{
+ Reference< XPropertySet> xCurrentModelSet(aModelIterator.Next(), UNO_QUERY);
+ if (!xCurrentModelSet.is())
+ break;
OSL_ENSURE(xCurrentModelSet.is(),"xCurrentModelSet is null!");
// create a description of the column to be created
// first : determine it's type
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 8e0873ffd653..685f3d99df5e 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -741,9 +741,12 @@ GalleryTheme* Gallery::AcquireTheme( const OUString& rThemeName, SfxListener& rL
GalleryTheme* pTheme = nullptr;
GalleryThemeEntry* pThemeEntry = ImplGetThemeEntry( rThemeName );
- if( pThemeEntry && ( ( pTheme = ImplGetCachedTheme( pThemeEntry ) ) != nullptr ) )
- rListener.StartListening(*pTheme, DuplicateHandling::Prevent);
-
+ if( pThemeEntry )
+ {
+ pTheme = ImplGetCachedTheme( pThemeEntry );
+ if (pTheme)
+ rListener.StartListening(*pTheme, DuplicateHandling::Prevent);
+ }
return pTheme;
}
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index f75e88a15fdd..a5b60f572817 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -285,8 +285,8 @@ INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDat
// get URL
if( SgaObjKind::SvDraw == eObjKind )
{
- OUString aFileName( "gallery/svdraw/dd" );
- aNewURL = INetURLObject( aFileName += OUString::number( ++nNextNumber % 99999999 ), INetProtocol::PrivSoffice );
+ OUString aFileName = "gallery/svdraw/dd" + OUString::number( ++nNextNumber % 99999999 );
+ aNewURL = INetURLObject( aFileName, INetProtocol::PrivSoffice );
bExists = false;
@@ -1384,8 +1384,8 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
{
if( SgaObjKind::SvDraw == pObj->eObjKind )
{
- OUString aDummyURL( "gallery/svdraw/" );
- pObj->aURL = INetURLObject( aDummyURL += aFileName, INetProtocol::PrivSoffice );
+ OUString aDummyURL = "gallery/svdraw/" + aFileName;
+ pObj->aURL = INetURLObject( aDummyURL, INetProtocol::PrivSoffice );
}
else
{
More information about the Libreoffice-commits
mailing list