Re: Make constant array accessible from different places

2020-08-28 Thread Regina Henschel

Hi Stephan,

thanks. I'll do it as you have suggested.

Kind regards
Regina

Stephan Bergmann schrieb am 28-Aug-20 um 19:16:

On 28/08/2020 18:53, Regina Henschel wrote:

I have a constant array
const std::pair aApiToLabelFooPairs[] =
{
 {"LineStyle", "LabelBorderStyle"},
    etc.
}

for to map draw object fill and line property names to data-label 
related properties of series and points in a chart on ODF import.


I need it in SchXMLSeries2Context::setStylesToSeries and in 
SchXMLSeries2Context::setStylesToDataPoints.


I have not worked on export yet, so I don't know whether it will be 
needed on export too.


Where to put this array and how?

I can put it separately from the SchXMLSeries2Context methods into the 
file SchXMLSeries2Context.cxx. Would that be "static" or not?


If aApiToLabelFooPairs is only used in 
xmloff/source/chart/SchXMLSeries2Context.cxx, you best put it in that 
file, at file scope.  And as the object is const, "static" would be 
redundant (and loplugin:redundantstatic would even warn about it).


(There's a slight drawback with global static objects involving e.g. 
OUString construction, as that incurs some cost when the library 
containing the object is loaded.  std::pair construction is by now 
constexpr if the construction of its members is, and two 
constexpr-constructible replacements for OUString that are suitable in 
many use cases is/was OUStringLiteral---but for which I'm planing on 
changing its role somewhat, so that it would unfortunately no longer be 
usable in your example---and std::u16string_view.  But you can ignore 
that for now and we can revisit things once (a) you know the final place 
for aApiToLabelFooPairs when all uses across import and export have been 
determined, and (b) the OUStringLiteral -> std::u16string_view situation 
has settled.)


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Make constant array accessible from different places

2020-08-28 Thread Stephan Bergmann

On 28/08/2020 18:53, Regina Henschel wrote:

I have a constant array
const std::pair aApiToLabelFooPairs[] =
{
 {"LineStyle", "LabelBorderStyle"},
    etc.
}

for to map draw object fill and line property names to data-label 
related properties of series and points in a chart on ODF import.


I need it in SchXMLSeries2Context::setStylesToSeries and in 
SchXMLSeries2Context::setStylesToDataPoints.


I have not worked on export yet, so I don't know whether it will be 
needed on export too.


Where to put this array and how?

I can put it separately from the SchXMLSeries2Context methods into the 
file SchXMLSeries2Context.cxx. Would that be "static" or not?


If aApiToLabelFooPairs is only used in 
xmloff/source/chart/SchXMLSeries2Context.cxx, you best put it in that 
file, at file scope.  And as the object is const, "static" would be 
redundant (and loplugin:redundantstatic would even warn about it).


(There's a slight drawback with global static objects involving e.g. 
OUString construction, as that incurs some cost when the library 
containing the object is loaded.  std::pair construction is by now 
constexpr if the construction of its members is, and two 
constexpr-constructible replacements for OUString that are suitable in 
many use cases is/was OUStringLiteral---but for which I'm planing on 
changing its role somewhat, so that it would unfortunately no longer be 
usable in your example---and std::u16string_view.  But you can ignore 
that for now and we can revisit things once (a) you know the final place 
for aApiToLabelFooPairs when all uses across import and export have been 
determined, and (b) the OUStringLiteral -> std::u16string_view situation 
has settled.)


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Make constant array accessible from different places

2020-08-28 Thread Michael Warner

Regina Henschel wrote:

Hi all,

I need some technical help.

I have a constant array
const std::pair aApiToLabelFooPairs[] =
{
{"LineStyle", "LabelBorderStyle"},
   etc.
}

for to map draw object fill and line property names to data-label 
related properties of series and points in a chart on ODF import.


I need it in SchXMLSeries2Context::setStylesToSeries and in 
SchXMLSeries2Context::setStylesToDataPoints.


I have not worked on export yet, so I don't know whether it will be 
needed on export too.


Where to put this array and how?

I can put it separately from the SchXMLSeries2Context methods into the 
file SchXMLSeries2Context.cxx. Would that be "static" or not?


Better place?

Kind regards
Regina


I'm still kind of new to this project, so I don't know if there is some 
kind of convention that applies. But for something like this, I would 
normally make it a private static const field of the class.

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice