Subject : Help regarding Bug 90341 - Clean up excessive const_cast'ing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

So I was aiming to do a medium difficulty level easy hack and came
across this one (Bug 90341) which interested me. I then studied what
const_cast does and what was the main issue that this bug was
addressing. As I looked into it more and ran the command " git grep
--word-regexp --count const_cast | sort --numeric-sort --key=2
--field-separator=: ", I got various results and decided to look into
core/xmloff/source/style/impastpl.cxx (lines 144 & 146).
I also decided to go through the previous commits made in the bug
thread for ideas and help, such as these:
https://git.libreoffice.org/core/+/7b152167a4e4c3eaac95aee8f282873681c90092%5E%21
and https://cgit.freedesktop.org/libreoffice/core/commit/?id=4ae319ae462f3f094452046e392c8c15446736ae.
I then decided to experiment with the file (impastpl.cxx) and then
removed const & const_cast from the above-mentioned lines. Then, when
I tried to build from source I got these errors (please see attached
text file).

I wasn't sure what to make of these errors as nothing helpful came
when I googled them & I also am not heavily experienced in c++ coding.
Then I started reading some documentation of the xmloff file to come
to understand that these files were related to outputting "basic ODF
import/export filter implementation for most applications".

One of the people at LibreOffice (buovjaga) also helped me with this
and pointed out that the any2string function in that file appeared in:
https://git.libreoffice.org/core/commit/c1015fdd51909495cefdc0258c3899cd73d4d2df.
I pondered about contacting the original contributor who pushed this
commit for help but as the commit was 9+ years old I dropped that idea
pretty quickly
I'd really appreciate it if the dev team could help me in any way with
this easy hack and tell me in which direction I should go!

Thanking you for your time,
Siddharth Khattar
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx: In function ‘rtl::OUString any2string(com::sun::star::uno::Any&)’:
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx:146:36: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
  146 |     return data2string(any.getValue(), any.pType);
      |                        ~~~~~~~~~~~~^~
      |                                    |
      |                                    const void*
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx:97:19: note:   initializing argument 1 of ‘rtl::OUString data2string(void*, const typelib_TypeDescriptionReference*)’
   97 | data2string(void *data,
      |             ~~~~~~^~~~
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx: In constructor ‘XMLAutoStylePoolProperties::XMLAutoStylePoolProperties(XMLAutoStyleFamily&, std::vector<XMLPropertyState>&&, const rtl::OUString&)’:
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx:182:50: error: binding reference of type ‘com::sun::star::uno::Any&’ to ‘const com::sun::star::uno::Any’ discards qualifiers
  182 |             aStemBuffer.append(any2string(rState.maValue));
      |                                           ~~~~~~~^~~~~~~
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx:144:38: note:   initializing argument 1 of ‘rtl::OUString any2string(com::sun::star::uno::Any&)’
  144 | static OUString any2string(uno::Any& any)
      |                            ~~~~~~~~~~^~~
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx: At global scope:
/home/siddharth/Desktop/core/xmloff/source/style/impastpl.cxx:144:17: warning: ‘rtl::OUString any2string(com::sun::star::uno::Any&)’ defined but not used [-Wunused-function]
  144 | static OUString any2string(uno::Any& any)
      |                 ^~~~~~~~~~
make[1]: *** [/home/siddharth/Desktop/core/solenv/gbuild/LinkTarget.mk:337: /home/siddharth/Desktop/core/workdir/CxxObject/xmloff/source/style/impastpl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:289: build] Error 2


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux