Possible option to simplify code?

Philipp Riemer ruderphilipp at gmail.com
Tue Jun 26 00:23:06 PDT 2012


2012/6/24 Michael Stahl <mstahl at redhat.com>:
> On 23/06/12 21:26, Philipp Riemer wrote:
>> (1) Wouldn't it be better in the method
>> "SwXTextDefaults::supportsService" to use the output of
>> "SwXTextDefaults::getSupportedServiceNames" and make an "is in array?"
>> check there instead of duplicating the allowed/supported string
>> values?
>
> yes there is some room for improvement with these methods, see e.g. the
> SupportsServiceImpl/GetSupportedServiceNamesImpl methods in
> sw/inc/unobaseclass.hxx and usage in e.g. sw/source/unocore/unobkm.cxx.
>
> guess it would make sense to deploy this more widely :)

It's on my TODO list -- or should I better file an EasyHack for it?

>> (2) I skimmed over the file "cppu/inc/com/sun/star/uno/Sequence.hxx"
>> since (a) there are no Doxygen pages for this module and (b) this
>> seems to be the return value of
>> "SwXTextDefaults::getSupportedServiceNames". As far as I understand,
>> this class does not provide any option to do such a simple "contains?"
>> checking (like e.g. the Java Collection class
>> <http://docs.oracle.com/javase/6/docs/api/java/util/Collection.html#contains(java.lang.Object)>).
>
> hmmm, adding such a method would be possible.
>
> but you can already do something similar by using the STL algorithms;
> there is a comphelper/stlunosequence.hxx that has some begin()/end()
> functions that work on uno::Sequence, and with that you can just use
> std::find() like on any STL container, which i guess is what's
> appropriate in C++.

Hmm... ok. But why not encapsulate this construct into a wrapper
method so that one does not need to repeat it at every position where
one wants to make such a lookup? Or would that introduce a circular
dependency? I put the point on my TODO list as well and will check it
in a few weeks when I understand C++ better.


More information about the LibreOffice mailing list