File: | home/maarten/src/libreoffice/core/vcl/unx/generic/print/genpspgraphics.cxx |
Warning: | line 127, column 13 Value stored to 'nDepth' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | |
55 | using namespace psp; |
56 | |
57 | // ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer --------------- |
58 | |
59 | namespace { |
60 | |
61 | class SalPrinterBmp : public psp::PrinterBmp |
62 | { |
63 | private: |
64 | BitmapBuffer* mpBmpBuffer; |
65 | |
66 | FncGetPixel mpFncGetPixel; |
67 | Scanline mpScanAccess; |
68 | sal_PtrDiff mnScanOffset; |
69 | |
70 | public: |
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 | |
83 | SalPrinterBmp::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 | |
105 | sal_uInt32 |
106 | SalPrinterBmp::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 | |
135 | sal_uInt32 |
136 | SalPrinterBmp::GetPaletteEntryCount () const |
137 | { |
138 | return mpBmpBuffer->maPalette.GetEntryCount (); |
139 | } |
140 | |
141 | sal_uInt32 |
142 | SalPrinterBmp::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 | |
151 | sal_uInt32 |
152 | SalPrinterBmp::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 | |
165 | sal_uInt8 |
166 | SalPrinterBmp::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 | |
180 | sal_uInt8 |
181 | SalPrinterBmp::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 | *******************************************************/ |
195 | GenPspGraphics::GenPspGraphics() |
196 | : m_pJobData( nullptr ), |
197 | m_pPrinterGfx( nullptr ) |
198 | { |
199 | } |
200 | |
201 | void GenPspGraphics::Init(psp::JobData* pJob, psp::PrinterGfx* pGfx) |
202 | { |
203 | m_pJobData = pJob; |
204 | m_pPrinterGfx = pGfx; |
205 | SetLayout( SalLayoutFlags::NONE ); |
206 | } |
207 | |
208 | GenPspGraphics::~GenPspGraphics() |
209 | { |
210 | ReleaseFonts(); |
211 | } |
212 | |
213 | void 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 | |
224 | sal_uInt16 GenPspGraphics::GetBitCount() const |
225 | { |
226 | return m_pPrinterGfx->GetBitCount(); |
227 | } |
228 | |
229 | long GenPspGraphics::GetGraphicsWidth() const |
230 | { |
231 | return 0; |
232 | } |
233 | |
234 | void GenPspGraphics::ResetClipRegion() |
235 | { |
236 | m_pPrinterGfx->ResetClipRegion(); |
237 | } |
238 | |
239 | bool 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 | |
284 | void GenPspGraphics::SetLineColor() |
285 | { |
286 | m_pPrinterGfx->SetLineColor (); |
287 | } |
288 | |
289 | void GenPspGraphics::SetLineColor( Color nColor ) |
290 | { |
291 | psp::PrinterColor aColor (nColor.GetRed(), |
292 | nColor.GetGreen(), |
293 | nColor.GetBlue()); |
294 | m_pPrinterGfx->SetLineColor (aColor); |
295 | } |
296 | |
297 | void GenPspGraphics::SetFillColor() |
298 | { |
299 | m_pPrinterGfx->SetFillColor (); |
300 | } |
301 | |
302 | void GenPspGraphics::SetFillColor( Color nColor ) |
303 | { |
304 | psp::PrinterColor aColor (nColor.GetRed(), |
305 | nColor.GetGreen(), |
306 | nColor.GetBlue()); |
307 | m_pPrinterGfx->SetFillColor (aColor); |
308 | } |
309 | |
310 | void 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 | |
315 | void 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 | |
320 | void 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 | |
325 | void GenPspGraphics::drawPixel( long nX, long nY ) |
326 | { |
327 | m_pPrinterGfx->DrawPixel (Point(nX, nY)); |
328 | } |
329 | |
330 | void 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 | |
338 | void GenPspGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) |
339 | { |
340 | m_pPrinterGfx->DrawLine (Point(nX1, nY1), Point(nX2, nY2)); |
341 | } |
342 | |
343 | void 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 | |
348 | void GenPspGraphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint *pPtAry ) |
349 | { |
350 | m_pPrinterGfx->DrawPolyLine (nPoints, reinterpret_cast<const Point *>(pPtAry)); |
351 | } |
352 | |
353 | void 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 | |
359 | void 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 | |
366 | bool 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 | |
375 | bool 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 | |
390 | bool 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 | |
396 | bool 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 | |
402 | bool 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 | |
412 | void 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 | |
419 | bool 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 | |
424 | void 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 | |
430 | void 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 | |
435 | void 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 | |
450 | void 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 | |
457 | void 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 | |
464 | std::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 | |
470 | Color 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 | |
476 | void 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 | |
481 | namespace { |
482 | |
483 | class ImplPspFontData : public FreetypeFontFace |
484 | { |
485 | private: |
486 | sal_IntPtr mnFontId; |
487 | |
488 | public: |
489 | explicit ImplPspFontData( const psp::FastPrintFontInfo& ); |
490 | virtual sal_IntPtr GetFontId() const override { return mnFontId; } |
491 | }; |
492 | |
493 | } |
494 | |
495 | ImplPspFontData::ImplPspFontData(const psp::FastPrintFontInfo& rInfo) |
496 | : FreetypeFontFace(nullptr, GenPspGraphics::Info2FontAttributes(rInfo)), |
497 | mnFontId( rInfo.m_nID ) |
498 | {} |
499 | |
500 | namespace { |
501 | |
502 | class PspSalLayout : public GenericSalLayout |
503 | { |
504 | public: |
505 | PspSalLayout(psp::PrinterGfx&, LogicalFontInstance &rFontInstance); |
506 | |
507 | void InitFont() const final override; |
508 | |
509 | private: |
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 | |
521 | PspSalLayout::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 | |
533 | void PspSalLayout::InitFont() const |
534 | { |
535 | GenericSalLayout::InitFont(); |
536 | mrPrinterGfx.SetFont(mnFontID, mnFontHeight, mnFontWidth, |
537 | mnOrientation, mbVertical, mbArtItalic, mbArtBold); |
538 | } |
539 | |
540 | void 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 | |
549 | FontCharMapRef GenPspGraphics::GetFontCharMap() const |
550 | { |
551 | if (!m_pFreetypeFont[0]) |
552 | return nullptr; |
553 | |
554 | return m_pFreetypeFont[0]->GetFreetypeFont().GetFontCharMap(); |
555 | } |
556 | |
557 | bool 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 | |
565 | void 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 | |
618 | void GenPspGraphics::SetTextColor( Color nColor ) |
619 | { |
620 | psp::PrinterColor aColor (nColor.GetRed(), |
621 | nColor.GetGreen(), |
622 | nColor.GetBlue()); |
623 | m_pPrinterGfx->SetTextColor (aColor); |
624 | } |
625 | |
626 | bool GenPspGraphics::AddTempDevFont( PhysicalFontCollection*, const OUString&,const OUString& ) |
627 | { |
628 | return false; |
629 | } |
630 | |
631 | bool 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 | |
665 | void 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 | |
680 | void GenPspGraphics::ClearDevFontCache() |
681 | { |
682 | FreetypeManager::get().ClearFontCache(); |
683 | } |
684 | |
685 | void 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 | |
694 | std::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 | |
702 | bool 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 | |
730 | void 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 | |
744 | void 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 | |
753 | FontAttributes 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 | |
780 | namespace 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 | |
800 | void 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 | |
829 | bool GenPspGraphics::blendBitmap( const SalTwoRect&, const SalBitmap& ) |
830 | { |
831 | return false; |
832 | } |
833 | |
834 | bool GenPspGraphics::blendAlphaBitmap( const SalTwoRect&, const SalBitmap&, const SalBitmap&, const SalBitmap& ) |
835 | { |
836 | return false; |
837 | } |
838 | |
839 | bool GenPspGraphics::drawAlphaBitmap( const SalTwoRect&, |
840 | const SalBitmap&, |
841 | const SalBitmap& ) |
842 | { |
843 | return false; |
844 | } |
845 | |
846 | bool 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 | |
857 | bool GenPspGraphics::drawAlphaRect( long, long, long, long, sal_uInt8 ) |
858 | { |
859 | return false; |
860 | } |
861 | |
862 | SystemGraphicsData GenPspGraphics::GetGraphicsData() const |
863 | { |
864 | return SystemGraphicsData(); |
865 | } |
866 | |
867 | #if ENABLE_CAIRO_CANVAS1 |
868 | |
869 | bool GenPspGraphics::SupportsCairo() const |
870 | { |
871 | return false; |
872 | } |
873 | |
874 | cairo::SurfaceSharedPtr GenPspGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const |
875 | { |
876 | return cairo::SurfaceSharedPtr(); |
877 | } |
878 | |
879 | cairo::SurfaceSharedPtr GenPspGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const |
880 | { |
881 | return cairo::SurfaceSharedPtr(); |
882 | } |
883 | |
884 | cairo::SurfaceSharedPtr GenPspGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/, const BitmapSystemData& /*rData*/, const Size& /*rSize*/) const |
885 | { |
886 | return cairo::SurfaceSharedPtr(); |
887 | } |
888 | |
889 | css::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 | |
896 | bool GenPspGraphics::supportsOperation( OutDevSupportType ) const |
897 | { |
898 | return false; |
899 | } |
900 | |
901 | void GenPspGraphics::DoFreeEmbedFontData( const void* pData, long nLen ) |
902 | { |
903 | if( pData ) |
904 | munmap( const_cast<void *>(pData), nLen ); |
905 | } |
906 | |
907 | const 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 | |
932 | void GenPspGraphics::FreeEmbedFontData( const void* pData, long nLen ) |
933 | { |
934 | DoFreeEmbedFontData( pData, nLen ); |
935 | } |
936 | |
937 | const 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: */ |