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

How to replace existing standard quotes with custom quotes ?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
tfg004
Newbie
Newbie


Joined: 18 Jun 2007
Posts: 3

PostPosted: Mon Jun 18, 2007 4:32 am    Post subject: How to replace existing standard quotes with custom quotes ? Reply with quote

Hi,

I have lots of documents which were written in OOo v1.x with standard quotes.
I'm using v2.0.4 now and have standard quotes automatically replaced with custom quotes by the AutoCorrect settings.

However, I couldn't find a way to automatically replace the standard quotes in all my older documents.

I found an old thread about this, and user RGB suggested:
Quote:
The opening quotes usually comes with a space before them, and the closing ones with a character instead: if you do a search-replace using space+normal quote, and replacing it by space+custom quote, you will be able to replace the opening quotes, then, doing a search-replace using normal quotes -> custom quotes, you will be able to replace the closing ones.

However, that is no option for me as the opening quotes in my documents usually are not after a space, but at the start of a sentence. But sometimes also after a space or tab.
The same with the close quotes, they could be followed by spaces, dots, commas, tabs, end of lines, etc.

Does anyone have any idea how to replace all my existing standard quotes with custom quotes ?

Thank you very much in advance for your help.
-tfg004
Back to top
View user's profile Send private message
RGB
Super User
Super User


Joined: 25 Nov 2003
Posts: 1743
Location: In Lombardy, near a glass of red Tuscany wine

PostPosted: Mon Jun 18, 2007 4:45 am    Post subject: Reply with quote

Format -> autoformat -> Apply.
It is simpler than my (forgotten) old answer...
Back to top
View user's profile Send private message
tfg004
Newbie
Newbie


Joined: 18 Jun 2007
Posts: 3

PostPosted: Mon Jun 18, 2007 6:31 am    Post subject: Reply with quote

I already tried that, but it didn't work Sad
Back to top
View user's profile Send private message
BillP
Super User
Super User


Joined: 07 Jan 2006
Posts: 2531

PostPosted: Mon Jun 18, 2007 7:03 am    Post subject: Reply with quote

Format > Autoformat > Apply only works on the Default paragraph style.

http://www.oooforum.org/forum/viewtopic.phtml?t=55635&highlight=autoformat
Back to top
View user's profile Send private message
acknak
Moderator
Moderator


Joined: 13 Aug 2004
Posts: 4312
Location: ~ 40°N,75°W

PostPosted: Mon Jun 18, 2007 7:48 am    Post subject: Reply with quote

If you have to resort to Find & Replace, you can do a pretty good job with

Search for: "\<
Replace with: (U+201C LEFT DOUBLE QUOTATION MARK)
Options / Regular expressions: ON

Repeat using
Replace with: (U+2018 LEFT SINGLE QUOTATION MARK)

That will handle almost all the opening quotes correctly.

Once that's done, you can use straight F&R on the remaining (closing) ascii quotes.
Back to top
View user's profile Send private message
tfg004
Newbie
Newbie


Joined: 18 Jun 2007
Posts: 3

PostPosted: Mon Jun 18, 2007 8:12 am    Post subject: Reply with quote

The F&R with Regular expressions did the job.
Thanks Smile
-tfg
Back to top
View user's profile Send private message
bluegecko
General User
General User


Joined: 12 Jun 2007
Posts: 45
Location: Portugal

PostPosted: Thu Sep 06, 2007 3:55 pm    Post subject: Reply with quote

The same limitation was bugging me for ages (why on earth OOo's Autoformat only works on Default paragraph styles I don't know!). Anyway, in case this helps others looking for a simple solution, here's a macro I wrote to do the business. It should also correctly change apostrophes (ie single quotes within words, like we'd or o'clock). There's a bit of a kludge required as OOo's implementation of Regular Expressions does not permit placing matched substrings in the replace field.

For ease of use, you could associate the macro with a hot key.

Code:
rem **********************************************************************
rem TYPOGRAPHIC QUOTES
rem **********************************************************************

rem   ---- this macro changes dumb quotes to curlies regardless of styles
rem   ---- (unlike OOo's in-built "Autoformat" function)

Sub TypographicQuotes
   oDoc = thisComponent
      ' character codes used in this macro
      ' Chr(34)   double quote
      ' Chr(39)   single quote
      ' Chr(8216)   single quote left
      ' Chr(8217)   single quote right
      ' Chr(8220)   double quote left
      ' Chr(8221)   double quote right
   aFind = Array(""+_
      Chr(34)+"\<",_
      Chr(34),_
      Chr(39)+"\<",_
      Chr(39),_
      "[0-9A-Za-zÀ-Ö\x00D8-\x00F6\x00F8-\x021B\x1E80-\x1EF3\xF730-\xF739\xFB00-\xFB06]\>"+Chr(8216)+"\<",_
      Chr(8216)+"OOoRegExSucks"_
      )
      ' The line beginning "[0-9 and ending +"\<",_ should be on one line.
      ' It's a workaround for OOo's lack of substring matching in RegEx when using find/replace.
      ' It appends a temporary tag to left single quotes when following words or numbers
      ' To avoid another bug/limitation, characters allowed at word-ends are defined in hex ranges
      ' (includes all Latin characters you're ever likely to need, plus the Unicode range for hanging/oldstyle figures)
   aReplace = Array(""+_
      Chr(8220),_
      Chr(8221),_
      Chr(8216),_
      Chr(8217),_
      "&OOoRegExSucks",_
      Chr(8217)_
      )
   aRayCount = 0
   FandR = oDoc.createReplaceDescriptor
   FandR.SearchCaseSensitive = true
   FandR.SearchRegularExpression = true
   While aRayCount <= uBound(aFind)
      FandR.setSearchString(aFind(aRayCount))
      FandR.setReplaceString(aReplace(aRayCount))
      aRayCount = aRayCount + 1
      oDoc.ReplaceAll(FandR)
   Wend
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
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