1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_PDFI_CONTENTSINK_HXX 29 #define INCLUDED_PDFI_CONTENTSINK_HXX 30 31 #include <com/sun/star/uno/Reference.hxx> 32 #include <com/sun/star/uno/Sequence.hxx> 33 #include <com/sun/star/rendering/ARGBColor.hpp> 34 #include <boost/shared_ptr.hpp> 35 36 namespace rtl { class OUString; } 37 namespace com { namespace sun { namespace star { 38 namespace rendering 39 { 40 class XPolyPolygon2D; 41 } 42 namespace geometry 43 { 44 struct Matrix2D; 45 struct AffineMatrix2D; 46 struct RealRectangle2D; 47 struct RealPoint2D; 48 struct RealSize2D; 49 } 50 namespace beans 51 { 52 struct PropertyValue; 53 } } } } 54 55 namespace pdfi 56 { 57 struct FontAttributes 58 { 59 FontAttributes( const rtl::OUString& familyName_, 60 bool isBold_, 61 bool isItalic_, 62 bool isUnderline_, 63 bool isOutline_, 64 double size_ ) : 65 familyName(familyName_), 66 isBold(isBold_), 67 isItalic(isItalic_), 68 isUnderline(isUnderline_), 69 isOutline(isOutline_), 70 size(size_) 71 {} 72 73 FontAttributes() : 74 familyName(), 75 isBold(false), 76 isItalic(false), 77 isUnderline(false), 78 isOutline(false), 79 size(0.0) 80 {} 81 82 ::rtl::OUString familyName; 83 bool isBold; 84 bool isItalic; 85 bool isUnderline; 86 bool isOutline; 87 double size; // device pixel 88 89 bool operator==(const FontAttributes& rFont) const 90 { 91 return familyName == rFont.familyName && 92 !isBold == !rFont.isBold && 93 !isItalic == !rFont.isItalic && 94 !isUnderline == !rFont.isUnderline && 95 !isOutline == !rFont.isOutline && 96 size == rFont.size; 97 } 98 }; 99 100 /** (preliminary) API wrapper around xpdf 101 102 Wraps the functionality currently used from xpdf's OutputDev 103 interface. Subject to change. 104 */ 105 struct ContentSink 106 { 107 virtual ~ContentSink() {} 108 109 /// Total number of pages for upcoming document 110 virtual void setPageNum( sal_Int32 nNumPages ) = 0; 111 virtual void startPage( const ::com::sun::star::geometry::RealSize2D& rSize ) = 0; 112 virtual void endPage() = 0; 113 114 virtual void hyperLink( const ::com::sun::star::geometry::RealRectangle2D& rBounds, 115 const ::rtl::OUString& rURI ) = 0; 116 117 virtual void pushState() = 0; 118 virtual void popState() = 0; 119 120 virtual void setFlatness( double ) = 0; 121 virtual void setTransformation( const ::com::sun::star::geometry::AffineMatrix2D& rMatrix ) = 0; 122 virtual void setLineDash( const ::com::sun::star::uno::Sequence<double>& dashes, 123 double start ) = 0; 124 virtual void setLineJoin( sal_Int8 lineJoin ) = 0; 125 virtual void setLineCap( sal_Int8 lineCap ) = 0; 126 virtual void setMiterLimit(double) = 0; 127 virtual void setLineWidth(double) = 0; 128 virtual void setFillColor( const ::com::sun::star::rendering::ARGBColor& rColor ) = 0; 129 virtual void setStrokeColor( const ::com::sun::star::rendering::ARGBColor& rColor ) = 0; 130 virtual void setBlendMode( sal_Int8 blendMode ) = 0; 131 virtual void setFont( const FontAttributes& rFont ) = 0; 132 virtual void setTextRenderMode( sal_Int32 ) = 0; 133 134 135 virtual void strokePath( const ::com::sun::star::uno::Reference< 136 ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; 137 virtual void fillPath( const ::com::sun::star::uno::Reference< 138 ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; 139 virtual void eoFillPath( const ::com::sun::star::uno::Reference< 140 ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; 141 142 virtual void intersectClip(const ::com::sun::star::uno::Reference< 143 ::com::sun::star::rendering::XPolyPolygon2D >& rPath) = 0; 144 virtual void intersectEoClip(const ::com::sun::star::uno::Reference< 145 ::com::sun::star::rendering::XPolyPolygon2D >& rPath) = 0; 146 147 virtual void drawGlyphs( const rtl::OUString& rGlyphs, 148 const ::com::sun::star::geometry::RealRectangle2D& rRect, 149 const ::com::sun::star::geometry::Matrix2D& rFontMatrix ) = 0; 150 151 /// issued when a sequence of associated glyphs is drawn 152 virtual void endText() = 0; 153 154 /// draws given bitmap as a mask (using current fill color) 155 virtual void drawMask(const ::com::sun::star::uno::Sequence< 156 ::com::sun::star::beans::PropertyValue>& xBitmap, 157 bool bInvert ) = 0; 158 /// Given image must already be color-mapped and normalized to sRGB. 159 virtual void drawImage(const ::com::sun::star::uno::Sequence< 160 ::com::sun::star::beans::PropertyValue>& xBitmap ) = 0; 161 /** Given image must already be color-mapped and normalized to sRGB. 162 163 maskColors must contain two sequences of color components 164 */ 165 virtual void drawColorMaskedImage(const ::com::sun::star::uno::Sequence< 166 ::com::sun::star::beans::PropertyValue>& xBitmap, 167 const ::com::sun::star::uno::Sequence< 168 ::com::sun::star::uno::Any>& xMaskColors ) = 0; 169 virtual void drawMaskedImage(const ::com::sun::star::uno::Sequence< 170 ::com::sun::star::beans::PropertyValue>& xBitmap, 171 const ::com::sun::star::uno::Sequence< 172 ::com::sun::star::beans::PropertyValue>& xMask, 173 bool bInvertMask) = 0; 174 virtual void drawAlphaMaskedImage(const ::com::sun::star::uno::Sequence< 175 ::com::sun::star::beans::PropertyValue>& xImage, 176 const ::com::sun::star::uno::Sequence< 177 ::com::sun::star::beans::PropertyValue>& xMask) = 0; 178 }; 179 180 typedef boost::shared_ptr<ContentSink> ContentSinkSharedPtr; 181 } 182 183 #endif /* INCLUDED_PDFI_CONTENTSINK_HXX */ 184 185