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
1663abc7
Kaydet (Commit)
1663abc7
authored
Haz 13, 2011
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#i49123# implement typedetection for supported .hwp format versions
üst
46d4d4b8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
31 deletions
+72
-31
writer_MIZI_Hwp_97.xcu
filter/source/config/fragments/types/writer_MIZI_Hwp_97.xcu
+2
-2
BK.hwp
hwpfilter/qa/cppunit/data/fail/BK.hwp
+0
-0
hwpfile.cpp
hwpfilter/source/hwpfile.cpp
+2
-9
hwpfile.h
hwpfilter/source/hwpfile.h
+7
-0
hwpreader.hxx
hwpfilter/source/hwpreader.hxx
+60
-20
makefile.mk
hwpfilter/source/makefile.mk
+1
-0
No files found.
filter/source/config/fragments/types/writer_MIZI_Hwp_97.xcu
Dosyayı görüntüle @
1663abc7
<node oor:name="writer_MIZI_Hwp_97" oor:op="replace" >
<prop oor:name="DetectService"
/
>
<prop oor:name="DetectService"
><value>com.sun.comp.hwpimport.HwpImportFilter</value></prop
>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>hwp</value></prop>
<prop oor:name="MediaType"
/
>
<prop oor:name="MediaType"
><value>application/x-hwp</value></prop
>
<prop oor:name="Preferred"><value>false</value></prop>
<prop oor:name="PreferredFilter"><value>writer_MIZI_Hwp_97</value></prop>
<prop oor:name="UIName">
...
...
hwpfilter/qa/cppunit/data/
pass
/BK.hwp
→
hwpfilter/qa/cppunit/data/
fail
/BK.hwp
Dosyayı görüntüle @
1663abc7
File moved
hwpfilter/source/hwpfile.cpp
Dosyayı görüntüle @
1663abc7
...
...
@@ -43,14 +43,9 @@
#include "hcode.h"
#include "hstream.h"
#define HWPIDLen 30
#define HWPHeadLen 128
#define HWPSummaryLen 1008
#define V20SIGNATURE "HWP Document File V2.00 \032\1\2\3\4\5"
#define V21SIGNATURE "HWP Document File V2.10 \032\1\2\3\4\5"
#define V30SIGNATURE "HWP Document File V3.00 \032\1\2\3\4\5"
#define FILESTG_SIGNATURE 0xF8995567
#define FILESTG_SIGNATURE_NORMAL 0xF8995568
...
...
@@ -127,8 +122,7 @@ int HWPFile::ReadHwpFile(HStream & stream)
return
State
();
}
static
int
hwp_version
(
char
*
str
)
int
detect_hwp_version
(
const
char
*
str
)
{
if
(
memcmp
(
V20SIGNATURE
,
str
,
HWPIDLen
)
==
0
)
return
HWP_V20
;
...
...
@@ -139,7 +133,6 @@ static int hwp_version(char *str)
return
0
;
}
// HIODev wrapper
int
HWPFile
::
Open
(
HStream
&
stream
)
...
...
@@ -162,7 +155,7 @@ int HWPFile::Open(HStream & stream)
char
idstr
[
HWPIDLen
];
if
(
ReadBlock
(
idstr
,
HWPIDLen
)
<=
0
||
HWP_V30
!=
(
version
=
hwp_version
(
idstr
)))
||
HWP_V30
!=
(
version
=
detect_
hwp_version
(
idstr
)))
{
return
SetState
(
HWP_UNSUPPORTED_VERSION
);
}
...
...
hwpfilter/source/hwpfile.h
Dosyayı görüntüle @
1663abc7
...
...
@@ -44,10 +44,17 @@
#include "hpara.h"
#include "list.hxx"
#define HWPIDLen 30
#define V20SIGNATURE "HWP Document File V2.00 \032\1\2\3\4\5"
#define V21SIGNATURE "HWP Document File V2.10 \032\1\2\3\4\5"
#define V30SIGNATURE "HWP Document File V3.00 \032\1\2\3\4\5"
#define HWP_V20 20
#define HWP_V21 21
#define HWP_V30 30
int
detect_hwp_version
(
const
char
*
str
);
struct
FBox
;
struct
EmPicture
;
struct
HyperText
;
...
...
hwpfilter/source/hwpreader.hxx
Dosyayı görüntüle @
1663abc7
...
...
@@ -52,11 +52,12 @@
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XActiveDataControl.hpp>
#include <com/sun/star/io/XStreamListener.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase
3
.hxx>
#include <cppuhelper/implbase
4
.hxx>
#include <cppuhelper/servicefactory.hxx>
using
namespace
::
rtl
;
...
...
@@ -69,9 +70,12 @@ using namespace ::com::sun::star::registry;
using
namespace
::
com
::
sun
::
star
::
document
;
using
namespace
::
com
::
sun
::
star
::
beans
;
using
namespace
::
com
::
sun
::
star
::
xml
::
sax
;
using
namespace
::
com
::
sun
::
star
::
document
;
#include <assert.h>
#include <comphelper/mediadescriptor.hxx>
#include "hwpfile.h"
#include "hcode.h"
#include "hbox.h"
...
...
@@ -82,8 +86,9 @@ using namespace ::com::sun::star::xml::sax;
#define IMPLEMENTATION_NAME "com.sun.comp.hwpimport.HwpImportFilter"
#define SERVICE_NAME "com.sun.star.document.ImportFilter"
#define WRITER_IMPORTER_NAME "com.sun.star.comp.Writer.XMLImporter"
#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection"
#define WRITER_IMPORTER_NAME "com.sun.star.comp.Writer.XMLImporter"
class
MyDataSink
:
public
::
cppu
::
WeakImplHelper2
<
XActiveDataControl
,
XActiveDataSink
>
{
...
...
@@ -193,7 +198,7 @@ private:
/* --------- Styles Parsing ------------ */
void
makePageStyle
();
void
makeColumns
(
ColumnDef
*
);
void
makeColumns
(
ColumnDef
*
);
void
makeTStyle
(
CharShape
*
);
void
makePStyle
(
ParaShape
*
);
void
makeFStyle
(
FBoxStyle
*
);
...
...
@@ -206,7 +211,7 @@ private:
char
*
getPStyleName
(
int
,
char
*
);
};
class
HwpImportFilter
:
public
WeakImplHelper
3
<
XFilter
,
XImporter
,
XServiceInfo
>
class
HwpImportFilter
:
public
WeakImplHelper
4
<
XFilter
,
XImporter
,
XServiceInfo
,
XExtendedFilterDetection
>
{
public
:
HwpImportFilter
(
const
Reference
<
XMultiServiceFactory
>
xFact
);
...
...
@@ -217,18 +222,23 @@ public:
static
OUString
getImplementationName_Static
()
throw
();
public
:
// XFilter
// XFilter
virtual
sal_Bool
SAL_CALL
filter
(
const
Sequence
<
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
);
virtual
void
SAL_CALL
cancel
()
throw
(
RuntimeException
);
// XImporter
// XImporter
virtual
void
SAL_CALL
setTargetDocument
(
const
Reference
<
XComponent
>&
xDoc
)
throw
(
IllegalArgumentException
,
RuntimeException
);
// XServiceInfo
// XServiceInfo
OUString
SAL_CALL
getImplementationName
()
throw
(
RuntimeException
);
Sequence
<
OUString
>
SAL_CALL
getSupportedServiceNames
(
void
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
sal_Bool
SAL_CALL
supportsService
(
const
OUString
&
ServiceName
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
//XExtendedFilterDetection
virtual
OUString
SAL_CALL
detect
(
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
rDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
public
:
Reference
<
XFilter
>
rFilter
;
Reference
<
XImporter
>
rImporter
;
...
...
@@ -248,6 +258,7 @@ Sequence< OUString > HwpImportFilter::getSupportedServiceNames_Static( void ) th
aRet
.
getArray
()[
0
]
=
HwpImportFilter
::
getImplementationName_Static
();
return
aRet
;
}
HwpImportFilter
::
HwpImportFilter
(
const
Reference
<
XMultiServiceFactory
>
xFact
)
{
OUString
sService
(
RTL_CONSTASCII_USTRINGPARAM
(
WRITER_IMPORTER_NAME
));
...
...
@@ -258,15 +269,14 @@ HwpImportFilter::HwpImportFilter( const Reference< XMultiServiceFactory > xFact
HwpReader
*
p
=
new
HwpReader
;
p
->
setDocumentHandler
(
xHandler
);
Sequence
<
Any
>
aArgs
(
2
);
aArgs
[
0
]
<<=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Local"
));
aArgs
[
1
]
<<=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Office"
));
Reference
<
XInterface
>
xUCB
(
xFact
->
createInstanceWithArguments
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"com.sun.star.ucb.UniversalContentBroker"
)),
aArgs
));
p
->
setUCB
(
xUCB
);
Sequence
<
Any
>
aArgs
(
2
);
aArgs
[
0
]
<<=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Local"
));
aArgs
[
1
]
<<=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Office"
));
Reference
<
XInterface
>
xUCB
(
xFact
->
createInstanceWithArguments
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"com.sun.star.ucb.UniversalContentBroker"
)),
aArgs
));
p
->
setUCB
(
xUCB
);
Reference
<
XImporter
>
xImporter
=
Reference
<
XImporter
>
(
xHandler
,
UNO_QUERY
);
rImporter
=
xImporter
;
...
...
@@ -314,6 +324,7 @@ OUString HwpImportFilter::getImplementationName() throw(::com::sun::star::uno::R
{
return
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
IMPLEMENTATION_NAME
));
}
sal_Bool
HwpImportFilter
::
supportsService
(
const
OUString
&
ServiceName
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
Sequence
<
OUString
>
aSNL
=
getSupportedServiceNames
();
...
...
@@ -326,11 +337,40 @@ sal_Bool HwpImportFilter::supportsService( const OUString& ServiceName ) throw(:
return
sal_False
;
}
//XExtendedFilterDetection
OUString
HwpImportFilter
::
detect
(
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
rDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
rtl
::
OUString
sTypeName
;
comphelper
::
MediaDescriptor
aDescriptor
(
rDescriptor
);
aDescriptor
.
addInputStream
();
Reference
<
XInputStream
>
xInputStream
(
aDescriptor
[
comphelper
::
MediaDescriptor
::
PROP_INPUTSTREAM
()],
UNO_QUERY
);
if
(
xInputStream
.
is
())
{
Sequence
<
sal_Int8
>
aData
;
sal_Int32
nLen
=
HWPIDLen
;
if
(
nLen
==
xInputStream
->
readBytes
(
aData
,
nLen
)
&&
detect_hwp_version
(
reinterpret_cast
<
const
char
*>
(
aData
.
getConstArray
()))
)
{
sTypeName
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"writer_MIZI_Hwp_97"
));
}
}
return
sTypeName
;
}
Sequence
<
OUString
>
HwpImportFilter
::
getSupportedServiceNames
(
void
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
Sequence
<
OUString
>
seq
(
1
);
seq
.
getArray
()[
0
]
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
SERVICE_NAME
));
return
seq
;
Sequence
<
OUString
>
aRet
(
2
);
OUString
*
pArray
=
aRet
.
getArray
();
pArray
[
0
]
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
SERVICE_NAME1
));
pArray
[
1
]
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
SERVICE_NAME2
));
return
aRet
;
}
/////////////////////////////////////////////////////////////////////////////////////
...
...
hwpfilter/source/makefile.mk
Dosyayı görüntüle @
1663abc7
...
...
@@ -72,6 +72,7 @@ SLOFILES = \
SHL1TARGET
=
$(TARGET)
SHL1STDLIBS
=
\
$(COMPHELPERLIB)
\
$(CPPULIB)
\
$(CPPUHELPERLIB)
\
$(SALLIB)
\
...
...
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