Kaydet (Commit) a3f09ab5 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Thorsten Behrens

emfplus: reorganized some old filter aspects

Change-Id: I1949e851c560a81a461ec42a992f3b2cb0d019f8
üst c7470f5b
......@@ -26,24 +26,27 @@ namespace emfio
{
class EmfReader : public MtfTools
{
bool bRecordPath;
sal_Int32 nRecordCount;
bool bEMFPlus;
private:
sal_Int32 mnRecordCount;
bool mbRecordPath : 1;
bool mbEMFPlus : 1;
bool ReadHeader();
// reads and converts the rectangle
static tools::Rectangle ReadRectangle(sal_Int32, sal_Int32, sal_Int32, sal_Int32);
public:
EmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = nullptr);
EmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile);
~EmfReader();
bool ReadEnhWMF();
private:
template <class T> void ReadAndDrawPolyPolygon();
template <class T> void ReadAndDrawPolyLine();
template <class T> tools::Polygon ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints);
template <class T, class Drawer> void ReadAndDrawPolygon(Drawer drawer, const bool skipFirst);
template <class T> tools::Polygon ReadPolygonWithSkip(const bool skipFirst);
tools::Rectangle ReadRectangle();
void ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC);
......
......@@ -134,7 +134,6 @@ namespace emfio
sal_uInt8 lfPitchAndFamily;
OUString alfFaceName;
};
struct WMF_EXTERNALHEADER;
}
#define TA_NOUPDATECP 0x0000
......@@ -423,8 +422,8 @@ namespace emfio
RasterOp eRasterOp;
Point aActPos;
WinMtfPathObj aPathObj;
WinMtfClipPath aClipPath;
WinMtfPathObj maPathObj;
WinMtfClipPath maClipPath;
XForm aXForm;
bool bFillStyleSelected;
......@@ -432,9 +431,9 @@ namespace emfio
struct BSaveStruct
{
BitmapEx aBmpEx;
tools::Rectangle aOutRect;
sal_uInt32 nWinRop;
BitmapEx aBmpEx;
tools::Rectangle aOutRect;
sal_uInt32 nWinRop;
BSaveStruct(const Bitmap& rBmp, const tools::Rectangle& rOutRect, sal_uInt32 nRop)
: aBmpEx(rBmp)
......@@ -449,17 +448,19 @@ namespace emfio
{}
};
class MtfToolsWriter final
class MtfTools
{
WinMtfPathObj aPathObj;
WinMtfClipPath aClipPath;
protected:
WinMtfPathObj maPathObj;
WinMtfClipPath maClipPath;
WinMtfLineStyle maLatestLineStyle;
WinMtfLineStyle maLineStyle;
WinMtfLineStyle m_NopLineStyle;
WinMtfLineStyle maNopLineStyle;
WinMtfFillStyle maLatestFillStyle;
WinMtfFillStyle maFillStyle;
WinMtfFillStyle m_NopFillStyle;
WinMtfFillStyle maNopFillStyle;
vcl::Font maLatestFont;
vcl::Font maFont;
sal_uInt32 mnLatestTextAlign;
......@@ -475,43 +476,52 @@ namespace emfio
RasterOp meLatestRasterOp;
RasterOp meRasterOp;
std::vector< std::unique_ptr<GDIObj> > vGDIObj;
std::vector< std::unique_ptr<GDIObj> > mvGDIObj;
Point maActPos;
WMFRasterOp mnRop;
bool mbNopMode;
bool mbFillStyleSelected;
bool mbClipNeedsUpdate;
bool mbComplexClip;
std::vector< std::shared_ptr<SaveStruct> > vSaveStack;
std::vector< std::shared_ptr<SaveStruct> > mvSaveStack;
sal_uInt32 mnGfxMode;
sal_uInt32 mnMapMode;
XForm maXForm;
sal_Int32 mnDevOrgX, mnDevOrgY;
sal_Int32 mnDevWidth, mnDevHeight;
sal_Int32 mnWinOrgX, mnWinOrgY; // aktuel window origin
sal_Int32 mnWinExtX, mnWinExtY; // aktuel window extend
bool mbIsMapWinSet;
bool mbIsMapDevSet;
sal_Int32 mnPixX, mnPixY; // Reference Device in pixel
sal_Int32 mnMillX, mnMillY; // Reference Device in Mill
tools::Rectangle mrclFrame; // rectangle in logical units 1/100th mm
tools::Rectangle mrclBounds;
sal_Int32 mnDevOrgX;
sal_Int32 mnDevOrgY;
sal_Int32 mnDevWidth;
sal_Int32 mnDevHeight;
sal_Int32 mnWinOrgX;
sal_Int32 mnWinOrgY;
sal_Int32 mnWinExtX;
sal_Int32 mnWinExtY;
sal_Int32 mnPixX; // Reference Device in pixel
sal_Int32 mnPixY; // Reference Device in pixel
sal_Int32 mnMillX; // Reference Device in Mill
sal_Int32 mnMillY; // Reference Device in Mill
tools::Rectangle mrclFrame;
tools::Rectangle mrclBounds;
GDIMetaFile* mpGDIMetaFile;
SvStream* mpWMF; // the WMF/EMF file to be read
sal_uInt32 mnStartPos;
sal_uInt32 mnEndPos;
std::vector<std::unique_ptr<BSaveStruct>> maBmpSaveList;
bool mbNopMode : 1;
bool mbFillStyleSelected : 1;
bool mbClipNeedsUpdate : 1;
bool mbComplexClip : 1;
bool mbIsMapWinSet : 1;
bool mbIsMapDevSet : 1;
void UpdateLineStyle();
void UpdateFillStyle();
Point ImplMap(const Point& rPt);
Point ImplScale(const Point& rPt);
Size ImplMap(const Size& rSize, bool bDoWorldTransform = true);
tools::Rectangle ImplMap(const tools::Rectangle& rRectangle);
tools::Rectangle ImplMap(const tools::Rectangle& rRectangle);
void ImplMap(vcl::Font& rFont);
tools::Polygon& ImplMap(tools::Polygon& rPolygon);
tools::PolyPolygon& ImplMap(tools::PolyPolygon& rPolyPolygon);
......@@ -559,11 +569,7 @@ namespace emfio
void CreateObject(std::unique_ptr<GDIObj> pObject);
void CreateObjectIndexed(sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject);
void CreateObject()
{
CreateObject(o3tl::make_unique<GDIObj>());
}
void CreateObject();
void DeleteObject(sal_Int32 nIndex);
void SelectObject(sal_Int32 nIndex);
......@@ -571,9 +577,9 @@ namespace emfio
const vcl::Font& GetFont() const { return maFont; }
void SetTextLayoutMode(ComplexTextLayoutFlags nLayoutMode);
void ClearPath() { aPathObj.Init(); };
void ClosePath() { aPathObj.ClosePath(); };
const tools::PolyPolygon& GetPathObj() { return aPathObj; };
void ClearPath() { maPathObj.Init(); };
void ClosePath() { maPathObj.ClosePath(); };
const tools::PolyPolygon& GetPathObj() { return maPathObj; };
void MoveTo(const Point& rPoint, bool bRecordPath = false);
void LineTo(const Point& rPoint, bool bRecordPath = false);
......@@ -631,33 +637,9 @@ namespace emfio
void PassEMFPlus(void* pBuffer, sal_uInt32 nLength);
void PassEMFPlusHeaderInfo();
explicit MtfToolsWriter(GDIMetaFile& rGDIMetaFile);
~MtfToolsWriter();
};
class MtfTools
{
protected:
std::unique_ptr<MtfToolsWriter> pOut;
SvStream* pWMF; // the WMF/EMF file to be read
sal_uInt32 nStartPos, nEndPos;
std::vector<std::unique_ptr<BSaveStruct>> aBmpSaveList;
FilterConfigItem* pFilterConfigItem;
css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator;
// assures aSampledBrush is the actual brush of the GDIMetaFile
Color ReadColor();
void Callback(sal_uInt16 nPercent);
MtfTools(
GDIMetaFile& rGDIMetaFile,
SvStream& rStreamWMF,
FilterConfigItem* pConfigItem
);
explicit MtfTools(GDIMetaFile& rGDIMetaFile, SvStream& rStreamWMF);
~MtfTools();
};
}
......
......@@ -25,61 +25,29 @@
namespace emfio
{
struct WMF_EXTERNALHEADER
{
sal_uInt16 xExt;
sal_uInt16 yExt;
/** One of the following values:
<ul>
<li>MM_TEXT</li>
<li>MM_LOMETRIC</li>
<li>MM_HIMETRIC</li>
<li>MM_LOENGLISH</li>
<li>MM_HIENGLISH</li>
<li>MM_TWIPS</li>
<li>MM_ISOTROPIC</li>
<li>MM_ANISOTROPIC</li>
</ul>
If this value is 0, then no external mapmode has been defined,
the internal one should then be used.
*/
sal_uInt16 mapMode;
WMF_EXTERNALHEADER() :
xExt(0),
yExt(0),
mapMode(0)
{
}
};
class WmfReader : public MtfTools
{
private:
sal_uInt16 nUnitsPerInch;
sal_uInt32 nRecSize;
sal_uInt16 mnUnitsPerInch;
sal_uInt32 mnRecSize;
// embedded EMF data
std::unique_ptr<SvMemoryStream> pEMFStream;
std::unique_ptr<SvMemoryStream> mpEMFStream;
// total number of comment records containing EMF data
sal_uInt32 nEMFRecCount;
sal_uInt32 mnEMFRecCount;
// number of EMF records read
sal_uInt32 nEMFRec;
sal_uInt32 mnEMFRec;
// total size of embedded EMF data
sal_uInt32 nEMFSize;
sal_uInt32 mnEMFSize;
sal_uInt32 nSkipActions;
sal_uInt32 nCurrentAction;
WMF_EXTERNALHEADER* pExternalHeader;
sal_uInt32 mnSkipActions;
sal_uInt32 mnCurrentAction;
// reads header of the WMF-Datei
bool ReadHeader();
bool ReadHeader();
// reads parameters of the record with the functionnumber nFunction.
void ReadRecordParams(sal_uInt16 nFunction);
......@@ -91,10 +59,7 @@ namespace emfio
void GetPlaceableBound(tools::Rectangle& rSize, SvStream* pStrm);
public:
WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile,
FilterConfigItem* pConfigItem,
WMF_EXTERNALHEADER* pExtHeader = nullptr);
WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile);
// read WMF file from stream and fill the GDIMetaFile
void ReadWMF();
......
......@@ -186,11 +186,11 @@ namespace emfio
if (nMetaType == 0x464d4520)
{
emfio::EmfReader(*pStream, aMtf, nullptr).ReadEnhWMF();
emfio::EmfReader(*pStream, aMtf).ReadEnhWMF();
}
else
{
emfio::WmfReader(*pStream, aMtf, nullptr).ReadWMF();
emfio::WmfReader(*pStream, aMtf).ReadWMF();
}
pStream->SetEndian(nOrigNumberFormat);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment