From 9090dc1f3b27195f5defd35586ac79357992be21 Mon Sep 17 00:00:00 2001
From: Noel Grandin <noelgrandin@gmail.com>
Date: Mon, 18 Jan 2021 18:27:19 +0200
Subject: split OutputDevice from Window

as part of a longer-term goal of doing our
widget rendering only inside a top-level render-
context.

I moved all of the OutputDevice-related code that existed in vcl::Window
into a new subclass of OutputDevice called WindowOutputDevice.

Notes for further work

(*) not sure why we are getting an 1x1 surface in
    SvpSalGraphics::releaseCairoContext, but to fix it I clamp
    the size there

(*) might have to dump VCLXDevice, and move it's code down into VCLXWindow and VCLXVirtualDevice

(*) can we remove use of VCLXDevice in other places, in favour of just talking to the VCL code?

Change-Id: I105946377f5322677d6f7d0c1c23847178a720b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113204
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
---
 basctl/source/basicide/baside2b.cxx |  8 ++++----
 basctl/source/basicide/baside3.cxx  |  2 +-
 basctl/source/basicide/layout.cxx   |  4 ++--
 basctl/source/dlged/dlged.cxx       |  4 ++--
 basctl/source/dlged/dlgedfunc.cxx   | 18 +++++++++---------
 basctl/source/dlged/dlgedobj.cxx    |  2 +-
 basctl/source/dlged/dlgedview.cxx   |  2 +-
 7 files changed, 20 insertions(+), 20 deletions(-)

(limited to 'basctl')

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 5a1bae42fd93..7d06e117d072 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1239,13 +1239,13 @@ void EditorWindow::ImplSetFont()
     {
         vcl::Font aTmpFont(OutputDevice::GetDefaultFont(DefaultFontType::FIXED,
                                                         Application::GetSettings().GetUILanguageTag().getLanguageType(),
-                                                        GetDefaultFontFlags::NONE, this));
+                                                        GetDefaultFontFlags::NONE, GetOutDev()));
         sFontName = aTmpFont.GetFamilyName();
     }
     Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
     vcl::Font aFont(sFontName, aFontSize);
     aFont.SetColor(rModulWindow.GetLayout().GetFontColor());
-    SetPointFont(*this, aFont); // FIXME RenderContext
+    SetPointFont(*GetOutDev(), aFont); // FIXME RenderContext
     aFont = GetFont();
 
     rModulWindow.GetBreakPointWindow().SetFont(aFont);
@@ -1330,7 +1330,7 @@ void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted )
         rModulWindow.GetBreakPoints().AdjustBreakPoints( static_cast<sal_uInt16>(nPara)+1, bInserted );
 
         tools::Long nLineHeight = GetTextHeight();
-        Size aSz = rModulWindow.GetBreakPointWindow().GetOutputSize();
+        Size aSz = rModulWindow.GetBreakPointWindow().GetOutDev()->GetOutputSize();
         tools::Rectangle aInvRect( Point( 0, 0 ), aSz );
         tools::Long nY = nPara*nLineHeight - rModulWindow.GetBreakPointWindow().GetCurYOffset();
         aInvRect.SetTop( nY );
@@ -1417,7 +1417,7 @@ void BreakPointWindow::ShowMarker(vcl::RenderContext& rRenderContext)
     if (nMarkerPos == NoMarker)
         return;
 
-    Size const aOutSz = GetOutputSize();
+    Size const aOutSz = GetOutDev()->GetOutputSize();
     tools::Long const nLineHeight = GetTextHeight();
 
     Image aMarker = GetImage(OUString(bErrorMarker ? std::u16string_view(u"" RID_BMP_ERRORMARKER) : std::u16string_view(u"" RID_BMP_STEPMARKER)));
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 69fc19b74329..b2ed314ebf25 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -1232,7 +1232,7 @@ void DialogWindow::InitSettings()
     // FIXME RenderContext
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     vcl::Font aFont = rStyleSettings.GetFieldFont();
-    SetPointFont(*this, aFont);
+    SetPointFont(*GetOutDev(), aFont);
 
     SetTextColor( rStyleSettings.GetFieldTextColor() );
     SetTextFillColor();
diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
index 8ec80e8e20a4..e6b6676ed6c6 100644
--- a/basctl/source/basicide/layout.cxx
+++ b/basctl/source/basicide/layout.cxx
@@ -420,8 +420,8 @@ void Layout::SplittedSide::InitSplitter (Splitter& rSplitter)
     rSplitter.SetSplitHdl(LINK(this, SplittedSide, SplitHdl));
     // color
     Color aColor = rLayout.GetSettings().GetStyleSettings().GetShadowColor();
-    rSplitter.SetLineColor(aColor);
-    rSplitter.SetFillColor(aColor);
+    rSplitter.GetOutDev()->SetLineColor(aColor);
+    rSplitter.GetOutDev()->SetFillColor(aColor);
 }
 
 
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 2d5154a6f8e0..34467260c140 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -198,7 +198,7 @@ DlgEditor::DlgEditor (
     ,m_xDocument( xModel )
 {
     pDlgEdModel->GetItemPool().FreezeIdRanges();
-    pDlgEdView.reset(new DlgEdView(*pDlgEdModel, rWindow_, *this));
+    pDlgEdView.reset(new DlgEdView(*pDlgEdModel, *rWindow_.GetOutDev(), *this));
     pDlgEdModel->SetScaleUnit( MapUnit::Map100thMM );
 
     SdrLayerAdmin& rAdmin = pDlgEdModel->GetLayerAdmin();
@@ -274,7 +274,7 @@ void DlgEditor::InitScrollBars()
     if ( !pHScroll || !pVScroll )
         return;
 
-    Size aOutSize = rWindow.GetOutputSize();
+    Size aOutSize = rWindow.GetOutDev()->GetOutputSize();
     Size aPgSize  = pDlgEdPage->GetSize();
 
     pHScroll->SetRange( Range( 0, aPgSize.Width()  ));
diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
index b16cf695a26a..593f0370f635 100644
--- a/basctl/source/dlged/dlgedfunc.cxx
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -342,7 +342,7 @@ void DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
 
     SdrView& rView  = rParent.GetView();
     vcl::Window& rWindow = rParent.GetWindow();
-    rView.SetActualWin(&rWindow);
+    rView.SetActualWin(rWindow.GetOutDev());
 
     Point aPos = rWindow.PixelToLogic( rMEvt.GetPosPixel() );
     sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width());
@@ -378,7 +378,7 @@ bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
 
     SdrView& rView  = rParent.GetView();
     vcl::Window& rWindow = rParent.GetWindow();
-    rView.SetActualWin(&rWindow);
+    rView.SetActualWin(rWindow.GetOutDev());
 
     rWindow.ReleaseMouse();
 
@@ -408,7 +408,7 @@ void DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
 {
     SdrView& rView  = rParent.GetView();
     vcl::Window& rWindow = rParent.GetWindow();
-    rView.SetActualWin(&rWindow);
+    rView.SetActualWin(rWindow.GetOutDev());
 
     Point aPos = rWindow.PixelToLogic(rMEvt.GetPosPixel());
     sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width());
@@ -419,7 +419,7 @@ void DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
         rView.MovAction(aPos);
     }
 
-    rWindow.SetPointer( rView.GetPreferredPointer( aPos, &rWindow, nHitLog ) );
+    rWindow.SetPointer( rView.GetPreferredPointer( aPos, rWindow.GetOutDev(), nHitLog ) );
 }
 
 DlgEdFuncSelect::DlgEdFuncSelect (DlgEditor& rParent_) :
@@ -436,7 +436,7 @@ void DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
     // get view from parent
     SdrView& rView  = rParent.GetView();
     vcl::Window& rWindow = rParent.GetWindow();
-    rView.SetActualWin(&rWindow);
+    rView.SetActualWin(rWindow.GetOutDev());
 
     sal_uInt16 nDrgLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width());
     sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width());
@@ -497,7 +497,7 @@ bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
     // get view from parent
     SdrView& rView  = rParent.GetView();
     vcl::Window& rWindow = rParent.GetWindow();
-    rView.SetActualWin(&rWindow);
+    rView.SetActualWin(rWindow.GetOutDev());
 
     Point aPnt = rWindow.PixelToLogic(rMEvt.GetPosPixel());
     sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width());
@@ -516,7 +516,7 @@ bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
         }
     }
 
-    rWindow.SetPointer( rView.GetPreferredPointer( aPnt, &rWindow, nHitLog ) );
+    rWindow.SetPointer( rView.GetPreferredPointer( aPnt, rWindow.GetOutDev(), nHitLog ) );
     rWindow.ReleaseMouse();
 
     return true;
@@ -526,7 +526,7 @@ void DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
 {
     SdrView& rView  = rParent.GetView();
     vcl::Window& rWindow = rParent.GetWindow();
-    rView.SetActualWin(&rWindow);
+    rView.SetActualWin(rWindow.GetOutDev());
 
     Point aPnt = rWindow.PixelToLogic(rMEvt.GetPosPixel());
     sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width());
@@ -540,7 +540,7 @@ void DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
         rView.MovAction(aPnt_);
     }
 
-    rWindow.SetPointer( rView.GetPreferredPointer( aPnt, &rWindow, nHitLog ) );
+    rWindow.SetPointer( rView.GetPreferredPointer( aPnt, rWindow.GetOutDev(), nHitLog ) );
 }
 
 } // namespace basctl
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index e4047abace14..6353ddf9ecd6 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -152,7 +152,7 @@ uno::Reference< awt::XControl > DlgEdObj::GetControl() const
     if (DlgEdForm const* pForm = GetDlgEdForm())
     {
         DlgEditor const& rEditor = pForm->GetDlgEditor();
-        xControl = GetUnoControl(rEditor.GetView(), rEditor.GetWindow());
+        xControl = GetUnoControl(rEditor.GetView(), *rEditor.GetWindow().GetOutDev());
     }
     return xControl;
 }
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
index f9371b10bac3..0878596d8f41 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -58,7 +58,7 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin )
     // visible area
     MapMode aMap( rWin.GetMapMode() );
     Point aOrg( aMap.GetOrigin() );
-    Size aVisSize( rWin.GetOutputSize() );
+    Size aVisSize( rWin.GetOutDev()->GetOutputSize() );
     tools::Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
     tools::Rectangle aVisRect( RectTmp );
 
-- 
cgit