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


OUString RectanglePointToOUString(const css::drawing::RectanglePoint& rp){
    if(rp == css::drawing::RectanglePoint::LEFT_TOP)
        return OUString::createFromAscii("LEFT_TOP");
...
    SAL_WARN("sd","Unknown RectanglePoint Value");
    return OUString::createFromAscii("");
}


The existing practice is to use a switch statement, not a sequence of if
statements. Also, as css::drawing::RectanglePoint is a new-style so-called
scoped enum (enum class, not plain enum), you should introduce a stream
output operator<< directly, no need for a ToString function just for
SAL_INFO etc usage. If you have an operator<< for it, you can use values of
that css::drawing::RectanglePoint type directly in SAL_INFO etc.

See for instance include/sfx2/event.hxx, this:

template< typename charT, typename traits >

inline std::basic_ostream<charT, traits> & operator <<(

    std::basic_ostream<charT, traits> & stream, const SvMacroItemId& id )

{

    switch(id)

    {
...

That is my code, and my style, and it is I who (as far as I have noticed)
have been adding such debug output operators when I have had the need.
Nobody has opposed, so that is the existing style you should follow. If
somebody now opposes, they are free to introduce another style, *if* they
change there existing ones to be of that style, too. Just my opinion, of
course.

Note that instead of a SAL_WARN as you have, I output the undefined value
as a number. That is more useful.

--tml

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.