mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
15 Commits
v9.0.2.9
...
feature/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fc7ebed19 | |||
| dbf89fcaa3 | |||
| 44c26bc020 | |||
| a3a1c5fc3e | |||
| e3968cec5b | |||
| 20ba78cd7c | |||
| 7043515089 | |||
| 68f070d073 | |||
| b2c6667823 | |||
| 0e563c8461 | |||
| ee47ced36b | |||
| efe6f4408b | |||
| b918f81c2b | |||
| 204bc33610 | |||
| db9fb871a1 |
@ -4,7 +4,6 @@ CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
core_ios:CONFIG += disable_enum_constexpr_conversion
|
||||
core_android:CONFIG += disable_enum_constexpr_conversion
|
||||
core_mac:CONFIG += disable_enum_constexpr_conversion
|
||||
core_linux_clang:CONFIG += disable_enum_constexpr_conversion
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/build/android/include
|
||||
|
||||
@ -1,818 +0,0 @@
|
||||
// https://android.googlesource.com/platform/external/harfbuzz/+/ics-mr0/contrib/tables/script-properties.h
|
||||
|
||||
/*
|
||||
* https://unicode.org/reports/tr29/
|
||||
|
||||
As far as a user is concerned, the underlying representation of text is not important,
|
||||
but it is important that an editing interface present a uniform implementation of what
|
||||
the user thinks of as characters. Grapheme clusters can be treated as units, by default,
|
||||
for processes such as the formatting of drop caps, as well as the implementation of text
|
||||
selection, arrow key movement or backspacing through text, and so forth. For example,
|
||||
when a grapheme cluster is represented internally by a character sequence consisting of
|
||||
base character + accents, then using the right arrow key would skip from the start of the
|
||||
base character to the end of the last accent.
|
||||
|
||||
This document defines a default specification for grapheme clusters. It may be customized
|
||||
for particular languages, operations, or other situations. For example, arrow key movement
|
||||
could be tailored by language, or could use knowledge specific to particular fonts to move
|
||||
in a more granular manner, in circumstances where it would be useful to edit individual
|
||||
components. This could apply, for example, to the complex editorial requirements for the
|
||||
Northern Thai script Tai Tham (Lanna). Similarly, editing a grapheme cluster element by
|
||||
element may be preferable in some circumstances. For example, on a given system the backspace
|
||||
key might delete by code point, while the delete key may delete an entire cluster.
|
||||
* */
|
||||
|
||||
#include "../../../core/DesktopEditor/common/File.h"
|
||||
#include "../../../core/DesktopEditor/raster/BgraFrame.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
#include FT_OUTLINE_H
|
||||
|
||||
#include <hb-ft.h>
|
||||
#include <hb-ot.h>
|
||||
#include <hb.h>
|
||||
|
||||
class CDrawer
|
||||
{
|
||||
public:
|
||||
CBgraFrame m_oFrame;
|
||||
BYTE *pixels;
|
||||
int width;
|
||||
int height;
|
||||
int pitch;
|
||||
BYTE Rshift;
|
||||
BYTE Gshift;
|
||||
BYTE Bshift;
|
||||
BYTE Ashift;
|
||||
|
||||
public:
|
||||
CDrawer(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
pitch = 4 * width;
|
||||
m_oFrame.put_Width(width);
|
||||
m_oFrame.put_Height(height);
|
||||
m_oFrame.put_Stride(pitch);
|
||||
|
||||
int size = 4 * width * height;
|
||||
BYTE *pPixels = new BYTE[size];
|
||||
for (int i = 0; i < size; i += 4)
|
||||
{
|
||||
pPixels[i] = 0xFF;
|
||||
pPixels[i + 1] = 0xFF;
|
||||
pPixels[i + 2] = 0xFF;
|
||||
pPixels[i + 3] = 0xFF;
|
||||
}
|
||||
pixels = pPixels;
|
||||
m_oFrame.put_Data(pPixels);
|
||||
|
||||
Bshift = 24;
|
||||
Gshift = 16;
|
||||
Rshift = 8;
|
||||
Ashift = 0;
|
||||
}
|
||||
void Save()
|
||||
{
|
||||
m_oFrame.SaveFile(NSFile::GetProcessDirectory() + L"/output.png", 4);
|
||||
}
|
||||
};
|
||||
|
||||
#define NUM_EXAMPLES 3
|
||||
|
||||
/* fonts */
|
||||
const char *fonts_paths[NUM_EXAMPLES] = {
|
||||
"C:/Windows/Fonts/calibri.ttf",
|
||||
//"C:/Windows/Fonts/arial.ttf",
|
||||
"C:/Users/korol/AppData/Local/Microsoft/Windows/Fonts/ArabicTest.ttf",
|
||||
"C:/Windows/Fonts/simsun.ttc"
|
||||
};
|
||||
|
||||
#define NUM_GLYPH_TYPES 5
|
||||
const char *num_glyph_types[NUM_GLYPH_TYPES] = {"UNCLASSIFIED", "BASE_GLYPH", "LIGATURE", "MARK", "COMPONENT"};
|
||||
|
||||
/* tranlations courtesy of google */
|
||||
const char *texts[NUM_EXAMPLES] = {
|
||||
"fi",
|
||||
"لا لآ لأ لا",
|
||||
"懶惰的姜貓"
|
||||
};
|
||||
|
||||
const hb_direction_t text_directions[NUM_EXAMPLES] = {
|
||||
HB_DIRECTION_LTR,
|
||||
HB_DIRECTION_RTL,
|
||||
HB_DIRECTION_TTB,
|
||||
};
|
||||
|
||||
const int text_skip[NUM_EXAMPLES] = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
|
||||
/* XXX: These are not correct, though it doesn't seem to break anything
|
||||
* regardless of their value. */
|
||||
const char *languages[NUM_EXAMPLES] = {
|
||||
"en",
|
||||
"ar",
|
||||
"ch",
|
||||
};
|
||||
|
||||
const hb_script_t scripts[NUM_EXAMPLES] = {
|
||||
HB_SCRIPT_LATIN,
|
||||
HB_SCRIPT_ARABIC,
|
||||
HB_SCRIPT_HAN,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENGLISH = 0,
|
||||
ARABIC,
|
||||
CHINESE
|
||||
};
|
||||
|
||||
typedef struct _spanner_baton_t
|
||||
{
|
||||
/* rendering part - assumes 32bpp surface */
|
||||
uint32_t *pixels; // set to the glyph's origin.
|
||||
uint32_t *first_pixel, *last_pixel; // bounds check
|
||||
uint32_t pitch;
|
||||
uint32_t rshift;
|
||||
uint32_t gshift;
|
||||
uint32_t bshift;
|
||||
uint32_t ashift;
|
||||
|
||||
/* sizing part */
|
||||
int min_span_x;
|
||||
int max_span_x;
|
||||
int min_y;
|
||||
int max_y;
|
||||
} spanner_baton_t;
|
||||
|
||||
/* This spanner is write only, suitable for write-only mapped buffers,
|
||||
but can cause dark streaks where glyphs overlap, like in arabic scripts.
|
||||
|
||||
Note how spanners don't clip against surface width - resize the window
|
||||
and see what it leads to. */
|
||||
void spanner_wo(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
uint32_t *scanline = baton->pixels - y * ((int)baton->pitch / 4);
|
||||
if (scanline < baton->first_pixel)
|
||||
return;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t color = ((spans[i].coverage / 2) << baton->rshift) | ((spans[i].coverage / 2) << baton->gshift) | ((spans[i].coverage / 2) << baton->bshift);
|
||||
|
||||
uint32_t *start = scanline + spans[i].x;
|
||||
if (start + spans[i].len > baton->last_pixel)
|
||||
return;
|
||||
|
||||
for (int x = 0; x < spans[i].len; x++)
|
||||
*start++ = color;
|
||||
}
|
||||
}
|
||||
|
||||
/* This spanner does read/modify/write, trading performance for accuracy.
|
||||
The color here is simply half coverage value in all channels,
|
||||
effectively mid-gray.
|
||||
Suitable for when artifacts mostly do come up and annoy.
|
||||
This might be optimized if one does rmw only for some values of x.
|
||||
But since the whole buffer has to be rw anyway, and the previous value
|
||||
is probably still in the cache, there's little point to. */
|
||||
void spanner_rw(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
uint32_t *scanline = baton->pixels - y * ((int)baton->pitch / 4);
|
||||
if (scanline < baton->first_pixel)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t color = ((spans[i].coverage / 2) << baton->rshift) | ((spans[i].coverage / 2) << baton->gshift) | ((spans[i].coverage / 2) << baton->bshift);
|
||||
uint32_t *start = scanline + spans[i].x;
|
||||
if (start + spans[i].len > baton->last_pixel)
|
||||
return;
|
||||
|
||||
for (int x = 0; x < spans[i].len; x++)
|
||||
*start++ |= color;
|
||||
}
|
||||
}
|
||||
|
||||
/* This spanner is for obtaining exact bounding box for the string.
|
||||
Unfortunately this can't be done without rendering it (or pretending to).
|
||||
After this runs, we get min and max values of coordinates used.
|
||||
*/
|
||||
void spanner_sizer(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
|
||||
if (y < baton->min_y)
|
||||
baton->min_y = y;
|
||||
if (y > baton->max_y)
|
||||
baton->max_y = y;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (spans[i].x + spans[i].len > baton->max_span_x)
|
||||
baton->max_span_x = spans[i].x + spans[i].len;
|
||||
if (spans[i].x < baton->min_span_x)
|
||||
baton->min_span_x = spans[i].x;
|
||||
}
|
||||
}
|
||||
|
||||
FT_SpanFunc spanner = spanner_wo;
|
||||
|
||||
void ftfdump(FT_Face ftf)
|
||||
{
|
||||
for (int i = 0; i < ftf->num_charmaps; i++)
|
||||
{
|
||||
printf(
|
||||
"%d: %s %s %c%c%c%c plat=%hu id=%hu\n", i, ftf->family_name, ftf->style_name, ftf->charmaps[i]->encoding >> 24, (ftf->charmaps[i]->encoding >> 16) & 0xff,
|
||||
(ftf->charmaps[i]->encoding >> 8) & 0xff, (ftf->charmaps[i]->encoding) & 0xff, ftf->charmaps[i]->platform_id, ftf->charmaps[i]->encoding_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* See http://www.microsoft.com/typography/otspec/name.htm
|
||||
for a list of some possible platform-encoding pairs.
|
||||
We're interested in 0-3 aka 3-1 - UCS-2.
|
||||
Otherwise, fail. If a font has some unicode map, but lacks
|
||||
UCS-2 - it is a broken or irrelevant font. What exactly
|
||||
Freetype will select on face load (it promises most wide
|
||||
unicode, and if that will be slower that UCS-2 - left as
|
||||
an excercise to check. */
|
||||
int force_ucs2_charmap(FT_Face ftf)
|
||||
{
|
||||
for (int i = 0; i < ftf->num_charmaps; i++)
|
||||
if (((ftf->charmaps[i]->platform_id == 0) && (ftf->charmaps[i]->encoding_id == 3)) || ((ftf->charmaps[i]->platform_id == 3) && (ftf->charmaps[i]->encoding_id == 1)))
|
||||
return FT_Set_Charmap(ftf, ftf->charmaps[i]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void hline(CDrawer *s, int min_x, int max_x, int y, uint32_t color)
|
||||
{
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
uint32_t *pix = (uint32_t *)s->pixels + (y * s->pitch) / 4 + min_x;
|
||||
uint32_t *end = (uint32_t *)s->pixels + (y * s->pitch) / 4 + max_x;
|
||||
|
||||
while (pix - 1 != end)
|
||||
*pix++ = color;
|
||||
}
|
||||
|
||||
void vline(CDrawer *s, int min_y, int max_y, int x, uint32_t color)
|
||||
{
|
||||
if (min_y < 0)
|
||||
min_y = 0;
|
||||
|
||||
uint32_t *pix = (uint32_t *)s->pixels + (min_y * s->pitch) / 4 + x;
|
||||
uint32_t *end = (uint32_t *)s->pixels + (max_y * s->pitch) / 4 + x;
|
||||
|
||||
while (pix - s->pitch / 4 != end)
|
||||
{
|
||||
*pix = color;
|
||||
pix += s->pitch / 4;
|
||||
}
|
||||
}
|
||||
|
||||
void assert(const bool &valid)
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
#define MAIN_CC_NO_PRIVATE_API
|
||||
#ifndef MAIN_CC_NO_PRIVATE_API
|
||||
/* Only this part of this mini app uses private API */
|
||||
#include "hb-open-file.hh"
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
#include "hb-ot-layout-gsubgpos.hh"
|
||||
#include "hb-static.cc"
|
||||
|
||||
using namespace OT;
|
||||
|
||||
static void print_layout_info_using_private_api(hb_blob_t *blob)
|
||||
{
|
||||
const char *font_data = hb_blob_get_data(blob, nullptr);
|
||||
hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob<OpenTypeFontFile>(blob);
|
||||
const OpenTypeFontFile *sanitized = font_blob->as<OpenTypeFontFile>();
|
||||
if (!font_blob->data)
|
||||
{
|
||||
printf("Sanitization of the file wasn't successful. Exit");
|
||||
exit(1);
|
||||
}
|
||||
const OpenTypeFontFile &ot = *sanitized;
|
||||
|
||||
switch (ot.get_tag())
|
||||
{
|
||||
case OpenTypeFontFile::TrueTypeTag:
|
||||
printf("OpenType font with TrueType outlines\n");
|
||||
break;
|
||||
case OpenTypeFontFile::CFFTag:
|
||||
printf("OpenType font with CFF (Type1) outlines\n");
|
||||
break;
|
||||
case OpenTypeFontFile::TTCTag:
|
||||
printf("TrueType Collection of OpenType fonts\n");
|
||||
break;
|
||||
case OpenTypeFontFile::TrueTag:
|
||||
printf("Obsolete Apple TrueType font\n");
|
||||
break;
|
||||
case OpenTypeFontFile::Typ1Tag:
|
||||
printf("Obsolete Apple Type1 font in SFNT container\n");
|
||||
break;
|
||||
case OpenTypeFontFile::DFontTag:
|
||||
printf("DFont Mac Resource Fork\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown font format\n");
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned num_faces = hb_face_count(blob);
|
||||
printf("%d font(s) found in file\n", num_faces);
|
||||
for (unsigned n_font = 0; n_font < num_faces; ++n_font)
|
||||
{
|
||||
const OpenTypeFontFace &font = ot.get_face(n_font);
|
||||
printf("Font %d of %d:\n", n_font, num_faces);
|
||||
|
||||
unsigned num_tables = font.get_table_count();
|
||||
printf(" %d table(s) found in font\n", num_tables);
|
||||
for (unsigned n_table = 0; n_table < num_tables; ++n_table)
|
||||
{
|
||||
const OpenTypeTable &table = font.get_table(n_table);
|
||||
printf(" Table %2d of %2d: %.4s (0x%08x+0x%08x)\n", n_table, num_tables, (const char *)table.tag, (unsigned)table.offset, (unsigned)table.length);
|
||||
|
||||
switch (table.tag)
|
||||
{
|
||||
|
||||
case HB_OT_TAG_GSUB:
|
||||
case HB_OT_TAG_GPOS:
|
||||
{
|
||||
|
||||
const GSUBGPOS &g = *reinterpret_cast<const GSUBGPOS *>(font_data + table.offset);
|
||||
|
||||
unsigned num_scripts = g.get_script_count();
|
||||
printf(" %d script(s) found in table\n", num_scripts);
|
||||
for (unsigned n_script = 0; n_script < num_scripts; ++n_script)
|
||||
{
|
||||
const Script &script = g.get_script(n_script);
|
||||
printf(" Script %2d of %2d: %.4s\n", n_script, num_scripts, (const char *)g.get_script_tag(n_script));
|
||||
|
||||
if (!script.has_default_lang_sys())
|
||||
printf(" No default language system\n");
|
||||
int num_langsys = script.get_lang_sys_count();
|
||||
printf(" %d language system(s) found in script\n", num_langsys);
|
||||
for (int n_langsys = script.has_default_lang_sys() ? -1 : 0; n_langsys < num_langsys; ++n_langsys)
|
||||
{
|
||||
const LangSys &langsys = n_langsys == -1 ? script.get_default_lang_sys() : script.get_lang_sys(n_langsys);
|
||||
if (n_langsys == -1)
|
||||
printf(" Default Language System\n");
|
||||
else
|
||||
printf(" Language System %2d of %2d: %.4s\n", n_langsys, num_langsys, (const char *)script.get_lang_sys_tag(n_langsys));
|
||||
if (!langsys.has_required_feature())
|
||||
printf(" No required feature\n");
|
||||
else
|
||||
printf(" Required feature index: %d\n", langsys.get_required_feature_index());
|
||||
|
||||
unsigned num_features = langsys.get_feature_count();
|
||||
printf(" %d feature(s) found in language system\n", num_features);
|
||||
for (unsigned n_feature = 0; n_feature < num_features; ++n_feature)
|
||||
{
|
||||
printf(" Feature index %2d of %2d: %d\n", n_feature, num_features, langsys.get_feature_index(n_feature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_features = g.get_feature_count();
|
||||
printf(" %d feature(s) found in table\n", num_features);
|
||||
for (unsigned n_feature = 0; n_feature < num_features; ++n_feature)
|
||||
{
|
||||
const Feature &feature = g.get_feature(n_feature);
|
||||
unsigned num_lookups = feature.get_lookup_count();
|
||||
printf(" Feature %2d of %2d: %c%c%c%c\n", n_feature, num_features, HB_UNTAG(g.get_feature_tag(n_feature)));
|
||||
|
||||
printf(" %d lookup(s) found in feature\n", num_lookups);
|
||||
for (unsigned n_lookup = 0; n_lookup < num_lookups; ++n_lookup)
|
||||
{
|
||||
printf(" Lookup index %2d of %2d: %d\n", n_lookup, num_lookups, feature.get_lookup_index(n_lookup));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_lookups = g.get_lookup_count();
|
||||
printf(" %d lookup(s) found in table\n", num_lookups);
|
||||
for (unsigned n_lookup = 0; n_lookup < num_lookups; ++n_lookup)
|
||||
{
|
||||
const Lookup &lookup = g.get_lookup(n_lookup);
|
||||
printf(" Lookup %2d of %2d: type %d, props 0x%04X\n", n_lookup, num_lookups, lookup.get_type(), lookup.get_props());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDEF::tableTag:
|
||||
{
|
||||
|
||||
const GDEF &gdef = *reinterpret_cast<const GDEF *>(font_data + table.offset);
|
||||
|
||||
printf(" Has %sglyph classes\n", gdef.has_glyph_classes() ? "" : "no ");
|
||||
printf(" Has %smark attachment types\n", gdef.has_mark_attachment_types() ? "" : "no ");
|
||||
printf(" Has %sattach points\n", gdef.has_attach_points() ? "" : "no ");
|
||||
printf(" Has %slig carets\n", gdef.has_lig_carets() ? "" : "no ");
|
||||
printf(" Has %smark sets\n", gdef.has_mark_sets() ? "" : "no ");
|
||||
|
||||
hb_position_t caret_array[16];
|
||||
unsigned int caret_count = 16;
|
||||
|
||||
unsigned int num_carets = gdef.get_lig_carets(nullptr, HB_DIRECTION_LTR, 302, 0, &caret_count, caret_array);
|
||||
int y = 0;
|
||||
++y;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end of private API use */
|
||||
#endif
|
||||
|
||||
struct hb_feature_test {
|
||||
hb_tag_t tag;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// hb_blob_t* blobFileTest = hb_blob_create_from_file("C:/Windows/Fonts/calibri.ttf");
|
||||
// print_layout_info_using_private_api(blobFileTest);
|
||||
|
||||
int ptSize = 40 * 64;
|
||||
int device_hdpi = 72;
|
||||
int device_vdpi = 72;
|
||||
|
||||
/* Init freetype */
|
||||
FT_Library ft_library;
|
||||
assert(!FT_Init_FreeType(&ft_library));
|
||||
|
||||
/* Load our fonts */
|
||||
FT_Face ft_face[NUM_EXAMPLES];
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[0], 0, &ft_face[ENGLISH]));
|
||||
assert(!FT_Set_Char_Size(ft_face[ENGLISH], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[ENGLISH]); // wonderful world of encodings ...
|
||||
// force_ucs2_charmap(ft_face[ENGLISH]); // which we ignore.
|
||||
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[1], 0, &ft_face[ARABIC]));
|
||||
assert(!FT_Set_Char_Size(ft_face[ARABIC], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[ARABIC]);
|
||||
// force_ucs2_charmap(ft_face[ARABIC]);
|
||||
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[2], 0, &ft_face[CHINESE]));
|
||||
assert(!FT_Set_Char_Size(ft_face[CHINESE], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[CHINESE]);
|
||||
// force_ucs2_charmap(ft_face[CHINESE]);
|
||||
|
||||
/* Get our harfbuzz font structs */
|
||||
hb_font_t *hb_ft_font[NUM_EXAMPLES];
|
||||
hb_ft_font[ENGLISH] = hb_ft_font_create(ft_face[ENGLISH], NULL);
|
||||
|
||||
// hb_blob_t* blobFile = hb_blob_create_from_file(sFont1.c_str());
|
||||
// hb_face_t* faceFile = hb_face_create(blobFile, 0);
|
||||
// hb_ft_font[ENGLISH] = hb_font_create(faceFile);
|
||||
|
||||
hb_ft_font[ARABIC] = hb_ft_font_create(ft_face[ARABIC], NULL);
|
||||
hb_ft_font[CHINESE] = hb_ft_font_create(ft_face[CHINESE], NULL);
|
||||
|
||||
hb_ft_font_set_funcs(hb_ft_font[ENGLISH]);
|
||||
hb_ft_font_set_funcs(hb_ft_font[ARABIC]);
|
||||
hb_ft_font_set_funcs(hb_ft_font[CHINESE]);
|
||||
|
||||
/** Setup our SDL window **/
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
int bpp = 32;
|
||||
|
||||
CDrawer oDrawer(width, height);
|
||||
|
||||
/* Create a buffer for harfbuzz to use */
|
||||
hb_buffer_t *buf = hb_buffer_create();
|
||||
for (int i = 0; i < NUM_EXAMPLES; ++i)
|
||||
{
|
||||
if (text_skip[i])
|
||||
continue;
|
||||
|
||||
hb_buffer_set_direction(buf, text_directions[i]); /* or LTR */
|
||||
hb_buffer_set_script(buf, scripts[i]); /* see hb-unicode.h */
|
||||
hb_buffer_set_language(buf, hb_language_from_string(languages[i], strlen(languages[i])));
|
||||
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
|
||||
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
|
||||
hb_feature_test features[] {
|
||||
{HB_TAG('r','l','i','g'), 1},
|
||||
{HB_TAG('l','i','g','a'), 0},
|
||||
{HB_TAG('c','l','i','g'), 1},
|
||||
{HB_TAG('h','l','i','g'), 1},
|
||||
{HB_TAG('d','l','i','g'), 1},
|
||||
{HB_TAG('k','e','r','n'), 2},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
int userfeatures_count = 0;
|
||||
hb_feature_t userfeatures[100];
|
||||
|
||||
hb_feature_test* current_feature = features;
|
||||
while (current_feature->tag != 0)
|
||||
{
|
||||
if (current_feature->value != 2)
|
||||
{
|
||||
userfeatures[userfeatures_count].tag = current_feature->tag;
|
||||
userfeatures[userfeatures_count].value = current_feature->value;
|
||||
userfeatures[userfeatures_count].start = HB_FEATURE_GLOBAL_START;
|
||||
userfeatures[userfeatures_count].end = HB_FEATURE_GLOBAL_END;
|
||||
userfeatures_count++;
|
||||
}
|
||||
current_feature++;
|
||||
}
|
||||
|
||||
/* Layout the text */
|
||||
hb_buffer_add_utf8(buf, texts[i], strlen(texts[i]), 0, strlen(texts[i]));
|
||||
|
||||
// detect script by codes
|
||||
hb_buffer_guess_segment_properties(buf);
|
||||
|
||||
// const char*const pHbShapers[] = { "graphite2", "coretext_aat", "ot", "fallback", nullptr };
|
||||
// bool ok = hb_shape_full(hb_ft_font[i], buf, userfeatures, userfeatures_count, pHbShapers);
|
||||
|
||||
hb_shape(hb_ft_font[i], buf, (userfeatures_count != 0) ? userfeatures : NULL, userfeatures_count);
|
||||
|
||||
unsigned int glyph_count;
|
||||
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);
|
||||
hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count);
|
||||
|
||||
#if 1
|
||||
hb_position_t caret_array[16];
|
||||
unsigned int caret_count = 16;
|
||||
|
||||
unsigned int num_carets = hb_ot_layout_get_ligature_carets(hb_ft_font[i], text_directions[i], glyph_info[0].codepoint, -1, &caret_count, caret_array);
|
||||
#endif
|
||||
|
||||
/* set up rendering via spanners */
|
||||
spanner_baton_t stuffbaton;
|
||||
|
||||
FT_Raster_Params ftr_params;
|
||||
ftr_params.target = 0;
|
||||
ftr_params.flags = FT_RASTER_FLAG_DIRECT | FT_RASTER_FLAG_AA;
|
||||
ftr_params.user = &stuffbaton;
|
||||
ftr_params.black_spans = 0;
|
||||
ftr_params.bit_set = 0;
|
||||
ftr_params.bit_test = 0;
|
||||
|
||||
/* Calculate string bounding box in pixels */
|
||||
ftr_params.gray_spans = spanner_sizer;
|
||||
|
||||
/* See http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html */
|
||||
|
||||
int max_x = INT_MIN; // largest coordinate a pixel has been set at, or the pen was advanced to.
|
||||
int min_x = INT_MAX; // smallest coordinate a pixel has been set at, or the pen was advanced to.
|
||||
int max_y = INT_MIN; // this is max topside bearing along the string.
|
||||
int min_y = INT_MAX; // this is max value of (height - topbearing) along the string.
|
||||
/* Naturally, the above comments swap their meaning between horizontal and vertical scripts,
|
||||
since the pen changes the axis it is advanced along.
|
||||
However, their differences still make up the bounding box for the string.
|
||||
Also note that all this is in FT coordinate system where y axis points upwards.
|
||||
*/
|
||||
|
||||
int sizer_x = 0;
|
||||
int sizer_y = 0; /* in FT coordinate system. */
|
||||
|
||||
printf("----------------------------------------------------\n");
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
hb_ot_layout_glyph_class_t glyph_type = hb_ot_layout_get_glyph_class(hb_font_get_face(hb_ft_font[i]), glyph_info[j].codepoint);
|
||||
hb_glyph_flags_t glyph_type_flags = hb_glyph_info_get_glyph_flags(&glyph_info[j]);
|
||||
printf(
|
||||
"glyph(%s, flags: %d): gid:%d, cluster:%d, [%d, %d, %d, %d, %d]\n", num_glyph_types[glyph_type], glyph_type_flags, (int)glyph_info[j].codepoint, (int)glyph_info[j].cluster,
|
||||
glyph_pos[j].x_advance, glyph_pos[j].y_advance, glyph_pos[j].x_offset, glyph_pos[j].y_offset, glyph_pos[j].var);
|
||||
}
|
||||
|
||||
FT_Error fterr;
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
if ((fterr = FT_Load_Glyph(ft_face[i], glyph_info[j].codepoint, 0)))
|
||||
{
|
||||
printf("load %08x failed fterr=%d.\n", glyph_info[j].codepoint, fterr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ft_face[i]->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
printf("glyph->format = %4s\n", (char *)&ft_face[i]->glyph->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
int gx = sizer_x + (glyph_pos[j].x_offset / 64);
|
||||
int gy = sizer_y + (glyph_pos[j].y_offset / 64); // note how the sign differs from the rendering pass
|
||||
|
||||
stuffbaton.min_span_x = INT_MAX;
|
||||
stuffbaton.max_span_x = INT_MIN;
|
||||
stuffbaton.min_y = INT_MAX;
|
||||
stuffbaton.max_y = INT_MIN;
|
||||
|
||||
if ((fterr = FT_Outline_Render(ft_library, &ft_face[i]->glyph->outline, &ftr_params)))
|
||||
printf("FT_Outline_Render() failed err=%d\n", fterr);
|
||||
|
||||
if (stuffbaton.min_span_x != INT_MAX)
|
||||
{
|
||||
/* Update values if the spanner was actually called. */
|
||||
if (min_x > stuffbaton.min_span_x + gx)
|
||||
min_x = stuffbaton.min_span_x + gx;
|
||||
|
||||
if (max_x < stuffbaton.max_span_x + gx)
|
||||
max_x = stuffbaton.max_span_x + gx;
|
||||
|
||||
if (min_y > stuffbaton.min_y + gy)
|
||||
min_y = stuffbaton.min_y + gy;
|
||||
|
||||
if (max_y < stuffbaton.max_y + gy)
|
||||
max_y = stuffbaton.max_y + gy;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The spanner wasn't called at all - an empty glyph, like space. */
|
||||
if (min_x > gx)
|
||||
min_x = gx;
|
||||
if (max_x < gx)
|
||||
max_x = gx;
|
||||
if (min_y > gy)
|
||||
min_y = gy;
|
||||
if (max_y < gy)
|
||||
max_y = gy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sizer_x += glyph_pos[j].x_advance / 64;
|
||||
sizer_y += glyph_pos[j].y_advance / 64; // note how the sign differs from the rendering pass
|
||||
}
|
||||
/* Still have to take into account last glyph's advance. Or not? */
|
||||
if (min_x > sizer_x)
|
||||
min_x = sizer_x;
|
||||
if (max_x < sizer_x)
|
||||
max_x = sizer_x;
|
||||
if (min_y > sizer_y)
|
||||
min_y = sizer_y;
|
||||
if (max_y < sizer_y)
|
||||
max_y = sizer_y;
|
||||
|
||||
/* The bounding box */
|
||||
int bbox_w = max_x - min_x;
|
||||
int bbox_h = max_y - min_y;
|
||||
|
||||
/* Two offsets below position the bounding box with respect to the 'origin',
|
||||
which is sort of origin of string's first glyph.
|
||||
|
||||
baseline_offset - offset perpendecular to the baseline to the topmost (horizontal),
|
||||
or leftmost (vertical) pixel drawn.
|
||||
|
||||
baseline_shift - offset along the baseline, from the first drawn glyph's origin
|
||||
to the leftmost (horizontal), or topmost (vertical) pixel drawn.
|
||||
|
||||
Thus those offsets allow positioning the bounding box to fit the rendered string,
|
||||
as they are in fact offsets from the point given to the renderer, to the top left
|
||||
corner of the bounding box.
|
||||
|
||||
NB: baseline is defined as y==0 for horizontal and x==0 for vertical scripts.
|
||||
(0,0) here is where the first glyph's origin ended up after shaping, not taking
|
||||
into account glyph_pos[0].xy_offset (yeah, my head hurts too).
|
||||
*/
|
||||
|
||||
int baseline_offset;
|
||||
int baseline_shift;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
baseline_offset = max_y;
|
||||
baseline_shift = min_x;
|
||||
}
|
||||
if (HB_DIRECTION_IS_VERTICAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
baseline_offset = min_x;
|
||||
baseline_shift = max_y;
|
||||
}
|
||||
|
||||
/* The pen/baseline start coordinates in window coordinate system
|
||||
- with those text placement in the window is controlled.
|
||||
- note that for RTL scripts pen still goes LTR */
|
||||
int x = 0, y = 50 + i * 75;
|
||||
if (i == ENGLISH)
|
||||
{
|
||||
x = 20;
|
||||
} /* left justify */
|
||||
if (i == ARABIC)
|
||||
{
|
||||
x = width - bbox_w - 20;
|
||||
} /* right justify */
|
||||
if (i == CHINESE)
|
||||
{
|
||||
x = width / 2 - bbox_w / 2;
|
||||
} /* center, and for TTB script h_advance is half-width. */
|
||||
|
||||
/* Draw baseline and the bounding box */
|
||||
/* The below is complicated since we simultaneously
|
||||
convert to the window coordinate system. */
|
||||
int left, right, top, bottom;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
/* bounding box in window coordinates without offsets */
|
||||
left = x;
|
||||
right = x + bbox_w;
|
||||
top = y - bbox_h;
|
||||
bottom = y;
|
||||
|
||||
/* apply offsets */
|
||||
left += baseline_shift;
|
||||
right += baseline_shift;
|
||||
top -= baseline_offset - bbox_h;
|
||||
bottom -= baseline_offset - bbox_h;
|
||||
|
||||
/* draw the baseline */
|
||||
hline(&oDrawer, x, x + bbox_w, y, 0x0000ff00);
|
||||
}
|
||||
|
||||
if (HB_DIRECTION_IS_VERTICAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
left = x;
|
||||
right = x + bbox_w;
|
||||
top = y;
|
||||
bottom = y + bbox_h;
|
||||
|
||||
left += baseline_offset;
|
||||
right += baseline_offset;
|
||||
top -= baseline_shift;
|
||||
bottom -= baseline_shift;
|
||||
|
||||
vline(&oDrawer, y, y + bbox_h, x, 0x0000ff00);
|
||||
}
|
||||
|
||||
/* +1/-1 are for the bbox borders be the next pixel outside the bbox itself */
|
||||
hline(&oDrawer, left - 1, right + 1, top - 1, 0xffff0000);
|
||||
hline(&oDrawer, left - 1, right + 1, bottom + 1, 0xffff0000);
|
||||
vline(&oDrawer, top - 1, bottom + 1, left - 1, 0xffff0000);
|
||||
vline(&oDrawer, top - 1, bottom + 1, right + 1, 0xffff0000);
|
||||
|
||||
/* set rendering spanner */
|
||||
ftr_params.gray_spans = spanner;
|
||||
|
||||
/* initialize rendering part of the baton */
|
||||
stuffbaton.pixels = NULL;
|
||||
stuffbaton.first_pixel = (uint32_t *)oDrawer.pixels;
|
||||
stuffbaton.last_pixel = (uint32_t *)(((uint8_t *)oDrawer.pixels) + oDrawer.pitch * oDrawer.height);
|
||||
stuffbaton.pitch = oDrawer.pitch;
|
||||
stuffbaton.rshift = oDrawer.Rshift;
|
||||
stuffbaton.gshift = oDrawer.Gshift;
|
||||
stuffbaton.bshift = oDrawer.Bshift;
|
||||
|
||||
/* render */
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
if ((fterr = FT_Load_Glyph(ft_face[i], glyph_info[j].codepoint, 0)))
|
||||
{
|
||||
printf("load %08x failed fterr=%d.\n", glyph_info[j].codepoint, fterr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ft_face[i]->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
printf("glyph->format = %4s\n", (char *)&ft_face[i]->glyph->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
int gx = x + (glyph_pos[j].x_offset / 64);
|
||||
int gy = y - (glyph_pos[j].y_offset / 64);
|
||||
|
||||
stuffbaton.pixels = (uint32_t *)(((uint8_t *)oDrawer.pixels) + gy * oDrawer.pitch) + gx;
|
||||
|
||||
if ((fterr = FT_Outline_Render(ft_library, &ft_face[i]->glyph->outline, &ftr_params)))
|
||||
printf("FT_Outline_Render() failed err=%d\n", fterr);
|
||||
}
|
||||
}
|
||||
|
||||
x += glyph_pos[j].x_advance / 64;
|
||||
y -= glyph_pos[j].y_advance / 64;
|
||||
}
|
||||
|
||||
/* clean up the buffer, but don't kill it just yet */
|
||||
hb_buffer_clear_contents(buf);
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
hb_buffer_destroy(buf);
|
||||
for (int i = 0; i < NUM_EXAMPLES; ++i)
|
||||
hb_font_destroy(hb_ft_font[i]);
|
||||
|
||||
FT_Done_FreeType(ft_library);
|
||||
|
||||
oDrawer.Save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
CONFIG -= qt
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/graphics/pro/freetype.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/harfbuzz/harfbuzz.pri)
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, graphics)
|
||||
DESTDIR = $$PWD/build
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#define DEFAULT_FONT_SIZE 12
|
||||
#define DEFAULT_FONT_SIZE 14
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
@ -49,8 +49,6 @@ namespace NSCSS
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -71,8 +69,6 @@ namespace NSCSS
|
||||
m_oDisplay = oElement.m_oDisplay;
|
||||
m_oTransform = oElement.m_oTransform;
|
||||
|
||||
m_arParentsStyles = oElement.m_arParentsStyles;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -113,8 +109,7 @@ namespace NSCSS
|
||||
bool CCompiledStyle::Empty() const
|
||||
{
|
||||
return m_oBackground.Empty() && m_oBorder.Empty() && m_oFont.Empty() &&
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() &&
|
||||
m_oDisplay.Empty() && m_oTransform.Empty();
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() && m_oDisplay.Empty();
|
||||
}
|
||||
|
||||
void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode)
|
||||
@ -319,7 +314,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER TOP
|
||||
CASE(L"border-top"):
|
||||
CASE(L"mso-border-top-alt"):
|
||||
{
|
||||
m_oBorder.SetTopSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -341,7 +335,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER RIGHT
|
||||
CASE(L"border-right"):
|
||||
CASE(L"mso-border-right-alt"):
|
||||
{
|
||||
m_oBorder.SetRightSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -363,7 +356,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER bottom
|
||||
CASE(L"border-bottom"):
|
||||
CASE(L"mso-border-bottom-alt"):
|
||||
{
|
||||
m_oBorder.SetBottomSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -385,7 +377,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER LEFT
|
||||
CASE(L"border-left"):
|
||||
CASE(L"mso-border-left-alt"):
|
||||
{
|
||||
m_oBorder.SetLeftSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -444,11 +435,6 @@ namespace NSCSS
|
||||
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
CASE(L"white-space"):
|
||||
{
|
||||
m_oDisplay.SetWhiteSpace(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
//TRANSFORM
|
||||
CASE(L"transform"):
|
||||
{
|
||||
@ -535,7 +521,7 @@ namespace NSCSS
|
||||
{
|
||||
return m_sId;
|
||||
}
|
||||
|
||||
|
||||
bool CCompiledStyle::HaveThisParent(const std::wstring &wsParentName) const
|
||||
{
|
||||
return m_arParentsStyles.end() != m_arParentsStyles.find(wsParentName);
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#ifndef CCOMPILEDSTYLE_H
|
||||
#define CCOMPILEDSTYLE_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@ -13,9 +13,14 @@ namespace NSCSS
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
bool CCssCalculator::CalculateCompiledStyle(std::vector<CNode>& arSelectors) const
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->CalculateCompiledStyle(arSelectors);
|
||||
return m_pInternal->GetCompiledStyle(arSelectors);
|
||||
}
|
||||
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
@ -58,11 +63,6 @@ namespace NSCSS
|
||||
return m_pInternal->GetDpi();
|
||||
}
|
||||
|
||||
bool CCssCalculator::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return m_pInternal->HaveStylesById(wsId);
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearPageData()
|
||||
{
|
||||
m_pInternal->ClearPageData();
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
#define CCSSCALCULATOR_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "StyleProperties.h"
|
||||
#include "CNode.h"
|
||||
#include "CCompiledStyle.h"
|
||||
#include "ConstValues.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace NSCSS
|
||||
@ -17,7 +19,8 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors) const;
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors) const;
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors) const;
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
@ -32,8 +35,6 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearPageData();
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
@ -184,7 +186,7 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector) const
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector)
|
||||
{
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
@ -470,7 +472,7 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
std::map<std::wstring, CElement*>::const_iterator itFound = mStyleData.find(wsSelector);
|
||||
|
||||
@ -486,95 +488,6 @@ namespace NSCSS
|
||||
{}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
bool CCssCalculator_Private::CalculateCompiledStyle(std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
if (L"#text" == arSelectors.back().m_wsName)
|
||||
{
|
||||
if (arSelectors.size() > 1 && arSelectors.back().m_pCompiledStyle->Empty())
|
||||
*arSelectors.back().m_pCompiledStyle += *(arSelectors.end() - 2)->m_pCompiledStyle;
|
||||
|
||||
if(arSelectors.crend() != std::find_if(arSelectors.crbegin(), arSelectors.crend(),
|
||||
[](const CNode& oNode){ return IsTableElement(oNode.m_wsName); }))
|
||||
{
|
||||
arSelectors.back().m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors.back().m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
arSelectors.back().SetCompiledStyle(new CCompiledStyle(oItem->second));
|
||||
return true;
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetDpi(m_nDpi);
|
||||
unsigned int unStart = 0;
|
||||
|
||||
std::vector<CNode>::const_reverse_iterator itFound = std::find_if(arSelectors.crbegin(), arSelectors.crend(), [](const CNode& oNode){ return !oNode.m_pCompiledStyle->Empty(); });
|
||||
|
||||
if (itFound != arSelectors.crend())
|
||||
unStart = itFound.base() - arSelectors.cbegin();
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < unStart; ++i)
|
||||
{
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = unStart; i < arSelectors.size(); ++i)
|
||||
{
|
||||
if (0 != i)
|
||||
*arSelectors[i].m_pCompiledStyle += *arSelectors[i - 1].m_pCompiledStyle;
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oFont.GetLineHeight().Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oPadding.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!arSelectors.back().m_pCompiledStyle->Empty())
|
||||
m_mUsedStyles[arSelectors] = *arSelectors.back().m_pCompiledStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
//TODO:: пересмотреть данный метод
|
||||
@ -592,11 +505,11 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart)
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend() - unStart; ++oNode)
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
@ -707,16 +620,6 @@ namespace NSCSS
|
||||
FindPrevAndKindElements(pFoundName, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
const CElement* pFoundAll = m_oStyleStorage.FindElement(L"*");
|
||||
|
||||
if (nullptr != pFoundAll)
|
||||
{
|
||||
if (!pFoundAll->Empty())
|
||||
arFindedElements.push_back(pFoundAll);
|
||||
|
||||
FindPrevAndKindElements(pFoundAll, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
@ -728,6 +631,79 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
GetCompiledStyle(oStyle, arSelectors);
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
{
|
||||
oStyle.AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
oStyle.m_oBackground.Clear();
|
||||
oStyle.m_oBorder.Clear();
|
||||
}
|
||||
|
||||
CCompiledStyle oTempStyle;
|
||||
|
||||
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
oStyle += oTempStyle;
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
oStyle.m_oFont.GetLineHeight().Clear();
|
||||
oStyle.m_oPadding.Clear();
|
||||
oStyle.m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator_Private::CalculateStyleId(const CNode& oNode)
|
||||
{
|
||||
return oNode.m_wsName + ((!oNode.m_wsClass.empty()) ? L'.' + oNode.m_wsClass : L"") + ((oNode.m_wsId.empty()) ? L"" : L'#' + oNode.m_wsId) + L'-' + std::to_wstring(++m_nCountNodes);
|
||||
@ -790,11 +766,6 @@ namespace NSCSS
|
||||
return m_nDpi;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return nullptr != m_oStyleStorage.FindElement(L'#' + wsId);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearEmbeddedStyles()
|
||||
{
|
||||
m_oStyleStorage.ClearEmbeddedStyles();
|
||||
@ -939,11 +910,4 @@ inline static std::wstring StringifyValue(const KatanaValue* oValue)
|
||||
return str;
|
||||
}
|
||||
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector) const;
|
||||
const CElement* FindElement(const std::wstring& wsSelector);
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace NSCSS
|
||||
|
||||
void GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const;
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData);
|
||||
};
|
||||
|
||||
class CCssCalculator_Private
|
||||
@ -102,7 +102,8 @@ namespace NSCSS
|
||||
~CCssCalculator_Private();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors);
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors);
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors);
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
@ -110,7 +111,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0);
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
|
||||
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
@ -122,8 +123,6 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
|
||||
@ -1,58 +1,19 @@
|
||||
#include "CNode.h"
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
#include "CCompiledStyle.h"
|
||||
#endif
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CNode::CNode()
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
: m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::CNode(const CNode& oNode)
|
||||
: m_wsName(oNode.m_wsName), m_wsClass(oNode.m_wsClass), m_wsId(oNode.m_wsId),
|
||||
m_wsStyle(oNode.m_wsStyle), m_mAttributes(oNode.m_mAttributes)
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *oNode.m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
|
||||
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
, m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::~CNode()
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CNode::Empty() const
|
||||
{
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CNode::SetCompiledStyle(CCompiledStyle* pCompiledStyle)
|
||||
{
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *pCompiledStyle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CNode::Clear()
|
||||
{
|
||||
m_wsName .clear();
|
||||
|
||||
@ -7,9 +7,6 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
class CCompiledStyle;
|
||||
#endif
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
@ -19,21 +16,12 @@ namespace NSCSS
|
||||
std::wstring m_wsStyle; // Стиль тэга
|
||||
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle *m_pCompiledStyle;
|
||||
#endif
|
||||
public:
|
||||
CNode();
|
||||
CNode(const CNode& oNode);
|
||||
CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId);
|
||||
~CNode();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
void Clear();
|
||||
|
||||
std::vector<std::wstring> GetData() const;
|
||||
|
||||
@ -1328,14 +1328,8 @@ namespace NSCSS
|
||||
|
||||
// DISPLAY
|
||||
CDisplay::CDisplay()
|
||||
{
|
||||
m_eWhiteSpace.SetMapping({{L"normal", EWhiteSpace::Normal },
|
||||
{L"nowrap", EWhiteSpace::Nowrap },
|
||||
{L"pre", EWhiteSpace::Pre },
|
||||
{L"pre-line", EWhiteSpace::Pre_Line},
|
||||
{L"pre-wrap", EWhiteSpace::Pre_Wrap}},
|
||||
EWhiteSpace::Normal);
|
||||
}
|
||||
: m_oDisplay(L"inline", 0)
|
||||
{}
|
||||
|
||||
void CDisplay::Equation(CDisplay &oFirstDisplay, CDisplay &oSecondDisplay)
|
||||
{
|
||||
@ -1348,8 +1342,6 @@ namespace NSCSS
|
||||
CString::Equation(oFirstDisplay.m_oHAlign, oSecondDisplay.m_oHAlign);
|
||||
|
||||
CString::Equation(oFirstDisplay.m_oDisplay, oSecondDisplay.m_oDisplay);
|
||||
|
||||
CEnum::Equation(oFirstDisplay.m_eWhiteSpace, oSecondDisplay.m_eWhiteSpace);
|
||||
}
|
||||
|
||||
bool CDisplay::SetX(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -1413,11 +1405,6 @@ namespace NSCSS
|
||||
return m_oDisplay.SetValue(wsValue, NSConstValues::DISPLAY_VALUES, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CDisplay::SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_eWhiteSpace.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
const CDigit& CDisplay::GetX() const
|
||||
{
|
||||
return m_oX;
|
||||
@ -1453,42 +1440,34 @@ namespace NSCSS
|
||||
return m_oDisplay;
|
||||
}
|
||||
|
||||
const CEnum& CDisplay::GetWhiteSpace() const
|
||||
{
|
||||
return m_eWhiteSpace;
|
||||
}
|
||||
|
||||
bool CDisplay::Empty() const
|
||||
{
|
||||
return m_oX.Empty() && m_oY.Empty() && m_oWidth.Empty() && m_oHeight.Empty() &&
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty() &&
|
||||
(m_eWhiteSpace.Empty() || m_eWhiteSpace == EWhiteSpace::Normal);
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty();
|
||||
}
|
||||
|
||||
CDisplay &CDisplay::operator+=(const CDisplay &oDisplay)
|
||||
{
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
m_eWhiteSpace += oDisplay.m_eWhiteSpace;
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CDisplay::operator==(const CDisplay &oDisplay) const
|
||||
{
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay &&
|
||||
m_eWhiteSpace == oDisplay.m_eWhiteSpace.ToInt();
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay;
|
||||
}
|
||||
|
||||
// STROKE
|
||||
|
||||
@ -328,15 +328,6 @@ namespace NSCSS
|
||||
};
|
||||
|
||||
// PROPERTIES
|
||||
typedef enum
|
||||
{
|
||||
Normal,
|
||||
Nowrap,
|
||||
Pre,
|
||||
Pre_Line,
|
||||
Pre_Wrap
|
||||
} EWhiteSpace;
|
||||
|
||||
class CDisplay
|
||||
{
|
||||
public:
|
||||
@ -356,8 +347,6 @@ namespace NSCSS
|
||||
|
||||
bool SetDisplay(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetX() const;
|
||||
const CDigit& GetY() const;
|
||||
const CDigit& GetWidth() const;
|
||||
@ -368,8 +357,6 @@ namespace NSCSS
|
||||
|
||||
const CString& GetDisplay() const;
|
||||
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
@ -384,8 +371,6 @@ namespace NSCSS
|
||||
CString m_oVAlign;
|
||||
|
||||
CString m_oDisplay;
|
||||
|
||||
CEnum m_eWhiteSpace;
|
||||
};
|
||||
|
||||
class CStroke
|
||||
|
||||
@ -22,10 +22,10 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
|
||||
|
||||
std::vector<std::wstring> arCommonElements1;
|
||||
std::vector<std::wstring> arCommonElements2;
|
||||
|
||||
@ -470,6 +470,9 @@ namespace NSCSS
|
||||
|
||||
int nSpace{0};
|
||||
|
||||
if (NULL != pPadding && !pPadding->Empty() && !pPadding->Zero())
|
||||
nSpace = pPadding->ToInt(NSCSS::Point);
|
||||
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
@ -556,7 +559,7 @@ namespace NSCSS
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
|
||||
m_sStyle += oXmlElement.GetPStyle(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -25,5 +25,3 @@ if not base.is_dir("katana-parser"):
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool2 katana_is_html_space(char c);", "static inline bool katana_is_html_space(char c);")
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "katanaget_text(parser->scanner)", "/*katanaget_text(parser->scanner)*/\"error\"")
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "#define KATANA_PARSER_STRING(literal) (KatanaParserString){", "#define KATANA_PARSER_STRING(literal) {")
|
||||
# katana may not be able to handle an empty string correctly in some cases (bug#73485)
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/foundation.c", "size_t len = strlen(str);", "if (NULL == str)\n return;\n size_t len = strlen(str);")
|
||||
|
||||
@ -19,6 +19,7 @@ static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|df
|
||||
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
|
||||
static std::string preserve_whitespace = "|pre|textarea|script|style|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string no_entity_sub = ""; //"|style|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
@ -68,10 +69,10 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
@ -210,7 +211,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
@ -226,18 +227,18 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// std::string sName = NSStringFinder::FindPropety(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -251,7 +252,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -265,7 +266,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
sCharset = NSStringFinder::FindPropety(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ static std::string mhtTohtml(const std::string& sFileContent)
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
@ -435,25 +436,9 @@ static void substitute_xml_entities_into_text(std::string& text)
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
@ -489,7 +474,6 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
@ -502,7 +486,7 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
static void build_attributes(const GumboVector* attribs, bool no_entities, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
@ -510,10 +494,6 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
@ -552,7 +532,8 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
if(!no_entities)
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
@ -561,6 +542,7 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
@ -574,8 +556,8 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
if(!no_entity_substitution)
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
@ -614,7 +596,6 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
@ -632,6 +613,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
@ -644,7 +626,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
build_attributes(attribs, no_entity_substitution, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
curDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||
dictionatiesDirectory = curDirectory + "/../../../../../dictionaries"
|
||||
|
||||
all_dictionaties = {}
|
||||
for dir in glob.glob(dictionatiesDirectory + "/*"):
|
||||
if not os.path.isdir(dir):
|
||||
continue
|
||||
dictionaryName = os.path.basename(dir)
|
||||
configFile = dictionatiesDirectory + "/" + dictionaryName + "/" + dictionaryName + ".json"
|
||||
if not os.path.isfile(configFile):
|
||||
continue
|
||||
isHyphen = False
|
||||
hyphenFile = dictionatiesDirectory + "/" + dictionaryName + "/hyph_" + dictionaryName + ".dic"
|
||||
if os.path.isfile(hyphenFile):
|
||||
isHyphen = True
|
||||
with open(configFile, 'r', encoding='utf-8') as file:
|
||||
data = json.loads(file.read())
|
||||
for lang in data["codes"]:
|
||||
all_dictionaties[str(lang)] = {
|
||||
"name": dictionaryName,
|
||||
"hyphen": isHyphen
|
||||
}
|
||||
|
||||
content = ""
|
||||
content += "#define DictionaryRec_count " + str(len(all_dictionaties)) + "\n"
|
||||
content += "typedef struct {\n"
|
||||
content += " const char* m_name;\n"
|
||||
content += " int m_lang;\n"
|
||||
content += "} DictionaryRec;\n\n"
|
||||
content += "static const DictionaryRec Dictionaries[DictionaryRec_count] = {\n"
|
||||
|
||||
for lang in all_dictionaties:
|
||||
info = all_dictionaties[lang]
|
||||
content += " { \"" + info["name"] + "\", " + str(lang) + " },\n"
|
||||
content += "};\n"
|
||||
|
||||
with open("./records.h", 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
@ -1,73 +0,0 @@
|
||||
#define DictionaryRec_count 65
|
||||
typedef struct {
|
||||
const char* m_name;
|
||||
int m_lang;
|
||||
} DictionaryRec;
|
||||
|
||||
static const DictionaryRec Dictionaries[DictionaryRec_count] = {
|
||||
{ "ar", 1025 },
|
||||
{ "ar", 2049 },
|
||||
{ "ar", 3073 },
|
||||
{ "ar", 4097 },
|
||||
{ "ar", 5121 },
|
||||
{ "ar", 6145 },
|
||||
{ "ar", 7169 },
|
||||
{ "ar", 8193 },
|
||||
{ "ar", 9217 },
|
||||
{ "ar", 10241 },
|
||||
{ "ar", 11265 },
|
||||
{ "ar", 12289 },
|
||||
{ "ar", 13313 },
|
||||
{ "ar", 14337 },
|
||||
{ "ar", 15361 },
|
||||
{ "ar", 16385 },
|
||||
{ "az_Latn_AZ", 1068 },
|
||||
{ "bg_BG", 1026 },
|
||||
{ "ca_ES", 1027 },
|
||||
{ "ca_ES_valencia", 2051 },
|
||||
{ "cs_CZ", 1029 },
|
||||
{ "da_DK", 1030 },
|
||||
{ "de_AT", 3079 },
|
||||
{ "de_CH", 2055 },
|
||||
{ "de_DE", 1031 },
|
||||
{ "el_GR", 1032 },
|
||||
{ "en_AU", 3081 },
|
||||
{ "en_CA", 4105 },
|
||||
{ "en_GB", 2057 },
|
||||
{ "en_US", 1033 },
|
||||
{ "en_ZA", 7177 },
|
||||
{ "es_ES", 3082 },
|
||||
{ "eu_ES", 1069 },
|
||||
{ "fr_FR", 1036 },
|
||||
{ "gl_ES", 1110 },
|
||||
{ "hr_HR", 1050 },
|
||||
{ "hu_HU", 1038 },
|
||||
{ "id_ID", 1057 },
|
||||
{ "it_IT", 1040 },
|
||||
{ "kk_KZ", 1087 },
|
||||
{ "ko_KR", 1042 },
|
||||
{ "lb_LU", 1134 },
|
||||
{ "lt_LT", 1063 },
|
||||
{ "lv_LV", 1062 },
|
||||
{ "mn_MN", 1104 },
|
||||
{ "nb_NO", 1044 },
|
||||
{ "nl_NL", 1043 },
|
||||
{ "nl_NL", 2067 },
|
||||
{ "nn_NO", 2068 },
|
||||
{ "oc_FR", 1154 },
|
||||
{ "pl_PL", 1045 },
|
||||
{ "pt_BR", 1046 },
|
||||
{ "pt_PT", 2070 },
|
||||
{ "ro_RO", 1048 },
|
||||
{ "ru_RU", 1049 },
|
||||
{ "sk_SK", 1051 },
|
||||
{ "sl_SI", 1060 },
|
||||
{ "sr_Cyrl_RS", 10266 },
|
||||
{ "sr_Latn_RS", 9242 },
|
||||
{ "sv_SE", 1053 },
|
||||
{ "tr_TR", 1055 },
|
||||
{ "uk_UA", 1058 },
|
||||
{ "uz_Cyrl_UZ", 2115 },
|
||||
{ "uz_Latn_UZ", 1091 },
|
||||
{ "vi_VN", 1066 },
|
||||
};
|
||||
4
Common/3dParty/md/.gitignore
vendored
4
Common/3dParty/md/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
md4c
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import config
|
||||
import base
|
||||
import os
|
||||
|
||||
base_directory = os.getcwd()
|
||||
|
||||
if not base.is_dir("md4c"):
|
||||
base.cmd("git", ["clone", "https://github.com/mity/md4c.git"])
|
||||
base.cmd_in_dir("md4c", "git", ["checkout", "481fbfbdf72daab2912380d62bb5f2187d438408"])
|
||||
@ -1,105 +0,0 @@
|
||||
#include "md2html.h"
|
||||
|
||||
#include "md4c/src/md4c-html.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace Md
|
||||
{
|
||||
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
(*(std::string*)pData).append(pValue, uSize);
|
||||
}
|
||||
|
||||
std::string ConvertMdStringToHtml(const std::string& sMdString)
|
||||
{
|
||||
std::string sData;
|
||||
md_html(sMdString.c_str(), sMdString.length(), ToHtml, &sData, 0, 0);
|
||||
return sData;
|
||||
}
|
||||
|
||||
void ToHtmlFile(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
((NSFile::CFileBinary*)pData)->WriteFile(pValue, uSize);
|
||||
}
|
||||
|
||||
void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
{
|
||||
oFile.WriteStringUTF8(L"<style>");
|
||||
|
||||
// Main styles
|
||||
oFile.WriteStringUTF8(L"* { font-family: Arial; color:black; white-space:pre; }");
|
||||
oFile.WriteStringUTF8(L"p { margin: 0 0 10px; display: block; }");
|
||||
oFile.WriteStringUTF8(L"a { color: #0553c1; text-decoration: underline; } a:visited { color: #954f72; text-decoration: underline; }");
|
||||
oFile.WriteStringUTF8(L"ul { margin-top: 0; margin-bottom: 10px; }");
|
||||
oFile.WriteStringUTF8(L"img { vertical-align: middle; }");
|
||||
|
||||
// Styles for tables
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group; vertical-align: middle; }");
|
||||
oFile.WriteStringUTF8(L"tr { display: table-row; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: left; display: table-cell; font-weight: bold; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"table thead tr th { vertical-align: bottom; border-bottom: 2px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table tbody tr th, table thead tr td, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table > caption + thead > tr > th, table > colgroup + thead > tr > th, table > thead > tr > th, table > caption + thead > tr > td, table > colgroup + thead > tr > td, table > thead > tr > td { border-top: 0; }");
|
||||
|
||||
// Styles for blockquote
|
||||
oFile.WriteStringUTF8(L"blockquote { border-left: 3px solid #e9e9e9; margin: 1.5em 0; padding: 0.5em 10px 0.5em 24px; font-size: 1.25rem; display: block; margin-top: 8pt; font-style: italic; color: #404040; }");
|
||||
|
||||
// Styles for code
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; border-radius: 0; background-color: #f5f5f5; color:black; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code, pre { font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; }");
|
||||
|
||||
// Styles for headings
|
||||
oFile.WriteStringUTF8(L"h1 { font-size: 20pt; color: #0f4761; margin-top: 18pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h2 { font-size: 16pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h3 { font-size: 14pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h4 { font-style: italic; color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h5 { color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h6 { font-style: italic; color: #595959; margin-top: 2pt; margin-bottom: 0; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"</style>");
|
||||
}
|
||||
|
||||
bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile)
|
||||
{
|
||||
std::string sMdData;
|
||||
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(wsPathToMdFile, sMdData))
|
||||
return false;
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.CreateFile(wsPathToHtmlFile))
|
||||
return false;
|
||||
|
||||
oFile.WriteStringUTF8(L"<html><body>");
|
||||
|
||||
oFile.WriteStringUTF8(L"<head>");
|
||||
//oFile.WriteStringUTF8(L"<meta charset=\"UTF-8\">");
|
||||
oFile.WriteStringUTF8(L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
|
||||
WriteBaseHtmlStyles(oFile);
|
||||
oFile.WriteStringUTF8(L"</head>");
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM,
|
||||
0))
|
||||
bResult = false;
|
||||
|
||||
oFile.WriteStringUTF8(L"</body></html>");
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
if (!bResult)
|
||||
NSFile::CFileBinary::Remove(wsPathToHtmlFile);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#ifndef MD2HTML_H
|
||||
#define MD2HTML_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef MDCONVERTER_DECL_EXPORT
|
||||
#define MDCONVERTER_DECL_EXPORT
|
||||
#else
|
||||
#include "../../../DesktopEditor/common/base_export.h"
|
||||
#define MDCONVERTER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace Md
|
||||
{
|
||||
std::string MDCONVERTER_DECL_EXPORT ConvertMdStringToHtml(const std::string& sMdString);
|
||||
bool MDCONVERTER_DECL_EXPORT ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile);
|
||||
}
|
||||
|
||||
#endif // MD2HTML_H
|
||||
@ -1,11 +0,0 @@
|
||||
DEFINES += MD4C_USE_UTF8
|
||||
|
||||
HEADERS += $$PWD/md4c/src/md4c.h \
|
||||
$$PWD/md4c/src/md4c-html.h \
|
||||
$$PWD/md4c/src/entity.h \
|
||||
$$PWD/md2html.h \
|
||||
|
||||
SOURCES += $$PWD/md4c/src/md4c.c \
|
||||
$$PWD/md4c/src/md4c-html.c \
|
||||
$$PWD/md4c/src/entity.c \
|
||||
$$PWD/md2html.cpp
|
||||
@ -1,16 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/md/md2html.pri)
|
||||
|
||||
DESTDIR = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
@ -1 +0,0 @@
|
||||
* foo **bar [link](http://example.com) baz**
|
||||
@ -1,10 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../md2html.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout << (ConvertMdFileToHtml(L"YOUR_PATH", L"YOUR_PATH") ? "Good" : "Bad") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -103,11 +103,9 @@ public:
|
||||
bool isBinaryDoctFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryXlstFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryPpttFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryVsdtFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
bool isDjvuFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isMobiFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isFB2FormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isXpsFile(const std::wstring& fileName);
|
||||
bool isOFDFile(const std::wstring& fileName);
|
||||
};
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
|
||||
#include "3dParty/pole/pole.h"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "OfficeFileFormatDefines.h"
|
||||
|
||||
@ -223,16 +222,6 @@ bool COfficeFileFormatChecker::isBinaryPpttFormatFile(unsigned char *pBuffer, in
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isBinaryVsdtFormatFile(unsigned char* pBuffer, int dwBytes)
|
||||
{
|
||||
if (pBuffer == NULL)
|
||||
return false;
|
||||
|
||||
if ((4 <= dwBytes) && ('V' == pBuffer[0] && 'S' == pBuffer[1] && 'D' == pBuffer[2] && 'Y' == pBuffer[3]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwBytes, std::wstring &documentID)
|
||||
{
|
||||
if (pBuffer == NULL)
|
||||
@ -797,13 +786,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOFDFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
@ -834,10 +816,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
|
||||
}
|
||||
else if (isBinaryVsdtFormatFile(bufferDetect, sizeRead)) // min size - 4
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_DRAW;
|
||||
}
|
||||
else if (isOOXFlatFormatFile(bufferDetect, sizeRead))
|
||||
{
|
||||
// nFileType;
|
||||
@ -937,8 +915,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
}
|
||||
else if (0 == sExt.compare(L".mht") || 0 == sExt.compare(L".mhtml"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
else if (0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
|
||||
@ -947,7 +923,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PDF;
|
||||
else if (0 == sExt.compare(L".doct")) // случай архива с html viewer
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx"))
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
@ -1174,10 +1150,6 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY;
|
||||
}
|
||||
else if (isBinaryVsdtFormatFile(pBuffer, nBufferSize))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY;
|
||||
}
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
@ -1187,222 +1159,58 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct TIWAField
|
||||
{
|
||||
size_t m_unStart;
|
||||
size_t m_unEnd;
|
||||
unsigned m_uIndex;
|
||||
unsigned m_unWireType;
|
||||
uint64_t m_oValue;
|
||||
};
|
||||
|
||||
bool ReadUVar(BYTE* pBuffer, size_t unEndPos, size_t& unPos, uint64_t& unValue)
|
||||
{
|
||||
std::vector<unsigned char> arBytes;
|
||||
arBytes.reserve(8);
|
||||
|
||||
unValue = 0;
|
||||
|
||||
bool bNext = true;
|
||||
while (unPos < unEndPos && bNext)
|
||||
{
|
||||
const unsigned char c = pBuffer[unPos++];
|
||||
arBytes.push_back((unsigned char)(c & ~0x80));
|
||||
bNext = c & 0x80;
|
||||
}
|
||||
|
||||
if (bNext && unPos == unEndPos)
|
||||
return false;
|
||||
|
||||
for (std::vector<unsigned char>::const_reverse_iterator it = arBytes.rbegin(); it != arBytes.rend(); ++it)
|
||||
{
|
||||
if (std::numeric_limits<uint64_t>::max() >> 7 < unValue ||
|
||||
std::numeric_limits<uint64_t>::max() - (unValue << 7) < *it) // overflow
|
||||
return false;
|
||||
|
||||
unValue = (unValue << 7) + *it;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadIWAField(BYTE* pBuffer, size_t unEndPos, size_t& unPos, TIWAField& oIWAField)
|
||||
{
|
||||
if (NULL == pBuffer || unPos + 2 > unEndPos)
|
||||
return false;
|
||||
|
||||
unsigned uSpec;
|
||||
|
||||
uSpec = (unsigned)pBuffer[unPos++];
|
||||
oIWAField.m_unWireType = uSpec & 0x7;
|
||||
|
||||
oIWAField.m_unStart = unPos;
|
||||
|
||||
switch (oIWAField.m_unWireType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (!ReadUVar(pBuffer, unEndPos, unPos, oIWAField.m_oValue))
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
unPos += 4;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
uint64_t unLen;
|
||||
if (!ReadUVar(pBuffer, unEndPos, unPos, unLen) || unPos + unLen > unEndPos)
|
||||
return false;
|
||||
|
||||
oIWAField.m_unStart = unPos;
|
||||
unPos += unLen;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
unPos += 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
oIWAField.m_unEnd = unPos;
|
||||
oIWAField.m_uIndex = uSpec >> 3;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DetectIWorkFormat(const std::wstring& fileName, int &nType)
|
||||
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG unSize = 0;
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, unSize);
|
||||
|
||||
if (hresult != S_OK || NULL == pBuffer)
|
||||
return false;
|
||||
|
||||
#define CLEAR_BUFFER_AND_RETURN(return_value)\
|
||||
do{\
|
||||
delete[] pBuffer;\
|
||||
return return_value;\
|
||||
}while(false)
|
||||
|
||||
if (unSize < 13)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
size_t uPos = 6;
|
||||
|
||||
for (; uPos < 12; ++uPos)
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if (0x08 == pBuffer[uPos] && 0x01 == pBuffer[uPos + 1])
|
||||
{
|
||||
--uPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (12 == uPos)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
uint64_t unHeaderLen;
|
||||
if (!ReadUVar(pBuffer, unSize, uPos, unHeaderLen))
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
const size_t uStartPos = uPos;
|
||||
|
||||
if (unHeaderLen < 8 || unSize < unHeaderLen + uStartPos)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
uPos += 2;
|
||||
|
||||
TIWAField oMessageField;
|
||||
|
||||
if (!ReadIWAField(pBuffer, uStartPos + unHeaderLen, uPos, oMessageField) || 2 != oMessageField.m_unWireType ||
|
||||
2 != oMessageField.m_uIndex)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
size_t uSubPos = oMessageField.m_unStart;
|
||||
TIWAField oField;
|
||||
|
||||
if (!ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oField) || 0 != oField.m_unWireType ||
|
||||
1 != oField.m_uIndex)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
switch (oField.m_oValue)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
uint32_t unDataLen = 0;
|
||||
|
||||
TIWAField oTempField;
|
||||
if (ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) &&
|
||||
ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) && 0 == oTempField.m_unWireType &&
|
||||
3 == oTempField.m_uIndex)
|
||||
unDataLen += oTempField.m_oValue;
|
||||
|
||||
size_t unTempPos = uStartPos + unHeaderLen;
|
||||
|
||||
// keynote: presentation ref in 2
|
||||
// number: sheet ref in 1
|
||||
if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
|
||||
(2 != oTempField.m_unWireType || 1 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
else if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
|
||||
(2 != oTempField.m_unWireType || 2 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 10000:
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
{
|
||||
if (DetectIWorkFormat(fileName, nFileType))
|
||||
return true;
|
||||
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
std::wstring sExt = L"unknown";
|
||||
|
||||
if (nExtPos != std::wstring::npos)
|
||||
sExt = fileName.substr(nExtPos);
|
||||
|
||||
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
|
||||
|
||||
if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Slide.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
return true;
|
||||
}
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Tables/DataList.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
return true;
|
||||
}
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
std::wstring sExt = L"unknown";
|
||||
|
||||
if (nExtPos != std::wstring::npos)
|
||||
sExt = fileName.substr(nExtPos);
|
||||
|
||||
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
|
||||
|
||||
if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
@ -1601,15 +1409,12 @@ bool COfficeFileFormatChecker::isOOXFlatFormatFile(unsigned char *pBuffer, int d
|
||||
const char *xlsxPackage = "progid=\"Excel.Sheet\"";
|
||||
const char *pptxPackage = "progid=\"PowerPoint.Show\"";
|
||||
const char *packageFormatLine = "xmlns:pkg=\"http://schemas.microsoft.com/office/2006/xmlPackage\"";
|
||||
const char* workbookFormatLine = "<Workbook";
|
||||
const char* htmlFormatLine = "<html";
|
||||
|
||||
if (std::string::npos != xml_string.find(docxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT;
|
||||
}
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine) && ( std::string::npos != xml_string.find(workbookFormatLine) ||
|
||||
std::string::npos == xml_string.find(htmlFormatLine)))
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT;
|
||||
}
|
||||
@ -1670,14 +1475,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodt";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT:
|
||||
return L".ott";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES:
|
||||
return L".pages";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP:
|
||||
return L".hwp";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX:
|
||||
return L".hwpx";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_MD:
|
||||
return L".md";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
|
||||
return L".pptx";
|
||||
@ -1699,10 +1496,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP:
|
||||
return L".otp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG:
|
||||
return L".odg";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY:
|
||||
return L".key";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
|
||||
return L".xlsx";
|
||||
@ -1724,8 +1517,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
|
||||
return L".ots";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS:
|
||||
return L".numbers";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF:
|
||||
@ -1736,8 +1527,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".djvu";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
|
||||
return L".xps";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD:
|
||||
return L".ofd";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG:
|
||||
return L".svg";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLR:
|
||||
@ -1779,15 +1568,12 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_WORD:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_DRAW:
|
||||
return L".bin";
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_DOCUMENT:
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY:
|
||||
return L".doct";
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY:
|
||||
return L".xlst";
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY:
|
||||
return L".vsdt";
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION:
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING:
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY:
|
||||
@ -1855,14 +1641,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT;
|
||||
if (L".ott" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT;
|
||||
if (L".pages" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
if (L".hwp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
if (L".hwpx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
if (L".md" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
|
||||
if (L".pptx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
@ -1884,10 +1662,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT;
|
||||
if (L".otp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP;
|
||||
if (L".odg" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG;
|
||||
if (L".key" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
if (L".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
@ -1915,8 +1689,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS;
|
||||
if (L".ods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
if (L".numbers" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
|
||||
if (L".ooxml" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_OTHER_OOXML;
|
||||
@ -1929,8 +1701,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
if (L".xps" == ext || L".oxps" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
if (L"ofd" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
if (L".jpg" == ext || L".jpeg" == ext || L".jpe" == ext || L".jfif" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
|
||||
@ -1965,8 +1735,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY;
|
||||
if (L".pptt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY;
|
||||
if (L".vsdt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY;
|
||||
|
||||
if (L".vsdx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DRAW_VSDX;
|
||||
@ -2069,26 +1837,3 @@ bool COfficeFileFormatChecker::isXpsFile(const std::wstring &fileName)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOFDFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE *pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"OFD.xml", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if (19 <= nBufferSize && NULL != strstr((char *)pBuffer, "ofd:OFD"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,8 +58,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0017
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001a
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0020
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
@ -104,7 +103,6 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRMenu AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0007
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x000a
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE 0x0400
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE_JPG AVS_OFFICESTUDIO_FILE_IMAGE + 0x0001
|
||||
@ -140,14 +138,12 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0002
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0004
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS 0x2000
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_WORD AVS_OFFICESTUDIO_FILE_CANVAS + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET AVS_OFFICESTUDIO_FILE_CANVAS + 0x0002
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION AVS_OFFICESTUDIO_FILE_CANVAS + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_PDF AVS_OFFICESTUDIO_FILE_CANVAS + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_DRAW AVS_OFFICESTUDIO_FILE_CANVAS + 0x0005
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW 0x4000
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDX AVS_OFFICESTUDIO_FILE_DRAW + 0x0001
|
||||
|
||||
@ -109,31 +109,6 @@ win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
}
|
||||
linux-clang {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang")
|
||||
}
|
||||
linux-clang-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang")
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
CONFIG += core_linux
|
||||
linux-g++:contains(QMAKE_HOST.arch, x86_64): {
|
||||
@ -221,10 +196,6 @@ core_mac {
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-implicit-function-declaration
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
@ -445,12 +416,6 @@ message($$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX)
|
||||
# COMPILER
|
||||
CONFIG += c++11
|
||||
|
||||
#CONFIG += enable_cpp_17
|
||||
enable_cpp_17 {
|
||||
CONFIG += c++1z
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
!core_windows {
|
||||
QMAKE_CXXFLAGS += -Wno-register
|
||||
QMAKE_CFLAGS += -Wno-register
|
||||
@ -458,11 +423,7 @@ enable_cpp_17 {
|
||||
|
||||
core_linux {
|
||||
core_static_link_libstd {
|
||||
!core_linux_clang {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
} else {
|
||||
# TODO: add libc++abi?
|
||||
}
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
|
||||
@ -416,16 +416,6 @@ namespace agg
|
||||
{
|
||||
return self_type(rgba::from_wavelength(wl, gamma));
|
||||
}
|
||||
|
||||
bool operator==(const self_type& other)
|
||||
{
|
||||
return a == other.a && r == other.r && g == other.g && b == other.b;
|
||||
}
|
||||
|
||||
bool operator!=(const self_type& other)
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -207,9 +207,9 @@ namespace agg
|
||||
}
|
||||
|
||||
p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
|
||||
if (r != cr) p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (g != cg) p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (b != cb) p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix_subpix(value_type* p,
|
||||
@ -1465,29 +1465,7 @@ namespace agg
|
||||
}
|
||||
};
|
||||
|
||||
template<class ColorT, class Order> struct comp_op_rgba_draw_on_black
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
|
||||
if (0x00 != p[Order::R] || 0x00 != p[Order::G] || 0x00 != p[Order::B])
|
||||
return;
|
||||
|
||||
comp_op_rgba_src_over <ColorT,Order>::blend_pix(p, sr, sg, sb, sa, cover);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1537,9 +1515,6 @@ namespace agg
|
||||
comp_op_rgba_contrast <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert_rgb <ColorT,Order>::blend_pix,
|
||||
|
||||
//Custom function
|
||||
comp_op_rgba_draw_on_black<ColorT,Order>::blend_pix,
|
||||
0
|
||||
};
|
||||
|
||||
@ -1576,9 +1551,6 @@ namespace agg
|
||||
comp_op_invert, //----comp_op_invert
|
||||
comp_op_invert_rgb, //----comp_op_invert_rgb
|
||||
|
||||
//Custom modes
|
||||
comp_op_draw_on_black, //----comp_op_draw_on_black
|
||||
|
||||
end_of_comp_op_e
|
||||
};
|
||||
|
||||
|
||||
@ -1000,17 +1000,7 @@ namespace agg
|
||||
{
|
||||
if (i < RES && j < RES)
|
||||
{
|
||||
if (m_oGradientInfo.luminocity)
|
||||
{
|
||||
ColorT fillC;
|
||||
fillC.r = m_oGradientInfo.shading.fill_color.r * c.r / 255 + 255 - c.r;
|
||||
fillC.g = m_oGradientInfo.shading.fill_color.g * c.g / 255 + 255 - c.g;
|
||||
fillC.b = m_oGradientInfo.shading.fill_color.b * c.b / 255 + 255 - c.b;
|
||||
fillC.a = 255;
|
||||
precalc[i][j] = fillC;
|
||||
}
|
||||
else
|
||||
precalc[i][j] = c;
|
||||
precalc[i][j] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1629,10 +1629,6 @@ namespace NSFile
|
||||
{
|
||||
wsTemp = L"";
|
||||
}
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
if (wsTempDir)
|
||||
free(wsTempDir);
|
||||
#endif
|
||||
wsTemp += L"x";
|
||||
int nTime = (int)time(NULL);
|
||||
for (int nIndex = 0; nIndex < 1000; ++nIndex)
|
||||
|
||||
@ -46,7 +46,6 @@ namespace NSProcessEnv
|
||||
static const char* gc_proxy = "proxy";
|
||||
static const char* gc_proxyUser = "proxyUser";
|
||||
static const char* gc_proxyHeader = "proxyHeader";
|
||||
static const char* gc_oformAsPdf = "oformAsPdf";
|
||||
}
|
||||
|
||||
// serialize
|
||||
|
||||
@ -319,14 +319,7 @@ namespace NSStringUtils
|
||||
{
|
||||
WriteEncodeXmlString(sString.c_str(), (int)sString.length());
|
||||
}
|
||||
void CStringBuilder::WriteEncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(std::wstring(sString.begin(), sString.end()));
|
||||
}
|
||||
void CStringBuilder::WriteUtf8EncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.size()));
|
||||
}
|
||||
|
||||
void CStringBuilder::WriteEncodeXmlString(const wchar_t* pString, int nCount)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
|
||||
@ -110,9 +110,6 @@ namespace NSStringUtils
|
||||
void WriteEncodeXmlString(const std::wstring& sString);
|
||||
void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
void WriteEncodeXmlString(const std::string& sString);
|
||||
void WriteUtf8EncodeXmlString(const std::string& sString);
|
||||
|
||||
void WriteEncodeXmlStringHHHH(const std::wstring& sString);
|
||||
void WriteEncodeXmlStringHHHH(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
|
||||
@ -332,7 +332,6 @@
|
||||
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
||||
*/
|
||||
# include <float.h>
|
||||
# include <math.h>
|
||||
|
||||
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#define DOC_BUILDER_ADDON_PRIVATE
|
||||
|
||||
#include <string>
|
||||
#include "../docbuilder.h"
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
@ -47,11 +46,11 @@ namespace NSDoctRenderer
|
||||
m_sWorkDirectory = sWorkDir;
|
||||
}
|
||||
public:
|
||||
std::wstring GetX2tSaveAddon(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
|
||||
std::wstring GetX2tSaveAddon()
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
int GetX2tPreSaveError(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
|
||||
int GetX2tPreSaveError()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include "./../common_deploy.h"
|
||||
#include "../docbuilder.h"
|
||||
#include "../../common/File.h"
|
||||
#include "../../common/SystemUtils.h"
|
||||
|
||||
#ifdef LINUX
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
@ -79,15 +78,6 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckLicense(const std::wstring& sSrc, const std::wstring& sDst)
|
||||
{
|
||||
if (sDst.empty())
|
||||
return false;
|
||||
NSFile::CFileBinary::Remove(sDst);
|
||||
NSFile::CFileBinary::Copy(sSrc, sDst);
|
||||
return NSFile::CFileBinary::Exists(sDst);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
@ -99,7 +89,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool bIsHelp = false;
|
||||
bool bIsFonts = false;
|
||||
bool bIsLicense = false;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
@ -132,33 +121,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
bIsFonts = true;
|
||||
}
|
||||
else if (sParam == "-register")
|
||||
{
|
||||
bIsLicense = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIsLicense)
|
||||
{
|
||||
std::wstring sLicensePathSrc = UTF8_TO_U(sParam);
|
||||
if (!NSFile::CFileBinary::Exists(sLicensePathSrc))
|
||||
return 1;
|
||||
|
||||
std::wstring sLicensePath = NSSystemUtils::GetEnvVariable(L"ONLYOFFICE_BUILDER_LICENSE");
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
sLicensePath = NSFile::GetProcessDirectory() + L"/license.xml";
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
sLicensePath = NSSystemUtils::GetAppDataDir() + L"/docbuilder/license.xml";
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsFonts)
|
||||
|
||||
@ -57,7 +57,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return m_pInternal->ExecuteCommand(command, retValue, false, false);
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
}
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext(bool enterContext)
|
||||
|
||||
@ -475,13 +475,6 @@ namespace NSDoctRenderer
|
||||
*/
|
||||
void SetPropertyW(const wchar_t* param, const wchar_t* value);
|
||||
|
||||
/**
|
||||
* GetProperty method.
|
||||
* @param param The parameter name in the Unicode format, the value is always --argument.
|
||||
* @return int value for property
|
||||
*/
|
||||
int GetPropertyInt(const wchar_t* param);
|
||||
|
||||
/**
|
||||
* Writes data to the log file. It is used for logs in JS code.
|
||||
* @param path The path to the file where all the logs will be written.
|
||||
|
||||
@ -16,18 +16,18 @@ static std::wstring wstringFromJavaString(JNIEnv* env, jstring jstr)
|
||||
return wstr;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilder());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -35,34 +35,34 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jcla
|
||||
return (jint)pSelf->OpenFile(strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->CreateFile((int)type);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
return (jboolean)pSelf->CreateFile(strExtension.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
void Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strFolder = wstringFromJavaString(env, folder);
|
||||
pSelf->SetTmpFolder(strFolder.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -70,7 +70,7 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(J
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
@ -78,7 +78,7 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
@ -87,20 +87,20 @@ JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithPar
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
pSelf->CloseFile();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
@ -108,14 +108,14 @@ JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetV
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str(), pRetValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jboolean)pSelf->Run(strPath.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfCommands = env->GetStringUTFChars(commands, nullptr);
|
||||
@ -124,7 +124,7 @@ JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, j
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfParam = env->GetStringUTFChars(param, nullptr);
|
||||
@ -133,7 +133,7 @@ JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, j
|
||||
env->ReleaseStringUTFChars(param, strUtfParam);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -141,13 +141,13 @@ JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jcl
|
||||
pSelf->WriteData(strPath.c_str(), strData.c_str(), (bool)append);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->IsSaveWithDoctrendererMode();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
char* strUtfVersion = pSelf->GetVersion();
|
||||
@ -156,30 +156,30 @@ JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env,
|
||||
return jstrVersion;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext((bool)enterContext)));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
void Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
{
|
||||
std::wstring strDirectory = wstringFromJavaString(env, directory);
|
||||
CDocBuilder::Initialize(strDirectory.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
void Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Dispose();
|
||||
}
|
||||
|
||||
@ -4,60 +4,60 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContext* pOther = reinterpret_cast<CDocBuilderContext*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(*pOther));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateUndefined()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateNull()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateObject()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateArray((int)length)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->GetGlobal()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(pSelf->CreateScope()));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return (jboolean)pSelf->IsError();
|
||||
|
||||
@ -4,24 +4,24 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContextScope* pOther = reinterpret_cast<CDocBuilderContextScope*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(*pOther));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
pSelf->Close();
|
||||
|
||||
@ -8,114 +8,114 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderValue* pOther = reinterpret_cast<CDocBuilderValue*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(*pOther));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsEmpty();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
pSelf->Clear();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsNull();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsUndefined();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsBool();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsInt();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsDouble();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsString();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsFunction();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsObject();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsArray();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->GetLength();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->ToBool();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->ToInt();
|
||||
}
|
||||
|
||||
JNIEXPORT jdouble JNICALL Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
jdouble Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jdouble)pSelf->ToDouble();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CString strValue = pSelf->ToString();
|
||||
@ -123,7 +123,7 @@ JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* e
|
||||
return env->NewStringUTF(strUtfData.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
@ -132,14 +132,14 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv*
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get((int)index));
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
@ -149,29 +149,29 @@ JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* e
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
pSelf->Set((int)index, *pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((bool)value));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((int)value));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((double)value));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
{
|
||||
const char* strUtf = env->GetStringUTFChars(str, nullptr);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(strUtf);
|
||||
@ -179,22 +179,22 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNI
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateUndefined()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateNull()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateArray((int)length)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
@ -203,7 +203,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -213,7 +213,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -224,7 +224,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -236,7 +236,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -249,7 +249,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -263,7 +263,7 @@ JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, j
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call6(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5, jlong p6)
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call6(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5, jlong p6)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
|
||||
@ -2,7 +2,6 @@ import ctypes
|
||||
import os
|
||||
import platform
|
||||
import atexit
|
||||
import subprocess
|
||||
|
||||
OBJECT_HANDLE = ctypes.c_void_p
|
||||
STRING_HANDLE = ctypes.c_void_p
|
||||
@ -383,20 +382,6 @@ class CDocBuilderValue:
|
||||
def __setitem__(self, key, value):
|
||||
self.Set(key, value)
|
||||
|
||||
def __getattr__(self, name):
|
||||
def method(*args):
|
||||
return self.Call(name, *args)
|
||||
return method
|
||||
|
||||
def __len__(self):
|
||||
return self.GetLength()
|
||||
|
||||
def __iter__(self):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not iterable")
|
||||
for i in range(self.GetLength()):
|
||||
yield self.Get(i)
|
||||
|
||||
@staticmethod
|
||||
def CreateUndefined():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateUndefined()))
|
||||
@ -437,36 +422,6 @@ class CDocBuilderValue:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call6(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal, values[4]._internal, values[5]._internal)))
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
def append(self, value):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
self.Set(length, value)
|
||||
return self
|
||||
|
||||
def extend(self, iterable):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
for i, value in enumerate(iterable, start=length):
|
||||
self.Set(i, value)
|
||||
return self
|
||||
|
||||
def insert(self, i, x):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
if i < 0:
|
||||
if abs(i) > length:
|
||||
raise IndexError("list index out of range")
|
||||
i = max(0, length + i)
|
||||
if i >= length:
|
||||
raise IndexError("list index out of range")
|
||||
for idx in range(length, i, -1):
|
||||
self.Set(idx, self.Get(idx - 1))
|
||||
self.Set(i, x)
|
||||
|
||||
|
||||
class CDocBuilder:
|
||||
_initialized = False
|
||||
@ -479,7 +434,7 @@ class CDocBuilder:
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilder_Destroy(self._internal)
|
||||
|
||||
def OpenFile(self, path, params=""):
|
||||
def OpenFile(self, path, params):
|
||||
return _lib.CDocBuilder_OpenFile(self._internal, ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
|
||||
def CreateFile(self, type):
|
||||
@ -653,17 +608,8 @@ class FileTypes:
|
||||
PNG = _IMAGE_MASK + 0x0005
|
||||
BMP = _IMAGE_MASK + 0x0008
|
||||
|
||||
# NOTE: do not change builder_path manually!
|
||||
builder_path = os.path.dirname(os.path.realpath(__file__))
|
||||
_loadLibrary(builder_path)
|
||||
CDocBuilder.Initialize(builder_path)
|
||||
|
||||
def registerLibrary(license_path):
|
||||
docbuilder_bin = os.path.join(builder_path, "docbuilder")
|
||||
if ("windows" == platform.system().lower()):
|
||||
docbuilder_bin += ".exe"
|
||||
return subprocess.call([docbuilder_bin, "-register", license_path], stderr=subprocess.STDOUT, shell=True)
|
||||
command = docbuilder_bin + " -register \"" + license_path.replace('\"', '\\\"') + "\""
|
||||
return subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
|
||||
|
||||
atexit.register(CDocBuilder.Dispose)
|
||||
|
||||
@ -13,16 +13,16 @@ scope = context.CreateScope()
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.GetDocument()
|
||||
paragraph1 = api.CreateParagraph()
|
||||
paragraph1.SetSpacingAfter(1000, False)
|
||||
paragraph1.AddText('Hello from Python!')
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.CreateParagraph()
|
||||
paragraph2.AddText('Goodbye!')
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.InsertContent(content)
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('path_to_docbuilder')
|
||||
import docbuilder
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
scope = context.CreateScope()
|
||||
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
builder.CloseFile()
|
||||
@ -74,7 +74,6 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
global->set("native", oNativeCtrl);
|
||||
|
||||
CBuilderEmbed* pBuilderJSNative = static_cast<CBuilderEmbed*>(oBuilderJS->getNative());
|
||||
pBuilderJSNative->SetExternalize(true);
|
||||
pBuilderJSNative->m_pBuilder = pBuilder;
|
||||
}
|
||||
CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
@ -83,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContextSrc)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -93,10 +92,6 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
bool isEnterContext = isEnterContextSrc;
|
||||
if (!isEnterContext && !m_context->IsEntered())
|
||||
isEnterContext = true;
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
@ -1242,13 +1237,13 @@ namespace NSDoctRenderer
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (_currentPos < _commandsLen && !((_commandsPtr[_currentPos] == '\"' || _commandsPtr[_currentPos] == '\'') && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
while (_currentPos < _commandsLen && !(_commandsPtr[_currentPos] == '\"' && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
++_currentPos;
|
||||
|
||||
++_currentPos;
|
||||
size_t _start = _currentPos;
|
||||
|
||||
while (_currentPos < _commandsLen && !((_commandsPtr[_currentPos] == '\"' || _commandsPtr[_currentPos] == '\'') && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
while (_currentPos < _commandsLen && !(_commandsPtr[_currentPos] == '\"' && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
++_currentPos;
|
||||
|
||||
if (_currentPos > _start)
|
||||
@ -1601,15 +1596,6 @@ namespace NSDoctRenderer
|
||||
return this->SetProperty(sA.c_str(), value);
|
||||
}
|
||||
|
||||
int CDocBuilder::GetPropertyInt(const wchar_t* param)
|
||||
{
|
||||
std::wstring sParam = std::wstring(param);
|
||||
std::string sParamA = U_TO_UTF8(sParam);
|
||||
if ("--save-use-only-names" == sParamA)
|
||||
return m_pInternal->m_bIsServerSafeVersion ? 1 : 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CDocBuilder::Initialize(const wchar_t* directory)
|
||||
{
|
||||
std::wstring sDirectory = L"";
|
||||
|
||||
@ -1003,7 +1003,7 @@ namespace NSDoctRenderer
|
||||
|
||||
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
||||
|
||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError(m_pParent, m_nFileType);
|
||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
|
||||
if (0 != nPreSaveError)
|
||||
return nPreSaveError;
|
||||
|
||||
@ -1090,7 +1090,7 @@ namespace NSDoctRenderer
|
||||
if (!sOptions.empty())
|
||||
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
||||
|
||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon(m_pParent, m_nFileType));
|
||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
|
||||
|
||||
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
||||
|
||||
@ -1275,7 +1275,7 @@ namespace NSDoctRenderer
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false, const bool& isEnterContext = true)
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
return true;
|
||||
@ -1291,12 +1291,12 @@ namespace NSDoctRenderer
|
||||
if (CheckWorker())
|
||||
{
|
||||
bool bIsOpenedFromSimpleJSOld = m_bIsOpenedFromSimpleJS;
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue);
|
||||
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
return m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -171,6 +171,7 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
@ -283,34 +284,6 @@ public:
|
||||
return NULL;
|
||||
return m_pFile->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
BYTE* SplitPages(int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->SplitPages(arrPageIndex, nLength, data, size);
|
||||
return NULL;
|
||||
}
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm, bool bCopy = false)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
// Память из CDrawingFileEmbed освобождается сразу после вызова функции, поэтому копируем
|
||||
if (bCopy)
|
||||
{
|
||||
BYTE* pCopy = (BYTE*)malloc(size);
|
||||
memcpy(pCopy, data, size);
|
||||
data = pCopy;
|
||||
}
|
||||
// Захватывает полученную память, будет освобождена либо в деструкторе MemStream, либо free в случае неудачи
|
||||
return ((CPdfFile*)m_pFile)->MergePages(data, size, nMaxID, sPrefixForm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool UnmergePages()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
@ -430,32 +403,22 @@ public:
|
||||
oRenderer.SetExternalImageStorage(m_pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
std::vector<std::wstring> arShapes;
|
||||
if (0 == mode)
|
||||
arShapes = oRenderer.ScanPage(m_pFile, nPageIndex);
|
||||
else
|
||||
arShapes = oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
|
||||
int nLen = (int)arShapes.size();
|
||||
|
||||
NSWasm::CData oRes;
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
std::vector<std::wstring> arShapes = (0 == mode) ? oRenderer.ScanPage(m_pFile, nPageIndex) : oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
int nLen = (int)arShapes.size();
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
oRes.WriteLen();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
oRes = oRenderer.ScanPageBin(m_pFile, nPageIndex);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
|
||||
@ -166,48 +166,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::FreeWasmData(JSSmart<CJSValue> typedArray)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data)
|
||||
{
|
||||
JSSmart<CJSArray> arrPages = arrPageIndexes->toArray();
|
||||
CJSDataBuffer changes;
|
||||
if (data->isTypedArray())
|
||||
changes = data->toTypedArray()->getData();
|
||||
|
||||
int nCountPages = arrPages->getCount();
|
||||
int* pPages = NULL;
|
||||
if (0 < nCountPages)
|
||||
pPages = new int[nCountPages];
|
||||
|
||||
for (int i = 0; i < nCountPages; i++)
|
||||
pPages[i] = arrPages->get(i)->toInt32();
|
||||
|
||||
JSSmart<CJSValue> res = WasmMemoryToJS(m_pFile->SplitPages(pPages, nCountPages, changes.Data, (LONG)changes.Len));
|
||||
if (pPages)
|
||||
delete [] pPages;
|
||||
return res;
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm)
|
||||
{
|
||||
bool result = false;
|
||||
if (m_pFile)
|
||||
{
|
||||
JSSmart<CJSTypedArray> dataPtr = data->toTypedArray();
|
||||
int maxID = nMaxID->toInt32();
|
||||
std::string prefix = sPrefixForm->toStringA();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
result = m_pFile->MergePages(buffer.Data, (LONG)buffer.Len, maxID, prefix, true);
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
return CJSContext::createBool(result);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::UnmergePages()
|
||||
{
|
||||
if (m_pFile)
|
||||
return CJSContext::createBool(m_pFile->UnmergePages());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
CJSContext::Embed<CDrawingFileEmbed>(false);
|
||||
|
||||
@ -51,10 +51,6 @@ public:
|
||||
|
||||
JSSmart<CJSValue> FreeWasmData(JSSmart<CJSValue> typedArray);
|
||||
|
||||
JSSmart<CJSValue> SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data);
|
||||
JSSmart<CJSValue> MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm);
|
||||
JSSmart<CJSValue> UnmergePages();
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
|
||||
@ -165,14 +165,9 @@ JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSVa
|
||||
JSSmart<CJSObject> pNativeObject = Native->toObject();
|
||||
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
|
||||
|
||||
if (m_pInternal->m_pAppImage && pNativeEmbedObject)
|
||||
{
|
||||
if (m_pInternal->m_pAppImage)
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = NULL;
|
||||
}
|
||||
|
||||
if (NULL == m_pInternal->m_pAppImage)
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
|
||||
if (pNativeEmbedObject)
|
||||
{
|
||||
@ -196,9 +191,7 @@ JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSVa
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
{
|
||||
// For save image bits, if needed.
|
||||
m_pInternal->Destroy();
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::EndDraw()
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
|
||||
public:
|
||||
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder && !m_isExternalize) RELEASEOBJECT(m_pBuilder); }
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
|
||||
|
||||
@ -88,7 +88,6 @@ JSSmart<CJSValue> CBuilderEmbed::OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJS
|
||||
JSSmart<CJSObject> oBuilderTmpDoc = CJSContext::createEmbedObject("CBuilderDocumentEmbed");
|
||||
CBuilderDocumentEmbed* pBuilderTmpDocNative = static_cast<CBuilderDocumentEmbed*>(oBuilderTmpDoc->getNative());
|
||||
pBuilderTmpDocNative->m_pBuilder = m_pBuilder;
|
||||
pBuilderTmpDocNative->SetExternalize(true);
|
||||
pBuilderTmpDocNative->_OpenFile(sPath, sParams);
|
||||
return oBuilderTmpDoc->toValue();
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
|
||||
CBuilderEmbed() : m_pBuilder(NULL) {}
|
||||
~CBuilderEmbed() { if(m_pBuilder && !m_isExternalize) RELEASEOBJECT(m_pBuilder); }
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
|
||||
|
||||
@ -27,9 +27,6 @@
|
||||
-(JSValue*) ScanPage : (JSValue*)nPageIndex : (JSValue*)mode;
|
||||
-(JSValue*) GetImageBase64 : (JSValue*)rId;
|
||||
-(JSValue*) FreeWasmData : (JSValue*)typedArray;
|
||||
-(JSValue*) SplitPages : (JSValue*)arrPageIndexes : (JSValue*)data;
|
||||
-(JSValue*) MergePages : (JSValue*)data : (JSValue*)nMaxID : (JSValue*)sPrefixForm;
|
||||
-(JSValue*) UnmergePages;
|
||||
@end
|
||||
|
||||
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
|
||||
@ -64,9 +61,6 @@ FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_JS_2(ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_JS_1(GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_JS_1(FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_JS_2(SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_JS_3(MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_JS_0(UnmergePages, UnmergePages)
|
||||
@end
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
|
||||
@ -30,9 +30,6 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_2(_ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_V8_1(_GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_V8_1(_FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_V8_3(_MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -62,9 +59,6 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "ScanPage", _ScanPage);
|
||||
NSV8Objects::Template_Set(result, "GetImageBase64", _GetImageBase64);
|
||||
NSV8Objects::Template_Set(result, "FreeWasmData", _FreeWasmData);
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
NSV8Objects::Template_Set(result, "MergePages", _MergePages);
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ namespace NSGraphics
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->SetFontManager(pManager);
|
||||
RELEASEINTERFACE(pManager);
|
||||
|
||||
int nRasterW = (int)width_px;
|
||||
int nRasterH = (int)height_px;
|
||||
|
||||
@ -115,16 +115,17 @@ namespace NSGraphics
|
||||
class CGraphics
|
||||
{
|
||||
public:
|
||||
CGraphicsAppImage* m_pAppImage = nullptr;
|
||||
CGraphicsAppImage* m_pAppImage;
|
||||
CBgraFrame m_oFrame;
|
||||
|
||||
private:
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer = nullptr;
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
CGrState m_oGrState;
|
||||
|
||||
public:
|
||||
CGraphics()
|
||||
{
|
||||
m_pAppImage = NULL;
|
||||
}
|
||||
~CGraphics()
|
||||
{
|
||||
|
||||
@ -31,7 +31,6 @@ namespace NSJSBase {
|
||||
{
|
||||
embed_native_internal = nullptr;
|
||||
m_pAdapter = nullptr;
|
||||
m_isExternalize = false;
|
||||
}
|
||||
|
||||
CJSEmbedObject::~CJSEmbedObject()
|
||||
@ -45,16 +44,6 @@ namespace NSJSBase {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CJSEmbedObject::SetExternalize(const bool& isExternalize)
|
||||
{
|
||||
m_isExternalize = isExternalize;
|
||||
}
|
||||
|
||||
bool CJSEmbedObject::GetExternalize()
|
||||
{
|
||||
return m_isExternalize;
|
||||
}
|
||||
|
||||
CJSEmbedObjectAdapterBase* CJSEmbedObject::getAdapter()
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@ -194,18 +194,10 @@ namespace NSJSBase
|
||||
*/
|
||||
virtual CJSEmbedObjectAdapterBase* getAdapter();
|
||||
|
||||
/**
|
||||
* Use the externalize flag if you are monitoring the object's destruction yourself.
|
||||
*/
|
||||
virtual void SetExternalize(const bool& isExternalize = true);
|
||||
virtual bool GetExternalize();
|
||||
|
||||
protected:
|
||||
CJSEmbedObjectPrivateBase* embed_native_internal;
|
||||
CJSEmbedObjectAdapterBase* m_pAdapter;
|
||||
|
||||
bool m_isExternalize;
|
||||
|
||||
friend class CJSEmbedObjectPrivateBase;
|
||||
friend class CJSEmbedObjectPrivate;
|
||||
};
|
||||
@ -491,12 +483,6 @@ namespace NSJSBase
|
||||
*/
|
||||
void Exit();
|
||||
|
||||
/**
|
||||
* Сheck if context is current.
|
||||
* This method is not safe.
|
||||
*/
|
||||
bool IsEntered();
|
||||
|
||||
/**
|
||||
* Embeds specified class in JS contexts.
|
||||
* @tparam T Embedded class name.
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
@protocol JSEmbedObjectProtocol
|
||||
-(void*) getNative;
|
||||
-(void) freeNative;
|
||||
@end
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
@ -42,10 +41,6 @@
|
||||
-(void*) getNative \
|
||||
{ \
|
||||
return m_internal; \
|
||||
} \
|
||||
-(void) freeNative \
|
||||
{ \
|
||||
RELEASEOBJECT(m_internal); \
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -34,7 +34,6 @@ namespace NSJSBase
|
||||
|
||||
// embed
|
||||
id CreateEmbedNativeObject(NSString* name);
|
||||
void FreeNativeObject(id embedded_object);
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -232,14 +232,10 @@ namespace NSJSBase
|
||||
{
|
||||
[m_internal->context evaluateScript:@"function jsc_toBase64(r){for(var o=[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\",\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"+\",\"/\"],a=r.length,f=4*(a/3>>0),n=f/76>>0,t=19,v=0,e=[],i=\"\",s=0;s<=n;s++){s==n&&(t=f%76/4>>0);for(var u=0;u<t;u++){for(var c=0,h=0;h<3;h++)c|=r[0+v++],c<<=8;i=\"\";for(var A=0;A<4;A++){i+=o[c>>>26&255],c<<=6,c&=4294967295}e.push(i)}}if(n=a%3!=0?a%3+1:0){for(c=0,h=0;h<3;h++)h<a%3&&(c|=r[0+v++]),c<<=8;i=\"\";for(A=0;A<n;A++){i+=o[c>>>26&255],c<<=6}t=0!=n?4-n:0;for(u=0;u<t;u++)i+=\"=\";e.push(i)}return e.join(\"\")}function jsc_fromBase64(r,o){for(var a,f=r.length,n=0,t=new Array(void 0===o?f:o),v=t,e=0,i=0;e<f;){for(var s=0,u=0,c=0;c<4&&!(f<=e);c++){var h=65<=(a=r.charCodeAt(e++))&&a<=90?a-65:97<=a&&a<=122?a-71:48<=a&&a<=57?a+4:43==a?62:47==a?63:-1;-1!=h?(s<<=6,s|=h,u+=6):c--}for(s<<=24-u,i=u>>>3,c=0;c<i;c++)v[n++]=(16711680&s)>>>16,s<<=8}return t}\n"];
|
||||
}
|
||||
// insert embed functions to global object of this context
|
||||
// insert CreateEmbedObject() function to global object of this context
|
||||
m_internal->context[@"CreateEmbedObject"] = ^(NSString* name) {
|
||||
return CreateEmbedNativeObject(name);
|
||||
};
|
||||
m_internal->context[@"FreeEmbedObject"] = ^(id embedded_object) {
|
||||
FreeNativeObject(embedded_object);
|
||||
};
|
||||
|
||||
|
||||
JSValue* global_js = [m_internal->context globalObject];
|
||||
[global_js setValue:global_js forProperty:[[NSString alloc] initWithUTF8String:"window"]];
|
||||
@ -250,8 +246,6 @@ namespace NSJSBase
|
||||
{
|
||||
CGlobalContext::GetInstance().UnregisterContextForId(*i);
|
||||
}
|
||||
// remove any exceptions pending to not prevent any JSValue deallocations
|
||||
m_internal->context.exception = nil;
|
||||
m_internal->context = nil;
|
||||
}
|
||||
|
||||
@ -445,11 +439,6 @@ namespace NSJSBase
|
||||
{
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class CJSLocalScopePrivate
|
||||
{
|
||||
public:
|
||||
@ -509,15 +498,6 @@ namespace NSJSBase
|
||||
return pEmbedObj;
|
||||
}
|
||||
|
||||
void FreeNativeObject(id embedded_object)
|
||||
{
|
||||
// check if the object was actually embedded and do nothing if it wasn't
|
||||
if ([embedded_object conformsToProtocol:@protocol(JSEmbedObjectProtocol)])
|
||||
{
|
||||
[embedded_object freeNative];
|
||||
}
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CJSEmbedObjectAdapterJSC::Native2Value(JSValue* value)
|
||||
{
|
||||
return js_value(value);
|
||||
|
||||
@ -214,41 +214,12 @@ namespace NSJSBase
|
||||
m_internal->m_contextPersistent.Reset(isolate, v8::Context::New(isolate));
|
||||
// create temporary local handle to context
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
// insert embed functions to global object of this context
|
||||
// insert CreateEmbedObject() function to global object of this context
|
||||
m_internal->InsertToGlobal("CreateEmbedObject", CreateEmbedNativeObject);
|
||||
m_internal->InsertToGlobal("FreeEmbedObject", FreeNativeObject);
|
||||
// clear temporary local handle
|
||||
m_internal->m_context.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
class WeakHandleVisitor : public v8::PersistentHandleVisitor
|
||||
{
|
||||
private:
|
||||
WeakHandleVisitor() = default;
|
||||
|
||||
public:
|
||||
void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t class_id) override
|
||||
{
|
||||
if (class_id == CJSEmbedObjectPrivate::kWeakHandleId)
|
||||
{
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<v8::Object> handle = value->Get(isolate).As<v8::Object>();
|
||||
v8::Local<v8::External> field = v8::Local<v8::External>::Cast(handle->GetInternalField(0));
|
||||
CJSEmbedObject* native = static_cast<CJSEmbedObject*>(field->Value());
|
||||
delete native;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static WeakHandleVisitor* getInstance()
|
||||
{
|
||||
static WeakHandleVisitor visitor;
|
||||
return &visitor;
|
||||
}
|
||||
};
|
||||
|
||||
void CJSContext::Dispose()
|
||||
{
|
||||
#ifdef V8_INSPECTOR
|
||||
@ -257,13 +228,7 @@ namespace NSJSBase
|
||||
#endif
|
||||
|
||||
m_internal->m_contextPersistent.Reset();
|
||||
// destroy native object in the weak handles before isolate disposal
|
||||
v8::Isolate* isolate = m_internal->m_isolate;
|
||||
{
|
||||
v8::Isolate::Scope scope(isolate);
|
||||
isolate->VisitHandlesWithClassIds(WeakHandleVisitor::getInstance());
|
||||
}
|
||||
isolate->Dispose();
|
||||
m_internal->m_isolate->Dispose();
|
||||
m_internal->m_isolate = NULL;
|
||||
}
|
||||
|
||||
@ -290,8 +255,6 @@ namespace NSJSBase
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
if (!m_internal->m_context.IsEmpty())
|
||||
m_internal->m_context->Enter();
|
||||
|
||||
m_internal->m_entered = true;
|
||||
}
|
||||
|
||||
void CJSContext::Exit()
|
||||
@ -308,13 +271,6 @@ namespace NSJSBase
|
||||
else
|
||||
m_internal->m_context = m_internal->m_isolate->GetCurrentContext();
|
||||
m_internal->m_isolate->Exit();
|
||||
|
||||
m_internal->m_entered = false;
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return m_internal->m_entered;
|
||||
}
|
||||
|
||||
CJSValue* CJSContext::createUndefined()
|
||||
@ -690,22 +646,4 @@ namespace NSJSBase
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
|
||||
void FreeNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
if (args.Length() != 1)
|
||||
{
|
||||
args.GetReturnValue().Set(v8::Undefined(isolate));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> obj = args[0].As<v8::Object>();
|
||||
v8::Local<v8::External> field = v8::Local<v8::External>::Cast(obj->GetInternalField(0));
|
||||
CJSEmbedObject* native = static_cast<CJSEmbedObject*>(field->Value());
|
||||
delete native;
|
||||
// weak persistent handle will be cleared and removed in CJSEmbedObjectPrivate destructor
|
||||
}
|
||||
}
|
||||
|
||||
@ -857,14 +857,12 @@ namespace NSJSBase
|
||||
v8::Local<v8::Context> m_context;
|
||||
|
||||
v8::StartupData m_startup_data;
|
||||
bool m_entered;
|
||||
|
||||
public:
|
||||
CJSContextPrivate() : m_isolate(NULL)
|
||||
{
|
||||
m_startup_data.data = NULL;
|
||||
m_startup_data.raw_size = 0;
|
||||
m_entered = false;
|
||||
}
|
||||
|
||||
void InsertToGlobal(const std::string& name, v8::FunctionCallback creator)
|
||||
@ -883,7 +881,6 @@ namespace NSJSBase
|
||||
|
||||
// embed
|
||||
void CreateEmbedNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
void FreeNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
class CJSEmbedObjectAdapterV8Template : public CJSEmbedObjectAdapterBase
|
||||
{
|
||||
@ -901,8 +898,6 @@ namespace NSJSBase
|
||||
{
|
||||
public:
|
||||
v8::Persistent<v8::Object> handle;
|
||||
// contstant id for all weak native handles
|
||||
static const uint16_t kWeakHandleId = 1;
|
||||
|
||||
CJSEmbedObjectPrivate(v8::Local<v8::Object> obj)
|
||||
{
|
||||
@ -921,8 +916,6 @@ namespace NSJSBase
|
||||
|
||||
handle.Reset(CV8Worker::GetCurrent(), obj);
|
||||
handle.SetWeak(pEmbedObject, EmbedObjectWeakCallback, v8::WeakCallbackType::kParameter);
|
||||
// set class_id for being able to iterate over all these handles to destroy them on isolate disposal
|
||||
handle.SetWrapperClassId(kWeakHandleId);
|
||||
|
||||
pEmbedObject->embed_native_internal = this;
|
||||
}
|
||||
@ -936,6 +929,8 @@ namespace NSJSBase
|
||||
|
||||
static void EmbedObjectWeakCallback(const v8::WeakCallbackInfo<CJSEmbedObject>& data)
|
||||
{
|
||||
v8::Isolate* isolate = data.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
CJSEmbedObject* wrap = data.GetParameter();
|
||||
((CJSEmbedObjectPrivate*)wrap->embed_native_internal)->handle.Reset();
|
||||
delete wrap;
|
||||
|
||||
@ -1,15 +1,4 @@
|
||||
#include "Embed.h"
|
||||
#include <iostream>
|
||||
|
||||
CTestEmbed::CTestEmbed()
|
||||
{
|
||||
std::cout << "debug: CTestEmbed constructed" << std::endl;
|
||||
}
|
||||
|
||||
CTestEmbed::~CTestEmbed()
|
||||
{
|
||||
std::cout << "debug: CTestEmbed destroyed" << std::endl;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SUM_DEL
|
||||
JSSmart<CJSValue> CTestEmbed::FunctionSum(JSSmart<CJSValue> param1, JSSmart<CJSValue> param2)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef CTESTEMBED_H_
|
||||
#define CTESTEMBED_H_
|
||||
#ifndef _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#define _BUILD_NATIVE_HASH_EMBED_H_
|
||||
|
||||
#include "js_internal/js_base.h"
|
||||
|
||||
@ -10,8 +10,13 @@ using namespace NSJSBase;
|
||||
class CTestEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CTestEmbed();
|
||||
~CTestEmbed();
|
||||
CTestEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
~CTestEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void* getObject() override { return NULL; }
|
||||
|
||||
@ -28,4 +33,4 @@ public:
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
#endif // CTESTEMBED_H_
|
||||
#endif // _BUILD_NATIVE_HASH_EMBED_H_
|
||||
|
||||
@ -1,14 +1,278 @@
|
||||
#include "test_functions.h"
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
int main()
|
||||
#include <iostream>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
#include "Embed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// TODO: test
|
||||
#if 0
|
||||
// Primitives example
|
||||
|
||||
// testMultipleContexts();
|
||||
testEmbedExternal();
|
||||
// testEmbedInternal();
|
||||
// testHashEmbed();
|
||||
// testEmbedMixed();
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext(false);
|
||||
oContext1->Initialize();
|
||||
|
||||
JSSmart<CJSContext> oContext2 = new CJSContext;
|
||||
// oContext2->Initialize();
|
||||
|
||||
// Work with first context
|
||||
oContext1->Enter();
|
||||
|
||||
{
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSLocalScope local_scope;
|
||||
JSSmart<CJSValue> oResLocal = oContext1->runScript("function f() { return 'Local scope test'; }; f();");
|
||||
std::cout << oResLocal->toStringA() << std::endl;
|
||||
}
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSValue> oVar2 = oContext1->createString("Hel");
|
||||
oGlobal1->set("v1", oVar2.GetPointer());
|
||||
oContext1->runScript("var res = v1 + 'lo'");
|
||||
|
||||
oContext1->Exit();
|
||||
|
||||
// Work with second context with CJSContextScope usage
|
||||
{
|
||||
CJSContextScope scope(oContext2);
|
||||
|
||||
JSSmart<CJSObject> oGlobal2 = oContext2->GetGlobal();
|
||||
JSSmart<CJSValue> oVar4 = oContext2->createString("Wor");
|
||||
oGlobal2->set("v1", oVar4.GetPointer());
|
||||
oContext2->runScript("var res = v1 + 'ld!'");
|
||||
}
|
||||
|
||||
// Print result from first context
|
||||
oContext1->Enter();
|
||||
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript("function f() { return res; }; f();");
|
||||
std::string strRes1 = oRes1->toStringA();
|
||||
std::cout << strRes1 << std::endl;
|
||||
|
||||
// Print second variable
|
||||
oContext2->Enter();
|
||||
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript("function f() { return res; }; f();");
|
||||
std::string strRes2 = oRes2->toStringA();
|
||||
std::cout << strRes2 << std::endl;
|
||||
|
||||
oContext2->Exit();
|
||||
oContext1->Exit();
|
||||
|
||||
// oContext1->Dispose();
|
||||
oContext2->Dispose();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// External embed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// Embedding
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSContext::Embed<CTestEmbed>();
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed1 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
std::cout << "FunctionSum(10, 5) = " << oResTestEmbed1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed2 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSquare(4); })();");
|
||||
std::cout << "FunctionSquare(4) = " << oResTestEmbed2->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed3 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionDel(30, 3); })();");
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed4 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CZipEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
JSSmart<CJSContext> oContext2 = new CJSContext();
|
||||
|
||||
// Work with first context
|
||||
oContext1->Enter();
|
||||
CreateDefaults();
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();");
|
||||
oContext1->Exit();
|
||||
|
||||
// Work with second context
|
||||
{
|
||||
CJSContextScope scope(oContext2);
|
||||
// CreateDefaults();
|
||||
JSSmart<CJSValue> oRes2 = oContext2->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "/../embed');\n"
|
||||
"oZip.close();");
|
||||
}
|
||||
|
||||
// Print first result
|
||||
oContext1->Enter();
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSArray> oFiles1 = oGlobal1->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 1:\n";
|
||||
for (int i = 0; i < oFiles1->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// Print second result
|
||||
oContext2->Enter();
|
||||
JSSmart<CJSObject> oGlobal2 = oContext2->GetGlobal();
|
||||
JSSmart<CJSArray> oFiles2 = oGlobal2->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 2:\n";
|
||||
for (int i = 0; i < oFiles2->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles2->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
oContext2->Exit();
|
||||
oContext1->Exit();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CHashEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// Call hash() on first context
|
||||
CJSContextScope scope(oContext1);
|
||||
CreateDefaults();
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal1->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Call hash2() on first context
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSTypedArray> oHash2 = oGlobal1->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < oHash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// Mixed embed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// External CTestEmbed
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSContext::Embed<CTestEmbed>(false);
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed1 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
if (oResTestEmbed1->isNumber())
|
||||
std::cout << "FunctionSum(10, 5) = " << oResTestEmbed1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSObject> oTestEmbed = CJSContext::createEmbedObject("CTestEmbed");
|
||||
|
||||
// JSSmart<CJSValue> oResTestEmbed2 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSquare(4); })();");
|
||||
JSSmart<CJSValue> args2[1];
|
||||
args2[0] = CJSContext::createInt(4);
|
||||
JSSmart<CJSValue> oResTestEmbed2 = oTestEmbed->call_func("FunctionSquare", 1, args2);
|
||||
if (oResTestEmbed2->isNumber())
|
||||
std::cout << "FunctionSquare(4) = " << oResTestEmbed2->toInt32() << std::endl;
|
||||
|
||||
// JSSmart<CJSValue> oResTestEmbed3 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionDel(30, 3); })();");
|
||||
JSSmart<CJSValue> args3[2];
|
||||
args3[0] = CJSContext::createInt(30);
|
||||
args3[1] = CJSContext::createInt(3);
|
||||
JSSmart<CJSValue> oResTestEmbed3 = oTestEmbed->call_func("FunctionDel", 2, args3);
|
||||
if (oResTestEmbed3->isNumber())
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed4 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
if (oResTestEmbed4->isNumber())
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
|
||||
// Internal CHashEmbed
|
||||
CreateDefaults();
|
||||
oContext1->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print hash
|
||||
JSSmart<CJSObject> oGlobal = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Internal CZipEmbed
|
||||
oContext1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();");
|
||||
|
||||
// Print files
|
||||
JSSmart<CJSArray> oFiles1 = oGlobal->get("files")->toArray();
|
||||
std::cout << "\nFILES IN CURRENT DIRECTORY:\n";
|
||||
for (int i = 0; i < oFiles1->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
#include "test_functions.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// all test functions should be called inside the `@autoreleasepool` block!
|
||||
@autoreleasepool
|
||||
{
|
||||
testEmbedExternal();
|
||||
// testHashEmbed();
|
||||
// testEmbedMixed();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -29,18 +29,10 @@ core_linux {
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
SOURCES += main.cpp \
|
||||
Embed.cpp
|
||||
|
||||
HEADERS += \
|
||||
Embed.h \
|
||||
test_functions.h
|
||||
|
||||
SOURCES += \
|
||||
Embed.cpp \
|
||||
test_functions.cpp
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += main.mm
|
||||
} else {
|
||||
SOURCES += main.cpp
|
||||
}
|
||||
Embed.h
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(Embed.h)
|
||||
|
||||
@ -1,286 +0,0 @@
|
||||
#include "test_functions.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
#include "Embed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
void testMultipleContexts()
|
||||
{
|
||||
// passing `false` when creating CJSContext means that we need to initialize it manually
|
||||
JSSmart<CJSContext> context1 = new CJSContext(false);
|
||||
context1->Initialize();
|
||||
|
||||
// while creating CJSContext without any arguments will create initialized CJSContext
|
||||
JSSmart<CJSContext> context2 = new CJSContext;
|
||||
// we don't need it:
|
||||
// oContext2->Initialize();
|
||||
|
||||
// entering the first context
|
||||
context1->Enter();
|
||||
{
|
||||
// entering the first context the second time in scope creation - it's allowed and the scopes stack correctly
|
||||
CJSContextScope scope(context1);
|
||||
// allocate new local variables inside a custom local scope instead of
|
||||
// the one that is provided by CJSContextScope by default
|
||||
CJSLocalScope local_scope;
|
||||
JSSmart<CJSValue> res_local = context1->runScript("(function() { return 'Local scope test'; })();");
|
||||
std::cout << res_local->toStringA() << std::endl;
|
||||
// the first context is going to be exited at the end of the scope
|
||||
}
|
||||
// at this moment we are still inside the first context, since we have entered it twices
|
||||
JSSmart<CJSObject> global1 = context1->GetGlobal();
|
||||
JSSmart<CJSValue> var = context1->createString("Hel");
|
||||
global1->set("v1", var);
|
||||
// here `res` is set to be "Hello"
|
||||
context1->runScript("var res = v1 + 'lo'");
|
||||
// exit from the first context
|
||||
context1->Exit();
|
||||
|
||||
// now we are going to work with the second context
|
||||
{
|
||||
// enter the second context via context scope
|
||||
CJSContextScope scope(context2);
|
||||
|
||||
JSSmart<CJSObject> global2 = context2->GetGlobal();
|
||||
JSSmart<CJSValue> var = context2->createString("Wor");
|
||||
global2->set("v1", var);
|
||||
// `res` is "World!"
|
||||
context2->runScript("var res = v1 + 'ld!'");
|
||||
// the second context is going to be exited at the end of the scope
|
||||
}
|
||||
|
||||
// enter the first context
|
||||
context1->Enter();
|
||||
// print `res` variable from the first context
|
||||
JSSmart<CJSValue> res1 = context1->runScript("(function() { return res; })();");
|
||||
std::string str_res1 = res1->toStringA();
|
||||
std::cout << str_res1 << ", ";
|
||||
// make new variable `v2` in first context
|
||||
// important to note, that accessing previous `global1` object is undefined behaviour and can lead to crashes!
|
||||
// that is because when we exited from the first context, every local handle inside CJSValue and CJSObject was invalidated
|
||||
global1 = context1->GetGlobal();
|
||||
global1->set("v2", CJSContext::createInt(42));
|
||||
|
||||
// enter from the second context (notice, we haven't exited the first context before)
|
||||
context2->Enter();
|
||||
// print `res` variable from the second context
|
||||
JSSmart<CJSValue> res2 = context1->runScript("(function() { return res; })();");
|
||||
std::string str_res2 = res2->toStringA();
|
||||
std::cout << str_res2 << std::endl;
|
||||
|
||||
// exit from the second context
|
||||
context2->Exit();
|
||||
|
||||
// at this moment we are still in the first context
|
||||
// we can validate that accessing `v2` variable, which exists only in the first context
|
||||
global1 = context1->GetGlobal();
|
||||
std::cout << global1->get("v2")->toInt32() << std::endl;
|
||||
// exit from the first context
|
||||
context1->Exit();
|
||||
|
||||
// manual disposing is not necessary, since it's going to be called in CJSContext's destructor anyway
|
||||
// so we don't need to explicitly write:
|
||||
// oContext1->Dispose();
|
||||
|
||||
// but still nothing wrong will happen if we do:
|
||||
context2->Dispose();
|
||||
}
|
||||
|
||||
void testEmbedExternal()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
// Embedding
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CTestEmbed>();
|
||||
|
||||
JSSmart<CJSValue> res1 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionSum(10, 5); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionSum(10, 5) = " << res1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res2 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionSquare(4); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionSquare(4) = " << res2->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res3 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionDel(30, 3); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionDel(30, 3) = " << res3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res4 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionGet(); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionGet() = " << res4->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
void testEmbedInternal()
|
||||
{
|
||||
// create both contexts
|
||||
JSSmart<CJSContext> context1 = new CJSContext();
|
||||
JSSmart<CJSContext> context2 = new CJSContext();
|
||||
|
||||
// work with the first context
|
||||
context1->Enter();
|
||||
// create embedding info for internally embedded objects (CZipEmbed is the one of them)
|
||||
CreateDefaults();
|
||||
context1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
context1->Exit();
|
||||
|
||||
// work with the second context via context scope
|
||||
{
|
||||
CJSContextScope scope(context2);
|
||||
// function CJSContext::Embed() is context-independent, so we don't actually need to call it in another context
|
||||
// CreateDefaults();
|
||||
context2->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "/../../../embed');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
}
|
||||
|
||||
// print the files from the first context
|
||||
context1->Enter();
|
||||
JSSmart<CJSObject> global1 = context1->GetGlobal();
|
||||
JSSmart<CJSArray> file_list1 = global1->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 1:\n";
|
||||
for (int i = 0; i < file_list1->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// print the files from the second result (note, we haven't exited the first context before)
|
||||
context2->Enter();
|
||||
JSSmart<CJSObject> global2 = context2->GetGlobal();
|
||||
JSSmart<CJSArray> file_list2 = global2->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 2:\n";
|
||||
for (int i = 0; i < file_list2->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list2->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// exit the contexts in reverse order
|
||||
context2->Exit();
|
||||
context1->Exit();
|
||||
}
|
||||
|
||||
void testHashEmbed()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
// test hash()
|
||||
CJSContextScope scope(context);
|
||||
CreateDefaults();
|
||||
context->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);"
|
||||
);
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
JSSmart<CJSTypedArray> res_hash = global->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < res_hash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(res_hash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// test hash2()
|
||||
context->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);"
|
||||
);
|
||||
|
||||
JSSmart<CJSTypedArray> res_hash2 = global->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < res_hash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(res_hash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void testEmbedMixed()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
CJSContextScope scope(context);
|
||||
|
||||
|
||||
// --- test external embedding with CTestEmbed ---
|
||||
// embed with `false` - means we are not able to create the object directly from JavaScript.
|
||||
CJSContext::Embed<CTestEmbed>(false);
|
||||
|
||||
// example of incorrect usage:
|
||||
JSSmart<CJSValue> res1 = context->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
if (res1->isNumber())
|
||||
{
|
||||
// this wouldn't print anything, since `res1` not a number - embedded object was not created in JS and exception was thrown.
|
||||
std::cout << "FunctionSum(10, 5) = " << res1->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// example of correct usage:
|
||||
JSSmart<CJSObject> embedded_object = CJSContext::createEmbedObject("CTestEmbed");
|
||||
JSSmart<CJSValue> args2[1];
|
||||
args2[0] = CJSContext::createInt(4);
|
||||
JSSmart<CJSValue> res2 = embedded_object->call_func("FunctionSquare", 1, args2);
|
||||
if (res2->isNumber())
|
||||
{
|
||||
// should print: "FunctionSquare(4) = 16"
|
||||
std::cout << "FunctionSquare(4) = " << res2->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// another example of correct usage:
|
||||
JSSmart<CJSValue> args3[2];
|
||||
args3[0] = CJSContext::createInt(30);
|
||||
args3[1] = CJSContext::createInt(3);
|
||||
JSSmart<CJSValue> oResTestEmbed3 = embedded_object->call_func("FunctionDel", 2, args3);
|
||||
if (oResTestEmbed3->isNumber())
|
||||
{
|
||||
// should print: "FunctionDel(30, 3) = 10"
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// another example of incorrect usage:
|
||||
JSSmart<CJSValue> oResTestEmbed4 = context->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
if (oResTestEmbed4->isNumber())
|
||||
{
|
||||
// again, this won't be executed and nothing will be printed
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// --- test internal embedding with CHashEmbed ---
|
||||
CreateDefaults();
|
||||
context->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);"
|
||||
);
|
||||
// print hash
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
JSSmart<CJSTypedArray> hash = global->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < hash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(hash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
// --- test internal embedding with CZipEmbed ---
|
||||
context->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
|
||||
// print files
|
||||
JSSmart<CJSArray> file_list = global->get("files")->toArray();
|
||||
std::cout << "\nFILES IN CURRENT DIRECTORY:\n";
|
||||
for (int i = 0; i < file_list->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
#ifndef TEST_FUNCTIONS_H_
|
||||
#define TEST_FUNCTIONS_H_
|
||||
|
||||
|
||||
/**
|
||||
* NOTE: V8 ONLY!
|
||||
* The function tests the work of two CJSContexts in one thread.
|
||||
* Current working context is managed with Enter() and Exit() functions, or with CJSContextScope.
|
||||
*/
|
||||
void testMultipleContexts();
|
||||
|
||||
/**
|
||||
* The function tests external embedding functionality by embedding CTestEmbed class.
|
||||
*/
|
||||
void testEmbedExternal();
|
||||
|
||||
/**
|
||||
* NOTE: V8 ONLY!
|
||||
* The function tests internal embedding functionality by using CZipEmbed class.
|
||||
* It also shows how embedding works for two CJSContext in the same thread (similar to testMultipleContexts()).
|
||||
*/
|
||||
void testEmbedInternal();
|
||||
|
||||
/**
|
||||
* The function tests CHashEmbed class that is embedded internally.
|
||||
*/
|
||||
void testHashEmbed();
|
||||
|
||||
/**
|
||||
* The function tests both internal and external embedding in a more complicated way.
|
||||
*/
|
||||
void testEmbedMixed();
|
||||
|
||||
#endif // TEST_FUNCTIONS_H_
|
||||
@ -351,11 +351,17 @@ CFontManager::~CFontManager()
|
||||
RELEASEINTERFACE(m_pFont);
|
||||
RELEASEOBJECT(m_pOwnerCache);
|
||||
}
|
||||
|
||||
void CFontManager::SetOwnerCache(NSFonts::IFontsCache* pCache)
|
||||
{
|
||||
m_pOwnerCache = (CFontsCache*)pCache;
|
||||
}
|
||||
|
||||
void CFontManager::ClearOwnerCache()
|
||||
{
|
||||
m_pOwnerCache->Clear();
|
||||
}
|
||||
|
||||
NSFonts::IFontsCache* CFontManager::GetCache() { return m_pOwnerCache; }
|
||||
NSFonts::IApplicationFonts* CFontManager::GetApplication() { return m_pApplication; }
|
||||
NSFonts::IFontFile* CFontManager::GetFile() { return m_pFont; }
|
||||
|
||||
@ -132,6 +132,7 @@ public:
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void SetOwnerCache(NSFonts::IFontsCache* pCache);
|
||||
virtual void ClearOwnerCache();
|
||||
|
||||
virtual NSFonts::IFontsCache* GetCache();
|
||||
virtual NSFonts::IApplicationFonts* GetApplication();
|
||||
|
||||
@ -451,7 +451,7 @@ namespace NSShaper
|
||||
CheckUnicodeFaceName(face, family_name, family_name_len);
|
||||
|
||||
unsigned int nLen1 = (unsigned int)family_name_len;
|
||||
unsigned int nLen2 = (unsigned int)((face->style_name != NULL) ? strlen(face->style_name) : 0);
|
||||
unsigned int nLen2 = (unsigned int)strlen(face->style_name);
|
||||
|
||||
unsigned int nLen = 28 + nLen1 + 1 + nLen2 + 1 + 1 + (int)face->num_fixed_sizes;
|
||||
|
||||
@ -693,13 +693,6 @@ namespace NSShaper
|
||||
g_userfeatures_init = true;
|
||||
}
|
||||
|
||||
// Turn on ligatures on arabic script
|
||||
if (nScript == HB_SCRIPT_ARABIC ||
|
||||
nScript == HB_SCRIPT_SYRIAC)
|
||||
{
|
||||
nFeatures |= 1;
|
||||
}
|
||||
|
||||
// font
|
||||
hb_font_t* pFont;
|
||||
if (NULL == font)
|
||||
|
||||
@ -94,14 +94,11 @@ void CheckUnicodeFaceName(FT_Face pFace, int*& UName, unsigned int& ULen)
|
||||
bool isBadASCII = false;
|
||||
|
||||
unsigned int face_name_len = 0;
|
||||
if (NULL != face_name)
|
||||
while ('\0' != face_name[face_name_len])
|
||||
{
|
||||
while ('\0' != face_name[face_name_len])
|
||||
{
|
||||
if ('?' == face_name[face_name_len])
|
||||
isBadASCII = true;
|
||||
++face_name_len;
|
||||
}
|
||||
if ('?' == face_name[face_name_len])
|
||||
isBadASCII = true;
|
||||
++face_name_len;
|
||||
}
|
||||
|
||||
if (face_name_len > 6 &&
|
||||
|
||||
@ -594,13 +594,6 @@ WASM_EXPORT unsigned char* ASC_HB_ShapeText(FT_Face pFace, hb_font_t* pFont, cha
|
||||
g_userfeatures_init = true;
|
||||
}
|
||||
|
||||
// Turn on ligatures on arabic script
|
||||
if (nScript == HB_SCRIPT_ARABIC ||
|
||||
nScript == HB_SCRIPT_SYRIAC)
|
||||
{
|
||||
nFeatures |= 1;
|
||||
}
|
||||
|
||||
// font
|
||||
if (NULL == pFont)
|
||||
{
|
||||
|
||||
@ -1020,39 +1020,22 @@ void CBooleanOperations::TracePaths()
|
||||
{
|
||||
size_t length = Segments1.size();
|
||||
Result.StartFigure();
|
||||
bool first_start = true;
|
||||
for (size_t i = 0; i < length + Segments2.size(); i++)
|
||||
{
|
||||
Segment s = i >= length ? Segments2[i - length] : Segments1[i];
|
||||
bool valid = s.IsValid(Op),
|
||||
start = true;
|
||||
PointD start_point;
|
||||
start = true;
|
||||
while (valid)
|
||||
{
|
||||
if (!start || (Op == Intersection && s.Inters && !GetNextSegment(s).Inters))
|
||||
SetVisited(s);
|
||||
|
||||
if (first_start)
|
||||
{
|
||||
if (start)
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
start_point = s.P;
|
||||
}
|
||||
else if (start)
|
||||
{
|
||||
double x, y;
|
||||
Result.GetLastPoint(x, y);
|
||||
if (isZero(start_point.X - x) && isZero(start_point.Y - y))
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
start_point = s.P;
|
||||
}
|
||||
else
|
||||
Result.LineTo(s.P.X, s.P.Y);
|
||||
}
|
||||
else if (s.IsCurve)
|
||||
Result.CurveTo(s.HI.X + s.P.X, s.HI.Y + s.P.Y,
|
||||
s.HO.X + s.P.X, s.HO.Y + s.P.Y,
|
||||
s.P.X, s.P.Y);
|
||||
s.HO.X + s.P.X, s.HO.Y + s.P.Y,
|
||||
s.P.X, s.P.Y);
|
||||
else
|
||||
Result.LineTo(s.P.X, s.P.Y);
|
||||
|
||||
@ -1082,9 +1065,6 @@ void CBooleanOperations::TracePaths()
|
||||
|
||||
if (start)
|
||||
start = false;
|
||||
|
||||
if (first_start)
|
||||
first_start = false;
|
||||
}
|
||||
|
||||
if (!start && AllOverlap()) break;
|
||||
@ -1665,14 +1645,12 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
std::vector<double> roots = curve.GetCurveLineIntersection(segment.P.X,segment.P.Y, point.X - segment.P.X, point.Y - segment.P.Y);
|
||||
Curve line(segment, Segment(point));
|
||||
|
||||
return roots.size() % 2;
|
||||
int count = 0;
|
||||
for (const auto& r : roots)
|
||||
if (line.GetTimeOf(curve.GetPoint(r)) != -1)
|
||||
count++;
|
||||
|
||||
// int count = 0;
|
||||
// for (const auto& r : roots)
|
||||
// if (line.GetTimeOf(curve.GetPoint(r)) != -1)
|
||||
// count++;
|
||||
|
||||
// return count;
|
||||
return count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -33,479 +33,647 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrush::CBrush(BrushType bType) : m_bType(bType)
|
||||
CBrush::CBrush()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CBrush::CBrush(const BrushType& type)
|
||||
: m_bType(type)
|
||||
{
|
||||
}
|
||||
|
||||
CBrush::~CBrush()
|
||||
{
|
||||
}
|
||||
|
||||
BrushType CBrush::GetType() const
|
||||
{
|
||||
return m_bType;
|
||||
BrushType CBrush::GetType() const
|
||||
{
|
||||
return m_bType;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushSolid::CBrushSolid(CColor dwColor) : CBrush(BrushTypeSolidColor), m_dwColor(dwColor)
|
||||
CBrushSolid::CBrushSolid() : CBrush()
|
||||
{
|
||||
}
|
||||
CBrushSolid::~CBrushSolid()
|
||||
|
||||
CBrushSolid::CBrushSolid(CColor color)
|
||||
: CBrush(),
|
||||
m_dwColor(color)
|
||||
{
|
||||
}
|
||||
CBrush* CBrushSolid::Clone() const
|
||||
{
|
||||
return new CBrushSolid(m_dwColor);
|
||||
|
||||
CBrushSolid::CBrushSolid(const CBrushSolid& other) : CBrush()
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
void CBrushSolid::GetColor(CColor* color) const { *color = m_dwColor; }
|
||||
void CBrushSolid::SetColor(const CColor &color) { m_dwColor = color; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushHatch::CBrushHatch() : CBrush(BrushTypeHatchFill)
|
||||
CBrushSolid::~CBrushSolid()
|
||||
{
|
||||
}
|
||||
CBrushHatch::~CBrushHatch()
|
||||
|
||||
void CBrushSolid::GetColor(CColor* color) const
|
||||
{
|
||||
*color = m_dwColor;
|
||||
}
|
||||
|
||||
void CBrushSolid::SetColor(const CColor &color)
|
||||
{
|
||||
m_dwColor = color;
|
||||
}
|
||||
|
||||
CBrushSolid& CBrushSolid::operator=(const CBrushSolid& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_dwColor = other.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushHatch::CBrushHatch()
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
}
|
||||
CBrush* CBrushHatch::Clone() const
|
||||
{
|
||||
CBrushHatch* clone = new CBrushHatch();
|
||||
clone->m_name = m_name;
|
||||
clone->m_dwColor1 = m_dwColor1;
|
||||
clone->m_dwColor2 = m_dwColor2;
|
||||
return clone;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 )
|
||||
CBrushHatch::CBrushHatch(const CBrushHatch& other)
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CBrushHatch::CBrushHatch(CBrushHatch&& other) noexcept
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushHatch::~CBrushHatch()
|
||||
{
|
||||
}
|
||||
|
||||
void CBrushHatch::SetName(const std::wstring& name)
|
||||
{
|
||||
m_wsName = name;
|
||||
}
|
||||
|
||||
std::wstring CBrushHatch::GetName() const
|
||||
{
|
||||
return m_wsName;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetColor1(const CColor& color)
|
||||
{
|
||||
m_dwColor1 = color;
|
||||
}
|
||||
|
||||
CColor CBrushHatch::GetColor1() const
|
||||
{
|
||||
return m_dwColor1;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetColor2(const CColor& color)
|
||||
{
|
||||
m_dwColor2 = color;
|
||||
}
|
||||
|
||||
CColor CBrushHatch::GetColor2() const
|
||||
{
|
||||
return m_dwColor2;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CDoubleRect& CBrushHatch::GetBounds()
|
||||
{
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
CBrushHatch& CBrushHatch::operator=(const CBrushHatch& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_wsName = other.m_wsName;
|
||||
m_dwColor1 = other.m_dwColor1;
|
||||
m_dwColor2 = other.m_dwColor2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushHatch& CBrushHatch::operator=(CBrushHatch&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_wsName = std::move(other.m_wsName);
|
||||
m_dwColor1 = other.m_dwColor1;
|
||||
m_dwColor2 = other.m_dwColor2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient()
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0] = p1;
|
||||
m_points[1] = p2;
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
|
||||
m_angle = 0;
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = FALSE;
|
||||
m_bRectable = FALSE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (float)p1.X;
|
||||
m_points[0].Y = (float)p1.Y;
|
||||
m_points[1].X = (float)p2.X;
|
||||
m_points[1].Y = (float)p2.Y;
|
||||
m_arPoints[0] = p1;
|
||||
m_arPoints[1] = p2;
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
|
||||
m_angle = 0;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = FALSE;
|
||||
m_bRectable = FALSE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Point& p1, const Point& p2, const CColor& c1, const CColor& c2)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = rect.GetLeft();
|
||||
m_points[0].Y = rect.GetTop();
|
||||
m_points[1].X = rect.GetRight();
|
||||
m_points[1].Y = rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(p1.X);
|
||||
m_arPoints[0].Y = static_cast<float>(p1.Y);
|
||||
m_arPoints[1].X = static_cast<float>(p2.X);
|
||||
m_arPoints[1].Y = static_cast<float>(p2.Y);
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
}
|
||||
|
||||
m_angle = angle;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
CBrushLinearGradient::CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_arPoints[0].X = rect.GetLeft();
|
||||
m_arPoints[0].Y = rect.GetTop();
|
||||
m_arPoints[1].X = rect.GetRight();
|
||||
m_arPoints[1].Y = rect.GetBottom();
|
||||
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_fAngle = angle;
|
||||
|
||||
m_bAngleScalable = isAngleScalable;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (float)rect.GetLeft();
|
||||
m_points[0].Y = (float)rect.GetTop();
|
||||
m_points[1].X = (float)rect.GetRight();
|
||||
m_points[1].Y = (float)rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(rect.GetLeft());
|
||||
m_arPoints[0].Y = static_cast<float>(rect.GetTop());
|
||||
m_arPoints[1].X = static_cast<float>(rect.GetRight());
|
||||
m_arPoints[1].Y = static_cast<float>(rect.GetBottom());
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_angle = angle;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
m_fAngle = angle;
|
||||
|
||||
m_bAngleScalable = isAngleScalable;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = rect.GetLeft();
|
||||
m_points[0].Y = rect.GetTop();
|
||||
m_points[1].X = rect.GetRight();
|
||||
m_points[1].Y = rect.GetBottom();
|
||||
m_arPoints[0].X = rect.GetLeft();
|
||||
m_arPoints[0].Y = rect.GetTop();
|
||||
m_arPoints[1].X = rect.GetRight();
|
||||
m_arPoints[1].Y = rect.GetBottom();
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LinearGradientModeHorizontal:
|
||||
m_angle = 0;
|
||||
m_fAngle = 0;
|
||||
break;
|
||||
|
||||
case LinearGradientModeVertical:
|
||||
m_angle = 90;
|
||||
m_fAngle = 90;
|
||||
break;
|
||||
|
||||
case LinearGradientModeForwardDiagonal:
|
||||
m_angle = 45;
|
||||
m_fAngle = 45;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_angle = 315;
|
||||
m_fAngle = 315;
|
||||
}
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = TRUE;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bAngleScalable = true;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (REAL)rect.GetLeft();
|
||||
m_points[0].Y = (REAL)rect.GetTop();
|
||||
m_points[1].X = (REAL)rect.GetRight();
|
||||
m_points[1].Y = (REAL)rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(rect.GetLeft());
|
||||
m_arPoints[0].Y = static_cast<float>(rect.GetTop());
|
||||
m_arPoints[1].X = static_cast<float>(rect.GetRight());
|
||||
m_arPoints[1].Y = static_cast<float>(rect.GetBottom());
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LinearGradientModeHorizontal:
|
||||
m_angle = 0;
|
||||
m_fAngle = 0;
|
||||
break;
|
||||
|
||||
case LinearGradientModeVertical:
|
||||
m_angle = 90;
|
||||
m_fAngle = 90;
|
||||
break;
|
||||
|
||||
case LinearGradientModeForwardDiagonal:
|
||||
m_angle = 45;
|
||||
m_fAngle = 45;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_angle = 315;
|
||||
m_fAngle = 315;
|
||||
}
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = TRUE;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bAngleScalable = true;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const CBrushLinearGradient& out )
|
||||
: CBrush(out.m_bType)
|
||||
CBrushLinearGradient::CBrushLinearGradient(const CBrushLinearGradient& other)
|
||||
: CBrush(other.m_bType)
|
||||
{
|
||||
m_colors[0] = out.m_colors[0];
|
||||
m_colors[1] = out.m_colors[1];
|
||||
m_points[0] = out.m_points[0];
|
||||
m_points[1] = out.m_points[1];
|
||||
|
||||
m_subcolors = out.m_subcolors;
|
||||
|
||||
m_matrix = out.m_matrix;
|
||||
m_angle = out.m_angle;
|
||||
|
||||
m_wrap = out.m_wrap;
|
||||
m_bAngleScalable = out.m_bAngleScalable;
|
||||
m_bRectable = out.m_bRectable;
|
||||
m_bRelativeCoords = out.m_bRelativeCoords;
|
||||
*this = other;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetLinearColors( CColor* colors ) const
|
||||
CBrushLinearGradient::CBrushLinearGradient(CBrushLinearGradient&& other) noexcept
|
||||
{
|
||||
if( !colors )
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushLinearGradient::~CBrushLinearGradient()
|
||||
{
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetLinearColors(CColor* colors) const
|
||||
{
|
||||
if(!colors)
|
||||
return InvalidParameter;
|
||||
|
||||
colors[0] = m_colors[0];
|
||||
colors[1] = m_colors[1];
|
||||
colors[0] = m_arColors[0];
|
||||
colors[1] = m_arColors[1];
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle( Rect *rect ) const
|
||||
Status CBrushLinearGradient::GetRectangle(Rect *rect) const
|
||||
{
|
||||
if( !rect )
|
||||
if(!rect)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = (int)( m_points[0].X );
|
||||
rect->Y = (int)( m_points[0].Y );
|
||||
rect->Width = (int)( m_points[1].X ) - rect->X;
|
||||
rect->Height = (int)( m_points[1].Y ) - rect->Y;
|
||||
rect->X = static_cast<int>((m_arPoints[0].X));
|
||||
rect->Y = static_cast<int>((m_arPoints[0].Y));
|
||||
rect->Width = static_cast<int>((m_arPoints[1].X) - rect->X);
|
||||
rect->Height = static_cast<int>((m_arPoints[1].Y) - rect->Y);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle(RectF *rect) const
|
||||
{
|
||||
if(!rect)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = m_arPoints[0].X;
|
||||
rect->Y = m_arPoints[0].Y;
|
||||
rect->Width = m_arPoints[1].X - rect->X;
|
||||
rect->Height = m_arPoints[1].Y - rect->Y;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle( RectF *rect ) const
|
||||
Status CBrushLinearGradient::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
if( !rect )
|
||||
if(!matrix)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = m_points[0].X;
|
||||
rect->Y = m_points[0].Y;
|
||||
rect->Width = m_points[1].X - rect->X;
|
||||
rect->Height = m_points[1].Y - rect->Y;
|
||||
*matrix = m_Matrix;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetTransform( CMatrix* matrix ) const
|
||||
Status CBrushLinearGradient::MultiplyTransform(const CMatrix *matrix, MatrixOrder order)
|
||||
{
|
||||
if( !matrix )
|
||||
return InvalidParameter;
|
||||
|
||||
*matrix = m_matrix;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::MultiplyTransform( const CMatrix *matrix, MatrixOrder order)
|
||||
{
|
||||
if( !matrix )
|
||||
return InvalidParameter;
|
||||
|
||||
m_matrix.Multiply( matrix, order );
|
||||
m_Matrix.Multiply(matrix, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::ResetTransform()
|
||||
{
|
||||
m_matrix.Reset();
|
||||
m_Matrix.Reset();
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::RotateTransform( REAL angle, MatrixOrder order )
|
||||
Status CBrushLinearGradient::RotateTransform(float angle, MatrixOrder order)
|
||||
{
|
||||
m_matrix.Rotate( angle, order );
|
||||
m_Matrix.Rotate(angle, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::ScaleTransform( REAL sx, REAL sy, MatrixOrder order )
|
||||
Status CBrushLinearGradient::ScaleTransform(float sx, float sy, MatrixOrder order)
|
||||
{
|
||||
m_matrix.Scale( sx, sy, order );
|
||||
m_Matrix.Scale(sx, sy, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CBrushLinearGradient::SetWrapMode( WrapMode mode )
|
||||
void CBrushLinearGradient::SetWrapMode(WrapMode mode)
|
||||
{
|
||||
m_wrap = mode;
|
||||
m_eWrap = mode;
|
||||
}
|
||||
|
||||
WrapMode CBrushLinearGradient::GetWrapMode() const
|
||||
{
|
||||
return m_wrap;
|
||||
return m_eWrap;
|
||||
}
|
||||
|
||||
CBrush* CBrushLinearGradient::Clone() const
|
||||
Status CBrushLinearGradient::SetInterpolationColors(const CColor *presetColors, const float *blendPositions, int count)
|
||||
{
|
||||
return new CBrushLinearGradient( *this );
|
||||
}
|
||||
m_arSubColors.clear();
|
||||
|
||||
Status CBrushLinearGradient::SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count )
|
||||
{
|
||||
m_subcolors.clear();
|
||||
|
||||
if( count > 0 && presetColors && blendPositions )
|
||||
if(count > 0 && presetColors && blendPositions)
|
||||
{
|
||||
m_subcolors.resize( count );
|
||||
m_arSubColors.resize(count);
|
||||
|
||||
for( int i = 0; i < count; i++ )
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
m_subcolors[i].color = presetColors[i];
|
||||
m_subcolors[i].position = blendPositions[i];
|
||||
m_arSubColors[i].color = presetColors[i];
|
||||
m_arSubColors[i].position = blendPositions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const
|
||||
Status CBrushLinearGradient::GetInterpolationColors(CColor *presetColors, float *blendPositions, int count) const
|
||||
{
|
||||
if( count > 0 && count <= (INT)m_subcolors.size() && presetColors && blendPositions )
|
||||
if( count > 0 && count <= (int)m_arSubColors.size() && presetColors && blendPositions )
|
||||
{
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
presetColors[i] = m_subcolors[i].color;
|
||||
blendPositions[i] = m_subcolors[i].position;
|
||||
presetColors[i] = m_arSubColors[i].color;
|
||||
blendPositions[i] = m_arSubColors[i].position;
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
INT CBrushLinearGradient::GetInterpolationColorsCount() const
|
||||
int CBrushLinearGradient::GetInterpolationColorsCount() const
|
||||
{
|
||||
return (INT)m_subcolors.size();
|
||||
return static_cast<int>(m_arSubColors.size());
|
||||
}
|
||||
|
||||
// additional methods
|
||||
void CBrushLinearGradient::GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const
|
||||
void CBrushLinearGradient::GetSubColor(int index, CColor* color, float* position) const
|
||||
{
|
||||
*pColor = m_subcolors[nIndex].color;
|
||||
*pPosition = m_subcolors[nIndex].position;
|
||||
*color = m_arSubColors[index].color;
|
||||
*position = m_arSubColors[index].position;
|
||||
}
|
||||
|
||||
void CBrushLinearGradient::SetRelativeCoords( INT bRelative )
|
||||
|
||||
void CBrushLinearGradient::SetRelativeCoords(bool relative)
|
||||
{
|
||||
m_bRelativeCoords = bRelative;
|
||||
m_bRelativeCoords = relative;
|
||||
}
|
||||
INT CBrushLinearGradient::IsRelativeCoords() const
|
||||
|
||||
bool CBrushLinearGradient::IsRelativeCoords() const
|
||||
{
|
||||
return m_bRelativeCoords;
|
||||
}
|
||||
|
||||
INT CBrushLinearGradient::IsAngleScalable() const
|
||||
bool CBrushLinearGradient::IsAngleScalable() const
|
||||
{
|
||||
return m_bAngleScalable;
|
||||
}
|
||||
INT CBrushLinearGradient::IsRectable() const
|
||||
|
||||
bool CBrushLinearGradient::IsRectable() const
|
||||
{
|
||||
return m_bRectable;
|
||||
}
|
||||
|
||||
float CBrushLinearGradient::GetAngle() const
|
||||
{
|
||||
return m_angle;
|
||||
return m_fAngle;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushTexture::CBrushTexture() : CBrush(BrushTypeTextureFill)
|
||||
void CBrushLinearGradient::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_pImage = NULL;
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
CDoubleRect& CBrushLinearGradient::GetBounds()
|
||||
{
|
||||
m_pImage = new CImage(strName);
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
CBrushLinearGradient& CBrushLinearGradient::operator=(const CBrushLinearGradient& other)
|
||||
{
|
||||
m_pImage = pImage;
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arColors[0] = other.m_arColors[0];
|
||||
m_arColors[1] = other.m_arColors[1];
|
||||
m_arPoints[0] = other.m_arPoints[0];
|
||||
m_arPoints[1] = other.m_arPoints[1];
|
||||
|
||||
m_arSubColors = other.m_arSubColors;
|
||||
|
||||
m_Matrix = other.m_Matrix;
|
||||
m_fAngle = other.m_fAngle;
|
||||
|
||||
m_eWrap = other.m_eWrap;
|
||||
|
||||
m_bAngleScalable = other.m_bAngleScalable;
|
||||
m_bRectable = other.m_bRectable;
|
||||
m_bRelativeCoords = other.m_bRelativeCoords;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
CBrushLinearGradient& CBrushLinearGradient::operator=(CBrushLinearGradient&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arColors[0] = other.m_arColors[0];
|
||||
m_arColors[1] = other.m_arColors[1];
|
||||
m_arPoints[0] = other.m_arPoints[0];
|
||||
m_arPoints[1] = other.m_arPoints[1];
|
||||
|
||||
m_arSubColors = other.m_arSubColors;
|
||||
|
||||
m_Matrix = std::move(other.m_Matrix);
|
||||
|
||||
m_eWrap = other.m_eWrap;
|
||||
|
||||
m_bAngleScalable = other.m_bAngleScalable;
|
||||
m_bRectable = other.m_bRectable;
|
||||
m_bRelativeCoords = other.m_bRelativeCoords;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture()
|
||||
: CBrush(BrushTypeTextureFill)
|
||||
{
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& name, WrapMode mode)
|
||||
: CBrush(BrushTypeTextureFill),
|
||||
m_eWrapMode(mode)
|
||||
{
|
||||
m_pImage = new CImage(name);
|
||||
m_bReleaseImage = true;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *image, WrapMode mode)
|
||||
: CBrush(BrushTypeTextureFill),
|
||||
m_eWrapMode(mode)
|
||||
{
|
||||
m_pImage = image;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const CBrushTexture& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CBrushTexture&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
{
|
||||
if (m_bReleaseImage)
|
||||
{
|
||||
RELEASEOBJECT(m_pImage);
|
||||
}
|
||||
}
|
||||
|
||||
CBrush* CBrushTexture::Clone() const
|
||||
|
||||
void CBrushTexture::TranslateTransform(double x, double y, MatrixOrder order)
|
||||
{
|
||||
CBrushTexture *pRet = new CBrushTexture(m_pImage, m_wrapMode);
|
||||
if( pRet )
|
||||
{
|
||||
pRet->m_mtx = m_mtx;
|
||||
}
|
||||
|
||||
return pRet;
|
||||
m_Matrix.Translate(x, y, order);
|
||||
}
|
||||
|
||||
void CBrushTexture::TranslateTransform(double dX, double dY, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Translate(dX, dY, order);
|
||||
}
|
||||
void CBrushTexture::ScaleTransform(double dX, double dY, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Scale(dX, dY, order);
|
||||
}
|
||||
void CBrushTexture::RotateTransform(double angle, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Rotate(angle, order);
|
||||
}
|
||||
void CBrushTexture::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
*matrix = m_mtx;
|
||||
}
|
||||
void CBrushTexture::SetTransform(const CMatrix* matrix)
|
||||
{
|
||||
m_mtx = *matrix;
|
||||
void CBrushTexture::ScaleTransform(double x, double y, MatrixOrder order)
|
||||
{
|
||||
m_Matrix.Scale(x, y, order);
|
||||
}
|
||||
|
||||
void CBrushTexture::SetWrapMode(WrapMode wMode)
|
||||
{
|
||||
m_wrapMode = wMode;
|
||||
void CBrushTexture::RotateTransform(double angle, MatrixOrder order)
|
||||
{
|
||||
m_Matrix.Rotate(angle, order);
|
||||
}
|
||||
WrapMode CBrushTexture::GetWrapMode() const
|
||||
{
|
||||
return(m_wrapMode);
|
||||
|
||||
void CBrushTexture::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
*matrix = m_Matrix;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetTransform(const CMatrix* matrix)
|
||||
{
|
||||
m_Matrix = *matrix;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetWrapMode(WrapMode mode)
|
||||
{
|
||||
m_eWrapMode = mode;
|
||||
}
|
||||
|
||||
WrapMode CBrushTexture::GetWrapMode() const
|
||||
{
|
||||
return m_eWrapMode;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_bUseBounds = true;
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CDoubleRect& CBrushTexture::GetBounds()
|
||||
{
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetReleaseImage(bool isReleaseImage)
|
||||
{
|
||||
m_bReleaseImage = isReleaseImage;
|
||||
}
|
||||
|
||||
bool CBrushTexture::IsReleaseImage() const
|
||||
{
|
||||
return m_bReleaseImage;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetAlpha(BYTE alpha)
|
||||
{
|
||||
m_Alpha = alpha;
|
||||
}
|
||||
|
||||
BYTE CBrushTexture::GetAlpha() const
|
||||
{
|
||||
return m_Alpha;
|
||||
}
|
||||
|
||||
void* CBrushTexture::GetData()
|
||||
{
|
||||
return m_pImage->m_pImgData;
|
||||
}
|
||||
|
||||
void* CBrushTexture::PatternFinalize()
|
||||
{
|
||||
{
|
||||
if (m_pImage->m_nStride < 0)
|
||||
return m_pImage->m_pImgData - ((m_pImage->m_dwHeight - 1) * m_pImage->m_nStride);
|
||||
return m_pImage->m_pImgData;
|
||||
}
|
||||
|
||||
DWORD CBrushTexture::PatternGetWidth()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_dwWidth;
|
||||
}
|
||||
|
||||
DWORD CBrushTexture::PatternGetHeight()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_dwHeight;
|
||||
}
|
||||
|
||||
int CBrushTexture::PatternGetStride()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_nStride;
|
||||
}
|
||||
|
||||
CBrushTexture& CBrushTexture::operator=(const CBrushTexture& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_pImage = new CImage(*other.m_pImage);
|
||||
|
||||
m_Matrix = other.m_Matrix;
|
||||
|
||||
m_eWrapMode = other.m_eWrapMode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture& CBrushTexture::operator=(CBrushTexture&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_pImage = std::move(other.m_pImage);
|
||||
|
||||
m_Matrix = std::move(other.m_Matrix);
|
||||
|
||||
m_eWrapMode = other.m_eWrapMode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,170 +43,256 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
|
||||
CBrush(BrushType bType);
|
||||
|
||||
public:
|
||||
virtual ~CBrush();
|
||||
|
||||
virtual CBrush* Clone() const = 0;
|
||||
BrushType GetType() const;
|
||||
|
||||
public:
|
||||
BrushType m_bType;
|
||||
};
|
||||
|
||||
class CBrushSolid : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushSolid(CColor dwColor);
|
||||
virtual ~CBrushSolid();
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
void GetColor(CColor* color) const;
|
||||
void SetColor(const CColor &color);
|
||||
|
||||
protected:
|
||||
CColor m_dwColor;
|
||||
};
|
||||
|
||||
class CBrushHatch : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushHatch();
|
||||
virtual ~CBrushHatch();
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
inline CDoubleRect& GetBounds() { return Bounds; }
|
||||
|
||||
|
||||
public:
|
||||
std::wstring m_name;
|
||||
CColor m_dwColor1;
|
||||
CColor m_dwColor2;
|
||||
|
||||
CDoubleRect Bounds;
|
||||
};
|
||||
|
||||
|
||||
class CBrushLinearGradient : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
public:
|
||||
CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 );
|
||||
CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 );
|
||||
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
|
||||
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
|
||||
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
|
||||
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
|
||||
CBrushLinearGradient( const CBrushLinearGradient& out );
|
||||
|
||||
Status GetLinearColors( CColor* colors ) const;
|
||||
Status GetRectangle( Rect *rect ) const;
|
||||
Status GetRectangle( RectF *rect ) const;
|
||||
|
||||
Status GetTransform( CMatrix* matrix ) const;
|
||||
Status MultiplyTransform( const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
Status ResetTransform();
|
||||
Status RotateTransform( REAL angle, MatrixOrder order = MatrixOrderPrepend );
|
||||
Status ScaleTransform( REAL sx, REAL sy, MatrixOrder order = MatrixOrderPrepend );
|
||||
|
||||
void SetWrapMode( WrapMode mode );
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
Status SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count );
|
||||
Status GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const;
|
||||
INT GetInterpolationColorsCount() const;
|
||||
|
||||
// additional methods
|
||||
void GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const;
|
||||
|
||||
void SetRelativeCoords( INT bRelative );
|
||||
INT IsRelativeCoords() const;
|
||||
INT IsAngleScalable() const;
|
||||
INT IsRectable() const;
|
||||
float GetAngle() const;
|
||||
inline void SetBounds(const CDoubleRect& oRect) { Bounds = oRect; }
|
||||
inline CDoubleRect& GetBounds() { return Bounds; }
|
||||
|
||||
// info about gradient
|
||||
NSStructures::GradientInfo m_oGradientInfo; // used in 60xx grad types
|
||||
protected:
|
||||
CColor m_colors[2];
|
||||
PointF m_points[2];
|
||||
|
||||
struct TSubColor
|
||||
/**
|
||||
* @abstract CBrush
|
||||
*
|
||||
* Base class for brushes (by default a solid brush
|
||||
* is created).
|
||||
*/
|
||||
class CBrush
|
||||
{
|
||||
CColor color;
|
||||
float position;
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
CBrush();
|
||||
CBrush(const BrushType& type);
|
||||
|
||||
public:
|
||||
virtual ~CBrush();
|
||||
|
||||
BrushType GetType() const;
|
||||
|
||||
public:
|
||||
BrushType m_bType = BrushTypeSolidColor;
|
||||
};
|
||||
|
||||
std::vector<TSubColor> m_subcolors;
|
||||
|
||||
CMatrix m_matrix;
|
||||
float m_angle; // угол поворота в градусах базовой линии p1 -> p2
|
||||
/**
|
||||
* @class CBrushSolid
|
||||
*
|
||||
* A single-color brush used to draw text, graphic paths,
|
||||
* and fills with a single color.
|
||||
*/
|
||||
class CBrushSolid : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushSolid();
|
||||
CBrushSolid(CColor color);
|
||||
virtual ~CBrushSolid();
|
||||
CBrushSolid(const CBrushSolid& other);
|
||||
|
||||
CDoubleRect Bounds;
|
||||
void GetColor(CColor* color) const;
|
||||
void SetColor(const CColor &color);
|
||||
|
||||
Aggplus::WrapMode m_wrap;
|
||||
CBrushSolid& operator=(const CBrushSolid& other);
|
||||
protected:
|
||||
CColor m_dwColor{};
|
||||
};
|
||||
|
||||
INT m_bAngleScalable; // масштабировать угол поворота относительно заданных точек b = arctan( width / height * tan(angle) );
|
||||
INT m_bRectable; // в качестве направляющей используется диагональ прямоугольника
|
||||
INT m_bRelativeCoords; // координаты точек считаются относительно рисуемого примитива
|
||||
};
|
||||
/**
|
||||
* @class CBrushHatch
|
||||
*
|
||||
* A two-color brush used to fill graphic paths using
|
||||
* one of the hatch patterns
|
||||
*/
|
||||
class CBrushHatch : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushHatch();
|
||||
CBrushHatch(const CBrushHatch& other);
|
||||
CBrushHatch(CBrushHatch&& other) noexcept;
|
||||
virtual ~CBrushHatch();
|
||||
|
||||
class CBrushTexture : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
CBrushTexture();
|
||||
void SetName(const std::wstring& name);
|
||||
std::wstring GetName() const;
|
||||
|
||||
public:
|
||||
CBrushTexture(const std::wstring& strName, WrapMode wrapMode = WrapModeTile);
|
||||
CBrushTexture(CImage *pImage, WrapMode wrapMode = WrapModeTile);
|
||||
virtual ~CBrushTexture();
|
||||
virtual CBrush* Clone() const;
|
||||
void SetColor1(const CColor& color);
|
||||
CColor GetColor1() const;
|
||||
void SetColor2(const CColor& color);
|
||||
CColor GetColor2() const;
|
||||
|
||||
void TranslateTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void ScaleTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void GetTransform(CMatrix* matrix) const;
|
||||
void SetTransform(const CMatrix* matrix);
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
void SetWrapMode(WrapMode wMode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
public:
|
||||
CBrushHatch& operator=(const CBrushHatch& other);
|
||||
CBrushHatch& operator=(CBrushHatch&& other) noexcept;
|
||||
protected:
|
||||
/**
|
||||
* @brief m_wsName - hatch brush pattern name
|
||||
* (as default - cross)
|
||||
*
|
||||
* See all patterns in agg_span_hatch.h, array -
|
||||
* c_resource_hatches_names.
|
||||
*/
|
||||
std::wstring m_wsName;
|
||||
CColor m_dwColor1{};
|
||||
CColor m_dwColor2{};
|
||||
|
||||
void* GetData();
|
||||
void* PatternFinalize();
|
||||
DWORD PatternGetWidth();
|
||||
DWORD PatternGetHeight();
|
||||
int PatternGetStride();
|
||||
|
||||
public:
|
||||
CImage* m_pImage;
|
||||
INT m_bReleaseImage;
|
||||
|
||||
WrapMode m_wrapMode;
|
||||
CMatrix m_mtx;
|
||||
CDoubleRect m_oBounds{};
|
||||
};
|
||||
|
||||
CColor m_colors[2];
|
||||
/**
|
||||
* @class CBrushLinearGradient
|
||||
*
|
||||
* brush for drawing gradients, stores information about the gradient.
|
||||
* According to the pdf documentation, it stores the start and end point
|
||||
* and color, as well as the linear interpolation of the colors.
|
||||
*/
|
||||
class CBrushLinearGradient : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
public:
|
||||
CBrushLinearGradient();
|
||||
CBrushLinearGradient(const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2);
|
||||
CBrushLinearGradient(const Point& p1, const Point& p2, const CColor& c1, const CColor& c2);
|
||||
CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable);
|
||||
CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable);
|
||||
CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode);
|
||||
CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode);
|
||||
CBrushLinearGradient(const CBrushLinearGradient& other);
|
||||
CBrushLinearGradient(CBrushLinearGradient&& other) noexcept;
|
||||
virtual ~CBrushLinearGradient();
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
Status GetLinearColors(CColor* colors) const;
|
||||
Status GetRectangle(Rect *rect) const;
|
||||
Status GetRectangle(RectF *rect) const;
|
||||
|
||||
Status GetTransform(CMatrix* matrix) const;
|
||||
Status MultiplyTransform(const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
Status ResetTransform();
|
||||
Status RotateTransform(float angle, MatrixOrder order = MatrixOrderPrepend );
|
||||
Status ScaleTransform(float sx, float sy, MatrixOrder order = MatrixOrderPrepend );
|
||||
|
||||
void SetWrapMode(WrapMode mode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
Status SetInterpolationColors(const CColor *presetColors, const float *blendPositions, int count);
|
||||
Status GetInterpolationColors(CColor *presetColors, float *blendPositions, int count) const;
|
||||
int GetInterpolationColorsCount() const;
|
||||
|
||||
void GetSubColor(int index, CColor* color, float* position) const;
|
||||
|
||||
void SetRelativeCoords(bool relative);
|
||||
bool IsRelativeCoords() const;
|
||||
bool IsAngleScalable() const;
|
||||
bool IsRectable() const;
|
||||
float GetAngle() const;
|
||||
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
CBrushLinearGradient& operator=(const CBrushLinearGradient& other);
|
||||
CBrushLinearGradient& operator=(CBrushLinearGradient&& other) noexcept;
|
||||
|
||||
NSStructures::GradientInfo m_oGradientInfo{};
|
||||
protected:
|
||||
CColor m_arColors[2];
|
||||
PointF m_arPoints[2];
|
||||
|
||||
struct TSubColor
|
||||
{
|
||||
CColor color{};
|
||||
float position = 0;
|
||||
};
|
||||
|
||||
std::vector<TSubColor> m_arSubColors;
|
||||
|
||||
CMatrix m_Matrix{};
|
||||
|
||||
/**
|
||||
* @brief m_angle - rotation angle of line p1 - p2 (measured in degrees)
|
||||
*/
|
||||
float m_fAngle = 0;
|
||||
|
||||
CDoubleRect m_oBounds{};
|
||||
|
||||
/**
|
||||
* @brief m_eWrapMode - Used to determine the rotation of the image tiles
|
||||
* (by default, we do not change the position).
|
||||
*/
|
||||
WrapMode m_eWrap = Aggplus::WrapModeTile;
|
||||
|
||||
/**
|
||||
* @brief m_bAngleScalable - whether to scale the rotation angle relative
|
||||
* to the given points
|
||||
*
|
||||
* calculated like this b = arctan(width / height * tan(angle));
|
||||
*/
|
||||
bool m_bAngleScalable = false;
|
||||
|
||||
/**
|
||||
* @brief m_bRectable - is the diagonal of a rectangle a guide
|
||||
*/
|
||||
bool m_bRectable = false;
|
||||
|
||||
/**
|
||||
* @brief m_bRelativeCoords - are the coordinates of the points calculated
|
||||
* relative to the resulting primitive
|
||||
*/
|
||||
bool m_bRelativeCoords = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class CBrushTexture
|
||||
*
|
||||
* A texture brush that is used to draw images on the renderer.
|
||||
*/
|
||||
class CBrushTexture : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
public:
|
||||
CBrushTexture();
|
||||
CBrushTexture(const std::wstring& name, WrapMode mode = WrapModeTile);
|
||||
CBrushTexture(CImage *image, WrapMode mode = WrapModeTile);
|
||||
CBrushTexture(const CBrushTexture& other);
|
||||
CBrushTexture(CBrushTexture&& other);
|
||||
virtual ~CBrushTexture();
|
||||
|
||||
void TranslateTransform(double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void ScaleTransform(double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void GetTransform(CMatrix* matrix) const;
|
||||
void SetTransform(const CMatrix* matrix);
|
||||
|
||||
void SetWrapMode(WrapMode mode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
void SetReleaseImage(bool isReleaseImage);
|
||||
bool IsReleaseImage() const;
|
||||
|
||||
void SetAlpha(BYTE alpha);
|
||||
BYTE GetAlpha() const;
|
||||
|
||||
void* GetData();
|
||||
void* PatternFinalize();
|
||||
DWORD PatternGetWidth();
|
||||
DWORD PatternGetHeight();
|
||||
int PatternGetStride();
|
||||
|
||||
CBrushTexture& operator=(const CBrushTexture& other);
|
||||
CBrushTexture& operator=(CBrushTexture&& other);
|
||||
|
||||
protected:
|
||||
CImage* m_pImage{nullptr};
|
||||
bool m_bReleaseImage = false;
|
||||
|
||||
/**
|
||||
* @brief m_eWrapMode - Used to determine the rotation of the image tiles
|
||||
* (by default, we do not change the position).
|
||||
*/
|
||||
WrapMode m_eWrapMode = WrapModeTile;
|
||||
|
||||
CMatrix m_Matrix{};
|
||||
|
||||
bool m_bUseBounds = false;
|
||||
CDoubleRect m_oBounds{};
|
||||
|
||||
BYTE m_Alpha = 255;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_BRUSH_H_
|
||||
|
||||
@ -832,7 +832,8 @@ namespace Aggplus
|
||||
b = ptxBrush->m_oBounds.bottom;
|
||||
}
|
||||
|
||||
CMatrix brushMatrix(ptxBrush->m_mtx);
|
||||
CMatrix brushMatrix;
|
||||
ptxBrush->GetTransform(&brushMatrix);
|
||||
if (ptxBrush->GetWrapMode() == Aggplus::WrapModeClamp)
|
||||
{
|
||||
double dScaleX = (r - x) / dwPatternWidth;
|
||||
@ -1652,11 +1653,11 @@ namespace Aggplus
|
||||
m_rasterizer.gamma(1.0);
|
||||
}
|
||||
#else
|
||||
agg::rgba8 c1 = agg::rgba8(pBrush->m_dwColor1.GetR(), pBrush->m_dwColor1.GetG(), pBrush->m_dwColor1.GetB(), pBrush->m_dwColor1.GetA());
|
||||
agg::rgba8 c2 = agg::rgba8(pBrush->m_dwColor2.GetR(), pBrush->m_dwColor2.GetG(), pBrush->m_dwColor2.GetB(), pBrush->m_dwColor2.GetA());
|
||||
agg::rgba8 c1 = agg::rgba8(pBrush->GetColor1().GetR(), pBrush->GetColor1().GetG(), pBrush->GetColor1().GetB(), pBrush->GetColor1().GetA());
|
||||
agg::rgba8 c2 = agg::rgba8(pBrush->GetColor2().GetR(), pBrush->GetColor2().GetG(), pBrush->GetColor2().GetB(), pBrush->GetColor2().GetA());
|
||||
|
||||
BYTE* pPattern = new BYTE[HATCH_TX_SIZE * HATCH_TX_SIZE * 4];
|
||||
agg::GetHatchPattern(pBrush->m_name, (agg::rgba8*)pPattern, c1, c2);
|
||||
agg::GetHatchPattern(pBrush->GetName(), (agg::rgba8*)pPattern, c1, c2);
|
||||
|
||||
agg::trans_affine mtx_Work(m_oTransform.m_internal->m_agg_mtx);
|
||||
if (m_dDpiTile > 1)
|
||||
@ -2049,22 +2050,22 @@ namespace Aggplus
|
||||
|
||||
if(pImgBuff && dwImgWidth && dwImgHeight)
|
||||
{
|
||||
Aggplus::WrapMode wrapmode = ptxBrush->m_wrapMode;
|
||||
Aggplus::CMatrix matrix = ptxBrush->m_mtx;
|
||||
Aggplus::WrapMode wrapmode = ptxBrush->m_eWrapMode;
|
||||
Aggplus::CMatrix matrix = ptxBrush->m_Matrix;
|
||||
|
||||
if(wrapmode == WrapModeClamp)
|
||||
{
|
||||
DoFillPathTextureClampSz2( matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz2( matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, ptxBrush->m_Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_bSwapRGB)
|
||||
{
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_bgra32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_bgra32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->m_Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_rgba32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_rgba32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->m_Alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Aggplus
|
||||
|
||||
CGraphicsPath::CGraphicsPath(CGraphicsPath&& other) noexcept
|
||||
{
|
||||
*this = other;
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CGraphicsPath::CGraphicsPath(const std::vector<CGraphicsPath>& paths) noexcept : CGraphicsPath()
|
||||
@ -863,23 +863,21 @@ namespace Aggplus
|
||||
|
||||
double CGraphicsPath::GetArea(unsigned idx, bool isCurve) const noexcept
|
||||
{
|
||||
double area;
|
||||
float area;
|
||||
if (isCurve)
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 4);
|
||||
area = (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3.0)
|
||||
- points[3].X * (points[2].Y + points[0].Y / 3.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = 4.0 * (points[1].Y * points[0].X - points[1].X * points[0].Y) / 3.0;
|
||||
area = 3 * ((points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y * points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3)
|
||||
- points[3].X * (points[2].Y - points[0].Y / 3)) / 20;
|
||||
}
|
||||
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = (points[1].Y * points[0].X - points[1].X * points[0].Y) / 20;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
|
||||
Aggplus::CColor o1((BYTE)(pBrush->Alpha1 * m_dGlobalAlpha), pBrush->Color1, bIsSwappedRGB);
|
||||
Aggplus::CColor o2((BYTE)(pBrush->Alpha2 * m_dGlobalAlpha), pBrush->Color2, bIsSwappedRGB);
|
||||
|
||||
Aggplus::CBrushLinearGradient* pNew = new Aggplus::CBrushLinearGradient( Aggplus::RectF(0.0f, 0.0f, 1.0f, 1.0f), o1, o2, (float)pBrush->LinearAngle, TRUE );
|
||||
Aggplus::CBrushLinearGradient* pNew = new Aggplus::CBrushLinearGradient(Aggplus::RectF(0.0f, 0.0f, 1.0f, 1.0f), o1, o2, (float)pBrush->LinearAngle, true);
|
||||
if( pNew )
|
||||
{
|
||||
pNew->SetRelativeCoords( TRUE );
|
||||
@ -180,11 +180,11 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
|
||||
Aggplus::CColor o2((BYTE)(pBrush->Alpha2 * m_dGlobalAlpha), pBrush->Color2, bIsSwappedRGB);
|
||||
|
||||
Aggplus::CBrushHatch* pNew = new Aggplus::CBrushHatch();
|
||||
pNew->m_dwColor1 = o1;
|
||||
pNew->m_dwColor2 = o2;
|
||||
pNew->m_name = pBrush->TexturePath;
|
||||
pNew->SetColor1(o1);
|
||||
pNew->SetColor2(o2);
|
||||
pNew->SetName(pBrush->TexturePath);
|
||||
|
||||
pNew->Bounds = pBrush->Bounds;
|
||||
pNew->SetBounds(pBrush->Bounds);
|
||||
|
||||
return pNew;
|
||||
}
|
||||
@ -996,7 +996,7 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
pTextureBrush->SetReleaseImage(true);
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
@ -1018,15 +1018,14 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
{
|
||||
pTextureBrush->SetTransform(&m_oBrush.Transform);
|
||||
|
||||
pTextureBrush->Alpha = (BYTE)m_oBrush.TextureAlpha;
|
||||
pTextureBrush->SetAlpha(static_cast<BYTE>(m_oBrush.TextureAlpha));
|
||||
|
||||
if (m_oBrush.Rectable == 1)
|
||||
{
|
||||
pTextureBrush->m_bUseBounds = true;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
|
||||
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
pTextureBrush->SetBounds({m_oBrush.Rect.X,
|
||||
m_oBrush.Rect.Y,
|
||||
m_oBrush.Rect.X + m_oBrush.Rect.Width,
|
||||
m_oBrush.Rect.Y + m_oBrush.Rect.Height});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,16 @@ namespace Aggplus
|
||||
Create(filename);
|
||||
}
|
||||
|
||||
CImage::CImage(const CImage& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CImage::CImage(CImage&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
{
|
||||
Destroy();
|
||||
@ -136,6 +146,46 @@ namespace Aggplus
|
||||
m_bExternalBuffer = false;
|
||||
}
|
||||
|
||||
CImage& CImage::operator=(const CImage& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_Status = other.m_Status;
|
||||
|
||||
m_dwHeight = other.m_dwHeight;
|
||||
m_dwWidth = other.m_dwWidth;
|
||||
m_nStride = other.m_nStride;
|
||||
|
||||
m_bExternalBuffer = other.m_bExternalBuffer;
|
||||
|
||||
size_t size_of_data = m_dwHeight * m_nStride > 0 ? m_nStride : -m_nStride;
|
||||
m_pImgData = new BYTE[size_of_data];
|
||||
|
||||
memcpy(m_pImgData, other.m_pImgData, size_of_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CImage& CImage::operator=(CImage&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_Status = other.m_Status;
|
||||
|
||||
m_dwHeight = other.m_dwHeight;
|
||||
m_dwWidth = other.m_dwWidth;
|
||||
m_nStride = other.m_nStride;
|
||||
|
||||
m_bExternalBuffer = other.m_bExternalBuffer;
|
||||
|
||||
m_pImgData = other.m_pImgData;
|
||||
other.m_pImgData = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
DWORD CImage::GetWidth() const { return(m_dwWidth); }
|
||||
DWORD CImage::GetHeight() const { return(m_dwHeight); }
|
||||
long CImage::GetStride() const { return(m_nStride); }
|
||||
@ -146,10 +196,10 @@ namespace Aggplus
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
CBitmap::CBitmap(LONG width, LONG height, PixelFormat format) : CImage()
|
||||
{
|
||||
if(width <= 0 || height <= 0)
|
||||
{
|
||||
m_Status=InvalidParameter;
|
||||
return;
|
||||
if(width <= 0 || height <= 0)
|
||||
{
|
||||
m_Status=InvalidParameter;
|
||||
return;
|
||||
}
|
||||
|
||||
LONG lSize = 4 * width * height;
|
||||
@ -168,15 +218,15 @@ namespace Aggplus
|
||||
CBitmap::CBitmap(LONG width, LONG height, LONG stride, PixelFormat format, BYTE* scan0) : CImage()
|
||||
{
|
||||
//Warning! This is not Gdiplus behavior; it returns Ok!
|
||||
if(width <= 0 || height <= 0 || stride == 0)
|
||||
{
|
||||
m_Status = InvalidParameter;
|
||||
return;
|
||||
if(width <= 0 || height <= 0 || stride == 0)
|
||||
{
|
||||
m_Status = InvalidParameter;
|
||||
return;
|
||||
}
|
||||
|
||||
m_bExternalBuffer = true;
|
||||
|
||||
if (stride > 0)
|
||||
if (stride > 0)
|
||||
{
|
||||
m_pImgData = scan0;
|
||||
}
|
||||
@ -184,7 +234,7 @@ namespace Aggplus
|
||||
{
|
||||
m_pImgData = scan0 + (height - 1) * (-stride);
|
||||
}
|
||||
|
||||
|
||||
m_dwWidth = width;
|
||||
m_dwHeight = height;
|
||||
m_nStride = stride;
|
||||
|
||||
@ -49,6 +49,8 @@ public:
|
||||
public:
|
||||
CImage();
|
||||
CImage(const std::wstring& filename);
|
||||
CImage(const CImage& other);
|
||||
CImage(CImage&& other);
|
||||
virtual ~CImage();
|
||||
|
||||
DWORD GetWidth() const;
|
||||
@ -64,6 +66,9 @@ public:
|
||||
bool SaveFile(const std::wstring& strFileName, UINT nFileType);
|
||||
void Destroy();
|
||||
|
||||
CImage& operator=(const CImage& other);
|
||||
CImage& operator=(CImage&& other);
|
||||
|
||||
protected:
|
||||
Status m_Status;
|
||||
|
||||
|
||||
@ -30,127 +30,133 @@
|
||||
*
|
||||
*/
|
||||
#include "Matrix_private.h"
|
||||
#include <utility>
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
|
||||
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx.sx = m11;
|
||||
m_internal->m_agg_mtx.shy = m12;
|
||||
m_internal->m_agg_mtx.shx = m21;
|
||||
m_internal->m_agg_mtx.sy = m22;
|
||||
m_internal->m_agg_mtx.tx = dx;
|
||||
m_internal->m_agg_mtx.ty = dy;
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx.sx = m11;
|
||||
m_internal->m_agg_mtx.shy = m12;
|
||||
m_internal->m_agg_mtx.shx = m21;
|
||||
m_internal->m_agg_mtx.sy = m22;
|
||||
m_internal->m_agg_mtx.tx = dx;
|
||||
m_internal->m_agg_mtx.ty = dy;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix(const CMatrix& oSrc)
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx = oSrc.m_internal->m_agg_mtx;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix()
|
||||
CMatrix::CMatrix()
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal = new CMatrix_private();
|
||||
}
|
||||
|
||||
|
||||
CMatrix::CMatrix(const CMatrix& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix(CMatrix&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CMatrix::~CMatrix()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
|
||||
void CMatrix::Translate(double offsetX, double offsetY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
|
||||
void CMatrix::Scale(double scaleX, double scaleY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
|
||||
void CMatrix::Shear(double shearX, double shearY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
|
||||
double CMatrix::Determinant() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.determinant();
|
||||
}
|
||||
|
||||
void CMatrix::TransformVectors(PointF* pts, int count) const
|
||||
{
|
||||
// Store matrix to an array [6] of double
|
||||
double M[6]; m_internal->m_agg_mtx.store_to(M);
|
||||
double M[6];
|
||||
m_internal->m_agg_mtx.store_to(M);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = (float)(x-M[4]);
|
||||
pts[i].Y = (float)(y-M[5]);
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = static_cast<float>(x-M[4]);
|
||||
pts[i].Y = static_cast<float>(y-M[5]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints(PointF* pts, int count) const
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = (float)x;
|
||||
pts[i].Y = (float)y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = static_cast<float>(x);
|
||||
pts[i].Y = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoint(double& x, double& y) const
|
||||
{
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints(PointF* dst, const PointF* src, int count) const
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
|
||||
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
|
||||
|
||||
dst[i].X = static_cast<float>(x);
|
||||
dst[i].Y = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::Rotate(double angle, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
void CMatrix::RotateAt(double angle, const PointF ¢er, MatrixOrder order)
|
||||
{
|
||||
Translate(-center.X, -center.Y, order);
|
||||
if(order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
if(order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
|
||||
Translate(center.X, center.Y, order);
|
||||
return;
|
||||
}
|
||||
@ -158,168 +164,169 @@ namespace Aggplus
|
||||
void CMatrix::RotateAt(double angle, double x, double y, MatrixOrder order)
|
||||
{
|
||||
Translate(-x, -y, order);
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
|
||||
Translate(x, y, order);
|
||||
}
|
||||
|
||||
void CMatrix::Multiply(const CMatrix* matrix, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
|
||||
double CMatrix::OffsetX() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
|
||||
double CMatrix::OffsetY() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
|
||||
double CMatrix::sx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sx;
|
||||
}
|
||||
double CMatrix::sy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sy;
|
||||
}
|
||||
double CMatrix::shx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shx;
|
||||
}
|
||||
double CMatrix::shy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shy;
|
||||
}
|
||||
double CMatrix::tx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
double CMatrix::ty() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
double CMatrix::rotation()
|
||||
{
|
||||
return m_internal->m_agg_mtx.rotation();
|
||||
}
|
||||
|
||||
|
||||
void CMatrix::SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx, const double& ty)
|
||||
{
|
||||
m_internal->m_agg_mtx.sx = sx;
|
||||
m_internal->m_agg_mtx.shy = shy;
|
||||
m_internal->m_agg_mtx.shx = shx;
|
||||
m_internal->m_agg_mtx.sy = sy;
|
||||
m_internal->m_agg_mtx.tx = tx;
|
||||
m_internal->m_agg_mtx.ty = ty;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(REAL* m) const
|
||||
double CMatrix::sx() const
|
||||
{
|
||||
double M[6]; m_internal->m_agg_mtx.store_to(M);
|
||||
m[0]=(REAL)M[0];
|
||||
m[1]=(REAL)M[1];
|
||||
m[2]=(REAL)M[2];
|
||||
m[3]=(REAL)M[3];
|
||||
m[4]=(REAL)M[4];
|
||||
m[5]=(REAL)M[5];
|
||||
return m_internal->m_agg_mtx.sx;
|
||||
}
|
||||
|
||||
double CMatrix::sy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sy;
|
||||
}
|
||||
|
||||
double CMatrix::shx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shx;
|
||||
}
|
||||
|
||||
double CMatrix::shy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shy;
|
||||
}
|
||||
|
||||
double CMatrix::tx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
|
||||
double CMatrix::ty() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
|
||||
double CMatrix::rotation()
|
||||
{
|
||||
return m_internal->m_agg_mtx.rotation();
|
||||
}
|
||||
|
||||
void CMatrix::SetElements(const double& sx, const double& shy, const double& shx,
|
||||
const double& sy, const double& tx, const double& ty)
|
||||
{
|
||||
m_internal->m_agg_mtx.sx = sx;
|
||||
m_internal->m_agg_mtx.shy = shy;
|
||||
m_internal->m_agg_mtx.shx = shx;
|
||||
m_internal->m_agg_mtx.sy = sy;
|
||||
m_internal->m_agg_mtx.tx = tx;
|
||||
m_internal->m_agg_mtx.ty = ty;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(float* m) const
|
||||
{
|
||||
double M[6];
|
||||
m_internal->m_agg_mtx.store_to(M);
|
||||
|
||||
m[0] = static_cast<float>(M[0]);
|
||||
m[1] = static_cast<float>(M[1]);
|
||||
m[2] = static_cast<float>(M[2]);
|
||||
m[3] = static_cast<float>(M[3]);
|
||||
m[4] = static_cast<float>(M[4]);
|
||||
m[5] = static_cast<float>(M[5]);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(double* m) const
|
||||
{
|
||||
m_internal->m_agg_mtx.store_to(m);
|
||||
m_internal->m_agg_mtx.store_to(m);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CMatrix::Reset()
|
||||
{
|
||||
m_internal->m_agg_mtx.reset();
|
||||
m_internal->m_agg_mtx.reset();
|
||||
}
|
||||
|
||||
double CMatrix::Determinant() const
|
||||
bool CMatrix::IsIdentity(const double& eps) const
|
||||
{
|
||||
return m_internal->m_agg_mtx.determinant();
|
||||
}
|
||||
return m_internal->m_agg_mtx.is_identity(eps);
|
||||
}
|
||||
|
||||
const CMatrix& CMatrix::operator=(const CMatrix& Src)
|
||||
bool CMatrix::IsIdentity2(const double& eps) const
|
||||
{
|
||||
m_internal->m_agg_mtx = Src.m_internal->m_agg_mtx;
|
||||
return *this;
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
return agg::is_equal_eps(m.sx, 1.0, eps) &&
|
||||
agg::is_equal_eps(m.shy, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.shx, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.sy, 1.0, eps);
|
||||
}
|
||||
|
||||
bool CMatrix::IsEqual(const CMatrix* mm1, const CMatrix* mm2, const double& eps, bool bIsOnlyMain)
|
||||
{
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps;
|
||||
}
|
||||
|
||||
Status CMatrix::Invert()
|
||||
{
|
||||
double d = m_internal->m_agg_mtx.determinant();
|
||||
if (0.0001 >= fabs(d))
|
||||
double d = m_internal->m_agg_mtx.determinant();
|
||||
if (0.0001 >= fabs(d))
|
||||
return InvalidParameter;
|
||||
|
||||
m_internal->m_agg_mtx.invert();
|
||||
m_internal->m_agg_mtx.invert();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
//Temp
|
||||
//Used in X_BrushLinearGradient constructor
|
||||
double CMatrix::z_Rotation() const
|
||||
{
|
||||
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints( PointF* dst, const PointF* src, int count ) const
|
||||
double CMatrix::z_Rotation() const
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
|
||||
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
|
||||
|
||||
dst[i].X = (float)x;
|
||||
dst[i].Y = (float)y;
|
||||
}
|
||||
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
|
||||
}
|
||||
|
||||
bool CMatrix::IsIdentity(const double& eps) const
|
||||
const CMatrix& CMatrix::operator=(const CMatrix& other)
|
||||
{
|
||||
return m_internal->m_agg_mtx.is_identity(eps);
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx = other.m_internal->m_agg_mtx;
|
||||
return *this;
|
||||
}
|
||||
bool CMatrix::IsIdentity2(const double& eps) const
|
||||
|
||||
CMatrix& CMatrix::operator=(CMatrix&& other)
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
return agg::is_equal_eps(m.sx, 1.0, eps) &&
|
||||
agg::is_equal_eps(m.shy, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.shx, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.sy, 1.0, eps);
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_internal = other.m_internal;
|
||||
other.m_internal = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CMatrix::IsEqual(const CMatrix* mm1, const CMatrix* mm2, const double& eps, bool bIsOnlyMain)
|
||||
{
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,62 +37,62 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CMatrix_private;
|
||||
class GRAPHICS_DECL CMatrix
|
||||
{
|
||||
public:
|
||||
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
|
||||
CMatrix();
|
||||
CMatrix(const CMatrix& oSrc);
|
||||
class CMatrix_private;
|
||||
class GRAPHICS_DECL CMatrix
|
||||
{
|
||||
public:
|
||||
CMatrix();
|
||||
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
|
||||
CMatrix(const CMatrix& other);
|
||||
CMatrix(CMatrix&& other);
|
||||
~CMatrix();
|
||||
|
||||
~CMatrix();
|
||||
void Translate(double offsetX, double offsetY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Scale(double scaleX, double scaleY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Shear(double shearX, double shearY, MatrixOrder order = MatrixOrderPrepend);
|
||||
double Determinant() const;
|
||||
|
||||
void Translate(double offsetX, double offsetY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Scale(double scaleX, double scaleY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Shear(double shearX, double shearY, MatrixOrder order = MatrixOrderPrepend);
|
||||
double Determinant() const;
|
||||
void TransformVectors(PointF* pts, int count) const;
|
||||
void TransformPoints(PointF* pts, int count) const;
|
||||
void TransformPoint(double& x, double& y) const;
|
||||
void TransformPoints(PointF* dst, const PointF* src, int count) const;
|
||||
|
||||
void TransformVectors(PointF* pts, int count) const;
|
||||
void TransformPoints(PointF* pts, int count) const;
|
||||
void TransformPoint(double& x, double& y) const;
|
||||
void TransformPoints(PointF* dst, const PointF* src, int count) const;
|
||||
void Rotate(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, const PointF ¢er, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
|
||||
void Rotate(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, const PointF ¢er, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Multiply(const CMatrix* matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
|
||||
void Multiply(const CMatrix* matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
double OffsetX() const;
|
||||
double OffsetY() const;
|
||||
|
||||
double OffsetX() const;
|
||||
double OffsetY() const;
|
||||
double sx() const;
|
||||
double sy() const;
|
||||
double shx() const;
|
||||
double shy() const;
|
||||
double tx() const;
|
||||
double ty() const;
|
||||
double rotation();
|
||||
|
||||
double sx() const;
|
||||
double sy() const;
|
||||
double shx() const;
|
||||
double shy() const;
|
||||
double tx() const;
|
||||
double ty() const;
|
||||
double rotation();
|
||||
void SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx = 0, const double& ty = 0);
|
||||
void SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx = 0, const double& ty = 0);
|
||||
Status GetElements(float* m) const;
|
||||
Status GetElements(double* m) const;
|
||||
|
||||
Status GetElements(float* m) const;
|
||||
Status GetElements(double* m) const;
|
||||
void Reset();
|
||||
bool IsIdentity(const double& eps = 0.00001) const;
|
||||
bool IsIdentity2(const double& eps = 0.00001) const;
|
||||
|
||||
void Reset();
|
||||
bool IsIdentity(const double& eps = 0.00001) const;
|
||||
bool IsIdentity2(const double& eps = 0.00001) const;
|
||||
static bool IsEqual(const CMatrix* m1, const CMatrix* m2, const double& eps = 0.001, bool bIsOnlyMain = false);
|
||||
|
||||
static bool IsEqual(const CMatrix* m1, const CMatrix* m2, const double& eps = 0.001, bool bIsOnlyMain = false);
|
||||
Status Invert();
|
||||
|
||||
const CMatrix& operator=(const CMatrix& Src);
|
||||
double z_Rotation() const;
|
||||
|
||||
Status Invert();
|
||||
const CMatrix& operator=(const CMatrix& other);
|
||||
CMatrix& operator=(CMatrix&& other);
|
||||
|
||||
double z_Rotation() const;
|
||||
|
||||
public:
|
||||
CMatrix_private* m_internal;
|
||||
};
|
||||
public:
|
||||
CMatrix_private* m_internal;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_MATRIX_H_
|
||||
|
||||
@ -214,7 +214,6 @@ int CAnnotFieldInfo::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
{
|
||||
@ -360,8 +359,6 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
if (nFlags & (1 << 8))
|
||||
m_nCopyAP = pReader->ReadInt();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -689,7 +686,6 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetDV() { return m_wsDV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetT() { return m_wsT; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontName() { return m_wsFN; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontKey() { return m_wsFK; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetTC() { return m_arrTC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBC() { return m_arrBC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBG() { return m_arrBG; }
|
||||
@ -890,8 +886,6 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
m_nParentID = pReader->ReadInt();
|
||||
if (nFlags & (1 << 18))
|
||||
m_wsT = pReader->ReadString();
|
||||
if (nFlags & (1 << 20))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
@ -988,7 +982,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsV = pReader->ReadString();
|
||||
if (nFlags & (1 << 10))
|
||||
m_nMaxLen = pReader->ReadInt();
|
||||
if (nFlags & (1 << 11))
|
||||
if (nWidgetFlag & (1 << 25))
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
@ -1067,21 +1061,15 @@ CWidgetsInfo::~CWidgetsInfo()
|
||||
for (int i = 0; i < m_arrParents.size(); ++i)
|
||||
RELEASEOBJECT(m_arrParents[i]);
|
||||
}
|
||||
const std::vector< std::pair<int, int> >& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector<int>& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector<std::wstring>& CWidgetsInfo::GetButtonImg() { return m_arrButtonImg; }
|
||||
const std::vector<CWidgetsInfo::CParent*>& CWidgetsInfo::GetParents() { return m_arrParents; }
|
||||
void CWidgetsInfo::ChangeCO(int i, int nNum, int nGen)
|
||||
{
|
||||
if (i < 0 || i > m_arrCO.size() - 1)
|
||||
return;
|
||||
m_arrCO[i] = std::make_pair(nNum, nGen);
|
||||
}
|
||||
bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrCO.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrCO.push_back(std::make_pair(pReader->ReadInt(), -1));
|
||||
m_arrCO.push_back(pReader->ReadInt());
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrParents.reserve(n);
|
||||
@ -1113,36 +1101,6 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
if (nFlags & (1 << 6))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
std::wstring s2 = pReader->ReadString();
|
||||
pParent->arrOpt.push_back(std::make_pair(s1, s2));
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
pParent->nFieldFlag = pReader->ReadInt();
|
||||
if (nFlags & (1 << 8))
|
||||
{
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
for (int i = 0; i < nAction; ++i)
|
||||
{
|
||||
std::wstring wsType = pReader->ReadString();
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
|
||||
if (pA)
|
||||
{
|
||||
pA->wsType = wsType;
|
||||
pParent->arrAction.push_back(pA);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
pParent->nMaxLen = pReader->ReadInt();
|
||||
m_arrParents.push_back(pParent);
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +194,6 @@ public:
|
||||
const std::wstring& GetT();
|
||||
const std::wstring& GetFontName();
|
||||
const std::wstring& GetFontKey();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::vector<double>& GetTC();
|
||||
const std::vector<double>& GetBC();
|
||||
const std::vector<double>& GetBG();
|
||||
@ -224,7 +223,6 @@ public:
|
||||
std::wstring m_wsT;
|
||||
std::wstring m_wsFN;
|
||||
std::wstring m_wsFK;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::vector<double> m_arrTC;
|
||||
std::vector<double> m_arrBC;
|
||||
std::vector<double> m_arrBG;
|
||||
@ -465,7 +463,6 @@ public:
|
||||
int GetID() const;
|
||||
int GetAnnotFlag() const;
|
||||
int GetPage() const;
|
||||
int GetCopyAP() const;
|
||||
void GetBE(BYTE& nS, double& dI);
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
@ -523,7 +520,6 @@ private:
|
||||
int m_nID;
|
||||
int m_nAnnotFlag;
|
||||
int m_nPage;
|
||||
int m_nCopyAP;
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
@ -569,31 +565,25 @@ public:
|
||||
{
|
||||
int nID;
|
||||
int nFlags;
|
||||
int nMaxLen;
|
||||
int nParentID;
|
||||
int nFieldFlag;
|
||||
std::wstring sName;
|
||||
std::wstring sV;
|
||||
std::wstring sDV;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > arrOpt;
|
||||
};
|
||||
|
||||
CWidgetsInfo();
|
||||
virtual ~CWidgetsInfo();
|
||||
|
||||
const std::vector< std::pair<int, int> >& GetCO();
|
||||
const std::vector<int>& GetCO();
|
||||
const std::vector<std::wstring>& GetButtonImg();
|
||||
const std::vector<CParent*>& GetParents();
|
||||
|
||||
void ChangeCO(int i, int nNum, int nGen);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::vector< std::pair<int, int> > m_arrCO;
|
||||
std::vector<int> m_arrCO;
|
||||
std::vector<std::wstring> m_arrButtonImg;
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
@ -701,6 +701,7 @@ namespace NSFonts
|
||||
virtual void Initialize() = 0;
|
||||
virtual void SetOwnerCache(IFontsCache* pCache) = 0;
|
||||
virtual void CreateOwnerCache(const int& nCacheSize = -1);
|
||||
virtual void ClearOwnerCache() = 0;
|
||||
|
||||
virtual void AfterLoad() = 0;
|
||||
|
||||
|
||||
@ -110,11 +110,20 @@ namespace NSImages
|
||||
#ifndef GRAPHICS_DISABLE_METAFILE
|
||||
namespace MetaFile
|
||||
{
|
||||
const int c_lMetaWmf = 0x01;
|
||||
const int c_lMetaEmf = 0x02;
|
||||
const int c_lMetaSvg = 0x04;
|
||||
const int c_lMetaSvm = 0x05;
|
||||
/**
|
||||
* @brief Meta file extension constants
|
||||
*/
|
||||
const long c_lMetaWmf = 0x0001;
|
||||
const long c_lMetaEmf = 0x0002;
|
||||
const long c_lMetaSvg = 0x0004;
|
||||
const long c_lMetaSvm = 0x0005;
|
||||
|
||||
/**
|
||||
* @interface IMetaFile
|
||||
*
|
||||
* The interface provides various options for loading a metafile and saving it
|
||||
* in another format.
|
||||
*/
|
||||
class GRAPHICS_DECL IMetaFile : public NSBase::CBaseRefCounter
|
||||
{
|
||||
public:
|
||||
@ -124,23 +133,20 @@ namespace MetaFile
|
||||
virtual bool LoadFromFile(const wchar_t* wsFilePath) = 0;
|
||||
virtual bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize) = 0;
|
||||
virtual bool LoadFromString(const std::wstring& data) = 0;
|
||||
virtual bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight) = 0;
|
||||
virtual bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY,
|
||||
double dWidth, double dHeight, const wchar_t* wsXmlFilePath = NULL) = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void GetBounds(double* pdX, double* pdY, double* pdW, double* pdH) = 0;
|
||||
virtual int GetType() = 0;
|
||||
virtual void ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1) = 0;
|
||||
virtual void ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1, const wchar_t* wsXmlOutFile = NULL) = 0;
|
||||
virtual NSFonts::IFontManager* get_FontManager() = 0;
|
||||
|
||||
virtual std::wstring ConvertToSvg(unsigned int unWidth = 0, unsigned int unHeight = 0) = 0;
|
||||
virtual void SetTempDirectory(const std::wstring& dir) = 0;
|
||||
|
||||
//Для тестов
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
virtual void ConvertToXml(const wchar_t *wsFilePath) = 0;
|
||||
virtual void ConvertToXmlAndRaster(const wchar_t *wsXmlFilePath, const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1) = 0;
|
||||
virtual bool LoadFromXmlFile(const wchar_t* wsFilePath) = 0;
|
||||
virtual void ConvertToXml(const wchar_t *wsFilePath) = 0;
|
||||
virtual void ConvertToEmf(const wchar_t *wsFilePath) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
GRAPHICS_DECL IMetaFile* Create(NSFonts::IApplicationFonts *pAppFonts);
|
||||
|
||||
@ -7,7 +7,7 @@ import os
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
base.cmd_in_dir("./../../../../../core/Common/js", sys.executable, ["make.py", "./../../DesktopEditor/graphics/pro/js/drawingfile.json"])
|
||||
base.cmd_in_dir("./../../../../../core/Common/js", "make.py", ["./../../DesktopEditor/graphics/pro/js/drawingfile.json"])
|
||||
|
||||
src_dir = "./deploy/"
|
||||
dst_dir = "./../../../../../sdkjs/pdf/src/engine/"
|
||||
|
||||
@ -51,9 +51,6 @@
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -70,7 +67,6 @@
|
||||
"../../../../PdfFile/lib/goo", "../../../../PdfFile/lib/fofi", "../../../../PdfFile/lib/splash", "../../../../PdfFile/lib",
|
||||
"../../../raster/Jp2/openjpeg", "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2",
|
||||
"../../../../Common/3dParty/openssl/openssl/include",
|
||||
"../../../../Common/3dParty/openssl/build/linux_64/include",
|
||||
"../../../../DocxRenderer"
|
||||
],
|
||||
"define": [
|
||||
@ -90,7 +86,7 @@
|
||||
"NO_CONSOLE_IO", "USE_EXTERNAL_JPEG2000", "USE_JPIP", "OPJ_STATIC", "FONT_ENGINE_DISABLE_FILESYSTEM",
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
"USE_OPENSSL_HASH",
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM", "CRYPTOPP_DISABLE_ASM", "DISABLE_TYPE_MISMATCH"
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
@ -139,7 +135,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "./wasm/src/",
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "HTMLRendererText.cpp"]
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp", "HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
@ -147,7 +143,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp", "MetafileToRenderer.cpp", "MetafileToRendererReader.cpp"]
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../fontengine/",
|
||||
@ -159,16 +155,12 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
"files": ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/cryptopp/",
|
||||
"files": ["cryptlib.cpp", "cpu.cpp", "integer.cpp", "3way.cpp", "adler32.cpp", "algebra.cpp", "algparam.cpp", "allocate.cpp", "arc4.cpp", "aria.cpp", "aria_simd.cpp", "ariatab.cpp", "asn.cpp", "authenc.cpp", "base32.cpp", "base64.cpp", "basecode.cpp", "bfinit.cpp", "blake2.cpp", "blake2s_simd.cpp", "blake2b_simd.cpp", "blowfish.cpp", "blumshub.cpp", "camellia.cpp", "cast.cpp", "casts.cpp", "cbcmac.cpp", "ccm.cpp", "chacha.cpp", "chacha_simd.cpp", "chacha_avx.cpp", "chachapoly.cpp", "cham.cpp", "cham_simd.cpp", "channels.cpp", "cmac.cpp", "crc.cpp", "crc_simd.cpp", "darn.cpp", "default.cpp", "des.cpp", "dessp.cpp", "dh.cpp", "dh2.cpp", "dll.cpp", "donna_32.cpp", "donna_64.cpp", "donna_sse.cpp", "dsa.cpp", "eax.cpp", "ec2n.cpp", "ecp.cpp", "eccrypto.cpp", "eprecomp.cpp", "elgamal.cpp", "emsa2.cpp", "eprecomp.cpp", "esign.cpp", "files.cpp", "filters.cpp", "fips140.cpp", "gcm.cpp", "gcm_simd.cpp", "gf256.cpp", "gf2_32.cpp", "gf2n.cpp", "gf2n_simd.cpp", "gfpcrypt.cpp", "gost.cpp", "gzip.cpp", "hc128.cpp", "hc256.cpp", "hex.cpp", "hight.cpp", "hmac.cpp", "hrtimer.cpp", "ida.cpp", "idea.cpp", "iterhash.cpp", "kalyna.cpp", "md5.cpp", "randpool.cpp", "osrng.cpp", "rijndael.cpp", "modes.cpp", "misc.cpp", "rdtables.cpp", "sha.cpp", "mqueue.cpp", "queue.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../OfficeUtils/src/",
|
||||
"files": ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp", "zlib_addon.c"]
|
||||
@ -187,23 +179,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/",
|
||||
"files": ["PdfFile.cpp", "PdfReader.cpp", "PdfWriter.cpp", "PdfEditor.cpp", "OnlineOfficeBinToPdf.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcReader/",
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/Resources/",
|
||||
"files": ["BaseFonts.cpp", "CMapMemory/cmap_memory.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/lib/",
|
||||
"files": ["fofi/FoFiBase.cc", "fofi/FoFiEncodings.cc", "fofi/FoFiIdentifier.cc", "fofi/FoFiTrueType.cc", "fofi/FoFiType1.cc", "fofi/FoFiType1C.cc", "goo/FixedPoint.cc", "goo/gfile.cc", "goo/GHash.cc", "goo/GList.cc", "goo/gmem.cc", "goo/gmempp.cc", "goo/GString.cc", "goo/parseargs.c", "goo/Trace.cc", "splash/Splash.cc", "splash/SplashBitmap.cc", "splash/SplashClip.cc", "splash/SplashFont.cc", "splash/SplashFontEngine.cc", "splash/SplashFontFile.cc", "splash/SplashFontFileID.cc", "splash/SplashFTFont.cc", "splash/SplashFTFontEngine.cc", "splash/SplashFTFontFile.cc", "splash/SplashPath.cc", "splash/SplashPattern.cc", "splash/SplashScreen.cc", "splash/SplashState.cc", "splash/SplashXPath.cc", "splash/SplashXPathScanner.cc", "xpdf/AcroForm.cc", "xpdf/Annot.cc", "xpdf/Array.cc", "xpdf/BuiltinFont.cc", "xpdf/BuiltinFontTables.cc", "xpdf/Catalog.cc", "xpdf/CharCodeToUnicode.cc", "xpdf/CMap.cc", "xpdf/Decrypt.cc", "xpdf/Dict.cc", "xpdf/DisplayState.cc", "xpdf/Error.cc", "xpdf/FontEncodingTables.cc", "xpdf/Function.cc", "xpdf/Gfx.cc", "xpdf/GfxFont.cc", "xpdf/GfxState.cc", "xpdf/GlobalParams.cc", "xpdf/ImageOutputDev.cc", "xpdf/JArithmeticDecoder.cc", "xpdf/JBIG2Stream.cc", "xpdf/JPXStream.cc", "xpdf/Lexer.cc", "xpdf/Link.cc", "xpdf/NameToCharCode.cc", "xpdf/Object.cc", "xpdf/OptionalContent.cc", "xpdf/Outline.cc", "xpdf/OutputDev.cc", "xpdf/Page.cc", "xpdf/Parser.cc", "xpdf/PDF417Barcode.cc", "xpdf/PDFCore.cc", "xpdf/PDFDoc.cc", "xpdf/PDFDocEncoding.cc", "xpdf/PreScanOutputDev.cc", "xpdf/PSOutputDev.cc", "xpdf/PSTokenizer.cc", "xpdf/SecurityHandler.cc", "xpdf/ShadingImage.cc", "xpdf/SplashOutputDev.cc", "xpdf/Stream.cc", "xpdf/TextOutputDev.cc", "xpdf/TextString.cc", "xpdf/TileCache.cc", "xpdf/TileCompositor.cc", "xpdf/TileMap.cc", "xpdf/UnicodeMap.cc", "xpdf/UnicodeRemapping.cc", "xpdf/UnicodeTypeTable.cc", "xpdf/UTF8.cc", "xpdf/WebFont.cc", "xpdf/XFAScanner.cc", "xpdf/XRef.cc", "xpdf/Zoox.cc"]
|
||||
"files": ["SrcReader/Adaptors.cpp", "SrcReader/GfxClip.cpp", "SrcReader/RendererOutputDev.cpp", "SrcReader/JPXStream2.cpp", "SrcReader/PdfAnnot.cpp", "Resources/BaseFonts.cpp", "Resources/CMapMemory/cmap_memory.cpp", "lib/fofi/FofiBase.cc", "lib/fofi/FofiEncodings.cc", "lib/fofi/FofiIdentifier.cc", "lib/fofi/FofiTrueType.cc", "lib/fofi/FofiType1.cc", "lib/fofi/FofiType1C.cc", "lib/goo/FixedPoint.cc", "lib/goo/gfile.cc", "lib/goo/GHash.cc", "lib/goo/GList.cc", "lib/goo/gmem.cc", "lib/goo/gmempp.cc", "lib/goo/GString.cc", "lib/goo/parseargs.c", "lib/goo/Trace.cc", "lib/splash/Splash.cc", "lib/splash/SplashBitmap.cc", "lib/splash/SplashClip.cc", "lib/splash/SplashFont.cc", "lib/splash/SplashFontEngine.cc", "lib/splash/SplashFontFile.cc", "lib/splash/SplashFontFileID.cc", "lib/splash/SplashFTFont.cc", "lib/splash/SplashFTFontEngine.cc", "lib/splash/SplashFTFontFile.cc", "lib/splash/SplashPath.cc", "lib/splash/SplashPattern.cc", "lib/splash/SplashScreen.cc", "lib/splash/SplashState.cc", "lib/splash/SplashXPath.cc", "lib/splash/SplashXPathScanner.cc", "lib/xpdf/AcroForm.cc", "lib/xpdf/Annot.cc", "lib/xpdf/Array.cc", "lib/xpdf/BuiltinFont.cc", "lib/xpdf/BuiltinFontTables.cc", "lib/xpdf/Catalog.cc", "lib/xpdf/CharCodeToUnicode.cc", "lib/xpdf/CMap.cc", "lib/xpdf/Decrypt.cc", "lib/xpdf/Dict.cc", "lib/xpdf/DisplayState.cc", "lib/xpdf/Error.cc", "lib/xpdf/FontEncodingTables.cc", "lib/xpdf/Function.cc", "lib/xpdf/Gfx.cc", "lib/xpdf/GfxFont.cc", "lib/xpdf/GfxState.cc", "lib/xpdf/GlobalParams.cc", "lib/xpdf/ImageOutputDev.cc", "lib/xpdf/JArithmeticDecoder.cc", "lib/xpdf/JBIG2Stream.cc", "lib/xpdf/JPXStream.cc", "lib/xpdf/Lexer.cc", "lib/xpdf/Link.cc", "lib/xpdf/NameToCharCode.cc", "lib/xpdf/Object.cc", "lib/xpdf/OptionalContent.cc", "lib/xpdf/Outline.cc", "lib/xpdf/OutputDev.cc", "lib/xpdf/Page.cc", "lib/xpdf/Parser.cc", "lib/xpdf/PDF417Barcode.cc", "lib/xpdf/PDFCore.cc", "lib/xpdf/PDFDoc.cc", "lib/xpdf/PDFDocEncoding.cc", "lib/xpdf/PreScanOutputDev.cc", "lib/xpdf/PSOutputDev.cc", "lib/xpdf/PSTokenizer.cc", "lib/xpdf/SecurityHandler.cc", "lib/xpdf/ShadingImage.cc", "lib/xpdf/SplashOutputDev.cc", "lib/xpdf/Stream.cc", "lib/xpdf/TextOutputDev.cc", "lib/xpdf/TextString.cc", "lib/xpdf/TileCache.cc", "lib/xpdf/TileCompositor.cc", "lib/xpdf/TileMap.cc", "lib/xpdf/UnicodeMap.cc", "lib/xpdf/UnicodeRemapping.cc", "lib/xpdf/UnicodeTypeTable.cc", "lib/xpdf/UTF8.cc", "lib/xpdf/WebFont.cc", "lib/xpdf/XFAScanner.cc", "lib/xpdf/XRef.cc", "lib/xpdf/Zoox.cc", "PdfFile.cpp", "PdfReader.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2/",
|
||||
|
||||
@ -619,7 +619,10 @@ INCLUDEPATH += \
|
||||
$$PDF_ROOT_DIR/lib/splash \
|
||||
$$PDF_ROOT_DIR/lib
|
||||
|
||||
HEADERS += $$files($$PDF_ROOT_DIR/lib/*.h, true)
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/lib/aconf.h \
|
||||
$$$files($$PDF_ROOT_DIR/lib/*.h)
|
||||
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.c, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.cc, true)
|
||||
|
||||
@ -641,7 +644,9 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp
|
||||
|
||||
HEADERS +=\
|
||||
$$PDF_ROOT_DIR/Resources/Fontd050000l.h \
|
||||
@ -665,87 +670,9 @@ HEADERS +=\
|
||||
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
# PdfWriter
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Consts.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encodings.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Types.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ICCProfile.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp
|
||||
|
||||
# PdfFile
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/PdfFile.h \
|
||||
$$PDF_ROOT_DIR/PdfWriter.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h \
|
||||
$$PDF_ROOT_DIR/PdfReader.h \
|
||||
$$PDF_ROOT_DIR/PdfEditor.h \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp \
|
||||
$$PDF_ROOT_DIR/PdfWriter.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfEditor.cpp \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.cpp
|
||||
$$PDF_ROOT_DIR/PdfFile.h
|
||||
|
||||
# DocxRenderer
|
||||
DOCX_RENDERER_ROOT_DIR = $$CORE_ROOT_DIR/DocxRenderer
|
||||
@ -802,6 +729,7 @@ HEADERS += \
|
||||
../wasm/src/Text.h
|
||||
|
||||
SOURCES += \
|
||||
../wasm/src/pdfwriter.cpp \
|
||||
../wasm/src/HTMLRendererText.cpp \
|
||||
../wasm/src/drawingfile.cpp \
|
||||
../wasm/src/drawingfile_test.cpp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,19 +42,6 @@ CNativePointer.prototype.free = function()
|
||||
g_native_drawing_file["FreeWasmData"](this.ptr);
|
||||
this.ptr = null;
|
||||
};
|
||||
CNativePointer.prototype.getMemory = function(isCopy)
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
|
||||
if (!isCopy)
|
||||
return this.ptr;
|
||||
|
||||
let copyArray = new Uint8Array(this.ptr.length);
|
||||
copyArray.set(this.ptr);
|
||||
|
||||
return copyArray;
|
||||
};
|
||||
CNativePointer.prototype.getReader = function()
|
||||
{
|
||||
if (!this.ptr)
|
||||
@ -107,34 +94,6 @@ CFile.prototype._getError = function()
|
||||
return g_native_drawing_file["GetErrorCode"]();
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(pages, changes)
|
||||
{
|
||||
let dataChanges = null;
|
||||
if (changes)
|
||||
dataChanges = (undefined !== changes.byteLength) ? new Uint8Array(changes) : changes;
|
||||
g_module_pointer.ptr = g_native_drawing_file["SplitPages"](pages, dataChanges);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
if (!prefixForm)
|
||||
prefixForm = "";
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
return g_native_drawing_file["MergePages"](data, maxID, prefixForm);
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
return g_native_drawing_file["UnmergePages"]();
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user