summaryrefslogtreecommitdiff
path: root/odk/examples/java/Text/TextDocumentStructure.java
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/java/Text/TextDocumentStructure.java')
-rw-r--r--odk/examples/java/Text/TextDocumentStructure.java58
1 files changed, 26 insertions, 32 deletions
diff --git a/odk/examples/java/Text/TextDocumentStructure.java b/odk/examples/java/Text/TextDocumentStructure.java
index f60ce98c937d..74b2659ac9ee 100644
--- a/odk/examples/java/Text/TextDocumentStructure.java
+++ b/odk/examples/java/Text/TextDocumentStructure.java
@@ -62,9 +62,8 @@ public class TextDocumentStructure {
// get the component laoder from the desktop to create a new
// text document
com.sun.star.frame.XComponentLoader xCLoader =
- (com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class,oDesktop);
+ com.sun.star.frame.XComponentLoader.class,oDesktop);
com.sun.star.beans.PropertyValue [] szEmptyArgs =
new com.sun.star.beans.PropertyValue [0];
String strDoc = "private:factory/swriter";
@@ -76,8 +75,8 @@ public class TextDocumentStructure {
// query the new document for the XTextDocument interface
com.sun.star.text.XTextDocument xTextDocument =
- (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface(
- com.sun.star.text.XTextDocument.class, xComp);
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComp);
// create some example data
com.sun.star.text.XText xText = xTextDocument.getText();
@@ -94,20 +93,18 @@ public class TextDocumentStructure {
System.out.println("create an enumeration of all paragraphs");
// create an enumeration access of all paragraphs of a document
com.sun.star.container.XEnumerationAccess xEnumerationAccess =
- (com.sun.star.container.XEnumerationAccess)
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class, xText);
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xText);
xParagraphEnumeration = xEnumerationAccess.createEnumeration();
// Loop through all paragraphs of the document
while ( xParagraphEnumeration.hasMoreElements() ) {
- xTextElement = (com.sun.star.text.XTextContent)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextContent.class,
- xParagraphEnumeration.nextElement());
+ xTextElement = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class,
+ xParagraphEnumeration.nextElement());
com.sun.star.lang.XServiceInfo xServiceInfo =
- (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
- com.sun.star.lang.XServiceInfo.class, xTextElement);
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xTextElement);
// check ifs the current paragraph really a paragraph or an
// anchor of a frame or picture
@@ -119,34 +116,31 @@ public class TextDocumentStructure {
// create another enumeration to get all text portions of
// the paragraph
xParaEnumerationAccess =
- (com.sun.star.container.XEnumerationAccess)
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class,
- xTextElement);
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class,
+ xTextElement);
xTextPortionEnum = xParaEnumerationAccess.createEnumeration();
while ( xTextPortionEnum.hasMoreElements() ) {
com.sun.star.text.XTextRange xTextPortion =
- (com.sun.star.text.XTextRange)UnoRuntime.queryInterface(
- com.sun.star.text.XTextRange.class,
- xTextPortionEnum.nextElement());
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xTextPortionEnum.nextElement());
System.out.println( "Text from the portion : "
+ xTextPortion.getString() );
com.sun.star.beans.XPropertySet xPropertySet =
- (com.sun.star.beans.XPropertySet)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class,
- xTextPortion);
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xTextPortion);
System.out.println( "Name of the font : "
+ xPropertySet.getPropertyValue( "CharFontName" ) );
// PropertyState status of each text portion.
com.sun.star.beans.XPropertyState xPropertyState =
- (com.sun.star.beans.XPropertyState)
- UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertyState.class,
- xTextPortion);
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertyState.class,
+ xTextPortion);
if( xPropertyState.getPropertyState("CharWeight").equals(
com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE) )
@@ -181,16 +175,16 @@ public class TextDocumentStructure {
xText.setString( "This is an example sentence" );
com.sun.star.text.XWordCursor xWordCursor =
- (com.sun.star.text.XWordCursor)UnoRuntime.queryInterface(
- com.sun.star.text.XWordCursor.class, xText.getStart());
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XWordCursor.class, xText.getStart());
xWordCursor.gotoNextWord(false);
xWordCursor.gotoNextWord(false);
xWordCursor.gotoEndOfWord(true);
com.sun.star.beans.XPropertySet xPropertySet =
- (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class, xWordCursor );
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor );
xPropertySet.setPropertyValue("CharWeight",
new Float( com.sun.star.awt.FontWeight.BOLD ));