[Solved] Modify document without opening it visually

Java, C++, C#, Delphi, ??? - Using the UNO bridges

[Solved] Modify document without opening it visually

Postby jacklafrip » Mon May 30, 2011 12:00 pm

Hi all,

First, Sorry for my bad English.

I'm working on a automatic generation of a document, exported after modification in pdf format.
It is working very well, but now that I know my document is good, and correclty generated in pdf format, I want to do it without it is opened visually by open office, that means the user will not see his openoffice document, but just his pdf document.
In the code that I used for pdf formatting creates a XComponent, that is load from URL with "_blanck" target.
Itry to use "Hidden", but it seems to be not existing.

How to i create a XComponent to be used as a XStorage without opening it in a frame ?

Thank you for your responses
Last edited by Hagar Delest on Mon May 30, 2011 8:41 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.3 on WindowsXP / VisualStudio 2005
jacklafrip
 
Posts: 7
Joined: Mon May 30, 2011 11:41 am

Re: Modify document without opening it visually

Postby FJCC » Mon May 30, 2011 3:20 pm

If you are using the loadComponentFromURL method, the fourth argument is an array of PropertyValues. The possible values of this array are listed here. As you can see, one of these is called Hidden. In OOo Basic this could be used like this
Code: Select all   Expand viewCollapse view
Dim Propvals(0) as New com.sun.star.beans.PropertyValue
Propvals(0).Name = Hidden
Propvals(0).Value = True
oDoc = StarDesktop.loadComponentFromURL(sURL, "_blank", 0, Propvals())

where sURL is a valid document URL. I didn't actually test that code, so I hope it doesn't have any stupid mistakes.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7748
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Modify document without opening it visually

Postby jacklafrip » Mon May 30, 2011 5:37 pm

Dera FJCC,

Thank you for your answer.
I have try this following code.
Code: Select all   Expand viewCollapse view
      
static XComponent initDocument(XComponentLoader aLoader, string file, string target)
{
   unoidl.com.sun.star.beans.PropertyValue[] propertyValue = new unoidl.com.sun.star.beans.PropertyValue[1];
   propertyValue[0] = new unoidl.com.sun.star.beans.PropertyValue();
   propertyValue[0].Name = "Hidden";
   propertyValue[0].Value = new uno.Any("true");
   XComponent xComponent = aLoader.loadComponentFromURL(file, target, 0, propertyValue);

   return xComponent;
}

But then, xComponent is always "null".

if I comment the Name assignation, or the Value assignation, there is no problem OpenOffice starts and xComponent is not null.

Do you have any idea? Should I use another method?
Best regards,
OpenOffice 3.3 on WindowsXP / VisualStudio 2005
jacklafrip
 
Posts: 7
Joined: Mon May 30, 2011 11:41 am

Re: Modify document without opening it visually

Postby jacklafrip » Mon May 30, 2011 5:46 pm

Sorry,
I did a big mistake.
I had to use an Any with a boolean, not with a String.
So the good code is the following:

Code: Select all   Expand viewCollapse view
      
static XComponent initDocument(XComponentLoader aLoader, string file, string target)
{
   unoidl.com.sun.star.beans.PropertyValue[] propertyValue = new unoidl.com.sun.star.beans.PropertyValue[1];
   propertyValue[0] = new unoidl.com.sun.star.beans.PropertyValue();
   propertyValue[0].Name = "Hidden";
   propertyValue[0].Value = new uno.Any(true);
   XComponent xComponent = aLoader.loadComponentFromURL(file, target, 0, propertyValue);

   return xComponent;
}


This now is fully functional.
Bye
jacklafrip
 
Posts: 7
Joined: Mon May 30, 2011 11:41 am


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests