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