| View previous topic :: View next topic |
| Author |
Message |
aloiziops Power User

Joined: 07 Jul 2006 Posts: 52
|
Posted: Tue Nov 07, 2006 1:35 pm Post subject: Merging documents |
|
|
I created one template *.ott which is upload as a writer document. Then I use this template to merge documents.
In template I put line spacing equal 1.5cm. When I merge the documents the merged document should have all text with line spacing 1.5, but it doesn't have. could someone help?
I set also in template margin left and right to 2cm and 1cm respectivally, this works. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Wed Nov 08, 2006 11:19 am Post subject: |
|
|
When you set line spacing for presumably the Default paragraph style to 1.5" did you do so in the Stylist which actually changes the style globally or did you do Format (or right click) > Paragraph which only does direct formatting of the current paragraph?
My quick test brought the merged single spaced file in as 1.5" spacing. I did the merge with Insert > File. |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3531 Location: Hamburg, Germany
|
|
| Back to top |
|
 |
aloiziops Power User

Joined: 07 Jul 2006 Posts: 52
|
Posted: Thu Nov 09, 2006 5:12 am Post subject: |
|
|
I am using the ppience of code below to change Paragraph attributes, but I get error.
| Code: | XPropertySet xPropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,mxDoc.getText());
// from styles.CharacterProperties
xPropSet.setPropertyValue("CharHeight", new Float(20.0));
// from styles.ParagraphProperties
xPropSet.setPropertyValue("ParaLeftMargin", new Integer(500)); |
This is the error:
| Code: | com.sun.star.lang.IllegalArgumentException:
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:275)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:141)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:377)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:346) | [/code] |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Thu Nov 09, 2006 6:24 am Post subject: |
|
|
I'm not much on reading Java code but it looks like you are get text and changing its properties which is direct formatting. To do what you want you need to get the paragraph style used by the target text and change its properties.
Here is an example in Basic. | Code: | Sub Main
oDoc = ThisComponent
oStyles = oDoc.getStyleFamilies()
oParaStyles = oStyles.getByName("ParagraphStyles")
thisStyle = oParaStyles.getByName("Text body")
thisStyle.setPropertyValue("CharHeight",20)
End Sub |
Note that many paragraph styles are derived from, and therefore inherit most of their properties from, the Default paragraph (internally named Standard) so if you change a property of this style you may change a lot of other styles at the same time.
Last edited by JohnV on Thu Nov 09, 2006 9:22 am; edited 1 time in total |
|
| Back to top |
|
 |
aloiziops Power User

Joined: 07 Jul 2006 Posts: 52
|
Posted: Thu Nov 09, 2006 7:45 am Post subject: |
|
|
| I don't understand Basic. I need one example in Java. I tryed to map the basic code to java code, but didn't work. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Thu Nov 09, 2006 9:02 am Post subject: |
|
|
Serge,
You have made no mistakes it started out in Code Snippets, and you posted. I moved it to Writer where I initially thought it belonged. Then it became obvious that we were talking about a macro so I again moved it to Macros & API.
Now I'm going to clean the tread up by removing all the extra posts about where it belongs, where did it go, etc.
Hopefully someone can help the OP with sample Jave code because I can't. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Thu Nov 09, 2006 9:21 am Post subject: |
|
|
I think it's pretty obvious I don't know Java (actually I've forgotten what I use to know which certainly didn't include dealing with another program's API) but I have move this thread to the Macros & API section where you are more likely to get more help.
FWIW, "oDoc = ThisComponent" just gets the current document object as a whole and I'm sure your Java code does that in some manner or you couldn't work with the document. From that point onward my code simply creates other objects using a method available from the prior object until we have some paragraph style object. That object's setPropertyValue() method then changes one of the object properties but I'm sure you know that.
OOo Basic is very loose on syntax and I can get away with things Java won't permit. Very few things are case sensitive and I could get away with this for the last line of my code above by addressing a property directly.
thisStyle.CharHeight = 20
I have edited my code to add () after oDoc.getStyleFamilies which makes it a little more syntactically correct. A review of the case used for my methods and properties indicate all is correct (a matter of luck not intentional use of proper case). |
|
| Back to top |
|
 |
|