Question on dubious code

Matteo Casalin matteo.casalin at yahoo.com
Sat Oct 5 10:45:07 PDT 2013


Hi all,
     in sw/source/core/graphic/ndgrf.cxx I stepped into the following 
code in function lcl_GetStreamStorageNames (this is after OUString 
conversion):

     const OUString aProt( "vnd.sun.star.Package:" );
     if (sUserData.startsWith(aProt))
     {
         // 6.0 (XML) Package
         const sal_Int32 nPos = sUserData.indexOf('/');
         if (nPos<0)
         {
             aNames.sStream = sUserData.copy(aProt.getLength());
         }
         else
         {
             sal_Int32 nPathStart = aProt.getLength();
             if (sUserData.startsWith("./"))
                 nPathStart += 2;
             aNames.sStorage = sUserData.copy( nPathStart, 
nPos-nPathStart );
             aNames.sStream = sUserData.copy( nPos+1 );
         }
     }

which looks wrong to me since aUserData cannot start with both aProt and 
".". I had a look at older revisions, but the logic remains the same at 
least from when it was integrated in 2005 with commit 
4fdb2d2cb198e7ea85d1293333d96a6c26b50323.

Does anybody knows ho to deal with this (the comparison with "./" should 
be done after aProt, is completely unnecessary, or something else)?

Thanks and kind regards
Matteo

PS: with OpenGrok I found some other locations in which 
"vnd.sun.star.Package:" is used, with also #define in two header files:

include/editeng/unoprnms.hxx
include/toolkit/controls/unocontrols.hxx

I don't have the necessary background, but maybe there could be some 
room for sharing code.


More information about the LibreOffice mailing list