1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef INCLUDED_PDFI_CONTENTSINK_HXX 25*b1cdbd2cSJim Jagielski #define INCLUDED_PDFI_CONTENTSINK_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/Reference.hxx> 28*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/Sequence.hxx> 29*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/ARGBColor.hpp> 30*b1cdbd2cSJim Jagielski #include <boost/shared_ptr.hpp> 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim Jagielski namespace rtl { class OUString; } 33*b1cdbd2cSJim Jagielski namespace com { namespace sun { namespace star { 34*b1cdbd2cSJim Jagielski namespace rendering 35*b1cdbd2cSJim Jagielski { 36*b1cdbd2cSJim Jagielski class XPolyPolygon2D; 37*b1cdbd2cSJim Jagielski } 38*b1cdbd2cSJim Jagielski namespace geometry 39*b1cdbd2cSJim Jagielski { 40*b1cdbd2cSJim Jagielski struct Matrix2D; 41*b1cdbd2cSJim Jagielski struct AffineMatrix2D; 42*b1cdbd2cSJim Jagielski struct RealRectangle2D; 43*b1cdbd2cSJim Jagielski struct RealPoint2D; 44*b1cdbd2cSJim Jagielski struct RealSize2D; 45*b1cdbd2cSJim Jagielski } 46*b1cdbd2cSJim Jagielski namespace beans 47*b1cdbd2cSJim Jagielski { 48*b1cdbd2cSJim Jagielski struct PropertyValue; 49*b1cdbd2cSJim Jagielski } } } } 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski namespace pdfi 52*b1cdbd2cSJim Jagielski { 53*b1cdbd2cSJim Jagielski struct FontAttributes 54*b1cdbd2cSJim Jagielski { FontAttributespdfi::FontAttributes55*b1cdbd2cSJim Jagielski FontAttributes( const rtl::OUString& familyName_, 56*b1cdbd2cSJim Jagielski bool isBold_, 57*b1cdbd2cSJim Jagielski bool isItalic_, 58*b1cdbd2cSJim Jagielski bool isUnderline_, 59*b1cdbd2cSJim Jagielski bool isOutline_, 60*b1cdbd2cSJim Jagielski double size_ ) : 61*b1cdbd2cSJim Jagielski familyName(familyName_), 62*b1cdbd2cSJim Jagielski isBold(isBold_), 63*b1cdbd2cSJim Jagielski isItalic(isItalic_), 64*b1cdbd2cSJim Jagielski isUnderline(isUnderline_), 65*b1cdbd2cSJim Jagielski isOutline(isOutline_), 66*b1cdbd2cSJim Jagielski size(size_) 67*b1cdbd2cSJim Jagielski {} 68*b1cdbd2cSJim Jagielski FontAttributespdfi::FontAttributes69*b1cdbd2cSJim Jagielski FontAttributes() : 70*b1cdbd2cSJim Jagielski familyName(), 71*b1cdbd2cSJim Jagielski isBold(false), 72*b1cdbd2cSJim Jagielski isItalic(false), 73*b1cdbd2cSJim Jagielski isUnderline(false), 74*b1cdbd2cSJim Jagielski isOutline(false), 75*b1cdbd2cSJim Jagielski size(0.0) 76*b1cdbd2cSJim Jagielski {} 77*b1cdbd2cSJim Jagielski 78*b1cdbd2cSJim Jagielski ::rtl::OUString familyName; 79*b1cdbd2cSJim Jagielski bool isBold; 80*b1cdbd2cSJim Jagielski bool isItalic; 81*b1cdbd2cSJim Jagielski bool isUnderline; 82*b1cdbd2cSJim Jagielski bool isOutline; 83*b1cdbd2cSJim Jagielski double size; // device pixel 84*b1cdbd2cSJim Jagielski operator ==pdfi::FontAttributes85*b1cdbd2cSJim Jagielski bool operator==(const FontAttributes& rFont) const 86*b1cdbd2cSJim Jagielski { 87*b1cdbd2cSJim Jagielski return familyName == rFont.familyName && 88*b1cdbd2cSJim Jagielski !isBold == !rFont.isBold && 89*b1cdbd2cSJim Jagielski !isItalic == !rFont.isItalic && 90*b1cdbd2cSJim Jagielski !isUnderline == !rFont.isUnderline && 91*b1cdbd2cSJim Jagielski !isOutline == !rFont.isOutline && 92*b1cdbd2cSJim Jagielski size == rFont.size; 93*b1cdbd2cSJim Jagielski } 94*b1cdbd2cSJim Jagielski }; 95*b1cdbd2cSJim Jagielski 96*b1cdbd2cSJim Jagielski /** (preliminary) API wrapper around xpdf 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski Wraps the functionality currently used from xpdf's OutputDev 99*b1cdbd2cSJim Jagielski interface. Subject to change. 100*b1cdbd2cSJim Jagielski */ 101*b1cdbd2cSJim Jagielski struct ContentSink 102*b1cdbd2cSJim Jagielski { ~ContentSinkpdfi::ContentSink103*b1cdbd2cSJim Jagielski virtual ~ContentSink() {} 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski /// Total number of pages for upcoming document 106*b1cdbd2cSJim Jagielski virtual void setPageNum( sal_Int32 nNumPages ) = 0; 107*b1cdbd2cSJim Jagielski virtual void startPage( const ::com::sun::star::geometry::RealSize2D& rSize ) = 0; 108*b1cdbd2cSJim Jagielski virtual void endPage() = 0; 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski virtual void hyperLink( const ::com::sun::star::geometry::RealRectangle2D& rBounds, 111*b1cdbd2cSJim Jagielski const ::rtl::OUString& rURI ) = 0; 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski virtual void pushState() = 0; 114*b1cdbd2cSJim Jagielski virtual void popState() = 0; 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski virtual void setFlatness( double ) = 0; 117*b1cdbd2cSJim Jagielski virtual void setTransformation( const ::com::sun::star::geometry::AffineMatrix2D& rMatrix ) = 0; 118*b1cdbd2cSJim Jagielski virtual void setLineDash( const ::com::sun::star::uno::Sequence<double>& dashes, 119*b1cdbd2cSJim Jagielski double start ) = 0; 120*b1cdbd2cSJim Jagielski virtual void setLineJoin( sal_Int8 lineJoin ) = 0; 121*b1cdbd2cSJim Jagielski virtual void setLineCap( sal_Int8 lineCap ) = 0; 122*b1cdbd2cSJim Jagielski virtual void setMiterLimit(double) = 0; 123*b1cdbd2cSJim Jagielski virtual void setLineWidth(double) = 0; 124*b1cdbd2cSJim Jagielski virtual void setFillColor( const ::com::sun::star::rendering::ARGBColor& rColor ) = 0; 125*b1cdbd2cSJim Jagielski virtual void setStrokeColor( const ::com::sun::star::rendering::ARGBColor& rColor ) = 0; 126*b1cdbd2cSJim Jagielski virtual void setBlendMode( sal_Int8 blendMode ) = 0; 127*b1cdbd2cSJim Jagielski virtual void setFont( const FontAttributes& rFont ) = 0; 128*b1cdbd2cSJim Jagielski virtual void setTextRenderMode( sal_Int32 ) = 0; 129*b1cdbd2cSJim Jagielski 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielski virtual void strokePath( const ::com::sun::star::uno::Reference< 132*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; 133*b1cdbd2cSJim Jagielski virtual void fillPath( const ::com::sun::star::uno::Reference< 134*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; 135*b1cdbd2cSJim Jagielski virtual void eoFillPath( const ::com::sun::star::uno::Reference< 136*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielski virtual void intersectClip(const ::com::sun::star::uno::Reference< 139*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XPolyPolygon2D >& rPath) = 0; 140*b1cdbd2cSJim Jagielski virtual void intersectEoClip(const ::com::sun::star::uno::Reference< 141*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XPolyPolygon2D >& rPath) = 0; 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim Jagielski virtual void drawGlyphs( const rtl::OUString& rGlyphs, 144*b1cdbd2cSJim Jagielski const ::com::sun::star::geometry::RealRectangle2D& rRect, 145*b1cdbd2cSJim Jagielski const ::com::sun::star::geometry::Matrix2D& rFontMatrix ) = 0; 146*b1cdbd2cSJim Jagielski 147*b1cdbd2cSJim Jagielski /// issued when a sequence of associated glyphs is drawn 148*b1cdbd2cSJim Jagielski virtual void endText() = 0; 149*b1cdbd2cSJim Jagielski 150*b1cdbd2cSJim Jagielski /// draws given bitmap as a mask (using current fill color) 151*b1cdbd2cSJim Jagielski virtual void drawMask(const ::com::sun::star::uno::Sequence< 152*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xBitmap, 153*b1cdbd2cSJim Jagielski bool bInvert ) = 0; 154*b1cdbd2cSJim Jagielski /// Given image must already be color-mapped and normalized to sRGB. 155*b1cdbd2cSJim Jagielski virtual void drawImage(const ::com::sun::star::uno::Sequence< 156*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xBitmap ) = 0; 157*b1cdbd2cSJim Jagielski /** Given image must already be color-mapped and normalized to sRGB. 158*b1cdbd2cSJim Jagielski 159*b1cdbd2cSJim Jagielski maskColors must contain two sequences of color components 160*b1cdbd2cSJim Jagielski */ 161*b1cdbd2cSJim Jagielski virtual void drawColorMaskedImage(const ::com::sun::star::uno::Sequence< 162*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xBitmap, 163*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Sequence< 164*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Any>& xMaskColors ) = 0; 165*b1cdbd2cSJim Jagielski virtual void drawMaskedImage(const ::com::sun::star::uno::Sequence< 166*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xBitmap, 167*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Sequence< 168*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xMask, 169*b1cdbd2cSJim Jagielski bool bInvertMask) = 0; 170*b1cdbd2cSJim Jagielski virtual void drawAlphaMaskedImage(const ::com::sun::star::uno::Sequence< 171*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xImage, 172*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Sequence< 173*b1cdbd2cSJim Jagielski ::com::sun::star::beans::PropertyValue>& xMask) = 0; 174*b1cdbd2cSJim Jagielski }; 175*b1cdbd2cSJim Jagielski 176*b1cdbd2cSJim Jagielski typedef boost::shared_ptr<ContentSink> ContentSinkSharedPtr; 177*b1cdbd2cSJim Jagielski } 178*b1cdbd2cSJim Jagielski 179*b1cdbd2cSJim Jagielski #endif /* INCLUDED_PDFI_CONTENTSINK_HXX */ 180*b1cdbd2cSJim Jagielski 181