diff options
-rw-r--r-- | chart2/Library_chartcontroller.mk | 1 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 3 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartWindow.cxx | 33 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartWindow.hxx | 9 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 1 | ||||
-rw-r--r-- | chart2/source/view/charttypes/GL3DBarChart.cxx | 82 | ||||
-rw-r--r-- | chart2/source/view/inc/GL3DBarChart.hxx | 6 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fuins2.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin5.cxx | 13 |
11 files changed, 79 insertions, 96 deletions
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index 96579986ffc4..b7e86bfc353e 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -43,7 +43,6 @@ $(eval $(call gb_Library_use_libraries,chartcontroller,\ ucbhelper \ utl \ vcl \ - vclopengl \ $(gb_UWINAPI) \ )) diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index d5eca79114b9..b57045d09bfe 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -726,9 +726,6 @@ void SAL_CALL ChartController::dispose() //--release all resources and references { - uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(getModel(), uno::UNO_QUERY_THROW); - x3DWindowProvider->setWindow(0); - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); if( xViewBroadcaster.is() ) xViewBroadcaster->removeModeChangeListener(this); diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx index 37335c4b87a2..917d69e8ae74 100644 --- a/chart2/source/controller/main/ChartWindow.cxx +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -22,11 +22,8 @@ #include "HelpIds.hrc" #include <vcl/help.hxx> -#include <vcl/openglwin.hxx> #include <vcl/settings.hxx> -#include <com/sun/star/chart2/X3DChartWindowProvider.hpp> - using namespace ::com::sun::star; namespace @@ -45,11 +42,10 @@ namespace namespace chart { -ChartWindow::ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle ) +ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ) : Window(pParent, nStyle) - , m_pWindowController( pController ) + , m_pWindowController( pWindowController ) , m_bInPaint(false) - , m_pOpenGLWindow(new OpenGLWindow(this)) { this->SetHelpId( HID_SCH_WIN_DOCUMENT ); this->SetMapMode( MapMode(MAP_100TH_MM) ); @@ -59,21 +55,10 @@ ChartWindow::ChartWindow( ChartController* pController, Window* pParent, WinBits EnableRTL( false ); if( pParent ) pParent->EnableRTL( false );// #i96215# necessary for a correct position of the context menu in rtl mode - - m_pOpenGLWindow->Show(); - uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(pController->getModel(), uno::UNO_QUERY_THROW); - sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(m_pOpenGLWindow); - x3DWindowProvider->setWindow(nWindowPtr); } ChartWindow::~ChartWindow() { - if (m_pWindowController && m_pWindowController->getModel().is()) - { - uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(m_pWindowController->getModel(), uno::UNO_QUERY_THROW); - x3DWindowProvider->setWindow(0); - } - delete m_pOpenGLWindow; } void ChartWindow::clear() @@ -94,18 +79,10 @@ void ChartWindow::PrePaint() void ChartWindow::Paint( const Rectangle& rRect ) { m_bInPaint = true; - if (m_pOpenGLWindow && m_pOpenGLWindow->IsVisible()) - { - m_pOpenGLWindow->Paint(rRect); - } - else if (m_pWindowController) - { - m_pWindowController->execute_Paint(rRect); - } + if( m_pWindowController ) + m_pWindowController->execute_Paint( rRect ); else - { Window::Paint( rRect ); - } m_bInPaint = false; } @@ -147,8 +124,6 @@ void ChartWindow::Resize() m_pWindowController->execute_Resize(); else Window::Resize(); - - m_pOpenGLWindow->SetSizePixel(GetSizePixel()); } void ChartWindow::Activate() diff --git a/chart2/source/controller/main/ChartWindow.hxx b/chart2/source/controller/main/ChartWindow.hxx index ee5884f013e5..ec5c05bde7c5 100644 --- a/chart2/source/controller/main/ChartWindow.hxx +++ b/chart2/source/controller/main/ChartWindow.hxx @@ -21,12 +21,10 @@ #include <vcl/window.hxx> -class OpenGLWindow; - namespace chart { -class ChartController; +class WindowController; /** The ChartWindow collects events from the window and forwards them the to the controller thus the controller can perform appropriate actions @@ -35,7 +33,7 @@ thus the controller can perform appropriate actions class ChartWindow : public Window { public: - ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle ); + ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ); virtual ~ChartWindow(); void clear(); @@ -65,9 +63,8 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; private: - ChartController* m_pWindowController; + WindowController* m_pWindowController; bool m_bInPaint; - OpenGLWindow* m_pOpenGLWindow; void adjustHighContrastMode(); }; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 0fb584b1b0d3..2d2a84860145 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -1412,6 +1412,7 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr ) { void* pPtr = (void*)nWindowPtr; OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr); + assert(pWindow); mpOpenGLWindow = pWindow; } diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index 0d12c4f6185f..62e5ec952ffb 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -47,8 +47,8 @@ void RenderThread::renderFrame() if(!mpChart->mbValidContext) return; - mpChart->mpWindow->getContext().makeCurrent(); - Size aSize = mpChart->mpWindow->GetSizePixel(); + mpChart->mrWindow.getContext().makeCurrent(); + Size aSize = mpChart->mrWindow.GetSizePixel(); mpChart->mpRenderer->SetSize(aSize); if(mpChart->mbNeedsNewRender) { @@ -64,7 +64,7 @@ void RenderThread::renderFrame() } mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender); mpChart->mbNeedsNewRender = false; - mpChart->mpWindow->getContext().swapBuffers(); + mpChart->mrWindow.getContext().swapBuffers(); } @@ -127,10 +127,10 @@ void RenderAnimationThread::execute() GL3DBarChart::GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartType, - OpenGLWindow* pWindow) : + OpenGLWindow& rWindow) : mxChartType(xChartType), mpRenderer(new opengl3D::OpenGL3DRenderer()), - mpWindow(pWindow), + mrWindow(rWindow), mpCamera(NULL), mbValidContext(true), mpTextCache(new opengl3D::TextCache()), @@ -142,13 +142,9 @@ GL3DBarChart::GL3DBarChart( mbNeedsNewRender(true), mbCameraInit(false) { - Size aSize; - if (mpWindow) - { - mpWindow->setRenderer(this); - aSize = mpWindow->GetSizePixel(); - } + Size aSize = mrWindow.GetSizePixel(); mpRenderer->SetSize(aSize); + mrWindow.setRenderer(this); mpRenderer->init(); } @@ -166,8 +162,8 @@ GL3DBarChart::~GL3DBarChart() if(mpRenderThread.is()) mpRenderThread->join(); osl::MutexGuard aGuard(maMutex); - if(mbValidContext && mpWindow) - mpWindow->setRenderer(NULL); + if(mbValidContext) + mrWindow.setRenderer(NULL); } namespace { @@ -222,9 +218,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer float nXEnd = 0.0; float nYPos = 0.0; - //const Color aSeriesColor[] = { - // COL_RED, COL_GREEN, COL_YELLOW, COL_BROWN, COL_BLUE - //}; + const Color aSeriesColor[] = { + COL_RED, COL_GREEN, COL_YELLOW, COL_BROWN, COL_BLUE + }; maCategories.clear(); maSeriesNames.clear(); @@ -246,7 +242,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer sal_Int32 nPointCount = rDataSeries.getTotalPointCount(); nMaxPointCount = std::max(nMaxPointCount, nPointCount); - //bool bMappedFillProperty = rDataSeries.hasPropertyMapping("FillColor"); + bool bMappedFillProperty = rDataSeries.hasPropertyMapping("FillColor"); // Create series name text object. OUString aSeriesName = @@ -271,28 +267,28 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer p->setPosition(aTopLeft, aTopRight, aBottomRight); } - //sal_Int32 nColor = aSeriesColor[nSeriesIndex % SAL_N_ELEMENTS(aSeriesColor)].GetColor(); + sal_Int32 nColor = aSeriesColor[nSeriesIndex % SAL_N_ELEMENTS(aSeriesColor)].GetColor(); for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex) { - //if(bMappedFillProperty) - //{ - // double nPropVal = rDataSeries.getValueByProperty(nIndex, "FillColor"); - // if(!rtl::math::isNan(nPropVal)) - // nColor = static_cast<sal_uInt32>(nPropVal); - //} + if(bMappedFillProperty) + { + double nPropVal = rDataSeries.getValueByProperty(nIndex, "FillColor"); + if(!rtl::math::isNan(nPropVal)) + nColor = static_cast<sal_uInt32>(nPropVal); + } float nVal = rDataSeries.getYValue(nIndex); float nXPos = nIndex * (BAR_SIZE_X + BAR_DISTANCE_X) + BAR_DISTANCE_X; - //glm::mat4 aScaleMatrix = glm::scale(glm::vec3(BAR_SIZE_X, BAR_SIZE_Y, float(nVal/nMaxVal))); - //glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(nXPos, nYPos, 0.0f)); - //glm::mat4 aBarPosition = aTranslationMatrix * aScaleMatrix; + glm::mat4 aScaleMatrix = glm::scale(glm::vec3(BAR_SIZE_X, BAR_SIZE_Y, float(nVal/nMaxVal))); + glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(nXPos, nYPos, 0.0f)); + glm::mat4 aBarPosition = aTranslationMatrix * aScaleMatrix; maBarMap.insert(std::pair<sal_uInt32, BarInformation>(nId, BarInformation(glm::vec3(nXPos, nYPos, float(nVal/nMaxVal)), nVal, nIndex, nSeriesIndex))); - //maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId)); + maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId)); nId += ID_STEP; } @@ -407,10 +403,10 @@ void GL3DBarChart::update() { if(mpRenderThread.is()) mpRenderThread->join(); - Size aSize = mpWindow->GetSizePixel(); - mpWindow->getContext().setWinSize(aSize); + Size aSize = mrWindow.GetSizePixel(); + mrWindow.getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderOneFrameThread(this)); - mpWindow->getContext().resetCurrent(); + mrWindow.getContext().resetCurrent(); mpRenderThread->launch(); } @@ -442,10 +438,10 @@ void GL3DBarChart::moveToDefault() if(mpRenderThread.is()) mpRenderThread->join(); - Size aSize = mpWindow->GetSizePixel(); - mpWindow->getContext().setWinSize(aSize); + Size aSize = mrWindow.GetSizePixel(); + mrWindow.getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maDefaultCameraPosition, STEPS)); - mpWindow->getContext().resetCurrent(); + mrWindow.getContext().resetCurrent(); mpRenderThread->launch(); /* @@ -500,10 +496,10 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons) glm::vec3 maTargetPosition = rBarInfo.maPos; maTargetPosition.z += 240; maTargetPosition.y += BAR_SIZE_Y / 2.0f; - Size aSize = mpWindow->GetSizePixel(); - mpWindow->getContext().setWinSize(aSize); + Size aSize = mrWindow.GetSizePixel(); + mrWindow.getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maTargetPosition, STEPS)); - mpWindow->getContext().resetCurrent(); + mrWindow.getContext().resetCurrent(); mpRenderThread->launch(); /* @@ -581,11 +577,11 @@ void GL3DBarChart::moveToCorner() if(mpRenderThread.is()) mpRenderThread->join(); - Size aSize = mpWindow->GetSizePixel(); - mpWindow->getContext().setWinSize(aSize); + Size aSize = mrWindow.GetSizePixel(); + mrWindow.getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, getCornerPosition(mnCornerId), maCameraPosition, STEPS)); - mpWindow->getContext().resetCurrent(); + mrWindow.getContext().resetCurrent(); mpRenderThread->launch(); // TODO: moggi: add to thread @@ -608,12 +604,6 @@ void GL3DBarChart::contextDestroyed() mbValidContext = false; } -void GL3DBarChart::setOpenGLWindow(OpenGLWindow* pWindow) -{ - if (mpWindow != pWindow) - mpWindow = pWindow; -} - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx index 56bac832f060..25176277f068 100644 --- a/chart2/source/view/inc/GL3DBarChart.hxx +++ b/chart2/source/view/inc/GL3DBarChart.hxx @@ -49,7 +49,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer public: GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartType, - OpenGLWindow* pContext); + OpenGLWindow& rContext); virtual ~GL3DBarChart(); @@ -65,8 +65,6 @@ public: virtual void scroll(long nDelta) SAL_OVERRIDE; virtual void contextDestroyed() SAL_OVERRIDE; - void setOpenGLWindow(OpenGLWindow* pWindow); - private: void moveToCorner(); @@ -77,7 +75,7 @@ private: boost::ptr_vector<opengl3D::Renderable3DObject> maShapes; boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer; - OpenGLWindow* mpWindow; + OpenGLWindow& mrWindow; opengl3D::Camera* mpCamera; bool mbValidContext; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 8dc8046c514b..2e8dc257a4bb 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -3250,13 +3250,7 @@ void ChartView::createShapes3D() if (!m_pGL3DPlotter) { - m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, pWindow)); - } - else - { - GL3DBarChart* pChart = dynamic_cast<GL3DBarChart*>(m_pGL3DPlotter.get()); - if (pChart) - pChart->setOpenGLWindow(pWindow); + m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, *pWindow)); } uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index 0a7703d78142..fa9dbfdfd6f5 100644 --- a/sc/source/ui/drawfunc/fuins2.cxx +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -544,6 +544,22 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* ScDocument& rScDoc = pScDocSh->GetDocument(); bool bUndo (rScDoc.IsUndoEnabled()); + Window* pParentWindow = rData.GetActiveWin(); + OpenGLWindow* pChildWindow = new OpenGLWindow(pParentWindow); + Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) ); + pChildWindow->SetSizePixel(aWindowSize); + pChildWindow->Show(); + uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( xChartModel, uno::UNO_QUERY_THROW ); + sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(pChildWindow); + x3DWindowProvider->setWindow(nWindowPtr); + ScGridWindow* pGridWindow = dynamic_cast<ScGridWindow*>(pParentWindow); + if(pGridWindow) + { + pGridWindow->AddChildWindow(pChildWindow); + } + else + SAL_WARN("sc", "not a grid window. You are in serious trouble"); + if( pReqArgs ) { const SfxPoolItem* pItem; @@ -618,6 +634,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); @@ -712,6 +729,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* sal_Int16 nDialogRet = xDialog->execute(); if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) { + pGridWindow->DeleteChildWindow(pChildWindow); // leave OLE inplace mode and unmark OSL_ASSERT( pViewShell ); OSL_ASSERT( pView ); diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 5afa835d75f9..ed066b22becc 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -420,6 +420,7 @@ public: * Takes ownership of the window */ void AddChildWindow(Window* pChildWindow); + void DeleteChildWindow(Window* pChildWindow); protected: // #114409# diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx index 8a3f27104e46..bed697b2db5b 100644 --- a/sc/source/ui/view/gridwin5.cxx +++ b/sc/source/ui/view/gridwin5.cxx @@ -477,4 +477,17 @@ void ScGridWindow::AddChildWindow(Window* pWindow) maChildWindows.push_back(pWindow); } +void ScGridWindow::DeleteChildWindow(Window* pWindow) +{ + for(boost::ptr_vector<Window>::iterator itr = maChildWindows.begin(), + itrEnd = maChildWindows.end(); itr != itrEnd; ++itr) + { + if(&(*itr) == pWindow) + { + maChildWindows.erase(itr); + return; + } + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |