26#include <com/sun/star/lang/XMultiServiceFactory.hpp>
27#include <com/sun/star/graphic/PdfTools.hpp>
28#include <com/sun/star/graphic/SvgTools.hpp>
29#include <com/sun/star/graphic/EmfTools.hpp>
30#include <com/sun/star/graphic/Primitive2DTools.hpp>
31#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
32#include <com/sun/star/util/XAccounting.hpp>
33#include <com/sun/star/util/XBinaryDataContainer.hpp>
50 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
52 const sal_uInt32 nMaximumQuadraticPixels,
54 const std::optional<Size>& rTargetDPI)
58 if(!rSequence.empty())
64 uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
65 const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer = graphic::Primitive2DTools::create(xContext);
67 uno::Sequence< beans::PropertyValue > aViewParameters = {
70 geometry::RealRectangle2D aRealRect;
72 aRealRect.X1 = rTargetRange.
getMinX();
73 aRealRect.Y1 = rTargetRange.
getMinY();
74 aRealRect.X2 = rTargetRange.
getMaxX();
75 aRealRect.Y2 = rTargetRange.
getMaxY();
79 if (rTargetDPI.has_value())
84 const uno::Reference< rendering::XBitmap > xBitmap(
85 xPrimitive2DRenderer->rasterize(
91 nMaximumQuadraticPixels));
95 const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
99 catch (
const uno::Exception&)
103 catch (
const std::exception& e)
105 SAL_WARN(
"vcl",
"Got no graphic::XPrimitive2DRenderer! : " << e.what());
113 std::deque<uno::Reference<graphic::XPrimitive2D>>
const& rSequence)
116 for (
auto& it : rSequence)
118 uno::Reference<util::XAccounting>
const xAcc(it, uno::UNO_QUERY);
120 nRet += xAcc->estimateUsage();
152 std::vector<BitmapEx> aBitmaps;
153 sal_Int32 nUsePageIndex = 0;
159 if (!aBitmaps.empty())
193 uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
201 const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext);
203 if (xInputStream.is())
204 maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(xInputStream, OUString()));
211 const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext);
215 if (xInputStream.is())
217 uno::Sequence< ::beans::PropertyValue > aPropertySequence;
220 geometry::RealPoint2D aSizeHint;
223 xEmfParser->setSizeHint(aSizeHint);
230 maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xEmfParser->getDecomposition(xInputStream, OUString(), aPropertySequence));
237 const uno::Reference<graphic::XPdfDecomposer> xPdfDecomposer = graphic::PdfTools::create(xContext);
244 auto xPrimitive2D = xPdfDecomposer->getDecomposition(xDataContainer, aDecompositionParameters);
245 maSequence = comphelper::sequenceToContainer<std::deque<uno::Reference<graphic::XPrimitive2D>>>(xPrimitive2D);
254 geometry::RealRectangle2D aRealRect;
255 uno::Sequence< beans::PropertyValue > aViewParameters;
260 const css::uno::Reference< css::graphic::XPrimitive2D > xReference(
maSequence[
a]);
264 aRealRect = xReference->getRange(aViewParameters);
294 sal_Int32 nPageIndex)
295: maDataContainer(
std::move(aDataContainer)),
296 mbSequenceCreated(false),
297 mNestedBitmapSize(0),
299 mnPageIndex(nPageIndex)
304 const OUString& rPath,
306: mbSequenceCreated(false),
307 mNestedBitmapSize(0),
sal_uInt64 BitmapChecksum
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
css::uno::Reference< css::io::XInputStream > getAsXInputStream()
const sal_uInt8 * getData() const
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
sal_uInt64 remainingSize()
void ensurePdfReplacement()
const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > & getPrimitive2DSequence() const
bool operator==(const VectorGraphicData &rCandidate) const
compare op
BitmapChecksum GetChecksum() const
void ensureSequenceAndRange()
std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence
const BitmapEx & getReplacement() const
VectorGraphicData(const VectorGraphicData &)=delete
const basegfx::B2DRange & getRange() const
data read and evtl. on demand creation
BinaryDataContainer maDataContainer
basegfx::B2DRange maRange
basegfx::B2DTuple maSizeHint
Useful for PDF, which is vector-based, but still rendered to a bitmap.
std::pair< State, size_t > getSizeBytes() const
sal_Int32 mnPageIndex
If the vector format has more pages this denotes which page to render.
const VectorGraphicDataType & getType() const
const BinaryDataContainer & getBinaryDataContainer() const
data read
void expand(const Tuple2D< TYPE > &rTuple)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN(area, stream)
constexpr OUStringLiteral aData
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
size_t RenderPDFBitmaps(const void *pBuffer, int nSize, std::vector< BitmapEx > &rBitmaps, const size_t nFirstPage, int nPages, const basegfx::B2DTuple *pSizeHint)
Fills the rBitmaps vector with rendered pages.
BitmapEx convertPrimitive2DSequenceToBitmapEx(const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > &rSequence, const basegfx::B2DRange &rTargetRange, const sal_uInt32 nMaximumQuadraticPixels, const o3tl::Length eTargetUnit, const std::optional< Size > &rTargetDPI)
static size_t estimateSize(std::deque< uno::Reference< graphic::XPrimitive2D > > const &rSequence)