[Libreoffice-commits] .: extensions/source

Michael Stahl mst at kemper.freedesktop.org
Mon Jan 9 09:54:06 PST 2012


 extensions/source/plugin/aqua/sysplug.mm             |   72 +++++++++++++++++++
 extensions/source/plugin/base/nfuncs.cxx             |   31 +-------
 extensions/source/plugin/base/xplugin.cxx            |    4 -
 extensions/source/plugin/inc/plugin/aqua/sysplug.hxx |   27 ++-----
 extensions/source/plugin/inc/plugin/impl.hxx         |   29 +++++--
 extensions/source/plugin/unx/sysplug.cxx             |    6 +
 extensions/source/plugin/win/sysplug.cxx             |    4 +
 7 files changed, 117 insertions(+), 56 deletions(-)

New commits:
commit 8f468159691f051ea2fa5d28486b989ecc75d69a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jan 9 18:47:31 2012 +0100

    extensions: plugin: try to fix Mac build:
    
    Move everything that requires ObjectiveC stuff to the ObjC++ files in
    the aqua subdirectory, where it belongs.

diff --git a/extensions/source/plugin/aqua/sysplug.mm b/extensions/source/plugin/aqua/sysplug.mm
index 415ca93..8db2dce 100644
--- a/extensions/source/plugin/aqua/sysplug.mm
+++ b/extensions/source/plugin/aqua/sysplug.mm
@@ -30,6 +30,11 @@
 #include <sys/types.h>
 #include <signal.h>
 #include <sys/wait.h>
+
+#include "premac.h"
+#include <Cocoa/Cocoa.h>
+#include "postmac.h"
+
 #include <osl/thread.h>
 
 #include <plugin/impl.hxx>
@@ -51,6 +56,73 @@ void TRACEN( char const * s, long n );
 #define TRACEN(x,n)
 #endif
 
+
+struct SysPlugData
+{
+    MacPluginComm::NP_CGContext m_aCGContext;
+    NP_Port                     m_aNPPort;
+    NSView*                     m_pParentView;
+    NSView*                     m_pPlugView;
+    int                         m_nDrawingModel;
+    NSPoint                     m_aLastPlugViewOrigin;
+    bool                        m_bSetWindowOnDraw;
+    SysPlugData()
+    {
+        memset( this, 0, sizeof(*this) );
+    }
+};
+
+::boost::shared_ptr<SysPlugData> CreateSysPlugData()
+{
+    return ::boost::shared_ptr<SysPlugData>(new SysPlugData);
+}
+
+void XPlugin_Impl::SetSysPlugDataParentView(SystemEnvData* pEnvData)
+{
+    m_pSysPlugData.m_pParentView = pEnvData->pView;
+}
+
+extern "C" {
+
+void /*SAL_CALL NP_LOADDS*/  NPN_ForceRedraw_Impl(NPP instance)
+{
+    TRACE( "NPN_ForceRedraw_Impl" );
+    XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+    if( pImpl )
+    {
+        SysPlugData& rPlugData( pImpl->getSysPlugData() );
+        if( rPlugData.m_pPlugView )
+            [rPlugData.m_pPlugView setNeedsDisplay: YES];
+    }
+}
+
+NPError /*SAL_CALL NP_LOADDS*/  NPN_SetValue_Impl( NPP instance,
+                                          NPPVariable variable,
+                                          void* value )
+{
+    TRACE( "NPN_SetValue_Impl" );
+    switch( variable )
+    {
+        case (NPPVariable)1000: // NPNVpluginDrawingModel
+        {
+            // ugly, but that's the way we need to do it
+            int nDrawingModel = (int)value;
+
+            TRACEN( "drawing model: ", nDrawingModel );
+            XPlugin_Impl* pImpl =
+                XPluginManager_Impl::getXPluginFromNPP( instance );
+            if (pImpl)
+                pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel;
+        }
+        break;
+        default:
+        break;
+    }
+    return NPERR_NO_ERROR;
+}
+
+} // extern "C"
+
 struct FakeEventRecord : public EventRecord
 {
     FakeEventRecord()
diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx
index d06c5b8..69b73f5 100644
--- a/extensions/source/plugin/base/nfuncs.cxx
+++ b/extensions/source/plugin/base/nfuncs.cxx
@@ -600,28 +600,11 @@ NPError SAL_CALL NP_LOADDS  NPN_SetValue( NPP instance,
 {
     NPError nError = NPERR_NO_ERROR;
     TRACEN( "NPN_SetValue ", variable );
-    switch( variable )
-    {
     #ifdef QUARTZ
-    case (NPPVariable)1000: // NPNVpluginDrawingModel
-    {
-        int nDrawingModel = (int)value; // ugly, but that's the way we need to do it
-
-        TRACEN( "drawing model: ", nDrawingModel );
-
-        XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
-        if( pImpl )
-            pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel;
-    }
-    break;
-    #endif
-    case NPPVpluginNameString: // make the windows compiler happy, it needs at least one case statement
-        break;
-    default:
-        break;
-    }
-    #ifndef QUARTZ
+    NPN_SetValue_Impl(instance, variable, value);
+    #else
     (void)instance;
+    (void)variable;
     (void)value;
     #endif
     return nError;
@@ -653,13 +636,7 @@ void SAL_CALL NP_LOADDS  NPN_ForceRedraw(NPP instance)
 {
     TRACE( "NPN_ForceRedraw" );
     #ifdef QUARTZ
-    XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
-    if( pImpl )
-    {
-        SysPlugData& rPlugData( pImpl->getSysPlugData() );
-        if( rPlugData.m_pPlugView )
-            [rPlugData.m_pPlugView setNeedsDisplay: YES];
-    }
+    NPN_ForceRedraw_Impl(instance);
     #else
     (void)instance;
     #endif
diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx
index fa9798e..4cce131 100644
--- a/extensions/source/plugin/base/xplugin.cxx
+++ b/extensions/source/plugin/base/xplugin.cxx
@@ -119,6 +119,7 @@ XPlugin_Impl::XPlugin_Impl( const uno::Reference< com::sun::star::lang::XMultiSe
         PluginControl_Impl(),
         m_xSMgr( rSMgr ),
         m_pPluginComm( NULL ),
+        m_pSysPlugData( CreateSysPlugData() ),
         m_aEncoding( osl_getThreadTextEncoding() ),
         m_pArgv( NULL ),
         m_pArgn( NULL ),
@@ -131,7 +132,6 @@ XPlugin_Impl::XPlugin_Impl( const uno::Reference< com::sun::star::lang::XMultiSe
 {
     memset( &m_aInstance, 0, sizeof( m_aInstance ) );
     memset( &m_aNPWindow, 0, sizeof( m_aNPWindow ) );
-    memset( &m_aSysPlugData, 0, sizeof( m_aSysPlugData ) );
 
     m_xModel = new PluginModel();
     uno::Reference< com::sun::star::beans::XPropertySet >  xPS( m_xModel, UNO_QUERY );
@@ -566,7 +566,7 @@ void XPlugin_Impl::loadPlugin()
                  NULL );
 #ifdef QUARTZ
     // m_aNPWindow is set up in the MacPluginComm from the view
-    m_aSysPlugData.m_pParentView = pEnvData->pView;
+    SetSysPlugDataParentView(pEnvData);
 #elif defined( UNX )
     XSync( (Display*)pEnvData->pDisplay, False );
     m_aNPWindow.window      = (void*)pEnvData->aWindow;
diff --git a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx
index ab3e5dd..ebf3025 100644
--- a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx
+++ b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx
@@ -25,8 +25,8 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-#ifndef __PLUGIN_INC_MACPLUG_HXX
-#define __PLUGIN_INC_MACPLUG_HXX
+#ifndef PLUGIN_INC_MACPLUG_HXX
+#define PLUGIN_INC_MACPLUG_HXX
 
 #include <unistd.h>
 
@@ -44,15 +44,18 @@
 #include "npsdk/npupp.h"
 
 #include "plugin/plcom.hxx"
-#include "premac.h"
-#include <Cocoa/Cocoa.h>
-#include "postmac.h"
 
 #include "vcl/sysdata.hxx"
 #include "vcl/threadex.hxx"
 #include "vcl/timer.hxx"
 #include "osl/module.h"
 
+#ifdef __OBJC__
+ at class NSView;
+#else
+class NSView;
+#endif
+
 class XPlugin_Impl;
 
 namespace plugstringhelper
@@ -150,20 +153,6 @@ private:
     std::list< XPlugin_Impl* >      m_aNullEventClients;
 };
 
-struct SysPlugData
-{
-    MacPluginComm::NP_CGContext m_aCGContext;
-    NP_Port                     m_aNPPort;
-    NSView*                     m_pParentView;
-    NSView*                     m_pPlugView;
-    int                         m_nDrawingModel;
-    NSPoint                     m_aLastPlugViewOrigin;
-    bool                        m_bSetWindowOnDraw;
-};
-
-
-
 #endif
 
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/impl.hxx b/extensions/source/plugin/inc/plugin/impl.hxx
index 6b1ce4a..4ba1b9a 100644
--- a/extensions/source/plugin/inc/plugin/impl.hxx
+++ b/extensions/source/plugin/inc/plugin/impl.hxx
@@ -25,13 +25,15 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-#ifndef __PLUGIN_SOURCE_MGR_IMPL_HXX
-#define __PLUGIN_SOURCE_MGR_IMPL_HXX
+#ifndef PLUGIN_SOURCE_MGR_IMPL_HXX
+#define PLUGIN_SOURCE_MGR_IMPL_HXX
 
 #ifdef SOLARIS
 #include <limits>
 #endif
 
+#include <boost/shared_ptr.hpp>
+
 #include "cppuhelper/weak.hxx"
 
 #include "com/sun/star/awt/Key.hpp"
@@ -81,10 +83,17 @@
 #include "plugin/unx/sysplug.hxx"
 #endif
 
-#if ! defined (QUARTZ)
-// the QUARTZ implementation needs special instance data
-typedef int SysPlugData;
-#endif
+struct SysPlugData;
+
+::boost::shared_ptr<SysPlugData> CreateSysPlugData();
+
+extern "C" {
+
+void /*SAL_CALL NP_LOADDS*/  NPN_ForceRedraw_Impl(NPP instance);
+NPError /*SAL_CALL NP_LOADDS*/  NPN_SetValue_Impl( NPP instance,
+                                          NPPVariable variable,
+                                          void* value );
+} // extern "C"
 
 #include "plugin/plctrl.hxx"
 #include "plugin/model.hxx"
@@ -123,7 +132,7 @@ private:
     PluginComm*                 m_pPluginComm;
     NPP_t                       m_aInstance;
     NPWindow                    m_aNPWindow;
-    SysPlugData                 m_aSysPlugData;
+    ::boost::shared_ptr<SysPlugData> m_pSysPlugData;
     rtl_TextEncoding            m_aEncoding;
 
     const char**                m_pArgv;
@@ -147,6 +156,10 @@ private:
 
     sal_Bool                        m_bIsDisposed;
 
+#ifdef QUARTZ
+    void SetSysPlugDataParentView(SystemEnvData* pEnvData);
+#endif
+
     void prependArg( const char* pName, const char* pValue ); // arguments will be strdup'ed
     void initArgs( const Sequence< rtl::OUString >& argn,
                    const Sequence< rtl::OUString >& argv,
@@ -186,7 +199,7 @@ public:
     rtl_TextEncoding getTextEncoding() { return m_aEncoding; }
     NPP             getNPPInstance() { return &m_aInstance; }
     NPWindow*       getNPWindow() { return &m_aNPWindow; }
-    SysPlugData&    getSysPlugData() { return m_aSysPlugData; }
+    SysPlugData&    getSysPlugData() { return *m_pSysPlugData; }
 
     void            enterPluginCallback() { m_nCalledFromPlugin++; }
     void            leavePluginCallback() { m_nCalledFromPlugin--; }
diff --git a/extensions/source/plugin/unx/sysplug.cxx b/extensions/source/plugin/unx/sysplug.cxx
index 8a2d240..24968fe 100644
--- a/extensions/source/plugin/unx/sysplug.cxx
+++ b/extensions/source/plugin/unx/sysplug.cxx
@@ -44,6 +44,12 @@
 
 #include <plugin/impl.hxx>
 
+
+::boost::shared_ptr<SysPlugData> CreateSysPlugData()
+{
+    return ::boost::shared_ptr<SysPlugData>();
+}
+
 int UnxPluginComm::nConnCounter = 0;
 
 UnxPluginComm::UnxPluginComm(
diff --git a/extensions/source/plugin/win/sysplug.cxx b/extensions/source/plugin/win/sysplug.cxx
index c60242e..b446719 100644
--- a/extensions/source/plugin/win/sysplug.cxx
+++ b/extensions/source/plugin/win/sysplug.cxx
@@ -63,6 +63,10 @@ void TRACEN( char const * s, long n );
 #define TRACEN(x,n)
 #endif
 
+::boost::shared_ptr<SysPlugData> CreateSysPlugData()
+{
+    return ::boost::shared_ptr<SysPlugData>();
+}
 
 //--------------------------------------------------------------------------------------------------
 PluginComm_Impl::PluginComm_Impl( const OUString& /*rMIME*/, const OUString& rName, HWND /*hWnd*/ )


More information about the Libreoffice-commits mailing list