[Libreoffice] Question about using namespace ::com::sun::star::uno
Julien Nabet
serval2412 at yahoo.fr
Mon Mar 7 11:25:26 PST 2011
Le 07/03/2011 16:45, Kohei Yoshida a écrit :
> On Sun, 2011-03-06 at 23:14 +0100, Julien Nabet wrote:
>
>> Le 04/03/2011 23:48, Julien Nabet a écrit :
>>
>>> Hello,
>>>
>>> I just finished the removing of using reference ::rtl:: in each
>>> directory (binfilters included).
>>> I'd like to be sure of what has to be done for "::com::sun::star::uno"
>>> part
>>> 1) remove "using namespace ::com::sun::star::uno" ok
>>> 2) replace "Reference" by "uno::Reference" ok
>>> 3) But what about "use ::com::sun::star" ? Must we replace this :
>>> using namespace ::com::sun::star::uno
>>> by this :
>>> using ::com::sun::star
>>> ?
>>>
>>> Julien.
>>>
>> Hello,
>>
>> I attached a patch which is a first try.
>> The patched file, sc/source/filter/xml/xmlstyli.cxx already had
>> using com::sun::star::uno::Reference;
>> but he had too :
>> using namespace ::com::sun::star:uno;
>>
>> So I removed the using namespace and had to add :
>> using com::sun::star::uno::UNO_QUERY;
>> for the compilation.
>> Is this patch ok ?
>>
> Yup, that patch looks good. Please commit& push.
>
>
>
>> If it's ok, 2 remarks :
>> 1) this file also has this :
>> using namespace ::com::sun::star;
>> using namespace ::com::sun::star::xml::sax;
>> using namespace ::com::sun::star::style;
>> using namespace ::com::sun::star::frame;
>> using namespace ::com::sun::star::beans;
>> using namespace ::com::sun::star::container;
>> Is the Reference problem which needs the removing of "using namespace
>> ::com::sun::star::uno" the only one or may there be some others "using
>> namespace" to remove ?
>>
> Well, aside from removing "using namespace ::rtl" which clearly caused
> clashes between rtl::Reference and com::sun::star::uno::Reference,
> nothing else is clear. So, I personally don't want us to go overboard
> on this.
>
> Even with "using namespace ::com::sun::star::uno", it's not clear that
> we want to remove this from all source files. I would rather we decide
> on a file-by-file basis, when we get a build issue due to symbol name
> clash on some platforms.
>
>
>> I read in some websites that it's better to remove "using namespace" in
>> include files to avoid conflicts.
>>
> If it's in a header file, yes. But those *.cxx *.cpp files are not
> header files. Header files typically have *.h, *.hxx or *.hpp
> extensions.
>
>
>> 2) like the other replacement (using namespace ::rtl), the changes will
>> certainly give some errors that i won't see since, obviously, i don't
>> compile with all environments and all the combinations of options. The
>> pb is there may be a lot more errors than when i made replacements for
>> using namespace ::rtl.
>>
> Then, my preference is to *not* remove using
> namespace ::com::sun::star::uno across the board, but only when using
> that causes some build issues on some platforms.
>
> Kohei
>
>
Ok I commit the patch and I let this task aside. I let you decide what
to do the easyhack section about it.
Thank you for your answers on this subject !
Julien.
More information about the LibreOffice
mailing list