How can I distinguish ß (Sharp s) and ss with 'basic macro'

Creating a macro - Writing a Script - Using the API

How can I distinguish ß (Sharp s) and ss with 'basic macro'

Postby billylee » Fri Jun 08, 2018 10:24 am

German letters were created while automatically converting pdf documents to docs.
Unfortunately, I was unable to distinguish between ß (Sharp s) and ss while doing other operations using macros.
I am looking for a way to avoid this. I have encountered 'basic macro' today.
I am doing the following work.


     oReplace.setSearchString ("ß") 'Please do not change "ss"
     oReplace.setReplaceString ("fl")
        
     oReplace.SearchRegularExpression = True 'Use regular expressions
     oReplace.searchAll = True 'Do the entire document
     oDoc.replaceAll (oReplace)
LibreOffice 4.2.8.2
billylee
 
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby Sébastien C » Sat Jun 09, 2018 12:34 pm

Hello billylee and welcome on this forum,

I am not sure to understand your question. But it is true that if we search “ß” in a document LibreOffice found characters string “ss”

It is a same problem with single long s (old typography) that I know so well...

You have for that to specify to respect the case sensitive.

Code: Select all   Expand viewCollapse view
oReplace.setSearchString ("ß") 'Please do not change "ss"
oReplace.setReplaceString ("fl")
oReplace.SearchCaseSensitive = True ' Set the case sensitive
oReplace.SearchRegularExpression = True ' Use regular expressions
oReplace.searchAll = True 'Do the entire document
oDoc.replaceAll (oReplace)


Viele Gruße
:lol:
LibreOffice 5.2.7.2 under GNU-Linux ARMbian on the Rock64 and M$-W XP
User avatar
Sébastien C
 
Posts: 81
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby billylee » Sat Jun 09, 2018 1:26 pm

Thank you for answer.
My question is that "ss" changes while changing "ß". I do not need the letter ß at all. In Asia, I do not use German a lot.
LibreOffice 4.2.8.2
billylee
 
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby Villeroy » Sat Jun 09, 2018 1:35 pm

Do it like the Swiss do. They abolished all uses of ß in favour of ss. Just perform a simple find/replace. No macro code required.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26968
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby Sébastien C » Sat Jun 09, 2018 2:36 pm

@billylee
If you are not in a macro context (I mean if your code is not include in a code that you use yet), Villeroy say right : just perform a simple find/replace. But if you are in a macro context, the code can be there:
Code: Select all   Expand viewCollapse view
Sub byBySharpS
   Dim oReplace As Object

   oReplace = thisComponent.CreateReplaceDescriptor()

   oReplace.setSearchString  ("ß")          '
   oReplace.setReplaceString ("ss")
   oReplace.SearchCaseSensitive     = True ' Set the case sensitive
   oReplace.SearchRegularExpression = True ' Use regular expressions
   oReplace.searchAll               = True ' Do the entire document.

   thisComponent.replaceAll (oReplace)
End Sub


@Villeroy
We do not know the context where billylee is! :roll: I can talk for my self about the long S witch it has been abolished in France since the end of the eighteenth century; and it is not for the sake of it that the question of transcribing it in a historical context cannot be posted in this forum!
There are even places where one gets here or there a specialty that LibreOffice solves!

Similarly, if billylee asks to make a change in macro, it is because he is probably in such a context!
LibreOffice 5.2.7.2 under GNU-Linux ARMbian on the Rock64 and M$-W XP
User avatar
Sébastien C
 
Posts: 81
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby billylee » Sun Jun 10, 2018 9:20 am

Thank you for your answers. My job is to edit many documents. So I need macro function.
If my document is not a binary document but text, I can simply do the following:
sed -i "s / ß / fl / d" * .doc

One hint is that the "match case" checkbox provided by Openoffice distinguishes between two characters.
LibreOffice 4.2.8.2
billylee
 
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby Sébastien C » Sun Jun 10, 2018 12:41 pm

So, if I resume your desire (because I do not understand yet well), you searching a macro for:
make an inventory of the name’s files for a complete directory.

  • open each file.
  • search and replace the “ß” character by “fl”.
  • close each file.
If I am right, say OK. But if I am wrong, please, say the incremental parts of what you want.
LibreOffice 5.2.7.2 under GNU-Linux ARMbian on the Rock64 and M$-W XP
User avatar
Sébastien C
 
Posts: 81
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby billylee » Sun Jun 10, 2018 4:11 pm

Hello. What I want is a script-level behavior that does not involve people needing to open, close, or click on a file. Let's say the document is 10,000. The most fundamental cause of this problem is that Openoffice can not distinguish between two letters. (Default mode). Maybe it does not seems to be resolved.
And as already mentioned
"My problem is that "ss" is also changed while changing "ß".
Lastly, the intention is not to solve this problem, but to let you know that this problem exists.

Thank you.
LibreOffice 4.2.8.2
billylee
 
Posts: 4
Joined: Fri Jun 08, 2018 10:10 am

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby Sébastien C » Sun Jun 10, 2018 4:53 pm

billylee wrote:My problem is that "ss" is also changed while changing "ß".

I really do not understand.

If I check the "match case" in my LibreOffice, it is not happening like you describe; “ss” is preserved. Do you really work on LibreOffice 4.2.8.2 as you say in signature or OpenOffice?
LibreOffice 5.2.7.2 under GNU-Linux ARMbian on the Rock64 and M$-W XP
User avatar
Sébastien C
 
Posts: 81
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: How can I distinguish ß (Sharp s) and ss with 'basic mac

Postby Villeroy » Sun Jun 10, 2018 10:30 pm

There is not a single developer on this forum. Bugs have to be reported to the bug tracker.
I don't understand the problem neither.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26968
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests