There are tons of functions in sc/qa/unit/opencl-test.cxx that are basically copies of the same template with a few details changed. Just look at testMathFormulaRoundUp(), testMathFormulaRoundDown(), testMathFormulaInt() for instance. This should be re-factored in the obvious fashion.
(And I don't mean by using C++ templates.)
(But if you can be convincing enough, sure, that would work, too. It's a unit test so code bloat is not an issue.)
I guess this is a duplicate of bug #39593, but maybe good to have a very specific case of copy-paste as a separate bug, too.
I would like to take this up and resolve this issue as my first contribution to libreoffice.
Good, please go ahead. First learn to build LibreOffice for your platform! (It is not necessary to assign the task to yourself, as long as you mention that you are working on it in a comment.)
Created attachment 113548 [details] WIP: Only Sample implementation This is just a sample implementation. I just thought it would be better to have your input on this before doing it for the whole file.
I can observe the repetitive code and it shouldn't be hard to create a wrapper function over it as in above attached patch. However, there are few functions that make use of ScDocShell::DoHardRecalc() instead of ScDocument::CalcAll(). I was wondering what is the difference between a ScDocShell::DoHardRecalc() and ScDocument::CalcAll(). I might be able to wrap these 4-5 functions that make use of DoHardRecalc too and reduce more amount of code. Otherwise, we can also choose to not wrap these functions.
Created attachment 113558 [details] WIP: Only Sample implementation
Created attachment 113568 [details] WIP: Only Sample implementation
Pranav Kant committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=0ef455bdc33356dcf00e3a2f724b2a18e15de38f tdf#89267: Reduce duplicate code It will be available in 4.5.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
i am sorry but i am unable to understand what to do after i build the libre office.i mean where can i find these files after building the office?please help me
Is there still work to be done here? Or has the previous commit already covered everything wanted?
How about taking a look in the source file in question and check if you see any?
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner SkillCpp) [NinjaEdit]
JanI is default CC for Easy Hacks (Add Jan; remove LibreOffice Dev List from CC) [NinjaEdit]
I think this can be marked as RESOLVED:FIXED, yeah.
Actually it turned out that this refactoring caused a memory usage issue. The ScDocShellRef variables were factored out to be members in the ScOpenCLTest class instead. The ScOpenCLTest objects for all the test functions are created in advance, then the functions are run, and only then the ScOpenCLTest objects are destroyed. This meant that the data held on to by the ScDocShellRef fields was not released, but accumulated as each test function loaded a test document (twice!). But I have a fix for that which I will push in a moment.
@Tor is your fix already merged?
Yes.