Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e6c5c854
Kaydet (Commit)
e6c5c854
authored
May 18, 2014
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
vcl wmf: EnhWMFReader constructor, ReadHeader, cleanup
Change-Id: I43b95f3ee7af42b5b1c9110cafbbae325dddb946
üst
8ff29fac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
53 deletions
+66
-53
enhwmf.cxx
vcl/source/filter/wmf/enhwmf.cxx
+63
-43
winmtf.hxx
vcl/source/filter/wmf/winmtf.hxx
+3
-10
No files found.
vcl/source/filter/wmf/enhwmf.cxx
Dosyayı görüntüle @
e6c5c854
...
@@ -153,6 +153,9 @@ using namespace std;
...
@@ -153,6 +153,9 @@ using namespace std;
#define EMR_SETLINKEDUFIS 119
#define EMR_SETLINKEDUFIS 119
#define EMR_SETTEXTJUSTIFICATION 120
#define EMR_SETTEXTJUSTIFICATION 120
namespace
{
#ifdef OSL_BIGENDIAN
#ifdef OSL_BIGENDIAN
// little endian <-> big endian switch
// little endian <-> big endian switch
static
float
GetSwapFloat
(
SvStream
&
rSt
)
static
float
GetSwapFloat
(
SvStream
&
rSt
)
...
@@ -239,6 +242,18 @@ static bool ImplReadRegion( PolyPolygon& rPolyPoly, SvStream& rSt, sal_uInt32 nL
...
@@ -239,6 +242,18 @@ static bool ImplReadRegion( PolyPolygon& rPolyPoly, SvStream& rSt, sal_uInt32 nL
return
bOk
;
return
bOk
;
}
}
}
// anonymous namespace
EnhWMFReader
::
EnhWMFReader
(
SvStream
&
rStream
,
GDIMetaFile
&
rGDIMetaFile
,
FilterConfigItem
*
pConfigItem
)
:
WinMtf
(
new
WinMtfOutput
(
rGDIMetaFile
),
rStream
,
pConfigItem
)
,
bRecordPath
(
false
)
,
nRecordCount
(
0
)
,
bEMFPlus
(
false
)
{}
EnhWMFReader
::~
EnhWMFReader
()
{}
void
EnhWMFReader
::
ReadEMFPlusComment
(
sal_uInt32
length
,
bool
&
bHaveDC
)
void
EnhWMFReader
::
ReadEMFPlusComment
(
sal_uInt32
length
,
bool
&
bHaveDC
)
{
{
if
(
!
bEMFPlus
)
{
if
(
!
bEMFPlus
)
{
...
@@ -1489,12 +1504,13 @@ bool EnhWMFReader::ReadHeader()
...
@@ -1489,12 +1504,13 @@ bool EnhWMFReader::ReadHeader()
{
{
sal_uInt32
nType
,
nSignature
,
nVersion
;
sal_uInt32
nType
,
nSignature
,
nVersion
;
sal_uInt32
nHeaderSize
,
nPalEntries
;
sal_uInt32
nHeaderSize
,
nPalEntries
;
sal_Int32
nLeft
,
nTop
,
nRight
,
nBottom
;
// Spare me the METAFILEHEADER here
// Spare me the METAFILEHEADER here
// Reading the METAHEADER - EMR_HEADER ([MS-EMF] section 2.3.4.2 EMR_HEADER Record Types)
// Reading the METAHEADER - EMR_HEADER ([MS-EMF] section 2.3.4.2 EMR_HEADER Record Types)
pWMF
->
ReadUInt32
(
nType
).
ReadUInt32
(
nHeaderSize
);
pWMF
->
ReadUInt32
(
nType
).
ReadUInt32
(
nHeaderSize
);
if
(
nType
!=
1
)
{
// per [MS-EMF] 2.3.4.2 EMF Header Record Types, type MUST be 0x00000001
if
(
nType
!=
0x00000001
)
{
// per [MS-EMF] 2.3.4.2 EMF Header Record Types, type MUST be 0x00000001
SAL_WARN
(
"vcl.emf"
,
"EMF header type is not set to 0x00000001 - possibly corrupted file?"
);
SAL_WARN
(
"vcl.emf"
,
"EMF header type is not set to 0x00000001 - possibly corrupted file?"
);
return
false
;
return
false
;
}
}
...
@@ -1502,54 +1518,48 @@ bool EnhWMFReader::ReadHeader()
...
@@ -1502,54 +1518,48 @@ bool EnhWMFReader::ReadHeader()
// Start reading the EMR_HEADER Header object
// Start reading the EMR_HEADER Header object
// bound size (RectL object, see [MS-WMF] section 2.2.2.19)
// bound size (RectL object, see [MS-WMF] section 2.2.2.19)
Rectangle
rclBounds
;
// rectangle in logical units
Rectangle
rclBounds
=
ReadRectangle
();
// rectangle in logical units
pWMF
->
ReadInt32
(
nLeft
).
ReadInt32
(
nTop
).
ReadInt32
(
nRight
).
ReadInt32
(
nBottom
);
rclBounds
.
Left
()
=
nLeft
;
rclBounds
.
Top
()
=
nTop
;
rclBounds
.
Right
()
=
nRight
;
rclBounds
.
Bottom
()
=
nBottom
;
// picture frame size (RectL object)
// picture frame size (RectL object)
Rectangle
rclFrame
;
// rectangle in device units 1/100th mm
Rectangle
rclFrame
=
ReadRectangle
();
// rectangle in device units 1/100th mm
pWMF
->
ReadInt32
(
nLeft
).
ReadInt32
(
nTop
).
ReadInt32
(
nRight
).
ReadInt32
(
nBottom
);
rclFrame
.
Left
()
=
nLeft
;
rclFrame
.
Top
()
=
nTop
;
rclFrame
.
Right
()
=
nRight
;
rclFrame
.
Bottom
()
=
nBottom
;
pWMF
->
ReadUInt32
(
nSignature
);
pWMF
->
ReadUInt32
(
nSignature
);
// nSignature MUST be the ASCII characters "FME", see [WS-EMF] 2.2.9 Header Object
// nSignature MUST be the ASCII characters "FME", see [WS-EMF] 2.2.9 Header Object
// and 2.1.14 FormatSignature Enumeration
// and 2.1.14 FormatSignature Enumeration
if
(
nSignature
!=
0x464d4520
)
{
if
(
nSignature
!=
0x464d4520
)
{
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
Signature is not 0x464d4520 (
\"
FME
\"
) - possibly corrupted file?"
);
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
Signature is not 0x464d4520 (
\"
FME
\"
) - possibly corrupted file?"
);
return
false
;
return
false
;
}
}
pWMF
->
ReadUInt32
(
nVersion
);
// according to [WS-EMF] 2.2.9, this SHOULD be 0x0001000, however
pWMF
->
ReadUInt32
(
nVersion
);
// according to [WS-EMF] 2.2.9, this SHOULD be 0x0001000, however
// Microsoft note that not even Windows checks this...
// Microsoft note that not even Windows checks this...
if
(
nVersion
!=
0x00010000
)
{
if
(
nVersion
!=
0x00010000
)
{
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
This really should be 0x00010000, though not absolutely essential..."
);
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
This really should be 0x00010000, though not absolutely essential..."
);
}
}
pWMF
->
ReadUInt32
(
nEndPos
);
// size of metafile
pWMF
->
ReadUInt32
(
nEndPos
);
// size of metafile
nEndPos
+=
nStartPos
;
nEndPos
+=
nStartPos
;
sal_uInt32
nStrmPos
=
pWMF
->
Tell
();
// checking if nEndPos is valid
sal_uInt32
nStrmPos
=
pWMF
->
Tell
();
// checking if nEndPos is valid
pWMF
->
Seek
(
STREAM_SEEK_TO_END
);
pWMF
->
Seek
(
STREAM_SEEK_TO_END
);
sal_uInt32
nActualFileSize
=
pWMF
->
Tell
();
sal_uInt32
nActualFileSize
=
pWMF
->
Tell
();
if
(
nActualFileSize
<
nEndPos
)
{
if
(
nActualFileSize
<
nEndPos
)
{
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
EMF Header object records number of bytes as "
<<
nEndPos
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
EMF Header object records number of bytes as "
<<
nEndPos
<<
", however the file size is actually "
<<
nActualFileSize
<<
", however the file size is actually "
<<
nActualFileSize
<<
" bytes. Possible file corruption?"
);
<<
" bytes. Possible file corruption?"
);
nEndPos
=
nActualFileSize
;
nEndPos
=
nActualFileSize
;
}
}
pWMF
->
Seek
(
nStrmPos
);
pWMF
->
Seek
(
nStrmPos
);
pWMF
->
ReadInt32
(
nRecordCount
);
pWMF
->
ReadInt32
(
nRecordCount
);
if
(
!
nRecordCount
)
{
if
(
nRecordCount
==
0
)
{
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
EMF Header object shows record counter as 0! This shouldn't "
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
EMF Header object shows record counter as 0! This shouldn't "
"be possible... indicator of possible file corruption?"
);
"be possible... indicator of possible file corruption?"
);
return
false
;
return
false
;
...
@@ -1558,16 +1568,17 @@ bool EnhWMFReader::ReadHeader()
...
@@ -1558,16 +1568,17 @@ bool EnhWMFReader::ReadHeader()
// the number of "handles", or graphics objects used in the metafile
// the number of "handles", or graphics objects used in the metafile
sal_uInt16
nHandlesCount
;
sal_uInt16
nHandlesCount
;
pWMF
->
ReadUInt16
(
nHandlesCount
);
pWMF
->
ReadUInt16
(
nHandlesCount
);
// the next 2 bytes are reserved, but according to [MS-EMF] section 2.2.9
// the next 2 bytes are reserved, but according to [MS-EMF] section 2.2.9
// it MUST be 0x000 and MUST be ignored... the thing is, having such a specific
// it MUST be 0x000 and MUST be ignored... the thing is, having such a specific
// value is actually pretty useful in checking if there is possible corruption
// value is actually pretty useful in checking if there is possible corruption
sal_uInt16
nReserved
;
sal_uInt16
nReserved
;
pWMF
->
ReadUInt16
(
nReserved
);
pWMF
->
ReadUInt16
(
nReserved
);
if
(
nReserved
!=
0x0000
)
{
if
(
nReserved
!=
0x0000
)
{
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
EMF Header object's reserved field is NOT 0x0000... possible "
SAL_WARN
(
"vcl.emf"
,
"EMF
\t\t
EMF Header object's reserved field is NOT 0x0000... possible "
"corruption?"
);
"corruption?"
);
}
}
...
@@ -1577,30 +1588,39 @@ bool EnhWMFReader::ReadHeader()
...
@@ -1577,30 +1588,39 @@ bool EnhWMFReader::ReadHeader()
// metafile description... zero means no description string.
// metafile description... zero means no description string.
// For now, we ignore it.
// For now, we ignore it.
pWMF
->
SeekRel
(
0x8
);
pWMF
->
SeekRel
(
0x8
);
sal_Int32
nPixX
,
nPixY
,
nMillX
,
nMillY
;
sal_Int32
nPixX
,
nPixY
,
nMillX
,
nMillY
;
pWMF
->
ReadUInt32
(
nPalEntries
).
ReadInt32
(
nPixX
).
ReadInt32
(
nPixY
).
ReadInt32
(
nMillX
).
ReadInt32
(
nMillY
);
pWMF
->
ReadUInt32
(
nPalEntries
);
pWMF
->
ReadInt32
(
nPixX
);
pOut
->
SetrclFrame
(
rclFrame
);
pWMF
->
ReadInt32
(
nPixY
);
pOut
->
SetrclBounds
(
rclBounds
);
pWMF
->
ReadInt32
(
nMillX
);
pOut
->
SetRefPix
(
Size
(
nPixX
,
nPixY
)
);
pWMF
->
ReadInt32
(
nMillY
);
pOut
->
SetRefMill
(
Size
(
nMillX
,
nMillY
)
);
pOut
->
SetrclFrame
(
rclFrame
);
pWMF
->
Seek
(
nStartPos
+
nHeaderSize
);
pOut
->
SetrclBounds
(
rclBounds
);
pOut
->
SetRefPix
(
Size
(
nPixX
,
nPixY
)
);
pOut
->
SetRefMill
(
Size
(
nMillX
,
nMillY
)
);
pWMF
->
Seek
(
nStartPos
+
nHeaderSize
);
return
true
;
return
true
;
}
}
Rectangle
EnhWMFReader
::
ReadRectangle
(
sal_Int32
x1
,
sal_Int32
y1
,
sal_Int32
x2
,
sal_Int32
y2
)
Rectangle
EnhWMFReader
::
ReadRectangle
()
{
sal_Int32
nLeft
,
nTop
,
nRight
,
nBottom
;
pWMF
->
ReadInt32
(
nLeft
);
pWMF
->
ReadInt32
(
nTop
);
pWMF
->
ReadInt32
(
nRight
);
pWMF
->
ReadInt32
(
nBottom
);
return
Rectangle
(
nLeft
,
nTop
,
nRight
,
nBottom
);
}
Rectangle
EnhWMFReader
::
ReadRectangle
(
sal_Int32
x1
,
sal_Int32
y1
,
sal_Int32
x2
,
sal_Int32
y2
)
{
{
Point
aTL
(
Point
(
x1
,
y1
)
);
Point
aTL
(
Point
(
x1
,
y1
)
);
Point
aBR
(
Point
(
--
x2
,
--
y2
)
);
Point
aBR
(
Point
(
--
x2
,
--
y2
)
);
return
Rectangle
(
aTL
,
aBR
);
return
Rectangle
(
aTL
,
aBR
);
}
}
EnhWMFReader
::~
EnhWMFReader
()
{
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl/source/filter/wmf/winmtf.hxx
Dosyayı görüntüle @
e6c5c854
...
@@ -800,16 +800,7 @@ class EnhWMFReader : public WinMtf
...
@@ -800,16 +800,7 @@ class EnhWMFReader : public WinMtf
Rectangle
ReadRectangle
(
sal_Int32
,
sal_Int32
,
sal_Int32
,
sal_Int32
);
Rectangle
ReadRectangle
(
sal_Int32
,
sal_Int32
,
sal_Int32
,
sal_Int32
);
public
:
public
:
EnhWMFReader
(
EnhWMFReader
(
SvStream
&
rStreamWMF
,
GDIMetaFile
&
rGDIMetaFile
,
FilterConfigItem
*
pConfigItem
=
NULL
);
SvStream
&
rStreamWMF
,
GDIMetaFile
&
rGDIMetaFile
,
FilterConfigItem
*
pConfigItem
=
NULL
)
:
WinMtf
(
new
WinMtfOutput
(
rGDIMetaFile
),
rStreamWMF
,
pConfigItem
)
,
bRecordPath
(
false
)
,
nRecordCount
(
0
)
,
bEMFPlus
(
false
)
{
}
~
EnhWMFReader
();
~
EnhWMFReader
();
bool
ReadEnhWMF
();
bool
ReadEnhWMF
();
...
@@ -819,6 +810,8 @@ private:
...
@@ -819,6 +810,8 @@ private:
template
<
class
T
>
void
ReadAndDrawPolyLine
();
template
<
class
T
>
void
ReadAndDrawPolyLine
();
template
<
class
T
>
Polygon
ReadPolygon
(
sal_uInt32
nStartIndex
,
sal_uInt32
nPoints
);
template
<
class
T
>
Polygon
ReadPolygon
(
sal_uInt32
nStartIndex
,
sal_uInt32
nPoints
);
template
<
class
T
,
class
Drawer
>
void
ReadAndDrawPolygon
(
Drawer
drawer
,
const
bool
skipFirst
);
template
<
class
T
,
class
Drawer
>
void
ReadAndDrawPolygon
(
Drawer
drawer
,
const
bool
skipFirst
);
Rectangle
ReadRectangle
();
};
};
class
WMFReader
:
public
WinMtf
class
WMFReader
:
public
WinMtf
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment