├── .clang-format ├── .gitattributes ├── .gitignore ├── .gitmodules ├── CONTRIBUTORS ├── LICENSE ├── LaTeX2AI.sln ├── LaTeX2AI.vcxproj ├── LaTeX2AI.vcxproj.filters ├── LaTeX2AI.vcxproj.user ├── LaTeX2AI.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── LaTeX2AI.xcscheme ├── README.md ├── doc ├── BUILD_FROM_SOURCE.md ├── CHANGELOG.md ├── images │ ├── convert_icons.sh │ ├── create_edit_ui.png │ ├── macos_permission_error.png │ ├── placement_baseline.png │ ├── placement_large.png │ ├── placement_small.png │ ├── tool_create.png │ ├── tool_options.png │ ├── tool_redo.png │ ├── tool_save_as_pdf.png │ └── tool_testing.png └── logo │ ├── create_logo.sh │ ├── icon_256.png │ ├── item_placement.tex │ ├── logo_black.png │ ├── logo_color.png │ ├── logo_icon.tex │ ├── logo_square.png │ └── logo_square_bw.png ├── resources ├── Mac │ ├── LaTeX2AI.r │ └── LaTeX2AI2x.r ├── Win │ ├── LaTeX2AI.rc │ └── Resource.h └── raw │ ├── IDToFile.txt │ ├── LaTeX2AI_cursor_create@2x.svg │ ├── LaTeX2AI_cursor_edit@2x.svg │ ├── LaTeX2AI_cursor_locked@2x.svg │ ├── LaTeX2AI_tool_create_dark@2x.svg │ ├── LaTeX2AI_tool_create_light@2x.svg │ ├── LaTeX2AI_tool_options_dark@2x.svg │ ├── LaTeX2AI_tool_options_light@2x.svg │ ├── LaTeX2AI_tool_redo_dark@2x.svg │ ├── LaTeX2AI_tool_redo_light@2x.svg │ ├── LaTeX2AI_tool_save_as_pdf_dark@2x.svg │ ├── LaTeX2AI_tool_save_as_pdf_light@2x.svg │ ├── LaTeX2AI_tool_testing_dark@2x.svg │ └── LaTeX2AI_tool_testing_light@2x.svg ├── scripts ├── __init__.py ├── base.py ├── check_license.py ├── compile_mac.sh ├── compile_solution.bat ├── create_headers.py ├── create_release.py ├── pipl │ ├── README.md │ ├── create_pipl.py │ └── pipl_gen │ │ ├── __init__.py │ │ ├── pipl_gen.py │ │ └── template_plugin.json ├── release_zip_readme.md └── ui_signing │ ├── SET_KEY_EXAMPLE.sh │ ├── ZXPSignCmd-64bit │ └── sign_ui_folder.sh ├── src ├── l2a_annotator.cpp ├── l2a_annotator.h ├── l2a_constants.h ├── l2a_global.cpp ├── l2a_global.h ├── l2a_item.cpp ├── l2a_item.h ├── l2a_latex.cpp ├── l2a_latex.h ├── l2a_names.h ├── l2a_plugin.cpp ├── l2a_plugin.h ├── l2a_property.cpp ├── l2a_property.h ├── l2a_suites.cpp ├── l2a_suites.h ├── l2a_ui_base.cpp ├── l2a_ui_base.h ├── l2a_ui_debug.cpp ├── l2a_ui_debug.h ├── l2a_ui_item.cpp ├── l2a_ui_item.h ├── l2a_ui_manager.cpp ├── l2a_ui_manager.h ├── l2a_ui_options.cpp ├── l2a_ui_options.h ├── l2a_ui_redo.cpp ├── l2a_ui_redo.h ├── tests │ ├── test_base64.cpp │ ├── test_base64.h │ ├── test_file_system.cpp │ ├── test_file_system.h │ ├── test_framework.cpp │ ├── test_framework.h │ ├── test_latex.cpp │ ├── test_latex.h │ ├── test_parameter_list.cpp │ ├── test_parameter_list.h │ ├── test_string_functions.cpp │ ├── test_string_functions.h │ ├── test_utility.cpp │ ├── test_utlity.h │ ├── testing.cpp │ ├── testing.h │ ├── testing_utility.cpp │ └── testing_utlity.h └── utils │ ├── l2a_ai_functions.cpp │ ├── l2a_ai_functions.h │ ├── l2a_error.cpp │ ├── l2a_error.h │ ├── l2a_execute.cpp │ ├── l2a_execute.h │ ├── l2a_file_system.cpp │ ├── l2a_file_system.h │ ├── l2a_math.cpp │ ├── l2a_math.h │ ├── l2a_parameter_list.cpp │ ├── l2a_parameter_list.h │ ├── l2a_string_functions.cpp │ ├── l2a_string_functions.h │ ├── l2a_utils.h │ ├── l2a_version.cpp │ └── l2a_version.h ├── tex ├── LaTeX2AI_header.tex └── LaTeX2AI_item.tex └── ui ├── CSXS └── manifest.xml ├── css └── latex2ai.css ├── html ├── index_debug.html ├── index_item.html ├── index_options.html ├── index_redo.html ├── item_placement_dark.png └── item_placement_light.png └── js ├── CSInterface.js ├── common.js ├── jquery-3.7.1.min.js ├── main_debug.js ├── main_item.js ├── main_options.js └── main_redo.js /.clang-format: -------------------------------------------------------------------------------- 1 | # Define the base style 2 | BasedOnStyle: Google 3 | 4 | # Modifications of base style 5 | AlignAfterOpenBracket: DontAlign 6 | BreakBeforeBraces: Allman 7 | ColumnLimit: 120 8 | MaxEmptyLinesToKeep: 3 9 | NamespaceIndentation: All 10 | SpacesInContainerLiterals: false 11 | Standard: c++17 12 | TabWidth: 4 13 | IndentWidth: 4 14 | 15 | # Sort imported headers 16 | IncludeBlocks: Regroup 17 | SortIncludes: CaseInsensitive 18 | IncludeCategories: 19 | # Precompiled Illustrator header 20 | - Regex: "IllustratorSDK\\.h" 21 | Priority: -1 22 | 23 | # Header corresponging to cpp file has priority 0 24 | 25 | # LaTeX2AI headers 26 | - Regex: "l2a_.*\\.(h|H)" 27 | Priority: 10 28 | 29 | # Standard library headers 30 | - Regex: "<[a-z_]+>" 31 | Priority: 100 32 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ai binary 2 | *.png binary 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Hidden files 2 | .* 3 | 4 | # Visual Studio files 5 | .vs/* 6 | */.vs/* 7 | 8 | # XCode files 9 | *xcuserdata* 10 | *xcworkspacedata* 11 | 12 | # Build files 13 | /forms/obj 14 | /build 15 | 16 | # Automatically generated files 17 | auto_generated/ 18 | scripts/executables/ 19 | ui/js/auto_generated.js 20 | plugin.pipl 21 | 22 | # Python 23 | __pycache__ 24 | *.pyc 25 | 26 | # TeX files 27 | *.aux 28 | *.log 29 | *.pdf 30 | *.synctex.gz 31 | *.fls 32 | *.fdb_latexmk 33 | 34 | # Certificate 35 | latex2ai_certificate.p12 36 | SET_KEY.sh 37 | latex2ai_ui.zxp 38 | com.isteinbrecher.latex2ai 39 | 40 | # Release 41 | LaTeX2AI*.aip 42 | LaTeX2AI*.zip 43 | */release_zip/* 44 | */release_zip_temp/* 45 | */release_files/* 46 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tpl/tinyxml2"] 2 | path = tpl/tinyxml2 3 | url = https://github.com/leethomason/tinyxml2.git 4 | [submodule "tpl/StackWalker"] 5 | path = tpl/StackWalker 6 | url = https://github.com/JochenKalmbach/StackWalker.git 7 | [submodule "tpl/json"] 8 | path = tpl/json 9 | url = https://github.com/nlohmann/json.git 10 | [submodule "tpl/base64"] 11 | path = tpl/base64 12 | url = https://github.com/isteinbrecher/base64.git 13 | [submodule "tpl/CRCpp"] 14 | path = tpl/CRCpp 15 | url = https://github.com/d-bahr/CRCpp.git 16 | [submodule "tpl/cpp-semver"] 17 | path = tpl/cpp-semver 18 | url = https://github.com/z4kn4fein/cpp-semver.git 19 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # List of authors for LaTeX2AI (including their GitHub user names) 2 | 3 | # Main developer 4 | 5 | Ivo Steinbrecher (@isteinbrecher) 6 | 7 | # Contributors (in chronological order of their first contribution) 8 | 9 | Nikita Rushmanov (@nikita240) 10 | Da Zhi (@dzhi1993) 11 | @MGG1996 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2025 Ivo Steinbrecher 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LaTeX2AI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34221.43 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LaTeX2AI", "LaTeX2AI.vcxproj", "{43DFFFAC-95F5-4D21-BB85-EA1BA160E9C2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {43DFFFAC-95F5-4D21-BB85-EA1BA160E9C2}.Debug|x64.ActiveCfg = Debug|x64 15 | {43DFFFAC-95F5-4D21-BB85-EA1BA160E9C2}.Debug|x64.Build.0 = Debug|x64 16 | {43DFFFAC-95F5-4D21-BB85-EA1BA160E9C2}.Release|x64.ActiveCfg = Release|x64 17 | {43DFFFAC-95F5-4D21-BB85-EA1BA160E9C2}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {68844410-2C22-484E-B8B2-EE78E416647E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /LaTeX2AI.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(ILLUSTRATOR_EXE) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(ILLUSTRATOR_EXE) 9 | WindowsLocalDebugger 10 | 11 | 12 | -------------------------------------------------------------------------------- /LaTeX2AI.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LaTeX2AI.xcodeproj/xcshareddata/xcschemes/LaTeX2AI.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 42 | 45 | 46 | 47 | 53 | 54 | 60 | 61 | 62 | 63 | 65 | 66 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /doc/BUILD_FROM_SOURCE.md: -------------------------------------------------------------------------------- 1 | # Build LaTeX2AI from source 2 | 3 | ## Requirements 4 | 5 | The additional requirements to build LaTeX2AI from source are: 6 | 7 | - A C++ compiler has to be available on the system. This repository includes a Visual Studio 2022 solution for Windows and a Xcode project for macOS. 8 | - `python3` and `git` have to be available on the system. 9 | 10 | ## Getting started 11 | 12 | 1. Download and unpack the [Adobe Illustrator SDK](https://console.adobe.io/downloads) 13 | 14 | 1. Go to the sample code folder `/sample code` and run 15 | ``` 16 | git clone https://github.com/isteinbrecher/latex2ai.git 17 | ``` 18 | 1. Go to `/sample code/LaTeX2AI` and run 19 | ``` 20 | git submodule update --init 21 | ``` 22 | 23 | ## Windows 24 | 25 | 1. Environment variables: 26 | 27 | - `PYTHON_EXE` has to point to a valid `python3` executable on the system. 28 | - `ILLUSTRATOR_EXE` has to point to the illustrator executable on the system (this path is used for debugging). 29 | 30 | 1. Open `/sample code/latex2ai/LaTeX2AI.sln` with Visual Studio, select the build type (_Release_ or _Debug_) and compile the solution. 31 | It might be necessary to change the _Windows SDK_ version for `LaTeX2AI` to match the one available on your system. 32 | 1. The compiled binary is located at `/sample code/output/win/x64/`. 33 | This directory has to be set as the Plugin directory in Illustrator. 34 | 1. You have to set a link to the UI folder so Illustrator can find the user interface: 35 | ``` 36 | mklink /D "C:\Users\\AppData\Roaming\Adobe\CEP\extensions\com.isteinbrecher.latex2ai" "\samplecode\latex2ai\ui" 37 | ``` 38 | 1. Debugging of unsigned extensions has to be turned on ([see the Adobe CEP cookbook](https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_11.x/Documentation/CEP%2011.1%20HTML%20Extension%20Cookbook.md#debugging-unsigned-extensions)): 39 | - Open `regedit` 40 | - Go to the key `HKEY_CURRENT_USER/Software/Adobe/CSXS.11` 41 | - Add a new entry `PlayerDebugMode` of type `string` with the value of `1` 42 | 43 | ## macOS 44 | 45 | 1. Open `/sample code/latex2ai/LaTeX2AI.xcodeproj` with Xcode and compile the solution. 46 | 1. The compiled binary is located at `/sample code/output/`. 47 | This directory has to be set as the Plugin directory in Illustrator. 48 | 1. You have to set a link to the UI folder so Illustrator can find the user interface: 49 | ```bash 50 | ln -s "\samplecode\latex2ai\ui" "~/Library/Application Support/Adobe/CEP/extensions/com.isteinbrecher.latex2ai" 51 | ``` 52 | 1. Debugging of unsigned extensions has to be turned on ([see the Adobe CEP cookbook](https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_11.x/Documentation/CEP%2011.1%20HTML%20Extension%20Cookbook.md#debugging-unsigned-extensions)): 53 | ```bash 54 | defaults write com.adobe.CSXS.11 PlayerDebugMode 1 55 | ``` 56 | -------------------------------------------------------------------------------- /doc/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | - **v1.0.3** 4 | - Features: 5 | - Pressing `Escape` in the debug form now returns to the item form instead of ending the item create/edit process. 6 | - Bug fixes: 7 | - Fix bug that could arise when the item vector inside the annotator contained items with non-valid pointers 8 | - **v1.0.2** 9 | - Bug fixes: 10 | - Fix bug that caused Illustrator to crash when deselecting all active LaTeX2AI elements [#189](https://github.com/isteinbrecher/latex2ai/issues/189). 11 | - **v1.0.1** 12 | - Bug fixes: 13 | - Fix bug that caused problems when using items that were created using a deprecated hash algorithm. 14 | - **v1.0.0** 15 | - Features: 16 | - Add macOS support. 17 | - Add support for Unicode file paths. 18 | - Fix pdf file structure before missing links message is shown. 19 | - Improve finding of LaTeX and ghostscript paths. 20 | - Rework documentation. 21 | - Fix errors when working with Creative Cloud documents. 22 | - Allow to chose hotkey to finish item create / edit UI. 23 | - Other: 24 | - Use platform independent string hash algorithm. 25 | - Use native `html` based UI. 26 | - Restructured the repository file structure. 27 | - Deprecations: 28 | - Due to the new `html` UI, **Illustrator CS6 support is dropped**. 29 | - **v0.0.10** 30 | - Features: 31 | - Add optional warnings when saving as PDF. 32 | - Other: 33 | - Add warning that LaTeX2AI is not compatible with non ASCII characters in the document path. 34 | - Support Illustrator 2022 35 | - Improve drawing of borders in preview mode. 36 | - **v0.0.9** 37 | - Features: 38 | - Add storage of labels inside Illustrator. 39 | - Add undo and redo text. 40 | - **v0.0.8** 41 | - Bug fixes: 42 | - Fix bug in header include function. 43 | - Fix a bug when using MikTeX. 44 | - Other: 45 | - Deactivate possible externalization in TikZ constructs. 46 | - **v0.0.7** 47 | - Bug fixes: 48 | - Fix bug in check version. 49 | - Other: 50 | - Improve path finding at startup. 51 | - **v0.0.6** 52 | - Bug fixes: 53 | - Fix bug when saving a PDF for an unsaved AI document. 54 | - Other: 55 | - LaTeX2AI now checks on startup if new releases are published on GitHub. 56 | - Improve output message for Illustrator errors. 57 | - Multiple images are now split with a single call to ghostscript. 58 | - Add logo. 59 | - **v0.0.5** 60 | - Other: 61 | - Support Illustrator 2017 62 | - **v0.0.4** 63 | - Bug fixes: 64 | - Fix error when editing item with missing PDF file. 65 | - Fix error with included headers containing relative paths. 66 | - Clean temp directory at startup. 67 | - Fix bugs when working with locked and or hidden layers / groups. 68 | - Other: 69 | - Create automated build script. 70 | - Support Illustrator CC 2018. 71 | - **v0.0.3** 72 | - New features: 73 | - Allow to redo boundary box from the create / edit form. 74 | - Allow to redo the latex label from the create / edit form. 75 | - Bug fixes: 76 | - Fix bug with whitespaces in `system` calls. 77 | - Other: 78 | - Add contributing guidelines. 79 | - Change the default placement options. 80 | - Rename environment variable `ILLUSTRATOR_PATH` to `ILLUSTRATOR_EXE`. 81 | - **v0.0.2** 82 | - New features: 83 | - Allow for `\input` commands in LaTeX headers. 84 | - Add option to edit LaTeX header in the settings form. 85 | - Bug fixes: 86 | - Replace hardcoded path to python executable with environment variable `PYTHON_EXE`. 87 | - Replace hardcoded path to Illustrator executable with environment variable `ILLUSTRATOR_PATH`. 88 | - Other: 89 | - Add information how to cite. 90 | - Forms and the plugin are now compiled in the same directory; also add more detailed build information. 91 | - LaTeX2AI can now also be installed in the default Illustrator plug-in directory. 92 | - Support Illustrator 2021. 93 | - **v0.0.1:** Initial release 94 | -------------------------------------------------------------------------------- /doc/images/convert_icons.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | 27 | declare -a ARRAY=("tool_create" "tool_options" "tool_redo" "tool_save_as_pdf" "tool_testing") 28 | 29 | # Loop over the strings in the array 30 | for NAME in "${ARRAY[@]}" 31 | do 32 | qlmanage -t -s 32 -o . "../../resources/raw/LaTeX2AI_${NAME}_light@2x.svg" 33 | mv "LaTeX2AI_${NAME}_light@2x.svg.png" "${NAME}.png" 34 | done 35 | -------------------------------------------------------------------------------- /doc/images/create_edit_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/create_edit_ui.png -------------------------------------------------------------------------------- /doc/images/macos_permission_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/macos_permission_error.png -------------------------------------------------------------------------------- /doc/images/placement_baseline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/placement_baseline.png -------------------------------------------------------------------------------- /doc/images/placement_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/placement_large.png -------------------------------------------------------------------------------- /doc/images/placement_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/placement_small.png -------------------------------------------------------------------------------- /doc/images/tool_create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/tool_create.png -------------------------------------------------------------------------------- /doc/images/tool_options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/tool_options.png -------------------------------------------------------------------------------- /doc/images/tool_redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/tool_redo.png -------------------------------------------------------------------------------- /doc/images/tool_save_as_pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/tool_save_as_pdf.png -------------------------------------------------------------------------------- /doc/images/tool_testing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/images/tool_testing.png -------------------------------------------------------------------------------- /doc/logo/create_logo.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | # Create the logo and icon pdf 27 | pdflatex logo_icon.tex 28 | 29 | # Convert the pdf into pngs 30 | # -r = [png pixel size] / [size in mm] / 10 / 2.54 31 | gs -dFirstPage=1 -dLastPage=1 -sDEVICE=pngalpha -dTextAlphaBits=4 -r2442 -o logo_black.png logo_icon.pdf 32 | gs -dFirstPage=2 -dLastPage=2 -sDEVICE=pngalpha -dTextAlphaBits=4 -r2442 -o logo_color.png logo_icon.pdf 33 | gs -dFirstPage=3 -dLastPage=3 -sDEVICE=pngalpha -dTextAlphaBits=4 -r2442 -o logo_square.png logo_icon.pdf 34 | gs -dFirstPage=4 -dLastPage=4 -sDEVICE=pngalpha -dTextAlphaBits=4 -r1250 -o icon_256.png logo_icon.pdf 35 | gs -dFirstPage=5 -dLastPage=5 -sDEVICE=pngalpha -dTextAlphaBits=4 -r2442 -o logo_square_bw.png logo_icon.pdf 36 | 37 | # Create the image placement 38 | pdflatex item_placement.tex 39 | 40 | # Convert the pdf into png 41 | gs -dFirstPage=1 -dLastPage=1 -sDEVICE=pngalpha -dTextAlphaBits=4 -r650 -o ../../ui/html/item_placement_light.png item_placement.pdf 42 | gs -dFirstPage=2 -dLastPage=2 -sDEVICE=pngalpha -dTextAlphaBits=4 -r650 -o ../../ui/html/item_placement_dark.png item_placement.pdf 43 | -------------------------------------------------------------------------------- /doc/logo/icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/logo/icon_256.png -------------------------------------------------------------------------------- /doc/logo/item_placement.tex: -------------------------------------------------------------------------------- 1 | % ----------------------------------------------------------------------------- 2 | % MIT License 3 | % 4 | % Copyright (c) 2020-2025 Ivo Steinbrecher 5 | % 6 | % Permission is hereby granted, free of charge, to any person obtaining a copy 7 | % of this software and associated documentation files (the "Software"), to deal 8 | % in the Software without restriction, including without limitation the rights 9 | % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | % copies of the Software, and to permit persons to whom the Software is 11 | % furnished to do so, subject to the following conditions: 12 | % 13 | % The above copyright notice and this permission notice shall be included in 14 | % all copies or substantial portions of the Software. 15 | % 16 | % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | % SOFTWARE. 23 | % ----------------------------------------------------------------------------- 24 | 25 | \documentclass[multi=page,border=0.2pt]{standalone} 26 | 27 | \usepackage{tikz} 28 | 29 | \newcommand{\ysep}{0.2mm} 30 | \newcommand{\demotext}{afg} 31 | 32 | \begin{document} 33 | % 34 | \begin{page}% 35 | \begin{tikzpicture}[] 36 | \node [anchor=base west,inner sep=0pt] (A) {\large \demotext}; 37 | \draw [red, dash pattern=on 1.5pt off 0.82pt] (A.base west) -- (A.base east); 38 | \draw [opacity=0]([yshift=-\ysep]A.south west) -- ([yshift=\ysep]A.north east); 39 | \end{tikzpicture}% 40 | \end{page}% 41 | % 42 | \begin{page}% 43 | \begin{tikzpicture}[] 44 | \node [anchor=base west,inner sep=0pt] (A) {\large \textcolor{lightgray}{\demotext}}; 45 | \draw [red, dash pattern=on 1.5pt off 0.82pt] (A.base west) -- (A.base east); 46 | \draw [opacity=0]([yshift=-\ysep]A.south west) -- ([yshift=\ysep]A.north east); 47 | \end{tikzpicture}% 48 | \end{page}% 49 | % 50 | \end{document} 51 | -------------------------------------------------------------------------------- /doc/logo/logo_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/logo/logo_black.png -------------------------------------------------------------------------------- /doc/logo/logo_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/logo/logo_color.png -------------------------------------------------------------------------------- /doc/logo/logo_icon.tex: -------------------------------------------------------------------------------- 1 | % ----------------------------------------------------------------------------- 2 | % MIT License 3 | % 4 | % Copyright (c) 2020-2025 Ivo Steinbrecher 5 | % 6 | % Permission is hereby granted, free of charge, to any person obtaining a copy 7 | % of this software and associated documentation files (the "Software"), to deal 8 | % in the Software without restriction, including without limitation the rights 9 | % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | % copies of the Software, and to permit persons to whom the Software is 11 | % furnished to do so, subject to the following conditions: 12 | % 13 | % The above copyright notice and this permission notice shall be included in 14 | % all copies or substantial portions of the Software. 15 | % 16 | % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | % SOFTWARE. 23 | % ----------------------------------------------------------------------------- 24 | 25 | \documentclass[multi,border=0mm]{standalone} 26 | 27 | \newenvironment{lta}{\ignorespaces}{\ignorespacesafterend} 28 | \standaloneenv{lta} 29 | 30 | \usepackage{sourcesanspro} 31 | \usepackage{tikz} 32 | 33 | \usepackage{xcolor} 34 | \definecolor{back}{cmyk}{0,0.5,1,0.85} 35 | \definecolor{yel}{cmyk}{0,0.5,1,0} 36 | 37 | % Full LaTeX2AI text 38 | \newcommand{\latextoai}{\LaTeX{}2\sffamily\bfseries{Ai}} 39 | 40 | % Half sizes for the icon 41 | \newcommand{\widthHalf}{23pt} 42 | \newcommand{\heightHalf}{7pt} 43 | 44 | % Half size for the square icons 45 | \newcommand{\sizeHalf}{7pt} 46 | 47 | \begin{document} 48 | 49 | % LaTeX2AI logo 50 | \begin{lta} 51 | \begin{tikzpicture} 52 | \node [anchor=base,inner sep=1pt](L) at (0pt,-3pt) {\textcolor{black}{\latextoai}}; 53 | \end{tikzpicture}% 54 | \end{lta} 55 | 56 | % LaTeX2AI icon 57 | \begin{lta} 58 | \begin{tikzpicture} 59 | \draw [yel,fill=back,thick] (-\widthHalf,-\heightHalf) rectangle (\widthHalf,\heightHalf); 60 | \node [anchor=base,inner sep=0pt](L) at (0pt,-3pt) {\textcolor{yel}{\latextoai}}; 61 | \end{tikzpicture}% 62 | \end{lta} 63 | 64 | % Large square icon 65 | \begin{lta} 66 | \begin{tikzpicture} 67 | \draw [yel,fill=back,thick] (-\sizeHalf,-\sizeHalf) rectangle (\sizeHalf,\sizeHalf); 68 | \node [anchor=base,inner sep=0pt](L) at (-3pt,-3pt) {\textcolor{yel}{$L$}}; 69 | \node [anchor=base,inner sep=0pt] (two) at (-0.5pt,0pt) {\tiny\textcolor{yel}{2}}; 70 | \node [anchor=base,inner sep=0pt] (A) at (3pt,-3pt) {\sffamily \bfseries \textcolor{yel}{A}}; 71 | \end{tikzpicture}% 72 | \end{lta} 73 | 74 | % Small square icon 75 | \begin{lta} 76 | \begin{tikzpicture} 77 | \draw [yel,fill=back,thick] (-\sizeHalf,-\sizeHalf) rectangle (\sizeHalf,\sizeHalf); 78 | \node [anchor=base,inner sep=0pt](L) at (-3.25pt,-3pt) {\textcolor{yel}{\bfseries \textit{L}}}; 79 | \node [anchor=base,inner sep=0pt] (A) at (3pt,-3pt) {\sffamily \bfseries \textcolor{yel}{A}}; 80 | \end{tikzpicture}% 81 | \end{lta} 82 | 83 | % Black white large square icon 84 | \renewcommand{\sizeHalf}{6.5pt} 85 | \begin{lta} 86 | \begin{tikzpicture} 87 | \draw [opacity=0] (-\sizeHalf,-\sizeHalf) rectangle (\sizeHalf,\sizeHalf); 88 | \node [anchor=base,inner sep=0pt](L) at (-3.15pt,-3pt) {$L$}; 89 | \node [anchor=base,inner sep=0pt] (two) at (-0.1pt,0.5pt) {\tiny 2}; 90 | \node [anchor=base,inner sep=0pt] (A) at (3.15pt,-3pt) {\sffamily \bfseries A}; 91 | \end{tikzpicture}% 92 | \end{lta} 93 | 94 | \end{document} 95 | -------------------------------------------------------------------------------- /doc/logo/logo_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/logo/logo_square.png -------------------------------------------------------------------------------- /doc/logo/logo_square_bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/doc/logo/logo_square_bw.png -------------------------------------------------------------------------------- /resources/Mac/LaTeX2AI.r: -------------------------------------------------------------------------------- 1 | //======================================================================================== 2 | // 3 | // $File$ 4 | // 5 | // $Revision$ 6 | // 7 | // Copyright 1987 Adobe Systems Incorporated. All rights reserved. 8 | // 9 | // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance 10 | // with the terms of the Adobe license agreement accompanying it. If you have received 11 | // this file from a source other than Adobe, then your use, modification, or 12 | // distribution of it requires the prior written permission of Adobe. 13 | // 14 | //======================================================================================== 15 | 16 | /* 17 | * Two Resource files are required for Mac one for the standard definition resources and one 18 | * for HiDPI resources. The resource entries for both are required regardless of whether 19 | * you will be providing HiDPI icons for your tools. If you do not provide the two resource 20 | * files you will receive [CANT] Errors on startup. 21 | * 22 | * The resource files should follow the naming convention: 23 | * PluginName.r -> eg. Annotator.r - for standard image definitions 24 | * PluginName2x.r -> eg. Annotator2x.r - for HiDPI image definitions 25 | * 26 | * 27 | * Changes in resource handling: 28 | * In 10.8 SDK, Apple deprecated all .r/.rsrc resource reading APIs. Now all resources files 29 | * will need to be copied to /Contents/Resources// as post build step. 30 | * 31 | * In this sample there are 9 resources used. 32 | * 33 | * The resources are added in the Run Script build phase of the target. Each resource is added 34 | * to a folder named after its extension. 35 | * e.g All png folders should be copied to /Contents/Resources/png/. 36 | * 37 | * IDToFile.txt 38 | * -------------- 39 | * Take a look in IDToFile.txt for how to define resources. 40 | */ 41 | 42 | #include 43 | -------------------------------------------------------------------------------- /resources/Mac/LaTeX2AI2x.r: -------------------------------------------------------------------------------- 1 | //======================================================================================== 2 | // 3 | // $File: //ai/mainline/devtech/sdk/public/samplecode/MultiArrowTool/Resources/MultiArrowTool.r $ 4 | // 5 | // $Revision: #4 $ 6 | // 7 | // Copyright 1987 Adobe Systems Incorporated. All rights reserved. 8 | // 9 | // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance 10 | // with the terms of the Adobe license agreement accompanying it. If you have received 11 | // this file from a source other than Adobe, then your use, modification, or 12 | // distribution of it requires the prior written permission of Adobe. 13 | // 14 | //======================================================================================== 15 | 16 | /* 17 | * You should copy your HiDPI images as post build step. See MultiArrowTool.r for more details. 18 | */ 19 | -------------------------------------------------------------------------------- /resources/Win/LaTeX2AI.rc: -------------------------------------------------------------------------------- 1 | //======================================================================================== 2 | // 3 | // $File$ 4 | // 5 | // $Revision$ 6 | // 7 | // Copyright 1987 Adobe Systems Incorporated. All rights reserved. 8 | // 9 | // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance 10 | // with the terms of the Adobe license agreement accompanying it. If you have received 11 | // this file from a source other than Adobe, then your use, modification, or 12 | // distribution of it requires the prior written permission of Adobe. 13 | // 14 | //======================================================================================== 15 | 16 | //Microsoft Developer Studio generated resource script. 17 | // 18 | #include "resource.h" 19 | 20 | #define APSTUDIO_READONLY_SYMBOLS 21 | ///////////////////////////////////////////////////////////////////////////// 22 | // 23 | // Generated from the TEXTINCLUDE 2 resource. 24 | // 25 | #include "l2a_constants.h" 26 | #include "windows.h" 27 | 28 | ///////////////////////////////////////////////////////////////////////////// 29 | #undef APSTUDIO_READONLY_SYMBOLS 30 | 31 | ///////////////////////////////////////////////////////////////////////////// 32 | // English (U.S.) resources 33 | 34 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 35 | #ifdef _WIN32 36 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 37 | #pragma code_page(1252) 38 | #endif //_WIN32 39 | 40 | #define kMySDKPluginName L2A_PLUGIN_NAME 41 | #define PIPL_PLUGIN_NAME kMySDKPluginName 42 | 43 | ///////////////////////////////////////////////////////////////////////////// 44 | // VersionInfo 45 | // 46 | 47 | #include "VersionInfo.rc" 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // 51 | // PIPL 52 | // 53 | 54 | plugin pipl "plugin.pipl" 55 | 56 | #ifdef APSTUDIO_INVOKED 57 | ///////////////////////////////////////////////////////////////////////////// 58 | // 59 | // TEXTINCLUDE 60 | // 61 | 62 | 1 TEXTINCLUDE DISCARDABLE 63 | BEGIN 64 | "resource.h\0" 65 | END 66 | 67 | 2 TEXTINCLUDE DISCARDABLE 68 | BEGIN 69 | "#include ""l2a_constants.h""\r\n" 70 | "#include ""windows.h""\r\n" 71 | END 72 | 73 | 3 TEXTINCLUDE DISCARDABLE 74 | BEGIN 75 | "\r\n" 76 | "\0" 77 | END 78 | 79 | #endif // APSTUDIO_INVOKED 80 | 81 | #endif // English (U.S.) resources 82 | ///////////////////////////////////////////////////////////////////////////// 83 | 84 | IDToFile txt IDToFile.txt 85 | 86 | LaTeX2AI_tool_create_dark_at_2x svg "LaTeX2AI_tool_create_dark@2x.svg" 87 | LaTeX2AI_tool_create_light_at_2x svg "LaTeX2AI_tool_create_light@2x.svg" 88 | LaTeX2AI_tool_redo_dark_at_2x svg "LaTeX2AI_tool_redo_dark@2x.svg" 89 | LaTeX2AI_tool_redo_light_at_2x svg "LaTeX2AI_tool_redo_light@2x.svg" 90 | LaTeX2AI_tool_options_dark_at_2x svg "LaTeX2AI_tool_options_dark@2x.svg" 91 | LaTeX2AI_tool_options_light_at_2x svg "LaTeX2AI_tool_options_light@2x.svg" 92 | LaTeX2AI_tool_save_as_pdf_dark_at_2x svg "LaTeX2AI_tool_save_as_pdf_dark@2x.svg" 93 | LaTeX2AI_tool_save_as_pdf_light_at_2x svg "LaTeX2AI_tool_save_as_pdf_light@2x.svg" 94 | LaTeX2AI_tool_testing_dark_at_2x svg "LaTeX2AI_tool_testing_dark@2x.svg" 95 | LaTeX2AI_tool_testing_light_at_2x svg "LaTeX2AI_tool_testing_light@2x.svg" 96 | 97 | LaTeX2AI_cursor_create_at_2x svg "LaTeX2AI_cursor_create@2x.svg" 98 | LaTeX2AI_cursor_edit_at_2x svg "LaTeX2AI_cursor_edit@2x.svg" 99 | LaTeX2AI_cursor_locked_at_2x svg "LaTeX2AI_cursor_locked@2x.svg" 100 | -------------------------------------------------------------------------------- /resources/Win/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by plugin.rc 4 | // 5 | #define kToolStrings 16100 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 113 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1000 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /resources/raw/IDToFile.txt: -------------------------------------------------------------------------------- 1 | 19000.svg LaTeX2AI_tool_create_dark@2x.svg 2 | 19001.svg LaTeX2AI_tool_create_light@2x.svg 3 | 19002.svg LaTeX2AI_tool_redo_dark@2x.svg 4 | 19003.svg LaTeX2AI_tool_redo_light@2x.svg 5 | 19004.svg LaTeX2AI_tool_options_dark@2x.svg 6 | 19005.svg LaTeX2AI_tool_options_light@2x.svg 7 | 19006.svg LaTeX2AI_tool_save_as_pdf_dark@2x.svg 8 | 19007.svg LaTeX2AI_tool_save_as_pdf_light@2x.svg 9 | 19008.svg LaTeX2AI_tool_testing_dark@2x.svg 10 | 19009.svg LaTeX2AI_tool_testing_light@2x.svg 11 | 19100.svg LaTeX2AI_cursor_create@2x.svg 12 | 19101.svg LaTeX2AI_cursor_locked@2x.svg 13 | 19102.svg LaTeX2AI_cursor_edit@2x.svg 14 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_cursor_create@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 32 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_cursor_edit@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 24 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_cursor_locked@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 23 | 30 | 31 | 32 | 35 | 36 | 41 | 42 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_create_dark@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 10 | 15 | 19 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_create_light@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 10 | 17 | 18 | 19 | 24 | 28 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_options_dark@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 15 | 17 | 18 | 19 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_options_light@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 15 | 17 | 18 | 19 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_redo_dark@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 14 | 16 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_redo_light@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 14 | 16 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_save_as_pdf_dark@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 19 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_save_as_pdf_light@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 19 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_testing_dark@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 13 | 16 | 17 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /resources/raw/LaTeX2AI_tool_testing_light@2x.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 13 | 16 | 17 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | -------------------------------------------------------------------------------- /scripts/base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | """ 27 | Convert integers to different bases and show the ascii equivalent. 28 | """ 29 | 30 | 31 | def number_to_digits(number, base): 32 | """Convert a positive number to its digit representation in base.""" 33 | digits = [] 34 | while number > 0: 35 | digits.insert(0, number % base) 36 | number = number // base 37 | return digits 38 | 39 | 40 | def number_to_string(number): 41 | """Print the ascii characters for the given digits.""" 42 | print("".join([chr(i) for i in number_to_digits(number, 256)])) 43 | 44 | 45 | def hex_to_string(hex_code): 46 | """Print the string represented by the hex code.""" 47 | print(bytearray.fromhex(hex_code).decode()) 48 | -------------------------------------------------------------------------------- /scripts/check_license.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | """ 27 | Check if the source files in the repository have the correct header. 28 | """ 29 | 30 | # Import python modules. 31 | import os 32 | import subprocess 33 | 34 | 35 | def get_repository_dir(): 36 | """ 37 | Get the root directory of this repository. 38 | """ 39 | 40 | script_path = os.path.realpath(__file__) 41 | root_dir = os.path.dirname(os.path.dirname(script_path)) 42 | return root_dir 43 | 44 | 45 | def get_license_text(): 46 | """ 47 | Return the license text as a string. 48 | """ 49 | 50 | license_path = os.path.join(get_repository_dir(), "LICENSE") 51 | with open(license_path) as license_file: 52 | return license_file.read().strip() 53 | 54 | 55 | def get_all_source_files(): 56 | """ 57 | Get all source files that should be checked for license headers. 58 | """ 59 | 60 | # Get the files in the git repository. 61 | repo_dir = get_repository_dir() 62 | process = subprocess.Popen( 63 | ["git", "ls-files"], stdout=subprocess.PIPE, cwd=repo_dir 64 | ) 65 | out, _err = process.communicate() 66 | files = out.decode("UTF-8").strip().split("\n") 67 | 68 | source_line_endings = [".py", ".cs", ".cpp", ".h", ".bat", ".sh", ".tex"] 69 | source_ending_types = { 70 | ".py": "py", 71 | ".cs": "c", 72 | ".cpp": "c", 73 | ".h": "c", 74 | ".bat": "bat", 75 | ".sh": "sh", 76 | ".tex": "tex", 77 | } 78 | source_files = {"py": [], "c": [], "bat": [], "sh": [], "tex": []} 79 | 80 | skip_folders = ["scripts/pipl"] 81 | 82 | for file in files: 83 | extension = os.path.splitext(file)[1] 84 | for skip_folder in skip_folders: 85 | if file.startswith(skip_folder): 86 | break 87 | else: 88 | if extension not in source_line_endings: 89 | pass 90 | else: 91 | source_files[source_ending_types[extension]].append( 92 | os.path.join(repo_dir, file) 93 | ) 94 | return source_files 95 | 96 | 97 | def license_to_source(license_text, source_type): 98 | """ 99 | Convert the license text to a text that can be written to source code. 100 | """ 101 | 102 | header = None 103 | start_line = "-" * 77 104 | if source_type == "py": 105 | header = "# -*- coding: utf-8 -*-" 106 | comment = "#" 107 | elif source_type == "c" or source_type == "js": 108 | comment = "//" 109 | elif source_type == "bat": 110 | comment = "@REM" 111 | elif source_type == "sh": 112 | header = "#! /bin/bash" 113 | comment = "#" 114 | elif source_type == "tex": 115 | comment = "%" 116 | else: 117 | raise ValueError("Wrong extension!") 118 | 119 | source = [] 120 | if header is not None: 121 | source.append(header) 122 | source.append(comment + " " + start_line) 123 | for line in license_text.split("\n"): 124 | if len(line) > 0: 125 | source.append(comment + " " + line) 126 | else: 127 | source.append(comment + line) 128 | source.append(comment + " " + start_line) 129 | return "\n".join(source) 130 | 131 | 132 | def check_license(): 133 | """ 134 | Check the license for all source files. 135 | """ 136 | 137 | license_text = get_license_text() 138 | source_files = get_all_source_files() 139 | 140 | skip_list = ["resources/Win/Resource.h"] 141 | 142 | for key in source_files: 143 | header = license_to_source(license_text, key) 144 | for file in source_files[key]: 145 | for skip in skip_list: 146 | if file.endswith(skip): 147 | break 148 | else: 149 | with open(file) as source_file: 150 | source_text = source_file.read() 151 | if not source_text.startswith(header): 152 | print("Wrong header in: {}".format(file)) 153 | 154 | 155 | if __name__ == "__main__": 156 | """ 157 | Execution part of script. 158 | """ 159 | 160 | check_license() 161 | -------------------------------------------------------------------------------- /scripts/compile_mac.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | # Get the path of the current script 27 | SCRIPT_DIR="$(dirname "$0")" 28 | 29 | # Remove an existing version 30 | BUILD_PATH=${SCRIPT_DIR}/../../output/mac/${L2A_BUILD_TYPE}/LaTeX2AI.aip 31 | rm -rf ${BUILD_PATH} 32 | 33 | # Build the version of LaTeX2AI 34 | xcodebuild -project ${SCRIPT_DIR}/../LaTeX2AI.xcodeproj -scheme "LaTeX2AI" -configuration "${L2A_BUILD_TYPE}" -destination "generic/platform=macOS" clean build 35 | 36 | # Move to the correct folder 37 | FINAL_PATH_DIR=${SCRIPT_DIR}/release_files/macOS 38 | mkdir -p ${FINAL_PATH_DIR} 39 | FINAL_PATH=${FINAL_PATH_DIR}/LaTeX2AI_${L2A_GIT_IDENTIFIER}_${L2A_BUILD_TYPE}.aip 40 | rm -rf ${FINAL_PATH} 41 | mv ${BUILD_PATH} ${FINAL_PATH} 42 | -------------------------------------------------------------------------------- /scripts/compile_solution.bat: -------------------------------------------------------------------------------- 1 | @REM ----------------------------------------------------------------------------- 2 | @REM MIT License 3 | @REM 4 | @REM Copyright (c) 2020-2025 Ivo Steinbrecher 5 | @REM 6 | @REM Permission is hereby granted, free of charge, to any person obtaining a copy 7 | @REM of this software and associated documentation files (the "Software"), to deal 8 | @REM in the Software without restriction, including without limitation the rights 9 | @REM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | @REM copies of the Software, and to permit persons to whom the Software is 11 | @REM furnished to do so, subject to the following conditions: 12 | @REM 13 | @REM The above copyright notice and this permission notice shall be included in 14 | @REM all copies or substantial portions of the Software. 15 | @REM 16 | @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | @REM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | @REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | @REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | @REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | @REM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | @REM SOFTWARE. 23 | @REM ----------------------------------------------------------------------------- 24 | 25 | @REM Load the Visual Studio developer command prompt 26 | call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" 27 | 28 | @REM Compile the LaTeX2AI solutions 29 | msbuild "..\LaTeX2AI.sln" /nologo /t:rebuild /p:Configuration=%L2A_build_type% /p:Platform=x64 30 | -------------------------------------------------------------------------------- /scripts/pipl/README.md: -------------------------------------------------------------------------------- 1 | # PIPL creation 2 | 3 | The files in this folder are directly taken from the Adobe SDK and adapted to work with `python3`. 4 | -------------------------------------------------------------------------------- /scripts/pipl/create_pipl.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 Adobe Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # FILENAME: create_pipl.py 6 | # 7 | # FUNCTION: create pipl file for given plugin pipl info. 8 | # 9 | # SYNTAX: python create_pipl.py -input '[{"name" : "plugin_name1", "entry_point" : "entry_point1"}, {"name" : "plugin_name2", "entry_point" : "entry_point2"}, ...] -output "pipl_name.pipl" 10 | # 11 | # PARAMETERS: N/A 12 | # 13 | # EXAMPLE: see Help for more detailed info 14 | # 15 | # AUTHOR : amisriva 16 | # 17 | ################################################################################## 18 | 19 | import sys 20 | import os 21 | import json 22 | import argparse 23 | 24 | from pipl_gen import pipl 25 | from pipl_gen import generate_multi_pipl_bin 26 | 27 | def parse_argument(): 28 | parser = argparse.ArgumentParser(description='Creates a PIPL file from given pipl info at given path') 29 | parser.add_argument('-input', help='Input json list of pipl dictionaries, with keys having name and entry_point', nargs = '?', default = [], dest = 'input_list') 30 | parser.add_argument('-output', help='file path of output pipl', dest = "output_file", nargs = 1) 31 | return parser.parse_args() 32 | 33 | def main(args): 34 | args = parse_argument() 35 | pipl_obj_list = [] 36 | if len(args.input_list): 37 | list_pipl = json.loads(args.input_list) 38 | for pipl_data in list_pipl: 39 | obj = pipl() 40 | if 'name' in pipl_data and len(pipl_data['name']): 41 | obj.add_plugin_name(str(pipl_data['name'])) 42 | if 'entry_point' in pipl_data and len(pipl_data['entry_point']): 43 | obj.add_plugin_entry(str(pipl_data['entry_point'])) 44 | if 'stsp' in pipl_data and pipl_data['stsp'] is True: 45 | obj.add_plugin_stsp(1) 46 | 47 | pipl_obj_list += [obj] 48 | else: 49 | obj = pipl() 50 | pipl_obj_list += [obj] 51 | generate_multi_pipl_bin(pipl_obj_list, "plugin.pipl") 52 | 53 | 54 | if __name__ == "__main__": 55 | main(sys.argv[1:]) 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /scripts/pipl/pipl_gen/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 Adobe Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # FILENAME: pipl_gen.py 6 | # 7 | # FUNCTION: pipl generator 8 | # 9 | # SYNTAX: N/A 10 | # 11 | # PARAMETERS: N/A 12 | # 13 | # EXAMPLE: N/A 14 | # 15 | # AUTHOR : amisriva 16 | # 17 | ################################################################################## 18 | from .pipl_gen import pipl 19 | from .pipl_gen import generate_multi_pipl_bin 20 | -------------------------------------------------------------------------------- /scripts/pipl/pipl_gen/template_plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind" : { 3 | "vendor": "ADBE", 4 | "value":"SPEA", 5 | "comment":"Only change vendor property, do not change value property" 6 | }, 7 | "ivrs" : { 8 | "vendor": "ADBE", 9 | "value": 2, 10 | "comment":"Only change vendor property, do not change value property" 11 | }, 12 | "mac" : { 13 | "mi32" : { 14 | "vendor": "ADBE", 15 | "value": "", 16 | "comment": "MacOnly, Change Vendor, set value to your plugin's entry point name, or pass name in API" 17 | } 18 | }, 19 | "win" : { 20 | "wx86" : { 21 | "vendor": "ADBE", 22 | "value": "", 23 | "comment": "WinOnly, Change Vendor, set value to your plugin's entry point name, or pass name in API" 24 | } 25 | }, 26 | "pinm" : { 27 | "vendor": "ADBE", 28 | "value":"Sample Plugin", 29 | "comment":"Change Vendor, change Sample Plugin to your plugin name, or pass name in API" 30 | }, 31 | "StsP" : { 32 | "vendor": "ADBE" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /scripts/release_zip_readme.md: -------------------------------------------------------------------------------- 1 | # LaTeX2AI 2 | 3 | For LaTeX2AI installation instructions have a look at https://github.com/isteinbrecher/latex2ai 4 | -------------------------------------------------------------------------------- /scripts/ui_signing/SET_KEY_EXAMPLE.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | export LATEX2AI_CERTIFICATE_PASSWORD="abcdefg1234" 27 | -------------------------------------------------------------------------------- /scripts/ui_signing/ZXPSignCmd-64bit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/scripts/ui_signing/ZXPSignCmd-64bit -------------------------------------------------------------------------------- /scripts/ui_signing/sign_ui_folder.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # ----------------------------------------------------------------------------- 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2025 Ivo Steinbrecher 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # ----------------------------------------------------------------------------- 25 | 26 | # Get the path of the current script 27 | SCRIPT_DIR="$(dirname "$0")" 28 | 29 | # Set the key for the certificate 30 | . ${SCRIPT_DIR}/SET_KEY.sh 31 | 32 | # Remove the packed zxp file if it exists 33 | ZXP_FILE=${SCRIPT_DIR}/latex2ai_ui.zxp 34 | rm -f $ZXP_FILE 35 | 36 | # Create the signed zxp file 37 | ${SCRIPT_DIR}/ZXPSignCmd-64bit -sign ${SCRIPT_DIR}/../../ui $ZXP_FILE ${SCRIPT_DIR}/latex2ai_certificate.p12 $LATEX2AI_CERTIFICATE_PASSWORD -tsa http://timestamp.digicert.com 38 | 39 | # Unzip to folder 40 | SIGNED_UI_FOLDER=${SCRIPT_DIR}/../release_files/com.isteinbrecher.latex2ai.${L2A_GIT_IDENTIFIER} 41 | rm -rf $SIGNED_UI_FOLDER 42 | mkdir $SIGNED_UI_FOLDER 43 | unzip $ZXP_FILE -d $SIGNED_UI_FOLDER 44 | rm -f $ZXP_FILE 45 | -------------------------------------------------------------------------------- /src/l2a_annotator.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Object that handles everython annotator related. 27 | */ 28 | 29 | 30 | #ifndef L2A_ANNOTATOR_H_ 31 | #define L2A_ANNOTATOR_H_ 32 | 33 | 34 | #include "l2a_suites.h" 35 | 36 | #include 37 | 38 | // Forward declaration. 39 | namespace L2A 40 | { 41 | class Item; 42 | } 43 | 44 | 45 | namespace L2A 46 | { 47 | class Annotator 48 | { 49 | public: 50 | /** Constructor. Create the annotator. 51 | */ 52 | Annotator(SPInterfaceMessage* message); 53 | 54 | /** Destructor. 55 | */ 56 | ~Annotator() {}; 57 | 58 | /** 59 | * \brief This method is called when the art selection changed. If the annotator is active, the items are 60 | * reloaded. 61 | */ 62 | void ArtSelectionChanged(); 63 | 64 | /** 65 | * \brief Return if the annotator is active or not. 66 | */ 67 | bool IsActive() const; 68 | 69 | /** 70 | * \brief Set the annotator including invalidating the annotator and reseting the item position tracker vector. 71 | */ 72 | void SetAnnotatorWithInvalidateBounds(bool active); 73 | 74 | /** 75 | * \brief Set the annotator active. 76 | */ 77 | void SetAnnotatorActive(); 78 | 79 | /** 80 | * \brief Set the annotator inactive. 81 | */ 82 | void SetAnnotatorInactive(); 83 | 84 | /** 85 | * \brief Check if any art items are underneath the cursor. 86 | */ 87 | bool CheckForArtHit(AIToolMessage* message); 88 | 89 | /** 90 | * \brief Return true if an item is hit. 91 | */ 92 | bool IsArtHit() const { return cursor_item_ != nullptr; } 93 | 94 | /** 95 | * \brief Return true hit item. 96 | */ 97 | AIArtHandle GetArtHit() const { return cursor_item_; } 98 | 99 | /** 100 | * \brief Draw the boundaries of the items. 101 | */ 102 | void Draw(AIAnnotatorMessage* message) const; 103 | 104 | /** 105 | * \brief Invalidate the annotation. 106 | */ 107 | void InvalAnnotation(const AIRealRect& artwork_bounds) const; 108 | 109 | /** 110 | * \brief Invalidate the entire document view bounds. 111 | */ 112 | void InvalAnnotation() const; 113 | 114 | private: 115 | /** 116 | * \brief Set the annotator inactive. 117 | */ 118 | void SetAnnotator(bool active); 119 | 120 | private: 121 | //! Handle for the annotator added by this plug-in. 122 | AIAnnotatorHandle annotator_handle_; 123 | 124 | //! Item the cursor is over. 125 | AIArtHandle cursor_item_; 126 | 127 | //! Vector of items. The items are stored in pairs, where the second pair entry are all positions of the 128 | //! bounding box. 129 | std::vector>> item_vector_; 130 | }; 131 | } // namespace L2A 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /src/l2a_constants.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Define constants for LaTeX2AI. 27 | */ 28 | 29 | 30 | #ifndef L2A_DEFINES_H_ 31 | #define L2A_DEFINES_H_ 32 | 33 | //! Include information regarding the curent git version. 34 | #include "auto_generated/version.h" 35 | 36 | //! Name of the plugin. 37 | #define L2A_PLUGIN_NAME "LaTeX2AI" 38 | 39 | //! Version of the plugin. 40 | #define L2A_VERSION_STRING_ "1.0.3" 41 | 42 | //! Icon IDs. 43 | #define TOOL_ICON_CREATE_DARK_ID 19000 // icon for create mode in dark mode 44 | #define TOOL_ICON_CREATE_LIGHT_ID 19001 // icon for create mode in light mode 45 | #define TOOL_ICON_REDO_DARK_ID 19002 // icon for redo mode in dark mode 46 | #define TOOL_ICON_REDO_LIGHT_ID 19003 // icon for redo mode in light mode 47 | #define TOOL_ICON_OPTIONS_DARK_ID 19004 // icon for options in dark mode 48 | #define TOOL_ICON_OPTIONS_LIGHT_ID 19005 // icon for options in light mode 49 | #define TOOL_ICON_SAVE_AS_PDF_DARK_ID 19006 // icon for save as pdf in dark mode 50 | #define TOOL_ICON_SAVE_AS_PDF_LIGHT_ID 19007 // icon for save as pdf in light mode 51 | #define TOOL_ICON_TESTING_DARK_ID 19008 // icon for testing in dark mode 52 | #define TOOL_ICON_TESTING_LIGHT_ID 19009 // icon for testing in light mode 53 | 54 | #define CURSOR_ICON_CREATE 19100 // cursor for create mode 55 | #define CURSOR_ICON_LOCKED 19101 // cursor for locked create mode 56 | #define CURSOR_ICON_EDIT 19102 // cursor for edit mode 57 | 58 | 59 | namespace L2A 60 | { 61 | namespace CONSTANTS 62 | { 63 | //! Tollerance for positions. 64 | static const AIReal eps_pos_ = (AIReal)0.002; 65 | 66 | //! Tollerance for angles. 67 | static const AIReal eps_angle_ = (AIReal)0.001; 68 | 69 | //! Tollerance for strech values. 70 | static const AIReal eps_strech_ = (AIReal)0.001; 71 | 72 | //! Radius of placement point for annotation. 73 | static const int radius_ = 7; 74 | 75 | //! Line width for annotation. 76 | static const int line_width_ = 5; 77 | 78 | //! Color for OK bounding box. 79 | static const AIRGBColor color_ok_ = {0, 65000, 0}; 80 | 81 | //! Color for scaled bounding box. 82 | static const AIRGBColor color_scaled_ = {0, 0, 65000}; 83 | 84 | //! Color for diamond bounding box. 85 | static const AIRGBColor color_diamond_ = {65000, 0, 0}; 86 | } // namespace CONSTANTS 87 | } // namespace L2A 88 | 89 | 90 | #endif // L2AID_H_ 91 | -------------------------------------------------------------------------------- /src/l2a_names.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Define constant names and function related to names for LaTeX2AI. 27 | */ 28 | 29 | 30 | #ifndef L2A_NAMES_H_ 31 | #define L2A_NAMES_H_ 32 | 33 | 34 | #include "l2a_string_functions.h" 35 | 36 | namespace L2A 37 | { 38 | namespace NAMES 39 | { 40 | //! Name of the directory where the L2A header and pdfs will be stored. 41 | static const char* pdf_file_directory_ = "links"; 42 | 43 | //! Name of header in the L2A directory. 44 | static const char* tex_header_name_ = "LaTeX2AI_header.tex"; 45 | 46 | //! Postfix to the document name for the pdf items. 47 | static const char* pdf_item_post_fix_ = "_LaTeX2AI_"; 48 | 49 | //! Name for the item in ai. 50 | static const char* ai_item_name_ = "LaTeX2AI"; 51 | 52 | //! Name for the tex file when creating a latex item. 53 | static const char* create_pdf_tex_name_base_ = "LaTeX2AI_item"; 54 | static const char* create_pdf_tex_name_ = 55 | "LaTeX2AI_item" 56 | ".tex"; 57 | 58 | /** 59 | * \brief Get the name of a pdf for an item of the current document. 60 | */ 61 | inline ai::UnicodeString GetPdfItemName(const ai::UnicodeString& document_name, const unsigned int i) 62 | { 63 | return document_name + L2A::NAMES::pdf_item_post_fix_ + L2A::UTIL::IntegerToString(i, 3) + ".pdf"; 64 | } 65 | } // namespace NAMES 66 | } // namespace L2A 67 | 68 | 69 | #endif // L2A_NAMES_H_ 70 | -------------------------------------------------------------------------------- /src/l2a_suites.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Define suites for LaTeX2AI. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "l2a_suites.h" 33 | 34 | 35 | extern "C" 36 | { 37 | AIToolSuite* sAITool = nullptr; 38 | AIUnicodeStringSuite* sAIUnicodeString = nullptr; 39 | AIPluginSuite* sAIPlugin = nullptr; 40 | SPBlocksSuite* sSPBlocks = nullptr; 41 | AIStringFormatUtilsSuite* sAIStringFormatUtils = nullptr; 42 | 43 | // Non default suites needed for L2A. 44 | AIDocumentSuite* sAIDocument = nullptr; 45 | AIDocumentListSuite* sAIDocumentList = nullptr; 46 | AIPlacedSuite* sAIPlaced = nullptr; 47 | AIArtSuite* sAIArt = nullptr; 48 | AIRealMathSuite* sAIRealMath = nullptr; 49 | AITransformArtSuite* sAITransformArt = nullptr; 50 | AIIsolationModeSuite* sAIIsolationMode = nullptr; 51 | AIMatchingArtSuite* sAIMatchingArt = nullptr; 52 | AIMdMemorySuite* sAIMdMemorySuite = nullptr; 53 | AIUndoSuite* sAIUndo = nullptr; 54 | AIAnnotatorSuite* sAIAnnotator = nullptr; 55 | AIAnnotatorDrawerSuite* sAIAnnotatorDrawer = nullptr; 56 | AIDocumentViewSuite* sAIDocumentView = nullptr; 57 | AIHitTestSuite* sAIHitTest = nullptr; 58 | AIActionManagerSuite* sAIActionManager = nullptr; 59 | AIPathSuite* sAIPath = nullptr; 60 | AIPathStyleSuite* sAIPathStyle = nullptr; 61 | AILayerSuite* sAILayer = nullptr; 62 | } 63 | 64 | ImportSuite gImportSuites[] = {kAIToolSuite, kAIToolVersion, &sAITool, kAIUnicodeStringSuite, kAIUnicodeStringVersion, 65 | &sAIUnicodeString, kAIPluginSuite, kAIPluginSuiteVersion, &sAIPlugin, kSPBlocksSuite, kSPBlocksSuiteVersion, 66 | &sSPBlocks, kAIStringFormatUtilsSuite, kAIStringFormatUtilsSuiteVersion, &sAIStringFormatUtils, 67 | 68 | // Non default suites needed for L2A. 69 | kAIDocumentSuite, kAIDocumentSuiteVersion, &sAIDocument, 70 | // 71 | kAIDocumentListSuite, kAIDocumentListSuiteVersion, &sAIDocumentList, 72 | // 73 | kAIPlacedSuite, kAIPlacedSuiteVersion, &sAIPlaced, 74 | // 75 | kAIArtSuite, kAIArtSuiteVersion, &sAIArt, 76 | // 77 | kAIRealMathSuite, kAIRealMathSuiteVersion, &sAIRealMath, 78 | // 79 | kAITransformArtSuite, kAITransformArtSuiteVersion, &sAITransformArt, 80 | // 81 | kAIIsolationModeSuite, kAIIsolationModeSuiteVersion, &sAIIsolationMode, kAIMatchingArtSuite, 82 | // 83 | kAIMatchingArtSuiteVersion, &sAIMatchingArt, 84 | // 85 | kAIMdMemorySuite, kAIMdMemorySuiteVersion, &sAIMdMemorySuite, 86 | // 87 | kAIUndoSuite, kAIUndoSuiteVersion, &sAIUndo, 88 | // 89 | kAIAnnotatorSuite, kAIAnnotatorSuiteVersion, &sAIAnnotator, 90 | // 91 | kAIAnnotatorDrawerSuite, kAIAnnotatorDrawerSuiteVersion, &sAIAnnotatorDrawer, 92 | // 93 | kAIDocumentViewSuite, kAIDocumentViewSuiteVersion, &sAIDocumentView, 94 | // 95 | kAIHitTestSuite, kAIHitTestSuiteVersion, &sAIHitTest, 96 | // 97 | kAIActionManagerSuite, kAIActionManagerSuiteVersion, &sAIActionManager, 98 | // 99 | kAIPathSuite, kAIPathSuiteVersion, &sAIPath, 100 | // 101 | kAIPathStyleSuite, kAIPathStyleSuiteVersion, &sAIPathStyle, 102 | // 103 | kAILayerSuite, kAILayerSuiteVersion, &sAILayer, 104 | 105 | nullptr, 0, nullptr}; 106 | -------------------------------------------------------------------------------- /src/l2a_suites.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Define suites for LaTeX2AI. 27 | */ 28 | 29 | 30 | #ifndef L2A_SUITES_H_ 31 | #define L2A_SUITES_H_ 32 | 33 | 34 | #include "IllustratorSDK.h" 35 | 36 | #include "AIAnnotator.h" 37 | #include "AIAnnotatorDrawer.h" 38 | #include "AIDocumentList.h" 39 | #include "AIIsolationMode.h" 40 | #include "AIStringFormatUtils.h" 41 | #include "AITransformArt.h" 42 | #include "Suites.hpp" 43 | 44 | extern "C" AIToolSuite* sAITool; 45 | extern "C" AIUnicodeStringSuite* sAIUnicodeString; 46 | extern "C" AIPluginSuite* sAIPlugin; 47 | extern "C" SPBlocksSuite* sSPBlocks; 48 | extern "C" AIStringFormatUtilsSuite* sAIStringFormatUtils; 49 | 50 | extern "C" AIDocumentSuite* sAIDocument; 51 | extern "C" AIDocumentListSuite* sAIDocumentList; 52 | extern "C" AIPlacedSuite* sAIPlaced; 53 | extern "C" AIArtSuite* sAIArt; 54 | extern "C" AIRealMathSuite* sAIRealMath; 55 | extern "C" AITransformArtSuite* sAITransformArt; 56 | extern "C" AIIsolationModeSuite* sAIIsolationMode; 57 | extern "C" AIMatchingArtSuite* sAIMatchingArt; 58 | extern "C" AIMdMemorySuite* sAIMdMemorySuite; 59 | extern "C" AIUndoSuite* sAIUndo; 60 | extern "C" AIAnnotatorSuite* sAIAnnotator; 61 | extern "C" AIAnnotatorDrawerSuite* sAIAnnotatorDrawer; 62 | extern "C" AIDocumentViewSuite* sAIDocumentView; 63 | extern "C" AIHitTestSuite* sAIHitTest; 64 | extern "C" AIActionManagerSuite* sAIActionManager; 65 | extern "C" AIPathSuite* sAIPath; 66 | extern "C" AIPathStyleSuite* sAIPathStyle; 67 | extern "C" AILayerSuite* sAILayer; 68 | 69 | #endif // L2A_SUITES_H_ 70 | -------------------------------------------------------------------------------- /src/l2a_ui_base.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | 26 | /** 27 | * \brief Base class for a UI form 28 | */ 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "l2a_ui_base.h" 33 | 34 | #include "l2a_ai_functions.h" 35 | #include "l2a_constants.h" 36 | #include "l2a_string_functions.h" 37 | 38 | 39 | /** 40 | * 41 | */ 42 | AIErr L2A::UI::FormBase::LoadForm() 43 | { 44 | PlugPlugErrorCode result = LoadExtension(); 45 | if (result != PlugPlugErrorCode_success) 46 | { 47 | ai::UnicodeString warning_string(""); 48 | warning_string += "Could not open the LaTeX2AI user interface!\n"; 49 | warning_string += "Please followed the installation instructions for the user interface stated on"; 50 | warning_string += "\"https://github.com/isteinbrecher/latex2ai\""; 51 | L2A::AI::WarningAlert(warning_string); 52 | } 53 | return kNoErr; 54 | } 55 | 56 | /** 57 | * 58 | */ 59 | AIErr L2A::UI::FormBase::CloseForm() 60 | { 61 | // Reset the state of the form 62 | ResetFormData(); 63 | 64 | // Send callback to close the form 65 | const auto event_close = event_name_base_ + ".close"; 66 | csxs::event::Event event = {event_close.c_str(), csxs::event::kEventScope_Application, "LaTeX2AI", NULL, ""}; 67 | csxs::event::EventErrorCode result = htmlPPLib.DispatchEvent(&event); 68 | if (result != csxs::event::kEventErrorCode_Success) 69 | { 70 | l2a_error(form_name_ + " form could not be closed"); 71 | } 72 | return kNoErr; 73 | } 74 | 75 | /** 76 | * 77 | */ 78 | void L2A::UI::FormBase::SetEventListeners(std::vector& event_listener_data) 79 | { 80 | if (event_listener_data.size() == 0) l2a_error("SetEventListeners requires at least one event listener"); 81 | event_listener_data_ = std::move(event_listener_data); 82 | } 83 | 84 | /** 85 | * 86 | */ 87 | csxs::event::EventErrorCode L2A::UI::FormBase::RegisterCSXSEventListeners() 88 | { 89 | csxs::event::EventErrorCode result = csxs::event::kEventErrorCode_Success; 90 | for (auto& event_data : event_listener_data_) 91 | { 92 | result = htmlPPLib.AddEventListener(event_data.event_id_.c_str(), event_data.event_listener_, this); 93 | 94 | if (result != csxs::event::kEventErrorCode_Success) 95 | { 96 | return result; 97 | } 98 | } 99 | return result; 100 | } 101 | 102 | /** 103 | * 104 | */ 105 | csxs::event::EventErrorCode L2A::UI::FormBase::RemoveEventListeners() 106 | { 107 | csxs::event::EventErrorCode result = csxs::event::kEventErrorCode_Success; 108 | for (auto& event_data : event_listener_data_) 109 | { 110 | result = htmlPPLib.RemoveEventListener(event_data.event_id_.c_str(), event_data.event_listener_, this); 111 | 112 | if (result != csxs::event::kEventErrorCode_Success) 113 | { 114 | return result; 115 | } 116 | } 117 | 118 | return result; 119 | } 120 | 121 | /** 122 | * 123 | */ 124 | void L2A::UI::FormBase::SendDataWrapper( 125 | const std::shared_ptr& form_data, const std::string& event_name) 126 | { 127 | // Create the combines data object 128 | L2A::UTIL::ParameterList full_form_data; 129 | full_form_data.SetSubList(ai::UnicodeString("form_data"), form_data); 130 | 131 | // Add git hash to check that the form and plugin application have the same version 132 | full_form_data.SetOption(ai::UnicodeString("git_hash"), ai::UnicodeString(L2A_VERSION_GIT_SHA_HEAD_)); 133 | 134 | // Get the string containing all data for the form and sent it 135 | std::string xml_string = L2A::UTIL::StringAiToStd(full_form_data.ToXMLString(ai::UnicodeString("full_data"))); 136 | csxs::event::Event event = { 137 | event_name.c_str(), csxs::event::kEventScope_Application, "LaTeX2AI", NULL, xml_string.c_str()}; 138 | csxs::event::EventErrorCode result = htmlPPLib.DispatchEvent(&event); 139 | if (result != csxs::event::kEventErrorCode_Success) 140 | { 141 | l2a_error("Data could not be sent to the " + form_name_ + " UI"); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/l2a_ui_debug.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Form for debugging LaTeX errors 27 | */ 28 | 29 | #ifndef L2A_UI_DEBUG_H_ 30 | #define L2A_UI_DEBUG_H_ 31 | 32 | #include "l2a_latex.h" 33 | #include "l2a_ui_base.h" 34 | 35 | namespace L2A::UI 36 | { 37 | /** 38 | * @brief Form for creating / editing an item 39 | */ 40 | class Debug : public FormBase 41 | { 42 | public: 43 | // Define names for this form 44 | static const std::string FORM_NAME; 45 | static const std::string FORM_ID; 46 | static const std::string EVENT_TYPE_BASE; 47 | static const std::string EVENT_TYPE_READY; 48 | static const std::string EVENT_TYPE_OK; 49 | static const std::string EVENT_TYPE_CANCEL; 50 | static const std::string EVENT_TYPE_OPEN_LOG; 51 | static const std::string EVENT_TYPE_CREATE_DEBUG; 52 | static const std::string EVENT_TYPE_UPDATE; 53 | 54 | /** 55 | * \brief Flags for the type of current latex creation 56 | */ 57 | enum class Action 58 | { 59 | none, 60 | create_item, 61 | edit_item, 62 | redo_items 63 | }; 64 | 65 | public: 66 | /** 67 | * @brief Constructor 68 | */ 69 | Debug(); 70 | 71 | /** 72 | * @brief Reset internal data of the form that is not relevant after it is closed 73 | */ 74 | void ResetFormData() override { action_ = Action::none; } 75 | 76 | /** 77 | * @brief Open the debug form 78 | * TODO: Check return type of this method and error handling 79 | */ 80 | void OpenDebugForm(const Action action, L2A::LATEX::LatexCreationResult& latex_creation_result); 81 | 82 | /** 83 | * @brief This function is called once the ui is loaded. We send the data to the ui here 84 | */ 85 | void CallbackFormReady(const csxs::event::Event* const eventParam); 86 | 87 | /** 88 | * @brief Callback when the redo latex code button is pressed 89 | */ 90 | void CallbackReeditLatexCode(const csxs::event::Event* const eventParam); 91 | 92 | /** 93 | * @brief Callback when the form is canceled 94 | */ 95 | void CallbackCancel(const csxs::event::Event* const eventParam); 96 | 97 | /** 98 | * @brief Callback for opening the log file 99 | */ 100 | void CallbackOpenLog(const csxs::event::Event* const eventParam); 101 | 102 | /** 103 | * @brief Callback for creating the debug folder 104 | */ 105 | void CallbackCreateDebugFolder(const csxs::event::Event* const eventParam); 106 | 107 | /** 108 | * \brief Send data to the form 109 | */ 110 | ASErr SendData() override; 111 | 112 | private: 113 | //! Flag for current latex creationß 114 | Action action_; 115 | 116 | //! Data from the LaTeX creation process 117 | L2A::LATEX::LatexCreationResult latex_creation_result_; 118 | }; 119 | } // namespace L2A::UI 120 | #endif 121 | -------------------------------------------------------------------------------- /src/l2a_ui_item.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Form for creating / editing an item 27 | */ 28 | 29 | #ifndef L2A_UI_ITEM_H_ 30 | #define L2A_UI_ITEM_H_ 31 | 32 | #include "l2a_item.h" 33 | #include "l2a_property.h" 34 | #include "l2a_ui_base.h" 35 | 36 | namespace L2A::UI 37 | { 38 | /** 39 | * @brief Form for creating / editing an item 40 | */ 41 | class Item : public FormBase 42 | { 43 | public: 44 | // Define names for this form 45 | static const std::string FORM_NAME; 46 | static const std::string FORM_ID; 47 | static const std::string EVENT_TYPE_BASE; 48 | static const std::string EVENT_TYPE_READY; 49 | static const std::string EVENT_TYPE_OK; 50 | static const std::string EVENT_TYPE_UPDATE; 51 | static const std::string EVENT_TYPE_SET_CLOSE_ON_FOCUS; 52 | 53 | public: 54 | /** 55 | * @brief Constructor 56 | */ 57 | Item(); 58 | 59 | /** 60 | * @brief Reset internal data of the form that is not relevant after it is closed 61 | */ 62 | void ResetFormData() override; 63 | 64 | /** 65 | * @brief Create a new item at the given cursor position 66 | * TODO: Check return type of this method and error handling 67 | */ 68 | void OpenCreateItemForm(const AIRealPoint& position); 69 | 70 | /** 71 | * @brief Edit an existing item 72 | * TODO: Check return type of this method and error handling 73 | */ 74 | void OpenEditItemForm(const AIArtHandle& art_handle); 75 | 76 | /** 77 | * @brief This function is called once the ui is loaded. We send the data to the ui here 78 | */ 79 | void CallbackFormReady(const csxs::event::Event* const eventParam); 80 | 81 | /** 82 | * @brief Callback when the form is not canceled 83 | */ 84 | void CallbackOk(const csxs::event::Event* const eventParam); 85 | 86 | /** 87 | * @brief Compile the data from the form to a new L2A item 88 | */ 89 | void CreateNewItem(const L2A::UTIL::ParameterList& item_data_from_form); 90 | 91 | /** 92 | * @brief Edit an existing L2A item 93 | */ 94 | void EditItem(const ai::UnicodeString& return_value, const L2A::UTIL::ParameterList& item_data_from_form); 95 | 96 | /** 97 | * \brief Send data to the form 98 | */ 99 | ASErr SendData() override; 100 | 101 | /** 102 | * \brief Set the flag that controlls the "focus" behavior of the form 103 | */ 104 | void SetCloseOnFocus(const bool value); 105 | 106 | /** 107 | * @brief Define what the current action of the form is 108 | */ 109 | enum class ActionType 110 | { 111 | none, 112 | create_item, 113 | edit_item 114 | }; 115 | 116 | /** 117 | * @brief Return the current action type 118 | */ 119 | ActionType GetActionType() const { return action_type_; } 120 | 121 | private: 122 | //! Current action type of the UI 123 | ActionType action_type_ = ActionType::none; 124 | 125 | //! Property of the last item change 126 | L2A::Property property_; 127 | 128 | //! Pointer to the item that is currently being edited 129 | std::unique_ptr change_item_; 130 | 131 | //! Position in the document where a new item shall be inserted 132 | AIRealPoint new_item_insertion_point_; 133 | }; 134 | } // namespace L2A::UI 135 | #endif 136 | -------------------------------------------------------------------------------- /src/l2a_ui_manager.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | 26 | /** 27 | * \brief Interact with the LaTeX2AI UI 28 | */ 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "l2a_ui_manager.h" 33 | 34 | 35 | /** 36 | * 37 | */ 38 | L2A::UI::Manager::Manager() 39 | { 40 | forms_[FormsEnum::item] = std::make_unique(); 41 | forms_[FormsEnum::redo] = std::make_unique(); 42 | forms_[FormsEnum::debug] = std::make_unique(); 43 | forms_[FormsEnum::options] = std::make_unique(); 44 | } 45 | 46 | /** 47 | * 48 | */ 49 | void L2A::UI::Manager::RegisterCSXSEventListeners() 50 | { 51 | for (auto& form : forms_) 52 | { 53 | auto error = csxs::event::EventErrorCode::kEventErrorCode_Success; 54 | error = form.second->RegisterCSXSEventListeners(); 55 | if (error != csxs::event::EventErrorCode::kEventErrorCode_Success) 56 | l2a_error("Error in RegisterCSXSEventListeners"); 57 | } 58 | } 59 | 60 | /** 61 | * 62 | */ 63 | void L2A::UI::Manager::RemoveEventListeners() 64 | { 65 | for (auto& form : forms_) 66 | { 67 | auto error = csxs::event::EventErrorCode::kEventErrorCode_Success; 68 | error = form.second->RemoveEventListeners(); 69 | if (error != csxs::event::EventErrorCode::kEventErrorCode_Success) l2a_error("Error in RemoveEventListeners"); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/l2a_ui_manager.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Interact with the LaTeX2AI UI 27 | */ 28 | 29 | #ifndef L2A_UI_MANAGER_H_ 30 | #define L2A_UI_MANAGER_H_ 31 | 32 | #include "l2a_ui_base.h" 33 | #include "l2a_ui_debug.h" 34 | #include "l2a_ui_item.h" 35 | #include "l2a_ui_options.h" 36 | #include "l2a_ui_redo.h" 37 | 38 | #include 39 | #include 40 | 41 | namespace L2A::UI 42 | { 43 | /** 44 | * @brief Flags for all forms in LaTeX2AI 45 | */ 46 | enum class FormsEnum 47 | { 48 | none, 49 | item, 50 | redo, 51 | debug, 52 | options 53 | }; 54 | 55 | /** 56 | * @brief Class that manages all forms in LaTeX2AI 57 | */ 58 | class Manager 59 | { 60 | public: 61 | /** 62 | * @brief Constructor 63 | */ 64 | Manager(); 65 | 66 | /** 67 | * @brief Register events of all forms 68 | */ 69 | void RegisterCSXSEventListeners(); 70 | 71 | /** 72 | * @brief Remove events of all forms 73 | */ 74 | void RemoveEventListeners(); 75 | 76 | /** 77 | * @brief Return reference to the item form 78 | */ 79 | Item& GetItemForm() 80 | { 81 | auto form = dynamic_cast(forms_[FormsEnum::item].get()); 82 | return *(form); 83 | } 84 | 85 | /** 86 | * @brief Return reference to the redo form 87 | */ 88 | Redo& GetRedoForm() 89 | { 90 | auto form = dynamic_cast(forms_[FormsEnum::redo].get()); 91 | return *(form); 92 | } 93 | 94 | /** 95 | * @brief Return reference to the debug form 96 | */ 97 | Debug& GetDebugForm() 98 | { 99 | auto form = dynamic_cast(forms_[FormsEnum::debug].get()); 100 | return *(form); 101 | } 102 | 103 | /** 104 | * @brief Return reference to the option form 105 | */ 106 | Options& GetOptionsForm() 107 | { 108 | auto form = dynamic_cast(forms_[FormsEnum::options].get()); 109 | return *(form); 110 | } 111 | 112 | private: 113 | //! Map containing all forms for LaTeX2AI 114 | std::map> forms_; 115 | }; 116 | } // namespace L2A::UI 117 | #endif 118 | -------------------------------------------------------------------------------- /src/l2a_ui_options.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Form for setting the LaTeX2AI options 27 | */ 28 | 29 | #ifndef L2A_UI_OPTIONS_H_ 30 | #define L2A_UI_OPTIONS_H_ 31 | 32 | #include "l2a_ui_base.h" 33 | 34 | namespace L2A::UI 35 | { 36 | /** 37 | * @brief Form for setting options 38 | */ 39 | class Options : public FormBase 40 | { 41 | public: 42 | // Define names for this form 43 | static const std::string FORM_NAME; 44 | static const std::string FORM_ID; 45 | static const std::string EVENT_TYPE_BASE; 46 | static const std::string EVENT_TYPE_READY; 47 | static const std::string EVENT_TYPE_SAVE; 48 | static const std::string EVENT_TYPE_UPDATE; 49 | static const std::string EVENT_TYPE_GET_DEFAULT_VALUES; 50 | static const std::string EVENT_TYPE_SELECT_GHOST_SCRIPT; 51 | static const std::string EVENT_TYPE_SELECT_LATEX_BIN; 52 | static const std::string EVENT_TYPE_OPEN_HEADER; 53 | static const std::string EVENT_TYPE_CREATE_DEFAULT_HEADER; 54 | 55 | public: 56 | /** 57 | * @brief Constructor 58 | */ 59 | Options(); 60 | 61 | /** 62 | * @brief Reset internal data of the form that is not relevant after it is closed 63 | */ 64 | void ResetFormData() override {}; 65 | 66 | /** 67 | * @brief Open the form to edit all items in a document 68 | */ 69 | void OpenOptionsForm(); 70 | 71 | /** 72 | * \brief Send the complete data to the form 73 | */ 74 | ASErr SendData(const std::shared_ptr& form_data); 75 | 76 | /** 77 | * @brief This function is called once the ui is loaded. We send the data to the ui here 78 | */ 79 | void CallbackFormReady(const csxs::event::Event* const eventParam); 80 | 81 | /** 82 | * @brief Callback when the form is not canceled 83 | */ 84 | void CallbackSave(const csxs::event::Event* const eventParam); 85 | 86 | /** 87 | * @brief Send the default values to the form 88 | */ 89 | void CallbackGetDefaultValues(const csxs::event::Event* const eventParam); 90 | 91 | /** 92 | * @brief Callback to select the ghost script executable 93 | */ 94 | void CallbackSelectGhostScript(const csxs::event::Event* const eventParam); 95 | 96 | /** 97 | * @brief Callback to select the latex binary directory 98 | */ 99 | void CallbackSelectLatex(const csxs::event::Event* const eventParam); 100 | 101 | /** 102 | * @brief Callback to open the header 103 | */ 104 | void CallbackOpenHeader(const csxs::event::Event* const eventParam); 105 | 106 | /** 107 | * @brief Callback to create the default header 108 | */ 109 | void CallbackCreateDefaultHeader(const csxs::event::Event* const eventParam); 110 | 111 | private: 112 | /** 113 | * @brief Convert callback data to parameter list 114 | */ 115 | std::shared_ptr CallbackDataToParameterList( 116 | const csxs::event::Event* const eventParam); 117 | 118 | /** 119 | * @brief Set the header data in the parameter list that will be sent to the form 120 | */ 121 | void SetHeaderData(const std::shared_ptr form_parameter_list); 122 | }; 123 | } // namespace L2A::UI 124 | #endif 125 | -------------------------------------------------------------------------------- /src/l2a_ui_redo.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Form for redoing all items 27 | */ 28 | 29 | #ifndef L2A_UI_REDO_H_ 30 | #define L2A_UI_REDO_H_ 31 | 32 | #include "l2a_item.h" 33 | #include "l2a_property.h" 34 | #include "l2a_ui_base.h" 35 | 36 | namespace L2A::UI 37 | { 38 | /** 39 | * @brief Form for redoing all items 40 | */ 41 | class Redo : public FormBase 42 | { 43 | public: 44 | // Define names for this form 45 | static const std::string FORM_NAME; 46 | static const std::string FORM_ID; 47 | static const std::string EVENT_TYPE_BASE; 48 | static const std::string EVENT_TYPE_READY; 49 | static const std::string EVENT_TYPE_OK; 50 | static const std::string EVENT_TYPE_UPDATE; 51 | 52 | public: 53 | /** 54 | * @brief Constructor 55 | */ 56 | Redo(); 57 | 58 | /** 59 | * @brief Reset internal data of the form that is not relevant after it is closed 60 | */ 61 | void ResetFormData() override; 62 | 63 | /** 64 | * @brief Open the form to edit all items in a document 65 | */ 66 | void OpenRedoForm(); 67 | 68 | /** 69 | * @brief This function is called once the ui is loaded. We send the data to the ui here 70 | */ 71 | void CallbackFormReady(const csxs::event::Event* const eventParam); 72 | 73 | /** 74 | * @brief Callback when the form is not canceled 75 | */ 76 | void CallbackOk(const csxs::event::Event* const eventParam); 77 | 78 | /** 79 | * \brief Send data to the form 80 | */ 81 | ASErr SendData() override; 82 | 83 | private: 84 | //! Vector with all LaTeX2AI items 85 | std::vector all_items_; 86 | 87 | //! Vector with all selected LaTeX2AI items 88 | std::vector selected_items_; 89 | }; 90 | } // namespace L2A::UI 91 | #endif 92 | -------------------------------------------------------------------------------- /src/tests/test_base64.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief File system functions testing. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "test_base64.h" 33 | 34 | #include "base64.h" 35 | #include "testing_utlity.h" 36 | 37 | #include "l2a_file_system.h" 38 | #include "l2a_string_functions.h" 39 | 40 | 41 | /** 42 | * 43 | */ 44 | void TestBase64Unit(L2A::TEST::UTIL::UnitTest& ut) 45 | { 46 | // Some examples taken from https://en.wikipedia.org/wiki/Base64 47 | 48 | std::vector char_vec = {107, -17, -15, 3, -1, -105, -5}; 49 | std::string char_str(char_vec.data(), char_vec.size()); 50 | 51 | std::vector text = {"Man", "Ma", "M", "light work.", "light work", "light wor", "light wo", "light w", 52 | L2A::TEST::UTIL::test_string_4_, char_str}; 53 | std::vector result = {"TWFu", "TWE", "TQ", "bGlnaHQgd29yay4", "bGlnaHQgd29yaw", "bGlnaHQgd29y", 54 | "bGlnaHQgd28", "bGlnaHQgdw", 55 | "SGllciBpc3QgZWluIGFuZGVyZXIgbGFuZ2VyIFRleHQgbWl0IFVtbGF1dGVuIMOkw7bDhMOWw5zDn0AhCnVuZCBuZXVlIFplaWxlbgoKCnRoZS" 56 | "BlbmQ8Pi8nJyIhCg", 57 | "a+/xA/+X+w"}; 58 | 59 | for (unsigned int i_value = 0; i_value < text.size(); i_value++) 60 | { 61 | std::string encoded = base64::encode(text[i_value].c_str(), text[i_value].length()); 62 | ut.CompareStr(ai::UnicodeString(encoded), ai::UnicodeString(result[i_value])); 63 | auto decoded_char = base64::decode(encoded); 64 | std::string decoded(decoded_char.data(), decoded_char.size()); 65 | ut.CompareStr(ai::UnicodeString(decoded), ai::UnicodeString(text[i_value])); 66 | } 67 | } 68 | 69 | /** 70 | * 71 | */ 72 | void TestBase64EnAndDecoding(L2A::TEST::UTIL::UnitTest& ut) 73 | { 74 | // Get the name of the temp directory and clear it. 75 | const auto temp_directory = L2A::UTIL::ClearTemporaryDirectory(); 76 | 77 | // Set name for the temp file to create. 78 | ai::FilePath temp_file = temp_directory; 79 | temp_file.AddComponent(ai::UnicodeString("l2a_test_base64.txt")); 80 | ai::FilePath temp_file_out = temp_directory; 81 | temp_file_out.AddComponent(ai::UnicodeString("l2a_test_base64_out.txt")); 82 | 83 | // If the file exists, delete it. 84 | L2A::UTIL::RemoveFile(temp_file, false); 85 | 86 | // Create the file with a text. 87 | const ai::UnicodeString test_text(L2A::TEST::UTIL::test_string_4_); 88 | L2A::UTIL::WriteFileUTF8(temp_file, test_text); 89 | 90 | // Load the file decoded in base64. 91 | std::string encoded_file = L2A::UTIL::encode_file_base64(temp_file); 92 | 93 | // Save the encoded string to file. 94 | L2A::UTIL::decode_file_base64(temp_file_out, L2A::UTIL::StringStdToAi(encoded_file)); 95 | 96 | // Load the created file. 97 | ai::UnicodeString text_from_file = L2A::UTIL::ReadFileUTF8(temp_file_out); 98 | 99 | // Compare values. 100 | ut.CompareStr(text_from_file, ai::UnicodeString(L2A::TEST::UTIL::test_string_4_)); 101 | } 102 | 103 | /** 104 | * 105 | */ 106 | void L2A::TEST::TestBase64(L2A::TEST::UTIL::UnitTest& ut) 107 | { 108 | // Set test name. 109 | ut.SetTestName(ai::UnicodeString("TestBase64")); 110 | 111 | TestBase64Unit(ut); 112 | TestBase64EnAndDecoding(ut); 113 | } 114 | -------------------------------------------------------------------------------- /src/tests/test_base64.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief File encoding to base 64. 27 | */ 28 | 29 | 30 | #ifndef TEST_BASE64_H_ 31 | #define TEST_BASE64_H_ 32 | 33 | 34 | // Forward declarations. 35 | namespace L2A 36 | { 37 | namespace TEST 38 | { 39 | namespace UTIL 40 | { 41 | class UnitTest; 42 | } 43 | } // namespace TEST 44 | } // namespace L2A 45 | 46 | 47 | namespace L2A 48 | { 49 | namespace TEST 50 | { 51 | /** 52 | * \brief Test the functionality of the base 64 encoding. 53 | */ 54 | void TestBase64(L2A::TEST::UTIL::UnitTest& ut); 55 | } // namespace TEST 56 | } // namespace L2A 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/tests/test_file_system.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief File system functions testing. 27 | */ 28 | 29 | 30 | #ifndef TEST_FILE_H_ 31 | #define TEST_FILE_H_ 32 | 33 | 34 | // Forward declarations. 35 | namespace L2A 36 | { 37 | namespace TEST 38 | { 39 | namespace UTIL 40 | { 41 | class UnitTest; 42 | } 43 | } // namespace TEST 44 | } // namespace L2A 45 | 46 | 47 | namespace L2A 48 | { 49 | namespace TEST 50 | { 51 | /** 52 | * \brief Test the functionality of the file system functions. 53 | */ 54 | void TestFileSystem(L2A::TEST::UTIL::UnitTest& ut); 55 | } // namespace TEST 56 | } // namespace L2A 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/tests/test_framework.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Functions to test the complete LaTeX2AI framework. 27 | */ 28 | 29 | 30 | #ifndef TEST_FRAMEWORK_H_ 31 | #define TEST_FRAMEWORK_H_ 32 | 33 | 34 | // Forward declarations. 35 | namespace L2A 36 | { 37 | namespace TEST 38 | { 39 | namespace UTIL 40 | { 41 | class UnitTest; 42 | } 43 | } // namespace TEST 44 | } // namespace L2A 45 | 46 | 47 | namespace L2A 48 | { 49 | namespace TEST 50 | { 51 | void TestFramework(L2A::TEST::UTIL::UnitTest& ut); 52 | 53 | namespace PRIVATE 54 | { 55 | void CheckItems(L2A::TEST::UTIL::UnitTest& ut); 56 | } 57 | } // namespace TEST 58 | } // namespace L2A 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/tests/test_latex.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief File system functions testing. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "test_latex.h" 33 | 34 | #include "testing_utlity.h" 35 | 36 | #include "l2a_file_system.h" 37 | #include "l2a_latex.h" 38 | 39 | 40 | /** 41 | * 42 | */ 43 | void TestLatexBase(L2A::TEST::UTIL::UnitTest& ut, const ai::FilePath& temp_directory) 44 | { 45 | ai::FilePath test_directory = temp_directory; 46 | test_directory.AddComponent(ai::UnicodeString("latex_test_") + L2A::TEST::UTIL::test_string_unicode()); 47 | L2A::UTIL::RemoveDirectoryAI(test_directory, false); 48 | L2A::UTIL::CreateDirectoryL2A(test_directory); 49 | 50 | ai::FilePath tex_file = test_directory; 51 | tex_file.AddComponent(ai::UnicodeString(L2A::TEST::UTIL::test_string_unicode() + "test.tex")); 52 | 53 | L2A::UTIL::WriteFileUTF8( 54 | tex_file, ai::UnicodeString( 55 | "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\begin{document}Test\\end{document}")); 56 | 57 | // Compile the latex file 58 | ai::FilePath pdf_file; 59 | const auto compile_ok = L2A::LATEX::CompileLatexDocument(tex_file, pdf_file); 60 | ut.CompareInt(compile_ok, 1); 61 | ut.CompareInt(L2A::UTIL::IsFile(pdf_file), 1); 62 | } 63 | 64 | /** 65 | * 66 | */ 67 | void L2A::TEST::TestLatex(L2A::TEST::UTIL::UnitTest& ut) 68 | { 69 | // Set test name. 70 | ut.SetTestName(ai::UnicodeString("TestLatex")); 71 | 72 | // Store the working, so we can reset it at the end 73 | const auto old_cwd = std::filesystem::current_path(); 74 | 75 | // Get the name of the temp directory and clear it. 76 | const auto temp_directory = L2A::UTIL::ClearTemporaryDirectory(); 77 | 78 | // Test that we can create a Latex document with a unicode path 79 | TestLatexBase(ut, temp_directory); 80 | 81 | L2A::UTIL::SetWorkingDirectory(L2A::UTIL::FilePathStdToAi(old_cwd)); 82 | } 83 | -------------------------------------------------------------------------------- /src/tests/test_latex.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief File encoding to base 64. 27 | */ 28 | 29 | 30 | #ifndef TEST_LATEX_H_ 31 | #define TEST_LATEX_H_ 32 | 33 | 34 | // Forward declarations. 35 | namespace L2A 36 | { 37 | namespace TEST 38 | { 39 | namespace UTIL 40 | { 41 | class UnitTest; 42 | } 43 | } // namespace TEST 44 | } // namespace L2A 45 | 46 | 47 | namespace L2A 48 | { 49 | namespace TEST 50 | { 51 | /** 52 | * \brief Test the functionality of the Latex module. 53 | */ 54 | void TestLatex(L2A::TEST::UTIL::UnitTest& ut); 55 | } // namespace TEST 56 | } // namespace L2A 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/tests/test_parameter_list.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Test the parameter list class. 27 | */ 28 | 29 | #ifndef TEST_UTIL_XML_H_ 30 | #define TEST_UTIL_XML_H_ 31 | 32 | 33 | // Forward declarations. 34 | namespace L2A 35 | { 36 | namespace TEST 37 | { 38 | namespace UTIL 39 | { 40 | class UnitTest; 41 | } 42 | } // namespace TEST 43 | } // namespace L2A 44 | 45 | 46 | namespace L2A 47 | { 48 | namespace TEST 49 | { 50 | /** 51 | * \brief Test the functionality of the parameter list class. 52 | */ 53 | void TestParameterList(L2A::TEST::UTIL::UnitTest& ut); 54 | } // namespace TEST 55 | } // namespace L2A 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/tests/test_string_functions.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Test the string functions. 27 | */ 28 | 29 | #ifndef TEST_UTIL_STRING_H_ 30 | #define TEST_UTIL_STRING_H_ 31 | 32 | 33 | // Forward declarations. 34 | namespace L2A 35 | { 36 | namespace TEST 37 | { 38 | namespace UTIL 39 | { 40 | class UnitTest; 41 | } 42 | } // namespace TEST 43 | } // namespace L2A 44 | 45 | 46 | namespace L2A 47 | { 48 | namespace TEST 49 | { 50 | /** 51 | * \brief Test the functionality of the string functions. 52 | */ 53 | void TestStringFunctions(L2A::TEST::UTIL::UnitTest& ut); 54 | } // namespace TEST 55 | } // namespace L2A 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/tests/test_utility.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Test utility functions. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "test_utlity.h" 33 | #include "testing_utlity.h" 34 | 35 | #include "l2a_ai_functions.h" 36 | #include "l2a_constants.h" 37 | #include "l2a_error.h" 38 | #include "l2a_version.h" 39 | 40 | 41 | /** 42 | * 43 | */ 44 | void TestErrorCodeConversion(L2A::TEST::UTIL::UnitTest& ut) 45 | { 46 | int code = 'SHRT'; 47 | ut.CompareStr(L2A::ERR::AIErrorCodeToString(code), ai::UnicodeString("SHRT")); 48 | code = 'ORD?'; 49 | ut.CompareStr(L2A::ERR::AIErrorCodeToString(code), ai::UnicodeString("ORD?")); 50 | code = '~VAT'; 51 | ut.CompareStr(L2A::ERR::AIErrorCodeToString(code), ai::UnicodeString("~VAT")); 52 | } 53 | 54 | /** 55 | * 56 | */ 57 | void L2A::TEST::TestUtilityFunctions(L2A::TEST::UTIL::UnitTest& ut) 58 | { 59 | // Set test name. 60 | ut.SetTestName(ai::UnicodeString("TestUtilityFunctions")); 61 | 62 | // Call the individual tests 63 | TestErrorCodeConversion(ut); 64 | } 65 | 66 | /** 67 | * 68 | */ 69 | void L2A::TEST::TestVersion(L2A::TEST::UTIL::UnitTest& ut) 70 | { 71 | // Set test name. 72 | ut.SetTestName(ai::UnicodeString("TestVersion")); 73 | 74 | try 75 | { 76 | const auto main_version = L2A::UTIL::ParseVersion(L2A_VERSION_STRING_); 77 | ut.CompareStr(ai::UnicodeString(main_version.str()), ai::UnicodeString(L2A_VERSION_STRING_)); 78 | 79 | const auto version_from_github = L2A::UTIL::ParseVersion("v0.0.5"); 80 | ut.CompareStr(ai::UnicodeString(version_from_github.str()), ai::UnicodeString("0.0.5")); 81 | ut.CompareInt(0, version_from_github.is_prerelease()); 82 | 83 | const auto version_pre_release_4 = L2A::UTIL::ParseVersion("v1.3.5-rc.4"); 84 | ut.CompareStr(ai::UnicodeString(version_pre_release_4.str()), ai::UnicodeString("1.3.5-rc.4")); 85 | ut.CompareInt(1, version_pre_release_4.is_prerelease()); 86 | 87 | const auto version_pre_release_5 = L2A::UTIL::ParseVersion("v1.3.5-rc.5"); 88 | ut.CompareStr(ai::UnicodeString(version_pre_release_5.str()), ai::UnicodeString("1.3.5-rc.5")); 89 | ut.CompareInt(1, version_pre_release_5.is_prerelease()); 90 | 91 | const auto version_pre_release_9 = L2A::UTIL::ParseVersion("v1.3.5-rc.9"); 92 | 93 | ut.CompareInt(1, version_pre_release_4 < version_pre_release_5); 94 | ut.CompareInt(0, version_pre_release_4 > version_pre_release_5); 95 | ut.CompareInt(0, version_pre_release_4 == version_pre_release_5); 96 | 97 | ut.CompareInt(1, version_pre_release_4 < version_pre_release_9); 98 | ut.CompareInt(0, version_pre_release_4 > version_pre_release_9); 99 | ut.CompareInt(0, version_pre_release_4 == version_pre_release_9); 100 | 101 | ut.CompareInt(1, version_pre_release_5 < version_pre_release_9); 102 | ut.CompareInt(0, version_pre_release_5 > version_pre_release_9); 103 | ut.CompareInt(0, version_pre_release_5 == version_pre_release_9); 104 | 105 | const auto version_alpha = L2A::UTIL::ParseVersion("v1.3.5-alpha"); 106 | ut.CompareStr(ai::UnicodeString(version_alpha.str()), ai::UnicodeString("1.3.5-alpha")); 107 | ut.CompareInt(1, version_alpha.is_prerelease()); 108 | 109 | const auto version_a = L2A::UTIL::ParseVersion("0.1.20"); 110 | const auto version_b = L2A::UTIL::ParseVersion("1.0.2"); 111 | const auto version_c = L2A::UTIL::ParseVersion("0.10.2"); 112 | const auto version_d = L2A::UTIL::ParseVersion("0.1.20"); 113 | ut.CompareInt(1, version_a < version_b); 114 | ut.CompareInt(1, version_a == version_d); 115 | ut.CompareInt(1, version_a <= version_d); 116 | ut.CompareInt(1, version_b > version_c); 117 | } 118 | catch (semver::semver_exception& exception) 119 | { 120 | L2A::AI::MessageAlert(ai::UnicodeString("Parsing error in version testing")); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/tests/test_utlity.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Test utility functions. 27 | */ 28 | 29 | #ifndef TEST_UTILITY_H_ 30 | #define TEST_UTILITY_H_ 31 | 32 | 33 | #include "IllustratorSDK.h" 34 | 35 | 36 | // Forward declarations. 37 | namespace L2A 38 | { 39 | namespace TEST 40 | { 41 | namespace UTIL 42 | { 43 | class UnitTest; 44 | } 45 | } // namespace TEST 46 | } // namespace L2A 47 | 48 | 49 | namespace L2A 50 | { 51 | namespace TEST 52 | { 53 | /** 54 | * \brief Test utility functions. 55 | */ 56 | void TestUtilityFunctions(L2A::TEST::UTIL::UnitTest& ut); 57 | 58 | /** 59 | * \brief Test utility functions. 60 | */ 61 | void TestVersion(L2A::TEST::UTIL::UnitTest& ut); 62 | } // namespace TEST 63 | } // namespace L2A 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/tests/testing.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Main function for testing. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "testing.h" 33 | 34 | #include "test_base64.h" 35 | #include "test_file_system.h" 36 | #include "test_framework.h" 37 | #include "test_latex.h" 38 | #include "test_parameter_list.h" 39 | #include "test_string_functions.h" 40 | #include "test_utlity.h" 41 | #include "testing_utlity.h" 42 | 43 | 44 | /** 45 | * 46 | */ 47 | void L2A::TEST::TestingMain(const bool print_status) 48 | { 49 | // Create the testing object. 50 | L2A::TEST::UTIL::UnitTest ut; 51 | 52 | // Call the individual testing functions. 53 | L2A::TEST::TestParameterList(ut); 54 | L2A::TEST::TestStringFunctions(ut); 55 | L2A::TEST::TestFileSystem(ut); 56 | L2A::TEST::TestUtilityFunctions(ut); 57 | L2A::TEST::TestVersion(ut); 58 | L2A::TEST::TestBase64(ut); 59 | L2A::TEST::TestLatex(ut); 60 | 61 | // Print the testing summary. For now this is deactivated. 62 | ut.PrintTestSummary(print_status); 63 | } 64 | 65 | /** 66 | * 67 | */ 68 | void L2A::TEST::TestFramework(const bool print_status) 69 | { 70 | // Create the testing object. 71 | L2A::TEST::UTIL::UnitTest ut; 72 | 73 | // Call the framework test. 74 | L2A::TEST::TestFramework(ut); 75 | 76 | // Print the testing summary. For now this is deactivated. 77 | ut.PrintTestSummary(print_status); 78 | } 79 | -------------------------------------------------------------------------------- /src/tests/testing.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Main function for testing. 27 | */ 28 | 29 | #ifndef TEST_MAIN_H_ 30 | #define TEST_MAIN_H_ 31 | 32 | 33 | namespace L2A 34 | { 35 | namespace TEST 36 | { 37 | /** 38 | * \brief This function will call all tests. 39 | */ 40 | void TestingMain(const bool print_status = true); 41 | 42 | /** 43 | * \brief Test the functionality of the complete LaTeX2AI toolbox. 44 | */ 45 | void TestFramework(const bool print_status = true); 46 | } // namespace TEST 47 | } // namespace L2A 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/utils/l2a_error.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Errors for l2a applications. 27 | */ 28 | 29 | 30 | #ifndef L2A_ERROR_H_ 31 | #define L2A_ERROR_H_ 32 | 33 | 34 | namespace L2A 35 | { 36 | namespace ERR 37 | { 38 | /** 39 | * \brief Base class for L2A Errors. 40 | */ 41 | class ExceptionBase : public exception 42 | { 43 | public: 44 | /** 45 | * \brief Constructor with error string and detailed information about the error. 46 | */ 47 | ExceptionBase() {}; 48 | }; 49 | 50 | /** 51 | * \brief Class for L2A Errors. 52 | */ 53 | class Exception : public ExceptionBase 54 | { 55 | public: 56 | /** 57 | * \brief Constructor with error string and detailed information about the error. 58 | */ 59 | Exception(const char* __file__, const int __line__, const char* __function__, 60 | const ai::UnicodeString& error_string, const bool display_error_message = true); 61 | }; 62 | 63 | /** 64 | * \brief Class for L2A Warnings. 65 | * 66 | * This class is intended for events that should be displayed to the user but are not considered as an error. 67 | */ 68 | class Warning : public ExceptionBase 69 | { 70 | public: 71 | /** 72 | * \brief Constructor with warning string. 73 | */ 74 | Warning(const ai::UnicodeString& warning_string) { sAIUser->MessageAlert(warning_string); }; 75 | }; 76 | 77 | /** 78 | * \brief Convert the Illustrator integer error to 4 characters. 79 | */ 80 | ai::UnicodeString AIErrorCodeToString(const int& err); 81 | 82 | /** 83 | * \brief Convert the Illustrator integer error to 4 characters. 84 | */ 85 | ai::UnicodeString AIErrorCodeToErrorString(const int& err); 86 | } // namespace ERR 87 | } // namespace L2A 88 | 89 | 90 | /** 91 | * \brief This macro throws an error and adds information where in the code the error happens. 92 | */ 93 | #define l2a_error(error_string) \ 94 | throw L2A::ERR::Exception(__FILE__, __LINE__, __FUNCTION__, ai::UnicodeString(error_string)) 95 | 96 | /** 97 | * \brief This macro throws an that only displays the error message in the debug mode. 98 | */ 99 | #if _DEBUG 100 | #define l2a_error_quiet(error_string) l2a_error(error_string) 101 | #else 102 | #define l2a_error_quiet(error_string) \ 103 | throw L2A::ERR::Exception(__FILE__, __LINE__, __FUNCTION__, ai::UnicodeString(error_string), false) 104 | #endif 105 | 106 | /** 107 | * \brief This macro checks the AI error code and throws an L2A error if something went wrong. 108 | */ 109 | #define l2a_check_ai_error(err) \ 110 | if (err) l2a_error(L2A::ERR::AIErrorCodeToErrorString(err)) 111 | 112 | /** 113 | * \brief Throw a warning. 114 | */ 115 | #define l2a_warning(warning) throw L2A::ERR::Warning(ai::UnicodeString(warning)); 116 | 117 | #endif // L2A_ERROR_H_ 118 | -------------------------------------------------------------------------------- /src/utils/l2a_execute.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Utility functions for executing system commands. 27 | */ 28 | 29 | #ifndef UTIL_EXECUTE_H_ 30 | #define UTIL_EXECUTE_H_ 31 | 32 | 33 | #include "IllustratorSDK.h" 34 | 35 | 36 | namespace L2A 37 | { 38 | namespace UTIL 39 | { 40 | /** 41 | * \brief Structure to return the results from a call to an external command 42 | */ 43 | struct CommandResult 44 | { 45 | //! The exit status returned by the command 46 | int exit_status_; 47 | 48 | //! The output string by the command 49 | ai::UnicodeString output_; 50 | }; 51 | 52 | /** 53 | * \brief Execute a command line. Return the exit code and the command output. 54 | */ 55 | CommandResult ExecuteCommandLine(const ai::UnicodeString& command); 56 | 57 | namespace INTERNAL 58 | { 59 | /** 60 | * \brief Execute system command and get stdout result. Do not throw errors in this function. 61 | * 62 | * Taken from https://github.com/RaymiiOrg/cpp-command-output 63 | * 64 | * If you want stderr, use shell redirection (2&>1). 65 | */ 66 | CommandResult ExecuteCommandLineStd(const ai::UnicodeString& command); 67 | 68 | /** 69 | * \brief Execute a command line. Return the exit code and the command output. Do not throw errors in this 70 | * function. 71 | * 72 | * This function can only be used on windows, as the ExecuteCommandLineStd function opens a console window 73 | * under Windows 74 | */ 75 | CommandResult ExecuteCommandLineWindowsNoConsole(const ai::UnicodeString& command); 76 | } // namespace INTERNAL 77 | 78 | /** 79 | * \brief Open a file on disk with the default application. 80 | */ 81 | void OpenFileWithDefaultApplication(const ai::FilePath& file_path); 82 | 83 | /** 84 | * \brief Open a folder in the GUI of the OS 85 | */ 86 | void OpenFolder(const ai::FilePath& folder_path); 87 | } // namespace UTIL 88 | } // namespace L2A 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/utils/l2a_math.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Utility math functions. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "l2a_math.h" 33 | 34 | 35 | /** 36 | * 37 | */ 38 | AIReal L2A::UTIL::MATH::GetNorm(const AIRealPoint& point) 39 | { 40 | return sqrt(pow(point.h, AIReal(2.0)) + pow(point.v, AIReal(2.0))); 41 | } 42 | 43 | /** 44 | * 45 | */ 46 | AIReal L2A::UTIL::MATH::GetDistance(const AIRealPoint& point_a, const AIRealPoint& point_b) 47 | { 48 | return GetNorm(point_a - point_b); 49 | } 50 | -------------------------------------------------------------------------------- /src/utils/l2a_math.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Utility math functions. 27 | */ 28 | 29 | #ifndef UTIL_MATH_ 30 | #define UTIL_MATH_ 31 | 32 | 33 | #include "IllustratorSDK.h" 34 | 35 | 36 | /** 37 | * \brief Overload operators for AIRealPoints. 38 | */ 39 | inline AIRealPoint operator-(const AIRealPoint& point) 40 | { 41 | AIRealPoint return_point; 42 | return_point.h = -point.h; 43 | return_point.v = -point.v; 44 | return return_point; 45 | } 46 | inline AIRealPoint operator+(const AIRealPoint& lhs, const AIRealPoint& rhs) 47 | { 48 | AIRealPoint return_point(lhs); 49 | return_point.h += rhs.h; 50 | return_point.v += rhs.v; 51 | return return_point; 52 | } 53 | inline AIRealPoint operator-(const AIRealPoint& lhs, const AIRealPoint& rhs) 54 | { 55 | AIRealPoint return_point(lhs); 56 | return_point.h -= rhs.h; 57 | return_point.v -= rhs.v; 58 | return return_point; 59 | } 60 | 61 | 62 | namespace L2A 63 | { 64 | namespace UTIL 65 | { 66 | namespace MATH 67 | { /** 68 | * \brief Calculate the norm of a vector. 69 | */ 70 | AIReal GetNorm(const AIRealPoint& point); 71 | 72 | /** 73 | * \brief Calculate the distance between two points. 74 | */ 75 | AIReal GetDistance(const AIRealPoint& point_a, const AIRealPoint& point_b); 76 | } // namespace MATH 77 | } // namespace UTIL 78 | } // namespace L2A 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/utils/l2a_utils.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Utility functions. 27 | */ 28 | 29 | #ifndef UTILS_H_ 30 | #define UTILS_H_ 31 | 32 | 33 | #include "l2a_error.h" 34 | 35 | 36 | namespace L2A 37 | { 38 | namespace UTIL 39 | { 40 | /** 41 | * \brief Convert a key that is in one array to a corresponding key in a second array. 42 | * @param key_array Array containing the keys. 43 | * @param value_array Array containing the values. 44 | * @param key Key that should be converted to a value. 45 | * 46 | * @tparam T Type of key. 47 | * @tparam V Type of value. 48 | * @tparam n Number of elements. 49 | */ 50 | template 51 | V KeyToValue(const std::array& key_array, const std::array& value_array, const T& key) 52 | { 53 | for (unsigned int i = 0; i < n; i++) 54 | if (key_array[i] == key) return value_array[i]; 55 | l2a_error("Key not found in key_array!"); 56 | } 57 | } // namespace UTIL 58 | } // namespace L2A 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/utils/l2a_version.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Functions to check the version of LaTeX2AI. 27 | */ 28 | 29 | 30 | #include "IllustratorSDK.h" 31 | 32 | #include "l2a_version.h" 33 | 34 | #include "json.hpp" 35 | 36 | #include "l2a_constants.h" 37 | #include "l2a_error.h" 38 | #include "l2a_execute.h" 39 | #include "l2a_file_system.h" 40 | #include "l2a_string_functions.h" 41 | 42 | 43 | /** 44 | * 45 | */ 46 | semver::version L2A::UTIL::ParseVersion(const std::string& version_string) 47 | { 48 | std::string string_to_parse = version_string; 49 | 50 | // The github versions have a prefix "v" -> remove this. 51 | if (version_string.at(0) == 'v') string_to_parse = string_to_parse.substr(1, string_to_parse.size() - 1); 52 | 53 | return semver::version::parse(string_to_parse); 54 | } 55 | 56 | /** 57 | * 58 | */ 59 | void L2A::UTIL::CheckGithubVersion() 60 | { 61 | try 62 | { 63 | // Get the packages in the GitHub repository. 64 | ai::UnicodeString command("curl -L -s https://api.github.com/repos/isteinbrecher/latex2ai/releases"); 65 | auto command_result = L2A::UTIL::ExecuteCommandLine(command); 66 | std::string curl_output = L2A::UTIL::StringAiToStd(command_result.output_); 67 | if (curl_output == "") return; 68 | 69 | // Convert the string to a json object. 70 | using json = nlohmann::json; 71 | auto github_releases = json::parse(curl_output); 72 | 73 | // Get the version tags. 74 | std::vector github_versions; 75 | for (auto& [key, value] : github_releases.items()) 76 | { 77 | if (value.contains("tag_name")) 78 | { 79 | const auto tag_version = L2A::UTIL::ParseVersion(value["tag_name"].get()); 80 | 81 | // Only add versions that are not pre release versions 82 | if (!tag_version.is_prerelease()) 83 | { 84 | github_versions.push_back(tag_version); 85 | } 86 | } 87 | } 88 | 89 | // If for some reasons no version could be found, return here. 90 | if (github_versions.size() == 0) l2a_error_quiet(ai::UnicodeString("Could not retrieve github versions.")); 91 | 92 | // Get the current version. 93 | auto& newest_version = *(std::max_element(std::begin(github_versions), std::end(github_versions))); 94 | const auto current_version = L2A::UTIL::ParseVersion(L2A_VERSION_STRING_); 95 | if (current_version < newest_version) 96 | { 97 | ai::UnicodeString message_string("The new LaTeX2AI version v"); 98 | message_string += newest_version.str(); 99 | message_string += 100 | " is available at GitHub (https://github.com/isteinbrecher/latex2ai/releases). The currently used " 101 | "version is v"; 102 | message_string += current_version.str() + "."; 103 | sAIUser->MessageAlert(message_string); 104 | } 105 | } 106 | catch (...) 107 | { 108 | #ifdef _DEBUG 109 | sAIUser->MessageAlert(ai::UnicodeString("Error in CheckGithubVersion")); 110 | #endif 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/utils/l2a_version.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // MIT License 3 | // 4 | // Copyright (c) 2020-2025 Ivo Steinbrecher 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ----------------------------------------------------------------------------- 24 | 25 | /** 26 | * \brief Functions to check the version of LaTeX2AI. 27 | */ 28 | 29 | #ifndef L2A_VERSION_ 30 | #define L2A_VERSION_ 31 | 32 | #include "IllustratorSDK.h" 33 | 34 | #include "semver.hpp" 35 | 36 | namespace L2A 37 | { 38 | namespace UTIL 39 | { 40 | /** 41 | * \brief Parse a string to a version object 42 | */ 43 | semver::version ParseVersion(const std::string& version_string); 44 | 45 | /** 46 | * \brief Check if the current version is up to date with the GitHub version. 47 | */ 48 | void CheckGithubVersion(); 49 | } // namespace UTIL 50 | } // namespace L2A 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /tex/LaTeX2AI_header.tex: -------------------------------------------------------------------------------- 1 | % ----------------------------------------------------------------------------- 2 | % MIT License 3 | % 4 | % Copyright (c) 2020-2025 Ivo Steinbrecher 5 | % 6 | % Permission is hereby granted, free of charge, to any person obtaining a copy 7 | % of this software and associated documentation files (the "Software"), to deal 8 | % in the Software without restriction, including without limitation the rights 9 | % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | % copies of the Software, and to permit persons to whom the Software is 11 | % furnished to do so, subject to the following conditions: 12 | % 13 | % The above copyright notice and this permission notice shall be included in 14 | % all copies or substantial portions of the Software. 15 | % 16 | % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | % SOFTWARE. 23 | % ----------------------------------------------------------------------------- 24 | 25 | % The document class `standalone` MAY NOT BE CHANGED! 26 | % With the `class` option, the `standalone` class can be based on anther document class 27 | % (the default base class for LaTeX2AI is `scrartcl`). 28 | \documentclass[class=scrartcl]{standalone} 29 | 30 | % Set the default font size 31 | \KOMAoptions{fontsize=11pt} 32 | 33 | % All LaTeX2AI items can be scaled using this variable. This variable HAS to be defined (default 1) 34 | \newcommand{\itemscalefactor}{1} 35 | 36 | % Add your needed packages/macros/includes here: 37 | \usepackage{amsmath} 38 | -------------------------------------------------------------------------------- /tex/LaTeX2AI_item.tex: -------------------------------------------------------------------------------- 1 | % ----------------------------------------------------------------------------- 2 | % MIT License 3 | % 4 | % Copyright (c) 2020-2025 Ivo Steinbrecher 5 | % 6 | % Permission is hereby granted, free of charge, to any person obtaining a copy 7 | % of this software and associated documentation files (the "Software"), to deal 8 | % in the Software without restriction, including without limitation the rights 9 | % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | % copies of the Software, and to permit persons to whom the Software is 11 | % furnished to do so, subject to the following conditions: 12 | % 13 | % The above copyright notice and this permission notice shall be included in 14 | % all copies or substantial portions of the Software. 15 | % 16 | % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | % SOFTWARE. 23 | % ----------------------------------------------------------------------------- 24 | 25 | % Placeholders {xxx} will be replaced in this file 26 | 27 | % include the LaTeX2AI header with resolved includes 28 | \input{{tex_header_name}} 29 | 30 | % Encoding options 31 | \usepackage[utf8]{inputenc} 32 | \usepackage[T1]{fontenc} 33 | 34 | % to create the line for baseline placement so Illustrator does not crop the pdf 35 | \usepackage{tikz} 36 | % deactivate externalization in case it is activated in the header 37 | \usetikzlibrary{external} 38 | \tikzexternaldisable 39 | 40 | % dimensions for tikzpicture 41 | \newlength\maxheight 42 | \newlength\diffheight 43 | 44 | % configuration for standalone package 45 | \standaloneconfig{border=1pt, multi} 46 | 47 | % standalone environment 48 | \newenvironment{lta}{\ignorespaces}{\ignorespacesafterend} 49 | \standaloneenv{lta} 50 | 51 | % environment for standard placement 52 | \newcommand{\LaTeXtoAI}[1]{% 53 | \begin{lta}% 54 | \scalebox{\itemscalefactor}{#1}% 55 | \end{lta}% 56 | } 57 | 58 | % environment for baseline placement 59 | \newbox\ltabox 60 | \newcommand{\LaTeXtoAIbase}[1]{ 61 | \begin{lta} 62 | \scalebox{\itemscalefactor}{% 63 | \setbox\ltabox\hbox{% 64 | #1% 65 | }% 66 | \begin{tikzpicture}[baseline={(current bounding box.center)}]% 67 | \pgfmathsetlength{\maxheight}{max(\ht\ltabox,\dp\ltabox)+1pt}; 68 | \pgfmathsetlength{\diffheight}{0.01pt}; 69 | \draw [line width=0.5\diffheight, opacity=0, draw=white](0,\maxheight-\diffheight) --(0,\maxheight);% 70 | \draw [line width=0.5\diffheight, opacity=0, draw=white](0,-\maxheight+\diffheight) --(0,-\maxheight);% 71 | \end{tikzpicture}% 72 | \unhbox\ltabox}% 73 | \end{lta}% 74 | } 75 | 76 | \begin{document} 77 | {latex_code} 78 | \end{document} 79 | -------------------------------------------------------------------------------- /ui/CSXS/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | ./html/index_item.html 26 | 27 | 28 | 29 | true 30 | 31 | 32 | ModalDialog 33 | 34 | 35 | 36 | 190 37 | 800 38 | 39 | 40 | 190 41 | 800 42 | 43 | 44 | 190 45 | 800 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | ./html/index_redo.html 56 | 57 | 58 | 59 | true 60 | 61 | 62 | ModalDialog 63 | 64 | 65 | 66 | 210 67 | 400 68 | 69 | 70 | 210 71 | 400 72 | 73 | 74 | 210 75 | 400 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | ./html/index_debug.html 86 | 87 | 88 | 89 | true 90 | 91 | 92 | ModalDialog 93 | 94 | 95 | 96 | 220 97 | 400 98 | 99 | 100 | 220 101 | 400 102 | 103 | 104 | 220 105 | 400 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | ./html/index_options.html 116 | 117 | 118 | 119 | true 120 | 121 | 122 | ModalDialog 123 | 124 | 125 | 126 | 625 127 | 400 128 | 129 | 130 | 625 131 | 400 132 | 133 | 134 | 625 135 | 400 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /ui/css/latex2ai.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 13px; 3 | font-family: sans-serif; 4 | user-select: none; 5 | } 6 | 7 | .allow_user_select { 8 | user-select: text; 9 | } 10 | 11 | .spread_over_width { 12 | display: flex; 13 | justify-content: space-between; /* This spreads the child elements to each end */ 14 | align-items: center; /* This vertically centers the items in the container */ 15 | } 16 | 17 | .button_third { 18 | width: 30%; 19 | } 20 | 21 | .label_almost_full_width { 22 | width: 90%; 23 | } 24 | 25 | .fake_label { 26 | /* Makes the input behave like a label */ 27 | pointer-events: none; 28 | border: none; 29 | background: transparent; 30 | } 31 | -------------------------------------------------------------------------------- /ui/html/index_debug.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

The compilation of the LaTeX code resulted in an error

14 |

15 |
16 |

17 | View the LaTeX log or create a debug folder to investigate the 18 | failed LaTeX code with an external IDE 19 |

20 | 21 | 26 |
27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ui/html/index_options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

LaTeX2AI information

16 |
17 | 18 | 19 |
20 |
21 |
22 | 23 | 24 |
25 |
26 |

Global LaTeX options

27 |
28 | 29 | 34 |
35 |
36 | 37 |
38 | 39 |
40 |
41 | 42 |
43 |
44 | 49 | 50 |
51 |
52 | 53 |
54 |
55 | 60 | 61 |
62 |
63 |
64 |

Item create / edit

65 |
67 | 73 | 74 | 79 | 80 |
81 |
82 |

Warnings

83 | 84 | 85 |
86 | 87 | 88 |
89 |

LaTeX2AI document information

90 | 91 |
92 |
93 | 94 | 95 |
96 |
97 |
98 | 104 | 110 | 116 |
117 | 118 | 119 | -------------------------------------------------------------------------------- /ui/html/index_redo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Action

16 | 17 | 18 |
19 | 26 | 27 |

Items

28 | 29 | 30 |
31 | 32 | 33 |
34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ui/html/item_placement_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/ui/html/item_placement_dark.png -------------------------------------------------------------------------------- /ui/html/item_placement_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isteinbrecher/LaTeX2AI/57794702274dd356ba36dbfc5114cd2bded71099/ui/html/item_placement_light.png -------------------------------------------------------------------------------- /ui/js/common.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Update the theme with the AppSkinInfo retrieved from the host product. 3 | */ 4 | function updateThemeWithAppSkinInfo(appSkinInfo) { 5 | //Update the background color of the panel 6 | var panelBackgroundColor = appSkinInfo.panelBackgroundColor.color 7 | document.body.bgColor = toHex(panelBackgroundColor) 8 | 9 | var styleId = "hostStyle" 10 | addRule(styleId, "body", "color:" + reverseColor(panelBackgroundColor)) 11 | } 12 | 13 | function addRule(stylesheetId, selector, rule) { 14 | var stylesheet = document.getElementById(stylesheetId) 15 | 16 | if (stylesheet) { 17 | stylesheet = stylesheet.sheet 18 | if (stylesheet.addRule) { 19 | stylesheet.addRule(selector, rule) 20 | } else if (stylesheet.insertRule) { 21 | stylesheet.insertRule( 22 | selector + " { " + rule + " }", 23 | stylesheet.cssRules.length 24 | ) 25 | } 26 | } 27 | } 28 | 29 | function reverseColor(color, delta) { 30 | return toHex( 31 | { 32 | red: Math.abs(255 - color.red), 33 | green: Math.abs(255 - color.green), 34 | blue: Math.abs(255 - color.blue), 35 | }, 36 | delta 37 | ) 38 | } 39 | 40 | /** 41 | * Convert the Color object to string in hexadecimal format; 42 | */ 43 | function toHex(color, delta) { 44 | function computeValue(value, delta) { 45 | var computedValue = !isNaN(delta) ? value + delta : value 46 | if (computedValue < 0) { 47 | computedValue = 0 48 | } else if (computedValue > 255) { 49 | computedValue = 255 50 | } 51 | 52 | computedValue = computedValue.toString(16) 53 | return computedValue.length == 1 ? "0" + computedValue : computedValue 54 | } 55 | 56 | var hex = "" 57 | if (color) { 58 | with (color) { 59 | hex = 60 | computeValue(red, delta) + 61 | computeValue(green, delta) + 62 | computeValue(blue, delta) 63 | } 64 | } 65 | return "#" + hex 66 | } 67 | 68 | function onAppThemeColorChanged(event) { 69 | // Should get a latest HostEnvironment object from application. 70 | var skinInfo = JSON.parse( 71 | window.__adobe_cep__.getHostEnvironment() 72 | ).appSkinInfo 73 | // Gets the style information such as color info from the skinInfo, 74 | // and redraw all UI controls of your extension according to the style info. 75 | updateThemeWithAppSkinInfo(skinInfo) 76 | } 77 | 78 | function evalScript(script, callback) { 79 | new CSInterface().evalScript(script, callback) 80 | } 81 | 82 | function check_git_hash(xml) { 83 | // Check that the git hash of the main plugin and the extension are the same 84 | const plugin_hash = xml.find("full_data").attr("git_hash") 85 | const ui_hash = get_git_sha() 86 | if (plugin_hash != ui_hash) { 87 | alert( 88 | "The git hashes of the LaTeX2AI plugin and the UI do not match! " + 89 | "Did you forget to update one of them?" + 90 | "\nThe plugin hash is: " + 91 | plugin_hash.slice(0, 8) + 92 | "\nThe UI hash is: " + 93 | ui_hash.slice(0, 8) 94 | ) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /ui/js/main_debug.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | var csInterface = new CSInterface() 3 | 4 | // Set the current skin colors 5 | updateThemeWithAppSkinInfo(csInterface.hostEnvironment.appSkinInfo) 6 | 7 | // Update the color of the panel when the theme color of the product changed 8 | csInterface.addEventListener( 9 | CSInterface.THEME_COLOR_CHANGED_EVENT, 10 | onAppThemeColorChanged 11 | ) 12 | 13 | // Add all the event listeners we need 14 | csInterface.addEventListener( 15 | "com.adobe.csxs.events.latex2ai.debug.update", 16 | update_create_form 17 | ) 18 | csInterface.addEventListener( 19 | "com.adobe.csxs.events.latex2ai.debug.close", 20 | csInterface.closeExtension 21 | ) 22 | 23 | // Set the functions for the possible actions on the form 24 | $("#button_ok").click(function (event) { 25 | event.preventDefault() 26 | var event = new CSEvent( 27 | "com.adobe.csxs.events.latex2ai.debug.ok", 28 | "APPLICATION", 29 | "ILST", 30 | "LaTeX2AIUI" 31 | ) 32 | event.data = "" 33 | csInterface.dispatchEvent(event) 34 | }) 35 | 36 | $("#button_open_log").click(function (event) { 37 | event.preventDefault() 38 | var event = new CSEvent( 39 | "com.adobe.csxs.events.latex2ai.debug.open_log", 40 | "APPLICATION", 41 | "ILST", 42 | "LaTeX2AIUI" 43 | ) 44 | event.data = "" 45 | csInterface.dispatchEvent(event) 46 | }) 47 | 48 | $("#button_create_debug").click(function (event) { 49 | event.preventDefault() 50 | var event = new CSEvent( 51 | "com.adobe.csxs.events.latex2ai.debug.create_debug", 52 | "APPLICATION", 53 | "ILST", 54 | "LaTeX2AIUI" 55 | ) 56 | event.data = "" 57 | csInterface.dispatchEvent(event) 58 | }) 59 | 60 | $("#button_cancel").click(function (event) { 61 | event.preventDefault() 62 | var event = new CSEvent( 63 | "com.adobe.csxs.events.latex2ai.debug.cancel", 64 | "APPLICATION", 65 | "ILST", 66 | "LaTeX2AIUI" 67 | ) 68 | event.data = "" 69 | csInterface.dispatchEvent(event) 70 | }) 71 | document.addEventListener("keydown", (event) => { 72 | // Somehow, when "Esc" is pressed we get an empty string as return value from event.key (instead of the expected "Escape"). 73 | // The variable event.code is also empty, but it seems like this one is only empty for escape (space also produces an 74 | // empty event.key but NOT an empty event.code). 75 | if (event.code === "") { 76 | event.preventDefault() 77 | var event = new CSEvent( 78 | "com.adobe.csxs.events.latex2ai.debug.ok", 79 | "APPLICATION", 80 | "ILST", 81 | "LaTeX2AIUI" 82 | ) 83 | event.data = "" 84 | csInterface.dispatchEvent(event) 85 | } 86 | }) 87 | 88 | // let the native plug-in part of this sample know that we are ready to receive events now. 89 | var panelReadyEvent = new CSEvent( 90 | "com.adobe.csxs.events.latex2ai.debug.ready", 91 | "APPLICATION", 92 | "ILST", 93 | "LaTeX2AIUI" 94 | ) 95 | csInterface.dispatchEvent(panelReadyEvent) 96 | }) 97 | 98 | function update_create_form(event) { 99 | var xmlData = $.parseXML(event.data) 100 | var $xml = $(xmlData) 101 | 102 | check_git_hash($xml) 103 | 104 | var l2a_xml = $xml.find("form_data") 105 | 106 | action = l2a_xml.attr("action") 107 | if (action == "redo_items") { 108 | $("#button_ok").prop("disabled", true) 109 | $("#extra_text").prop( 110 | "innerHTML", 111 | "The error occurred while recompiling items that were not changed.\nThis usually happens when something in the header changes or the document is compiled on a different system than before." 112 | ) 113 | } else if (action == "item_create") { 114 | $("#button_cancel").val("Cancel item creation") 115 | } else if (action == "item_edit") { 116 | $("#button_cancel").val("Cancel item edit") 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /ui/js/main_redo.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | var csInterface = new CSInterface() 3 | 4 | // Set the current skin colors 5 | updateThemeWithAppSkinInfo(csInterface.hostEnvironment.appSkinInfo) 6 | 7 | // Update the color of the panel when the theme color of the product changed 8 | csInterface.addEventListener( 9 | CSInterface.THEME_COLOR_CHANGED_EVENT, 10 | onAppThemeColorChanged 11 | ) 12 | 13 | // Add all the event listeners we need 14 | csInterface.addEventListener( 15 | "com.adobe.csxs.events.latex2ai.redo.update", 16 | update_form 17 | ) 18 | csInterface.addEventListener( 19 | "com.adobe.csxs.events.latex2ai.redo.close", 20 | csInterface.closeExtension 21 | ) 22 | 23 | // Set the functions for the possible actions on the form 24 | $("#button_ok").click(function (event) { 25 | event.preventDefault() 26 | var event = new CSEvent( 27 | "com.adobe.csxs.events.latex2ai.redo.ok", 28 | "APPLICATION", 29 | "ILST", 30 | "LaTeX2AIUI" 31 | ) 32 | event.data = get_form_return_xml_string("ok", true) 33 | csInterface.dispatchEvent(event) 34 | }) 35 | $("#button_cancel").click(function (event) { 36 | event.preventDefault() 37 | // No callback needed here 38 | csInterface.closeExtension() 39 | }) 40 | 41 | // let the native plug-in part of this sample know that we are ready to receive events now.. 42 | var panelReadyEvent = new CSEvent( 43 | "com.adobe.csxs.events.latex2ai.redo.ready", 44 | "APPLICATION", 45 | "ILST", 46 | "LaTeX2AIUI" 47 | ) 48 | csInterface.dispatchEvent(panelReadyEvent) 49 | }) 50 | 51 | function get_form_return_xml_string(return_value, add_item_data) { 52 | var root_xml_document = $.parseXML("") 53 | if (return_value != null) { 54 | root_xml_document.documentElement.setAttribute( 55 | "return_value", 56 | return_value 57 | ) 58 | } 59 | if (add_item_data) { 60 | root_xml_document.documentElement.appendChild( 61 | form_content_to_xml().documentElement 62 | ) 63 | } 64 | return new XMLSerializer().serializeToString(root_xml_document) 65 | } 66 | 67 | function form_content_to_xml() { 68 | // Convert the item contents to an xml object that can be send back to the main plugin 69 | var xml_document = $.parseXML("") 70 | 71 | // Set the action type 72 | xml_document.documentElement.setAttribute( 73 | "action_type", 74 | $("input[name='action']:checked").val() 75 | ) 76 | 77 | // Set the action type 78 | xml_document.documentElement.setAttribute( 79 | "items", 80 | $("input[name='items']:checked").val() 81 | ) 82 | 83 | // Return the created xml document 84 | return xml_document 85 | } 86 | 87 | function update_form(event) { 88 | var xmlData = $.parseXML(event.data) 89 | var $xml = $(xmlData) 90 | 91 | check_git_hash($xml) 92 | 93 | var redo_xml = $xml.find("form_data") 94 | $("#items_all_label").prop( 95 | "innerHTML", 96 | "All Items (" + redo_xml.attr("n_all_items") + ")" 97 | ) 98 | $("#items_selected_label").prop( 99 | "innerHTML", 100 | "Selected Items (" + redo_xml.attr("n_selected_items") + ")" 101 | ) 102 | } 103 | --------------------------------------------------------------------------------