Re: [dev] Sections and appending documents

2009-03-25 Thread Fhomasp

Hey,

I was thinking about first writing the original document to disk and later
if an unmerge is needed to just use loadFromURL with the path of the
original document to reload it.  However it doesn't get past the loading of
the XComponent.  The application freezes as a result and I need to kill the
soffice.bin process manually.

This is the code:



 public void loadFromURL(final String aURL, final
 com.sun.star.beans.PropertyValue aArguments[],String target) {
 if(target == null){
 target = _self;
 }
 try {
 XMultiComponentFactory serviceFactory =
 getOOoConnection().getComponentContext().getServiceManager();
 xServiceFactory = (com.sun.star.lang.XMultiServiceFactory)
 UnoRuntime.queryInterface(
 com.sun.star.lang.XMultiServiceFactory.class,
 serviceFactory);
 
 if (xFrameWindow == null) {
 serviceFactory =
 getOOoConnection().getComponentContext().getServiceManager();
 removeAll();
 xFrameWindow =
 iConnection.createOfficeWindow(MyOOoBean.this);
 add(xFrameWindow.getAWTComponent());
 }
 if (aFrame == null) {
 com.sun.star.awt.XWindow xWindow =
 (com.sun.star.awt.XWindow)
 UnoRuntime.queryInterface(
 com.sun.star.awt.XWindow.class,
 xFrameWindow.getUNOWindowPeer());
 xFrame =
 xServiceFactory.createInstance(com.sun.star.frame.Frame);
 aFrame = new Frame((com.sun.star.frame.XFrame)
 UnoRuntime.queryInterface(
 com.sun.star.frame.XFrame.class, xFrame));
 aFrame.initialize(xWindow);
 aFrame.setName(aFrame.toString());
 
 // register the frame at the desktop
 com.sun.star.frame.XFrames xFrames =
 ((com.sun.star.frame.XFramesSupplier)
 UnoRuntime.queryInterface(
 com.sun.star.frame.XFramesSupplier.class,
 getOOoDesktop())).getFrames();
 xFrames.append(aFrame);
 }
 xURLTransformer = (com.sun.star.util.XURLTransformer)
 UnoRuntime.queryInterface(
 com.sun.star.util.XURLTransformer.class,

 xServiceFactory.createInstance(com.sun.star.util.URLTransformer));
 
 // get XComponentLoader from frame
 com.sun.star.frame.XComponentLoader xLoader =
 (com.sun.star.frame.XComponentLoader)

 UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
 aFrame);
 
 if (xLoader == null) {
 throw new java.lang.RuntimeException(
 com.sun.star.frame.Frame( + aFrame +
 ) without
 com.sun.star.frame.XComponentLoader);
 }
 
 com.sun.star.beans.PropertyValue aArgs[] =
 addArgument(aArguments, new
 com.sun.star.beans.PropertyValue(
 MacroExecutionMode, -1,
 new
 Short(com.sun.star.document.MacroExecMode.USE_CONFIG),

 com.sun.star.beans.PropertyState.DIRECT_VALUE));
 
 com.sun.star.lang.XComponent xComponent =
 xLoader.loadComponentFromURL(
 aURL, target, 0, aArgs); //2nd load doesn't get past
 this point resulting in a crash
 
 // nothing loaded?
 if (xComponent == null  aDocument != null) {
 // reactivate old document
 if (aFrame != null  aFrame.getController() != null)
 aFrame.getController().suspend(false);
 aDocument.setModified(true);
 
 // throw exception
 throw new java.io.IOException(
 Can not load a document: \ + aURL + \);
 }
 
 // Get document's XModifiable interface if any.
 xModel = (com.sun.star.frame.XModel)
 UnoRuntime.queryInterface(
 com.sun.star.frame.XModel.class, xComponent);
 aTxtDocument = (XTextDocument)
 UnoRuntime.queryInterface(XTextDocument.class,xComponent);
 XComponentContext xRemoteContext =
 com.sun.star.comp.helper.Bootstrap.bootstrap();
 
 aDocument = new OfficeDocument(xModel);
 
 //adding additional listeners to the frame
 createBroadCaster();
 
 
 } catch (NoConnectionException e) {
 
 }
 catch (IllegalArgumentException e) {
 e.printStackTrace();  //To change body of catch statement use
 File | Settings | File Templates.
 } catch (IOException e) {
 e.printStackTrace();  //To change body of catch statement use
 File | Settings | File Templates.
 } catch (Exception e) {
 e.printStackTrace();  //To change body of catch statement use
 File 

Re: [dev] Sections and appending documents

2009-03-24 Thread Grover Blue
yeah, I'm not sure how to do that.  I start with a fresh document.




On Mon, Mar 23, 2009 at 11:04 AM, Fhomasp thomas.peet...@realdolmen.comwrote:


 Hey,

 Now that the merging is working fine I seem to stumble upon a new question.
 How should I start unmerging the document, or actively rollback to the
 document state before the merge?

 Any idea's?

 At first I was thinking about closing the bean and its container and
 reloading the whole process from there, although it is way too time
 consuming.

 What doesn't work is just assigning a new Object to the bean, as the
 container keeps looking at the current one.

 Basically I should be able to clear the whole document and then use the
 same
 code as a merge, only with the first initial document as 2nd document for
 the merge.  I'm just not sure where to start.

 Oh and where can I find all the URL's in string format listed?  For
 example:
 serviceFactory.createInstance(com.sun.star.text.TextSection));
 or
 .uno:Print ?

 --
 View this message in context:
 http://www.nabble.com/Sections-and-appending-documents-tp22312435p22661953.html
 Sent from the openoffice - dev mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org




