summaryrefslogtreecommitdiff
path: root/odk/examples/java/DocumentHandling
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/java/DocumentHandling')
-rw-r--r--odk/examples/java/DocumentHandling/DocumentConverter.java58
-rw-r--r--odk/examples/java/DocumentHandling/DocumentLoader.java16
-rw-r--r--odk/examples/java/DocumentHandling/DocumentPrinter.java22
-rw-r--r--odk/examples/java/DocumentHandling/DocumentSaver.java16
4 files changed, 56 insertions, 56 deletions
diff --git a/odk/examples/java/DocumentHandling/DocumentConverter.java b/odk/examples/java/DocumentHandling/DocumentConverter.java
index 69ded5e24f45..97d407935501 100644
--- a/odk/examples/java/DocumentHandling/DocumentConverter.java
+++ b/odk/examples/java/DocumentHandling/DocumentConverter.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
import com.sun.star.uno.UnoRuntime;
@@ -59,7 +59,7 @@ public class DocumentConverter {
/** Containing the directory where the converted files are saved
*/
static String sOutputDir = "";
-
+
/** Traversing the given directory recursively and converting their files to
* the favoured type if possible
* @param fileDirectory Containing the directory
@@ -75,17 +75,17 @@ public class DocumentConverter {
// Prepare Url for the output directory
File outdir = new File(DocumentConverter.sOutputDir);
String sOutUrl = "file:///" + outdir.getAbsolutePath().replace( '\\', '/' );
-
+
System.out.println("\nThe converted documents will stored in \""
+ outdir.getPath() + "!");
-
+
System.out.println(sIndent + "[" + fileDirectory.getName() + "]");
sIndent += " ";
-
+
// Getting all files and directories in the current directory
File[] entries = fileDirectory.listFiles();
-
+
// Iterating for each file and directory
for ( int i = 0; i < entries.length; ++i ) {
// Testing, if the entry in the list is a directory
@@ -98,7 +98,7 @@ public class DocumentConverter {
// Composing the URL by replacing all backslashs
String sUrl = "file:///"
+ entries[ i ].getAbsolutePath().replace( '\\', '/' );
-
+
// Loading the wanted document
com.sun.star.beans.PropertyValue propertyValues[] =
new com.sun.star.beans.PropertyValue[1];
@@ -109,13 +109,13 @@ public class DocumentConverter {
Object oDocToStore =
DocumentConverter.xCompLoader.loadComponentFromURL(
sUrl, "_blank", 0, propertyValues);
-
+
// Getting an object that will offer a simple way to store
// a document to a URL.
com.sun.star.frame.XStorable xStorable =
(com.sun.star.frame.XStorable)UnoRuntime.queryInterface(
com.sun.star.frame.XStorable.class, oDocToStore );
-
+
// Preparing properties for converting the document
propertyValues = new com.sun.star.beans.PropertyValue[2];
// Setting the flag for overwriting
@@ -126,16 +126,16 @@ public class DocumentConverter {
propertyValues[1] = new com.sun.star.beans.PropertyValue();
propertyValues[1].Name = "FilterName";
propertyValues[1].Value = DocumentConverter.sConvertType;
-
+
// Appending the favoured extension to the origin document name
int index1 = sUrl.lastIndexOf('/');
- int index2 = sUrl.lastIndexOf('.');
+ int index2 = sUrl.lastIndexOf('.');
String sStoreUrl = sOutUrl + sUrl.substring(index1, index2 + 1)
+ DocumentConverter.sExtension;
-
+
// Storing and converting the document
xStorable.storeAsURL(sStoreUrl, propertyValues);
-
+
// Closing the converted document. Use XCloseable.clsoe if the
// interface is supported, otherwise use XComponent.dispose
com.sun.star.util.XCloseable xCloseable =
@@ -148,21 +148,21 @@ public class DocumentConverter {
com.sun.star.lang.XComponent xComp =
(com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
com.sun.star.lang.XComponent.class, xStorable);
-
+
xComp.dispose();
}
}
catch( Exception e ) {
- e.printStackTrace(System.err);
+ e.printStackTrace(System.err);
}
-
+
System.out.println(sIndent + entries[ i ].getName());
}
}
-
+
sIndent = sIndent.substring(2);
}
-
+
/** Bootstrap UNO, getting the remote component context, getting a new instance
* of the desktop (used interface XComponentLoader) and calling the
* static method traverse
@@ -180,9 +180,9 @@ public class DocumentConverter {
"\"c:/myoffice\" \"swriter: MS Word 97\" \"doc\"");
System.exit(1);
}
-
+
com.sun.star.uno.XComponentContext xContext = null;
-
+
try {
// get the remote office component context
xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
@@ -191,35 +191,35 @@ public class DocumentConverter {
// get the remote office service manager
com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();
-
+
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
-
+
xCompLoader = (com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
oDesktop);
-
+
// Getting the given starting directory
File file = new File(args[0]);
-
+
// Getting the given type to convert to
sConvertType = args[1];
-
+
// Getting the given extension that should be appended to the
// origin document
sExtension = args[2];
-
+
// Getting the given type to convert to
sOutputDir = args[3];
// Starting the conversion of documents in the given directory
// and subdirectories
traverse(file);
-
+
System.exit(0);
} catch( Exception e ) {
e.printStackTrace(System.err);
- System.exit(1);
+ System.exit(1);
}
}
}
diff --git a/odk/examples/java/DocumentHandling/DocumentLoader.java b/odk/examples/java/DocumentHandling/DocumentLoader.java
index 8185cbf6da5f..a5a7fb5fc730 100644
--- a/odk/examples/java/DocumentHandling/DocumentLoader.java
+++ b/odk/examples/java/DocumentHandling/DocumentLoader.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
import com.sun.star.uno.UnoRuntime;
@@ -47,21 +47,21 @@ public class DocumentLoader {
"java -jar DocumentLoader.jar \"private:factory/swriter\"" );
System.exit(1);
}
-
+
com.sun.star.uno.XComponentContext xContext = null;
try {
// get the remote office component context
xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
-
+
// get the remote office service manager
com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();
-
+
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
-
+
com.sun.star.frame.XComponentLoader xCompLoader =
(com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface(
@@ -73,8 +73,8 @@ public class DocumentLoader {
StringBuffer sbTmp = new StringBuffer("file:///");
sbTmp.append(sourceFile.getCanonicalPath().replace('\\', '/'));
sUrl = sbTmp.toString();
- }
-
+ }
+
// Load a Writer document, which will be automaticly displayed
com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
sUrl, "_blank", 0, new com.sun.star.beans.PropertyValue[0]);
diff --git a/odk/examples/java/DocumentHandling/DocumentPrinter.java b/odk/examples/java/DocumentHandling/DocumentPrinter.java
index e6a7a1430d4e..3331f43f809a 100644
--- a/odk/examples/java/DocumentHandling/DocumentPrinter.java
+++ b/odk/examples/java/DocumentHandling/DocumentPrinter.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
import com.sun.star.uno.UnoRuntime;
@@ -56,10 +56,10 @@ public class DocumentPrinter {
// get the remote office service manager
com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();
-
+
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
-
+
com.sun.star.frame.XComponentLoader xCompLoader =
(com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface(
@@ -68,17 +68,17 @@ public class DocumentPrinter {
java.io.File sourceFile = new java.io.File(args[1]);
StringBuffer sUrl = new StringBuffer("file:///");
sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
-
+
// Load a Writer document, which will be automaticly displayed
com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
sUrl.toString(), "_blank", 0,
new com.sun.star.beans.PropertyValue[0] );
-
+
// Querying for the interface XPrintable on the loaded document
com.sun.star.view.XPrintable xPrintable =
(com.sun.star.view.XPrintable)UnoRuntime.queryInterface(
com.sun.star.view.XPrintable.class, xComp);
-
+
// Setting the property "Name" for the favoured printer (name of
// IP address)
com.sun.star.beans.PropertyValue propertyValue[] =
@@ -86,19 +86,19 @@ public class DocumentPrinter {
propertyValue[0] = new com.sun.star.beans.PropertyValue();
propertyValue[0].Name = "Name";
propertyValue[0].Value = args[ 0 ];
-
+
// Setting the name of the printer
xPrintable.setPrinter( propertyValue );
-
+
// Setting the property "Pages" so that only the desired pages
// will be printed.
propertyValue[0] = new com.sun.star.beans.PropertyValue();
propertyValue[0].Name = "Pages";
propertyValue[0].Value = args[ 2 ];
-
+
// Printing the loaded document
xPrintable.print( propertyValue );
-
+
System.exit(0);
}
catch( Exception e ) {
diff --git a/odk/examples/java/DocumentHandling/DocumentSaver.java b/odk/examples/java/DocumentHandling/DocumentSaver.java
index f6f21ea48228..93d6231a4b44 100644
--- a/odk/examples/java/DocumentHandling/DocumentSaver.java
+++ b/odk/examples/java/DocumentHandling/DocumentSaver.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
import com.sun.star.uno.UnoRuntime;
@@ -44,7 +44,7 @@ public class DocumentSaver {
* @param args The program needs two arguments:
* - full file name to open,
* - full file name to save.
- */
+ */
public static void main(String args[]) {
if ( args.length < 2 ) {
System.out.println("usage: java -jar DocumentSaver.jar" +
@@ -66,10 +66,10 @@ public class DocumentSaver {
// get the remote office service manager
com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();
-
+
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
-
+
com.sun.star.frame.XComponentLoader xCompLoader =
(com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface(
@@ -88,7 +88,7 @@ public class DocumentSaver {
propertyValue[0] = new com.sun.star.beans.PropertyValue();
propertyValue[0].Name = "Hidden";
propertyValue[0].Value = new Boolean(true);
-
+
Object oDocToStore = xCompLoader.loadComponentFromURL(
sLoadUrl.toString(), "_blank", 0, propertyValue );
com.sun.star.frame.XStorable xStorable =
@@ -106,7 +106,7 @@ public class DocumentSaver {
System.out.println("\nDocument \"" + sLoadUrl + "\" saved under \"" +
sSaveUrl + "\"\n");
-
+
com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
oDocToStore );
@@ -120,7 +120,7 @@ public class DocumentSaver {
com.sun.star.lang.XComponent.class, oDocToStore );
xComp.dispose();
}
- System.out.println("document closed!");
+ System.out.println("document closed!");
System.exit(0);
}
catch( Exception e ) {