[Libreoffice] Duplicate code: SwDoc::SplitDoc

Michael Meeks michael.meeks at novell.com
Mon May 9 04:27:59 PDT 2011

Hi Christina,

On Sun, 2011-05-08 at 23:08 +0200, Chr. Rossmanith wrote:
> there are two slightly different implementations of SwDoc::SplitDoc(), 

	Wow - that is -horrible- :-) sw/source/core/doc/docglbl.cxx takes quite
some reading. Anyone cutting and pasting code like that deserves a
near-death experience ...

> depending on the third parameter given. As far as I can see they only 
> differ in the way pSttNd (what stands Stt for?) and pEndNd are found. If 
> that's true, I'd suggest to have two different GetEndNode() and 
> GetSttNode() methods and only one


> with either pSplitColl OR nOutlineLevel passed as parameter but not 
> both. Would that be bad coding style ?

	It would be great; we could leave the public methods as they are now,
and have a single private impl. that they call with the extra
'bool bOutline' or whatever ?

>  On the other hand, are ~200 lines of identical code good style ?

	Simply terrible :-)

>  Any suggestions how to get rid of the duplicates else?

	I would save each method to its own file, and do a 'diff -uw' between
them to be sure we isolated all the changes. Then add a boolean
conditional in there instead, and revert to a single version. Of course,
any differences may be bug fixes that only hit one version ;-) so I'd be
inclined to check their provenance in the git record.



 michael.meeks at novell.com  <><, Pseudo Engineer, itinerant idiot

More information about the LibreOffice mailing list