[PATCH] Cleanup in Tools -> Options -> User Data

János Uray uray.janos at gmail.com
Fri Jul 27 01:31:21 PDT 2012


The patch simplifies two source files: cui/source/options/optgenrl.cxx and
unotools/source/config/useroptions.cxx.
The problem was similar to the Tools -> Options -> Appearance (see
https://bugs.freedesktop.org/show_bug.cgi?id=47957 ).

Most important changes:

cui/source/options/optgenrl.cxx:
1.
SvxGeneralTabPage had 30 data members for the labels and the edit boxes.
The member functions had lots of code to handle each item by name.
Now they are stored in an std::vector, and constructed dynamically. In the
beginning of the file, there are two static arrays that contain information
about the rows and the edit boxes. The member functions use loops to handle
the items.
2.
In the resource file (optgenrl.src), the size and position values were
given in each control by #define-constants like "RIGHT- ( MID+2* (
NAMELEN-8+HSPACE )".
Now the position and size are calculated automatically. The static array in
optgenrl.cxx contains relative widths of the fields in the same row (like
5:5:2).
3.
Some languages need different fields in some rows. For example, the "name"
row in russian also contains a "Father's name" field. In the old code, the
constructor manually resized/moved/hided/renamed the appropriate controls
to meet the special needs of the special languages. Other member functions
also had some complicated code to handle the different languages.
Now the language information is stored in the static arrays: some row has a
flag "only russian", some has "anything except russian", and so on. Only
those controls are contructed that are needed by the current language, so
the language problem need to be handled only once.

In unotools/source/config/useroptions.cxx:
4.
There are 18 properties in SvtUserOptions like company, first name etc.
In the old code, all properties were handled by repeated long codes in
exactly the same way (except a single identifier).
Now the repeated long function bodies are removed, and the getters/setters
(e.g. GetCompany(), GetStreet()) call two general functions: GetToken() and
SetToken(). The differenct names are handled by a single array.
Note: the GetToken() and SetToken() functions are now used also in
optgenrl.cxx to simplify that file too.
5.
Manual reference counting was implemented in useroptions.cxx by global
variables.
Now boost::shared_ptr is used.
6.
The implementation classes for SvtUserOptions were global classes:
SvtUserOptions_Impl and SvtUserConfigChangeListener_Impl.
Now they are private nested classes: SvtUserOptions::Impl and
SvtUserOptions::ChangeListener.

I hope that these changes were useful.

Uray M. János
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120727/7a68d7a0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Cleanup-in-Tools-Options-User-Data.patch
Type: text/x-patch
Size: 105636 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120727/7a68d7a0/attachment-0001.bin>


More information about the LibreOffice mailing list