21#include <osl/diagnose.h>
28#include <rtl/tencinfo.h>
45#define W_META_SETBKMODE 0x0102
46#define W_META_SETROP2 0x0104
47#define W_META_SETSTRETCHBLTMODE 0x0107
48#define W_META_SETTEXTCOLOR 0x0209
49#define W_META_SETWINDOWORG 0x020B
50#define W_META_SETWINDOWEXT 0x020C
51#define W_META_LINETO 0x0213
52#define W_META_MOVETO 0x0214
53#define W_META_INTERSECTCLIPRECT 0x0416
54#define W_META_ARC 0x0817
55#define W_META_ELLIPSE 0x0418
56#define W_META_PIE 0x081A
57#define W_META_RECTANGLE 0x041B
58#define W_META_ROUNDRECT 0x061C
59#define W_META_SAVEDC 0x001E
60#define W_META_SETPIXEL 0x041F
61#define W_META_TEXTOUT 0x0521
62#define W_META_POLYGON 0x0324
63#define W_META_POLYLINE 0x0325
64#define W_META_ESCAPE 0x0626
65#define W_META_RESTOREDC 0x0127
66#define W_META_SELECTOBJECT 0x012D
67#define W_META_SETTEXTALIGN 0x012E
68#define W_META_CHORD 0x0830
69#define W_META_EXTTEXTOUT 0x0a32
70#define W_META_POLYPOLYGON 0x0538
71#define W_META_STRETCHDIB 0x0f43
72#define W_META_DELETEOBJECT 0x01f0
73#define W_META_CREATEPENINDIRECT 0x02FA
74#define W_META_CREATEFONTINDIRECT 0x02FB
75#define W_META_CREATEBRUSHINDIRECT 0x02FC
77#define W_TRANSPARENT 1
82#define W_R2_COPYPEN 13
84#define W_TA_NOUPDATECP 0x0000
85#define W_TA_LEFT 0x0000
86#define W_TA_RIGHT 0x0002
87#define W_TA_TOP 0x0000
88#define W_TA_BOTTOM 0x0008
89#define W_TA_BASELINE 0x0018
90#define W_TA_RTLREADING 0x0100
92#define W_SRCCOPY 0x00CC0020L
93#define W_SRCPAINT 0x00EE0086L
94#define W_SRCAND 0x008800C6L
95#define W_SRCINVERT 0x00660046L
96#define W_DSTINVERT 0x00550009L
101#define W_PS_DASHDOT 3
102#define W_PS_DASHDOTDOT 4
105#define W_LF_FACESIZE 32
107#define W_ANSI_CHARSET 0
109#define W_DEFAULT_PITCH 0x00
110#define W_FIXED_PITCH 0x01
111#define W_VARIABLE_PITCH 0x02
113#define W_FF_DONTCARE 0x00
114#define W_FF_ROMAN 0x10
115#define W_FF_SWISS 0x20
116#define W_FF_MODERN 0x30
117#define W_FF_SCRIPT 0x40
118#define W_FF_DECORATIVE 0x50
120#define W_FW_DONTCARE 0
122#define W_FW_LIGHT 300
123#define W_FW_NORMAL 400
124#define W_FW_MEDIUM 500
125#define W_FW_SEMIBOLD 600
127#define W_FW_ULTRALIGHT 200
128#define W_FW_ULTRABOLD 800
129#define W_FW_BLACK 900
134#define W_MFCOMMENT 15
136#define PRIVATE_ESCAPE_UNICODE 2
143 , nMetafileHeaderPos(0)
148 , pAttrStack(nullptr)
157 , nNumberOfActions(0)
158 , nNumberOfBitmaps(0)
161 , nActBitmapPercent(0)
184 if( nPercent <= 100 )
191 size_t nAction, nActionCount;
195 for ( nAction=0; nAction < nActionCount; nAction++ )
269 if ((nSize & 1)!=0) {
311 sal_uInt16 nWeight,
i;
337 rtl_TextEncoding eFontNameEncoding = rFont.
GetCharSet();
338 sal_uInt8 nCharSet = rtl_getBestWindowsCharsetFromTextEncoding( eFontNameEncoding );
339 if ( eFontNameEncoding == RTL_TEXTENCODING_SYMBOL )
340 eFontNameEncoding = RTL_TEXTENCODING_MS_1252;
365 char nChar = (
i < aFontName.getLength() ) ? aFontName[
i] : 0;
375 switch( rLineInfo.GetStyle() )
379 if ( rLineInfo.GetDotCount() )
381 if ( !rLineInfo.GetDashCount() )
385 if ( rLineInfo.GetDotCount() == 1 )
422 sal_uInt32 nTmp = OSL_SWAPDWORD( nEsc );
423 sal_uInt32 nCheckSum = rtl_crc32( 0, &nTmp, 4 );
425 sal_uInt32 nCheckSum = rtl_crc32( 0, &nEsc, 4 );
428 nCheckSum = rtl_crc32( nCheckSum,
pData, nLen );
447 bool bEscapeUsed =
false;
449 sal_uInt32
i, nStringLen = rUniStr.getLength();
458 OUString aUniStr2(OStringToOUString(aByteStr, aTextEncodingOrg));
459 const sal_Unicode* pConversion = aUniStr2.getStr();
460 for (
i = 0;
i < nStringLen;
i++ )
462 if ( *pBuf++ != *pConversion++ )
466 if (
i != nStringLen )
468 pBuf = rUniStr.getStr();
471 if (aTextEncoding == RTL_TEXTENCODING_DONTKNOW) {
472 aTextEncoding = aTextEncodingOrg;
474 for (
i = 1;
i < nStringLen;
i++)
476 if (aTextEncoding != aTextEncodingOrg)
480 if (aTextEncoding == RTL_TEXTENCODING_DONTKNOW) {
481 aTextEncoding = aTextEncodingOrg;
486 aUniStr2 = OStringToOUString(aByteStr, aTextEncoding);
487 pConversion = aUniStr2.getStr();
488 for (
i = 0;
i < nStringLen;
i++ )
490 if ( *pBuf++ != *pConversion++ )
509 std::vector<tools::PolyPolygon> aPolyPolyVec;
512 sal_uInt32 nDXCount = !pDXAry.
empty() ? nStringLen : 0;
513 sal_uInt32 nSkipActions = aPolyPolyVec.size();
514 sal_Int32 nStrmLen = 8 +
515 +
sizeof( nStringLen ) + ( nStringLen * 2 )
516 +
sizeof( nDXCount ) + ( nDXCount * 4 )
517 +
sizeof( nSkipActions );
524 for (
i = 0;
i < nStringLen;
i++ )
527 for (
i = 0;
i < nDXCount;
i++ )
532 for (
const auto& rPolyPoly : aPolyPolyVec )
535 aPolyPoly.
Move( rPoint.
X(), rPoint.
Y() );
549 std::u16string_view rString,
552 sal_Int32 nOriginalTextLen = rString.size();
554 if ( (nOriginalTextLen <= 1) || pDXAry.
empty() )
569 sal_uInt16 nNewTextLen =
static_cast<sal_uInt16
>(rByteString.getLength());
572 if ( nNewTextLen & 1 )
575 sal_Int32 nOriginalTextLen = rString.size();
576 std::unique_ptr<sal_Int16[]> pConvertedDXAry(
new sal_Int16[ nOriginalTextLen ]);
578 pConvertedDXAry[ j++ ] =
static_cast<sal_Int16
>(
ScaleWidth( pDXAry[ 0 ] ));
579 for (sal_Int32
i = 1;
i < ( nOriginalTextLen - 1 ); ++
i)
580 pConvertedDXAry[ j++ ] =
static_cast<sal_Int16
>(
ScaleWidth( pDXAry[
i ] - pDXAry[
i - 1 ] ));
581 pConvertedDXAry[ j ] =
static_cast<sal_Int16
>(
ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) ));
583 for (sal_Int32
i = 0;
i < nOriginalTextLen; ++
i)
585 sal_Int16 nDx = pConvertedDXAry[
i ];
587 if ( nOriginalTextLen < nNewTextLen )
591 j = aTemp.getLength();
596 pConvertedDXAry.reset();
627 const sal_uInt16 nSize = aSimplePoly.
GetSize();
630 for (sal_uInt16
i=0;
i<nSize; ++
i)
641 const sal_uInt16 nSize = aSimplePoly.
GetSize();
644 for (sal_uInt16
i=0;
i<nSize; ++
i)
657 if ( aSimplePolyPoly[
i ].HasFlags() )
661 aSimplePolyPoly[
i ] = aSimplePoly;
742 switch (eFontAlign) {
747 nAlign|=eHorTextAlign;
773 const Bitmap & rBitmap, sal_uInt32 nROP )
839 sal_Int32 nLen = rString.getLength();
872 sal_uInt16 nOldHandle;
886 sal_uInt16 nOldHandle;
900 sal_uInt16 nOldHandle;
955 if ( ( xFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 )
968 if(!rLinePolygon.
count())
974 rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon);
976 if(aLinePolyPolygon.
count())
981 for(
auto const& rB2DPolygon : std::as_const(aLinePolyPolygon))
987 if(!aFillPolyPolygon.
count())
997 for(
auto const& rB2DPolygon : std::as_const(aFillPolyPolygon))
1016 for(
size_t nA = 0; nA < nACount; nA++ )
1160 OUString aTemp( pA->
GetText() );
1199 const sal_Int32 nLen = aTemp.getLength();
1202 if (nLen && nNormSize == 0)
1204 OSL_FAIL(
"Impossible div by 0 action: MetaStretchTextAction!");
1208 for ( sal_Int32
i = 0;
i < ( nLen - 1 );
i++ )
1209 aDXAry.
set(
i, aDXAry[
i] *
static_cast<sal_Int32
>(pA->
GetWidth()) / nNormSize);
1210 if ( ( nLen <= 1 ) || (
static_cast<sal_Int32
>(pA->
GetWidth()) == nNormSize ) )
1403 if( aOrigin.
X() >= 0 )
1417 if( aOrigin.
Y() >= 0 )
1564 const double fScaleX = aSrcSize.
Width() ?
static_cast<double>(aDestSize.
Width()) / aSrcSize.
Width() : 1.0;
1565 const double fScaleY = aSrcSize.
Height() ?
static_cast<double>(aDestSize.
Height()) / aSrcSize.
Height() : 1.0;
1571 if( fScaleX != 1.0 || fScaleY != 1.0 )
1573 aTmpMtf.
Scale( fScaleX, fScaleY );
1578 nMoveX = aDestPt.
X() - aSrcPt.
X();
1579 nMoveY = aDestPt.
Y() - aSrcPt.
Y();
1581 if( nMoveX || nMoveY )
1582 aTmpMtf.
Move( nMoveX, nMoveY );
1629 sal_uInt16 nCheckSum,
nValue;
1631 sal_uInt16 nUnitsPerInch =
static_cast<sal_uInt16
>( ( aSize.
Width() + aSize.
Height() ) >> 1 );
1660 sal_uInt32 nFileSize;
1664 if ((nFileSize&1)!=0) {
1695 auto it =
aMap.find(
"EmbedEMF");
1696 if (it !=
aMap.end())
1703 pWMF=&rTargetStream;
1804 const Size& rPrefSize)
1807 sal_uInt16 nDivisor = 1;
1811 while( nDivisor <= 64 && (aSize.
Width() > 32767 || aSize.
Height() > 32767) )
1835 sal_uInt64
const nTotalSize = aStream.
Tell();
1839 sal_uInt32 nRemainingSize =
static_cast< sal_uInt32
>( nTotalSize );
1840 sal_uInt32 nRecCounts = ( (nTotalSize - 1) / 0x2000 ) + 1;
1841 sal_uInt16 nCheckSum = 0, nWord;
1843 sal_uInt32
nPos = 0;
1845 while(
nPos + 1 < nTotalSize )
1852 nCheckSum =
static_cast< sal_uInt16
>( nCheckSum * -1 );
1855 while( nRemainingSize > 0 )
1857 sal_uInt32 nCurSize;
1858 if( nRemainingSize > 0x2000 )
1861 nRemainingSize -= 0x2000;
1865 nCurSize = nRemainingSize;
1880 sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum )
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
bool Replace(const AlphaMask &rAlpha, const Color &rMergeColor)
Merge bitmap with given background color according to specified alpha mask.
Size GetSizePixel() const
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
bool WriteEMF(const GDIMetaFile &rMtf)
css::uno::Reference< css::task::XStatusIndicator > GetStatusIndicator() const
const css::uno::Sequence< css::beans::PropertyValue > & GetFilterData() const
sal_Int32 GetNumerator() const
sal_Int32 GetDenominator() const
void AddGradientActions(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile)
void set(size_t nIndex, sal_Int32 nValue)
void SetOrigin(const Point &rOrigin)
void SetScaleY(const Fraction &rScaleY)
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Point & GetOrigin() const
const Fraction & GetScaleY() const
void SetScaleX(const Fraction &rScaleX)
sal_uInt32 GetWidth() const
sal_Int32 GetIndex() const
const OUString & GetText() const
const Point & GetPoint() const
const Point & GetPoint() const
const OUString & GetText() const
sal_Int32 GetIndex() const
TextAlign GetTextAlign() const
sal_Int32 GetIndex() const
const KernArray & GetDXArray() const
const OUString & GetText() const
const Point & GetPoint() const
const Color & GetColor() const
const Color & GetColor() const
const tools::Rectangle & GetRect() const
const OUString & GetText() const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
void AddHatchActions(const tools::PolyPolygon &rPolyPoly, const Hatch &rHatch, GDIMetaFile &rMtf)
bool GetFontCharMap(FontCharMapRef &rxFontCharMap) const
tools::Long GetTextArray(const OUString &rStr, KernArray *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, bool bCaret=false, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
bool GetTextOutlines(PolyPolyVector &, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}) const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvStream & WriteInt32(sal_Int32 nInt32)
void SetEndian(SvStreamEndian SvStreamEndian)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteChar(char nChar)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
void WriteRecords(const GDIMetaFile &rMTF)
sal_uInt16 nDstFontHandle
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
void HandleLineInfoPolyPolygons(const LineInfo &rInfo, const basegfx::B2DPolygon &rLinePolygon)
void WMFRecord_LineTo(const Point &rPoint)
void WMFRecord_StretchDIB(const Point &rPoint, const Size &rSize, const Bitmap &rBitmap, sal_uInt32 nROP=0)
void WMFRecord_CreatePenIndirect(const Color &rColor, const LineInfo &rLineInfo)
void WMFRecord_SetBkMode(bool bTransparent)
void WriteEMFRecord(SvMemoryStream &rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize, sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum)
sal_uLong nWrittenBitmaps
bool bHandleAllocated[MAXOBJECTHANDLES]
void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
void WritePointXY(const Point &rPoint)
void WMFRecord_SetWindowExt(const Size &rSize)
void WriteHeader(bool bPlaceable)
void CreateSelectDeleteBrush(const Color &rColor)
void WMFRecord_CreateFontIndirect(const vcl::Font &rFont)
void WMFRecord_ExtTextOut(const Point &rPoint, std::u16string_view rString, KernArraySpan pDXAry)
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
sal_uLong nWrittenActions
void WMFRecord_SetWindowOrg(const Point &rPoint)
void UpdateRecordHeader()
void WMFRecord_RoundRect(const tools::Rectangle &rRect, tools::Long nHorzRound, tools::Long nVertRound)
sal_uInt16 eSrcHorTextAlign
void WMFRecord_Chord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
sal_uLong nNumberOfBitmaps
sal_uLong nMetafileHeaderPos
VclPtr< VirtualDevice > pVirDev
void SetLineAndFillAttr()
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, KernArraySpan pDXAry)
void CreateSelectDeleteFont(const vcl::Font &rFont)
void WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorTextAlign)
void WMFRecord_TextOut(const Point &rPoint, std::u16string_view rString)
vcl::Region aSrcClipRegion
vcl::Region aDstClipRegion
void WMFRecord_SetPixel(const Point &rPoint, const Color &rColor)
void CreateSelectDeletePen(const Color &rColor, const LineInfo &rLineInfo)
void WMFRecord_MoveTo(const Point &rPoint)
void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle)
void WMFRecord_SetStretchBltMode()
void WriteHeightWidth(const Size &rSize)
sal_uLong nActBitmapPercent
void WriteSize(const Size &rSize)
sal_uLong nNumberOfActions
void WMFRecord_SetROP2(RasterOp eROP)
void WMFRecord_Pie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
void WMFRecord_RestoreDC()
void WMFRecord_IntersectClipRect(const tools::Rectangle &rRect)
void WMFRecord_Arc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
void WriteColor(const Color &rColor)
void WMFRecord_Rectangle(const tools::Rectangle &rRect)
void TrueTextOut(const Point &rPoint, const OString &rString)
void FreeHandle(sal_uInt16 nObjectHandle)
void TrueExtTextOut(const Point &rPoint, std::u16string_view rString, const OString &rByteString, KernArraySpan pDXAry)
void WMFRecord_Polygon(const tools::Polygon &rPoly)
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
void WMFRecord_PolyPolygon(const tools::PolyPolygon &rPolyPoly)
void WriteRectangle(const tools::Rectangle &rRect)
sal_uInt32 nMaxRecordSize
void WritePointYX(const Point &rPoint)
void WMFRecord_CreateBrushIndirect(const Color &rColor)
sal_uInt16 eDstHorTextAlign
void WMFRecord_SetTextColor(const Color &rColor)
void CountActionsAndBitmaps(const GDIMetaFile &rMTF)
sal_Int32 ScaleWidth(sal_Int32 nDX)
sal_uInt16 nDstBrushHandle
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
WMFWriterAttrStackMember * pAttrStack
void WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
const Color & GetColor() const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
FontFamily GetFamilyType()
void SetFillColor(const Color &)
void SetColor(const Color &)
FontStrikeout GetStrikeout() const
const OUString & GetFamilyName() const
TextAlign GetAlignment() const
void SetCharSet(rtl_TextEncoding)
const Size & GetFontSize() const
const Color & GetColor() const
void SetAlignment(TextAlign)
FontLineStyle GetUnderline() const
rtl_TextEncoding GetCharSet() const
Degree10 GetOrientation() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
UNOTOOLS_DLLPUBLIC bool IsOpenSymbol(std::u16string_view rFontName)
tools::Long FRound(double fVal)
std::unique_ptr< sal_Int32[]> pData
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
HashMap_OWString_Interface aMap
std::size_t write_uInt8s_FromOString(SvStream &rStrm, std::string_view rStr, std::size_t nUnits)
TOOLS_DLLPUBLIC std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream &rStrm, std::string_view rStr)
struct WMFWriterAttrStackMember * pSucc
UNDERLYING_TYPE get() const
TOOLS_DLLPUBLIC rtl_TextEncoding getBestMSEncodingByChar(sal_Unicode c)
TOOLS_DLLPUBLIC rtl_TextEncoding GetExtendedTextEncoding(rtl_TextEncoding eEncoding)
#define PRIVATE_ESCAPE_UNICODE
#define W_META_SELECTOBJECT
#define W_META_EXTTEXTOUT
#define W_META_SETTEXTALIGN
#define W_META_SETSTRETCHBLTMODE
#define W_META_POLYPOLYGON
#define W_META_CREATEPENINDIRECT
#define W_META_SETWINDOWEXT
#define W_META_SETTEXTCOLOR
#define W_META_SETWINDOWORG
#define W_META_CREATEFONTINDIRECT
#define W_META_DELETEOBJECT
#define W_META_STRETCHDIB
#define W_META_CREATEBRUSHINDIRECT
#define W_META_INTERSECTCLIPRECT