[Libreoffice] [PATCH] Easy Hack - Get rid ofSvULongs in writer

Maciej Rumianowski maciej.rumianowski at gmail.com
Wed Aug 3 15:40:54 PDT 2011

Dnia 2011-08-03, śro o godzinie 00:23 -0400, Kohei Yoshida pisze:
> @@ -2017,7 +2011,7 @@ bool
> WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
>              {
>                  // textbox - content
>                  WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
> -                aCps.Insert( nCP, i );
> +                aCps.push_back( nCP );
>                  pTxtPos->Append( nCP );
> Hmm are you sure that you can replace that with vector's push_back()
> there?  For this to work correctly the i has to always point to the
> end
> position (last element + 1), but from the surrounding code I'm not
> sure
> if that's guaranteed.  You probably should use vector's insert()
> method
> with a specific insert position, instead of using push_back() in this
> case.

Ups, I will be more careful in the future, I have checked the function
itself but as you said calling this function is not guaranteed with
empty aCps.

> Also, I've seen a code like the following
> if (!vec.empty())
>     vec.clear();
> in several places.  While this code is not wrong (since the original
> code was written that way), calling clear() on an empty vector does
> nothing & is harmless.  So just calling clear() should be fine without
> checking for empty-ness.

Ok changed.

> Other than that, the rest looks okay to me.  I'd prefer someone more
> experienced in Writer's code to sanity-check though. 

O, so by the way there is in wrtww8.hxx a VARARR WW8Bytes which should
be migrated to ww::bytes. Is it okay to do?

Best Regards,

More information about the LibreOffice mailing list