Re: [libreoffice-users] Localized Basic macros

2020-05-10 Thread jean-francois

Hi Johnny,

Le 10/05/2020 à 14:35, Johnny Rosenberg a écrit :

I'm playing a little with macros (my level is probably one step or two
above beginner) and making extensions out of them. I found a few examples
online and I got it to work.

I don't know if I'm going to share anything in the future (because I don't
think my extensions will fulfil anyone else's needs than my own and they
are probably poorly written anyway), but if I want to do that, there's a
minor problem: My macros interact with the user (usually me) in Swedish,
and I guess it would be a good idea to at least write an English version
for sharing with others.

However, it would be nice if the extension adapts to the user's locale when
installed (and falls back to English when the user's locale is not
available, that is in most cases). Is that possible? A link to some guide
of some sort would be appreciated. I found nothing so far.


IMO, as English is the lingua franca of IT, writing *any* code should 
always be done in English (including comments). Using any other language 
leads to what you're experiencing: no one will read the code, other than 
a native.


As for user's interactions, yes, a translation into English could be of 
use. I'm using po files with a Basic adapted gettext() function I had 
written for that (well, it's a little more convoluted but you get the idea).


https://www.gnu.org/software/gettext/
https://www.gnu.org/software/gettext/manual/gettext.html

My 2 (euro)cents.

Best,
--
Jean-Francois Nifenecker, Bordeaux


--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


Re: [libreoffice-users] Localized Basic macros

2020-05-10 Thread Johnny Rosenberg
Den sön 10 maj 2020 kl 17:25 skrev Johnny Rosenberg :

> Den sön 10 maj 2020 kl 15:29 skrev Regina Henschel <
> rb.hensc...@t-online.de>:
>
>> Hi Johnny,
>>
>> Johnny Rosenberg schrieb am 10-May-20 um 14:35:
>> > Hi!
>> > I'm playing a little with macros (my level is probably one step or two
>> > above beginner) and making extensions out of them. I found a few
>> examples
>> > online and I got it to work.
>> >
>> > I don't know if I'm going to share anything in the future (because I
>> don't
>> > think my extensions will fulfil anyone else's needs than my own and they
>> > are probably poorly written anyway), but if I want to do that, there's a
>> > minor problem: My macros interact with the user (usually me) in Swedish,
>> > and I guess it would be a good idea to at least write an English version
>> > for sharing with others.
>> >
>> > However, it would be nice if the extension adapts to the user's locale
>> when
>> > installed (and falls back to English when the user's locale is not
>> > available, that is in most cases). Is that possible? A link to some
>> guide
>> > of some sort would be appreciated. I found nothing so far.
>>
>> Perhaps start with the help
>>
>> https://help.libreoffice.org/latest/en-GB/text/sbasic/guide/translation.html
>>
>>
> I didn't even think of that… I'll have a look there first, of course.
>

Seems like only custom dialogues can be translated, not text in general,
such as Print or MsgBox.
I could of course create some arrays with translations and use them
depending on which UI language is selected, but it doesn't seem to be
possible for a macro to detect that. I only found things like
ThisComponent.CharLocale.Language, but that seems to be more about the
selected language for characters, and it doesn't change when I just change
the UI language.


Kind regards

Johnny Rosenberg


>
>> Info from OpenOffice.org might be still valid:
>>
>> https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Dialog_Localization
>>
>
>
>> There had been some issues with localization of dialogs:
>> According to https://bugs.documentfoundation.org/show_bug.cgi?id=130932
>> you need at least LO version 6.4.
>>
>
> I currently run LibreOffice 6.4.3.3, so I'm fine, I guess.
>
>
>>
>> And this issue is not yet solved:
>> https://bugs.documentfoundation.org/show_bug.cgi?id=100792
>> It contains a test document.
>>
>
> I'll have a look at that too.
>
>>
>> Kind regards
>> Regina
>>
>>
> Thanks for replying! This should get me going.
>
>
> Kind regards
>
> Johnny Rosenberg
>
>
>>
>> --
>> To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
>> Problems?
>> https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
>> List archive: https://listarchives.libreoffice.org/global/users/
>> Privacy Policy: https://www.documentfoundation.org/privacy
>>
>

-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


[libreoffice-users] Re: Test

2020-05-10 Thread James

On 2020-05-10 12:22 p.m., Jim wrote:


I am using gmane.io. I switched to it when the original gmane stopped 
working. The problem started on the original gmane and continued to 
gmane.io. I have always been able to read the group but at some point 
in  time I could no longer post to it.


At some point I corresponded with a moderator. He replied to my 
problem with some questions, I answered him but never heard anything 
back. At that point I just gave up.


I am sending this reply via gmane.io, we'll see what happens.

Maybe you need to be subscribed.
I can't find a way to check my subscription.
You could leave yourself subscribed the "-nomail" way.
Some special-case subscribers might want to be able to post to a list 
but might not want to receive messages from that list (community 
contributors who post announcements, for instance). In this case, 
please subscribe to the so-called "nomail" version of the list by 
attaching -nomail to the normal subscription address. For example, to 
do this for The Document Foundation general discussions list, the 
subscription address would be: 
discuss+subscribe-nom...@documentfoundation.org 
.




--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


[libreoffice-users] Re: Test

2020-05-10 Thread Jim

On 5/9/20 9:09 PM, James wrote:

On 2020-05-09 9:44 p.m., Jim wrote:
For some time now I have been unable to post to this list using gmane, 
so I decided to try subscribing to the list and using email. Hopefully 
this gets posted.


Regards,  Jim


https://en.wikipedia.org/wiki/Gmane
Use gmane.io




I am using gmane.io. I switched to it when the original gmane stopped 
working. The problem started on the original gmane and continued to 
gmane.io. I have always been able to read the group but at some point in 
 time I could no longer post to it.


At some point I corresponded with a moderator. He replied to my problem 
with some questions, I answered him but never heard anything back. At 
that point I just gave up.


I am sending this reply via gmane.io, we'll see what happens.

Regards,  Jim


--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


Re: [libreoffice-users] Localized Basic macros

2020-05-10 Thread Johnny Rosenberg
Den sön 10 maj 2020 kl 15:29 skrev Regina Henschel :

> Hi Johnny,
>
> Johnny Rosenberg schrieb am 10-May-20 um 14:35:
> > Hi!
> > I'm playing a little with macros (my level is probably one step or two
> > above beginner) and making extensions out of them. I found a few examples
> > online and I got it to work.
> >
> > I don't know if I'm going to share anything in the future (because I
> don't
> > think my extensions will fulfil anyone else's needs than my own and they
> > are probably poorly written anyway), but if I want to do that, there's a
> > minor problem: My macros interact with the user (usually me) in Swedish,
> > and I guess it would be a good idea to at least write an English version
> > for sharing with others.
> >
> > However, it would be nice if the extension adapts to the user's locale
> when
> > installed (and falls back to English when the user's locale is not
> > available, that is in most cases). Is that possible? A link to some guide
> > of some sort would be appreciated. I found nothing so far.
>
> Perhaps start with the help
>
> https://help.libreoffice.org/latest/en-GB/text/sbasic/guide/translation.html
>
>
I didn't even think of that… I'll have a look there first, of course.


> Info from OpenOffice.org might be still valid:
>
> https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Dialog_Localization
>


> There had been some issues with localization of dialogs:
> According to https://bugs.documentfoundation.org/show_bug.cgi?id=130932
> you need at least LO version 6.4.
>

I currently run LibreOffice 6.4.3.3, so I'm fine, I guess.


>
> And this issue is not yet solved:
> https://bugs.documentfoundation.org/show_bug.cgi?id=100792
> It contains a test document.
>

I'll have a look at that too.

>
> Kind regards
> Regina
>
>
Thanks for replying! This should get me going.


Kind regards

Johnny Rosenberg


>
> --
> To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
> Problems?
> https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
> List archive: https://listarchives.libreoffice.org/global/users/
> Privacy Policy: https://www.documentfoundation.org/privacy
>

-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


Re: [libreoffice-users] Localized Basic macros

2020-05-10 Thread Regina Henschel

Hi Johnny,

Johnny Rosenberg schrieb am 10-May-20 um 14:35:

Hi!
I'm playing a little with macros (my level is probably one step or two
above beginner) and making extensions out of them. I found a few examples
online and I got it to work.

I don't know if I'm going to share anything in the future (because I don't
think my extensions will fulfil anyone else's needs than my own and they
are probably poorly written anyway), but if I want to do that, there's a
minor problem: My macros interact with the user (usually me) in Swedish,
and I guess it would be a good idea to at least write an English version
for sharing with others.

However, it would be nice if the extension adapts to the user's locale when
installed (and falls back to English when the user's locale is not
available, that is in most cases). Is that possible? A link to some guide
of some sort would be appreciated. I found nothing so far.


Perhaps start with the help
https://help.libreoffice.org/latest/en-GB/text/sbasic/guide/translation.html

Info from OpenOffice.org might be still valid:
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Dialog_Localization

There had been some issues with localization of dialogs:
According to https://bugs.documentfoundation.org/show_bug.cgi?id=130932 
you need at least LO version 6.4.


And this issue is not yet solved:
https://bugs.documentfoundation.org/show_bug.cgi?id=100792
It contains a test document.

Kind regards
Regina


--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


[libreoffice-users] Localized Basic macros

2020-05-10 Thread Johnny Rosenberg
Hi!
I'm playing a little with macros (my level is probably one step or two
above beginner) and making extensions out of them. I found a few examples
online and I got it to work.

I don't know if I'm going to share anything in the future (because I don't
think my extensions will fulfil anyone else's needs than my own and they
are probably poorly written anyway), but if I want to do that, there's a
minor problem: My macros interact with the user (usually me) in Swedish,
and I guess it would be a good idea to at least write an English version
for sharing with others.

However, it would be nice if the extension adapts to the user's locale when
installed (and falls back to English when the user's locale is not
available, that is in most cases). Is that possible? A link to some guide
of some sort would be appreciated. I found nothing so far.

Experimenting with the stuff gave me nothing yet. All I came up with is a
box in the Basic IDE in which I can select a language, but I'm not sure how
to use it. After adding some languages I can now select en-US and sv-SE,
but then what? Should I just copy all of the code to a new module,
translate everything there and select the language I used in that box?

And what do I need to do when packaging the whole thing? I realised a few
things. For instance in the Addons.xcu file, I can use several different
languages for the tool tip text like so:
My description
Min beskrivning

But in my library folder (the one LibreOffice created for me when exporting
as Basic library), there are three files:
dialog.xlb
MyMacro.xba
script.xlb
If I want to use several languages, what would happen here? Or would there
be one ”library” for each language?

So, obviously I haven't grasped the concept for this at all yet. Any hints?



Kind regards

Johnny Rosenberg

-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


Re: [libreoffice-users] Range names

2020-05-10 Thread Johnny Rosenberg
Den tis 5 maj 2020 kl 02:07 skrev Steve Edmonds :

>
>
> On 04/05/2020 09:09, Johnny Rosenberg wrote:
>
> Den sön 3 maj 2020 kl 22:39 skrev Steve Edmonds <
> steve.edmo...@ptglobal.com>:
>
>>
>>
>> On 04/05/2020 08:24, Johnny Rosenberg wrote:
>>
>> Den sön 3 maj 2020 kl 21:39 skrev Steve Edmonds <
>> steve.edmo...@ptglobal.com>:
>>
>>> Hi Johnny.
>>> I came up against this issue last year after needing to open an excel
>>> sheet in Calc.
>>> Excel allows range names that Calc doesn't so the sheet wouldn't work. I
>>> wanted to rename the offending excel ranges.
>>>
>>
>> Out of curiosity, I would like to know what kinds of range names that is.
>> Can you give me some examples?
>>
>> I filed a bug; https://bugs.documentfoundation.org/show_bug.cgi?id=130577
>>
>
> So Excel allows for a leading backslash, LibreOffice does not. I'l have a
> look at it tomorrow, if I remember to.
>
>
>> Does your name changing macro change the name through range name and
>> formulae using that range name to be changed?
>>
> Do you mean the code I wrote below or the macro that I mentioned before
> that?
> The macro I mentioned first, the one with the obvious bug, is not finished
> yet, but I think it will be tomorrow (and hopefully bug free too, almost).
> It loops through all defined cell range names and cell names. For every
> name, it finds its corresponding reference, for instance ”$Sheet1.$A$1”.
> Then it search all sheets for that reference and replaces it with the cell
> range name. So if cell A1 has the name ”Length” and cell A2 is
> ”=$A$1*$A$1”, then the macro will change A2 to ”=Length*Length”. However,
> it will also change things like ”$A$123”, but I think I solved that one
> now. I'll try to finish it tomorrow.
>
> The code I wrote below is just a starting point if you want to create your
> own macro to change all the names in that Excel file. I don't know if
> that's even possible, maybe you need to do that in Excel, since those names
> are invalid in LibreOffice Calc. I don't know yet, I'll give it a go
> tomorrow, I think.
>
> I think I might have to do my replacement of range names in the excel file
> as by the time Calc opens it the import filter has messed it up when range
> names are offending.
>

