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