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