I just had some time to check it out, the file you attached to that bug
report, and we were right, you can't fix it automatically in LibreOffice
Calc. The problem is that some of the names are broken (refers to #REF!).
Of course you could do it manually if you know what all the names are. In
this case there are 34 names, and not all of them are broken, so it
shouldn't take too long if you know the references for all the broken
names. But I guess it's easier to fix it in Excel, either manually or with
a VBA macro. You could, for instance, make a VBA macro that replace all
backslashes with something else, like yet another underscore (first make
sure there will be no doublets) or just something unique, like _Ch92_,
_Asc92_,  _bsol_ or whatever, making the risk of doublets minimal.


Kind regards

Johnny Rosenberg


>
> Kind regards
>
> Johnny Rosenberg
>
>
>> Regards, Steve
>>
>>
>> I actually wrote a macro that replaces range references with existing
>> range names, but I can see a few bugs that I don't have a solution for at
>> the moment.
>> At this stage, the macro goes through all existing range names (and cell
>> names), find their corresponding references and then do a search and
>> replace.
>> For instance, if there's a name ”MyName” for ”$Sheet1.$A$1:$B$7”, every
>> occurrence of ”$Sheet1.$A$1:$B$7” will be replaced with ”MyName”. That
>> means that if it, for instance, finds ”$Sheet1.$A$1:$B$70” (note the extra
>> ”0” at the end), the result will be ”MyName0”, which is not meaningful… But
>> I'm working on it.
>>
>> When dealing with ranges, I think this problem is rarely going to happen.
>> If ”$Sheet1.$A$1:$B$7” has a name, why would we find the reference
>> ”$Sheet1.$A$1:$B$70”? But it's probably a much bigger problem with single
>> cells.
>>
>>>
>>> I couldn't find a solution like you seek.
>>>
>>
>> If you want to edit names with a macro, you can find and edit all defined
>> names like so:
>>
>> *Sub CorrectNames *
>> * For Index=0 To ThisComponent.NamedRanges.getCount()-1*
>> *  Name=ThisComponent.NamedRanges.getByIndex(Index).getName()*
>>
>> *  DoSomething(Name) *
>> *  ThisComponent.NamedRanges.getByIndex(Index).setName(Name)*
>>
>> * Next Index *
>>
>> *End Sub *
>>
>>
>> *Sub DoSomething(ByRef Name) *
>>
>> *  ' Enter Name changing, mind blowing code below. *
>>
>> *End Sub *
>>
>> Something like that.
>>
>>
>> Kind regards
>>
>> Johnny Rosenberg
>>
>>
>>> steve
>>>
>>> On 03/05/2020 19:35, Johnny Rosenberg wrote:
>>> > Hi!
>>> >
>>> > I'm just wondering if I'm missing something.
>>> > Let's say I have a spreadsheet (I actually have several…) with a lot of
>>> > cells and ranges already filled with data and formulas. One day I
>>> discover
>>> > the range naming feature, so I name a few cell 

Fwd: [libreoffice-users] Range names

2020-05-10 Thread Johnny Rosenberg
Once again I accidentally sent something in private rather than to the
list. When will I learn?
Anyway, apologies to Dave and here it is for the list:

-- Forwarded message -
Från: Johnny Rosenberg 
Date: sön 10 maj 2020 kl 09:07
Subject: Re: [libreoffice-users] Range names
To: Dave Howorth 


Den ons 6 maj 2020 kl 00:11 skrev Dave Howorth :

> On Tue, 5 May 2020 21:20:24 +0200
> Johnny Rosenberg  wrote:
>
> > Den tis 5 maj 2020 kl 08:38 skrev Luuk :
> >
> > >
> > > On 4-5-2020 09:43, Brian Barker wrote:
> > > > At 09:35 03/05/2020 +0200, Johnny Rosenberg wrote:
> > > >> Let's say I have a spreadsheet (I actually have several…) with a
> > > >> lot of cells and ranges already filled with data and formulas.
> > > >> One day I discover the range naming feature, so I name a few
> > > >> cell ranges. Shouldn't there be some easy way to replace every
> > > >> occurrence of those cell ranges in all my formulas?
> > > >
> > > > I don't think any automatic system could do exactly what you
> > > > probably want.
> > >
> >
> > What I probably want doesn't have anything to do with me. That's
> > rather a matter of other peoples guesses about me and not relevant
> > for anything.
> >
> > >
> > > > Say your range is A1:B5 on Sheet1 and suppose you name this as
> > > > Name. You may think that "Name" is now synonymous with "A1:B5",
> > > > but no: instead it is shorthand for "$Sheet1.$A$1:$B$5".
> >
> >
> > Great, that's exactly what I want.
> >
> > There are thirty-two
> > > > variations on "Sheet1.A1:B5" you may have in your spreadsheet,
> > > > each including a different combination of those dollar signs. As
> > > > you will know, each version behaves differently if you fill
> > > > ranges from a cell with a formula containing it, or if you copy
> > > > and paste from such a cell. So the differences are important. By
> > > > including "Name" in a formula, you are choosing to imply the
> > > > anchored or absolute version of the range.
> > >
> >
> > I can't see any problems with that. Maybe I don't follow.
> >
> > >
> >
> > > In order to preserve the precise meaning and behaviour of your
> > > > existing formulae, any automatic system should replace a
> > > > spelled-out reference only when it includes all five dollar
> > > > signs.
> >
> >
> > Yes, why would it do anything else than that?
> >
> >
> > > But in practice
> > > > one may rarely add all those dollar signs in formulae, instead
> > > > using only as many are necessary for the filling or copying that
> > > > one is expecting to need.
> >
> >
> > Oh, I don't know anything about that. I only know I wouldn't, and if
> > I did, it would be my fault only. I'm not expecting Calc to do the
> > thinking for me.
> >
> >
> > > I suspect you wouldn't be impressed if an automatic
> > > > system failed to replace "A1:B5" or "A$1:B$5" with your newly
> > > > defined "Name".
> >
> >
> > No, I'm rarely impressed when things just work as expected. They just
> > should.
> >
> >
> > > But if it did, it would corrupt some spreadsheets that you or
> > > > others might compose.
> > > >
> > > >> And when I say easy, I mean easier than doing search and replace
> > > >> on each one of them one by one. I can't find such a feature. Is
> > > >> there an extension for it?
> > > >
> > > > When you do this, you would need to determine in each case
> > > > whether the replacement by the range name would be appropriate.
> > > > And an automatic system could not do that for you.
> > >
> >
> > No, that's just wrong. Only absolute references (those with $-signs
> > everywhere) will be searched for, nothing else. Don't over complicate
> > this now.
> >
> > >
> > > >> I'm going to write a macro for it, ...
> > > >
> > > > Which of the thirty-two variations will it replace?
> > >
> >
> > The one that Calc itself associates with the name, that is those with
> > $-signs everywhere. I actually finished my macro instead of making up
> > a lot of problems.
> > It proved to be quite easy, actually:
> > You can easily get any used name and its corresponding reference (or
> > ”address”) by index with:
> > lNameCount=ThisComponent.NamedRanges.getCount()
> > For lNameIndex=0 To lNameCount-1
> >  sName=ThisComponent.NamedRanges.getByIndex(lNameIndex).getName()
> >  sAddress=ThisComponent.NamedRanges.getByIndex(lNameIndex).getContent()
> >  ⁝
> >  ⁝
> > Next lNameIndex
> >
> > sAddress in this case always looks something like $SomeSheet.$A1:$B75.
>
> Why isn't it: $SomeSheet.$A$1:$B$75 ?
>

It is indeed, I just made a typo. Sorry, and thanks for pointing it out. ☺

Kind regards

Johnny Rosenberg

>
> > Inside that loop I have another loop, that loops through all sheets.
> > When searching the same sheet as the Name is located, I also search
> > for $A1:$B75 kind of reference.
> >
> > It works great as far as I can tell, so far. Maybe I will run into
> > something in the future, who knows?
> > The only problem I saw so far is that at one point there was a
> > reference like this: