mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
295 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ca53d3d035 | |||
| a4f271d7b0 | |||
| c99b304ec2 | |||
| db57d253d9 | |||
| b48909edaa | |||
| 1bfb055a50 | |||
| 149d3a2030 | |||
| 8bad09ea5a | |||
| 91656095fa | |||
| 9e89e48c07 | |||
| 1c5bd6cbab | |||
| 8ba7535fc8 | |||
| 038fa50194 | |||
| c94a294317 | |||
| d220685cff | |||
| edae000326 | |||
| 2cbc83b389 | |||
| d05afa3106 | |||
| de56349019 | |||
| 821f9cacd0 | |||
| 4f38f17bd1 | |||
| 9f4a145b48 | |||
| eaa0bbf047 | |||
| e78391c68b | |||
| 109a5fe2b4 | |||
| 36b7400e0e | |||
| 8318535aae | |||
| 21f5e09237 | |||
| de9c51a2db | |||
| f42079a55f | |||
| 5e0b5b6e34 | |||
| 9b87eba66b | |||
| 09f2db26e0 | |||
| aa038179cc | |||
| c09d5197b7 | |||
| c6f616d42e | |||
| dcc208257e | |||
| cc369ffbcb | |||
| 93018caf09 | |||
| d80d6c4168 | |||
| 5360487954 | |||
| cd73ab58b1 | |||
| 1119fd4307 | |||
| 0769a5ed3b | |||
| 82ad23840f | |||
| 5cb971d600 | |||
| c66cb32dde | |||
| ab62a3ebcf | |||
| 04d3e94dcc | |||
| 1c4462e2e9 | |||
| 91dc5b8582 | |||
| e9cf55f8db | |||
| 43fc84e6ef | |||
| 5a8bd3f8ce | |||
| 84dda72a13 | |||
| 5819c36cee | |||
| b5b9d948b9 | |||
| 72ac94412d | |||
| 4125e698d6 | |||
| 7c2a95202c | |||
| c3527ad8d4 | |||
| 9fe692b048 | |||
| df66cbbca9 | |||
| d877278d8d | |||
| 41a4edb223 | |||
| 0979902167 | |||
| 20618403b6 | |||
| 131efd2eaa | |||
| 8871c785dd | |||
| 8bbdb30419 | |||
| 15370bcbce | |||
| 48c9a001dd | |||
| 4c806b07a2 | |||
| 6a75bc62f0 | |||
| 6cb7e763d3 | |||
| 0d55fddd02 | |||
| 1dfb9bff3a | |||
| 4dd15a8e80 | |||
| bd60a20b91 | |||
| bd7914e7c7 | |||
| c7fa85602d | |||
| 809effa5df | |||
| 2f42eb6c42 | |||
| 641a505cf8 | |||
| f5f3d2572e | |||
| 68992278ce | |||
| 95476fc998 | |||
| fa5fa35a34 | |||
| c503044fc9 | |||
| 4bef318bd6 | |||
| 6546ae3fd9 | |||
| ac300f57a6 | |||
| c7a4edec03 | |||
| aaeb745ad3 | |||
| 0a85051119 | |||
| 85c60f172c | |||
| 7a9c57038e | |||
| 888f67dab2 | |||
| 87a9b92fea | |||
| 185be63b27 | |||
| 7cd7b03b89 | |||
| 3fe4c2ac21 | |||
| 776569ca81 | |||
| 7b264e940d | |||
| 160e99ab90 | |||
| 6988009971 | |||
| 66bed0e286 | |||
| 36aae7a6ab | |||
| 3f42678932 | |||
| 4bd0a53c9e | |||
| e9162eb230 | |||
| 44684c462e | |||
| 81be9c1c1f | |||
| c84f2a11d5 | |||
| 21451d83e4 | |||
| 21ec043636 | |||
| 83e6e5971c | |||
| aeb78a561e | |||
| 75c0dde6d2 | |||
| 2cb34822cd | |||
| e5c7a043be | |||
| b8cdfa9b36 | |||
| 7893197071 | |||
| f2bda6c81a | |||
| 3d2cb819d5 | |||
| ddb544ce34 | |||
| f441ec5c35 | |||
| d7a8c30461 | |||
| e8bb81b88e | |||
| fee4394d3f | |||
| 744d90e655 | |||
| 5692732901 | |||
| 1aaec18152 | |||
| 266425e817 | |||
| 5b8549db9d | |||
| 8f0a4ebfc9 | |||
| be5627ba60 | |||
| 34f36cefc3 | |||
| 7ceefa54cb | |||
| e4188148ba | |||
| a92bf23081 | |||
| 1d9230b731 | |||
| d2b5299b99 | |||
| 29c8e185ca | |||
| 723e4713fd | |||
| 7e235780fc | |||
| cfbed19648 | |||
| 0e09d4ab7a | |||
| eb37cabb4e | |||
| 4b611b304b | |||
| c5e6fb69c8 | |||
| af5feabdac | |||
| 716cbd42b2 | |||
| eebe3f321a | |||
| 925c40aa80 | |||
| b6741a504f | |||
| 3522897670 | |||
| 6973cb4c54 | |||
| fedf33e2c2 | |||
| a0c49966b9 | |||
| 58f4828563 | |||
| 9e52adeb53 | |||
| aed320e57a | |||
| 96a7e3ac36 | |||
| caa34c540a | |||
| b67ed51103 | |||
| cf91b46ea7 | |||
| 44d76014bf | |||
| dad19380a2 | |||
| 23410ccbf9 | |||
| ce129fe49d | |||
| ed0f4f9e5e | |||
| d8f9aab1ed | |||
| 37fc9784a7 | |||
| 7252d29579 | |||
| d257c68d5f | |||
| 051169b0f5 | |||
| 6a4ba5ec8d | |||
| 9390761867 | |||
| e100f594d7 | |||
| d620a53cd0 | |||
| df0528c69f | |||
| 49da36637d | |||
| 850fd21f09 | |||
| fdc374256a | |||
| ed12f6766d | |||
| 4e7ccd2506 | |||
| b7a335ef83 | |||
| 2d0bb82f41 | |||
| 005b790e14 | |||
| 2a5d7a78a3 | |||
| 16c77add4d | |||
| 684e83f0f3 | |||
| 16023ed916 | |||
| 561221102e | |||
| 71f164b029 | |||
| a438ae3d2e | |||
| 7edb3bd141 | |||
| 18b8e3ed7c | |||
| 52de014e14 | |||
| adea12d9f7 | |||
| 3a8601c354 | |||
| 86c994d0a0 | |||
| ba1597a8d5 | |||
| 84ecffa75e | |||
| d83cbfc031 | |||
| 7a3815bc5f | |||
| 08ae28224f | |||
| 4d23382c92 | |||
| e1274dadea | |||
| 4342c245c5 | |||
| 52602f902e | |||
| 56179f70bf | |||
| 9cde3dc699 | |||
| 8791f446b7 | |||
| bd838daa90 | |||
| 484d9342ac | |||
| e1c1ff3eb4 | |||
| d76dddeda6 | |||
| 1830a1103a | |||
| 631f498532 | |||
| 4957b61033 | |||
| 462556599f | |||
| a7551f69eb | |||
| 7a1c1be599 | |||
| 0796745158 | |||
| 06cc67a925 | |||
| 55cae3d38c | |||
| fc540fdf5f | |||
| 06a287dffe | |||
| 6e6ffbf604 | |||
| 3d58a8565a | |||
| 9ed356c103 | |||
| b20cdcd107 | |||
| 4d4a67b15a | |||
| cca89624c6 | |||
| 258890352a | |||
| 09567e225e | |||
| 62dbbc6d0d | |||
| 4085f58b09 | |||
| f5d2ff992a | |||
| f28dc0a36a | |||
| 79145ad0c7 | |||
| 54c0943754 | |||
| 49a40fa841 | |||
| f9662752f7 | |||
| 7eb0892ab9 | |||
| bb65d1a90b | |||
| 0136530b93 | |||
| edcd907749 | |||
| e1b13913ac | |||
| 9f3ab7cc29 | |||
| 229b263a9f | |||
| 9757220019 | |||
| 028157d2ef | |||
| bc0a582bf6 | |||
| 3428537113 | |||
| d09ab5ecfe | |||
| 8bc887142c | |||
| af4e0243d2 | |||
| 4de7ba4e52 | |||
| e7a7400801 | |||
| feeb471aad | |||
| 600d2a6ac5 | |||
| cd102c738f | |||
| 70be48fec3 | |||
| c60ff31fd4 | |||
| 7c1636a33e | |||
| 3ec3aa8575 | |||
| 3227b91a7c | |||
| 826d3fc678 | |||
| ec0ed4d2f0 | |||
| ed63f9cf29 | |||
| 7556d0859d | |||
| fff7f4e63f | |||
| 7e8e4586ca | |||
| 6411aed137 | |||
| 650a5c4c1f | |||
| 662f318d6b | |||
| 9352721ec4 | |||
| eb751507c0 | |||
| e2df5a8ab0 | |||
| d196a15a0e | |||
| 8a86347eb6 | |||
| d6675bb981 | |||
| eba03f9833 | |||
| e7a462fb60 | |||
| aeb657ef25 | |||
| a9b225782d | |||
| b46df522e9 | |||
| c2eb402ebf | |||
| dabedf6121 | |||
| dd02c9594b | |||
| 894f88e475 | |||
| ba46a97bde |
@ -4,6 +4,7 @@ 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
|
||||
|
||||
@ -84,7 +84,7 @@ public:
|
||||
|
||||
/* fonts */
|
||||
const char *fonts_paths[NUM_EXAMPLES] = {
|
||||
"C:/Windows/Fonts/arial.ttf",
|
||||
"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"
|
||||
@ -95,7 +95,7 @@ const char *num_glyph_types[NUM_GLYPH_TYPES] = {"UNCLASSIFIED", "BASE_GLYPH", "L
|
||||
|
||||
/* tranlations courtesy of google */
|
||||
const char *texts[NUM_EXAMPLES] = {
|
||||
"hello",
|
||||
"fi",
|
||||
"لا لآ لأ لا",
|
||||
"懶惰的姜貓"
|
||||
};
|
||||
@ -107,7 +107,7 @@ const hb_direction_t text_directions[NUM_EXAMPLES] = {
|
||||
};
|
||||
|
||||
const int text_skip[NUM_EXAMPLES] = {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
@ -435,6 +435,11 @@ static void print_layout_info_using_private_api(hb_blob_t *blob)
|
||||
/* 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");
|
||||
@ -499,28 +504,34 @@ int main(int argc, char *argv[])
|
||||
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_CHARACTERS);
|
||||
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
|
||||
#if 0
|
||||
#define userfeatures_count 4
|
||||
hb_feature_t userfeatures[userfeatures_count];
|
||||
hb_tag_t tags[] = {
|
||||
HB_TAG('l','i','g','a'),
|
||||
HB_TAG('c','l','i','g'),
|
||||
HB_TAG('d','l','i','g'),
|
||||
HB_TAG('h','l','i','g'),
|
||||
};
|
||||
for (int f = 0; f < userfeatures_count; f++)
|
||||
{
|
||||
userfeatures[f].tag = tags[f];
|
||||
userfeatures[f].value = 1;
|
||||
userfeatures[f].start = HB_FEATURE_GLOBAL_START;
|
||||
userfeatures[f].end = HB_FEATURE_GLOBAL_END;
|
||||
}
|
||||
#else
|
||||
#define userfeatures_count 0
|
||||
hb_feature_t *userfeatures = NULL;
|
||||
#endif
|
||||
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]));
|
||||
@ -531,7 +542,7 @@ int main(int argc, char *argv[])
|
||||
// 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, userfeatures_count);
|
||||
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);
|
||||
|
||||
@ -103,9 +103,11 @@ 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,6 +44,7 @@
|
||||
|
||||
#include "3dParty/pole/pole.h"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "OfficeFileFormatDefines.h"
|
||||
|
||||
@ -222,6 +223,16 @@ 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)
|
||||
@ -786,6 +797,13 @@ 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)
|
||||
@ -816,6 +834,10 @@ 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;
|
||||
@ -1150,6 +1172,10 @@ 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;
|
||||
@ -1660,6 +1686,8 @@ 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_SPREADSHEET_XLSX:
|
||||
return L".xlsx";
|
||||
@ -1691,6 +1719,8 @@ 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:
|
||||
@ -1732,12 +1762,15 @@ 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:
|
||||
@ -1826,6 +1859,8 @@ 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".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
@ -1865,6 +1900,8 @@ 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;
|
||||
@ -1899,6 +1936,8 @@ 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;
|
||||
@ -2001,3 +2040,26 @@ 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;
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@
|
||||
#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
|
||||
@ -138,12 +139,14 @@
|
||||
#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
|
||||
@ -151,4 +154,4 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTX AVS_OFFICESTUDIO_FILE_DRAW + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDM AVS_OFFICESTUDIO_FILE_DRAW + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSSM AVS_OFFICESTUDIO_FILE_DRAW + 0x0005
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
@ -109,6 +109,31 @@ 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): {
|
||||
@ -196,6 +221,10 @@ core_mac {
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-implicit-function-declaration
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
@ -416,6 +445,12 @@ 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
|
||||
@ -423,7 +458,11 @@ CONFIG += c++11
|
||||
|
||||
core_linux {
|
||||
core_static_link_libstd {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
!core_linux_clang {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
} else {
|
||||
# TODO: add libc++abi?
|
||||
}
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
|
||||
@ -319,7 +319,14 @@ 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,6 +110,9 @@ 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,6 +332,7 @@
|
||||
* 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)
|
||||
|
||||
@ -81,6 +81,8 @@ 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);
|
||||
|
||||
@ -57,7 +57,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
return m_pInternal->ExecuteCommand(command, retValue, false, false);
|
||||
}
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext(bool enterContext)
|
||||
|
||||
@ -16,18 +16,18 @@ static std::wstring wstringFromJavaString(JNIEnv* env, jstring jstr)
|
||||
return wstr;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilder());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
JNIEXPORT jint JNICALL 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 @@ jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self
|
||||
return (jint)pSelf->OpenFile(strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
JNIEXPORT jboolean JNICALL 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);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
JNIEXPORT jboolean JNICALL 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());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
JNIEXPORT void JNICALL 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());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
JNIEXPORT jint JNICALL 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());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
JNIEXPORT jint JNICALL 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 @@ jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
JNIEXPORT jint JNICALL 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 @@ jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls,
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
JNIEXPORT jint JNICALL 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 @@ jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, j
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
pSelf->CloseFile();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
JNIEXPORT jboolean JNICALL 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());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
JNIEXPORT jboolean JNICALL 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 @@ jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env,
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str(), pRetValue);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
JNIEXPORT jboolean JNICALL 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());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
JNIEXPORT jboolean JNICALL 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 @@ jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong s
|
||||
return result;
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
JNIEXPORT void JNICALL 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 @@ void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong s
|
||||
env->ReleaseStringUTFChars(param, strUtfParam);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
JNIEXPORT void JNICALL 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 @@ void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong sel
|
||||
pSelf->WriteData(strPath.c_str(), strData.c_str(), (bool)append);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->IsSaveWithDoctrendererMode();
|
||||
}
|
||||
|
||||
jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jstring JNICALL 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 @@ jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong
|
||||
return jstrVersion;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL 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()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
JNIEXPORT jlong JNICALL 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)));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
{
|
||||
std::wstring strDirectory = wstringFromJavaString(env, directory);
|
||||
CDocBuilder::Initialize(strDirectory.c_str());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Dispose();
|
||||
}
|
||||
|
||||
@ -4,60 +4,60 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContext* pOther = reinterpret_cast<CDocBuilderContext*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL 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()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL 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()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL 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()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
JNIEXPORT jlong JNICALL 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)));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL 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()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL 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()));
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL 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;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContextScope* pOther = reinterpret_cast<CDocBuilderContextScope*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL 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;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderValue* pOther = reinterpret_cast<CDocBuilderValue*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsEmpty();
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
pSelf->Clear();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsNull();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsUndefined();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsBool();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsInt();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsDouble();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsString();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsFunction();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsObject();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsArray();
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->GetLength();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->ToBool();
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->ToInt();
|
||||
}
|
||||
|
||||
jdouble Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jdouble JNICALL Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jdouble)pSelf->ToDouble();
|
||||
}
|
||||
|
||||
jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jstring JNICALL 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 @@ jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jl
|
||||
return env->NewStringUTF(strUtfData.c_str());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, j
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
JNIEXPORT jlong JNICALL 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);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
JNIEXPORT void JNICALL 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 @@ void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jl
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
JNIEXPORT void JNICALL 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);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((bool)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((int)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((double)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass c
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateUndefined()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateNull()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateArray((int)length)));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
JNIEXPORT jlong JNICALL 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 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5)
|
||||
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)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -263,7 +263,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
|
||||
@ -383,6 +383,20 @@ 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()))
|
||||
@ -423,6 +437,36 @@ 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
|
||||
@ -618,6 +662,8 @@ 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)
|
||||
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.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
document = api.GetDocument()
|
||||
paragraph1 = api.CreateParagraph()
|
||||
paragraph1.SetSpacingAfter(1000, False)
|
||||
paragraph1.AddText('Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
paragraph2 = api.CreateParagraph()
|
||||
paragraph2.AddText('Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
document.InsertContent(content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
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()
|
||||
@ -82,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContextSrc)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -92,6 +92,10 @@ 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();
|
||||
|
||||
|
||||
@ -1275,7 +1275,7 @@ namespace NSDoctRenderer
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false)
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false, const bool& isEnterContext = true)
|
||||
{
|
||||
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);
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
return m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -171,7 +171,6 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
@ -284,6 +283,24 @@ 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)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
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)
|
||||
{
|
||||
|
||||
@ -165,9 +165,14 @@ JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSVa
|
||||
JSSmart<CJSObject> pNativeObject = Native->toObject();
|
||||
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
|
||||
|
||||
if (m_pInternal->m_pAppImage)
|
||||
if (m_pInternal->m_pAppImage && pNativeEmbedObject)
|
||||
{
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
m_pInternal->m_pAppImage = NULL;
|
||||
}
|
||||
|
||||
if (NULL == m_pInternal->m_pAppImage)
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
|
||||
if (pNativeEmbedObject)
|
||||
{
|
||||
|
||||
@ -483,6 +483,12 @@ 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.
|
||||
|
||||
@ -439,6 +439,11 @@ namespace NSJSBase
|
||||
{
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class CJSLocalScopePrivate
|
||||
{
|
||||
public:
|
||||
|
||||
@ -255,6 +255,8 @@ 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()
|
||||
@ -271,6 +273,13 @@ 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()
|
||||
|
||||
@ -857,12 +857,14 @@ 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)
|
||||
|
||||
@ -214,6 +214,7 @@ 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)
|
||||
{
|
||||
@ -359,6 +360,8 @@ 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())
|
||||
{
|
||||
@ -686,6 +689,7 @@ 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; }
|
||||
@ -886,6 +890,8 @@ 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();
|
||||
@ -982,7 +988,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsV = pReader->ReadString();
|
||||
if (nFlags & (1 << 10))
|
||||
m_nMaxLen = pReader->ReadInt();
|
||||
if (nWidgetFlag & (1 << 25))
|
||||
if (nFlags & (1 << 11))
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
@ -1061,15 +1067,21 @@ CWidgetsInfo::~CWidgetsInfo()
|
||||
for (int i = 0; i < m_arrParents.size(); ++i)
|
||||
RELEASEOBJECT(m_arrParents[i]);
|
||||
}
|
||||
const std::vector<int>& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector< std::pair<int, 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(pReader->ReadInt());
|
||||
m_arrCO.push_back(std::make_pair(pReader->ReadInt(), -1));
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrParents.reserve(n);
|
||||
@ -1101,6 +1113,36 @@ 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,6 +194,7 @@ 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();
|
||||
@ -223,6 +224,7 @@ 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;
|
||||
@ -463,6 +465,7 @@ 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();
|
||||
@ -520,6 +523,7 @@ 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;
|
||||
@ -565,25 +569,31 @@ 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<int>& GetCO();
|
||||
const std::vector< std::pair<int, 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<int> m_arrCO;
|
||||
std::vector< std::pair<int, int> > m_arrCO;
|
||||
std::vector<std::wstring> m_arrButtonImg;
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -86,7 +89,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"
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM", "CRYPTOPP_DISABLE_ASM", "DISABLE_TYPE_MISMATCH"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
@ -135,7 +138,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "./wasm/src/",
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp", "HTMLRendererText.cpp"]
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
@ -143,7 +146,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"]
|
||||
"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"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../fontengine/",
|
||||
@ -155,12 +158,16 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.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"]
|
||||
@ -179,7 +186,23 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/",
|
||||
"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"]
|
||||
"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"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2/",
|
||||
|
||||
@ -619,10 +619,7 @@ INCLUDEPATH += \
|
||||
$$PDF_ROOT_DIR/lib/splash \
|
||||
$$PDF_ROOT_DIR/lib
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/lib/aconf.h \
|
||||
$$$files($$PDF_ROOT_DIR/lib/*.h)
|
||||
|
||||
HEADERS += $$files($$PDF_ROOT_DIR/lib/*.h, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.c, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.cc, true)
|
||||
|
||||
@ -644,9 +641,7 @@ 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/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
|
||||
HEADERS +=\
|
||||
$$PDF_ROOT_DIR/Resources/Fontd050000l.h \
|
||||
@ -670,9 +665,87 @@ 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 \
|
||||
$$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/PdfReader.h \
|
||||
$$PDF_ROOT_DIR/PdfFile.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
|
||||
|
||||
# DocxRenderer
|
||||
DOCX_RENDERER_ROOT_DIR = $$CORE_ROOT_DIR/DocxRenderer
|
||||
@ -729,7 +802,6 @@ 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
@ -94,6 +94,11 @@ CFile.prototype._getError = function()
|
||||
return g_native_drawing_file["GetErrorCode"]();
|
||||
};
|
||||
|
||||
CFile.prototype._addPDF = function(buffer, password)
|
||||
{
|
||||
return g_native_drawing_file["AddPDF"]();
|
||||
}
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -86,8 +86,9 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
let data = new Uint8Array(buffer);
|
||||
this.stream_size = data.length;
|
||||
this.stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, this.stream);
|
||||
let stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, stream);
|
||||
this.stream.push(stream);
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
@ -98,7 +99,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
this.nativeFile = Module["_Open"](this.stream, this.stream_size, passwordPtr);
|
||||
this.nativeFile = Module["_Open"](this.stream[0], this.stream_size, passwordPtr);
|
||||
|
||||
if (passwordPtr)
|
||||
Module["_free"](passwordPtr);
|
||||
@ -112,7 +113,7 @@ CFile.prototype._closeFile = function()
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
return Module["_GetType"](this.stream, this.stream_size);
|
||||
return Module["_GetType"](this.stream[0], this.stream_size);
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
@ -120,6 +121,70 @@ CFile.prototype._getError = function()
|
||||
return Module["_GetErrorCode"](this.nativeFile);
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(memoryBuffer, arrayBufferChanges)
|
||||
{
|
||||
let changesPtr = 0;
|
||||
let changesLen = 0;
|
||||
if (arrayBufferChanges)
|
||||
{
|
||||
let changes = new Uint8Array(arrayBufferChanges);
|
||||
changesLen = changes.length;
|
||||
changesPtr = Module["_malloc"](changesLen);
|
||||
Module["HEAP8"].set(changes, changesPtr);
|
||||
}
|
||||
|
||||
let pointer = Module["_malloc"](memoryBuffer.length * 4);
|
||||
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
|
||||
let ptr = Module["_SplitPages"](this.nativeFile, pointer, memoryBuffer.length, changesPtr, changesLen);
|
||||
Module["_free"](pointer);
|
||||
if (changesPtr)
|
||||
Module["_free"](changesPtr);
|
||||
return ptr;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
let stream2 = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, stream2);
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
|
||||
let prefixPtr = 0;
|
||||
if (prefixForm)
|
||||
{
|
||||
let prefixBuf = prefixForm.toUtf8();
|
||||
prefixPtr = Module["_malloc"](prefixBuf.length);
|
||||
Module["HEAP8"].set(prefixBuf, prefixPtr);
|
||||
}
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length, maxID, prefixPtr);
|
||||
if (bRes == 1)
|
||||
this.stream.push(stream2);
|
||||
else
|
||||
Module["_free"](stream2);
|
||||
|
||||
if (prefixPtr)
|
||||
Module["_free"](prefixPtr);
|
||||
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
let bRes = Module["_UnmergePages"](this.nativeFile);
|
||||
if (bRes == 1)
|
||||
{
|
||||
let str = this.stream.pop();
|
||||
Module["_free"](str);
|
||||
}
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -42,6 +42,12 @@ CBinaryReader.prototype.readByte = function()
|
||||
this.pos += 1;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readShort = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8;
|
||||
this.pos += 2;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readInt = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8 | this.data[this.pos + 2] << 16 | this.data[this.pos + 3] << 24;
|
||||
@ -56,6 +62,10 @@ CBinaryReader.prototype.readDouble2 = function()
|
||||
{
|
||||
return this.readInt() / 10000;
|
||||
};
|
||||
CBinaryReader.prototype.readDouble3 = function()
|
||||
{
|
||||
return this.readInt() / 100000;
|
||||
};
|
||||
CBinaryReader.prototype.readString = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
@ -63,9 +73,20 @@ CBinaryReader.prototype.readString = function()
|
||||
this.pos += len;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readString2 = function()
|
||||
{
|
||||
let len = this.readShort();
|
||||
let val = "";
|
||||
for (let i = 0; i < len; ++i)
|
||||
{
|
||||
let c = this.readShort();
|
||||
val += String.fromCharCode(c);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readData = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
let len = this.readInt() - 4;
|
||||
let val = this.data.slice(this.pos, this.pos + len);
|
||||
this.pos += len;
|
||||
return val;
|
||||
|
||||
@ -125,7 +125,7 @@ WASM_EXPORT BYTE* GetGlyphs(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetGlyphs(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetLinks (CDrawingFile* pFile, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetLinks(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetLinks(nPageIndex);
|
||||
}
|
||||
@ -177,6 +177,18 @@ WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
}
|
||||
WASM_EXPORT BYTE* SplitPages(CDrawingFile* pFile, int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
return pFile->SplitPages(arrPageIndex, nLength, data, size);
|
||||
}
|
||||
WASM_EXPORT int MergePages(CDrawingFile* pFile, BYTE* data, LONG size, int nMaxID, const char* sPrefixForm)
|
||||
{
|
||||
return pFile->MergePages(data, size, nMaxID, sPrefixForm) ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int UnmergePages(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UnmergePages() ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@ enum OfficeDrawingFileType
|
||||
odftPDF = 0,
|
||||
odftXPS = 1,
|
||||
odftDJVU = 2,
|
||||
odftOFD = 3,
|
||||
odftUndefined = 255
|
||||
};
|
||||
|
||||
|
||||
@ -19,6 +19,10 @@ core_linux {
|
||||
QMAKE_CXXFLAGS += -Wno-narrowing
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
}
|
||||
|
||||
core_mac {
|
||||
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ CImageFileFormatChecker::CImageFileFormatChecker()
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
}
|
||||
CImageFileFormatChecker::CImageFileFormatChecker(std::wstring sFileName)
|
||||
CImageFileFormatChecker::CImageFileFormatChecker(const std::wstring& sFileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
isImageFile(sFileName);
|
||||
@ -433,7 +433,7 @@ bool CImageFileFormatChecker::isPicFile(BYTE *pBuffer, DWORD dwBytes)
|
||||
return false;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CImageFileFormatChecker::isImageFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -673,7 +673,7 @@ bool CImageFileFormatChecker::isImageFile(BYTE* buffer, DWORD sizeRead)
|
||||
if (eFileType) return true;
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvmFile(std::wstring & fileName)
|
||||
bool CImageFileFormatChecker::isSvmFile(const std::wstring & fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -703,7 +703,7 @@ bool CImageFileFormatChecker::isSvmFile(std::wstring & fileName)
|
||||
if (eFileType)return true;
|
||||
else return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isPngFile(std::wstring & fileName)
|
||||
bool CImageFileFormatChecker::isPngFile(const std::wstring & fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -735,7 +735,7 @@ bool CImageFileFormatChecker::isPngFile(std::wstring & fileName)
|
||||
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isRawFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isRawFile(const std::wstring& fileName)
|
||||
{
|
||||
// TODO:
|
||||
return false;
|
||||
@ -745,7 +745,7 @@ bool CImageFileFormatChecker::isRawFile(BYTE* pBuffer, DWORD dwBytes)
|
||||
// TODO:
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvgFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isSvgFile(const std::wstring& fileName)
|
||||
{
|
||||
#ifndef IMAGE_CHECKER_DISABLE_XML
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
|
||||
@ -71,17 +71,17 @@ public:
|
||||
__ENUM_CXIMAGE_FORMATS eFileType;
|
||||
|
||||
CImageFileFormatChecker();
|
||||
CImageFileFormatChecker(std::wstring sFileName);
|
||||
CImageFileFormatChecker(const std::wstring& sFileName);
|
||||
CImageFileFormatChecker(BYTE* pBuffer, DWORD dwBytes);
|
||||
|
||||
bool isImageFileInZip(std::wstring& fileName);
|
||||
bool isImageFileInZip(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(std::wstring& fileName);
|
||||
bool isPngFile(std::wstring& fileName);
|
||||
bool isSvmFile(std::wstring& fileName);
|
||||
bool isImageFile(const std::wstring& fileName);
|
||||
bool isPngFile(const std::wstring& fileName);
|
||||
bool isSvmFile(const std::wstring& fileName);
|
||||
|
||||
bool isRawFile(std::wstring& fileName);
|
||||
bool isSvgFile(std::wstring& fileName);
|
||||
bool isRawFile(const std::wstring& fileName);
|
||||
bool isSvgFile(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isBmpFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include "../../../common/StringExt.h"
|
||||
|
||||
#ifndef BYTE
|
||||
|
||||
@ -85,6 +85,7 @@ namespace XmlUtils
|
||||
bool FromString (const wchar_t* sXml);
|
||||
bool FromString (const std::wstring& sXml);
|
||||
bool FromStringA(const std::string& sXml);
|
||||
bool FromStringA(const char* sXml, int size);
|
||||
|
||||
bool MoveToStart();
|
||||
|
||||
|
||||
@ -111,6 +111,10 @@ namespace XmlUtils
|
||||
{
|
||||
return m_pInternal->FromStringA(sXml);
|
||||
}
|
||||
bool CXmlLiteReader::FromStringA(const char* sXml, int size)
|
||||
{
|
||||
return m_pInternal->FromStringA(sXml, size);
|
||||
}
|
||||
bool CXmlLiteReader::MoveToStart()
|
||||
{
|
||||
return m_pInternal->MoveToStart();
|
||||
|
||||
@ -214,7 +214,15 @@ namespace XmlUtils
|
||||
|
||||
return true;
|
||||
}
|
||||
inline bool FromStringA(const char* sXml, int size)
|
||||
{
|
||||
m_lStreamLen = size;
|
||||
m_pStream = new BYTE[m_lStreamLen];
|
||||
memcpy(m_pStream, sXml, m_lStreamLen);
|
||||
reader = xmlReaderForMemory((char*)m_pStream, m_lStreamLen, NULL, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
inline bool MoveToStart()
|
||||
{
|
||||
if (NULL != reader)
|
||||
|
||||
@ -121,3 +121,15 @@ BYTE* CDjVuFile::GetLinks (int nPageIndex)
|
||||
return m_pImplementation->GetPageLinks(nPageIndex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned char* CDjVuFile::ConvertToPixels(
|
||||
int nPageIndex,
|
||||
int nRasterW, int nRasterH, bool bIsFlip,
|
||||
NSFonts::IFontManager* pFonts,
|
||||
int nBackgroundColor, bool bIsDarkMode,
|
||||
int nBackgroundOpacity)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->ConvertToPixels(nPageIndex, nRasterW, nRasterH, !bIsFlip);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -76,4 +76,11 @@ public:
|
||||
|
||||
virtual BYTE* GetStructure();
|
||||
virtual BYTE* GetLinks (int nPageIndex);
|
||||
|
||||
virtual unsigned char* ConvertToPixels(
|
||||
int nPageIndex,
|
||||
int nRasterW, int nRasterH, bool bIsFlip = false,
|
||||
NSFonts::IFontManager* pFonts = NULL,
|
||||
int nBackgroundColor = 0xFFFFFF, bool bIsDarkMode = false,
|
||||
int nBackgroundOpacity = 0xFF);
|
||||
};
|
||||
|
||||
@ -247,18 +247,11 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPag
|
||||
long lRendererType = c_nUnknownRenderer;
|
||||
pRenderer->get_Type(&lRendererType);
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (c_nPDFWriter == lRendererType)
|
||||
{
|
||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
||||
CreatePdfFrame(pRenderer, pPage, nPageIndex, oText);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
||||
CreateFrame(pRenderer, pPage, nPageIndex, oText);
|
||||
}
|
||||
XmlUtils::CXmlNode text;
|
||||
if (c_nPDFWriter == lRendererType || c_nHtmlRendrererText == lRendererType)
|
||||
text = ParseText(pPage);
|
||||
|
||||
CreateFrame(pRenderer, pPage, nPageIndex, text);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -463,9 +456,14 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
}
|
||||
|
||||
int nDpi = pPage->get_dpi();
|
||||
|
||||
double dPixToMM = 25.4;
|
||||
|
||||
if (c_nHtmlRendrererText == lRendererType && text.IsValid())
|
||||
{
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
return;
|
||||
}
|
||||
|
||||
double dRendDpiX = 0;
|
||||
double dRendDpiY = 0;
|
||||
|
||||
@ -491,150 +489,22 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
LONG lImageWidth = (LONG)(dRendDpiX * dRendWidth / dPixToMM);
|
||||
LONG lImageHeight = (LONG)(dRendDpiY * dRendHeight / dPixToMM);
|
||||
|
||||
BYTE* pBufferDst = new BYTE[4 * lImageHeight * lImageWidth];
|
||||
BYTE* pBufferDst = this->ConvertToPixels(pPage, lImageWidth, lImageHeight, false);
|
||||
|
||||
if (!pBufferDst)
|
||||
return;
|
||||
|
||||
bool bIsInit = false;
|
||||
|
||||
Aggplus::CImage oImage;
|
||||
oImage.Create(pBufferDst, lImageWidth, lImageHeight, 4 * lImageWidth);
|
||||
if (pPage->is_legal_photo() || pPage->is_legal_compound())
|
||||
{
|
||||
bIsInit = true;
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
|
||||
BYTE* pBuffer = pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
GPixel* pLine = pImage->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, pBuffer += 4, ++pLine)
|
||||
{
|
||||
pBuffer[0] = pLine->b;
|
||||
pBuffer[1] = pLine->g;
|
||||
pBuffer[2] = pLine->r;
|
||||
pBuffer[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pPage->is_legal_bilevel())
|
||||
{
|
||||
bIsInit = true;
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
int decrement = color / (nPaletteEntries - 1);
|
||||
for (int i = 0; i < nPaletteEntries; ++i)
|
||||
{
|
||||
BYTE level = (BYTE)(color >> 16);
|
||||
palette[i] = (0xFF000000 | level << 16 | level << 8 | level);
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, ++pBuffer, ++pLine)
|
||||
{
|
||||
if (*pLine < nPaletteEntries)
|
||||
{
|
||||
*pBuffer = palette[*pLine];
|
||||
}
|
||||
else
|
||||
{
|
||||
*pBuffer = palette[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
// белый фрейм??
|
||||
//memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight);
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
|
||||
if (NULL != pImage)
|
||||
{
|
||||
bIsInit = true;
|
||||
BYTE* pBuffer = pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
GPixel* pLine = pImage->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, pBuffer += 4, ++pLine)
|
||||
{
|
||||
pBuffer[0] = pLine->b;
|
||||
pBuffer[1] = pLine->g;
|
||||
pBuffer[2] = pLine->r;
|
||||
pBuffer[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
|
||||
if (NULL != pBitmap)
|
||||
{
|
||||
bIsInit = true;
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
int decrement = color / (nPaletteEntries - 1);
|
||||
for (int i = 0; i < nPaletteEntries; ++i)
|
||||
{
|
||||
BYTE level = (BYTE)(color >> 16);
|
||||
palette[i] = (0xFF000000 | level << 16 | level << 8 | level);
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, ++pBuffer, ++pLine)
|
||||
{
|
||||
if (*pLine < nPaletteEntries)
|
||||
{
|
||||
*pBuffer = palette[*pLine];
|
||||
}
|
||||
else
|
||||
{
|
||||
*pBuffer = palette[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(palette);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pRenderer->BeginCommand(c_nPageType);
|
||||
|
||||
if (c_nGrRenderer != lRendererType && c_nHtmlRendrerer != lRendererType && c_nHtmlRendrerer2 != lRendererType)
|
||||
if (text.IsValid())
|
||||
{
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
}
|
||||
|
||||
if (bIsInit)
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
pRenderer->EndCommand(c_nPageType);
|
||||
}
|
||||
void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pPage, int nPageIndex, XmlUtils::CXmlNode& oText)
|
||||
@ -849,6 +719,104 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>
|
||||
pRenderer->EndCommand(c_nPageType);
|
||||
}
|
||||
|
||||
unsigned char* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip)
|
||||
{
|
||||
try
|
||||
{
|
||||
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||
//pPage->wait_for_complete_decode();
|
||||
pPage->set_rotate(0);
|
||||
return ConvertToPixels(pPage, nRasterW, nRasterH, bIsFlip);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned char* CDjVuFileImplementation::ConvertToPixels(GP<DjVuImage>& pPage, int nImageW, int nImageH, bool bFlip)
|
||||
{
|
||||
BYTE* pBufferDst = NULL;
|
||||
|
||||
auto processPixmap = [&](GP<GPixmap> pImage, bool bFlip = false)
|
||||
{
|
||||
pBufferDst = new BYTE[4 * nImageW * nImageH];
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = 0; j < nImageH; ++j)
|
||||
{
|
||||
int nRow = bFlip ? j : (nImageH - 1 - j);
|
||||
GPixel* pLine = pImage->operator[](nRow);
|
||||
for (int i = 0; i < nImageW; ++i)
|
||||
{
|
||||
*pBuffer++ = 0xFF000000 | pLine->r << 16 | pLine->g << 8 | pLine->b;
|
||||
++pLine;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto processBitmap = [&](GP<GBitmap> pBitmap, bool bFlip = false)
|
||||
{
|
||||
pBufferDst = new BYTE[4 * nImageW * nImageH];
|
||||
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
int color = 0xFF0000;
|
||||
int decrement = color / (nPaletteEntries - 1);
|
||||
for (int i = 0; i < nPaletteEntries; ++i)
|
||||
{
|
||||
BYTE level = (BYTE)(color >> 16);
|
||||
palette[i] = (0xFF000000 | level << 16 | level << 8 | level);
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = 0; j < nImageH; ++j)
|
||||
{
|
||||
int nRow = bFlip ? j : (nImageH - 1 - j);
|
||||
BYTE* pLine = pBitmap->operator[](nRow);
|
||||
for (int i = 0; i < nImageW; ++i)
|
||||
{
|
||||
*pBuffer++ = palette[*pLine < nPaletteEntries ? *pLine : 0];
|
||||
++pLine;
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(palette);
|
||||
};
|
||||
|
||||
GRect oRectAll(0, 0, nImageW, nImageH);
|
||||
|
||||
if (pPage->is_legal_photo() || pPage->is_legal_compound())
|
||||
{
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
processPixmap(pImage, bFlip);
|
||||
}
|
||||
else if (pPage->is_legal_bilevel())
|
||||
{
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
processBitmap(pBitmap, bFlip);
|
||||
}
|
||||
else
|
||||
{
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
if (pImage)
|
||||
{
|
||||
processPixmap(pImage, bFlip);
|
||||
}
|
||||
else
|
||||
{
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
if (pBitmap)
|
||||
{
|
||||
processBitmap(pBitmap, bFlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pBufferDst;
|
||||
}
|
||||
|
||||
XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
|
||||
{
|
||||
XmlUtils::CXmlNode paragraph;
|
||||
|
||||
@ -79,8 +79,12 @@ public:
|
||||
BYTE* GetPageGlyphs(int nPageIndex);
|
||||
BYTE* GetPageLinks (int nPageIndex);
|
||||
|
||||
unsigned char* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip = false);
|
||||
|
||||
private:
|
||||
|
||||
unsigned char* ConvertToPixels(GP<DjVuImage>& pPage, int nRasterW, int nRasterH, bool bIsFlip = false);
|
||||
|
||||
void CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
||||
void CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
||||
XmlUtils::CXmlNode ParseText(GP<DjVuImage> pPage);
|
||||
|
||||
@ -1943,15 +1943,15 @@ void DjVuDocument::ReadPageInfo(int nPage, int& width, int& height, int& nDpi)
|
||||
bHasIW44 = true;
|
||||
|
||||
// Get image dimensions and resolution from bitmap chunk
|
||||
UINT serial = chunk_stream->read8();
|
||||
UINT slices = chunk_stream->read8();
|
||||
UINT major = chunk_stream->read8();
|
||||
UINT minor = chunk_stream->read8();
|
||||
unsigned int serial = chunk_stream->read8();
|
||||
unsigned int slices = chunk_stream->read8();
|
||||
unsigned int major = chunk_stream->read8();
|
||||
unsigned int minor = chunk_stream->read8();
|
||||
|
||||
UINT xhi = chunk_stream->read8();
|
||||
UINT xlo = chunk_stream->read8();
|
||||
UINT yhi = chunk_stream->read8();
|
||||
UINT ylo = chunk_stream->read8();
|
||||
unsigned int xhi = chunk_stream->read8();
|
||||
unsigned int xlo = chunk_stream->read8();
|
||||
unsigned int yhi = chunk_stream->read8();
|
||||
unsigned int ylo = chunk_stream->read8();
|
||||
|
||||
width = (xhi << 8) | xlo;
|
||||
height = (yhi << 8) | ylo;
|
||||
|
||||
@ -16,7 +16,9 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics)
|
||||
|
||||
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY \
|
||||
CRYPTOPP_DISABLE_ASM
|
||||
|
||||
|
||||
SOURCES += \
|
||||
HWPFile.cpp \
|
||||
|
||||
@ -780,20 +780,5 @@ bool isColumn(const std::wstring& columnName, _UINT32 listIndex, _UINT16& indexC
|
||||
}
|
||||
return false;
|
||||
}
|
||||
unsigned int getColumnsCount(_UINT32 listIndex)
|
||||
{
|
||||
auto arrColumn = XLS::GlobalWorkbookInfo::mapTableColumnNames_static.find(listIndex);
|
||||
if(arrColumn != XLS::GlobalWorkbookInfo::mapTableColumnNames_static.end())
|
||||
{
|
||||
auto counter = 0;
|
||||
for(auto i:arrColumn->second)
|
||||
{
|
||||
if(!i.empty())
|
||||
counter++;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} //namespace XMLSTUFF
|
||||
|
||||
|
||||
@ -87,15 +87,13 @@ namespace STR
|
||||
};
|
||||
|
||||
namespace XMLSTUFF
|
||||
{;
|
||||
|
||||
{
|
||||
const std::wstring name2sheet_name(std::wstring name, const std::wstring prefix);
|
||||
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix = L"");
|
||||
unsigned short sheetsnames2ixti(std::wstring name);
|
||||
unsigned int definenames2index(std::wstring name);
|
||||
bool isTableFmla(const std::wstring& tableName, _UINT32& listIndex);
|
||||
bool isColumn(const std::wstring& columnName, _UINT32 listIndex, _UINT16& indexColumn);
|
||||
unsigned int getColumnsCount(_UINT32 listIndex);
|
||||
unsigned short AddMultysheetXti(const std::wstring& name, const _INT32& firstIxti, const _INT32& secondIxti);
|
||||
unsigned int AddDefinedName(const std::wstring& name);
|
||||
}
|
||||
|
||||
@ -61,12 +61,12 @@ namespace XLS
|
||||
|
||||
static const ElementType type = typeXF;
|
||||
|
||||
_UINT16 font_index;
|
||||
_UINT16 font_index = 0;
|
||||
|
||||
_UINT16 ifmt; //used
|
||||
std::wstring format_code;
|
||||
_UINT16 ifmt = 0; //used
|
||||
std::wstring format_code = L"";
|
||||
|
||||
_UINT16 ixfParent;
|
||||
_UINT16 ixfParent = 0;
|
||||
|
||||
bool fLocked = false;
|
||||
bool fHidden = false;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2021
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -71,10 +71,9 @@ namespace XLSB
|
||||
|
||||
void FRTSqref::save(XLS::CFRecord& record)
|
||||
{
|
||||
_UINT32 flags = 0;
|
||||
_UINT32 flags = 2;
|
||||
|
||||
SETBIT(flags, 0, fAdjDelete)
|
||||
SETBIT(flags, 1, fDoAdjust)
|
||||
SETBIT(flags, 2, fAdjChange)
|
||||
SETBIT(flags, 3, fEdit)
|
||||
|
||||
|
||||
@ -531,8 +531,8 @@ Ftab_Cetab::ValuesDetermination::ValuesDetermination()
|
||||
params_fixed.insert(ParamsFixed(0x01E0, 2, L"IFERROR"));
|
||||
params_fixed.insert(ParamsFixed(0x01E1, -1, L"COUNTIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E2, 3, L"SUMIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E3, 2, L"AVERAGEIF"));
|
||||
params_fixed.insert(ParamsFixed(0x01E4, 3, L"AVERAGEIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E3, -1, L"AVERAGEIF"));
|
||||
params_fixed.insert(ParamsFixed(0x01E4, -1, L"AVERAGEIFS"));
|
||||
|
||||
// Cetab values
|
||||
params_fixed.insert(ParamsFixed(0x8000, -1, L"BEEP"));
|
||||
|
||||
@ -82,6 +82,7 @@ OfficeArtRecordPtr OfficeArtContainer::CreateOfficeArt(unsigned short type)
|
||||
case FSP:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtFSP); break;
|
||||
case FOPT:
|
||||
case SecondaryFOPT:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtFOPT); break;
|
||||
case ChildAnchor:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtChildAnchor); break;
|
||||
@ -116,8 +117,6 @@ OfficeArtRecordPtr OfficeArtContainer::CreateOfficeArt(unsigned short type)
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtBStoreContainer); break;
|
||||
case TertiaryFOPT:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtTertiaryFOPT); break;
|
||||
case SecondaryFOPT:
|
||||
|
||||
case FPSPL:
|
||||
case FDGSL:
|
||||
case FBSE:
|
||||
|
||||
@ -617,21 +617,11 @@ const bool SyntaxPtg::extract_PtgList(std::wstring::const_iterator& first, std::
|
||||
}
|
||||
else if (boost::regex_search(first, last, results_1, reg_inside_table6))
|
||||
{
|
||||
auto colCount = XMLSTUFF::getColumnsCount(indexTable);
|
||||
if(colCount>1)
|
||||
{
|
||||
ptgList.columns = 0x02;
|
||||
ptgList.colFirst = 0;
|
||||
ptgList.colLast = colCount-1;
|
||||
first = results_1[0].second;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptgList.columns = 0x01;
|
||||
ptgList.colFirst = 0;
|
||||
ptgList.colLast = 0;
|
||||
first = results_1[0].second;
|
||||
}
|
||||
ptgList.columns = 0;
|
||||
ptgList.colFirst = 0;
|
||||
ptgList.colLast = 0;
|
||||
ptgList.rowType = 0x00;
|
||||
first = results_1[0].second;
|
||||
return true;
|
||||
}
|
||||
else if(boost::regex_search(first, last, results_1, reg_inside_table4))
|
||||
|
||||
147
OFDFile/OFDFile.cpp
Normal file
147
OFDFile/OFDFile.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#include "OFDFile.h"
|
||||
#include "src/OFDFile_Private.h"
|
||||
|
||||
#ifndef DISABLE_PDF_CONVERTATION
|
||||
#include "../PdfFile/PdfFile.h"
|
||||
#endif
|
||||
|
||||
COFDFile::COFDFile(NSFonts::IApplicationFonts* pFonts)
|
||||
: m_pInternal(new COFDFile_Private(pFonts))
|
||||
{}
|
||||
|
||||
COFDFile::~COFDFile()
|
||||
{
|
||||
COFDFile::Close();
|
||||
|
||||
if (nullptr != m_pInternal)
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
bool COFDFile::LoadFromFile(const std::wstring& file, const std::wstring& options, const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return false;
|
||||
|
||||
Close();
|
||||
|
||||
return m_pInternal->LoadFromFile(file);
|
||||
}
|
||||
|
||||
bool COFDFile::LoadFromMemory(unsigned char* data, unsigned long length, const std::wstring& options, const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return false;
|
||||
|
||||
Close();
|
||||
|
||||
return m_pInternal->LoadFromMemory(data, length);
|
||||
}
|
||||
|
||||
void COFDFile::Close()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
m_pInternal->Close();
|
||||
}
|
||||
|
||||
NSFonts::IApplicationFonts* COFDFile::GetFonts()
|
||||
{
|
||||
return (nullptr != m_pInternal) ? m_pInternal->GetFonts() : nullptr;
|
||||
}
|
||||
|
||||
OfficeDrawingFileType COFDFile::GetType()
|
||||
{
|
||||
return odftOFD;
|
||||
}
|
||||
|
||||
std::wstring COFDFile::GetTempDirectory()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
return m_pInternal->GetTempDir();
|
||||
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
void COFDFile::SetTempDirectory(const std::wstring& directory)
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
m_pInternal->SetTempDir(directory);
|
||||
}
|
||||
|
||||
int COFDFile::GetPagesCount()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
return m_pInternal->GetPageCount();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void COFDFile::GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return;
|
||||
|
||||
m_pInternal->GetPageSize(nPageIndex, *pdWidth, *pdHeight);
|
||||
|
||||
*pdDpiX = 25.4;
|
||||
*pdDpiY = 25.4;
|
||||
}
|
||||
|
||||
void COFDFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak, COfficeDrawingPageParams* pParams)
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == m_pInternal)
|
||||
return;
|
||||
|
||||
m_pInternal->DrawPage(pRenderer, nPageIndex);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_PDF_CONVERTATION
|
||||
void COFDFile::ConvertToPdf(const std::wstring& wsDstPath)
|
||||
{
|
||||
CPdfFile oPdf(GetFonts());
|
||||
oPdf.CreatePdf();
|
||||
bool bBreak = false;
|
||||
|
||||
int nPagesCount = GetPagesCount();
|
||||
for (int nPageIndex = 0; nPageIndex < nPagesCount; nPageIndex++)
|
||||
{
|
||||
oPdf.NewPage();
|
||||
oPdf.BeginCommand(c_nPageType);
|
||||
|
||||
double dPageDpiX = 96., dPageDpiY = 96.;
|
||||
double dWidth = 0., dHeight = 0.;
|
||||
|
||||
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
|
||||
dWidth *= 25.4 / dPageDpiX;
|
||||
dHeight *= 25.4 / dPageDpiY;
|
||||
|
||||
oPdf.put_Width(dWidth);
|
||||
oPdf.put_Height(dHeight);
|
||||
|
||||
DrawPageOnRenderer(&oPdf, nPageIndex, &bBreak);
|
||||
|
||||
oPdf.EndCommand(c_nPageType);
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("page %d / %d\n", nPageIndex + 1, nPagesCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
oPdf.SaveToFile(wsDstPath);
|
||||
}
|
||||
|
||||
std::wstring COFDFile::GetInfo()
|
||||
{
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
unsigned char* COFDFile::GetStructure()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned char* COFDFile::GetLinks(int nPageIndex)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
56
OFDFile/OFDFile.h
Normal file
56
OFDFile/OFDFile.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef OFDFILE_H
|
||||
#define OFDFILE_H
|
||||
|
||||
#ifndef OFD_USE_DYNAMIC_LIBRARY
|
||||
#define OFD_DECL_EXPORT
|
||||
#else
|
||||
#include "../DesktopEditor/common/base_export.h"
|
||||
#define OFD_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
#include "../DesktopEditor/graphics/pro/officedrawingfile.h"
|
||||
#include "../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
class COFDFile_Private;
|
||||
class OFD_DECL_EXPORT COFDFile : public IOfficeDrawingFile
|
||||
{
|
||||
COFDFile_Private* m_pInternal;
|
||||
public:
|
||||
COFDFile(NSFonts::IApplicationFonts* pFonts);
|
||||
virtual ~COFDFile();
|
||||
|
||||
// Open
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") override;
|
||||
virtual bool LoadFromMemory(unsigned char* data, unsigned long length, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") override;
|
||||
|
||||
// Close
|
||||
void Close() override;
|
||||
|
||||
// Get IApplicationFonts for wrappers
|
||||
virtual NSFonts::IApplicationFonts* GetFonts() override;
|
||||
|
||||
// Type
|
||||
virtual OfficeDrawingFileType GetType() override;
|
||||
|
||||
// Temp directory
|
||||
virtual std::wstring GetTempDirectory() override;
|
||||
virtual void SetTempDirectory(const std::wstring& directory) override;
|
||||
|
||||
// Pages info/draw
|
||||
virtual int GetPagesCount() override;
|
||||
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) override;
|
||||
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak, COfficeDrawingPageParams* pParams = NULL) override;
|
||||
|
||||
#ifndef DISABLE_PDF_CONVERTATION
|
||||
void ConvertToPdf(const std::wstring& wsDstPath);
|
||||
#endif
|
||||
|
||||
// Common methods for viewer
|
||||
virtual std::wstring GetInfo() override;
|
||||
virtual unsigned char* GetStructure() override;
|
||||
virtual unsigned char* GetLinks(int nPageIndex) override;
|
||||
};
|
||||
|
||||
#endif // OFDFILE_H
|
||||
86
OFDFile/OFDFile.pro
Normal file
86
OFDFile/OFDFile.pro
Normal file
@ -0,0 +1,86 @@
|
||||
QT -= core gui
|
||||
|
||||
VERSION = 1.0.0.1
|
||||
TARGET = OFDFile
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
|
||||
|
||||
DEFINES += OFD_USE_DYNAMIC_LIBRARY
|
||||
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, PdfFile)
|
||||
|
||||
core_windows {
|
||||
LIBS += -lgdi32 \
|
||||
-ladvapi32 \
|
||||
-luser32 \
|
||||
-lshell32
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include/freetype
|
||||
|
||||
HEADERS += \
|
||||
OFDFile.h \
|
||||
src/Content/ImageObject.h \
|
||||
src/Content/PageBlock.h \
|
||||
src/Content/PathObject.h \
|
||||
src/IOFDElement.h \
|
||||
src/OFDFile_Private.h \
|
||||
src/Base.h \
|
||||
src/Content/Content.h \
|
||||
src/Content/GraphicUnit.h \
|
||||
src/Content/IPageBlock.h \
|
||||
src/Content/Layer.h \
|
||||
src/Content/TextObject.h \
|
||||
src/Document.h \
|
||||
src/Page.h \
|
||||
src/Res.h \
|
||||
src/Types/Color.h \
|
||||
src/Types/ColorSpace.h \
|
||||
src/Types/CommonData.h \
|
||||
src/Types/CompositeGraphicUnit.h \
|
||||
src/Types/DrawParam.h \
|
||||
src/Types/Font.h \
|
||||
src/Types/MultiMedia.h \
|
||||
src/Types/PageArea.h \
|
||||
src/Types/Signature.h \
|
||||
src/Types/TemplatePage.h \
|
||||
src/Utils/Types.h \
|
||||
src/Utils/Utils.h \
|
||||
src/Utils/XmlReader.h
|
||||
|
||||
SOURCES += \
|
||||
OFDFile.cpp \
|
||||
src/Content/ImageObject.cpp \
|
||||
src/Content/PageBlock.cpp \
|
||||
src/Content/PathObject.cpp \
|
||||
src/OFDFile_Private.cpp \
|
||||
src/Base.cpp \
|
||||
src/Content/Content.cpp \
|
||||
src/Content/GraphicUnit.cpp \
|
||||
src/Content/Layer.cpp \
|
||||
src/Content/TextObject.cpp \
|
||||
src/Document.cpp \
|
||||
src/Page.cpp \
|
||||
src/Res.cpp \
|
||||
src/Types/Color.cpp \
|
||||
src/Types/ColorSpace.cpp \
|
||||
src/Types/CommonData.cpp \
|
||||
src/Types/CompositeGraphicUnit.cpp \
|
||||
src/Types/DrawParam.cpp \
|
||||
src/Types/Font.cpp \
|
||||
src/Types/MultiMedia.cpp \
|
||||
src/Types/PageArea.cpp \
|
||||
src/Types/Signature.cpp \
|
||||
src/Types/TemplatePage.cpp \
|
||||
src/Utils/Types.cpp \
|
||||
src/Utils/XmlReader.cpp
|
||||
213
OFDFile/src/Base.cpp
Normal file
213
OFDFile/src/Base.cpp
Normal file
@ -0,0 +1,213 @@
|
||||
#include "Base.h"
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
#define IF_CHECK_NODE(node_name, varible_name)\
|
||||
if (node_name == sNodeName)\
|
||||
varible_name = oLiteReader.GetText2()
|
||||
|
||||
#define ELSE_IF_CHECK_NODE(node_name, varible_name)\
|
||||
else if (node_name == sNodeName)\
|
||||
varible_name = oLiteReader.GetText2()
|
||||
|
||||
EDocUsege GetDocUsage(const std::wstring& wsValue)
|
||||
{
|
||||
if (L"EBook" == wsValue)
|
||||
return EDocUsege::EBook;
|
||||
else if (L"ENewsPaper" == wsValue)
|
||||
return EDocUsege::ENewsPaper;
|
||||
else if (L"EMagnize" == wsValue)
|
||||
return EDocUsege::EMagzine;
|
||||
else
|
||||
return EDocUsege::Normal;
|
||||
}
|
||||
|
||||
CDocInfo::CDocInfo()
|
||||
: m_eDocUsage(EDocUsege::Normal)
|
||||
{}
|
||||
|
||||
bool CDocInfo::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (L"ofd:DocInfo" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
IF_CHECK_NODE("ofd:DocID", m_wsDocId);
|
||||
ELSE_IF_CHECK_NODE("ofd:Title", m_wsTitle);
|
||||
ELSE_IF_CHECK_NODE("ofd:Author", m_wsAuthor);
|
||||
ELSE_IF_CHECK_NODE("ofd:Subject", m_wsSubject);
|
||||
ELSE_IF_CHECK_NODE("ofd:Abstruct", m_wsAbstact);
|
||||
ELSE_IF_CHECK_NODE("ofd:CreationDate", m_wsCreationDate);
|
||||
ELSE_IF_CHECK_NODE("ofd:ModDate", m_wsModDate);
|
||||
ELSE_IF_CHECK_NODE("ofd:Cover", m_wsCover);
|
||||
ELSE_IF_CHECK_NODE("ofd:Creator", m_wsCreator);
|
||||
ELSE_IF_CHECK_NODE("ofd:CreatorVersion", m_wsCreatorVersion);
|
||||
else if ("ofd:DocUsage" == sNodeName)
|
||||
m_eDocUsage = GetDocUsage(oLiteReader.GetText2());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDocBody::ReadSignatures(const std::wstring& wsFilePath, IFolder* pFolder)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, pFolder->getFullFilePath(L"")))
|
||||
return;
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(CombinePaths(pFolder->getFullFilePath(L""), wsFilePath)) || !oLiteReader.ReadNextNode() || L"ofd:Signatures" != oLiteReader.GetName())
|
||||
return;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::string sNodeName;
|
||||
unsigned int unMaxSignId = 0;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:MaxSignId" == sNodeName)
|
||||
unMaxSignId = oLiteReader.GetUInteger();
|
||||
else if ("ofd:Signature" == sNodeName)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
continue;
|
||||
|
||||
do
|
||||
{
|
||||
if ("BaseLoc" == oLiteReader.GetNameA())
|
||||
AddToContainer(CSignature::Read(oLiteReader.GetText(), pFolder), m_arSignatures);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CDocBody::CDocBody()
|
||||
{}
|
||||
|
||||
CDocBody::~CDocBody()
|
||||
{
|
||||
ClearContainer(m_arSignatures);
|
||||
}
|
||||
|
||||
CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||
{
|
||||
if (L"ofd:DocBody" != oLiteReader.GetName())
|
||||
return nullptr;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::string sNodeName;
|
||||
|
||||
CDocBody *pDocBody = new CDocBody();
|
||||
|
||||
if (nullptr == pDocBody)
|
||||
return nullptr;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:DocInfo" == sNodeName)
|
||||
{
|
||||
if (!pDocBody->m_oDocInfo.Read(oLiteReader))
|
||||
{
|
||||
delete pDocBody;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if ("ofd:DocRoot" == sNodeName)
|
||||
pDocBody->m_oDocument.Read(oLiteReader.GetText2(), pFolder);
|
||||
else if ("ofd:Signatures" == sNodeName)
|
||||
pDocBody->ReadSignatures(oLiteReader.GetText2(), pFolder);
|
||||
}
|
||||
|
||||
return pDocBody;
|
||||
}
|
||||
|
||||
bool CDocBody::DrawPage(IRenderer* pRenderer, int nPageIndex) const
|
||||
{
|
||||
const bool bResult = m_oDocument.DrawPage(pRenderer, nPageIndex);
|
||||
|
||||
for (const CSignature* pSignature : m_arSignatures)
|
||||
if (pSignature->Draw(pRenderer, nPageIndex, nullptr))
|
||||
break;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
unsigned int CDocBody::GetPageCount() const
|
||||
{
|
||||
return m_oDocument.GetPageCount();
|
||||
}
|
||||
|
||||
bool CDocBody::GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const
|
||||
{
|
||||
return m_oDocument.GetPageSize(nPageIndex, dWidth, dHeight);
|
||||
}
|
||||
|
||||
CBase::CBase()
|
||||
{}
|
||||
|
||||
CBase::~CBase()
|
||||
{
|
||||
for (CDocBody* pDocBody : m_arDocBodies)
|
||||
RELEASEOBJECT(pDocBody);
|
||||
}
|
||||
|
||||
bool CBase::Read(IFolder* pFolder)
|
||||
{
|
||||
if (nullptr == pFolder || !pFolder->existsXml(L"OFD.xml"))
|
||||
return false;
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(pFolder->getFullFilePath(L"OFD.xml")) || !oLiteReader.ReadNextNode() || L"ofd:OFD" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
CDocBody* pDocBody = nullptr;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
pDocBody = CDocBody::Read(oLiteReader, pFolder);
|
||||
if (nullptr != pDocBody)
|
||||
m_arDocBodies.push_back(pDocBody);
|
||||
}
|
||||
|
||||
return !m_arDocBodies.empty();
|
||||
}
|
||||
|
||||
void CBase::DrawPage(IRenderer* pRenderer, int nPageIndex) const
|
||||
{
|
||||
for (const CDocBody* pDocBody : m_arDocBodies)
|
||||
if (pDocBody->DrawPage(pRenderer, nPageIndex))
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int CBase::GetPageCount() const
|
||||
{
|
||||
unsigned int unCount = 0;
|
||||
|
||||
for (const CDocBody* pDocBody : m_arDocBodies)
|
||||
unCount += pDocBody->GetPageCount();
|
||||
|
||||
return unCount;
|
||||
}
|
||||
|
||||
void CBase::GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const
|
||||
{
|
||||
for (const CDocBody* pDocBody : m_arDocBodies)
|
||||
if (pDocBody->GetPageSize(nPageIndex, dWidth, dHeight))
|
||||
return;
|
||||
}
|
||||
}
|
||||
79
OFDFile/src/Base.h
Normal file
79
OFDFile/src/Base.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef BASE_H
|
||||
#define BASE_H
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
#include "Document.h"
|
||||
#include "Types/Signature.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
enum class EDocUsege
|
||||
{
|
||||
Normal,
|
||||
EBook,
|
||||
ENewsPaper,
|
||||
EMagzine
|
||||
};
|
||||
|
||||
class CDocInfo
|
||||
{
|
||||
std::wstring m_wsDocId;
|
||||
std::wstring m_wsTitle;
|
||||
std::wstring m_wsAuthor;
|
||||
std::wstring m_wsSubject;
|
||||
std::wstring m_wsAbstact;
|
||||
|
||||
std::wstring m_wsCreationDate;
|
||||
std::wstring m_wsModDate;
|
||||
|
||||
EDocUsege m_eDocUsage;
|
||||
std::wstring m_wsCover;
|
||||
std::vector<std::wstring> m_arKeywords;
|
||||
|
||||
std::wstring m_wsCreator;
|
||||
std::wstring m_wsCreatorVersion;
|
||||
|
||||
std::vector<std::wstring> m_arCustomData;
|
||||
public:
|
||||
CDocInfo();
|
||||
bool Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
class CDocBody
|
||||
{
|
||||
CDocInfo m_oDocInfo;
|
||||
CDocument m_oDocument;
|
||||
// std::wstring m_wsVersions;
|
||||
std::vector<CSignature*> m_arSignatures;
|
||||
|
||||
void ReadSignatures(const std::wstring& wsFilePath, IFolder* pFolder);
|
||||
public:
|
||||
CDocBody();
|
||||
~CDocBody();
|
||||
|
||||
static CDocBody* Read(CXmlReader& oLiteReader, IFolder* pFolder);
|
||||
|
||||
bool DrawPage(IRenderer* pRenderer, int nPageIndex) const;
|
||||
|
||||
unsigned int GetPageCount() const;
|
||||
bool GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const;
|
||||
};
|
||||
|
||||
class CBase
|
||||
{
|
||||
std::vector<CDocBody*> m_arDocBodies;
|
||||
public:
|
||||
CBase();
|
||||
~CBase();
|
||||
|
||||
bool Read(IFolder* pFolder);
|
||||
void DrawPage(IRenderer* pRenderer, int nPageIndex) const;
|
||||
|
||||
unsigned int GetPageCount() const;
|
||||
void GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // BASE_H
|
||||
41
OFDFile/src/Content/Content.cpp
Normal file
41
OFDFile/src/Content/Content.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "Content.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CContent::CContent()
|
||||
{}
|
||||
|
||||
CContent::~CContent()
|
||||
{
|
||||
for (CLayer* pLayer : m_arLayers)
|
||||
delete pLayer;
|
||||
}
|
||||
|
||||
bool CContent::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (L"ofd:Content" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
|
||||
if (L"ofd:Layer" == wsNodeName)
|
||||
m_arLayers.push_back(new CLayer(oLiteReader));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CContent::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const CLayer* pLayer : m_arLayers)
|
||||
pLayer->Draw(pRenderer, oCommonData);
|
||||
}
|
||||
}
|
||||
21
OFDFile/src/Content/Content.h
Normal file
21
OFDFile/src/Content/Content.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef CONTENT_H
|
||||
#define CONTENT_H
|
||||
|
||||
#include "Layer.h"
|
||||
#include "../Types/CommonData.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CContent
|
||||
{
|
||||
std::vector<CLayer*> m_arLayers;
|
||||
public:
|
||||
CContent();
|
||||
~CContent();
|
||||
|
||||
bool Read(CXmlReader& oLiteReader);
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CONTENT_H
|
||||
108
OFDFile/src/Content/GraphicUnit.cpp
Normal file
108
OFDFile/src/Content/GraphicUnit.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
#include "GraphicUnit.h"
|
||||
#include "../../../OOXML/Base/Unit.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||
: m_bVisible(true), m_unDrawParam(0), m_dLineWidth(0.353),
|
||||
m_eCap(ECap::Butt), m_eJoin(EJoin::Miter), m_dMiterLimit(4.234),
|
||||
m_dDashOffset(0.), m_uchAlpha(255)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"Boundary" == wsAttributeName)
|
||||
m_oBoundary.Read(oLiteReader.GetTextA());
|
||||
else if (L"Name" == wsAttributeName)
|
||||
m_wsName = oLiteReader.GetText();
|
||||
else if (L"Visible" == wsAttributeName)
|
||||
m_bVisible = oLiteReader.GetBoolean(true);
|
||||
else if (L"CTM" == wsAttributeName)
|
||||
m_oCTM.Read(oLiteReader.GetTextA());
|
||||
else if (L"DrawParam" == wsAttributeName)
|
||||
m_unDrawParam = oLiteReader.GetUInteger(true);
|
||||
else if (L"LineWidth" == wsAttributeName)
|
||||
m_dLineWidth = oLiteReader.GetDouble(true);
|
||||
else if (L"Cap" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Butt" == wsValue)
|
||||
m_eCap = ECap::Butt;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eCap = ECap::Round;
|
||||
else if (L"Square" == wsValue)
|
||||
m_eCap = ECap::Square;
|
||||
}
|
||||
else if (L"Join" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Miter" == wsValue)
|
||||
m_eJoin = EJoin::Miter;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eJoin = EJoin::Round;
|
||||
else if (L"Bevel" == wsValue)
|
||||
m_eJoin = EJoin::Bevel;
|
||||
}
|
||||
else if (L"MiterLimit" == wsAttributeName)
|
||||
m_dMiterLimit = oLiteReader.GetDouble(true);
|
||||
else if (L"DashOffset" == wsAttributeName)
|
||||
m_dDashOffset = oLiteReader.GetDouble(true);
|
||||
else if (L"Alpha" == wsAttributeName)
|
||||
m_uchAlpha = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CGraphicUnit::Apply(IRenderer* pRenderer, TMatrix& oOldTransform) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
pRenderer->GetTransform(&oOldTransform.m_dM11, &oOldTransform.m_dM12, &oOldTransform.m_dM21, &oOldTransform.m_dM22, &oOldTransform.m_dDx, &oOldTransform.m_dDy);
|
||||
|
||||
Aggplus::CMatrix oTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
const Aggplus::CMatrix oCurrentTransform(m_oCTM.m_dM11, m_oCTM.m_dM12, m_oCTM.m_dM21, m_oCTM.m_dM22, m_oBoundary.m_dX + m_oCTM.m_dDx, m_oBoundary.m_dY + m_oCTM.m_dDy);
|
||||
|
||||
oTransform.Multiply(&oCurrentTransform);
|
||||
|
||||
// Clipping
|
||||
pRenderer->put_ClipMode(c_nClipRegionTypeWinding | c_nClipRegionIntersect);
|
||||
|
||||
pRenderer->BeginCommand(c_nResetClipType);
|
||||
pRenderer->EndCommand(c_nResetClipType);
|
||||
|
||||
if (!m_oBoundary.Empty())
|
||||
{
|
||||
pRenderer->BeginCommand(c_nClipType);
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
|
||||
pRenderer->PathCommandMoveTo(m_oBoundary.m_dX, m_oBoundary.m_dY);
|
||||
pRenderer->PathCommandLineTo(m_oBoundary.m_dX + m_oBoundary.m_dWidth, m_oBoundary.m_dY);
|
||||
pRenderer->PathCommandLineTo(m_oBoundary.m_dX + m_oBoundary.m_dWidth, m_oBoundary.m_dY + m_oBoundary.m_dHeight);
|
||||
pRenderer->PathCommandLineTo(m_oBoundary.m_dX, m_oBoundary.m_dY + m_oBoundary.m_dHeight);
|
||||
pRenderer->PathCommandLineTo(m_oBoundary.m_dX, m_oBoundary.m_dY);
|
||||
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
pRenderer->EndCommand(c_nClipType);
|
||||
pRenderer->PathCommandEnd();
|
||||
}
|
||||
|
||||
pRenderer->SetTransform(oTransform.sx(), oTransform.shy(), oTransform.shx(), oTransform.sy(), oTransform.tx(), oTransform.ty());
|
||||
}
|
||||
|
||||
TBox CGraphicUnit::GetBoundary() const
|
||||
{
|
||||
return m_oBoundary;
|
||||
}
|
||||
|
||||
}
|
||||
51
OFDFile/src/Content/GraphicUnit.h
Normal file
51
OFDFile/src/Content/GraphicUnit.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef GRAPHICUNIT_H
|
||||
#define GRAPHICUNIT_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Utils/Types.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CGraphicUnit
|
||||
{
|
||||
TBox m_oBoundary;
|
||||
std::wstring m_wsName;
|
||||
bool m_bVisible;
|
||||
TMatrix m_oCTM;
|
||||
unsigned int m_unDrawParam;
|
||||
double m_dLineWidth;
|
||||
|
||||
enum class ECap
|
||||
{
|
||||
Butt,
|
||||
Round,
|
||||
Square
|
||||
} m_eCap;
|
||||
|
||||
enum class EJoin
|
||||
{
|
||||
Miter,
|
||||
Round,
|
||||
Bevel
|
||||
} m_eJoin;
|
||||
|
||||
double m_dMiterLimit;
|
||||
double m_dDashOffset;
|
||||
std::vector<double> m_arDashPattern;
|
||||
unsigned char m_uchAlpha;
|
||||
|
||||
friend class CPathObject;
|
||||
public:
|
||||
CGraphicUnit(CXmlReader& oLiteReader);
|
||||
|
||||
void Apply(IRenderer* pRenderer, TMatrix& oOldTransform) const;
|
||||
|
||||
TBox GetBoundary() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // GRAPHICUNIT_H
|
||||
21
OFDFile/src/Content/IPageBlock.h
Normal file
21
OFDFile/src/Content/IPageBlock.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef IPAGEBLOCK_H
|
||||
#define IPAGEBLOCK_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../Types/CommonData.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class IPageBlock : public IOFDElement
|
||||
{
|
||||
public:
|
||||
IPageBlock(CXmlReader& oLiteReader)
|
||||
: IOFDElement(oLiteReader){};
|
||||
virtual ~IPageBlock(){};
|
||||
virtual void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IPAGEBLOCK_H
|
||||
49
OFDFile/src/Content/ImageObject.cpp
Normal file
49
OFDFile/src/Content/ImageObject.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "ImageObject.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CImageObject::CImageObject(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader), CGraphicUnit(oLiteReader), m_unMultiMediaID(0)
|
||||
{
|
||||
if ("ofd:ImageObject" != oLiteReader.GetNameA() || 0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::string sAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
sAttributeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ResourceID" == sAttributeName)
|
||||
{
|
||||
m_unMultiMediaID = oLiteReader.GetUInteger(true);
|
||||
break;
|
||||
}
|
||||
} while(oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == oCommonData.GetDocumentRes())
|
||||
return;
|
||||
|
||||
const CMultiMedia* pMultiMedia = oCommonData.GetDocumentRes()->GetMultiMedia(m_unMultiMediaID);
|
||||
|
||||
if (nullptr == pMultiMedia)
|
||||
return;
|
||||
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
const std::wstring wsFilePath = pMultiMedia->GetFilePath();
|
||||
|
||||
if (wsFilePath.empty())
|
||||
return;
|
||||
|
||||
pRenderer->DrawImageFromFile(wsFilePath, 0, 0, 1, 1);
|
||||
|
||||
pRenderer->SetTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
}
|
||||
}
|
||||
19
OFDFile/src/Content/ImageObject.h
Normal file
19
OFDFile/src/Content/ImageObject.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef IMAGEOBJECT_H
|
||||
#define IMAGEOBJECT_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
#include "GraphicUnit.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CImageObject : public IPageBlock, public CGraphicUnit
|
||||
{
|
||||
unsigned int m_unMultiMediaID;
|
||||
public:
|
||||
CImageObject(CXmlReader& oLiteReader);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IMAGEOBJECT_H
|
||||
32
OFDFile/src/Content/Layer.cpp
Normal file
32
OFDFile/src/Content/Layer.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "Layer.h"
|
||||
|
||||
#include "../../../OOXML/Base/Unit.h"
|
||||
|
||||
#include "PageBlock.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CLayer::CLayer(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader), m_eType(EType::Body)
|
||||
{
|
||||
if (L"ofd:Layer" != oLiteReader.GetName())
|
||||
return;
|
||||
|
||||
CPageBlock::ReadIntoContainer(oLiteReader, m_arPageBlocks);
|
||||
}
|
||||
|
||||
CLayer::~CLayer()
|
||||
{
|
||||
for (IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
delete pPageBlock;
|
||||
}
|
||||
|
||||
void CLayer::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
pPageBlock->Draw(pRenderer, oCommonData);
|
||||
}
|
||||
}
|
||||
27
OFDFile/src/Content/Layer.h
Normal file
27
OFDFile/src/Content/Layer.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef LAYER_H
|
||||
#define LAYER_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CLayer : public IPageBlock
|
||||
{
|
||||
enum class EType
|
||||
{
|
||||
Body,
|
||||
Foreground,
|
||||
Background
|
||||
} m_eType;
|
||||
|
||||
unsigned int m_unID;
|
||||
std::vector<IPageBlock*> m_arPageBlocks;
|
||||
public:
|
||||
CLayer(CXmlReader& oLiteReader);
|
||||
~CLayer();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LAYER_H
|
||||
52
OFDFile/src/Content/PageBlock.cpp
Normal file
52
OFDFile/src/Content/PageBlock.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "PageBlock.h"
|
||||
|
||||
#include "TextObject.h"
|
||||
#include "PathObject.h"
|
||||
#include "ImageObject.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CPageBlock::CPageBlock(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader)
|
||||
{
|
||||
if ("ofd:PageBlock" != oLiteReader.GetNameA() || oLiteReader.IsEmptyNode())
|
||||
return;
|
||||
|
||||
CPageBlock::ReadIntoContainer(oLiteReader, m_arPageBlocks);
|
||||
}
|
||||
|
||||
void CPageBlock::ReadIntoContainer(CXmlReader& oLiteReader, std::vector<IPageBlock*>& arPageBlocks)
|
||||
{
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
IPageBlock* pPageBlock = nullptr;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
pPageBlock = nullptr;
|
||||
|
||||
if (L"ofd:TextObject" == wsNodeName)
|
||||
pPageBlock = new CTextObject(oLiteReader);
|
||||
else if (L"ofd:PathObject" == wsNodeName)
|
||||
pPageBlock = new CPathObject(oLiteReader);
|
||||
else if (L"ofd:PageBlock" == wsNodeName)
|
||||
pPageBlock = new CPageBlock(oLiteReader);
|
||||
else if (L"ofd:ImageObject" == wsNodeName)
|
||||
pPageBlock = new CImageObject(oLiteReader);
|
||||
|
||||
if (nullptr != pPageBlock)
|
||||
arPageBlocks.push_back(pPageBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void CPageBlock::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
pPageBlock->Draw(pRenderer, oCommonData);
|
||||
}
|
||||
}
|
||||
21
OFDFile/src/Content/PageBlock.h
Normal file
21
OFDFile/src/Content/PageBlock.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef PAGEBLOCK_H
|
||||
#define PAGEBLOCK_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPageBlock : public IPageBlock
|
||||
{
|
||||
std::vector<IPageBlock*> m_arPageBlocks;
|
||||
public:
|
||||
CPageBlock(CXmlReader& oLiteReader);
|
||||
|
||||
static void ReadIntoContainer(CXmlReader& oLiteReader, std::vector<IPageBlock*>& arPageBlocks);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PAGEBLOCK_H
|
||||
392
OFDFile/src/Content/PathObject.cpp
Normal file
392
OFDFile/src/Content/PathObject.cpp
Normal file
@ -0,0 +1,392 @@
|
||||
#include "PathObject.h"
|
||||
#include "src/Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CPathObject::CPathObject(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader), CGraphicUnit(oLiteReader),
|
||||
m_bStroke(true), m_bFill(false), m_eRule(ERule::NonZero),
|
||||
m_pFillColor(nullptr), m_pStrokeColor(nullptr)
|
||||
{
|
||||
if (L"ofd:PathObject" != oLiteReader.GetName() || oLiteReader.IsEmptyElement() || !oLiteReader.IsValid())
|
||||
return;
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"Stroke" == wsAttributeName)
|
||||
m_bStroke = oLiteReader.GetBoolean(true);
|
||||
else if (L"Fill" == wsAttributeName)
|
||||
m_bFill = oLiteReader.GetBoolean(true);
|
||||
else if (L"Rule" == wsAttributeName)
|
||||
{
|
||||
if (L"Even-odd" == oLiteReader.GetText())
|
||||
m_eRule = ERule::Even_Odd;
|
||||
else
|
||||
m_eRule = ERule::NonZero;
|
||||
}
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
|
||||
if (L"ofd:FillColor" == wsNodeName)
|
||||
{
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
|
||||
m_pFillColor = new CColor(oLiteReader);
|
||||
}
|
||||
else if (L"ofd:StrokeColor" == wsNodeName)
|
||||
{
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
m_pStrokeColor = new CColor(oLiteReader);
|
||||
}
|
||||
else if (L"ofd:AbbreviatedData" == wsNodeName)
|
||||
{
|
||||
std::vector<std::string> arValues{Split(oLiteReader.GetText2A(), ' ')};
|
||||
|
||||
std::vector<std::string>::const_iterator itElement = arValues.cbegin();
|
||||
|
||||
char chElementName;
|
||||
|
||||
while (arValues.cend() != itElement)
|
||||
{
|
||||
if (arValues.front().length() != 1)
|
||||
{
|
||||
++itElement;
|
||||
continue;
|
||||
}
|
||||
|
||||
chElementName = (*itElement)[0];
|
||||
++itElement;
|
||||
|
||||
switch (chElementName)
|
||||
{
|
||||
case 'S':
|
||||
{
|
||||
AddElement(CStartElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'M':
|
||||
{
|
||||
AddElement(CMoveElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'L':
|
||||
{
|
||||
AddElement(CLineElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'Q':
|
||||
{
|
||||
AddElement(CBezierCurve2Element::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'B':
|
||||
{
|
||||
AddElement(CBezierCurveElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'A':
|
||||
{
|
||||
AddElement(CArcElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'C':
|
||||
{
|
||||
AddElement(new CCloseElement());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPathObject::~CPathObject()
|
||||
{
|
||||
for (const IPathElement* pElement : m_arElements)
|
||||
delete pElement;
|
||||
}
|
||||
|
||||
void CPathObject::AddElement(const IPathElement* pElement)
|
||||
{
|
||||
if (nullptr != pElement)
|
||||
m_arElements.push_back(pElement);
|
||||
}
|
||||
|
||||
void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_arElements.empty())
|
||||
return;
|
||||
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
|
||||
for (const IPathElement* pElement : m_arElements)
|
||||
pElement->Draw(pRenderer);
|
||||
|
||||
int nEndType = -1;
|
||||
|
||||
if (m_bStroke)
|
||||
nEndType = c_nStroke;
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
switch (m_eRule)
|
||||
{
|
||||
case ERule::NonZero:
|
||||
{
|
||||
nEndType = (-1 == nEndType ? c_nWindingFillMode : nEndType | c_nWindingFillMode);
|
||||
break;
|
||||
}
|
||||
case ERule::Even_Odd:
|
||||
{
|
||||
nEndType = (-1 == nEndType ? c_nEvenOddFillMode : nEndType | c_nEvenOddFillMode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
{
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_BrushColor1(0);
|
||||
pRenderer->put_BrushAlpha1(0xff);
|
||||
}
|
||||
}
|
||||
else
|
||||
pRenderer->put_BrushType(c_BrushTypeNotSet);
|
||||
|
||||
|
||||
if(m_bStroke)
|
||||
{
|
||||
pRenderer->put_PenSize(m_dLineWidth);
|
||||
|
||||
if (nullptr != m_pStrokeColor)
|
||||
{
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_PenAlpha(m_pStrokeColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_PenColor(0);
|
||||
pRenderer->put_PenAlpha(0xff);
|
||||
}
|
||||
}
|
||||
else
|
||||
pRenderer->put_PenSize(0.);
|
||||
|
||||
if (-1 != nEndType)
|
||||
pRenderer->DrawPath(nEndType);
|
||||
|
||||
pRenderer->PathCommandEnd();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
|
||||
pRenderer->SetTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
}
|
||||
|
||||
CStartElement::CStartElement()
|
||||
{}
|
||||
|
||||
IPathElement* CStartElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (itEnd - itBegin < 2)
|
||||
return nullptr;
|
||||
|
||||
CStartElement *pElement = new CStartElement();
|
||||
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX) && StringToDouble(*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CStartElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr != pRenderer)
|
||||
pRenderer->PathCommandMoveTo(m_dX, m_dY);
|
||||
}
|
||||
|
||||
CMoveElement::CMoveElement()
|
||||
{}
|
||||
|
||||
IPathElement* CMoveElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (itEnd - itBegin < 2)
|
||||
return nullptr;
|
||||
|
||||
CMoveElement *pElement = new CMoveElement();
|
||||
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX) && StringToDouble(*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CMoveElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr != pRenderer)
|
||||
pRenderer->PathCommandMoveTo(m_dX, m_dY);
|
||||
}
|
||||
|
||||
CLineElement::CLineElement()
|
||||
{}
|
||||
|
||||
IPathElement* CLineElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (itEnd - itBegin < 2)
|
||||
return nullptr;
|
||||
|
||||
CLineElement *pElement = new CLineElement();
|
||||
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX) && StringToDouble(*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CLineElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr != pRenderer)
|
||||
pRenderer->PathCommandLineTo(m_dX, m_dY);
|
||||
}
|
||||
|
||||
CBezierCurve2Element::CBezierCurve2Element()
|
||||
{}
|
||||
|
||||
IPathElement* CBezierCurve2Element::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (itEnd - itBegin < 4)
|
||||
return nullptr;
|
||||
|
||||
CBezierCurve2Element *pElement = new CBezierCurve2Element();
|
||||
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX1) && StringToDouble(*itBegin++, pElement->m_dY1) &&
|
||||
StringToDouble(*itBegin++, pElement->m_dX2) && StringToDouble(*itBegin++, pElement->m_dY2))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CBezierCurve2Element::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
double dX = 0, dY = 0;
|
||||
pRenderer->PathCommandGetCurrentPoint(&dX, &dY);
|
||||
pRenderer->PathCommandCurveTo(dX, dY, m_dX1, m_dY1, m_dX2, m_dY2);
|
||||
}
|
||||
|
||||
CBezierCurveElement::CBezierCurveElement()
|
||||
{}
|
||||
|
||||
IPathElement* CBezierCurveElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (itEnd - itBegin < 6)
|
||||
return nullptr;
|
||||
|
||||
CBezierCurveElement *pElement = new CBezierCurveElement();
|
||||
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX1) && StringToDouble(*itBegin++, pElement->m_dY1) &&
|
||||
StringToDouble(*itBegin++, pElement->m_dX2) && StringToDouble(*itBegin++, pElement->m_dY2) &&
|
||||
StringToDouble(*itBegin++, pElement->m_dX3) && StringToDouble(*itBegin++, pElement->m_dY3))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CBezierCurveElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr != pRenderer)
|
||||
pRenderer->PathCommandCurveTo(m_dX1, m_dY1, m_dX2, m_dY2, m_dX3, m_dY3);
|
||||
}
|
||||
|
||||
CArcElement::CArcElement()
|
||||
{}
|
||||
|
||||
IPathElement* CArcElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
|
||||
if (itEnd - itBegin < 7)
|
||||
return nullptr;
|
||||
|
||||
CArcElement *pElement = new CArcElement();
|
||||
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble (*itBegin++, pElement->m_dRadiusX) && StringToDouble (*itBegin++, pElement->m_dRadiusY) &&
|
||||
StringToDouble (*itBegin++, pElement->m_dAngle) && StringToBoolean(*itBegin++, pElement->m_bLarge) &&
|
||||
StringToBoolean(*itBegin++, pElement->m_bSweep) && StringToDouble (*itBegin++, pElement->m_dX) &&
|
||||
StringToDouble (*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CArcElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
// if (nullptr != pRenderer)
|
||||
// pRenderer->PathCommandArcTo(m_dX, m_dY, m_dRadiusX * 2., m_dRadiusY * 2., )
|
||||
}
|
||||
|
||||
CCloseElement::CCloseElement()
|
||||
{}
|
||||
|
||||
void CCloseElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr != pRenderer)
|
||||
pRenderer->PathCommandClose();
|
||||
}
|
||||
}
|
||||
124
OFDFile/src/Content/PathObject.h
Normal file
124
OFDFile/src/Content/PathObject.h
Normal file
@ -0,0 +1,124 @@
|
||||
#ifndef PATHOBJECT_H
|
||||
#define PATHOBJECT_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
#include "GraphicUnit.h"
|
||||
|
||||
#include "../Types/Color.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class IPathElement
|
||||
{
|
||||
public:
|
||||
IPathElement(){};
|
||||
virtual ~IPathElement(){};
|
||||
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues) { return nullptr; };
|
||||
virtual void Draw(IRenderer* pRenderer) const = 0;
|
||||
};
|
||||
|
||||
class CStartElement : public IPathElement
|
||||
{
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
public:
|
||||
CStartElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CMoveElement : public IPathElement
|
||||
{
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
public:
|
||||
CMoveElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CLineElement : public IPathElement
|
||||
{
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
public:
|
||||
CLineElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CBezierCurve2Element : public IPathElement
|
||||
{
|
||||
double m_dX1;
|
||||
double m_dY1;
|
||||
double m_dX2;
|
||||
double m_dY2;
|
||||
public:
|
||||
CBezierCurve2Element();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CBezierCurveElement : public IPathElement
|
||||
{
|
||||
double m_dX1;
|
||||
double m_dY1;
|
||||
double m_dX2;
|
||||
double m_dY2;
|
||||
double m_dX3;
|
||||
double m_dY3;
|
||||
public:
|
||||
CBezierCurveElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CArcElement : public IPathElement
|
||||
{
|
||||
double m_dRadiusX;
|
||||
double m_dRadiusY;
|
||||
double m_dAngle;
|
||||
bool m_bLarge;
|
||||
bool m_bSweep;
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
public:
|
||||
CArcElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CCloseElement : public IPathElement
|
||||
{
|
||||
public:
|
||||
CCloseElement();
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
class CPathObject : public IPageBlock, public CGraphicUnit
|
||||
{
|
||||
bool m_bStroke;
|
||||
bool m_bFill;
|
||||
|
||||
enum class ERule
|
||||
{
|
||||
NonZero,
|
||||
Even_Odd
|
||||
} m_eRule;
|
||||
|
||||
CColor* m_pFillColor;
|
||||
CColor* m_pStrokeColor;
|
||||
|
||||
std::vector<const IPathElement*> m_arElements;
|
||||
|
||||
void AddElement(const IPathElement* pElement);
|
||||
public:
|
||||
CPathObject(CXmlReader& oLiteReader);
|
||||
~CPathObject();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PATHOBJECT_H
|
||||
277
OFDFile/src/Content/TextObject.cpp
Normal file
277
OFDFile/src/Content/TextObject.cpp
Normal file
@ -0,0 +1,277 @@
|
||||
#include "TextObject.h"
|
||||
|
||||
#include "../Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CTextCode::CTextCode(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (L"ofd:TextCode" != oLiteReader.GetName() || oLiteReader.IsEmptyElement() || !oLiteReader.IsValid())
|
||||
return;
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"X" == wsAttributeName)
|
||||
m_dX = oLiteReader.GetDouble(true);
|
||||
else if (L"Y" == wsAttributeName)
|
||||
m_dY = oLiteReader.GetDouble(true);
|
||||
else if (L"DeltaX" == wsAttributeName ||
|
||||
L"DeltaY" == wsAttributeName)
|
||||
{
|
||||
const std::vector<std::string> arValues{oLiteReader.GetArrayStrings(true)};
|
||||
|
||||
std::vector<double>& arDelta{L"DeltaX" == wsAttributeName ? m_arDeltaX : m_arDeltaY};
|
||||
|
||||
arDelta.reserve(arValues.size());
|
||||
double dValue = 0.;
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arValues.size(); ++unIndex)
|
||||
{
|
||||
if ("g" == arValues[unIndex] && unIndex + 2 < arValues.size())
|
||||
{
|
||||
unsigned int unCount = 0;
|
||||
|
||||
if (!StringToUInteger(arValues[unIndex + 1], unCount) || !StringToDouble(arValues[unIndex + 2], dValue))
|
||||
continue;
|
||||
|
||||
unIndex += 2;
|
||||
|
||||
arDelta.insert(arDelta.end(), unCount, dValue);
|
||||
}
|
||||
else if (StringToDouble(arValues[unIndex], dValue))
|
||||
arDelta.push_back(dValue);
|
||||
else
|
||||
arDelta.push_back(0.);
|
||||
}
|
||||
}
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
m_wsText = oLiteReader.GetText2();
|
||||
}
|
||||
|
||||
void CTextCode::Draw(IRenderer* pRenderer, unsigned int& unIndex, const std::vector<TCGTransform>& arCGTransforms) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_wsText.empty())
|
||||
return;
|
||||
|
||||
double dX = m_dX, dY = m_dY, dDeltaX = 0, dDeltaY = 0;
|
||||
bool bDrawed = false;
|
||||
|
||||
for (unsigned int unGlyphIndex = 0; unGlyphIndex < m_wsText.length(); ++unGlyphIndex)
|
||||
{
|
||||
if (!arCGTransforms.empty())
|
||||
{
|
||||
for (const TCGTransform& oCGTransform : arCGTransforms)
|
||||
{
|
||||
if (oCGTransform.Draw(pRenderer, m_wsText[unGlyphIndex], unIndex, dX, dY))
|
||||
{
|
||||
bDrawed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bDrawed)
|
||||
{
|
||||
pRenderer->CommandDrawTextCHAR(m_wsText[unGlyphIndex], dX, dY, 0, 0);
|
||||
++unIndex;
|
||||
}
|
||||
|
||||
if (unGlyphIndex < m_arDeltaX.size())
|
||||
dDeltaX = m_arDeltaX[unGlyphIndex];
|
||||
|
||||
if (unGlyphIndex < m_arDeltaY.size())
|
||||
dDeltaY = m_arDeltaY[unGlyphIndex];
|
||||
|
||||
dX += dDeltaX;
|
||||
dY += dDeltaY;
|
||||
}
|
||||
}
|
||||
|
||||
CTextObject::CTextObject(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader), CGraphicUnit(oLiteReader),
|
||||
m_bStroke(false), m_bFill(true), m_dHScale(1.),
|
||||
m_unReadDirection(0), m_unCharDirection(0), m_unWeight(400),
|
||||
m_bItalic(false),
|
||||
m_pFillColor(nullptr), m_pStrokeColor(nullptr), m_unFontID(0)
|
||||
{
|
||||
if (L"ofd:TextObject" != oLiteReader.GetName() || oLiteReader.IsEmptyElement() || !oLiteReader.IsValid())
|
||||
return;
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"Font" == wsAttributeName)
|
||||
m_unFontID = oLiteReader.GetUInteger(true);
|
||||
else if (L"Size" == wsAttributeName)
|
||||
m_dSize = oLiteReader.GetDouble(true);
|
||||
else if (L"Stroke" == wsAttributeName)
|
||||
m_bStroke = oLiteReader.GetBoolean(true);
|
||||
else if (L"Fill" == wsAttributeName)
|
||||
m_bFill = oLiteReader.GetBoolean(true);
|
||||
else if (L"HScale" == wsAttributeName)
|
||||
m_dHScale = oLiteReader.GetDouble(true);
|
||||
else if (L"ReadDirection" == wsAttributeName)
|
||||
m_unReadDirection = oLiteReader.GetUInteger(true);
|
||||
else if (L"CharDirection" == wsAttributeName)
|
||||
m_unCharDirection =oLiteReader.GetUInteger(true);
|
||||
else if (L"Weight" == wsAttributeName)
|
||||
m_unWeight = oLiteReader.GetUInteger(true);
|
||||
else if (L"Italic" == wsAttributeName)
|
||||
m_bItalic = oLiteReader.GetBoolean(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
|
||||
if (L"ofd:FillColor" == wsNodeName)
|
||||
{
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
|
||||
m_pFillColor = new CColor(oLiteReader);
|
||||
}
|
||||
else if (L"ofd:StrokeColor" == wsNodeName)
|
||||
{
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
m_pStrokeColor = new CColor(oLiteReader);
|
||||
}
|
||||
else if (L"ofd:TextCode" == wsNodeName)
|
||||
m_arTextCodes.push_back(new CTextCode(oLiteReader));
|
||||
else if (L"ofd:CGTransform" == wsNodeName)
|
||||
m_arCGTransforms.push_back(TCGTransform::Read(oLiteReader));
|
||||
}
|
||||
}
|
||||
|
||||
CTextObject::~CTextObject()
|
||||
{
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
for (const CTextCode* pTextCode : m_arTextCodes)
|
||||
delete pTextCode;
|
||||
}
|
||||
|
||||
void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_arTextCodes.empty())
|
||||
return;
|
||||
|
||||
const CFont* pFont = oCommonData.GetPublicRes()->GetFont(m_unFontID);
|
||||
|
||||
if (nullptr == pFont)
|
||||
return;
|
||||
|
||||
pFont->Apply(pRenderer);
|
||||
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
{
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_BrushColor1(0);
|
||||
pRenderer->put_BrushAlpha1(0xff);
|
||||
}
|
||||
}
|
||||
else
|
||||
pRenderer->put_BrushType(c_BrushTypeNotSet);
|
||||
|
||||
pRenderer->put_FontSize(m_dSize * 72. / 25.4);
|
||||
|
||||
unsigned int unGlyphsIndex = 0;
|
||||
|
||||
for (const CTextCode* pTextCode : m_arTextCodes)
|
||||
pTextCode->Draw(pRenderer, unGlyphsIndex, m_arCGTransforms);
|
||||
|
||||
pRenderer->SetTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
}
|
||||
|
||||
TCGTransform TCGTransform::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
TCGTransform oCGTransform;
|
||||
|
||||
if (L"ofd:CGTransform" != oLiteReader.GetName() || oLiteReader.IsEmptyElement())
|
||||
return oCGTransform;
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"CodePosition" == wsAttributeName)
|
||||
oCGTransform.m_unCodePosition = oLiteReader.GetUInteger(true);
|
||||
else if (L"CodeCount" == wsAttributeName)
|
||||
oCGTransform.m_unCodeCount = oLiteReader.GetUInteger(true);
|
||||
else if (L"GlyphCount" == wsAttributeName)
|
||||
oCGTransform.m_unGlyphCount = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
unsigned int unCount = 0;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth) && unCount < oCGTransform.m_unGlyphCount)
|
||||
{
|
||||
if ("ofd:Glyphs" == oLiteReader.GetNameA())
|
||||
{
|
||||
oCGTransform.m_arGlyphs.push_back(oLiteReader.GetUInteger());
|
||||
++unCount;
|
||||
}
|
||||
}
|
||||
|
||||
return oCGTransform;
|
||||
}
|
||||
|
||||
bool TCGTransform::Draw(IRenderer* pRenderer, const LONG& lUnicode, unsigned int& unIndex, double dX, double dY) const
|
||||
{
|
||||
if (m_unCodePosition != unIndex || 0 == m_unCodeCount || 0 == m_unGlyphCount)
|
||||
return false;
|
||||
|
||||
for (unsigned int unGlyphCount = 0; unGlyphCount < m_unGlyphCount; ++unGlyphCount)
|
||||
pRenderer->CommandDrawTextExCHAR(lUnicode, m_arGlyphs[unGlyphCount], dX, dY, 0, 0);
|
||||
|
||||
unIndex += m_unCodeCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
65
OFDFile/src/Content/TextObject.h
Normal file
65
OFDFile/src/Content/TextObject.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef TEXTOBJECT_H
|
||||
#define TEXTOBJECT_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
#include "GraphicUnit.h"
|
||||
|
||||
#include "../Types/Color.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
struct TCGTransform
|
||||
{
|
||||
unsigned int m_unCodePosition;
|
||||
unsigned int m_unCodeCount;
|
||||
unsigned int m_unGlyphCount;
|
||||
|
||||
std::vector<unsigned int> m_arGlyphs;
|
||||
|
||||
static TCGTransform Read(CXmlReader& oLiteReader);
|
||||
|
||||
bool Draw(IRenderer* pRenderer, const LONG& lUnicode, unsigned int& unIndex, double dX, double dY) const;
|
||||
};
|
||||
|
||||
class CTextCode
|
||||
{
|
||||
double m_dX;
|
||||
double m_dY;
|
||||
|
||||
std::vector<double> m_arDeltaX;
|
||||
std::vector<double> m_arDeltaY;
|
||||
|
||||
std::wstring m_wsText;
|
||||
public:
|
||||
CTextCode(CXmlReader& oLiteReader);
|
||||
|
||||
void Draw(IRenderer* pRenderer, unsigned int& unIndex, const std::vector<TCGTransform>& arCGTransforms) const;
|
||||
};
|
||||
|
||||
class CTextObject : public IPageBlock, public CGraphicUnit
|
||||
{
|
||||
double m_dSize;
|
||||
bool m_bStroke;
|
||||
bool m_bFill;
|
||||
double m_dHScale;
|
||||
unsigned int m_unReadDirection;
|
||||
unsigned int m_unCharDirection;
|
||||
unsigned int m_unWeight;
|
||||
bool m_bItalic;
|
||||
|
||||
CColor* m_pFillColor;
|
||||
CColor* m_pStrokeColor;
|
||||
|
||||
unsigned int m_unFontID;
|
||||
|
||||
std::vector<const CTextCode*> m_arTextCodes;
|
||||
std::vector<TCGTransform> m_arCGTransforms;
|
||||
public:
|
||||
CTextObject(CXmlReader& oLiteReader);
|
||||
~CTextObject();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TEXTOBJECT_H
|
||||
142
OFDFile/src/Document.cpp
Normal file
142
OFDFile/src/Document.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
#include "Document.h"
|
||||
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
#include "../../DesktopEditor/common/Path.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CPermission::CPermission()
|
||||
: m_bEdit(true), m_bAnnot(true), m_bExport(true),
|
||||
m_bSignature(true), m_bWatermark(true), m_bPrintScreen(true)
|
||||
{}
|
||||
|
||||
bool CPermission::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (L"ofd:Permission" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
|
||||
if (L"ofd:Edit" == wsNodeName)
|
||||
m_bEdit = oLiteReader.GetBoolean();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CDocument::CDocument()
|
||||
{}
|
||||
|
||||
CDocument::~CDocument()
|
||||
{
|
||||
for (std::pair<int, CPage*> oElement : m_mPages)
|
||||
delete oElement.second;
|
||||
}
|
||||
|
||||
bool CDocument::Empty() const
|
||||
{
|
||||
return m_mPages.empty();
|
||||
}
|
||||
|
||||
bool CDocument::Read(const std::wstring& wsFilePath, IFolder* pFolder)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, pFolder->getFullFilePath(L"")))
|
||||
return false;
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(pFolder->getFullFilePath(wsFilePath)) || !oLiteReader.ReadNextNode() || L"ofd:Document" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const std::wstring wsCoreDirectory{pFolder->getFullFilePath(NSSystemPath::GetDirectoryName(wsFilePath))};
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
|
||||
if (L"ofd:CommonData" == wsNodeName)
|
||||
m_oCommonData.Read(oLiteReader, wsCoreDirectory);
|
||||
else if (L"ofd:Pages" == wsNodeName)
|
||||
{
|
||||
const int nPagesDepth = oLiteReader.GetDepth();
|
||||
|
||||
int nID = -1;
|
||||
std::wstring wsBaseLoc;
|
||||
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nPagesDepth))
|
||||
{
|
||||
if (L"ofd:Page" != oLiteReader.GetName() || 2 > oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
continue;
|
||||
|
||||
do
|
||||
{
|
||||
if (L"ID" == oLiteReader.GetName())
|
||||
nID = oLiteReader.GetInteger(true);
|
||||
else if (L"BaseLoc" == oLiteReader.GetName())
|
||||
wsBaseLoc = oLiteReader.GetText();
|
||||
}while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
if (wsBaseLoc.empty())
|
||||
continue;
|
||||
|
||||
if (-1 == nID)
|
||||
nID = m_mPages.size() + 1;
|
||||
|
||||
CPage* pPage = CPage::Read(wsBaseLoc, wsCoreDirectory);
|
||||
|
||||
if (nullptr != pPage)
|
||||
m_mPages.insert(std::make_pair(m_mPages.size(), pPage));
|
||||
|
||||
wsBaseLoc.clear();
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
}
|
||||
else if (L"ofd:Permissions" == wsNodeName)
|
||||
m_oPermission.Read(oLiteReader);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDocument::DrawPage(IRenderer* pRenderer, int nPageIndex) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return false;
|
||||
|
||||
std::map<unsigned int, CPage*>::const_iterator itFound = m_mPages.find(nPageIndex);
|
||||
|
||||
if (itFound == m_mPages.cend())
|
||||
return false;
|
||||
|
||||
itFound->second->Draw(pRenderer, m_oCommonData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int CDocument::GetPageCount() const
|
||||
{
|
||||
return m_mPages.size();
|
||||
}
|
||||
|
||||
bool CDocument::GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const
|
||||
{
|
||||
m_oCommonData.GetPageSize(dWidth, dHeight);
|
||||
|
||||
std::map<unsigned int, CPage*>::const_iterator itFound = m_mPages.find(nPageIndex);
|
||||
|
||||
if (itFound == m_mPages.cend())
|
||||
return false;
|
||||
|
||||
itFound->second->GetPageSize(dWidth, dHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
46
OFDFile/src/Document.h
Normal file
46
OFDFile/src/Document.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef DOCUMENT_H
|
||||
#define DOCUMENT_H
|
||||
|
||||
#include "Page.h"
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPermission
|
||||
{
|
||||
bool m_bEdit;
|
||||
bool m_bAnnot;
|
||||
bool m_bExport;
|
||||
bool m_bSignature;
|
||||
bool m_bWatermark;
|
||||
bool m_bPrintScreen;
|
||||
public:
|
||||
CPermission();
|
||||
|
||||
bool Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
class CDocument
|
||||
{
|
||||
CCommonData m_oCommonData;
|
||||
CPermission m_oPermission;
|
||||
|
||||
std::map<unsigned int, CPage*> m_mPages;
|
||||
public:
|
||||
CDocument();
|
||||
~CDocument();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool Read(const std::wstring& wsFilePath, IFolder* pFolder);
|
||||
|
||||
bool DrawPage(IRenderer* pRenderer, int nPageIndex) const;
|
||||
|
||||
unsigned int GetPageCount() const;
|
||||
bool GetPageSize(int nPageIndex, double& dWidth, double &dHeight) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOCUMENT_H
|
||||
35
OFDFile/src/IOFDElement.h
Normal file
35
OFDFile/src/IOFDElement.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef IOFDELEMENT_H
|
||||
#define IOFDELEMENT_H
|
||||
|
||||
#include "Utils/XmlReader.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class IOFDElement
|
||||
{
|
||||
unsigned int m_unID;
|
||||
public:
|
||||
IOFDElement(CXmlReader& oLiteReader)
|
||||
: m_unID(0)
|
||||
{
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
do
|
||||
{
|
||||
if (L"ID" == oLiteReader.GetName())
|
||||
m_unID = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
};
|
||||
virtual ~IOFDElement(){};
|
||||
|
||||
unsigned int GetID() const
|
||||
{
|
||||
return m_unID;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IOFDELEMENT_H
|
||||
140
OFDFile/src/OFDFile_Private.cpp
Normal file
140
OFDFile/src/OFDFile_Private.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
#include "OFDFile_Private.h"
|
||||
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
COFDFile_Private::COFDFile_Private(NSFonts::IApplicationFonts* pFonts)
|
||||
: m_pAppFonts(pFonts), m_pFontManager(nullptr), m_pTempFolder(nullptr)
|
||||
{
|
||||
if (nullptr == pFonts)
|
||||
return;
|
||||
|
||||
// Создаем менеджер шрифтов с собственным кэшем
|
||||
m_pFontManager = pFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
pMeasurerCache->SetStreams(pFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetCacheSize(16);
|
||||
}
|
||||
|
||||
COFDFile_Private::~COFDFile_Private()
|
||||
{
|
||||
Close();
|
||||
|
||||
if (nullptr != m_pTempFolder)
|
||||
delete m_pTempFolder;
|
||||
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
}
|
||||
|
||||
void COFDFile_Private::Close()
|
||||
{}
|
||||
|
||||
void COFDFile_Private::SetTempDir(const std::wstring& wsPath)
|
||||
{
|
||||
if (nullptr != m_pTempFolder)
|
||||
delete m_pTempFolder;
|
||||
|
||||
if (!NSDirectory::Exists(wsPath))
|
||||
NSDirectory::CreateDirectory(wsPath);
|
||||
|
||||
int nCounter = 0;
|
||||
std::wstring wsTempFolder = wsPath + L"/OFD/";
|
||||
|
||||
while (NSDirectory::Exists(wsTempFolder))
|
||||
{
|
||||
wsTempFolder = wsPath + L"/OFD" + std::to_wstring(nCounter) + L'/';
|
||||
nCounter++;
|
||||
}
|
||||
|
||||
NSDirectory::CreateDirectory(wsTempFolder);
|
||||
|
||||
m_pTempFolder = new CFolderSystem(wsTempFolder);
|
||||
}
|
||||
|
||||
std::wstring COFDFile_Private::GetTempDir() const
|
||||
{
|
||||
return (nullptr != m_pTempFolder) ? m_pTempFolder->getFullFilePath(L"") : std::wstring();
|
||||
}
|
||||
|
||||
bool COFDFile_Private::Read(IFolder* pFolder)
|
||||
{
|
||||
if (nullptr == pFolder)
|
||||
return false;
|
||||
|
||||
return m_oBase.Read(pFolder);
|
||||
}
|
||||
|
||||
bool COFDFile_Private::LoadFromFile(const std::wstring& wsFilePath)
|
||||
{
|
||||
if (wsFilePath.empty() || nullptr == m_pTempFolder)
|
||||
return false;
|
||||
|
||||
Close();
|
||||
|
||||
COfficeUtils oUtils(NULL);
|
||||
|
||||
if (S_OK != oUtils.ExtractToDirectory(wsFilePath, m_pTempFolder->getFullFilePath(L""), NULL, 0))
|
||||
return false;
|
||||
|
||||
return Read(m_pTempFolder);
|
||||
}
|
||||
|
||||
bool COFDFile_Private::LoadFromMemory(BYTE* pData, DWORD ulLength)
|
||||
{
|
||||
Close();
|
||||
|
||||
if (nullptr != m_pTempFolder)
|
||||
delete m_pTempFolder;
|
||||
|
||||
m_pTempFolder = new CZipFolderMemory(pData, ulLength);
|
||||
|
||||
return Read(m_pTempFolder);
|
||||
}
|
||||
|
||||
unsigned int COFDFile_Private::GetPageCount() const
|
||||
{
|
||||
return m_oBase.GetPageCount();
|
||||
}
|
||||
|
||||
void COFDFile_Private::GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const
|
||||
{
|
||||
m_oBase.GetPageSize(nPageIndex, dWidth, dHeight);
|
||||
}
|
||||
|
||||
void COFDFile_Private::DrawPage(IRenderer* pRenderer, int nPageIndex)
|
||||
{
|
||||
m_oBase.DrawPage(pRenderer, nPageIndex);
|
||||
}
|
||||
|
||||
void COFDFile_Private::DrawPage(IRenderer* pRenderer, int nPageIndex, const double& dX, const double& dY, const double& dWidth, const double& dHeight)
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
double dPageWidth = 0., dPageHeight = 0.;
|
||||
|
||||
GetPageSize(nPageIndex, dPageWidth, dPageHeight);
|
||||
|
||||
if (OFD::IsZeroValue(dPageWidth) || OFD::IsZeroValue(dPageHeight))
|
||||
return;
|
||||
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
|
||||
Aggplus::CMatrix oTransform(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
|
||||
oTransform.Scale(dWidth / dPageWidth, dHeight / dPageHeight);
|
||||
oTransform.Translate(dX, dY);
|
||||
|
||||
pRenderer->SetTransform(oTransform.sx(), oTransform.shy(), oTransform.shx(), oTransform.sy(), oTransform.tx(), oTransform.ty());
|
||||
|
||||
m_oBase.DrawPage(pRenderer, nPageIndex);
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
}
|
||||
|
||||
NSFonts::IApplicationFonts* COFDFile_Private::GetFonts()
|
||||
{
|
||||
return m_pAppFonts;
|
||||
}
|
||||
41
OFDFile/src/OFDFile_Private.h
Normal file
41
OFDFile/src/OFDFile_Private.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef OFDFILE_PRIVATE_H
|
||||
#define OFDFILE_PRIVATE_H
|
||||
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
class COFDFile_Private
|
||||
{
|
||||
NSFonts::IApplicationFonts* m_pAppFonts;
|
||||
NSFonts::IFontManager* m_pFontManager;
|
||||
IFolder* m_pTempFolder;
|
||||
|
||||
OFD::CBase m_oBase;
|
||||
|
||||
bool Read(IFolder* pFolder);
|
||||
public:
|
||||
COFDFile_Private(NSFonts::IApplicationFonts* pFonts);
|
||||
~COFDFile_Private();
|
||||
|
||||
void Close();
|
||||
|
||||
void SetTempDir(const std::wstring& wsPath);
|
||||
std::wstring GetTempDir() const;
|
||||
|
||||
bool LoadFromFile(const std::wstring& wsFilePath);
|
||||
bool LoadFromMemory(BYTE* pData, DWORD ulLength);
|
||||
|
||||
unsigned int GetPageCount() const;
|
||||
void GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const;
|
||||
|
||||
void DrawPage(IRenderer* pRenderer, int nPageIndex);
|
||||
void DrawPage(IRenderer* pRenderer, int nPageIndex, const double& dX, const double& dY, const double& dWidth, const double& dHeight);
|
||||
|
||||
NSFonts::IApplicationFonts* GetFonts();
|
||||
};
|
||||
|
||||
#endif // OFDFILE_PRIVATE_H
|
||||
94
OFDFile/src/Page.cpp
Normal file
94
OFDFile/src/Page.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
#include "Page.h"
|
||||
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CPage::CPage()
|
||||
: m_parTemplatePage{0, EZOrder::Background}
|
||||
{}
|
||||
|
||||
CPage::~CPage()
|
||||
{}
|
||||
|
||||
CPage* CPage::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, wsRootPath))
|
||||
return nullptr;
|
||||
|
||||
std::wstring wsNormalizedPath = CombinePaths(wsRootPath, wsFilePath);
|
||||
|
||||
if (L"xml" != NSFile::GetFileExtention(wsNormalizedPath))
|
||||
wsNormalizedPath = CombinePaths(wsNormalizedPath, L"Content.xml");
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || L"ofd:Page" != oLiteReader.GetName())
|
||||
return nullptr;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
|
||||
CPage *pPage = new CPage();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
|
||||
if (L"ofd:Content" == wsNodeName)
|
||||
pPage->m_oContent.Read(oLiteReader);
|
||||
else if (L"ofd:Area" == wsNodeName)
|
||||
pPage->m_oArea.Read(oLiteReader);
|
||||
else if (L"ofd:Template" == wsNodeName && 0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string sAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
sAttributeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ZOrder" == sAttributeName)
|
||||
pPage->m_parTemplatePage.second = GetZOrderFromString(oLiteReader.GetTextA());
|
||||
else if ("TemplateID" == sAttributeName)
|
||||
pPage->m_parTemplatePage.first = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
}
|
||||
|
||||
return pPage;
|
||||
}
|
||||
|
||||
void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
pRenderer->BeginCommand(c_nImageType);
|
||||
|
||||
if (0 != m_parTemplatePage.first)
|
||||
{
|
||||
const CTemplatePage *pTemplatePage = oCommonData.GetTemplatePage(m_parTemplatePage.first, m_parTemplatePage.second);
|
||||
|
||||
if (nullptr != pTemplatePage && EZOrder::Background == pTemplatePage->GetZOrder() && nullptr != pTemplatePage->GetPage())
|
||||
pTemplatePage->GetPage()->Draw(pRenderer, oCommonData);
|
||||
}
|
||||
|
||||
m_oContent.Draw(pRenderer, oCommonData);
|
||||
|
||||
pRenderer->EndCommand(c_nImageType);
|
||||
}
|
||||
|
||||
void CPage::GetPageSize(double& dWidth, double& dHeight) const
|
||||
{
|
||||
TBox oPhysicalBox{m_oArea.GetPhysicalBox()};
|
||||
|
||||
if (oPhysicalBox.Empty())
|
||||
return;
|
||||
|
||||
dWidth = oPhysicalBox.m_dWidth;
|
||||
dHeight = oPhysicalBox.m_dHeight;
|
||||
}
|
||||
}
|
||||
27
OFDFile/src/Page.h
Normal file
27
OFDFile/src/Page.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef PAGE_H
|
||||
#define PAGE_H
|
||||
|
||||
#include "Content/Content.h"
|
||||
#include "Types/CommonData.h"
|
||||
#include "Types/TemplatePage.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPage
|
||||
{
|
||||
CPageArea m_oArea;
|
||||
CContent m_oContent;
|
||||
|
||||
std::pair<unsigned int, EZOrder> m_parTemplatePage;
|
||||
public:
|
||||
CPage();
|
||||
~CPage();
|
||||
|
||||
static CPage* Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const;
|
||||
|
||||
void GetPageSize(double& dWidth, double& dHeight) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PAGE_H
|
||||
138
OFDFile/src/Res.cpp
Normal file
138
OFDFile/src/Res.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
#include "Res.h"
|
||||
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CRes::CRes()
|
||||
{}
|
||||
|
||||
CRes::~CRes()
|
||||
{
|
||||
#define CLEAR_VECTOR(type, arvaribles)\
|
||||
for (const std::pair<unsigned int, type*>& oValue : arvaribles)\
|
||||
delete oValue.second
|
||||
|
||||
CLEAR_VECTOR(CColorSpace, m_mColorSpaces);
|
||||
CLEAR_VECTOR(CDrawParam, m_mDrawParams);
|
||||
CLEAR_VECTOR(CFont, m_mFonts);
|
||||
CLEAR_VECTOR(CMultiMedia, m_mMultiMedias);
|
||||
CLEAR_VECTOR(CCompositeGraphicUnit, m_mCCompositeGraphicUnits);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void AddElementToMap(T* pElement, unsigned int unIndex, std::map<unsigned int, T*>& mElements)
|
||||
{
|
||||
if (nullptr == pElement)
|
||||
return;
|
||||
|
||||
typename std::map<unsigned int, T*>::const_iterator itFound = mElements.find(unIndex);
|
||||
|
||||
if (mElements.cend() != itFound)
|
||||
delete itFound->second;
|
||||
|
||||
mElements.insert(std::make_pair(unIndex, pElement));
|
||||
}
|
||||
|
||||
bool CRes::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, wsRootPath))
|
||||
return false;
|
||||
|
||||
const std::wstring wsFullPath{CombinePaths(wsRootPath, wsFilePath)};
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(wsFullPath) || !oLiteReader.ReadNextNode() || L"ofd:Res" != oLiteReader.GetName() || oLiteReader.IsEmptyNode())
|
||||
return false;
|
||||
|
||||
std::wstring wsResRootPath;
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string sNodeName;
|
||||
do
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("BaseLoc" == sNodeName)
|
||||
{
|
||||
wsResRootPath = CombinePaths(NSDirectory::GetFolderPath(wsFullPath), oLiteReader.GetText());
|
||||
break;
|
||||
}
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
std::string sNodeName;
|
||||
|
||||
#define PARSE_CONTAINER(container_name, element_name, element_type, melements, creator)\
|
||||
if (container_name == sNodeName)\
|
||||
{\
|
||||
const int nChildrenDepth = oLiteReader.GetDepth();\
|
||||
element_type* pElement = nullptr;\
|
||||
while (oLiteReader.ReadNextSiblingNode(nChildrenDepth))\
|
||||
{\
|
||||
if (element_name == oLiteReader.GetNameA())\
|
||||
{\
|
||||
pElement = creator;\
|
||||
AddElementToMap(pElement, pElement->GetID(), melements);\
|
||||
}\
|
||||
}\
|
||||
continue;\
|
||||
}
|
||||
|
||||
#define PARSE_CONTAINER_WITHOUT_PATH(container_name, element_name, element_type, melements)\
|
||||
PARSE_CONTAINER(container_name, element_name, element_type, melements, new element_type(oLiteReader))
|
||||
|
||||
#define PARSE_CONTAINER_WITH_PATH(container_name, element_name, element_type, melements)\
|
||||
PARSE_CONTAINER(container_name, element_name, element_type, melements, new element_type(oLiteReader, wsResRootPath))
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
PARSE_CONTAINER_WITHOUT_PATH("ofd:ColorSpaces", "ofd:ColorSpace", CColorSpace, m_mColorSpaces)
|
||||
PARSE_CONTAINER_WITHOUT_PATH("ofd:DrawParams", "ofd:DrawParam", CDrawParam, m_mDrawParams)
|
||||
PARSE_CONTAINER_WITHOUT_PATH("ofd:CompositeGraphicUnits", "ofd:CCompositeGraphicUnit", CCompositeGraphicUnit, m_mCCompositeGraphicUnits)
|
||||
|
||||
PARSE_CONTAINER_WITH_PATH("ofd:Fonts", "ofd:Font", CFont, m_mFonts)
|
||||
PARSE_CONTAINER_WITH_PATH("ofd:MultiMedias", "ofd:MultiMedia", CMultiMedia, m_mMultiMedias)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define RETURN_ELEMENT_FROM_MAP(element_type, mElements)\
|
||||
const std::map<unsigned int, element_type*>::const_iterator itFound = mElements.find(unId);\
|
||||
return (mElements.cend() != itFound) ? itFound->second : nullptr\
|
||||
|
||||
const CColorSpace* CRes::GetColorSpace(unsigned int unId) const
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CColorSpace, m_mColorSpaces);
|
||||
}
|
||||
|
||||
const CDrawParam* CRes::GetDrawParam(unsigned int unId) const
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CDrawParam, m_mDrawParams);
|
||||
}
|
||||
|
||||
const CFont* CRes::GetFont(unsigned int unId) const
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CFont, m_mFonts);
|
||||
}
|
||||
|
||||
const CMultiMedia* CRes::GetMultiMedia(unsigned int unId) const
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CMultiMedia, m_mMultiMedias);
|
||||
}
|
||||
|
||||
const CCompositeGraphicUnit* CRes::GetCompositeGraphicUnit(unsigned int unId) const
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CCompositeGraphicUnit, m_mCCompositeGraphicUnits);
|
||||
}
|
||||
}
|
||||
37
OFDFile/src/Res.h
Normal file
37
OFDFile/src/Res.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef RES_H
|
||||
#define RES_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Types/ColorSpace.h"
|
||||
#include "Types/DrawParam.h"
|
||||
#include "Types/Font.h"
|
||||
#include "Types/MultiMedia.h"
|
||||
#include "Types/CompositeGraphicUnit.h"
|
||||
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CRes
|
||||
{
|
||||
std::map<unsigned int, CColorSpace*> m_mColorSpaces;
|
||||
std::map<unsigned int, CDrawParam*> m_mDrawParams;
|
||||
std::map<unsigned int, CFont*> m_mFonts;
|
||||
std::map<unsigned int, CMultiMedia*> m_mMultiMedias;
|
||||
std::map<unsigned int, CCompositeGraphicUnit*> m_mCCompositeGraphicUnits;
|
||||
public:
|
||||
CRes();
|
||||
~CRes();
|
||||
|
||||
bool Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
|
||||
const CColorSpace* GetColorSpace(unsigned int unId) const;
|
||||
const CDrawParam* GetDrawParam(unsigned int unId) const;
|
||||
const CFont* GetFont(unsigned int unId) const;
|
||||
const CMultiMedia* GetMultiMedia(unsigned int unId) const;
|
||||
const CCompositeGraphicUnit* GetCompositeGraphicUnit(unsigned int unId) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // RES_H
|
||||
79
OFDFile/src/Types/Color.cpp
Normal file
79
OFDFile/src/Types/Color.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include "Color.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CColor::CColor(CXmlReader& oXmlReader)
|
||||
: m_oValues{0, 0, 0, 0}, m_nIndex(0), m_chAlpha(255), m_unColodSpaceID(0)
|
||||
{
|
||||
if (0 == oXmlReader.GetAttributesCount() || !oXmlReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::string sAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
sAttributeName = oXmlReader.GetNameA();
|
||||
|
||||
if ("ColorSpace" == sAttributeName)
|
||||
m_unColodSpaceID = oXmlReader.GetUInteger(true);
|
||||
else if ("Value" == sAttributeName)
|
||||
{
|
||||
const std::vector<double> arValues{oXmlReader.GetArrayDoubles(true)};
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < (std::min)((unsigned int)arValues.size(), (unsigned int)4); ++unIndex)
|
||||
m_oValues[unIndex] = static_cast<BYTE>(arValues[unIndex]);
|
||||
}
|
||||
else if ("Alpha" == sAttributeName)
|
||||
m_chAlpha = oXmlReader.GetUInteger(true);
|
||||
else if ("Index" == sAttributeName)
|
||||
m_nIndex = oXmlReader.GetInteger(true);
|
||||
} while (oXmlReader.MoveToNextAttribute());
|
||||
|
||||
oXmlReader.MoveToElement();
|
||||
}
|
||||
|
||||
int CColor::ToInt(const CRes* pPublicRes) const
|
||||
{
|
||||
if (nullptr == pPublicRes)
|
||||
return 0;
|
||||
|
||||
const CColorSpace* pColorSpace = pPublicRes->GetColorSpace(m_unColodSpaceID);
|
||||
|
||||
CColorSpace::EType eColoSpaceType{CColorSpace::EType::RGB};
|
||||
|
||||
if (nullptr != pColorSpace)
|
||||
eColoSpaceType = pColorSpace->GetType();
|
||||
|
||||
switch(eColoSpaceType)
|
||||
{
|
||||
case CColorSpace::EType::GRAY:
|
||||
return (255 << 24) | (m_oValues[0] << 16) | (m_oValues[0] << 8) | (m_oValues[0] << 0);
|
||||
case CColorSpace::EType::RGB:
|
||||
return (255 << 24) | (m_oValues[2] << 16) | (m_oValues[1] << 8) | (m_oValues[0] << 0);
|
||||
case CColorSpace::EType::CMYK:
|
||||
{
|
||||
const float cF = m_oValues[0] / 255.0f;
|
||||
const float mF = m_oValues[1] / 255.0f;
|
||||
const float yF = m_oValues[2] / 255.0f;
|
||||
const float kF = m_oValues[3] / 255.0f;
|
||||
|
||||
const float r = (1.0f - cF) * (1.0f - kF);
|
||||
const float g = (1.0f - mF) * (1.0f - kF);
|
||||
const float b = (1.0f - yF) * (1.0f - kF);
|
||||
|
||||
const unsigned char rByte = static_cast<unsigned char>(r * 255);
|
||||
const unsigned char gByte = static_cast<unsigned char>(g * 255);
|
||||
const unsigned char bByte = static_cast<unsigned char>(b * 255);
|
||||
|
||||
return (rByte << 0) | (gByte << 8) | (bByte << 16);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BYTE CColor::GetAlpha() const
|
||||
{
|
||||
return m_chAlpha;
|
||||
}
|
||||
}
|
||||
30
OFDFile/src/Types/Color.h
Normal file
30
OFDFile/src/Types/Color.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CColor
|
||||
{
|
||||
BYTE m_oValues[4];
|
||||
|
||||
int m_nIndex;
|
||||
BYTE m_chAlpha;
|
||||
|
||||
unsigned int m_unColodSpaceID;
|
||||
// Pattern
|
||||
// AxialShd
|
||||
// RadialShd
|
||||
// GouraudShd
|
||||
// LaGouraudhd
|
||||
public:
|
||||
CColor(CXmlReader& oXmlReader);
|
||||
|
||||
int ToInt(const CRes* pPublicRes) const;
|
||||
BYTE GetAlpha() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COLOR_H
|
||||
35
OFDFile/src/Types/ColorSpace.cpp
Normal file
35
OFDFile/src/Types/ColorSpace.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "ColorSpace.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CColorSpace::CColorSpace(CXmlReader& oXmlReader)
|
||||
: IOFDElement(oXmlReader)
|
||||
{
|
||||
if (0 != oXmlReader.GetAttributesCount() && oXmlReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string sArgumentName;
|
||||
do
|
||||
{
|
||||
sArgumentName = oXmlReader.GetNameA();
|
||||
|
||||
if ("Type" == sArgumentName)
|
||||
{
|
||||
const std::string sValue{oXmlReader.GetTextA()};
|
||||
|
||||
if ("Gray" == sValue)
|
||||
m_eType = EType::GRAY;
|
||||
else if ("RGB" == sValue)
|
||||
m_eType = EType::RGB;
|
||||
else if ("CMYK" == sValue)
|
||||
m_eType = EType::CMYK;
|
||||
}
|
||||
} while (oXmlReader.MoveToNextAttribute());
|
||||
}
|
||||
oXmlReader.MoveToElement();
|
||||
}
|
||||
|
||||
CColorSpace::EType CColorSpace::GetType() const
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
}
|
||||
25
OFDFile/src/Types/ColorSpace.h
Normal file
25
OFDFile/src/Types/ColorSpace.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef COLORSPACE_H
|
||||
#define COLORSPACE_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CColorSpace : public IOFDElement
|
||||
{
|
||||
public:
|
||||
CColorSpace(CXmlReader& oXmlReader);
|
||||
|
||||
enum class EType
|
||||
{
|
||||
GRAY,
|
||||
RGB,
|
||||
CMYK
|
||||
};
|
||||
|
||||
EType GetType() const;
|
||||
private:
|
||||
EType m_eType;
|
||||
};
|
||||
}
|
||||
#endif // COLORSPACE_H
|
||||
88
OFDFile/src/Types/CommonData.cpp
Normal file
88
OFDFile/src/Types/CommonData.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
#include "CommonData.h"
|
||||
#include "../Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CCommonData::CCommonData()
|
||||
: m_unMaxUnitID(0), m_pPublicRes(nullptr), m_pDocumentRes(nullptr)
|
||||
{}
|
||||
|
||||
CCommonData::~CCommonData()
|
||||
{
|
||||
if (nullptr != m_pPublicRes)
|
||||
delete m_pPublicRes;
|
||||
|
||||
if (nullptr != m_pDocumentRes)
|
||||
delete m_pDocumentRes;
|
||||
}
|
||||
|
||||
bool CCommonData::Read(CXmlReader& oLiteReader, const std::wstring& wsRootPath)
|
||||
{
|
||||
if ("ofd:CommonData" != oLiteReader.GetNameA())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:PageArea" == sNodeName)
|
||||
m_oPageArea.Read(oLiteReader);
|
||||
else if ("ofd:PublicRes" == sNodeName)
|
||||
{
|
||||
if (nullptr == m_pPublicRes)
|
||||
m_pPublicRes = new CRes();
|
||||
|
||||
m_pPublicRes->Read(oLiteReader.GetText2(), wsRootPath);
|
||||
}
|
||||
else if ("ofd:DocumentRes" == sNodeName)
|
||||
{
|
||||
if(nullptr == m_pDocumentRes)
|
||||
m_pDocumentRes = new CRes();
|
||||
|
||||
m_pDocumentRes->Read(oLiteReader.GetText2(), wsRootPath);
|
||||
}
|
||||
else if ("ofd:MaxUnitID" == sNodeName)
|
||||
m_unMaxUnitID = oLiteReader.GetUInteger();
|
||||
else if ("ofd:TemplatePage" == sNodeName)
|
||||
AddToContainer(new const CTemplatePage(oLiteReader, wsRootPath), m_arTemplatePages);
|
||||
// else if (L"ofd:DefaultCS" == wsNodeName)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCommonData::GetPageSize(double& dWidth, double& dHeight) const
|
||||
{
|
||||
TBox oPhysicalBox{m_oPageArea.GetPhysicalBox()};
|
||||
|
||||
if (oPhysicalBox.Empty())
|
||||
return;
|
||||
|
||||
dWidth = oPhysicalBox.m_dWidth;
|
||||
dHeight = oPhysicalBox.m_dHeight;
|
||||
}
|
||||
|
||||
const CRes* CCommonData::GetPublicRes() const
|
||||
{
|
||||
return m_pPublicRes;
|
||||
}
|
||||
|
||||
const CRes* CCommonData::GetDocumentRes() const
|
||||
{
|
||||
return m_pDocumentRes;
|
||||
}
|
||||
|
||||
const CTemplatePage* CCommonData::GetTemplatePage(unsigned int unTemplateID, EZOrder eZOrder) const
|
||||
{
|
||||
for (const CTemplatePage* pTemplatePage : m_arTemplatePages)
|
||||
{
|
||||
if (unTemplateID == pTemplatePage->GetID() && eZOrder == pTemplatePage->GetZOrder())
|
||||
return pTemplatePage;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
33
OFDFile/src/Types/CommonData.h
Normal file
33
OFDFile/src/Types/CommonData.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef COMMONDATA_H
|
||||
#define COMMONDATA_H
|
||||
|
||||
#include "../Res.h"
|
||||
#include "PageArea.h"
|
||||
#include "TemplatePage.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CCommonData
|
||||
{
|
||||
unsigned int m_unMaxUnitID;
|
||||
CPageArea m_oPageArea;
|
||||
CRes* m_pPublicRes;
|
||||
CRes* m_pDocumentRes;
|
||||
|
||||
std::vector<const CTemplatePage*> m_arTemplatePages;
|
||||
public:
|
||||
CCommonData();
|
||||
~CCommonData();
|
||||
|
||||
bool Read(CXmlReader& oLiteReader, const std::wstring& wsRootPath);
|
||||
|
||||
void GetPageSize(double& dWidth, double &dHeight) const;
|
||||
|
||||
const CRes* GetPublicRes() const;
|
||||
const CRes* GetDocumentRes() const;
|
||||
|
||||
const CTemplatePage* GetTemplatePage(unsigned int unTemplateID, EZOrder eZOrder) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COMMONDATA_H
|
||||
8
OFDFile/src/Types/CompositeGraphicUnit.cpp
Normal file
8
OFDFile/src/Types/CompositeGraphicUnit.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "CompositeGraphicUnit.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CCompositeGraphicUnit::CCompositeGraphicUnit(CXmlReader& oXmlReader)
|
||||
: IOFDElement(oXmlReader)
|
||||
{}
|
||||
}
|
||||
15
OFDFile/src/Types/CompositeGraphicUnit.h
Normal file
15
OFDFile/src/Types/CompositeGraphicUnit.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef COMPOSITEGRAPHICUNIT_H
|
||||
#define COMPOSITEGRAPHICUNIT_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CCompositeGraphicUnit : public IOFDElement
|
||||
{
|
||||
public:
|
||||
CCompositeGraphicUnit(CXmlReader& oXmlReader);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COMPOSITEGRAPHICUNIT_H
|
||||
8
OFDFile/src/Types/DrawParam.cpp
Normal file
8
OFDFile/src/Types/DrawParam.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "DrawParam.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CDrawParam::CDrawParam(CXmlReader& oXmlReader)
|
||||
: IOFDElement(oXmlReader)
|
||||
{}
|
||||
}
|
||||
14
OFDFile/src/Types/DrawParam.h
Normal file
14
OFDFile/src/Types/DrawParam.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef DRAWPARAM_H
|
||||
#define DRAWPARAM_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CDrawParam : public IOFDElement
|
||||
{
|
||||
public:
|
||||
CDrawParam(CXmlReader& oXmlReader);
|
||||
};
|
||||
}
|
||||
#endif // DRAWPARAM_H
|
||||
76
OFDFile/src/Types/Font.cpp
Normal file
76
OFDFile/src/Types/Font.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include "Font.h"
|
||||
|
||||
#include "../Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CFont::CFont(CXmlReader& oXmlReader, const std::wstring& wsRootPath)
|
||||
: IOFDElement(oXmlReader),
|
||||
m_wsCharset(L"unicode"), m_bItalic(false), m_bBold(false),
|
||||
m_bSerif(false), m_bFixedWidth(false)
|
||||
{
|
||||
if (0 != oXmlReader.GetAttributesCount() && oXmlReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string sArgumentName;
|
||||
|
||||
do
|
||||
{
|
||||
sArgumentName = oXmlReader.GetNameA();
|
||||
|
||||
if ("FontName" == sArgumentName)
|
||||
m_wsFontName = oXmlReader.GetText();
|
||||
else if ("FamilyName" == sArgumentName)
|
||||
m_wsFamilyName = oXmlReader.GetText();
|
||||
else if ("Charset" == sArgumentName)
|
||||
m_wsCharset = oXmlReader.GetText();
|
||||
else if ("Italic" == sArgumentName)
|
||||
m_bItalic = oXmlReader.GetBoolean(true);
|
||||
else if ("Bold" == sArgumentName)
|
||||
m_bBold = oXmlReader.GetBoolean(true);
|
||||
else if ("Serif" == sArgumentName)
|
||||
m_bSerif = oXmlReader.GetBoolean(true);
|
||||
else if ("FixedWidth" == sArgumentName)
|
||||
m_bFixedWidth = oXmlReader.GetBoolean(true);
|
||||
} while (oXmlReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oXmlReader.MoveToElement();
|
||||
|
||||
if (oXmlReader.IsEmptyNode())
|
||||
return;
|
||||
|
||||
const int nDepth = oXmlReader.GetDepth();
|
||||
|
||||
while (oXmlReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:FontFile" == oXmlReader.GetNameA())
|
||||
{
|
||||
const std::wstring wsPath{oXmlReader.GetText2()};
|
||||
|
||||
if (CanUseThisPath(wsPath, wsRootPath))
|
||||
m_wsFilePath = CombinePaths(wsRootPath, wsPath);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CFont::Apply(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
int nFontStyle = 0;
|
||||
|
||||
if (m_bBold)
|
||||
nFontStyle |= 0x01;
|
||||
if (m_bItalic)
|
||||
nFontStyle |= 0x02;
|
||||
|
||||
pRenderer->put_FontStyle(nFontStyle);
|
||||
pRenderer->put_FontName(m_wsFontName);
|
||||
|
||||
if (!m_wsFilePath.empty())
|
||||
pRenderer->put_FontPath(m_wsFilePath);
|
||||
}
|
||||
}
|
||||
29
OFDFile/src/Types/Font.h
Normal file
29
OFDFile/src/Types/Font.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef FONT_H
|
||||
#define FONT_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CFont : public IOFDElement
|
||||
{
|
||||
public:
|
||||
CFont(CXmlReader& oXmlReader, const std::wstring& wsRootPath);
|
||||
|
||||
void Apply(IRenderer* pRenderer) const;
|
||||
private:
|
||||
std::wstring m_wsFontName;
|
||||
std::wstring m_wsFamilyName;
|
||||
std::wstring m_wsCharset;
|
||||
bool m_bItalic;
|
||||
bool m_bBold;
|
||||
bool m_bSerif;
|
||||
bool m_bFixedWidth;
|
||||
|
||||
std::wstring m_wsFilePath;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // FONT_H
|
||||
61
OFDFile/src/Types/MultiMedia.cpp
Normal file
61
OFDFile/src/Types/MultiMedia.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "MultiMedia.h"
|
||||
|
||||
#include "../Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CMultiMedia::CMultiMedia(CXmlReader& oXmlReader, const std::wstring& wsRootPath)
|
||||
: IOFDElement(oXmlReader), m_eType(EType::Image)
|
||||
{
|
||||
if (0 != oXmlReader.GetAttributesCount() && oXmlReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string sArgumentName;
|
||||
do
|
||||
{
|
||||
sArgumentName = oXmlReader.GetNameA();
|
||||
|
||||
if ("Type" == sArgumentName)
|
||||
{
|
||||
const std::string sValue{oXmlReader.GetTextA()};
|
||||
|
||||
if ("Image" == sValue)
|
||||
m_eType = EType::Image;
|
||||
else if ("Audio" == sValue)
|
||||
m_eType = EType::Audio;
|
||||
else if ("Video" == sValue)
|
||||
m_eType = EType::Video;
|
||||
}
|
||||
} while (oXmlReader.MoveToNextAttribute());
|
||||
}
|
||||
|
||||
oXmlReader.MoveToElement();
|
||||
|
||||
if (oXmlReader.IsEmptyNode())
|
||||
return;
|
||||
|
||||
const int nDepth = oXmlReader.GetDepth();
|
||||
|
||||
while (oXmlReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:MediaFile" == oXmlReader.GetNameA())
|
||||
{
|
||||
const std::wstring wsPath{oXmlReader.GetText2()};
|
||||
|
||||
if (CanUseThisPath(wsPath, wsRootPath))
|
||||
m_wsFilePath = CombinePaths(wsRootPath, wsPath);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CMultiMedia::EType CMultiMedia::GetType() const
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
|
||||
std::wstring CMultiMedia::GetFilePath() const
|
||||
{
|
||||
return m_wsFilePath;
|
||||
}
|
||||
}
|
||||
28
OFDFile/src/Types/MultiMedia.h
Normal file
28
OFDFile/src/Types/MultiMedia.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef MULTIMEDIA_H
|
||||
#define MULTIMEDIA_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CMultiMedia : public IOFDElement
|
||||
{
|
||||
public:
|
||||
CMultiMedia(CXmlReader& oXmlReader, const std::wstring& wsRootPath);
|
||||
|
||||
enum class EType
|
||||
{
|
||||
Image,
|
||||
Audio,
|
||||
Video
|
||||
};
|
||||
|
||||
EType GetType() const;
|
||||
std::wstring GetFilePath() const;
|
||||
private:
|
||||
EType m_eType;
|
||||
std::wstring m_wsFilePath;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MULTIMEDIA_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user