C++开发Libreoffice7.6, libreoffice在linux、windows下sdk环境配置

xingyun86 6月前 269

C++开发Libreoffice7.6, libreoffice在linux、windows下sdk环境配置

下载地址:下载 LibreOffice | LibreOffice 简体中文官方网站 - 自由免费的办公套件

libreoffice下载地址:https://www.libreoffice.org/donate/dl/win-x86_64/7.6.2/zh-CN/LibreOffice_7.6.2_Win_x86-64.msi

libreoffice-sdk下载地址:https://download.documentfoundation.org/libreoffice/stable/7.6.2/win/x86_64/LibreOffice_7.6.2_Win_x86-64_sdk.msi

切换到root用户下

1. 安装libreoffice到D盘根目录(避免权限问题)

2. 安装libreoffice-sdk到D盘根目录

3. 设置环境变量 ./setsdkenv_unix

4. 根据rdb数据文件反射生成C++头文件,由于sdk附带的C++头文件太少,按需生成头文件。基于UNO组件的反射机制,使用uno工具来生成这些头文件。

执行:

cppumaker -Gc -O D:\LibreOffice_7.6_SDK\sdk\includecpp "D:\LibreOffice64\program\types.rdb" "D:\LibreOffice64\program\types\offapi.rdb"

生成头文件需要types.rdb和offapi.rdb两个文件,前者是UNO运行时需要的类型库信息,后者是office组件的API类型库信息。现在应该可以在sdk\include目录下看到所需要的C++头文件了。

5.用户工程调用

INCLUDEPATH +=

D:\LibreOffice_7.6_SDK\sdk\include

D:\LibreOffice_7.6_SDK\sdk\includecpp


LIBS += -L D:\LibreOffice_7.6_SDK\sdk\lib

    -l icppu.lib

    -l icppuhelper.lib

    -l ipurpenvhelper.lib

    -l isal.lib

    -l isalhelper.lib

6.编译完成后,将libreoffice安装目录bin下的dll拷贝到编译exe同目录即可。

7.运行结果截图

8.启动libreoffice服务

D:\LibreOffice64\program\soffice.exe "--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"

9.启动转换工具

D:\LibreOffice64\program>PlyOfficeConverter.exe -env:URE_MORE_TYPES="file:///d:/LibreOffice64/program/types/offapi.rdb" aa.docx "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"

执行结果如下:

file:///F:/LibreOffice64/program/aa.docx

file:///F:/LibreOffice64/program/output.pdf

Output output.pdf generated.

10.PDF生成完成!


×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回