Kaydet (Commit) 2ed3d691 authored tarafından Arkadiy Illarionov's avatar Arkadiy Illarionov Kaydeden (comit) Noel Grandin

Use hasElements to check Sequence emptiness in cppcanvas..desktop

Similar to clang-tidy readability-container-size-empty

Change-Id: I81c0ff78d2ecc7d984e3ed5e5ce60efe327fc162
Reviewed-on: https://gerrit.libreoffice.org/71799
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6c31c2b0
......@@ -392,8 +392,8 @@ namespace cppcanvas
const OutDevState& rState( rParms.mrStates.getState() );
if( (!rState.isLineColorSet &&
!rState.isFillColorSet) ||
(rState.lineColor.getLength() == 0 &&
rState.fillColor.getLength() == 0) )
(!rState.lineColor.hasElements() &&
!rState.fillColor.hasElements()) )
{
return false;
}
......@@ -1813,7 +1813,7 @@ namespace cppcanvas
case MetaActionType::POINT:
{
const OutDevState& rState( rStates.getState() );
if( rState.lineColor.getLength() )
if( rState.lineColor.hasElements() )
{
std::shared_ptr<Action> pPointAction(
internal::PointActionFactory::createPointAction(
......@@ -1837,7 +1837,7 @@ namespace cppcanvas
case MetaActionType::PIXEL:
{
const OutDevState& rState( rStates.getState() );
if( rState.lineColor.getLength() )
if( rState.lineColor.hasElements() )
{
std::shared_ptr<Action> pPointAction(
internal::PointActionFactory::createPointAction(
......@@ -1862,7 +1862,7 @@ namespace cppcanvas
case MetaActionType::LINE:
{
const OutDevState& rState( rStates.getState() );
if( rState.lineColor.getLength() )
if( rState.lineColor.hasElements() )
{
MetaLineAction* pLineAct = static_cast<MetaLineAction*>(pCurrAct);
......@@ -2048,8 +2048,8 @@ namespace cppcanvas
case MetaActionType::POLYLINE:
{
const OutDevState& rState( rStates.getState() );
if( rState.lineColor.getLength() ||
rState.fillColor.getLength() )
if( rState.lineColor.hasElements() ||
rState.fillColor.hasElements() )
{
MetaPolyLineAction* pPolyLineAct = static_cast<MetaPolyLineAction*>(pCurrAct);
......@@ -2395,8 +2395,8 @@ namespace cppcanvas
case MetaActionType::Transparent:
{
const OutDevState& rState( rStates.getState() );
if( rState.lineColor.getLength() ||
rState.fillColor.getLength() )
if( rState.lineColor.hasElements() ||
rState.fillColor.hasElements() )
{
MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pCurrAct);
::basegfx::B2DPolyPolygon aPoly( pAct->GetPolyPolygon().getB2DPolyPolygon() );
......
......@@ -155,7 +155,7 @@ namespace cppcanvas
rendering::RenderState aLocalState( maState );
::canvas::tools::prependToRenderState(aLocalState, rTransformation);
if( maFillColor.getLength() )
if( maFillColor.hasElements() )
{
// TODO(E3): Use DBO's finalizer here,
// fillPolyPolygon() might throw
......@@ -169,7 +169,7 @@ namespace cppcanvas
aLocalState.DeviceColor = aTmpColor;
}
if( aLocalState.DeviceColor.getLength() )
if( aLocalState.DeviceColor.hasElements() )
{
rCachedPrimitive = mpCanvas->getUNOCanvas()->drawPolyPolygon( mxPolyPoly,
mpCanvas->getViewState(),
......
......@@ -155,7 +155,7 @@ namespace cppcanvas
void initLayoutWidth(double& rLayoutWidth, const uno::Sequence<double>& rOffsets)
{
ENSURE_OR_THROW(rOffsets.getLength(),
ENSURE_OR_THROW(rOffsets.hasElements(),
"::cppcanvas::internal::initLayoutWidth(): zero-length array" );
rLayoutWidth = *(std::max_element(rOffsets.begin(), rOffsets.end()));
}
......@@ -236,7 +236,7 @@ namespace cppcanvas
const OutDevState& rState,
const ::basegfx::B2DHomMatrix* pTextTransform )
{
ENSURE_OR_THROW( rOffsets.getLength(),
ENSURE_OR_THROW( rOffsets.hasElements(),
"::cppcanvas::internal::initArrayAction(): zero-length DX array" );
const ::basegfx::B2DPoint aLocalStartPoint(
......
......@@ -288,7 +288,7 @@ Any ComponentContext::lookupMap( OUString const & rName )
Reference< lang::XSingleComponentFactory > xFac;
if (usesService >>= xFac) // try via factory
{
xInstance = args.getLength()
xInstance = args.hasElements()
? xFac->createInstanceWithArgumentsAndContext( args, this )
: xFac->createInstanceWithContext( this );
}
......@@ -298,7 +298,7 @@ Any ComponentContext::lookupMap( OUString const & rName )
if (usesService >>= xFac2)
{
// try via old XSingleServiceFactory
xInstance = args.getLength()
xInstance = args.hasElements()
? xFac2->createInstanceWithArguments( args )
: xFac2->createInstance();
}
......@@ -308,7 +308,7 @@ Any ComponentContext::lookupMap( OUString const & rName )
if ((usesService >>= serviceName) &&
!serviceName.isEmpty())
{
xInstance = args.getLength()
xInstance = args.hasElements()
? m_xSMgr->createInstanceWithArgumentsAndContext(
serviceName, args, this )
: m_xSMgr->createInstanceWithContext(
......
......@@ -186,7 +186,7 @@ Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndCont
}
else
{
if ( rArguments.getLength() )
if ( rArguments.hasElements() )
{
// dispose the here created UNO object before throwing out exception
// to avoid risk of memory leaks #i113722#
......@@ -747,7 +747,7 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
Sequence< OUString > ORegistryFactoryHelper::getSupportedServiceNames()
{
MutexGuard aGuard( aMutex );
if( aServiceNames.getLength() == 0 )
if( !aServiceNames.hasElements() )
{
// not yet loaded
try
......
......@@ -203,7 +203,7 @@ cppuhelper::WrapperConstructorFn mapConstructorFn(
void *const ctxt = mapTo.mapInterface(
context,
cppu::UnoType<css::uno::XComponentContext>::get());
if (args.getLength() > 0) {
if (args.hasElements()) {
std::abort(); // TODO map args
}
void * instance = nullptr;
......
......@@ -122,7 +122,7 @@ static typelib_TypeDescription * createCTD(
const Reference< XStructTypeDescription > & xType )
{
typelib_TypeDescription * pRet = nullptr;
if (xType.is() && xType->getTypeParameters().getLength() == 0)
if (xType.is() && !xType->getTypeParameters().hasElements())
{
typelib_TypeDescription * pBaseType = createCTD(
access, xType->getBaseType() );
......@@ -171,7 +171,7 @@ static typelib_TypeDescription * createCTD(
// string is held by rMemberNames
rInit.aBase.pMemberName = pMemberNames[nPos].pData;
rInit.bParameterizedType = templateMemberTypes.getLength() != 0
rInit.bParameterizedType = templateMemberTypes.hasElements()
&& (templateMemberTypes[nPos]->getTypeClass()
== TypeClass_UNKNOWN);
}
......
......@@ -1690,7 +1690,7 @@ Enumeration::nextTypeDescription()
}
bool Enumeration::matches(css::uno::TypeClass tc) const {
if (types_.getLength() == 0) {
if (!types_.hasElements()) {
return true;
}
for (sal_Int32 i = 0; i != types_.getLength(); ++i) {
......
......@@ -101,7 +101,7 @@ css::uno::Reference< css::graphic::XGraphic > SvxConfigPageHelper::GetGraphic(
aGraphicSeq =
xImageManager->getImages( GetImageType(), aImageCmdSeq );
if ( aGraphicSeq.getLength() > 0 )
if ( aGraphicSeq.hasElements() )
{
result = aGraphicSeq[0];
}
......
......@@ -2725,7 +2725,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
{
name[ 0 ] = elem.first;
uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
if ( graphics.getLength() > 0 )
if ( graphics.hasElements() )
{
m_aGraphics.push_back(graphics[0]);
Image img(graphics[0]);
......@@ -2771,7 +2771,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
// added to the list
}