Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

Problems after upgrading to Sierra or High Sierra? Try these steps
Problems after upgrading to NeoOffice 2017? Try these steps
Download or installation problems? Try these steps


Support
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


RSS Feeds
· Announcements Only
· All Posts


  
NeoOffice :: View topic - How to re-wrap imported text?
How to re-wrap imported text?
 
Post new topic   Reply to topic    NeoOffice Forum Index -> NeoOffice Releases
View previous topic :: View next topic  
Author Message
Dallas
Blue Pill


Joined: Dec 02, 2006
Posts: 1
Location: Tucson, AZ

PostPosted: Sat Dec 02, 2006 11:46 am    Post subject: How to re-wrap imported text? Reply with quote

Every week I copy and paste a 10 page text file into Word and click AutoFormat and it re-wraps the text to fit my wide margins.

However, I wish to use NeoOffice now and am not finding a way to simply re-wrap the text. I imagine this is so simple and I am just missing it somehow.

Can someone please help?
Back to top
View user's profile Send private message Visit poster's website
OPENSTEP
The One
The One


Joined: May 25, 2003
Posts: 4752
Location: Santa Barbara, CA

PostPosted: Sat Dec 02, 2006 2:05 pm    Post subject: Reply with quote

While I don't know of any autoformatting tools myself to "beautify" raw text that has embedded carriage returns, you can use the Find & Replace with regular expressions to turn carriage returns into spaces. Turn on regular expressions (More Options) and then search for "$" and replace with " " (no quotes in either). If you have some type of special character sequence separating your paragraphs like a heading style or something you could then do a second search and replace on that to reinsert carriage returns between paragraphs.

Not sure if it's useful but it might be a start.

ed
Back to top
View user's profile Send private message Visit poster's website AIM Address
ovvldc
Captain Naiobi


Joined: Sep 13, 2004
Posts: 2352
Location: Zürich, CH

PostPosted: Sat Dec 02, 2006 6:32 pm    Post subject: Reply with quote

I'd suggest saving yourself a lot of anguish by doing the following:

* search for double CR (i.e. new paragraphs) and replace these by a placeholder.
* search for single CR and covert to spaces
* replace placeholder by CR

That way, your entire text does not turn into a sinle paragraph of wrapped text..

Best wishes,
Oscar

_________________
"What do you think of Western Civilization?"
"I think it would be a good idea!"
- Mohandas Karamchand Gandhi
Back to top
View user's profile Send private message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Sun Dec 03, 2006 3:43 am    Post subject: Reply with quote

A lazy man's macro for this:
Code:
sub reWrap
rem --------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem --------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem --------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, Array())

rem --------------------------------------------------
dim searchArgs(18) as new com.sun.star.beans.PropertyValue
searchArgs(0).Name = "SearchItem.StyleFamily"
searchArgs(0).Value = 2
searchArgs(1).Name = "SearchItem.CellType"
searchArgs(1).Value = 0
searchArgs(2).Name = "SearchItem.RowDirection"
searchArgs(2).Value = true
searchArgs(3).Name = "SearchItem.AllTables"
searchArgs(3).Value = false
searchArgs(4).Name = "SearchItem.Backward"
searchArgs(4).Value = false
searchArgs(5).Name = "SearchItem.Pattern"
searchArgs(5).Value = false
searchArgs(6).Name = "SearchItem.Content"
searchArgs(6).Value = false
searchArgs(7).Name = "SearchItem.AsianOptions"
searchArgs(7).Value = false
searchArgs(8).Name = "SearchItem.AlgorithmType"
searchArgs(8).Value = 1
searchArgs(9).Name = "SearchItem.SearchFlags"
searchArgs(9).Value = 65536
searchArgs(10).Name = "SearchItem.SearchString"
searchArgs(11).Name = "SearchItem.ReplaceString"
searchArgs(12).Name = "SearchItem.Locale"
searchArgs(12).Value = 255
searchArgs(13).Name = "SearchItem.ChangedChars"
searchArgs(13).Value = 2
searchArgs(14).Name = "SearchItem.DeletedChars"
searchArgs(14).Value = 2
searchArgs(15).Name = "SearchItem.InsertedChars"
searchArgs(15).Value = 2
searchArgs(16).Name = "SearchItem.TransliterateFlags"
searchArgs(16).Value = 1280
searchArgs(17).Name = "SearchItem.Command"
searchArgs(17).Value = 3
searchArgs(18).Name = "Quiet"
searchArgs(18).Value = true

searchArgs(10).Value = "$"
searchArgs(11).Value = "±"

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, searchArgs())

searchArgs(10).Value = "±±"
searchArgs(11).Value = "$"

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, searchArgs())

searchArgs(10).Value = "±"
searchArgs(11).Value = " "

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, searchArgs())

end sub

I'm sure there's a much tidier way to do this using proper starbasic rather than dispatcher, but I haven't ever had time to learn that - whenever I try to write something in starbasic it doesn't work, sigh... anyway, I use the ± as a placeholder character because, let's face it, it's voted least likely to turn up in normal text.

Incidentally, I go about it this way (convert all CRs to something else, and *then* weed out the doubles) because depending on what kind of CRs you're dealing with, it can be hard to get Neo to find/replace double CRs, as the find/replace function is working on a 'per-paragraph' basis.

- padmavyuha
Back to top
View user's profile Send private message
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Sun Dec 03, 2006 11:10 am    Post subject: Reply with quote

I added a link to this macro to our Find/Replace page in the wiki.

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
View user's profile Send private message Visit poster's website
Lorinda
Captain Mifune


Joined: Jun 20, 2006
Posts: 2051
Location: Midwest, USA

PostPosted: Fri Apr 20, 2007 7:26 pm    Post subject: Reply with quote

At the risk of betraying my ignorance....

I would really like to use this macro, but I can't for the life of me figure out how to enter the code in NeoOffice. I know how to record a macro, but not how to take written code and save it so Neo can access it as a macro.

I've looked in the help file and the User Guide section on Macros to no avail.

No doubt this is incredibly simple, and I'm just overlooking something.

Thanks.
Back to top
View user's profile Send private message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Fri Apr 20, 2007 9:37 pm    Post subject: Reply with quote

go to Tools->Macros->Organise Macros->NeoOffice Basic... and then e.g. in My Macros-Standard-Module1 (it highights this by default) in the left panel, and Main highlighted in the right panel, click on Edit.

Then just paste the code in anywhere below the Main/End Sub lines - making sure you don't paste in the middle of any other macros you saved, so a couple of lines after Main's End Sub line is an obvious choice. Then hit Save and there it is.

- padmavyuha
Back to top
View user's profile Send private message
Lorinda
Captain Mifune


Joined: Jun 20, 2006
Posts: 2051
Location: Midwest, USA

PostPosted: Sat Apr 21, 2007 5:13 am    Post subject: Reply with quote

Thank you very much, yoxi. I knew it had to be simple, but I have to say that for someone like me who doesn't code at all, it was not an intuitive solution! (Not your fault, just the way OOo is.)

It worked perfectly, but it doing what you said, I discovered I already had a (different) macro there to remove the carriage returns. I must have downloaded and installed it from somewhere. Embarassed

So, the "Main" category contains the code for all the macros in that Module, is that correct?
Back to top
View user's profile Send private message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Sat Apr 21, 2007 7:01 am    Post subject: Reply with quote

Sorry, when I posted the macro originally it didn't occur to me to explain how to add it in!

Yes, in the NeoOffice Basic window's right pane, the Module1 list will show Main and all other 'existing macros' added - I'm sure, if memory serves, that in previous versions this list sorted alphabetically, but now it appears to be in the order in which the macros appear within that module.

- padmavyuha
Back to top
View user's profile Send private message
Slrman
Blue Pill


Joined: Mar 06, 2009
Posts: 1

PostPosted: Fri Mar 06, 2009 9:54 am    Post subject: Reply with quote

I have been chasing all over the net trying to do what I thought would be simple. I want to reformat text files in NeoOffice by finding Paragraph marks and replacing them with two paragraph marks. This is so the file will be easier to read on my ebook reader. (iRex Iliad)

Sometimes I also need to do a find/replace for a Paragraph mark and a manual line break, too. In addition, I usually like to replace a Paragraph mark followed by two or more spaces to indent the next paragraph. In those cases, I want two paragraph marks again.

None of the codes I have found for regular expressions seem to work. If I enter a ^$ for the mark, it doesn't like that. If I enter a plain $, it doesn't like that, either. If I enter the /n or /n/n in the replace field that's what it puts in the document.

I suspect I am not different from most when I say I would prefer not to enter all of these things manually. Wink So, is there a solution?
Back to top
View user's profile Send private message Yahoo Messenger
OPENSTEP
The One
The One


Joined: May 25, 2003
Posts: 4752
Location: Santa Barbara, CA

PostPosted: Fri Mar 06, 2009 10:21 am    Post subject: Reply with quote

Ah, to put in a newline, you should use a backslash, not a forward slash:

\n

That will translate to a newline.

Also, make sure that regular expressions are enabled. By default regular expression support in the find/replace dialog is disabled. You will need to enable it by clicking the "More Options" button and checking the regular expression checkbox.

ed
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    NeoOffice Forum Index -> NeoOffice Releases All times are GMT - 7 Hours
Page 1 of 1

 
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
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.03 Seconds