[Libreoffice] Moving duplicate code into methods

Jan Holesovsky kendy at suse.cz
Wed May 4 01:00:33 PDT 2011

Hi Christina,

On 2011-05-03 at 20:35 +0200, Chr. Rossmanith wrote:

> static void <prefix>ShapePropertiesFromDFF (const SvxMSDffHandle* pData, 
> com::sun::star::beans::PropertyValues& rPropValues)
> with <prefix>  = "lcl_" or "[Ii]mpl" - is one of these prefices more 
> modern than the others? What about indentation and formatting of 
> if/then/else or switch statements? Any rules?
> > Though that's a matter of taste ... ;)
> That's why I've asked for review  :-)

We do not have strict coding rules (even though I personally would like
to have something more 'official', the discussions about them tend to
create huge, and unproductive flame wars we do not want to start), but
the following is common to all the styles seen in the LibreOffice code:

- four spaces for indentation instead the tab characters
  (vi: set shiftwidth=4 softtabstop=4 expandtab)
- '{'s (beginnings of blocks) on new lines, newlines after '}'s
- spaces after ','
- spaces around '='
- blocks begin at the level of the keyword (if / for / switch),
  indentation inside the block

static int IDontKnow( int something )
    static int i = 0;
    if ( i < something )
    // or if (i < something)
        return something;
    return 42;

In most cases there are

- spaces after keywords

Sometimes yes, sometimes no:

- spaces after '(', and before ')'

Controversial bits are:

- in most of the codebase, variables are named like xName [where x is
  'p' for pointers, 'r' for references, 'n' for integer types, 'e' for
  enums, 'a' for other types]
  - this is controversial because eg. for an obvious iterator in 'for',
    it makes no sense to name it aIterator; 'i', or 'it' usually works
- attributes are prefixed with m_ doing m_xName
- methods use CapitalFirstThenCamelCase(), or
  firstSmallThenCamelCase(), static functions
  - or at least my memory says the impl_ is the most used version :-) -
    but as Thorsten pointed out, other possibilities are used too

Hope that helps, and even more - I hope this does not start a flame
war :-)


More information about the LibreOffice mailing list