25#include <osl/diagnose.h>
35#include <com/sun/star/container/XNameContainer.hpp>
36#include <com/sun/star/beans/XPropertySet.hpp>
37#include <com/sun/star/graphic/XGraphic.hpp>
43using com::sun::star::uno::XInterface;
44using com::sun::star::uno::UNO_QUERY;
46using com::sun::star::container::XNameContainer;
49#define WATERMARK_LUM_OFFSET 50
50#define WATERMARK_CON_OFFSET -70
56 std::vector<uno::Reference<css::graphic::XGraphic>> & raGraphicList)
58 uno::Reference<beans::XPropertySet> xPropertySet(xInterface, UNO_QUERY);
59 if (xPropertySet.is())
61 if (xPropertySet->getPropertySetInfo()->hasPropertyByName(
"ImageURL"))
64 xPropertySet->getPropertyValue(
"ImageURL") >>= sURL;
73 }
else if (xPropertySet->getPropertySetInfo()->hasPropertyByName(
"Graphic"))
75 uno::Reference<css::graphic::XGraphic> xGraphic;
76 xPropertySet->getPropertyValue(
"Graphic") >>= xGraphic;
79 raGraphicList.push_back(xGraphic);
86 const css::uno::Sequence<OUString> aElementNames = xContainer->getElementNames();
87 for (OUString
const & rName : aElementNames)
89 uno::Reference<XInterface> xInnerInterface;
90 xContainer->getByName(rName) >>= xInnerInterface;
113 if( aGraphic.IsSupportedGraphic() )
121 aPoly.Rotate( aPt, nRot10 );
123 aPt = aRotBoundRect.TopLeft();
124 aSz = aRotBoundRect.GetSize();
127 aGraphic.Draw(rOut, aPt, aSz);
142 switch( aAttr.GetDrawMode() )
166 rBmpEx.
Adjust( aAttr.GetLuminance(), aAttr.GetContrast(),
167 aAttr.GetChannelR(), aAttr.GetChannelG(), aAttr.GetChannelB(),
168 aAttr.GetGamma(), aAttr.IsInvert() );
173 rBmpEx.
Mirror( aAttr.GetMirrorFlags() );
178 rBmpEx.
Rotate( aAttr.GetRotation(), COL_TRANSPARENT );
193 switch( aAttr.GetDrawMode() )
217 rMtf.
Adjust( aAttr.GetLuminance(), aAttr.GetContrast(),
218 aAttr.GetChannelR(), aAttr.GetChannelG(), aAttr.GetChannelB(),
219 aAttr.GetGamma(), aAttr.IsInvert() );
224 rMtf.
Mirror( aAttr.GetMirrorFlags() );
229 rMtf.
Rotate( aAttr.GetRotation() );
234 OSL_FAIL(
"Missing implementation: Mtf-Transparency" );
244 switch( aAttr.GetDrawMode() )
268 rAnimation.
Adjust( aAttr.GetLuminance(), aAttr.GetContrast(),
269 aAttr.GetChannelR(), aAttr.GetChannelG(), aAttr.GetChannelB(),
270 aAttr.GetGamma(), aAttr.IsInvert() );
275 rAnimation.
Mirror( aAttr.GetMirrorFlags() );
280 OSL_FAIL(
"Missing implementation: Animation-Rotation" );
285 OSL_FAIL(
"Missing implementation: Animation-Transparency" );
311 , maAttr(rGraphicObj.maAttr)
359 const Point aOldOrigin( rPt );
360 const MapMode aMap100( MapUnit::Map100thMM );
366 aClipPoly.
Rotate( rPt, nRot10 );
367 bRectClipRegion =
false;
370 bRectClipRegion =
true;
385 if( !aSize100.
IsEmpty() && nTotalWidth > 0 && nTotalHeight > 0 )
387 double fScale =
static_cast<double>(aSize100.
Width()) / nTotalWidth;
391 fScale =
static_cast<double>(rSz.
Width()) / aSize100.
Width();
395 fScale =
static_cast<double>(aSize100.
Height()) / nTotalHeight;
399 fScale =
static_cast<double>(rSz.
Height()) / aSize100.
Height();
407 aOriginPoly[ 0 ] = rPt;
408 aOriginPoly.
Rotate( aOldOrigin, nRot10 );
409 rPt = aOriginPoly[ 0 ];
421 if( &rGraphicObj !=
this )
474 if( aSz.
Width() < 0 )
493 const bool bCrop =
ImplGetCropParams(rOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip);
513 bRet = lclDrawObj(rOut, aPt, aSz, *
this, aAttr);
524 const Size& rOffset,
int nTileCacheSize1D)
537 nTileCacheSize1D /= 2;
539 nTileCacheSize1D /= 2;
541 ImplDrawTiled(rOut, rArea, aOutTileSize, rOffset,
nullptr, nTileCacheSize1D);
564 const bool bCrop =
ImplGetCropParams(rOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip);
583 mxSimpleCache->maGraphic.StartAnimation(rOut, aPt, aSz, nRendererId, pFirstFrameOutDev);
591 bRet =
Draw(rOut, rPt, rSz, &aAttr);
621 const MapMode aMap100( MapUnit::Map100thMM );
624 Size aCropRightBottom;
630 if (aMapGraph.
GetMapUnit() == MapUnit::MapPixel)
670 aMtf.
Scale(
static_cast<double>(rDestSize.
Width()) / (aSrcSize.
Width() - aCropLeftTop.
Width() - aCropRightBottom.
Width()),
671 static_cast<double>(rDestSize.
Height()) / (aSrcSize.
Height() - aCropLeftTop.
Height() - aCropRightBottom.
Height()) );
693 aTransGraphic = aMtf;
703 if (aMapGraph.
GetMapUnit() == MapUnit::MapPixel)
732 && aSrcSizePixel.
Width())
756 aSrcSizePixel.
Width() - aCropRightBottom.
Width(),
765 for(
size_t nFrame=0; nFrame<aAnim.
Count(); ++nFrame )
779 aCropRectRel, rDestSize,
false );
781 aAnim.
Replace( aAnimationFrame, nFrame );
788 if( aCropLeftTop.
Width() < 0 ||
789 aCropLeftTop.
Height() < 0 ||
790 aCropRightBottom.
Width() < 0 ||
791 aCropRightBottom.
Height() < 0 )
803 if( aCropLeftTop.
Width() < 0 ||
804 aCropLeftTop.
Height() < 0 )
806 Point aPosOffset( aCropLeftTop.
Width() < 0 ? -aCropLeftTop.
Width() : 0,
807 aCropLeftTop.
Height() < 0 ? -aCropLeftTop.
Height() : 0 );
809 for(
size_t nFrame=0; nFrame<aAnim.
Count(); ++nFrame )
815 aAnim.
Replace( aAnimationFrame, nFrame );
819 aTransGraphic = aAnim;
824 aCropRect, rDestSize,
true );
826 aTransGraphic = aBitmapEx;
836 return aTransGraphic;
857 aGraphic = aAnimation;
879 aGraphic = aAnimation;
902 double fBottomCrop)
const
904 const MapMode aMapMode100thmm(MapUnit::Map100thMM);
906 double fFactorX(1.0);
907 double fFactorY(1.0);
918 const double fDivX(aBitmapSize.
Width() - fLeftCrop - fRightCrop);
919 const double fDivY(aBitmapSize.
Height() - fTopCrop - fBottomCrop);
923 fFactorX = fabs(fWidth) / fDivX;
928 fFactorY = fabs(fHeight) / fDivY;
#define WATERMARK_CON_OFFSET
#define WATERMARK_LUM_OFFSET
Sequence< NamedValue > maUserData
void Replace(const AnimationFrame &rNewAnimationBmp, sal_uInt16 nAnimation)
void Convert(BmpConversion eConversion)
const Size & GetDisplaySizePixel() const
void Mirror(BmpMirrorFlags nMirrorFlags)
void SetLoopCount(const sal_uInt32 nLoopCount)
const AnimationFrame & Get(sal_uInt16 nAnimation) const
void Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false)
void SetDisplaySizePixel(const Size &rSize)
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
bool Convert(BmpConversion eConversion)
Convert bitmap format.
bool Rotate(Degree10 nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
void AdjustTransparency(sal_uInt8 cTrans)
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Change various global color characteristics.
const Size & GetSizePixel() const
Degree10 GetRotation() const
tools::Long GetTopCrop() const
bool IsTransparent() const
bool IsSpecialDrawMode() const
tools::Long GetBottomCrop() const
tools::Long GetRightCrop() const
void SetMirrorFlags(BmpMirrorFlags nMirrFlags)
BmpMirrorFlags GetMirrorFlags() const
tools::Long GetLeftCrop() const
void VCL_DLLPRIVATE ImplTransformBitmap(BitmapEx &rBmpEx, const GraphicAttr &rAttr, const Size &rCropLeftTop, const Size &rCropRightBottom, const tools::Rectangle &rCropRect, const Size &rDstSize, bool bEnlarge) const
static bool isGraphicObjectUniqueIdURL(std::u16string_view rURL)
basegfx::B2DVector calculateCropScaling(double fWidth, double fHeight, double fLeftCrop, double fTopCrop, double fRightCrop, double fBottomCrop) const
void SetGraphic(const Graphic &rGraphic)
MapMode GetPrefMapMode() const
const Graphic & GetGraphic() const
GraphicType GetType() const
Graphic GetTransformedGraphic(const Size &rDestSize, const MapMode &rDestMap, const GraphicAttr &rAttr) const
Get graphic transformed according to given attributes.
bool VCL_DLLPRIVATE ImplDrawTiled(OutputDevice &rOut, const tools::Rectangle &rArea, const Size &rSizePixel, const Size &rOffset, const GraphicAttr *pAttr, int nTileCacheSize1D)
void StopAnimation(const OutputDevice *pOut=nullptr, tools::Long nExtraData=0)
const GraphicAttr & GetAttr() const
bool StartAnimation(OutputDevice &rOut, const Point &rPt, const Size &rSz, tools::Long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
bool IsTransparent() const
bool operator==(const GraphicObject &rCacheObj) const
void DrawTiled(OutputDevice &rOut, const tools::Rectangle &rArea, const Size &rSize, const Size &rOffset, int nTileCacheSize1D=128)
Draw the graphic repeatedly into the given output rectangle.
GraphicObject & operator=(const GraphicObject &rCacheObj)
bool Draw(OutputDevice &rOut, const Point &rPt, const Size &rSz, const GraphicAttr *pAttr=nullptr) const
bool VCL_DLLPRIVATE ImplGetCropParams(const OutputDevice &rOut, Point &rPt, Size &rSz, const GraphicAttr *pAttr, tools::PolyPolygon &rClipPolyPoly, bool &bRectClipRegion) const
OString GetUniqueID() const
void SetAttr(const GraphicAttr &rAttr)
std::unique_ptr< GrfSimpleCacheObj > mxSimpleCache
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
OString getUniqueID() const
Animation GetAnimation() const
void SetPrefMapMode(const MapMode &rPrefMapMode)
bool IsSupportedGraphic() const
sal_uInt32 GetAnimationLoopCount() const
const GDIMetaFile & GetGDIMetaFile() const
GraphicType GetType() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
MapMode GetPrefMapMode() const
void SetPrefSize(const Size &rPrefSize)
bool IsTransparent() const
void SetOrigin(const Point &rOrigin)
MapUnit GetMapUnit() const
const Point & GetOrigin() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void SetDrawMode(DrawModeFlags nDrawMode)
DrawModeFlags GetDrawMode() const
void IntersectClipRegion(const tools::Rectangle &rRect)
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
tools::Long FRound(double fVal)
B2IRange fround(const B2DRange &rRange)
class SAL_NO_VTABLE XPropertySet
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
void SearchForGraphics(uno::Reference< uno::XInterface > const &xInterface, std::vector< uno::Reference< css::graphic::XGraphic > > &raGraphicList)
Graphic loadFromURL(OUString const &rURL, weld::Window *pParentWin)
GrfSimpleCacheObj(Graphic aGraphic, const GraphicAttr &rAttr)