LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / drawinglayer / inc / wmfemfhelper.hxx
blob4a6bbe81228cf81e0cbb77a445b2e2b8d6e5c673
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 <sal/config.h>
23 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
24 #include <vcl/font.hxx>
25 #include <rtl/ref.hxx>
26 #include <vcl/rendercontext/State.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
29 #include <memory>
31 // predefines
32 namespace drawinglayer::geometry { class ViewInformation2D; }
33 class GDIMetaFile;
34 namespace wmfemfhelper { class PropertyHolder; }
36 namespace wmfemfhelper
38 /** Helper class to buffer and hold a Primitive target vector. It
39 encapsulates the new/delete functionality and allows to work
40 on pointers of the implementation classes. All data will
41 be converted to uno sequences of uno references when accessing the
42 data.
44 class TargetHolder
46 private:
47 std::vector< rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> > aTargets;
49 public:
50 TargetHolder();
51 ~TargetHolder();
52 sal_uInt32 size() const;
53 void append(const rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> & pCandidate)
55 append(pCandidate.get());
57 void append(drawinglayer::primitive2d::BasePrimitive2D* pCandidate);
58 drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequence(const PropertyHolder& rPropertyHolder);
61 /** Helper class which builds a stack on the TargetHolder class */
62 class TargetHolders
64 private:
65 std::vector< TargetHolder* > maTargetHolders;
67 public:
68 TargetHolders();
69 sal_uInt32 size() const;
70 void Push();
71 void Pop();
72 TargetHolder& Current();
73 ~TargetHolders();
76 /** helper class for graphic context
78 This class allows to hold a complete representation of classic
79 VCL OutputDevice state. This data is needed for correct
80 interpretation of the MetaFile action flow.
82 class PropertyHolder
84 private:
85 /// current transformation (aka MapMode)
86 basegfx::B2DHomMatrix maTransformation;
87 MapUnit maMapUnit;
89 /// current colors
90 basegfx::BColor maLineColor;
91 basegfx::BColor maFillColor;
92 basegfx::BColor maTextColor;
93 basegfx::BColor maTextFillColor;
94 basegfx::BColor maTextLineColor;
95 basegfx::BColor maOverlineColor;
97 /// clipping
98 basegfx::B2DPolyPolygon maClipPolyPolygon;
100 /// font, etc.
101 vcl::Font maFont;
102 RasterOp maRasterOp;
103 vcl::text::ComplexTextLayoutFlags mnLayoutMode;
104 LanguageType maLanguageType;
105 vcl::PushFlags mnPushFlags;
107 /// contains all active markers
108 bool mbLineColor : 1;
109 bool mbFillColor : 1;
110 bool mbTextColor : 1;
111 bool mbTextFillColor : 1;
112 bool mbTextLineColor : 1;
113 bool mbOverlineColor : 1;
114 bool mbClipPolyPolygonActive : 1;
116 public:
117 PropertyHolder();
119 /// read/write accesses
120 const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
121 void setTransformation(const basegfx::B2DHomMatrix& rNew) { if (rNew != maTransformation) maTransformation = rNew; }
123 MapUnit getMapUnit() const { return maMapUnit; }
124 void setMapUnit(MapUnit eNew) { if (eNew != maMapUnit) maMapUnit = eNew; }
126 const basegfx::BColor& getLineColor() const { return maLineColor; }
127 void setLineColor(const basegfx::BColor& rNew) { if (rNew != maLineColor) maLineColor = rNew; }
128 bool getLineColorActive() const { return mbLineColor; }
129 void setLineColorActive(bool bNew) { if (bNew != mbLineColor) mbLineColor = bNew; }
131 const basegfx::BColor& getFillColor() const { return maFillColor; }
132 void setFillColor(const basegfx::BColor& rNew) { if (rNew != maFillColor) maFillColor = rNew; }
133 bool getFillColorActive() const { return mbFillColor; }
134 void setFillColorActive(bool bNew) { if (bNew != mbFillColor) mbFillColor = bNew; }
136 const basegfx::BColor& getTextColor() const { return maTextColor; }
137 void setTextColor(const basegfx::BColor& rNew) { if (rNew != maTextColor) maTextColor = rNew; }
138 bool getTextColorActive() const { return mbTextColor; }
139 void setTextColorActive(bool bNew) { if (bNew != mbTextColor) mbTextColor = bNew; }
141 const basegfx::BColor& getTextFillColor() const { return maTextFillColor; }
142 void setTextFillColor(const basegfx::BColor& rNew) { if (rNew != maTextFillColor) maTextFillColor = rNew; }
143 bool getTextFillColorActive() const { return mbTextFillColor; }
144 void setTextFillColorActive(bool bNew) { if (bNew != mbTextFillColor) mbTextFillColor = bNew; }
146 const basegfx::BColor& getTextLineColor() const { return maTextLineColor; }
147 void setTextLineColor(const basegfx::BColor& rNew) { if (rNew != maTextLineColor) maTextLineColor = rNew; }
148 bool getTextLineColorActive() const { return mbTextLineColor; }
149 void setTextLineColorActive(bool bNew) { if (bNew != mbTextLineColor) mbTextLineColor = bNew; }
151 const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
152 void setOverlineColor(const basegfx::BColor& rNew) { if (rNew != maOverlineColor) maOverlineColor = rNew; }
153 bool getOverlineColorActive() const { return mbOverlineColor; }
154 void setOverlineColorActive(bool bNew) { if (bNew != mbOverlineColor) mbOverlineColor = bNew; }
156 const basegfx::B2DPolyPolygon& getClipPolyPolygon() const { return maClipPolyPolygon; }
157 void setClipPolyPolygon(const basegfx::B2DPolyPolygon& rNew) { if (rNew != maClipPolyPolygon) maClipPolyPolygon = rNew; }
158 bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive; }
159 void setClipPolyPolygonActive(bool bNew) { if (bNew != mbClipPolyPolygonActive) mbClipPolyPolygonActive = bNew; }
161 const vcl::Font& getFont() const { return maFont; }
162 void setFont(const vcl::Font& rFont) { if (rFont != maFont) maFont = rFont; }
164 const RasterOp& getRasterOp() const { return maRasterOp; }
165 void setRasterOp(const RasterOp& rRasterOp) { if (rRasterOp != maRasterOp) maRasterOp = rRasterOp; }
166 bool isRasterOpInvert() const { return (RasterOp::Xor == maRasterOp || RasterOp::Invert == maRasterOp); }
167 bool isRasterOpForceBlack() const { return RasterOp::N0 == maRasterOp; }
168 bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); }
170 vcl::text::ComplexTextLayoutFlags getLayoutMode() const { return mnLayoutMode; }
171 void setLayoutMode(vcl::text::ComplexTextLayoutFlags nNew) { if (nNew != mnLayoutMode) mnLayoutMode = nNew; }
173 LanguageType getLanguageType() const { return maLanguageType; }
174 void setLanguageType(LanguageType aNew) { if (aNew != maLanguageType) maLanguageType = aNew; }
176 vcl::PushFlags getPushFlags() const { return mnPushFlags; }
177 void setPushFlags(vcl::PushFlags nNew) { if (nNew != mnPushFlags) mnPushFlags = nNew; }
179 bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); }
182 /** stack for properties
184 This class builds a stack based on the PropertyHolder
185 class. It encapsulates the pointer/new/delete usage to
186 make it safe and implements the push/pop as needed by a
187 VCL Metafile interpreter. The critical part here are the
188 flag values VCL OutputDevice uses here; not all stuff is
189 pushed and thus needs to be copied at pop.
191 class PropertyHolders
193 private:
194 std::vector< PropertyHolder* > maPropertyHolders;
196 public:
197 PropertyHolders();
198 void PushDefault();
199 void Push(vcl::PushFlags nPushFlags);
200 void Pop();
201 PropertyHolder& Current();
202 ~PropertyHolders();
205 drawinglayer::primitive2d::Primitive2DContainer interpretMetafile(
206 const GDIMetaFile& rMetaFile,
207 const drawinglayer::geometry::ViewInformation2D& rViewInformation);
209 void HandleNewClipRegion(
210 const basegfx::B2DPolyPolygon& rClipPolyPolygon,
211 TargetHolders& rTargetHolders,
212 PropertyHolders& rPropertyHolders);
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */