summaryrefslogtreecommitdiff
path: root/HACKING.md
blob: a4b7e0d0f0e390ab3e70c4d2bec3d3a95d00502f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Hacking

## Coding style

### C++ version

We use C++ 98/03. No C++11/14, please.

### Indentation

We indent with spaces. No tabs, please. Try to keep lines less than 120 columns wide. Please run

    make astyle

before committing.

### Naming

Names are in camel case. Names of classes, structs and enums start with a capital letter, names of functions and variables with a lower-case letter. Member variables should have `m_` prefix. Short-hand for variable names is allowed, but don't overdo it (e.g., `len` instead of `length` or `para` instead of `paragraph` is OK).

Names of all non-local classes, enumerations and constants should have a prefix, depending on their use. This is:

* `IWORK`: for symbols used by all (or more than one) parsers;
* `KEY`: symbols specific to Keynote;
* `PAG`: symbols specific to Pages;
* `NUM`: symbols specific to Numbers.

Furthermore, if a symbol is specific for a specific version of a format, the prefix should be followed by the version number, e.g., `KEY2Parser`.

If you want to add a typedef for a smart pointer or a container of something, add `Ptr_t`, `List_t` or `Map_t` suffix to the name.

### Source files

Every class should be declared in a separate header file and defined in a separate source file. The names of these files should be the same as that of the class itself, including the camel case. Exception: structs that only contain data or enums can be grouped together; they can be put into one of the existing `*Type.h` and `*Enum.h` files.

All the sources are in `src/lib`, except for XML parser contexts, which are in `src/lib/contexts`.

### Memory management

Manual memory management is strongly discouraged. Use smart pointers or pointer containers from Boost.

### Data structures

Use data structures from the standard library or Boost, if possible. You may use either the C++ standard strings or our very own UTF-8-compliant `librevenge::RVNGString`. Use of C strings is strongly discouraged.

### Compiler warnings

Configure with ``--enable-werror --enable-weffc``. Do not ignore compiler warnings.

### External code

Do not add additional dependencies without a good reason. If you have to, prefer projects that are already used by other DLP library or LibreOffice. Use any Boost library you like, as long as it is header-only and is available in all supported versions of Boost (some of us still build with Boost 1.47).

Do not include external code unless it has got a clear (and compatible) license. Exception: picking from other DLP libraries is typically not a problem and is even encouraged.

### Fun

Remember, the important thing is to have fun. :-) These rules are a means, not an end. Happy hacking!

## Hacking notes

### Main entities

* `*Parser`: a parser :-) Passes raw data to collector for further processing.
* `*Collector`: an output producer; uses the data passed to it from parser.
* `IWORKPropertyMap`: a type-safe property map. A property map is typically not used directly, except in the parser. Instead, it is wrapped in an `IWORKStyle`.
* `IWORKStyleStack`: a hierarchy of currently applied styles. It allows lookup of properties without checking multiple styles explicitly.
* `IWORKDocumentInterface`: an amalgamation of librevenge document interfaces, to allow common handling of some parts of the file format.

See the documentation for concrete classes for more details.

### Tokenizer

We use gperf to generate lookup maps for XML tokens. These are split by namespace: names in `sf` and `sfa` namespaces are in IWORKToken, `key` in in KEYToken, `ls` in NUMToken and `sl` in PAGToken. To add a new token, add it into the enum in appropriate `*Token.h` and define it in `*Token.gperf`.

### Type-safe property map

To add a new property, declare it in `IWORKProperties.h` and define in `IWORKProperties.cpp`.

### XML Parser

Parsing is done by parser context classes. These handle a specific XML element or a class of elements (e.g., references or styles). The contexts have access to a global state (which is format-specific), but most of the results are passed either to the collector or up to the parent context. In the later case, the output is saved through references to `boost::optional<Foo>` passed in the constructor.

The context classes employ various suffixes for better orientation. `Context` is common for several elements, `Element` is for a single element, `Base` is a base class adding a common functionality, which is not supposed to be used directly.
-4-4-1'>libreoffice-4-4-1 Unnamed repository; edit this file to name it for gitweb.root
summaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2024-09-11update translations for 24.2.6 rc2cp-24.04.8-2cp-24.04.8-1cp-24.04.7-3cp-24.04.7-2Christian Lohmaier23-501/+501
2024-09-11update translations for 24.2.6 rc2Christian Lohmaier197-2935/+2885
2024-09-11update translations for 24.2.6 rc1Christian Lohmaier746-17182/+18007
2024-09-11update translations for 24.2.5 rc2Christian Lohmaier195-2778/+2804
2024-07-03update translations for 24.2.5 rc1cp-24.04.7-1cp-24.04.6-3cp-24.04.5-2cp-24.04.5-1Christian Lohmaier237-1516/+1421
2024-07-03update translations for 24.2.5 rc1Christian Lohmaier415-5218/+5205
2024-06-24update translations for 24.2.4 rc2Christian Lohmaier90-793/+781
2024-06-03update translations for 24.2.4 rc2cp-24.04.4-5cp-24.04.4-4cp-24.04.4-3cp-24.04.4-2co-24.04.4-4Christian Lohmaier486-33672/+32762
2024-06-03update translations for 24.2.4 rc1Christian Lohmaier529-32993/+29625
2024-06-03update translations for 24.2.3 rc2Christian Lohmaier309-5301/+5274
2024-04-19update translations for 24.2.3 rc1cp-24.04.3-6cp-24.04.3-5cp-24.04.3-4cp-24.04.3-2cp-24.04.3-1cp-24.04.1-3co-24.04.3-2Christian Lohmaier81-860/+829
2024-04-19update translations for 24.2.3 rc1Christian Lohmaier523-5055/+4725
2024-03-27update translations for 24.2.2 rc2cp-24.04.1-2Christian Lohmaier111-677/+662
2024-03-27bump copyright year for sl translationChristian Lohmaier2-4/+4
2024-03-27update translations for 24-2 and force-fix errors using pocheckChristian Lohmaier521-8071/+8016
2024-03-27update translations for 24.2.2 rc1Christian Lohmaier263-4995/+4896
2024-03-27update translations for 24.2.1 rc2Christian Lohmaier276-5469/+5410
2024-02-22[cp] Remove reference to menu in dialog textcp-24.04.1-1Andras Timar35-280/+70
2024-02-09update translations for 24.2.1 rc1cp-24.04.0-1Christian Lohmaier34-497/+476
2024-02-08update translations for 24.2.1 rc1Christian Lohmaier291-7745/+7428
2024-01-26update translations for 24.2.0 rc3Christian Lohmaier13-196/+196
2024-01-25update translations for 24.2.0 rc3Christian Lohmaier631-33232/+15659
2024-01-23Updated Slovenian translationMartin Srebotnjak4-248/+80
2024-01-22update sl translation for gerrit#161999Christian Lohmaier1-2/+2
2024-01-11update translations for master/24.2.0 rc1co-24.04-branch-pointChristian Lohmaier78-1234/+1150
2024-01-10Updated Slovenian translationMartin Srebotnjak19-91/+127
2024-01-10update translations for master/24-2Christian Lohmaier267-5889/+8163
2024-01-10add translations for Armenian (hy)Christian Lohmaier158-0/+273799
2024-01-10update translations for master/24-2Christian Lohmaier115-1769/+2348
2024-01-08update translations for master/24-2Christian Lohmaier914-17234/+21265
2023-12-30Updated Slovenian translationMartin Srebotnjak37-651/+1998
2023-12-21update translations for master/24.2.0 RC1Christian Lohmaier1440-36867/+87000
2023-12-20Updated Slovenian translationMartin Srebotnjak48-1612/+4963
2023-12-15update translations for master/24-2Christian Lohmaier1551-39007/+124820
2023-12-08Branch libreoffice-24-2Christian Lohmaier0-0/+0
2023-12-08update translations for master/24.2.0 Beta1libreoffice-24-2-branch-pointChristian Lohmaier53-466/+477
2023-12-07update translations for master/24.2.0 beta1Christian Lohmaier499-7052/+13102
2023-12-04update translations for masterChristian Lohmaier258-7146/+8658
2023-12-04update translations for masterChristian Lohmaier3565-257579/+431237
2023-11-30update translations for masterXisco Fauli198-4875/+4861
2023-11-23update translations for masterXisco Fauli51-1332/+1330
2023-11-23Updated Slovenian translationMartin Srebotnjak51-13811/+21418
2023-11-21update translations for masterXisco Fauli904-51173/+45191
2023-11-08update translations for masterChristian Lohmaier921-43573/+49527
2023-11-02update translations for masterChristian Lohmaier2450-251413/+438677
2023-10-11update translations for masterChristian Lohmaier1928-67440/+90920
2023-10-02update translations for masterChristian Lohmaier1480-87735/+84059
2023-09-28update translations for masterChristian Lohmaier