summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-29 15:50:02 +0200
committerTomaž Vajngerl <quikee@gmail.com>2019-04-30 04:57:21 +0200
commit7334034ae93b49fc93b5859a3c047a319d138282 (patch)
tree6216d895de7ede63bd946a0e75913a3b07e4c2b6
parentc0ff8a24365456383900ed7958c8fb9ea68043e9 (diff)
drop Graphic::operator bool
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 <quikee@gmail.com>
-rw-r--r--editeng/source/items/frmitems.cxx6
-rw-r--r--editeng/source/uno/unonrule.cxx2
-rw-r--r--filter/source/msfilter/escherex.cxx2
-rw-r--r--filter/source/msfilter/msdffimp.cxx2
-rw-r--r--include/vcl/graph.hxx3
-rw-r--r--sd/source/filter/eppt/epptso.cxx2
-rw-r--r--sfx2/source/appl/linkmgr2.cxx2
-rw-r--r--svtools/source/graphic/renderer.cxx2
-rw-r--r--svtools/source/misc/embedhlp.cxx2
-rw-r--r--svx/qa/unit/XTableImportExportTest.cxx2
-rw-r--r--svx/source/gallery2/galbrws2.cxx2
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx8
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx2
-rw-r--r--svx/source/unodraw/unoshap2.cxx4
-rw-r--r--svx/source/xml/xmlgrhlp.cxx2
-rw-r--r--svx/source/xoutdev/xattrbmp.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx2
-rw-r--r--sw/source/core/unocore/unoframe.cxx4
-rw-r--r--sw/source/core/unocore/unosett.cxx2
-rw-r--r--vcl/source/gdi/graph.cxx9
-rw-r--r--vcl/source/graphic/GraphicObject.cxx2
-rw-r--r--vcl/source/graphic/UnoGraphic.cxx17
-rw-r--r--vcl/source/graphic/UnoGraphicProvider.cxx4
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<beans::Propert
if (aVal >>= 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<GraphicObject> 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<OUString>();
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<graphic::XGraphic> 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<XPropertyEntry> 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<SdrGrafObj*>(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<SdrGrafObj*>(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<SvStream> 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<graphic::XGraphic> 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<uno::XInterface> 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_Int8> SAL_CALL Graphic::getDIB()
{
SolarMutexGuard aGuard;
- if (!!maGraphic && maGraphic.GetType() != ::GraphicType::NONE)
+ if (!maGraphic.IsNone())
{
SvMemoryStream aMemoryStream;
@@ -174,7 +169,7 @@ uno::Sequence<sal_Int8> 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);