标签: uno

使用OpenOffice Uno CLI和C#创建电子表格

到目前为止,我已经找到了几个讨论ODS文件创建的来源:如何在.Net中创建ODS文档以及 如何使用C#.NET创建.odt文件?

最有趣的是打开calc文件的解释.然而,这会在全屏幕中打开OpenOffice,我正在寻找的是一种写入Calc文件(.ods)而不实际打开Openoffice的方法.这样我就可以编写一个只打开savefiledialog的函数,获取文件名,然后创建并保存.ods文件.

是否有任何C#代码示例可用于执行此类操作?

c# openoffice.org uno

4
推荐指数
1
解决办法
1万
查看次数

使用命名管道连接到LibreOffice

我可以使用套接字进行连接,但是我听说在所有内容都是本地的情况下使用管道的速度更快,因此我想尝试一下,但无法建立连接。

我从Libre开始

 > soffice --headless --invisible --norestore --nodefault --nolockcheck --nofirstwizard --accept='pipe,name=ooo_pipe;urp;'
Run Code Online (Sandbox Code Playgroud)

而应该工作但不起作用的最低限度的最小python脚本是

import uno
from com.sun.star.connection import NoConnectException

pipe = 'ooo_pipe'
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
context = resolver.resolve("uno:pipe,name=%s;urp;StarOffice.ComponentContext" % pipe)
Run Code Online (Sandbox Code Playgroud)

python openoffice.org named-pipes uno libreoffice

4
推荐指数
1
解决办法
2645
查看次数

OpenOffice with .NET:如何遍历所有段落并阅读文本

如何遍历OpenOffice Writer文档中的所有段落并输出文本.我有Java示例,但不知道如何将代码转换为C#.Java示例可以在这里找到:http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextDocumentStructure

我的C#代码:

InitOpenOfficeEnvironment();
XMultiServiceFactory multiServiceFactory = connect();
XComponentLoader componentLoader =           
    XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop"); 

//set the property
PropertyValue[] propertyValue = new PropertyValue[1];
PropertyValue aProperty = new PropertyValue();
aProperty.Name = "Hidden";
aProperty.Value = new uno.Any(false);
propertyValue[0] = aProperty;

XComponent xComponent =
        componentLoader.loadComponentFromURL(
            @"file:///C:/code/test3.doc", 
            "_blank", 0, propertyValue);

XEnumerationAccess xEnumerationAccess = (XEnumerationAccess)xComponent;
XEnumeration xParagraphEnumeration = xEnumerationAccess.createEnumeration();

while ( xParagraphEnumeration.hasMoreElements() ) 
{
    // ???
    // The problem is here nextElement() returns uno.Any but
    // I some how should get XTextContent????
    uno.Any textElement = …
Run Code Online (Sandbox Code Playgroud)

c# openoffice.org openoffice-writer uno

3
推荐指数
1
解决办法
5006
查看次数

如何避免连接器在 Open Office/Libre Office Draw 中移动到形状上

我正在以编程方式绘制流程图(使用 Java UNO 运行时参考),其中显示 If-Else 条件。附图)在此处输入图片说明

我用来绘制连接器的代码是:-

XShapes xShapes = (XShapes)
                UnoRuntime.queryInterface(XShapes.class, xDrawPage);
        XMultiServiceFactory xMsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc);
        Object connector = xMsf.createInstance("com.sun.star.drawing.ConnectorShape"); 
        xShapes.add(UnoRuntime.queryInterface(XShape.class, connector));

XPropertySet xConnector2PropSet = (XPropertySet)UnoRuntime.queryInterface(
                XPropertySet.class, connector);
        xConnector2PropSet.setPropertyValue("EdgeKind", ConnectorType.STANDARD);
        xConnector2PropSet.setPropertyValue("StartShape", xShape1);
        xConnector2PropSet.setPropertyValue("StartGluePointIndex", new Integer(startPt));
        xConnector2PropSet.setPropertyValue("LineEndName", "Arrow");
        xConnector2PropSet.setPropertyValue("EndShape", xShape2 );
        xConnector2PropSet.setPropertyValue("EndGluePointIndex", new Integer(endPt));
Run Code Online (Sandbox Code Playgroud)

请建议如何使用 Java 中的 UNO 运行时参考正确布局和路由连接器。

java api openoffice.org uno libreoffice

3
推荐指数
1
解决办法
1566
查看次数

使用 Python 使用 Uno 访问 LibreOffice Calc

我正在尝试编写一个脚本来使用 Python 3.7 操作 Ubuntu Mint _LibreOffice Calc 表。出于某种原因,当我尝试导入 Uno 时出现错误。我可以从 Calc 内部运行一个宏调用这个

    desktop = XSCRIPTCONTEXT.getDesktop()
    model = desktop.getCurrentComponent()
    active_sheet = model.CurrentController.ActiveSheet
    write 'Hello World' in A1
    active_sheet.getCellRangeByName("A1").String = "Hello World!
Run Code Online (Sandbox Code Playgroud)

但不能直接从 VS_code IDE 与工作表进行交互。是否有我需要设置为 Uno_ 的路径

使用 LibreOffice 6.4、Python 3.7 和 APSO。我对 LibreOffice 感到非常沮丧,似乎对新手的 Python 支持很少。

