10 | /// Command line tool to Convert a document into a different format.
11 | ///
12 | /// Usage: can Convert a single file
13 | ///
14 | ///
15 | /// ConvertDocument test.odt test.pdf
16 | ///
17 | ///
18 | /// or multiple files at once by specifying the output format
19 | ///
20 | ///
21 | /// ConvertDocument -f pdf test1.odt test2.odt
22 | /// ConvertDocument -f pdf *.odt
23 | ///
24 | ///
25 | class Program
26 | {
27 | private static readonly Option OptionOutputFormat = new Option("f", "output-format", true, "output format (e.g. pdf)");
28 | private static readonly Option OptionPort = new Option("p", "port", true, "OpenOffice.org port");
29 | private static readonly Option OptionVerbose = new Option("v", "verbose", false, "verbose");
30 | private static readonly Option OptionXmlRegistry = new Option("x", "xml-registry", true, "XML document format registry");
31 | private static readonly Options Options = InitOptions();
32 |
33 | private const int ExitCodeConnectionFailed = 1;
34 | //private const int ExitCodeXmlRegistryNotFound = 254;
35 | private const int ExitCodeTooFewArgs = 255;
36 |
37 | private static Options InitOptions()
38 | {
39 | Options options = new Options();
40 | options.AddOption(OptionOutputFormat);
41 | options.AddOption(OptionPort);
42 | options.AddOption(OptionVerbose);
43 | options.AddOption(OptionXmlRegistry);
44 | return options;
45 | }
46 | [STAThread]
47 | static void Main(string[] arguments)
48 | {
49 | ICommandLineParser commandLineParser = new PosixParser();
50 | CommandLine commandLine = commandLineParser.Parse(Options, arguments);
51 |
52 | int port = SocketOpenOfficeConnection.DefaultPort;
53 | if (commandLine.HasOption(OptionPort.Opt))
54 | {
55 | port = Convert.ToInt32(commandLine.GetOptionValue(OptionPort.Opt));
56 | }
57 |
58 | String outputFormat = null;
59 | if (commandLine.HasOption(OptionOutputFormat.Opt))
60 | {
61 | outputFormat = commandLine.GetOptionValue(OptionOutputFormat.Opt);
62 | }
63 |
64 | bool verbose = commandLine.HasOption(OptionVerbose.Opt);
65 |
66 | IDocumentFormatRegistry registry = new DefaultDocumentFormatRegistry();
67 |
68 | String[] fileNames = commandLine.Args;
69 | if ((outputFormat == null && fileNames.Length != 2) || fileNames.Length < 1)
70 | {
71 | String syntax = "Convert [options] input-file output-file; or\n" + "[options] -f output-format input-file [input-file...]";
72 | HelpFormatter helpFormatter = new HelpFormatter();
73 | helpFormatter.PrintHelp(syntax, Options);
74 | Environment.Exit(ExitCodeTooFewArgs);
75 | }
76 |
77 | IOpenOfficeConnection connection = new SocketOpenOfficeConnection(port);
78 | OfficeInfo oo = EnvUtils.Get();
79 | if(oo.Kind == OfficeKind.Unknown)
80 | {
81 | Console.Out.WriteLine("please setup OpenOffice or LibreOffice!");
82 | return;
83 | }
84 | try
85 | {
86 | if (verbose)
87 | {
88 | Console.Out.WriteLine("-- connecting to OpenOffice.org on port " + port);
89 | }
90 | connection.Connect();
91 | }
92 | catch (Exception)
93 | {
94 | string CmdArguments = string.Format("-headless -accept=\"socket,host={0},port={1};urp;\" -nofirststartwizard", SocketOpenOfficeConnection.DefaultHost, SocketOpenOfficeConnection.DefaultPort);
95 | if(!EnvUtils.RunCmd(oo.OfficeUnoPath, "soffice", CmdArguments))
96 | {
97 | Console.Error.WriteLine("ERROR: connection failed. Please make sure OpenOffice.org is running and listening on port " + port + ".");
98 | Environment.Exit(ExitCodeConnectionFailed);
99 | }
100 |
101 | }
102 | try
103 | {
104 |
105 | IDocumentConverter converter = new OpenOfficeDocumentConverter(connection, registry);
106 | if (outputFormat == null)
107 | {
108 | FileInfo inputFile = new FileInfo(fileNames[0]);
109 | FileInfo outputFile = new FileInfo(fileNames[1]);
110 | ConvertOne(converter, inputFile, outputFile, verbose);
111 | }
112 | else
113 | {
114 | foreach (var t in fileNames)
115 | {
116 | var inputFile = new FileInfo(t);
117 | var outputFile = new FileInfo(inputFile.FullName.Remove(inputFile.FullName.LastIndexOf(".", StringComparison.Ordinal)) + "." + outputFormat);
118 | ConvertOne(converter, inputFile, outputFile, verbose);
119 | }
120 | }
121 | }
122 | finally
123 | {
124 | if (verbose)
125 | {
126 | Console.Out.WriteLine("-- disconnecting");
127 | }
128 | connection.Disconnect();
129 | }
130 | }
131 | private static void ConvertOne(IDocumentConverter converter, FileInfo inputFile, FileInfo outputFile, bool verbose)
132 | {
133 | if (verbose)
134 | {
135 | Console.Out.WriteLine("-- converting " + inputFile + " to " + outputFile);
136 | }
137 | converter.Convert(inputFile, outputFile);
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/NODConverter/OpenOffice/Connection/AbstractOpenOfficeConnection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Sockets;
3 | using System.Runtime.CompilerServices;
4 | using Slf;
5 | using uno.util;
6 | using unoidl.com.sun.star.beans;
7 | using unoidl.com.sun.star.bridge;
8 | using unoidl.com.sun.star.connection;
9 | using unoidl.com.sun.star.frame;
10 | using unoidl.com.sun.star.lang;
11 | using unoidl.com.sun.star.ucb;
12 | using unoidl.com.sun.star.uno;
13 | using Exception = System.Exception;
14 | namespace NODConverter.OpenOffice.Connection
15 | {
16 | using Logger = ILogger;
17 |
18 | public abstract class AbstractOpenOfficeConnection : IOpenOfficeConnection, XEventListener
19 | {
20 |
21 | protected internal readonly Logger Logger = LoggerFactory.GetLogger();
22 |
23 | private readonly string _connectionString;
24 | private XComponent _bridgeComponent;
25 | private XMultiComponentFactory _serviceManager;
26 | private XComponentContext _componentContext;
27 | private XBridge _bridge;
28 | private bool _connected;
29 | private bool _expectingDisconnection;
30 | protected internal AbstractOpenOfficeConnection(string connectionString)
31 | {
32 | _connectionString = connectionString;
33 | }
34 | [MethodImpl(MethodImplOptions.Synchronized)]
35 | public virtual void Connect()
36 | {
37 | Logger.Debug("connecting");
38 | try
39 | {
40 | EnvUtils.InitUno();
41 | SocketUtils.Connect();
42 | //var sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
43 | XComponentContext localContext = Bootstrap.bootstrap();
44 | //XComponentContext localContext = Bootstrap.defaultBootstrap_InitialComponentContext();
45 | XMultiComponentFactory localServiceManager = localContext.getServiceManager();
46 | XConnector connector = (XConnector)localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext);
47 | XConnection connection = connector.connect(_connectionString);
48 | XBridgeFactory bridgeFactory = (XBridgeFactory)localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext);
49 | _bridge = bridgeFactory.createBridge("", "urp", connection, null);
50 | _bridgeComponent = (XComponent)_bridge;
51 | _bridgeComponent.addEventListener(this);
52 | _serviceManager = (XMultiComponentFactory)_bridge.getInstance("StarOffice.ServiceManager");
53 | XPropertySet properties = (XPropertySet)_serviceManager;
54 | // Get the default context from the office server.
55 | var oDefaultContext = properties.getPropertyValue("DefaultContext");
56 |
57 | _componentContext = (XComponentContext)oDefaultContext.Value;
58 | _connected = true;
59 | Logger.Info("connected");
60 | }
61 | catch (NoConnectException connectException)
62 | {
63 | throw new OpenOfficeException("connection failed: " + _connectionString + ": " + connectException.Message);
64 | }
65 | catch (Exception exception)
66 | {
67 | throw new OpenOfficeException("connection failed: " + _connectionString, exception);
68 | }
69 | }
70 |
71 | [MethodImpl(MethodImplOptions.Synchronized)]
72 | public virtual void Disconnect()
73 | {
74 | SocketUtils.Disconnect();
75 | Logger.Debug("disconnecting");
76 | _expectingDisconnection = true;
77 | _bridgeComponent.dispose();
78 | }
79 |
80 | public virtual bool Connected
81 | {
82 | get
83 | {
84 | return _connected;
85 | }
86 | }
87 |
88 | public virtual void disposing(EventObject @event)
89 | {
90 | _connected = false;
91 | if (_expectingDisconnection)
92 | {
93 | Logger.Info("disconnected");
94 | }
95 | else
96 | {
97 | Logger.Error("disconnected unexpectedly");
98 | }
99 | _expectingDisconnection = false;
100 | }
101 |
102 | // for unit tests only
103 | internal virtual void SimulateUnexpectedDisconnection()
104 | {
105 | disposing(null);
106 | _bridgeComponent.dispose();
107 | }
108 |
109 | private object GetService(string className)
110 | {
111 | try
112 | {
113 | if (!_connected)
114 | {
115 | Logger.Info("trying to (re)connect");
116 | Connect();
117 | }
118 | return _serviceManager.createInstanceWithContext(className, _componentContext);
119 | }
120 | catch (Exception exception)
121 | {
122 | throw new OpenOfficeException("could not obtain service: " + className, exception);
123 | }
124 | }
125 |
126 | public virtual XComponentLoader Desktop
127 | {
128 | get
129 | {
130 | return (XComponentLoader)GetService("com.sun.star.frame.Desktop");
131 | }
132 | }
133 |
134 | public virtual XFileIdentifierConverter FileContentProvider
135 | {
136 | get
137 | {
138 | return (XFileIdentifierConverter)GetService("com.sun.star.ucb.FileContentProvider");
139 | }
140 | }
141 |
142 | public virtual XBridge Bridge
143 | {
144 | get
145 | {
146 | return _bridge;
147 | }
148 | }
149 |
150 | public virtual XMultiComponentFactory RemoteServiceManager
151 | {
152 | get
153 | {
154 | return _serviceManager;
155 | }
156 | }
157 |
158 | public virtual XComponentContext ComponentContext
159 | {
160 | get
161 | {
162 | return _componentContext;
163 | }
164 | }
165 |
166 |
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/NODConverter/OpenOffice/Converter/AbstractOpenOfficeDocumentConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.IO;
4 | using NODConverter.OpenOffice.Connection;
5 | using uno;
6 | using unoidl.com.sun.star.beans;
7 | using unoidl.com.sun.star.lang;
8 | using unoidl.com.sun.star.util;
9 |
10 | namespace NODConverter.OpenOffice.Converter
11 | {
12 | public abstract class AbstractOpenOfficeDocumentConverter : IDocumentConverter
13 | {
14 | virtual protected internal IDictionary DefaultLoadProperties
15 | {
16 | get
17 | {
18 | return _defaultLoadProperties;
19 | }
20 |
21 | }
22 | virtual protected internal IDocumentFormatRegistry DocumentFormatRegistry
23 | {
24 | get
25 | {
26 | return _documentFormatRegistry;
27 | }
28 |
29 | }
30 |
31 |
32 | private readonly IDictionary _defaultLoadProperties;
33 |
34 | protected internal IOpenOfficeConnection OpenOfficeConnection;
35 | private readonly IDocumentFormatRegistry _documentFormatRegistry;
36 |
37 | protected AbstractOpenOfficeDocumentConverter(IOpenOfficeConnection connection)
38 | : this(connection, new DefaultDocumentFormatRegistry())
39 | {
40 | }
41 |
42 | protected AbstractOpenOfficeDocumentConverter(IOpenOfficeConnection openOfficeConnection, IDocumentFormatRegistry documentFormatRegistry)
43 | {
44 | OpenOfficeConnection = openOfficeConnection;
45 | _documentFormatRegistry = documentFormatRegistry;
46 |
47 |
48 | _defaultLoadProperties = new Hashtable();
49 | _defaultLoadProperties["Hidden"] = true;
50 | _defaultLoadProperties["ReadOnly"] = true;
51 | }
52 |
53 | public virtual void SetDefaultLoadProperty(String name, Object valueRenamed)
54 | {
55 | _defaultLoadProperties[name] = valueRenamed;
56 | }
57 |
58 | public virtual void Convert(FileInfo inputFile, FileInfo outputFile)
59 | {
60 | Convert(inputFile, outputFile, null);
61 | }
62 |
63 | public virtual void Convert(FileInfo inputFile, FileInfo outputFile, DocumentFormat outputFormat)
64 | {
65 | Convert(inputFile, null, outputFile, outputFormat);
66 | }
67 |
68 | public virtual void Convert(Stream inputStream, DocumentFormat inputFormat, Stream outputStream, DocumentFormat outputFormat)
69 | {
70 | EnsureNotNull("inputStream", inputStream);
71 | EnsureNotNull("inputFormat", inputFormat);
72 | EnsureNotNull("outputStream", outputStream);
73 | EnsureNotNull("outputFormat", outputFormat);
74 | ConvertInternal(inputStream, inputFormat, outputStream, outputFormat);
75 | }
76 |
77 | public virtual void Convert(FileInfo inputFile, DocumentFormat inputFormat, FileInfo outputFile, DocumentFormat outputFormat)
78 | {
79 | EnsureNotNull("inputFile", inputFile);
80 | EnsureNotNull("outputFile", outputFile);
81 |
82 | var tmpBool = File.Exists(inputFile.FullName) || Directory.Exists(inputFile.FullName);
83 | if (!tmpBool)
84 | {
85 | throw new ArgumentException("inputFile doesn't exist: " + inputFile);
86 | }
87 | if (inputFormat == null)
88 | {
89 | inputFormat = GuessDocumentFormat(inputFile);
90 | }
91 | if (outputFormat == null)
92 | {
93 | outputFormat = GuessDocumentFormat(outputFile);
94 | }
95 | if (!inputFormat.Importable)
96 | {
97 | throw new ArgumentException("unsupported input format: " + inputFormat.Name);
98 | }
99 | if (!inputFormat.IsExportableTo(outputFormat))
100 | {
101 | throw new ArgumentException("unsupported conversion: from " + inputFormat.Name + " to " + outputFormat.Name);
102 | }
103 | ConvertInternal(inputFile, inputFormat, outputFile, outputFormat);
104 | }
105 |
106 | protected internal abstract void ConvertInternal(Stream inputStream, DocumentFormat inputFormat, Stream outputStream, DocumentFormat outputFormat);
107 |
108 | protected internal abstract void ConvertInternal(FileInfo inputFile, DocumentFormat inputFormat, FileInfo outputFile, DocumentFormat outputFormat);
109 |
110 | private static void EnsureNotNull(string argumentName, object argumentValue)
111 | {
112 | if (argumentValue == null)
113 | {
114 | throw new ArgumentException(argumentName + " is null");
115 | }
116 | }
117 |
118 | private DocumentFormat GuessDocumentFormat(FileInfo file)
119 | {
120 | //System.String extension = FilenameUtils.getExtension(file.Name);
121 | //System.String extension = System.IO.Path.GetExtension(file.Name);
122 | String extension = file.Extension.Substring(1);
123 | DocumentFormat format = DocumentFormatRegistry.GetFormatByFileExtension(extension);
124 | if (format == null)
125 | {
126 | throw new ArgumentException("unknown document format for file: " + file);
127 | }
128 | return format;
129 | }
130 |
131 | protected internal virtual void RefreshDocument(XComponent document)
132 | {
133 | XRefreshable refreshable = (XRefreshable)document;
134 | if (refreshable != null)
135 | {
136 | refreshable.refresh();
137 | }
138 | }
139 |
140 | protected internal static PropertyValue Property(String name, Object valueRenamed)
141 | {
142 | PropertyValue property = new PropertyValue
143 | {
144 | Name = name,
145 | Value = new Any(valueRenamed.GetType(), valueRenamed)
146 | };
147 | //property.Value = new uno.Any("writer_pdf_Export"); value_Renamed;
148 | return property;
149 | }
150 |
151 | protected internal static PropertyValue[] ToPropertyValues(IDictionary properties)
152 | {
153 | PropertyValue[] propertyValues = new PropertyValue[properties.Count];
154 | int i = 0;
155 |
156 | for (IEnumerator iter = new SupportClass.HashSetSupport(properties).GetEnumerator(); iter.MoveNext(); )
157 | {
158 | if (iter.Current != null)
159 | {
160 | DictionaryEntry entry = (DictionaryEntry)iter.Current;
161 | Object valueRenamed = entry.Value;
162 | var renamed = valueRenamed as IDictionary;
163 | if (renamed != null)
164 | {
165 | // recursively Convert nested Map to PropertyValue[]
166 | IDictionary subProperties = renamed;
167 | valueRenamed = ToPropertyValues(subProperties);
168 | }
169 | propertyValues[i++] = Property((String)entry.Key, valueRenamed);
170 | }
171 | }
172 | return propertyValues;
173 | }
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/NODConverter/DefaultDocumentFormatRegistry.cs:
--------------------------------------------------------------------------------
1 | namespace NODConverter
2 | {
3 | public sealed class DefaultDocumentFormatRegistry : BasicDocumentFormatRegistry
4 | {
5 |
6 | public DefaultDocumentFormatRegistry()
7 | {
8 |
9 | DocumentFormat pdf = new DocumentFormat("Portable Document Format", "application/pdf", "pdf");
10 | pdf.SetExportFilter(DocumentFamily.Drawing, "draw_pdf_Export");
11 | pdf.SetExportFilter(DocumentFamily.Presentation, "impress_pdf_Export");
12 | pdf.SetExportFilter(DocumentFamily.Spreadsheet, "calc_pdf_Export");
13 | pdf.SetExportFilter(DocumentFamily.Text, "writer_pdf_Export");
14 | AddDocumentFormat(pdf);
15 |
16 |
17 | DocumentFormat swf = new DocumentFormat("Macromedia Flash", "application/x-shockwave-flash", "swf");
18 | swf.SetExportFilter(DocumentFamily.Drawing, "draw_flash_Export");
19 | swf.SetExportFilter(DocumentFamily.Presentation, "impress_flash_Export");
20 | AddDocumentFormat(swf);
21 |
22 |
23 | DocumentFormat xhtml = new DocumentFormat("XHTML", "application/xhtml+xml", "xhtml");
24 | xhtml.SetExportFilter(DocumentFamily.Presentation, "XHTML Impress File");
25 | xhtml.SetExportFilter(DocumentFamily.Spreadsheet, "XHTML Calc File");
26 | xhtml.SetExportFilter(DocumentFamily.Text, "XHTML Writer File");
27 | AddDocumentFormat(xhtml);
28 |
29 | // HTML is treated as Text when supplied as input, but as an output it is also
30 | // available for exporting Spreadsheet and Presentation formats
31 |
32 | DocumentFormat html = new DocumentFormat("HTML", DocumentFamily.Text, "text/html", "html");
33 | html.SetExportFilter(DocumentFamily.Presentation, "impress_html_Export");
34 | html.SetExportFilter(DocumentFamily.Spreadsheet, "HTML (StarCalc)");
35 | html.SetExportFilter(DocumentFamily.Text, "HTML (StarWriter)");
36 | AddDocumentFormat(html);
37 |
38 |
39 | DocumentFormat odt = new DocumentFormat("OpenDocument Text", DocumentFamily.Text, "application/vnd.oasis.opendocument.text", "odt");
40 | odt.SetExportFilter(DocumentFamily.Text, "writer8");
41 | AddDocumentFormat(odt);
42 |
43 |
44 | DocumentFormat sxw = new DocumentFormat("OpenOffice.org 1.0 Text Document", DocumentFamily.Text, "application/vnd.sun.xml.writer", "sxw");
45 | sxw.SetExportFilter(DocumentFamily.Text, "StarOffice XML (Writer)");
46 | AddDocumentFormat(sxw);
47 |
48 |
49 | DocumentFormat doc = new DocumentFormat("Microsoft Word", DocumentFamily.Text, "application/msword", "doc");
50 | doc.SetExportFilter(DocumentFamily.Text, "MS Word 97");
51 | AddDocumentFormat(doc);
52 |
53 |
54 | DocumentFormat docx = new DocumentFormat("Microsoft Word 2007 XML", DocumentFamily.Text, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx");
55 | AddDocumentFormat(docx);
56 |
57 |
58 | DocumentFormat rtf = new DocumentFormat("Rich Text Format", DocumentFamily.Text, "text/rtf", "rtf");
59 | rtf.SetExportFilter(DocumentFamily.Text, "Rich Text Format");
60 | AddDocumentFormat(rtf);
61 |
62 |
63 | DocumentFormat wpd = new DocumentFormat("WordPerfect", DocumentFamily.Text, "application/wordperfect", "wpd");
64 | AddDocumentFormat(wpd);
65 |
66 |
67 | DocumentFormat txt = new DocumentFormat("Plain Text", DocumentFamily.Text, "text/plain", "txt");
68 | // default to "Text (encoded)" UTF8,CRLF to prevent OOo from trying to display the "ASCII Filter Options" dialog
69 | txt.SetImportOption("FilterName", "Text (encoded)");
70 | txt.SetImportOption("FilterOptions", "UTF8,CRLF");
71 | txt.SetExportFilter(DocumentFamily.Text, "Text (encoded)");
72 | txt.SetExportOption(DocumentFamily.Text, "FilterOptions", "UTF8,CRLF");
73 | AddDocumentFormat(txt);
74 |
75 |
76 | DocumentFormat wikitext = new DocumentFormat("MediaWiki wikitext", "text/x-wiki", "wiki");
77 | wikitext.SetExportFilter(DocumentFamily.Text, "MediaWiki");
78 | AddDocumentFormat(wikitext);
79 |
80 |
81 | DocumentFormat ods = new DocumentFormat("OpenDocument Spreadsheet", DocumentFamily.Spreadsheet, "application/vnd.oasis.opendocument.spreadsheet", "ods");
82 | ods.SetExportFilter(DocumentFamily.Spreadsheet, "calc8");
83 | AddDocumentFormat(ods);
84 |
85 |
86 | DocumentFormat sxc = new DocumentFormat("OpenOffice.org 1.0 Spreadsheet", DocumentFamily.Spreadsheet, "application/vnd.sun.xml.calc", "sxc");
87 | sxc.SetExportFilter(DocumentFamily.Spreadsheet, "StarOffice XML (Calc)");
88 | AddDocumentFormat(sxc);
89 |
90 |
91 | DocumentFormat xls = new DocumentFormat("Microsoft Excel", DocumentFamily.Spreadsheet, "application/vnd.ms-excel", "xls");
92 | xls.SetExportFilter(DocumentFamily.Spreadsheet, "MS Excel 97");
93 | AddDocumentFormat(xls);
94 |
95 |
96 | DocumentFormat xlsx = new DocumentFormat("Microsoft Excel 2007 XML", DocumentFamily.Spreadsheet, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
97 | AddDocumentFormat(xlsx);
98 |
99 |
100 | DocumentFormat csv = new DocumentFormat("CSV", DocumentFamily.Spreadsheet, "text/csv", "csv");
101 | csv.SetImportOption("FilterName", "Text - txt - csv (StarCalc)");
102 | csv.SetImportOption("FilterOptions", "44,34,0"); // Field Separator: ','; Text Delimiter: '"'
103 | csv.SetExportFilter(DocumentFamily.Spreadsheet, "Text - txt - csv (StarCalc)");
104 | csv.SetExportOption(DocumentFamily.Spreadsheet, "FilterOptions", "44,34,0");
105 | AddDocumentFormat(csv);
106 |
107 |
108 | DocumentFormat tsv = new DocumentFormat("Tab-separated Values", DocumentFamily.Spreadsheet, "text/tab-separated-values", "tsv");
109 | tsv.SetImportOption("FilterName", "Text - txt - csv (StarCalc)");
110 | tsv.SetImportOption("FilterOptions", "9,34,0"); // Field Separator: '\t'; Text Delimiter: '"'
111 | tsv.SetExportFilter(DocumentFamily.Spreadsheet, "Text - txt - csv (StarCalc)");
112 | tsv.SetExportOption(DocumentFamily.Spreadsheet, "FilterOptions", "9,34,0");
113 | AddDocumentFormat(tsv);
114 |
115 |
116 | DocumentFormat odp = new DocumentFormat("OpenDocument Presentation", DocumentFamily.Presentation, "application/vnd.oasis.opendocument.presentation", "odp");
117 | odp.SetExportFilter(DocumentFamily.Presentation, "impress8");
118 | AddDocumentFormat(odp);
119 |
120 |
121 | DocumentFormat sxi = new DocumentFormat("OpenOffice.org 1.0 Presentation", DocumentFamily.Presentation, "application/vnd.sun.xml.impress", "sxi");
122 | sxi.SetExportFilter(DocumentFamily.Presentation, "StarOffice XML (Impress)");
123 | AddDocumentFormat(sxi);
124 |
125 |
126 | DocumentFormat ppt = new DocumentFormat("Microsoft PowerPoint", DocumentFamily.Presentation, "application/vnd.ms-powerpoint", "ppt");
127 | ppt.SetExportFilter(DocumentFamily.Presentation, "MS PowerPoint 97");
128 | AddDocumentFormat(ppt);
129 |
130 |
131 | DocumentFormat pptx = new DocumentFormat("Microsoft PowerPoint 2007 XML", DocumentFamily.Presentation, "application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx");
132 | AddDocumentFormat(pptx);
133 |
134 |
135 | DocumentFormat odg = new DocumentFormat("OpenDocument Drawing", DocumentFamily.Drawing, "application/vnd.oasis.opendocument.graphics", "odg");
136 | odg.SetExportFilter(DocumentFamily.Drawing, "draw8");
137 | AddDocumentFormat(odg);
138 |
139 |
140 | DocumentFormat svg = new DocumentFormat("Scalable Vector Graphics", "image/svg+xml", "svg");
141 | svg.SetExportFilter(DocumentFamily.Drawing, "draw_svg_Export");
142 | AddDocumentFormat(svg);
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/NODConverter/OpenOffice/Converter/OpenOfficeDocumentConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.IO;
4 | using Dotnet.Commons.IO;
5 | using NODConverter.OpenOffice.Connection;
6 | using Slf;
7 | using unoidl.com.sun.star.frame;
8 | using unoidl.com.sun.star.lang;
9 | using unoidl.com.sun.star.task;
10 | using unoidl.com.sun.star.ucb;
11 | using unoidl.com.sun.star.util;
12 |
13 | namespace NODConverter.OpenOffice.Converter
14 | {
15 | using IOUtils = StreamUtils;
16 | using Logger = ILogger;
17 |
18 | ///