Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
wmf-inout.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/* Authors:
6 * Ulf Erikson <ulferikson@users.sf.net>
7 *
8 * Copyright (C) 2006-2008 Authors
9 *
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12#ifndef SEEN_EXTENSION_INTERNAL_WMF_H
13#define SEEN_EXTENSION_INTERNAL_WMF_H
14
16#include "extension/internal/metafile-inout.h" // picks up PNG
18#include "style.h"
19#include "text_reassemble.h"
20
22
23#define DIRTY_NONE 0x00
24#define DIRTY_TEXT 0x01
25#define DIRTY_FILL 0x02
26#define DIRTY_STROKE 0x04 // not used currently
27
28struct WMF_OBJECT {
29 int type = 0;
30 int level = 0;
31 char *record = nullptr;
32};
33
35 int size = 0; // number of slots allocated in strings
36 int count = 0; // number of slots used in strings
37 char **strings = nullptr; // place to store strings
38};
39
42 // SPStyle: class with constructor
43 font_name(nullptr),
44 clip_id(0),
46 fill_set(false), fill_mode(0), fill_idx(0), fill_recidx(0),
47 dirty(0),
48 active_pen(-1), active_brush(-1), active_font(-1), // -1 when the default is used
49 // sizeWnd, sizeView, winorg, vieworg,
50 ScaleInX(0), ScaleInY(0),
51 ScaleOutX(0), ScaleOutY(0),
52 bkMode(U_TRANSPARENT),
53 // bkColor, textColor
54 textAlign(0)
55 // worldTransform, cur
56 {
57 sizeWnd = point16_set( 0.0, 0.0 );
58 sizeView = point16_set( 0.0, 0.0 );
59 winorg = point16_set( 0.0, 0.0 );
60 vieworg = point16_set( 0.0, 0.0 );
61 bkColor = U_RGB(255, 255, 255); // default foreground color (white)
62 textColor = U_RGB(0, 0, 0); // default foreground color (black)
63 cur = point16_set( 0.0, 0.0 );
64 };
66 char *font_name;
67 int clip_id; // 0 if none, else 1 + index into clips
69 int stroke_mode; // enumeration from drawmode, not used if fill_set is not True
70 int stroke_idx; // used with DRAW_PATTERN and DRAW_IMAGE to return the appropriate fill
71 int stroke_recidx;// record used to regenerate hatch when it needs to be redone due to bkmode, textmode, etc. change
73 int fill_mode; // enumeration from drawmode, not used if fill_set is not True
74 int fill_idx; // used with DRAW_PATTERN and DRAW_IMAGE to return the appropriate fill
75 int fill_recidx; // record used to regenerate hatch when it needs to be redone due to bkmode, textmode, etc. change
76 int dirty; // holds the dirty bits for text, stroke, fill
77 int active_pen; // used when the active object is deleted to set the default values, -1 is none active
78 int active_brush; // ditto
79 int active_font; // ditto. also used to hold object number in case font needs to be remade due to textcolor change.
86 uint16_t bkMode;
89 uint16_t textAlign;
91};
92
93inline constexpr auto WMF_MAX_DC = 128;
94
95// like this causes a mysterious crash on the return from Wmf::open
96//typedef struct emf_callback_data {
97// this fixes it, so some confusion between this struct and the one in emf-inout???
98//typedef struct wmf_callback_data {
99// as does this
101
103 // dc: array, structure w/ constructor
104 level(0),
105 E2IdirY(1.0),
106 D2PscaleX(1.0), D2PscaleY(1.0),
107 PixelsInX(0), PixelsInY(0),
108 PixelsOutX(0), PixelsOutY(0),
111 mask(0),
112 arcdir(U_AD_COUNTERCLOCKWISE),
113 dwRop2(U_R2_COPYPEN), dwRop3(0),
114 id(0), drawtype(0),
115 // hatches, images, gradients, struct w/ constructor
116 tri(nullptr),
117 n_obj(0),
118 low_water(0)
119 //wmf_obj
120 {};
121
122 Glib::ustring outsvg;
123 Glib::ustring path;
124 Glib::ustring outdef;
125 Glib::ustring defs;
126
127 WMF_DEVICE_CONTEXT dc[WMF_MAX_DC+1]; // FIXME: This should be dynamic..
128 int level;
129
130 double E2IdirY; // WMF Y direction relative to Inkscape Y direction. Will be negative for MM_LOMETRIC etc.
131 double D2PscaleX,D2PscaleY; // WMF device to Inkscape Page scale.
132 float PixelsInX, PixelsInY; // size of the drawing, in WMF device pixels
133 float PixelsOutX, PixelsOutY; // size of the drawing, in Inkscape pixels
134 double ulCornerInX,ulCornerInY; // Upper left corner, from header rclBounds, in logical units
135 double ulCornerOutX,ulCornerOutY; // Upper left corner, in Inkscape pixels
136 uint32_t mask; // Draw properties
137 int arcdir; // U_AD_COUNTERCLOCKWISE 1 or U_AD_CLOCKWISE 2
138
139 uint32_t dwRop2; // Binary raster operation, 0 if none (use brush/pen unmolested)
140 uint32_t dwRop3; // Ternary raster operation, 0 if none (use brush/pen unmolested)
141
142 unsigned int id;
143 unsigned int drawtype; // one of 0 or U_WMR_FILLPATH, U_WMR_STROKEPATH, U_WMR_STROKEANDFILLPATH
144 // both of these end up in <defs> under the names shown here. These structures allow duplicates to be avoided.
145 WMF_STRINGS hatches; // hold pattern names, all like WMFhatch#_$$$$$$ where # is the WMF hatch code and $$$$$$ is the color
146 WMF_STRINGS images; // hold images, all like Image#, where # is the slot the image lives.
147 WMF_STRINGS clips; // hold clipping paths, referred to be the slot where the clipping path lives
148 TR_INFO *tri; // Text Reassembly data structure
149
150
151 int n_obj;
152 int low_water; // first object slot which _might_ be unoccupied. Everything below is filled.
154};
156
157class Wmf : public Metafile
158{
159public:
160 bool check(Inkscape::Extension::Extension *module) override; //Can this module load (always yes for now)
161
162 void save(Inkscape::Extension::Output *mod, // Save the given document to the given filename
163 SPDocument *doc,
164 char const *filename) override;
165
166 std::unique_ptr<SPDocument> open(Inkscape::Extension::Input *mod, char const *uri, bool is_importing) override;
167
168 static void init();
169
170protected:
171 static void print_document_to_file(SPDocument *doc, const gchar *filename);
172 static double current_scale(PWMF_CALLBACK_DATA d);
173 static std::string current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int useoffset);
174 static double current_rotation(PWMF_CALLBACK_DATA d);
175 static void enlarge_hatches(PWMF_CALLBACK_DATA d);
176 static int in_hatches(PWMF_CALLBACK_DATA d, char *test);
177 static uint32_t add_hatch(PWMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hatchColor);
178 static void enlarge_images(PWMF_CALLBACK_DATA d);
179 static int in_images(PWMF_CALLBACK_DATA d, char *test);
180 static uint32_t add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsage);
181 static uint32_t add_bm16_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char *px);
182
183 static void enlarge_clips(PWMF_CALLBACK_DATA d);
184 static int in_clips(PWMF_CALLBACK_DATA d, const char *test);
185 static void add_clips(PWMF_CALLBACK_DATA d, const char *clippath, unsigned int logic);
186
187 static void output_style(PWMF_CALLBACK_DATA d);
188 static double _pix_x_to_point(PWMF_CALLBACK_DATA d, double px);
189 static double _pix_y_to_point(PWMF_CALLBACK_DATA d, double py);
190 static double pix_to_x_point(PWMF_CALLBACK_DATA d, double px, double py);
191 static double pix_to_y_point(PWMF_CALLBACK_DATA d, double px, double py);
192 static double pix_to_abs_size(PWMF_CALLBACK_DATA d, double px);
193 static std::string pix_to_xy(PWMF_CALLBACK_DATA d, double x, double y);
194 static void select_brush(PWMF_CALLBACK_DATA d, int index);
195 static void select_font(PWMF_CALLBACK_DATA d, int index);
196 static void select_pen(PWMF_CALLBACK_DATA d, int index);
198 static void delete_object(PWMF_CALLBACK_DATA d, int index);
199 static int insert_object(PWMF_CALLBACK_DATA d, int type, const char *record);
200 static uint32_t *unknown_chars(size_t count);
201 static void common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
202 double dx, double dy, double dw, double dh, int sx, int sy, int sw, int sh, uint32_t iUsage);
203 static void common_bm16_to_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char *px,
204 double dx, double dy, double dw, double dh, int sx, int sy, int sw, int sh);
205 static int myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK_DATA d);
206 static void free_wmf_strings(WMF_STRINGS name);
207};
208
209} // namespace Inkscape::Extension::Internal
210
211#endif /* EXTENSION_INTERNAL_WMF_H */
212
213/*
214 Local Variables:
215 mode:c++
216 c-file-style:"stroustrup"
217 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
218 indent-tabs-mode:nil
219 fill-column:99
220 End:
221*/
222// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
int test()
Definition 2junctions.cpp:5
The object that is the basis for the Extension system.
Definition extension.h:133
static int in_images(PWMF_CALLBACK_DATA d, char *test)
static double pix_to_x_point(PWMF_CALLBACK_DATA d, double px, double py)
static double pix_to_abs_size(PWMF_CALLBACK_DATA d, double px)
static double _pix_y_to_point(PWMF_CALLBACK_DATA d, double py)
static void select_pen(PWMF_CALLBACK_DATA d, int index)
static uint32_t add_bm16_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char *px)
static void enlarge_hatches(PWMF_CALLBACK_DATA d)
static uint32_t add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsage)
static void add_clips(PWMF_CALLBACK_DATA d, const char *clippath, unsigned int logic)
std::unique_ptr< SPDocument > open(Inkscape::Extension::Input *mod, char const *uri, bool is_importing) override
Open a file.
static double pix_to_y_point(PWMF_CALLBACK_DATA d, double px, double py)
static void select_font(PWMF_CALLBACK_DATA d, int index)
static int myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK_DATA d)
static void output_style(PWMF_CALLBACK_DATA d)
static void delete_object(PWMF_CALLBACK_DATA d, int index)
static double current_scale(PWMF_CALLBACK_DATA d)
static double current_rotation(PWMF_CALLBACK_DATA d)
static std::string current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int useoffset)
static void common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib, double dx, double dy, double dw, double dh, int sx, int sy, int sw, int sh, uint32_t iUsage)
store SVG for an image given the pixmap and various coordinate information
static void enlarge_images(PWMF_CALLBACK_DATA d)
static void common_bm16_to_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char *px, double dx, double dy, double dw, double dh, int sx, int sy, int sw, int sh)
store SVG for an image given the pixmap and various coordinate information
static int insert_object(PWMF_CALLBACK_DATA d, int type, const char *record)
void save(Inkscape::Extension::Output *mod, SPDocument *doc, char const *filename) override
static double _pix_x_to_point(PWMF_CALLBACK_DATA d, double px)
static uint32_t * unknown_chars(size_t count)
static int in_hatches(PWMF_CALLBACK_DATA d, char *test)
static void free_wmf_strings(WMF_STRINGS name)
bool check(Inkscape::Extension::Extension *module) override
Verify any dependencies.
Definition wmf-inout.cpp:61
static int in_clips(PWMF_CALLBACK_DATA d, const char *test)
static uint32_t add_hatch(PWMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hatchColor)
static void print_document_to_file(SPDocument *doc, const gchar *filename)
Definition wmf-inout.cpp:67
static void enlarge_clips(PWMF_CALLBACK_DATA d)
static std::string pix_to_xy(PWMF_CALLBACK_DATA d, double x, double y)
static int insertable_object(PWMF_CALLBACK_DATA d)
static void select_brush(PWMF_CALLBACK_DATA d, int index)
Typed SVG document implementation.
Definition document.h:103
An SVG style object.
Definition style.h:45
Metafile input - common functions.
WMF_DEVICE_CONTEXT dc[WMF_MAX_DC+1]
Definition wmf-inout.h:127
Information for the entire text reassembly system.
Bitmap16 Object WMF manual 2.2.2.1.
Definition uwmf.h:869
WMF manual 2.2.2.8.
Definition uemf.h:474
WMF manual 2.2.2.16.
Definition uemf.h:563
SPStyle - a style object for SPItem objects.
int index
text_reassemble.h from libTERE
Glib::ustring name
Definition toolbars.cpp:55
Structures, definitions, and function prototypes for WMF files.