26#include <com/sun/star/graphic/XGraphic.hpp>
36void ImplDrawDefault(
OutputDevice& rOutDev,
const OUString* pText,
38 const Point& rDestPt,
const Size& rDestSize)
41 sal_uInt16 nPixelWidth =
nPixel;
42 Point aPoint( rDestPt.
X() + nPixelWidth, rDestPt.
Y() + nPixelWidth );
43 Size aSize( rDestSize.
Width() - ( nPixelWidth << 1 ), rDestSize.
Height() - ( nPixelWidth << 1 ) );
44 bool bFilled = ( pBitmapEx !=
nullptr || pFont != nullptr );
54 aPoint.AdjustX(nPixelWidth + 2*nPixel );
55 aPoint.AdjustY(nPixelWidth + 2*nPixel );
56 aSize.AdjustWidth( -(2*nPixelWidth + 4*nPixel) );
57 aSize.AdjustHeight( -(2*nPixelWidth + 4*nPixel) );
59 if( !aSize.IsEmpty() && pBitmapEx && !pBitmapEx->
IsEmpty() )
63 if( aSize.Height() > aBitmapSize.Height() && aSize.Width() > aBitmapSize.Width() )
66 aPoint.AdjustX(aBitmapSize.Width() + 2*nPixel );
67 aSize.AdjustWidth( -(aBitmapSize.Width() + 2*nPixel) );
71 if ( !aSize.IsEmpty() && pFont && pText && pText->getLength() && rOutDev.
IsOutputEnabled() )
73 MapMode aMapMode( MapUnit::MapPoint );
79 nStep = aSz.
Height() - nThreshold;
95 if ( nTextWidth <= nWidth || aSz.
Height() <= nThreshold )
100 while( nStart < pText->
getLength() && (*pText)[nStart] ==
' ' )
102 while( nStart+nLen < pText->
getLength() && (*pText)[nStart+nLen] !=
' ' )
104 while( nStart < pText->
getLength() && nLines-- )
106 sal_Int32 nNext = nLen;
109 while ( nStart+nNext < pText->
getLength() && (*pText)[nStart+nNext] ==
' ' )
111 while ( nStart+nNext < pText->
getLength() && (*pText)[nStart+nNext] !=
' ' )
113 nTextWidth = rOutDev.
GetTextWidth( *pText, nStart, nNext );
114 if ( nTextWidth > aSize.Width() )
118 while ( nStart+nNext < pText->
getLength() );
122 while( nTextWidth > aSize.Width() )
123 nTextWidth = rOutDev.
GetTextWidth( *pText, nStart, --n );
124 rOutDev.
DrawText( aPoint, *pText, nStart, n );
126 aPoint.AdjustY(nTextHeight );
127 nStart = sal::static_int_cast<sal_uInt16>(nStart + nLen);
129 while( nStart < pText->
getLength() && (*pText)[nStart] ==
' ' )
146 aBorderRect.AdjustLeft( 1 );
147 aBorderRect.AdjustTop( 1 );
148 aBorderRect.AdjustRight( -1 );
149 aBorderRect.AdjustBottom( -1 );
152 rOutDev.
DrawLine( aBorderRect.TopLeft(), aBorderRect.BottomRight() );
153 rOutDev.
DrawLine( aBorderRect.TopRight(), aBorderRect.BottomLeft() );
162 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance())
175 : mxImpGraphic(std::move(rGraphic.mxImpGraphic))
180 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance(rGfxLink, nPageIndex))
185 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance(rGraphicExternalLink))
190 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance(rBmpEx))
200 OUString aStock = rImage.
GetStock();
201 if (aStock.getLength())
202 mxImpGraphic->setOriginURL(
"private:graphicrepository/" + aStock);
206 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance(rVectorGraphicDataPtr))
211 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance(rAnimation))
216 : mxImpGraphic(
vcl::graphic::Manager::
get().newInstance(rMtf))
222 const ::unographic::Graphic* pUnoGraphic =
dynamic_cast<::
unographic::Graphic*
>(rxGraphic.get());
223 const ::Graphic* pGraphic = pUnoGraphic ? &pUnoGraphic->
GetGraphic() :
nullptr;
227 if (pGraphic->IsAnimated())
256 if( &rGraphic !=
this )
269 mxImpGraphic = std::move(rGraphic.mxImpGraphic);
352 uno::Reference<css::graphic::XGraphic> xGraphic;
357 pUnoGraphic->init(*
this);
358 xGraphic = pUnoGraphic;
396 nGrfDPIx = aGrfPixelSize.
Width() / (
static_cast<double>(aGrfMap.
GetScaleX()) * aGrfPrefMapModeSize.
Width() );
397 nGrfDPIy = aGrfPixelSize.
Height() / (
static_cast<double>(aGrfMap.
GetScaleY()) * aGrfPrefMapModeSize.
Height() );
402 aGrfPrefMapModeSize, aGrfMap,
MapMode(MapUnit::Map1000thInch));
403 nGrfDPIx = aGrf1000thInchSize.
Width() == 0
404 ? 0.0 : 1000.0 * aGrfPixelSize.
Width() / aGrf1000thInchSize.
Width();
405 nGrfDPIy = aGrf1000thInchSize.
Height() == 0
406 ? 0.0 : 1000.0 * aGrfPixelSize.
Height() / aGrf1000thInchSize.
Height();
435 const Size& rDestSz)
const
438 ImplDrawDefault(rOutDev,
nullptr,
nullptr,
nullptr, rDestPt, rDestSz);
445 const Point& rDestPt,
const Size& rDestSz)
447 ImplDrawDefault(rOutDev, &rText, &rFont, &rBitmap, rDestPt, rDestSz);
455 mxImpGraphic->startAnimation(rOutDev, rDestPt, rDestSz, nRendererId, pFirstFrameOutDev);
554 OString aUniqueString;
557 return aUniqueString;
sal_uInt64 BitmapChecksum
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
const Size & GetSizePixel() const
void StopAnimation(const OutputDevice *pOutputDevice, tools::Long nExtraData)
sal_uLong GetSizeBytes() const
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
SAL_DLLPRIVATE void ImplTestRefCount()
void SetAnimationNotifyHdl(const Link< Animation *, void > &rLink)
basegfx::B2DSize GetPPI() const
std::shared_ptr< ImpGraphic > mxImpGraphic
OString getUniqueID() const
Animation GetAnimation() const
OUString getOriginURL() const
void SetPrefMapMode(const MapMode &rPrefMapMode)
void SetDummyContext(bool value)
Graphic & operator=(const Graphic &rGraphic)
bool IsSupportedGraphic() const
const std::shared_ptr< GfxLink > & GetSharedGfxLink() const
void SetReaderContext(const std::shared_ptr< GraphicReader > &pReader)
sal_uInt32 GetAnimationLoopCount() const
const GDIMetaFile & GetGDIMetaFile() const
bool IsDummyContext() const
GraphicType GetType() const
void SetGfxLink(const std::shared_ptr< GfxLink > &rGfxLink)
GfxLink GetGfxLink() const
sal_Int32 getPageNumber() const
Get the page number of the multi-page source this Graphic is rendered from.
BitmapChecksum GetChecksum() const
const BitmapEx & GetBitmapExRef() const
Gives direct access to the contained BitmapEx.
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
MapMode GetPrefMapMode() const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
void Draw(OutputDevice &rOutDev, const Point &rDestPt) const
void StartAnimation(OutputDevice &rOutDev, const Point &rDestPt, const Size &rDestSize, tools::Long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
Link< Animation *, void > GetAnimationNotifyHdl() const
std::shared_ptr< GraphicReader > & GetReaderContext()
void SetPrefSize(const Size &rPrefSize)
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
static void DrawEx(OutputDevice &rOutDev, const OUString &rText, vcl::Font &rFont, const BitmapEx &rBitmap, const Point &rDestPt, const Size &rDestSize)
bool IsTransparent() const
bool operator!=(const Graphic &rGraphic) const
bool operator==(const Graphic &rGraphic) const
void setOriginURL(OUString const &rOriginURL)
OUString GetStock() const
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Fraction & GetScaleY() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
virtual void DrawBorder(tools::Rectangle aBorderRect)
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawLine(const Point &rStartPt, const Point &rEndPt)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
bool IsOutputEnabled() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
constexpr tools::Long Width() const
const ::Graphic & GetGraphic() const
void SetFontSize(const Size &)
std::shared_ptr< ImpGraphic > newInstance()
std::shared_ptr< ImpGraphic > copy(std::shared_ptr< ImpGraphic > const &pImpGraphic)
double getLength(const B2DPolygon &rCandidate)
std::shared_ptr< T > make_shared(Args &&... args)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)