Re: [Libreoffice] [PATCH] Conditional compilation of legacy Addin mechanism in calc

2011-02-21 Thread Kohei Yoshida
On Sat, 2011-02-19 at 09:33 +, Alfonso Eusebio wrote:
 Hi,
 
 Please find attached patches for the conditional removal of legacy calc 
 addins.
 As always, these changes are made available under LGPLv3+/MPL.
 
 Kohei, I have used a macro definition to conditionally compile the code 
 in/out.
 In this patch the macro (SC_WITHOUT_LEGACY_ADDIN) is undefined, so the 
 mechanism 
 is left untouched.
 
 Defining SC_WITHOUT_LEGACY_ADDIN in global.hxx (both in calc and in 
 binfilter) 
 will remove the legacy addin mechanism.

Thanks a lot for this patch.  This helps identify those code blocks that
can potentially be removed later.

One correction is needed however.  You've used #ifndef  #endif block
throughout the code base to conditionally disable code blocks, but the
better way is to define in global.hxx

#define SC_WITH_LEGACY_ADDIN 1

and use

#if SC_WITH_LEGACY_ADDIN

  code block

#endif

This way, all you have to do to enable/disable the code is to toggle the
value of SC_WITH_LEGACY_ADDIN in the global.hxx and re-compile.

Another thing is to associate the value of 1 to enabling, and the value
of 0 to disabling, to make it easier for the brain to process this, as
it requires a bit of extra work mentally to process 0 for enabling and 1
for disabling.

Thanks!

Kohei

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Conditional compilation of legacy Addin mechanism in calc

2011-02-19 Thread Alfonso Eusebio
Hi,

Please find attached patches for the conditional removal of legacy calc addins.
As always, these changes are made available under LGPLv3+/MPL.

Kohei, I have used a macro definition to conditionally compile the code in/out.
In this patch the macro (SC_WITHOUT_LEGACY_ADDIN) is undefined, so the 
mechanism 
is left untouched.

Defining SC_WITHOUT_LEGACY_ADDIN in global.hxx (both in calc and in binfilter) 
will remove the legacy addin mechanism.

The changes are not optimal from a code point of view, but I've tried to ensure 
that it is clear what needs to be removed when (and if) the mechanism is 
finally 
eliminated.
Searching for SC_WITHOUT_LEGACY_ADDIN will find all the pieces of code that 
should be removed.

Regards,
Alfonso



- Original Message 
From: Kohei Yoshida kyosh...@novell.com
To: Alfonso Eusebio alfonso_euse...@yahoo.co.uk
Cc: michael.me...@novell.com
Sent: Thu, 17 February, 2011 15:31:03
Subject: Re: [Libreoffice] [PATCH] Remove legacy Addin mechanism from calc

On Thu, 2011-02-17 at 13:39 +, Alfonso Eusebio wrote:
 Hi Michael,
 
 Don't worry: it was a bit of work, but it was a good exercise as well.
 I'm happy to change it to conditionally compiled if you think it's worth  it, 

My preferred approach is indeed to make this code conditionally
compiled, and at some point experimentally ship a release without this
piece to see how many users complain. ;-)

And yes, that would be worth the effort IMO.

 The only problem I see is that the version with this piece excluded  might 
 not 

 get that much testing and hide some issues (I did only limited  testing).

If we can make that a build time option with --enable-calc-addin (or
similar), and then default to on, then we can still test this piece.  If
you are not too familiar with these autoconf stuff, simply defining a
switch somewhere in sc/inc/global.hxx would be fine.  Then one of us
will work on making that a configure/autogen.sh option.

Thanks a lot for looking into this, BTW.

Kohei

-- 
Kohei Yoshida, LibreOffice hacker, Calc
kyosh...@novell.com


  From a034cf51de6e1decb36da9b2a07dbdf06d161102 Mon Sep 17 00:00:00 2001
From: Alfonso Eusebio alfonso_euse...@yahoo.co.uk
Date: Sat, 19 Feb 2011 09:15:23 +
Subject: [PATCH] Conditional compilation of legacy addins in calc

Introduces conditional compilation of legacy addin mechanism in calc.
Controlled through a macro definition in global.hxx
---
 sc/inc/callform.hxx  |5 +
 sc/inc/global.hxx|7 +++
 sc/source/core/data/documen2.cxx |6 ++
 sc/source/core/data/funcdesc.cxx |   10 +-
 sc/source/core/data/global.cxx   |   17 -
 sc/source/core/data/globalx.cxx  |9 ++---
 sc/source/core/inc/addinlis.hxx  |   11 +++
 sc/source/core/inc/adiasync.hxx  |5 -
 sc/source/core/inc/core_pch.hxx  |9 +
 sc/source/core/inc/interpre.hxx  |3 +++
 sc/source/core/tool/addinlis.cxx |5 +
 sc/source/core/tool/adiasync.cxx |7 ++-
 sc/source/core/tool/callform.cxx |   12 ++--
 sc/source/core/tool/compiler.cxx |   10 ++
 sc/source/core/tool/interpr4.cxx |   19 ---
 sc/source/core/tool/parclass.cxx |   12 ++--
 sc/source/ui/unoobj/funcuno.cxx  |7 +++
 17 files changed, 132 insertions(+), 22 deletions(-)

diff --git a/sc/inc/callform.hxx b/sc/inc/callform.hxx
index df22605..4add518 100644
--- a/sc/inc/callform.hxx
+++ b/sc/inc/callform.hxx
@@ -29,6 +29,9 @@
 #ifndef SC_CALLFORM_HXX
 #define SC_CALLFORM_HXX
 
+#include global.hxx  // for SC_WITHOUT_LEGACY_ADDIN definition
+#ifndef SC_WITHOUT_LEGACY_ADDIN  //Conditionally removes legacy addin
+
 #include collect.hxx
 
 #include rtl/ustring.hxx
@@ -125,6 +128,8 @@ public:
 BOOL InitExternalFunc(const rtl::OUString rModuleName);
 void ExitExternalFunc();
 
+#endif //SC_WITHOUT_LEGACY_ADDIN
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 80e4ccc..3143e42 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -29,6 +29,9 @@
 #ifndef SC_SCGLOB_HXX
 #define SC_SCGLOB_HXX
 
+// Remove comment below to remove legacy addins mechanism
+//#define SC_WITHOUT_LEGACY_ADDIN //When defined the legacy addin mechanism is not compiled in
+
 #include address.hxx
 #include i18npool/lang.h
 #include tools/stream.hxx
@@ -555,7 +558,9 @@ public:
 SC_DLLPUBLIC static void	SetSearchItem( const SvxSearchItem rNew );
 SC_DLLPUBLIC static ScAutoFormat*		GetAutoFormat();
 static void	ClearAutoFormat(); //BugId 54209
+#ifndef SC_WITHOUT_LEGACY_ADDIN
 static FuncCollection*		GetFuncCollection();
+#endif
 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
 SC_DLLPUBLIC static ScUserList*			GetUserList();
 static void	SetUserList( const ScUserList* pNewList );
@@ -582,7 +587,9 @@ public:
 static longnLastColWidthExtra;
 
 static void Init();		// during