diff options
Diffstat (limited to 'chart2/source/controller/main/ChartWindow.cxx')
-rw-r--r-- | chart2/source/controller/main/ChartWindow.cxx | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx index 21cc0cefc2ab..d50a741cd001 100644 --- a/chart2/source/controller/main/ChartWindow.cxx +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -28,6 +28,13 @@ #include <config_features.h> #include <com/sun/star/chart2/X3DChartWindowProvider.hpp> +#include <sfx2/ipclient.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/lokhelper.hxx> +#include <comphelper/lok.hxx> + +#define TWIPS_PER_PIXEL 15 + using namespace ::com::sun::star; namespace @@ -50,6 +57,7 @@ ChartWindow::ChartWindow( ChartController* pController, vcl::Window* pParent, Wi : Window(pParent, nStyle) , m_pWindowController( pController ) , m_bInPaint(false) + , m_pViewShellWindow( nullptr ) #if HAVE_FEATURE_OPENGL , m_pOpenGLWindow(VclPtr<OpenGLWindow>::Create(this, false)) #else @@ -94,6 +102,7 @@ void ChartWindow::dispose() xUpdatable->update(); } m_pOpenGLWindow.disposeAndClear(); + m_pViewShellWindow.clear(); vcl::Window::dispose(); } @@ -114,6 +123,10 @@ void ChartWindow::PrePaint(vcl::RenderContext& rRenderContext) void ChartWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) { + if (comphelper::LibreOfficeKit::isActive() + && rRenderContext.GetOutDevType() != OutDevType::OUTDEV_VIRDEV) + return; + m_bInPaint = true; if (m_pOpenGLWindow && m_pOpenGLWindow->IsVisible()) { @@ -307,6 +320,56 @@ void ChartWindow::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags } } +void ChartWindow::LogicInvalidate(const Rectangle* pRectangle) +{ + OString sRectangle; + if (!pRectangle) + { + // we have to invalidate the whole chart area not the whole document + sRectangle = GetBoundingBox().toString(); + } + else + { + Rectangle aRectangle(*pRectangle); + // When dragging shapes the map mode is disabled. + if (IsMapModeEnabled()) + { + if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + aRectangle = OutputDevice::LogicToLogic(aRectangle, MapUnit::Map100thMM, MapUnit::MapTwip); + } + else + { + aRectangle = PixelToLogic(aRectangle, MapMode(MapUnit::MapTwip)); + } + + vcl::Window* pEditWin = GetParentEditWin(); + if (pEditWin) + { + MapMode aCWMapMode = GetMapMode(); + double fXScale = aCWMapMode.GetScaleX(); + double fYScale = aCWMapMode.GetScaleY(); + + if (!IsMapModeEnabled()) + { + aRectangle.Left() /= fXScale; + aRectangle.Right() /= fXScale; + aRectangle.Top() /= fYScale; + aRectangle.Bottom() /= fYScale; + } + + Point aOffset = this->GetOffsetPixelFrom(*pEditWin); + aOffset.X() *= (TWIPS_PER_PIXEL / fXScale); + aOffset.Y() *= (TWIPS_PER_PIXEL / fYScale); + + aRectangle = Rectangle(aRectangle.TopLeft() + aOffset, aRectangle.GetSize()); + } + + sRectangle = aRectangle.toString(); + } + SfxViewShell* pCurrentShell = SfxViewShell::Current(); + SfxLokHelper::notifyInvalidation(pCurrentShell, sRectangle); +} + FactoryFunction ChartWindow::GetUITestFactory() const { return ChartWindowUIObject::create; @@ -317,6 +380,53 @@ ChartController* ChartWindow::GetController() return m_pWindowController; } +vcl::Window* ChartWindow::GetParentEditWin() +{ + if (m_pViewShellWindow) + return m_pViewShellWindow.get(); + + // So, you are thinking, why do not invoke pCurrentShell->GetWindow() ? + // Because in Impress the parent edit win is not view shell window. + SfxViewShell* pCurrentShell = SfxViewShell::Current(); + if( pCurrentShell ) + { + SfxInPlaceClient* pIPClient = pCurrentShell->GetIPClient(); + if (pIPClient) + { + vcl::Window* pRootWin = pIPClient->GetEditWin(); + if(pRootWin && pRootWin->IsAncestorOf(*this)) + { + m_pViewShellWindow = pRootWin; + return m_pViewShellWindow.get(); + } + } + } + return nullptr; +} + +Rectangle ChartWindow::GetBoundingBox() +{ + Rectangle aBBox; + + vcl::Window* pRootWin = GetParentEditWin(); + if (pRootWin) + { + // In all cases, the following code fragment + // returns the chart bounding box in twips. + MapMode aCWMapMode = GetMapMode(); + double fXScale = aCWMapMode.GetScaleX(); + double fYScale = aCWMapMode.GetScaleY(); + Point aOffset = GetOffsetPixelFrom(*pRootWin); + aOffset.X() *= (TWIPS_PER_PIXEL / fXScale); + aOffset.Y() *= (TWIPS_PER_PIXEL / fYScale); + Size aSize = GetSizePixel(); + aSize.Width() *= (TWIPS_PER_PIXEL / fXScale); + aSize.Height() *= (TWIPS_PER_PIXEL / fYScale); + aBBox = Rectangle(aOffset, aSize); + } + return aBBox; +} + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |