[Libreoffice-commits] core.git: 14 commits - chart2/inc chart2/source include/vcl offapi/com offapi/UnoApi_offapi.mk sc/Library_sc.mk sc/source vcl/Library_vclopengl.mk vcl/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Wed May 7 12:28:33 PDT 2014


 chart2/inc/ChartModel.hxx                             |   18 +++++-
 chart2/source/model/main/ChartModel.cxx               |   18 ++++++
 chart2/source/view/charttypes/GL3DBarChart.cxx        |   18 ++++--
 chart2/source/view/inc/3DChartObjects.hxx             |   18 ------
 chart2/source/view/inc/GL3DBarChart.hxx               |    6 +-
 chart2/source/view/inc/GL3DRenderer.hxx               |    4 -
 chart2/source/view/main/3DChartObjects.cxx            |   31 -----------
 chart2/source/view/main/ChartView.cxx                 |   18 ++++++
 include/vcl/openglwin.hxx                             |   35 +++++++++++++
 offapi/UnoApi_offapi.mk                               |    1 
 offapi/com/sun/star/chart2/X3DChartWindowProvider.idl |   33 ++++++++++++
 sc/Library_sc.mk                                      |    1 
 sc/source/ui/drawfunc/fuins2.cxx                      |   25 +++++++++
 sc/source/ui/inc/gridwin.hxx                          |    7 ++
 sc/source/ui/view/gridwin5.cxx                        |    5 +
 vcl/Library_vclopengl.mk                              |    1 
 vcl/source/window/openglwin.cxx                       |   47 ++++++++++++++++++
 17 files changed, 225 insertions(+), 61 deletions(-)

New commits:
commit b2dffb1addc0285c6a00ad3efdbfafff734c260c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 21:01:47 2014 +0200

    fix crash on exit
    
    Change-Id: I31374684a09f1b056154efcaa5c7dfe73bcc1a61

diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 0c941b2..2043ff9 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -82,6 +82,7 @@ using namespace ::com::sun::star;
 #include "globstr.hrc"
 #include "drawview.hxx"
 #include "markdata.hxx"
+#include "gridwin.hxx"
 
 namespace {
 
@@ -544,11 +545,19 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
         ScDocument* pScDoc   = pScDocSh->GetDocument();
         bool bUndo (pScDoc->IsUndoEnabled());
 
-        OpenGLWindow* pChildWindow = new OpenGLWindow(pData->GetActiveWin());
+        Window* pParentWindow = pData->GetActiveWin();
+        ScGridWindow* pGridWindow = dynamic_cast<ScGridWindow*>(pParentWindow);
+        if(pGridWindow)
+        {
+            pGridWindow->AddChildWindow(pGridWindow);
+        }
+        else
+            SAL_WARN("sc", "not a grid window. Youare in serious trouble");
+        OpenGLWindow* pChildWindow = new OpenGLWindow(pParentWindow);
         Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
         pChildWindow->SetSizePixel(aWindowSize);
         Wallpaper aBackground = pChildWindow->GetBackground();
-        aBackground.SetColor(COL_RED);
+        aBackground.SetColor(COL_BLUE);
         pChildWindow->SetBackground(aBackground);
         pChildWindow->Show();
         uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( xChartModel, uno::UNO_QUERY_THROW );
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 63e930b..5170e25 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -32,6 +32,7 @@
 #include <boost/scoped_ptr.hpp>
 #include <boost/unordered_map.hpp>
 #include <boost/ptr_container/ptr_map.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
 
 namespace editeng {
     struct MisspellRanges;
@@ -129,6 +130,7 @@ class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHe
     VisibleRange maVisibleRange;
 
     boost::scoped_ptr<sc::SpellCheckContext> mpSpellCheckCxt;
+    boost::ptr_vector<Window> maChildWindows;
 
     ScViewData*             pViewData;
     ScSplitPos              eWhich;
@@ -409,6 +411,11 @@ public:
     void            UpdateShrinkOverlay();
     void            UpdateAllOverlays();
 
+    /**
+     * Takes ownership of the window
+     */
+    void            AddChildWindow(Window* pChildWindow);
+
 protected:
     // #114409#
     void ImpCreateOverlayObjects();
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index 404ca59..798d34a 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -474,4 +474,9 @@ void ScGridWindow::SwitchView()
     }
 }
 
+void ScGridWindow::AddChildWindow(Window* pWindow)
+{
+    maChildWindows.push_back(pWindow);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 945ee344830fe22602cf9beb632a1ad58903e9a4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 21:01:28 2014 +0200

    hide OpenGLWindow in normal charts
    
    Change-Id: Ie45a910d2b99b7644a8055476aa191ef8a724d38

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 79eec7b..93d4133 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2459,6 +2459,14 @@ void ChartView::createShapes()
         createShapes3D();
         return;
     }
+    else
+    {
+        // hide OpenGL window for now in normal charts
+        OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
+        if(pWindow)
+            pWindow->Show(false);
+
+    }
 #endif
 
     {
@@ -3149,6 +3157,8 @@ void ChartView::createShapes3D()
     if(!pWindow)
         return;
 
+    pWindow->Show();
+
     GL3DBarChart aBarChart(aDataSeries, *pWindow);
     aBarChart.create3DShapes();
     aBarChart.render();
commit 5ae77e8fbf34bf2e76612f7e39f87ccfbc846c80
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 20:37:15 2014 +0200

    provide bar color for 3D OGL chart
    
    Change-Id: Ia41748cabba89a0257c62f66a280810adc56960e

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index e21a34b..12a5417 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -17,6 +17,8 @@
 #include "3DChartObjects.hxx"
 #include "GL3DRenderer.hxx"
 
+using namespace com::sun::star;
+
 namespace chart {
 
 GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries,
@@ -53,11 +55,13 @@ void GL3DBarChart::create3DShapes()
             float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
             float nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY);
 
+            sal_Int32 nColor = COL_BLUE;
+
             glm::mat4 aBarPosition;
             aBarPosition = glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
             aBarPosition = glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
 
-            maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nId++));
+            maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++));
         }
 
         ++nSeriesIndex;
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 9b4f118..05c2f5b 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -37,7 +37,7 @@ protected:
 class Bar : public Renderable3DObject
 {
 public:
-    Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId);
+    Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 nColor, sal_uInt32 nId);
 
     virtual void render() SAL_OVERRIDE;
 private:
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 86f9c63..c43b999 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -24,10 +24,11 @@ void Renderable3DObject::render()
     (void) mnUniqueId;
 }
 
-Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId)
+Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId)
     : Renderable3DObject(pRenderer, nId)
     , mbRoundedCorners(false)
     , maPos(rPosition)
+    , maColor(aColor)
 {
 }
 
commit 464439667f7f3e356549d91380ebd58273ccce9d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 20:35:42 2014 +0200

    fix crash when canceling the chart wizard
    
    Change-Id: Iebd9db279e9db22bc273509cf480737d7c7a1dd6

diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 873588d..0c941b2 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -724,7 +724,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
                         sal_Int16 nDialogRet = xDialog->execute();
                         if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
                         {
-                            delete pWindow;
+                            delete pChildWindow;
                             // leave OLE inplace mode and unmark
                             OSL_ASSERT( pViewShell );
                             OSL_ASSERT( pView );
commit 66d02a560469aa42990b2eff0fe9bce1f82dc21a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 15:47:17 2014 +0200

    set the size to context and renderer before rendering
    
    Change-Id: I2945a7b8647d0a40270b1e65cde2a0eb936ab1d1

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 9c4264d..e21a34b 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -67,6 +67,9 @@ void GL3DBarChart::create3DShapes()
 void GL3DBarChart::render()
 {
     mrWindow.getContext()->makeCurrent();
+    Size aSize = mrWindow.GetSizePixel();
+    mpRenderer->SetSize(aSize);
+    mrWindow.getContext()->setWinSize(aSize);
     for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
             itrEnd = maShapes.end(); itr != itrEnd; ++itr)
     {
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 1df5ea1..81c9315 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -249,9 +249,9 @@ private:
     double m_dFreq;
 #endif
 
-    int m_iWidth;
+    sal_Int32 m_iWidth;
 
-    int m_iHeight;
+    sal_Int32 m_iHeight;
 
     float m_fZmax;
 
commit 62b71e9ad3b7e3b2e6dd6c872b6c5d806859bd0f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 15:34:51 2014 +0200

    let us pass the window to get the size correct
    
    Change-Id: I8bd8a319e67cdcf7266d3c8f86d1bf132163d665

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index f19ab64..9c4264d 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -20,10 +20,10 @@
 namespace chart {
 
 GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries,
-        OpenGLContext& rContext):
+        OpenGLWindow& rWindow):
     maDataSeries(rDataSeries),
     mpRenderer(new opengl3D::OpenGL3DRenderer()),
-    mrContext(rContext)
+    mrWindow(rWindow)
 {
 }
 
@@ -66,13 +66,13 @@ void GL3DBarChart::create3DShapes()
 
 void GL3DBarChart::render()
 {
-    mrContext.makeCurrent();
+    mrWindow.getContext()->makeCurrent();
     for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
             itrEnd = maShapes.end(); itr != itrEnd; ++itr)
     {
         itr->render();
     }
-    mrContext.swapBuffers();
+    mrWindow.getContext()->swapBuffers();
 }
 
 }
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 6efc86c..06b1be5 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -14,7 +14,7 @@
 #include <boost/ptr_container/ptr_vector.hpp>
 #include "VDataSeries.hxx"
 
-#include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/openglwin.hxx>
 
 namespace chart {
 
@@ -32,7 +32,7 @@ class TemporaryContext;
 class GL3DBarChart
 {
 public:
-    GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries, OpenGLContext& rContext);
+    GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries, OpenGLWindow& rContext);
     ~GL3DBarChart();
 
     void create3DShapes();
@@ -45,7 +45,7 @@ private:
     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
 
     boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
-    OpenGLContext& mrContext;
+    OpenGLWindow& mrWindow;
 };
 
 }
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 98c9b91..79eec7b 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -3149,7 +3149,7 @@ void ChartView::createShapes3D()
     if(!pWindow)
         return;
 
-    GL3DBarChart aBarChart(aDataSeries, *pWindow->getContext());
+    GL3DBarChart aBarChart(aDataSeries, *pWindow);
     aBarChart.create3DShapes();
     aBarChart.render();
 }
commit 4df22646d43f9d5f2063eaa663223aae07c1d443
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 05:17:19 2014 +0200

    the temporary context can finally die
    
    Change-Id: I7dec2772000e25c4bd23f21b61dbd835ef9397cf

diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index c86b3f0..9b4f118 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -99,22 +99,6 @@ private:
     glm::vec3 maDirection;
 };
 
-namespace temporary {
-
-class TemporaryContext: public opengl3D::Renderable3DObject
-{
-public:
-    TemporaryContext(OpenGL3DRenderer* pRenderer);
-
-    void init();
-    virtual void render() SAL_OVERRIDE;
-
-private:
-    OpenGLContext maContext;
-};
-
-}
-
 }
 
 }
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 19770c0..86f9c63 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -111,34 +111,6 @@ void Camera::render()
     mpRenderer->SetCameraInfo(maPos, maDirection, maUp, true);
 }
 
-void Camera::zoom(sal_uInt32 /*nId*/)
-{
-    // TODO here
-}
-
-namespace temporary {
-
-TemporaryContext::TemporaryContext(OpenGL3DRenderer* pRenderer):
-    Renderable3DObject(pRenderer, -1)
-{
-}
-
-void TemporaryContext::render()
-{
-    maContext.renderToFile();
-}
-
-void TemporaryContext::init()
-{
-    maContext.init();
-    Size winSize(800, 600);
-    maContext.setWinSize(winSize);
-    mpRenderer->SetSize(winSize);
-    mpRenderer->init();
-}
-
-}
-
 }
 
 }
commit a7eba60df0a8ce190015a54f8fa919c1bb377a7e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 05:10:12 2014 +0200

    the rendering is working on-screen
    
    I can't believe that I finally see something on the screen.
    
    Change-Id: Ic374c8a0d0fa5050b0701a5553136759c9c7602c

diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index fc0741d..6ea16fd 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -70,6 +70,7 @@
 #include <boost/scoped_ptr.hpp>
 
 class SvNumberFormatter;
+class OpenGLWindow;
 
 namespace chart
 {
@@ -595,10 +596,13 @@ public:
     void getNextTimePoint();
     void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd);
 
+    OpenGLWindow* getOpenGLWindow();
+
 private:
     sal_Int32 mnStart;
     sal_Int32 mnEnd;
     bool bSet;
+    OpenGLWindow* mpOpenGLWindow;
 };
 
 }  // namespace chart
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index cf52cac..f876a88 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -108,6 +108,7 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
     , mnStart(0)
     , mnEnd(0)
     ,bSet(false)
+    , mpOpenGLWindow(NULL)
 {
     OSL_TRACE( "ChartModel: CTOR called" );
 
@@ -153,6 +154,7 @@ ChartModel::ChartModel( const ChartModel & rOther )
     , mnStart(rOther.mnStart)
     , mnEnd(rOther.mnEnd)
     , bSet(false)
+    , mpOpenGLWindow(NULL)
 {
     OSL_TRACE( "ChartModel: Copy-CTOR called" );
 
@@ -1415,6 +1417,12 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
     void* pPtr = (void*)nWindowPtr;
     OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr);
     assert(pWindow);
+    mpOpenGLWindow = pWindow;
+}
+
+OpenGLWindow* ChartModel::getOpenGLWindow()
+{
+    return mpOpenGLWindow;
 }
 
 }  // namespace chart
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index b29d193..f19ab64 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -19,10 +19,11 @@
 
 namespace chart {
 
-GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries):
+GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries,
+        OpenGLContext& rContext):
     maDataSeries(rDataSeries),
     mpRenderer(new opengl3D::OpenGL3DRenderer()),
-    mxContext(new opengl3D::temporary::TemporaryContext(mpRenderer.get()))
+    mrContext(rContext)
 {
 }
 
@@ -65,13 +66,13 @@ void GL3DBarChart::create3DShapes()
 
 void GL3DBarChart::render()
 {
-    mxContext->init();
+    mrContext.makeCurrent();
     for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
             itrEnd = maShapes.end(); itr != itrEnd; ++itr)
     {
         itr->render();
     }
-    mxContext->render();
+    mrContext.swapBuffers();
 }
 
 }
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index da3d1e1..6efc86c 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -32,7 +32,7 @@ class TemporaryContext;
 class GL3DBarChart
 {
 public:
-    GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries);
+    GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries, OpenGLContext& rContext);
     ~GL3DBarChart();
 
     void create3DShapes();
@@ -45,7 +45,7 @@ private:
     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
 
     boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
-    boost::scoped_ptr<opengl3D::temporary::TemporaryContext> mxContext;
+    OpenGLContext& mrContext;
 };
 
 }
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 88c3103..98c9b91 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -65,6 +65,8 @@
 #include <vcl/svapp.hxx>
 #include <osl/mutex.hxx>
 #include <svx/unofill.hxx>
+#include <vcl/openglwin.hxx>
+#include <vcl/opengl/OpenGLContext.hxx>
 
 #include <drawinglayer/XShapeDumper.hxx>
 
@@ -3143,7 +3145,11 @@ void ChartView::createShapes3D()
         }
     }
 
-    GL3DBarChart aBarChart(aDataSeries);
+    OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
+    if(!pWindow)
+        return;
+
+    GL3DBarChart aBarChart(aDataSeries, *pWindow->getContext());
     aBarChart.create3DShapes();
     aBarChart.render();
 }
commit af578839ca4bfd3dfc09203994189254a60e5ea9
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 04:20:02 2014 +0200

    let us use the new OpenGLWindow
    
    Change-Id: I5cbab0aa1707513b62f7a9958fac013b3beb2dcb

diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index a16f435..cf52cac 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -33,7 +33,7 @@
 #include "UndoManager.hxx"
 #include "ChartView.hxx"
 
-#include <vcl/window.hxx>
+#include <vcl/openglwin.hxx>
 
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 
@@ -1413,7 +1413,7 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
     throw (uno::RuntimeException, std::exception)
 {
     void* pPtr = (void*)nWindowPtr;
-    Window* pWindow = reinterpret_cast<Window*>(pPtr);
+    OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr);
     assert(pWindow);
 }
 
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index eb4ace5..e8ab3b4 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -88,6 +88,7 @@ $(eval $(call gb_Library_use_libraries,sc,\
     $(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
         vbahelper) \
     vcl \
+	vclopengl \
     xo \
     $(gb_UWINAPI) \
 ))
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index dde5089..873588d 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -32,7 +32,7 @@
 #include <tools/urlobj.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/syschild.hxx>
-#include <vcl/sysdata.hxx>
+#include <vcl/openglwin.hxx>
 #include <svl/urihelper.hxx>
 #include <unotools/moduleoptions.hxx>
 #include <svtools/insdlg.hxx>
@@ -544,7 +544,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
         ScDocument* pScDoc   = pScDocSh->GetDocument();
         bool bUndo (pScDoc->IsUndoEnabled());
 
-        SystemChildWindow* pChildWindow = new SystemChildWindow(pData->GetActiveWin(), 0);
+        OpenGLWindow* pChildWindow = new OpenGLWindow(pData->GetActiveWin());
         Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
         pChildWindow->SetSizePixel(aWindowSize);
         Wallpaper aBackground = pChildWindow->GetBackground();
commit 67c134d4e26fca9317157f634bed1fff6a3093e4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 04:16:54 2014 +0200

    avoid linking against the OpenGL libs when only using the window
    
    This lets us avoid to link libsclo against all the OpenGL libraries and
    only link against libvcl_opengl. Only code actually using the context
    will need to link against the OpenGL libs.
    
    Change-Id: Ia47f4c651702a7fb8517073cda6fb113e7e26e50

diff --git a/include/vcl/openglwin.hxx b/include/vcl/openglwin.hxx
index 5c57d45..9c4e611 100644
--- a/include/vcl/openglwin.hxx
+++ b/include/vcl/openglwin.hxx
@@ -11,16 +11,23 @@
 #define INCLUDED_VCL_OPENGLWIN_HXX
 
 #include <vcl/syschild.hxx>
-#include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/vclopengl_dllapi.hxx>
 
-class OpenGLWindow : public SystemChildWindow
+#include <boost/scoped_ptr.hpp>
+
+class OpenGLContext;
+class OpenGLWindowImpl;
+
+// pImpl Pattern to avoid linking against OpenGL libs when using the class without the context
+class VCLOPENGL_DLLPUBLIC OpenGLWindow : public SystemChildWindow
 {
 public:
     OpenGLWindow(Window* pParent);
-    OpenGLContext& getContext();
+    ~OpenGLWindow();
+    OpenGLContext* getContext();
 
 private:
-    OpenGLContext maContext;
+    boost::scoped_ptr<OpenGLWindowImpl> mpImpl;
 };
 
 #endif
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 29a21a2..3065718 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -8,15 +8,40 @@
  */
 
 #include <vcl/openglwin.hxx>
+#include <vcl/opengl/OpenGLContext.hxx>
+
+class OpenGLWindowImpl
+{
+public:
+    OpenGLWindowImpl(SystemChildWindow* pWindow);
+    OpenGLContext* getContext();
+private:
+    OpenGLContext maContext;
+};
+
+OpenGLWindowImpl::OpenGLWindowImpl(SystemChildWindow* pWindow)
+{
+    maContext.init(pWindow);
+}
+
+OpenGLContext* OpenGLWindowImpl::getContext()
+{
+    return &maContext;
+}
 
 OpenGLWindow::OpenGLWindow(Window* pParent):
-    SystemChildWindow(pParent, 0)
+    SystemChildWindow(pParent, 0),
+    mpImpl(new OpenGLWindowImpl(this))
+{
+}
+
+OpenGLWindow::~OpenGLWindow()
 {
 }
 
-OpenGLContext& OpenGLWindow::getContext()
+OpenGLContext* OpenGLWindow::getContext()
 {
-    return maContext;
+    return mpImpl->getContext();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a8e66dd657dff28ef7ae9cfbe15ea43e4c08aefd
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 7 03:45:41 2014 +0200

    add new window that contains OpenGL context
    
    Change-Id: I81ce3581942d03785809d728b6b54b570899bcdc

diff --git a/include/vcl/openglwin.hxx b/include/vcl/openglwin.hxx
new file mode 100644
index 0000000..5c57d45
--- /dev/null
+++ b/include/vcl/openglwin.hxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_OPENGLWIN_HXX
+#define INCLUDED_VCL_OPENGLWIN_HXX
+
+#include <vcl/syschild.hxx>
+#include <vcl/opengl/OpenGLContext.hxx>
+
+class OpenGLWindow : public SystemChildWindow
+{
+public:
+    OpenGLWindow(Window* pParent);
+    OpenGLContext& getContext();
+
+private:
+    OpenGLContext maContext;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vclopengl.mk b/vcl/Library_vclopengl.mk
index 84310bb8..11b46e5 100644
--- a/vcl/Library_vclopengl.mk
+++ b/vcl/Library_vclopengl.mk
@@ -40,6 +40,7 @@ $(eval $(call gb_Library_use_libraries,vclopengl,\
 $(eval $(call gb_Library_add_exception_objects,vclopengl,\
     vcl/source/opengl/OpenGLContext \
     vcl/source/opengl/OpenGLHelper \
+    vcl/source/window/openglwin \
 ))
 
 ifeq ($(strip $(OS)),WNT)
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
new file mode 100644
index 0000000..29a21a2
--- /dev/null
+++ b/vcl/source/window/openglwin.cxx
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vcl/openglwin.hxx>
+
+OpenGLWindow::OpenGLWindow(Window* pParent):
+    SystemChildWindow(pParent, 0)
+{
+}
+
+OpenGLContext& OpenGLWindow::getContext()
+{
+    return maContext;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 036b6c9ef43ab98d481f666cfe83896e8437daa2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 06:35:32 2014 +0200

    fix the OpenGL offscreen rendering a bit
    
    Change-Id: I1f11cdff0de48e3281a58aec9ea37a78c637195e

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 4e3b96c..b29d193 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -36,7 +36,6 @@ void GL3DBarChart::create3DShapes()
     const float nBarSizeY = 10;
     const float nBarDistanceX = nBarSizeX / 2;
     const float nBarDistanceY = nBarSizeY / 2;
-    opengl3D::OpenGL3DRenderer* pRenderer = NULL;
 
     maShapes.clear();
     maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
commit a28bcb6e57aef0a05e04195c9bdc52a4bc39bba1
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 06:16:56 2014 +0200

    provide the OpenGL window
    
    This approach looks much better. We get size and position correct
    without much work and can easily plug the window into the sc window
    hierarchy.
    
    We still have a crash on exit as the ScGridWindow goes out of scope and
    the SystemChildWindow is still alive. We need to fix it and bind the
    lifecycle of the SystemChildWindow to ScGridWindow.
    
    Another open item is the OpenGL context work. Right now it looks like
    the best way forward is to create a subclass of SystemChildWindow that
    contains the OpenGLContext.
    
    Change-Id: Ie0a74531e1b818cea92912345464c8fa219bbae2

diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index 38735d9..fc0741d 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -50,15 +50,16 @@
 
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XTitled.hpp>
+#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
 
 #include <com/sun/star/frame/XLoadable.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/datatransfer/XTransferable.hpp>
 
-#ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22
-#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22
-#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22
+#ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_23
+#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_23
+#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 23
 #include "comphelper/implbase_var.hxx"
 #endif
 #include <osl/mutex.hxx>
@@ -77,7 +78,7 @@ namespace impl
 {
 
 // Note: needed for queryInterface (if it calls the base-class implementation)
-typedef ::comphelper::WeakImplHelper22<
+typedef ::comphelper::WeakImplHelper23<
 //       ::com::sun::star::frame::XModel        //comprehends XComponent (required interface), base of XChartDocument
          ::com::sun::star::util::XCloseable     //comprehends XCloseBroadcaster
         ,::com::sun::star::frame::XStorable2    //(extension of XStorable)
@@ -100,6 +101,7 @@ typedef ::comphelper::WeakImplHelper22<
         ,::com::sun::star::document::XDocumentPropertiesSupplier
         ,::com::sun::star::chart2::data::XDataSource
         ,::com::sun::star::document::XUndoManagerSupplier
+        ,::com::sun::star::chart2::X3DChartWindowProvider
         ,::com::sun::star::qa::XDumper
         >
     ChartModel_Base;
@@ -573,6 +575,10 @@ public:
     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences()
         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
+    // X3DChartWindowProvider
+    virtual void SAL_CALL setWindow( const sal_uInt64 nWindowPtr )
+        throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
     // XDumper
     virtual OUString SAL_CALL dump()
         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index e386d7f..a16f435 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -33,6 +33,8 @@
 #include "UndoManager.hxx"
 #include "ChartView.hxx"
 
+#include <vcl/window.hxx>
+
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 
 #include <comphelper/InlineContainer.hxx>
@@ -1407,6 +1409,14 @@ uno::Reference< uno::XInterface > ChartModel::getChartView()
     return xChartView;
 }
 
+void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
+    throw (uno::RuntimeException, std::exception)
+{
+    void* pPtr = (void*)nWindowPtr;
+    Window* pWindow = reinterpret_cast<Window*>(pPtr);
+    assert(pWindow);
+}
+
 }  // namespace chart
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 8074e8b..3ce5e06 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2005,6 +2005,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2,\
 	SymbolStyle \
 	TickmarkStyle \
 	TransparencyStyle \
+	X3DChartWindowProvider \
 	XAnyDescriptionAccess \
 	XAxis \
 	XChartDocument \
diff --git a/offapi/com/sun/star/chart2/X3DChartWindowProvider.idl b/offapi/com/sun/star/chart2/X3DChartWindowProvider.idl
new file mode 100644
index 0000000..ff67fc3
--- /dev/null
+++ b/offapi/com/sun/star/chart2/X3DChartWindowProvider.idl
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_chart2_X3DChartWindowProvider_idl__
+#define __com_sun_star_chart2_X3DChartWindowProvider_idl__
+
+module com {  module sun {  module star {  module chart2 {
+
+interface X3DChartWindowProvider
+{
+    void setWindow( [in] unsigned hyper window );
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 183740d..dde5089 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -31,6 +31,8 @@
 #include <svx/pfiledlg.hxx>
 #include <tools/urlobj.hxx>
 #include <vcl/msgbox.hxx>
+#include <vcl/syschild.hxx>
+#include <vcl/sysdata.hxx>
 #include <svl/urihelper.hxx>
 #include <unotools/moduleoptions.hxx>
 #include <svtools/insdlg.hxx>
@@ -53,6 +55,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/chart2/data/XDataProvider.hpp>
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -541,6 +544,17 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
         ScDocument* pScDoc   = pScDocSh->GetDocument();
         bool bUndo (pScDoc->IsUndoEnabled());
 
+        SystemChildWindow* pChildWindow = new SystemChildWindow(pData->GetActiveWin(), 0);
+        Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
+        pChildWindow->SetSizePixel(aWindowSize);
+        Wallpaper aBackground = pChildWindow->GetBackground();
+        aBackground.SetColor(COL_RED);
+        pChildWindow->SetBackground(aBackground);
+        pChildWindow->Show();
+        uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( xChartModel, uno::UNO_QUERY_THROW );
+        sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(pChildWindow);
+        x3DWindowProvider->setWindow(nWindowPtr);
+
         if( pReqArgs )
         {
             const SfxPoolItem* pItem;
@@ -615,6 +629,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
             // get chart position (from window size and data range)
             aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
         }
+        pChildWindow->SetPosPixel(pChildWindow->LogicToPixel(aStart, MapMode(MAP_100TH_MM)));
 
         Rectangle aRect (aStart, aSize);
         SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
@@ -709,6 +724,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
                         sal_Int16 nDialogRet = xDialog->execute();
                         if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
                         {
+                            delete pWindow;
                             // leave OLE inplace mode and unmark
                             OSL_ASSERT( pViewShell );
                             OSL_ASSERT( pView );
commit 42a47cd66eb6d277e5560efa341efa423f9e8fff
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 02:05:29 2014 +0200

    remove global variable
    
    Change-Id: Ie5f55feb39798dff27e0c6b41d5b88b6e9bf19bc

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index b29d193..4e3b96c 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -36,6 +36,7 @@ void GL3DBarChart::create3DShapes()
     const float nBarSizeY = 10;
     const float nBarDistanceX = nBarSizeX / 2;
     const float nBarDistanceY = nBarSizeY / 2;
+    opengl3D::OpenGL3DRenderer* pRenderer = NULL;
 
     maShapes.clear();
     maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));


More information about the Libreoffice-commits mailing list