diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-03-12 23:36:17 +1100 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-21 19:10:30 +0000 |
commit | 143c059ff7f69a363b3cf736a9f0197a9f25cf9c (patch) | |
tree | 4042b695c3ea9676dad869ca9220c31b4e47fb62 /vcl/source/gdi/print.cxx | |
parent | 9dc4377c91b00585519abfd4fc1528393fe84e4a (diff) |
fdo#74702 Moved ImplReleaseGraphics into correct classes
Made OutputDevice::ImplReleaseGraphics a pure virtual function, then
implemented function in Printer, Window and VirtualDevice. The reason
was that OutputDevice was checking to see if it was a Printer, Window
or VirtualDevice that was calling on it in an if statement, very
uncool :-) Now I let the classes themselves do the work.
There is some common functionality, which is to release the fonts. I
have put this into a protected OutputDevice function, ImplReleaseFonts.
Change-Id: Id41db2119d4022ea2fc7855158ca9f610af3c85c
Reviewed-on: https://gerrit.libreoffice.org/8548
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'vcl/source/gdi/print.cxx')
-rw-r--r-- | vcl/source/gdi/print.cxx | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index dca6ef3ee5e2..3f1acd120daa 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -527,6 +527,90 @@ bool Printer::ImplInitGraphics() const return mpGraphics ? true : false; } +void Printer::ImplReleaseFonts() +{ +#ifndef UNX + // HACK to fix an urgent P1 printing issue fast + // WinSalPrinter does not respect GetGraphics/ReleaseGraphics conventions + // so Printer::mpGraphics often points to a dead WinSalGraphics + // TODO: fix WinSalPrinter's GetGraphics/ReleaseGraphics handling + mpGraphics->ReleaseFonts(); +#endif + mbNewFont = true; + mbInitFont = true; + + if ( mpFontEntry ) + { + mpFontCache->Release( mpFontEntry ); + mpFontEntry = NULL; + } + + if ( mpGetDevFontList ) + { + delete mpGetDevFontList; + mpGetDevFontList = NULL; + } + + if ( mpGetDevSizeList ) + { + delete mpGetDevSizeList; + mpGetDevSizeList = NULL; + } +} + +void Printer::ImplReleaseGraphics( bool bRelease ) +{ + DBG_TESTSOLARMUTEX(); + + if ( !mpGraphics ) + return; + + // release the fonts of the physically released graphics device + if( bRelease ) + ImplReleaseFonts(); + + ImplSVData* pSVData = ImplGetSVData(); + + Printer* pPrinter = (Printer*)this; + + if ( !pPrinter->mpJobGraphics ) + { + if ( pPrinter->mpDisplayDev ) + { + VirtualDevice* pVirDev = pPrinter->mpDisplayDev; + if ( bRelease ) + pVirDev->mpVirDev->ReleaseGraphics( mpGraphics ); + // remove from global LRU list of virtual device graphics + if ( mpPrevGraphics ) + mpPrevGraphics->mpNextGraphics = mpNextGraphics; + else + pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics; + if ( mpNextGraphics ) + mpNextGraphics->mpPrevGraphics = mpPrevGraphics; + else + pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics; + } + else + { + if ( bRelease ) + pPrinter->mpInfoPrinter->ReleaseGraphics( mpGraphics ); + // remove from global LRU list of printer graphics + if ( mpPrevGraphics ) + mpPrevGraphics->mpNextGraphics = mpNextGraphics; + else + pSVData->maGDIData.mpFirstPrnGraphics = mpNextGraphics; + if ( mpNextGraphics ) + mpNextGraphics->mpPrevGraphics = mpPrevGraphics; + else + pSVData->maGDIData.mpLastPrnGraphics = mpPrevGraphics; + } + } + + mpGraphics = NULL; + mpPrevGraphics = NULL; + mpNextGraphics = NULL; +} + void Printer::ImplInit( SalPrinterQueueInfo* pInfo ) { ImplSVData* pSVData = ImplGetSVData(); |