LibreOffice Module sdext (master)  1
contentsink.hxx
Go to the documentation of this file.
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 <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <com/sun/star/rendering/ARGBColor.hpp>
26 #include <memory>
27 
28 namespace com { namespace sun { namespace star {
29 namespace rendering
30 {
31  class XPolyPolygon2D;
32 }
33 namespace geometry
34 {
35  struct Matrix2D;
36  struct AffineMatrix2D;
37  struct RealRectangle2D;
38  struct RealPoint2D;
39  struct RealSize2D;
40 }
41 namespace beans
42 {
43  struct PropertyValue;
44 } } } }
45 
46 namespace pdfi
47 {
49  {
50  FontAttributes( const OUString& familyName_,
51  bool isBold_,
52  bool isItalic_,
53  bool isUnderline_,
54  double size_,
55  double ascent_) :
56  familyName(familyName_),
57  isBold(isBold_),
58  isItalic(isItalic_),
59  isUnderline(isUnderline_),
60  isOutline(false),
61  size(size_),
62  ascent(ascent_)
63  {}
64 
66  familyName(),
67  isBold(false),
68  isItalic(false),
69  isUnderline(false),
70  isOutline(false),
71  size(0.0),
72  ascent(1.0)
73  {}
74 
75  OUString familyName;
76  bool isBold;
77  bool isItalic;
79  bool isOutline;
80  double size; // device pixel
81  double ascent;
82 
83  bool operator==(const FontAttributes& rFont) const
84  {
85  return familyName == rFont.familyName &&
86  !isBold == !rFont.isBold &&
87  !isItalic == !rFont.isItalic &&
88  !isUnderline == !rFont.isUnderline &&
89  !isOutline == !rFont.isOutline &&
90  size == rFont.size &&
91  ascent == rFont.ascent;
92  }
93  };
94 
100  struct ContentSink
101  {
102  virtual ~ContentSink() {}
103 
105  virtual void setPageNum( sal_Int32 nNumPages ) = 0;
106  virtual void startPage( const css::geometry::RealSize2D& rSize ) = 0;
107  virtual void endPage() = 0;
108 
109  virtual void hyperLink( const css::geometry::RealRectangle2D& rBounds,
110  const OUString& rURI ) = 0;
111 
112  virtual void pushState() = 0;
113  virtual void popState() = 0;
114 
115  virtual void setFlatness( double ) = 0;
116  virtual void setTransformation( const css::geometry::AffineMatrix2D& rMatrix ) = 0;
117  virtual void setLineDash( const css::uno::Sequence<double>& dashes,
118  double start ) = 0;
119  virtual void setLineJoin( sal_Int8 lineJoin ) = 0;
120  virtual void setLineCap( sal_Int8 lineCap ) = 0;
121  virtual void setMiterLimit(double) = 0;
122  virtual void setLineWidth(double) = 0;
123  virtual void setFillColor( const css::rendering::ARGBColor& rColor ) = 0;
124  virtual void setStrokeColor( const css::rendering::ARGBColor& rColor ) = 0;
125  virtual void setFont( const FontAttributes& rFont ) = 0;
126  virtual void setTextRenderMode( sal_Int32 ) = 0;
127 
128 
129  virtual void strokePath( const css::uno::Reference<
130  css::rendering::XPolyPolygon2D >& rPath ) = 0;
131  virtual void fillPath( const css::uno::Reference<
132  css::rendering::XPolyPolygon2D >& rPath ) = 0;
133  virtual void eoFillPath( const css::uno::Reference<
134  css::rendering::XPolyPolygon2D >& rPath ) = 0;
135 
136  virtual void intersectClip(const css::uno::Reference<
137  css::rendering::XPolyPolygon2D >& rPath) = 0;
138  virtual void intersectEoClip(const css::uno::Reference<
139  css::rendering::XPolyPolygon2D >& rPath) = 0;
140 
141  virtual void drawGlyphs( const OUString& rGlyphs,
142  const css::geometry::RealRectangle2D& rRect,
143  const css::geometry::Matrix2D& rFontMatrix,
144  double fontSize) = 0;
145 
147  virtual void endText() = 0;
148 
150  virtual void drawMask(const css::uno::Sequence<
151  css::beans::PropertyValue>& xBitmap,
152  bool bInvert ) = 0;
154  virtual void drawImage(const css::uno::Sequence<
155  css::beans::PropertyValue>& xBitmap ) = 0;
160  virtual void drawColorMaskedImage(const css::uno::Sequence<
161  css::beans::PropertyValue>& xBitmap,
162  const css::uno::Sequence<
163  css::uno::Any>& xMaskColors ) = 0;
164  virtual void drawMaskedImage(const css::uno::Sequence<
165  css::beans::PropertyValue>& xBitmap,
166  const css::uno::Sequence<
167  css::beans::PropertyValue>& xMask,
168  bool bInvertMask) = 0;
169  virtual void drawAlphaMaskedImage(const css::uno::Sequence<
170  css::beans::PropertyValue>& xImage,
171  const css::uno::Sequence<
172  css::beans::PropertyValue>& xMask) = 0;
173  };
174 
175  typedef std::shared_ptr<ContentSink> ContentSinkSharedPtr;
176 }
177 
178 #endif // INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_CONTENTSINK_HXX
179 
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void hyperLink(const css::geometry::RealRectangle2D &rBounds, const OUString &rURI)=0
virtual void endText()=0
issued when a sequence of associated glyphs is drawn
virtual void drawMaskedImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap, const css::uno::Sequence< css::beans::PropertyValue > &xMask, bool bInvertMask)=0
virtual void intersectEoClip(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath)=0
signed char sal_Int8
virtual void setFillColor(const css::rendering::ARGBColor &rColor)=0
virtual void setPageNum(sal_Int32 nNumPages)=0
Total number of pages for upcoming document.
virtual void setLineDash(const css::uno::Sequence< double > &dashes, double start)=0
virtual void setTextRenderMode(sal_Int32)=0
virtual ~ContentSink()
virtual void drawGlyphs(const OUString &rGlyphs, const css::geometry::RealRectangle2D &rRect, const css::geometry::Matrix2D &rFontMatrix, double fontSize)=0
virtual void pushState()=0
virtual void drawImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap)=0
Given image must already be color-mapped and normalized to sRGB.
FontAttributes(const OUString &familyName_, bool isBold_, bool isItalic_, bool isUnderline_, double size_, double ascent_)
Definition: contentsink.hxx:50
virtual void setMiterLimit(double)=0
virtual void setFont(const FontAttributes &rFont)=0
virtual void intersectClip(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath)=0
virtual void strokePath(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath)=0
virtual void setLineWidth(double)=0
virtual void setLineCap(sal_Int8 lineCap)=0
virtual void setLineJoin(sal_Int8 lineJoin)=0
virtual void setStrokeColor(const css::rendering::ARGBColor &rColor)=0
virtual void eoFillPath(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath)=0
virtual void drawMask(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap, bool bInvert)=0
draws given bitmap as a mask (using current fill color)
(preliminary) API wrapper around xpdf
virtual void fillPath(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath)=0
bool operator==(const FontAttributes &rFont) const
Definition: contentsink.hxx:83
virtual void startPage(const css::geometry::RealSize2D &rSize)=0
virtual void popState()=0
virtual void drawColorMaskedImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap, const css::uno::Sequence< css::uno::Any > &xMaskColors)=0
Given image must already be color-mapped and normalized to sRGB.
virtual void drawAlphaMaskedImage(const css::uno::Sequence< css::beans::PropertyValue > &xImage, const css::uno::Sequence< css::beans::PropertyValue > &xMask)=0
virtual void endPage()=0
virtual void setFlatness(double)=0
std::shared_ptr< ContentSink > ContentSinkSharedPtr
virtual void setTransformation(const css::geometry::AffineMatrix2D &rMatrix)=0