[Libreoffice] Macro Cleanup in UNO

Joseph Powers jpowers27 at cox.net
Sun Oct 31 21:44:12 PDT 2010


In UNO land, each header would declare macros to make defining the class easier; however, these macros where never used outside of the header they where declared in. Thus we'd get the following:

#define UNO3_ANY	 ::com::sun::star::uno::Any
#define UNO3_RECTANGLE	::com::sun::star::awt::Rectangle

class {
… some code using the above macros.
}

The problem with above code, is now UNO3_ANY is defined everywhere the header is included. The second issue I have is that Rectangle is part of awt and not uno so why is the macro UNO3.

I modified the code so the macros only override the name space and not the function (I hate uppercase only); thus, I now have CSS_UNO for ::com::sun::star::uno and CSS_AWT for ::com::sun::star::awt. I also added #undefs to the bottom of the header to drop the name space overrides.

While there I discovered that the header components/UnoControls/inc/definesunocontrols.hxx isn't used any where. Which explains why the macros defined there aren't used anywhere. The macros in the file where somewhat redefined in the normal header along with the classes.

The defaults for the classes where defined in the header (good); however, they used generic names like DEFAULT_VALUE, FREESPACE, … (bad). I went ahead and renamed them by prefixing CLASSNAME_ to the start of them. Someone already found this issue since I found some #undefs before #defines so the values could be changed.

Naturally, I found some unused macros; I just deleted them.

The reset is mostly minor formatting issues to make things fit nicer into 100 column screens (yes, I didn't get more excited to cut the lines down to 80). Some of the 160 columns lines, just didn't fit on my screen.
The program builds and seems to run fine under OS X 10.6.4.

Joe P.

PS: I left the CreateFromASCII() work to the other team. I will note that anything CreateFromASCII( ALLUPPERCASE ) is a constant and can be optimize (check the header file of the same name).

PS: Patch released under LGPL 3+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101031/14d235df/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Macro-Cleanup-in-UNO-land.patch
Type: application/octet-stream
Size: 211404 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101031/14d235df/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101031/14d235df/attachment-0001.htm>


More information about the LibreOffice mailing list