-- 
“If the American people ever allow private banks to control the issue of
their currency, first by inflation, then by deflation, the banks...will
deprive the people of all property until their children wake-up homeless on
the continent their fathers conquered... The issuing power should be taken
from the banks and restored to the people, to whom it properly belongs.
-- Thomas Jefferson

Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases --- Thomas Jefferson

www.CampaignForLiberty.org


Re: [dev] Sections and appending documents

2009-03-23 Thread Fhomasp

Hey,

Now that the merging is working fine I seem to stumble upon a new question. 
How should I start unmerging the document, or actively rollback to the
document state before the merge?

Any idea's?

At first I was thinking about closing the bean and its container and
reloading the whole process from there, although it is way too time
consuming.

What doesn't work is just assigning a new Object to the bean, as the
container keeps looking at the current one.

Basically I should be able to clear the whole document and then use the same
code as a merge, only with the first initial document as 2nd document for
the merge.  I'm just not sure where to start.

Oh and where can I find all the URL's in string format listed?  For example:
serviceFactory.createInstance(com.sun.star.text.TextSection));
or
.uno:Print ?

-- 
View this message in context: 
http://www.nabble.com/Sections-and-appending-documents-tp22312435p22661953.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-18 Thread Fhomasp


Ariel Constenla-Haile wrote:
 
 Hello Fhomasp,
 you're mixing things: a css.text.TextSection is to be instantiated at the 
 document factory, not at the global service manager.
 So you're mixing the css.lang.XMultiServiceFactory (implemented by the 
 css.text.[Generic]TextDocument)
 http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMultiServiceFactory.html
 
 with the css.lang.XMultiComponentFactory
 http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html
 Query css.lang.XMultiServiceFactory from your css.text.TextDocument, and
 then 
 invoke css.lang.XMultiServiceFactory.createInstance() which only takes an 
 string, no css.uno.XComponentContext
 

I did try the XMultiServiceFactory first.  However I didn't query it from
the TextDocument.  I used a global variable which got instantiated earlier. 
So thanks, now it works like a charm.


Ariel Constenla-Haile wrote:
 
 no, the problem is that you started coding without even studying the
 basics 
 first.
 http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide
 

Obviously that has a lot to do with it.  However I just needed to alter the
menubar and merge documents, which works now, thanks to this thread.  Most
of the Objects in the classes are globals and were already instantiated
earlier, which didn't require me to study the whole OOo thoroughly.
When I get the time to do so I will.

Thanks ;-)

-- 
View this message in context: 
http://www.nabble.com/Sections-and-appending-documents-tp22312435p22578997.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-18 Thread Grover Blue
 When I get the time to do so I will.



I've been saying that for years.  ;-D




 Thanks ;-)




--


Re: [dev] Sections and appending documents

2009-03-17 Thread Fhomasp

Thanks, you've been most helpful.

I do still have a problem with the createInstanceWithContext part.
The idea is to get an XNamed using:

xChildNamed = (XNamed) UnoRuntime.queryInterface(
 XNamed.class,

factory.createInstanceWithContext(com.sun.star.text.TextSection,componentContext));

Now there are two ways to get an XComponentContext object.  
One is to get it from the OfficeConnection object, which doesn't seem to
work for me.  The resulting XNamedObject is null.

The other is even worse.  Namely:
XComponentContext xRemoteContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();

Running this static method hangs my application.

I think the problem might be related to the environment of the application. 
The OOo document runs within a Swing context.  It might, I don't know for
sure.


Grover Blue wrote:
 
 That is my fault.  The class in the code below was a wrapper class.  The
 code should be something like:
 
 serviceFactory.createInstance(com.sun.star.text.TextSection);
 
 Also,
 
 componentExport  is just a method to export my document (ie, save using
 XStorable) .  The saved document will then be loaded using
 insertDocumentFromURL
 
 
 
 On Mon, Mar 16, 2009 at 11:58 AM, Fhomasp
 thomas.peet...@realdolmen.comwrote:
 

 Hey,

 I've been looking to merge an unknown nr. of documents in order to print
 them using a custom method.
 And so I came up to this code but there are a few things that are
 bothering
 me, which might be related to me being new to OOo Uno programming.
 All the documents are always OpenOffice 2.4 populated Writer templates.

 The problems I have are here:

 serviceFactory.createInstance(com.sun.star.text.TextSection, document1)

 I can't seem to find a (X)ServiceFactory type that allows two arguments
 (String, Object?).

 also the use of the method componentExport.  I know I should find it
 somewhere in the added links around here but with the first problem being
 unresolved, I haven't really gotten around to this one.

 Thanks at any rate already.  This thread does already showed that there
 is
 a
 possible solution to this.




 Grover Blue wrote:
 
  I got everything to work, except for images and horizontal line
 objects.
  Images are completely ignored and not imported into the document,
 whereas
  horizontal line objects are flushing themselves at the top of the
 current
  page.
 
  I do have a question about the section I am using.  If you look at the
  following code, am I properly inserting the second document (document2)
  into
  the newly created section?
 
  Here is my routine:
 
  public void appendDocument(XTextDocument document1, XTextDocument
  document2)
  throws IllegalArgumentException, java.lang.Exception {
 
  XText xDocText = document1.getText();
  XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
  XNamed xChildNamed;
  XTextContent xChildContent;
  String tempDoc = generateTempDocucmentPathName();
 
  xOrigDocTextCursor.gotoEnd(false);
 
  xDocText.insertControlCharacter(xOrigDocTextCursor,
  ControlCharacter.PARAGRAPH_BREAK, false);
 
  xChildNamed = (XNamed) UnoRuntime.queryInterface(
   XNamed.class,
 
  serviceFactory.createInstance(com.sun.star.text.TextSection,
  document1));
 
  xChildNamed.setName( + document2.hashCode());
 
  xChildContent = (XTextContent) UnoRuntime.queryInterface(
  XTextContent.class,
  xChildNamed);
 
  /*  Add document2 to the new section */
  xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
  false);
 
  PropertyValue[] storeProps = createPropertyValueArray(
  createPropertyValue(FilterName, new
  Any(Type.STRING, writer8_template)),
  createPropertyValue(CompressionMode,
 new
  Any(Type.STRING, 1)),
  createPropertyValue(Pages, new
  Any(Type.STRING, All)),
  createPropertyValue(Overwrite, new
  Any(Type.BOOLEAN, Boolean.TRUE)));
 
  componentExport(document2, storeProps, tempDoc);
 
  XDocumentInsertable xDocI = (XDocumentInsertable)
  UnoRuntime.queryInterface(
  XDocumentInsertable.class,
  xOrigDocTextCursor);
 
  PropertyValue[] loadProps=new PropertyValue[0];
 
  xDocI.insertDocumentFromURL(file:/// + tempDoc, loadProps);
 
  deleteFile(tempDoc);
  }
 
 

 --
 View this message in context:
 http://www.nabble.com/Sections-and-appending-documents-tp22312435p22541182.html
 Sent from the openoffice - dev mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional 

Re: [dev] Sections and appending documents

2009-03-17 Thread Ariel Constenla-Haile
Hello Fhomasp,

On Tuesday 17 March 2009, 07:50, Fhomasp wrote:
 Thanks, you've been most helpful.

 I do still have a problem with the createInstanceWithContext part.

 factory.createInstanceWithContext(com.sun.star.text.TextSection,component
Context));

you're mixing things: a css.text.TextSection is to be instantiated at the 
document factory, not at the global service manager.
So you're mixing the css.lang.XMultiServiceFactory (implemented by the 
css.text.[Generic]TextDocument)
http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMultiServiceFactory.html

with the css.lang.XMultiComponentFactory
http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html

Query css.lang.XMultiServiceFactory from your css.text.TextDocument, and then 
invoke css.lang.XMultiServiceFactory.createInstance() which only takes an 
string, no css.uno.XComponentContext

http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMultiServiceFactory.html#createInstance

 I think the problem might be related to the environment of the application.

no, the problem is that you started coding without even studying the basics 
first.
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter.
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-16 Thread Fhomasp

Hey,

I've been looking to merge an unknown nr. of documents in order to print
them using a custom method.
And so I came up to this code but there are a few things that are bothering
me, which might be related to me being new to OOo Uno programming.
All the documents are always OpenOffice 2.4 populated Writer templates.

The problems I have are here:

serviceFactory.createInstance(com.sun.star.text.TextSection, document1)

I can't seem to find a (X)ServiceFactory type that allows two arguments
(String, Object?).

also the use of the method componentExport.  I know I should find it
somewhere in the added links around here but with the first problem being
unresolved, I haven't really gotten around to this one.

Thanks at any rate already.  This thread does already showed that there is a
possible solution to this.




Grover Blue wrote:
 
 I got everything to work, except for images and horizontal line objects.
 Images are completely ignored and not imported into the document, whereas
 horizontal line objects are flushing themselves at the top of the current
 page.
 
 I do have a question about the section I am using.  If you look at the
 following code, am I properly inserting the second document (document2)
 into
 the newly created section?
 
 Here is my routine:
 
 public void appendDocument(XTextDocument document1, XTextDocument
 document2)
 throws IllegalArgumentException, java.lang.Exception {
 
 XText xDocText = document1.getText();
 XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
 XNamed xChildNamed;
 XTextContent xChildContent;
 String tempDoc = generateTempDocucmentPathName();
 
 xOrigDocTextCursor.gotoEnd(false);
 
 xDocText.insertControlCharacter(xOrigDocTextCursor,
 ControlCharacter.PARAGRAPH_BREAK, false);
 
 xChildNamed = (XNamed) UnoRuntime.queryInterface(
  XNamed.class,
 
 serviceFactory.createInstance(com.sun.star.text.TextSection,
 document1));
 
 xChildNamed.setName( + document2.hashCode());
 
 xChildContent = (XTextContent) UnoRuntime.queryInterface(
 XTextContent.class,
 xChildNamed);
 
 /*  Add document2 to the new section */
 xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
 false);
 
 PropertyValue[] storeProps = createPropertyValueArray(
 createPropertyValue(FilterName, new
 Any(Type.STRING, writer8_template)),
 createPropertyValue(CompressionMode, new
 Any(Type.STRING, 1)),
 createPropertyValue(Pages, new
 Any(Type.STRING, All)),
 createPropertyValue(Overwrite, new
 Any(Type.BOOLEAN, Boolean.TRUE)));
 
 componentExport(document2, storeProps, tempDoc);
 
 XDocumentInsertable xDocI = (XDocumentInsertable)
 UnoRuntime.queryInterface(
 XDocumentInsertable.class,
 xOrigDocTextCursor);
 
 PropertyValue[] loadProps=new PropertyValue[0];
 
 xDocI.insertDocumentFromURL(file:/// + tempDoc, loadProps);
 
 deleteFile(tempDoc);
 }
 
 

-- 
View this message in context: 
http://www.nabble.com/Sections-and-appending-documents-tp22312435p22541182.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-16 Thread Grover Blue
That is my fault.  The class in the code below was a wrapper class.  The
code should be something like:

serviceFactory.createInstance(com.sun.star.text.TextSection);

Also,

componentExport  is just a method to export my document (ie, save using
XStorable) .  The saved document will then be loaded using
insertDocumentFromURL



On Mon, Mar 16, 2009 at 11:58 AM, Fhomasp thomas.peet...@realdolmen.comwrote:


 Hey,

 I've been looking to merge an unknown nr. of documents in order to print
 them using a custom method.
 And so I came up to this code but there are a few things that are bothering
 me, which might be related to me being new to OOo Uno programming.
 All the documents are always OpenOffice 2.4 populated Writer templates.

 The problems I have are here:

 serviceFactory.createInstance(com.sun.star.text.TextSection, document1)

 I can't seem to find a (X)ServiceFactory type that allows two arguments
 (String, Object?).

 also the use of the method componentExport.  I know I should find it
 somewhere in the added links around here but with the first problem being
 unresolved, I haven't really gotten around to this one.

 Thanks at any rate already.  This thread does already showed that there is
 a
 possible solution to this.




 Grover Blue wrote:
 
  I got everything to work, except for images and horizontal line objects.
  Images are completely ignored and not imported into the document, whereas
  horizontal line objects are flushing themselves at the top of the current
  page.
 
  I do have a question about the section I am using.  If you look at the
  following code, am I properly inserting the second document (document2)
  into
  the newly created section?
 
  Here is my routine:
 
  public void appendDocument(XTextDocument document1, XTextDocument
  document2)
  throws IllegalArgumentException, java.lang.Exception {
 
  XText xDocText = document1.getText();
  XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
  XNamed xChildNamed;
  XTextContent xChildContent;
  String tempDoc = generateTempDocucmentPathName();
 
  xOrigDocTextCursor.gotoEnd(false);
 
  xDocText.insertControlCharacter(xOrigDocTextCursor,
  ControlCharacter.PARAGRAPH_BREAK, false);
 
  xChildNamed = (XNamed) UnoRuntime.queryInterface(
   XNamed.class,
 
  serviceFactory.createInstance(com.sun.star.text.TextSection,
  document1));
 
  xChildNamed.setName( + document2.hashCode());
 
  xChildContent = (XTextContent) UnoRuntime.queryInterface(
  XTextContent.class,
  xChildNamed);
 
  /*  Add document2 to the new section */
  xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
  false);
 
  PropertyValue[] storeProps = createPropertyValueArray(
  createPropertyValue(FilterName, new
  Any(Type.STRING, writer8_template)),
  createPropertyValue(CompressionMode,
 new
  Any(Type.STRING, 1)),
  createPropertyValue(Pages, new
  Any(Type.STRING, All)),
  createPropertyValue(Overwrite, new
  Any(Type.BOOLEAN, Boolean.TRUE)));
 
  componentExport(document2, storeProps, tempDoc);
 
  XDocumentInsertable xDocI = (XDocumentInsertable)
  UnoRuntime.queryInterface(
  XDocumentInsertable.class,
  xOrigDocTextCursor);
 
  PropertyValue[] loadProps=new PropertyValue[0];
 
  xDocI.insertDocumentFromURL(file:/// + tempDoc, loadProps);
 
  deleteFile(tempDoc);
  }
 
 

 --
 View this message in context:
 http://www.nabble.com/Sections-and-appending-documents-tp22312435p22541182.html
 Sent from the openoffice - dev mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org




-- 
“If the American people ever allow private banks to control the issue of
their currency, first by inflation, then by deflation, the banks...will
deprive the people of all property until their children wake-up homeless on
the continent their fathers conquered... The issuing power should be taken
from the banks and restored to the people, to whom it properly belongs.
-- Thomas Jefferson

Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases --- Thomas Jefferson

www.CampaignForLiberty.org


Re: [dev] Sections and appending documents

2009-03-05 Thread Tor Lillqvist
 On 2009-03-05 at 02:15, grover.b...@gmail.com wrote:
 file:/// + tempDoc

That is very wrong. Use whatever proper API that I am sure Java provides to 
construct  a file: URI from a file name.

--tml


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-05 Thread Grover Blue
Tor, thanks for your input.  I updated my code to reflect that.

I would also like to let everyone know that this issue has been resolved.
The original file was Word document that we ran through a converter.
Apparently, the original image was BMP and the conversion saved that image
as an object in the ODT file (instead of an embedded image).  I deleted the
BMP image object from the OpenOffice template and re-added it as a PNG.
Since doing so everything is working fine.

I want to thank everyone for all your help, and I hope this thread proves
useful to someone else.

Thanks.


On Thu, Mar 5, 2009 at 5:05 AM, Tor Lillqvist tlillqv...@novell.com wrote:

  On 2009-03-05 at 02:15, grover.b...@gmail.com wrote:
  file:/// + tempDoc

 That is very wrong. Use whatever proper API that I am sure Java provides to
 construct  a file: URI from a file name.

 --tml


 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org




-- 
“If the American people ever allow private banks to control the issue of
their currency, first by inflation, then by deflation, the banks...will
deprive the people of all property until their children wake-up homeless on
the continent their fathers conquered... The issuing power should be taken
from the banks and restored to the people, to whom it properly belongs.
-- Thomas Jefferson

Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases --- Thomas Jefferson

www.CampaignForLiberty.org


Re: [dev] Sections and appending documents

2009-03-04 Thread Peter Eberlein

Hi,
inserting Sections:
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Sections
inserting Documents at a cursors position:
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Inserting_Text_Files
Please be aware that instead of using a file-URL you can also insert 
from a Stream.


Regards

Peter

Grover Blue schrieb:

Does anyone have an example of inserting a section and merging two
XTextDocuments?

I'm stuck.  Below is what I have so far, but I'm not sure how to insert the
second document.

public void appendDocument(XTextDocument document1, XTextDocument document2)
throws IllegalArgumentException, java.lang.Exception {

XText xDocText = document1.getText();
XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
XNamed xChildNamed;
XTextContent xChildContent;
XPropertySet xOrigDocTextCursorProp;

xOrigDocTextCursor.gotoEnd(false);
xDocText.insertControlCharacter(xOrigDocTextCursor,
ControlCharacter.PARAGRAPH_BREAK, false);

xOrigDocTextCursorProp = (XPropertySet)
FileManager.getOOoUnoRuntimeQueryInterface(
XPropertySet.class,
xOrigDocTextCursor);

xOrigDocTextCursorProp.setPropertyValue(BreakType,
BreakType.PAGE_BEFORE);

xChildNamed = (XNamed) FileManager.getOOoUnoRuntimeQueryInterface(
XNamed.class,

FileManager.getOOoUnoRuntimeCreateInstance(com.sun.star.text.TextSection));

xChildNamed.setName(NewSection);
xChildContent = (XTextContent)
FileManager.getOOoUnoRuntimeQueryInterface(
XTextContent.class,
xChildNamed);

/*  Add document2 to the new section somehow */

xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
false);

Thanks





-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-04 Thread Grover Blue
I found examples of inserting via a file, but I'm confused on how I would go
from a XTextDocument to an input stream.  I guess I'd need to use an
XInputStream object (assuming that is the interface I want to use when
passing the InputStream property to XDocumentInsertable), but it's not
clear on how to obtain that from XTextDocument.  You wouldn't happen to have
an example?




On Wed, Mar 4, 2009 at 9:46 AM, Peter Eberlein 
pet@refofd.verwalt-berlin.de wrote:

 Hi,
 inserting Sections:

 http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Sections
 inserting Documents at a cursors position:

 http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Inserting_Text_Files
 Please be aware that instead of using a file-URL you can also insert from a
 Stream.

 Regards

 Peter

 Grover Blue schrieb:

  Does anyone have an example of inserting a section and merging two
 XTextDocuments?

 I'm stuck.  Below is what I have so far, but I'm not sure how to insert
 the
 second document.

 public void appendDocument(XTextDocument document1, XTextDocument
 document2)
throws IllegalArgumentException, java.lang.Exception {

XText xDocText = document1.getText();
XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
XNamed xChildNamed;
XTextContent xChildContent;
XPropertySet xOrigDocTextCursorProp;

xOrigDocTextCursor.gotoEnd(false);
xDocText.insertControlCharacter(xOrigDocTextCursor,
 ControlCharacter.PARAGRAPH_BREAK, false);

xOrigDocTextCursorProp = (XPropertySet)
 FileManager.getOOoUnoRuntimeQueryInterface(
XPropertySet.class,
xOrigDocTextCursor);

xOrigDocTextCursorProp.setPropertyValue(BreakType,
 BreakType.PAGE_BEFORE);

xChildNamed = (XNamed) FileManager.getOOoUnoRuntimeQueryInterface(
XNamed.class,


 FileManager.getOOoUnoRuntimeCreateInstance(com.sun.star.text.TextSection));

xChildNamed.setName(NewSection);
xChildContent = (XTextContent)
 FileManager.getOOoUnoRuntimeQueryInterface(
XTextContent.class,
xChildNamed);

/*  Add document2 to the new section somehow */

xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
 false);

 Thanks




 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org




-- 
“If the American people ever allow private banks to control the issue of
their currency, first by inflation, then by deflation, the banks...will
deprive the people of all property until their children wake-up homeless on
the continent their fathers conquered... The issuing power should be taken
from the banks and restored to the people, to whom it properly belongs.
-- Thomas Jefferson

Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases --- Thomas Jefferson

www.CampaignForLiberty.org


Re: [dev] Sections and appending documents

2009-03-04 Thread Peter Eberlein

Grover Blue schrieb:

I found examples of inserting via a file, but I'm confused on how I would go
from a XTextDocument to an input stream.  I guess I'd need to use an
XInputStream object (assuming that is the interface I want to use when
passing the InputStream property to XDocumentInsertable), but it's not
clear on how to obtain that from XTextDocument.  You wouldn't happen to have
an example?


Sorry, no.
If you have a XTextDocument, I guess you have a URL where it is stored. 
If not (created from a template and modified) you can store it to a 
temp-folder or to a stream which you can reuse, for example 
http://user.services.openoffice.org/en/forum/viewtopic.php?f=44t=3801start=0st=0sk=tsd=a


Peter



-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-04 Thread Grover Blue
I got everything to work, except for images and horizontal line objects.
Images are completely ignored and not imported into the document, whereas
horizontal line objects are flushing themselves at the top of the current
page.

I do have a question about the section I am using.  If you look at the
following code, am I properly inserting the second document (document2) into
the newly created section?

Here is my routine:

public void appendDocument(XTextDocument document1, XTextDocument
document2)
throws IllegalArgumentException, java.lang.Exception {

XText xDocText = document1.getText();
XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
XNamed xChildNamed;
XTextContent xChildContent;
String tempDoc = generateTempDocucmentPathName();

xOrigDocTextCursor.gotoEnd(false);

xDocText.insertControlCharacter(xOrigDocTextCursor,
ControlCharacter.PARAGRAPH_BREAK, false);

xChildNamed = (XNamed) UnoRuntime.queryInterface(
 XNamed.class,

serviceFactory.createInstance(com.sun.star.text.TextSection, document1));

xChildNamed.setName( + document2.hashCode());

xChildContent = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class,
xChildNamed);

/*  Add document2 to the new section */
xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
false);

PropertyValue[] storeProps = createPropertyValueArray(
createPropertyValue(FilterName, new
Any(Type.STRING, writer8_template)),
createPropertyValue(CompressionMode, new
Any(Type.STRING, 1)),
createPropertyValue(Pages, new
Any(Type.STRING, All)),
createPropertyValue(Overwrite, new
Any(Type.BOOLEAN, Boolean.TRUE)));

componentExport(document2, storeProps, tempDoc);

XDocumentInsertable xDocI = (XDocumentInsertable)
UnoRuntime.queryInterface(
XDocumentInsertable.class,
xOrigDocTextCursor);

PropertyValue[] loadProps=new PropertyValue[0];

xDocI.insertDocumentFromURL(file:/// + tempDoc, loadProps);

deleteFile(tempDoc);
}


On Wed, Mar 4, 2009 at 10:38 AM, Peter Eberlein 
pet@refofd.verwalt-berlin.de wrote:

 Grover Blue schrieb:

 I found examples of inserting via a file, but I'm confused on how I would
 go
 from a XTextDocument to an input stream.  I guess I'd need to use an
 XInputStream object (assuming that is the interface I want to use when
 passing the InputStream property to XDocumentInsertable), but it's not
 clear on how to obtain that from XTextDocument.  You wouldn't happen to
 have
 an example?

  Sorry, no.
 If you have a XTextDocument, I guess you have a URL where it is stored. If
 not (created from a template and modified) you can store it to a temp-folder
 or to a stream which you can reuse, for example
 http://user.services.openoffice.org/en/forum/viewtopic.php?f=44t=3801start=0st=0sk=tsd=a

 Peter




 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org




-- 
“If the American people ever allow private banks to control the issue of
their currency, first by inflation, then by deflation, the banks...will
deprive the people of all property until their children wake-up homeless on
the continent their fathers conquered... The issuing power should be taken
from the banks and restored to the people, to whom it properly belongs.
-- Thomas Jefferson

Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases --- Thomas Jefferson

www.CampaignForLiberty.org


Re: [dev] Sections and appending documents

2009-03-04 Thread Cor Nouws

Hi,

Grover Blue wrote (4-3-2009 22:22)

I got everything to work, except for images and horizontal line objects.
Images are completely ignored and not imported into the document, whereas
horizontal line objects are flushing themselves at the top of the current
page.
[...]


Are you aware that those objects are on the Draw page object? Maybe that 
is the cause..



/*  Add document2 to the new section */
xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
false);
[...]



Regards,
Cor

--
Cor Nouws-nl.OpenOffice.org marketing contact
= 2009 - Develop OOo   =   www.nieuwsteoffice.nl  =

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-04 Thread Grover Blue
hi Cor,

I'm not sure what you mean by on the Draw page object.   I have found
forum posts where images were imported fine:

http://www.oooforum.org/forum/viewtopic.phtml?t=45027

My images are not in a header/footer, but there seems to be a frame style
associated with them.

I am so close to completing this!




On Wed, Mar 4, 2009 at 4:42 PM, Cor Nouws oo...@nouenoff.nl wrote:

 Hi,

 Grover Blue wrote (4-3-2009 22:22)

 I got everything to work, except for images and horizontal line objects.
 Images are completely ignored and not imported into the document, whereas
 horizontal line objects are flushing themselves at the top of the current
 page.
 [...]


 Are you aware that those objects are on the Draw page object? Maybe that is
 the cause..

 /*  Add document2 to the new section */
xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
 false);
 [...]



 Regards,
 Cor



Re: [dev] Sections and appending documents

2009-03-04 Thread Cor Nouws

Hi,

Grover Blue wrote (4-3-2009 23:16)
I'm not sure what you mean by on the Draw page object.   


Images are placed on the Drawpage of the document. So when you import 
the text-content (see below), that might explain your problem.



I have found forum posts where images were imported fine:

http://www.oooforum.org/forum/viewtopic.phtml?t=45027


You can see that in this example another method is used: 
insertDocumentFromURL



My images are not in a header/footer, but there seems to be a frame style
associated with them.

I am so close to completing this!


You'll get there, I'm sure :-)

Succes,
Cor


On Wed, Mar 4, 2009 at 4:42 PM, Cor Nouws oo...@nouenoff.nl wrote:


Hi,

Grover Blue wrote (4-3-2009 22:22)


I got everything to work, except for images and horizontal line objects.
Images are completely ignored and not imported into the document, whereas
horizontal line objects are flushing themselves at the top of the current
page.
[...]


Are you aware that those objects are on the Draw page object? Maybe that is
the cause..

/*  Add document2 to the new section */

   xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
false);
[...]



--
Cor Nouws-nl.OpenOffice.org marketing contact
= 2009 - Develop OOo   =   www.nieuwsteoffice.nl  =

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] Sections and appending documents

2009-03-04 Thread Grover Blue
 I have found forum posts where images were imported fine:

 http://www.oooforum.org/forum/viewtopic.phtml?t=45027


 You can see that in this example another method is used:
 insertDocumentFromURL


I am using that same method (with the exception of Java vs C++):

xDocI.insertDocumentFromURL(file:/// + tempDoc, loadProps);

I'll post updates if I find anything.