/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
struct ImplOutDevData; class LogicalFontInstance; struct SystemGraphicsData; class ImplFontCache; class SalGraphics; class Gradient; class Hatch; class BitmapReadAccess; class Image; class TextRectInfo; class FontMetric; class GDIMetaFile; class GfxLink; namespace tools { class Line;
} class LineInfo; class AlphaMask; class FontCharMap; class SalLayout; class VirtualDevice; struct SalTwoRect; class Printer; class VCLXGraphics; class SalLayoutGlyphs;
namespace vcl
{ class ExtOutDevData; class TextLayoutCommon; struct FontCapabilities; class Window; class WindowOutputDevice; namespace font { struct Feature; class PhysicalFontCollection; class PhysicalFontFaceCollection;
}
namespace text { class ImplLayoutArgs; class TextLayoutCache;
}
}
namespace basegfx { class B2DHomMatrix; class B2ISize;
}
namespace com::sun::star::awt { class XGraphics;
}
namespace com::sun::star::rendering { class XCanvas; class XSpriteCanvas;
}
/** * Some things multiple-inherit from VclAbstractDialog and OutputDevice, * so we need to use virtual inheritance to keep the referencing counting * OK.
*/ class SAL_WARN_UNUSED VCL_DLLPUBLIC OutputDevice : publicvirtual VclReferenceBase
{ friendclass Printer; friendclass VirtualDevice; friendclass vcl::Window; friendclass vcl::WindowOutputDevice; friendclass WorkWindow; friendvoid ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight );
mutable SalGraphics* mpGraphics; ///< Graphics context to draw on mutable VclPtr<OutputDevice> mpPrevGraphics; ///< Previous output device in list mutable VclPtr<OutputDevice> mpNextGraphics; ///< Next output device in list
GDIMetaFile* mpMetaFile; mutable rtl::Reference<LogicalFontInstance> mpFontInstance;
rtl::Reference<LogicalFontInstance> mpForcedFallbackInstance; mutable std::unique_ptr<vcl::font::PhysicalFontFaceCollection> mpFontFaceCollection;
std::vector<vcl::State> maOutDevStateStack;
std::unique_ptr<ImplOutDevData> mpOutDevData;
std::vector< VCLXGraphics* >* mpUnoGraphicsList;
vcl::ExtOutDevData* mpExtOutDevData; // The canvas interface for this output device. Is persistent after the first GetCanvas() call mutable css::uno::WeakReference< css::rendering::XCanvas > mxCanvas;
// Used by the canvas module. Despite the name it does not always return true if Cairo is supported. bool SupportsCairo() const; /// Create Surface from given cairo surface
cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const; /// Create surface with given dimensions
cairo::SurfaceSharedPtr CreateSurface(int x, int y, int width, int height) const; /// Create Surface for given bitmap data
cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData& rData, constSize& rSize) const; /// Return native handle for underlying surface
css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const;
SAL_DLLPRIVATE css::uno::Any GetSystemGfxDataAny() const;
/** Acquire a graphics device that the output device uses to draw on.
There is an LRU of OutputDevices that is used to get the graphics. The actual creation of a SalGraphics instance is done via the SalFrame implementation.
However, the SalFrame instance will only return a valid SalGraphics instance if it is not in use or there wasn't one in the first place. When this happens, AcquireGraphics finds the least recently used OutputDevice in a different frame and "steals" it (releases it then starts using it).
If there are no frames to steal an OutputDevice's SalGraphics instance from then it blocks until the graphics is released.
Once it has acquired a graphics instance, then we add the OutputDevice to the LRU.
@returns true if was able to initialize the graphics device, false otherwise.
*/ virtualbool AcquireGraphics() const = 0;
/** Release the graphics device, and remove it from the graphics device list.
@param bRelease Determines whether to release the fonts of the physically released graphics device.
*/ virtualvoid ReleaseGraphics( bool bRelease = true ) = 0; ///@}
/** If this OutputDevice is used for displaying a Print Preview the OutDevViewType should be set to 'OutDevViewType::PrintPreview'.
A View can then make painting decisions dependent on this OutDevViewType. E.g. text colors need to be handled differently, dependent on whether it's a PrintPreview or not. (see #106611# for more)
*/ void SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; }
OutDevViewType GetOutDevViewType() const { return meOutDevViewType; }
/** Perform actual rect clip against outdev dimensions, to generate empty clips whenever one of the values is completely off the device.
@param aRegion region to be clipped to the device dimensions @returns region clipped to the device bounds
**/ virtual vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const; virtualvoid ClipToPaintRegion ( tools::Rectangle& rDstRect );
/// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd void DrawCheckered( const Point& rPos, const Size& rSize,
sal_uInt32 nLen = 8,
Color aStart = COL_WHITE,
Color aEnd = COL_BLACK);
/** Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
*/
SAL_DLLPRIVATE void drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const LineInfo& rInfo ); ///@}
/** @name Polyline functions
*/ ///@{
public:
/** Render the given polygon as a line stroke
The given polygon is stroked with the current LineColor, start and end point are not automatically connected
The given polygon is stroked with the current LineColor, start and end point are not automatically connected. The line is rendered according to the specified LineInfo, e.g. supplying a dash pattern, or a line thickness.
// #i101491# // Helper which holds the old line geometry creation and is extended to use AA when // switched on. Advantage is that line geometry is only temporarily used for paint
SAL_DLLPRIVATE void drawPolyLine(const tools::Polygon& rPoly, const LineInfo& rLineInfo);
The given polygon is stroked with the current LineColor, and filled with the current FillColor. If one of these colors are transparent, the corresponding stroke or fill stays invisible. Start and end point of the polygon are automatically connected.
The given poly-polygon is stroked with the current LineColor, and filled with the current FillColor. If one of these colors are transparent, the corresponding stroke or fill stays invisible. Start and end points of the contained polygons are automatically connected.
The text is then drawn exactly from rRect.TopLeft() to rRect.BottomRight(), don't assume that rRect.TopLeft() is [0, 0].
Please note that you don't always want to use GetTextBoundRect(); in many cases you actually want to use GetTextHeight(), because GetTextBoundRect() gives you the exact bounding rectangle regardless what is the baseline of the text.
Code snippet to get just exactly the text (no filling around that) as a bitmap via a VirtualDevice (regardless what is the baseline):
// exactly only the text, regardless of the baseline Bitmap aBitmap(aDevice.GetBitmap(aRect.TopLeft(), aRect.GetSize())); </code>
Code snippet to get the text as a bitmap via a Virtual device that contains even the filling so that the baseline is always preserved (ie. the text will not jump up and down according to whether it contains 'y' or not etc.)
<code> VirtualDevice aDevice; // + the appropriate font / device setup, see above
This method splits up the text rect into multiple MetaTextActions, one for each line of text. This is comparable to AddGradientActions(), which splits up a gradient into its constituent polygons. Parameter semantics fully compatible to DrawText().
*/ void AddTextRectActions( const tools::Rectangle& rRect, const OUString& rOrigStr,
DrawTextFlags nStyle,
GDIMetaFile& rMtf );
/** Height where any character of the current font fits; in logic coordinates.
See also GetTextBoundRect() for more explanation + code examples.
*/
tools::Long GetTextHeight() const; double GetTextHeightDouble() const; float approximate_digit_width() const;
// tdf#163105: Get map of valid kashida positions for a single word void GetWordKashidaPositions(const OUString& rText, std::vector<bool>* pOutMap) const;
//drop font data for all outputdevices. //If bNewFontLists is true then empty lists of system fonts staticvoid ImplClearAllFontData( bool bNewFontLists ); //fetch font data for all outputdevices //If bNewFontLists is true then fetch lists of system fonts staticvoid ImplRefreshAllFontData( bool bNewFontLists ); //drop and fetch font data for all outputdevices //If bNewFontLists is true then drop and refetch lists of system fonts
SAL_DLLPRIVATE staticvoid ImplUpdateAllFontData( bool bNewFontLists );
/* These functions allow collecting information on how fonts are mapped when used, such as what replacements are used when a requested font is missing or which fonts are used as fallbacks when a font doesn't provide all necessary glyphs. After StartTrackingFontMappingUse() is called, VCL starts collecting font usage for all text layout calls, FinishTrackingFontMappingUse() will stop collecting and providing the collected information. Each item is a mapping from a requested font to a list of actually used fonts and the number of times this mapping was done.
*/ struct FontMappingUseItem
{
OUString mOriginalFont;
std::vector<OUString> mUsedFonts; int mCount;
}; typedef std::vector<FontMappingUseItem> FontMappingUseData; staticvoid StartTrackingFontMappingUse(); static FontMappingUseData FinishTrackingFontMappingUse();
// Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphicsLayout virtualvoid EnableRTL( bool bEnable = true); bool IsRTLEnabled() const { return mbEnableRTL; }
@param rTransformation The transformation describing the target positioning of the given bitmap. Transforming the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to discrete coordinates
@param rBitmapEx The BitmapEx to be painted
@param fAlpha Optional additional alpha to use for drawing (0 to 1, 1 being no change).
*/ void DrawTransformedBitmapEx( const basegfx::B2DHomMatrix& rTransformation, const BitmapEx& rBitmapEx, double fAlpha = 1.0);
/** Return true if DrawTransformedBitmapEx() is fast.
@param aFullTransform The B2DHomMatrix used for the transformation @param rBitmapEx Reference to the bitmap to be transformed and drawn
@return true if it was able to draw the bitmap, false if not
*/ virtualbool DrawTransformBitmapExDirect( const basegfx::B2DHomMatrix& aFullTransform, const BitmapEx& rBitmapEx, double fAlpha = 1.0);
/** Transform and reduce the area that needs to be drawn of the bitmap and return the new visible range and the maximum area.
@param aFullTransform B2DHomMatrix used for transformation @param aVisibleRange The new visible area of the bitmap @param fMaximumArea The maximum area of the bitmap
@returns true if there is an area to be drawn, otherwise nothing is left to be drawn so return false
*/ virtualbool TransformAndReduceBitmapExToTargetRange( const basegfx::B2DHomMatrix& aFullTransform,
basegfx::B2DRange &aVisibleRange, double &fMaximumArea);
/** helper method removing transparencies from a metafile (e.g. for printing)
@returns true: transparencies were removed false: output metafile is unchanged input metafile
@attention this is a member method, so current state can influence the result ! @attention the output metafile is prepared in pixel mode for the currentOutputDevice state. It can not be moved or rotated reliably anymore.
*/ bool RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf,
tools::Long nMaxBmpDPIX, tools::Long nMaxBmpDPIY, bool bReduceTransparency, bool bTransparencyAutoMode, bool bDownsampleBitmaps, const Color& rBackground = COL_TRANSPARENT );
This method offsets every drawing operation that converts its coordinates to pixel by the given value. Normally, the effect can be achieved by setting a MapMode with a different origin. Unfortunately, this origin is in logical coordinates and can lead to rounding errors (see #102532# for details).
@attention This offset is only applied when converting to pixel, i.e. some output modes such as metafile recordings might be completely unaffected by this method! Use with care. Furthermore, if the OutputDevice's MapMode is the default (that's MapUnit::MapPixel), then any pixel offset set is ignored also. This might be unintuitive for cases, but would have been far more fragile to implement. What's more, the reason why the pixel offset was introduced (avoiding rounding errors) does not apply for MapUnit::MapPixel, because one can always use the MapMode origin then.
@param rOffset The offset in pixel
*/ void SetPixelOffset( const Size& rOffset );
/** Get the offset in pixel
@see OutputDevice::SetPixelOffset for details
@return the current offset in pixel
*/
SAL_WARN_UNUSED_RESULT Size GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY);}
// create a mapping transformation from rMapModeSource to rMapModeDest (the above methods // for B2DPoly/Polygons use this internally anyway to transform the B2DPolygon)
SAL_WARN_UNUSED_RESULT static basegfx::B2DHomMatrix LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest);
/** Convert a logical rectangle to a rectangle in physical device pixel units.
@param rLogicRect Const reference to a rectangle in logical units
@returns Rectangle based on physical device pixel coordinates and units.
*/
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel( const tools::Rectangle& rLogicRect ) const;
/** Convert a logical point to a physical point on the device.
@param rLogicPt Const reference to a point in logical units.
@returns Physical point on the device.
*/
SAL_DLLPRIVATE Point ImplLogicToDevicePixel( const Point& rLogicPt ) const;
SAL_DLLPRIVATE basegfx::B2DPoint ImplLogicToDeviceSubPixel(const Point& rLogicPt) const;
/** Convert a logical width to a width in units of device pixels.
To get the number of device pixels, it must calculate the X-DPI of the device and the map scaling factor. If there is no mapping, then it just returns the width as nothing more needs to be done.
@param nWidth Logical width
@returns Width in units of device pixels.
*/
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel( tools::Long nWidth ) const;
SAL_DLLPRIVATE double ImplLogicWidthToDeviceSubPixel(tools::Long nWidth) const;
/** Convert a logical height to a height in units of device pixels.
To get the number of device pixels, it must calculate the Y-DPI of the device and the map scaling factor. If there is no mapping, then it just returns the height as nothing more needs to be done.
@param nHeight Logical height
@returns Height in units of device pixels.
*/
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel( tools::Long nHeight ) const;
SAL_DLLPRIVATE double ImplLogicHeightToDeviceSubPixel(tools::Long nHeight) const;
SAL_DLLPRIVATE Point SubPixelToLogic(const basegfx::B2DPoint& rDevicePt) const;
/** Convert device pixels to a width in logical units.
To get the logical width, it must calculate the X-DPI of the device and the map scaling factor.
/** Convert a logical size to the size on the physical device.
@param rLogicSize Const reference to a size in logical units
@returns Physical size on the device.
*/
SAL_DLLPRIVATE Size ImplLogicToDevicePixel( const Size& rLogicSize ) const;
/** Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords.
@param rPixelRect Const reference to rectangle in logical units and coords.
@returns Rectangle based on logical coordinates and units.
*/
SAL_DLLPRIVATE tools::Rectangle ImplDevicePixelToLogic( const tools::Rectangle& rPixelRect ) const;
/** Convert a logical polygon to a polygon in physical device pixel units.
@param rLogicPoly Const reference to a polygon in logical units
@returns Polygon based on physical device pixel coordinates and units.
*/
SAL_DLLPRIVATE tools::Polygon ImplLogicToDevicePixel( const tools::Polygon& rLogicPoly ) const;
/** Convert a logical B2DPolygon to a B2DPolygon in physical device pixel units.
@param rLogicSize Const reference to a B2DPolygon in logical units
@returns B2DPolyPolygon based on physical device pixel coordinates and units.
*/
SAL_DLLPRIVATE ::basegfx::B2DPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolygon& rLogicPoly ) const;
/** Convert a logical polypolygon to a polypolygon in physical device pixel units.
@param rLogicPolyPoly Const reference to a polypolygon in logical units
@returns Polypolygon based on physical device pixel coordinates and units.
*/
SAL_DLLPRIVATE tools::PolyPolygon ImplLogicToDevicePixel( const tools::PolyPolygon& rLogicPolyPoly ) const;
/** Convert a line in logical units to a line in physical device pixel units.
@param rLineInfo Const reference to a line in logical units
@returns Line based on physical device pixel coordinates and units.
*/
SAL_DLLPRIVATE LineInfo ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const;
/** Convert a region in pixel units to a region in device pixel units and coords.
@param rRegion Const reference to region.
@returns vcl::Region based on device pixel coordinates and units.
*/
SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel( const vcl::Region& rRegion ) const;
private: /** Convert a logical X coordinate to a device pixel's X coordinate.
To get the device's X coordinate, it must calculate the mapping offset coordinate X position (if there is one - if not then it just adds the pseudo-window offset to the logical X coordinate), the X-DPI of the device and the mapping's X scaling factor.
/** Convert a logical Y coordinate to a device pixel's Y coordinate.
To get the device's Y coordinate, it must calculate the mapping offset coordinate Y position (if there is one - if not then it just adds the pseudo-window offset to the logical Y coordinate), the Y-DPI of the device and the mapping's Y scaling factor.
@param nY Logical Y coordinate
@returns Device's Y pixel coordinate
*/
SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel( tools::Long nY ) const;
These all just call through to the private mpGraphics functions of the same name.
*/ ///@{
public:
/** Determine if native widgets can be enabled
*/ virtualbool CanEnableNativeWidget() const { returnfalse; }
/** Query the platform layer for control support
*/ bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) const;
/** Query the native control to determine if it was acted upon
*/
SAL_DLLPRIVATE bool HitTestNativeScrollbar(
ControlPart nPart, const tools::Rectangle& rControlRegion, const Point& aPos, bool& rIsInside ) const;
/** Request rendering of a particular control and/or part
*/ bool DrawNativeControl(
ControlType nType,
ControlPart nPart, const tools::Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& aValue, const OUString& aCaption, const Color& rBackgroundColor = COL_AUTO );
/** @returns boolean value to see if EPS could be painted directly. Theoretically, handing over a matrix would be needed to handle painting rotated EPS files (e.g. contained in Metafiles). This would then need to be supported for Mac and PS printers, but
that's too much for now, wrote \#i107046# for this */ bool DrawEPS( const Point& rPt, const Size& rSz, const GfxLink& rGfxLink, GDIMetaFile* pSubst = nullptr ); ///@}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.