diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-09 12:47:57 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-02-01 19:31:49 +0000 |
commit | 0eaad910442a1bbb0c6a89a8887322ea3d6906e0 (patch) | |
tree | c03fc63172ced9ad29db4022f5008b28ae2d4bca | |
parent | 9274d41bd72c5310491d81c6d8d938e44ed9d223 (diff) |
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 <caolanm@redhat.com>
-rw-r--r-- | basctl/source/basicide/basdoc.cxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/basdoc.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/objsh.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/docshell/docshel2.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/inc/DrawDocShell.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objembed.cxx | 12 | ||||
-rw-r--r-- | starmath/inc/document.hxx | 3 | ||||
-rw-r--r-- | starmath/source/document.cxx | 3 | ||||
-rw-r--r-- | sw/inc/docsh.hxx | 2 | ||||
-rw-r--r-- | sw/inc/viewsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/view/viewimp.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/view/vprint.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/utlui/unotools.cxx | 3 |
18 files changed, 42 insertions, 30 deletions
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 b64fa61389bf..e3a5b4a022f1 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -650,9 +650,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, @@ -717,7 +718,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 a57a40e9be8b..3ef4dba632d8 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2174,7 +2174,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 edf0cbc1c1b0..6df3ebc010e9 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -198,7 +198,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 86917fcb7402..e9dfe4235132 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 73b53f675301..10143dae9afb 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -1139,7 +1139,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 74fa2225ae93..890c2c48ed67 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 1114478ed395..3c8bc31b88c0 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -367,7 +367,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 6cb71550387c..640d8dce0fe3 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1264,7 +1264,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 20ed476398d8..0387246285b8 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2134,7 +2134,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; @@ -2150,8 +2153,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; @@ -2200,10 +2203,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 272cd962e6f6..0ca4026252e2 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 fba4437f4a54..74f47fc2aa8b 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(); } |