uno python-3.x libreoffice-calc

3
推荐指数
2
解决办法
8341
查看次数

Openoffice3.1 pyuno混淆错误

我正在尝试获取样本和其他示例代码,我发现pyuno运行openoffice 3.1.1和python 2.5没有运气.

不幸的是,pyuno没有提供任何关于出错的线索.


In [1]: import uno
In [2]: local = uno.getComponentContext()
In [3]: resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)
---------------------------------------------------------------------------
com.sun.star.uno.RuntimeException         Traceback (most recent call last)

/opt/openoffice.org/basis3.1/program/ in ()

com.sun.star.uno.RuntimeException: : 'tuple' object has no attribute 'getTypes', traceback follows
no traceback available

下面是/opt/openoffice.org/basis3.1/program/officehelper.py的执行输出,它基本上启动无头办公室实例并返回一个相关的上下文对象.

den@ev:/opt/openoffice.org/basis3.1/program > python officehelper.py
Traceback (most recent call last):
  File "officehelper.py", line 42, in 
    from com.sun.star.connection import NoConnectException
  File "uno.py", line 273, in _uno_import
    RuntimeException = pyuno.getClass( "com.sun.star.uno.RuntimeException" )
RuntimeError: pyuno.getClass: expecting one string argument

pyuno只有一个参数,它有一个字符串,如 …

python openoffice.org uno pyuno

2
推荐指数
1
解决办法
1261
查看次数

使用JAVA的LibreOffice/OpenOffice转换文件格式

我正在使用LibreOffice4.0 UNO来转换文件.我管理doc和docx之间的转换,从xlsx到xls以及从docx到doc,但是我找不到XLSX和PPTX的FilterName值.

propertyValues[0] = new PropertyValue();
propertyValues[0].Name = "FilterName";
propertyValues[0].Value = "...";

for doc I used:  "swriter: MS Word 97";
for docx I used: "Office Open XML Text";
for xls I used:  "swriter: MS Excel 97";
for ppt I used:  "swriter: MS PowerPoint 97";
Run Code Online (Sandbox Code Playgroud)

谢谢.

java openoffice.org uno libreoffice

2
推荐指数
1
解决办法
2472
查看次数

将 libreoffice 作为服务运行

我正在构建一个 Web 应用程序,除其他外,它执行文件从格式docpdf格式的转换。

我一直在使用安装在同一台服务器上的 LibreOffice 以及我的 Web 应用程序。通过libreoffice从我的 Web 应用程序的代码中删除和调用二进制文件,我能够成功转换文档。

问题:当我的 Web 应用程序在很短的时间内(例如毫秒)收到多个用于 doc->pdf 转换的 HTTP 请求时,调用libreoffice无法一次启动多个实例。这会导致一些文件被成功转换,而有些则没有。

我认为这个问题的解决方案是这样的:

  1. 启动libreoffice服务一次,确保它接受连接,
  2. 在我的 Web 应用程序中处理 HTTP 请求时,与正在运行的libreoffice服务对话,要求它执行文件格式转换,
  3. “对话”部分将通过使用某些 CLI 工具或通过其他方式(例如将libreofficeAPI 请求发送到端口或套接字文件)来促进。

经过一番研究,我找到了一个名为jodconverter. 从它,我可以jodconverter-cli用来转换文件。转换有效,但不幸的是jodconverterlibreoffice在执行转换后停止服务器(有一个未解决的问题)。我没有看到关闭这种行为的方法。

或者,我正在考虑以下选项:

  1. 在我的网络应用程序中,确保所有转换请求都已排队;这显然会破坏并发性,例如我的用户将不得不等待他们的文件被转换,

  2. 进一步研究并使用称为UNO 的东西,但是我使用的语言(Elixir)没有绑定,我似乎看不到手动构建 UNO 有效负载的方法。

如何libreoffice使用 UNO 作为服务使用?

openoffice.org file-conversion uno libreoffice web

2
推荐指数
1
解决办法
3078
查看次数

OpenOffice.org API 还是 LibreOffice API?

我应该使用哪个 API?哪一个更有前途?我的主要目标是生成 ODF 文档。支持 ODF 1.2 对我来说很重要。我想使用 C++ 和 CLI。

openoffice.org odf uno libreoffice

1
推荐指数
1
解决办法
6160
查看次数

ErrorCodeIOException转换文件

我正在尝试实现Office基于LibreOffice 4.0的PDF转换系统并始终获取ErrorCodeIOException(尝试文件格式doc,docx,txt),我的stacktrace如下:

com.sun.star.task.ErrorCodeIOException: 

at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:177)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:143)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:335)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:304)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:91)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:639)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:151)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:133)
at com.sun.proxy.$Proxy49.storeAsURL(Unknown Source)
at Framework.Config.DocumentConverter.traverse(DocumentConverter.java:103)
at Framework.Config.DocumentConverter.main1(DocumentConverter.java:184)
at Framework.DAO.CRUD_Generic.ping(CRUD_Generic.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.struts2.json.JSONInterceptor.invoke(JSONInterceptor.java:248)
at org.apache.struts2.json.JSONInterceptor.intercept(JSONInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at …
Run Code Online (Sandbox Code Playgroud)

java uno libreoffice

1
推荐指数
1
解决办法
2743
查看次数