25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/graphic/PdfTools.hpp>
27 #include <com/sun/star/graphic/SvgTools.hpp>
28 #include <com/sun/star/graphic/EmfTools.hpp>
29 #include <com/sun/star/graphic/Primitive2DTools.hpp>
30 #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
31 #include <com/sun/star/util/XAccounting.hpp>
32 #include <com/sun/star/util/XBinaryDataContainer.hpp>
49 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
51 const sal_uInt32 nMaximumQuadraticPixels,
53 const std::optional<Size>& rTargetDPI)
57 if(!rSequence.empty())
64 const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer = graphic::Primitive2DTools::create(xContext);
66 uno::Sequence< beans::PropertyValue > aViewParameters = {
69 geometry::RealRectangle2D aRealRect;
71 aRealRect.X1 = rTargetRange.
getMinX();
72 aRealRect.Y1 = rTargetRange.
getMinY();
73 aRealRect.X2 = rTargetRange.
getMaxX();
74 aRealRect.Y2 = rTargetRange.
getMaxY();
78 if (rTargetDPI.has_value())
83 const uno::Reference< rendering::XBitmap > xBitmap(
84 xPrimitive2DRenderer->rasterize(
90 nMaximumQuadraticPixels));
94 const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
98 catch (
const uno::Exception&)
102 catch (
const std::exception& e)
104 SAL_WARN(
"vcl",
"Got no graphic::XPrimitive2DRenderer! : " << e.what());
112 std::deque<uno::Reference<graphic::XPrimitive2D>>
const& rSequence)
115 for (
auto& it : rSequence)
117 uno::Reference<util::XAccounting>
const xAcc(it, uno::UNO_QUERY);
119 nRet += xAcc->estimateUsage();
161 std::vector<BitmapEx> aBitmaps;
162 sal_Int32 nUsePageIndex = 0;
168 if (!aBitmaps.empty())
213 const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext);
215 if (xInputStream.is())
223 const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext);
229 uno::Sequence< ::beans::PropertyValue > aPropertySequence;
236 if (xInputStream.is())
239 geometry::RealPoint2D aSizeHint;
242 xEmfParser->setSizeHint(aSizeHint);
246 auto aVector = comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aPropertySequence);
251 maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xEmfParser->getDecomposition(xInputStream, OUString(), aPropertySequence));
258 const uno::Reference<graphic::XPdfDecomposer> xPdfDecomposer = graphic::PdfTools::create(xContext);
265 auto xPrimitive2D = xPdfDecomposer->getDecomposition(xDataContainer, aDecompositionParameters);
266 maSequence = comphelper::sequenceToContainer<std::deque<uno::Reference<graphic::XPrimitive2D>>>(xPrimitive2D);
275 geometry::RealRectangle2D aRealRect;
276 uno::Sequence< beans::PropertyValue > aViewParameters;
281 const css::uno::Reference< css::graphic::XPrimitive2D > xReference(
maSequence[
a]);
285 aRealRect = xReference->getRange(aViewParameters);
315 sal_Int32 nPageIndex)
316 : maDataContainer(rDataContainer),
317 mbSequenceCreated(
false),
318 mNestedBitmapSize(0),
320 mnPageIndex(nPageIndex)
325 const OUString& rPath,
327 : mbSequenceCreated(
false),
328 mNestedBitmapSize(0),
339 auto pData = aVectorGraphicDataArray.getArray();
const BitmapEx & getReplacement() const
sal_uInt64 BitmapChecksum
void expand(const B2DTuple &rTuple)
sal_Int32 mnPageIndex
If the vector format has more pages this denotes which page to render.
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.
const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > & getPrimitive2DSequence() const
std::unique_ptr< sal_Int32[]> pData
void ensurePdfReplacement()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
basegfx::B2DTuple maSizeHint
Useful for PDF, which is vector-based, but still rendered to a bitmap.
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
const basegfx::B2DRange & getRange() const
data read and evtl. on demand creation
void setWmfExternalHeader(const WmfExternal &aExtHeader)
special: needed for emf/wmf, maybe replaced by scaling the result later (?)
const BinaryDataContainer & getBinaryDataContainer() const
data read
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
BitmapChecksum GetChecksum() const
constexpr tools::Long getHeight() const
sal_uInt64 remainingSize()
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
basegfx::B2DRange maRange
std::pair< State, size_t > getSizeBytes() const
#define TOOLS_WARN_EXCEPTION(area, stream)
void ensureSequenceAndRange()
bool operator==(const VectorGraphicData &rCandidate) const
compare op
const sal_uInt8 * getData() const
std::size_t ReadBytes(void *pData, std::size_t nSize)
css::uno::Sequence< sal_Int8 > VectorGraphicDataArray
std::unique_ptr< WmfExternal > mpExternalHeader
static size_t estimateSize(std::deque< uno::Reference< graphic::XPrimitive2D >> const &rSequence)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
VectorGraphicData(const VectorGraphicData &)=delete
Reference< XComponentContext > getProcessComponentContext()
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)
#define SAL_WARN(area, stream)
const VectorGraphicDataType & getType() const
constexpr tools::Long getWidth() const
std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence
BinaryDataContainer maDataContainer
bool m_bDetectedRangeSegmentation false