Re: [dev] custom menu item disappearing after printpreview

2009-03-31 Thread Fhomasp

Hey, thanks

I'm not very used to working with proxies.

Some new info about my issue here has come to light.  It would seem that
both your suggested approaches work occasionally.  That is, both only works
in debug mode.  Which makes me assume that it is a Threading issue.
However attempting to control the sequence of the Threads doesn't work at
all.  For example:

public void layoutEvent(EventObject eventObject, short i, Object object) {
if (i == LayoutManagerEvents.UIELEMENT_VISIBLE 
object.equals(private:resource/menubar/menubar)) {
SwingUtilities.invokeLater(new Runnable(){

public void run() {
try {
addParagraafMenu();
} catch (Exception e) {
throw new
SeriousException(e.getMessage(),this,e);
}
}
});

}
}



Carsten Driesner wrote:
 
 Fhomasp wrote:
 Hey, and thanks! :)

 You mean an XLayoutManagerEventBroadcaster I assume?
 I can't say I found many examples of an XLayoutManagerEventBroadcaster. 
 And
 I'm not sure where and which listener I need to attach.
   
 Hi Fhomasp,
 
 This is trivial if you look at the interface declaration of 
 com.sun.star.frame.XLayoutManagerEventBroadcaster. You need to implement 
 the interface com.sun.star.frame.XLayoutManagerListener. It contains 
 just on method called:
 
 void layoutEvent( [in] com::sun::star::lang::EventObject aSource, [in] 
 short eLayoutEvent, [in] any aInfo );
 
 As your code already retrieves the LayoutManager from the frame it's 
 fairly simple to query for 
 com.sun.star.frame.XLayoutManagerEventBroadcaster and call 
 addLayoutManagerEventListener( yourlistenerinstance ).
 
 In your implementation for layoutEvent(...) you should first look for 
 the interesting eLayoutEvent called UIELEMENT_VISIBLE. The aInfo 
 parameter contains the resource url of the user interface element. E.g. 
 for your use case this is private:resource/menubar/menubar. So if you 
 receive an event with eLayoutEvent == UIELEMENT_VISIBLE and aInfo == 
 private:resource/menubar/menubar than you should use the source (which 
 is the LayoutManager) to query for the menu bar. If the menu bar needs 
 to be changed you should call your configuration code.
 
 Regards,
 Carsten
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22800525.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] custom menu item disappearing after printpreview

2009-03-31 Thread Fhomasp

Hey,

Alright, noted.  However I still need to get this to work.  At this point it
seems that the LayoutManager lifecycle is already put into another Thread. 
How else could it be that I can get it working slightly better with the use
of Threads, and get 100% successrate if I wait long enough in Debug mode?
Still.  It's nowhere near a good solution, and I can't have the users go
through debug mode :-)




Carsten Driesner wrote:
 
 Fhomasp wrote:
 Hey, thanks

 I'm not very used to working with proxies.

 Some new info about my issue here has come to light.  It would seem that
 both your suggested approaches work occasionally.  That is, both only
 works
 in debug mode.  Which makes me assume that it is a Threading issue.
 However attempting to control the sequence of the Threads doesn't work at
 all.  For example:

 public void layoutEvent(EventObject eventObject, short i, Object object)
 {
 if (i == LayoutManagerEvents.UIELEMENT_VISIBLE 
 object.equals(private:resource/menubar/menubar)) {
 SwingUtilities.invokeLater(new Runnable(){

 public void run() {
 try {
 addParagraafMenu();
 } catch (Exception e) {
 throw new
 SeriousException(e.getMessage(),this,e);
 }
 }
 });

 }
 }
   
 Hi Fhomasp,
 
 Please don't call your menu bar changes in another thread. You have to 
 make the changes directly in the layoutEvent call. OpenOffice.org is not 
 well prepared for multi threading.
 
 Regards,
 Carsten
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22804128.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] custom menu item disappearing after printpreview

2009-03-31 Thread Fhomasp

I'm using OpenOffice 2.4.  It's not my choice.  Maybe that has something to
do with it.  There are a few other functions that seems to require OOo 2.4.

However with this version I've noticed some other strange behaviour as well. 
It might have something to do with how the proxies are implemented, although
that's just speculation on my part.
Of course the listeners do run in a seperate Thread, IIRC.

I'll send you my controller class and the Swing panel containing the
document.  No rush of course, you've been most helpful already.



Carsten Driesner wrote:
 
 Fhomasp wrote:
 Hey,

 Alright, noted.  However I still need to get this to work.  At this point
 it
 seems that the LayoutManager lifecycle is already put into another
 Thread. 
 How else could it be that I can get it working slightly better with the
 use
 of Threads, and get 100% successrate if I wait long enough in Debug mode?
 Still.  It's nowhere near a good solution, and I can't have the users go
 through debug mode :-)
   
 Hi Fhomasp,
 
 I don't know why you have these kind of problems as I cannot reproduce 
 it with my own implementation. I also know that the LayoutManager is 
 normally not running in a different thread. OpenOffice.org has just one 
 thread for the user interface called the main thread. It's possible to 
 call the LayoutManager from a different thread using remote UNO but I 
 cannot recommend it. The only thing I can propose to you is that you 
 send me your solution via mail and I will try to find out what's wrong. 
 As we are short before the release of OOo 3.1 I cannot promise that I 
 have time to check it in the next couple of days.
 
 Regards,
 Carsten
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
 For additional commands, e-mail: dev-h...@openoffice.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/custom-menu-item-disappearing-after-printpreview-tp22741195p22804938.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



[dev] custom menu item disappearing after printpreview

2009-03-27 Thread Fhomasp

Hey,

I implemented a custom menu item using one of the examples.  However this
extra menu item disappears as soon as a printpreview screen is invoked.  The
menu item doesn't return when the printpreview is closed.

Here's the code I used



 public void doMenuExtras() {
 try {
 //getting the extra menu names
 getConditionList();
 //you need the top window of the openoffice window
 if (xTraMenuList.size()  0) {
 
 String sMenuBar = private:resource/menubar/menubar;
 XComponentContext context =
 iConnection.getComponentContext();
 XMultiComponentFactory serviceMgr =
 context.getServiceManager();
 XPropertySet xps = (XPropertySet)
 UnoRuntime.queryInterface(
 XPropertySet.class, aFrame);
 XLayoutManager xLayoutManager = (XLayoutManager)
 UnoRuntime.queryInterface(
 XLayoutManager.class,
 xps.getPropertyValue(LayoutManager));
 
 //getting the menubar of the topwindow by the
 layoutmanager
 XUIElement oMenuBar = xLayoutManager.getElement(sMenuBar);
 menuBarProps = (XPropertySet) UnoRuntime.queryInterface(
 XPropertySet.class, oMenuBar);
 
 //the menubar we want is a property of the XUIElement
 oMenuBar
 XMenuBar bar = (XMenuBar)
 UnoRuntime.queryInterface(XMenuBar.class,
 menuBarProps.getPropertyValue(XMenuBar));
 
 XUIElementSettings xoMenuBarSettings =
 (XUIElementSettings) UnoRuntime
 .queryInterface(XUIElementSettings.class,
 oMenuBar);
 XIndexContainer oMenuBarSettings = (XIndexContainer)
 UnoRuntime
 .queryInterface(XIndexContainer.class,
 xoMenuBarSettings
 .getSettings(true));
 
 XSingleComponentFactory factory =
 (XSingleComponentFactory)
 UnoRuntime

 .queryInterface(XSingleComponentFactory.class,
 oMenuBarSettings);
 
 
 PropertyValue[] propsContainer = (PropertyValue[])
 oMenuBarSettings.getByIndex(0);
 XIndexContainer container = null;
 
 for (int i = 0; i  propsContainer.length; i++) {
 if
 (propsContainer[i].Name.equals(ItemDescriptorContainer)) {
 container = (XIndexContainer)
 UnoRuntime.queryInterface(XIndexContainer.class, propsContainer[i].Value);
 
 }
 }
 
 PropertyValue[] subPv1 = createMenuItem(.uno:Print++,
 FENIKS_PRINT, factory);
 
 container.insertByIndex(26, subPv1);
 xoMenuBarSettings.setSettings(oMenuBarSettings);
 XTopWindow topWindow = (XTopWindow)
 UnoRuntime.queryInterface(XTopWindow.class,
 xFrameWindow.getUNOWindowPeer());
 
 //inserting an new menu name
 bar.insertItem((short) 0, ~Paragraaf,
 com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0);
 //setting the menu
 bar.setPopupMenu((short) 0, getPopupMenu());
 
 //adding an menuListener
 bar.addMenuListener(this);
 
 //setting the new menubar
 topWindow.setMenuBar(bar);
 //not setting it persistent otherwise is will be added
 multiple times on every reload
 menuBarProps.setPropertyValue(Persistent, false); //true
 helpt niet voor het print prev prob
 
 
 }
 } catch (Exception e) {
 e.printStackTrace();  //To change body of catch statement use
 File | Settings | File Templates.
 }
 }
 
 public XPopupMenu getPopupMenu() {
 XPopupMenu xPopupMenu = null;
 try {
 // create a popup menu
 XComponentContext context = iConnection.getComponentContext();
 Object oPopupMenu =
 context.getServiceManager().createInstanceWithContext(stardiv.Toolkit.VCLXPopupMenu,
 context);
 xPopupMenu = (XPopupMenu)
 UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
 XMenuExtended xMenuExtended = (XMenuExtended)
 UnoRuntime.queryInterface(XMenuExtended.class, xPopupMenu);
 XTextSectionsSupplier oTSSupp = (XTextSectionsSupplier)
 UnoRuntime.queryInterface(
 XTextSectionsSupplier.class, aDocument);
 
 XNameAccess nameAccess = oTSSupp.getTextSections();
 
 
 for (int i = 0; i  xTraMenuList.size(); i++) {
 XPropertySet pAccess = (XPropertySet)
 UnoRuntime.queryInterface(XPropertySet.class,
 nameAccess.getByName(xTraMenuList.get(i)));
 xPopupMenu.insertItem((short) i, xTraMenuList.get(i),
 (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), (short) i);
 

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 

[dev] Dispatcher: .uno:Print wait for print job to finish

2009-03-24 Thread Fhomasp

Hey,

I need to have documents printed, which was ok to implement.
Basically I used the dispatcher to summon me the default print dialog in
writer.  After the ok from the user I need to close the JPanel in which is
the container for the office document.  Problem is that it gets closed
before the print job is finished and I'm not sure how to continue.  I can't
use Thread.sleep() as I won't know how many pages there are going to be or
how fast the target machine will be.  It's not good programming anyhow.

I thought I'd be able to do this using XNotifyingDispatch and an
XDispatchResultListener, however the problem persists.

Somehow I'd need to grab the print process and hold on to it until it
finishes.  Then I can close the container.  I don't really know how :-)

Here's my code:


 XURLTransformer xParser = (XURLTransformer)
 UnoRuntime.queryInterface(XURLTransformer.class,

 xServiceFactory.createInstance(com.sun.star.util.URLTransformer));
 URL [] parseUrl = new URL[1];
 parseUrl[0] = new URL();
 parseUrl[0].Complete = .uno:Print;
 if(xParser.parseStrict(parseUrl)){
 //ok
 }else
 {
 throw new TechnicalException(URL not
 validated,this);
 }
 
 XDispatch xDispatch =
 this.queryDispatch(parseUrl[0],,0);
 XNotifyingDispatch notifier = (XNotifyingDispatch)
 UnoRuntime.queryInterface(XNotifyingDispatch.class,
 xDispatch);
 if(notifier != null){

 notifier.dispatchWithNotification(parseUrl[0],propertyValues,new
 XDispatchResultListener(){
 
 public void
 dispatchFinished(DispatchResultEvent dre) {
 System.out.println(finish called!);
 
 if(dre.Result.equals(Boolean.TRUE)){
 brief.setBriefAfgedrukt(true);
 //I'd need to close the container here
 
 }else
 {
 panel.sluit(); //this works, there's
 no print job
 }
 }
 
 public void disposing(EventObject eventObject)
 {
 System.out.println(dispatch disposed!);
 //never gets called
 }
 
 });
 }
 
-- 
View this message in context: 
http://www.nabble.com/Dispatcher%3A-%22.uno%3APrint%22-wait-for-print-job-to-finish-tp22680911p22680911.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-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-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-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