Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sdext/source/pdfimport/inc/contentsink.hxx
Line
Count
Source
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_SDEXT_SOURCE_PDFIMPORT_INC_CONTENTSINK_HXX
21
#define INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_CONTENTSINK_HXX
22
23
#include <basegfx/vector/b2enums.hxx>
24
#include <com/sun/star/uno/Reference.hxx>
25
#include <com/sun/star/uno/Sequence.hxx>
26
#include <com/sun/star/rendering/ARGBColor.hpp>
27
#include <memory>
28
29
namespace com::sun::star {
30
    namespace rendering
31
    {
32
        class  XPolyPolygon2D;
33
    }
34
    namespace geometry
35
    {
36
        struct Matrix2D;
37
        struct AffineMatrix2D;
38
        struct RealRectangle2D;
39
        struct RealSize2D;
40
    }
41
    namespace beans
42
    {
43
        struct PropertyValue;
44
    }
45
}
46
47
namespace pdfi
48
{
49
    struct FontAttributes
50
    {
51
        FontAttributes( OUString             familyName_,
52
                        OUString             sFontWeight,
53
                        bool                 isItalic_,
54
                        bool                 isUnderline_,
55
                        double               size_,
56
                        double               ascent_) :
57
0
            familyName(std::move(familyName_)),
58
0
            fontWeight(std::move(sFontWeight)),
59
0
            isItalic(isItalic_),
60
0
            isUnderline(isUnderline_),
61
0
            isOutline(false),
62
0
            size(size_),
63
0
            ascent(ascent_)
64
0
        {}
65
66
        FontAttributes() :
67
0
            familyName(),
68
0
            fontWeight(u"normal"_ustr),
69
0
            isItalic(false),
70
0
            isUnderline(false),
71
0
            isOutline(false),
72
0
            size(0.0),
73
0
            ascent(1.0)
74
0
        {}
75
76
        OUString            familyName;
77
        OUString            fontWeight;
78
        bool                isItalic;
79
        bool                isUnderline;
80
        bool                isOutline;
81
        double              size; // device pixel
82
        double              ascent;
83
84
        bool operator==(const FontAttributes& rFont) const
85
0
        {
86
0
            return familyName == rFont.familyName &&
87
0
                fontWeight == rFont.fontWeight &&
88
0
                !isItalic == !rFont.isItalic &&
89
0
                !isUnderline == !rFont.isUnderline &&
90
0
                !isOutline == !rFont.isOutline &&
91
0
                size == rFont.size &&
92
0
                ascent == rFont.ascent;
93
0
        }
94
    };
95
96
    /** (preliminary) API wrapper around xpdf
97
98
        Wraps the functionality currently used from xpdf's OutputDev
99
        interface. Subject to change.
100
     */
101
    struct ContentSink
102
    {
103
0
        virtual ~ContentSink() {}
104
105
        /// Total number of pages for upcoming document
106
        virtual void setPageNum( sal_Int32 nNumPages ) = 0;
107
        virtual void startPage( const css::geometry::RealSize2D& rSize ) = 0;
108
        virtual void endPage() = 0;
109
110
        virtual void hyperLink( const css::geometry::RealRectangle2D& rBounds,
111
                                const OUString&                             rURI ) = 0;
112
113
        virtual void pushState() = 0;
114
        virtual void popState() = 0;
115
116
        virtual void setFlatness( double ) = 0;
117
        virtual void setTransformation( const css::geometry::AffineMatrix2D& rMatrix ) = 0;
118
        virtual void setLineDash( const css::uno::Sequence<double>& dashes,
119
                                  double                                         start ) = 0;
120
        virtual void setLineJoin( basegfx::B2DLineJoin lineJoin ) = 0;
121
        virtual void setLineCap( sal_Int8 lineCap ) = 0;
122
        virtual void setMiterLimit(double) = 0;
123
        virtual void setLineWidth(double) = 0;
124
        virtual void setFillColor( const css::rendering::ARGBColor& rColor ) = 0;
125
        virtual void setStrokeColor( const css::rendering::ARGBColor& rColor ) = 0;
126
        virtual void setFont( const FontAttributes& rFont ) = 0;
127
        virtual void setTextRenderMode( sal_Int32 ) = 0;
128
129
130
        virtual void strokePath( const css::uno::Reference<
131
                                       css::rendering::XPolyPolygon2D >& rPath ) = 0;
132
        virtual void fillPath( const css::uno::Reference<
133
                                     css::rendering::XPolyPolygon2D >& rPath ) = 0;
134
        virtual void eoFillPath( const css::uno::Reference<
135
                                       css::rendering::XPolyPolygon2D >& rPath ) = 0;
136
137
        virtual void intersectClip(const css::uno::Reference<
138
                                         css::rendering::XPolyPolygon2D >& rPath) = 0;
139
        virtual void intersectClipToStroke(const css::uno::Reference<
140
                                                 css::rendering::XPolyPolygon2D >& rPath) = 0;
141
        virtual void intersectEoClip(const css::uno::Reference<
142
                                           css::rendering::XPolyPolygon2D >& rPath) = 0;
143
144
        virtual void drawGlyphs( const OUString& rGlyphs,
145
                                 const css::geometry::RealRectangle2D& rRect,
146
                                 const css::geometry::Matrix2D&        rFontMatrix,
147
                                 double fontSize) = 0;
148
149
        /// issued when a sequence of associated glyphs is drawn
150
        virtual void endText() = 0;
151
152
        /// draws given bitmap as a mask (using current fill color)
153
        virtual void drawMask(const css::uno::Sequence<
154
                                    css::beans::PropertyValue>& xBitmap,
155
                              bool                                           bInvert ) = 0;
156
        /// Given image must already be color-mapped and normalized to sRGB.
157
        virtual void drawImage(const css::uno::Sequence<
158
                                     css::beans::PropertyValue>& xBitmap ) = 0;
159
        /** Given image must already be color-mapped and normalized to sRGB.
160
161
            maskColors must contain two sequences of color components
162
         */
163
        virtual void drawColorMaskedImage(const css::uno::Sequence<
164
                                                css::beans::PropertyValue>& xBitmap,
165
                                          const css::uno::Sequence<
166
                                                css::uno::Any>&             xMaskColors ) = 0;
167
        virtual void drawMaskedImage(const css::uno::Sequence<
168
                                           css::beans::PropertyValue>& xBitmap,
169
                                     const css::uno::Sequence<
170
                                           css::beans::PropertyValue>& xMask,
171
                                     bool                                             bInvertMask) = 0;
172
        virtual void drawAlphaMaskedImage(const css::uno::Sequence<
173
                                                css::beans::PropertyValue>& xImage,
174
                                          const css::uno::Sequence<
175
                                                css::beans::PropertyValue>& xMask) = 0;
176
        virtual void tilingPatternFill(int nX0, int nY0, int nX1, int nY1,
177
                                       double nxStep, double nyStep,
178
                                       int nPaintType,
179
                                       css::geometry::AffineMatrix2D& rMat,
180
                                       const css::uno::Sequence<css::beans::PropertyValue>& xTile) = 0;
181
        virtual void beginTransparencyGroup(bool bForSoftMask) = 0;
182
        virtual void endTransparencyGroup(void) = 0;
183
    };
184
185
    typedef std::shared_ptr<ContentSink> ContentSinkSharedPtr;
186
}
187
188
#endif // INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_CONTENTSINK_HXX
189
190
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */