Bug Summary

File:home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx
Warning:line 127, column 13
Value stored to 'nDepth' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name genpspgraphics.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/glm -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/cairo -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/pixman-1 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/libxml2 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D VCL_DLLIMPLEMENTATION -D DLLIMPLEMENTATION_UITEST -D CUI_DLL_NAME="libcuilo.so" -D DESKTOP_DETECTOR_DLL_NAME="libdesktop_detectorlo.so" -D TK_DLL_NAME="libtklo.so" -D SYSTEM_ZLIB -D GLM_FORCE_CTOR_INIT -D SK_USER_CONFIG_HEADER=</home/maarten/src/libreoffice/core/config_host/config_skia.h> -D SKIA_DLL -D ENABLE_CUPS -D HAVE_VALGRIND_HEADERS -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/epoxy/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/core -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/effects -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/gpu -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/config -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/ports -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/include/third_party/vulkan -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia/tools/gpu -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/skia -I /home/maarten/src/libreoffice/core/external/skia/inc/ -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/mdds/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/lcms2/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/harfbuzz/src -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/graphite/include -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/pdfium -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/pdfium/public -D COMPONENT_BUILD -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/libpng -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/libjpeg-turbo -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/vcl/inc -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libxml2 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21#include <sal/log.hxx>
22
23#include <vector>
24
25#include <sal/types.h>
26
27#include <unistd.h>
28#include <fcntl.h>
29#include <sys/mman.h>
30#include <sys/stat.h>
31
32#include <i18nlangtag/mslangid.hxx>
33#include <vcl/bitmapaccess.hxx>
34#include <jobdata.hxx>
35#include <vcl/settings.hxx>
36#include <vcl/svapp.hxx>
37#include <vcl/sysdata.hxx>
38#include <vcl/fontcharmap.hxx>
39#include <config_cairo_canvas.h>
40
41#include <fontsubset.hxx>
42#include <unx/freetype_glyphcache.hxx>
43#include <unx/geninst.h>
44#include <unx/genpspgraphics.h>
45#include <unx/printergfx.hxx>
46#include <langboost.hxx>
47#include <fontinstance.hxx>
48#include <fontattributes.hxx>
49#include <impfontmetricdata.hxx>
50#include <PhysicalFontCollection.hxx>
51#include <PhysicalFontFace.hxx>
52#include <salbmp.hxx>
53#include <sallayout.hxx>
54
55using namespace psp;
56
57// ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer ---------------
58
59namespace {
60
61class SalPrinterBmp : public psp::PrinterBmp
62{
63private:
64 BitmapBuffer* mpBmpBuffer;
65
66 FncGetPixel mpFncGetPixel;
67 Scanline mpScanAccess;
68 sal_PtrDiff mnScanOffset;
69
70public:
71 explicit SalPrinterBmp (BitmapBuffer* pBitmap);
72
73 virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const override;
74 virtual sal_uInt32 GetPaletteEntryCount () const override;
75 virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const override;
76 virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const override;
77 virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const override;
78 virtual sal_uInt32 GetDepth () const override;
79};
80
81}
82
83SalPrinterBmp::SalPrinterBmp (BitmapBuffer* pBuffer)
84 : mpBmpBuffer(pBuffer)
85{
86 assert(mpBmpBuffer && "SalPrinterBmp::SalPrinterBmp () can't acquire Bitmap")(static_cast <bool> (mpBmpBuffer && "SalPrinterBmp::SalPrinterBmp () can't acquire Bitmap"
) ? void (0) : __assert_fail ("mpBmpBuffer && \"SalPrinterBmp::SalPrinterBmp () can't acquire Bitmap\""
, "/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
, 86, __extension__ __PRETTY_FUNCTION__))
;
87
88 // calibrate scanline buffer
89 if( mpBmpBuffer->mnFormat & ScanlineFormat::TopDown )
90 {
91 mpScanAccess = mpBmpBuffer->mpBits;
92 mnScanOffset = mpBmpBuffer->mnScanlineSize;
93 }
94 else
95 {
96 mpScanAccess = mpBmpBuffer->mpBits
97 + (mpBmpBuffer->mnHeight - 1) * mpBmpBuffer->mnScanlineSize;
98 mnScanOffset = - mpBmpBuffer->mnScanlineSize;
99 }
100
101 // request read access to the pixels
102 mpFncGetPixel = BitmapReadAccess::GetPixelFunction( mpBmpBuffer->mnFormat );
103}
104
105sal_uInt32
106SalPrinterBmp::GetDepth () const
107{
108 sal_uInt32 nDepth;
109
110 switch (mpBmpBuffer->mnBitCount)
111 {
112 case 1:
113 nDepth = 1;
114 break;
115
116 case 4:
117 case 8:
118 nDepth = 8;
119 break;
120
121 case 24:
122 case 32:
123 nDepth = 24;
124 break;
125
126 default:
127 nDepth = 1;
Value stored to 'nDepth' is never read
128 assert(false && "Error: unsupported bitmap depth in SalPrinterBmp::GetDepth()")(static_cast <bool> (false && "Error: unsupported bitmap depth in SalPrinterBmp::GetDepth()"
) ? void (0) : __assert_fail ("false && \"Error: unsupported bitmap depth in SalPrinterBmp::GetDepth()\""
, "/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
, 128, __extension__ __PRETTY_FUNCTION__))
;
129 break;
130 }
131
132 return nDepth;
133}
134
135sal_uInt32
136SalPrinterBmp::GetPaletteEntryCount () const
137{
138 return mpBmpBuffer->maPalette.GetEntryCount ();
139}
140
141sal_uInt32
142SalPrinterBmp::GetPaletteColor(sal_uInt32 nIdx) const
143{
144 BitmapColor aColor(mpBmpBuffer->maPalette[nIdx]);
145
146 return ((aColor.GetBlue()) & 0x000000ff)
147 | ((aColor.GetGreen() << 8) & 0x0000ff00)
148 | ((aColor.GetRed() << 16) & 0x00ff0000);
149}
150
151sal_uInt32
152SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const
153{
154 Scanline pScan = mpScanAccess + nRow * mnScanOffset;
155 BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
156
157 if (!!mpBmpBuffer->maPalette)
158 GetPaletteColor(aColor.GetIndex());
159
160 return ((aColor.GetBlue()) & 0x000000ff)
161 | ((aColor.GetGreen() << 8) & 0x0000ff00)
162 | ((aColor.GetRed() << 16) & 0x00ff0000);
163}
164
165sal_uInt8
166SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const
167{
168 Scanline pScan = mpScanAccess + nRow * mnScanOffset;
169 BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
170
171 if (!!mpBmpBuffer->maPalette)
172 aColor = mpBmpBuffer->maPalette[aColor.GetIndex()];
173
174 return ( aColor.GetBlue() * 28UL
175 + aColor.GetGreen() * 151UL
176 + aColor.GetRed() * 77UL ) >> 8;
177
178}
179
180sal_uInt8
181SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const
182{
183 Scanline pScan = mpScanAccess + nRow * mnScanOffset;
184 BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
185
186 if (!!mpBmpBuffer->maPalette)
187 return aColor.GetIndex();
188 else
189 return 0;
190}
191
192/*******************************************************
193 * GenPspGraphics *
194 *******************************************************/
195GenPspGraphics::GenPspGraphics()
196 : m_pJobData( nullptr ),
197 m_pPrinterGfx( nullptr )
198{
199}
200
201void GenPspGraphics::Init(psp::JobData* pJob, psp::PrinterGfx* pGfx)
202{
203 m_pJobData = pJob;
204 m_pPrinterGfx = pGfx;
205 SetLayout( SalLayoutFlags::NONE );
206}
207
208GenPspGraphics::~GenPspGraphics()
209{
210 ReleaseFonts();
211}
212
213void GenPspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY )
214{
215 if (m_pJobData != nullptr)
216 {
217 int x = m_pJobData->m_aContext.getRenderResolution();
218
219 rDPIX = x;
220 rDPIY = x;
221 }
222}
223
224sal_uInt16 GenPspGraphics::GetBitCount() const
225{
226 return m_pPrinterGfx->GetBitCount();
227}
228
229long GenPspGraphics::GetGraphicsWidth() const
230{
231 return 0;
232}
233
234void GenPspGraphics::ResetClipRegion()
235{
236 m_pPrinterGfx->ResetClipRegion();
237}
238
239bool GenPspGraphics::setClipRegion( const vcl::Region& i_rClip )
240{
241 // TODO: support polygonal clipregions here
242 RectangleVector aRectangles;
243 i_rClip.GetRegionRectangles(aRectangles);
244 m_pPrinterGfx->BeginSetClipRegion();
245
246 for (auto const& rectangle : aRectangles)
247 {
248 const long nW(rectangle.GetWidth());
249
250 if(nW)
251 {
252 const long nH(rectangle.GetHeight());
253
254 if(nH)
255 {
256 m_pPrinterGfx->UnionClipRegion(
257 rectangle.Left(),
258 rectangle.Top(),
259 nW,
260 nH);
261 }
262 }
263 }
264
265 m_pPrinterGfx->EndSetClipRegion();
266
267 //m_pPrinterGfx->BeginSetClipRegion( i_rClip.GetRectCount() );
268
269 //ImplRegionInfo aInfo;
270 //long nX, nY, nW, nH;
271 //bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
272 //while( bRegionRect )
273 //{
274 // if ( nW && nH )
275 // {
276 // m_pPrinterGfx->UnionClipRegion( nX, nY, nW, nH );
277 // }
278 // bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
279 //}
280 //m_pPrinterGfx->EndSetClipRegion();
281 return true;
282}
283
284void GenPspGraphics::SetLineColor()
285{
286 m_pPrinterGfx->SetLineColor ();
287}
288
289void GenPspGraphics::SetLineColor( Color nColor )
290{
291 psp::PrinterColor aColor (nColor.GetRed(),
292 nColor.GetGreen(),
293 nColor.GetBlue());
294 m_pPrinterGfx->SetLineColor (aColor);
295}
296
297void GenPspGraphics::SetFillColor()
298{
299 m_pPrinterGfx->SetFillColor ();
300}
301
302void GenPspGraphics::SetFillColor( Color nColor )
303{
304 psp::PrinterColor aColor (nColor.GetRed(),
305 nColor.GetGreen(),
306 nColor.GetBlue());
307 m_pPrinterGfx->SetFillColor (aColor);
308}
309
310void GenPspGraphics::SetROPLineColor( SalROPColor )
311{
312 SAL_WARN( "vcl", "Error: PrinterGfx::SetROPLineColor() not implemented" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::SetROPLineColor() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "312" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::SetROPLineColor() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::SetROPLineColor() not implemented"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"),
("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "312" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::SetROPLineColor() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "312" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::SetROPLineColor() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::SetROPLineColor() not implemented"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"),
("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "312" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
313}
314
315void GenPspGraphics::SetROPFillColor( SalROPColor )
316{
317 SAL_WARN( "vcl", "Error: PrinterGfx::SetROPFillColor() not implemented" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::SetROPFillColor() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "317" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::SetROPFillColor() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::SetROPFillColor() not implemented"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"),
("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "317" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::SetROPFillColor() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "317" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::SetROPFillColor() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::SetROPFillColor() not implemented"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"),
("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "317" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
318}
319
320void GenPspGraphics::SetXORMode( bool bSet, bool )
321{
322 SAL_WARN_IF( bSet, "vcl", "Error: PrinterGfx::SetXORMode() not implemented" )do { if (true && (bSet)) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "Error: PrinterGfx::SetXORMode() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "322" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::SetXORMode() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::SetXORMode() not implemented"; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "322" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::SetXORMode() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "322" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::SetXORMode() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::SetXORMode() not implemented"; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "322" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
323}
324
325void GenPspGraphics::drawPixel( long nX, long nY )
326{
327 m_pPrinterGfx->DrawPixel (Point(nX, nY));
328}
329
330void GenPspGraphics::drawPixel( long nX, long nY, Color nColor )
331{
332 psp::PrinterColor aColor (nColor.GetRed(),
333 nColor.GetGreen(),
334 nColor.GetBlue());
335 m_pPrinterGfx->DrawPixel (Point(nX, nY), aColor);
336}
337
338void GenPspGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
339{
340 m_pPrinterGfx->DrawLine (Point(nX1, nY1), Point(nX2, nY2));
341}
342
343void GenPspGraphics::drawRect( long nX, long nY, long nDX, long nDY )
344{
345 m_pPrinterGfx->DrawRect (tools::Rectangle(Point(nX, nY), Size(nDX, nDY)));
346}
347
348void GenPspGraphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint *pPtAry )
349{
350 m_pPrinterGfx->DrawPolyLine (nPoints, reinterpret_cast<const Point *>(pPtAry));
351}
352
353void GenPspGraphics::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
354{
355 // Point must be equal to SalPoint! see include/vcl/salgtype.hxx
356 m_pPrinterGfx->DrawPolygon (nPoints, reinterpret_cast<const Point *>(pPtAry));
357}
358
359void GenPspGraphics::drawPolyPolygon( sal_uInt32 nPoly,
360 const sal_uInt32 *pPoints,
361 PCONSTSALPOINT *pPtAry )
362{
363 m_pPrinterGfx->DrawPolyPolygon (nPoly, pPoints, reinterpret_cast<const Point**>(pPtAry));
364}
365
366bool GenPspGraphics::drawPolyPolygon(
367 const basegfx::B2DHomMatrix& /*rObjectToDevice*/,
368 const basegfx::B2DPolyPolygon&,
369 double /*fTransparency*/)
370{
371 // TODO: implement and advertise OutDevSupportType::B2DDraw support
372 return false;
373}
374
375bool GenPspGraphics::drawPolyLine(
376 const basegfx::B2DHomMatrix& /* rObjectToDevice */,
377 const basegfx::B2DPolygon&,
378 double /*fTransparency*/,
379 double /*fLineWidth*/,
380 const std::vector< double >* /*pStroke*/, // MM01
381 basegfx::B2DLineJoin /*eJoin*/,
382 css::drawing::LineCap /*eLineCap*/,
383 double /*fMiterMinimumAngle*/,
384 bool /* bPixelSnapHairline */)
385{
386 // TODO: a PS printer can draw B2DPolyLines almost directly
387 return false;
388}
389
390bool GenPspGraphics::drawPolyLineBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry )
391{
392 m_pPrinterGfx->DrawPolyLineBezier (nPoints, reinterpret_cast<Point const *>(pPtAry), pFlgAry);
393 return true;
394}
395
396bool GenPspGraphics::drawPolygonBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry )
397{
398 m_pPrinterGfx->DrawPolygonBezier (nPoints, reinterpret_cast<Point const *>(pPtAry), pFlgAry);
399 return true;
400}
401
402bool GenPspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly,
403 const sal_uInt32* pPoints,
404 const SalPoint* const* pPtAry,
405 const PolyFlags* const* pFlgAry )
406{
407 // Point must be equal to SalPoint! see include/vcl/salgtype.hxx
408 m_pPrinterGfx->DrawPolyPolygonBezier (nPoly, pPoints, reinterpret_cast<Point const * const *>(pPtAry), pFlgAry);
409 return true;
410}
411
412void GenPspGraphics::invert( sal_uInt32,
413 const SalPoint*,
414 SalInvert )
415{
416 SAL_WARN( "vcl", "Error: PrinterGfx::Invert() not implemented" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::Invert() not implemented") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "416" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::Invert() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::Invert() not implemented"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "416" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Error: PrinterGfx::Invert() not implemented") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "416" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Error: PrinterGfx::Invert() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Error: PrinterGfx::Invert() not implemented"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "416" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
417}
418
419bool GenPspGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uInt32 nSize )
420{
421 return m_pPrinterGfx->DrawEPS( tools::Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ), pPtr, nSize );
422}
423
424void GenPspGraphics::copyBits( const SalTwoRect&,
425 SalGraphics* )
426{
427 OSL_FAIL( "Error: PrinterGfx::CopyBits() not implemented" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "427" ": "), "%s", "Error: PrinterGfx::CopyBits() not implemented"
); } } while (false)
;
428}
429
430void GenPspGraphics::copyArea ( long,long,long,long,long,long,bool )
431{
432 OSL_FAIL( "Error: PrinterGfx::CopyArea() not implemented" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "432" ": "), "%s", "Error: PrinterGfx::CopyArea() not implemented"
); } } while (false)
;
433}
434
435void GenPspGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
436{
437 tools::Rectangle aSrc (Point(rPosAry.mnSrcX, rPosAry.mnSrcY),
438 Size(rPosAry.mnSrcWidth, rPosAry.mnSrcHeight));
439 tools::Rectangle aDst (Point(rPosAry.mnDestX, rPosAry.mnDestY),
440 Size(rPosAry.mnDestWidth, rPosAry.mnDestHeight));
441
442 BitmapBuffer* pBuffer= const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(BitmapAccessMode::Read);
443
444 SalPrinterBmp aBmp (pBuffer);
445 m_pPrinterGfx->DrawBitmap (aDst, aSrc, aBmp);
446
447 const_cast<SalBitmap&>(rSalBitmap).ReleaseBuffer (pBuffer, BitmapAccessMode::Read);
448}
449
450void GenPspGraphics::drawBitmap( const SalTwoRect&,
451 const SalBitmap&,
452 const SalBitmap& )
453{
454 OSL_FAIL("Error: no PrinterGfx::DrawBitmap() for transparent bitmap")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "454" ": "), "%s", "Error: no PrinterGfx::DrawBitmap() for transparent bitmap"
); } } while (false)
;
455}
456
457void GenPspGraphics::drawMask( const SalTwoRect&,
458 const SalBitmap &,
459 Color )
460{
461 OSL_FAIL("Error: PrinterGfx::DrawMask() not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "461" ": "), "%s", "Error: PrinterGfx::DrawMask() not implemented"
); } } while (false)
;
462}
463
464std::shared_ptr<SalBitmap> GenPspGraphics::getBitmap( long, long, long, long )
465{
466 SAL_INFO("vcl", "Warning: PrinterGfx::GetBitmap() not implemented")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Warning: PrinterGfx::GetBitmap() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "466" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Warning: PrinterGfx::GetBitmap() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Warning: PrinterGfx::GetBitmap() not implemented";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl"), (
"/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "466" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Warning: PrinterGfx::GetBitmap() not implemented"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl"
), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "466" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Warning: PrinterGfx::GetBitmap() not implemented"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Warning: PrinterGfx::GetBitmap() not implemented";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl"), (
"/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "466" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
467 return nullptr;
468}
469
470Color GenPspGraphics::getPixel( long, long )
471{
472 OSL_FAIL("Warning: PrinterGfx::GetPixel() not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "472" ": "), "%s", "Warning: PrinterGfx::GetPixel() not implemented"
); } } while (false)
;
473 return 0;
474}
475
476void GenPspGraphics::invert(long,long,long,long,SalInvert)
477{
478 OSL_FAIL("Warning: PrinterGfx::Invert() not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "478" ": "), "%s", "Warning: PrinterGfx::Invert() not implemented"
); } } while (false)
;
479}
480
481namespace {
482
483class ImplPspFontData : public FreetypeFontFace
484{
485private:
486 sal_IntPtr mnFontId;
487
488public:
489 explicit ImplPspFontData( const psp::FastPrintFontInfo& );
490 virtual sal_IntPtr GetFontId() const override { return mnFontId; }
491};
492
493}
494
495ImplPspFontData::ImplPspFontData(const psp::FastPrintFontInfo& rInfo)
496: FreetypeFontFace(nullptr, GenPspGraphics::Info2FontAttributes(rInfo)),
497 mnFontId( rInfo.m_nID )
498{}
499
500namespace {
501
502class PspSalLayout : public GenericSalLayout
503{
504public:
505 PspSalLayout(psp::PrinterGfx&, LogicalFontInstance &rFontInstance);
506
507 void InitFont() const final override;
508
509private:
510 ::psp::PrinterGfx& mrPrinterGfx;
511 sal_IntPtr mnFontID;
512 int mnFontHeight;
513 int mnFontWidth;
514 bool mbVertical;
515 bool mbArtItalic;
516 bool mbArtBold;
517};
518
519}
520
521PspSalLayout::PspSalLayout(::psp::PrinterGfx& rGfx, LogicalFontInstance &rFontInstance)
522: GenericSalLayout(rFontInstance)
523, mrPrinterGfx(rGfx)
524{
525 mnFontID = mrPrinterGfx.GetFontID();
526 mnFontHeight = mrPrinterGfx.GetFontHeight();
527 mnFontWidth = mrPrinterGfx.GetFontWidth();
528 mbVertical = mrPrinterGfx.GetFontVertical();
529 mbArtItalic = mrPrinterGfx.GetArtificialItalic();
530 mbArtBold = mrPrinterGfx.GetArtificialBold();
531}
532
533void PspSalLayout::InitFont() const
534{
535 GenericSalLayout::InitFont();
536 mrPrinterGfx.SetFont(mnFontID, mnFontHeight, mnFontWidth,
537 mnOrientation, mbVertical, mbArtItalic, mbArtBold);
538}
539
540void GenPspGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
541{
542 const GlyphItem* pGlyph;
543 Point aPos;
544 int nStart = 0;
545 while (rLayout.GetNextGlyph(&pGlyph, aPos, nStart))
546 m_pPrinterGfx->DrawGlyph(aPos, *pGlyph);
547}
548
549FontCharMapRef GenPspGraphics::GetFontCharMap() const
550{
551 if (!m_pFreetypeFont[0])
552 return nullptr;
553
554 return m_pFreetypeFont[0]->GetFreetypeFont().GetFontCharMap();
555}
556
557bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
558{
559 if (!m_pFreetypeFont[0])
560 return false;
561
562 return m_pFreetypeFont[0]->GetFreetypeFont().GetFontCapabilities(rFontCapabilities);
563}
564
565void GenPspGraphics::SetFont(LogicalFontInstance *pFontInstance, int nFallbackLevel)
566{
567 // release all fonts that are to be overridden
568 for( int i = nFallbackLevel; i < MAX_FALLBACK16; ++i )
569 {
570 // old server side font is no longer referenced
571 m_pFreetypeFont[i] = nullptr;
572 }
573
574 // return early if there is no new font
575 if (!pFontInstance)
576 return;
577
578 sal_IntPtr nID = pFontInstance->GetFontFace()->GetFontId();
579
580 const FontSelectPattern& rEntry = pFontInstance->GetFontSelectPattern();
581
582 // determine which font attributes need to be emulated
583 bool bArtItalic = false;
584 bool bArtBold = false;
585 if( rEntry.GetItalic() == ITALIC_OBLIQUE || rEntry.GetItalic() == ITALIC_NORMAL )
586 {
587 FontItalic eItalic = m_pPrinterGfx->GetFontMgr().getFontItalic( nID );
588 if( eItalic != ITALIC_NORMAL && eItalic != ITALIC_OBLIQUE )
589 bArtItalic = true;
590 }
591 int nWeight = static_cast<int>(rEntry.GetWeight());
592 int nRealWeight = static_cast<int>(m_pPrinterGfx->GetFontMgr().getFontWeight( nID ));
593 if( nRealWeight <= int(WEIGHT_MEDIUM) && nWeight > int(WEIGHT_MEDIUM) )
594 {
595 bArtBold = true;
596 }
597
598 // also set the serverside font for layouting
599 // requesting a font provided by builtin rasterizer
600 FreetypeFontInstance* pFreetypeFont = static_cast<FreetypeFontInstance*>(pFontInstance);
601 m_pFreetypeFont[ nFallbackLevel ] = pFreetypeFont;
602
603 // ignore fonts with e.g. corrupted font files
604 if (!m_pFreetypeFont[nFallbackLevel]->GetFreetypeFont().TestFont())
605 m_pFreetypeFont[nFallbackLevel] = nullptr;
606
607 // set the printer font
608 m_pPrinterGfx->SetFont( nID,
609 rEntry.mnHeight,
610 rEntry.mnWidth,
611 rEntry.mnOrientation,
612 rEntry.mbVertical,
613 bArtItalic,
614 bArtBold
615 );
616}
617
618void GenPspGraphics::SetTextColor( Color nColor )
619{
620 psp::PrinterColor aColor (nColor.GetRed(),
621 nColor.GetGreen(),
622 nColor.GetBlue());
623 m_pPrinterGfx->SetTextColor (aColor);
624}
625
626bool GenPspGraphics::AddTempDevFont( PhysicalFontCollection*, const OUString&,const OUString& )
627{
628 return false;
629}
630
631bool GenPspGraphics::AddTempDevFontHelper( PhysicalFontCollection* pFontCollection,
632 const OUString& rFileURL,
633 const OUString& rFontName)
634{
635 // inform PSP font manager
636 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
637 std::vector<psp::fontID> aFontIds = rMgr.addFontFile( rFileURL );
638 if( aFontIds.empty() )
639 return false;
640
641 FreetypeManager& rFreetypeManager = FreetypeManager::get();
642 for (auto const& elem : aFontIds)
643 {
644 // prepare font data
645 psp::FastPrintFontInfo aInfo;
646 rMgr.getFontFastInfo( elem, aInfo );
647 aInfo.m_aFamilyName = rFontName;
648
649 // inform glyph cache of new font
650 FontAttributes aDFA = GenPspGraphics::Info2FontAttributes( aInfo );
651 aDFA.IncreaseQualityBy( 5800 );
652
653 int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID );
654 int nVariantNum = rMgr.getFontFaceVariation( aInfo.m_nID );
655
656 const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID );
657 rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA);
658 }
659
660 // announce new font to device's font list
661 rFreetypeManager.AnnounceFonts(pFontCollection);
662 return true;
663}
664
665void GenPspGraphics::GetDevFontList( PhysicalFontCollection *pFontCollection )
666{
667 ::std::vector< psp::fontID > aList;
668 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
669 rMgr.getFontList( aList );
670
671 psp::FastPrintFontInfo aInfo;
672 for (auto const& elem : aList)
673 if (rMgr.getFontFastInfo (elem, aInfo))
674 AnnounceFonts( pFontCollection, aInfo );
675
676 // register platform specific font substitutions if available
677 SalGenericInstance::RegisterFontSubstitutors( pFontCollection );
678}
679
680void GenPspGraphics::ClearDevFontCache()
681{
682 FreetypeManager::get().ClearFontCache();
683}
684
685void GenPspGraphics::GetFontMetric(ImplFontMetricDataRef& rxFontMetric, int nFallbackLevel)
686{
687 if (nFallbackLevel >= MAX_FALLBACK16)
688 return;
689
690 if (m_pFreetypeFont[nFallbackLevel])
691 m_pFreetypeFont[nFallbackLevel]->GetFreetypeFont().GetFontMetric(rxFontMetric);
692}
693
694std::unique_ptr<GenericSalLayout> GenPspGraphics::GetTextLayout(int nFallbackLevel)
695{
696 assert(m_pFreetypeFont[nFallbackLevel])(static_cast <bool> (m_pFreetypeFont[nFallbackLevel]) ?
void (0) : __assert_fail ("m_pFreetypeFont[nFallbackLevel]",
"/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
, 696, __extension__ __PRETTY_FUNCTION__))
;
697 if (!m_pFreetypeFont[nFallbackLevel])
698 return nullptr;
699 return std::make_unique<PspSalLayout>(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]);
700}
701
702bool GenPspGraphics::CreateFontSubset(
703 const OUString& rToFile,
704 const PhysicalFontFace* pFont,
705 const sal_GlyphId* pGlyphIds,
706 const sal_uInt8* pEncoding,
707 sal_Int32* pWidths,
708 int nGlyphCount,
709 FontSubsetInfo& rInfo
710 )
711{
712 // in this context the pFont->GetFontId() is a valid PSP
713 // font since they are the only ones left after the PDF
714 // export has filtered its list of subsettable fonts (for
715 // which this method was created). The correct way would
716 // be to have the FreetypeManager search for the PhysicalFontFace pFont
717 psp::fontID aFont = pFont->GetFontId();
718
719 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
720 bool bSuccess = rMgr.createFontSubset( rInfo,
721 aFont,
722 rToFile,
723 pGlyphIds,
724 pEncoding,
725 pWidths,
726 nGlyphCount );
727 return bSuccess;
728}
729
730void GenPspGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
731 bool bVertical,
732 std::vector< sal_Int32 >& rWidths,
733 Ucs2UIntMap& rUnicodeEnc )
734{
735 // in this context the pFont->GetFontId() is a valid PSP
736 // font since they are the only ones left after the PDF
737 // export has filtered its list of subsettable fonts (for
738 // which this method was created). The correct way would
739 // be to have the FreetypeManager search for the PhysicalFontFace pFont
740 psp::fontID aFont = pFont->GetFontId();
741 GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
742}
743
744void GenPspGraphics::DoGetGlyphWidths( psp::fontID aFont,
745 bool bVertical,
746 std::vector< sal_Int32 >& rWidths,
747 Ucs2UIntMap& rUnicodeEnc )
748{
749 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
750 rMgr.getGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
751}
752
753FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo& rInfo )
754{
755 FontAttributes aDFA;
756 aDFA.SetFamilyName( rInfo.m_aFamilyName );
757 aDFA.SetStyleName( rInfo.m_aStyleName );
758 aDFA.SetFamilyType( rInfo.m_eFamilyStyle );
759 aDFA.SetWeight( rInfo.m_eWeight );
760 aDFA.SetItalic( rInfo.m_eItalic );
761 aDFA.SetWidthType( rInfo.m_eWidth );
762 aDFA.SetPitch( rInfo.m_ePitch );
763 aDFA.SetSymbolFlag( rInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL(((rtl_TextEncoding) 10)) );
764 aDFA.SetQuality(512);
765
766 // add font family name aliases
767 for (auto const& alias : rInfo.m_aAliases)
768 aDFA.AddMapName(alias);
769
770#if OSL_DEBUG_LEVEL1 > 2
771 if( aDFA.GetMapNames().getLength() > 0 )
772 {
773 SAL_INFO( "vcl.fonts", "using alias names " << aDFA.GetMapNames() << " for font family " << aDFA.GetFamilyName() )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "vcl.fonts")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "using alias names " <<
aDFA.GetMapNames() << " for font family " << aDFA
.GetFamilyName()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("vcl.fonts"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "773" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "using alias names " << aDFA.GetMapNames
() << " for font family " << aDFA.GetFamilyName()
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "using alias names " << aDFA.GetMapNames() <<
" for font family " << aDFA.GetFamilyName(); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.fonts"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "773" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "using alias names " << aDFA.GetMapNames() <<
" for font family " << aDFA.GetFamilyName()) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.fonts"),
("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "773" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "using alias names " << aDFA.GetMapNames
() << " for font family " << aDFA.GetFamilyName()
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "using alias names " << aDFA.GetMapNames() <<
" for font family " << aDFA.GetFamilyName(); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.fonts"), ("/home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx"
":" "773" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
774 }
775#endif
776
777 return aDFA;
778}
779
780namespace vcl
781{
782 const char* getLangBoost()
783 {
784 const char* pLangBoost;
785 const LanguageType eLang = Application::GetSettings().GetUILanguageTag().getLanguageType();
786 if (eLang == LANGUAGE_JAPANESELanguageType(0x0411))
787 pLangBoost = "jan";
788 else if (MsLangId::isKorean(eLang))
789 pLangBoost = "kor";
790 else if (MsLangId::isSimplifiedChinese(eLang))
791 pLangBoost = "zhs";
792 else if (MsLangId::isTraditionalChinese(eLang))
793 pLangBoost = "zht";
794 else
795 pLangBoost = nullptr;
796 return pLangBoost;
797 }
798}
799
800void GenPspGraphics::AnnounceFonts( PhysicalFontCollection* pFontCollection, const psp::FastPrintFontInfo& aInfo )
801{
802 int nQuality = 0;
803
804 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
805 OString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) );
806 int nPos = aFileName.lastIndexOf( '_' );
807 if( nPos == -1 || aFileName[nPos+1] == '.' )
808 nQuality += 5;
809 else
810 {
811 static const char* pLangBoost = nullptr;
812 static bool bOnce = true;
813 if( bOnce )
814 {
815 bOnce = false;
816 pLangBoost = vcl::getLangBoost();
817 }
818
819 if( pLangBoost )
820 if( aFileName.copy( nPos+1, 3 ).equalsIgnoreAsciiCase( pLangBoost ) )
821 nQuality += 10;
822 }
823
824 rtl::Reference<ImplPspFontData> pFD(new ImplPspFontData( aInfo ));
825 pFD->IncreaseQualityBy( nQuality );
826 pFontCollection->Add( pFD.get() );
827}
828
829bool GenPspGraphics::blendBitmap( const SalTwoRect&, const SalBitmap& )
830{
831 return false;
832}
833
834bool GenPspGraphics::blendAlphaBitmap( const SalTwoRect&, const SalBitmap&, const SalBitmap&, const SalBitmap& )
835{
836 return false;
837}
838
839bool GenPspGraphics::drawAlphaBitmap( const SalTwoRect&,
840 const SalBitmap&,
841 const SalBitmap& )
842{
843 return false;
844}
845
846bool GenPspGraphics::drawTransformedBitmap(
847 const basegfx::B2DPoint&,
848 const basegfx::B2DPoint&,
849 const basegfx::B2DPoint&,
850 const SalBitmap&,
851 const SalBitmap*)
852{
853 // here direct support for transformed bitmaps can be implemented
854 return false;
855}
856
857bool GenPspGraphics::drawAlphaRect( long, long, long, long, sal_uInt8 )
858{
859 return false;
860}
861
862SystemGraphicsData GenPspGraphics::GetGraphicsData() const
863{
864 return SystemGraphicsData();
865}
866
867#if ENABLE_CAIRO_CANVAS1
868
869bool GenPspGraphics::SupportsCairo() const
870{
871 return false;
872}
873
874cairo::SurfaceSharedPtr GenPspGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
875{
876 return cairo::SurfaceSharedPtr();
877}
878
879cairo::SurfaceSharedPtr GenPspGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const
880{
881 return cairo::SurfaceSharedPtr();
882}
883
884cairo::SurfaceSharedPtr GenPspGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/, const BitmapSystemData& /*rData*/, const Size& /*rSize*/) const
885{
886 return cairo::SurfaceSharedPtr();
887}
888
889css::uno::Any GenPspGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/, const basegfx::B2ISize& /*rSize*/) const
890{
891 return css::uno::Any();
892}
893
894#endif // ENABLE_CAIRO_CANVAS
895
896bool GenPspGraphics::supportsOperation( OutDevSupportType ) const
897{
898 return false;
899}
900
901void GenPspGraphics::DoFreeEmbedFontData( const void* pData, long nLen )
902{
903 if( pData )
904 munmap( const_cast<void *>(pData), nLen );
905}
906
907const void* GenPspGraphics::DoGetEmbedFontData(psp::fontID aFont, long* pDataLen)
908{
909
910 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
911
912 OString aSysPath = rMgr.getFontFileSysPath( aFont );
913
914 int fd = open( aSysPath.getStr(), O_RDONLY00 );
915 if( fd < 0 )
916 return nullptr;
917 struct stat aStat;
918 if( fstat( fd, &aStat ) )
919 {
920 close( fd );
921 return nullptr;
922 }
923 void* pFile = mmap( nullptr, aStat.st_size, PROT_READ0x1, MAP_SHARED0x01, fd, 0 );
924 close( fd );
925 if( pFile == MAP_FAILED((void *) -1) )
926 return nullptr;
927 *pDataLen = aStat.st_size;
928
929 return pFile;
930}
931
932void GenPspGraphics::FreeEmbedFontData( const void* pData, long nLen )
933{
934 DoFreeEmbedFontData( pData, nLen );
935}
936
937const void* GenPspGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)
938{
939 // in this context the pFont->GetFontId() is a valid PSP
940 // font since they are the only ones left after the PDF
941 // export has filtered its list of subsettable fonts (for
942 // which this method was created). The correct way would
943 // be to have the FreetypeManager search for the PhysicalFontFace pFont
944 psp::fontID aFont = pFont->GetFontId();
945 return DoGetEmbedFontData(aFont, pDataLen);
946}
947
948/* vim:set shiftwidth=4 softtabstop=4 expandtab: */