20#include <osl/thread.h>
41enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
47#define BegDocumnMagic 0xA8A8
48#define EndDocumnMagic 0xA8A9
50#define BegResGrpMagic 0xC6A8
51#define EndResGrpMagic 0xC6A9
53#define BegColAtrMagic 0x77A8
54#define EndColAtrMagic 0x77A9
55#define BlkColAtrMagic 0x77B0
56#define MapColAtrMagic 0x77AB
58#define BegImgObjMagic 0xFBA8
59#define EndImgObjMagic 0xFBA9
60#define DscImgObjMagic 0xFBA6
61#define DatImgObjMagic 0xFBEE
63#define BegObEnv1Magic 0xC7A8
64#define EndObEnv1Magic 0xC7A9
66#define BegGrfObjMagic 0xBBA8
67#define EndGrfObjMagic 0xBBA9
68#define DscGrfObjMagic 0xBBA6
69#define DatGrfObjMagic 0xBBEE
71#define MapCodFntMagic 0x8AAB
72#define MapDatResMagic 0xC3AB
76#define GOrdGivArc 0xC6
77#define GOrdCurArc 0x86
78#define GOrdGivBzr 0xE5
79#define GOrdCurBzr 0xA5
80#define GOrdGivBox 0xC0
81#define GOrdCurBox 0x80
82#define GOrdGivFil 0xC5
83#define GOrdCurFil 0x85
84#define GOrdGivCrc 0xC7
85#define GOrdCurCrc 0x87
86#define GOrdGivLin 0xC1
87#define GOrdCurLin 0x81
88#define GOrdGivMrk 0xC2
89#define GOrdCurMrk 0x82
90#define GOrdGivArP 0xE3
91#define GOrdCurArP 0xA3
92#define GOrdGivRLn 0xE1
93#define GOrdCurRLn 0xA1
94#define GOrdGivSFl 0xE4
95#define GOrdCurSFl 0xA4
97#define GOrdGivStM 0xF1
98#define GOrdCurStM 0xB1
99#define GOrdGivStr 0xC3
100#define GOrdCurStr 0x83
101#define GOrdGivStx 0xFEF0
102#define GOrdCurStx 0xFEB0
104#define GOrdGivImg 0xD1
105#define GOrdCurImg 0x91
106#define GOrdImgDat 0x92
107#define GOrdEndImg 0x93
108#define GOrdBegAra 0x68
109#define GOrdEndAra 0x60
110#define GOrdBegElm 0xD2
111#define GOrdEndElm 0x49
113#define GOrdBegPth 0xD0
114#define GOrdEndPth 0x7F
115#define GOrdFilPth 0xD7
116#define GOrdModPth 0xD8
117#define GOrdOutPth 0xD4
118#define GOrdSClPth 0xB4
120#define GOrdNopNop 0x00
121#define GOrdRemark 0x01
122#define GOrdSegLab 0xD3
123#define GOrdBitBlt 0xD6
124#define GOrdCalSeg 0x07
125#define GOrdSSgBnd 0x32
126#define GOrdSegChr 0x04
127#define GOrdCloFig 0x7D
128#define GOrdEndSym 0xFF
129#define GOrdEndPlg 0x3E
130#define GOrdEscape 0xD5
131#define GOrdExtEsc 0xFED5
132#define GOrdPolygn 0xF3
134#define GOrdStkPop 0x3F
136#define GOrdSIvAtr 0x14
137#define GOrdPIvAtr 0x54
138#define GOrdSColor 0x0A
139#define GOrdPColor 0x4A
140#define GOrdSIxCol 0xA6
141#define GOrdPIxCol 0xE6
142#define GOrdSXtCol 0x26
143#define GOrdPXtCol 0x66
144#define GOrdSBgCol 0x25
145#define GOrdPBgCol 0x65
146#define GOrdSBxCol 0xA7
147#define GOrdPBxCol 0xE7
148#define GOrdSMixMd 0x0C
149#define GOrdPMixMd 0x4C
150#define GOrdSBgMix 0x0D
151#define GOrdPBgMix 0x4D
153#define GOrdSPtSet 0x08
154#define GOrdPPtSet 0x48
155#define GOrdSPtSym 0x28
156#define GOrdPPtSym 0x09
157#define GOrdSPtRef 0xA0
158#define GOrdPPtRef 0xE0
160#define GOrdSLnEnd 0x1A
161#define GOrdPLnEnd 0x5A
162#define GOrdSLnJoi 0x1B
163#define GOrdPLnJoi 0x5B
164#define GOrdSLnTyp 0x18
165#define GOrdPLnTyp 0x58
166#define GOrdSLnWdt 0x19
167#define GOrdPLnWdt 0x59
168#define GOrdSFrLWd 0x11
169#define GOrdPFrLWd 0x51
170#define GOrdSStLWd 0x15
171#define GOrdPStLWd 0x55
173#define GOrdSChDir 0x3A
174#define GOrdPChDir 0x7A
175#define GOrdSChPrc 0x39
176#define GOrdPChPrc 0x79
177#define GOrdSChSet 0x38
178#define GOrdPChSet 0x78
179#define GOrdSChAng 0x34
180#define GOrdPChAng 0x74
181#define GOrdSChBrx 0x05
182#define GOrdPChBrx 0x45
183#define GOrdSChCel 0x33
184#define GOrdPChCel 0x03
185#define GOrdSChXtr 0x17
186#define GOrdPChXtr 0x57
187#define GOrdSChShr 0x35
188#define GOrdPChShr 0x75
189#define GOrdSTxAlg 0x36
190#define GOrdPTxAlg 0x76
192#define GOrdSMkPrc 0x3B
193#define GOrdPMkPrc 0x7B
194#define GOrdSMkSet 0x3C
195#define GOrdPMkSet 0x7C
196#define GOrdSMkSym 0x29
197#define GOrdPMkSym 0x69
198#define GOrdSMkCel 0x37
199#define GOrdPMkCel 0x77
201#define GOrdSArcPa 0x22
202#define GOrdPArcPa 0x62
204#define GOrdSCrPos 0x21
205#define GOrdPCrPos 0x61
207#define GOrdSMdTrn 0x24
208#define GOrdPMdTrn 0x64
209#define GOrdSPkIdn 0x43
210#define GOrdPPkIdn 0x23
211#define GOrdSVwTrn 0x31
212#define GOrdSVwWin 0x27
213#define GOrdPVwWin 0x67
283 sal_uInt32 nWidth, nHeight;
284 sal_uInt16 nBitsPerPixel;
291 sal_uInt16 nPushOrder;
314 sal_Int32 nArcP, nArcQ, nArcR, nArcS;
316 sal_Int32 nChrCellHeight;
320 sal_uInt16 nLinWidth;
326 sal_uInt16 nStrLinWidth;
350 , eLinStyle(PEN_NULL)
376 OSPalette * pPaletteStack;
387 OSBitmap * pBitmapList;
393 std::unique_ptr<SvMemoryStream> xOrdFile;
398 void PushAttr(sal_uInt16 nPushOrder);
401 void ChangeBrush(
const Color& rPatColor,
bool bFill );
402 void SetPen(
const Color& rColor, sal_uInt16 nStrLinWidth = 0,
PenStyle ePenStyle = PEN_SOLID );
405 void SetPalette0RGB(sal_uInt16
nIndex, sal_uInt32 nCol);
406 sal_uInt32 GetPalette0RGB(sal_uInt32
nIndex)
const;
412 bool IsLineInfo()
const;
416 sal_uInt16 ReadBigEndianWord();
417 sal_uInt32 ReadBigEndian3BytesLong();
418 sal_uInt32 ReadLittleEndian3BytesLong();
419 sal_Int32 ReadCoord(
bool b32);
420 Point ReadPoint(
const bool bAdjustBoundRect =
true );
422 void ReadLine(
bool bGivenPos, sal_uInt16 nOrderLen);
423 void ReadRelLine(
bool bGivenPos, sal_uInt16 nOrderLen);
424 void ReadBox(
bool bGivenPos);
426 void ReadChrStr(
bool bGivenPos,
bool bMove,
bool bExtra, sal_uInt16 nOrderLen);
427 void ReadArc(
bool bGivenPos);
428 void ReadFullArc(
bool bGivenPos, sal_uInt16 nOrderSize);
429 void ReadPartialArc(
bool bGivenPos, sal_uInt16 nOrderSize);
431 void ReadBezier(
bool bGivenPos, sal_uInt16 nOrderLen);
432 void ReadFillet(
bool bGivenPos, sal_uInt16 nOrderLen);
433 void ReadFilletSharp(
bool bGivenPos, sal_uInt16 nOrderLen);
434 void ReadMarker(
bool bGivenPos, sal_uInt16 nOrderLen);
435 void ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen);
436 void ReadDsc(sal_uInt16 nDscID);
437 void ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen);
438 void ReadFont(sal_uInt16 nFieldSize);
439 void ReadField(sal_uInt16 nFieldType, sal_uInt16 nFieldSize);
455OS2METReader::OS2METReader()
460 , pPaletteStack(nullptr)
461 , pAreaStack(nullptr)
462 , pPathStack(nullptr)
465 , pBitmapList(nullptr)
466 , pAttrStack(nullptr)
468 pVirDev->EnableOutput(
false);
471OS2METReader::~OS2METReader()
473 pVirDev.disposeAndClear();
475 while (pAreaStack!=
nullptr) {
476 OSArea *
p=pAreaStack;
481 while (pPathStack!=
nullptr) {
482 OSPath *
p=pPathStack;
487 while (pPathList!=
nullptr) {
488 OSPath *
p=pPathList;
493 while (pFontList!=
nullptr) {
494 OSFont *
p=pFontList;
499 while (pBitmapList!=
nullptr) {
500 OSBitmap *
p=pBitmapList;
501 pBitmapList=
p->pSucc;
506 while (pAttrStack!=
nullptr) {
507 OSAttr *
p=pAttrStack;
512 while (pPaletteStack!=
nullptr) {
513 OSPalette *
p=pPaletteStack;
514 pPaletteStack=
p->pSucc;
520bool OS2METReader::IsLineInfo()
const
522 return ( ! ( aLineInfo.IsDefault() || ( aLineInfo.GetStyle() ==
LineStyle::NONE ) || ( pVirDev->GetLineColor() == COL_TRANSPARENT ) ) );
527 if ( aLineInfo.GetStyle() ==
LineStyle::Dash || ( aLineInfo.GetWidth() > 1 ) )
528 pVirDev->DrawPolyLine( rPolygon, aLineInfo );
530 pVirDev->DrawPolyLine( rPolygon );
538 pVirDev->SetLineColor( COL_TRANSPARENT );
539 pVirDev->DrawPolygon( rPolygon );
541 pVirDev->DrawPolyLine( rPolygon, aLineInfo );
544 pVirDev->DrawPolygon( rPolygon );
552 pVirDev->SetLineColor( COL_TRANSPARENT );
553 pVirDev->DrawPolyPolygon( rPolyPolygon );
555 for ( sal_uInt16 i = 0;
i < rPolyPolygon.
Count();
i++ )
556 pVirDev->DrawPolyLine( rPolyPolygon.
GetObject( i ), aLineInfo );
559 pVirDev->DrawPolyPolygon( rPolyPolygon );
564 sal_uInt16 nOldSize, nNewSize,
i;
566 if (pAreaStack==
nullptr || rPoly.
GetSize()==0)
return;
568 if (pPP->
Count()==0 || pAreaStack->bClosed) pPP->
Insert(rPoly);
571 nOldSize=aLastPoly.GetSize();
572 if (nOldSize && aLastPoly.GetPoint(nOldSize-1)==rPoly.
GetPoint(0)) nOldSize--;
573 nNewSize=nOldSize+rPoly.
GetSize();
574 aLastPoly.SetSize(nNewSize);
575 for (i=nOldSize;
i<nNewSize;
i++) {
576 aLastPoly.SetPoint(rPoly.
GetPoint(i-nOldSize),i);
580 pAreaStack->bClosed=
false;
585 sal_uInt16 nOldSize, nNewSize,
i;
587 if (pPathStack==
nullptr || rPoly.
GetSize()==0)
return;
592 nOldSize=aLastPoly.GetSize();
593 if (nOldSize && aLastPoly.GetPoint(nOldSize-1)!=rPoly.
GetPoint(0)) pPP->
Insert(rPoly);
596 nNewSize=nOldSize+rPoly.
GetSize();
597 aLastPoly.SetSize(nNewSize);
598 for (i=nOldSize;
i<nNewSize;
i++) {
599 aLastPoly.SetPoint(rPoly.
GetPoint(i-nOldSize),i);
604 pPathStack->bClosed=
false;
607void OS2METReader::CloseFigure()
609 if (pAreaStack!=
nullptr) pAreaStack->bClosed=
true;
610 else if (pPathStack!=
nullptr) pPathStack->bClosed=
true;
613void OS2METReader::PushAttr(sal_uInt16 nPushOrder)
618 p->pSucc=pAttrStack; pAttrStack=
p;
619 p->nPushOrder=nPushOrder;
622void OS2METReader::PopAttr()
624 OSAttr *
p=pAttrStack;
626 if (p==
nullptr)
return;
627 switch (
p->nPushOrder) {
630 switch (
p->nIvAttrA) {
631 case 1:
switch (
p->nIvAttrP) {
632 case 1: aAttr.aLinCol=
p->aLinCol;
break;
633 case 2: aAttr.aChrCol=
p->aChrCol;
break;
634 case 3: aAttr.aMrkCol=
p->aMrkCol;
break;
635 case 4: aAttr.aPatCol=
p->aPatCol;
break;
636 case 5: aAttr.aImgCol=
p->aImgCol;
break;
638 case 2:
switch (
p->nIvAttrP) {
639 case 1: aAttr.aLinBgCol=
p->aLinBgCol;
break;
640 case 2: aAttr.aChrBgCol=
p->aChrBgCol;
break;
641 case 3: aAttr.aMrkBgCol=
p->aMrkBgCol;
break;
642 case 4: aAttr.aPatBgCol=
p->aPatBgCol;
break;
643 case 5: aAttr.aImgBgCol=
p->aImgBgCol;
break;
645 case 3:
switch (
p->nIvAttrP) {
646 case 1: aAttr.eLinMix=
p->eLinMix;
break;
647 case 2: aAttr.eChrMix=
p->eChrMix;
break;
648 case 3: aAttr.eMrkMix=
p->eMrkMix;
break;
649 case 4: aAttr.ePatMix=
p->ePatMix;
break;
650 case 5: aAttr.eImgMix=
p->eImgMix;
break;
652 case 4:
switch (
p->nIvAttrP) {
653 case 1: aAttr.eLinBgMix=
p->eLinBgMix;
break;
654 case 2: aAttr.eChrBgMix=
p->eChrBgMix;
break;
655 case 3: aAttr.eMrkBgMix=
p->eMrkBgMix;
break;
656 case 4: aAttr.ePatBgMix=
p->ePatBgMix;
break;
657 case 5: aAttr.eImgBgMix=
p->eImgBgMix;
break;
662 case GOrdPLnTyp: aAttr.eLinStyle=
p->eLinStyle;
break;
664 case GOrdPLnWdt: aAttr.nLinWidth=
p->nLinWidth;
break;
666 case GOrdPStLWd: aAttr.nStrLinWidth=
p->nStrLinWidth;
break;
673 aAttr.eLinMix=
p->eLinMix;
674 aAttr.eChrMix=
p->eChrMix;
675 aAttr.eMrkMix=
p->eMrkMix;
676 aAttr.ePatMix=
p->ePatMix;
677 aAttr.eImgMix=
p->eImgMix;
681 aAttr.eLinBgMix=
p->eLinBgMix;
682 aAttr.eChrBgMix=
p->eChrBgMix;
683 aAttr.eMrkBgMix=
p->eMrkBgMix;
684 aAttr.ePatBgMix=
p->ePatBgMix;
685 aAttr.eImgBgMix=
p->eImgBgMix;
693 aAttr.aLinCol=
p->aLinCol;
694 aAttr.aChrCol=
p->aChrCol;
695 aAttr.aMrkCol=
p->aMrkCol;
696 aAttr.aPatCol=
p->aPatCol;
697 aAttr.aImgCol=
p->aImgCol;
702 aAttr.aLinBgCol=
p->aLinBgCol;
703 aAttr.aChrBgCol=
p->aChrBgCol;
704 aAttr.aMrkBgCol=
p->aMrkBgCol;
705 aAttr.aPatBgCol=
p->aPatBgCol;
706 aAttr.aImgBgCol=
p->aImgBgCol;
709 case GOrdPMkPrc: aAttr.nMrkPrec=aDefAttr.nMrkPrec;
break;
711 case GOrdPMkSet: aAttr.nMrkSet=aDefAttr.nMrkSet;
break;
713 case GOrdPMkSym: aAttr.nMrkSymbol=aDefAttr.nMrkSymbol;
break;
715 case GOrdPMkCel: aAttr.aMrkCellSize=aDefAttr.aMrkCellSize;
break;
718 aAttr.nArcP=
p->nArcP; aAttr.nArcQ=
p->nArcQ;
719 aAttr.nArcR=
p->nArcR; aAttr.nArcS=
p->nArcS;
723 aAttr.aCurPos=
p->aCurPos;
730void OS2METReader::ChangeBrush(
const Color& rPatColor,
bool bFill )
739 if( pVirDev->GetFillColor() != aColor )
740 pVirDev->SetFillColor( aColor );
743void OS2METReader::SetPen(
const Color& rColor, sal_uInt16 nLineWidth,
PenStyle ePenStyle )
747 if ( pVirDev->GetLineColor() != rColor )
748 pVirDev->SetLineColor( rColor );
749 aLineInfo.SetWidth( nLineWidth );
751 sal_uInt16 nDotCount = 0;
752 sal_uInt16 nDashCount = 0;
767 aLineInfo.SetDotCount( nDotCount );
768 aLineInfo.SetDashCount( nDashCount );
769 aLineInfo.SetDistance( nLineWidth );
770 aLineInfo.SetDotLen( nLineWidth );
771 aLineInfo.SetDashLen( nLineWidth << 2 );
777 aLineInfo.SetStyle( eLineStyle );
780void OS2METReader::SetRasterOp(
RasterOp eROP)
782 if (pVirDev->GetRasterOp()!=eROP) pVirDev->SetRasterOp(eROP);
785void OS2METReader::SetPalette0RGB(sal_uInt16 nIndex, sal_uInt32 nCol)
787 if (pPaletteStack==
nullptr) {
788 pPaletteStack=
new OSPalette;
789 pPaletteStack->pSucc=
nullptr;
790 pPaletteStack->p0RGB=
nullptr;
791 pPaletteStack->nSize=0;
793 if (pPaletteStack->p0RGB==
nullptr || nIndex>=pPaletteStack->nSize) {
794 sal_uInt32 * pOld0RGB=pPaletteStack->p0RGB;
795 size_t nOldSize = pPaletteStack->nSize;
796 if (pOld0RGB==
nullptr) nOldSize=0;
797 pPaletteStack->nSize=2*(
nIndex+1);
798 if (pPaletteStack->nSize<256) pPaletteStack->nSize=256;
799 pPaletteStack->p0RGB =
new sal_uInt32[pPaletteStack->nSize];
800 for (
size_t i=0;
i < pPaletteStack->nSize; ++
i)
802 if (i<nOldSize) pPaletteStack->p0RGB[
i]=pOld0RGB[
i];
803 else if (i==0) pPaletteStack->p0RGB[
i]=0x00ffffff;
804 else pPaletteStack->p0RGB[
i]=0;
808 pPaletteStack->p0RGB[
nIndex]=nCol;
811sal_uInt32 OS2METReader::GetPalette0RGB(sal_uInt32 nIndex)
const
813 if (pPaletteStack!=
nullptr && pPaletteStack->p0RGB!=
nullptr &&
814 pPaletteStack->nSize>nIndex)
nIndex=pPaletteStack->p0RGB[
nIndex];
818Color OS2METReader::GetPaletteColor(sal_uInt32 nIndex)
const
820 nIndex=GetPalette0RGB(nIndex);
821 return Color(sal::static_int_cast< sal_uInt8 >((nIndex>>16)&0xff),
822 sal::static_int_cast< sal_uInt8 >((nIndex>>8)&0xff),
823 sal::static_int_cast< sal_uInt8 >(nIndex&0xff));
826sal_uInt16 OS2METReader::ReadBigEndianWord()
829 pOS2MET->ReadUChar( nHi ).ReadUChar( nLo );
830 return (
static_cast<sal_uInt16
>(nHi)<<8)|(
static_cast<sal_uInt16
>(nLo)&0x00ff);
833sal_uInt32 OS2METReader::ReadBigEndian3BytesLong()
836 pOS2MET->ReadUChar( nHi );
837 sal_uInt16 nLo = ReadBigEndianWord();
838 return ((
static_cast<sal_uInt32
>(nHi)<<16)&0x00ff0000)|
static_cast<sal_uInt32
>(nLo);
841sal_uInt32 OS2METReader::ReadLittleEndian3BytesLong()
845 pOS2MET->ReadUChar( nLo ).ReadUChar( nMed ).ReadUChar( nHi );
846 return ((
static_cast<sal_uInt32
>(nHi)&0xff)<<16)|((
static_cast<sal_uInt32
>(nMed)&0xff)<<8)|(
static_cast<sal_uInt32
>(nLo)&0xff);
849sal_Int32 OS2METReader::ReadCoord(
bool b32)
853 if (b32) pOS2MET->ReadInt32( l );
854 else {
short s(0); pOS2MET->ReadInt16( s ); l =
static_cast<sal_Int32
>(s); }
858Point OS2METReader::ReadPoint(
const bool bAdjustBoundRect )
860 sal_Int32
x = ReadCoord(bCoord32);
861 sal_Int32
y = ReadCoord(bCoord32);
862 x=
x-aBoundingRect.Left();
863 y=aBoundingRect.Bottom()-
y;
865 if (bAdjustBoundRect)
867 if (x == SAL_MAX_INT32 || y == SAL_MAX_INT32)
868 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
886void OS2METReader::ReadLine(
bool bGivenPos, sal_uInt16 nOrderLen)
888 sal_uInt16
i,nPolySize;
890 if (bCoord32) nPolySize=nOrderLen/8;
else nPolySize=nOrderLen/4;
891 if (!bGivenPos) nPolySize++;
892 if (nPolySize==0)
return;
894 for (i=0;
i<nPolySize;
i++) {
895 if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
896 else aPolygon.SetPoint(ReadPoint(),i);
898 aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
899 if (pAreaStack!=
nullptr) AddPointsToArea(aPolygon);
900 else if (pPathStack!=
nullptr) AddPointsToPath(aPolygon);
903 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
904 SetRasterOp(aAttr.eLinMix);
905 DrawPolyLine( aPolygon );
909void OS2METReader::ReadRelLine(
bool bGivenPos, sal_uInt16 nOrderLen)
911 sal_uInt16
i,nPolySize;
916 if (bCoord32) nOrderLen-=8;
else nOrderLen-=4;
918 else aP0=aAttr.aCurPos;
919 if (nOrderLen > pOS2MET->remainingSize())
920 throw css::uno::Exception(
"attempt to read past end of input",
nullptr);
921 nPolySize=nOrderLen/2;
922 if (nPolySize==0)
return;
924 for (i=0;
i<nPolySize;
i++) {
926 pOS2MET->ReadSChar( nsignedbyte ); aP0.
AdjustX(
static_cast<sal_Int32
>(nsignedbyte));
927 pOS2MET->ReadSChar( nsignedbyte ); aP0.
AdjustY(-
static_cast<sal_Int32
>(nsignedbyte));
929 aPolygon.SetPoint(aP0,i);
931 aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
932 if (pAreaStack!=
nullptr) AddPointsToArea(aPolygon);
933 else if (pPathStack!=
nullptr) AddPointsToPath(aPolygon);
936 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
937 SetRasterOp(aAttr.eLinMix);
938 DrawPolyLine( aPolygon );
942void OS2METReader::ReadBox(
bool bGivenPos)
947 pOS2MET->ReadUChar( nFlags );
955 aAttr.aCurPos = ReadPoint();
956 sal_Int32 nHRound = ReadCoord(bCoord32);
957 sal_Int32 nVRound = ReadCoord(bCoord32);
959 if (!pOS2MET->good())
961 SAL_WARN(
"filter.os2met",
"OS2METReader::ReadBox: short read");
969 else if ( pPathStack )
974 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
976 SetPen( COL_TRANSPARENT );
980 ChangeBrush(aAttr.aPatCol, aAttr.bFill);
981 SetRasterOp(aAttr.ePatMix);
985 ChangeBrush( COL_TRANSPARENT,
false );
986 SetRasterOp(aAttr.eLinMix);
995 pVirDev->SetLineColor( COL_TRANSPARENT );
996 pVirDev->DrawRect( aBoxRect, nHRound, nVRound );
999 pVirDev->DrawPolyLine( aPolygon, aLineInfo );
1002 pVirDev->DrawRect( aBoxRect, nHRound, nVRound );
1006void OS2METReader::ReadBitBlt()
1008 pOS2MET->SeekRel(4);
1010 pOS2MET->ReadUInt32( nID );
1011 pOS2MET->SeekRel(4);
1012 Point aP1 = ReadPoint();
1013 Point aP2 = ReadPoint();
1014 if (aP1.
X() > aP2.
X()) {
auto nt=aP1.
X(); aP1.
setX(aP2.
X() ); aP2.
setX(nt ); }
1015 if (aP1.
Y() > aP2.
Y()) {
auto nt=aP1.
Y(); aP1.
setY(aP2.
Y() ); aP2.
setY(nt ); }
1016 Size aSize(aP2.
X() - aP1.
X(), aP2.
Y() - aP1.
Y());
1018 OSBitmap* pB = pBitmapList;
1019 while (pB!=
nullptr && pB->nID!=nID) pB=pB->pSucc;
1021 SetRasterOp(aAttr.ePatMix);
1022 pVirDev->DrawBitmapEx(aP1,aSize,pB->aBitmapEx);
1026void OS2METReader::ReadChrStr(
bool bGivenPos,
bool bMove,
bool bExtra, sal_uInt16 nOrderLen)
1035 while (pF!=
nullptr && pF->nID!=aAttr.nChrSet) pF=pF->pSucc;
1040 if ( aAttr.nChrAng )
1046 aP0 = aAttr.aCurPos;
1049 pOS2MET->SeekRel(2);
1052 pOS2MET->ReadUInt16( nLen );
1058 else if ( bCoord32 )
1063 if (!pOS2MET->good() || nLen > pOS2MET->remainingSize())
1064 throw css::uno::Exception(
"attempt to read past end of input",
nullptr);
1065 std::unique_ptr<char[]> pChr(
new char[nLen+1]);
1066 for (sal_uInt16 i=0;
i<nLen;
i++)
1067 pOS2MET->ReadChar( pChr[i] );
1069 OUString
aStr( pChr.get(), strlen(pChr.get()), osl_getThreadTextEncoding() );
1070 SetRasterOp(aAttr.eChrMix);
1071 if (pVirDev->GetFont()!=aFont)
1072 pVirDev->SetFont(aFont);
1073 pVirDev->DrawText(aP0,aStr);
1075 aSize =
Size( pVirDev->GetTextWidth(aStr), pVirDev->GetTextHeight() );
1076 if ( !aAttr.nChrAng )
1081 aAttr.aCurPos =
Point( aP0.
X() + aSize.
Width(), aP0.
Y());
1087 aDummyPoly.SetPoint(
Point( aP0.
X(), aP0.
Y() ), 0);
1088 aDummyPoly.SetPoint(
Point( aP0.
X(), aP0.
Y() - aSize.
Height() ), 1);
1089 aDummyPoly.SetPoint(
Point( aP0.
X() + aSize.
Width(), aP0.
Y() ), 2);
1091 aDummyPoly.Rotate( aP0, aAttr.nChrAng );
1093 aAttr.aCurPos = aDummyPoly.GetPoint( 0 );
1094 aCalcBndRect.Union(
tools::Rectangle( aDummyPoly.GetPoint( 0 ), aDummyPoly.GetPoint( 3 ) ) );
1095 aCalcBndRect.Union(
tools::Rectangle( aDummyPoly.GetPoint( 1 ), aDummyPoly.GetPoint( 2 ) ) );
1099void OS2METReader::ReadArc(
bool bGivenPos)
1101 Point aP1, aP2, aP3;
1102 double x1,y1,x2,y2,x3,y3,
p,q,cx,cy,ncx,ncy,r,rx,ry,w1,w3;
1103 if (bGivenPos) aP1=ReadPoint();
else aP1=aAttr.aCurPos;
1104 aP2=ReadPoint(); aP3=ReadPoint();
1106 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1107 SetRasterOp(aAttr.eLinMix);
1110 x1=aP1.
X(); y1=aP1.
Y();
1111 x2=aP2.
X(); y2=aP2.
Y();
1112 x3=aP3.
X(); y3=aP3.
Y();
1113 p=aAttr.nArcP;q=aAttr.nArcQ;
1115 ncy=2*
p*
p*((y3-y1)*(x2-x1)-(y1-y2)*(x1-x3));
1117 if ( (ncx<0.001 && ncx>-0.001) || (ncy<0.001 && ncy>-0.001) ) {
1119 pVirDev->DrawLine(aP1,aP2);
1120 pVirDev->DrawLine(aP2,aP3);
1123 cy=( q*q*((x3*x3-x1*x1)*(x2-x1)+(x2*x2-x1*x1)*(x1-x3)) +
1124 p*p*((y3*y3-y1*y1)*(x2-x1)+(y2*y2-y1*y1)*(x1-x3)) ) / ncy;
1125 cx=( q*q*(x2*x2-x1*x1)+p*p*(y2*y2-y1*y1)+cy*2*
p*
p*(y1-y2) ) / ncx;
1127 r=sqrt(q*q*(x1-cx)*(x1-cx)+p*p*(y1-cy)*(y1-cy));
1131 w1=fmod((atan2(x1-cx,y1-cy)-atan2(x2-cx,y2-cy)),6.28318530718);
if (w1<0) w1+=6.28318530718;
1132 w3=fmod((atan2(x3-cx,y3-cy)-atan2(x2-cx,y2-cy)),6.28318530718);
if (w3<0) w3+=6.28318530718;
1134 pVirDev->DrawArc(
tools::Rectangle(
static_cast<sal_Int32
>(cx-rx),
static_cast<sal_Int32
>(cy-ry),
1135 static_cast<sal_Int32
>(cx+rx),
static_cast<sal_Int32
>(cy+ry)),aP1,aP3);
1138 pVirDev->DrawArc(
tools::Rectangle(
static_cast<sal_Int32
>(cx-rx),
static_cast<sal_Int32
>(cy-ry),
1139 static_cast<sal_Int32
>(cx+rx),
static_cast<sal_Int32
>(cy+ry)),aP3,aP1);
1143void OS2METReader::ReadFullArc(
bool bGivenPos, sal_uInt16 nOrderSize)
1149 aCenter=ReadPoint();
1150 if (bCoord32) nOrderSize-=8;
else nOrderSize-=4;
1152 else aCenter=aAttr.aCurPos;
1154 sal_Int32 nP = aAttr.nArcP;
1155 sal_Int32 nQ = aAttr.nArcQ;
1162 pOS2MET->ReadUInt32( nMul );
1164 sal_uInt16 nMulS(0);
1165 pOS2MET->ReadUInt16( nMulS );
1166 nMul=
static_cast<sal_uInt32
>(nMulS)<<8;
1168 if (nMul!=0x00010000) {
1174 aCenter.
X()+nP,aCenter.
Y()+nQ);
1175 aCalcBndRect.Union(aRect);
1177 if (pAreaStack!=
nullptr) {
1178 ChangeBrush(aAttr.aPatCol, aAttr.bFill);
1179 SetRasterOp(aAttr.ePatMix);
1180 if ((pAreaStack->nFlags&0x40)!=0)
1181 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1183 SetPen( COL_TRANSPARENT, 0, PEN_NULL );
1187 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1188 ChangeBrush(COL_TRANSPARENT,
false);
1189 SetRasterOp(aAttr.eLinMix);
1191 pVirDev->DrawEllipse(aRect);
1194void OS2METReader::ReadPartialArc(
bool bGivenPos, sal_uInt16 nOrderSize)
1196 Point aP0, aCenter,aPStart,aPEnd;
1201 if (bCoord32) nOrderSize-=8;
else nOrderSize-=4;
1203 else aP0=aAttr.aCurPos;
1204 aCenter=ReadPoint();
1206 sal_Int32 nP = aAttr.nArcP;
1207 sal_Int32 nQ = aAttr.nArcQ;
1214 pOS2MET->ReadUInt32( nMul );
1216 sal_uInt16 nMulS(0);
1217 pOS2MET->ReadUInt16( nMulS );
1218 nMul=
static_cast<sal_uInt32
>(nMulS)<<8;
1220 if (nMul!=0x00010000) {
1225 sal_Int32 nStart(0), nSweep(0);
1226 pOS2MET->ReadInt32( nStart ).ReadInt32( nSweep );
1227 double fStart = basegfx::deg2rad<65536>(
static_cast<double>(nStart));
1228 double fEnd = fStart+ basegfx::deg2rad<65536>(
static_cast<double>(nSweep));
1229 aPStart=
Point(aCenter.
X()+
static_cast<sal_Int32
>( cos(fStart)*nP),
1230 aCenter.
Y()+
static_cast<sal_Int32
>(-sin(fStart)*nQ));
1231 aPEnd=
Point(aCenter.
X()+
static_cast<sal_Int32
>( cos(fEnd)*nP),
1232 aCenter.
Y()+
static_cast<sal_Int32
>(-sin(fEnd)*nQ));
1235 aCenter.
X()+nP,aCenter.
Y()+nQ);
1236 aCalcBndRect.Union(aRect);
1238 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1239 SetRasterOp(aAttr.eLinMix);
1241 pVirDev->DrawLine(aP0,aPStart);
1242 pVirDev->DrawArc(aRect,aPStart,aPEnd);
1243 aAttr.aCurPos=aPEnd;
1246void OS2METReader::ReadPolygons()
1253 sal_uInt32 nNumPolys(0);
1254 pOS2MET->ReadUChar(nFlags).ReadUInt32(nNumPolys);
1256 if (!pOS2MET->good() || nNumPolys > SAL_MAX_UINT16)
1258 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
1263 for (sal_uInt32 i=0;
i<nNumPolys; ++
i)
1265 sal_uInt32 nNumPoints(0);
1266 pOS2MET->ReadUInt32(nNumPoints);
1269 if (!pOS2MET->good() || nNumPoints > nLimit)
1271 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
1275 if (i==0) ++nNumPoints;
1276 aPoly.
SetSize(
static_cast<short>(nNumPoints));
1277 for (sal_uInt32 j=0; j<nNumPoints; ++j)
1279 if (i==0 && j==0) aPoint=aAttr.aCurPos;
1280 else aPoint=ReadPoint();
1281 aPoly.
SetPoint(aPoint,
static_cast<short>(j));
1282 if (i==nNumPolys-1 && j==nNumPoints-1) aAttr.aCurPos=aPoint;
1287 ChangeBrush(aAttr.aPatCol, aAttr.bFill);
1288 SetRasterOp(aAttr.ePatMix);
1289 if ((nFlags&0x01)!=0)
1290 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1292 SetPen( COL_TRANSPARENT, 0, PEN_NULL );
1293 DrawPolyPolygon( aPolyPoly );
1296void OS2METReader::ReadBezier(
bool bGivenPos, sal_uInt16 nOrderLen)
1298 sal_uInt16
i, nNumPoints = nOrderLen / ( bCoord32 ? 8 : 4 );
1308 for( i=0;
i < nNumPoints;
i++ )
1310 if( i==0 && !bGivenPos)
1311 aPolygon.SetPoint( aAttr.aCurPos, i );
1313 aPolygon.SetPoint( ReadPoint(), i );
1316 if( !( nNumPoints % 4 ) )
1319 const sal_uInt16 nSegPoints = 25;
1320 const sal_uInt16 nSegments = aPolygon.GetSize() >> 2;
1323 sal_uInt16 nSeg, nBezPos, nStartPos;
1324 for( nSeg = 0, nBezPos = 0, nStartPos = 0; nSeg < nSegments; nSeg++, nStartPos += 4 )
1326 const tools::Polygon aSegPoly( aPolygon[ nStartPos ], aPolygon[ nStartPos + 1 ],
1327 aPolygon[ nStartPos + 3 ], aPolygon[ nStartPos + 2 ],
1330 for( sal_uInt16 nSegPos = 0; nSegPos < nSegPoints; )
1331 aBezPoly[ nBezPos++ ] = aSegPoly[ nSegPos++ ];
1334 nNumPoints = nBezPos;
1336 if( nNumPoints != aBezPoly.GetSize() )
1337 aBezPoly.SetSize( nNumPoints );
1339 aPolygon = aBezPoly;
1342 aAttr.aCurPos = aPolygon[ nNumPoints - 1 ];
1344 if (pAreaStack!=
nullptr)
1345 AddPointsToArea(aPolygon);
1346 else if (pPathStack!=
nullptr)
1347 AddPointsToPath(aPolygon);
1350 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1351 SetRasterOp(aAttr.eLinMix);
1352 DrawPolyLine( aPolygon );
1356void OS2METReader::ReadFillet(
bool bGivenPos, sal_uInt16 nOrderLen)
1358 sal_uInt16
i,nNumPoints;
1360 if (bCoord32) nNumPoints=nOrderLen/8;
else nNumPoints=nOrderLen/4;
1361 if (!bGivenPos) nNumPoints++;
1362 if (nNumPoints==0)
return;
1364 for (i=0;
i<nNumPoints;
i++) {
1365 if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
1366 else aPolygon.SetPoint(ReadPoint(),i);
1368 aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
1369 if (pAreaStack!=
nullptr) AddPointsToArea(aPolygon);
1370 else if (pPathStack!=
nullptr) AddPointsToPath(aPolygon);
1372 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1373 SetRasterOp(aAttr.eLinMix);
1374 DrawPolyLine( aPolygon );
1378void OS2METReader::ReadFilletSharp(
bool bGivenPos, sal_uInt16 nOrderLen)
1381 aAttr.aCurPos=ReadPoint();
1382 if (bCoord32) nOrderLen-=8;
else nOrderLen-=4;
1385 sal_uInt16 nNumPoints;
1386 if (bCoord32) nNumPoints=1+nOrderLen/10;
1387 else nNumPoints=1+nOrderLen/6;
1390 aPolygon.SetPoint(aAttr.aCurPos, 0);
1391 for (sal_uInt16 i = 1;
i <nNumPoints; ++
i)
1392 aPolygon.SetPoint(ReadPoint(), i);
1394 if (!pOS2MET->good())
1396 SAL_WARN(
"filter.os2met",
"OS2METReader::ReadFilletSharp: short read");
1400 aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
1401 if (pAreaStack!=
nullptr) AddPointsToArea(aPolygon);
1402 else if (pPathStack!=
nullptr) AddPointsToPath(aPolygon);
1405 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1406 SetRasterOp(aAttr.eLinMix);
1407 DrawPolyLine( aPolygon );
1411void OS2METReader::ReadMarker(
bool bGivenPos, sal_uInt16 nOrderLen)
1413 sal_uInt16
i,nNumPoints;
1415 SetPen( aAttr.aMrkCol );
1416 SetRasterOp(aAttr.eMrkMix);
1417 if (aAttr.nMrkSymbol>=5 && aAttr.nMrkSymbol<=9)
1419 ChangeBrush(aAttr.aMrkCol,
true);
1423 ChangeBrush(COL_TRANSPARENT,
false);
1425 if (bCoord32) nNumPoints=nOrderLen/8;
else nNumPoints=nOrderLen/4;
1426 if (!bGivenPos) nNumPoints++;
1427 for (i=0;
i<nNumPoints;
i++) {
1428 if (i!=0 || bGivenPos) aAttr.aCurPos=ReadPoint();
1429 const auto x = aAttr.aCurPos.X();
1430 const auto y = aAttr.aCurPos.Y();
1432 switch (aAttr.nMrkSymbol) {
1434 pVirDev->DrawLine(
Point(x-4,y),
Point(x+4,y));
1435 pVirDev->DrawLine(
Point(x,y-4),
Point(x,y+4));
1444 pVirDev->DrawPolygon(aPoly);
1454 pVirDev->DrawPolygon(aPoly);
1471 pVirDev->DrawPolygon(aPoly);
1492 pVirDev->DrawPolygon(aPoly);
1504 pVirDev->DrawLine(
Point(x-4,y-4),
Point(x+4,y+4));
1505 pVirDev->DrawLine(
Point(x-4,y+4),
Point(x+4,y-4));
1511void OS2METReader::ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen)
1518 case GOrdGivBzr: ReadBezier(
true,nOrderLen);
break;
1519 case GOrdCurBzr: ReadBezier(
false,nOrderLen);
break;
1524 case GOrdGivFil: ReadFillet(
true,nOrderLen);
break;
1525 case GOrdCurFil: ReadFillet(
false,nOrderLen);
break;
1527 case GOrdGivCrc: ReadFullArc(
true,nOrderLen);
break;
1528 case GOrdCurCrc: ReadFullArc(
false,nOrderLen);
break;
1530 case GOrdGivLin: ReadLine(
true, nOrderLen);
break;
1531 case GOrdCurLin: ReadLine(
false, nOrderLen);
break;
1533 case GOrdGivMrk: ReadMarker(
true, nOrderLen);
break;
1534 case GOrdCurMrk: ReadMarker(
false, nOrderLen);
break;
1536 case GOrdGivArP: ReadPartialArc(
true,nOrderLen);
break;
1537 case GOrdCurArP: ReadPartialArc(
false,nOrderLen);
break;
1539 case GOrdGivRLn: ReadRelLine(
true,nOrderLen);
break;
1540 case GOrdCurRLn: ReadRelLine(
false,nOrderLen);
break;
1542 case GOrdGivSFl: ReadFilletSharp(
true,nOrderLen);
break;
1543 case GOrdCurSFl: ReadFilletSharp(
false,nOrderLen);
break;
1545 case GOrdGivStM: ReadChrStr(
true ,
true ,
false, nOrderLen);
break;
1546 case GOrdCurStM: ReadChrStr(
false,
true ,
false, nOrderLen);
break;
1547 case GOrdGivStr: ReadChrStr(
true ,
false,
false, nOrderLen);
break;
1548 case GOrdCurStr: ReadChrStr(
false,
false,
false, nOrderLen);
break;
1549 case GOrdGivStx: ReadChrStr(
true ,
false,
true , nOrderLen);
break;
1550 case GOrdCurStx: ReadChrStr(
false,
false,
true , nOrderLen);
break;
1562 OSArea *
p=
new OSArea;
1564 p->pSucc=pAreaStack; pAreaStack=
p;
1565 pOS2MET->ReadUChar(
p->nFlags );
1566 p->aCol=aAttr.aPatCol;
1567 p->aBgCol=aAttr.aPatBgCol;
1568 p->eMix=aAttr.ePatMix;
1569 p->eBgMix=aAttr.ePatBgMix;
1570 p->bFill=aAttr.bFill;
1575 OSArea *
p=pAreaStack;
1578 pAreaStack =
p->pSucc;
1581 for ( sal_uInt16 i=0;
i<
p->aPPoly.Count();
i++ )
1583 AddPointsToPath(
p->aPPoly.GetObject( i ) );
1589 if ( (
p->nFlags & 0x40 ) == 0 )
1590 SetPen( COL_TRANSPARENT, 0, PEN_NULL );
1592 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1594 ChangeBrush(
p->aCol,
p->bFill);
1595 SetRasterOp(
p->eMix);
1596 DrawPolyPolygon(
p->aPPoly );
1609 OSPath *
p=
new OSPath;
1610 p->pSucc=pPathStack; pPathStack=
p;
1611 pOS2MET->SeekRel(2);
1612 pOS2MET->ReadUInt32(
p->nID );
1618 OSPath *
p, * pprev, * psucc;
1619 if (pPathStack==
nullptr)
break;
1620 p=pPathList; pprev=
nullptr;
1621 while (p!=
nullptr) {
1623 if (
p->nID==pPathStack->nID) {
1624 if (pprev==
nullptr) pPathList=psucc;
else pprev->pSucc=psucc;
1631 pPathStack=
p->pSucc;
1632 p->pSucc=pPathList; pPathList=
p;
1638 sal_uInt16 nDummy(0);
1639 OSPath*
p = pPathList;
1641 pOS2MET->ReadUInt16( nDummy )
1644 if ( ! ( nDummy & 0x20 ) )
1646 while( p &&
p->nID != nID )
1653 SetPen( aAttr.aPatCol, aAttr.nStrLinWidth );
1654 ChangeBrush(COL_TRANSPARENT,
false);
1655 SetRasterOp( aAttr.ePatMix );
1658 for ( sal_uInt16 i = 0;
i <
p->aPPoly.Count();
i++ )
1659 pVirDev->DrawPolyLine(
p->aPPoly.GetObject( i ), aLineInfo );
1662 pVirDev->DrawPolyPolygon(
p->aPPoly );
1666 SetPen( COL_TRANSPARENT, 0, PEN_NULL );
1667 ChangeBrush( aAttr.aPatCol, aAttr.bFill );
1668 SetRasterOp( aAttr.ePatMix );
1669 pVirDev->DrawPolyPolygon(
p->aPPoly );
1678 OSPath*
p = pPathList;
1680 while( p &&
p->nID != 1 )
1692 OSPath*
p=pPathList;
1693 pOS2MET->SeekRel(2);
1694 pOS2MET->ReadUInt32( nID );
1695 while (p && pOS2MET->good() &&
p->nID != nID)
1700 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
1701 SetRasterOp(aAttr.eLinMix);
1702 ChangeBrush(COL_TRANSPARENT,
false);
1703 nC=
p->aPPoly.Count();
1704 for (i=0;
i<nC;
i++)
1706 if (i+1<nC ||
p->bClosed)
1709 DrawPolyLine(
p->aPPoly.GetObject( i ) );
1715 SAL_INFO(
"filter.os2met",
"GOrdSClPth");
1717 OSPath *
p=pPathList;
1718 pOS2MET->SeekRel(2);
1719 pOS2MET->ReadUInt32( nID );
1720 if (nID==0)
p=
nullptr;
1721 while (p!=
nullptr &&
p->nID!=nID)
p=
p->pSucc;
1722 if (p!=
nullptr) pVirDev->SetClipRegion(
vcl::Region(
p->aPPoly));
1723 else pVirDev->SetClipRegion();
1763 pOS2MET->ReadUChar( nA ).ReadUChar( nP ).ReadUChar( nFlags );
1765 pAttrStack->nIvAttrA=nA;
1766 pAttrStack->nIvAttrP=nP;
1769 if ((nFlags&0x80)!=0) {
1770 if (nA==1)
switch (nP) {
1771 case 1: aAttr.aLinCol=aDefAttr.aLinCol;
break;
1772 case 2: aAttr.aChrCol=aDefAttr.aChrCol;
break;
1773 case 3: aAttr.aMrkCol=aDefAttr.aMrkCol;
break;
1774 case 4: aAttr.aPatCol=aDefAttr.aPatCol;
break;
1775 case 5: aAttr.aImgCol=aDefAttr.aImgCol;
break;
1778 case 1: aAttr.aLinBgCol=aDefAttr.aLinBgCol;
break;
1779 case 2: aAttr.aChrBgCol=aDefAttr.aChrBgCol;
break;
1780 case 3: aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
break;
1781 case 4: aAttr.aPatBgCol=aDefAttr.aPatBgCol;
break;
1782 case 5: aAttr.aImgBgCol=aDefAttr.aImgBgCol;
break;
1786 const auto nVal = ReadLittleEndian3BytesLong();
1787 if ((nFlags&0x40)!=0 && nVal==1) aCol=
COL_BLACK;
1788 else if ((nFlags&0x40)!=0 && nVal==2) aCol=
COL_WHITE;
1789 else if ((nFlags&0x40)!=0 && nVal==4) aCol=
COL_WHITE;
1790 else if ((nFlags&0x40)!=0 && nVal==5) aCol=
COL_BLACK;
1791 else aCol=GetPaletteColor(nVal);
1792 if (nA==1)
switch (nP) {
1793 case 1: aAttr.aLinCol=aCol;
break;
1794 case 2: aAttr.aChrCol=aCol;
break;
1795 case 3: aAttr.aMrkCol=aCol;
break;
1796 case 4: aAttr.aPatCol=aCol;
break;
1797 case 5: aAttr.aImgCol=aCol;
break;
1800 case 1: aAttr.aLinBgCol=aCol;
break;
1801 case 2: aAttr.aChrBgCol=aCol;
break;
1802 case 3: aAttr.aMrkBgCol=aCol;
break;
1803 case 4: aAttr.aPatBgCol=aCol;
break;
1804 case 5: aAttr.aImgBgCol=aCol;
break;
1810 pOS2MET->ReadUChar( nMix );
1813 case 1: aAttr.eLinBgMix=aDefAttr.eLinBgMix;
break;
1814 case 2: aAttr.eChrBgMix=aDefAttr.eChrBgMix;
break;
1815 case 3: aAttr.eMrkBgMix=aDefAttr.eMrkBgMix;
break;
1816 case 4: aAttr.ePatBgMix=aDefAttr.ePatBgMix;
break;
1817 case 5: aAttr.eImgBgMix=aDefAttr.eImgBgMix;
break;
1821 eROP=OS2MixToRasterOp(nMix);
1823 case 1: aAttr.eLinBgMix=eROP;
break;
1824 case 2: aAttr.eChrBgMix=eROP;
break;
1825 case 3: aAttr.eMrkBgMix=eROP;
break;
1826 case 4: aAttr.ePatBgMix=eROP;
break;
1827 case 5: aAttr.eImgBgMix=eROP;
break;
1837 pOS2MET->ReadUChar( nFlags );
1838 if ((nFlags&0x80)!=0) {
1839 aAttr.aLinCol=aDefAttr.aLinCol;
1840 aAttr.aChrCol=aDefAttr.aChrCol;
1841 aAttr.aMrkCol=aDefAttr.aMrkCol;
1842 aAttr.aPatCol=aDefAttr.aPatCol;
1843 aAttr.aImgCol=aDefAttr.aImgCol;
1847 const auto nVal = ReadLittleEndian3BytesLong();
1848 if ((nFlags&0x40)!=0 && nVal==1) aCol=
COL_BLACK;
1849 else if ((nFlags&0x40)!=0 && nVal==2) aCol=
COL_WHITE;
1850 else if ((nFlags&0x40)!=0 && nVal==4) aCol=
COL_WHITE;
1851 else if ((nFlags&0x40)!=0 && nVal==5) aCol=
COL_BLACK;
1852 else aCol=GetPaletteColor(nVal);
1853 aAttr.aLinCol = aAttr.aChrCol = aAttr.aMrkCol = aAttr.aPatCol =
1854 aAttr.aImgCol = aCol;
1867 pOS2MET->ReadUChar( nbyte ); nVal=
static_cast<sal_uInt16
>(nbyte)|0xff00;
1869 else pOS2MET->ReadUInt16( nVal );
1870 if (nVal==0x0000 || nVal==0xff00) {
1871 aAttr.aLinCol=aDefAttr.aLinCol;
1872 aAttr.aChrCol=aDefAttr.aChrCol;
1873 aAttr.aMrkCol=aDefAttr.aMrkCol;
1874 aAttr.aPatCol=aDefAttr.aPatCol;
1875 aAttr.aImgCol=aDefAttr.aImgCol;
1881 else if (nVal==0xff08) aCol=GetPaletteColor(1);
1882 else aCol=GetPaletteColor(
static_cast<sal_uInt32
>(nVal) & 0x000000ff);
1883 aAttr.aLinCol = aAttr.aChrCol = aAttr.aMrkCol = aAttr.aPatCol =
1884 aAttr.aImgCol = aCol;
1893 pOS2MET->ReadUInt16( nVal );
1894 if (nVal==0x0000 || nVal==0xff00) {
1895 aAttr.aLinBgCol=aDefAttr.aLinBgCol;
1896 aAttr.aChrBgCol=aDefAttr.aChrBgCol;
1897 aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
1898 aAttr.aPatBgCol=aDefAttr.aPatBgCol;
1899 aAttr.aImgBgCol=aDefAttr.aImgBgCol;
1905 else if (nVal==0xff08) aCol=GetPaletteColor(0);
1906 else aCol=GetPaletteColor(
static_cast<sal_uInt32
>(nVal) & 0x000000ff);
1907 aAttr.aLinBgCol = aAttr.aChrBgCol = aAttr.aMrkBgCol =
1908 aAttr.aPatBgCol = aAttr.aImgBgCol = aCol;
1916 pOS2MET->ReadUChar( nFlags );
1917 if ((nFlags&0x80)!=0) {
1918 aAttr.aLinBgCol=aDefAttr.aLinBgCol;
1919 aAttr.aChrBgCol=aDefAttr.aChrBgCol;
1920 aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
1921 aAttr.aPatBgCol=aDefAttr.aPatBgCol;
1922 aAttr.aImgBgCol=aDefAttr.aImgBgCol;
1926 const auto nVal = ReadLittleEndian3BytesLong();
1927 if ((nFlags&0x40)!=0 && nVal==1) aCol=
COL_BLACK;
1928 else if ((nFlags&0x40)!=0 && nVal==2) aCol=
COL_WHITE;
1929 else if ((nFlags&0x40)!=0 && nVal==4) aCol=
COL_WHITE;
1930 else if ((nFlags&0x40)!=0 && nVal==5) aCol=
COL_BLACK;
1931 else aCol=GetPaletteColor(nVal);
1932 aAttr.aLinBgCol = aAttr.aChrBgCol = aAttr.aMrkBgCol =
1933 aAttr.aPatBgCol = aAttr.aImgBgCol = aCol;
1942 pOS2MET->ReadUChar( nMix );
1944 aAttr.eLinMix=aDefAttr.eLinMix;
1945 aAttr.eChrMix=aDefAttr.eChrMix;
1946 aAttr.eMrkMix=aDefAttr.eMrkMix;
1947 aAttr.ePatMix=aDefAttr.ePatMix;
1948 aAttr.eImgMix=aDefAttr.eImgMix;
1951 aAttr.eLinMix = aAttr.eChrMix = aAttr.eMrkMix =
1952 aAttr.ePatMix = aAttr.eImgMix = OS2MixToRasterOp(nMix);
1960 pOS2MET->ReadUChar( nMix );
1962 aAttr.eLinBgMix=aDefAttr.eLinBgMix;
1963 aAttr.eChrBgMix=aDefAttr.eChrBgMix;
1964 aAttr.eMrkBgMix=aDefAttr.eMrkBgMix;
1965 aAttr.ePatBgMix=aDefAttr.ePatBgMix;
1966 aAttr.eImgBgMix=aDefAttr.eImgBgMix;
1969 aAttr.eLinBgMix = aAttr.eChrBgMix = aAttr.eMrkBgMix =
1970 aAttr.ePatBgMix = aAttr.eImgBgMix = OS2MixToRasterOp(nMix);
1983 pOS2MET->ReadUChar( nPatt );
1984 aAttr.bFill = ( nPatt != 0x0f );
2007 pOS2MET->ReadUChar( nType );
2009 case 0: aAttr.eLinStyle=aDefAttr.eLinStyle;
break;
2010 case 1:
case 4: aAttr.eLinStyle=PEN_DOT;
break;
2011 case 2:
case 5: aAttr.eLinStyle=PEN_DASH;
break;
2012 case 3:
case 6: aAttr.eLinStyle=PEN_DASHDOT;
break;
2013 case 8: aAttr.eLinStyle=PEN_NULL;
break;
2014 default: aAttr.eLinStyle=PEN_SOLID;
2022 pOS2MET->ReadUChar( nbyte );
2023 if (nbyte==0) aAttr.nLinWidth=aDefAttr.nLinWidth;
2024 else aAttr.nLinWidth=
static_cast<sal_uInt16
>(nbyte)-1;
2038 pOS2MET->ReadUChar( nFlags );
2039 if ( nFlags & 0x80 )
2040 aAttr.nStrLinWidth = aDefAttr.nStrLinWidth;
2043 pOS2MET->SeekRel( 1 );
2044 sal_Int32 nWd = ReadCoord( bCoord32 );
2047 aAttr.nStrLinWidth =
static_cast<sal_uInt16
>(nWd);
2065 pOS2MET->ReadUChar( nbyte );
2066 aAttr.nChrSet=
static_cast<sal_uInt32
>(nbyte)&0xff;
2072 sal_Int32 nX = ReadCoord(bCoord32);
2073 sal_Int32 nY = ReadCoord(bCoord32);
2074 if (nX>=0 && nY==0) aAttr.nChrAng=0_deg10;
2076 aAttr.nChrAng =
Degree10(
static_cast<short>(basegfx::rad2deg<10>(atan2(
static_cast<double>(nY),
static_cast<double>(nX)))));
2077 while (aAttr.nChrAng < 0_deg10) aAttr.nChrAng += 3600_deg10;
2078 aAttr.nChrAng %= 3600_deg10;
2090 sal_uInt16 nLen=nOrderLen;
2091 (void) ReadCoord(bCoord32);
2092 auto nHeight = ReadCoord(bCoord32);
2093 if (nHeight < 0 || nHeight > SAL_MAX_INT16)
2095 SAL_WARN(
"filter.os2met",
"ignoring out of sane range font height: " << nHeight);
2096 aAttr.nChrCellHeight = aDefAttr.nChrCellHeight;
2099 aAttr.nChrCellHeight = nHeight;
2100 if (bCoord32) nLen-=8;
else nLen-=4;
2102 pOS2MET->SeekRel(4); nLen-=4;
2106 pOS2MET->ReadUChar( nbyte );
2107 if ((nbyte&0x80)==0 && aAttr.nChrCellHeight == 0)
2108 aAttr.nChrCellHeight = aDefAttr.nChrCellHeight;
2131 pOS2MET->ReadUChar( nbyte );
2132 if (nbyte==0) aAttr.nMrkPrec=aDefAttr.nMrkPrec;
2133 else aAttr.nMrkPrec=nbyte;
2141 pOS2MET->ReadUChar( nbyte );
2142 if (nbyte==0) aAttr.nMrkSet=aDefAttr.nMrkSet;
2143 else aAttr.nMrkSet=nbyte;
2151 pOS2MET->ReadUChar( nbyte );
2152 if (nbyte==0) aAttr.nMrkSymbol=aDefAttr.nMrkSymbol;
2153 else aAttr.nMrkSymbol=nbyte;
2160 sal_uInt16 nLen=nOrderLen;
2161 aAttr.aMrkCellSize.setWidth(ReadCoord(bCoord32) );
2162 aAttr.aMrkCellSize.setHeight(ReadCoord(bCoord32) );
2163 if (bCoord32) nLen-=8;
else nLen-=4;
2166 pOS2MET->ReadUChar( nbyte );
2167 if ((nbyte&0x80)==0 && aAttr.aMrkCellSize==
Size(0,0))
2168 aAttr.aMrkCellSize=aDefAttr.aMrkCellSize;
2176 aAttr.nArcP=ReadCoord(bCoord32);
2177 aAttr.nArcQ=ReadCoord(bCoord32);
2178 aAttr.nArcR=ReadCoord(bCoord32);
2179 aAttr.nArcS=ReadCoord(bCoord32);
2185 aAttr.aCurPos=ReadPoint();
2205 default:
SAL_INFO(
"filter.os2met",
"Unknown order: " << nOrderID);
2209void OS2METReader::ReadDsc(sal_uInt16 nDscID)
2214 pOS2MET->SeekRel(6);
2215 pOS2MET->ReadUChar( nbyte );
2216 if (nbyte==0x05) bCoord32=
true;
2217 else if (nbyte==0x04) bCoord32=
false;
2219 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2230 pOS2MET->SeekRel(2);
2231 pOS2MET->ReadUChar( nbyte );
2235 else if(nbyte==0x04)
2240 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2244 pOS2MET->ReadUChar( nUnitType );
2246 sal_Int32 xr = ReadCoord(b32);
2247 sal_Int32 yr = ReadCoord(b32);
2251 if (nUnitType==0x00 && xr>0 && yr>0)
2253 else if (nUnitType==0x01 && xr>0 && yr>0)
2258 sal_Int32 x1 = ReadCoord(b32);
2259 sal_Int32 x2 = ReadCoord(b32);
2260 sal_Int32 y1 = ReadCoord(b32);
2261 sal_Int32 y2 = ReadCoord(b32);
2277 aBoundingRect.SetLeft( x1 );
2278 aBoundingRect.SetRight( x2 );
2279 aBoundingRect.SetTop( y1 );
2280 aBoundingRect.SetBottom( y2 );
2292void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen)
2294 OSBitmap *
p=pBitmapList;
if (p==
nullptr)
return;
2305 pOS2MET->SeekRel(5);
2306 p->nHeight=ReadBigEndianWord();
2307 p->nWidth=ReadBigEndianWord();
2315 pOS2MET->ReadUChar( nbyte );
p->nBitsPerPixel=nbyte;
2328 if (
p->pBMP==
nullptr) {
2330 p->pBMP->SetEndian(SvStreamEndian::LITTLE);
2331 if (
p->nWidth==0 ||
p->nHeight==0 ||
p->nBitsPerPixel==0) {
2332 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2337 p->pBMP->WriteUInt32( 40 ).WriteUInt32(
p->nWidth ).WriteUInt32(
p->nHeight );
2338 p->pBMP->WriteUInt16( 1 ).WriteUInt16(
p->nBitsPerPixel );
2339 p->pBMP->WriteUInt32( 0 ).WriteUInt32( 0 ).WriteUInt32( 0 ).WriteUInt32( 0 );
2340 p->pBMP->WriteUInt32( 0 ).WriteUInt32( 0 );
2342 if (
p->nBitsPerPixel<=8) {
2343 sal_uInt16
i, nColTabSize=1<<(
p->nBitsPerPixel);
2344 for (i=0;
i<nColTabSize;
i++)
p->pBMP->WriteUInt32( GetPalette0RGB(i) );
2349 std::unique_ptr<sal_uInt8[]> pBuf(
new sal_uInt8[nDataLen]);
2350 pOS2MET->ReadBytes(pBuf.get(), nDataLen);
2351 sal_uInt32 nBytesPerLineToSwap = (
p->nBitsPerPixel == 24) ?
2352 ((
p->nWidth * 3 + 3) & 0xfffffffc) : 0;
2353 if (nBytesPerLineToSwap) {
2354 sal_uInt32 nAlign =
p->nMapPos - (
p->nMapPos % nBytesPerLineToSwap);
2356 while (nAlign+i+2<
p->nMapPos+nDataLen) {
2357 if (nAlign+i>=
p->nMapPos) {
2358 sal_uInt32 j = nAlign +
i -
p->nMapPos;
2359 std::swap(pBuf[j], pBuf[j+2]);
2362 if (i + 2 >= nBytesPerLineToSwap) {
2363 nAlign += nBytesPerLineToSwap;
2368 p->pBMP->WriteBytes(pBuf.get(), nDataLen);
2369 p->nMapPos+=nDataLen;
2382 OSFont * pF=
new OSFont;
2383 pF->pSucc=pFontList; pFontList=pF;
2385 pF->aFont.SetTransparent(
true);
2386 pF->aFont.SetAlignment(ALIGN_BASELINE);
2388 auto nPos=pOS2MET->Tell();
2389 auto nMaxPos =
nPos + nFieldSize;
2390 pOS2MET->SeekRel(2);
nPos+=2;
2391 while (nPos<nMaxPos && pOS2MET->good()) {
2393 pOS2MET->ReadUChar(nByte);
2394 sal_uInt16 nLen =
static_cast<sal_uInt16
>(nByte) & 0x00ff;
2397 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2401 pOS2MET->ReadUChar( nTripType );
2402 switch (nTripType) {
2406 pOS2MET->ReadUChar( nTripType2 );
2407 switch (nTripType2) {
2412 pOS2MET->SeekRel(1);
2413 str[pOS2MET->ReadBytes(str, 32)] = 0;
2414 OUString
aStr( str, strlen(str), osl_getThreadTextEncoding() );
2415 if (
aStr.equalsIgnoreAsciiCase(
"Helv" ) )
2417 pF->aFont.SetFamilyName( aStr );
2426 pOS2MET->ReadUChar( nTripType2 );
2427 switch (nTripType2) {
2429 pOS2MET->ReadUChar( nByte );
2430 pF->nID=
static_cast<sal_uInt32
>(nByte)&0xff;
2440 pOS2MET->ReadUChar( nbyte );
2453 pF->aFont.SetWeight(eWeight);
2458 pOS2MET->Seek(nPos);
2462void OS2METReader::ReadField(sal_uInt16 nFieldType, sal_uInt16 nFieldSize)
2464 switch (nFieldType) {
2479 sal_uInt16 nStartIndex, nEndIndex,
i, nElemLen, nBytesPerCol;
2481 auto nPos = pOS2MET->Tell();
2482 auto nMaxPos =
nPos + nFieldSize;
2483 pOS2MET->SeekRel(3);
nPos+=3;
2484 while (nPos<nMaxPos && pOS2MET->
GetError()==ERRCODE_NONE) {
2485 pOS2MET->ReadUChar( nbyte ); nElemLen=
static_cast<sal_uInt16
>(nbyte) & 0x00ff;
2487 pOS2MET->SeekRel(4);
2488 nStartIndex=ReadBigEndianWord();
2489 pOS2MET->SeekRel(3);
2490 pOS2MET->ReadUChar( nbyte );
2491 nBytesPerCol=
static_cast<sal_uInt16
>(nbyte) & 0x00ff;
2492 if (nBytesPerCol == 0)
2494 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2498 nEndIndex=nStartIndex+(nElemLen-11)/nBytesPerCol;
2499 for (i=nStartIndex;
i<nEndIndex;
i++) {
2500 if (nBytesPerCol > 3) pOS2MET->SeekRel(nBytesPerCol-3);
2501 auto nCol = ReadBigEndian3BytesLong();
2502 SetPalette0RGB(i, nCol);
2505 else if (nElemLen<10) {
2506 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2510 pOS2MET->Seek(nPos);
2518 OSBitmap * pB=
new OSBitmap;
2519 pB->pSucc=pBitmapList; pBitmapList=pB;
2520 pB->pBMP=
nullptr; pB->nWidth=0; pB->nHeight=0; pB->nBitsPerPixel=0;
2526 pOS2MET->ReadUChar(nbyte).ReadUChar(nbyte2);
2529 nbyte = (nbyte << 4) | nbyte2;
2530 pB->nID=(pB->nID>>8)|(
static_cast<sal_uInt32
>(nbyte)<<24);
2533 OSPalette * pP=
new OSPalette;
2534 pP->pSucc=pPaletteStack; pPaletteStack=pP;
2535 pP->p0RGB=
nullptr; pP->nSize=0;
2540 if (pBitmapList==
nullptr || pBitmapList->pBMP==
nullptr ||
2542 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2546 pBitmapList->pBMP->Seek(0);
2550 if (pBitmapList->pBMP->GetError()!=ERRCODE_NONE) {
2551 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2554 delete pBitmapList->pBMP; pBitmapList->pBMP=
nullptr;
2556 OSPalette * pP=pPaletteStack;
2558 pPaletteStack=pP->pSucc;
2567 sal_uInt16 nDataID, nDataLen;
2570 auto nPos = pOS2MET->Tell();
2571 auto nMaxPos =
nPos + nFieldSize;
2572 while (nPos<nMaxPos && pOS2MET->
GetError()==ERRCODE_NONE) {
2573 pOS2MET->ReadUChar( nbyte ); nDataID=
static_cast<sal_uInt16
>(nbyte)&0x00ff;
2574 if (nDataID==0x00fe) {
2575 pOS2MET->ReadUChar( nbyte );
2576 nDataID=(nDataID<<8)|(static_cast<sal_uInt16>(nbyte)&0x00ff);
2577 nDataLen=ReadBigEndianWord();
2581 pOS2MET->ReadUChar( nbyte ); nDataLen=
static_cast<sal_uInt16
>(nbyte)&0x00ff;
2584 ReadImageData(nDataID, nDataLen);
2586 pOS2MET->Seek(nPos);
2601 auto nMaxPos = xOrdFile->Tell();
2611 pOS2MET=xOrdFile.get();
2618 const sal_uInt8 nLastByte =
static_cast<const sal_uInt8*
>(xOrdFile->GetData())[nMaxPos-1];
2620 pOS2MET->SetStreamSize(nMaxPos);
2621 assert(pOS2MET->remainingSize() == nMaxPos || pOS2MET->remainingSize() == nMaxPos - 1);
2622 SAL_WARN_IF(pOS2MET->remainingSize() == nMaxPos,
"filter.os2met",
"this SetStreamSize workaround is no longer needed");
2625 if (pOS2MET->remainingSize() < nMaxPos)
2627 pOS2MET->Seek(nMaxPos);
2631 assert(nLastByte ==
static_cast<const sal_uInt8*
>(xOrdFile->GetData())[nMaxPos-1]);
2634 assert(pOS2MET->remainingSize() == nMaxPos);
2637 xOrdFile->SetResizeOffset(0);
2642 pOS2MET->ReadUChar( nbyte );
2644 pOS2MET->SeekRel(15);
2646 else pOS2MET->SeekRel(-1);
2649 while (pOS2MET->Tell()<nMaxPos && pOS2MET->GetError()==ERRCODE_NONE) {
2650 pOS2MET->ReadUChar( nbyte );
2651 sal_uInt16 nOrderID =
static_cast<sal_uInt16
>(nbyte) & 0x00ff;
2652 if (nOrderID==0x00fe) {
2653 pOS2MET->ReadUChar( nbyte );
2654 nOrderID=(nOrderID << 8) | (static_cast<sal_uInt16>(nbyte) & 0x00ff);
2656 sal_uInt16 nOrderLen;
2657 if (nOrderID>0x00ff || nOrderID==
GOrdPolygn) {
2663 pOS2MET->ReadUChar( nbyte ); nOrderLen=
static_cast<sal_uInt16
>(nbyte)&0x00ff;
2664 pOS2MET->ReadUChar( nbyte );
if (nbyte!=0) nOrderLen=nOrderLen<<8|(static_cast<sal_uInt16>(nbyte)&0x00ff);
2667 else if ((nOrderID&0xff88)==0x0008) nOrderLen=1;
2668 else if (nOrderID==0x0000 || nOrderID==0x00ff) nOrderLen=0;
2669 else { pOS2MET->ReadUChar( nbyte ); nOrderLen=
static_cast<sal_uInt16
>(nbyte) & 0x00ff; }
2670 auto nPos=pOS2MET->Tell();
2671 ReadOrder(nOrderID, nOrderLen);
2672 if (nPos+nOrderLen < pOS2MET->Tell()) {
2673 SAL_INFO(
"filter.os2met",
"Order is shorter than expected. OrderID: " << nOrderID <<
" Position: " << nPos);
2675 else if (nPos+nOrderLen != pOS2MET->Tell()) {
2676 SAL_INFO(
"filter.os2met",
"Order was not read completely. OrderID: " << nOrderID <<
" Position: " << nPos);
2678 pOS2MET->Seek(nPos+nOrderLen);
2682 if (xOrdFile->GetError()) {
2683 pOS2MET->
SetError(SVSTREAM_FILEFORMAT_ERROR);
2690 sal_uInt16 nDscID, nDscLen;
2693 auto nMaxPos = pOS2MET->Tell() + nFieldSize;
2694 while (pOS2MET->Tell()<nMaxPos && pOS2MET->GetError()==ERRCODE_NONE) {
2695 pOS2MET->ReadUChar( nbyte ); nDscID =
static_cast<sal_uInt16
>(nbyte) & 0x00ff;
2696 pOS2MET->ReadUChar( nbyte ); nDscLen=
static_cast<sal_uInt16
>(nbyte) & 0x00ff;
2697 auto nPos = pOS2MET->Tell();
2699 pOS2MET->Seek(nPos+nDscLen);
2706 xOrdFile->SetEndian(SvStreamEndian::LITTLE);
2708 std::unique_ptr<sal_uInt8[]> pBuf(
new sal_uInt8[nFieldSize]);
2709 pOS2MET->ReadBytes(pBuf.get(), nFieldSize);
2710 xOrdFile->WriteBytes(pBuf.get(), nFieldSize);
2726 pOS2MET = &rStreamOS2MET;
2727 auto nOrigPos = pOS2MET->
Tell();
2731 pPaletteStack=
nullptr;
2736 pBitmapList=
nullptr;
2763 aDefAttr.nChrAng =0_deg10;
2764 aDefAttr.nChrCellHeight = 12;
2765 aDefAttr.nChrSet =0;
2766 aDefAttr.aCurPos =
Point(0,0);
2767 aDefAttr.eLinStyle =PEN_SOLID;
2768 aDefAttr.nLinWidth =0;
2769 aDefAttr.aMrkCellSize=
Size(10,10);
2770 aDefAttr.nMrkPrec =0x01;
2771 aDefAttr.nMrkSet =0xff;
2772 aDefAttr.nMrkSymbol =0x01;
2773 aDefAttr.bFill =
true;
2774 aDefAttr.nStrLinWidth=0;
2780 rGDIMetaFile.
Record(pVirDev);
2782 pOS2MET->SetEndian(SvStreamEndian::LITTLE);
2784 sal_uInt64
nPos = pOS2MET->Tell();
2788 sal_uInt16 nFieldSize = ReadBigEndianWord();
2790 pOS2MET->ReadUChar( nMagicByte );
2791 if (nMagicByte!=0xd3) {
2792 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2797 sal_uInt16 nFieldType(0);
2798 pOS2MET->ReadUInt16(nFieldType);
2800 pOS2MET->SeekRel(3);
2802 if (pOS2MET->GetError())
2808 if (pOS2MET->eof() || nFieldSize < 8)
2810 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2815 nPos+=8; nFieldSize-=8;
2817 if (nFieldSize > pOS2MET->remainingSize())
2819 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2824 ReadField(nFieldType, nFieldSize);
2827 if (pOS2MET->Tell() > nPos)
2829 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
2833 pOS2MET->Seek(nPos);
2836 rGDIMetaFile.
Stop();
2840 if( aBoundingRect.GetWidth() && aBoundingRect.GetHeight() )
2841 rGDIMetaFile.
SetPrefSize( aBoundingRect.GetSize() );
2844 if( aCalcBndRect.Left() || aCalcBndRect.Top() )
2845 rGDIMetaFile.
Move( -aCalcBndRect.Left(), -aCalcBndRect.Top() );
2847 rGDIMetaFile.
SetPrefSize( aCalcBndRect.GetSize() );
2850 pOS2MET->SetEndian(nOrigNumberFormat);
2852 if (pOS2MET->GetError()) {
2854 pOS2MET->Seek(nOrigPos);
2862 OS2METReader aOS2METReader;
2868 aOS2METReader.ReadOS2MET( rStream, aMTF );
2876 catch (
const css::uno::Exception&)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetError(ErrCode nErrorCode)
sal_uInt64 Seek(sal_uInt64 nPos)
void SetFontSize(const Size &)
void SetOrientation(Degree10 nLineOrientation)
void SetColor(const Color &)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
SvStream & ReadFont(SvStream &rIStm, vcl::Font &rFont)
bool ImportMetGraphic(SvStream &rStream, Graphic &rGraphic)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::enable_if< std::is_signed< T >::value, T >::type saturating_toggle_sign(T a)