diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-23 11:47:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-23 14:38:14 +0200 |
commit | 5e028ad5dccc6ff1a9250baf2196f7a2f235e314 (patch) | |
tree | 6c6992e6fccf43b60141fb6ae32a6ad8e37cb84d /sfx2 | |
parent | f905d6056606234ba53a26a3e4105ad3560d4b7b (diff) |
simplify some string handling in tracing calls
Change-Id: I0fb76562429e691400a02216019c7f96791cf9b3
Reviewed-on: https://gerrit.libreoffice.org/39159
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 93 | ||||
-rw-r--r-- | sfx2/source/control/objface.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/control/request.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/doc/docfac.cxx | 5 |
4 files changed, 29 insertions, 102 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index e79e1177c52e..2abeaf4f4e28 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -194,11 +194,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if ( !pItem ) { -#ifdef DBG_UTIL - OStringBuffer aStr("No creator method for item: "); - aStr.append(static_cast<sal_Int32>(nSlotId)); - OSL_FAIL(aStr.getStr()); -#endif + SAL_WARN( "sfx", "No creator method for item: " << nSlotId ); return; } @@ -216,14 +212,10 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if( pItem->PutValue( rProp.Value, bConvertTwips ? CONVERT_TWIPS : 0 ) ) // only use successfully converted items rSet.Put( *pItem ); -#ifdef DBG_UTIL else { - OStringBuffer aStr("Property not convertible: "); - aStr.append(pSlot->pUnoName); - OSL_FAIL( aStr.getStr() ); + SAL_WARN( "sfx", "Property not convertible: " << pSlot->pUnoName ); } -#endif } #ifdef DBG_UTIL else if ( nSubCount == 0 ) @@ -242,9 +234,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert // so this should be notified as a warning only if ( nCount != nSubCount ) { - OStringBuffer aStr("MacroPlayer: wrong number of parameters for slot: "); - aStr.append(static_cast<sal_Int32>(nSlotId)); - SAL_INFO("sfx.appl", aStr.getStr()); + SAL_INFO("sfx.appl", "MacroPlayer: wrong number of parameters for slot: " << nSlotId ); } #endif // complex property; collect sub items from the parameter set and reconstruct complex item @@ -265,27 +255,16 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert nSubId |= CONVERT_TWIPS; if ( pItem->PutValue( rPropValue.Value, nSubId ) ) nFound++; -#ifdef DBG_UTIL else { - OStringBuffer aDbgStr("Property not convertible: "); - aDbgStr.append(pSlot->pUnoName); - OSL_FAIL( aDbgStr.getStr() ); + SAL_WARN( "sfx.appl", "Property not convertible: " << pSlot->pUnoName); } -#endif break; } } -#ifdef DBG_UTIL - if ( nSub >= nSubCount ) - { - // there was a parameter with a name that didn't match to any of the members - OStringBuffer aStr("Property name does not match: "); - aStr.append(OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8)); - OSL_FAIL( aStr.getStr() ); - } -#endif + // there was a parameter with a name that didn't match to any of the members + SAL_WARN_IF( nSub >= nSubCount, "sfx.appl", "Property name does not match: " << rPropValue.Name ); } // at least one part of the complex item must be present; other parts can have default values @@ -311,11 +290,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert std::unique_ptr<SfxPoolItem> pItem(rArg.CreateItem()); if ( !pItem ) { -#ifdef DBG_UTIL - OStringBuffer aStr("No creator method for argument: "); - aStr.append(rArg.pName); - OSL_FAIL( aStr.getStr() ); -#endif + SAL_WARN( "sfx", "No creator method for argument: " << rArg.pName ); return; } @@ -339,14 +314,10 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if( pItem->PutValue( rProp.Value, 0 ) ) // only use successfully converted items rSet.Put( *pItem ); -#ifdef DBG_UTIL else { - OStringBuffer aStr("Property not convertible: "); - aStr.append(rArg.pName); - OSL_FAIL( aStr.getStr() ); + SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); } -#endif break; } } @@ -368,14 +339,10 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if( pItem->PutValue( rProp.Value, 0 ) ) // only use successfully converted items rSet.Put( *pItem ); -#ifdef DBG_UTIL else { - OStringBuffer aStr("Property not convertible: "); - aStr.append(rArg.pName); - OSL_FAIL( aStr.getStr() ); + SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); } -#endif } } @@ -407,11 +374,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert { // ... but it was not convertible bRet = false; -#ifdef DBG_UTIL - OStringBuffer aDbgStr("Property not convertible: "); - aDbgStr.append(rArg.pName); - OSL_FAIL( aDbgStr.getStr() ); -#endif + SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); } break; @@ -901,9 +864,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if ( nFoundArgs == nCount ) { // except for the "special" slots: assure that every argument was convertible - OStringBuffer aStr("MacroPlayer: Some properties didn't match to any formal argument for slot: "); - aStr.append(pSlot->pUnoName); - SAL_INFO( "sfx.appl", aStr.getStr() ); + SAL_INFO( "sfx.appl", "MacroPlayer: Some properties didn't match to any formal argument for slot: "<< pSlot->pUnoName ); } #endif } @@ -945,15 +906,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b // simple property: we expect to get exactly one item nProps++; } -#ifdef DBG_UTIL else { // we will not rely on the "toggle" ability of some property slots - OStringBuffer aStr("Processing property slot without argument: "); - aStr.append(static_cast<sal_Int32>(nSlotId)); - OSL_FAIL(aStr.getStr()); + SAL_WARN( "sfx", "Processing property slot without argument: " << nSlotId ); } -#endif #ifdef DBG_UTIL nItems++; @@ -1281,9 +1238,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b pValue[nActProp].Name = OUString::createFromAscii(pSlot->pUnoName) ; if ( !pItem->QueryValue( pValue[nActProp].Value ) ) { - OStringBuffer aStr("Item not convertible: "); - aStr.append(static_cast<sal_Int32>(nSlotId)); - OSL_FAIL(aStr.getStr()); + SAL_WARN( "sfx", "Item not convertible: " << nSlotId ); } } else @@ -1302,12 +1257,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b pValue[nActProp].Name = aName; if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) ) { - OStringBuffer aStr("Sub item "); - aStr.append(static_cast<sal_Int32>( - pType->aAttrib[n-1].nAID)); - aStr.append(" not convertible in slot: "); - aStr.append(static_cast<sal_Int32>(nSlotId)); - OSL_FAIL( aStr.getStr() ); + SAL_WARN( "sfx", "Sub item " << pType->aAttrib[n-1].nAID + << " not convertible in slot: " << nSlotId ); } } } @@ -1333,9 +1284,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) ; if ( !pItem->QueryValue( pValue[nActProp++].Value ) ) { - OStringBuffer aStr("Item not convertible: "); - aStr.append(static_cast<sal_Int32>(rArg.nSlotId)); - OSL_FAIL(aStr.getStr()); + SAL_WARN( "sfx", "Item not convertible: " << rArg.nSlotId ); } } else @@ -1354,12 +1303,10 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b pValue[nActProp].Name = aName; if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) ) { - OStringBuffer aStr("Sub item "); - aStr.append(static_cast<sal_Int32>( - rArg.pType->aAttrib[n-1].nAID)); - aStr.append(" not convertible in slot: "); - aStr.append(static_cast<sal_Int32>(rArg.nSlotId)); - OSL_FAIL(aStr.getStr()); + SAL_WARN( "sfx", "Sub item " + << rArg.pType->aAttrib[n-1].nAID + << " not convertible in slot: " + << rArg.nSlotId ); } } } diff --git a/sfx2/source/control/objface.cxx b/sfx2/source/control/objface.cxx index 39ebcc96eb55..2a12149cc6b3 100644 --- a/sfx2/source/control/objface.cxx +++ b/sfx2/source/control/objface.cxx @@ -179,12 +179,9 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) pCurSlot = pCurSlot->pNextSlot; if ( pCurSlot->GetStateFnc() != pIter->GetStateFnc() ) { - OStringBuffer aStr("Linked Slots with different State Methods : "); - aStr.append(static_cast<sal_Int32>( - pCurSlot->GetSlotId())); - aStr.append(" , "); - aStr.append(static_cast<sal_Int32>(pIter->GetSlotId())); - SAL_WARN("sfx.control", aStr.getStr()); + SAL_WARN("sfx.control", "Linked Slots with different State Methods : " + << pCurSlot->GetSlotId() + << " , " << pIter->GetSlotId() ); } } while ( pCurSlot != pIter ); diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index b9bcabb547a6..11f5bb9e7786 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -191,14 +191,10 @@ SfxRequest::SfxRequest pImpl->xRecorder = SfxRequest::GetMacroRecorder( pViewFrame ); pImpl->aTarget = pImpl->pShell->GetName(); } -#ifdef DBG_UTIL else { - OStringBuffer aStr("Recording unsupported slot: "); - aStr.append(static_cast<sal_Int32>(pImpl->pPool->GetSlotId(nSlotId))); - OSL_FAIL(aStr.getStr()); + SAL_WARN( "sfx", "Recording unsupported slot: " << pImpl->pPool->GetSlotId(nSlotId) ); } -#endif } @@ -573,12 +569,8 @@ void SfxRequest::Done_Impl // recordable? // new Recording uses UnoName! - if ( !pImpl->pSlot->pUnoName ) - { - OStringBuffer aStr("Recording not exported slot: "); - aStr.append(static_cast<sal_Int32>(pImpl->pSlot->GetSlotId())); - OSL_FAIL(aStr.getStr()); - } + SAL_WARN_IF( !pImpl->pSlot->pUnoName, "sfx", "Recording not exported slot: " + << pImpl->pSlot->GetSlotId() ); if ( !pImpl->pSlot->pUnoName ) // playing it safe return; @@ -593,14 +585,8 @@ void SfxRequest::Done_Impl const SfxPoolItem *pItem; sal_uInt16 nWhich = rPool.GetWhich(pImpl->pSlot->GetSlotId()); SfxItemState eState = pSet ? pSet->GetItemState( nWhich, false, &pItem ) : SfxItemState::UNKNOWN; -#ifdef DBG_UTIL - if ( SfxItemState::SET != eState ) - { - OStringBuffer aStr("Recording property not available: "); - aStr.append(static_cast<sal_Int32>(pImpl->pSlot->GetSlotId())); - OSL_FAIL(aStr.getStr()); - } -#endif + SAL_WARN_IF( SfxItemState::SET != eState, "sfx", "Recording property not available: " + << pImpl->pSlot->GetSlotId() ); uno::Sequence < beans::PropertyValue > aSeq; if ( eState == SfxItemState::SET ) TransformItems( pImpl->pSlot->GetSlotId(), *pSet, aSeq, pImpl->pSlot ); diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx index 6a26e7b8420f..3fcbcdc4a77d 100644 --- a/sfx2/source/doc/docfac.cxx +++ b/sfx2/source/doc/docfac.cxx @@ -108,10 +108,7 @@ void SfxObjectFactory::RegisterViewFactory { if ( (*it)->GetAPIViewName() != sViewName ) continue; - OStringBuffer aStr("SfxObjectFactory::RegisterViewFactory: duplicate view name '"); - aStr.append(OUStringToOString(sViewName, RTL_TEXTENCODING_ASCII_US)); - aStr.append("'!"); - OSL_FAIL(aStr.getStr()); + SAL_WARN( "sfx", "SfxObjectFactory::RegisterViewFactory: duplicate view name: " << sViewName ); break; } } |