Bump version to 24.04.3.4
[LibreOffice.git] / drawinglayer / source / processor2d / vclmetafileprocessor2d.hxx
blobc315281ebf61322b998b19eaada5edb9d26a4bb7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <stack>
24 #include "vclprocessor2d.hxx"
25 #include <com/sun/star/i18n/XBreakIterator.hpp>
26 #include <basegfx/polygon/b2dpolypolygon.hxx>
27 #include <vcl/pdfextoutdevdata.hxx> // vcl::PDFExtOutDevData support
28 #include <vcl/lazydelete.hxx>
30 class GDIMetaFile;
31 namespace tools
33 class Rectangle;
35 class Gradient;
36 class SvtGraphicFill;
37 class SvtGraphicStroke;
39 namespace drawinglayer::attribute
41 class FillGradientAttribute;
42 class LineAttribute;
43 class StrokeAttribute;
44 class LineStartEndAttribute;
47 namespace drawinglayer::primitive2d
49 class GraphicPrimitive2D;
50 class ControlPrimitive2D;
51 class TextHierarchyFieldPrimitive2D;
52 class TextHierarchyLinePrimitive2D;
53 class TextHierarchyBulletPrimitive2D;
54 class TextHierarchyParagraphPrimitive2D;
55 class TextHierarchyBlockPrimitive2D;
56 class TextSimplePortionPrimitive2D;
57 class PolygonHairlinePrimitive2D;
58 class PolygonStrokePrimitive2D;
59 class PolygonStrokeArrowPrimitive2D;
60 class PolyPolygonGraphicPrimitive2D;
61 class PolyPolygonHatchPrimitive2D;
62 class PolyPolygonGradientPrimitive2D;
63 class PolyPolygonColorPrimitive2D;
64 class MaskPrimitive2D;
65 class UnifiedTransparencePrimitive2D;
66 class TransparencePrimitive2D;
67 class ObjectInfoPrimitive2D;
68 class StructureTagPrimitive2D;
71 namespace basegfx
73 class BColor;
76 namespace drawinglayer::processor2d
78 /** VclMetafileProcessor2D class
80 This processor derived from VclProcessor2D is the base class for rendering
81 all fed primitives to a classical VCL-Metafile, including all over the
82 time grown extra data in comments and PDF exception data creations. Also
83 printing needs some exception stuff.
85 All in all it is needed to emulate the old ::paint output from the old
86 Drawinglayer as long as exporters and/or filters still use the Metafile
87 and the extra-data added to it (which can be seen mostly as 'extensions'
88 or simply as 'hacks').
90 class VclMetafileProcessor2D : public VclProcessor2D
92 private:
93 tools::Rectangle impDumpToMetaFile(const primitive2d::Primitive2DContainer& rContent,
94 GDIMetaFile& o_rContentMetafile);
95 void
96 impConvertFillGradientAttributeToVCLGradient(Gradient& o_rVCLGradient,
97 const attribute::FillGradientAttribute& rFiGrAtt,
98 bool bIsTransparenceGradient) const;
99 void impStartSvtGraphicFill(SvtGraphicFill const* pSvtGraphicFill);
100 void impEndSvtGraphicFill(SvtGraphicFill const* pSvtGraphicFill);
101 std::unique_ptr<SvtGraphicStroke>
102 impTryToCreateSvtGraphicStroke(const basegfx::B2DPolygon& rB2DPolygon,
103 const basegfx::BColor* pColor,
104 const attribute::LineAttribute* pLineAttribute,
105 const attribute::StrokeAttribute* pStrokeAttribute,
106 const attribute::LineStartEndAttribute* pStart,
107 const attribute::LineStartEndAttribute* pEnd);
108 void impStartSvtGraphicStroke(SvtGraphicStroke const* pSvtGraphicStroke);
109 void impEndSvtGraphicStroke(SvtGraphicStroke const* pSvtGraphicStroke);
110 void popStructureElement(vcl::PDFWriter::StructElement eElem);
111 void popListItem();
112 void popList();
114 void processGraphicPrimitive2D(const primitive2d::GraphicPrimitive2D& rGraphicPrimitive);
115 void processControlPrimitive2D(const primitive2d::ControlPrimitive2D& rControlPrimitive);
116 void processTextHierarchyFieldPrimitive2D(
117 const primitive2d::TextHierarchyFieldPrimitive2D& rFieldPrimitive);
118 void processTextHierarchyLinePrimitive2D(
119 const primitive2d::TextHierarchyLinePrimitive2D& rLinePrimitive);
120 void processTextHierarchyBulletPrimitive2D(
121 const primitive2d::TextHierarchyBulletPrimitive2D& rBulletPrimitive);
122 void processTextHierarchyParagraphPrimitive2D(
123 const primitive2d::TextHierarchyParagraphPrimitive2D& rParagraphPrimitive);
124 void processTextHierarchyBlockPrimitive2D(
125 const primitive2d::TextHierarchyBlockPrimitive2D& rBlockPrimitive);
126 void processTextSimplePortionPrimitive2D(
127 const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate);
128 void processPolygonHairlinePrimitive2D(
129 const primitive2d::PolygonHairlinePrimitive2D& rHairlinePrimitive);
130 void
131 processPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rStrokePrimitive);
132 void processPolygonStrokeArrowPrimitive2D(
133 const primitive2d::PolygonStrokeArrowPrimitive2D& rStrokeArrowPrimitive);
134 void processPolyPolygonGraphicPrimitive2D(
135 const primitive2d::PolyPolygonGraphicPrimitive2D& rBitmapCandidate);
136 void processPolyPolygonHatchPrimitive2D(
137 const primitive2d::PolyPolygonHatchPrimitive2D& rHatchCandidate);
138 void processPolyPolygonGradientPrimitive2D(
139 const primitive2d::PolyPolygonGradientPrimitive2D& rGradientCandidate);
140 void processPolyPolygonColorPrimitive2D(
141 const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate);
142 void processMaskPrimitive2D(const primitive2d::MaskPrimitive2D& rMaskCandidate);
143 void processUnifiedTransparencePrimitive2D(
144 const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate);
145 void processTransparencePrimitive2D(
146 const primitive2d::TransparencePrimitive2D& rTransparenceCandidate);
147 void
148 processObjectInfoPrimitive2D(const primitive2d::ObjectInfoPrimitive2D& rObjectInfoPrimitive2D);
149 void processStructureTagPrimitive2D(
150 const primitive2d::StructureTagPrimitive2D& rStructureTagCandidate);
152 /// Convert the fWidth to the same space as its coordinates.
153 double getTransformedLineWidth(double fWidth) const;
155 /// the current clipping tools::PolyPolygon from MaskPrimitive2D
156 basegfx::B2DPolyPolygon maClipPolyPolygon;
158 /// the target MetaFile
159 GDIMetaFile* mpMetaFile;
161 /* do not allow embedding SvtGraphicFills into each other,
162 use a counter to prevent that
164 sal_uInt32 mnSvtGraphicFillCount;
166 /// same for SvtGraphicStroke
167 sal_uInt32 mnSvtGraphicStrokeCount;
169 /* hold the last unified transparence value to have it handy
170 on SvtGraphicStroke creation
172 double mfCurrentUnifiedTransparence;
174 /* break iterator support
175 made static so it only needs to be fetched once, even with many single
176 constructed VclMetafileProcessor2D. It's still incarnated on demand,
177 but exists for OOo runtime now by purpose.
179 static vcl::DeleteOnDeinit<css::uno::Reference<css::i18n::XBreakIterator>> mxBreakIterator;
181 /* vcl::PDFExtOutDevData support
182 For the first step, some extra actions at vcl::PDFExtOutDevData need to
183 be emulated with the VclMetafileProcessor2D. These are potentially temporarily
184 since PDF export may use PrimitiveSequences one day directly.
186 vcl::PDFExtOutDevData* mpPDFExtOutDevData;
188 // Remember the current OutlineLevel. This is used when tagged PDF export
189 // is used to create/write valid structured list entries using PDF statements
190 // like '/L', '/LI', 'LBody' instead of simple '/P' (Paragraph).
191 // The value -1 means 'no OutlineLevel' and values >= 0 express the level.
192 sal_Int16 mnCurrentOutlineLevel;
193 bool mbInListItem;
194 bool mbBulletPresent;
196 std::stack<vcl::PDFWriter::StructElement> maListElements;
198 primitive2d::StructureTagPrimitive2D const* mpCurrentStructureTag = nullptr;
200 protected:
201 /* the local processor for BasePrimitive2D-Implementation based primitives,
202 called from the common process()-implementation
204 virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
206 public:
207 /// constructor/destructor
208 VclMetafileProcessor2D(const geometry::ViewInformation2D& rViewInformation,
209 OutputDevice& rOutDev);
210 virtual ~VclMetafileProcessor2D() override;
212 } // end of namespace processor2d::drawinglayer
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */