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 <pdfwriter_impl.hxx>
21 #include <vcl/bitmapex.hxx>
22 #include <vcl/image.hxx>
26 PDFWriter::AnyWidget::~AnyWidget()
30 PDFWriter::PDFSignContext::PDFSignContext(OStringBuffer
& rCMSHexBuffer
)
31 : m_pDerEncoded(nullptr),
33 m_pByteRange1(nullptr),
35 m_pByteRange2(nullptr),
37 m_rCMSHexBuffer(rCMSHexBuffer
)
41 PDFWriter::PDFWriter( const PDFWriter::PDFWriterContext
& rContext
, const css::uno::Reference
< css::beans::XMaterialHolder
>& xEnc
)
43 xImplementation( new PDFWriterImpl( rContext
, xEnc
, *this ) )
47 PDFWriter::~PDFWriter()
51 OutputDevice
* PDFWriter::GetReferenceDevice()
53 return xImplementation
->getReferenceDevice();
56 void PDFWriter::NewPage( double nPageWidth
, double nPageHeight
, Orientation eOrientation
)
58 xImplementation
->newPage( nPageWidth
, nPageHeight
, eOrientation
);
61 bool PDFWriter::Emit()
63 return xImplementation
->emit();
66 void PDFWriter::SetDocumentLocale( const css::lang::Locale
& rLoc
)
68 xImplementation
->setDocumentLocale( rLoc
);
71 void PDFWriter::SetFont( const vcl::Font
& rFont
)
73 xImplementation
->setFont( rFont
);
76 void PDFWriter::DrawText( const Point
& rPos
, const OUString
& rText
)
78 xImplementation
->drawText( rPos
, rText
, 0, rText
.getLength() );
81 void PDFWriter::DrawTextLine(
84 FontStrikeout eStrikeout
,
85 FontLineStyle eUnderline
,
86 FontLineStyle eOverline
)
88 xImplementation
->drawTextLine( rPos
, nWidth
, eStrikeout
, eUnderline
, eOverline
, false/*bUnderlineAbove*/ );
91 void PDFWriter::DrawTextArray(
92 const Point
& rStartPt
,
98 xImplementation
->drawTextArray( rStartPt
, rStr
, pDXAry
, nIndex
, nLen
);
101 void PDFWriter::DrawStretchText(
102 const Point
& rStartPt
,
104 const OUString
& rStr
,
108 xImplementation
->drawStretchText( rStartPt
, nWidth
, rStr
, nIndex
, nLen
);
111 void PDFWriter::DrawText(
112 const tools::Rectangle
& rRect
,
113 const OUString
& rStr
,
114 DrawTextFlags nStyle
)
116 xImplementation
->drawText( rRect
, rStr
, nStyle
);
119 void PDFWriter::DrawLine( const Point
& rStart
, const Point
& rStop
)
121 xImplementation
->drawLine( rStart
, rStop
);
124 void PDFWriter::DrawLine( const Point
& rStart
, const Point
& rStop
, const LineInfo
& rInfo
)
126 xImplementation
->drawLine( rStart
, rStop
, rInfo
);
129 void PDFWriter::DrawPolygon( const tools::Polygon
& rPoly
)
131 xImplementation
->drawPolygon( rPoly
);
134 void PDFWriter::DrawPolyLine( const tools::Polygon
& rPoly
)
136 xImplementation
->drawPolyLine( rPoly
);
139 void PDFWriter::DrawRect( const tools::Rectangle
& rRect
)
141 xImplementation
->drawRectangle( rRect
);
144 void PDFWriter::DrawRect( const tools::Rectangle
& rRect
, sal_uLong nHorzRound
, sal_uLong nVertRound
)
146 xImplementation
->drawRectangle( rRect
, nHorzRound
, nVertRound
);
149 void PDFWriter::DrawEllipse( const tools::Rectangle
& rRect
)
151 xImplementation
->drawEllipse( rRect
);
154 void PDFWriter::DrawArc( const tools::Rectangle
& rRect
, const Point
& rStart
, const Point
& rStop
)
156 xImplementation
->drawArc( rRect
, rStart
, rStop
, false, false );
159 void PDFWriter::DrawPie( const tools::Rectangle
& rRect
, const Point
& rStart
, const Point
& rStop
)
161 xImplementation
->drawArc( rRect
, rStart
, rStop
, true, false );
164 void PDFWriter::DrawChord( const tools::Rectangle
& rRect
, const Point
& rStart
, const Point
& rStop
)
166 xImplementation
->drawArc( rRect
, rStart
, rStop
, false, true );
169 void PDFWriter::DrawPolyLine( const tools::Polygon
& rPoly
, const LineInfo
& rInfo
)
171 xImplementation
->drawPolyLine( rPoly
, rInfo
);
174 void PDFWriter::DrawPolyLine( const tools::Polygon
& rPoly
, const ExtLineInfo
& rInfo
)
176 xImplementation
->drawPolyLine( rPoly
, rInfo
);
179 void PDFWriter::DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
)
181 xImplementation
->drawPolyPolygon( rPolyPoly
);
184 void PDFWriter::DrawPixel( const Point
& rPos
, const Color
& rColor
)
186 xImplementation
->drawPixel( rPos
, rColor
);
189 void PDFWriter::DrawBitmap( const Point
& rDestPt
, const Size
& rDestSize
, const Bitmap
& rBitmap
, const Graphic
& rGraphic
)
191 xImplementation
->drawBitmap( rDestPt
, rDestSize
, rBitmap
, rGraphic
);
194 void PDFWriter::DrawBitmapEx( const Point
& rDestPt
, const Size
& rDestSize
, const BitmapEx
& rBitmap
)
196 xImplementation
->drawBitmap( rDestPt
, rDestSize
, rBitmap
);
199 void PDFWriter::DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
)
201 xImplementation
->drawHatch( rPolyPoly
, rHatch
);
204 void PDFWriter::DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
)
206 xImplementation
->drawGradient( rRect
, rGradient
);
209 void PDFWriter::DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
)
211 xImplementation
->push(PushFlags::CLIPREGION
);
212 xImplementation
->setClipRegion( rPolyPoly
.getB2DPolyPolygon() );
213 xImplementation
->drawGradient( rPolyPoly
.GetBoundRect(), rGradient
);
214 xImplementation
->pop();
217 void PDFWriter::DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
)
219 xImplementation
->drawWallpaper( rRect
, rWallpaper
);
222 void PDFWriter::DrawTransparent( const tools::PolyPolygon
& rPolyPoly
, sal_uInt16 nTransparencePercent
)
224 xImplementation
->drawTransparent( rPolyPoly
, nTransparencePercent
);
227 void PDFWriter::BeginTransparencyGroup()
229 xImplementation
->beginTransparencyGroup();
232 void PDFWriter::EndTransparencyGroup( const tools::Rectangle
& rRect
, sal_uInt16 nTransparentPercent
)
234 xImplementation
->endTransparencyGroup( rRect
, nTransparentPercent
);
237 void PDFWriter::Push( PushFlags nFlags
)
239 xImplementation
->push( nFlags
);
242 void PDFWriter::Pop()
244 xImplementation
->pop();
247 void PDFWriter::SetMapMode( const MapMode
& rMapMode
)
249 xImplementation
->setMapMode( rMapMode
);
252 void PDFWriter::SetLineColor( const Color
& rColor
)
254 xImplementation
->setLineColor( rColor
);
257 void PDFWriter::SetFillColor( const Color
& rColor
)
259 xImplementation
->setFillColor( rColor
);
262 void PDFWriter::SetClipRegion()
264 xImplementation
->clearClipRegion();
267 void PDFWriter::SetClipRegion( const basegfx::B2DPolyPolygon
& rRegion
)
269 xImplementation
->setClipRegion( rRegion
);
272 void PDFWriter::MoveClipRegion( long nHorzMove
, long nVertMove
)
274 xImplementation
->moveClipRegion( nHorzMove
, nVertMove
);
277 void PDFWriter::IntersectClipRegion( const basegfx::B2DPolyPolygon
& rRegion
)
279 xImplementation
->intersectClipRegion( rRegion
);
282 void PDFWriter::IntersectClipRegion( const tools::Rectangle
& rRect
)
284 xImplementation
->intersectClipRegion( rRect
);
287 void PDFWriter::SetLayoutMode( ComplexTextLayoutFlags nMode
)
289 xImplementation
->setLayoutMode( nMode
);
292 void PDFWriter::SetDigitLanguage( LanguageType eLang
)
294 xImplementation
->setDigitLanguage( eLang
);
297 void PDFWriter::SetTextColor( const Color
& rColor
)
299 xImplementation
->setTextColor( rColor
);
302 void PDFWriter::SetTextFillColor()
304 xImplementation
->setTextFillColor();
307 void PDFWriter::SetTextFillColor( const Color
& rColor
)
309 xImplementation
->setTextFillColor( rColor
);
312 void PDFWriter::SetTextLineColor()
314 xImplementation
->setTextLineColor();
317 void PDFWriter::SetTextLineColor( const Color
& rColor
)
319 xImplementation
->setTextLineColor( rColor
);
322 void PDFWriter::SetOverlineColor()
324 xImplementation
->setOverlineColor();
327 void PDFWriter::SetOverlineColor( const Color
& rColor
)
329 xImplementation
->setOverlineColor( rColor
);
332 void PDFWriter::SetTextAlign( ::TextAlign eAlign
)
334 xImplementation
->setTextAlign( eAlign
);
337 void PDFWriter::DrawJPGBitmap( SvStream
& rStreamData
, bool bIsTrueColor
, const Size
& rSrcSizePixel
, const tools::Rectangle
& rTargetArea
, const Bitmap
& rMask
, const Graphic
& rGraphic
)
339 xImplementation
->drawJPGBitmap( rStreamData
, bIsTrueColor
, rSrcSizePixel
, rTargetArea
, rMask
, rGraphic
);
342 sal_Int32
PDFWriter::CreateLink( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
)
344 return xImplementation
->createLink( rRect
, nPageNr
);
347 sal_Int32
PDFWriter::CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
)
349 return xImplementation
->createScreen(rRect
, nPageNr
);
352 sal_Int32
PDFWriter::RegisterDestReference( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
)
354 return xImplementation
->registerDestReference( nDestId
, rRect
, nPageNr
, eType
);
357 sal_Int32
PDFWriter::CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, PDFWriter::DestAreaType eType
)
359 return xImplementation
->createNamedDest( sDestName
, rRect
, nPageNr
, eType
);
361 sal_Int32
PDFWriter::CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, PDFWriter::DestAreaType eType
)
363 return xImplementation
->createDest( rRect
, nPageNr
, eType
);
366 void PDFWriter::SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
)
368 xImplementation
->setLinkDest( nLinkId
, nDestId
);
371 void PDFWriter::SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
)
373 xImplementation
->setLinkURL( nLinkId
, rURL
);
376 void PDFWriter::SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
)
378 xImplementation
->setScreenURL(nScreenId
, rURL
);
381 void PDFWriter::SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
)
383 xImplementation
->setScreenStream(nScreenId
, rURL
);
386 void PDFWriter::SetLinkPropertyID( sal_Int32 nLinkId
, sal_Int32 nPropertyId
)
388 xImplementation
->setLinkPropertyId( nLinkId
, nPropertyId
);
391 sal_Int32
PDFWriter::CreateOutlineItem( sal_Int32 nParent
, const OUString
& rText
, sal_Int32 nDestID
)
393 return xImplementation
->createOutlineItem( nParent
, rText
, nDestID
);
396 void PDFWriter::CreateNote( const tools::Rectangle
& rRect
, const PDFNote
& rNote
, sal_Int32 nPageNr
)
398 xImplementation
->createNote( rRect
, rNote
, nPageNr
);
401 sal_Int32
PDFWriter::BeginStructureElement( PDFWriter::StructElement eType
, const OUString
& rAlias
)
403 return xImplementation
->beginStructureElement( eType
, rAlias
);
406 void PDFWriter::EndStructureElement()
408 xImplementation
->endStructureElement();
411 bool PDFWriter::SetCurrentStructureElement( sal_Int32 nID
)
413 return xImplementation
->setCurrentStructureElement( nID
);
416 bool PDFWriter::SetStructureAttribute( enum StructAttribute eAttr
, enum StructAttributeValue eVal
)
418 return xImplementation
->setStructureAttribute( eAttr
, eVal
);
421 bool PDFWriter::SetStructureAttributeNumerical( enum StructAttribute eAttr
, sal_Int32 nValue
)
423 return xImplementation
->setStructureAttributeNumerical( eAttr
, nValue
);
426 void PDFWriter::SetStructureBoundingBox( const tools::Rectangle
& rRect
)
428 xImplementation
->setStructureBoundingBox( rRect
);
431 void PDFWriter::SetActualText( const OUString
& rText
)
433 xImplementation
->setActualText( rText
);
436 void PDFWriter::SetAlternateText( const OUString
& rText
)
438 xImplementation
->setAlternateText( rText
);
441 void PDFWriter::SetPageTransition( PDFWriter::PageTransition eType
, sal_uInt32 nMilliSec
, sal_Int32 nPageNr
)
443 xImplementation
->setPageTransition( eType
, nMilliSec
, nPageNr
);
446 sal_Int32
PDFWriter::CreateControl( const PDFWriter::AnyWidget
& rControl
)
448 return xImplementation
->createControl( rControl
);
451 PDFOutputStream::~PDFOutputStream()
455 void PDFWriter::AddStream( const OUString
& rMimeType
, PDFOutputStream
* pStream
)
457 xImplementation
->addStream( rMimeType
, pStream
);
460 std::set
< PDFWriter::ErrorCode
> PDFWriter::GetErrors()
462 return xImplementation
->getErrors();
465 css::uno::Reference
< css::beans::XMaterialHolder
>
466 PDFWriter::InitEncryption( const OUString
& i_rOwnerPassword
,
467 const OUString
& i_rUserPassword
,
471 return PDFWriterImpl::initEncryption( i_rOwnerPassword
, i_rUserPassword
, b128Bit
);
474 void PDFWriter::PlayMetafile( const GDIMetaFile
& i_rMTF
, const vcl::PDFWriter::PlayMetafileContext
& i_rPlayContext
, PDFExtOutDevData
* i_pData
)
476 xImplementation
->playMetafile( i_rMTF
, i_pData
, i_rPlayContext
);
479 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */