| View previous topic :: View next topic |
| Author |
Message |
tfg004 Newbie

Joined: 18 Jun 2007 Posts: 3
|
Posted: Mon Jun 18, 2007 4:32 am Post subject: How to replace existing standard quotes with custom quotes ? |
|
|
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 |
|
 |
RGB Super User


Joined: 25 Nov 2003 Posts: 1743 Location: In Lombardy, near a glass of red Tuscany wine
|
Posted: Mon Jun 18, 2007 4:45 am Post subject: |
|
|
Format -> autoformat -> Apply.
It is simpler than my (forgotten) old answer... |
|
| Back to top |
|
 |
tfg004 Newbie

Joined: 18 Jun 2007 Posts: 3
|
Posted: Mon Jun 18, 2007 6:31 am Post subject: |
|
|
I already tried that, but it didn't work  |
|
| Back to top |
|
 |
BillP Super User

Joined: 07 Jan 2006 Posts: 2531
|
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4312 Location: ~ 40°N,75°W
|
Posted: Mon Jun 18, 2007 7:48 am Post subject: |
|
|
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 |
|
 |
tfg004 Newbie

Joined: 18 Jun 2007 Posts: 3
|
Posted: Mon Jun 18, 2007 8:12 am Post subject: |
|
|
The F&R with Regular expressions did the job.
Thanks
-tfg |
|
| Back to top |
|
 |
bluegecko General User

Joined: 12 Jun 2007 Posts: 45 Location: Portugal
|
Posted: Thu Sep 06, 2007 3:55 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|