OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Writer Examples
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Tue Feb 08, 2005 7:56 am    Post subject: Re: Search and get the text, hyperlinkURL in a document Reply with quote

lsropia wrote:
I have a problem. I have to make a document from large number of html files in a directory.

You are likely to get the best result by posting your question as a new thread in the Macros and API section.

Someone else may already know how to do what you want.

Being a new question on its own thread, it is easy to discuss various detailed aspects of the overall problem.

I'll keep your question bookmarked. I'll come back to it if I find a solution or if I have time to develop a solution.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Sat Mar 05, 2005 11:31 am    Post subject: Reply with quote

Here is an example of how to create shapes in a Writer document that have persistent custom attributes.
http://www.oooforum.org/forum/viewtopic.phtml?p=69067#69067
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Thu Mar 31, 2005 12:30 pm    Post subject: Reply with quote

Here is an example of adding text to a text frame.
http://www.oooforum.org/forum/viewtopic.phtml?p=72774#72774
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
p00hba
Newbie
Newbie


Joined: 04 Apr 2006
Posts: 3

PostPosted: Tue Apr 04, 2006 8:45 am    Post subject: DannyB is the Man! Reply with quote

Yo DannyB, thx for all the writeups! Very Happy
Back to top
View user's profile Send private message
kog
Newbie
Newbie


Joined: 27 Apr 2006
Posts: 3

PostPosted: Thu Apr 27, 2006 10:08 pm    Post subject: Reply with quote

Does anyone know how to set the page orientation for a text document ?
Thanks,
kog
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Sat Apr 29, 2006 9:52 pm    Post subject: Reply with quote

This doesn't answer your question but have a look :
Export selection to PDF in landscape mode? http://www.oooforum.org/forum/viewtopic.phtml?t=28408
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
spotsy8a
Newbie
Newbie


Joined: 01 Aug 2006
Posts: 1
Location: Spain

PostPosted: Tue Aug 01, 2006 9:16 am    Post subject: Re: Writer Examples Reply with quote

Hi Danny, I'm very interesting in this code "Obtain a Writer document by either.... or Create a new one" and the consecutives steps that you have in this section"

But I have a problem, your code is in Visual Basic or Phyton, and I need in Java like in
http://www.oooforum.org/forum/viewtopic.phtml?t=19721&view=previous whit the name SimpleWriterExample.java, but only exist the creation of a new file, or the opening of an existing file.

My question is the next, Do you have the others points implemented in Java???
I refer to 2,3,4,5,6 whit clauses.

I saw you last works like CalcExamples.java, and is very easy work whit this file, some like this, Dou you have for Writer?????

Thanks a lot, And I hope your response. Or someone else to want to answer.


[quote="DannyB"]This is a short example program which shows how to...

1. Obtain a Writer document by either....
1A. Create a new one
1B. Open one from disk (both Linux and Windows examples), including loading a Word or RTF file.
1C. Access the current Writer document, assuming that this macro is embedded into a Writer document rather than some other type of document.
1D. Access the frontmost window, which must be a Writer document.

2. Put some content into the document.
2A. Changing the style of a paragraph.
2B. Moving the cursor within a document.

3. Print the document three different ways...
3A. Simple printing via. the API.
3B. Printing via. the API, but with some arguments.
3C. Using the dispatcher to print by displaying the pring job dialog box.

4. Save the Writer document in native OOo format.

5. Export the Writer document to...
* Word
* PDF
* RTF
* HTML

6. Close the document.

This example can serve as a companion to my similar example article for the Calc spreadsheet, which can be found here...
http://www.oooforum.org/forum/viewtopic.php?t=4996

Very Happy
_________________
José Luis O.
Back to top
View user's profile Send private message Yahoo Messenger
gidi
General User
General User


Joined: 14 Aug 2005
Posts: 5

PostPosted: Tue Aug 28, 2007 6:30 am    Post subject: Reply with quote

Hi Danny,

I hope you can help me...

I've a C# application, and i need to open a document (writer) and then replace text in it (replace Text1 with NewText for example).
and then i want to print it.

while doing it, i don't want the user to see that the writer was open (meaning to do all of this in hidden mode).

here is my code which i got from one of the guys here in the forum,

XComponentContext xComponentContext = Connector.GetComponentContext();
XMultiServiceFactory xMultiServiceFactory = Connector.GetMultiServiceFactory(xComponentContext);
XDesktop xDesktop = Connector.GetDesktop(xMultiServiceFactory);
string myFileToPrint = OpenOfficeLib.Document.Component.PathConverter(letter_loc_txt.Text);
XComponent xComponent = OpenOfficeLib.Document.Component.LoadDocument(
(XComponentLoader)xDesktop, myFileToPrint, "_blank");

hope you can help me,
Thanks,
Gidi
Back to top
View user's profile Send private message
pauliv_de
General User
General User


Joined: 31 Aug 2007
Posts: 12
Location: Germany, Enger

PostPosted: Wed Apr 16, 2008 4:49 am    Post subject: Reply with quote

I was looking for an example how to insert an image into a tablecell, and I found it - thanks very much to Danny. But a have a problem and I didn't find a solution until now.

I want to know the size of the inserted image then I want to rescale it to specific needs and then write this new size into a cell of the table

So I inserted some lines of code....

Code:

Sub PutImageIntoCell( oDoc, oTable, nCol, nRow, cImageUrl )
   ' Create an image.
   oImage = oDoc.createInstance( "com.sun.star.text.GraphicObject" )
   oImage.GraphicURL = cImageUrl
   oImage.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
   
   oCell = oTable.getCellByPosition( nCol, nRow )
   ' Get the Text of the cell.
   ' After this line, you can do many things with oText,
   '  just as if it were the text of the main document.
   oText = oCell.getText()
   oCursor = oText.createTextCursor()
   oText.insertTextContent( oCursor, oImage, False )
   

'-------------------------------------------------------------------------------------
'--- additional lines start hereafter
'--- what is the size of the image ?
'-------------------------------------------------------------------------------------
   
     msgbox oImage.getName()     ' what happens here, if I comment this line out ?????

     dim oImageSize as new com.sun.star.awt.Size
   oImageSize = oImage.GetSize()
   
   msgbox " oImageSize width  : " & oImageSize.width & chr(10) &_
          " oImageSize height : " & oImageSize.height, 0, " oImageSize"

   oImageSize.width = oImageSize.width * 1.5
   oImageSize.height= oImageSize.height* 1.5
   
    oImage.setSize(oImageSize)
'------------------------------------------------------------------------------------
   PutTextIntoCell( oDoc, oTable, nCol, nRow,    "width:" & oImageSize.width &_
                                   chr(10) & "height:" & oImageSize.height &  chr(10))
   
End Sub


Sub PutTextIntoCell( oDoc, oTable, nCol, nRow, cText )
   oCell    = oTable.getCellByPosition( nCol, nRow )
   oText    = oCell.getText()
   oCursor    = oText.createTextCursor()
   oText.insertString(oCursor, cText ,FALSE)   
End Sub


This works fine until I have a look at the name of the image via msgbox ...

But if I do a comment at the msgbox-line
Code:

'msgbox oImage.getName()   

then I always get a size of 566 ! (*1.5 = 849)

But why ?
I cannot find my mistake, hopefully somebody can give me a hint.
Thanks in advance
Paul
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group