├── .gitattributes ├── .github └── workflows │ ├── macos.yml │ └── windows.yml ├── .gitignore ├── LICENSE ├── Libraries ├── LibXlsxRW │ ├── LibXlsxRW.cpp │ ├── LibXlsxRW.h │ ├── LibXlsxRW.pro │ ├── libxlsxrw_global.h │ └── xlsx │ │ ├── qtxlsx.pri │ │ ├── xlsxabstractooxmlfile.cpp │ │ ├── xlsxabstractooxmlfile.h │ │ ├── xlsxabstractooxmlfile_p.h │ │ ├── xlsxabstractsheet.cpp │ │ ├── xlsxabstractsheet.h │ │ ├── xlsxabstractsheet_p.h │ │ ├── xlsxcell.cpp │ │ ├── xlsxcell.h │ │ ├── xlsxcell_p.h │ │ ├── xlsxcellformula.cpp │ │ ├── xlsxcellformula.h │ │ ├── xlsxcellformula_p.h │ │ ├── xlsxcellrange.cpp │ │ ├── xlsxcellrange.h │ │ ├── xlsxcellreference.cpp │ │ ├── xlsxcellreference.h │ │ ├── xlsxchart.cpp │ │ ├── xlsxchart.h │ │ ├── xlsxchart_p.h │ │ ├── xlsxchartsheet.cpp │ │ ├── xlsxchartsheet.h │ │ ├── xlsxchartsheet_p.h │ │ ├── xlsxcolor.cpp │ │ ├── xlsxcolor_p.h │ │ ├── xlsxconditionalformatting.cpp │ │ ├── xlsxconditionalformatting.h │ │ ├── xlsxconditionalformatting_p.h │ │ ├── xlsxcontenttypes.cpp │ │ ├── xlsxcontenttypes_p.h │ │ ├── xlsxdatavalidation.cpp │ │ ├── xlsxdatavalidation.h │ │ ├── xlsxdatavalidation_p.h │ │ ├── xlsxdocpropsapp.cpp │ │ ├── xlsxdocpropsapp_p.h │ │ ├── xlsxdocpropscore.cpp │ │ ├── xlsxdocpropscore_p.h │ │ ├── xlsxdocument.cpp │ │ ├── xlsxdocument.h │ │ ├── xlsxdocument_p.h │ │ ├── xlsxdrawing.cpp │ │ ├── xlsxdrawing_p.h │ │ ├── xlsxdrawinganchor.cpp │ │ ├── xlsxdrawinganchor_p.h │ │ ├── xlsxformat.cpp │ │ ├── xlsxformat.h │ │ ├── xlsxformat_p.h │ │ ├── xlsxglobal.h │ │ ├── xlsxmediafile.cpp │ │ ├── xlsxmediafile_p.h │ │ ├── xlsxnumformatparser.cpp │ │ ├── xlsxnumformatparser_p.h │ │ ├── xlsxrelationships.cpp │ │ ├── xlsxrelationships_p.h │ │ ├── xlsxrichstring.cpp │ │ ├── xlsxrichstring.h │ │ ├── xlsxrichstring_p.h │ │ ├── xlsxsharedstrings.cpp │ │ ├── xlsxsharedstrings_p.h │ │ ├── xlsxsimpleooxmlfile.cpp │ │ ├── xlsxsimpleooxmlfile_p.h │ │ ├── xlsxstyles.cpp │ │ ├── xlsxstyles_p.h │ │ ├── xlsxtheme.cpp │ │ ├── xlsxtheme_p.h │ │ ├── xlsxutility.cpp │ │ ├── xlsxutility_p.h │ │ ├── xlsxworkbook.cpp │ │ ├── xlsxworkbook.h │ │ ├── xlsxworkbook_p.h │ │ ├── xlsxworksheet.cpp │ │ ├── xlsxworksheet.h │ │ ├── xlsxworksheet_p.h │ │ ├── xlsxzipreader.cpp │ │ ├── xlsxzipreader_p.h │ │ ├── xlsxzipwriter.cpp │ │ └── xlsxzipwriter_p.h └── Libraries.pro ├── MainApps ├── MainApps.pro └── TSFileEditor │ ├── DataModel │ ├── TranslateModel.cpp │ └── TranslateModel.h │ ├── ExcelRW.cpp │ ├── ExcelRW.h │ ├── MainWindow.cpp │ ├── MainWindow.h │ ├── MainWindow.ui │ ├── NetWorker.cpp │ ├── NetWorker.h │ ├── TSFileEditor.pro │ ├── TranslateWorker.cpp │ ├── TranslateWorker.h │ ├── XmlRW.cpp │ ├── XmlRW.h │ └── main.cpp ├── Path.pri ├── README.md ├── TSFileEditor.pro ├── config └── config.ini ├── picture ├── code.png ├── excel.png ├── gen_excel.gif ├── translate.gif ├── translate.png └── youdao.png ├── run_tools_for_ubuntu.sh └── ssl ├── libcrypto-1_1.dll └── libssl-1_1.dll /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: MacOS 2 | on: 3 | push: 4 | paths-ignore: 5 | - 'README.md' 6 | - 'LICENSE' 7 | pull_request: 8 | paths-ignore: 9 | - 'README.md' 10 | - 'LICENSE' 11 | jobs: 12 | build: 13 | name: Build 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | os: [macos-latest] 18 | qt_ver: [5.12.6] 19 | qt_arch: [clang_64] 20 | env: 21 | targetName: TSFileEditor 22 | steps: 23 | - name: cacheQt 24 | id: MacosCacheQt 25 | uses: actions/cache@v1 26 | with: 27 | path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} 28 | key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} 29 | - name: setupQt 30 | if: steps.MacosCacheQt.outputs.cache-hit == 'true' 31 | shell: pwsh 32 | env: 33 | QtPath: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} 34 | run: | 35 | $qt_Path=${env:QtPath} 36 | echo "::set-env name=Qt5_Dir::$qt_Path" 37 | echo "::add-path::$qt_Path/bin" 38 | - name: Install Qt 39 | if: steps.MacosCacheQt.outputs.cache-hit != 'true' 40 | uses: jurplel/install-qt-action@v2.0.0 41 | with: 42 | version: ${{ matrix.qt_ver }} 43 | 44 | - uses: actions/checkout@v1 45 | with: 46 | fetch-depth: 1 47 | - name: build macos 48 | run: | 49 | qmake 50 | make 51 | # tag 打包 52 | - name: package 53 | if: startsWith(github.event.ref, 'refs/tags/') 54 | run: | 55 | # 拷贝依赖 56 | macdeployqt bin/${targetName}.app -qmldir=. -verbose=1 -dmg 57 | # tag 查询github-Release 58 | - name: queryRelease 59 | id: queryReleaseMacos 60 | if: startsWith(github.event.ref, 'refs/tags/') 61 | shell: pwsh 62 | env: 63 | githubFullName: ${{ github.event.repository.full_name }} 64 | ref: ${{ github.event.ref }} 65 | run: | 66 | [string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1) 67 | [string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag} 68 | $response={} 69 | try { 70 | $response = Invoke-RestMethod -Uri $url -Method Get 71 | } catch { 72 | Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 73 | Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription 74 | # 没查到,输出 75 | echo "::set-output name=needCreateRelease::true" 76 | return 77 | } 78 | [string]$latestUpUrl = $response.upload_url 79 | Write-Host 'latestUpUrl:'$latestUpUrl 80 | if ($latestUpUrl.Length -eq 0) { 81 | # 没查到,输出 82 | echo "::set-output name=needCreateRelease::true" 83 | } 84 | # tag 创建github-Release 85 | - name: createReleaseWin 86 | id: createReleaseWin 87 | if: startsWith(github.event.ref, 'refs/tags/') && steps.queryReleaseMacos.outputs.needCreateRelease == 'true' 88 | env: 89 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 90 | uses: actions/create-release@v1.0.0 91 | with: 92 | tag_name: ${{ github.ref }} 93 | release_name: Release ${{ github.ref }} 94 | body: ${{ github.event.head_commit.message }} 95 | draft: false 96 | prerelease: false 97 | # 重定向upload_url到环境变量uploadUrl。 98 | - name: getLatestTagRelease 99 | # tag 上一步无论成功还是失败都执行 100 | if: startsWith(github.event.ref, 'refs/tags/') 101 | shell: pwsh 102 | env: 103 | githubFullName: ${{ github.event.repository.full_name }} 104 | upUrl: ${{ steps.queryReleaseMacos.outputs.upload_url }} 105 | ref: ${{ github.event.ref }} 106 | run: | 107 | # upUrl不为空,导出就完事 108 | if (${env:upUrl}.Length -gt 0) { 109 | $v=${env:upUrl} 110 | echo "::set-env name=uploadUrl::$v" 111 | return 112 | } 113 | [string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1) 114 | [string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag} 115 | $response = Invoke-RestMethod -Uri $url -Method Get 116 | [string]$latestUpUrl = $response.upload_url 117 | Write-Host 'latestUpUrl:'$latestUpUrl 118 | echo "::set-env name=uploadUrl::$latestUpUrl" 119 | Write-Host 'env uploadUrl:'${env:uploadUrl} 120 | # tag 上传Release 121 | - name: uploadRelease 122 | id: uploadRelease 123 | if: startsWith(github.event.ref, 'refs/tags/') 124 | env: 125 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 126 | uses: actions/upload-release-asset@v1.0.1 127 | with: 128 | upload_url: ${{ env.uploadUrl }} 129 | asset_path: ./bin/${{ env.targetName }}.dmg 130 | asset_name: ${{ env.targetName }}.dmg 131 | asset_content_type: application/applefile -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### C++ ### 2 | # Prerequisites 3 | *.d 4 | 5 | # Compiled Object files 6 | *.slo 7 | *.lo 8 | *.o 9 | *.obj 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Fortran module files 16 | *.mod 17 | *.smod 18 | 19 | 20 | ### Qt ### 21 | 22 | # Qt-es 23 | 24 | /.qmake.cache 25 | /.qmake.stash 26 | *.pro.user 27 | *.pro.user.* 28 | *.qbs.user 29 | *.qbs.user.* 30 | *.moc 31 | moc_*.cpp 32 | qrc_*.cpp 33 | ui_*.h 34 | Makefile* 35 | *build-* 36 | 37 | # QtCreator 38 | 39 | *.autosave 40 | 41 | # QtCtreator Qml 42 | *.qmlproject.user 43 | *.qmlproject.user.* 44 | 45 | # QtCtreator CMake 46 | CMakeLists.txt.user* 47 | 48 | ### macOS ### 49 | *.DS_Store 50 | 51 | ### build ### 52 | bin 53 | 54 | config/config.ini 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 longxr 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 all 13 | 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 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/LibXlsxRW.cpp: -------------------------------------------------------------------------------- 1 | #include "LibXlsxRW.h" 2 | 3 | 4 | LibXlsxRW::LibXlsxRW() 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/LibXlsxRW.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBXLSXRW_H 2 | #define LIBXLSXRW_H 3 | 4 | #include "libxlsxrw_global.h" 5 | #include "xlsx/xlsxdocument.h" 6 | class LIBXLSXRWSHARED_EXPORT LibXlsxRW 7 | { 8 | 9 | public: 10 | LibXlsxRW(); 11 | }; 12 | 13 | #endif // LIBXLSXRW_H 14 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/LibXlsxRW.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-01-20T15:14:16 4 | # 5 | #------------------------------------------------- 6 | 7 | QT -= gui 8 | 9 | TARGET = LibXlsxRW 10 | TEMPLATE = lib 11 | 12 | # /////////////////////////////////////////////////////////////////////////////////// 13 | 14 | include(./../../Path.pri) 15 | # /////////////////////////////////////////////////////////////////////////////////// 16 | 17 | INCLUDEPATH += ../LibXlsxRW 18 | 19 | DEFINES += LIBXLSXRW_LIBRARY 20 | include(xlsx/qtxlsx.pri) 21 | SOURCES += LibXlsxRW.cpp 22 | 23 | HEADERS += LibXlsxRW.h\ 24 | libxlsxrw_global.h 25 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/libxlsxrw_global.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBXLSXRW_GLOBAL_H 2 | #define LIBXLSXRW_GLOBAL_H 3 | 4 | #include 5 | 6 | #if defined(LIBXLSXRW_LIBRARY) 7 | # define LIBXLSXRWSHARED_EXPORT Q_DECL_EXPORT 8 | #else 9 | # define LIBXLSXRWSHARED_EXPORT Q_DECL_IMPORT 10 | #endif 11 | 12 | #endif // LIBXLSXRW_GLOBAL_H 13 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/qtxlsx.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | QT += core gui gui-private 5 | !build_xlsx_lib:DEFINES += XLSX_NO_LIB 6 | 7 | HEADERS += $$PWD/xlsxdocpropscore_p.h \ 8 | $$PWD/xlsxdocpropsapp_p.h \ 9 | $$PWD/xlsxrelationships_p.h \ 10 | $$PWD/xlsxutility_p.h \ 11 | $$PWD/xlsxsharedstrings_p.h \ 12 | $$PWD/xlsxcontenttypes_p.h \ 13 | $$PWD/xlsxtheme_p.h \ 14 | $$PWD/xlsxformat.h \ 15 | $$PWD/xlsxworkbook.h \ 16 | $$PWD/xlsxstyles_p.h \ 17 | $$PWD/xlsxabstractsheet.h \ 18 | $$PWD/xlsxabstractsheet_p.h \ 19 | $$PWD/xlsxworksheet.h \ 20 | $$PWD/xlsxworksheet_p.h \ 21 | $$PWD/xlsxchartsheet.h \ 22 | $$PWD/xlsxchartsheet_p.h \ 23 | $$PWD/xlsxzipwriter_p.h \ 24 | $$PWD/xlsxworkbook_p.h \ 25 | $$PWD/xlsxformat_p.h \ 26 | $$PWD/xlsxglobal.h \ 27 | $$PWD/xlsxdrawing_p.h \ 28 | $$PWD/xlsxzipreader_p.h \ 29 | $$PWD/xlsxdocument.h \ 30 | $$PWD/xlsxdocument_p.h \ 31 | $$PWD/xlsxcell.h \ 32 | $$PWD/xlsxcell_p.h \ 33 | $$PWD/xlsxdatavalidation.h \ 34 | $$PWD/xlsxdatavalidation_p.h \ 35 | $$PWD/xlsxcellreference.h \ 36 | $$PWD/xlsxcellrange.h \ 37 | $$PWD/xlsxrichstring_p.h \ 38 | $$PWD/xlsxrichstring.h \ 39 | $$PWD/xlsxconditionalformatting.h \ 40 | $$PWD/xlsxconditionalformatting_p.h \ 41 | $$PWD/xlsxcolor_p.h \ 42 | $$PWD/xlsxnumformatparser_p.h \ 43 | $$PWD/xlsxdrawinganchor_p.h \ 44 | $$PWD/xlsxmediafile_p.h \ 45 | $$PWD/xlsxabstractooxmlfile.h \ 46 | $$PWD/xlsxabstractooxmlfile_p.h \ 47 | $$PWD/xlsxchart.h \ 48 | $$PWD/xlsxchart_p.h \ 49 | $$PWD/xlsxsimpleooxmlfile_p.h \ 50 | $$PWD/xlsxcellformula.h \ 51 | $$PWD/xlsxcellformula_p.h 52 | 53 | SOURCES += $$PWD/xlsxdocpropscore.cpp \ 54 | $$PWD/xlsxdocpropsapp.cpp \ 55 | $$PWD/xlsxrelationships.cpp \ 56 | $$PWD/xlsxutility.cpp \ 57 | $$PWD/xlsxsharedstrings.cpp \ 58 | $$PWD/xlsxcontenttypes.cpp \ 59 | $$PWD/xlsxtheme.cpp \ 60 | $$PWD/xlsxformat.cpp \ 61 | $$PWD/xlsxstyles.cpp \ 62 | $$PWD/xlsxworkbook.cpp \ 63 | $$PWD/xlsxabstractsheet.cpp \ 64 | $$PWD/xlsxworksheet.cpp \ 65 | $$PWD/xlsxchartsheet.cpp \ 66 | $$PWD/xlsxzipwriter.cpp \ 67 | $$PWD/xlsxdrawing.cpp \ 68 | $$PWD/xlsxzipreader.cpp \ 69 | $$PWD/xlsxdocument.cpp \ 70 | $$PWD/xlsxcell.cpp \ 71 | $$PWD/xlsxdatavalidation.cpp \ 72 | $$PWD/xlsxcellreference.cpp \ 73 | $$PWD/xlsxcellrange.cpp \ 74 | $$PWD/xlsxrichstring.cpp \ 75 | $$PWD/xlsxconditionalformatting.cpp \ 76 | $$PWD/xlsxcolor.cpp \ 77 | $$PWD/xlsxnumformatparser.cpp \ 78 | $$PWD/xlsxdrawinganchor.cpp \ 79 | $$PWD/xlsxmediafile.cpp \ 80 | $$PWD/xlsxabstractooxmlfile.cpp \ 81 | $$PWD/xlsxchart.cpp \ 82 | $$PWD/xlsxsimpleooxmlfile.cpp \ 83 | $$PWD/xlsxcellformula.cpp 84 | 85 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxabstractooxmlfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include "xlsxabstractooxmlfile.h" 27 | #include "xlsxabstractooxmlfile_p.h" 28 | 29 | #include 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | 34 | AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag=AbstractOOXmlFile::F_NewFromScratch) 35 | :relationships(new Relationships), flag(flag), q_ptr(q) 36 | { 37 | 38 | } 39 | 40 | AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate() 41 | { 42 | 43 | } 44 | 45 | /*! 46 | * \internal 47 | * 48 | * \class AbstractOOXmlFile 49 | * 50 | * Base class of all the ooxml part file. 51 | */ 52 | 53 | AbstractOOXmlFile::AbstractOOXmlFile(CreateFlag flag) 54 | :d_ptr(new AbstractOOXmlFilePrivate(this, flag)) 55 | { 56 | } 57 | 58 | AbstractOOXmlFile::AbstractOOXmlFile(AbstractOOXmlFilePrivate *d) 59 | :d_ptr(d) 60 | { 61 | 62 | } 63 | 64 | AbstractOOXmlFile::~AbstractOOXmlFile() 65 | { 66 | if (d_ptr->relationships) 67 | delete d_ptr->relationships; 68 | delete d_ptr; 69 | } 70 | 71 | QByteArray AbstractOOXmlFile::saveToXmlData() const 72 | { 73 | QByteArray data; 74 | QBuffer buffer(&data); 75 | buffer.open(QIODevice::WriteOnly); 76 | saveToXmlFile(&buffer); 77 | 78 | return data; 79 | } 80 | 81 | bool AbstractOOXmlFile::loadFromXmlData(const QByteArray &data) 82 | { 83 | QBuffer buffer; 84 | buffer.setData(data); 85 | buffer.open(QIODevice::ReadOnly); 86 | 87 | return loadFromXmlFile(&buffer); 88 | } 89 | 90 | /*! 91 | * \internal 92 | */ 93 | void AbstractOOXmlFile::setFilePath(const QString path) 94 | { 95 | Q_D(AbstractOOXmlFile); 96 | d->filePathInPackage = path; 97 | } 98 | 99 | /*! 100 | * \internal 101 | */ 102 | QString AbstractOOXmlFile::filePath() const 103 | { 104 | Q_D(const AbstractOOXmlFile); 105 | return d->filePathInPackage; 106 | } 107 | 108 | 109 | /*! 110 | * \internal 111 | */ 112 | Relationships *AbstractOOXmlFile::relationships() const 113 | { 114 | Q_D(const AbstractOOXmlFile); 115 | return d->relationships; 116 | } 117 | 118 | 119 | QT_END_NAMESPACE_XLSX 120 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxabstractooxmlfile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_XLSXABSTRACTOOXMLFILE_H 27 | #define QXLSX_XLSXABSTRACTOOXMLFILE_H 28 | 29 | #include "xlsxglobal.h" 30 | 31 | class QIODevice; 32 | class QByteArray; 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | class Relationships; 36 | class AbstractOOXmlFilePrivate; 37 | 38 | class Q_XLSX_EXPORT AbstractOOXmlFile 39 | { 40 | Q_DECLARE_PRIVATE(AbstractOOXmlFile) 41 | public: 42 | enum CreateFlag 43 | { 44 | F_NewFromScratch, 45 | F_LoadFromExists 46 | }; 47 | 48 | virtual ~AbstractOOXmlFile(); 49 | 50 | virtual void saveToXmlFile(QIODevice *device) const = 0; 51 | virtual bool loadFromXmlFile(QIODevice *device) = 0; 52 | 53 | virtual QByteArray saveToXmlData() const; 54 | virtual bool loadFromXmlData(const QByteArray &data); 55 | 56 | Relationships *relationships() const; 57 | 58 | void setFilePath(const QString path); 59 | QString filePath() const; 60 | 61 | protected: 62 | AbstractOOXmlFile(CreateFlag flag); 63 | AbstractOOXmlFile(AbstractOOXmlFilePrivate *d); 64 | 65 | AbstractOOXmlFilePrivate *d_ptr; 66 | }; 67 | 68 | QT_END_NAMESPACE_XLSX 69 | 70 | #endif // QXLSX_XLSXABSTRACTOOXMLFILE_H 71 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxabstractooxmlfile_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef XLSXOOXMLFILE_P_H 27 | #define XLSXOOXMLFILE_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxabstractooxmlfile.h" 41 | #include "xlsxrelationships_p.h" 42 | 43 | #include 44 | 45 | QT_BEGIN_NAMESPACE_XLSX 46 | 47 | class XLSX_AUTOTEST_EXPORT AbstractOOXmlFilePrivate 48 | { 49 | Q_DECLARE_PUBLIC(AbstractOOXmlFile) 50 | 51 | public: 52 | AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag); 53 | virtual ~AbstractOOXmlFilePrivate(); 54 | 55 | QString filePathInPackage;//such as "xl/worksheets/sheet1.xml" 56 | //used when load the .xlsx file 57 | Relationships *relationships; 58 | AbstractOOXmlFile::CreateFlag flag; 59 | AbstractOOXmlFile *q_ptr; 60 | }; 61 | 62 | QT_END_NAMESPACE_XLSX 63 | 64 | #endif // XLSXOOXMLFILE_P_H 65 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxabstractsheet.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxabstractsheet.h" 26 | #include "xlsxabstractsheet_p.h" 27 | #include "xlsxworkbook.h" 28 | 29 | QT_BEGIN_NAMESPACE_XLSX 30 | 31 | AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag) 32 | : AbstractOOXmlFilePrivate(p, flag) 33 | { 34 | type = AbstractSheet::ST_WorkSheet; 35 | sheetState = AbstractSheet::SS_Visible; 36 | } 37 | 38 | AbstractSheetPrivate::~AbstractSheetPrivate() 39 | { 40 | } 41 | 42 | /*! 43 | \class AbstractSheet 44 | \inmodule QtXlsx 45 | \brief Base class for worksheet, chartsheet, etc. 46 | */ 47 | 48 | /*! 49 | \enum AbstractSheet::SheetType 50 | 51 | \value ST_WorkSheet 52 | \value ST_ChartSheet 53 | \omitvalue ST_DialogSheet 54 | \omitvalue ST_MacroSheet 55 | */ 56 | 57 | /*! 58 | \enum AbstractSheet::SheetState 59 | 60 | \value SS_Visible 61 | \value SS_Hidden 62 | \value SS_VeryHidden User cann't make a veryHidden sheet visible in normal way. 63 | */ 64 | 65 | /*! 66 | \fn AbstractSheet::copy(const QString &distName, int distId) const 67 | 68 | Copies the current sheet to a sheet called \a distName with \a distId. 69 | Returns the new sheet. 70 | */ 71 | 72 | /*! 73 | * \internal 74 | */ 75 | AbstractSheet::AbstractSheet(const QString &name, int id, Workbook *workbook, AbstractSheetPrivate *d) : 76 | AbstractOOXmlFile(d) 77 | { 78 | d_func()->name = name; 79 | d_func()->id = id; 80 | d_func()->workbook = workbook; 81 | } 82 | 83 | 84 | /*! 85 | * Returns the name of the sheet. 86 | */ 87 | QString AbstractSheet::sheetName() const 88 | { 89 | Q_D(const AbstractSheet); 90 | return d->name; 91 | } 92 | 93 | /*! 94 | * \internal 95 | */ 96 | void AbstractSheet::setSheetName(const QString &sheetName) 97 | { 98 | Q_D(AbstractSheet); 99 | d->name = sheetName; 100 | } 101 | 102 | /*! 103 | * Returns the type of the sheet. 104 | */ 105 | AbstractSheet::SheetType AbstractSheet::sheetType() const 106 | { 107 | Q_D(const AbstractSheet); 108 | return d->type; 109 | } 110 | 111 | /*! 112 | * \internal 113 | */ 114 | void AbstractSheet::setSheetType(SheetType type) 115 | { 116 | Q_D(AbstractSheet); 117 | d->type = type; 118 | } 119 | 120 | /*! 121 | * Returns the state of the sheet. 122 | * 123 | * \sa isHidden(), isVisible(), setSheetState() 124 | */ 125 | AbstractSheet::SheetState AbstractSheet::sheetState() const 126 | { 127 | Q_D(const AbstractSheet); 128 | return d->sheetState; 129 | } 130 | 131 | /*! 132 | * Set the state of the sheet to \a state. 133 | */ 134 | void AbstractSheet::setSheetState(SheetState state) 135 | { 136 | Q_D(AbstractSheet); 137 | d->sheetState = state; 138 | } 139 | 140 | /*! 141 | * Returns true if the sheet is not visible, otherwise false will be returned. 142 | * 143 | * \sa sheetState(), setHidden() 144 | */ 145 | bool AbstractSheet::isHidden() const 146 | { 147 | Q_D(const AbstractSheet); 148 | return d->sheetState != SS_Visible; 149 | } 150 | 151 | /*! 152 | * Returns true if the sheet is visible. 153 | */ 154 | bool AbstractSheet::isVisible() const 155 | { 156 | return !isHidden(); 157 | } 158 | 159 | /*! 160 | * Make the sheet hiden or visible based on \a hidden. 161 | */ 162 | void AbstractSheet::setHidden(bool hidden) 163 | { 164 | Q_D(AbstractSheet); 165 | if (hidden == isHidden()) 166 | return; 167 | 168 | d->sheetState = hidden ? SS_Hidden : SS_Visible; 169 | } 170 | 171 | /*! 172 | * Convenience function, equivalent to setHidden(! \a visible). 173 | */ 174 | void AbstractSheet::setVisible(bool visible) 175 | { 176 | setHidden(!visible); 177 | } 178 | 179 | /*! 180 | * \internal 181 | */ 182 | int AbstractSheet::sheetId() const 183 | { 184 | Q_D(const AbstractSheet); 185 | return d->id; 186 | } 187 | 188 | /*! 189 | * \internal 190 | */ 191 | Drawing *AbstractSheet::drawing() const 192 | { 193 | Q_D(const AbstractSheet); 194 | return d->drawing.data(); 195 | } 196 | 197 | /*! 198 | * Return the workbook 199 | */ 200 | Workbook *AbstractSheet::workbook() const 201 | { 202 | Q_D(const AbstractSheet); 203 | return d->workbook; 204 | } 205 | 206 | QT_END_NAMESPACE_XLSX 207 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxabstractsheet.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXABSTRACTSHEET_H 26 | #define XLSXABSTRACTSHEET_H 27 | 28 | #include "xlsxabstractooxmlfile.h" 29 | #include 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | class Workbook; 34 | class Drawing; 35 | class AbstractSheetPrivate; 36 | class Q_XLSX_EXPORT AbstractSheet : public AbstractOOXmlFile 37 | { 38 | Q_DECLARE_PRIVATE(AbstractSheet) 39 | public: 40 | enum SheetType { 41 | ST_WorkSheet, 42 | ST_ChartSheet, 43 | ST_DialogSheet, 44 | ST_MacroSheet 45 | }; 46 | 47 | enum SheetState { 48 | SS_Visible, 49 | SS_Hidden, 50 | SS_VeryHidden 51 | }; 52 | 53 | QString sheetName() const; 54 | SheetType sheetType() const; 55 | SheetState sheetState() const; 56 | void setSheetState(SheetState ss); 57 | bool isHidden() const; 58 | bool isVisible() const; 59 | void setHidden(bool hidden); 60 | void setVisible(bool visible); 61 | 62 | Workbook *workbook() const; 63 | 64 | protected: 65 | friend class Workbook; 66 | AbstractSheet(const QString &sheetName, int sheetId, Workbook *book, AbstractSheetPrivate *d); 67 | virtual AbstractSheet *copy(const QString &distName, int distId) const = 0; 68 | void setSheetName(const QString &sheetName); 69 | void setSheetType(SheetType type); 70 | int sheetId() const; 71 | 72 | Drawing *drawing() const; 73 | }; 74 | 75 | QT_END_NAMESPACE_XLSX 76 | #endif // XLSXABSTRACTSHEET_H 77 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxabstractsheet_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXABSTRACTSHEET_P_H 26 | #define XLSXABSTRACTSHEET_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxabstractsheet.h" 41 | #include "xlsxabstractooxmlfile_p.h" 42 | 43 | #include 44 | 45 | namespace QXlsx { 46 | 47 | class XLSX_AUTOTEST_EXPORT AbstractSheetPrivate : public AbstractOOXmlFilePrivate 48 | { 49 | Q_DECLARE_PUBLIC(AbstractSheet) 50 | public: 51 | AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag); 52 | ~AbstractSheetPrivate(); 53 | 54 | Workbook *workbook; 55 | QSharedPointer drawing; 56 | 57 | QString name; 58 | int id; 59 | AbstractSheet::SheetState sheetState; 60 | AbstractSheet::SheetType type; 61 | }; 62 | 63 | } 64 | #endif // XLSXABSTRACTSHEET_P_H 65 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcell.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxcell.h" 26 | #include "xlsxcell_p.h" 27 | #include "xlsxformat.h" 28 | #include "xlsxformat_p.h" 29 | #include "xlsxutility_p.h" 30 | #include "xlsxworksheet.h" 31 | #include "xlsxworkbook.h" 32 | #include 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | 36 | CellPrivate::CellPrivate(Cell *p) : 37 | q_ptr(p) 38 | { 39 | 40 | } 41 | 42 | CellPrivate::CellPrivate(const CellPrivate * const cp) 43 | : value(cp->value), formula(cp->formula), cellType(cp->cellType) 44 | , format(cp->format), richString(cp->richString), parent(cp->parent) 45 | { 46 | 47 | } 48 | 49 | /*! 50 | \class Cell 51 | \inmodule QtXlsx 52 | \brief The Cell class provides a API that is used to handle the worksheet cell. 53 | 54 | */ 55 | 56 | /*! 57 | \enum Cell::CellType 58 | \value BooleanType Boolean type 59 | \value NumberType Number type, can be blank or used with forumula 60 | \value ErrorType Error type 61 | \value SharedStringType Shared string type 62 | \value StringType String type, can be used with forumula 63 | \value InlineStringType Inline string type 64 | */ 65 | 66 | /*! 67 | * \internal 68 | * Created by Worksheet only. 69 | */ 70 | Cell::Cell(const QVariant &data, CellType type, const Format &format, Worksheet *parent) : 71 | d_ptr(new CellPrivate(this)) 72 | { 73 | d_ptr->value = data; 74 | d_ptr->cellType = type; 75 | d_ptr->format = format; 76 | d_ptr->parent = parent; 77 | } 78 | 79 | /*! 80 | * \internal 81 | */ 82 | Cell::Cell(const Cell * const cell): 83 | d_ptr(new CellPrivate(cell->d_ptr)) 84 | { 85 | d_ptr->q_ptr = this; 86 | } 87 | 88 | /*! 89 | * Destroys the Cell and cleans up. 90 | */ 91 | Cell::~Cell() 92 | { 93 | delete d_ptr; 94 | } 95 | 96 | /*! 97 | * Return the dataType of this Cell 98 | */ 99 | Cell::CellType Cell::cellType() const 100 | { 101 | Q_D(const Cell); 102 | return d->cellType; 103 | } 104 | 105 | /*! 106 | * Return the data content of this Cell 107 | */ 108 | QVariant Cell::value() const 109 | { 110 | Q_D(const Cell); 111 | return d->value; 112 | } 113 | 114 | /*! 115 | * Return the style used by this Cell. If no style used, 0 will be returned. 116 | */ 117 | Format Cell::format() const 118 | { 119 | Q_D(const Cell); 120 | return d->format; 121 | } 122 | 123 | /*! 124 | * Returns true if the cell has one formula. 125 | */ 126 | bool Cell::hasFormula() const 127 | { 128 | Q_D(const Cell); 129 | return d->formula.isValid(); 130 | } 131 | 132 | /*! 133 | * Return the formula contents if the dataType is Formula 134 | */ 135 | CellFormula Cell::formula() const 136 | { 137 | Q_D(const Cell); 138 | return d->formula; 139 | } 140 | 141 | /*! 142 | * Returns whether the value is probably a dateTime or not 143 | */ 144 | bool Cell::isDateTime() const 145 | { 146 | Q_D(const Cell); 147 | if (d->cellType == NumberType && d->value.toDouble() >=0 148 | && d->format.isValid() && d->format.isDateTimeFormat()) { 149 | return true; 150 | } 151 | return false; 152 | } 153 | 154 | /*! 155 | * Return the data time value. 156 | */ 157 | QDateTime Cell::dateTime() const 158 | { 159 | Q_D(const Cell); 160 | if (!isDateTime()) 161 | return QDateTime(); 162 | return datetimeFromNumber(d->value.toDouble(), d->parent->workbook()->isDate1904()); 163 | } 164 | 165 | /*! 166 | * Returns whether the cell is probably a rich string or not 167 | */ 168 | bool Cell::isRichString() const 169 | { 170 | Q_D(const Cell); 171 | if (d->cellType != SharedStringType && d->cellType != InlineStringType 172 | && d->cellType != StringType) 173 | return false; 174 | 175 | return d->richString.isRichString(); 176 | } 177 | 178 | QT_END_NAMESPACE_XLSX 179 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcell.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_XLSXCELL_H 26 | #define QXLSX_XLSXCELL_H 27 | 28 | #include "xlsxglobal.h" 29 | #include "xlsxformat.h" 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | 34 | class Worksheet; 35 | class Format; 36 | class CellFormula; 37 | class CellPrivate; 38 | class WorksheetPrivate; 39 | 40 | class Q_XLSX_EXPORT Cell 41 | { 42 | Q_DECLARE_PRIVATE(Cell) 43 | public: 44 | enum CellType { 45 | BooleanType, //t="b" 46 | NumberType, //t="n" (default) 47 | ErrorType, //t="e" 48 | SharedStringType, //t="s" 49 | StringType, //t="str" 50 | InlineStringType //t="inlineStr" 51 | }; 52 | 53 | CellType cellType() const; 54 | QVariant value() const; 55 | Format format() const; 56 | 57 | bool hasFormula() const; 58 | CellFormula formula() const; 59 | 60 | bool isDateTime() const; 61 | QDateTime dateTime() const; 62 | 63 | bool isRichString() const; 64 | 65 | ~Cell(); 66 | private: 67 | friend class Worksheet; 68 | friend class WorksheetPrivate; 69 | 70 | Cell(const QVariant &data=QVariant(), CellType type=NumberType, const Format &format=Format(), Worksheet *parent=0); 71 | Cell(const Cell * const cell); 72 | CellPrivate * const d_ptr; 73 | }; 74 | 75 | QT_END_NAMESPACE_XLSX 76 | 77 | #endif // QXLSX_XLSXCELL_H 78 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcell_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXCELL_P_H 26 | #define XLSXCELL_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxcell.h" 41 | #include "xlsxcellrange.h" 42 | #include "xlsxrichstring.h" 43 | #include "xlsxcellformula.h" 44 | #include 45 | #include 46 | 47 | QT_BEGIN_NAMESPACE_XLSX 48 | 49 | class CellPrivate 50 | { 51 | Q_DECLARE_PUBLIC(Cell) 52 | public: 53 | CellPrivate(Cell *p); 54 | CellPrivate(const CellPrivate * const cp); 55 | 56 | QVariant value; 57 | CellFormula formula; 58 | Cell::CellType cellType; 59 | Format format; 60 | 61 | RichString richString; 62 | 63 | Worksheet *parent; 64 | Cell *q_ptr; 65 | }; 66 | 67 | QT_END_NAMESPACE_XLSX 68 | 69 | #endif // XLSXCELL_P_H 70 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcellformula.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_XLSXCELLFORMULA_H 26 | #define QXLSX_XLSXCELLFORMULA_H 27 | 28 | #include "xlsxglobal.h" 29 | #include 30 | 31 | class QXmlStreamWriter; 32 | class QXmlStreamReader; 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | 36 | class CellFormulaPrivate; 37 | class CellRange; 38 | class Worksheet; 39 | class WorksheetPrivate; 40 | 41 | class Q_XLSX_EXPORT CellFormula 42 | { 43 | public: 44 | enum FormulaType { 45 | NormalType, 46 | ArrayType, 47 | DataTableType, 48 | SharedType 49 | }; 50 | 51 | CellFormula(); 52 | CellFormula(const char *formula, FormulaType type=NormalType); 53 | CellFormula(const QString &formula, FormulaType type=NormalType); 54 | CellFormula(const QString &formula, const CellRange &ref, FormulaType type); 55 | CellFormula(const CellFormula &other); 56 | ~CellFormula(); 57 | CellFormula &operator =(const CellFormula &other); 58 | bool isValid() const; 59 | 60 | FormulaType formulaType() const; 61 | QString formulaText() const; 62 | CellRange reference() const; 63 | int sharedIndex() const; 64 | 65 | bool operator == (const CellFormula &formula) const; 66 | bool operator != (const CellFormula &formula) const; 67 | 68 | bool saveToXml(QXmlStreamWriter &writer) const; 69 | bool loadFromXml(QXmlStreamReader &reader); 70 | private: 71 | friend class Worksheet; 72 | friend class WorksheetPrivate; 73 | QExplicitlySharedDataPointer d; 74 | }; 75 | 76 | QT_END_NAMESPACE_XLSX 77 | 78 | #endif // QXLSX_XLSXCELLFORMULA_H 79 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcellformula_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXCELLFORMULA_P_H 26 | #define XLSXCELLFORMULA_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxcellformula.h" 41 | #include "xlsxcellrange.h" 42 | 43 | #include 44 | #include 45 | 46 | QT_BEGIN_NAMESPACE_XLSX 47 | 48 | class CellFormulaPrivate : public QSharedData 49 | { 50 | public: 51 | CellFormulaPrivate(const QString &formula, const CellRange &reference, CellFormula::FormulaType type); 52 | CellFormulaPrivate(const CellFormulaPrivate &other); 53 | ~CellFormulaPrivate(); 54 | 55 | QString formula; //formula contents 56 | CellFormula::FormulaType type; 57 | CellRange reference; 58 | bool ca; //Calculate Cell 59 | int si; //Shared group index 60 | }; 61 | 62 | QT_END_NAMESPACE_XLSX 63 | 64 | #endif // XLSXCELLFORMULA_P_H 65 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcellrange.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxcellrange.h" 26 | #include "xlsxcellreference.h" 27 | #include 28 | #include 29 | #include 30 | 31 | QT_BEGIN_NAMESPACE_XLSX 32 | 33 | /*! 34 | \class CellRange 35 | \brief For a range "A1:B2" or single cell "A1" 36 | \inmodule QtXlsx 37 | 38 | The CellRange class stores the top left and bottom 39 | right rows and columns of a range in a worksheet. 40 | */ 41 | 42 | /*! 43 | Constructs an range, i.e. a range 44 | whose rowCount() and columnCount() are 0. 45 | */ 46 | CellRange::CellRange() 47 | : top(-1), left(-1), bottom(-2), right(-2) 48 | { 49 | } 50 | 51 | /*! 52 | Constructs the range from the given \a top, \a 53 | left, \a bottom and \a right rows and columns. 54 | 55 | \sa topRow(), leftColumn(), bottomRow(), rightColumn() 56 | */ 57 | CellRange::CellRange(int top, int left, int bottom, int right) 58 | : top(top), left(left), bottom(bottom), right(right) 59 | { 60 | } 61 | 62 | CellRange::CellRange(const CellReference &topLeft, const CellReference &bottomRight) 63 | : top(topLeft.row()), left(topLeft.column()) 64 | , bottom(bottomRight.row()), right(bottomRight.column()) 65 | { 66 | } 67 | 68 | /*! 69 | \overload 70 | Constructs the range form the given \a range string. 71 | */ 72 | CellRange::CellRange(const QString &range) 73 | { 74 | init(range); 75 | } 76 | 77 | /*! 78 | \overload 79 | Constructs the range form the given \a range string. 80 | */ 81 | CellRange::CellRange(const char *range) 82 | { 83 | init(QString::fromLatin1(range)); 84 | } 85 | 86 | void CellRange::init(const QString &range) 87 | { 88 | QStringList rs = range.split(QLatin1Char(':')); 89 | if (rs.size() == 2) { 90 | CellReference start(rs[0]); 91 | CellReference end(rs[1]); 92 | top = start.row(); 93 | left = start.column(); 94 | bottom = end.row(); 95 | right = end.column(); 96 | } else { 97 | CellReference p(rs[0]); 98 | top = p.row(); 99 | left = p.column(); 100 | bottom = p.row(); 101 | right = p.column(); 102 | } 103 | } 104 | 105 | /*! 106 | Constructs a the range by copying the given \a 107 | other range. 108 | */ 109 | CellRange::CellRange(const CellRange &other) 110 | : top(other.top), left(other.left), bottom(other.bottom), right(other.right) 111 | { 112 | } 113 | 114 | /*! 115 | Destroys the range. 116 | */ 117 | CellRange::~CellRange() 118 | { 119 | } 120 | 121 | /*! 122 | Convert the range to string notation, such as "A1:B5". 123 | */ 124 | QString CellRange::toString(bool row_abs, bool col_abs) const 125 | { 126 | if (!isValid()) 127 | return QString(); 128 | 129 | if (left == right && top == bottom) { 130 | //Single cell 131 | return CellReference(top, left).toString(row_abs, col_abs); 132 | } 133 | 134 | QString cell_1 = CellReference(top, left).toString(row_abs, col_abs); 135 | QString cell_2 = CellReference(bottom, right).toString(row_abs, col_abs); 136 | return cell_1 + QLatin1String(":") + cell_2; 137 | } 138 | 139 | /*! 140 | * Returns true if the Range is valid. 141 | */ 142 | bool CellRange::isValid() const 143 | { 144 | return left <= right && top <= bottom; 145 | } 146 | 147 | QT_END_NAMESPACE_XLSX 148 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcellrange.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_XLSXCELLRANGE_H 26 | #define QXLSX_XLSXCELLRANGE_H 27 | #include "xlsxglobal.h" 28 | #include "xlsxcellreference.h" 29 | 30 | QT_BEGIN_NAMESPACE_XLSX 31 | 32 | class Q_XLSX_EXPORT CellRange 33 | { 34 | public: 35 | CellRange(); 36 | CellRange(int firstRow, int firstColumn, int lastRow, int lastColumn); 37 | CellRange(const CellReference &topLeft, const CellReference &bottomRight); 38 | CellRange(const QString &range); 39 | CellRange(const char *range); 40 | CellRange(const CellRange &other); 41 | ~CellRange(); 42 | 43 | QString toString(bool row_abs=false, bool col_abs=false) const; 44 | bool isValid() const; 45 | inline void setFirstRow(int row) { top = row; } 46 | inline void setLastRow(int row) { bottom = row; } 47 | inline void setFirstColumn(int col) { left = col; } 48 | inline void setLastColumn(int col) { right = col; } 49 | inline int firstRow() const { return top; } 50 | inline int lastRow() const { return bottom; } 51 | inline int firstColumn() const { return left; } 52 | inline int lastColumn() const { return right; } 53 | inline int rowCount() const { return bottom - top + 1; } 54 | inline int columnCount() const { return right - left + 1; } 55 | inline CellReference topLeft() const { return CellReference(top, left); } 56 | inline CellReference topRight() const { return CellReference(top, right); } 57 | inline CellReference bottomLeft() const { return CellReference(bottom, left); } 58 | inline CellReference bottomRight() const { return CellReference(bottom, right); } 59 | 60 | inline bool operator ==(const CellRange &other) const 61 | { 62 | return top==other.top && bottom==other.bottom 63 | && left == other.left && right == other.right; 64 | } 65 | inline bool operator !=(const CellRange &other) const 66 | { 67 | return top!=other.top || bottom!=other.bottom 68 | || left != other.left || right != other.right; 69 | } 70 | private: 71 | void init(const QString &range); 72 | int top, left, bottom, right; 73 | }; 74 | 75 | QT_END_NAMESPACE_XLSX 76 | 77 | Q_DECLARE_TYPEINFO(QXlsx::CellRange, Q_MOVABLE_TYPE); 78 | 79 | #endif // QXLSX_XLSXCELLRANGE_H 80 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcellreference.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxcellreference.h" 26 | #include 27 | #include 28 | #include 29 | 30 | QT_BEGIN_NAMESPACE_XLSX 31 | 32 | namespace { 33 | 34 | int intPow(int x, int p) 35 | { 36 | if (p == 0) return 1; 37 | if (p == 1) return x; 38 | 39 | int tmp = intPow(x, p/2); 40 | if (p%2 == 0) return tmp * tmp; 41 | else return x * tmp * tmp; 42 | } 43 | 44 | QString col_to_name(int col_num) 45 | { 46 | static QMap col_cache; 47 | 48 | if (!col_cache.contains(col_num)) { 49 | QString col_str; 50 | int remainder; 51 | while (col_num) { 52 | remainder = col_num % 26; 53 | if (remainder == 0) 54 | remainder = 26; 55 | col_str.prepend(QChar('A'+remainder-1)); 56 | col_num = (col_num - 1) / 26; 57 | } 58 | col_cache.insert(col_num, col_str); 59 | } 60 | 61 | return col_cache[col_num]; 62 | } 63 | 64 | int col_from_name(const QString &col_str) 65 | { 66 | int col = 0; 67 | int expn = 0; 68 | for (int i=col_str.size()-1; i>-1; --i) { 69 | col += (col_str[i].unicode() - 'A' + 1) * intPow(26, expn); 70 | expn++; 71 | } 72 | 73 | return col; 74 | } 75 | } //namespace 76 | 77 | /*! 78 | \class CellReference 79 | \brief For one single cell such as "A1" 80 | \inmodule QtXlsx 81 | 82 | The CellReference class stores the cell location in a worksheet. 83 | */ 84 | 85 | /*! 86 | Constructs an invalid Cell Reference 87 | */ 88 | CellReference::CellReference() 89 | : _row(-1), _column(-1) 90 | { 91 | } 92 | 93 | /*! 94 | Constructs the Reference from the given \a row, and \a column. 95 | */ 96 | CellReference::CellReference(int row, int column) 97 | : _row(row), _column(column) 98 | { 99 | } 100 | 101 | /*! 102 | \overload 103 | Constructs the Reference form the given \a cell string. 104 | */ 105 | CellReference::CellReference(const QString &cell) 106 | { 107 | init(cell); 108 | } 109 | 110 | /*! 111 | \overload 112 | Constructs the Reference form the given \a cell string. 113 | */ 114 | CellReference::CellReference(const char *cell) 115 | { 116 | init(QString::fromLatin1(cell)); 117 | } 118 | 119 | void CellReference::init(const QString &cell_str) 120 | { 121 | static QRegularExpression re(QStringLiteral("^\\$?([A-Z]{1,3})\\$?(\\d+)$")); 122 | QRegularExpressionMatch match = re.match(cell_str); 123 | if (match.hasMatch()) { 124 | const QString col_str = match.captured(1); 125 | const QString row_str = match.captured(2); 126 | _row = row_str.toInt(); 127 | _column = col_from_name(col_str); 128 | } 129 | } 130 | 131 | /*! 132 | Constructs a Reference by copying the given \a 133 | other Reference. 134 | */ 135 | CellReference::CellReference(const CellReference &other) 136 | : _row(other._row), _column(other._column) 137 | { 138 | } 139 | 140 | /*! 141 | Destroys the Reference. 142 | */ 143 | CellReference::~CellReference() 144 | { 145 | } 146 | 147 | /*! 148 | Convert the Reference to string notation, such as "A1" or "$A$1". 149 | If current object is invalid, an empty string will be returned. 150 | */ 151 | QString CellReference::toString(bool row_abs, bool col_abs) const 152 | { 153 | if (!isValid()) 154 | return QString(); 155 | 156 | QString cell_str; 157 | if (col_abs) 158 | cell_str.append(QLatin1Char('$')); 159 | cell_str.append(col_to_name(_column)); 160 | if (row_abs) 161 | cell_str.append(QLatin1Char('$')); 162 | cell_str.append(QString::number(_row)); 163 | return cell_str; 164 | } 165 | 166 | /*! 167 | * Returns true if the Reference is valid. 168 | */ 169 | bool CellReference::isValid() const 170 | { 171 | return _row > 0 && _column > 0; 172 | } 173 | 174 | QT_END_NAMESPACE_XLSX 175 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcellreference.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_XLSXCELLREFERENCE_H 26 | #define QXLSX_XLSXCELLREFERENCE_H 27 | #include "xlsxglobal.h" 28 | 29 | QT_BEGIN_NAMESPACE_XLSX 30 | 31 | class Q_XLSX_EXPORT CellReference 32 | { 33 | public: 34 | CellReference(); 35 | CellReference(int row, int column); 36 | CellReference(const QString &cell); 37 | CellReference(const char *cell); 38 | CellReference(const CellReference &other); 39 | ~CellReference(); 40 | 41 | QString toString(bool row_abs=false, bool col_abs=false) const; 42 | static CellReference fromString(const QString &cell); 43 | bool isValid() const; 44 | inline void setRow(int row) { _row = row; } 45 | inline void setColumn(int col) { _column = col; } 46 | inline int row() const { return _row; } 47 | inline int column() const { return _column; } 48 | 49 | inline bool operator ==(const CellReference &other) const 50 | { 51 | return _row==other._row && _column==other._column; 52 | } 53 | inline bool operator !=(const CellReference &other) const 54 | { 55 | return _row!=other._row || _column!=other._column; 56 | } 57 | private: 58 | void init(const QString &cell); 59 | int _row, _column; 60 | }; 61 | 62 | QT_END_NAMESPACE_XLSX 63 | 64 | Q_DECLARE_TYPEINFO(QXlsx::CellReference, Q_MOVABLE_TYPE); 65 | 66 | #endif // QXLSX_XLSXCELLREFERENCE_H 67 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxchart.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_CHART_H 27 | #define QXLSX_CHART_H 28 | 29 | #include "xlsxabstractooxmlfile.h" 30 | 31 | #include 32 | 33 | class QXmlStreamReader; 34 | class QXmlStreamWriter; 35 | 36 | QT_BEGIN_NAMESPACE_XLSX 37 | 38 | class AbstractSheet; 39 | class Worksheet; 40 | class ChartPrivate; 41 | class CellRange; 42 | class DrawingAnchor; 43 | 44 | class Q_XLSX_EXPORT Chart : public AbstractOOXmlFile 45 | { 46 | Q_DECLARE_PRIVATE(Chart) 47 | 48 | public: 49 | enum ChartType { 50 | CT_Area = 1, //Zero is internally used for unknown types 51 | CT_Area3D, 52 | CT_Line, 53 | CT_Line3D, 54 | CT_Stock, 55 | CT_Radar, 56 | CT_Scatter, 57 | CT_Pie, 58 | CT_Pie3D, 59 | CT_Doughnut, 60 | CT_Bar, 61 | CT_Bar3D, 62 | CT_OfPie, 63 | CT_Surface, 64 | CT_Surface3D, 65 | CT_Bubble 66 | }; 67 | 68 | ~Chart(); 69 | 70 | void addSeries(const CellRange &range, AbstractSheet *sheet=0); 71 | void setChartType(ChartType type); 72 | void setChartStyle(int id); 73 | 74 | void saveToXmlFile(QIODevice *device) const; 75 | bool loadFromXmlFile(QIODevice *device); 76 | 77 | private: 78 | friend class AbstractSheet; 79 | friend class Worksheet; 80 | friend class Chartsheet; 81 | friend class DrawingAnchor; 82 | 83 | Chart(AbstractSheet *parent, CreateFlag flag); 84 | }; 85 | 86 | QT_END_NAMESPACE_XLSX 87 | 88 | #endif // QXLSX_CHART_H 89 | 90 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxchart_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_CHART_P_H 27 | #define QXLSX_CHART_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxabstractooxmlfile_p.h" 41 | #include "xlsxchart.h" 42 | 43 | #include 44 | 45 | class QXmlStreamReader; 46 | class QXmlStreamWriter; 47 | 48 | namespace QXlsx { 49 | 50 | class XlsxSeries 51 | { 52 | public: 53 | //At present, we care about number cell ranges only! 54 | QString numberDataSource_numRef; //yval, val 55 | QString axDataSource_numRef; //xval, cat 56 | }; 57 | 58 | class XlsxAxis 59 | { 60 | public: 61 | enum Type 62 | { 63 | T_Cat, 64 | T_Val, 65 | T_Date, 66 | T_Ser 67 | }; 68 | 69 | enum Pos 70 | { 71 | Left, 72 | Right, 73 | Top, 74 | Bottom 75 | }; 76 | 77 | XlsxAxis(){} 78 | 79 | XlsxAxis(Type t, Pos p, int id, int crossId) 80 | :type(t), axisPos(p), axisId(id), crossAx(crossId) 81 | { 82 | } 83 | 84 | Type type; 85 | Pos axisPos; //l,r,b,t 86 | int axisId; 87 | int crossAx; 88 | }; 89 | 90 | class ChartPrivate : public AbstractOOXmlFilePrivate 91 | { 92 | Q_DECLARE_PUBLIC(Chart) 93 | 94 | public: 95 | ChartPrivate(Chart *q, Chart::CreateFlag flag); 96 | ~ChartPrivate(); 97 | 98 | bool loadXmlChart(QXmlStreamReader &reader); 99 | bool loadXmlPlotArea(QXmlStreamReader &reader); 100 | bool loadXmlXxxChart(QXmlStreamReader &reader); 101 | bool loadXmlSer(QXmlStreamReader &reader); 102 | QString loadXmlNumRef(QXmlStreamReader &reader); 103 | bool loadXmlAxis(QXmlStreamReader &reader); 104 | 105 | void saveXmlChart(QXmlStreamWriter &writer) const; 106 | void saveXmlPieChart(QXmlStreamWriter &writer) const; 107 | void saveXmlBarChart(QXmlStreamWriter &writer) const; 108 | void saveXmlLineChart(QXmlStreamWriter &writer) const; 109 | void saveXmlScatterChart(QXmlStreamWriter &writer) const; 110 | void saveXmlAreaChart(QXmlStreamWriter &writer) const; 111 | void saveXmlDoughnutChart(QXmlStreamWriter &writer) const; 112 | void saveXmlSer(QXmlStreamWriter &writer, XlsxSeries *ser, int id) const; 113 | void saveXmlAxes(QXmlStreamWriter &writer) const; 114 | 115 | Chart::ChartType chartType; 116 | 117 | QList > seriesList; 118 | QList > axisList; 119 | 120 | AbstractSheet *sheet; 121 | }; 122 | 123 | } // namespace QXlsx 124 | 125 | #endif // QXLSX_CHART_P_H 126 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxchartsheet.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxchartsheet.h" 26 | #include "xlsxchartsheet_p.h" 27 | #include "xlsxworkbook.h" 28 | #include "xlsxutility_p.h" 29 | #include "xlsxdrawing_p.h" 30 | #include "xlsxdrawinganchor_p.h" 31 | #include "xlsxchart.h" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | QT_BEGIN_NAMESPACE_XLSX 38 | 39 | ChartsheetPrivate::ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag) 40 | : AbstractSheetPrivate(p, flag), chart(0) 41 | { 42 | 43 | } 44 | 45 | ChartsheetPrivate::~ChartsheetPrivate() 46 | { 47 | } 48 | 49 | /*! 50 | \class Chartsheet 51 | \inmodule QtXlsx 52 | \brief Represent one chartsheet in the workbook. 53 | */ 54 | 55 | /*! 56 | * \internal 57 | */ 58 | Chartsheet::Chartsheet(const QString &name, int id, Workbook *workbook, CreateFlag flag) 59 | :AbstractSheet(name, id, workbook, new ChartsheetPrivate(this, flag)) 60 | { 61 | setSheetType(ST_ChartSheet); 62 | 63 | if (flag == Chartsheet::F_NewFromScratch) { 64 | d_func()->drawing = QSharedPointer(new Drawing(this, flag)); 65 | 66 | DrawingAbsoluteAnchor *anchor = new DrawingAbsoluteAnchor(drawing(), DrawingAnchor::Picture); 67 | 68 | anchor->pos = QPoint(0, 0); 69 | anchor->ext = QSize(9293679, 6068786); 70 | 71 | QSharedPointer chart = QSharedPointer(new Chart(this, flag)); 72 | chart->setChartType(Chart::CT_Bar); 73 | anchor->setObjectGraphicFrame(chart); 74 | 75 | d_func()->chart = chart.data(); 76 | } 77 | } 78 | 79 | /*! 80 | * \internal 81 | * 82 | * Make a copy of this sheet. 83 | */ 84 | 85 | Chartsheet *Chartsheet::copy(const QString &distName, int distId) const 86 | { 87 | //:Todo 88 | Q_UNUSED(distName) 89 | Q_UNUSED(distId) 90 | return 0; 91 | } 92 | 93 | /*! 94 | * Destroys this workssheet. 95 | */ 96 | Chartsheet::~Chartsheet() 97 | { 98 | } 99 | 100 | /*! 101 | * Returns the chart object of the sheet. 102 | */ 103 | Chart *Chartsheet::chart() 104 | { 105 | Q_D(Chartsheet); 106 | 107 | return d->chart; 108 | } 109 | 110 | void Chartsheet::saveToXmlFile(QIODevice *device) const 111 | { 112 | Q_D(const Chartsheet); 113 | d->relationships->clear(); 114 | 115 | QXmlStreamWriter writer(device); 116 | 117 | writer.writeStartDocument(QStringLiteral("1.0"), true); 118 | writer.writeDefaultNamespace(QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main")); 119 | writer.writeNamespace(QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), QStringLiteral("r")); 120 | writer.writeStartElement(QStringLiteral("chartsheet")); 121 | 122 | writer.writeStartElement(QStringLiteral("sheetViews")); 123 | writer.writeEmptyElement(QStringLiteral("sheetView")); 124 | writer.writeAttribute(QStringLiteral("workbookViewId"), QString::number(0)); 125 | writer.writeAttribute(QStringLiteral("zoomToFit"), QStringLiteral("1")); 126 | writer.writeEndElement(); //sheetViews 127 | 128 | int idx = d->workbook->drawings().indexOf(d->drawing.data()); 129 | d->relationships->addWorksheetRelationship(QStringLiteral("/drawing"), QStringLiteral("../drawings/drawing%1.xml").arg(idx+1)); 130 | 131 | writer.writeEmptyElement(QStringLiteral("drawing")); 132 | writer.writeAttribute(QStringLiteral("r:id"), QStringLiteral("rId%1").arg(d->relationships->count())); 133 | 134 | writer.writeEndElement();//chartsheet 135 | writer.writeEndDocument(); 136 | } 137 | 138 | bool Chartsheet::loadFromXmlFile(QIODevice *device) 139 | { 140 | Q_D(Chartsheet); 141 | 142 | QXmlStreamReader reader(device); 143 | while (!reader.atEnd()) { 144 | reader.readNextStartElement(); 145 | if (reader.tokenType() == QXmlStreamReader::StartElement) { 146 | if (reader.name() == QLatin1String("drawing")) { 147 | QString rId = reader.attributes().value(QStringLiteral("r:id")).toString(); 148 | QString name = d->relationships->getRelationshipById(rId).target; 149 | QString path = QDir::cleanPath(splitPath(filePath())[0] + QLatin1String("/") + name); 150 | d->drawing = QSharedPointer(new Drawing(this, F_LoadFromExists)); 151 | d->drawing->setFilePath(path); 152 | } 153 | } 154 | } 155 | 156 | return true; 157 | } 158 | 159 | QT_END_NAMESPACE_XLSX 160 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxchartsheet.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXCHARTSHEET_H 26 | #define XLSXCHARTSHEET_H 27 | 28 | #include "xlsxabstractsheet.h" 29 | #include 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | class Workbook; 34 | class DocumentPrivate; 35 | class ChartsheetPrivate; 36 | class Chart; 37 | class Q_XLSX_EXPORT Chartsheet : public AbstractSheet 38 | { 39 | Q_DECLARE_PRIVATE(Chartsheet) 40 | public: 41 | 42 | ~Chartsheet(); 43 | Chart *chart(); 44 | 45 | private: 46 | friend class DocumentPrivate; 47 | friend class Workbook; 48 | Chartsheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag); 49 | Chartsheet *copy(const QString &distName, int distId) const; 50 | 51 | void saveToXmlFile(QIODevice *device) const; 52 | bool loadFromXmlFile(QIODevice *device); 53 | }; 54 | 55 | QT_END_NAMESPACE_XLSX 56 | #endif // XLSXCHARTSHEET_H 57 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxchartsheet_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXCHARTSHEET_P_H 26 | #define XLSXCHARTSHEET_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxchartsheet.h" 41 | #include "xlsxabstractsheet_p.h" 42 | 43 | namespace QXlsx { 44 | 45 | class XLSX_AUTOTEST_EXPORT ChartsheetPrivate : public AbstractSheetPrivate 46 | { 47 | Q_DECLARE_PUBLIC(Chartsheet) 48 | public: 49 | ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag); 50 | ~ChartsheetPrivate(); 51 | 52 | Chart *chart; 53 | }; 54 | 55 | } 56 | #endif // XLSXCHARTSHEET_P_H 57 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcolor.cpp: -------------------------------------------------------------------------------- 1 | #include "xlsxcolor_p.h" 2 | #include "xlsxstyles_p.h" 3 | #include "xlsxutility_p.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace QXlsx { 11 | 12 | 13 | XlsxColor::XlsxColor(const QColor &color) 14 | { 15 | if (color.isValid()) 16 | val.setValue(color); 17 | } 18 | 19 | XlsxColor::XlsxColor(const QString &theme, const QString &tint) 20 | :val(QStringList()<() && val.value().isValid()) 34 | return true; 35 | return false; 36 | } 37 | 38 | bool XlsxColor::isIndexedColor() const 39 | { 40 | return val.userType() == QMetaType::Int; 41 | } 42 | 43 | bool XlsxColor::isThemeColor() const 44 | { 45 | return val.userType() == QMetaType::QStringList; 46 | } 47 | 48 | bool XlsxColor::isInvalid() const 49 | { 50 | return !val.isValid(); 51 | } 52 | 53 | QColor XlsxColor::rgbColor() const 54 | { 55 | if (isRgbColor()) 56 | return val.value(); 57 | return QColor(); 58 | } 59 | 60 | int XlsxColor::indexedColor() const 61 | { 62 | if (isIndexedColor()) 63 | return val.toInt(); 64 | return -1; 65 | } 66 | 67 | QStringList XlsxColor::themeColor() const 68 | { 69 | if (isThemeColor()) 70 | return val.toStringList(); 71 | return QStringList(); 72 | } 73 | 74 | bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const 75 | { 76 | if (!node.isEmpty()) 77 | writer.writeEmptyElement(node); //color, bgColor, fgColor 78 | else 79 | writer.writeEmptyElement(QStringLiteral("color")); 80 | 81 | if (val.userType() == qMetaTypeId()) { 82 | writer.writeAttribute(QStringLiteral("rgb"), XlsxColor::toARGBString(val.value())); 83 | } else if (val.userType() == QMetaType::QStringList) { 84 | QStringList themes = val.toStringList(); 85 | writer.writeAttribute(QStringLiteral("theme"), themes[0]); 86 | if (!themes[1].isEmpty()) 87 | writer.writeAttribute(QStringLiteral("tint"), themes[1]); 88 | } else if (val.userType() == QMetaType::Int) { 89 | writer.writeAttribute(QStringLiteral("indexed"), val.toString()); 90 | } else { 91 | writer.writeAttribute(QStringLiteral("auto"), QStringLiteral("1")); 92 | } 93 | 94 | return true; 95 | } 96 | 97 | bool XlsxColor::loadFromXml(QXmlStreamReader &reader) 98 | { 99 | QXmlStreamAttributes attributes = reader.attributes(); 100 | 101 | if (attributes.hasAttribute(QLatin1String("rgb"))) { 102 | QString colorString = attributes.value(QLatin1String("rgb")).toString(); 103 | val.setValue(fromARGBString(colorString)); 104 | } else if (attributes.hasAttribute(QLatin1String("indexed"))) { 105 | int index = attributes.value(QLatin1String("indexed")).toString().toInt(); 106 | val.setValue(index); 107 | } else if (attributes.hasAttribute(QLatin1String("theme"))) { 108 | QString theme = attributes.value(QLatin1String("theme")).toString(); 109 | QString tint = attributes.value(QLatin1String("tint")).toString(); 110 | val.setValue(QStringList()<(), this); 118 | } 119 | 120 | 121 | QColor XlsxColor::fromARGBString(const QString &c) 122 | { 123 | Q_ASSERT(c.length() == 8); 124 | QColor color; 125 | color.setAlpha(c.mid(0, 2).toInt(0, 16)); 126 | color.setRed(c.mid(2, 2).toInt(0, 16)); 127 | color.setGreen(c.mid(4, 2).toInt(0, 16)); 128 | color.setBlue(c.mid(6, 2).toInt(0, 16)); 129 | return color; 130 | } 131 | 132 | QString XlsxColor::toARGBString(const QColor &c) 133 | { 134 | QString color; 135 | color.sprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue()); 136 | return color; 137 | } 138 | 139 | #if !defined(QT_NO_DATASTREAM) 140 | QDataStream &operator<<(QDataStream &s, const XlsxColor &color) 141 | { 142 | if (color.isInvalid()) 143 | s<<0; 144 | else if (color.isRgbColor()) 145 | s<<1<>(QDataStream &s, XlsxColor &color) 157 | { 158 | int marker(4); 159 | s>>marker; 160 | if (marker == 0) { 161 | color = XlsxColor(); 162 | } else if (marker == 1) { 163 | QColor c; 164 | s>>c; 165 | color = XlsxColor(c); 166 | } else if (marker == 2) { 167 | int indexed; 168 | s>>indexed; 169 | color = XlsxColor(indexed); 170 | } else if (marker == 3) { 171 | QStringList list; 172 | s>>list; 173 | color = XlsxColor(list[0], list[1]); 174 | } 175 | 176 | return s; 177 | } 178 | 179 | #endif 180 | 181 | #ifndef QT_NO_DEBUG_STREAM 182 | QDebug operator<<(QDebug dbg, const XlsxColor &c) 183 | { 184 | if (c.isInvalid()) 185 | dbg.nospace() << "XlsxColor(invalid)"; 186 | else if (c.isRgbColor()) 187 | dbg.nospace() << c.rgbColor(); 188 | else if (c.isIndexedColor()) 189 | dbg.nospace() << "XlsxColor(indexed," << c.indexedColor() << ")"; 190 | else if (c.isThemeColor()) 191 | dbg.nospace() << "XlsxColor(theme," << c.themeColor().join(QLatin1Char(':')) << ")"; 192 | 193 | return dbg.space(); 194 | } 195 | 196 | #endif 197 | 198 | } // namespace QXlsx 199 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcolor_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_XLSXCOLOR_P_H 27 | #define QXLSX_XLSXCOLOR_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxglobal.h" 41 | #include 42 | #include 43 | 44 | class QXmlStreamWriter; 45 | class QXmlStreamReader; 46 | 47 | namespace QXlsx { 48 | 49 | class Styles; 50 | 51 | class Q_XLSX_EXPORT XlsxColor 52 | { 53 | public: 54 | explicit XlsxColor(const QColor &color = QColor()); 55 | explicit XlsxColor(const QString &theme, const QString &tint=QString()); 56 | explicit XlsxColor (int index); 57 | 58 | bool isThemeColor() const; 59 | bool isIndexedColor() const; 60 | bool isRgbColor() const; 61 | bool isInvalid() const; 62 | 63 | QColor rgbColor() const; 64 | int indexedColor() const; 65 | QStringList themeColor() const; 66 | 67 | operator QVariant() const; 68 | 69 | static QColor fromARGBString(const QString &c); 70 | static QString toARGBString(const QColor &c); 71 | 72 | bool saveToXml(QXmlStreamWriter &writer, const QString &node=QString()) const; 73 | bool loadFromXml(QXmlStreamReader &reader); 74 | 75 | private: 76 | QVariant val; 77 | }; 78 | 79 | #if !defined(QT_NO_DATASTREAM) 80 | Q_XLSX_EXPORT QDataStream &operator<<(QDataStream &, const XlsxColor &); 81 | Q_XLSX_EXPORT QDataStream &operator>>(QDataStream &, XlsxColor &); 82 | #endif 83 | 84 | #ifndef QT_NO_DEBUG_STREAM 85 | Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const XlsxColor &c); 86 | #endif 87 | 88 | } // namespace QXlsx 89 | 90 | Q_DECLARE_METATYPE(QXlsx::XlsxColor) 91 | 92 | #endif // QXLSX_XLSXCOLOR_P_H 93 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxconditionalformatting.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_XLSXCONDITIONALFORMATTING_H 26 | #define QXLSX_XLSXCONDITIONALFORMATTING_H 27 | 28 | #include "xlsxglobal.h" 29 | #include "xlsxcellrange.h" 30 | #include "xlsxcellreference.h" 31 | #include 32 | #include 33 | #include 34 | 35 | class QXmlStreamReader; 36 | class QXmlStreamWriter; 37 | class QColor; 38 | class ConditionalFormattingTest; 39 | 40 | QT_BEGIN_NAMESPACE_XLSX 41 | 42 | class Format; 43 | class Worksheet; 44 | class Styles; 45 | 46 | class ConditionalFormattingPrivate; 47 | class Q_XLSX_EXPORT ConditionalFormatting 48 | { 49 | public: 50 | enum HighlightRuleType { 51 | Highlight_LessThan, 52 | Highlight_LessThanOrEqual, 53 | Highlight_Equal, 54 | Highlight_NotEqual, 55 | Highlight_GreaterThanOrEqual, 56 | Highlight_GreaterThan, 57 | Highlight_Between, 58 | Highlight_NotBetween, 59 | 60 | Highlight_ContainsText, 61 | Highlight_NotContainsText, 62 | Highlight_BeginsWith, 63 | Highlight_EndsWith, 64 | 65 | Highlight_TimePeriod, 66 | 67 | Highlight_Duplicate, 68 | Highlight_Unique, 69 | Highlight_Blanks, 70 | Highlight_NoBlanks, 71 | Highlight_Errors, 72 | Highlight_NoErrors, 73 | 74 | Highlight_Top, 75 | Highlight_TopPercent, 76 | Highlight_Bottom, 77 | Highlight_BottomPercent, 78 | 79 | Highlight_AboveAverage, 80 | Highlight_AboveOrEqualAverage, 81 | Highlight_AboveStdDev1, 82 | Highlight_AboveStdDev2, 83 | Highlight_AboveStdDev3, 84 | Highlight_BelowAverage, 85 | Highlight_BelowOrEqualAverage, 86 | Highlight_BelowStdDev1, 87 | Highlight_BelowStdDev2, 88 | Highlight_BelowStdDev3, 89 | 90 | Highlight_Expression 91 | }; 92 | 93 | enum ValueObjectType 94 | { 95 | VOT_Formula, 96 | VOT_Max, 97 | VOT_Min, 98 | VOT_Num, 99 | VOT_Percent, 100 | VOT_Percentile 101 | }; 102 | 103 | ConditionalFormatting(); 104 | ConditionalFormatting(const ConditionalFormatting &other); 105 | ~ConditionalFormatting(); 106 | 107 | bool addHighlightCellsRule(HighlightRuleType type, const Format &format, bool stopIfTrue=false); 108 | bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const Format &format, bool stopIfTrue=false); 109 | bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const QString &formula2, const Format &format, bool stopIfTrue=false); 110 | bool addDataBarRule(const QColor &color, bool showData=true, bool stopIfTrue=false); 111 | bool addDataBarRule(const QColor &color, ValueObjectType type1, const QString &val1, ValueObjectType type2, const QString &val2, bool showData=true, bool stopIfTrue=false); 112 | bool add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue=false); 113 | bool add3ColorScaleRule(const QColor &minColor, const QColor &midColor, const QColor &maxColor, bool stopIfTrue=false); 114 | 115 | QList ranges() const; 116 | 117 | void addCell(const CellReference &cell); 118 | void addCell(int row, int col); 119 | void addRange(int firstRow, int firstCol, int lastRow, int lastCol); 120 | void addRange(const CellRange &range); 121 | 122 | //needed by QSharedDataPointer!! 123 | ConditionalFormatting &operator=(const ConditionalFormatting &other); 124 | 125 | private: 126 | friend class Worksheet; 127 | friend class ::ConditionalFormattingTest; 128 | bool saveToXml(QXmlStreamWriter &writer) const; 129 | bool loadFromXml(QXmlStreamReader &reader, Styles *styles=0); 130 | QSharedDataPointer d; 131 | }; 132 | 133 | QT_END_NAMESPACE_XLSX 134 | 135 | #endif // QXLSX_XLSXCONDITIONALFORMATTING_H 136 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxconditionalformatting_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef XLSXCONDITIONALFORMATTING_P_H 27 | #define XLSXCONDITIONALFORMATTING_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxconditionalformatting.h" 41 | #include "xlsxformat.h" 42 | #include "xlsxcolor_p.h" 43 | #include 44 | #include 45 | #include 46 | 47 | QT_BEGIN_NAMESPACE_XLSX 48 | 49 | class XlsxCfVoData 50 | { 51 | public: 52 | XlsxCfVoData() 53 | :gte(true) 54 | { 55 | } 56 | 57 | XlsxCfVoData(ConditionalFormatting::ValueObjectType type, const QString &value, bool gte=true) 58 | :type(type), value(value), gte(gte) 59 | { 60 | } 61 | 62 | ConditionalFormatting::ValueObjectType type; 63 | QString value; 64 | bool gte; 65 | }; 66 | 67 | class XlsxCfRuleData 68 | { 69 | public: 70 | enum Attribute { 71 | A_type, 72 | A_dxfId, 73 | //A_priority, 74 | A_stopIfTrue, 75 | A_aboveAverage, 76 | A_percent, 77 | A_bottom, 78 | A_operator, 79 | A_text, 80 | A_timePeriod, 81 | A_rank, 82 | A_stdDev, 83 | A_equalAverage, 84 | 85 | A_dxfFormat, 86 | A_formula1, 87 | A_formula2, 88 | A_formula3, 89 | A_formula1_temp, 90 | 91 | A_color1, 92 | A_color2, 93 | A_color3, 94 | 95 | A_cfvo1, 96 | A_cfvo2, 97 | A_cfvo3, 98 | 99 | A_hideData 100 | }; 101 | 102 | XlsxCfRuleData() 103 | :priority(1) 104 | {} 105 | 106 | int priority; 107 | Format dxfFormat; 108 | QMap attrs; 109 | }; 110 | 111 | class ConditionalFormattingPrivate : public QSharedData 112 | { 113 | public: 114 | ConditionalFormattingPrivate(); 115 | ConditionalFormattingPrivate(const ConditionalFormattingPrivate &other); 116 | ~ConditionalFormattingPrivate(); 117 | 118 | void writeCfVo(QXmlStreamWriter &writer, const XlsxCfVoData& cfvo) const; 119 | bool readCfVo(QXmlStreamReader &reader, XlsxCfVoData& cfvo); 120 | bool readCfRule(QXmlStreamReader &reader, XlsxCfRuleData *cfRule, Styles *styles); 121 | bool readCfDataBar(QXmlStreamReader &reader, XlsxCfRuleData *cfRule); 122 | bool readCfColorScale(QXmlStreamReader &reader, XlsxCfRuleData *cfRule); 123 | 124 | QList >cfRules; 125 | QList ranges; 126 | }; 127 | 128 | QT_END_NAMESPACE_XLSX 129 | 130 | Q_DECLARE_METATYPE(QXlsx::XlsxCfVoData) 131 | #endif // XLSXCONDITIONALFORMATTING_P_H 132 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxcontenttypes_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXCONTENTTYPES_H 26 | #define XLSXCONTENTTYPES_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxabstractooxmlfile.h" 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | class QIODevice; 46 | 47 | namespace QXlsx { 48 | 49 | class ContentTypes : public AbstractOOXmlFile 50 | { 51 | public: 52 | ContentTypes(CreateFlag flag); 53 | 54 | void addDefault(const QString &key, const QString &value); 55 | void addOverride(const QString &key, const QString &value); 56 | 57 | //Convenient funcation for addOverride() 58 | void addDocPropCore(); 59 | void addDocPropApp(); 60 | void addStyles(); 61 | void addTheme(); 62 | void addWorkbook(); 63 | void addWorksheetName(const QString &name); 64 | void addChartsheetName(const QString &name); 65 | void addChartName(const QString &name); 66 | void addDrawingName(const QString &name); 67 | void addCommentName(const QString &name); 68 | void addTableName(const QString &name); 69 | void addExternalLinkName(const QString &name); 70 | void addSharedString(); 71 | void addVmlName(); 72 | void addCalcChain(); 73 | void addVbaProject(); 74 | 75 | void clearOverrides(); 76 | 77 | void saveToXmlFile(QIODevice *device) const; 78 | bool loadFromXmlFile(QIODevice *device); 79 | private: 80 | QMap m_defaults; 81 | QMap m_overrides; 82 | 83 | QString m_package_prefix; 84 | QString m_document_prefix; 85 | }; 86 | 87 | } 88 | #endif // XLSXCONTENTTYPES_H 89 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdatavalidation.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_XLSXDATAVALIDATION_H 26 | #define QXLSX_XLSXDATAVALIDATION_H 27 | 28 | #include "xlsxglobal.h" 29 | #include 30 | #include 31 | #include 32 | 33 | class QXmlStreamReader; 34 | class QXmlStreamWriter; 35 | 36 | QT_BEGIN_NAMESPACE_XLSX 37 | 38 | class Worksheet; 39 | class CellRange; 40 | class CellReference; 41 | 42 | class DataValidationPrivate; 43 | class Q_XLSX_EXPORT DataValidation 44 | { 45 | public: 46 | enum ValidationType 47 | { 48 | None, 49 | Whole, 50 | Decimal, 51 | List, 52 | Date, 53 | Time, 54 | TextLength, 55 | Custom 56 | }; 57 | 58 | enum ValidationOperator 59 | { 60 | Between, 61 | NotBetween, 62 | Equal, 63 | NotEqual, 64 | LessThan, 65 | LessThanOrEqual, 66 | GreaterThan, 67 | GreaterThanOrEqual 68 | }; 69 | 70 | enum ErrorStyle 71 | { 72 | Stop, 73 | Warning, 74 | Information 75 | }; 76 | 77 | DataValidation(); 78 | DataValidation(ValidationType type, ValidationOperator op=Between, const QString &formula1=QString() 79 | , const QString &formula2=QString(), bool allowBlank=false); 80 | DataValidation(const DataValidation &other); 81 | ~DataValidation(); 82 | 83 | ValidationType validationType() const; 84 | ValidationOperator validationOperator() const; 85 | ErrorStyle errorStyle() const; 86 | QString formula1() const; 87 | QString formula2() const; 88 | bool allowBlank() const; 89 | QString errorMessage() const; 90 | QString errorMessageTitle() const; 91 | QString promptMessage() const; 92 | QString promptMessageTitle() const; 93 | bool isPromptMessageVisible() const; 94 | bool isErrorMessageVisible() const; 95 | QList ranges() const; 96 | 97 | void setValidationType(ValidationType type); 98 | void setValidationOperator(ValidationOperator op); 99 | void setErrorStyle(ErrorStyle es); 100 | void setFormula1(const QString &formula); 101 | void setFormula2(const QString &formula); 102 | void setErrorMessage(const QString &error, const QString &title=QString()); 103 | void setPromptMessage(const QString &prompt, const QString &title=QString()); 104 | void setAllowBlank(bool enable); 105 | void setPromptMessageVisible(bool visible); 106 | void setErrorMessageVisible(bool visible); 107 | 108 | void addCell(const CellReference &cell); 109 | void addCell(int row, int col); 110 | void addRange(int firstRow, int firstCol, int lastRow, int lastCol); 111 | void addRange(const CellRange &range); 112 | 113 | DataValidation &operator=(const DataValidation &other); 114 | 115 | bool saveToXml(QXmlStreamWriter &writer) const; 116 | static DataValidation loadFromXml(QXmlStreamReader &reader); 117 | private: 118 | QSharedDataPointer d; 119 | }; 120 | 121 | QT_END_NAMESPACE_XLSX 122 | 123 | #endif // QXLSX_XLSXDATAVALIDATION_H 124 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdatavalidation_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef XLSXDATAVALIDATION_P_H 27 | #define XLSXDATAVALIDATION_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxdatavalidation.h" 41 | #include 42 | 43 | QT_BEGIN_NAMESPACE_XLSX 44 | 45 | class Q_XLSX_EXPORT DataValidationPrivate : public QSharedData 46 | { 47 | public: 48 | DataValidationPrivate(); 49 | DataValidationPrivate(DataValidation::ValidationType type, DataValidation::ValidationOperator op, const QString &formula1, const QString &formula2, bool allowBlank); 50 | DataValidationPrivate(const DataValidationPrivate &other); 51 | ~DataValidationPrivate(); 52 | 53 | DataValidation::ValidationType validationType; 54 | DataValidation::ValidationOperator validationOperator; 55 | DataValidation::ErrorStyle errorStyle; 56 | bool allowBlank; 57 | bool isPromptMessageVisible; 58 | bool isErrorMessageVisible; 59 | QString formula1; 60 | QString formula2; 61 | QString errorMessage; 62 | QString errorMessageTitle; 63 | QString promptMessage; 64 | QString promptMessageTitle; 65 | QList ranges; 66 | }; 67 | 68 | QT_END_NAMESPACE_XLSX 69 | #endif // XLSXDATAVALIDATION_P_H 70 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdocpropsapp_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXDOCPROPSAPP_H 26 | #define XLSXDOCPROPSAPP_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxabstractooxmlfile.h" 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | class QIODevice; 47 | 48 | namespace QXlsx { 49 | 50 | class XLSX_AUTOTEST_EXPORT DocPropsApp : public AbstractOOXmlFile 51 | { 52 | public: 53 | DocPropsApp(CreateFlag flag); 54 | 55 | void addPartTitle(const QString &title); 56 | void addHeadingPair(const QString &name, int value); 57 | 58 | bool setProperty(const QString &name, const QString &value); 59 | QString property(const QString &name) const; 60 | QStringList propertyNames() const; 61 | 62 | void saveToXmlFile(QIODevice *device) const; 63 | bool loadFromXmlFile(QIODevice *device); 64 | 65 | private: 66 | QStringList m_titlesOfPartsList; 67 | QList > m_headingPairsList; 68 | QMap m_properties; 69 | }; 70 | 71 | } 72 | #endif // XLSXDOCPROPSAPP_H 73 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdocpropscore_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXDOCPROPSCORE_H 26 | #define XLSXDOCPROPSCORE_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxabstractooxmlfile.h" 41 | #include 42 | #include 43 | 44 | class QIODevice; 45 | 46 | namespace QXlsx { 47 | 48 | class XLSX_AUTOTEST_EXPORT DocPropsCore : public AbstractOOXmlFile 49 | { 50 | public: 51 | explicit DocPropsCore(CreateFlag flag); 52 | 53 | bool setProperty(const QString &name, const QString &value); 54 | QString property(const QString &name) const; 55 | QStringList propertyNames() const; 56 | 57 | void saveToXmlFile(QIODevice *device) const; 58 | bool loadFromXmlFile(QIODevice *device); 59 | 60 | private: 61 | QMap m_properties; 62 | }; 63 | 64 | } 65 | #endif // XLSXDOCPROPSCORE_H 66 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdocument_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef XLSXDOCUMENT_P_H 27 | #define XLSXDOCUMENT_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxdocument.h" 41 | #include "xlsxworkbook.h" 42 | #include "xlsxcontenttypes_p.h" 43 | 44 | #include 45 | 46 | namespace QXlsx { 47 | 48 | class DocumentPrivate 49 | { 50 | Q_DECLARE_PUBLIC(Document) 51 | public: 52 | DocumentPrivate(Document *p); 53 | void init(); 54 | 55 | bool loadPackage(QIODevice *device); 56 | bool savePackage(QIODevice *device) const; 57 | 58 | Document *q_ptr; 59 | const QString defaultPackageName; //default name when package name not specified 60 | QString packageName; //name of the .xlsx file 61 | 62 | QMap documentProperties; //core, app and custom properties 63 | QSharedPointer workbook; 64 | QSharedPointer contentTypes; 65 | }; 66 | 67 | } 68 | 69 | #endif // XLSXDOCUMENT_P_H 70 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdrawing.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include "xlsxdrawing_p.h" 27 | #include "xlsxdrawinganchor_p.h" 28 | #include "xlsxabstractsheet.h" 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace QXlsx { 35 | 36 | Drawing::Drawing(AbstractSheet *sheet, CreateFlag flag) 37 | :AbstractOOXmlFile(flag), sheet(sheet) 38 | { 39 | workbook = sheet->workbook(); 40 | } 41 | 42 | Drawing::~Drawing() 43 | { 44 | qDeleteAll(anchors); 45 | } 46 | 47 | void Drawing::saveToXmlFile(QIODevice *device) const 48 | { 49 | relationships()->clear(); 50 | 51 | QXmlStreamWriter writer(device); 52 | 53 | writer.writeStartDocument(QStringLiteral("1.0"), true); 54 | writer.writeStartElement(QStringLiteral("xdr:wsDr")); 55 | writer.writeAttribute(QStringLiteral("xmlns:xdr"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing")); 56 | writer.writeAttribute(QStringLiteral("xmlns:a"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/main")); 57 | 58 | foreach (DrawingAnchor *anchor, anchors) 59 | anchor->saveToXml(writer); 60 | 61 | writer.writeEndElement();//xdr:wsDr 62 | writer.writeEndDocument(); 63 | } 64 | 65 | bool Drawing::loadFromXmlFile(QIODevice *device) 66 | { 67 | QXmlStreamReader reader(device); 68 | while (!reader.atEnd()) { 69 | reader.readNextStartElement(); 70 | if (reader.tokenType() == QXmlStreamReader::StartElement) { 71 | if (reader.name() == QLatin1String("absoluteAnchor")) { 72 | DrawingAbsoluteAnchor * anchor = new DrawingAbsoluteAnchor(this); 73 | anchor->loadFromXml(reader); 74 | } else if (reader.name() == QLatin1String("oneCellAnchor")) { 75 | DrawingOneCellAnchor * anchor = new DrawingOneCellAnchor(this); 76 | anchor->loadFromXml(reader); 77 | } else if (reader.name() == QLatin1String("twoCellAnchor")) { 78 | DrawingTwoCellAnchor * anchor = new DrawingTwoCellAnchor(this); 79 | anchor->loadFromXml(reader); 80 | } 81 | } 82 | } 83 | 84 | return true; 85 | } 86 | 87 | } // namespace QXlsx 88 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdrawing_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_DRAWING_H 27 | #define QXLSX_DRAWING_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxrelationships_p.h" 41 | #include "xlsxabstractooxmlfile.h" 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | class QIODevice; 48 | class QXmlStreamWriter; 49 | 50 | namespace QXlsx { 51 | 52 | class DrawingAnchor; 53 | class Workbook; 54 | class AbstractSheet; 55 | class MediaFile; 56 | 57 | class Drawing : public AbstractOOXmlFile 58 | { 59 | public: 60 | Drawing(AbstractSheet *sheet, CreateFlag flag); 61 | ~Drawing(); 62 | void saveToXmlFile(QIODevice *device) const; 63 | bool loadFromXmlFile(QIODevice *device); 64 | 65 | AbstractSheet *sheet; 66 | Workbook *workbook; 67 | QList anchors; 68 | }; 69 | 70 | } // namespace QXlsx 71 | 72 | #endif // QXLSX_DRAWING_H 73 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxdrawinganchor_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_XLSXDRAWINGANCHOR_P_H 27 | #define QXLSX_XLSXDRAWINGANCHOR_P_H 28 | 29 | #include "xlsxglobal.h" 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | class QXmlStreamReader; 37 | class QXmlStreamWriter; 38 | 39 | namespace QXlsx { 40 | 41 | class Drawing; 42 | class MediaFile; 43 | class Chart; 44 | 45 | //Helper class 46 | struct XlsxMarker 47 | { 48 | XlsxMarker(){} 49 | XlsxMarker(int row, int column, int rowOffset, int colOffset) 50 | :cell(QPoint(row, column)), offset(rowOffset, colOffset) 51 | { 52 | 53 | } 54 | 55 | int row() const {return cell.x();} 56 | int col() const {return cell.y();} 57 | int rowOff() const {return offset.width();} 58 | int colOff() const {return offset.height();} 59 | 60 | QPoint cell; 61 | QSize offset; 62 | }; 63 | 64 | class DrawingAnchor 65 | { 66 | public: 67 | enum ObjectType { 68 | GraphicFrame, 69 | Shape, 70 | GroupShape, 71 | ConnectionShape, 72 | Picture, 73 | Unknown 74 | }; 75 | 76 | DrawingAnchor(Drawing *drawing, ObjectType objectType); 77 | virtual ~DrawingAnchor(); 78 | void setObjectPicture(const QImage &img); 79 | void setObjectGraphicFrame(QSharedPointer chart); 80 | 81 | virtual bool loadFromXml(QXmlStreamReader &reader) = 0; 82 | virtual void saveToXml(QXmlStreamWriter &writer) const = 0; 83 | 84 | protected: 85 | QPoint loadXmlPos(QXmlStreamReader &reader); 86 | QSize loadXmlExt(QXmlStreamReader &reader); 87 | XlsxMarker loadXmlMarker(QXmlStreamReader &reader, const QString &node); 88 | void loadXmlObject(QXmlStreamReader &reader); 89 | void loadXmlObjectShape(QXmlStreamReader &reader); 90 | void loadXmlObjectGroupShape(QXmlStreamReader &reader); 91 | void loadXmlObjectGraphicFrame(QXmlStreamReader &reader); 92 | void loadXmlObjectConnectionShape(QXmlStreamReader &reader); 93 | void loadXmlObjectPicture(QXmlStreamReader &reader); 94 | 95 | void saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const; 96 | void saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const; 97 | void saveXmlMarker(QXmlStreamWriter &writer, const XlsxMarker &marker, const QString &node) const; 98 | void saveXmlObject(QXmlStreamWriter &writer) const; 99 | void saveXmlObjectShape(QXmlStreamWriter &writer) const; 100 | void saveXmlObjectGroupShape(QXmlStreamWriter &writer) const; 101 | void saveXmlObjectGraphicFrame(QXmlStreamWriter &writer) const; 102 | void saveXmlObjectConnectionShape(QXmlStreamWriter &writer) const; 103 | void saveXmlObjectPicture(QXmlStreamWriter &writer) const; 104 | 105 | Drawing *m_drawing; 106 | ObjectType m_objectType; 107 | QSharedPointer m_pictureFile; 108 | QSharedPointer m_chartFile; 109 | 110 | int m_id; 111 | }; 112 | 113 | class DrawingAbsoluteAnchor : public DrawingAnchor 114 | { 115 | public: 116 | DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType=Unknown); 117 | 118 | QPoint pos; 119 | QSize ext; 120 | 121 | bool loadFromXml(QXmlStreamReader &reader); 122 | void saveToXml(QXmlStreamWriter &writer) const; 123 | }; 124 | 125 | class DrawingOneCellAnchor : public DrawingAnchor 126 | { 127 | public: 128 | DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType=Unknown); 129 | 130 | XlsxMarker from; 131 | QSize ext; 132 | 133 | bool loadFromXml(QXmlStreamReader &reader); 134 | void saveToXml(QXmlStreamWriter &writer) const; 135 | }; 136 | 137 | class DrawingTwoCellAnchor : public DrawingAnchor 138 | { 139 | public: 140 | DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType=Unknown); 141 | 142 | XlsxMarker from; 143 | XlsxMarker to; 144 | 145 | bool loadFromXml(QXmlStreamReader &reader); 146 | void saveToXml(QXmlStreamWriter &writer) const; 147 | }; 148 | 149 | } // namespace QXlsx 150 | 151 | #endif // QXLSX_XLSXDRAWINGANCHOR_P_H 152 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxformat_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXFORMAT_P_H 26 | #define XLSXFORMAT_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxformat.h" 40 | #include 41 | #include 42 | #include 43 | 44 | namespace QXlsx { 45 | 46 | class FormatPrivate : public QSharedData 47 | { 48 | public: 49 | enum FormatType 50 | { 51 | FT_Invalid = 0, 52 | FT_NumFmt = 0x01, 53 | FT_Font = 0x02, 54 | FT_Alignment = 0x04, 55 | FT_Border = 0x08, 56 | FT_Fill = 0x10, 57 | FT_Protection = 0x20 58 | }; 59 | 60 | enum Property { 61 | P_STARTID, 62 | 63 | //numFmt 64 | P_NumFmt_Id, 65 | P_NumFmt_FormatCode, 66 | 67 | //font 68 | P_Font_STARTID, 69 | P_Font_Size = P_Font_STARTID, 70 | P_Font_Italic, 71 | P_Font_StrikeOut, 72 | P_Font_Color, 73 | P_Font_Bold, 74 | P_Font_Script, 75 | P_Font_Underline, 76 | P_Font_Outline, 77 | P_Font_Shadow, 78 | P_Font_Name, 79 | P_Font_Family, 80 | P_Font_Charset, 81 | P_Font_Scheme, 82 | P_Font_Condense, 83 | P_Font_Extend, 84 | P_Font_ENDID, 85 | 86 | //border 87 | P_Border_STARTID, 88 | P_Border_LeftStyle = P_Border_STARTID, 89 | P_Border_RightStyle, 90 | P_Border_TopStyle, 91 | P_Border_BottomStyle, 92 | P_Border_DiagonalStyle, 93 | P_Border_LeftColor, 94 | P_Border_RightColor, 95 | P_Border_TopColor, 96 | P_Border_BottomColor, 97 | P_Border_DiagonalColor, 98 | P_Border_DiagonalType, 99 | P_Border_ENDID, 100 | 101 | //fill 102 | P_Fill_STARTID, 103 | P_Fill_Pattern = P_Fill_STARTID, 104 | P_Fill_BgColor, 105 | P_Fill_FgColor, 106 | P_Fill_ENDID, 107 | 108 | //alignment 109 | P_Alignment_STARTID, 110 | P_Alignment_AlignH = P_Alignment_STARTID, 111 | P_Alignment_AlignV, 112 | P_Alignment_Wrap, 113 | P_Alignment_Rotation, 114 | P_Alignment_Indent, 115 | P_Alignment_ShinkToFit, 116 | P_Alignment_ENDID, 117 | 118 | //protection 119 | P_Protection_Locked, 120 | P_Protection_Hidden, 121 | 122 | P_ENDID 123 | }; 124 | 125 | FormatPrivate(); 126 | FormatPrivate(const FormatPrivate &other); 127 | ~FormatPrivate(); 128 | 129 | bool dirty; //The key re-generation is need. 130 | QByteArray formatKey; 131 | 132 | bool font_dirty; 133 | bool font_index_valid; 134 | QByteArray font_key; 135 | int font_index; 136 | 137 | bool fill_dirty; 138 | bool fill_index_valid; 139 | QByteArray fill_key; 140 | int fill_index; 141 | 142 | bool border_dirty; 143 | bool border_index_valid; 144 | QByteArray border_key; 145 | int border_index; 146 | 147 | int xf_index; 148 | bool xf_indexValid; 149 | 150 | bool is_dxf_fomat; 151 | int dxf_index; 152 | bool dxf_indexValid; 153 | 154 | int theme; 155 | 156 | QMap properties; 157 | }; 158 | 159 | } 160 | 161 | #endif // XLSXFORMAT_P_H 162 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxglobal.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXGLOBAL_H 26 | #define XLSXGLOBAL_H 27 | #include 28 | 29 | #define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx { 30 | #define QT_END_NAMESPACE_XLSX } 31 | #define QTXLSX_USE_NAMESPACE using namespace QXlsx; 32 | 33 | #if !defined(QT_STATIC) && !defined(XLSX_NO_LIB) 34 | # if defined(QT_BUILD_XLSX_LIB) 35 | # define Q_XLSX_EXPORT Q_DECL_EXPORT 36 | # else 37 | # define Q_XLSX_EXPORT Q_DECL_IMPORT 38 | # endif 39 | #else 40 | # define Q_XLSX_EXPORT Q_DECL_EXPORT 41 | #endif 42 | 43 | #ifdef XLSX_TEST 44 | # define XLSX_AUTOTEST_EXPORT Q_XLSX_EXPORT 45 | #else 46 | # define XLSX_AUTOTEST_EXPORT Q_XLSX_EXPORT 47 | #endif 48 | 49 | #endif // XLSXGLOBAL_H 50 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxmediafile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include "xlsxmediafile_p.h" 27 | #include 28 | 29 | namespace QXlsx { 30 | 31 | MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType) 32 | : m_contents(bytes), m_suffix(suffix), m_mimeType(mimeType) 33 | , m_index(0), m_indexValid(false) 34 | { 35 | m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5); 36 | } 37 | 38 | MediaFile::MediaFile(const QString &fileName) 39 | :m_fileName(fileName), m_index(0), m_indexValid(false) 40 | { 41 | 42 | } 43 | 44 | void MediaFile::set(const QByteArray &bytes, const QString &suffix, const QString &mimeType) 45 | { 46 | m_contents = bytes; 47 | m_suffix = suffix; 48 | m_mimeType = mimeType; 49 | m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5); 50 | m_indexValid = false; 51 | } 52 | 53 | void MediaFile::setFileName(const QString &name) 54 | { 55 | m_fileName = name; 56 | } 57 | 58 | QString MediaFile::fileName() const 59 | { 60 | return m_fileName; 61 | } 62 | 63 | QString MediaFile::suffix() const 64 | { 65 | return m_suffix; 66 | } 67 | 68 | QString MediaFile::mimeType() const 69 | { 70 | return m_mimeType; 71 | } 72 | 73 | QByteArray MediaFile::contents() const 74 | { 75 | return m_contents; 76 | } 77 | 78 | int MediaFile::index() const 79 | { 80 | return m_index; 81 | } 82 | 83 | bool MediaFile::isIndexValid() const 84 | { 85 | return m_indexValid; 86 | } 87 | 88 | void MediaFile::setIndex(int idx) 89 | { 90 | m_index = idx; 91 | m_indexValid = true; 92 | } 93 | 94 | QByteArray MediaFile::hashKey() const 95 | { 96 | return m_hashKey; 97 | } 98 | 99 | } // namespace QXlsx 100 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxmediafile_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_XLSXMEDIAFILE_H 27 | #define QXLSX_XLSXMEDIAFILE_H 28 | 29 | 30 | // 31 | // W A R N I N G 32 | // ------------- 33 | // 34 | // This file is not part of the Qt Xlsx API. It exists for the convenience 35 | // of the Qt Xlsx. This header file may change from 36 | // version to version without notice, or even be removed. 37 | // 38 | // We mean it. 39 | // 40 | 41 | #include "xlsxglobal.h" 42 | 43 | #include 44 | #include 45 | 46 | namespace QXlsx { 47 | 48 | class MediaFile 49 | { 50 | public: 51 | MediaFile(const QString &fileName); 52 | MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString()); 53 | 54 | void set(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString()); 55 | QString suffix() const; 56 | QString mimeType() const; 57 | QByteArray contents() const; 58 | 59 | bool isIndexValid() const; 60 | int index() const; 61 | void setIndex(int idx); 62 | QByteArray hashKey() const; 63 | 64 | void setFileName(const QString &name); 65 | QString fileName() const; 66 | 67 | private: 68 | QString m_fileName; //... 69 | QByteArray m_contents; 70 | QString m_suffix; 71 | QString m_mimeType; 72 | 73 | int m_index; 74 | bool m_indexValid; 75 | QByteArray m_hashKey; 76 | }; 77 | 78 | } // namespace QXlsx 79 | 80 | #endif // QXLSX_XLSXMEDIAFILE_H 81 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxnumformatparser.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxnumformatparser_p.h" 26 | 27 | #include 28 | 29 | namespace QXlsx { 30 | 31 | bool NumFormatParser::isDateTime(const QString &formatCode) 32 | { 33 | for (int i = 0; i < formatCode.length(); ++i) { 34 | const QChar &c = formatCode[i]; 35 | 36 | switch (c.unicode()) { 37 | case '[': 38 | // [h], [m], [s] are valid format for time 39 | if (i < formatCode.length()-2 && formatCode[i+2] == QLatin1Char(']')) { 40 | const QChar cc = formatCode[i+1].toLower(); 41 | if (cc == QLatin1Char('h') || cc == QLatin1Char('m') || cc == QLatin1Char('s')) 42 | return true; 43 | i+=2; 44 | break; 45 | } else { 46 | // condition or color: don't care, ignore 47 | while (i < formatCode.length() && formatCode[i] != QLatin1Char(']')) 48 | ++i; 49 | break; 50 | } 51 | 52 | // quoted plain text block: don't care, ignore 53 | case '"': 54 | while (i < formatCode.length()-1 && formatCode[++i] != QLatin1Char('"')) 55 | ; 56 | break; 57 | 58 | // escaped char: don't care, ignore 59 | case '\\': 60 | if (i < formatCode.length() - 1) 61 | ++i; 62 | break; 63 | 64 | // date/time can only be positive number, 65 | // so only the first section of the format make sense. 66 | case ';': 67 | return false; 68 | break; 69 | 70 | // days 71 | case 'D': 72 | case 'd': 73 | // years 74 | case 'Y': 75 | case 'y': 76 | // hours 77 | case 'H': 78 | case 'h': 79 | // seconds 80 | case 'S': 81 | case 's': 82 | // minutes or months, depending on context 83 | case 'M': 84 | case 'm': 85 | return true; 86 | 87 | default: 88 | break; 89 | } 90 | } 91 | return false; 92 | } 93 | 94 | } // namespace QXlsx 95 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxnumformatparser_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_NUMFORMATPARSER_H 26 | #define QXLSX_NUMFORMATPARSER_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | 41 | namespace QXlsx { 42 | 43 | class NumFormatParser 44 | { 45 | public: 46 | static bool isDateTime(const QString &formatCode); 47 | }; 48 | 49 | } // namespace QXlsx 50 | 51 | #endif // QXLSX_NUMFORMATPARSER_H 52 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxrelationships_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXRELATIONSHIPS_H 26 | #define XLSXRELATIONSHIPS_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include 41 | #include 42 | class QIODevice; 43 | 44 | namespace QXlsx { 45 | 46 | struct XlsxRelationship 47 | { 48 | QString id; 49 | QString type; 50 | QString target; 51 | QString targetMode; 52 | }; 53 | 54 | class XLSX_AUTOTEST_EXPORT Relationships 55 | { 56 | public: 57 | Relationships(); 58 | 59 | QList documentRelationships(const QString &relativeType) const; 60 | QList packageRelationships(const QString &relativeType) const; 61 | QList msPackageRelationships(const QString &relativeType) const; 62 | QList worksheetRelationships(const QString &relativeType) const; 63 | 64 | void addDocumentRelationship(const QString &relativeType, const QString &target); 65 | void addPackageRelationship(const QString &relativeType, const QString &target); 66 | void addMsPackageRelationship(const QString &relativeType, const QString &target); 67 | void addWorksheetRelationship(const QString &relativeType, const QString &target, const QString &targetMode=QString()); 68 | 69 | void saveToXmlFile(QIODevice *device) const; 70 | QByteArray saveToXmlData() const; 71 | bool loadFromXmlFile(QIODevice *device); 72 | bool loadFromXmlData(const QByteArray &data); 73 | XlsxRelationship getRelationshipById(const QString &id) const; 74 | 75 | void clear(); 76 | int count() const; 77 | bool isEmpty() const; 78 | 79 | private: 80 | QList relationships(const QString &type) const; 81 | void addRelationship(const QString &type, const QString &target, const QString &targetMode=QString()); 82 | 83 | QList m_relationships; 84 | }; 85 | 86 | } 87 | #endif // XLSXRELATIONSHIPS_H 88 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxrichstring.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXRICHSTRING_H 26 | #define XLSXRICHSTRING_H 27 | 28 | #include "xlsxglobal.h" 29 | #include "xlsxformat.h" 30 | #include 31 | #include 32 | #include 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | class RichStringPrivate; 36 | class RichString; 37 | // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) 38 | Q_XLSX_EXPORT uint qHash(const RichString &rs, uint seed = 0) Q_DECL_NOTHROW; 39 | 40 | class Q_XLSX_EXPORT RichString 41 | { 42 | public: 43 | RichString(); 44 | explicit RichString(const QString text); 45 | RichString(const RichString &other); 46 | ~RichString(); 47 | 48 | bool isRichString() const; 49 | bool isNull() const; 50 | bool isEmtpy() const; 51 | QString toPlainString() const; 52 | QString toHtml() const; 53 | void setHtml(const QString &text); 54 | 55 | int fragmentCount() const; 56 | void addFragment(const QString &text, const Format &format); 57 | QString fragmentText(int index) const; 58 | Format fragmentFormat(int index) const; 59 | 60 | operator QVariant() const; 61 | 62 | RichString &operator=(const RichString &other); 63 | private: 64 | friend Q_XLSX_EXPORT uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW; 65 | friend Q_XLSX_EXPORT bool operator==(const RichString &rs1, const RichString &rs2); 66 | friend Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const RichString &rs2); 67 | friend Q_XLSX_EXPORT bool operator<(const RichString &rs1, const RichString &rs2); 68 | friend Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const RichString &rs); 69 | 70 | QSharedDataPointer d; 71 | }; 72 | 73 | Q_XLSX_EXPORT bool operator==(const RichString &rs1, const RichString &rs2); 74 | Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const RichString &rs2); 75 | Q_XLSX_EXPORT bool operator<(const RichString &rs1, const RichString &rs2); 76 | Q_XLSX_EXPORT bool operator==(const RichString &rs1, const QString &rs2); 77 | Q_XLSX_EXPORT bool operator==(const QString &rs1, const RichString &rs2); 78 | Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const QString &rs2); 79 | Q_XLSX_EXPORT bool operator!=(const QString &rs1, const RichString &rs2); 80 | 81 | #ifndef QT_NO_DEBUG_STREAM 82 | Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const RichString &rs); 83 | #endif 84 | 85 | QT_END_NAMESPACE_XLSX 86 | 87 | Q_DECLARE_METATYPE(QXlsx::RichString) 88 | 89 | #endif // XLSXRICHSTRING_H 90 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxrichstring_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXRICHSTRING_P_H 26 | #define XLSXRICHSTRING_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxrichstring.h" 40 | 41 | QT_BEGIN_NAMESPACE_XLSX 42 | 43 | class RichStringPrivate : public QSharedData 44 | { 45 | public: 46 | RichStringPrivate(); 47 | RichStringPrivate(const RichStringPrivate &other); 48 | ~RichStringPrivate(); 49 | 50 | QByteArray idKey() const; 51 | 52 | QStringList fragmentTexts; 53 | QList fragmentFormats; 54 | QByteArray _idKey; 55 | bool _dirty; 56 | }; 57 | 58 | QT_END_NAMESPACE_XLSX 59 | 60 | #endif // XLSXRICHSTRING_P_H 61 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxsharedstrings_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXSHAREDSTRINGS_H 26 | #define XLSXSHAREDSTRINGS_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxrichstring.h" 41 | #include "xlsxabstractooxmlfile.h" 42 | #include 43 | #include 44 | #include 45 | 46 | class QIODevice; 47 | class QXmlStreamReader; 48 | class QXmlStreamWriter; 49 | 50 | namespace QXlsx { 51 | 52 | class XlsxSharedStringInfo 53 | { 54 | public: 55 | XlsxSharedStringInfo(int index=0, int count = 1) : 56 | index(index), count(count) 57 | { 58 | } 59 | 60 | int index; 61 | int count; 62 | }; 63 | 64 | class XLSX_AUTOTEST_EXPORT SharedStrings : public AbstractOOXmlFile 65 | { 66 | public: 67 | SharedStrings(CreateFlag flag); 68 | int count() const; 69 | bool isEmpty() const; 70 | 71 | int addSharedString(const QString &string); 72 | int addSharedString(const RichString &string); 73 | void removeSharedString(const QString &string); 74 | void removeSharedString(const RichString &string); 75 | void incRefByStringIndex(int idx); 76 | 77 | int getSharedStringIndex(const QString &string) const; 78 | int getSharedStringIndex(const RichString &string) const; 79 | RichString getSharedString(int index) const; 80 | QList getSharedStrings() const; 81 | 82 | void saveToXmlFile(QIODevice *device) const; 83 | bool loadFromXmlFile(QIODevice *device); 84 | 85 | private: 86 | void readString(QXmlStreamReader &reader); // 87 | void readRichStringPart(QXmlStreamReader &reader, RichString &rich); // 88 | void readPlainStringPart(QXmlStreamReader &reader, RichString &rich); // 89 | Format readRichStringPart_rPr(QXmlStreamReader &reader); 90 | void writeRichStringPart_rPr(QXmlStreamWriter &writer, const Format &format) const; 91 | 92 | QHash m_stringTable; //for fast lookup 93 | QList m_stringList; 94 | int m_stringCount; 95 | }; 96 | 97 | } 98 | #endif // XLSXSHAREDSTRINGS_H 99 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxsimpleooxmlfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxsimpleooxmlfile_p.h" 26 | #include 27 | 28 | namespace QXlsx { 29 | SimpleOOXmlFile::SimpleOOXmlFile(CreateFlag flag) 30 | :AbstractOOXmlFile(flag) 31 | { 32 | } 33 | 34 | void SimpleOOXmlFile::saveToXmlFile(QIODevice *device) const 35 | { 36 | device->write(xmlData); 37 | } 38 | 39 | QByteArray SimpleOOXmlFile::saveToXmlData() const 40 | { 41 | return xmlData; 42 | } 43 | 44 | bool SimpleOOXmlFile::loadFromXmlData(const QByteArray &data) 45 | { 46 | xmlData = data; 47 | return true; 48 | } 49 | 50 | bool SimpleOOXmlFile::loadFromXmlFile(QIODevice *device) 51 | { 52 | xmlData = device->readAll(); 53 | return true; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxsimpleooxmlfile_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXSIMPLEOOXMLFILE_H 26 | #define XLSXSIMPLEOOXMLFILE_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | #include "xlsxabstractooxmlfile.h" 39 | 40 | #include 41 | class QIODevice; 42 | 43 | namespace QXlsx { 44 | 45 | class SimpleOOXmlFile : public AbstractOOXmlFile 46 | { 47 | public: 48 | SimpleOOXmlFile(CreateFlag flag); 49 | 50 | void saveToXmlFile(QIODevice *device) const; 51 | QByteArray saveToXmlData() const; 52 | bool loadFromXmlData(const QByteArray &data); 53 | bool loadFromXmlFile(QIODevice *device); 54 | 55 | QByteArray xmlData; 56 | }; 57 | 58 | } 59 | #endif // XLSXSIMPLEOOXMLFILE_H 60 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxstyles_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXSTYLES_H 26 | #define XLSXSTYLES_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxformat.h" 41 | #include "xlsxabstractooxmlfile.h" 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | class QXmlStreamWriter; 50 | class QXmlStreamReader; 51 | class QIODevice; 52 | class StylesTest; 53 | 54 | namespace QXlsx { 55 | 56 | class Format; 57 | class XlsxColor; 58 | 59 | struct XlsxFormatNumberData 60 | { 61 | XlsxFormatNumberData() : formatIndex(0) {} 62 | 63 | int formatIndex; 64 | QString formatString; 65 | }; 66 | 67 | class XLSX_AUTOTEST_EXPORT Styles : public AbstractOOXmlFile 68 | { 69 | public: 70 | Styles(CreateFlag flag); 71 | ~Styles(); 72 | void addXfFormat(const Format &format, bool force=false); 73 | Format xfFormat(int idx) const; 74 | void addDxfFormat(const Format &format, bool force=false); 75 | Format dxfFormat(int idx) const; 76 | 77 | void saveToXmlFile(QIODevice *device) const; 78 | bool loadFromXmlFile(QIODevice *device); 79 | 80 | QColor getColorByIndex(int idx); 81 | 82 | private: 83 | friend class Format; 84 | friend class ::StylesTest; 85 | 86 | void fixNumFmt(const Format &format); 87 | 88 | void writeNumFmts(QXmlStreamWriter &writer) const; 89 | void writeFonts(QXmlStreamWriter &writer) const; 90 | void writeFont(QXmlStreamWriter &writer, const Format &font, bool isDxf = false) const; 91 | void writeFills(QXmlStreamWriter &writer) const; 92 | void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false) const; 93 | void writeBorders(QXmlStreamWriter &writer) const; 94 | void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false) const; 95 | void writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) const; 96 | void writeCellXfs(QXmlStreamWriter &writer) const; 97 | void writeDxfs(QXmlStreamWriter &writer) const; 98 | void writeDxf(QXmlStreamWriter &writer, const Format &format) const; 99 | void writeColors(QXmlStreamWriter &writer) const; 100 | 101 | bool readNumFmts(QXmlStreamReader &reader); 102 | bool readFonts(QXmlStreamReader &reader); 103 | bool readFont(QXmlStreamReader &reader, Format &format); 104 | bool readFills(QXmlStreamReader &reader); 105 | bool readFill(QXmlStreamReader &reader, Format &format); 106 | bool readBorders(QXmlStreamReader &reader); 107 | bool readBorder(QXmlStreamReader &reader, Format &format); 108 | bool readSubBorder(QXmlStreamReader &reader, const QString &name, Format::BorderStyle &style, XlsxColor &color); 109 | bool readCellXfs(QXmlStreamReader &reader); 110 | bool readDxfs(QXmlStreamReader &reader); 111 | bool readDxf(QXmlStreamReader &reader); 112 | bool readColors(QXmlStreamReader &reader); 113 | bool readIndexedColors(QXmlStreamReader &reader); 114 | 115 | QHash m_builtinNumFmtsHash; 116 | QMap > m_customNumFmtIdMap; 117 | QHash > m_customNumFmtsHash; 118 | int m_nextCustomNumFmtId; 119 | QList m_fontsList; 120 | QList m_fillsList; 121 | QList m_bordersList; 122 | QHash m_fontsHash; 123 | QHash m_fillsHash; 124 | QHash m_bordersHash; 125 | 126 | QVector m_indexedColors; 127 | bool m_isIndexedColorsDefault; 128 | 129 | QList m_xf_formatsList; 130 | QHash m_xf_formatsHash; 131 | 132 | QList m_dxf_formatsList; 133 | QHash m_dxf_formatsHash; 134 | 135 | bool m_emptyFormatAdded; 136 | }; 137 | 138 | } 139 | #endif // XLSXSTYLES_H 140 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxtheme_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXTHEME_H 26 | #define XLSXTHEME_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | #include "xlsxabstractooxmlfile.h" 39 | 40 | #include 41 | class QIODevice; 42 | 43 | namespace QXlsx { 44 | 45 | class Theme : public AbstractOOXmlFile 46 | { 47 | public: 48 | Theme(CreateFlag flag); 49 | 50 | void saveToXmlFile(QIODevice *device) const; 51 | QByteArray saveToXmlData() const; 52 | bool loadFromXmlData(const QByteArray &data); 53 | bool loadFromXmlFile(QIODevice *device); 54 | 55 | QByteArray xmlData; 56 | }; 57 | 58 | } 59 | #endif // XLSXTHEME_H 60 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxutility_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXUTILITY_H 26 | #define XLSXUTILITY_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | class QPoint; 41 | class QString; 42 | class QStringList; 43 | class QColor; 44 | class QDateTime; 45 | class QTime; 46 | 47 | namespace QXlsx { 48 | class CellReference; 49 | 50 | XLSX_AUTOTEST_EXPORT bool parseXsdBoolean(const QString &value, bool defaultValue=false); 51 | 52 | XLSX_AUTOTEST_EXPORT QStringList splitPath(const QString &path); 53 | XLSX_AUTOTEST_EXPORT QString getRelFilePath(const QString &filePath); 54 | 55 | XLSX_AUTOTEST_EXPORT double datetimeToNumber(const QDateTime &dt, bool is1904=false); 56 | XLSX_AUTOTEST_EXPORT QDateTime datetimeFromNumber(double num, bool is1904=false); 57 | XLSX_AUTOTEST_EXPORT double timeToNumber(const QTime &t); 58 | 59 | XLSX_AUTOTEST_EXPORT QString createSafeSheetName(const QString &nameProposal); 60 | XLSX_AUTOTEST_EXPORT bool isSpaceReserveNeeded(const QString &string); 61 | 62 | XLSX_AUTOTEST_EXPORT QString convertSharedFormula(const QString &rootFormula, const CellReference &rootCell, const CellReference &cell); 63 | 64 | } //QXlsx 65 | #endif // XLSXUTILITY_H 66 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxworkbook.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXWORKBOOK_H 26 | #define XLSXWORKBOOK_H 27 | 28 | #include "xlsxglobal.h" 29 | #include "xlsxabstractooxmlfile.h" 30 | #include "xlsxabstractsheet.h" 31 | #include 32 | #include 33 | #include 34 | 35 | class QIODevice; 36 | 37 | QT_BEGIN_NAMESPACE_XLSX 38 | 39 | class SharedStrings; 40 | class Styles; 41 | class Drawing; 42 | class Document; 43 | class Theme; 44 | class Relationships; 45 | class DocumentPrivate; 46 | class MediaFile; 47 | class Chart; 48 | class Chartsheet; 49 | class Worksheet; 50 | 51 | class WorkbookPrivate; 52 | class Q_XLSX_EXPORT Workbook : public AbstractOOXmlFile 53 | { 54 | Q_DECLARE_PRIVATE(Workbook) 55 | public: 56 | ~Workbook(); 57 | 58 | int sheetCount() const; 59 | AbstractSheet *sheet(int index) const; 60 | 61 | AbstractSheet *addSheet(const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet); 62 | AbstractSheet *insertSheet(int index, const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet); 63 | bool renameSheet(int index, const QString &name); 64 | bool deleteSheet(int index); 65 | bool copySheet(int index, const QString &newName=QString()); 66 | bool moveSheet(int srcIndex, int distIndex); 67 | 68 | AbstractSheet *activeSheet() const; 69 | bool setActiveSheet(int index); 70 | 71 | // void addChart(); 72 | bool defineName(const QString &name, const QString &formula, const QString &comment=QString(), const QString &scope=QString()); 73 | bool isDate1904() const; 74 | void setDate1904(bool date1904); 75 | bool isStringsToNumbersEnabled() const; 76 | void setStringsToNumbersEnabled(bool enable=true); 77 | bool isStringsToHyperlinksEnabled() const; 78 | void setStringsToHyperlinksEnabled(bool enable=true); 79 | bool isHtmlToRichStringEnabled() const; 80 | void setHtmlToRichStringEnabled(bool enable=true); 81 | QString defaultDateFormat() const; 82 | void setDefaultDateFormat(const QString &format); 83 | 84 | //internal used member 85 | void addMediaFile(QSharedPointer media, bool force=false); 86 | QList > mediaFiles() const; 87 | void addChartFile(QSharedPointer chartFile); 88 | QList > chartFiles() const; 89 | 90 | private: 91 | friend class Worksheet; 92 | friend class Chartsheet; 93 | friend class WorksheetPrivate; 94 | friend class Document; 95 | friend class DocumentPrivate; 96 | 97 | Workbook(Workbook::CreateFlag flag); 98 | 99 | void saveToXmlFile(QIODevice *device) const; 100 | bool loadFromXmlFile(QIODevice *device); 101 | 102 | SharedStrings *sharedStrings() const; 103 | Styles *styles(); 104 | Theme *theme(); 105 | QList images(); 106 | QList drawings(); 107 | QList > getSheetsByTypes(AbstractSheet::SheetType type) const; 108 | QStringList worksheetNames() const; 109 | AbstractSheet *addSheet(const QString &name, int sheetId, AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet); 110 | }; 111 | 112 | QT_END_NAMESPACE_XLSX 113 | 114 | #endif // XLSXWORKBOOK_H 115 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxworkbook_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef XLSXWORKBOOK_P_H 26 | #define XLSXWORKBOOK_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxworkbook.h" 40 | #include "xlsxabstractooxmlfile_p.h" 41 | #include "xlsxtheme_p.h" 42 | #include "xlsxsimpleooxmlfile_p.h" 43 | #include "xlsxrelationships_p.h" 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | namespace QXlsx { 50 | 51 | struct XlsxDefineNameData 52 | { 53 | XlsxDefineNameData() 54 | :sheetId(-1) 55 | {} 56 | XlsxDefineNameData(const QString &name, const QString &formula, const QString &comment, int sheetId=-1) 57 | :name(name), formula(formula), comment(comment), sheetId(sheetId) 58 | { 59 | 60 | } 61 | QString name; 62 | QString formula; 63 | QString comment; 64 | //using internal sheetId, instead of the localSheetId(order in the workbook) 65 | int sheetId; 66 | }; 67 | 68 | class WorkbookPrivate : public AbstractOOXmlFilePrivate 69 | { 70 | Q_DECLARE_PUBLIC(Workbook) 71 | public: 72 | WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag); 73 | 74 | QSharedPointer sharedStrings; 75 | QList > sheets; 76 | QList > externalLinks; 77 | QStringList sheetNames; 78 | QSharedPointer styles; 79 | QSharedPointer theme; 80 | QList > mediaFiles; 81 | QList > chartFiles; 82 | QList definedNamesList; 83 | 84 | bool strings_to_numbers_enabled; 85 | bool strings_to_hyperlinks_enabled; 86 | bool html_to_richstring_enabled; 87 | bool date1904; 88 | QString defaultDateFormat; 89 | 90 | int x_window; 91 | int y_window; 92 | int window_width; 93 | int window_height; 94 | 95 | int activesheetIndex; 96 | int firstsheet; 97 | int table_count; 98 | 99 | //Used to generate new sheet name and id 100 | int last_worksheet_index; 101 | int last_chartsheet_index; 102 | int last_sheet_id; 103 | }; 104 | 105 | } 106 | 107 | #endif // XLSXWORKBOOK_P_H 108 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxzipreader.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include "xlsxzipreader_p.h" 27 | 28 | #include 29 | 30 | #include 31 | 32 | namespace QXlsx { 33 | 34 | ZipReader::ZipReader(const QString &filePath) : 35 | m_reader(new QZipReader(filePath)) 36 | { 37 | init(); 38 | } 39 | 40 | ZipReader::ZipReader(QIODevice *device) : 41 | m_reader(new QZipReader(device)) 42 | { 43 | init(); 44 | } 45 | 46 | ZipReader::~ZipReader() 47 | { 48 | 49 | } 50 | 51 | void ZipReader::init() 52 | { 53 | QVector allFiles = m_reader->fileInfoList(); 54 | foreach (const QZipReader::FileInfo &fi, allFiles) { 55 | if (fi.isFile) 56 | m_filePaths.append(fi.filePath); 57 | } 58 | } 59 | 60 | bool ZipReader::exists() const 61 | { 62 | return m_reader->exists(); 63 | } 64 | 65 | QStringList ZipReader::filePaths() const 66 | { 67 | return m_filePaths; 68 | } 69 | 70 | QByteArray ZipReader::fileData(const QString &fileName) const 71 | { 72 | return m_reader->fileData(fileName); 73 | } 74 | 75 | } // namespace QXlsx 76 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxzipreader_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXLSX_XLSXZIPREADER_P_H 27 | #define QXLSX_XLSXZIPREADER_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxglobal.h" 41 | #include 42 | #include 43 | class QZipReader; 44 | class QIODevice; 45 | 46 | namespace QXlsx { 47 | 48 | class XLSX_AUTOTEST_EXPORT ZipReader 49 | { 50 | public: 51 | explicit ZipReader(const QString &fileName); 52 | explicit ZipReader(QIODevice *device); 53 | ~ZipReader(); 54 | bool exists() const; 55 | QStringList filePaths() const; 56 | QByteArray fileData(const QString &fileName) const; 57 | 58 | private: 59 | Q_DISABLE_COPY(ZipReader) 60 | void init(); 61 | QScopedPointer m_reader; 62 | QStringList m_filePaths; 63 | }; 64 | 65 | } // namespace QXlsx 66 | 67 | #endif // QXLSX_XLSXZIPREADER_P_H 68 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxzipwriter.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #include "xlsxzipwriter_p.h" 26 | #include 27 | #include 28 | 29 | namespace QXlsx { 30 | 31 | ZipWriter::ZipWriter(const QString &filePath) 32 | { 33 | m_writer = new QZipWriter(filePath, QIODevice::WriteOnly); 34 | m_writer->setCompressionPolicy(QZipWriter::AutoCompress); 35 | } 36 | 37 | ZipWriter::ZipWriter(QIODevice *device) 38 | { 39 | m_writer = new QZipWriter(device); 40 | m_writer->setCompressionPolicy(QZipWriter::AutoCompress); 41 | } 42 | 43 | ZipWriter::~ZipWriter() 44 | { 45 | delete m_writer; 46 | } 47 | 48 | bool ZipWriter::error() const 49 | { 50 | return m_writer->status() != QZipWriter::NoError; 51 | } 52 | 53 | void ZipWriter::addFile(const QString &filePath, QIODevice *device) 54 | { 55 | m_writer->addFile(filePath, device); 56 | } 57 | 58 | void ZipWriter::addFile(const QString &filePath, const QByteArray &data) 59 | { 60 | m_writer->addFile(filePath, data); 61 | } 62 | 63 | void ZipWriter::close() 64 | { 65 | m_writer->close(); 66 | } 67 | 68 | } // namespace QXlsx 69 | -------------------------------------------------------------------------------- /Libraries/LibXlsxRW/xlsx/xlsxzipwriter_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 3 | ** All right reserved. 4 | ** 5 | ** Permission is hereby granted, free of charge, to any person obtaining 6 | ** a copy of this software and associated documentation files (the 7 | ** "Software"), to deal in the Software without restriction, including 8 | ** without limitation the rights to use, copy, modify, merge, publish, 9 | ** distribute, sublicense, and/or sell copies of the Software, and to 10 | ** permit persons to whom the Software is furnished to do so, subject to 11 | ** the following conditions: 12 | ** 13 | ** The above copyright notice and this permission notice shall be 14 | ** included in all copies or substantial portions of the Software. 15 | ** 16 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXLSX_ZIPWRITER_H 26 | #define QXLSX_ZIPWRITER_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include 40 | class QIODevice; 41 | class QZipWriter; 42 | 43 | namespace QXlsx { 44 | 45 | class ZipWriter 46 | { 47 | public: 48 | explicit ZipWriter(const QString &filePath); 49 | explicit ZipWriter(QIODevice *device); 50 | ~ZipWriter(); 51 | 52 | void addFile(const QString &filePath, QIODevice *device); 53 | void addFile(const QString &filePath, const QByteArray &data); 54 | bool error() const; 55 | void close(); 56 | 57 | private: 58 | QZipWriter *m_writer; 59 | }; 60 | 61 | } // namespace QXlsx 62 | 63 | #endif // QXLSX_ZIPWRITER_H 64 | -------------------------------------------------------------------------------- /Libraries/Libraries.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | LibXlsxRW \ 5 | 6 | CONFIG += ordered 7 | -------------------------------------------------------------------------------- /MainApps/MainApps.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | TSFileEditor 5 | 6 | CONFIG += ordered 7 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/DataModel/TranslateModel.cpp: -------------------------------------------------------------------------------- 1 | #include "TranslateModel.h" 2 | 3 | TranslateModel::TranslateModel() 4 | { 5 | 6 | } 7 | 8 | TranslateModel::TranslateModel(const TranslateModel &other) 9 | { 10 | this->m_key = other.GetKey(); 11 | this->m_source = other.GetSource(); 12 | this->m_translate = other.GetTranslate(); 13 | } 14 | 15 | TranslateModel &TranslateModel::operator=(const TranslateModel &other) 16 | { 17 | if(&other != this){ 18 | this->m_key = other.GetKey(); 19 | this->m_source = other.GetSource(); 20 | this->m_translate = other.GetTranslate(); 21 | } 22 | 23 | return *this; 24 | } 25 | 26 | TranslateModel::~TranslateModel() 27 | { 28 | 29 | } 30 | 31 | //****************************Getter && Setter************************************* 32 | QString TranslateModel::GetKey() const 33 | { 34 | return m_key; 35 | } 36 | 37 | QString TranslateModel::GetSource() const 38 | { 39 | return m_source; 40 | } 41 | 42 | QString TranslateModel::GetTranslate() const 43 | { 44 | return m_translate; 45 | } 46 | 47 | void TranslateModel::SetKey(const QString &str) 48 | { 49 | m_key = str; 50 | } 51 | 52 | void TranslateModel::SetSource(const QString &str) 53 | { 54 | m_source = str; 55 | } 56 | 57 | void TranslateModel::SetTranslate(const QString &str) 58 | { 59 | m_translate = str; 60 | } 61 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/DataModel/TranslateModel.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSLATEMODEL_H 2 | #define TRANSLATEMODEL_H 3 | 4 | #include 5 | 6 | class TranslateModel 7 | { 8 | public: 9 | explicit TranslateModel(); 10 | TranslateModel(const TranslateModel&); 11 | TranslateModel &operator= (const TranslateModel&); 12 | ~TranslateModel(); 13 | 14 | QString GetKey() const; 15 | QString GetSource() const; 16 | QString GetTranslate() const; 17 | 18 | void SetKey(const QString &str); 19 | void SetSource(const QString &str); 20 | void SetTranslate(const QString &str); 21 | 22 | private: 23 | QString m_key; 24 | QString m_source; 25 | QString m_translate; 26 | }; 27 | 28 | #endif // TRANSLATEMODEL_H 29 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/ExcelRW.cpp: -------------------------------------------------------------------------------- 1 | #include "ExcelRW.h" 2 | #include 3 | #include 4 | 5 | ExcelRW::ExcelRW(int keyColumn, int sourceColumn, int transColumn, QObject *parent) : QObject(parent) 6 | { 7 | m_TotalCount = 0; 8 | m_KeyColumn = keyColumn; 9 | m_SourceColumn = sourceColumn; 10 | m_TransColumn = transColumn; 11 | } 12 | 13 | bool ExcelRW::ImportFromXlsx(QList &list, QString strPath) 14 | { 15 | bool bSuccess = true; 16 | // int nErrLine = 1; 17 | list.clear(); 18 | 19 | QString strKey, strSource, strTranslate; 20 | QXlsx::CellRange cellRange; 21 | 22 | QXlsx::Document* m_pDoc = new QXlsx::Document(strPath); 23 | if(nullptr == m_pDoc) 24 | { 25 | return bSuccess; 26 | } 27 | if(m_pDoc->sheetNames().isEmpty()) 28 | { 29 | return bSuccess; 30 | } 31 | m_pDoc->selectSheet(m_pDoc->sheetNames().first()); 32 | cellRange = m_pDoc->currentWorksheet()->dimension(); 33 | 34 | do 35 | { 36 | if(1 == cellRange.lastRow() && (nullptr == m_pDoc->cellAt(cellRange.lastRow(), cellRange.lastColumn()))) 37 | { 38 | bSuccess = true; 39 | break; 40 | } 41 | 42 | for(int i = 2; i<=cellRange.lastRow(); i++) 43 | { 44 | m_TotalCount++; 45 | 46 | if(m_pDoc->cellAt(i, m_KeyColumn) == nullptr) 47 | { 48 | strKey = ""; 49 | }else 50 | { 51 | strKey = m_pDoc->cellAt(i, m_KeyColumn)->value().toString(); 52 | } 53 | 54 | if(m_pDoc->cellAt(i, m_SourceColumn) == nullptr) 55 | { 56 | strSource = ""; 57 | }else 58 | { 59 | strSource = m_pDoc->cellAt(i, m_SourceColumn)->value().toString(); 60 | } 61 | 62 | if(m_pDoc->cellAt(i, m_TransColumn) == nullptr) 63 | { 64 | strTranslate = ""; 65 | }else 66 | { 67 | strTranslate = m_pDoc->cellAt(i, m_TransColumn)->value().toString(); 68 | } 69 | 70 | // nErrLine = i; 71 | 72 | // if(strSite.isEmpty()) 73 | // { 74 | // addError(EXCEL_EMPTY_ERROR, nErrLine); 75 | // bSuccess = false; 76 | // continue; 77 | // } 78 | 79 | 80 | TranslateModel model; 81 | model.SetKey(strKey); 82 | model.SetSource(strSource); 83 | model.SetTranslate(strTranslate); 84 | list.append(model); 85 | } 86 | }while(0); 87 | 88 | delete m_pDoc; 89 | return bSuccess; 90 | } 91 | 92 | bool ExcelRW::ExportToXlsx(QList& list, QString strPath) 93 | { 94 | if(strPath.isEmpty()) { 95 | emit error("Export path cannot be empty"); 96 | return false; 97 | } 98 | 99 | if (list.count() <= 0) 100 | { 101 | emit error("*.ts file is empty"); 102 | return false; 103 | } 104 | 105 | QString strHeaderkey = tr("Key"); 106 | QString strHeaderSource = tr("Source"); 107 | QString strHeaderTranslate = tr("Translate"); 108 | 109 | QXlsx::Document xlsx; 110 | xlsx.addSheet("Sheet1"); 111 | xlsx.write(1, m_KeyColumn, QVariant(strHeaderkey)); 112 | xlsx.write(1, m_SourceColumn, QVariant(strHeaderSource)); 113 | xlsx.write(1, m_TransColumn, QVariant(strHeaderTranslate)); 114 | 115 | for(int i=0; i < list.count(); i++) 116 | { 117 | for(int j=1; j<=3; j++){ 118 | xlsx.write(i+2, m_KeyColumn, QVariant(list[i].GetKey())); 119 | xlsx.write(i+2, m_SourceColumn, QVariant(list[i].GetSource())); 120 | xlsx.write(i+2, m_TransColumn, QVariant(list[i].GetTranslate())); 121 | } 122 | } 123 | 124 | xlsx.saveAs(strPath); 125 | 126 | return true; 127 | } 128 | 129 | void ExcelRW::SetTransColumn(int column) 130 | { 131 | m_TransColumn = column; 132 | } 133 | 134 | bool ExcelRW::checkAccountName(QString string) 135 | { 136 | if(string.isEmpty()) 137 | { 138 | return false; 139 | } 140 | 141 | QRegExp regp("^[a-zA-Z_0-9]+$"); 142 | QRegExpValidator validator(regp,nullptr); 143 | int pos = 0; 144 | if(QValidator::Acceptable != validator.validate(string, pos)){ 145 | return false; 146 | } 147 | 148 | return true; 149 | } 150 | 151 | bool ExcelRW::checkPassword(QString string) 152 | { 153 | if(string.isEmpty()) 154 | { 155 | return false; 156 | } 157 | 158 | QRegExp regp("^[\\x21-\\x7E]+$"); 159 | QRegExpValidator validator(regp, this); 160 | int pos = 0; 161 | if(QValidator::Acceptable != validator.validate(string, pos)){ 162 | return false; 163 | } 164 | return true; 165 | } 166 | 167 | bool ExcelRW::checkIsNumber(QString string) 168 | { 169 | if(string.isEmpty()) 170 | { 171 | return false; 172 | } 173 | QRegExp regp("^[0-9]+$"); 174 | QRegExpValidator validator(regp,nullptr); 175 | int pos=0; 176 | if(QValidator::Acceptable != validator.validate(string,pos)) 177 | { 178 | return false; 179 | } 180 | return true; 181 | } 182 | 183 | bool ExcelRW::checkWebSite(QString site) 184 | { 185 | if(site.isEmpty()) 186 | { 187 | return false; 188 | } 189 | QRegExp regp("^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$"); 190 | QRegExpValidator validator(regp,nullptr); 191 | int pos=0; 192 | if(QValidator::Acceptable != validator.validate(site, pos)) 193 | { 194 | return false; 195 | } 196 | 197 | return true; 198 | } 199 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/ExcelRW.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCELRW_H 2 | #define EXCELRW_H 3 | 4 | #include 5 | #include 6 | #include "DataModel/TranslateModel.h" 7 | 8 | #define MAX_ERROR_COUNT 10 9 | #define MAX_GROUP 16 10 | #define MAX_GROUP_LENGTH 2 11 | 12 | class ExcelRW : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | enum ERROR_TYPE{ 17 | EXCEL_EMPTY_ERROR = 0, 18 | }; 19 | 20 | public: 21 | explicit ExcelRW(int keyColumn = 1, int sourceColumn = 2, int transColumn = 3, QObject *parent = 0); 22 | 23 | bool ImportFromXlsx(QList& list, QString strPath); 24 | bool ExportToXlsx(QList& list, QString strPath); 25 | void SetTransColumn(int column); 26 | 27 | signals: 28 | void error(const QString& msg); 29 | 30 | public slots: 31 | 32 | private: 33 | bool checkAccountName(QString string); 34 | bool checkPassword(QString string); 35 | bool checkIsNumber(QString string); 36 | bool checkWebSite(QString site); 37 | 38 | int m_TotalCount; 39 | 40 | int m_KeyColumn; 41 | int m_SourceColumn; 42 | int m_TransColumn; 43 | }; 44 | 45 | #endif // EXCELRW_H 46 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | #include "DataModel/TranslateModel.h" 8 | 9 | namespace Ui { 10 | class MainWindow; 11 | } 12 | 13 | class XmlRW; 14 | class ExcelRW; 15 | class TranslateWorker; 16 | 17 | class MainWindow : public QMainWindow 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | explicit MainWindow(QWidget *parent = nullptr); 23 | ~MainWindow(); 24 | 25 | private slots: 26 | void on_tsLookBtn_clicked(); 27 | void on_excelLookBtn_clicked(); 28 | void on_generateBtn_clicked(); 29 | void on_tsUpdateBtn_clicked(); 30 | void on_translateBtn_clicked(); 31 | void on_tsImportBtn_clicked(); 32 | 33 | void onComboBoxChanged(int); 34 | void onReceiveMsg(const QString& msg); 35 | 36 | void on_tsDirLookBtn_clicked(); 37 | void on_excelDirBtn_clicked(); 38 | void on_generateBtn_2_clicked(); 39 | void on_tsUpdateBtn_2_clicked(); 40 | 41 | private: 42 | Ui::MainWindow* ui; 43 | 44 | QList m_transList; 45 | 46 | QString m_toLanguage; 47 | 48 | XmlRW* m_pXmlWorker; 49 | ExcelRW* m_pExcelWorker; 50 | TranslateWorker* m_pTranslateWorker; 51 | 52 | QMap m_tsColumnMap; 53 | 54 | void readConfig(); 55 | void saveConfig(); 56 | }; 57 | 58 | #endif // MAINWINDOW_H 59 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/NetWorker.cpp: -------------------------------------------------------------------------------- 1 | #include "networker.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | NetWorker *NetWorker::instance() 8 | { 9 | static NetWorker netWorker; 10 | return &netWorker; 11 | } 12 | 13 | NetWorker::NetWorker(QObject *parent) : 14 | QObject(parent) 15 | { 16 | m_manager = new QNetworkAccessManager(this); 17 | 18 | connect(m_manager, &QNetworkAccessManager::finished, this, &NetWorker::finished); 19 | } 20 | 21 | NetWorker::~NetWorker() 22 | { 23 | 24 | } 25 | 26 | QNetworkAccessManager *NetWorker::GetAccessManager() 27 | { 28 | return m_manager; 29 | } 30 | 31 | void NetWorker::setDefaultConfig() 32 | { //WLAN changed 33 | qDebug() << "setDefaultConfig"; 34 | QNetworkConfigurationManager manager; 35 | m_manager->setConfiguration(manager.defaultConfiguration()); 36 | } 37 | 38 | QNetworkReply * NetWorker::get(const QString &baseUrl) 39 | { 40 | QUrl url(baseUrl); 41 | QNetworkRequest request = QNetworkRequest(url); 42 | // request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); 43 | // request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8"); 44 | // request.setRawHeader("Cache-Control", "no-cache"); 45 | // request.setRawHeader("Connection", "keep-alive"); 46 | // request.setRawHeader("DNT","1"); 47 | // request.setRawHeader("Pragma","no-cache"); 48 | // request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36"); 49 | return (m_manager->get(request)); 50 | } 51 | 52 | QNetworkReply * NetWorker::get(const QString &baseUrl, const QUrlQuery &query) 53 | { 54 | QUrl url(baseUrl); 55 | url.setQuery(query); 56 | // qDebug() << "get argv: " << url; 57 | return (m_manager->get(QNetworkRequest(url))); 58 | } 59 | 60 | QNetworkReply * NetWorker::post(const QString &url, const QByteArray &data) 61 | { 62 | QNetworkRequest request; 63 | request.setUrl(QUrl(url)); 64 | request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 65 | 66 | // qDebug() << "post argv: " << data; 67 | return (m_manager->post(request, data)); 68 | } 69 | 70 | QNetworkReply * NetWorker::postJson(const QString &url, const QByteArray &data) 71 | { 72 | QNetworkRequest request; 73 | request.setUrl(QUrl(url)); 74 | request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); 75 | 76 | // qDebug() << "post argv: " << data; 77 | 78 | return (m_manager->post(request, data)); 79 | } 80 | 81 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/NetWorker.h: -------------------------------------------------------------------------------- 1 | #ifndef NETWORKER_H 2 | #define NETWORKER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class QNetworkReply; 11 | 12 | class NetWorker : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | // explicit NetWorker(QObject *parent = 0); 17 | static NetWorker * instance(); 18 | ~NetWorker(); 19 | 20 | QNetworkAccessManager* GetAccessManager(); 21 | void setDefaultConfig(); 22 | 23 | QNetworkReply *get(const QString &baseUrl); 24 | QNetworkReply *get(const QString &baseUrl, const QUrlQuery &query); 25 | 26 | QNetworkReply *post(const QString &url, const QByteArray &data); 27 | QNetworkReply *postJson(const QString &url, const QByteArray &data); 28 | 29 | signals: 30 | void finished(QNetworkReply *reply); 31 | 32 | private: 33 | QNetworkAccessManager *m_manager; 34 | 35 | explicit NetWorker(QObject *parent = 0); 36 | NetWorker(const NetWorker &) Q_DECL_EQ_DELETE; 37 | NetWorker& operator=(NetWorker rhs) Q_DECL_EQ_DELETE; 38 | }; 39 | 40 | #endif // NETWORKER_H 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/TSFileEditor.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2018-04-04T10:31:33 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui xml 8 | QT += network 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = TSFileEditor 13 | TEMPLATE = app 14 | 15 | include(./../../Path.pri) 16 | 17 | INCLUDEPATH += ../../Libraries 18 | 19 | LIBS += -L$${DESTDIR} -lLibXlsxRW 20 | 21 | SOURCES += main.cpp\ 22 | MainWindow.cpp \ 23 | XmlRW.cpp \ 24 | ExcelRW.cpp \ 25 | DataModel/TranslateModel.cpp \ 26 | NetWorker.cpp \ 27 | TranslateWorker.cpp 28 | 29 | HEADERS += MainWindow.h \ 30 | XmlRW.h \ 31 | ExcelRW.h \ 32 | DataModel/TranslateModel.h \ 33 | NetWorker.h \ 34 | TranslateWorker.h 35 | 36 | FORMS += MainWindow.ui 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/TranslateWorker.cpp: -------------------------------------------------------------------------------- 1 | #include "TranslateWorker.h" 2 | #include 3 | #include 4 | #include 5 | 6 | TranslateWorker::TranslateWorker(QList &list, QObject *parent) : QObject(parent), 7 | m_list(list) 8 | { 9 | m_pNetWorker = NetWorker::instance(); 10 | 11 | connect(this, &TranslateWorker::translateResult, this, &TranslateWorker::onTranslateResult); 12 | } 13 | 14 | TranslateWorker::~TranslateWorker() 15 | { 16 | 17 | } 18 | 19 | void TranslateWorker::SetIdKey(const QString &id, const QString &key) 20 | { 21 | m_appId = id; 22 | m_appKey = key; 23 | } 24 | 25 | bool TranslateWorker::YoudaoTranslate(const QString &from, const QString &to) 26 | { 27 | if(m_list.count() <=0) { 28 | emit error("translate list is empty"); 29 | return false; 30 | } 31 | 32 | m_fromLang = from; 33 | m_toLang = to; 34 | 35 | for(int i=0; iget(baseUrl, query)); 61 | 62 | connect(pReply, &QNetworkReply::finished, this, [=](){ 63 | if (pReply->error() != QNetworkReply::NoError) { 64 | emit error("Http error: " + pReply->errorString()); 65 | } else { 66 | // QVariant variant = pReply->attribute(QNetworkRequest::HttpStatusCodeAttribute); 67 | // int nStatusCode = variant.toInt(); 68 | // qDebug() << "Status Code :" << nStatusCode; 69 | 70 | QByteArray replyData = pReply->readAll(); 71 | 72 | qDebug() << replyData; 73 | 74 | QJsonParseError jsonError; 75 | QJsonDocument jsonDocument = QJsonDocument::fromJson(replyData, &jsonError); 76 | if (jsonError.error == QJsonParseError::NoError) { 77 | if (!(jsonDocument.isNull() || jsonDocument.isEmpty()) && jsonDocument.isObject()) { 78 | QVariantMap data = jsonDocument.toVariant().toMap(); 79 | // qDebug() << data; 80 | int errorcode = data[QLatin1String("errorCode")].toInt(); 81 | 82 | if(0 == errorcode){ 83 | QVariantList detailList = data[QLatin1String("translation")].toList(); 84 | QString str = detailList.first().toString(); 85 | 86 | emit translateResult(index, str); 87 | } 88 | 89 | } 90 | } else { 91 | emit error(jsonError.errorString()); 92 | } 93 | } 94 | 95 | pReply->deleteLater(); 96 | }); 97 | } 98 | 99 | QByteArray TranslateWorker::GetYoudaoSign(const QString &source, const QString &uuid, const QString ×tamp) 100 | { 101 | QByteArray sign; 102 | 103 | QString str = m_appId + source + uuid + timestamp + m_appKey; 104 | 105 | // qDebug() << "str: " << str; 106 | 107 | sign = QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Sha256).toHex().toUpper(); 108 | 109 | // qDebug() << sign; 110 | 111 | return sign; 112 | } 113 | 114 | void TranslateWorker::onTranslateResult(int index, const QString &str) 115 | { 116 | TranslateModel model = m_list.at(index); 117 | model.SetTranslate(str); 118 | m_list.replace(index, model); 119 | 120 | qDebug() << "key: " << m_list.at(index).GetKey() << "\tsource: " << m_list.at(index).GetSource() << "\ttranslation: " << m_list.at(index).GetTranslate(); 121 | } 122 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/TranslateWorker.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSLATEWORKER_H 2 | #define TRANSLATEWORKER_H 3 | 4 | #include 5 | #include "DataModel/TranslateModel.h" 6 | 7 | class NetWorker; 8 | 9 | class TranslateWorker : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | 14 | explicit TranslateWorker(QList &list, QObject *parent = nullptr); 15 | ~TranslateWorker(); 16 | 17 | void SetIdKey(const QString& id, const QString& key); 18 | bool YoudaoTranslate(const QString &from = QString("auto"), const QString &to = QString("en")); 19 | 20 | signals: 21 | void translateResult(int index, const QString &str); 22 | void error(const QString& msg); 23 | 24 | private slots: 25 | void onTranslateResult(int index, const QString &str); 26 | 27 | private: 28 | QByteArray GetYoudaoSign(const QString &source, const QString& uuid, const QString& timestamp); 29 | void YoudaoTranslate(int index, const QString &source); 30 | 31 | NetWorker* m_pNetWorker; 32 | 33 | QString m_fromLang; 34 | QString m_toLang; 35 | QString m_appId; 36 | QString m_appKey; 37 | QList &m_list; 38 | }; 39 | 40 | #endif // TRANSLATEWORKER_H 41 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/XmlRW.h: -------------------------------------------------------------------------------- 1 | #ifndef XMLRW_H 2 | #define XMLRW_H 3 | 4 | #include 5 | #include 6 | 7 | #include "DataModel/TranslateModel.h" 8 | 9 | class XmlRW : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit XmlRW(QObject *parent = 0); 14 | 15 | bool ImportFromTS(QList& list, QString strPath); 16 | bool ExportToTS(QList& list, QString strPath); 17 | QString ErrorString() const; 18 | 19 | private: 20 | void UpdateTranslateMap(QList& list); 21 | void ReadXBEL(); 22 | void ReadContext(); 23 | void ReadMessage(); 24 | 25 | QXmlStreamReader xml; 26 | QString m_tsFilePath; 27 | QMap m_translateMap; 28 | }; 29 | 30 | #endif // XMLRW_H 31 | -------------------------------------------------------------------------------- /MainApps/TSFileEditor/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Path.pri: -------------------------------------------------------------------------------- 1 | 2 | CONFIG(release, debug|release) { 3 | BuildType=release 4 | CONFIG += warn_off 5 | } else { 6 | BuildType=debug 7 | DEFINES += __DEBUG 8 | } 9 | 10 | #DESTDIR = $$PWD/../RunImage/$$BuildType 11 | DESTDIR = $$absolute_path($$PWD/bin/) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 翻译文件(.ts)和Excel文件的相互转换工具 2 | 3 | ## 运行环境 4 | Win10 Qt5.12.2 Mingw && MSVC VS2017 5 | 6 | ## 依赖库 7 | [qtxlsx](https://qtxlsx.debao.me/) 8 | 9 | ## status 10 | | [Windows][win-link] | [MacOS][macos-link] | [Release][release-link] | [Download][download-link] | 11 | | ------------------- | ------------------- | ----------------------- | ------------------------- | 12 | | ![win-badge] | ![macos-badge] | ![release-badge] | ![download-badge] | 13 | 14 | [win-link]: https://github.com/Longxr/TSFileEditor/actions?query=workflow%3AWindows "WindowsAction" 15 | [win-badge]: https://github.com/Longxr/TSFileEditor/workflows/Windows/badge.svg "Windows" 16 | 17 | [macos-link]: https://github.com/Longxr/TSFileEditor/actions?query=workflow%3AMacOS "MacOSAction" 18 | [macos-badge]: https://github.com/Longxr/TSFileEditor/workflows/MacOS/badge.svg "MacOS" 19 | 20 | [release-link]: https://github.com/Longxr/TSFileEditor/releases "Release status" 21 | [release-badge]: https://img.shields.io/github/release/Longxr/TSFileEditor.svg?style=flat-square "Release status" 22 | 23 | [download-link]: https://github.com/Longxr/TSFileEditor/releases/latest "Download status" 24 | [download-badge]: https://img.shields.io/github/downloads/Longxr/TSFileEditor/total.svg?style=flat-square "Download status" 25 | 26 | ## 主要功能 27 | ### 生成待翻译字符串的excel文件 28 | ![生成excel文件](picture/gen_excel.gif) 29 | 30 | .ts文件中的源文本作为excel的第一列key值,翻译文本(如果有的话)在抽出的时候放在第三列,没有则为空 31 | ![excel截图.png](picture/excel.png) 32 | 33 | 因为我加入了一列key值,一般情况生成的话key就是你原来的源文本,如果要使用自动翻译功能,将第一列拷贝一份到第二列即可;也可以像我这样代码里代码里不写实际的文本,另外生成一个中文的翻译文件(ts),将translation放上中文,需要其他语言的翻译的时候将中文拷贝到第二列即可 34 | 35 | ### 更新翻译文件(.ts) 36 | * 如果有专门负责翻译的人的话,可以将excel第二列放源文本后给别人,让他把翻译好的字符串放在第三列。翻译好后,选择好excel文件和ts文件,点击*译文写入*按钮就可以愉快地导入翻译内容了 37 | * 部分包含标点符号的地方可能有点小问题,可以打开Qt语言家检查下 38 | 39 | ### 自动翻译 40 | * 将要翻译的excel文件第二列放要翻译的文本(重要!!!) 41 | * 自动翻译功能调用的[有道智云的API](http://ai.youdao.com/index.s),需要使用的话自己去注册一个账号,免费送100元体验金。注册好后添加自己的翻译实例和应用,并将你的应用ID和应用密钥填到程序代码的:`TSFileEditor\Source\MainApps\TSFileEditor\TranslateWorker.cpp`上边 42 | ![有道智云](picture/youdao.png) 43 | 44 | ![填写位置](picture/code.png) 45 | 46 | 主界面最下方有填写应用ID和应用密钥的地方,在网页申请好后使用即可。 47 | 48 | * 下面是中文翻译成日文的栗子(导入ts文件->有道翻译->生成excel): 49 | ![translate.gif](picture/translate.gif) 50 | 51 | 点击*excel生成*按钮后,就可以得到翻译好的excel了: 52 | ![翻译结果](picture/translate.png) 53 | 54 | * 然后可以结合功能二来更新翻译文件(ts),之后就可以愉快地发布出(qm)给程序用了 55 | -------------------------------------------------------------------------------- /TSFileEditor.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | Libraries \ 5 | MainApps 6 | 7 | CONFIG += ordered 8 | 9 | 10 | -------------------------------------------------------------------------------- /config/config.ini: -------------------------------------------------------------------------------- 1 | [path] 2 | tsPath= 3 | tsDir=C:/Users/xuanren.long/Desktop/translations 4 | excelPath= 5 | excelPath2=C:/Users/xuanren.long/Desktop/translations/translations.xlsx 6 | 7 | [languages] 8 | size=13 9 | 1\column=3 10 | 1\tsFile=i18n_zh_cn.ts 11 | 2\column=4 12 | 2\tsFile=i18n_zh_tw.ts 13 | 3\column=5 14 | 3\tsFile=i18n_en.ts 15 | 4\column=6 16 | 4\tsFile=i18n_id.ts 17 | 5\column=7 18 | 5\tsFile=i18n_th.ts 19 | 6\column=8 20 | 6\tsFile=i18n_de.ts 21 | 7\column=9 22 | 7\tsFile=i18n_fr.ts 23 | 8\column=10 24 | 8\tsFile=i18n_es.ts 25 | 9\column=11 26 | 9\tsFile=i18n_pt.ts 27 | 10\column=12 28 | 10\tsFile=i18n_ru.ts 29 | 11\column=13 30 | 11\tsFile=i18n_ko.ts 31 | 12\column=14 32 | 12\tsFile=i18n_vi.ts 33 | 13\column=15 34 | 13\tsFile=i18n_ja.ts 35 | -------------------------------------------------------------------------------- /picture/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/picture/code.png -------------------------------------------------------------------------------- /picture/excel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/picture/excel.png -------------------------------------------------------------------------------- /picture/gen_excel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/picture/gen_excel.gif -------------------------------------------------------------------------------- /picture/translate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/picture/translate.gif -------------------------------------------------------------------------------- /picture/translate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/picture/translate.png -------------------------------------------------------------------------------- /picture/youdao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/picture/youdao.png -------------------------------------------------------------------------------- /run_tools_for_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd bin 3 | export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH 4 | ./TSFileEditor & 5 | cd .. 6 | -------------------------------------------------------------------------------- /ssl/libcrypto-1_1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/ssl/libcrypto-1_1.dll -------------------------------------------------------------------------------- /ssl/libssl-1_1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Longxr/TSFileEditor/8815777a6bcd26b10a8ea25b2aebe7842e4be3c1/ssl/libssl-1_1.dll --------------------------------------------------------------------------------