update dev300-m58
[ooovba.git] / vcl / source / gdi / pdfwriter.cxx
blob7928b5ef95eda1646c814177e9c7ba533fcfd6a9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pdfwriter.cxx,v $
10 * $Revision: 1.24.134.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <pdfwriter_impl.hxx>
35 #include <vcl/bitmapex.hxx>
36 #include <vcl/image.hxx>
38 using namespace vcl;
40 PDFWriter::AnyWidget::~AnyWidget()
44 PDFWriter::PDFWriter( const PDFWriter::PDFWriterContext& rContext )
46 pImplementation( new PDFWriterImpl( rContext ) )
50 PDFWriter::~PDFWriter()
52 delete (PDFWriterImpl*)pImplementation;
55 OutputDevice* PDFWriter::GetReferenceDevice()
57 return ((PDFWriterImpl*)pImplementation)->getReferenceDevice();
60 sal_Int32 PDFWriter::NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation )
62 return ((PDFWriterImpl*)pImplementation)->newPage( nPageWidth, nPageHeight, eOrientation );
65 bool PDFWriter::Emit()
67 return ((PDFWriterImpl*)pImplementation)->emit();
70 PDFWriter::PDFVersion PDFWriter::GetVersion() const
72 return ((PDFWriterImpl*)pImplementation)->getVersion();
75 void PDFWriter::SetDocInfo( const PDFDocInfo& rInfo )
77 ((PDFWriterImpl*)pImplementation)->setDocInfo( rInfo );
80 const PDFDocInfo& PDFWriter::GetDocInfo() const
82 return ((PDFWriterImpl*)pImplementation)->getDocInfo();
85 void PDFWriter::SetDocumentLocale( const com::sun::star::lang::Locale& rLoc )
87 ((PDFWriterImpl*)pImplementation)->setDocumentLocale( rLoc );
90 void PDFWriter::SetFont( const Font& rFont )
92 ((PDFWriterImpl*)pImplementation)->setFont( rFont );
95 void PDFWriter::DrawText( const Point& rPos, const String& rText )
97 ((PDFWriterImpl*)pImplementation)->drawText( rPos, rText );
100 void PDFWriter::DrawTextLine(
101 const Point& rPos,
102 long nWidth,
103 FontStrikeout eStrikeout,
104 FontUnderline eUnderline,
105 FontUnderline eOverline,
106 BOOL bUnderlineAbove )
108 ((PDFWriterImpl*)pImplementation)->drawTextLine( rPos, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove );
111 void PDFWriter::DrawTextArray(
112 const Point& rStartPt,
113 const XubString& rStr,
114 const sal_Int32* pDXAry,
115 xub_StrLen nIndex,
116 xub_StrLen nLen )
118 ((PDFWriterImpl*)pImplementation)->drawTextArray( rStartPt, rStr, pDXAry, nIndex, nLen );
121 void PDFWriter::DrawStretchText(
122 const Point& rStartPt,
123 ULONG nWidth,
124 const XubString& rStr,
125 xub_StrLen nIndex,
126 xub_StrLen nLen )
128 ((PDFWriterImpl*)pImplementation)->drawStretchText( rStartPt, nWidth, rStr, nIndex, nLen );
131 void PDFWriter::DrawText(
132 const Rectangle& rRect,
133 const XubString& rStr,
134 USHORT nStyle )
136 ((PDFWriterImpl*)pImplementation)->drawText( rRect, rStr, nStyle );
139 void PDFWriter::DrawLine( const Point& rStart, const Point& rStop )
141 ((PDFWriterImpl*)pImplementation)->drawLine( rStart, rStop );
144 void PDFWriter::DrawLine( const Point& rStart, const Point& rStop, const LineInfo& rInfo )
146 ((PDFWriterImpl*)pImplementation)->drawLine( rStart, rStop, rInfo );
149 void PDFWriter::DrawPolygon( const Polygon& rPoly )
151 ((PDFWriterImpl*)pImplementation)->drawPolygon( rPoly );
154 void PDFWriter::DrawPolyLine( const Polygon& rPoly )
156 ((PDFWriterImpl*)pImplementation)->drawPolyLine( rPoly );
159 void PDFWriter::DrawRect( const Rectangle& rRect )
161 ((PDFWriterImpl*)pImplementation)->drawRectangle( rRect );
164 void PDFWriter::DrawRect( const Rectangle& rRect, ULONG nHorzRound, ULONG nVertRound )
166 ((PDFWriterImpl*)pImplementation)->drawRectangle( rRect, nHorzRound, nVertRound );
169 void PDFWriter::DrawEllipse( const Rectangle& rRect )
171 ((PDFWriterImpl*)pImplementation)->drawEllipse( rRect );
174 void PDFWriter::DrawArc( const Rectangle& rRect, const Point& rStart, const Point& rStop )
176 ((PDFWriterImpl*)pImplementation)->drawArc( rRect, rStart, rStop, false, false );
179 void PDFWriter::DrawPie( const Rectangle& rRect, const Point& rStart, const Point& rStop )
181 ((PDFWriterImpl*)pImplementation)->drawArc( rRect, rStart, rStop, true, false );
184 void PDFWriter::DrawChord( const Rectangle& rRect, const Point& rStart, const Point& rStop )
186 ((PDFWriterImpl*)pImplementation)->drawArc( rRect, rStart, rStop, false, true );
189 void PDFWriter::DrawPolyLine( const Polygon& rPoly, const LineInfo& rInfo )
191 ((PDFWriterImpl*)pImplementation)->drawPolyLine( rPoly, rInfo );
194 void PDFWriter::DrawPolyLine( const Polygon& rPoly, const ExtLineInfo& rInfo )
196 ((PDFWriterImpl*)pImplementation)->drawPolyLine( rPoly, rInfo );
199 void PDFWriter::DrawPolyPolygon( const PolyPolygon& rPolyPoly )
201 ((PDFWriterImpl*)pImplementation)->drawPolyPolygon( rPolyPoly );
204 void PDFWriter::DrawPixel( const Point& rPos, const Color& rColor )
206 ((PDFWriterImpl*)pImplementation)->drawPixel( rPos, rColor );
209 void PDFWriter::DrawPixel( const Polygon& rPts, const Color* pColors )
211 ((PDFWriterImpl*)pImplementation)->drawPixel( rPts, pColors );
214 void PDFWriter::DrawBitmap( const Point& rDestPt, const Bitmap& rBitmap )
216 Size aSize = OutputDevice::LogicToLogic( rBitmap.GetPrefSize(),
217 rBitmap.GetPrefMapMode(),
218 ((PDFWriterImpl*)pImplementation)->getMapMode() );
219 ((PDFWriterImpl*)pImplementation)->drawBitmap( rDestPt, aSize, rBitmap );
222 void PDFWriter::DrawBitmap( const Point& rDestPt, const Size& rDestSize, const Bitmap& rBitmap )
224 ((PDFWriterImpl*)pImplementation)->drawBitmap( rDestPt, rDestSize, rBitmap );
227 void PDFWriter::DrawBitmap( const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel, const Bitmap& rBitmap )
229 Bitmap aBitmap( rBitmap );
230 aBitmap.Crop( Rectangle( rSrcPtPixel, rSrcSizePixel ) );
231 ((PDFWriterImpl*)pImplementation)->drawBitmap( rDestPt, rDestSize, aBitmap );
234 void PDFWriter::DrawBitmapEx( const Point& rDestPt, const BitmapEx& rBitmap )
236 Size aSize = OutputDevice::LogicToLogic( rBitmap.GetPrefSize(),
237 rBitmap.GetPrefMapMode(),
238 ((PDFWriterImpl*)pImplementation)->getMapMode() );
239 ((PDFWriterImpl*)pImplementation)->drawBitmap( rDestPt, aSize, rBitmap );
242 void PDFWriter::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, const BitmapEx& rBitmap )
244 ((PDFWriterImpl*)pImplementation)->drawBitmap( rDestPt, rDestSize, rBitmap );
247 void PDFWriter::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel, const BitmapEx& rBitmap )
249 if ( !!rBitmap )
251 BitmapEx aBitmap( rBitmap );
252 aBitmap.Crop( Rectangle( rSrcPtPixel, rSrcSizePixel ) );
253 ((PDFWriterImpl*)pImplementation)->drawBitmap( rDestPt, rDestSize, aBitmap );
257 void PDFWriter::DrawMask( const Point& rDestPt, const Bitmap& rBitmap, const Color& rMaskColor )
259 Size aSize = OutputDevice::LogicToLogic( rBitmap.GetPrefSize(),
260 rBitmap.GetPrefMapMode(),
261 ((PDFWriterImpl*)pImplementation)->getMapMode() );
262 ((PDFWriterImpl*)pImplementation)->drawMask( rDestPt, aSize, rBitmap, rMaskColor );
265 void PDFWriter::DrawMask( const Point& rDestPt, const Size& rDestSize, const Bitmap& rBitmap, const Color& rMaskColor )
267 ((PDFWriterImpl*)pImplementation)->drawMask( rDestPt, rDestSize, rBitmap, rMaskColor );
270 void PDFWriter::DrawMask( const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel, const Bitmap& rBitmap, const Color& rMaskColor )
272 Bitmap aBitmap( rBitmap );
273 aBitmap.Crop( Rectangle( rSrcPtPixel, rSrcSizePixel ) );
274 ((PDFWriterImpl*)pImplementation)->drawMask( rDestPt, rDestSize, aBitmap, rMaskColor );
277 void PDFWriter::DrawGradient( const Rectangle& rRect, const Gradient& rGradient )
279 ((PDFWriterImpl*)pImplementation)->drawGradient( rRect, rGradient );
282 void PDFWriter::DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient )
284 ((PDFWriterImpl*)pImplementation)->drawGradient( rPolyPoly, rGradient );
287 void PDFWriter::DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch )
289 ((PDFWriterImpl*)pImplementation)->drawHatch( rPolyPoly, rHatch );
292 void PDFWriter::DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper )
294 ((PDFWriterImpl*)pImplementation)->drawWallpaper( rRect, rWallpaper );
297 void PDFWriter::DrawTransparent( const PolyPolygon& rPolyPoly, USHORT nTransparencePercent )
299 ((PDFWriterImpl*)pImplementation)->drawTransparent( rPolyPoly, nTransparencePercent );
302 void PDFWriter::BeginTransparencyGroup()
304 ((PDFWriterImpl*)pImplementation)->beginTransparencyGroup();
307 void PDFWriter::EndTransparencyGroup( const Rectangle& rRect, USHORT nTransparentPercent )
309 ((PDFWriterImpl*)pImplementation)->endTransparencyGroup( rRect, nTransparentPercent );
312 void PDFWriter::EndTransparencyGroup( const Rectangle& rRect, const Bitmap& rAlphaMask )
314 ((PDFWriterImpl*)pImplementation)->endTransparencyGroup( rRect, rAlphaMask );
317 void PDFWriter::Push( USHORT nFlags )
319 ((PDFWriterImpl*)pImplementation)->push( nFlags );
322 void PDFWriter::Pop()
324 ((PDFWriterImpl*)pImplementation)->pop();
327 void PDFWriter::SetMapMode( const MapMode& rMapMode )
329 ((PDFWriterImpl*)pImplementation)->setMapMode( rMapMode );
332 void PDFWriter::SetMapMode()
334 ((PDFWriterImpl*)pImplementation)->setMapMode();
337 void PDFWriter::SetLineColor( const Color& rColor )
339 ((PDFWriterImpl*)pImplementation)->setLineColor( rColor );
342 void PDFWriter::SetFillColor( const Color& rColor )
344 ((PDFWriterImpl*)pImplementation)->setFillColor( rColor );
347 void PDFWriter::SetClipRegion()
349 ((PDFWriterImpl*)pImplementation)->clearClipRegion();
352 void PDFWriter::SetClipRegion( const Region& rRegion )
354 ((PDFWriterImpl*)pImplementation)->setClipRegion( rRegion );
357 void PDFWriter::MoveClipRegion( long nHorzMove, long nVertMove )
359 ((PDFWriterImpl*)pImplementation)->moveClipRegion( nHorzMove, nVertMove );
362 void PDFWriter::IntersectClipRegion( const Region& rRegion )
364 ((PDFWriterImpl*)pImplementation)->intersectClipRegion( rRegion );
367 void PDFWriter::IntersectClipRegion( const Rectangle& rRect )
369 ((PDFWriterImpl*)pImplementation)->intersectClipRegion( rRect );
372 void PDFWriter::SetAntialiasing( USHORT nMode )
374 ((PDFWriterImpl*)pImplementation)->setAntiAlias( (sal_Int32)nMode );
377 void PDFWriter::SetLayoutMode( ULONG nMode )
379 ((PDFWriterImpl*)pImplementation)->setLayoutMode( (sal_Int32)nMode );
382 void PDFWriter::SetDigitLanguage( LanguageType eLang )
384 ((PDFWriterImpl*)pImplementation)->setDigitLanguage( eLang );
387 void PDFWriter::SetTextColor( const Color& rColor )
389 ((PDFWriterImpl*)pImplementation)->setTextColor( rColor );
392 void PDFWriter::SetTextFillColor()
394 ((PDFWriterImpl*)pImplementation)->setTextFillColor();
397 void PDFWriter::SetTextFillColor( const Color& rColor )
399 ((PDFWriterImpl*)pImplementation)->setTextFillColor( rColor );
402 void PDFWriter::SetTextLineColor()
404 ((PDFWriterImpl*)pImplementation)->setTextLineColor();
407 void PDFWriter::SetTextLineColor( const Color& rColor )
409 ((PDFWriterImpl*)pImplementation)->setTextLineColor( rColor );
412 void PDFWriter::SetOverlineColor()
414 ((PDFWriterImpl*)pImplementation)->setOverlineColor();
417 void PDFWriter::SetOverlineColor( const Color& rColor )
419 ((PDFWriterImpl*)pImplementation)->setOverlineColor( rColor );
422 void PDFWriter::SetTextAlign( ::TextAlign eAlign )
424 ((PDFWriterImpl*)pImplementation)->setTextAlign( eAlign );
427 void PDFWriter::DrawJPGBitmap( SvStream& rStreamData, bool bIsTrueColor, const Size& rSrcSizePixel, const Rectangle& rTargetArea, const Bitmap& rMask )
429 ((PDFWriterImpl*)pImplementation)->drawJPGBitmap( rStreamData, bIsTrueColor, rSrcSizePixel, rTargetArea, rMask );
432 sal_Int32 PDFWriter::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr )
434 return ((PDFWriterImpl*)pImplementation)->createLink( rRect, nPageNr );
436 //--->i56629
437 sal_Int32 PDFWriter::CreateNamedDest( const rtl::OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
439 return ((PDFWriterImpl*)pImplementation)->createNamedDest( sDestName, rRect, nPageNr, eType );
441 //<---
442 sal_Int32 PDFWriter::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
444 return ((PDFWriterImpl*)pImplementation)->createDest( rRect, nPageNr, eType );
447 sal_Int32 PDFWriter::SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId )
449 return ((PDFWriterImpl*)pImplementation)->setLinkDest( nLinkId, nDestId );
452 sal_Int32 PDFWriter::SetLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL )
454 return ((PDFWriterImpl*)pImplementation)->setLinkURL( nLinkId, rURL );
457 void PDFWriter::SetLinkPropertyID( sal_Int32 nLinkId, sal_Int32 nPropertyId )
459 ((PDFWriterImpl*)pImplementation)->setLinkPropertyId( nLinkId, nPropertyId );
462 sal_Int32 PDFWriter::CreateOutlineItem( sal_Int32 nParent, const rtl::OUString& rText, sal_Int32 nDestID )
464 return ((PDFWriterImpl*)pImplementation)->createOutlineItem( nParent, rText, nDestID );
467 sal_Int32 PDFWriter::SetOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent )
469 return ((PDFWriterImpl*)pImplementation)->setOutlineItemParent( nItem, nNewParent );
472 sal_Int32 PDFWriter::SetOutlineItemText( sal_Int32 nItem, const rtl::OUString& rText )
474 return ((PDFWriterImpl*)pImplementation)->setOutlineItemText( nItem, rText );
477 sal_Int32 PDFWriter::SetOutlineItemDest( sal_Int32 nItem, sal_Int32 nDest )
479 return ((PDFWriterImpl*)pImplementation)->setOutlineItemDest( nItem, nDest );
482 void PDFWriter::CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
484 ((PDFWriterImpl*)pImplementation)->createNote( rRect, rNote, nPageNr );
487 sal_Int32 PDFWriter::BeginStructureElement( PDFWriter::StructElement eType, const rtl::OUString& rAlias )
489 return ((PDFWriterImpl*)pImplementation)->beginStructureElement( eType, rAlias );
492 void PDFWriter::EndStructureElement()
494 ((PDFWriterImpl*)pImplementation)->endStructureElement();
497 bool PDFWriter::SetCurrentStructureElement( sal_Int32 nID )
499 return ((PDFWriterImpl*)pImplementation)->setCurrentStructureElement( nID );
502 sal_Int32 PDFWriter::GetCurrentStructureElement()
504 return ((PDFWriterImpl*)pImplementation)->getCurrentStructureElement();
507 bool PDFWriter::SetStructureAttribute( enum StructAttribute eAttr, enum StructAttributeValue eVal )
509 return ((PDFWriterImpl*)pImplementation)->setStructureAttribute( eAttr, eVal );
512 bool PDFWriter::SetStructureAttributeNumerical( enum StructAttribute eAttr, sal_Int32 nValue )
514 return ((PDFWriterImpl*)pImplementation)->setStructureAttributeNumerical( eAttr, nValue );
517 void PDFWriter::SetStructureBoundingBox( const Rectangle& rRect )
519 ((PDFWriterImpl*)pImplementation)->setStructureBoundingBox( rRect );
522 void PDFWriter::SetActualText( const String& rText )
524 ((PDFWriterImpl*)pImplementation)->setActualText( rText );
527 void PDFWriter::SetAlternateText( const String& rText )
529 ((PDFWriterImpl*)pImplementation)->setAlternateText( rText );
532 void PDFWriter::SetAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr )
534 ((PDFWriterImpl*)pImplementation)->setAutoAdvanceTime( nSeconds, nPageNr );
537 void PDFWriter::SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr )
539 ((PDFWriterImpl*)pImplementation)->setPageTransition( eType, nMilliSec, nPageNr );
542 sal_Int32 PDFWriter::CreateControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr )
544 return ((PDFWriterImpl*)pImplementation)->createControl( rControl, nPageNr );
547 PDFOutputStream::~PDFOutputStream()
551 void PDFWriter::AddStream( const String& rMimeType, PDFOutputStream* pStream, bool bCompress )
553 ((PDFWriterImpl*)pImplementation)->addStream( rMimeType, pStream, bCompress );
556 void PDFWriter::BeginPattern( const Rectangle& rCellRect )
558 ((PDFWriterImpl*)pImplementation)->beginPattern( rCellRect );
561 sal_Int32 PDFWriter::EndPattern( const SvtGraphicFill::Transform& rTransform )
563 return ((PDFWriterImpl*)pImplementation)->endPattern( rTransform );
566 void PDFWriter::DrawPolyPolygon( const PolyPolygon& rPolyPoly, sal_Int32 nPattern, bool bEOFill )
568 ((PDFWriterImpl*)pImplementation)->drawPolyPolygon( rPolyPoly, nPattern, bEOFill );
571 std::set< PDFWriter::ErrorCode > PDFWriter::GetErrors()
573 return ((PDFWriterImpl*)pImplementation)->getErrors();