From 7334034ae93b49fc93b5859a3c047a319d138282 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 29 Apr 2019 15:50:02 +0200 Subject: drop Graphic::operator bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which tends to interact in very weird ways with other code, for example it makes Graphic appear to have an operator< Change-Id: I335fe8f3644b710bc61291e625cbca7334a37716 Reviewed-on: https://gerrit.libreoffice.org/71532 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- editeng/source/items/frmitems.cxx | 6 +++--- editeng/source/uno/unonrule.cxx | 2 +- filter/source/msfilter/escherex.cxx | 2 +- filter/source/msfilter/msdffimp.cxx | 2 +- include/vcl/graph.hxx | 3 +-- sd/source/filter/eppt/epptso.cxx | 2 +- sfx2/source/appl/linkmgr2.cxx | 2 +- svtools/source/graphic/renderer.cxx | 2 +- svtools/source/misc/embedhlp.cxx | 2 +- svx/qa/unit/XTableImportExportTest.cxx | 2 +- svx/source/gallery2/galbrws2.cxx | 2 +- svx/source/unodraw/UnoGraphicExporter.cxx | 8 ++++---- svx/source/unodraw/XPropertyTable.cxx | 2 +- svx/source/unodraw/unoshap2.cxx | 4 ++-- svx/source/xml/xmlgrhlp.cxx | 2 +- svx/source/xoutdev/xattrbmp.cxx | 2 +- sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 2 +- sw/source/core/unocore/unoframe.cxx | 4 ++-- sw/source/core/unocore/unosett.cxx | 2 +- vcl/source/gdi/graph.cxx | 9 ++------- vcl/source/graphic/GraphicObject.cxx | 2 +- vcl/source/graphic/UnoGraphic.cxx | 17 ++++++----------- vcl/source/graphic/UnoGraphicProvider.cxx | 4 ++-- 23 files changed, 37 insertions(+), 48 deletions(-) diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index ac78520bdaa8..0d49c25681b6 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -2992,7 +2992,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) aGraphic = Graphic(xGraphic); } - if (aGraphic) + if (!aGraphic.IsNone()) { maStrLink.clear(); @@ -3001,11 +3001,11 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) ApplyGraphicTransparency_Impl(); xOldGrfObj.reset(); - if (aGraphic && eGraphicPos == GPOS_NONE) + if (!aGraphic.IsNone() && eGraphicPos == GPOS_NONE) { eGraphicPos = GPOS_MM; } - else if (!aGraphic) + else if (aGraphic.IsNone()) { eGraphicPos = GPOS_NONE; } diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx index 4ed69af5c922..e3a3d5111706 100644 --- a/editeng/source/uno/unonrule.cxx +++ b/editeng/source/uno/unonrule.cxx @@ -361,7 +361,7 @@ void SvxUnoNumberingRules::setNumberingRuleByIndex(const Sequence>= aURL) { Graphic aGraphic = vcl::graphic::loadFromURL(aURL); - if (aGraphic) + if (!aGraphic.IsNone()) { SvxBrushItem aBrushItem(aGraphic, GPOS_AREA, SID_ATTR_BRUSH); aFmt.SetGraphicBrush(&aBrushItem); diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 8abcf7c64416..a34a47cf1847 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -1371,7 +1371,7 @@ void EscherPropertyContainer::CreateEmbeddedBitmapProperties( if (!xGraphic.is()) return; const Graphic aGraphic(xGraphic); - if (!aGraphic) + if (aGraphic.IsNone()) return; const GraphicObject aGraphicObject(aGraphic); if (aGraphicObject.GetType() == GraphicType::NONE) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 82a1abc20407..4caf50622d7f 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -6588,7 +6588,7 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool // size to the size of this record. sal_uInt64 maxSize = pGrStream == &rBLIPStream ? nLength : 0; Graphic aGraphic = rGF.ImportUnloadedGraphic(*pGrStream, maxSize); - if (aGraphic) + if (!aGraphic.IsNone()) { rData = aGraphic; nRes = ERRCODE_NONE; diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index f44858c88085..e8af0d2c06ce 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -128,9 +128,8 @@ public: Graphic& operator=( Graphic&& rGraphic ); bool operator==( const Graphic& rGraphic ) const; bool operator!=( const Graphic& rGraphic ) const; - bool operator!() const; - operator bool() const; + bool IsNone() const; void Clear(); diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 7d6ee3090263..bcd4d1cf9711 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -83,7 +83,7 @@ sal_uInt16 PPTExBulletProvider::GetId(Graphic const & rGraphic, Size& rGraphicSi { sal_uInt16 nRetValue = 0xffff; - if (rGraphic) + if (!rGraphic.IsNone()) { Graphic aMappedGraphic, aGraphic(rGraphic); std::unique_ptr xGraphicObject(new GraphicObject(aGraphic)); diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 9a2c3fb657f9..6a6c282dc4ab 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -515,7 +515,7 @@ bool LinkManager::GetGraphicFromAny(const OUString& rMimeType, OUString sURL = rValue.get(); if (!SvtSecurityOptions().isUntrustedReferer(rReferer)) rGraphic = vcl::graphic::loadFromURL(sURL, pParentWin); - if (!rGraphic) + if (rGraphic.IsNone()) rGraphic.SetDefaultType(); rGraphic.setOriginURL(sURL); return true; diff --git a/svtools/source/graphic/renderer.cxx b/svtools/source/graphic/renderer.cxx index d8b971566980..602fbc16e1f8 100644 --- a/svtools/source/graphic/renderer.cxx +++ b/svtools/source/graphic/renderer.cxx @@ -281,7 +281,7 @@ void SAL_CALL GraphicRendererVCL::render( const uno::Reference< graphic::XGraphi if( mpOutDev && mxDevice.is() && rxGraphic.is() ) { Graphic aGraphic(rxGraphic); - if (aGraphic) + if (!aGraphic.IsNone()) { GraphicObject aGraphicObject(aGraphic); aGraphicObject.Draw( mpOutDev, maDestRect.TopLeft(), maDestRect.GetSize() ); diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 9d6622e5b0a5..55a65e513734 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -436,7 +436,7 @@ void EmbeddedObjectRef::GetReplacement( bool bUpdate ) // note that UpdateReplacementOnDemand which resets mpImpl->pGraphic to null may have been called // e.g. when exporting ooo58458-1.odt to doc - if (bUpdate && (!mpImpl->pGraphic || !*mpImpl->pGraphic) && aOldGraphic) + if (bUpdate && (!mpImpl->pGraphic || mpImpl->pGraphic->IsNone()) && !aOldGraphic.IsNone()) { // We used to have an old graphic, tried to update and the update // failed. Go back to the old graphic instead of having no graphic at diff --git a/svx/qa/unit/XTableImportExportTest.cxx b/svx/qa/unit/XTableImportExportTest.cxx index cc86393577e3..bbbc67a314b2 100644 --- a/svx/qa/unit/XTableImportExportTest.cxx +++ b/svx/qa/unit/XTableImportExportTest.cxx @@ -76,7 +76,7 @@ CPPUNIT_TEST_FIXTURE(XTableImportExportTest, testImportExport) uno::Reference xGraphic(xBitmap, uno::UNO_QUERY); CPPUNIT_ASSERT(xGraphic.is()); Graphic aGraphic(xGraphic); - CPPUNIT_ASSERT(aGraphic); + CPPUNIT_ASSERT(!aGraphic.IsNone()); Bitmap aBitmap = aGraphic.GetBitmapEx().GetBitmap(); CPPUNIT_ASSERT_EQUAL(aChecksum, aBitmap.GetChecksum()); } diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index c92c4041ae41..8aa991a74084 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -1056,7 +1056,7 @@ void GalleryBrowser2::DispatchAdd( Graphic aGraphic; bool bGraphic = mpCurTheme->GetGraphic( mnCurActionPos, aGraphic ); - if ( bGraphic && !!aGraphic ) + if ( bGraphic && !aGraphic.IsNone() ) xGraphic.set( aGraphic.GetXGraphic() ); OSL_ENSURE( xGraphic.is(), "gallery item is graphic, but the reference is invalid!" ); diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 56e3f75fd7c0..2d9d8b61fc75 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -993,10 +993,10 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes { ::SolarMutexGuard aGuard; - if( !maGraphic && nullptr == mpUnoPage ) + if( maGraphic.IsNone() && nullptr == mpUnoPage ) return false; - if( !maGraphic && ( nullptr == mpUnoPage->GetSdrPage() || nullptr == mpDoc ) ) + if( maGraphic.IsNone() && ( nullptr == mpUnoPage->GetSdrPage() || nullptr == mpDoc ) ) return false; GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter(); @@ -1014,7 +1014,7 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes Graphic aGraphic = maGraphic; ErrCode nStatus = ERRCODE_NONE; - if (!maGraphic) + if (maGraphic.IsNone()) { SvtOptionsDrawinglayer aOptions; bool bAntiAliasing = aOptions.IsAntiAliasing(); @@ -1147,7 +1147,7 @@ void SAL_CALL GraphicExporter::setSourceDocument( const Reference< lang::XCompon break; maGraphic = Graphic(xGraphic); - if (maGraphic) + if (!maGraphic.IsNone()) return; else break; diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx index e9c16bc98bcb..31b000dd92aa 100644 --- a/svx/source/unodraw/XPropertyTable.cxx +++ b/svx/source/unodraw/XPropertyTable.cxx @@ -632,7 +632,7 @@ std::unique_ptr SvxUnoXBitmapTable::createEntry(const OUString& return nullptr; Graphic aGraphic(xGraphic); - if (!aGraphic) + if (aGraphic.IsNone()) return nullptr; GraphicObject aGraphicObject(aGraphic); diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index 9e9fe4071a59..760b6eb4da6a 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1273,7 +1273,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte if (rValue >>= aURL) { Graphic aGraphic = vcl::graphic::loadFromURL(aURL); - if (aGraphic) + if (!aGraphic.IsNone()) { static_cast(GetSdrObject())->SetGraphic(aGraphic); bOk = true; @@ -1285,7 +1285,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte if (xGraphic.is()) { Graphic aGraphic = xGraphic; - if (aGraphic) + if (!aGraphic.IsNone()) { static_cast(GetSdrObject())->SetGraphic(aGraphic); bOk = true; diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 4e99e87b21a5..b1a2a4b699fa 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -490,7 +490,7 @@ Graphic SvXMLGraphicHelper::ImplReadGraphic( const OUString& rPictureStorageName GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter(); std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream)); Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(*pStream); - if (aGraphic) + if (!aGraphic.IsNone()) aReturnGraphic = aGraphic; else rGraphicFilter.ImportGraphic(aReturnGraphic, "", *pStream); diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index 648a0ba8578f..e4b7bac69581 100644 --- a/svx/source/xoutdev/xattrbmp.cxx +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -284,7 +284,7 @@ bool XFillBitmapItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) if (bSetURL && !aURL.isEmpty()) { Graphic aGraphic = vcl::graphic::loadFromURL(aURL); - if (aGraphic) + if (!aGraphic.IsNone()) { maGraphicObject.SetGraphic(aGraphic.GetXGraphic()); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 85ecb0cae056..3e90fe359865 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -154,7 +154,7 @@ DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, "textbox_picturefill.docx") uno::Reference xGraphic(xBitmap, uno::UNO_QUERY); CPPUNIT_ASSERT(xGraphic.is()); Graphic aGraphic(xGraphic); - CPPUNIT_ASSERT(aGraphic); + CPPUNIT_ASSERT(!aGraphic.IsNone()); CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0L); CPPUNIT_ASSERT_EQUAL(447L, aGraphic.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL(528L, aGraphic.GetSizePixel().Height()); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index d5dfc5681fb6..99358c62f5ab 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1617,7 +1617,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& } } - if (aGraphic) + if (!aGraphic.IsNone()) { const ::SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if (pIdx) @@ -1653,7 +1653,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& } } - if (aGraphic) + if (!aGraphic.IsNone()) { const ::SwFormatContent* pCnt = &pFormat->GetContent(); if ( pCnt->GetContentIdx() && pDoc->GetNodes()[ pCnt->GetContentIdx()->GetIndex() + 1 ] ) diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 3a8e27b15774..ebaf24260187 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -2020,7 +2020,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( } Graphic aGraphic = vcl::graphic::loadFromURL(aURL); - if (aGraphic) + if (!aGraphic.IsNone()) pSetBrush->SetGraphic(aGraphic); } else diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 0b2c043572db..8d63a4ab8171 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -296,14 +296,9 @@ bool Graphic::operator!=( const Graphic& rGraphic ) const return (*mxImpGraphic != *rGraphic.mxImpGraphic); } -bool Graphic::operator!() const +bool Graphic::IsNone() const { - return (GraphicType::NONE == mxImpGraphic->ImplGetType()); -} - -Graphic::operator bool() const -{ - return GraphicType::NONE != mxImpGraphic->ImplGetType(); + return GraphicType::NONE == mxImpGraphic->ImplGetType(); } void Graphic::Clear() diff --git a/vcl/source/graphic/GraphicObject.cxx b/vcl/source/graphic/GraphicObject.cxx index be2dc76bd2a6..8e1b50a2c0da 100644 --- a/vcl/source/graphic/GraphicObject.cxx +++ b/vcl/source/graphic/GraphicObject.cxx @@ -71,7 +71,7 @@ void SearchForGraphics(uno::Reference const & xInterface, if (!sURL.isEmpty() && !GraphicObject::isGraphicObjectUniqueIdURL(sURL)) { Graphic aGraphic = vcl::graphic::loadFromURL(sURL); - if (aGraphic) + if (!aGraphic.IsNone()) { raGraphicList.push_back(aGraphic.GetXGraphic()); } diff --git a/vcl/source/graphic/UnoGraphic.cxx b/vcl/source/graphic/UnoGraphic.cxx index bc2ce6349f55..446da50867a4 100644 --- a/vcl/source/graphic/UnoGraphic.cxx +++ b/vcl/source/graphic/UnoGraphic.cxx @@ -125,15 +125,10 @@ sal_Int8 SAL_CALL Graphic::getType() { sal_Int8 cRet = graphic::GraphicType::EMPTY; - if (!!maGraphic) + if (!maGraphic.IsNone()) { - ::GraphicType eType = maGraphic.GetType(); - - if (eType != ::GraphicType::NONE) - { - cRet = (eType == ::GraphicType::Bitmap) ? graphic::GraphicType::PIXEL - : graphic::GraphicType::VECTOR; - } + cRet = (maGraphic.GetType() == ::GraphicType::Bitmap) ? graphic::GraphicType::PIXEL + : graphic::GraphicType::VECTOR; } return cRet; @@ -146,7 +141,7 @@ awt::Size SAL_CALL Graphic::getSize() SolarMutexGuard aGuard; Size aVclSize; - if (!!maGraphic && maGraphic.GetType() != ::GraphicType::NONE) + if (!maGraphic.IsNone()) { aVclSize = maGraphic.GetSizePixel(); } @@ -157,7 +152,7 @@ uno::Sequence SAL_CALL Graphic::getDIB() { SolarMutexGuard aGuard; - if (!!maGraphic && maGraphic.GetType() != ::GraphicType::NONE) + if (!maGraphic.IsNone()) { SvMemoryStream aMemoryStream; @@ -174,7 +169,7 @@ uno::Sequence SAL_CALL Graphic::getMaskDIB() { SolarMutexGuard aGuard; - if (!!maGraphic && maGraphic.GetType() != ::GraphicType::NONE) + if (!maGraphic.IsNone()) { SvMemoryStream aMemoryStream; diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index 9e99cd89decd..450fd2b26f4b 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -408,10 +408,10 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co if (bLazyRead) { Graphic aGraphic = rFilter.ImportUnloadedGraphic(*pIStm); - if (aGraphic) + if (!aGraphic.IsNone()) aVCLGraphic = aGraphic; } - if (!aVCLGraphic) + if (aVCLGraphic.IsNone()) error = rFilter.ImportGraphic(aVCLGraphic, aPath, *pIStm, GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pExtHeader); -- cgit