calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / processor2d / vclmetafileprocessor2d.hxx
blob730b7aac11f211ad42439c562a2e92ffbfc54a51
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
29 class GDIMetaFile;
30 namespace tools
32 class Rectangle;
34 class Gradient;
35 class SvtGraphicFill;
36 class SvtGraphicStroke;
38 namespace drawinglayer::attribute
40 class FillGradientAttribute;
41 class LineAttribute;
42 class StrokeAttribute;
43 class LineStartEndAttribute;
46 namespace drawinglayer::primitive2d
48 class GraphicPrimitive2D;
49 class ControlPrimitive2D;
50 class TextHierarchyFieldPrimitive2D;
51 class TextHierarchyLinePrimitive2D;
52 class TextHierarchyBulletPrimitive2D;
53 class TextHierarchyParagraphPrimitive2D;
54 class TextHierarchyBlockPrimitive2D;
55 class TextSimplePortionPrimitive2D;
56 class PolygonHairlinePrimitive2D;
57 class PolygonStrokePrimitive2D;
58 class PolygonStrokeArrowPrimitive2D;
59 class PolyPolygonGraphicPrimitive2D;
60 class PolyPolygonHatchPrimitive2D;
61 class PolyPolygonGradientPrimitive2D;
62 class PolyPolygonColorPrimitive2D;
63 class MaskPrimitive2D;
64 class UnifiedTransparencePrimitive2D;
65 class TransparencePrimitive2D;
66 class ObjectInfoPrimitive2D;
67 class StructureTagPrimitive2D;
70 namespace basegfx
72 class BColor;
75 namespace drawinglayer::processor2d
77 /** VclMetafileProcessor2D class
79 This processor derived from VclProcessor2D is the base class for rendering
80 all fed primitives to a classical VCL-Metafile, including all over the
81 time grown extra data in comments and PDF exception data creations. Also
82 printing needs some exception stuff.
84 All in all it is needed to emulate the old ::paint output from the old
85 Drawinglayer as long as exporters and/or filters still use the Metafile
86 and the extra-data added to it (which can be seen mostly as 'extensions'
87 or simply as 'hacks').
89 class VclMetafileProcessor2D : public VclProcessor2D
91 private:
92 tools::Rectangle impDumpToMetaFile(const primitive2d::Primitive2DContainer& rContent,
93 GDIMetaFile& o_rContentMetafile);
94 void
95 impConvertFillGradientAttributeToVCLGradient(Gradient& o_rVCLGradient,
96 const attribute::FillGradientAttribute& rFiGrAtt,
97 bool bIsTransparenceGradient) const;
98 void impStartSvtGraphicFill(SvtGraphicFill const* pSvtGraphicFill);
99 void impEndSvtGraphicFill(SvtGraphicFill const* pSvtGraphicFill);
100 std::unique_ptr<SvtGraphicStroke>
101 impTryToCreateSvtGraphicStroke(const basegfx::B2DPolygon& rB2DPolygon,
102 const basegfx::BColor* pColor,
103 const attribute::LineAttribute* pLineAttribute,
104 const attribute::StrokeAttribute* pStrokeAttribute,
105 const attribute::LineStartEndAttribute* pStart,
106 const attribute::LineStartEndAttribute* pEnd);
107 void impStartSvtGraphicStroke(SvtGraphicStroke const* pSvtGraphicStroke);
108 void impEndSvtGraphicStroke(SvtGraphicStroke const* pSvtGraphicStroke);
109 void popStructureElement(vcl::PDFWriter::StructElement eElem);
110 void popListItem();
111 void popList();
113 void processGraphicPrimitive2D(const primitive2d::GraphicPrimitive2D& rGraphicPrimitive);
114 void processControlPrimitive2D(const primitive2d::ControlPrimitive2D& rControlPrimitive);
115 void processTextHierarchyFieldPrimitive2D(
116 const primitive2d::TextHierarchyFieldPrimitive2D& rFieldPrimitive);
117 void processTextHierarchyLinePrimitive2D(
118 const primitive2d::TextHierarchyLinePrimitive2D& rLinePrimitive);
119 void processTextHierarchyBulletPrimitive2D(
120 const primitive2d::TextHierarchyBulletPrimitive2D& rBulletPrimitive);
121 void processTextHierarchyParagraphPrimitive2D(
122 const primitive2d::TextHierarchyParagraphPrimitive2D& rParagraphPrimitive);
123 void processTextHierarchyBlockPrimitive2D(
124 const primitive2d::TextHierarchyBlockPrimitive2D& rBlockPrimitive);
125 void processTextSimplePortionPrimitive2D(
126 const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate);
127 void processPolygonHairlinePrimitive2D(
128 const primitive2d::PolygonHairlinePrimitive2D& rHairlinePrimitive);
129 void
130 processPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rStrokePrimitive);
131 void processPolygonStrokeArrowPrimitive2D(
132 const primitive2d::PolygonStrokeArrowPrimitive2D& rStrokeArrowPrimitive);
133 void processPolyPolygonGraphicPrimitive2D(
134 const primitive2d::PolyPolygonGraphicPrimitive2D& rBitmapCandidate);
135 void processPolyPolygonHatchPrimitive2D(
136 const primitive2d::PolyPolygonHatchPrimitive2D& rHatchCandidate);
137 void processPolyPolygonGradientPrimitive2D(
138 const primitive2d::PolyPolygonGradientPrimitive2D& rGradientCandidate);
139 void processPolyPolygonColorPrimitive2D(
140 const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate);
141 void processMaskPrimitive2D(const primitive2d::MaskPrimitive2D& rMaskCandidate);
142 void processUnifiedTransparencePrimitive2D(
143 const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate);
144 void processTransparencePrimitive2D(
145 const primitive2d::TransparencePrimitive2D& rTransparenceCandidate);
146 void
147 processObjectInfoPrimitive2D(const primitive2d::ObjectInfoPrimitive2D& rObjectInfoPrimitive2D);
148 void processStructureTagPrimitive2D(
149 const primitive2d::StructureTagPrimitive2D& rStructureTagCandidate);
151 /// Convert the fWidth to the same space as its coordinates.
152 double getTransformedLineWidth(double fWidth) const;
154 /// the current clipping tools::PolyPolygon from MaskPrimitive2D
155 basegfx::B2DPolyPolygon maClipPolyPolygon;
157 /// the target MetaFile
158 GDIMetaFile* mpMetaFile;
160 /* do not allow embedding SvtGraphicFills into each other,
161 use a counter to prevent that
163 sal_uInt32 mnSvtGraphicFillCount;
165 /// same for SvtGraphicStroke
166 sal_uInt32 mnSvtGraphicStrokeCount;
168 /* hold the last unified transparence value to have it handy
169 on SvtGraphicStroke creation
171 double mfCurrentUnifiedTransparence;
173 /* break iterator support
174 made static so it only needs to be fetched once, even with many single
175 constructed VclMetafileProcessor2D. It's still incarnated on demand,
176 but exists for OOo runtime now by purpose.
178 static css::uno::Reference<css::i18n::XBreakIterator> mxBreakIterator;
180 /* vcl::PDFExtOutDevData support
181 For the first step, some extra actions at vcl::PDFExtOutDevData need to
182 be emulated with the VclMetafileProcessor2D. These are potentially temporarily
183 since PDF export may use PrimitiveSequences one day directly.
185 vcl::PDFExtOutDevData* mpPDFExtOutDevData;
187 // Remember the current OutlineLevel. This is used when tagged PDF export
188 // is used to create/write valid structured list entries using PDF statements
189 // like '/L', '/LI', 'LBody' instead of simple '/P' (Paragraph).
190 // The value -1 means 'no OutlineLevel' and values >= 0 express the level.
191 sal_Int16 mnCurrentOutlineLevel;
192 bool mbInListItem;
193 bool mbBulletPresent;
195 std::stack<vcl::PDFWriter::StructElement> maListElements;
197 primitive2d::StructureTagPrimitive2D const* mpCurrentStructureTag = nullptr;
199 protected:
200 /* the local processor for BasePrimitive2D-Implementation based primitives,
201 called from the common process()-implementation
203 virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
205 public:
206 /// constructor/destructor
207 VclMetafileProcessor2D(const geometry::ViewInformation2D& rViewInformation,
208 OutputDevice& rOutDev);
209 virtual ~VclMetafileProcessor2D() override;
211 } // end of namespace processor2d::drawinglayer
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */