basctl/source/basicide/basdoc.cxx | 2 +- basctl/source/basicide/basdoc.hxx | 2 +- include/sfx2/objsh.hxx | 8 +++++--- sc/source/ui/docshell/docsh4.cxx | 2 +- sc/source/ui/inc/docsh.hxx | 2 +- sd/source/ui/docshell/docshel2.cxx | 2 +- sd/source/ui/inc/DrawDocShell.hxx | 2 +- sfx2/source/doc/objembed.cxx | 12 ++++++------ starmath/inc/document.hxx | 3 ++- starmath/source/document.cxx | 3 ++- sw/inc/docsh.hxx | 2 +- sw/inc/viewsh.hxx | 3 ++- sw/source/core/doc/notxtfrm.cxx | 2 +- sw/source/core/txtnode/fntcache.cxx | 13 ++++++++----- sw/source/core/view/viewimp.cxx | 2 +- sw/source/core/view/vprint.cxx | 5 ++++- sw/source/uibase/app/docsh.cxx | 4 ++-- sw/source/uibase/utlui/unotools.cxx | 3 ++- 18 files changed, 42 insertions(+), 30 deletions(-)
New commits: commit f72013ab3ee05276c8b8ae66e7b051efbded8a26 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Jan 9 12:47:57 2023 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 24 08:31:17 2023 +0200 Resolves: tdf#152845 AutoText preview not readable in high contrast mode if its a high contrast mode with white text on black background. Reuse isOutputToWindow to distinguish between the case we are outputting to screen but not using a vcl::Window (and want to use the appropiate color for autocolor) vs the cases we are printing or exporting to pdf and not using a vcl::Window where the color should be black. Change-Id: Ib688892a6315fe88ba585613539088611d3995ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145234 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158307 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx index 83a3f1781630..ffd22b9063c7 100644 --- a/basctl/source/basicide/basdoc.cxx +++ b/basctl/source/basicide/basdoc.cxx @@ -82,7 +82,7 @@ void DocShell::FillClass( SvGlobalName*, SotClipboardFormatId*, OUString*, sal_I DBG_ASSERT( !bTemplate, "No template for Basic" ); } -void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16 ) +void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16, bool ) {} } // namespace basctl diff --git a/basctl/source/basicide/basdoc.hxx b/basctl/source/basicide/basdoc.hxx index d5b3aabcf961..bb847a0a9b1a 100644 --- a/basctl/source/basicide/basdoc.hxx +++ b/basctl/source/basicide/basdoc.hxx @@ -34,7 +34,7 @@ class DocShell: public SfxObjectShell protected: virtual void Draw( OutputDevice *, const JobSetup & rSetup, - sal_uInt16 nAspect ) override; + sal_uInt16 nAspect, bool bOutputForScreen ) override; virtual void FillClass( SvGlobalName * pClassName, SotClipboardFormatId * pFormat, OUString * pFullTypeName, diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 38ae4166cf0e..e447b4297362 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -651,9 +651,10 @@ public: void DoDraw( OutputDevice *, const Point & rObjPos, const Size & rSize, const JobSetup & rSetup, - sal_uInt16 nAspect = ASPECT_CONTENT ); + sal_uInt16 nAspect = ASPECT_CONTENT, + bool bOutputForScreen = false ); virtual void Draw( OutputDevice *, const JobSetup & rSetup, - sal_uInt16 nAspect ) = 0; + sal_uInt16 nAspect, bool bOutputForScreen ) = 0; virtual void FillClass( SvGlobalName * pClassName, @@ -718,7 +719,8 @@ public: const Fraction & rScaleX, const Fraction & rScaleY, const JobSetup & rSetup, - sal_uInt16 nAspect ); + sal_uInt16 nAspect, + bool bOutputForScreen ); // Shell Interface SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 91ee281523f4..ceef6e3009f5 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2172,7 +2172,7 @@ void ScDocShell::GetState( SfxItemSet &rSet ) } } -void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uInt16 nAspect ) +void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uInt16 nAspect, bool /*bOutputToWindow*/ ) { SCTAB nVisTab = m_pDocument->GetVisibleTab(); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 0555b0077a12..cb54b932991a 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -199,7 +199,7 @@ public: virtual bool DoSaveCompleted( SfxMedium * pNewStor=nullptr, bool bRegisterRecent=true ) override; // SfxObjectShell virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ) override; - virtual void Draw( OutputDevice *, const JobSetup & rSetup, sal_uInt16 nAspect ) override; + virtual void Draw(OutputDevice *, const JobSetup & rSetup, sal_uInt16 nAspect, bool bOutputForScreen) override; virtual void SetVisArea( const tools::Rectangle & rVisArea ) override; diff --git a/sd/source/ui/docshell/docshel2.cxx b/sd/source/ui/docshell/docshel2.cxx index 160c64a662eb..caf0fc86f1b1 100644 --- a/sd/source/ui/docshell/docshel2.cxx +++ b/sd/source/ui/docshell/docshel2.cxx @@ -44,7 +44,7 @@ namespace sd { /** * Drawing of DocShell (with the helper class SdDrawViewShell) */ -void DrawDocShell::Draw(OutputDevice* pOut, const JobSetup&, sal_uInt16 nAspect) +void DrawDocShell::Draw(OutputDevice* pOut, const JobSetup&, sal_uInt16 nAspect, bool /*bOutputForScreen*/) { if (nAspect == ASPECT_THUMBNAIL) { diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx index 5c742befd855..4b21acae84f0 100644 --- a/sd/source/ui/inc/DrawDocShell.hxx +++ b/sd/source/ui/inc/DrawDocShell.hxx @@ -90,7 +90,7 @@ public: virtual bool SaveAs( SfxMedium &rMedium ) override; virtual ::tools::Rectangle GetVisArea(sal_uInt16 nAspect) const override; - virtual void Draw(OutputDevice*, const JobSetup& rSetup, sal_uInt16 nAspect) override; + virtual void Draw(OutputDevice*, const JobSetup& rSetup, sal_uInt16 nAspect, bool bOutputForScreen) override; virtual SfxUndoManager* GetUndoManager() override; virtual Printer* GetDocumentPrinter() override; virtual void OnDocumentPrinterChanged(Printer* pNewPrinter) override; diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx index 91e886c8ac3c..f2e91cef821e 100644 --- a/sfx2/source/doc/objembed.cxx +++ b/sfx2/source/doc/objembed.cxx @@ -122,12 +122,12 @@ void SfxObjectShell::FillTransferableObjectDescriptor( TransferableObjectDescrip rDesc.maDisplayName.clear(); } - void SfxObjectShell::DoDraw( OutputDevice* pDev, const Point & rObjPos, const Size & rSize, const JobSetup & rSetup, - sal_uInt16 nAspect ) + sal_uInt16 nAspect, + bool bOutputForScreen ) { if (!rSize.Width() || !rSize.Height()) return; @@ -141,17 +141,17 @@ void SfxObjectShell::DoDraw( OutputDevice* pDev, Fraction aXF( rSize.Width(), aSize.Width() ); Fraction aYF( rSize.Height(), aSize.Height() ); - DoDraw_Impl( pDev, rObjPos, aXF, aYF, rSetup, nAspect ); + DoDraw_Impl(pDev, rObjPos, aXF, aYF, rSetup, nAspect, bOutputForScreen); } } - void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev, const Point & rViewPos, const Fraction & rScaleX, const Fraction & rScaleY, const JobSetup & rSetup, - sal_uInt16 nAspect ) + sal_uInt16 nAspect, + bool bOutputForScreen ) { tools::Rectangle aVisArea = GetVisArea( nAspect ); // MapUnit of the target @@ -194,7 +194,7 @@ void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev, if( pMtf ) pMtf->Record( pDev ); - Draw( pDev, rSetup, nAspect ); + Draw( pDev, rSetup, nAspect, bOutputForScreen ); // Restore Device settings pDev->Pop(); diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 214d9a9ce558..bf9477b30f11 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -103,7 +103,8 @@ class SM_DLLPUBLIC SmDocShell final : public SfxObjectShell, public SfxListener virtual void Draw(OutputDevice *pDevice, const JobSetup & rSetup, - sal_uInt16 nAspect) override; + sal_uInt16 nAspect, + bool bOutputForScreen) override; virtual void FillClass(SvGlobalName* pClassName, SotClipboardFormatId* pFormat, diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index b92c024401d2..e00c3094e4d7 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -1137,7 +1137,8 @@ void SmDocShell::SaveSymbols() void SmDocShell::Draw(OutputDevice *pDevice, const JobSetup &, - sal_uInt16 /*nAspect*/) + sal_uInt16 /*nAspect*/, + bool /*bOutputForScreen*/) { pDevice->IntersectClipRegion(GetVisArea()); Point atmppoint; diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index a48dcad8276b..a06d1f80e2f7 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -120,7 +120,7 @@ class SW_DLLPUBLIC SwDocShell SAL_DLLPRIVATE virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet) override; /// OLE-stuff - SAL_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16 nAspect) override; + SAL_DLLPRIVATE virtual void Draw(OutputDevice*, const JobSetup&, sal_uInt16 nAspect, bool bOutputToWindow) override; /// Methods for StyleSheets diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 2c409945fd11..2ef93801deeb 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -391,7 +391,8 @@ public: // Printing for OLE 2.0. static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions, - vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ); + vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, + bool bOutputForScreen ); // Fill temporary doc with selected text for Print or PDF export. void FillPrtDoc( SwDoc& rPrtDoc, const SfxPrinter* pPrt ); diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 5367006809c2..f3aeacb12921 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1267,7 +1267,7 @@ void SwNoTextFrame::ImplPaintPictureGraphic( vcl::RenderContext* pOut, ? pImp->GetPageView() : nullptr); // tdf#130951 caution - target may be Window, use the correct OutputDevice - OutputDevice* pTarget(pShell->isOutputToWindow() + OutputDevice* pTarget((pShell->isOutputToWindow() && pShell->GetWin()) ? pShell->GetWin()->GetOutDev() : pShell->GetOut()); SdrPageWindow* pPageWindow(nullptr != pPageView && nullptr != pTarget diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 47f7e8eb71de..bc5dd603a433 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2144,7 +2144,10 @@ bool SwDrawTextInfo::ApplyAutoColor( vcl::Font* pFont ) bool bChgFntColor = false; bool bChgLineColor = false; - if (GetShell() && !GetShell()->GetWin() && GetShell()->GetViewOptions()->IsBlackFont()) + const SwViewShell *pVSh = GetShell(); + const bool bOutputToWindow(pVSh && (pVSh->GetWin() || pVSh->isOutputToWindow())); + + if (pVSh && !bOutputToWindow && pVSh->GetViewOptions()->IsBlackFont()) { if ( COL_BLACK != rFnt.GetColor() ) bChgFntColor = true; @@ -2160,8 +2163,8 @@ bool SwDrawTextInfo::ApplyAutoColor( vcl::Font* pFont ) // LineColor has to be changed if: // 1. IsAlwaysAutoColor is set - bChgLineColor = GetShell() && GetShell()->GetWin() && - GetShell()->GetAccessibilityOptions()->IsAlwaysAutoColor(); + bChgLineColor = pVSh && bOutputToWindow && + pVSh->GetAccessibilityOptions()->IsAlwaysAutoColor(); bChgFntColor = COL_AUTO == rFnt.GetColor() || bChgLineColor; @@ -2210,10 +2213,10 @@ bool SwDrawTextInfo::ApplyAutoColor( vcl::Font* pFont ) if ( ! pCol ) pCol = aGlobalRetoucheColor; - if( GetShell() && GetShell()->GetWin() ) + if (pVSh && bOutputToWindow) { // here we determine the preferred window text color for painting - const SwViewOption* pViewOption = GetShell()->GetViewOptions(); + const SwViewOption* pViewOption = pVSh->GetViewOptions(); if(pViewOption->IsPagePreview() && !officecfg::Office::Common::Accessibility::IsForPagePreviews::get()) nNewColor = COL_BLACK; diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index fe1dcd6512af..3f427ed77316 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -291,7 +291,7 @@ Color SwViewShellImp::GetRetoucheColor() const { Color aRet( COL_TRANSPARENT ); const SwViewShell &rSh = *GetShell(); - if ( rSh.GetWin() ) + if (rSh.GetWin() || rSh.isOutputToWindow()) { if ( rSh.GetViewOptions()->getBrowseMode() && COL_TRANSPARENT != rSh.GetViewOptions()->GetRetoucheColor() ) diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index c792773cd765..0ad22ccf5357 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -574,7 +574,8 @@ bool SwViewShell::PrintOrPDFExport( } void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions, - vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) + vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, + bool bOutputForScreen ) { // For printing a shell is needed. Either the Doc already has one, then we // create a new view, or it has none, then we create the first view. @@ -584,6 +585,8 @@ void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintD else pSh.reset(new SwViewShell( *pDoc, nullptr, pOpt, &rRenderContext)); + pSh->setOutputToWindow(bOutputForScreen); + { CurrShell aCurr( pSh.get() ); pSh->PrepareForPrint( rOptions ); diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index b9a8430deedc..72dd3319fc4b 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -847,7 +847,7 @@ bool SwDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor // Draw()-Override for OLE2 (Sfx) void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup, - sal_uInt16 nAspect ) + sal_uInt16 nAspect, bool bOutputForScreen ) { //fix #25341# Draw should not affect the Modified bool bResetModified = IsEnableSetModified(); @@ -876,7 +876,7 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup, pDev->SetBackground(); const bool bWeb = dynamic_cast< const SwWebDocShell *>( this ) != nullptr; SwPrintData aOpts; - SwViewShell::PrtOle2(m_xDoc.get(), SW_MOD()->GetUsrPref(bWeb), aOpts, *pDev, aRect); + SwViewShell::PrtOle2(m_xDoc.get(), SW_MOD()->GetUsrPref(bWeb), aOpts, *pDev, aRect, bOutputForScreen); pDev->Pop(); if( pOrig ) diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index 4f520f50525f..896c2ecf0d7e 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -53,6 +53,7 @@ #include <comphelper/string.hxx> #include <docsh.hxx> #include <editsh.hxx> +#include <wrtsh.hxx> #include <swmodule.hxx> #include <TextCursorHelper.hxx> #include <doc.hxx> @@ -169,7 +170,7 @@ void SwOneExampleFrame::Paint(vcl::RenderContext& rRenderContext, const tools::R tools::Rectangle aRect(Point(), m_xVirDev->PixelToLogic(aSize)); pShell->SetVisArea(tools::Rectangle(Point(), Size(aRect.GetWidth() * fZoom, aRect.GetHeight() * fZoom))); - pShell->DoDraw(m_xVirDev.get(), aRect.TopLeft(), aRect.GetSize(), JobSetup(), ASPECT_CONTENT); + pShell->DoDraw(m_xVirDev.get(), aRect.TopLeft(), aRect.GetSize(), JobSetup(), ASPECT_CONTENT, true); m_xVirDev->Pop(); }