1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/bitmapex.hxx>
22 #include <pdf/pdfwriter_impl.hxx>
23 #include <vcl/pdf/PDFEncryptionInitialization.hxx>
27 PDFWriter::AnyWidget::~AnyWidget()
31 PDFWriter::PDFWriter( const PDFWriter::PDFWriterContext
& rContext
, const css::uno::Reference
< css::beans::XMaterialHolder
>& xEnc
)
33 xImplementation( VclPtr
<PDFWriterImpl
>::Create(rContext
, xEnc
, *this) )
37 PDFWriter::~PDFWriter()
39 xImplementation
.disposeAndClear();
42 OutputDevice
* PDFWriter::GetReferenceDevice()
44 return xImplementation
.get();
47 void PDFWriter::NewPage( double nPageWidth
, double nPageHeight
, Orientation eOrientation
)
49 xImplementation
->newPage( nPageWidth
, nPageHeight
, eOrientation
);
52 bool PDFWriter::Emit()
54 return xImplementation
->emit();
57 void PDFWriter::SetDocumentLocale( const css::lang::Locale
& rLoc
)
59 xImplementation
->setDocumentLocale( rLoc
);
62 void PDFWriter::SetFont( const vcl::Font
& rFont
)
64 xImplementation
->setFont( rFont
);
67 void PDFWriter::DrawText( const Point
& rPos
, const OUString
& rText
)
69 xImplementation
->drawText( rPos
, rText
, 0, rText
.getLength() );
72 void PDFWriter::DrawTextLine(
75 FontStrikeout eStrikeout
,
76 FontLineStyle eUnderline
,
77 FontLineStyle eOverline
)
79 xImplementation
->drawTextLine( rPos
, nWidth
, eStrikeout
, eUnderline
, eOverline
, false/*bUnderlineAbove*/ );
82 void PDFWriter::DrawTextArray(const Point
& rStartPt
, const OUString
& rStr
, KernArraySpan pDXAry
,
83 std::span
<const sal_Bool
> pKashidaAry
, sal_Int32 nIndex
,
84 sal_Int32 nLen
, sal_Int32 nLayoutContextIndex
,
85 sal_Int32 nLayoutContextLen
)
87 xImplementation
->drawTextArray(rStartPt
, rStr
, pDXAry
, pKashidaAry
, nIndex
, nLen
,
88 nLayoutContextIndex
, nLayoutContextLen
);
91 void PDFWriter::DrawStretchText(
92 const Point
& rStartPt
,
98 xImplementation
->drawStretchText( rStartPt
, nWidth
, rStr
, nIndex
, nLen
);
101 void PDFWriter::DrawText(
102 const tools::Rectangle
& rRect
,
103 const OUString
& rStr
,
104 DrawTextFlags nStyle
)
106 xImplementation
->drawText( rRect
, rStr
, nStyle
);
109 void PDFWriter::DrawLine( const Point
& rStart
, const Point
& rStop
)
111 xImplementation
->drawLine( rStart
, rStop
);
114 void PDFWriter::DrawLine( const Point
& rStart
, const Point
& rStop
, const LineInfo
& rInfo
)
116 xImplementation
->drawLine( rStart
, rStop
, rInfo
);
119 void PDFWriter::DrawPolygon( const tools::Polygon
& rPoly
)
121 xImplementation
->drawPolygon( rPoly
);
124 void PDFWriter::DrawPolyLine( const tools::Polygon
& rPoly
)
126 xImplementation
->drawPolyLine( rPoly
);
129 void PDFWriter::DrawRect( const tools::Rectangle
& rRect
)
131 xImplementation
->drawRectangle( rRect
);
134 void PDFWriter::DrawRect( const tools::Rectangle
& rRect
, sal_uInt32 nHorzRound
, sal_uInt32 nVertRound
)
136 xImplementation
->drawRectangle( rRect
, nHorzRound
, nVertRound
);
139 void PDFWriter::DrawEllipse( const tools::Rectangle
& rRect
)
141 xImplementation
->drawEllipse( rRect
);
144 void PDFWriter::DrawArc( const tools::Rectangle
& rRect
, const Point
& rStart
, const Point
& rStop
)
146 xImplementation
->drawArc( rRect
, rStart
, rStop
, false, false );
149 void PDFWriter::DrawPie( const tools::Rectangle
& rRect
, const Point
& rStart
, const Point
& rStop
)
151 xImplementation
->drawArc( rRect
, rStart
, rStop
, true, false );
154 void PDFWriter::DrawChord( const tools::Rectangle
& rRect
, const Point
& rStart
, const Point
& rStop
)
156 xImplementation
->drawArc( rRect
, rStart
, rStop
, false, true );
159 void PDFWriter::DrawPolyLine( const tools::Polygon
& rPoly
, const LineInfo
& rInfo
)
161 xImplementation
->drawPolyLine( rPoly
, rInfo
);
164 void PDFWriter::DrawPolyLine( const tools::Polygon
& rPoly
, const ExtLineInfo
& rInfo
)
166 xImplementation
->drawPolyLine( rPoly
, rInfo
);
169 void PDFWriter::DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
)
171 xImplementation
->drawPolyPolygon( rPolyPoly
);
174 void PDFWriter::DrawPixel( const Point
& rPos
, const Color
& rColor
)
176 xImplementation
->drawPixel( rPos
, rColor
);
179 void PDFWriter::DrawBitmap( const Point
& rDestPt
, const Size
& rDestSize
, const Bitmap
& rBitmap
, const Graphic
& rGraphic
)
181 xImplementation
->drawBitmap( rDestPt
, rDestSize
, rBitmap
, rGraphic
);
184 void PDFWriter::DrawBitmapEx( const Point
& rDestPt
, const Size
& rDestSize
, const BitmapEx
& rBitmap
)
186 xImplementation
->drawBitmap( rDestPt
, rDestSize
, rBitmap
);
189 void PDFWriter::DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
)
191 xImplementation
->drawHatch( rPolyPoly
, rHatch
);
194 void PDFWriter::DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
)
196 xImplementation
->drawGradient( rRect
, rGradient
);
199 void PDFWriter::DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
)
201 xImplementation
->push(PushFlags::CLIPREGION
);
202 xImplementation
->setClipRegion( rPolyPoly
.getB2DPolyPolygon() );
203 xImplementation
->drawGradient( rPolyPoly
.GetBoundRect(), rGradient
);
204 xImplementation
->pop();
207 void PDFWriter::DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
)
209 xImplementation
->drawWallpaper( rRect
, rWallpaper
);
212 void PDFWriter::DrawTransparent( const tools::PolyPolygon
& rPolyPoly
, sal_uInt16 nTransparencePercent
)
214 xImplementation
->drawTransparent( rPolyPoly
, nTransparencePercent
);
217 void PDFWriter::BeginTransparencyGroup()
219 xImplementation
->beginTransparencyGroup();
222 void PDFWriter::EndTransparencyGroup( const tools::Rectangle
& rRect
, sal_uInt16 nTransparentPercent
)
224 xImplementation
->endTransparencyGroup( rRect
, nTransparentPercent
);
227 void PDFWriter::Push( PushFlags nFlags
)
229 xImplementation
->push( nFlags
);
232 void PDFWriter::Pop()
234 xImplementation
->pop();
237 void PDFWriter::SetMapMode( const MapMode
& rMapMode
)
239 xImplementation
->setMapMode( rMapMode
);
242 void PDFWriter::SetLineColor( const Color
& rColor
)
244 xImplementation
->setLineColor( rColor
);
247 void PDFWriter::SetFillColor( const Color
& rColor
)
249 xImplementation
->setFillColor( rColor
);
252 void PDFWriter::SetClipRegion()
254 xImplementation
->clearClipRegion();
257 void PDFWriter::SetClipRegion( const basegfx::B2DPolyPolygon
& rRegion
)
259 xImplementation
->setClipRegion( rRegion
);
262 void PDFWriter::MoveClipRegion( tools::Long nHorzMove
, tools::Long nVertMove
)
264 xImplementation
->moveClipRegion( nHorzMove
, nVertMove
);
267 void PDFWriter::IntersectClipRegion( const basegfx::B2DPolyPolygon
& rRegion
)
269 xImplementation
->intersectClipRegion( rRegion
);
272 void PDFWriter::IntersectClipRegion( const tools::Rectangle
& rRect
)
274 xImplementation
->intersectClipRegion( rRect
);
277 void PDFWriter::SetLayoutMode( vcl::text::ComplexTextLayoutFlags nMode
)
279 xImplementation
->setLayoutMode( nMode
);
282 void PDFWriter::SetDigitLanguage( LanguageType eLang
)
284 xImplementation
->setDigitLanguage( eLang
);
287 void PDFWriter::SetTextColor( const Color
& rColor
)
289 xImplementation
->setTextColor( rColor
);
292 void PDFWriter::SetTextFillColor()
294 xImplementation
->setTextFillColor();
297 void PDFWriter::SetTextFillColor( const Color
& rColor
)
299 xImplementation
->setTextFillColor( rColor
);
302 void PDFWriter::SetTextLineColor()
304 xImplementation
->setTextLineColor();
307 void PDFWriter::SetTextLineColor( const Color
& rColor
)
309 xImplementation
->setTextLineColor( rColor
);
312 void PDFWriter::SetOverlineColor()
314 xImplementation
->setOverlineColor();
317 void PDFWriter::SetOverlineColor( const Color
& rColor
)
319 xImplementation
->setOverlineColor( rColor
);
322 void PDFWriter::SetTextAlign( ::TextAlign eAlign
)
324 xImplementation
->setTextAlign( eAlign
);
327 void PDFWriter::DrawJPGBitmap( SvStream
& rStreamData
, bool bIsTrueColor
, const Size
& rSrcSizePixel
, const tools::Rectangle
& rTargetArea
, const AlphaMask
& rAlphaMask
, const Graphic
& rGraphic
)
329 xImplementation
->drawJPGBitmap( rStreamData
, bIsTrueColor
, rSrcSizePixel
, rTargetArea
, rAlphaMask
, rGraphic
);
332 sal_Int32
PDFWriter::CreateLink(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, OUString
const& rAltText
)
334 return xImplementation
->createLink(rRect
, nPageNr
, rAltText
);
337 sal_Int32
PDFWriter::CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, OUString
const& rAltText
, OUString
const& rMimeType
)
339 return xImplementation
->createScreen(rRect
, nPageNr
, rAltText
, rMimeType
);
342 sal_Int32
PDFWriter::RegisterDestReference( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
)
344 return xImplementation
->registerDestReference( nDestId
, rRect
, nPageNr
, eType
);
347 sal_Int32
PDFWriter::CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, PDFWriter::DestAreaType eType
)
349 return xImplementation
->createNamedDest( sDestName
, rRect
, nPageNr
, eType
);
351 sal_Int32
PDFWriter::CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, PDFWriter::DestAreaType eType
)
353 return xImplementation
->createDest( rRect
, nPageNr
, eType
);
356 void PDFWriter::SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
)
358 xImplementation
->setLinkDest( nLinkId
, nDestId
);
361 void PDFWriter::SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
)
363 xImplementation
->setLinkURL( nLinkId
, rURL
);
366 void PDFWriter::SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
)
368 xImplementation
->setScreenURL(nScreenId
, rURL
);
371 void PDFWriter::SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
)
373 xImplementation
->setScreenStream(nScreenId
, rURL
);
376 void PDFWriter::SetLinkPropertyID( sal_Int32 nLinkId
, sal_Int32 nPropertyId
)
378 xImplementation
->setLinkPropertyId( nLinkId
, nPropertyId
);
381 sal_Int32
PDFWriter::CreateOutlineItem( sal_Int32 nParent
, std::u16string_view rText
, sal_Int32 nDestID
)
383 return xImplementation
->createOutlineItem( nParent
, rText
, nDestID
);
386 sal_Int32
PDFWriter::CreateNote(const tools::Rectangle
& rRect
, const tools::Rectangle
& rPopupRect
,
387 const PDFNote
& rNote
, sal_Int32 nPageNr
)
389 return xImplementation
->createNote(rRect
, rPopupRect
, rNote
, nPageNr
);
392 sal_Int32
PDFWriter::EnsureStructureElement()
394 return xImplementation
->ensureStructureElement();
397 void PDFWriter::InitStructureElement(sal_Int32
const id
,
398 vcl::pdf::StructElement
const eType
, std::u16string_view
const rAlias
)
400 return xImplementation
->initStructureElement(id
, eType
, rAlias
);
403 void PDFWriter::BeginStructureElement(sal_Int32
const id
)
405 return xImplementation
->beginStructureElement(id
);
408 void PDFWriter::EndStructureElement()
410 xImplementation
->endStructureElement();
413 void PDFWriter::SetCurrentStructureElement( sal_Int32 nID
)
415 xImplementation
->setCurrentStructureElement( nID
);
418 void PDFWriter::SetStructureAttribute( enum StructAttribute eAttr
, enum StructAttributeValue eVal
)
420 xImplementation
->setStructureAttribute( eAttr
, eVal
);
423 void PDFWriter::SetStructureAttributeNumerical( enum StructAttribute eAttr
, sal_Int32 nValue
)
425 xImplementation
->setStructureAttributeNumerical( eAttr
, nValue
);
428 void PDFWriter::SetStructureBoundingBox( const tools::Rectangle
& rRect
)
430 xImplementation
->setStructureBoundingBox( rRect
);
433 void PDFWriter::SetStructureAnnotIds(::std::vector
<sal_Int32
> const& rAnnotIds
)
435 xImplementation
->setStructureAnnotIds(rAnnotIds
);
438 void PDFWriter::SetActualText( const OUString
& rText
)
440 xImplementation
->setActualText( rText
);
443 void PDFWriter::SetAlternateText( const OUString
& rText
)
445 xImplementation
->setAlternateText( rText
);
448 void PDFWriter::SetPageTransition( PDFWriter::PageTransition eType
, sal_uInt32 nMilliSec
, sal_Int32 nPageNr
)
450 xImplementation
->setPageTransition( eType
, nMilliSec
, nPageNr
);
453 sal_Int32
PDFWriter::CreateControl( const PDFWriter::AnyWidget
& rControl
)
455 return xImplementation
->createControl( rControl
);
458 PDFOutputStream::~PDFOutputStream()
462 void PDFWriter::AddAttachedFile(OUString
const& rFileName
, OUString
const& rMimeType
, OUString
const& rDescription
, std::unique_ptr
<PDFOutputStream
> pStream
)
464 xImplementation
->addDocumentAttachedFile(rFileName
, rMimeType
, rDescription
, std::move(pStream
));
467 std::set
< PDFWriter::ErrorCode
> const & PDFWriter::GetErrors() const
469 return xImplementation
->getErrors();
472 css::uno::Reference
< css::beans::XMaterialHolder
>
473 PDFWriter::InitEncryption(const OUString
& i_rOwnerPassword
, const OUString
& i_rUserPassword
)
475 return vcl::pdf::initEncryption(i_rOwnerPassword
, i_rUserPassword
);
478 void PDFWriter::PlayMetafile( const GDIMetaFile
& i_rMTF
, const vcl::PDFWriter::PlayMetafileContext
& i_rPlayContext
, PDFExtOutDevData
* i_pData
)
480 xImplementation
->playMetafile( i_rMTF
, i_pData
, i_rPlayContext
);
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */