Kaydet (Commit) 7334034a authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Tomaž Vajngerl

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: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst c0ff8a24
......@@ -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;
}
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
......
......@@ -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();
......
......@@ -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));
......
......@@ -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;
......
......@@ -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() );
......
......@@ -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
......
......@@ -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());
}
......
......@@ -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!" );
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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());
}
......
......@@ -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());
......
......@@ -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 ] )
......
......@@ -2020,7 +2020,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
}
Graphic aGraphic = vcl::graphic::loadFromURL(aURL);
if (aGraphic)
if (!aGraphic.IsNone())
pSetBrush->SetGraphic(aGraphic);
}
else
......
......@@ -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()
......
......@@ -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());
}
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment