Compare commits

...

181 Commits

Author SHA1 Message Date
0dd978c000 Exist folder check: Add white list for some folders 2024-02-29 16:02:38 +03:00
cf90cd9e12 Merge pull request #1426 from ONLYOFFICE/fix/bug61241
fix bug #61241
2024-02-20 22:47:29 +03:00
690d17f6c4 fix bug #61241 2024-02-20 22:29:13 +03:00
7776743d8d Fix bug 66567 2024-02-19 22:15:10 +03:00
159ffec93b Merge pull request #1423 from ONLYOFFICE/fix/bug66562
Fix bug #66562
2024-02-19 17:37:53 +03:00
aba868b9ac Fix bug #66562 2024-02-19 18:25:05 +06:00
7d6a95d521 Fix bug 65583 2024-02-18 22:10:54 +03:00
0ff68fcd8d Merge pull request #1422 from ONLYOFFICE/fix/bug66545 2024-02-17 10:42:05 +03:00
25fc759e61 Fix bug 66545 2024-02-17 10:18:10 +03:00
ace094fc2a for bug #63610 2024-02-16 17:31:21 +03:00
77901663a0 Fix bug 66513 2024-02-16 12:50:59 +03:00
e11f145d30 Merge pull request #1420 from ONLYOFFICE/fix/bug66504
Fix bug 66504
2024-02-15 17:26:44 +03:00
5c69cb0358 Fix MemStream::setPos 2024-02-15 17:20:57 +03:00
2f4fee3555 Fix bug 66504 2024-02-15 16:35:27 +03:00
7710090d31 Merge pull request #1419 from ONLYOFFICE/fix/pdf-name
Fix T name due to Adobe
2024-02-15 16:16:16 +03:00
c7df1bc3ce Merge pull request #1418 from ONLYOFFICE/fix/bug66504
Fix bug 66504
2024-02-15 16:15:56 +03:00
7fdead0eda Fix T name due to Adobe 2024-02-15 16:13:33 +03:00
e78a4c84b4 Fix bug 66504 2024-02-15 15:50:36 +03:00
62481e5def Fix bug 66473 2024-02-15 11:20:01 +03:00
192704636f Fix build 2024-02-14 20:47:26 +03:00
0a9356f54b For bug 65400 2024-02-14 20:06:36 +03:00
ae8b458f79 fix bug #66497 2024-02-14 18:58:12 +03:00
8a88fce72f Merge pull request #1417 from ONLYOFFICE/feature/pdf-line
Write AP of pdf line annot
2024-02-14 14:58:44 +03:00
d23ebbdb38 Fix BC,BG for widget, C,S Line endpoint offset 2024-02-14 14:40:10 +03:00
5a9f74f5ad fix bug #66467 2024-02-14 14:22:44 +03:00
ef3cbf03b3 Merge pull request #1416 from ONLYOFFICE/fix/66463
Fix bug #66463
2024-02-14 13:30:19 +03:00
a6a73ffe3a Refactoring 2024-02-14 13:20:08 +03:00
33c5852834 Fix bug #66436 2024-02-13 20:25:30 +03:00
f055d0d592 Fix Line endpoint offset 2024-02-13 17:48:55 +03:00
bf68f87aa7 fix bug #65975 2024-02-13 14:41:10 +03:00
d4c245029d Create AdjustLineEndpoint and DrawLineArrow 2024-02-12 17:42:24 +03:00
fb72c73ca0 fix bug #66440 2024-02-10 18:40:10 +03:00
cf19a912ee fix bug #66392 2024-02-10 16:16:20 +03:00
01d76af52f Create AP for Line annots 2024-02-09 18:01:16 +03:00
795274a886 for bug #66401 2024-02-09 16:15:17 +03:00
5ccef7bdff Merge pull request #1415 from ONLYOFFICE/fix/WmfSize
Fix Wmf file Size
2024-02-09 13:15:06 +03:00
581e54691b Fix Wmf file Size 2024-02-09 12:59:17 +03:00
ba79959955 fix bug #66419 2024-02-08 17:59:20 +03:00
ea9ef2349d fix bug #66401
remove template
2024-02-08 15:09:27 +03:00
aaf9772805 Fix getting the cache key for qt tool (#1414) 2024-02-08 14:06:47 +03:00
8b62c50107 [android][x2t] Add format checker 2024-02-08 12:34:33 +03:00
3889ca0c94 Add codeql check (#1413)
* Add new action with codeql scanner

* Cosmetic changes

* Disable scanning on PR event

* codeql: ignore some unimportant paths

---------

Co-authored-by: Danil Titarenko <77471369+danilapog@users.noreply.github.com>
2024-02-08 12:11:41 +03:00
ca4c17847d fix bug #63352 2024-02-07 15:30:13 +03:00
1994a25b61 fix bug #66396 2024-02-07 11:38:03 +03:00
1e59463499 fix bug #66395 2024-02-07 11:33:07 +03:00
5d642ff7c4 fix bug #66394 2024-02-07 11:30:26 +03:00
74baaca570 Merge pull request #1411 from ONLYOFFICE/feature/android
Feature/android
2024-02-07 11:11:10 +03:00
5609c5fc7d fix bug #55873 2024-02-06 19:49:46 +03:00
a9394ac989 fix bug #66333 2024-02-06 17:43:33 +03:00
51a8984ab8 Merge pull request #1408 from ONLYOFFICE/fix/pdf-refactoring
Fix pdf bug
2024-02-06 17:16:48 +03:00
b413dbfb4a fix bug #66345 2024-02-06 14:03:17 +03:00
22bf7a149a Fix bug 66223 2024-02-06 12:26:52 +03:00
430adb678d Fix typo 2024-02-06 00:34:18 +03:00
d5126dbda9 PdfAnnot refactoring, For bug 66223 2024-02-05 18:00:18 +03:00
f6eb25b3f1 GetButtonIcon without W,H 2024-02-05 17:27:55 +03:00
c2231fca7c Add BaseThreadMonitor class 2024-02-05 12:32:41 +03:00
0529bc9d82 Merge remote-tracking branch 'origin/hotfix/v8.0.1' into fix/pdf-refactoring 2024-02-05 11:24:37 +03:00
29eb5bed4d Add new class 2024-02-05 10:54:54 +03:00
157c8acf57 fix bug #66312 2024-02-03 15:51:14 +03:00
397421c9c1 Fix build 2024-02-02 22:43:23 +03:00
59e977d94c Fix typo 2024-02-02 14:21:12 +03:00
e25071cecf Merge pull request #1407 from ONLYOFFICE/fix/bug66076
Fix bug 66076
2024-02-02 12:02:24 +03:00
c3e19a6376 Merge pull request #1406 from ONLYOFFICE/fix/pdf-formfield-fonts
Fix create unused font for CheckBox FormField
2024-02-02 12:01:03 +03:00
4868df7e10 Fix refactoring 2024-02-02 11:21:06 +03:00
7d55ebafbc Add openssl and logging 2024-02-02 11:16:43 +03:00
03078b01d1 Revert "Without static Decrypt"
This reverts commit 0ee70f03c1.
2024-02-02 10:52:31 +03:00
4c1420a3a6 PdfReader refactoring 2024-02-01 17:55:41 +03:00
ff6866c68a Merge pull request #1404 from ONLYOFFICE/fix/fix-bugs-v8.0
Fix/fix bugs v8.0
2024-02-01 11:41:33 +03:00
4d3f925a11 fix bug #65994 2024-01-31 14:46:24 +03:00
b05bdc68ce Fix create unused font for CheckBox FormField 2024-01-31 13:50:09 +03:00
4ddc517b93 fix bug #65786 2024-01-30 19:58:51 +03:00
fb78b3b611 for bug #66201 2024-01-30 19:14:47 +03:00
617714a907 fix same bugs 2024-01-30 19:13:55 +03:00
0ee70f03c1 Without static Decrypt 2024-01-30 17:00:08 +03:00
e30abd06a2 Merge branch release/v8.0.0 into master 2024-01-30 11:25:04 +00:00
70d8a1a927 For bug 66076 2024-01-30 01:17:31 +03:00
8e12b946a8 Merge pull request #1401 from ONLYOFFICE/fix/bug66223
Fix bug 66223
2024-01-29 18:53:44 +03:00
6e8c2d46fa Merge pull request #1402 from ONLYOFFICE/fix/bug66185
Fix bug #66185
2024-01-29 18:53:07 +03:00
efead80648 Fix bug #66185 2024-01-29 18:28:11 +03:00
3efd9aebc9 Fix bug 66223 2024-01-29 18:00:04 +03:00
2eed2729cc Merge pull request #1400 from ONLYOFFICE/fix/savingAnnots
Fix saving annots
2024-01-29 14:54:44 +03:00
f9000aba58 Fix saving annots 2024-01-29 14:49:00 +03:00
e61999c5fe fix bug #66192 2024-01-29 12:18:08 +03:00
108b749d4f fix unknown codepage 2024-01-29 11:51:33 +03:00
cb2dff90b9 Fix bug 63590 2024-01-29 00:02:55 +03:00
48a055d390 Fix metafiles with bad sizes. And revert one commit. 2024-01-29 00:00:37 +03:00
f8293950ca Merge pull request #1398 from ONLYOFFICE/fix/pdf-forms
Fix Opt for radiobutton, fix unicode for JS
2024-01-26 19:03:50 +03:00
84b19f48c7 Fix Opt for radiobutton, fix unicode for JS 2024-01-26 18:19:32 +03:00
ec107421bb Merge remote-tracking branch 'origin/fix/bug66175' into fix/fix-bugs-v8.0 2024-01-26 17:33:26 +03:00
d2acd7d86d Fix bug #66175 2024-01-26 16:54:30 +03:00
18d274cff2 Merge pull request #1396 from ONLYOFFICE/fix/bug65955
fix bug #65955
2024-01-26 15:51:23 +03:00
1686efd6ba Fix bug 66147 2024-01-26 15:11:51 +03:00
e73992f869 fix bug #65955 2024-01-26 15:10:46 +03:00
13a1d953b8 Merge pull request #1395 from ONLYOFFICE/fix/bug66136
Fix bug #66136
2024-01-25 17:02:40 +03:00
0764850b79 Fix bug #66136 2024-01-25 16:55:57 +03:00
9cfbb0012c Merge remote-tracking branch 'origin/fix/footersConversion' into fix/fix-bugs-v8.0 2024-01-25 16:35:24 +03:00
dfb8359d11 Merge pull request #1394 from ONLYOFFICE/fix/bug-pdf-web
[x2t] Fix bug with pdf opening in web
2024-01-25 13:54:36 +03:00
bd4d242aee [x2t] Fix bug with pdf opening in web 2024-01-25 13:52:16 +03:00
06cf8b4a3d Fix footer converion from xlsb to xlsx 2024-01-25 16:52:08 +06:00
16fec2e641 fix bug #66123 2024-01-25 12:08:44 +03:00
08c9dd34ac Fix build 65925 2024-01-24 21:59:09 +03:00
0ed9b41710 Merge pull request #1393 from ONLYOFFICE/fix/bug66122
fix bug #66122
2024-01-24 21:23:20 +03:00
fefe6b3053 fix bug #66122 2024-01-24 21:18:37 +03:00
50f3ad5d65 Merge branch 'release/v8.0.0' of https://github.com/ONLYOFFICE/core into release/v8.0.0 2024-01-24 21:03:16 +03:00
f134870e73 Fix bug 66072 2024-01-24 21:02:27 +03:00
180451e272 Merge pull request #1392 from ONLYOFFICE/fix/wmf
Fixed a bug with calculating the image size in wmf
2024-01-24 20:59:51 +03:00
9b97070db7 Fixed a bug with calculating the image size in wmf 2024-01-24 20:44:47 +03:00
9b16f92ae5 Merge pull request #1391 from ONLYOFFICE/fix/pdf-forms
Fix xref stream for big file
2024-01-24 16:49:50 +03:00
edb2a0f503 Fix xref stream for big file 2024-01-24 16:46:01 +03:00
39b61f1094 Merge pull request #1390 from ONLYOFFICE/fix/pdf-forms
Fix pdf forms
2024-01-24 15:52:46 +03:00
0e68fac03d Fix test 2024-01-24 15:36:40 +03:00
46ce3f962e Create SetEmptyAP 2024-01-24 14:35:20 +03:00
2be05c4439 Fix write AP_V with parent V, read/write AA 2024-01-24 12:47:14 +03:00
cb5d6d72b9 Fix convertation pdf/xps/djvu to doct 2024-01-24 12:30:50 +03:00
9f9da695d0 Add format detector to export 2024-01-24 10:54:43 +03:00
809ed0f91d Fix convertation to forms from forms format 2024-01-23 22:58:25 +03:00
1f4f05d52e Fix bug 65244 2024-01-23 21:59:25 +03:00
daaf4f0390 Fix bug 66011 2024-01-23 21:28:16 +03:00
1432c7b07e Fix pdf write 2024-01-23 18:44:36 +03:00
e9b9f0f550 Fix color precision 2024-01-23 18:41:29 +03:00
d61a309ca0 fix bug #66085 2024-01-23 15:12:10 +03:00
5c54ec3280 Fix bug 63779 2024-01-23 13:21:51 +03:00
aefce8c03c Merge pull request #1387 from ONLYOFFICE/fix/bug65989
Fix bug 65989
2024-01-23 10:41:46 +03:00
a879cd94c6 Fix bug 65989 2024-01-23 10:32:59 +03:00
42b86ceb53 Fix work in embedded mode (xp) 2024-01-22 21:25:44 +03:00
5cb048e074 Merge remote-tracking branch 'origin/fix/bug65600' into release/v8.0.0 2024-01-22 21:05:01 +03:00
eac27ae43b Fix bug #65600 2024-01-22 19:10:31 +05:00
0415a3ec56 Fix write unicode with encrypt 2024-01-22 16:45:27 +03:00
ad4754f7fc fix bug #65595 2024-01-22 16:17:15 +03:00
b589d8e3ce fix bug #65975 2024-01-22 16:02:48 +03:00
84ae9da444 fix bug #65976 2024-01-22 12:48:45 +03:00
bd7bcc6b4d fix bug #65977 2024-01-22 12:20:24 +03:00
7259f9b376 Merge remote-tracking branch 'origin/fix/bug50186' into release/v8.0.0 2024-01-22 11:28:18 +03:00
44b1abf27d Fix convertation to forms from forms format 2024-01-22 11:11:12 +03:00
d878291091 Fix bug 65650 2024-01-21 21:00:39 +03:00
4ee2ca7098 Fix bug 65965 2024-01-20 22:25:01 +03:00
78cb8a7d55 Fix bug #50186 2024-01-19 21:32:51 +05:00
29fe342a1c Merge pull request #1386 from ONLYOFFICE/fix/pdf-pushbutton
Fix pdf pushbutton
2024-01-19 14:36:32 +03:00
a2916309b3 Fix ShiftRespectBorder 2024-01-19 13:21:28 +03:00
9b38a17d5f Merge pull request #1385 from ONLYOFFICE/fix/pdf-font
Fix pdf font
2024-01-19 11:09:10 +03:00
0803b33067 Write PushButton 2024-01-18 18:37:54 +03:00
004fcbe7ba Merge remote-tracking branch 'origin/fix/bug65838' into release/v8.0.0 2024-01-18 17:49:51 +03:00
bbfdab9231 Fix bug #65838 2024-01-18 19:42:37 +05:00
14d9d2b01e fix bug #65829 2024-01-18 17:15:52 +03:00
7b6a706ca3 Merge remote-tracking branch 'origin/fix/bug65600' into release/v8.0.0 2024-01-18 13:17:36 +03:00
d593418616 Fix bug #65600 2024-01-18 01:12:15 +05:00
a160bc7ad1 Find dShiftY for pushbutton 2024-01-17 18:05:06 +03:00
f341dac2c3 Merge pull request #1384 from ONLYOFFICE/fix/Metafiles
Fix bugs in metafiles conversion
2024-01-17 15:52:36 +03:00
4041e5b31c Fix bug #65918 2024-01-17 13:52:58 +03:00
0774df72ca fix bug #65914 2024-01-17 13:43:10 +03:00
a3b0bb2294 Fix bug #65915 2024-01-16 23:13:40 +03:00
20a2424605 Fix WriteString method 2024-01-16 22:13:46 +03:00
a871295ad7 fix bug #65827 2024-01-16 18:28:49 +03:00
2cf11468d4 fix bug #65831 2024-01-16 18:12:04 +03:00
b59b2ba039 Merge pull request #1366 from ONLYOFFICE/feature/js-serialize-update
Added IsInit() function and more exceptions
2024-01-16 17:28:45 +03:00
950449b8de Merge pull request #1383 from ONLYOFFICE/feature/json-stringify
Add JSON_stringify
2024-01-16 17:24:21 +03:00
15ba22dc5c Implemented for V8 2024-01-16 18:16:22 +04:00
63b2b0b432 Merge pull request #1382 from ONLYOFFICE/release/v8.0.0
Release/v8.0.0
2024-01-16 16:22:09 +03:00
86eddff91d Add tests 2024-01-16 15:32:03 +04:00
c426474c50 Implement function 2024-01-16 15:31:40 +04:00
4fc9fc68e2 Merge pull request #1381 from ONLYOFFICE/fix/bug65853
Fix bug 65853
2024-01-16 12:46:06 +03:00
540fce9ab8 Fix bug 65853 2024-01-16 12:44:51 +03:00
505231291f Fix bug 65853 2024-01-16 12:42:34 +03:00
441e9276f4 Merge remote-tracking branch 'origin/fix/bug65779' into release/v8.0.0 2024-01-16 11:07:29 +03:00
9bbea65319 Merge remote-tracking branch 'origin/fix/bug65359' into release/v8.0.0 2024-01-16 10:59:43 +03:00
ba9d6b430a Fix bug 65862 2024-01-15 20:09:42 +03:00
95073fd590 Fix bug #65779 2024-01-15 20:05:28 +05:00
6bc58b973c Fix selection font for standard fonts 2024-01-15 17:26:35 +03:00
9da99f35b8 Fix duplicate for button font = DA font 2024-01-15 16:30:44 +03:00
d81efffbef Write m_sButtonFontName 2024-01-15 16:04:32 +03:00
650db9c31f Add run_path addon params 2024-01-14 22:07:49 +03:00
4064aba5fb Create SetButtonFont 2024-01-12 17:25:28 +03:00
6d5d74de0c Write border for pushbutton AP 2024-01-11 17:24:00 +03:00
57497bc14b Add caption to pushbutton AP 2024-01-11 14:30:09 +03:00
5663169473 Include stdexcept for windows 2024-01-11 14:57:02 +04:00
af04c2bac1 Added more exceptions 2024-01-11 14:57:02 +04:00
e4477c9926 Add IsInit() function 2024-01-11 14:57:02 +04:00
2ba62286d0 Create SetAP for pushbutton 2024-01-10 18:19:58 +03:00
28768e32af Fix bug #65359 2024-01-10 16:07:38 +05:00
50a83e819f Merge branch hotfix/v7.5.1 into master 2023-11-08 12:05:57 +00:00
954f3d5471 Merge branch hotfix/v7.5.1 into master 2023-10-31 14:41:39 +00:00
224 changed files with 6026 additions and 2811 deletions

162
.github/workflows/codeql.yaml vendored Normal file
View File

@ -0,0 +1,162 @@
name: "CodeQL Scanner"
on:
push:
branches:
- 'master'
- 'release/**'
- 'hotfix/**'
paths-ignore:
- '**/README.md'
- '**/LICENSE'
- '.github/**'
#pull_request:
# branches:
# - 'master'
# - 'release/**'
# - 'hotfix/**'
schedule:
- cron: '00 19 * * 5'
# This job take a lot of time, so if the number of worker
# processes from one branch or one PR exceeds 1, all previous
# running processes will be automatically canceled to avoid the accumulation
# of a large number of concurrent workers
concurrency:
group: codeql-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
env:
SOURCE_ROOT: "/build/core"
jobs:
analyze:
name: Analyze
runs-on: ${{ 'ubuntu-latest' }}
container:
image: ${{ matrix.image }}
options: --privileged
volumes:
- /usr/local/lib:/foovolume/android
- /usr/local/share:/foovolume/boost
- /usr/share:/foovolume/dotnet
- /opt:/foovolume/opt
- /opt/hostedtoolcache:/foovolume/tool
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'c-cpp' ]
image: ["ubuntu:20.04"]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: make free space in container
run: |
rm -rf /foovolume/android/android
rm -rf /foovolume/dotnet/dotnet
rm -rf /foovolume/boost/boost
rm -rf /foovolume/opt/ghc
rm -rf /foovolume/tool/*
df -h
# Prepare container environment
# Install some deps
# Set cache restore keys
- name: Prepare environment
id: prepare
shell: bash
env:
TZ: Etc/UTC
run: |
pwd
ls -la
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone
apt-get update
apt-get install -y python3 python2 sudo curl jq git
apt-get install -y python || true
rm /usr/bin/python || true
ln -s /usr/bin/python2 /usr/bin/python
mkdir -p /build
git clone --depth 1 \
--single-branch \
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/core.git ${SOURCE_ROOT}
git clone --depth 1 \
--single-branch \
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/build_tools.git /build/build_tools
echo "party-key=$(curl -L -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/ONLYOFFICE/core/commits?per_page=1&path=/Common/3dParty&sha=${{ github.base_ref || github.ref_name }}" | \
jq -r '.[].sha')" >> "$GITHUB_OUTPUT"
echo "qt-key=$(cat /build/build_tools/tools/linux/automate.py | egrep -m1 -o "qt_source_([0-9])?.([0-9])?.([0-9])?")" >> "$GITHUB_OUTPUT"
# Restore 3dParty from cache if cache key is match
- uses: actions/cache/restore@v3
id: restore-3d
with:
path: /build/core/Common/3dParty
key: 3dParty-${{ steps.prepare.outputs.party-key }}
# Restore qt tool from cache if cache key is match
- uses: actions/cache/restore@v3
id: restore-qt
with:
path: /build/build_tools/tools/linux/qt_build
key: qt-${{ steps.prepare.outputs.qt-key }}
# NOTE:
# init codeql with custom source-root dir
# because sources code was checkout with git from cli
# NOT with checkout action
# Also. Init and scan with codeql only if all cache hit
# otherwise will no initialization, just build and cache depends
- name: Initialize CodeQL
if: >
steps.restore-3d.outputs.cache-hit == 'true'
&& steps.restore-qt.outputs.cache-hit == 'true'
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: ${{ env.SOURCE_ROOT }}
- name: build
shell: bash
run: |
cd /build/build_tools/tools/linux
python3 ./automate.py core
- name: Perform CodeQL Analysis
if: >
steps.restore-3d.outputs.cache-hit == 'true'
&& steps.restore-qt.outputs.cache-hit == 'true'
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
# Make new 3dParty cache if restore action do not restore any cache
- uses: actions/cache/save@v3
if: steps.restore-3d.outputs.cache-hit != 'true'
id: save-3d
with:
path: /build/core/Common/3dParty
key: 3dParty-${{ steps.prepare.outputs.party-key }}
# Make new qt tool cache if restore action do not restore any cache
- uses: actions/cache/save@v3
if: steps.restore-qt.outputs.cache-hit != 'true'
id: save-qt
with:
path: /build/build_tools/tools/linux/qt_build
key: qt-${{ steps.prepare.outputs.qt-key }}

View File

@ -34,6 +34,7 @@
#include "../../../../DesktopEditor/common/File.h"
#include "../../../../DesktopEditor/graphics/BaseThread.h"
#include "../include/FileTransporter.h"
#include "../../../../DesktopEditor/common/ProcessEnv.h"
namespace NSNetwork
{
@ -240,13 +241,25 @@ namespace NSNetwork
{
m_pInternal->m_bComplete = false;
bool bIsCanUseNetwork = true;
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_allowNetworkRequest))
bIsCanUseNetwork = NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_allowNetworkRequest);
int hrResultAll = 0;
if(m_pInternal->m_eLoadType == m_pInternal->DOWNLOADFILE)
hrResultAll = m_pInternal->DownloadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADFILE)
hrResultAll = m_pInternal->UploadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADDATA)
hrResultAll = m_pInternal->UploadData();
if (bIsCanUseNetwork)
{
if(m_pInternal->m_eLoadType == m_pInternal->DOWNLOADFILE)
hrResultAll = m_pInternal->DownloadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADFILE)
hrResultAll = m_pInternal->UploadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADDATA)
hrResultAll = m_pInternal->UploadData();
}
else
{
hrResultAll = 1;
}
if (0 == hrResultAll)
m_pInternal->m_bComplete = true;

View File

@ -442,6 +442,36 @@ namespace NSNetwork
std::function<void(int)> func_onProgress = nullptr;
};
void EscapeQuotesPS(std::wstring& command, bool isPath)
{
/*
var symbols = [0x22, 0x27, 0x2018, 0x2019, 0x201a, 0x201b, 0x201c, 0x201d, 0x201e, 0x201f];
var output = "";
for (let i = 0; i < symbols.length; i++) output += (" " + encodeURI(String.fromCharCode(symbols[i])));
console.log(output);
result:
"%22 %27 %E2%80%98 %E2%80%99 %E2%80%9A %E2%80%9B %E2%80%9C %E2%80%9D %E2%80%9E %E2%80%9F"
*/
std::wstring sTmp = L" ";
if (isPath)
{
sTmp[0] = (wchar_t)'\\'; NSStringExt::Replace(command, sTmp, L"/");
}
sTmp[0] = (wchar_t)0x22; NSStringExt::Replace(command, sTmp, L"%22");
sTmp[0] = (wchar_t)0x27; NSStringExt::Replace(command, sTmp, L"%27");
sTmp[0] = (wchar_t)0x2018; NSStringExt::Replace(command, sTmp, L"%E2%80%98");
sTmp[0] = (wchar_t)0x2019; NSStringExt::Replace(command, sTmp, L"%E2%80%99");
sTmp[0] = (wchar_t)0x201a; NSStringExt::Replace(command, sTmp, L"%E2%80%9A");
sTmp[0] = (wchar_t)0x201b; NSStringExt::Replace(command, sTmp, L"%E2%80%9B");
sTmp[0] = (wchar_t)0x201c; NSStringExt::Replace(command, sTmp, L"%E2%80%9C");
sTmp[0] = (wchar_t)0x201d; NSStringExt::Replace(command, sTmp, L"%E2%80%9D");
sTmp[0] = (wchar_t)0x201e; NSStringExt::Replace(command, sTmp, L"%E2%80%9E");
sTmp[0] = (wchar_t)0x201f; NSStringExt::Replace(command, sTmp, L"%E2%80%9F");
}
bool DownloadFilePS(const std::wstring& sFileURLOriginal, const std::wstring& strFileOutput)
{
@ -452,8 +482,8 @@ namespace NSNetwork
std::wstring sFileDst = strFileOutput;
std::wstring sFileURL = sFileURLOriginal;
NSStringExt::Replace(sFileDst, L"\\", L"/");
NSStringExt::Replace(sFileURL, L"'", L"%27");
EscapeQuotesPS(sFileDst, true);
EscapeQuotesPS(sFileURL, false);
std::wstring sApp = L"powershell.exe c \"(new-object System.Net.WebClient).DownloadFile('" + sFileURL + L"','" + sFileDst + L"')\"";
wchar_t* pCommandLine = new wchar_t[sApp.length() + 1];

View File

@ -33,6 +33,7 @@
#include <iostream>
#include <unistd.h>
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/ProcessEnv.h"
#ifdef USE_EXTERNAL_TRANSPORT
@ -96,7 +97,7 @@ namespace NSNetwork
{
std::string sProgramBinA = U_TO_UTF8(sCurlBin);
const char* nargs[10];
const char* nargs[16];
nargs[0] = sProgramBinA.c_str();
nargs[1] = "--url";
nargs[2] = sUrlA.c_str();
@ -107,6 +108,36 @@ namespace NSNetwork
nargs[7] = "--connect-timeout";
nargs[8] = "10";
nargs[9] = NULL;
nargs[10] = NULL;
nargs[11] = NULL;
nargs[12] = NULL;
nargs[13] = NULL;
nargs[14] = NULL;
nargs[15] = NULL;
std::string sProxy;
std::string sProxyIser;
std::string sProxyHeader;
int nIndexLast = 9;
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_proxy))
{
sProxy = NSProcessEnv::GetStringValueA(NSProcessEnv::Converter::gc_proxy);
nargs[nIndexLast++] = "--proxy";
nargs[nIndexLast++] = sProxy.c_str();
}
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_proxyUser))
{
sProxyIser = NSProcessEnv::GetStringValueA(NSProcessEnv::Converter::gc_proxyUser);
nargs[nIndexLast++] = "--proxy-user";
nargs[nIndexLast++] = sProxyIser.c_str();
}
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_proxyHeader))
{
sProxyHeader = NSProcessEnv::GetStringValueA(NSProcessEnv::Converter::gc_proxyHeader);
nargs[nIndexLast++] = "--proxy-header";
nargs[nIndexLast++] = sProxyHeader.c_str();
}
const char* nenv[3];
nenv[0] = "LD_PRELOAD=";

View File

@ -229,6 +229,14 @@ core_linux {
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN/system\'"
QMAKE_LFLAGS += -Wl,--disable-new-dtags
!disable_rpath_addon {
RUN_PATH_ADDON = $$(RUN_PATH_ADDON)
!isEmpty(RUN_PATH_ADDON){
RUN_PATH_ADDON_ARRAY = $$split(RUN_PATH_ADDON, ";;")
for(rpath_item, RUN_PATH_ADDON_ARRAY):QMAKE_LFLAGS += "-Wl,-rpath,\'$$rpath_item\'"
}
}
}
}

56
Common/js/logging.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef _LOG_FILE_H
#define _LOG_FILE_H
#include <stdio.h>
#define LOG_BUFFER_SIZE 1000
namespace Logging
{
void logBytes(char* name, unsigned char* str, int len)
{
char buffer[LOG_BUFFER_SIZE];
char* name_cur = name;
char* buf_cur = buffer;
while (*name_cur != 0)
{
*buf_cur++ = *name_cur++;
}
*buf_cur++ = ':';
*buf_cur++ = ' ';
*buf_cur++ = '[';
for (int i = 0; i < len; ++i)
{
unsigned char c = str[i];
unsigned char n1 = (unsigned char)(c / 100);
c -= (n1 * 100);
unsigned char n2 = (unsigned char)(c / 10);
c -= (n2 * 10);
if (buf_cur - buffer + 4 >= LOG_BUFFER_SIZE)
{
*buf_cur++ = '\0';
printf("%s\n", buffer);
buf_cur = buffer;
}
*buf_cur++ = (char)('0' + n1);
*buf_cur++ = (char)('0' + n2);
*buf_cur++ = (char)('0' + c);
*buf_cur++ = ',';
}
buf_cur--;
*buf_cur++ = ']';
*buf_cur++ = '\0';
printf("%s\n", buffer);
}
}
#endif // _LOG_FILE_H

View File

@ -30,25 +30,27 @@ HEADERS += ./kernel_config.h
# BLOCKER
HEADERS += \
./../DesktopEditor/graphics/TemporaryCS.h
./../DesktopEditor/graphics/TemporaryCS.h
SOURCES += \
./../DesktopEditor/graphics/TemporaryCS.cpp
./../DesktopEditor/graphics/TemporaryCS.cpp
# THREAD
core_android:DEFINES += NOT_USE_PTHREAD_CANCEL USE_FILE32API
HEADERS += \
./../DesktopEditor/graphics/BaseThread.h
./../DesktopEditor/graphics/BaseThread.h \
./../DesktopEditor/graphics/BaseThreadMonitor.h
SOURCES += \
./../DesktopEditor/graphics/BaseThread.cpp
./../DesktopEditor/graphics/BaseThread.cpp \
./../DesktopEditor/graphics/BaseThreadMonitor.cpp
# TIMER
HEADERS += \
./../DesktopEditor/graphics/Timer.h
./../DesktopEditor/graphics/Timer.h
SOURCES += \
./../DesktopEditor/graphics/Timer.cpp
./../DesktopEditor/graphics/Timer.cpp
# PATH
HEADERS += ./../DesktopEditor/common/Path.h
@ -92,11 +94,11 @@ HEADERS += ./../DesktopEditor/common/ProcessEnv.h
SOURCES += ./../DesktopEditor/common/ProcessEnv.cpp
core_windows {
LIBS += -lRpcrt4
LIBS += -lShell32
LIBS += -lRpcrt4
LIBS += -lShell32
}
core_ios {
OBJECTIVE_SOURCES += ./../DesktopEditor/common/File_ios.mm
LIBS += -framework Foundation
OBJECTIVE_SOURCES += ./../DesktopEditor/common/File_ios.mm
LIBS += -framework Foundation
}

View File

@ -60,6 +60,10 @@ namespace NSDirectory
#if !defined(_WIN32) && !defined (_WIN64)
static bool is_directory_exist(char* dir)
{
#ifdef __ANDROID__
if (0 == strcmp("/storage/emulated", dir))
return true;
#endif
struct stat st;
bool bRes = (0 == stat(dir, &st)) && S_ISDIR(st.st_mode);
return bRes;

View File

@ -256,7 +256,7 @@ namespace NSFile
}
pUnicodeString[lIndexUnicode++] = (WCHAR)(val);
lIndex += 5;
lIndex += 6;
}
}
@ -986,14 +986,16 @@ namespace NSFile
}
long CFileBinary::GetFilePosition()
{
m_lFilePosition = ftell(m_pFile);
if (!m_pFile) return 0;
m_lFilePosition = ftell(m_pFile);
return m_lFilePosition;
}
unsigned long CFileBinary::GetPosition()
{
m_lFilePosition = ftell(m_pFile);
if (!m_pFile) return 0;
m_lFilePosition = ftell(m_pFile);
return (unsigned long)m_lFilePosition;
}

View File

@ -31,6 +31,7 @@
*/
#include "Path.h"
#include "File.h"
#include <stack>
#if defined(_WIN32) || defined (_WIN64)
#include <tchar.h>
@ -110,7 +111,7 @@ namespace NSSystemPath
}
template<class CHAR, class STRING = std::basic_string<CHAR, std::char_traits<CHAR>, std::allocator<CHAR>>>
STRING NormalizePathTemplate(const STRING& strFileName)
STRING NormalizePathTemplate(const STRING& strFileName, const bool& canHead = false)
{
const CHAR* pData = strFileName.c_str();
int nLen = (int) strFileName.length();
@ -124,6 +125,12 @@ namespace NSSystemPath
int nCurrentW = 0;
bool bIsUp = false;
if (canHead)
{
nCurrentSlash = 0;
pSlashPoints[0] = 0;
}
if (pData[nCurrent] == '/' || pData[nCurrent] == '\\')
{
#if !defined(_WIN32) && !defined (_WIN64)
@ -177,12 +184,69 @@ namespace NSSystemPath
return result;
}
std::string NormalizePath(const std::string& strFileName)
std::string NormalizePath(const std::string& strFileName, const bool& canHead)
{
return NormalizePathTemplate<char>(strFileName);
return NormalizePathTemplate<char>(strFileName, canHead);
}
std::wstring NormalizePath(const std::wstring& strFileName)
std::wstring NormalizePath(const std::wstring& strFileName, const bool& canHead)
{
return NormalizePathTemplate<wchar_t>(strFileName);
return NormalizePathTemplate<wchar_t>(strFileName, canHead);
}
std::wstring ShortenPath(const std::wstring &strPath, const bool& bRemoveExternalPath)
{
std::stack<std::wstring> arStack;
std::wstring wsToken;
for (size_t i = 0; i < strPath.size(); ++i)
{
if (L'/' == strPath[i] || L'\\' == strPath[i])
{
if (L".." == wsToken)
{
if (!arStack.empty() && L".." != arStack.top())
arStack.pop();
else
arStack.push(wsToken);
}
else if (L"." != wsToken && !wsToken.empty())
arStack.push(wsToken);
wsToken.clear();
}
else
wsToken += strPath[i];
}
if (L".." == wsToken)
{
if (!arStack.empty() && L".." == arStack.top())
arStack.pop();
else
arStack.push(wsToken);
}
else if (L"." != wsToken && !wsToken.empty())
arStack.push(wsToken);
wsToken.clear();
if (arStack.empty())
return std::wstring();
std::wstring wsNewPath;
while (!arStack.empty())
{
if (bRemoveExternalPath && L".." == arStack.top())
break;
wsNewPath = arStack.top() + L'/' + wsNewPath;
arStack.pop();
}
wsNewPath.pop_back();
return wsNewPath;
}
}

View File

@ -41,8 +41,9 @@ namespace NSSystemPath
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& strFileName);
KERNEL_DECL std::wstring GetFileName(const std::wstring& strFileName);
KERNEL_DECL std::wstring Combine(const std::wstring& strLeft, const std::wstring& strRight);
KERNEL_DECL std::string NormalizePath(const std::string& strFileName);
KERNEL_DECL std::wstring NormalizePath(const std::wstring& strFileName);
KERNEL_DECL std::string NormalizePath(const std::string& strFileName, const bool& canHead = false);
KERNEL_DECL std::wstring NormalizePath(const std::wstring& strFileName, const bool& canHead = false);
KERNEL_DECL std::wstring ShortenPath(const std::wstring& strPath, const bool& bRemoveExternalPath = false);
}
#endif //_BUILD_PATH_CROSSPLATFORM_H_

View File

@ -43,9 +43,14 @@
#define CXIMAGE_SUPPORT_MNG 1
#define CXIMAGE_SUPPORT_SKA 1
#define CXIMAGE_SUPPORT_RAW 1
#define CXIMAGE_SUPPORT_PSD 1
#ifndef BUILDING_WASM_MODULE
#define CXIMAGE_SUPPORT_RAW 1
#else
#define CXIMAGE_SUPPORT_RAW 0
#endif
#ifdef CXIMAGE_DISABLE_SUPPORT_MNG
#undef CXIMAGE_SUPPORT_MNG
#define CXIMAGE_SUPPORT_MNG 0

View File

@ -30,6 +30,7 @@
*
*/
#include "docbuilder_p.h"
#include "server.h"
std::wstring NSDoctRenderer::CDocBuilder_Private::m_sExternalDirectory = L"";
@ -1521,6 +1522,8 @@ namespace NSDoctRenderer
{
m_pInternal->m_bIsServerSafeVersion = true;
m_pInternal->m_sFolderForSaveOnlyUseNames = std::wstring(value);
CServerInstance::getInstance().Enable(true);
}
else if (sParam == "--all-fonts-path")
{

View File

@ -540,6 +540,42 @@ namespace NSDoctRenderer
}
break;
}
case DoctRendererFormat::WATERMARK:
{
if (!pParams->m_sJsonParams.empty())
{
std::string sTmp = U_TO_UTF8((pParams->m_sJsonParams));
args[0] = context->JSON_Parse(sTmp.c_str());
JSSmart<CJSValue> js_watermark = js_objectApi->call_func("asc_nativeGetWatermark", 1, args);
if (!try_catch->Check() && js_watermark->isString())
{
std::string sWatermark = js_watermark->toStringA();
std::string::size_type pos = sWatermark.find(',');
if (pos != std::string::npos)
{
int nInputSize = (int)(sWatermark.length() - pos) - 1;
char* pInput = (char*)(sWatermark.c_str() + pos + 1);
int nOutputSize = 0;
BYTE* pOutput = NULL;
if (NSFile::CBase64Converter::Decode(pInput, nInputSize, pOutput, nOutputSize))
{
NSFile::CFileBinary oFileWatermark;
if (oFileWatermark.CreateFileW(pParams->m_strDstFilePath))
{
oFileWatermark.WriteFile(pOutput, nOutputSize);
oFileWatermark.CloseFile();
}
RELEASEARRAYOBJECTS(pOutput);
}
}
}
}
break;
}
default:
break;
}
@ -606,27 +642,20 @@ namespace NSDoctRenderer
// Api object
JSSmart<CJSObject> js_objectApi;
// OPEN
bool bIsWatermark = (m_oParams.m_eDstFormat == NSDoctRenderer::DoctRendererFormat::WATERMARK) ? true : false;
JSSmart<CJSValue> openOptions;
if (!bIsBreak)
{
CChangesWorker oWorkerLoader;
int nVersion = oWorkerLoader.OpenNative(pNative->GetFilePath());
JSSmart<CJSValue> args_open[4];
args_open[0] = oWorkerLoader.GetDataFull()->toValue();
args_open[1] = CJSContext::createInt(nVersion);
std::wstring sXlsx = NSFile::GetDirectoryName(pNative->GetFilePath()) + L"/Editor.xlsx";
args_open[2] = NSFile::CFileBinary::Exists(sXlsx) ? CJSContext::createString(sXlsx) : CJSContext::createUndefined();
if (!m_oParams.m_sJsonParams.empty())
{
std::string sTmp = U_TO_UTF8((m_oParams.m_sJsonParams));
args_open[3] = context->JSON_Parse(sTmp.c_str());
openOptions = context->JSON_Parse(sTmp.c_str());
if (0 < m_oParams.m_nLcid)
{
if (args_open[3]->isObject())
args_open[3]->toObject()->set("locale", CJSContext::createInt(m_oParams.m_nLcid));
if (openOptions->isObject())
openOptions->toObject()->set("locale", CJSContext::createInt(m_oParams.m_nLcid));
}
}
else
@ -634,10 +663,35 @@ namespace NSDoctRenderer
JSSmart<CJSObject> optionsParams = CJSContext::createObject();
if (0 < m_oParams.m_nLcid)
optionsParams->set("locale", CJSContext::createInt(m_oParams.m_nLcid));
args_open[3] = optionsParams->toValue();
openOptions = optionsParams->toValue();
}
}
// OPEN
if (!bIsBreak)
{
if (!bIsWatermark)
{
CChangesWorker oWorkerLoader;
int nVersion = oWorkerLoader.OpenNative(pNative->GetFilePath());
JSSmart<CJSValue> args_open[4];
args_open[0] = oWorkerLoader.GetDataFull()->toValue();
args_open[1] = CJSContext::createInt(nVersion);
std::wstring sXlsx = NSFile::GetDirectoryName(pNative->GetFilePath()) + L"/Editor.xlsx";
args_open[2] = NSFile::CFileBinary::Exists(sXlsx) ? CJSContext::createString(sXlsx) : CJSContext::createUndefined();
args_open[3] = openOptions;
global_js->call_func("NativeOpenFileData", 4, args_open);
}
else
{
JSSmart<CJSValue> args_open[1];
args_open[0] = openOptions;
global_js->call_func("NativeCreateApi", 1, args_open);
}
global_js->call_func("NativeOpenFileData", 4, args_open);
if (try_catch->Check())
{
strError = L"code=\"open\"";
@ -655,7 +709,7 @@ namespace NSDoctRenderer
LOGGER_SPEED_LAP("open");
// CHANGES
if (!bIsBreak)
if (!bIsBreak && !bIsWatermark)
{
if (m_oParams.m_arChanges.size() != 0)
{
@ -892,6 +946,7 @@ namespace NSDoctRenderer
case DoctRendererFormat::PDF:
case DoctRendererFormat::IMAGE:
case DoctRendererFormat::HTML:
case DoctRendererFormat::WATERMARK:
{
arSdkFiles = &m_pInternal->m_arDoctSDK;
m_pInternal->m_strEditorType = L"document";

View File

@ -42,14 +42,15 @@ namespace NSDoctRenderer
{
enum FormatFile
{
DOCT = 0,
XLST = 1,
PPTT = 2,
PDF = 3,
HTML = 4,
DOCT = 0,
XLST = 1,
PPTT = 2,
PDF = 3,
HTML = 4,
PPTX_THEME_THUMBNAIL = 5,
IMAGE = 6,
VSDT = 7,
IMAGE = 6,
VSDT = 7,
WATERMARK = 8,
INVALID = 255
};

View File

@ -42,7 +42,8 @@ HEADERS += \
docbuilder_p.h \
nativecontrol.h \
graphics.h \
hash.h
hash.h \
server.h
HEADERS += \
embed/PointerEmbed.h \

View File

@ -564,3 +564,14 @@ JSSmart<CJSValue> CGraphicsEmbed::GetTransform()
e->set("ty", res.ty);
return e->toValue();
}
JSSmart<CJSValue> CGraphicsEmbed::CreateLayer(JSSmart<CJSValue> opacity)
{
m_pInternal->CreateLayer(opacity->toDouble());
return NULL;
}
JSSmart<CJSValue> CGraphicsEmbed::BlendLayer()
{
m_pInternal->BlendLayer();
return NULL;
}

View File

@ -82,11 +82,11 @@ public:
JSSmart<CJSValue> drawHorLine (JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW);
JSSmart<CJSValue> drawHorLine2(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW);
JSSmart<CJSValue> drawVerLine (JSSmart<CJSValue> align, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> b, JSSmart<CJSValue> penW);
// мега крутые функции для таблиц
JSSmart<CJSValue> drawHorLineExt(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW, JSSmart<CJSValue> leftMW, JSSmart<CJSValue> rightMW);
JSSmart<CJSValue> rect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
JSSmart<CJSValue> TableRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
// функции клиппирования
JSSmart<CJSValue> AddClipRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
JSSmart<CJSValue> RemoveClipRect();
JSSmart<CJSValue> SetClip(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
@ -132,6 +132,10 @@ public:
JSSmart<CJSValue> CoordTransformOffset(JSSmart<CJSValue> tx, JSSmart<CJSValue> ty);
JSSmart<CJSValue> GetTransform();
// layer
JSSmart<CJSValue> CreateLayer(JSSmart<CJSValue> opacity);
JSSmart<CJSValue> BlendLayer();
DECLARE_EMBED_METHODS
};

View File

@ -1,4 +1,5 @@
#include "NativeControlEmbed.h"
#include "../server.h"
JSSmart<CJSValue> CNativeControlEmbed::SetFilePath(JSSmart<CJSValue> path)
{
@ -24,7 +25,17 @@ JSSmart<CJSValue> CNativeControlEmbed::GetFileId()
JSSmart<CJSValue> CNativeControlEmbed::GetFileBinary(JSSmart<CJSValue> file)
{
return CJSContext::createUint8Array(file->toStringW());
std::wstring sFilePath = file->toStringW();
if (CServerInstance::getInstance().IsEnable())
{
std::wstring sFileFolder = NSFile::GetDirectoryName(m_pInternal->GetFilePath());
if (0 == sFilePath.find(sFileFolder))
return CJSContext::createUint8Array(sFilePath);
return CJSContext::createNull();
}
return CJSContext::createUint8Array(sFilePath);
}
JSSmart<CJSValue> CNativeControlEmbed::GetFontBinary(JSSmart<CJSValue> file)
@ -59,6 +70,8 @@ JSSmart<CJSValue> CNativeControlEmbed::GetFontsDirectory()
JSSmart<CJSValue> CNativeControlEmbed::GetFileString(JSSmart<CJSValue> file)
{
if (CServerInstance::getInstance().IsEnable())
return CJSContext::createNull();
return CJSContext::createUint8Array(file->toStringW());
}

View File

@ -2,6 +2,7 @@
#include "../../raster/BgraFrame.h"
#include "../../graphics/pro/Image.h"
#include "../../raster/ImageFileFormatChecker.h"
#include "server.h"
JSSmart<CJSValue> CZipEmbed::open(JSSmart<CJSValue> typedArray_or_Folder)
{
@ -18,7 +19,8 @@ JSSmart<CJSValue> CZipEmbed::open(JSSmart<CJSValue> typedArray_or_Folder)
}
else if (typedArray_or_Folder->isString())
{
m_pFolder = new CFolderSystem(typedArray_or_Folder->toStringW());
if (!CServerInstance::getInstance().IsEnable())
m_pFolder = new CFolderSystem(typedArray_or_Folder->toStringW());
}
if (!m_pFolder)
@ -174,7 +176,7 @@ JSSmart<CJSValue> CZipEmbed::encodeImageData(JSSmart<CJSValue> typedArray, JSSma
if (oFrame.Encode(pBuffer, nEncodedSize, format->toInt32()))
{
BYTE* pData = NSAllocator::Alloc((size_t)nEncodedSize);
memcpy(pData, oFrame.get_Data(), (size_t)nEncodedSize);
memcpy(pData, pBuffer, (size_t)nEncodedSize);
oFrame.FreeEncodedMemory(pBuffer);
oFrame.put_Data(NULL);
@ -228,7 +230,7 @@ JSSmart<CJSValue> CZipEmbed::encodeImage(JSSmart<CJSValue> typedArray, JSSmart<C
if (oFrame.Encode(pBuffer, nEncodedSize, format->toInt32()))
{
BYTE* pData = NSAllocator::Alloc((size_t)nEncodedSize);
memcpy(pData, oFrame.get_Data(), (size_t)nEncodedSize);
memcpy(pData, pBuffer, (size_t)nEncodedSize);
oFrame.FreeEncodedMemory(pBuffer);
oFrame.put_Data(NULL);

View File

@ -108,6 +108,8 @@
-(JSValue*) DrawPath : (JSValue*)path;
-(JSValue*) CoordTransformOffset : (JSValue*)tx : (JSValue*)ty;
-(JSValue*) GetTransform;
-(JSValue*) CreateLayer : (JSValue*)opacity;
-(JSValue*) BlendLayer;
@end
@interface CJSCGraphicsEmbed : NSObject<IJSCGraphicsEmbed, JSEmbedObjectProtocol>
@ -223,6 +225,8 @@ FUNCTION_WRAPPER_JS_0(GetlineWidth, GetlineWidth)
FUNCTION_WRAPPER_JS_1(DrawPath, DrawPath)
FUNCTION_WRAPPER_JS_2(CoordTransformOffset, CoordTransformOffset)
FUNCTION_WRAPPER_JS_0(GetTransform, GetTransform)
FUNCTION_WRAPPER_JS_1(CreateLayer, CreateLayer)
FUNCTION_WRAPPER_JS_0(BlendLayer, BlendLayer)
@end
class CGraphicsEmbedAdapter : public CJSEmbedObjectAdapterJSC

View File

@ -111,6 +111,8 @@ namespace NSGraphicsEmbed
FUNCTION_WRAPPER_V8_1(_DrawPath, DrawPath)
FUNCTION_WRAPPER_V8_2(_CoordTransformOffset, CoordTransformOffset)
FUNCTION_WRAPPER_V8_0(_GetTransform, GetTransform)
FUNCTION_WRAPPER_V8_1(_CreateLayer, CreateLayer)
FUNCTION_WRAPPER_V8_0(_BlendLayer, BlendLayer)
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
{
@ -221,6 +223,8 @@ namespace NSGraphicsEmbed
NSV8Objects::Template_Set(result, "DrawPath", _DrawPath);
NSV8Objects::Template_Set(result, "CoordTransformOffset", _CoordTransformOffset);
NSV8Objects::Template_Set(result, "GetTransform", _GetTransform);
NSV8Objects::Template_Set(result, "CreateLayer", _CreateLayer);
NSV8Objects::Template_Set(result, "BlendLayer", _BlendLayer);
return handle_scope.Escape(result);
}

View File

@ -1,5 +1,6 @@
#include "graphics.h"
#include "../common/Base64.h"
#include "../raster/Metafile/MetaFileCommon.h"
#include <string>
#include <iostream>
@ -1132,28 +1133,30 @@ namespace NSGraphics
}
std::string CGraphics::toDataURL(std::wstring type)
{
std::wstring sPath = NSFile::CFileBinary::CreateTempFileWithUniqueName(m_sApplicationImagesDirectory, L"img");
#ifdef _DEBUG
std::wcout << "toDataURL " << sPath << std::endl;
std::wcout << "toDataURL " << type << std::endl;
#endif
m_oFrame.SaveFile(sPath, _CXIMAGE_FORMAT_PNG);
std::wstring sFormat = (type.length() > 6) ? type.substr(6) : type;
NSFile::CFileBinary oReader;
if (oReader.OpenFile(sPath))
BYTE* pDataImage = NULL;
int nDataImageSize = 0;
int nImageFormat = _CXIMAGE_FORMAT_PNG;
if ((L"jpg" == sFormat) ||(L"jpeg" == sFormat))
nImageFormat = _CXIMAGE_FORMAT_JPG;
std::string sRes = "";
if (m_oFrame.Encode(pDataImage, nDataImageSize, nImageFormat))
{
DWORD dwFileSize = oReader.GetFileSize();
BYTE* pFileContent = new BYTE[dwFileSize];
DWORD dwReaded;
oReader.ReadFile(pFileContent, dwFileSize, dwReaded);
oReader.CloseFile();
NSFile::CFileBinary::Remove(sPath);
int nEncodeLen = NSBase64::Base64EncodeGetRequiredLength(dwFileSize);
BYTE* pImageData = new BYTE[nEncodeLen];
if (TRUE == NSBase64::Base64Encode(pFileContent, dwFileSize, pImageData, &nEncodeLen))
return "data:" + U_TO_UTF8(type) + ";base64, " + std::string((char*)pImageData, nEncodeLen);
char* cData64 = NULL;
int nData64Dst = 0;
if (NSFile::CBase64Converter::Encode(pDataImage, nDataImageSize, cData64, nData64Dst, NSBase64::B64_BASE64_FLAG_NOCRLF))
{
sRes = ("data:" + U_TO_UTF8(type) + ";base64," + std::string(cData64, nData64Dst));
}
RELEASEARRAYOBJECTS(cData64);
}
return "";
RELEASEARRAYOBJECTS(pDataImage);
return sRes;
}
CColor CGraphics::GetPenColor()
{
@ -1235,7 +1238,7 @@ namespace NSGraphics
pMetafile->GetBounds(&x, &y, &w, &h);
sName += L"png";
pMetafile->ConvertToRaster(sName.c_str(), 4, 1000);
MetaFile::ConvertToRasterMaxSize(pMetafile, sName.c_str(), 4, 1000);
RELEASEOBJECT(pMetafile);
}
@ -1371,4 +1374,14 @@ namespace NSGraphics
m_pRenderer->GetTransform(&oRes.sx, &oRes.shy, &oRes.shx, &oRes.sy, &oRes.tx, &oRes.ty);
return oRes;
}
void CGraphics::CreateLayer(double opacity)
{
m_pRenderer->BeginCommand(c_nLayerType);
m_pRenderer->put_LayerOpacity(opacity);
}
void CGraphics::BlendLayer()
{
m_pRenderer->EndCommand(c_nLayerType);
}
}

View File

@ -235,6 +235,10 @@ namespace NSGraphics
void DrawPath(int path);
void CoordTransformOffset(double tx, double ty);
CTransform GetTransform();
// layer
void CreateLayer(double opacity);
void BlendLayer();
};
}

View File

@ -495,6 +495,12 @@ namespace NSJSBase
* @return The pointer to resulted JS value after parsing.
*/
JSSmart<CJSValue> JSON_Parse(const char* json_content);
/**
* Creates a string that contains the JSON-serialized representation of a JS value.
* @param value The JS value to serialize.
* @return The string that contains the result of serialization, or empty string in case of errors.
*/
std::string JSON_Stringify(JSSmart<CJSValue> value);
/**
* Do not use this function. It is for internal needs.
* Associates current context with the specifed thread id.

View File

@ -387,6 +387,25 @@ namespace NSJSBase
return _value;
}
std::string CJSContext::JSON_Stringify(JSSmart<CJSValue> value)
{
CJSValueJSC* _value = static_cast<CJSValueJSC*>(value.GetPointer());
JSStringRef ret = JSValueCreateJSONString(m_internal->context.JSGlobalContextRef, _value->value.JSValueRef, 0, nullptr);
if (ret == nullptr)
return "";
const size_t nBufferSize = JSStringGetMaximumUTF8CStringSize(ret);
char* buffer = new char[nBufferSize];
if (buffer == nullptr)
return "";
JSStringGetUTF8CString(ret, buffer, nBufferSize);
std::string sRet(buffer);
delete[] buffer;
return sRet;
}
void CJSContext::MoveToThread(ASC_THREAD_ID* id)
{
if (CGlobalContext::GetInstance().RegisterContext(m_internal, id))

View File

@ -413,11 +413,44 @@ namespace NSJSBase
else
_value->doUndefined();
#else
// TODO: Use MaybeLocal version
_value->value = v8::JSON::Parse(CreateV8String(CV8Worker::GetCurrent(), sTmp));
#endif
return _value;
}
std::string CJSContext::JSON_Stringify(JSSmart<CJSValue> value)
{
// if don't return an empty string explicitly, V8 will return "undefined", which is incorrect
if (value->isUndefined())
return "";
CJSValueV8* _value = static_cast<CJSValueV8*>(value.GetPointer());
v8::MaybeLocal<v8::String> result;
#ifndef V8_OS_XP
#ifdef V8_VERSION_89_PLUS
result = v8::JSON::Stringify(m_internal->m_context, _value->value);
#else
v8::MaybeLocal<v8::Object> json_object = _value->value->ToObject(m_internal->m_context);
if (json_object.IsEmpty())
// in case of null and other non-object values
result = _value->value->ToString(m_internal->m_context);
else
result = v8::JSON::Stringify(m_internal->m_context, json_object.ToLocalChecked());
#endif
#else
// there is no built-in stringifier in V8_XP, so use JSON.stringify() from JS
v8::Local<v8::Object> json = m_internal->m_context->Global()->Get(CreateV8String(m_internal->m_isolate, "JSON"))->ToObject();
v8::Local<v8::Function> stringify = json->Get(CreateV8String(m_internal->m_isolate, "stringify")).As<v8::Function>();
result = stringify->Call(json, 1, &_value->value)->ToString(m_internal->m_context);
#endif
if (result.IsEmpty())
return "";
v8::String::Utf8Value data(V8IsolateFirstArg result.ToLocalChecked());
return std::string((char*)(*data), data.length());
}
void CJSContext::MoveToThread(ASC_THREAD_ID* id)
{
// none

View File

@ -42,6 +42,12 @@ namespace NSJSON
return m_internal->m_type == CTypedValue::vtNull;
}
bool IValue::IsInit() const
{
// the same as (m_internal->m_type != CTypedValue::vtUndefined && m_internal->m_type != CTypedValue::vtNull) but a little bit faster
return m_internal->m_value.get() != nullptr;
}
bool IValue::IsBool() const
{
return (m_internal->m_type == CTypedValue::vtPrimitive &&
@ -203,19 +209,39 @@ namespace NSJSON
int IValue::GetCount() const
{
if (m_internal->m_type == CTypedValue::vtArray)
{
return static_cast<CArray*>(m_internal->m_value.get())->getCount();
}
else if (m_internal->m_type == CTypedValue::vtTypedArray)
{
return static_cast<CTypedArray*>(m_internal->m_value.get())->getCount();
}
else
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return 0;
}
}
const CValueRef IValue::Get(int index) const
{
if (m_internal->m_type != CTypedValue::vtArray)
return CValue();
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return CValue();
}
if (index < 0 || index >= GetCount())
{
#ifdef JSON_DEBUG
throw std::out_of_range("std::out_of_range");
#endif
return CValue();
}
return static_cast<CArray*>(m_internal->m_value.get())->get(index);
}
@ -241,7 +267,12 @@ namespace NSJSON
const BYTE* IValue::GetData() const
{
if (m_internal->m_type != CTypedValue::vtTypedArray)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return nullptr;
}
return static_cast<CTypedArray*>(m_internal->m_value.get())->getData();
}
@ -253,7 +284,12 @@ namespace NSJSON
const CValueRef IValue::Get(const char* name) const
{
if (m_internal->m_type != CTypedValue::vtObject)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return CValue();
}
return static_cast<CObject*>(m_internal->m_value.get())->get(name);
}
@ -275,7 +311,12 @@ namespace NSJSON
std::vector<std::string> IValue::GetPropertyNames() const
{
if (m_internal->m_type != CTypedValue::vtObject)
{
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif
return {};
}
return static_cast<CObject*>(m_internal->m_value.get())->getPropertyNames();
}

View File

@ -20,6 +20,10 @@
// uncomment to enable exceptions throwing
//#define JSON_DEBUG
#ifdef JSON_DEBUG
#include <stdexcept>
#endif
namespace NSJSON
{
typedef unsigned char BYTE;
@ -50,6 +54,10 @@ namespace NSJSON
* Returns true if the value is null.
*/
bool IsNull() const;
/**
* Returns true if the value is not undefined or null.
*/
bool IsInit() const;
/**
* Returns true if the value is a boolean value.
*/

View File

@ -33,6 +33,7 @@
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../DesktopEditor/raster/BgraFrame.h"
#include "../../Common/Network/FileTransporter/include/FileTransporter.h"
#include "server.h"
CImagesWorker::CImagesWorker(const std::wstring& sFolder)
{
@ -42,6 +43,8 @@ CImagesWorker::CImagesWorker(const std::wstring& sFolder)
}
std::wstring CImagesWorker::GetImageLocal(const std::wstring& sUrl)
{
if (CServerInstance::getInstance().IsEnable())
return L"error";
std::wstring sExt = NSFile::GetFileExtention(sUrl);
std::wstring sRet = L"image" + std::to_wstring(m_nIndex++) + L"." + sExt;
m_mapImages.insert(std::make_pair(sUrl, sRet));

View File

@ -0,0 +1,64 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef SERVER_SETTINGS_H
#define SERVER_SETTINGS_H
// class for server version (disable local files and etc)
class CServerInstance
{
private:
bool m_bIsEnabled;
CServerInstance()
{
m_bIsEnabled = false;
}
public:
static CServerInstance& getInstance()
{
static CServerInstance server;
return server;
}
void Enable(const bool& enabled)
{
m_bIsEnabled = enabled;
}
bool IsEnable()
{
return m_bIsEnabled;
}
};
#endif // SERVER_SETTINGS_H

View File

@ -1,11 +1,17 @@
#include "gtest/gtest.h"
#include "js_internal/js_base.h"
#ifdef JS_INTERNAL_GOOGLE_TEST
#include "gtest/gtest.h"
#include <algorithm>
#else
#include <iostream>
#endif
using namespace NSJSBase;
#ifdef JS_INTERNAL_GOOGLE_TEST
// CJSObject::getPropertyNames() tests
// run with "--gtest_filter=CGetPropertyNamesTest.*" to run only this test suite
class CGetPropertyNamesTest : public testing::Test
{
public:
@ -122,3 +128,189 @@ TEST_F(CGetPropertyNamesTest, object_with_prototype)
std::vector<std::string> expected2 = {"name", "greet"};
EXPECT_TRUE(compare(result2, expected2)) << printInfo("Actual: ", result2) << printInfo("Expected: ", expected2);
}
// CJSContext::JSON_Stringify() tests
// run with "--gtest_filter=CJSONStringifyTest.*" to run only this test suite
class CJSONStringifyTest : public testing::Test
{
public:
void SetUp() override
{
// create and enter context
m_pContext = new CJSContext();
m_pContext->Enter();
}
void TearDown() override
{
m_pContext->Exit();
}
JSSmart<CJSObject> createObject(const std::string& objLiteral)
{
return m_pContext->runScript("(() => { return " + objLiteral + ";})();")->toObject();
}
public:
JSSmart<CJSContext> m_pContext;
};
TEST_F(CJSONStringifyTest, undefined)
{
JSSmart<CJSValue> jsValue = CJSContext::createUndefined();
std::string sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "");
}
TEST_F(CJSONStringifyTest, null)
{
JSSmart<CJSValue> jsValue = CJSContext::createNull();
std::string sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "null");
}
TEST_F(CJSONStringifyTest, numbers)
{
JSSmart<CJSValue> jsValue = CJSContext::createInt(42);
std::string sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "42");
jsValue = CJSContext::createUInt(7);
sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "7");
jsValue = CJSContext::createDouble(3.1415926535);
sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "3.1415926535");
}
TEST_F(CJSONStringifyTest, strings)
{
JSSmart<CJSValue> jsValue = CJSContext::createString("");
std::string sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "\"\"");
jsValue = CJSContext::createString("foo bar");
sRes = m_pContext->JSON_Stringify(jsValue);
EXPECT_EQ(sRes, "\"foo bar\"");
}
TEST_F(CJSONStringifyTest, arrays)
{
JSSmart<CJSArray> jsArr = CJSContext::createArray(0);
std::string sRes = m_pContext->JSON_Stringify(jsArr->toValue());
EXPECT_EQ(sRes, "[]");
jsArr = CJSContext::createArray(4);
jsArr->set(0, 42);
// inner array
JSSmart<CJSArray> jsArrInner = CJSContext::createArray(2);
jsArrInner->set(0, CJSContext::createString("foo"));
jsArrInner->set(1, CJSContext::createDouble(2.71828));
jsArr->set(1, jsArrInner->toValue());
jsArr->set(2, CJSContext::createNull());
jsArr->set(3, CJSContext::createUndefined());
sRes = m_pContext->JSON_Stringify(jsArr->toValue());
EXPECT_EQ(sRes, "[42,[\"foo\",2.71828],null,null]");
}
TEST_F(CJSONStringifyTest, typed_arrays)
{
BYTE* data = NSAllocator::Alloc(4);
data[0] = 0x1A;
data[1] = 0x54;
data[2] = 0xFE;
data[3] = 0xFF;
JSSmart<CJSTypedArray> jsTypedArr = CJSContext::createUint8Array(data, 4, false);
std::string sRes = m_pContext->JSON_Stringify(jsTypedArr->toValue());
EXPECT_EQ(sRes, "{\"0\":26,\"1\":84,\"2\":254,\"3\":255}");
}
TEST_F(CJSONStringifyTest, empty_object)
{
JSSmart<CJSObject> jsObj = CJSContext::createObject();
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{}");
jsObj->set("number", CJSContext::createInt(42));
jsObj->set("name", CJSContext::createString("foo"));
sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{\"number\":42,\"name\":\"foo\"}");
}
TEST_F(CJSONStringifyTest, normal_object)
{
JSSmart<CJSObject> jsObj = createObject("{number: 42, name: 'foo', arr: [1, 'abc', 2, 3], func() { return 'bar'; }}");
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{\"number\":42,\"name\":\"foo\",\"arr\":[1,\"abc\",2,3]}");
}
TEST_F(CJSONStringifyTest, only_one_function_in_object)
{
JSSmart<CJSObject> jsObj = createObject("{add(a, b) { return a + b; }}");
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{}");
}
TEST_F(CJSONStringifyTest, inner_object)
{
JSSmart<CJSObject> jsObj = createObject("{inner: {number: 42, name: 'foo'}, own: 'bar'}");
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{\"inner\":{\"number\":42,\"name\":\"foo\"},\"own\":\"bar\"}");
}
TEST_F(CJSONStringifyTest, object_with_null_and_undefined_properties)
{
JSSmart<CJSObject> jsObj = createObject("{number: null, name: undefined, func() { return 'bar'; }}");
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{\"number\":null}");
}
TEST_F(CJSONStringifyTest, object_with_only_undefined_properties)
{
JSSmart<CJSObject> jsObj = createObject("{foo: undefined, bar: undefined}");
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{}");
}
TEST_F(CJSONStringifyTest, array_as_object)
{
JSSmart<CJSObject> jsObj = createObject("{0: 4, 1: 2, 2: undefined, 3: 'foo', 42: 'bar'}");
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{\"0\":4,\"1\":2,\"3\":\"foo\",\"42\":\"bar\"}");
}
TEST_F(CJSONStringifyTest, object_with_prototype)
{
m_pContext->runScript(
"var personPrototype = { age: 42, greet() { return 'Hello, world!'; } };"
"function Person(name) { this.name = name; }"
);
JSSmart<CJSObject> jsObj = m_pContext->runScript("new Person('Foo');")->toObject();
std::string sRes = m_pContext->JSON_Stringify(jsObj->toValue());
EXPECT_EQ(sRes, "{\"name\":\"Foo\"}");
m_pContext->runScript("Object.assign(Person.prototype, personPrototype);");
sRes = m_pContext->JSON_Stringify(jsObj->toValue());
// expect the same result, because JSON.stringify does not preserve any of the not-owned properties of the object
EXPECT_EQ(sRes, "{\"name\":\"Foo\"}");
}
#else
int main()
{
JSSmart<CJSContext> pContext = new CJSContext();
CJSContextScope scope(pContext);
JSSmart<CJSObject> jsObj = CJSContext::createObject();
jsObj->set("number", CJSContext::createInt(42));
jsObj->set("name", CJSContext::createString("foo"));
std::cout << pContext->JSON_Stringify(jsObj->toValue()) << std::endl;
return 0;
}
#endif // JS_INTERNAL_GOOGLE_TEST

View File

@ -1,32 +1,40 @@
QT -= core
QT -= gui
QT -= core
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CONFIG += core_static_link_libstd
CONFIG += core_static_link_libstd
CORE_ROOT_DIR = $$PWD/../../../../../core
CORE_3DPARTY_DIR = $$CORE_ROOT_DIR/Common/3dParty
PWD_ROOT_DIR = $$PWD
#CONFIG += build_xp
include($$CORE_ROOT_DIR/Common/base.pri)
include($$CORE_3DPARTY_DIR/googletest/googletest.pri)
# Comment to inspect custom main
# Uncomment to run google tests
CONFIG += js_internal_google_test
js_internal_google_test {
include($$CORE_3DPARTY_DIR/googletest/googletest.pri)
DEFINES += JS_INTERNAL_GOOGLE_TEST
}
DESTDIR = $$PWD/build
INCLUDEPATH += $$CORE_ROOT_DIR/DesktopEditor/doctrenderer
INCLUDEPATH += ../..
ADD_DEPENDENCY(doctrenderer)
core_linux {
LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs
LIBS += -ldl
LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs
LIBS += -ldl
}
SOURCES += \
main.cpp

View File

@ -338,9 +338,16 @@ TEST_F(CJSONTest, array_from_static_method)
arr[2][0] = true;
arr[2][1] = 2.5;
EXPECT_TRUE(arr[3].IsUndefined());
#ifdef JSON_DEBUG
EXPECT_THROW(arr[100].IsUndefined(), std::out_of_range);
EXPECT_THROW(arr[-1].IsUndefined(), std::out_of_range);
EXPECT_THROW(arr[5] = 1, std::out_of_range);
#else
EXPECT_TRUE(arr[100].IsUndefined());
EXPECT_TRUE(arr[-1].IsUndefined());
arr[5] = 1;
#endif
EXPECT_EQ(arr.GetCount(), 4);
JSSmart<CJSArray> jsArr = CJSContext::createArray(4);
jsArr->set(0, CJSContext::createNull());
jsArr->set(1, CJSContext::createInt(42));
@ -357,9 +364,16 @@ TEST_F(CJSONTest, array_from_initializer_list)
{
CValue arr = {CValue::CreateNull(), 42, {true, 2.5}, CValue::CreateUndefined()};
EXPECT_TRUE(arr[3].IsUndefined());
#ifdef JSON_DEBUG
EXPECT_THROW(arr[100].IsUndefined(), std::out_of_range);
EXPECT_THROW(arr[-1].IsUndefined(), std::out_of_range);
EXPECT_THROW(arr[5] = 1, std::out_of_range);
#else
EXPECT_TRUE(arr[100].IsUndefined());
EXPECT_TRUE(arr[-1].IsUndefined());
arr[5] = 1;
#endif
EXPECT_EQ(arr.GetCount(), 4);
JSSmart<CJSArray> jsArr = CJSContext::createArray(4);
jsArr->set(0, CJSContext::createNull());
jsArr->set(1, CJSContext::createInt(42));
@ -377,14 +391,22 @@ TEST_F(CJSONTest, array_empty)
CValue arr = CValue::CreateArray(0);
EXPECT_TRUE(arr.IsArray());
EXPECT_EQ(arr.GetCount(), 0);
#ifdef JSON_DEBUG
EXPECT_THROW(arr[0].IsUndefined(), std::out_of_range);
#else
EXPECT_TRUE(arr[0].IsUndefined());
#endif
}
TEST_F(CJSONTest, array_negative_size)
{
CValue arr = CValue::CreateArray(-1);
EXPECT_TRUE(arr.IsUndefined());
EXPECT_TRUE(arr[100].IsUndefined());
#ifdef JSON_DEBUG
EXPECT_THROW(arr[0].IsUndefined(), std::bad_cast);
#else
EXPECT_TRUE(arr[0].IsUndefined());
#endif
}
TEST_F(CJSONTest, typed_array_externalize)
@ -510,11 +532,19 @@ TEST_F(CJSONTest, constants)
TEST_F(CJSONTest, wrong_usage)
{
CValue val = 42;
#ifdef JSON_DEBUG
EXPECT_THROW(val["name"].IsUndefined(), std::bad_cast);
EXPECT_THROW(val[0].IsUndefined(), std::bad_cast);
EXPECT_THROW(val.GetPropertyNames(), std::bad_cast);
EXPECT_THROW(val.GetCount(), std::bad_cast);
EXPECT_THROW(val.GetData(), std::bad_cast);
#else
EXPECT_TRUE(val["name"].IsUndefined());
EXPECT_TRUE(val[0].IsUndefined());
EXPECT_TRUE(val.GetPropertyNames().empty());
EXPECT_EQ(val.GetCount(), 0);
EXPECT_EQ(val.GetData(), nullptr);
#endif
EXPECT_DOUBLE_EQ(val.ToDouble(), 42.0);
#ifdef JSON_DEBUG
EXPECT_THROW((bool)val, std::bad_cast);
@ -557,12 +587,14 @@ TEST_F(CJSONTest, wrong_usage)
val = CValue::CreateObject();
#ifdef JSON_DEBUG
EXPECT_THROW(val[0].IsUndefined(), std::bad_cast);
EXPECT_THROW((bool)val, std::bad_cast);
EXPECT_THROW((int)val, std::bad_cast);
EXPECT_THROW((double)val, std::bad_cast);
EXPECT_THROW((std::string)val, std::bad_cast);
EXPECT_THROW((std::wstring)val, std::bad_cast);
#else
EXPECT_TRUE(val[0].IsUndefined());
EXPECT_EQ((bool)val, false);
EXPECT_EQ((int)val, 0);
EXPECT_EQ((double)val, 0.0);
@ -571,6 +603,27 @@ TEST_F(CJSONTest, wrong_usage)
#endif
}
TEST_F(CJSONTest, is_init)
{
CValue val;
EXPECT_FALSE(val.IsInit());
val = CValue::CreateNull();
EXPECT_FALSE(val.IsInit());
val = 42;
EXPECT_TRUE(val.IsInit());
CValue val2 = val;
val2 = CValue::CreateUndefined();
EXPECT_TRUE(val.IsInit());
EXPECT_FALSE(val2.IsInit());
CValueRef ref = val;
ref = CValue::CreateUndefined();
EXPECT_FALSE(val.IsInit());
EXPECT_FALSE(ref.IsInit());
ref = 3;
EXPECT_TRUE(val.IsInit());
EXPECT_TRUE(ref.IsInit());
}
// ----------- toJS() tests -----------
TEST_F(CJSONTest, toJS_undefined)

View File

@ -1,4 +1,4 @@
/*
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
@ -38,7 +38,7 @@
#ifdef _DEBUG
#define _LOGGING_NATIVE_
#else
//#define _LOGGING_NATIVE_
// #define _LOGGING_NATIVE_
#endif
#ifdef _LINUX
@ -51,9 +51,9 @@ static void LOGGING(const std::string& strFile, const std::wstring& strMessage)
{
#ifdef _LOGGING_NATIVE_
FILE* f = fopen(strFile.c_str(), "a+");
BYTE* pData = NULL;
LONG lLen = 0;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strMessage.c_str(), (LONG)strMessage.length(), pData, lLen);
pData[lLen] = 0;
@ -79,10 +79,10 @@ namespace NSMemoryStream
public:
CMemoryStream()
{
m_pBuffer = NULL;
m_pBufferMem = NULL;
m_pBuffer = NULL;
m_pBufferMem = NULL;
m_lSize = 0;
m_lSize = 0;
}
virtual ~CMemoryStream()
{
@ -100,10 +100,10 @@ namespace NSMemoryStream
inline void Clear()
{
m_lSize = 0;
m_lSize = 0;
m_pBuffer = NULL;
m_pBufferMem = NULL;
m_pBuffer = NULL;
m_pBufferMem = NULL;
}
inline void ClearNoAttack()
@ -133,17 +133,17 @@ namespace NSMemoryStream
BYTE* pNew = new BYTE[m_lSize];
memcpy(pNew, m_pBuffer, m_pBufferMem - m_pBuffer);
m_pBufferMem = pNew + (m_pBufferMem - m_pBuffer);
m_pBufferMem = pNew + (m_pBufferMem - m_pBuffer);
RELEASEARRAYOBJECTS(m_pBuffer);
m_pBuffer = pNew;
m_pBuffer = pNew;
}
}
else
{
m_lSize = 1000;
m_pBuffer = new BYTE[m_lSize];
m_pBufferMem = m_pBuffer;
m_lSize = 1000;
m_pBuffer = new BYTE[m_lSize];
m_pBufferMem = m_pBuffer;
CheckBufferSize(lPlus);
}
@ -166,23 +166,34 @@ namespace NSMemoryStream
}
inline void WriteLONG(const LONG& lValue)
{
CheckBufferSize(sizeof(INT));
CheckBufferSize(sizeof(INT));
#ifdef _ARM_ALIGN_
INT v = lValue;
memcpy(m_pBufferMem, &v, sizeof(INT));
INT v = lValue;
memcpy(m_pBufferMem, &v, sizeof(INT));
#else
*((INT*)(m_pBufferMem)) = (INT)lValue;
*((INT*)(m_pBufferMem)) = (INT)lValue;
#endif
m_pBufferMem += sizeof(INT);
m_pBufferMem += sizeof(INT);
}
inline void WriteUSHORT(const USHORT& lValue)
{
CheckBufferSize(sizeof(USHORT));
#ifdef _ARM_ALIGN_
USHORT v = lValue;
memcpy(m_pBufferMem, &v, sizeof(USHORT));
#else
*((USHORT*)(m_pBufferMem)) = (USHORT)lValue;
#endif
m_pBufferMem += sizeof(USHORT);
}
inline void WriteDouble(const double& dValue)
{
CheckBufferSize(sizeof(double));
#ifdef _ARM_ALIGN_
double v = dValue;
memcpy(m_pBufferMem, &v, sizeof(double));
double v = dValue;
memcpy(m_pBufferMem, &v, sizeof(double));
#else
*((double*)(m_pBufferMem)) = dValue;
*((double*)(m_pBufferMem)) = dValue;
#endif
m_pBufferMem += sizeof(double);
}
@ -202,112 +213,50 @@ namespace NSMemoryStream
}
inline void WriteStringA2(const char* pData, int nLen)
{
CheckBufferSize(nLen + sizeof(INT));
CheckBufferSize(nLen + sizeof(INT));
#ifdef __ANDROID__
memcpy(m_pBufferMem, &nLen, sizeof(INT));
#else
*((INT*)(m_pBufferMem)) = (INT)nLen;
#endif
m_pBufferMem += sizeof(INT);
m_pBufferMem += sizeof(INT);
memcpy(m_pBufferMem, pData, nLen);
m_pBufferMem += nLen;
}
inline void WriteStringTruncate2(const wchar_t* pData, int nLenDouble)
{
if (sizeof(wchar_t) == 2)
{
memcpy(m_pBufferMem, pData, nLenDouble);
}
else
{
int len = nLenDouble >> 1;
USHORT* mass = new USHORT[len];
for (int i = 0; i < len; ++i)
mass[i] = (USHORT)pData[i];
memcpy(m_pBufferMem, mass, nLenDouble);
RELEASEARRAYOBJECTS(mass);
}
m_pBufferMem += nLenDouble;
}
inline void WriteString(const wchar_t* pData, int nLen)
{
#ifdef _ARM_ALIGN_
CheckBufferSize(nLen + sizeof(USHORT));
USHORT v = (USHORT)(nLen);
memcpy(m_pBufferMem, &v, sizeof(USHORT));
m_pBufferMem += sizeof(USHORT);
int nLen2 = nLen << 1;
if (sizeof(wchar_t) == 2)
{
memcpy(m_pBufferMem, pData, nLen2);
}
else
{
int len = nLen >> 1;
USHORT* mass = new USHORT[len];
for (int i = 0; i < len; ++i)
mass[i] = (USHORT)pData[i];
memcpy(m_pBufferMem, mass, nLen2);
RELEASEARRAYOBJECTS(mass);
}
m_pBufferMem += nLen2;
#else
CheckBufferSize(nLen + sizeof(USHORT));
*((USHORT*)(m_pBufferMem)) = (USHORT)nLen;
m_pBufferMem += sizeof(USHORT);
int nLen2 = nLen << 1;
if (sizeof(wchar_t) == 2)
{
memcpy(m_pBufferMem, pData, nLen2);
}
else
{
int len = nLen >> 1;
USHORT* mass = new USHORT[len];
for (int i = 0; i < len; ++i)
mass[i] = (USHORT)pData[i];
memcpy(m_pBufferMem, mass, nLen2);
RELEASEARRAYOBJECTS(mass);
}
m_pBufferMem += nLen2;
#endif
CheckBufferSize(nLen2 + sizeof(USHORT));
WriteUSHORT((USHORT)(nLen));
WriteStringTruncate2(pData, nLen2);
}
inline void WriteString2(const wchar_t* pData, int nLen)
{
#ifdef _ARM_ALIGN_
int nLen2 = nLen << 1;
CheckBufferSize(nLen2 + sizeof(INT));
INT v = (INT)(nLen2);
memcpy(m_pBufferMem, &v, sizeof(INT));
m_pBufferMem += sizeof(INT);
if (sizeof(wchar_t) == 2)
{
memcpy(m_pBufferMem, pData, nLen2);
}
else
{
USHORT* mass = new USHORT[nLen];
for (int i = 0; i < nLen; ++i)
mass[i] = (USHORT)pData[i];
memcpy(m_pBufferMem, mass, nLen2);
RELEASEARRAYOBJECTS(mass);
}
m_pBufferMem += nLen2;
#else
int nLen2 = nLen << 1;
CheckBufferSize(nLen2 + sizeof(INT));
*((INT*)(m_pBufferMem)) = (INT)nLen2;
m_pBufferMem += sizeof(INT);
if (sizeof(wchar_t) == 2)
{
memcpy(m_pBufferMem, pData, nLen2);
}
else
{
USHORT* mass = new USHORT[nLen];
for (int i = 0; i < nLen; ++i)
mass[i] = (USHORT)pData[i];
memcpy(m_pBufferMem, mass, nLen2);
RELEASEARRAYOBJECTS(mass);
}
m_pBufferMem += nLen2;
#endif
CheckBufferSize(nLen2 + sizeof(INT));
WriteLONG(nLen2);
WriteStringTruncate2(pData, nLen2);
}
inline void __WriteBYTE(const BYTE& lValue)
@ -326,20 +275,20 @@ namespace NSMemoryStream
inline void __WriteLONG(const LONG& lValue)
{
#ifdef _ARM_ALIGN_
INT v = (INT)lValue;
memcpy(m_pBufferMem, &v, sizeof(INT));
INT v = (INT)lValue;
memcpy(m_pBufferMem, &v, sizeof(INT));
#else
*((INT*)(m_pBufferMem)) = (INT)lValue;
*((INT*)(m_pBufferMem)) = (INT)lValue;
#endif
m_pBufferMem += sizeof(INT);
m_pBufferMem += sizeof(INT);
}
inline void __WriteDouble(const double& dValue)
{
#ifdef _ARM_ALIGN_
double v = dValue;
memcpy(m_pBufferMem, &v, sizeof(double));
double v = dValue;
memcpy(m_pBufferMem, &v, sizeof(double));
#else
*((double*)(m_pBufferMem)) = dValue;
*((double*)(m_pBufferMem)) = dValue;
#endif
m_pBufferMem += sizeof(double);
}
@ -350,7 +299,7 @@ namespace NSMemoryStream
memcpy(m_pBufferMem, pData, len);
m_pBufferMem += len;
}
};
}
};
} // namespace NSMemoryStream
#endif // _BUILD_MEMORYSTREAM_H_

View File

@ -35,7 +35,20 @@
var AscFonts = window['AscFonts'];
if (window["NATIVE_EDITOR_ENJINE"])
window.setImmediate = function(fn) { fn(); };
{
var immediateArray = [];
window.setImmediate = function(fn) {
if (immediateArray)
immediateArray.push(fn);
else
fn();
};
window.immediateRun = function() {
for (var i = 0; i < immediateArray.length; i++)
immediateArray[i]();
immediateArray = undefined;
};
}
var setImmediate = window.setImmediate;
@ -595,6 +608,8 @@ AscFonts.Hyphen_Word = function(lang, word)
return hyphens;
};
if (window["NATIVE_EDITOR_ENJINE"])
window.immediateRun();
AscFonts.onLoadModule();
})(window, undefined);

View File

@ -262,6 +262,10 @@
"folder": "../../",
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp"]
},
{
"folder": "../../raster/",
"files": ["PICT/PICFile.cpp", "PICT/pic.cpp"]
},
{
"folder": "../../graphics/pro/js/qt/raster",
"files": ["pro_Fonts_empty.cpp", "pro_Graphics_empty.cpp", "raster.cpp"]

View File

@ -30,13 +30,13 @@
*
*/
#if defined(__ANDROID__) && !defined (NOT_USE_PTHREAD_CANCEL)
#if defined(__ANDROID__) && !defined(NOT_USE_PTHREAD_CANCEL)
#include <pthread_setcanceltype.h>
#endif
#include "./BaseThread.h"
#include "./BaseThreadMonitor.h"
#if defined(_WIN32) || defined(_WIN64) ||defined(_WIN32_WCE)
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
#include <winbase.h>
@ -49,203 +49,230 @@
namespace NSThreads
{
class CThreadDescriptor
{
public:
CThreadDescriptor()
{
}
virtual ~CThreadDescriptor()
{
}
};
class CThreadDescriptor
{
public:
CThreadDescriptor()
{
}
virtual ~CThreadDescriptor()
{
}
};
ASC_THREAD_ID GetCurrentThreadId()
{
#if defined(_WIN32) || defined (_WIN64)
return ::GetCurrentThreadId();
ASC_THREAD_ID GetCurrentThreadId()
{
#if defined(_WIN32) || defined(_WIN64)
return ::GetCurrentThreadId();
#else
return pthread_self();
return pthread_self();
#endif
}
}
void Sleep(int nMilliseconds)
void Sleep(int nMilliseconds)
{
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
::Sleep((DWORD)nMilliseconds);
#else
struct timespec tim, tim2;
tim.tv_sec = nMilliseconds / 1000;
tim.tv_nsec = (nMilliseconds % 1000) * 1000000;
tim.tv_sec = nMilliseconds / 1000;
tim.tv_nsec = (nMilliseconds % 1000) * 1000000;
::nanosleep(&tim , &tim2);
::nanosleep(&tim, &tim2);
#endif
}
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
DWORD WINAPI CBaseThread::__ThreadProc(void* pv)
{
CBaseThread* pThis = (CBaseThread*)pv;
DWORD value = pThis->ThreadProc();
if (pThis->m_bIsNeedDestroy)
delete pThis;
return value;
}
DWORD WINAPI CBaseThread::__ThreadProc(void* pv)
{
CBaseThread* pThis = (CBaseThread*)pv;
class __native_thread : public CThreadDescriptor
{
friend class CBaseThread;
private:
HANDLE m_thread = nullptr;
CBaseThreadMonitor::Get().Register(pThis);
DWORD value = pThis->ThreadProc();
CBaseThreadMonitor::Get().Unregister(pThis);
public:
__native_thread() : CThreadDescriptor()
{
}
virtual ~__native_thread()
{
if (m_thread)
{
CloseHandle(m_thread);
m_thread = NULL;
}
}
};
if (pThis->m_bIsNeedDestroy)
delete pThis;
return value;
}
class __native_thread : public CThreadDescriptor
{
friend class CBaseThread;
private:
HANDLE m_thread = nullptr;
public:
__native_thread() : CThreadDescriptor()
{
}
virtual ~__native_thread()
{
if (m_thread)
{
CloseHandle(m_thread);
m_thread = NULL;
}
}
};
#else
void* CBaseThread::__ThreadProc(void* pv)
{
void* CBaseThread::__ThreadProc(void* pv)
{
#ifndef NOT_USE_PTHREAD_CANCEL
int old_thread_type;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old_thread_type);
int old_thread_type;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old_thread_type);
#endif
CBaseThread* pThis = (CBaseThread*)pv;
pThis->ThreadProc();
CBaseThread* pThis = (CBaseThread*)pv;
if (pThis->m_bIsNeedDestroy)
delete pThis;
CBaseThreadMonitor::Get().Register(pThis);
DWORD value = pThis->ThreadProc();
CBaseThreadMonitor::Get().Unregister(pThis);
return NULL;
}
class __native_thread : public CThreadDescriptor
{
friend class CBaseThread;
private:
pthread_t m_thread;
if (pThis->m_bIsNeedDestroy)
delete pThis;
public:
__native_thread() : CThreadDescriptor()
{
m_thread = NULL;
}
virtual ~__native_thread()
{
}
};
return NULL;
}
class __native_thread : public CThreadDescriptor
{
friend class CBaseThread;
private:
pthread_t m_thread;
public:
__native_thread() : CThreadDescriptor()
{
m_thread = NULL;
}
virtual ~__native_thread()
{
}
};
#endif
CBaseThread::CBaseThread()
{
m_hThread = NULL;
m_bRunThread = FALSE;
m_bSuspend = FALSE;
CBaseThread::CBaseThread()
{
m_hThread = NULL;
m_bRunThread = FALSE;
m_bSuspend = FALSE;
m_lError = 0;
m_lThreadPriority = 0;
m_lError = 0;
m_lThreadPriority = 0;
m_bIsNeedDestroy = false;
}
CBaseThread::~CBaseThread()
{
Stop();
}
void CBaseThread::Start(int lPriority)
{
if (m_bRunThread)
return;
m_lError = 0;
m_bSuspend = FALSE;
m_bIsNeedDestroy = false;
}
CBaseThread::~CBaseThread()
{
Stop();
}
void CBaseThread::Start(int lPriority)
{
if (m_bRunThread)
return;
m_lError = 0;
m_bSuspend = FALSE;
m_hThread = new __native_thread();
m_hThread = new __native_thread();
m_bRunThread = TRUE;
m_bRunThread = TRUE;
m_bIsExit.store(false);
m_bIsExit.store(false);
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
DWORD dwTemp;
((__native_thread*)m_hThread)->m_thread = CreateThread(NULL, 0, &__ThreadProc, (void*)this, 0, &dwTemp);
SetThreadPriority(((__native_thread*)m_hThread)->m_thread, lPriority);
DWORD dwTemp;
((__native_thread*)m_hThread)->m_thread = CreateThread(NULL, 0, &__ThreadProc, (void*)this, 0, &dwTemp);
SetThreadPriority(((__native_thread*)m_hThread)->m_thread, lPriority);
#else
pthread_create(&((__native_thread*)m_hThread)->m_thread, 0, &__ThreadProc, (void*)this);
pthread_create(&((__native_thread*)m_hThread)->m_thread, 0, &__ThreadProc, (void*)this);
#endif
m_lThreadPriority = lPriority;
}
void CBaseThread::Suspend()
{
m_bSuspend = TRUE;
}
void CBaseThread::Resume()
{
m_bSuspend = FALSE;
}
void CBaseThread::Stop()
{
if (!m_bRunThread)
return;
m_lThreadPriority = lPriority;
}
void CBaseThread::Suspend()
{
m_bSuspend = TRUE;
}
void CBaseThread::Resume()
{
m_bSuspend = FALSE;
}
void CBaseThread::Stop()
{
if (!m_bRunThread)
return;
m_bIsExit.store(true);
m_bRunThread = FALSE;
m_bIsExit.store(true);
m_bRunThread = FALSE;
Join();
RELEASEOBJECT(m_hThread);
}
void CBaseThread::StopNoJoin()
{
m_bRunThread = FALSE;
m_bIsExit.store(true);
RELEASEOBJECT(m_hThread);
}
void CBaseThread::DestroyOnFinish()
{
m_bIsNeedDestroy = true;
}
Join();
RELEASEOBJECT(m_hThread);
}
void CBaseThread::StopNoJoin()
{
m_bRunThread = FALSE;
m_bIsExit.store(true);
RELEASEOBJECT(m_hThread);
}
void CBaseThread::DestroyOnFinish()
{
m_bIsNeedDestroy = true;
}
INT CBaseThread::IsSuspended() { return m_bSuspend; }
INT CBaseThread::IsRunned() { return m_bRunThread; }
int CBaseThread::GetError() { return m_lError; }
bool CBaseThread::isAborted() {return m_bIsExit && m_bIsExit.load();}
INT CBaseThread::IsSuspended()
{
return m_bSuspend;
}
INT CBaseThread::IsRunned()
{
return m_bRunThread;
}
int CBaseThread::GetError()
{
return m_lError;
}
bool CBaseThread::isAborted()
{
return m_bIsExit && m_bIsExit.load();
}
CThreadDescriptor* CBaseThread::GetDescriptor() { return m_hThread; }
int CBaseThread::GetPriority() { return m_lThreadPriority; }
CThreadDescriptor* CBaseThread::GetDescriptor()
{
return m_hThread;
}
int CBaseThread::GetPriority()
{
return m_lThreadPriority;
}
void CBaseThread::CheckSuspend()
{
while (m_bSuspend && m_bRunThread)
NSThreads::Sleep(10);
}
void CBaseThread::CheckSuspend()
{
while (m_bSuspend && m_bRunThread)
NSThreads::Sleep(10);
}
void CBaseThread::Join()
{
if (NULL == m_hThread)
return;
void CBaseThread::Join()
{
if (NULL == m_hThread)
return;
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
WaitForSingleObject(((__native_thread*)m_hThread)->m_thread, INFINITE);
WaitForSingleObject(((__native_thread*)m_hThread)->m_thread, INFINITE);
#else
pthread_join(((__native_thread*)m_hThread)->m_thread, 0);
pthread_join(((__native_thread*)m_hThread)->m_thread, 0);
#endif
}
}
void CBaseThread::Cancel()
{
if (NULL == m_hThread)
return;
void CBaseThread::Cancel()
{
if (NULL == m_hThread)
return;
m_bIsExit.store(true);
m_bIsExit.store(true);
m_bRunThread = FALSE;
m_bRunThread = FALSE;
Join();
RELEASEOBJECT(m_hThread);
}
}
Join();
RELEASEOBJECT(m_hThread);
}
} // namespace NSThreads

View File

@ -41,7 +41,7 @@
#include <pthread.h>
#endif
#if defined(_WIN32) || defined (_WIN64)
#if defined(_WIN32) || defined(_WIN64)
typedef DWORD ASC_THREAD_ID;
#else
typedef pthread_t ASC_THREAD_ID;
@ -51,56 +51,57 @@ typedef pthread_t ASC_THREAD_ID;
namespace NSThreads
{
KERNEL_DECL ASC_THREAD_ID GetCurrentThreadId();
KERNEL_DECL ASC_THREAD_ID GetCurrentThreadId();
KERNEL_DECL void Sleep(int nMilliseconds);
KERNEL_DECL void Sleep(int nMilliseconds);
class CThreadDescriptor;
class KERNEL_DECL CBaseThread
class CThreadDescriptor;
class KERNEL_DECL CBaseThread
{
protected:
CThreadDescriptor* m_hThread;
INT m_bRunThread;
INT m_bSuspend;
CThreadDescriptor* m_hThread;
INT m_bRunThread;
INT m_bSuspend;
int m_lError;
int m_lThreadPriority;
int m_lError;
int m_lThreadPriority;
bool m_bIsNeedDestroy;
std::atomic<bool> m_bIsExit{false};
bool m_bIsNeedDestroy;
std::atomic<bool> m_bIsExit{false};
public:
CBaseThread();
virtual ~CBaseThread();
CBaseThread();
virtual ~CBaseThread();
public:
virtual void Start(int lPriority);
virtual void Suspend();
virtual void Resume();
virtual void Stop();
virtual void StopNoJoin();
virtual void DestroyOnFinish();
virtual void Cancel();
virtual void Start(int lPriority);
virtual void Suspend();
virtual void Resume();
virtual void Stop();
virtual void StopNoJoin();
virtual void DestroyOnFinish();
virtual void Cancel();
INT IsSuspended();
INT IsRunned();
bool isAborted();
int GetError();
INT IsSuspended();
INT IsRunned();
bool isAborted();
int GetError();
CThreadDescriptor* GetDescriptor();
int GetPriority();
virtual void CheckSuspend();
CThreadDescriptor* GetDescriptor();
int GetPriority();
virtual void CheckSuspend();
protected:
virtual void Join();
virtual void Join();
virtual DWORD ThreadProc() = 0;
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
static DWORD WINAPI __ThreadProc(void* pv);
static DWORD WINAPI __ThreadProc(void* pv);
#else
static void* __ThreadProc(void* pv);
static void* __ThreadProc(void* pv);
#endif
};
};
}
#endif // _BUILD_BASETHREAD_H_

View File

@ -0,0 +1,150 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "./BaseThreadMonitor.h"
namespace NSThreads
{
CBaseThreadMonitor::CBaseThreadMonitor()
{
m_bIsInit = false;
m_pReceiver = NULL;
m_funcRelease = nullptr;
m_oCS.InitializeCriticalSection();
}
CBaseThreadMonitor::~CBaseThreadMonitor()
{
m_oCS.DeleteCriticalSection();
}
CBaseThreadMonitor& CBaseThreadMonitor::Get()
{
static CBaseThreadMonitor instance;
return instance;
}
bool CBaseThreadMonitor::Init(void* receiver)
{
CTemporaryCS oCS(&m_oCS);
if (m_bIsInit)
return false;
m_bIsInit = true;
m_pReceiver = receiver;
return true;
}
bool CBaseThreadMonitor::Destroy()
{
CTemporaryCS oCS(&m_oCS);
if (!m_bIsInit)
return false;
m_bIsInit = false;
m_pReceiver = NULL;
m_listThreads.clear();
return true;
}
bool CBaseThreadMonitor::IsInit()
{
CTemporaryCS oCS(&m_oCS);
return m_bIsInit;
}
NSCriticalSection::CRITICAL_SECTION* CBaseThreadMonitor::GetCS()
{
return &m_oCS;
}
CBaseThread* CBaseThreadMonitor::GetBaseThread(const ASC_THREAD_ID& nThreadId)
{
// лист - потому что будет всегда мало записей - и то будет быстрее мапа. двигаем всегда текущий на первое место
if (m_listThreads.size() == 0)
return NULL;
std::list<CBaseThreadInfo>::iterator i = m_listThreads.begin();
if (i->ID == nThreadId)
return i->Instance;
i++;
while (i != m_listThreads.end())
{
if (i->ID == nThreadId)
{
m_listThreads.erase(i);
m_listThreads.insert(m_listThreads.begin(), *i);
return i->Instance;
}
i++;
}
return NULL;
}
void CBaseThreadMonitor::SetReleaseHandler(std::function<void(void* initializer, CBaseThread*)> func)
{
CTemporaryCS oCS(&m_oCS);
m_funcRelease = func;
}
void CBaseThreadMonitor::Register(CBaseThread* pInstance)
{
CTemporaryCS oCS(&m_oCS);
if (!m_bIsInit)
return;
m_listThreads.push_back({NSThreads::GetCurrentThreadId(), pInstance});
}
void CBaseThreadMonitor::Unregister(CBaseThread* pInstance)
{
CTemporaryCS oCS(&m_oCS);
if (!m_bIsInit)
return;
for (std::list<CBaseThreadInfo>::iterator i = m_listThreads.begin(); i != m_listThreads.end(); i++)
{
if (i->Instance == pInstance)
{
m_listThreads.erase(i);
if (m_funcRelease)
m_funcRelease(m_pReceiver, pInstance);
return;
}
}
}
}

View File

@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _BUILD_BASETHREAD_MONITOR_H_
#define _BUILD_BASETHREAD_MONITOR_H_
#include "BaseThread.h"
#include "TemporaryCS.h"
#include <functional>
#include <list>
namespace NSThreads
{
class CBaseThreadInfo
{
public:
ASC_THREAD_ID ID;
CBaseThread* Instance;
};
class KERNEL_DECL CBaseThreadMonitor
{
private:
NSCriticalSection::CRITICAL_SECTION m_oCS;
bool m_bIsInit;
void* m_pReceiver;
std::function<void(void* initializer, CBaseThread*)> m_funcRelease;
std::list<CBaseThreadInfo> m_listThreads;
private:
CBaseThreadMonitor();
public:
static CBaseThreadMonitor& Get();
~CBaseThreadMonitor();
public:
bool IsInit();
bool Init(void* receiver);
bool Destroy();
CBaseThread* GetBaseThread(const ASC_THREAD_ID& nThreadId);
void SetReleaseHandler(std::function<void(void* initializer, CBaseThread*)> func);
NSCriticalSection::CRITICAL_SECTION* GetCS();
private:
void Register(CBaseThread* pInstance);
void Unregister(CBaseThread* pInstance);
friend class CBaseThread;
};
}
#endif // _BUILD_BASETHREAD_MONITOR_H_

View File

@ -38,7 +38,7 @@
#include "../common/File.h"
#ifndef GRAPHICS_DISABLE_METAFILE
#include "../raster/Metafile/MetaFile.h"
#include "../raster/Metafile/MetaFileCommon.h"
#endif
#if defined (GetTempPath)
@ -77,9 +77,11 @@ public:
else
{
std::wstring sTempFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"AscMetafile_");
pMetafile->ConvertToRaster(sTempFile.c_str(), 4, 1000, -1);
m_oImage.Create(sTempFile);
//pMetafile->ConvertToRaster(sTempFile.c_str(), 4, 1000, -1);
MetaFile::ConvertToRasterMaxSize(pMetafile, sTempFile.c_str(), 4, 1000);
m_oImage.Create(sTempFile);
NSFile::CFileBinary::Remove(sTempFile);
}
RELEASEINTERFACE(pMetafile);

View File

@ -5,6 +5,7 @@ import base
base.configure_common_apps()
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;", "\n{\n UDataMemory tData;")
base.replaceInFile("../../../../DesktopEditor/cximage/png/pnglibconf.h", "//#define PNG_CONSOLE_IO_SUPPORTED", "#define PNG_CONSOLE_IO_SUPPORTED")
# finalize
base.replaceInFile("./deploy/drawingfile.js", "function getBinaryPromise(", "function getBinaryPromise2(")

View File

@ -13,6 +13,8 @@ if not base.is_dir("xml"):
base.replaceInFile("./xml/src/xmllight_private.h", "#include \"../../common/", "#include \"../../../../../common/")
base.replaceInFile("./xml/src/xmllight_private.h", "#include \"../../../UnicodeConverter/", "#include \"../../../../../../UnicodeConverter/")
base.replaceInFile("./xml/include/xmlutils.h", "#include \"../../common/", "#include \"../../../../../common/")
base.replaceInFile("./xml/libxml2/globals.c", "int xmlGetWarningsDefaultValue = 1;", "int xmlGetWarningsDefaultValue = 0;")
base.replaceInFile("./xml/libxml2/globals.c", "static int xmlGetWarningsDefaultValueThrDef = 1;", "static int xmlGetWarningsDefaultValueThrDef = 0;")
if not base.is_dir("freetype-2.10.4"):
base.copy_dir("../../../freetype-2.10.4", "./freetype-2.10.4")
@ -34,3 +36,4 @@ if not base.is_dir("freetype-2.10.4"):
common.apply_patch("./freetype-2.10.4/builds/unix/ftsystem.c", "./wasm/patches/ftsystem.patch")
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n UDataMemory tData;", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;")
base.replaceInFile("../../../../DesktopEditor/cximage/png/pnglibconf.h", "#define PNG_CONSOLE_IO_SUPPORTED", "//#define PNG_CONSOLE_IO_SUPPORTED")

View File

@ -47,7 +47,8 @@
"_SetCMapData"
],
"include_path": [
"wasm/src/lib", "../../../agg-2.4/include", "../../../cximage/jasper/include", "../../../cximage/jpeg", "../../../cximage/png", "freetype-2.10.4/include", "freetype-2.10.4/include/freetype", "../../../../OfficeUtils/src/zlib-1.2.11", "../../../../OfficeUtils/src", "../../../../Common/3dParty/icu/icu/source/common", "../../../xml/libxml2/include", "../../../xml/build/qt", "../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip", "../../../../PdfFile/lib/goo", "../../../../PdfFile/lib/fofi", "../../../../PdfFile/lib/splash", "../../../../PdfFile/lib", "../../../raster/Jp2/openjpeg", "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2"
"wasm/src/lib", "../../../agg-2.4/include", "../../../cximage/jasper/include", "../../../cximage/jpeg", "../../../cximage/png", "freetype-2.10.4/include", "freetype-2.10.4/include/freetype", "../../../../OfficeUtils/src/zlib-1.2.11", "../../../../OfficeUtils/src", "../../../../Common/3dParty/icu/icu/source/common", "../../../xml/libxml2/include", "../../../xml/build/qt", "../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip", "../../../../PdfFile/lib/goo", "../../../../PdfFile/lib/fofi", "../../../../PdfFile/lib/splash", "../../../../PdfFile/lib", "../../../raster/Jp2/openjpeg", "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2",
"../../../../Common/3dParty/openssl/openssl/include"
],
"define": [
"__linux__", "_LINUX", "UNIX",
@ -60,11 +61,12 @@
"LIBXML_READER_ENABLED", "LIBXML_PUSH_ENABLED", "LIBXML_HTML_ENABLED",
"LIBXML_XPATH_ENABLED", "LIBXML_OUTPUT_ENABLED", "LIBXML_C14N_ENABLED",
"LIBXML_SAX1_ENABLED", "LIBXML_TREE_ENABLED", "LIBXML_XPTR_ENABLED",
"IN_LIBXML", "LIBXML_STATIC", "BUILD_ZLIB_AS_SOURCES",
"XML_ERROR_DISABLE_MODE", "IN_LIBXML", "LIBXML_STATIC", "BUILD_ZLIB_AS_SOURCES",
"_ARM_ALIGN_",
"_tcsnicmp=strncmp", "_lseek=lseek", "_getcwd=getcwd",
"NO_CONSOLE_IO", "USE_EXTERNAL_JPEG2000", "USE_JPIP", "OPJ_STATIC", "FONT_ENGINE_DISABLE_FILESYSTEM",
"IMAGE_CHECKER_DISABLE_XML"
"IMAGE_CHECKER_DISABLE_XML",
"USE_OPENSSL_HASH"
],
"compile_files_array": [
{

View File

@ -27,7 +27,8 @@ INCLUDEPATH += \
$$CORE_ROOT_DIR/DesktopEditor/cximage/jpeg \
$$CORE_ROOT_DIR/DesktopEditor/cximage/png \
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include \
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include/freetype
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include/freetype \
$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl/include
win32 {
DEFINES += \

View File

@ -563,7 +563,7 @@
let n = reader.readInt();
rec["C"] = [];
for (let i = 0; i < n; ++i)
rec["C"].push(reader.readDouble());
rec["C"].push(reader.readDouble2());
}
// Border/BS
if (flags & (1 << 4))
@ -718,6 +718,13 @@
for (let i = 0; i < n; ++i)
rec["value"].push(reader.readString());
}
if (flags & (1 << 6))
{
let n = reader.readInt();
rec["Opt"] = [];
for (let i = 0; i < n; ++i)
rec["Opt"].push(reader.readString());
}
res["Parents"].push(rec);
}
@ -741,7 +748,7 @@
{
rec["font"]["color"] = [];
for (let i = 0; i < tc; ++i)
rec["font"]["color"].push(reader.readDouble());
rec["font"]["color"].push(reader.readDouble2());
}
// 0 - left-justified, 1 - centered, 2 - right-justified
rec["alignment"] = reader.readByte();
@ -775,7 +782,7 @@
let n = reader.readInt();
rec["BC"] = [];
for (let i = 0; i < n; ++i)
rec["BC"].push(reader.readDouble());
rec["BC"].push(reader.readDouble2());
}
// Rotate an annotation relative to the page - R
if (flags & (1 << 6))
@ -786,7 +793,7 @@
let n = reader.readInt();
rec["BG"] = [];
for (let i = 0; i < n; ++i)
rec["BG"].push(reader.readDouble());
rec["BG"].push(reader.readDouble2());
}
// Default value - DV
if (flags & (1 << 8))
@ -795,6 +802,8 @@
rec["Parent"] = reader.readInt();
if (flags & (1 << 18))
rec["name"] = reader.readString();
if (flags & (1 << 19))
rec["font"]["AP"] = reader.readString();
// Action
let nAction = reader.readInt();
if (nAction > 0)
@ -999,7 +1008,7 @@
}
let res = {};
let ext = Module["_GetButtonIcons"](this.nativeFile, width, height, backgroundColor === undefined ? 0xFFFFFF : backgroundColor, pageIndex, bBase64 ? 1 : 0, nWidget === undefined ? -1 : nWidget, nView);
let ext = Module["_GetButtonIcons"](this.nativeFile, backgroundColor === undefined ? 0xFFFFFF : backgroundColor, pageIndex, bBase64 ? 1 : 0, nWidget === undefined ? -1 : nWidget, nView);
if (ext == 0)
return res;
@ -1176,7 +1185,7 @@
let n = reader.readInt();
rec["IC"] = [];
for (let i = 0; i < n; ++i)
rec["IC"].push(reader.readDouble());
rec["IC"].push(reader.readDouble2());
}
// LL
if (flags & (1 << 17))
@ -1244,7 +1253,7 @@
let n = reader.readInt();
rec["IC"] = [];
for (let i = 0; i < n; ++i)
rec["IC"].push(reader.readDouble());
rec["IC"].push(reader.readDouble2());
}
}
// Polygon, PolyLine
@ -1268,7 +1277,7 @@
let n = reader.readInt();
rec["IC"] = [];
for (let i = 0; i < n; ++i)
rec["IC"].push(reader.readDouble());
rec["IC"].push(reader.readDouble2());
}
// IT
// 0 - PolygonCloud, 1 - PolyLineDimension, 2 - PolygonDimension
@ -1329,7 +1338,7 @@
let n = reader.readInt();
rec["C"] = [];
for (let i = 0; i < n; ++i)
rec["C"].push(reader.readDouble());
rec["C"].push(reader.readDouble2());
}
}
// Caret

View File

@ -177,7 +177,7 @@ WASM_EXPORT BYTE* GetInteractiveFormsAP(CGraphicsFileDrawing* pGraphics, int nRa
return pGraphics->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sButtonView);
}
WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int bBase64, int nButtonWidget, int nIconView)
WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nBackgroundColor, int nPageIndex, int bBase64, int nButtonWidget, int nIconView)
{
const char* sIconView = NULL;
if (nIconView == 0)
@ -187,7 +187,7 @@ WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nRasterW,
else if (nIconView == 2)
sIconView = "IX";
return pGraphics->GetButtonIcon(nRasterW, nRasterH, nBackgroundColor, nPageIndex, bBase64 ? true : false, nButtonWidget, sIconView);
return pGraphics->GetButtonIcon(nBackgroundColor, nPageIndex, bBase64 ? true : false, nButtonWidget, sIconView);
}
WASM_EXPORT BYTE* GetAnnotationsInfo(CGraphicsFileDrawing* pGraphics, int nPageIndex)
{

View File

@ -154,10 +154,10 @@ public:
return ((CPdfFile*)pReader)->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sBView);
return NULL;
}
BYTE* GetButtonIcon(int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, bool bBase64, int nBWidget = -1, const char* sIView = NULL)
BYTE* GetButtonIcon(int nBackgroundColor, int nPageIndex, bool bBase64, int nBWidget = -1, const char* sIView = NULL)
{
if (nType == 0)
return ((CPdfFile*)pReader)->GetButtonIcon(nRasterW, nRasterH, nBackgroundColor, nPageIndex, bBase64, nBWidget, sIView);
return ((CPdfFile*)pReader)->GetButtonIcon(nBackgroundColor, nPageIndex, bBase64, nBWidget, sIView);
return NULL;
}
BYTE* GetAPAnnots (int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nAnnot = -1, const char* sView = NULL)

View File

@ -225,7 +225,7 @@ void ReadAnnot(BYTE* pWidgets, int& i)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << (double)nPathLength / 100.0 << " ";
std::cout << (double)nPathLength / 10000.0 << " ";
}
std::cout << ", ";
}
@ -356,6 +356,21 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
}
std::cout << ", ";
}
if (nFlags & (1 << 6))
{
int nILength = READ_INT(pWidgets + i);
i += 4;
std::cout << "Opt [";
for (int j = 0; j < nILength; ++j)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << " " << std::string((char*)(pWidgets + i), nPathLength);
i += nPathLength;
}
std::cout << " ], ";
}
std::cout << std::endl;
}
@ -400,7 +415,7 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << " " << (double)nPathLength / 100.0;
std::cout << " " << (double)nPathLength / 10000.0;
}
std::cout << ", ";
}
@ -464,7 +479,7 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << (double)nPathLength / 100.0 << " ";
std::cout << (double)nPathLength / 10000.0 << " ";
}
std::cout << ", ";
}
@ -484,7 +499,7 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << (double)nPathLength / 100.0 << " ";
std::cout << (double)nPathLength / 10000.0 << " ";
}
std::cout << ", ";
}
@ -508,6 +523,13 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
std::cout << "Name " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
}
if (nFlags & (1 << 19))
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "Font button " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
}
//Action
@ -1086,7 +1108,7 @@ int main(int argc, char* argv[])
free(pWidgetsAP);
int bBase64 = 1;
BYTE* pWidgetsMK = GetButtonIcons(pGrFile, nWidth, nHeight, 0xFFFFFF, nTestPage, bBase64, -1, -1);
BYTE* pWidgetsMK = GetButtonIcons(pGrFile, 0xFFFFFF, nTestPage, bBase64, -1, -1);
nLength = READ_INT(pWidgetsMK);
i = 4;
nLength -= 4;
@ -1310,7 +1332,7 @@ int main(int argc, char* argv[])
{
nPathLength = READ_INT(pAnnots + i);
i += 4;
std::cout << " " << (double)nPathLength / 100.0;
std::cout << " " << (double)nPathLength / 10000.0;
}
std::cout << ", ";
}
@ -1425,7 +1447,7 @@ int main(int argc, char* argv[])
{
nPathLength = READ_INT(pAnnots + i);
i += 4;
std::cout << (double)nPathLength / 100.0 << " ";
std::cout << (double)nPathLength / 10000.0 << " ";
}
std::cout << ", ";
}
@ -1467,7 +1489,7 @@ int main(int argc, char* argv[])
{
nPathLength = READ_INT(pAnnots + i);
i += 4;
std::cout << " " << (double)nPathLength / 100.0;
std::cout << " " << (double)nPathLength / 10000.0;
}
std::cout << ", ";
}
@ -1557,7 +1579,7 @@ int main(int argc, char* argv[])
{
nPathLength = READ_INT(pAnnots + i);
i += 4;
std::cout << " " << (double)nPathLength / 100.0;
std::cout << " " << (double)nPathLength / 10000.0;
}
std::cout << ", ";
}

View File

@ -80,7 +80,7 @@ namespace MetaFile
virtual bool IsWindowFlippedY() = 0;
virtual bool IsWindowFlippedX() = 0;
virtual unsigned int GetMapMode() = 0;
virtual double GetDpi() = 0;
virtual USHORT GetDpi() = 0;
virtual IRegion* GetRegion() = 0;
virtual unsigned int GetArcDirection() = 0;
virtual CPath* GetPath() = 0;

View File

@ -454,7 +454,12 @@ namespace MetaFile
}
else
{
pFontManager->LoadFontByName(wsFaceName, dFontHeight, lStyle, 72, 72);
double dRendererDpiX, dRendererDpiY;
m_pRenderer->get_DpiX(&dRendererDpiX);
m_pRenderer->get_DpiY(&dRendererDpiY);
pFontManager->LoadFontByName(wsFaceName, dFontHeight, lStyle, dRendererDpiX, dRendererDpiY);
pFontManager->SetCharSpacing(dFontCharSpace * 72 / 25.4);
double dMmToPt = 25.4 / 72;
@ -1220,7 +1225,7 @@ namespace MetaFile
double dWidth = pPen->GetWidth();
if (Equals(0, dWidth) || PS_COSMETIC == ulPenType)
if (Equals(0, dWidth) || (Equals(1, dWidth) && PS_COSMETIC == ulPenType))
{
double dRendererDpiX;
m_pRenderer->get_DpiX(&dRendererDpiX);

View File

@ -44,7 +44,7 @@
#define DIB_RGB_COLORS 0x00
#endif
#define MINACCURACY 3
#define MINACCURACY 5
#define MAXACCURACY 10
namespace MetaFile
@ -1097,7 +1097,7 @@ namespace MetaFile
if (std::wstring::npos == unFirstPosition)
return wsValue.substr(0, unDotPosition);
const size_t unLastPosition = wsValue.find_last_not_of(L'0', unFirstPosition + 2);
const size_t unLastPosition = wsValue.find_last_not_of(L'0', unFirstPosition + MINACCURACY - 1);
return wsValue.substr(0, unLastPosition + 1);
}

View File

@ -749,9 +749,9 @@ namespace MetaFile
return m_pDC->GetMapMode();
}
double CEmfParserBase::GetDpi()
USHORT CEmfParserBase::GetDpi()
{
return 96.;
return 96;
}
IRegion *CEmfParserBase::GetRegion()

View File

@ -79,7 +79,7 @@ namespace MetaFile
bool IsWindowFlippedY() override;
bool IsWindowFlippedX() override;
unsigned int GetMapMode() override;
double GetDpi() override;
USHORT GetDpi() override;
IRegion* GetRegion() override;
unsigned int GetArcDirection() override;
CPath* GetPath() override;

View File

@ -336,9 +336,9 @@ namespace MetaFile
this->ClearFile();
}
double CEmfPlusParser::GetDpi()
USHORT CEmfPlusParser::GetDpi()
{
return (double)m_unLogicalDpiX;
return m_unLogicalDpiX;
}
EmfParserType CEmfPlusParser::GetType()
@ -919,6 +919,9 @@ namespace MetaFile
m_oStream >> unLength;
if (unLength > 15) // 30 байта / 2 (размер ushort) = 15 символов максимальная длина имени Unicode шрифта
unLength = 15;
unsigned short* pString = new unsigned short[unLength + 1];
if (pString)
{
@ -2346,6 +2349,9 @@ namespace MetaFile
if (0 == unLength)
return;
if (2 * unLength > m_ulRecordSize - 28) // 28 = 4*3 + 4*4
unLength = m_ulRecordSize - 28;
m_oStream >> oRect;
unsigned short* pString = new unsigned short[unLength + 1];

View File

@ -21,7 +21,7 @@ namespace MetaFile
void PlayFile() override;
void Scan() override;
double GetDpi() override;
USHORT GetDpi() override;
EmfParserType GetType() override;

View File

@ -0,0 +1,64 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _METAFILE_COMMON_H
#define _METAFILE_COMMON_H
#include "./MetaFile.h"
namespace MetaFile
{
static void ConvertToRasterMaxSize(MetaFile::IMetaFile* pMetafile, const wchar_t* wsOutFilePath, unsigned int unFileType, int nOneMaxSize)
{
double dX, dY, dW, dH;
pMetafile->GetBounds(&dX, &dY, &dW, &dH);
if (dW < 0) dW = -dW;
if (dH < 0) dH = -dH;
double dOneMaxSize = (double)nOneMaxSize;
if (dW > dH)
{
dH *= (dOneMaxSize / dW);
dW = dOneMaxSize;
}
else
{
dW *= (dOneMaxSize / dH);
dH = dOneMaxSize;
}
pMetafile->ConvertToRaster(wsOutFilePath, unFileType, (int)dW, (int)dH);
}
}
#endif //_METAFILE_COMMON_H

View File

@ -1070,7 +1070,7 @@ void CSvmFile::Read_META_BMP(TSvmBitmap & bitmap_info, BYTE** ppDstBuffer, unsig
MetaFile::ReadImage((BYTE*)&bitmap_info, bitmap_info.nSize, destBuf, destSize, ppDstBuffer, pulWidth, pulHeight);
delete []destBuf;
}
else
else if (nHeaderSize >= bitmap_info.nSize)
{
BYTE *Header = new BYTE [ nHeaderSize];
memcpy(Header, &bitmap_info, bitmap_info.nSize);

View File

@ -202,9 +202,9 @@ class CSvmFile : virtual public IMetaFileBase
return MM_ANISOTROPIC;
}
double GetDpi()
USHORT GetDpi()
{
return 96.;
return 96;
}
IRegion* GetRegion()

View File

@ -659,7 +659,7 @@ namespace MetaFile
double dStrokeWidth = std::fabs(m_pParser->GetPen()->GetWidth());
if (Equals(0, dStrokeWidth) || PS_COSMETIC == (m_pParser->GetPen()->GetStyle() & PS_TYPE_MASK))
if (Equals(0, dStrokeWidth) || (Equals(1, dStrokeWidth) && PS_COSMETIC == (m_pParser->GetPen()->GetStyle() & PS_TYPE_MASK)))
{
dStrokeWidth = 1;
arAttributes.push_back({L"vector-effect", L"non-scaling-stroke"});

View File

@ -161,9 +161,9 @@ namespace MetaFile
return m_pDC->GetMapMode();
}
double CWmfParserBase::GetDpi()
USHORT CWmfParserBase::GetDpi()
{
return (0 != m_oPlaceable.ushInch) ? m_oPlaceable.ushInch : 96.;
return (0 != m_oPlaceable.ushInch) ? m_oPlaceable.ushInch : 96;
}
IRegion *CWmfParserBase::GetRegion()
@ -249,6 +249,19 @@ namespace MetaFile
oBB = m_oPlaceable.oBoundingBox;
const USHORT ushFileDpi = GetDpi();
const USHORT ushRendererDpi = 96;
if (ushFileDpi != ushRendererDpi && 0 != ushFileDpi)
{
const double dKoef = (double)ushRendererDpi / (double)ushFileDpi;
oBB.Left = std::round(oBB.Left * dKoef);
oBB.Top = std::round(oBB.Top * dKoef);
oBB.Right = std::round(oBB.Right * dKoef);
oBB.Bottom = std::round(oBB.Bottom * dKoef);
}
// Иногда m_oPlaceable.BoundingBox задается нулевой ширины и высоты
if (abs(oBB.Right - oBB.Left) <= 1)
{
@ -261,17 +274,6 @@ namespace MetaFile
oBB.Bottom = m_oBoundingBox.Bottom;
}
const double dFileDpi = GetDpi();
const double dRendererDpi = 96;
if (Equals(dFileDpi, dRendererDpi) && !Equals(0, dFileDpi))
return oBB;
oBB.Left = std::round(oBB.Left * dRendererDpi / dFileDpi);
oBB.Top = std::round(oBB.Top * dRendererDpi / dFileDpi);
oBB.Right = std::round(oBB.Right * dRendererDpi / dFileDpi);
oBB.Bottom = std::round(oBB.Bottom * dRendererDpi / dFileDpi);
return oBB;
}
else

View File

@ -57,7 +57,7 @@ namespace MetaFile
bool IsWindowFlippedY() override;
bool IsWindowFlippedX() override;
unsigned int GetMapMode() override;
double GetDpi() override;
USHORT GetDpi() override;
IRegion* GetRegion() override;
unsigned int GetArcDirection() override;
CPath* GetPath() override;

View File

@ -3,56 +3,11 @@
#include "../CSvgFile.h"
#include "../../graphics/Image.h"
#include "../../../BgraFrame.h"
#include <stack>
#include "../../../../common/Path.h"
#include "../../../../common/ProcessEnv.h"
namespace SVG
{
std::wstring ShortenPath(const std::wstring& wsPath)
{
std::stack<std::wstring> arStack;
std::wstring wsToken;
std::wstring wsNewPath;
std::function<void()> checkToken = [&]()
{
if (L".." == wsToken)
{
if (!arStack.empty() && L".." != arStack.top())
arStack.pop();
else
arStack.push(wsToken);
}
else if (L"." != wsToken && !wsToken.empty())
arStack.push(wsToken);
wsToken.clear();
};
for (size_t i = 0; i < wsPath.size(); ++i)
{
if (L'/' == wsPath[i] || L'\\' == wsPath[i])
checkToken();
else
wsToken += wsPath[i];
}
checkToken();
if (arStack.empty())
return std::wstring();
while (!arStack.empty())
{
wsNewPath = arStack.top() + L'/' + wsNewPath;
arStack.pop();
}
wsNewPath.pop_back();
return wsNewPath;
}
CImage::CImage(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent)
: CRenderedObject(oNode, pParent)
{
@ -106,15 +61,19 @@ namespace SVG
}
#ifndef METAFILE_DISABLE_FILESYSTEM
std::wstring wsFilePath = ShortenPath(m_wsHref);
std::wstring wsFilePath = NSSystemPath::ShortenPath(m_wsHref);
if (!wsFilePath.empty() && L'.' != wsFilePath[0])
{
wsFilePath = pFile->GetWorkingDirectory() + L'/' + wsFilePath;
bool bIsAllowExternalLocalFiles = true;
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_allowPrivateIP))
bIsAllowExternalLocalFiles = NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_allowPrivateIP);
if (!NSFile::CFileBinary::Exists(wsFilePath) || !NSFile::CFileBinary::ReadAllBytes(wsFilePath, &pBuffer, ulSize))
return false;
}
if (!bIsAllowExternalLocalFiles && wsFilePath.length() >= 3 && L"../" == wsFilePath.substr(0, 3))
return true;
wsFilePath = pFile->GetWorkingDirectory() + L'/' + wsFilePath;
if (!NSFile::CFileBinary::Exists(wsFilePath) || !NSFile::CFileBinary::ReadAllBytes(wsFilePath, &pBuffer, ulSize))
return false;
#endif
if (NULL == pBuffer)

View File

@ -896,7 +896,12 @@ XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
XmlUtils::CXmlNode hiddenText;
XmlUtils::CXmlNode pageColumn;
XmlUtils::CXmlNode region;
hiddenText.FromXmlStringA(NSDjvu::MakeCString(pageText));
std::string sPageText = NSDjvu::MakeCString(pageText);
if (!hiddenText.FromXmlStringA(sPageText))
{
std::wstring sPageTextW = UTF8_TO_U(sPageText);
hiddenText.FromXmlString(sPageTextW);
}
hiddenText.GetNode(L"PAGECOLUMN", pageColumn);
pageColumn.GetNode(L"REGION", region);
region.GetNode(L"PARAGRAPH", paragraph);

View File

@ -1551,65 +1551,27 @@ public:
m_oTitleInfo.m_sKeywords = EncodeXmlString(sAtrContent);
}
}
else if (sName == L"h1")
else if (sName == L"h1" || sName == L"h2" || sName == L"h3" || sName == L"h4" || sName == L"h5" || sName == L"h6")
{
if (!m_bInTable)
oXml.WriteString(L"<section><title><p>");
m_bInP = true;
bool bInH = false;
int nH = 0;
if (!m_bInTable && !m_bInP)
{
nH = stoi(sName.substr(1));
for (int i = 0; i < nH; ++i)
oXml.WriteString(L"<section>");
oXml.WriteString(L"<title><p>");
bInH = true;
m_bInP = true;
}
readStream(oXml);
m_bInP = false;
if (!m_bInTable)
oXml.WriteString(L"</p></title></section>");
}
else if (sName == L"h2")
{
if (!m_bInTable)
oXml.WriteString(L"<section><section><title><p>");
m_bInP = true;
readStream(oXml);
m_bInP = false;
if (!m_bInTable)
oXml.WriteString(L"</p></title></section></section>");
}
else if (sName == L"h3")
{
if (!m_bInTable)
oXml.WriteString(L"<section><section><section><title><p>");
m_bInP = true;
readStream(oXml);
m_bInP = false;
if (!m_bInTable)
oXml.WriteString(L"</p></title></section></section></section>");
}
else if (sName == L"h4")
{
if (!m_bInTable)
oXml.WriteString(L"<section><section><section><section><title><p>");
m_bInP = true;
readStream(oXml);
m_bInP = false;
if (!m_bInTable)
oXml.WriteString(L"</p></title></section></section></section></section>");
}
else if (sName == L"h5")
{
if (!m_bInTable)
oXml.WriteString(L"<section><section><section><section><section><title><p>");
m_bInP = true;
readStream(oXml);
m_bInP = false;
if (!m_bInTable)
oXml.WriteString(L"</p></title></section></section></section></section></section>");
}
else if (sName == L"h6")
{
if (!m_bInTable)
oXml.WriteString(L"<section><section><section><section><section><section><title><p>");
m_bInP = true;
readStream(oXml);
m_bInP = false;
if (!m_bInTable)
oXml.WriteString(L"</p></title></section></section></section></section></section></section>");
if (bInH)
{
oXml.WriteString(L"</p></title>");
for (int i = 0; i < nH; ++i)
oXml.WriteString(L"</section>");
m_bInP = false;
}
}
else if (sName == L"span")
{

View File

@ -25,6 +25,7 @@
#include "../DesktopEditor/raster/BgraFrame.h"
#include "../DesktopEditor/graphics/pro/Fonts.h"
#include "../DesktopEditor/graphics/pro/Graphics.h"
#include "../DesktopEditor/raster/Metafile/MetaFileCommon.h"
#include "htmlfile2.h"
#include <boost/regex.hpp>
@ -101,6 +102,25 @@ std::wstring EncodeXmlString(const std::wstring& s)
return sRes;
}
bool GetStatusUsingExternalLocalFiles()
{
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_allowPrivateIP))
return NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_allowPrivateIP);
return true;
}
bool CanUseThisPath(const std::wstring& wsPath, bool bIsAllowExternalLocalFiles)
{
if (bIsAllowExternalLocalFiles)
return true;
if (wsPath.length() >= 3 && L"../" == wsPath.substr(0, 3))
return false;
return true;
}
class CHtmlFile2_Private
{
public:
@ -1769,14 +1789,14 @@ private:
std::wstring sImageName = std::to_wstring(m_arrImages.size()) + L'.' + sExtention;
if (oImageWriter.CreateFileW(m_sDst + L"/word/media/i" + sImageName))
{
std::string sSrc = U_TO_UTF8(sSrcM);
std::string sBase64 = sSrc.substr(nBase + 7);
int nSrcLen = (int)sBase64.length();
int nOffset = nBase + 7;
int nSrcLen = (int)(sSrcM.length() - nBase + 1);
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
if (nDecodeLen != 0)
{
BYTE* pImageData = new BYTE[nDecodeLen];
if (TRUE == NSBase64::Base64Decode(sBase64.c_str(), nSrcLen, pImageData, &nDecodeLen))
if (TRUE == NSBase64::Base64Decode(sSrcM.c_str() + nOffset, nSrcLen, pImageData, &nDecodeLen))
{
oImageWriter.WriteFile(pImageData, (DWORD)nDecodeLen);
bRes = true;
@ -1848,14 +1868,22 @@ private:
return;
}
bool bIsAllowExternalLocalFiles = true;
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_allowPrivateIP))
bIsAllowExternalLocalFiles = NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_allowPrivateIP);
const bool bIsAllowExternalLocalFiles = GetStatusUsingExternalLocalFiles();
bool bIsBase64 = false;
if (sSrcM.length() > 4 && sSrcM.substr(0, 4) == L"data" && sSrcM.find(L"/", 4) != std::wstring::npos)
bIsBase64 = true;
if (!bIsBase64)
sSrcM = NSSystemPath::ShortenPath(sSrcM);
if (!CanUseThisPath(sSrcM, bIsAllowExternalLocalFiles))
return;
int nImageId = -1;
std::wstring sImageSrc, sExtention;
// Предполагаем картинку в Base64
if (sSrcM.length() > 4 && sSrcM.substr(0, 4) == L"data" && sSrcM.find(L"/", 4) != std::wstring::npos)
if (bIsBase64)
bRes = readBase64(sSrcM, sExtention);
if (!bRes)
@ -2143,7 +2171,12 @@ private:
size_t nHRefLen = sSVG.find(L"\"", nHRef);
if(nHRefLen == std::wstring::npos)
break;
std::wstring sImageName = sSVG.substr(nHRef, nHRefLen - nHRef);
const std::wstring sImageName = NSSystemPath::ShortenPath(sSVG.substr(nHRef, nHRefLen - nHRef));
if (!CanUseThisPath(sImageName, GetStatusUsingExternalLocalFiles()))
break;
std::wstring sTIN(sImageName);
sTIN.erase(std::remove_if(sTIN.begin(), sTIN.end(), [] (wchar_t ch) { return std::iswspace(ch) || (ch == L'^'); }), sTIN.end());
sTIN = NSFile::GetFileName(sTIN);
@ -2174,7 +2207,7 @@ private:
if (bLoad)
{
std::wstring sPngFile = m_sDst + L"/word/media/i" + sImageId + L".png";
pMetafile->ConvertToRaster(sPngFile.data(), 4, 1000);
MetaFile::ConvertToRasterMaxSize(pMetafile, sPngFile.data(), 4, 1000);
}
pMetafile->Release();
pFonts->Release();

View File

@ -29,8 +29,8 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _ASC_HTMLRENDERER3_H_
#define _ASC_HTMLRENDERER3_H_
#ifndef _ASC_HTMLRENDERER3_TEXT_H_
#define _ASC_HTMLRENDERER3_TEXT_H_
#include "../../DesktopEditor/graphics/IRenderer.h"
#include "../../DesktopEditor/graphics/pro/officedrawingfile.h"
@ -187,4 +187,4 @@ namespace NSHtmlRenderer
};
}
#endif // _ASC_HTMLRENDERER3_H_
#endif // _ASC_HTMLRENDERER3_TEXT_H_

View File

@ -0,0 +1,397 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "FormatUtils.h"
namespace DocFileFormat
{
#define WriteWCharPadding(STLCollection, padding) \
for (int i = 0; i < padding; ++i)\
{\
STLCollection->push_back((wchar_t)0);\
}
static void WriteUtf16ToWChar(int code, std::vector<wchar_t>* STLCollection, int padding)
{
int used = 0;
if (code < 0x10000)
{
STLCollection->push_back((wchar_t)code);
used = 1;
}
else
{
code -= 0x10000;
STLCollection->push_back((wchar_t)(0xD800 | ((code >> 10) & 0x03FF)));
STLCollection->push_back((wchar_t)(0xDC00 | (code & 0x03FF)));
used = 2;
}
WriteWCharPadding(STLCollection, padding - used);
}
static bool GetSTLCollectionFromUtf8(std::vector<wchar_t>* STLCollection, unsigned char* pBuffer, int lCount)
{
if ((STLCollection == NULL) || (pBuffer == NULL))
{
return false;
}
int lIndex = 0;
if (sizeof(wchar_t) == 2)//utf8 -> utf16
{
while (lIndex < lCount)
{
BYTE byteMain = pBuffer[lIndex];
if (0x00 == (byteMain & 0x80))
{
// 1 byte
STLCollection->push_back((WCHAR)byteMain);
++lIndex;
}
else if (0x00 == (byteMain & 0x20))
{
// 2 byte
int val = 0;
if ((lIndex + 1) < lCount)
{
val = (int)(((byteMain & 0x1F) << 6) |
(pBuffer[lIndex + 1] & 0x3F));
}
STLCollection->push_back((wchar_t)val);
STLCollection->push_back((wchar_t)0);
lIndex += 2;
}
else if (0x00 == (byteMain & 0x10))
{
// 3 byte
int val = 0;
if ((lIndex + 2) < lCount)
{
val = (int)(((byteMain & 0x0F) << 12) |
((pBuffer[lIndex + 1] & 0x3F) << 6) |
(pBuffer[lIndex + 2] & 0x3F));
}
WriteUtf16ToWChar(val, STLCollection, 3);
lIndex += 3;
}
else if (0x00 == (byteMain & 0x0F))
{
// 4 byte
int val = 0;
if ((lIndex + 3) < lCount)
{
val = (int)(((byteMain & 0x07) << 18) |
((pBuffer[lIndex + 1] & 0x3F) << 12) |
((pBuffer[lIndex + 2] & 0x3F) << 6) |
(pBuffer[lIndex + 3] & 0x3F));
}
WriteUtf16ToWChar(val, STLCollection, 4);
lIndex += 4;
}
else if (0x00 == (byteMain & 0x08))
{
// 4 byte
int val = 0;
if ((lIndex + 3) < lCount)
{
val = (int)(((byteMain & 0x07) << 18) |
((pBuffer[lIndex + 1] & 0x3F) << 12) |
((pBuffer[lIndex + 2] & 0x3F) << 6) |
(pBuffer[lIndex + 3] & 0x3F));
}
WriteUtf16ToWChar(val, STLCollection, 4);
lIndex += 4;
}
else if (0x00 == (byteMain & 0x04))
{
// 5 byte
int val = 0;
if ((lIndex + 4) < lCount)
{
val = (int)(((byteMain & 0x03) << 24) |
((pBuffer[lIndex + 1] & 0x3F) << 18) |
((pBuffer[lIndex + 2] & 0x3F) << 12) |
((pBuffer[lIndex + 3] & 0x3F) << 6) |
(pBuffer[lIndex + 4] & 0x3F));
}
WriteUtf16ToWChar(val, STLCollection, 5);
lIndex += 5;
}
else
{
// 6 byte
int val = 0;
if ((lIndex + 5) < lCount)
{
val = (int)(((byteMain & 0x01) << 30) |
((pBuffer[lIndex + 1] & 0x3F) << 24) |
((pBuffer[lIndex + 2] & 0x3F) << 18) |
((pBuffer[lIndex + 3] & 0x3F) << 12) |
((pBuffer[lIndex + 4] & 0x3F) << 6) |
(pBuffer[lIndex + 5] & 0x3F));
}
WriteUtf16ToWChar(val, STLCollection, 6);
lIndex += 6;
}
}
}
else //utf8 -> utf32
{
while (lIndex < lCount)
{
BYTE byteMain = pBuffer[lIndex];
if (0x00 == (byteMain & 0x80))
{
// 1 byte
STLCollection->push_back((WCHAR)byteMain);
++lIndex;
}
else if (0x00 == (byteMain & 0x20))
{
// 2 byte
int val = 0;
if ((lIndex + 1) < lCount)
{
val = (int)(((byteMain & 0x1F) << 6) |
(pBuffer[lIndex + 1] & 0x3F));
}
STLCollection->push_back((WCHAR)val);
STLCollection->push_back((WCHAR)0);
lIndex += 2;
}
else if (0x00 == (byteMain & 0x10))
{
// 3 byte
int val = 0;
if ((lIndex + 2) < lCount)
{
val = (int)(((byteMain & 0x0F) << 12) |
((pBuffer[lIndex + 1] & 0x3F) << 6) |
(pBuffer[lIndex + 2] & 0x3F));
}
STLCollection->push_back((WCHAR)val);
WriteWCharPadding(STLCollection, 2);
lIndex += 3;
}
else if (0x00 == (byteMain & 0x0F))
{
// 4 byte
int val = 0;
if ((lIndex + 3) < lCount)
{
val = (int)(((byteMain & 0x07) << 18) |
((pBuffer[lIndex + 1] & 0x3F) << 12) |
((pBuffer[lIndex + 2] & 0x3F) << 6) |
(pBuffer[lIndex + 3] & 0x3F));
}
STLCollection->push_back((WCHAR)val);
WriteWCharPadding(STLCollection, 3);
lIndex += 4;
}
else if (0x00 == (byteMain & 0x08))
{
// 4 byte
int val = 0;
if ((lIndex + 3) < lCount)
{
val = (int)(((byteMain & 0x07) << 18) |
((pBuffer[lIndex + 1] & 0x3F) << 12) |
((pBuffer[lIndex + 2] & 0x3F) << 6) |
(pBuffer[lIndex + 3] & 0x3F));
}
STLCollection->push_back((WCHAR)val);
WriteWCharPadding(STLCollection, 3);
lIndex += 4;
}
else if (0x00 == (byteMain & 0x04))
{
// 5 byte
int val = 0;
if ((lIndex + 4) < lCount)
{
val = (int)(((byteMain & 0x03) << 24) |
((pBuffer[lIndex + 1] & 0x3F) << 18) |
((pBuffer[lIndex + 2] & 0x3F) << 12) |
((pBuffer[lIndex + 3] & 0x3F) << 6) |
(pBuffer[lIndex + 4] & 0x3F));
}
STLCollection->push_back((WCHAR)val);
WriteWCharPadding(STLCollection, 4);
lIndex += 5;
}
else
{
// 6 byte
int val = 0;
if ((lIndex + 5) < lCount)
{
val = (int)(((byteMain & 0x01) << 30) |
((pBuffer[lIndex + 1] & 0x3F) << 24) |
((pBuffer[lIndex + 2] & 0x3F) << 18) |
((pBuffer[lIndex + 3] & 0x3F) << 12) |
((pBuffer[lIndex + 4] & 0x3F) << 6) |
(pBuffer[lIndex + 5] & 0x3F));
}
STLCollection->push_back((WCHAR)val);
WriteWCharPadding(STLCollection, 5);
lIndex += 6;
}
}
}
return true;
}
}
bool DocFileFormat::FormatUtils::GetWStringFromBytes(std::wstring& string, unsigned char* bytes, int size, int code_page)
{
if (bytes == NULL)
{
return false;
}
if (code_page == ENCODING_UTF8)
{
string = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(bytes, size);
return true;
}
else if (code_page == ENCODING_UTF16)
{
string = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)bytes, size / 2);
}
else if (code_page == ENCODING_WINDOWS_1250)
{
wchar_t wch = 0;
int i = 0;
while (i < size)
{
wch = MapByteToWChar(bytes[i++]);
string += (wch);
}
}
else
{
std::string sCodePage;
std::map<int, std::string>::const_iterator pFind = NSUnicodeConverter::mapEncodingsICU.find(code_page);
if (pFind != NSUnicodeConverter::mapEncodingsICU.end())
{
sCodePage = pFind->second;
}
if (sCodePage.empty())
sCodePage = "CP1250"/* + std::to_string(code_page)*/;
NSUnicodeConverter::CUnicodeConverter oConverter;
string = oConverter.toUnicode((char*)bytes, (unsigned int)size, sCodePage.c_str());
}
return true;
}
bool DocFileFormat::FormatUtils::GetSTLCollectionFromBytes(std::vector<wchar_t>* STLCollection, unsigned char* bytes, int size, int code_page)
{
if (bytes == NULL)
{
return false;
}
if (code_page == ENCODING_UTF8)
{
return GetSTLCollectionFromUtf8(STLCollection, bytes, size);
}
else if (code_page == ENCODING_UTF16)
{
int i = 0;
#if !defined(_WIN32) && !defined(_WIN64)
int nCount = size / 2;
unsigned short* pShort = (unsigned short*)bytes;
int nCurrent = 0;
while (nCurrent < nCount)
{
if (*pShort < 0xD800 || *pShort > 0xDBFF)
{
STLCollection->push_back((wchar_t)(*pShort));
++pShort;
++nCurrent;
}
else
{
STLCollection->push_back((wchar_t)(((((pShort[0] - 0xD800) & 0x03FF) << 10) | ((pShort[1] - 0xDC00) & 0x03FF)) + 0x10000));
STLCollection->push_back((wchar_t)0);
pShort += 2;
nCurrent += 2;
}
}
#else
while (i < size)
{
STLCollection->push_back(FormatUtils::BytesToUInt16(bytes, i, size));
i += 2;
}
#endif
}
else if (code_page == ENCODING_WINDOWS_1250)
{
wchar_t wch = 0;
int i = 0;
while (i < size)
{
wch = MapByteToWChar(bytes[i++]);
STLCollection->push_back(wch);
}
}
else
{
std::string sCodePage;
std::map<int, std::string>::const_iterator pFind = NSUnicodeConverter::mapEncodingsICU.find(code_page);
if (pFind != NSUnicodeConverter::mapEncodingsICU.end())
{
sCodePage = pFind->second;
}
if (sCodePage.empty())
sCodePage = "CP1250"/* + std::to_string(code_page)*/;
NSUnicodeConverter::CUnicodeConverter oConverter;
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, (unsigned int)size, sCodePage.c_str());
for (size_t i = 0; i < unicode_string.size(); i++)
{
STLCollection->push_back(unicode_string[i]);
}
}
return true;
}

View File

@ -494,152 +494,8 @@ namespace DocFileFormat
}
return true;
}
template<class T> static bool GetSTLCollectionFromUtf8( T *STLCollection, unsigned char *bytes, int size)
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
{
return false;
}
if (sizeof(wchar_t) == 2)//utf8 -> utf16
{
unsigned int nLength = size;
UTF16 *pStrUtf16 = new UTF16 [nLength+1];
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) bytes;
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF16 *pStrUtf16_Conv = pStrUtf16;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf16;
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
}
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf16[i]);
}
delete [] pStrUtf16;
return true;
}
else //utf8 -> utf32
{
unsigned int nLength = size;
UTF32 *pStrUtf32 = new UTF32 [nLength+1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) bytes;
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
}
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf32[i]);
}
delete [] pStrUtf32;
return true;
}
}
template<class T> static bool GetSTLCollectionFromBytes( T *STLCollection, unsigned char *bytes, int size, int code_page )
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
{
return false;
}
if (code_page == ENCODING_UTF8)
{
return GetSTLCollectionFromUtf8(STLCollection, bytes, size);
}
else if (code_page == ENCODING_UTF16)
{
int i = 0;
#if !defined(_WIN32) && !defined(_WIN64)
int nCount = size / 2;
unsigned short* pShort = (unsigned short*)bytes;
int nCurrent = 0;
while (nCurrent < nCount)
{
if (*pShort < 0xD800 || *pShort > 0xDBFF)
{
STLCollection->push_back((wchar_t)(*pShort));
++pShort;
++nCurrent;
}
else
{
STLCollection->push_back((wchar_t)(((((pShort[0] - 0xD800) & 0x03FF) << 10) | ((pShort[1] - 0xDC00) & 0x03FF)) + 0x10000));
STLCollection->push_back((wchar_t)0);
pShort += 2;
nCurrent += 2;
}
}
#else
while ( i < size )
{
STLCollection->push_back( FormatUtils::BytesToUInt16( bytes, i, size ) );
i += 2;
}
#endif
}
else if (code_page == ENCODING_WINDOWS_1250)
{
wchar_t wch = 0;
int i = 0;
while ( i < size )
{
wch = MapByteToWChar( bytes[i++] );
STLCollection->push_back( wch );
}
}
else
{
std::string sCodePage;
std::map<int, std::string>::const_iterator pFind = NSUnicodeConverter::mapEncodingsICU.find(code_page);
if (pFind != NSUnicodeConverter::mapEncodingsICU.end())
{
sCodePage = pFind->second;
}
if (sCodePage.empty())
sCodePage = "CP1250"/* + std::to_string(code_page)*/;
NSUnicodeConverter::CUnicodeConverter oConverter;
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, (unsigned int)size, sCodePage.c_str());
for (size_t i = 0; i < unicode_string.size(); i++)
{
STLCollection->push_back(unicode_string[i]);
}
}
return true;
}
static bool GetWStringFromBytes(std::wstring & string, unsigned char* bytes, int size, int code_page);
static bool GetSTLCollectionFromBytes(std::vector<wchar_t>* STLCollection, unsigned char* bytes, int size, int code_page);
static int BitmaskToInt( int value, int mask )
{

View File

@ -325,14 +325,15 @@ std::wstring CVbaReader::convertObject(const std::wstring & name, unsigned int c
{
for (size_t i = 0; i < FormControlStream->SiteData->Sites.size(); ++i)
{
if (strmObject->getDataSize() < nextStreamPositionEmbedded)
break;
VBA::OleSiteConcreteControlPtr & site = FormControlStream->SiteData->Sites[i];
if (site->ObjectStreamSize && strmObject)
VBA::OleSiteConcreteControlPtr& site = FormControlStream->SiteData->Sites[i];
if (!site)
continue;
if (strmObject)
{
site->Object = VBA::ActiveXObjectPtr(OOX::ActiveXObject::Create(site->ClsidCacheIndex ? *site->ClsidCacheIndex : 0));
if (site->ObjectStreamSize)
if (strmObject->getDataSize() > nextStreamPositionEmbedded && site->ObjectStreamSize)
{
site->Object->Parse(strmObject->getData() + nextStreamPositionEmbedded, *site->ObjectStreamSize);
nextStreamPositionEmbedded += *site->ObjectStreamSize;

View File

@ -45,7 +45,7 @@ namespace DocFileFormat
short cch = reader->ReadByte();
unsigned char *chars = reader->ReadBytes(cch, true);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->m_UserInitials), chars, cch , ENCODING_WINDOWS_1250);
FormatUtils::GetWStringFromBytes(newObject->m_UserInitials, chars, cch , ENCODING_WINDOWS_1250);
newObject->m_AuthorIndex = reader->ReadUInt16();
newObject->m_BookmarkId = reader->ReadInt16();

View File

@ -485,6 +485,36 @@ namespace DocFileFormat
}
}
}
if (_doc->nWordVersion > 0)
{
if (false == m_sAsciiFont.empty())
{
if (m_sEastAsiaFont.empty())
{
m_sEastAsiaFont = m_sAsciiFont;
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute(L"w:eastAsia");
eastAsia->SetValue(FormatUtils::XmlEncode(m_sEastAsiaFont));
rFonts->AppendAttribute(*eastAsia);
RELEASEOBJECT(eastAsia);
}
if (m_shAnsiFont.empty())
{
m_shAnsiFont = m_sAsciiFont;
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute(L"w:hAnsi");
ansi->SetValue(FormatUtils::XmlEncode(m_shAnsiFont));
rFonts->AppendAttribute(*ansi);
RELEASEOBJECT(ansi);
}
if (m_sCsFont.empty())
{
m_sCsFont = m_sAsciiFont;
XMLTools::XMLAttribute* cs = new XMLTools::XMLAttribute(L"w:cs");
cs->SetValue(FormatUtils::XmlEncode(m_sCsFont, true));
rFonts->AppendAttribute(*cs);
RELEASEOBJECT(cs);
}
}
}
if ( lang->GetAttributeCount() > 0 )
{
parent->AppendChild( *lang );

View File

@ -107,7 +107,7 @@ namespace DocFileFormat
if (reader->nWordVersion > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 );
FormatUtils::GetWStringFromBytes(newObject->xszFtn, bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 );
}
else
{
@ -141,7 +141,7 @@ namespace DocFileFormat
if (reader->nWordVersion > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250);
FormatUtils::GetWStringFromBytes( newObject->xszAlt, bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250);
}
else
{

View File

@ -228,7 +228,7 @@ namespace DocFileFormat
}
if (strLen > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xst), data + 20, ( strLen ), ENCODING_WINDOWS_1250);
FormatUtils::GetWStringFromBytes( xst, data + 20, ( strLen ), ENCODING_WINDOWS_1250);
}
}
OutlineListDescriptor::~OutlineListDescriptor()
@ -273,7 +273,7 @@ namespace DocFileFormat
}
if (strLen > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xst), data + 20, ( strLen ), ENCODING_WINDOWS_1250);
FormatUtils::GetWStringFromBytes( xst, data + 20, ( strLen ), ENCODING_WINDOWS_1250);
}
}
}

View File

@ -356,7 +356,7 @@ void OleObject::processLinkInfoStream( VirtualStreamReader& reader )
{
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
FormatUtils::GetWStringFromBytes( this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string

View File

@ -310,7 +310,7 @@ namespace DocFileFormat
if ( stPicName != NULL )
{
std::wstring picName;
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &picName, stPicName, cchPicName, ENCODING_WINDOWS_1250 );
FormatUtils::GetWStringFromBytes( picName, stPicName, cchPicName, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS(stPicName);
}
}

View File

@ -188,7 +188,7 @@ namespace DocFileFormat
stream->seek(pcd.fc);
stream->read(bytes, cb);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(piecePairs, bytes, cb, pcd.code_page);
FormatUtils::GetSTLCollectionFromBytes(piecePairs, bytes, cb, pcd.code_page);
RELEASEARRAYOBJECTS(bytes);
}
@ -234,7 +234,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb);
//get the chars
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.code_page );
FormatUtils::GetSTLCollectionFromBytes( encodingChars, bytes, cb, pcd.code_page );
RELEASEARRAYOBJECTS( bytes );
}
@ -253,7 +253,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb);
//get the chars
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.code_page );
FormatUtils::GetSTLCollectionFromBytes( encodingChars, bytes, cb, pcd.code_page );
RELEASEARRAYOBJECTS( bytes );
}
@ -272,7 +272,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb);
//get the chars
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(encodingChars, bytes, cb, pcd.code_page);
FormatUtils::GetSTLCollectionFromBytes(encodingChars, bytes, cb, pcd.code_page);
RELEASEARRAYOBJECTS(bytes);
@ -295,7 +295,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb );
//get the chars
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.code_page );
FormatUtils::GetSTLCollectionFromBytes( encodingChars, bytes, cb, pcd.code_page );
RELEASEARRAYOBJECTS( bytes );
@ -484,7 +484,7 @@ namespace DocFileFormat
word->read(bytes, size);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(encodingChars, bytes, size, coding);
FormatUtils::GetSTLCollectionFromBytes(encodingChars, bytes, size, coding);
RELEASEARRAYOBJECTS(bytes);

View File

@ -116,7 +116,7 @@ namespace DocFileFormat
{
//user style
unsigned char *bytes = tableReader.ReadBytes( sz_name, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &std->xstzName, bytes, sz_name, ENCODING_WINDOWS_1250 );
FormatUtils::GetWStringFromBytes( std->xstzName, bytes, sz_name, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( bytes );
}
// ms style

View File

@ -138,7 +138,7 @@ namespace DocFileFormat
{
name = new unsigned char[characterCount];//characters are zero-terminated, so 1 char has 2 bytes:
memcpy( name, ( bytes + cbStdBase + 1 ), ( characterCount ) );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xstzName), name, ( characterCount ), ENCODING_WINDOWS_1250 );
FormatUtils::GetWStringFromBytes( xstzName, name, ( characterCount ), ENCODING_WINDOWS_1250 );
upxOffset = cbStdBase + 1 + ( characterCount /** 2*/ ) + 1;
}
else

View File

@ -194,7 +194,7 @@ std::wstring VirtualStreamReader::ReadXst()
int xstzSize = DocFileFormat::FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1;
xstz = ReadBytes(xstzSize, true);
DocFileFormat::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 );
DocFileFormat::FormatUtils::GetWStringFromBytes( wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 );
}
else
{
@ -272,7 +272,7 @@ std::wstring VirtualStreamReader::ReadLengthPrefixedAnsiString(unsigned int max_
//dont read the terminating zero
stringBytes = ReadBytes( cch, true );
DocFileFormat::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250);
DocFileFormat::FormatUtils::GetWStringFromBytes( result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250);
}
RELEASEARRAYOBJECTS( stringBytes );

View File

@ -54,11 +54,11 @@ namespace DocFileFormat
//It's a real string table
if (reader->nWordVersion > 0)
{
FormatUtils::GetSTLCollectionFromBytes<WideString>( newObject, bytes, length, ENCODING_WINDOWS_1250 );
FormatUtils::GetWStringFromBytes( *newObject, bytes, length, ENCODING_WINDOWS_1250 );
}
else
{
FormatUtils::GetSTLCollectionFromBytes<WideString>( newObject, bytes, length, ENCODING_UTF16 );
FormatUtils::GetWStringFromBytes( *newObject, bytes, length, ENCODING_UTF16 );
}
RELEASEARRAYOBJECTS( bytes );

View File

@ -499,18 +499,13 @@ namespace DocFileFormat
RELEASEOBJECT(Text);
Text = new std::vector<wchar_t>();
int coding = nFontsCodePage != ENCODING_WINDOWS_1250 ? nFontsCodePage : nDocumentCodePage;
int coding = nFontsCodePage != ENCODING_WINDOWS_1250 ? nFontsCodePage : (nWordVersion < 1 ? nDocumentCodePage : ENCODING_WINDOWS_1250);
if (coding == ENCODING_UTF16)
{
std::wstring sText = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)(bytes), cb / 2);
std::copy(sText.begin(), sText.end(), std::back_inserter(*Text));
}
else
{
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(Text, bytes, cb, coding);
}
FormatUtils::GetSTLCollectionFromBytes(Text, bytes, cb, coding);
//std::wstring strTest1 = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(bytes, cb);
//std::wstring strTest2;
//FormatUtils::GetWStringFromBytes(strTest2, bytes, cb, ENCODING_WINDOWS_1250);
RELEASEARRAYOBJECTS(bytes);
}
}

View File

@ -221,6 +221,7 @@ namespace PPT
<Default Extension=\"xml\" ContentType=\"application/xml\"/>\
<Default Extension=\"gif\" ContentType=\"image/gif\"/>\
<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\
<Default Extension=\"pct\" ContentType=\"image/unknown\"/>\
<Default Extension=\"wav\" ContentType=\"audio/wav\"/>\
<Default Extension=\"wma\" ContentType=\"audio/x-ms-wma\"/>\
<Default Extension=\"mp3\" ContentType=\"audio/unknown\"/>\

View File

@ -31,8 +31,9 @@ SOURCES += \
../../../DocFile/EncryptionHeader.cpp \
../../../DocFile/DrawingPrimitives.cpp \
../../../DocFile/Spa.cpp \
../../../DocFile/OleObject.cpp \
../../../Common/Base/XmlTools.cpp
../../../DocFile/OleObject.cpp \
../../../Common/Base/FormatUtils.cpp \
../../../Common/Base/XmlTools.cpp
core_release {
SOURCES += \

View File

@ -141,6 +141,7 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\Common\Base\FormatUtils.h" />
<ClInclude Include="..\..\..\DocFile\AbstractOpenXmlMapping.h" />
<ClInclude Include="..\..\..\DocFile\AnnotationOwnerList.h" />
<ClInclude Include="..\..\..\DocFile\AnnotationReferenceDescriptor.h" />
@ -308,6 +309,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\Common\3dParty\pole\pole.cpp" />
<ClCompile Include="..\..\..\Common\Base\FormatUtils.cpp" />
<ClCompile Include="..\..\..\Common\Base\XmlTools.cpp" />
<ClCompile Include="..\..\..\DocFile\AbstractOpenXmlMapping.cpp" />
<ClCompile Include="..\..\..\DocFile\AnnotationOwnerList.cpp" />

View File

@ -505,6 +505,7 @@
<ClInclude Include="..\..\..\DocFile\VMLShapeTypeMapping.h">
<Filter>Converter</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Common\Base\FormatUtils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\DocFile\OfficeDrawing\Record.cpp">
@ -870,5 +871,6 @@
<Filter>OfficeDrawing</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Common\Base\XmlTools.cpp" />
<ClCompile Include="..\..\..\Common\Base\FormatUtils.cpp" />
</ItemGroup>
</Project>

View File

@ -761,7 +761,7 @@ void XlsConverter::convert(XLS::GlobalsSubstream* globals)
for (size_t i = 0 ; i < globals->m_arHFPictureDrawing.size(); i++)
{
convert((ODRAW::OfficeArtDgContainer*)globals->m_arHFPictureDrawing[i].get());
convert((ODRAW::OfficeArtDggContainer*)globals->m_arHFPictureDrawing[i].get());
}
globals->serialize_protection(xlsx_context->workbook_protection());
@ -833,10 +833,10 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
CP_XML_NODE(L"numFmts")
{
CP_XML_ATTR(L"count", xls_global_info->m_arNumFormats.size());
for (size_t i = 0; i < xls_global_info->m_arNumFormats.size(); i++)
CP_XML_ATTR(L"count", xls_global_info->m_mapNumFormats.size());
for (std::map<_UINT16, XLS::BaseObjectPtr>::iterator it = xls_global_info->m_mapNumFormats.begin(); it != xls_global_info->m_mapNumFormats.end(); ++it)
{
XLS::Format* fmt = dynamic_cast<XLS::Format*>(xls_global_info->m_arNumFormats[i].get());
XLS::Format* fmt = dynamic_cast<XLS::Format*>(it->second.get());
if (fmt->ifmt < 5 || (fmt->ifmt > 8 && fmt->ifmt < 23) || (fmt->ifmt > 36 && fmt->ifmt < 41) || (fmt->ifmt > 44 && fmt->ifmt < 50))
continue;
@ -1428,14 +1428,21 @@ void XlsConverter::convert(ODRAW::OfficeArtSpgrContainer * spgr)
for (size_t i = 0; i < spgr->child_records.size(); i++)
{
int type_object = 2;//rect
if (xlsx_context->get_drawing_context().start_drawing(type_object))
ODRAW::OfficeArtSpContainer* SpContainer = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[i].get());
if (SpContainer)
{
xlsx_context->get_drawing_context().set_mode_HF(true);
convert(spgr->child_records[i].get());
ODRAW::OfficeArtFSP* fsp = dynamic_cast<ODRAW::OfficeArtFSP*>(SpContainer->m_OfficeArtFSP.get());
if ((fsp) && (fsp->fHaveSpt))
{
int type_object = 2;//rect
if (xlsx_context->get_drawing_context().start_drawing(type_object))
{
xlsx_context->get_drawing_context().set_mode_HF(true);
convert(spgr->child_records[i].get());
xlsx_context->get_drawing_context().end_drawing();
xlsx_context->get_drawing_context().end_drawing();
}
}
}
}
}
@ -1534,6 +1541,12 @@ void XlsConverter::convert(ODRAW::OfficeArtRecord * art)
convert(dg->m_OfficeArtSpgrContainer.get());
}break;
case XLS::typeOfficeArtDggContainer:
{
ODRAW::OfficeArtDggContainer* dg = dynamic_cast<ODRAW::OfficeArtDggContainer*>(art);
convert(dg->m_OfficeArtBStoreContainer.get());
}break;
default:
break;
}

View File

@ -2959,7 +2959,7 @@ void xlsx_drawing_context::set_picture_crop_right (double val)
}
void xlsx_drawing_context::set_picture_name(const std::wstring & str)
{
//....
current_drawing_states->back()->fill.name = str;
}
void xlsx_drawing_context::set_picture_grayscale(bool val)
{

View File

@ -289,6 +289,8 @@ public:
_CP_OPT(bool) grayscale;
_CP_OPT(int) biLevel;
std::wstring name;
std::vector<std::pair<double, _color>> colorsPosition;
}fill;

View File

@ -47,7 +47,14 @@ table_state::table_state(xlsx_conversion_context & Context) : drawing_context_(C
table_state_ptr & xlsx_sheet_context::state()
{
return tables_state_.back();
if (false == tables_state_.empty())
{
return tables_state_.back();
}
else
{
throw;
}
}
xlsx_sheet_context::xlsx_sheet_context(xlsx_conversion_context & Context) : context_(Context)
@ -114,38 +121,57 @@ void xlsx_sheet_context::end_table()
xlsx_drawing_context & xlsx_sheet_context::get_drawing_context()
{
return state()->drawing_context_;
if (state())
return state()->drawing_context_;
else
{
throw;
}
}
xlsx_comments_context & xlsx_sheet_context::get_comments_context()
{
return state()->comments_context_;
if (state())
return state()->comments_context_;
else
{
throw;
}
}
std::wstring xlsx_sheet_context::add_hyperlink(std::wstring const & ref, std::wstring const & target, std::wstring const & display, bool bExternal)
{
return state()->hyperlinks_.add( ref, target, display, bExternal);
if (state())
return state()->hyperlinks_.add(ref, target, display, bExternal);
else return L"";
}
void xlsx_sheet_context::dump_rels_hyperlinks(rels & Rels)
{
state()->hyperlinks_.dump_rels(Rels);
if (state())
state()->hyperlinks_.dump_rels(Rels);
}
void xlsx_sheet_context::serialize_hyperlinks(std::wostream & _Wostream)
{
state()->hyperlinks_.serialize(_Wostream);
if (state())
state()->hyperlinks_.serialize(_Wostream);
}
void xlsx_sheet_context::dump_rels_drawing(rels & Rels)
{
xlsx_drawings_rels_ptr drawing_rels = state()->drawing_context_.get_sheet_rels();
drawing_rels->dump_rels(Rels);
if (state())
{
xlsx_drawings_rels_ptr drawing_rels = state()->drawing_context_.get_sheet_rels();
drawing_rels->dump_rels(Rels);
}
}
void xlsx_sheet_context::serialize_ole_objects(std::wostream & strm)
{
state()->drawing_context_.serialize_objects(strm);
if (state())
state()->drawing_context_.serialize_objects(strm);
}
void xlsx_sheet_context::serialize_controls(std::wostream & strm)
{
state()->drawing_context_.serialize_controls(strm);
if (state())
state()->drawing_context_.serialize_controls(strm);
}
}

View File

@ -90,11 +90,12 @@ CFRecord::CFRecord(NSFile::CFileBinary &file, GlobalWorkbookInfoPtr global_info)
: rdPtr(0),
size_(0),
data_(NULL),
type_id_(rt_EOF),
global_info_(global_info)
{
file_ptr = file.GetFilePosition();
if (file.GetFilePosition() + 4 < file.GetFileSize())
if (file.GetFilePosition() + 4 <= file.GetFileSize())
{
unsigned short size_short;
DWORD size_read = 0;
@ -133,7 +134,8 @@ CFRecord::CFRecord(NSBinPptxRW::CBinaryFileReader &reader, GlobalWorkbookInfoPtr
: rdPtr(0),
size_(0),
data_(NULL),
global_info_(global_info)
type_id_(rt_EOF),
global_info_(global_info)
{
file_ptr = reinterpret_cast<std::uintptr_t>(reader.GetPointer(0)) ;
BYTE lenght = 0;

View File

@ -53,8 +53,8 @@ public:
int serialize(std::wostream & stream);
//-----------------------------
_UINT16 ifmt_used;
_UINT16 ifmt;
_UINT16 ifmt_used = 0xFFFF;
_UINT16 ifmt = 0xFFFF;
std::wstring stFormat;
};

View File

@ -56,7 +56,7 @@ public:
std::wstring guid;
TabId iTabid;
_UINT32 wScale;
Icv icvHdr;
Icv icvHdr = 64;
PaneType pnnSel;
bool fShowBrks;

View File

@ -55,16 +55,21 @@ void Window1::readFields(CFRecord& record)
{
if (record.getGlobalWorkbookInfo()->Version < 0x0800)
{
unsigned short flags;
_INT16 xWn_2b;
_INT16 yWn_2b;
_INT16 dxWn_2b;
_INT16 dyWn_2b;
_UINT16 itabCur_2b;
_UINT16 itabFirst_2b;
_UINT16 wTabRatio_2b;
BYTE flags = 0, reserved;
_INT16 xWn_2b = 0;
_INT16 yWn_2b = 0;
_INT16 dxWn_2b = 0;
_INT16 dyWn_2b = 0;
_UINT16 itabCur_2b = 0;
_UINT16 itabFirst_2b = 0;
_UINT16 wTabRatio_2b = 0;
record >> xWn_2b >> yWn_2b >> dxWn_2b >> dyWn_2b >> flags >> itabCur_2b >> itabFirst_2b >> ctabSel >> wTabRatio_2b;
record >> xWn_2b >> yWn_2b >> dxWn_2b >> dyWn_2b >> flags;
if (record.getGlobalWorkbookInfo()->Version > 0x0400)
{
record >> reserved >> itabCur_2b >> itabFirst_2b >> ctabSel >> wTabRatio_2b;
}
fHidden = GETBIT(flags, 0);
fIconic = GETBIT(flags, 1);

View File

@ -51,47 +51,44 @@ public:
void readFields(CFRecord& record) override;
void writeFields(CFRecord& record) override;
static const ElementType type = typeWindow2;
static const ElementType type = typeWindow2;
bool fDspFmlaRt; //fDspFmla in biff12
bool fDspGridRt; //fDspGrid in biff12
bool fDspRwColRt; //fDspRwCol in biff12
bool fFrozenRt;
bool fDspZerosRt; // fDspZeros in biff12
bool fDefaultHdr; // *
bool fRightToLeft; // *
bool fDspGuts; // *
bool fFrozenNoSplit;
bool fSelected; // *
bool fPaged;
bool fSLV;
bool fDspFmlaRt = false; //fDspFmla in biff12
bool fDspGridRt = false; //fDspGrid in biff12
bool fDspRwColRt = false; //fDspRwCol in biff12
bool fFrozenRt = false;
bool fDspZerosRt = false; // fDspZeros in biff12
bool fDefaultHdr = false; // *
bool fRightToLeft = false; // *
bool fDspGuts = false; // *
bool fFrozenNoSplit = false;
bool fSelected = false; // *
bool fPaged = false;
bool fSLV = false;
bool is_contained_in_chart_substream;
//_UINT16 rwTop;
UncheckedRw rwTop;
//_UINT16 colLeft;
UncheckedCol colLeft;
UncheckedRw rwTop;
UncheckedCol colLeft;
_UINT16 icvHdr; // 1 Byte in biff12
_UINT16 icvHdr = 64; // 1 Byte in biff12
_UINT16 wScaleSLV;
_UINT16 wScaleNormal;
std::wstring topLeftCell;
_UINT16 wScaleSLV;
_UINT16 wScaleNormal;
std::wstring topLeftCell;
//biff12
bool fWnProt;
bool fDspRuler;
bool fWhitespaceHidden;
bool fWnProt = false;
bool fDspRuler = false;
bool fWhitespaceHidden = false;
_UINT32 xlView;
_UINT32 xlView;
_UINT16 wScale;
_UINT16 wScalePLV;
_UINT32 iWbkView;
bool _isChart;
_UINT16 wScale;
_UINT16 wScalePLV;
_UINT32 iWbkView;
bool _isChart = false;
};
} // namespace XLS

View File

@ -74,15 +74,9 @@ namespace XLS
fill.fls = GETBIT(flags2, 7) ? 1 : 0;
//---------------------------------------------------------------------------------------------------
if (ifmt_index < global_info->m_arNumFormats.size() && ifmt_index != 0xff)
if (ifmt_index != 0xff)
{
Format* fmt = dynamic_cast<Format*>(global_info->m_arNumFormats[ifmt_index].get());
if (fmt)
{
format_code = fmt->stFormat;
ifmt = fmt->ifmt_used = global_info->RegisterNumFormat(fmt->ifmt, format_code); // return update
}
ifmt = global_info->RegisterNumFormat(ifmt_index, L""); // return update
}
if (font_index >= 0 && font_index < global_info->m_arFonts.size())
@ -144,14 +138,9 @@ namespace XLS
border.dgRight = static_cast<unsigned char>(GETBITS(flags5, 24, 26));
border.icvRight = (0 != border.dgRight) ? static_cast<unsigned char>(GETBITS(flags5, 27, 31)) : 0;
//---------------------------------------------------------------------------------------------------
if (ifmt_index < global_info->m_arNumFormats.size() && ifmt_index != 0xff)
if (ifmt_index != 0xff)
{
Format* fmt = dynamic_cast<Format*>(global_info->m_arNumFormats[ifmt_index].get());
if (fmt)
{
format_code = fmt->stFormat;
ifmt = fmt->ifmt_used = global_info->RegisterNumFormat(fmt->ifmt, format_code); // return update
}
ifmt = global_info->RegisterNumFormat(ifmt_index, L"");
}
if (font_index >= 0 && font_index < global_info->m_arFonts.size())
@ -186,6 +175,8 @@ namespace XLS
ixfParent = 0;
font_index = 0xffff;
ifmt = 0xffff;
}
XF::~XF()
{
@ -389,14 +380,9 @@ void XF::readFields(CFRecord& record)
case 2: trot = 90; break; // Text orientation: 90 deg counterclockwise.
case 3: trot = 270; break; // Text orientation: 90 deg clockwise.
}
if (ifmt_index < global_info->m_arNumFormats.size() && ifmt_index != 0xff)
if (ifmt_index != 0xff)
{
Format* fmt = dynamic_cast<Format*>(global_info->m_arNumFormats[ifmt_index].get());
if (fmt)
{
format_code = fmt->stFormat;
ifmt = fmt->ifmt_used = global_info->RegisterNumFormat(fmt->ifmt, format_code); // return update
}
ifmt = global_info->RegisterNumFormat(ifmt_index, L"");
}
if (font_index >= 0 && font_index < global_info->m_arFonts.size())

View File

@ -54,8 +54,8 @@ public:
static OfficeArtRecordPtr loadAnyArtRecord(XLS::CFRecord& record);
OfficeArtClientAnchorType anchor_type_;
std::vector<OfficeArtRecordPtr> child_records;
OfficeArtClientAnchorType anchor_type_;
std::vector<OfficeArtRecordPtr> child_records;
private:
OfficeArtRecordPtr CreateOfficeArt(unsigned short type);

View File

@ -86,9 +86,14 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
for (size_t i = 0 ; i < child_records.size(); i++)
{
//Log::warning("ArtRecord : " + STR::int2str(child_records[i]->rh_own.recType, 16));
switch(child_records[i]->rh_own.recType)
{
case ODRAW::OfficeArtRecord::DgContainer:
case ODRAW::OfficeArtRecord::DggContainer:
{
}break;
case ODRAW::OfficeArtRecord::DgContainer:
{
OfficeArtDgContainer * dg = dynamic_cast<OfficeArtDgContainer *>(child_records[i].get());
if (dg)
@ -107,22 +112,22 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
}
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::FDG:
case ODRAW::OfficeArtRecord::FDG:
{
m_OfficeArtFDG = child_records[i];
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::FRITContainer:
case ODRAW::OfficeArtRecord::FRITContainer:
{
m_OfficeArtFRITContainer = child_records[i];
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::SpgrContainer:
case ODRAW::OfficeArtRecord::SpgrContainer:
{
m_OfficeArtSpgrContainer = child_records[i];
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::SpContainer:
case ODRAW::OfficeArtRecord::SpContainer:
{
m_OfficeArtSpContainer.push_back(child_records[i]);
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
@ -132,8 +137,8 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
// m_OfficeArtSpgrContainerFileBlock = OfficeArtContainerPtr(art_container);
// child_records.erase(child_records.begin() + i,child_records.begin() + i + 1);
// }break;
default:
break;
default:
break;
}
}

View File

@ -52,7 +52,7 @@ public:
static const bool CheckIfContainerStartFound(XLS::CFRecord& record);
static const bool CheckIfContainerSizeOK(XLS::CFRecord& record);
static const XLS::ElementType type = XLS::typeOfficeArtDgContainer;
static const XLS::ElementType type = XLS::typeOfficeArtDgContainer;
void loadFields(XLS::CFRecord& record);

Some files were not shown because too many files have changed in this diff Show More