[Libreoffice] [PATCH] Easy Hack - Get rid ofSvULongs in writer
Kohei Yoshida
kohei.yoshida at suse.com
Tue Aug 2 21:23:02 PDT 2011
On Tue, 2011-08-02 at 19:12 +0200, Maciej Rumianowski wrote:
> Hello,
>
> This is my second patch for Bug 38831 - [EasyHack] Get rid of
> SV_DECL_VARARR, SV_DECL_VARARR_PLAIN, SV_DECL_VARARR_SORT ....
>
> It replace SvULongs and WW8_WrSepInfoPtrs (another VARARR) with
> std:vector, SvStringsDtor with boost::ptr_vector in writer.
@@ -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.
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.
Other than that, the rest looks okay to me. I'd prefer someone more
experienced in Writer's code to sanity-check though.
Kohei
--
Kohei Yoshida, LibreOffice hacker, Calc
<kohei.yoshida at suse.com>
More information about the LibreOffice
mailing list