Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Den 24 mars 2012 13:11 skrev Dan Lewis <elderdanlewis@gmail.com>:
On Sat, 2012-03-24 at 11:01 +0000, Brian Barker wrote:
At 09:24 24/03/2012 +0000, E. Letter wrote:
On a separate issue, what is the syntax in LO to
select paragraph breaks (pilcrow (¶) sign) in
the 'find and replace' dialogue window?

There isn't one.  LibreOffice doesn't think that
way: you don't search for the paragraph break as
such.  Instead, you do what you need using ^
(circumflex) to lock your search term to the
beginning of a paragraph or $ (dollar) to lock it
to the end of a paragraph.  Perversely, you can
search for a line break (as entered with
Shift+Enter) using \n (backslash-en).  Oh, but if
you use \n in a "Replace with" expression, it means a paragraph break instead.

I trust this helps.

Brian Barker

    See if this works using Find and Replace with Regular Expressions
checked (ticked):
1) Enter ^$ into the Search for box.
2) Enter " zzz " (space then zzz then space) in the Replaced with box.
3) Click the Replace All button. This replaces the second paragraph
break
  used for spacing between paragraphs.
4) Enter $ into the Search for box.
5) Enter a space in the Replaced with box.
6) Click the Replace All button.
7) Enter " zzz " in the Search for box.
8) Enter \n in the Replaced with box.
9) Click the Replaced All button.
    The first three steps replaces the empty paragraphs used for
spacing with the word "zzz" (space before and after the zzz allows a
later search for it). The middle three steps replaces the rest of the
paragraph breaks used as line breaks with a space. (This guarantees a
space between the last word of one line and the first word of the next
line.) The last three steps replaces the word "zzz" with a paragraph
break.
    One more search might need to be made: replace any double spaces
with a single space.

--Dan

I wrote a simple macro (just a draft, feel free to modify it in
anyway) that does it all. It's based on Dan's post above:

REM  *****  BASIC  *****

Sub Main
        Dim sFind As String, sReplace As String

        sFind="^$"
        sReplace="¶"
        SearchAndReplace(sFind, sReplace)
        
        sFind="$"
        sReplace=" "
        SearchAndReplace(sFind, sReplace)
        
        sFind="¶"
        sReplace="\n"
        SearchAndReplace(sFind, sReplace)
        
        sFind="  "
        sReplace=" "
        SearchAndReplace(sFind, sReplace)

        sFind="^ "
        sReplace=""
        SearchAndReplace(sFind, sReplace)

        sFind=" $"
        sReplace=""
        SearchAndReplace(sFind, sReplace)
End Sub


Sub SearchAndReplace(a As String, b As String)
        Dim Descriptor As Object
        Descriptor=ThisComponent.createReplaceDescriptor()
        With Descriptor
                .SearchString=a
                .ReplaceString=b
                .SearchRegularExpression=True
                .SearchAll=True
        End With
        ThisComponent.replaceAll(Descriptor)
End Sub

-- 
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.