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
8657b48a
Kaydet (Commit)
8657b48a
authored
Nis 25, 2014
tarafından
David Tardon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
refactor to decrease the amount of copypasta
Change-Id: Ib540d79034f1963905685c1282d091bc034cf4f3
üst
0a861a50
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
368 additions
and
657 deletions
+368
-657
Library_wpftwriter.mk
writerperfect/Library_wpftwriter.mk
+1
-0
AbiWordImportFilter.cxx
writerperfect/source/writer/AbiWordImportFilter.cxx
+9
-151
AbiWordImportFilter.hxx
writerperfect/source/writer/AbiWordImportFilter.hxx
+7
-43
EBookImportFilter.cxx
writerperfect/source/writer/EBookImportFilter.cxx
+33
-183
EBookImportFilter.hxx
writerperfect/source/writer/EBookImportFilter.hxx
+7
-43
ImportFilterBase.cxx
writerperfect/source/writer/ImportFilterBase.cxx
+186
-0
ImportFilterBase.hxx
writerperfect/source/writer/ImportFilterBase.hxx
+102
-0
MSWorksImportFilter.cxx
writerperfect/source/writer/MSWorksImportFilter.cxx
+8
-151
MSWorksImportFilter.hxx
writerperfect/source/writer/MSWorksImportFilter.hxx
+7
-43
MWAWImportFilter.cxx
writerperfect/source/writer/MWAWImportFilter.cxx
+0
-0
MWAWImportFilter.hxx
writerperfect/source/writer/MWAWImportFilter.hxx
+8
-43
No files found.
writerperfect/Library_wpftwriter.mk
Dosyayı görüntüle @
8657b48a
...
...
@@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_externals,wpftwriter,\
$(eval $(call gb_Library_add_exception_objects,wpftwriter,\
writerperfect/source/writer/AbiWordImportFilter \
writerperfect/source/writer/EBookImportFilter \
writerperfect/source/writer/ImportFilterBase \
writerperfect/source/writer/MSWorksImportFilter \
writerperfect/source/writer/MWAWImportFilter \
writerperfect/source/writer/WordPerfectImportFilter \
...
...
writerperfect/source/writer/AbiWordImportFilter.cxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -9,179 +9,37 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
#include <writerperfect/DocumentHandler.hxx>
#include <writerperfect/WPXSvInputStream.hxx>
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
#include <libabw/libabw.h>
#include <libodfgen/libodfgen.hxx>
#include "AbiWordImportFilter.hxx"
#include <iostream>
using
namespace
::
com
::
sun
::
star
::
uno
;
using
com
::
sun
::
star
::
uno
::
Sequence
;
using
com
::
sun
::
star
::
uno
::
Reference
;
using
com
::
sun
::
star
::
uno
::
Any
;
using
com
::
sun
::
star
::
uno
::
UNO_QUERY
;
using
com
::
sun
::
star
::
uno
::
XInterface
;
using
com
::
sun
::
star
::
uno
::
Exception
;
using
com
::
sun
::
star
::
uno
::
RuntimeException
;
using
com
::
sun
::
star
::
beans
::
PropertyValue
;
using
com
::
sun
::
star
::
document
::
XFilter
;
using
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
;
using
com
::
sun
::
star
::
ucb
::
XCommandEnvironment
;
using
com
::
sun
::
star
::
io
::
XInputStream
;
using
com
::
sun
::
star
::
document
::
XImporter
;
using
com
::
sun
::
star
::
xml
::
sax
::
InputSource
;
using
com
::
sun
::
star
::
xml
::
sax
::
XAttributeList
;
using
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
;
using
com
::
sun
::
star
::
xml
::
sax
::
XParser
;
using
writerperfect
::
DocumentHandler
;
using
writerperfect
::
WPXSvInputStream
;
sal_Bool
SAL_CALL
AbiWordImportFilter
::
importImpl
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
)
{
SAL_INFO
(
"writerperfect"
,
"AbiWordImportFilter::importImpl"
);
sal_Int32
nLength
=
aDescriptor
.
getLength
();
const
PropertyValue
*
pValue
=
aDescriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
!
xInputStream
.
is
()
)
{
OSL_ASSERT
(
false
);
return
sal_False
;
}
// An XML import service: what we push sax messages to..
Reference
<
XDocumentHandler
>
xInternalHandler
(
mxContext
->
getServiceManager
()
->
createInstanceWithContext
(
"com.sun.star.comp.Writer.XMLOasisImporter"
,
mxContext
),
css
::
uno
::
UNO_QUERY_THROW
);
// The XImporter sets up an empty target document for XDocumentHandler to write to..
Reference
<
XImporter
>
xImporter
(
xInternalHandler
,
UNO_QUERY
);
xImporter
->
setTargetDocument
(
mxDoc
);
// OO Document Handler: abstract class to handle document SAX messages, concrete implementation here
// writes to in-memory target doc
DocumentHandler
xHandler
(
xInternalHandler
);
WPXSvInputStream
input
(
xInputStream
);
OdtGenerator
collector
(
&
xHandler
,
ODF_FLAT_XML
);
if
(
libabw
::
AbiDocument
::
parse
(
&
input
,
&
collector
))
return
sal_True
;
return
sal_False
;
}
sal_Bool
SAL_CALL
AbiWordImportFilter
::
filter
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"AbiWordImportFilter::filter"
);
return
importImpl
(
aDescriptor
);
}
void
SAL_CALL
AbiWordImportFilter
::
cancel
(
)
throw
(
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"AbiWordImportFilter::cancel"
);
}
using
com
::
sun
::
star
::
uno
::
XComponentContext
;
using
com
::
sun
::
star
::
uno
::
XInterface
;
// XImporter
void
SAL_CALL
AbiWordImportFilter
::
setTargetDocument
(
const
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
RuntimeException
,
std
::
exception
)
bool
AbiWordImportFilter
::
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
,
WPXDocumentInterface
&
rGenerator
)
{
SAL_INFO
(
"writerperfect"
,
"AbiWordImportFilter::getTargetDocument"
);
mxDoc
=
xDoc
;
return
libabw
::
AbiDocument
::
parse
(
&
rInput
,
&
rGenerator
);
}
// XExtendedFilterDetection
OUString
SAL_CALL
AbiWordImportFilter
::
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
bool
AbiWordImportFilter
::
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
{
SAL_INFO
(
"writerperfect"
,
"AbiWordImportFilter::detect"
);
OUString
sTypeName
;
sal_Int32
nLength
=
Descriptor
.
getLength
();
sal_Int32
location
=
nLength
;
const
PropertyValue
*
pValue
=
Descriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
if
(
libabw
::
AbiDocument
::
isFileFormatSupported
(
&
rInput
))
{
if
(
pValue
[
i
].
Name
==
"TypeName"
)
location
=
i
;
else
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
rTypeName
=
"writer_AbiWord_Document"
;
return
true
;
}
if
(
!
xInputStream
.
is
())
return
OUString
();
WPXSvInputStream
input
(
xInputStream
);
if
(
libabw
::
AbiDocument
::
isFileFormatSupported
(
&
input
))
sTypeName
=
"writer_AbiWord_Document"
;
if
(
!
sTypeName
.
isEmpty
())
{
if
(
location
==
nLength
)
{
Descriptor
.
realloc
(
nLength
+
1
);
Descriptor
[
location
].
Name
=
"TypeName"
;
}
Descriptor
[
location
].
Value
<<=
sTypeName
;
}
return
sTypeName
;
return
false
;
}
// XInitialization
void
SAL_CALL
AbiWordImportFilter
::
initialize
(
const
Sequence
<
Any
>&
aArguments
)
throw
(
Exception
,
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"AbiWordImportFilter::initialize"
);
Sequence
<
PropertyValue
>
aAnySeq
;
sal_Int32
nLength
=
aArguments
.
getLength
();
if
(
nLength
&&
(
aArguments
[
0
]
>>=
aAnySeq
)
)
{
const
PropertyValue
*
pValue
=
aAnySeq
.
getConstArray
();
nLength
=
aAnySeq
.
getLength
();
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"Type"
)
{
pValue
[
i
].
Value
>>=
msFilterName
;
break
;
}
}
}
}
OUString
AbiWordImportFilter_getImplementationName
()
throw
(
RuntimeException
)
{
...
...
writerperfect/source/writer/AbiWordImportFilter.hxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -10,58 +10,19 @@
#ifndef _ABIWORDIMPORTFILTER_HXX
#define _ABIWORDIMPORTFILTER_HXX
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include
<cppuhelper/implbase5.hxx>
#include
"ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class
AbiWordImportFilter
:
public
cppu
::
WeakImplHelper5
<
com
::
sun
::
star
::
document
::
XFilter
,
com
::
sun
::
star
::
document
::
XImporter
,
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
,
com
::
sun
::
star
::
lang
::
XInitialization
,
com
::
sun
::
star
::
lang
::
XServiceInfo
>
class
AbiWordImportFilter
:
public
writerperfect
::
writer
::
ImportFilterBase
{
protected
:
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
mxContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>
mxDoc
;
OUString
msFilterName
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
>
mxHandler
;
sal_Bool
SAL_CALL
importImpl
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
public
:
AbiWordImportFilter
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
&
rxContext
)
:
mxContext
(
rxContext
)
{}
virtual
~
AbiWordImportFilter
()
{}
// XFilter
virtual
sal_Bool
SAL_CALL
filter
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
virtual
void
SAL_CALL
cancel
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XImporter
virtual
void
SAL_CALL
setTargetDocument
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
//XExtendedFilterDetection
virtual
OUString
SAL_CALL
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
com
::
sun
::
star
::
beans
::
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XInitialization
virtual
void
SAL_CALL
initialize
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>&
aArguments
)
throw
(
::
com
::
sun
::
star
::
uno
::
Exception
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
:
writerperfect
::
writer
::
ImportFilterBase
(
rxContext
)
{}
// XServiceInfo
virtual
OUString
SAL_CALL
getImplementationName
(
)
...
...
@@ -71,6 +32,9 @@ public:
virtual
::
com
::
sun
::
star
::
uno
::
Sequence
<
OUString
>
SAL_CALL
getSupportedServiceNames
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
private
:
virtual
bool
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
SAL_OVERRIDE
;
virtual
bool
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
rFilterName
,
WPXDocumentInterface
&
rGenerator
)
SAL_OVERRIDE
;
};
OUString
AbiWordImportFilter_getImplementationName
()
...
...
writerperfect/source/writer/EBookImportFilter.cxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -9,209 +9,59 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
#include <writerperfect/DocumentHandler.hxx>
#include <writerperfect/WPXSvInputStream.hxx>
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
#include <libe-book/libe-book.h>
#include <libodfgen/libodfgen.hxx>
#include "EBookImportFilter.hxx"
#include <iostream>
using
namespace
::
com
::
sun
::
star
::
uno
;
using
com
::
sun
::
star
::
uno
::
Sequence
;
using
com
::
sun
::
star
::
uno
::
Reference
;
using
com
::
sun
::
star
::
uno
::
Any
;
using
com
::
sun
::
star
::
uno
::
UNO_QUERY
;
using
com
::
sun
::
star
::
uno
::
XInterface
;
using
com
::
sun
::
star
::
uno
::
Exception
;
using
com
::
sun
::
star
::
uno
::
RuntimeException
;
using
com
::
sun
::
star
::
beans
::
PropertyValue
;
using
com
::
sun
::
star
::
document
::
XFilter
;
using
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
;
using
com
::
sun
::
star
::
ucb
::
XCommandEnvironment
;
using
com
::
sun
::
star
::
io
::
XInputStream
;
using
com
::
sun
::
star
::
document
::
XImporter
;
using
com
::
sun
::
star
::
xml
::
sax
::
InputSource
;
using
com
::
sun
::
star
::
xml
::
sax
::
XAttributeList
;
using
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
;
using
com
::
sun
::
star
::
xml
::
sax
::
XParser
;
using
writerperfect
::
DocumentHandler
;
using
writerperfect
::
WPXSvInputStream
;
sal_Bool
SAL_CALL
EBookImportFilter
::
importImpl
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
)
{
SAL_INFO
(
"writerperfect"
,
"EBookImportFilter::importImpl"
);
sal_Int32
nLength
=
aDescriptor
.
getLength
();
const
PropertyValue
*
pValue
=
aDescriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
rtl
::
OUString
sFilterName
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"FilterName"
)
pValue
[
i
].
Value
>>=
sFilterName
;
else
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
sFilterName
.
isEmpty
()
)
{
OSL_ASSERT
(
false
);
return
sal_False
;
}
if
(
!
xInputStream
.
is
()
)
{
OSL_ASSERT
(
false
);
return
sal_False
;
}
// An XML import service: what we push sax messages to..
Reference
<
XDocumentHandler
>
xInternalHandler
(
mxContext
->
getServiceManager
()
->
createInstanceWithContext
(
"com.sun.star.comp.Writer.XMLOasisImporter"
,
mxContext
),
css
::
uno
::
UNO_QUERY_THROW
);
// The XImporter sets up an empty target document for XDocumentHandler to write to..
Reference
<
XImporter
>
xImporter
(
xInternalHandler
,
UNO_QUERY
);
xImporter
->
setTargetDocument
(
mxDoc
);
// OO Document Handler: abstract class to handle document SAX messages, concrete implementation here
// writes to in-memory target doc
DocumentHandler
xHandler
(
xInternalHandler
);
WPXSvInputStream
input
(
xInputStream
);
OdtGenerator
collector
(
&
xHandler
,
ODF_FLAT_XML
);
if
(
sFilterName
==
"FictionBook 2"
)
return
libebook
::
FB2Document
::
parse
(
&
input
,
&
collector
);
else
if
(
sFilterName
==
"PalmDoc"
)
return
libebook
::
PDBDocument
::
parse
(
&
input
,
&
collector
);
else
if
(
sFilterName
==
"Plucker eBook"
)
return
libebook
::
PLKRDocument
::
parse
(
&
input
,
&
collector
);
else
if
(
sFilterName
==
"eReader eBook"
)
return
libebook
::
PMLDocument
::
parse
(
&
input
,
&
collector
);
else
if
(
sFilterName
==
"TealDoc"
)
return
libebook
::
TDDocument
::
parse
(
&
input
,
&
collector
);
else
if
(
sFilterName
==
"zTXT"
)
return
libebook
::
ZTXTDocument
::
parse
(
&
input
,
&
collector
);
return
sal_False
;
}
using
com
::
sun
::
star
::
uno
::
XComponentContext
;
sal_Bool
SAL_CALL
EBookImportFilter
::
filter
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"EBookImportFilter::filter"
);
return
importImpl
(
aDescriptor
);
}
void
SAL_CALL
EBookImportFilter
::
cancel
(
)
throw
(
RuntimeException
,
std
::
exception
)
bool
EBookImportFilter
::
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
rFilterName
,
WPXDocumentInterface
&
rGenerator
)
{
SAL_INFO
(
"writerperfect"
,
"EBookImportFilter::cancel"
);
if
(
rFilterName
==
"FictionBook 2"
)
return
libebook
::
FB2Document
::
parse
(
&
rInput
,
&
rGenerator
);
else
if
(
rFilterName
==
"PalmDoc"
)
return
libebook
::
PDBDocument
::
parse
(
&
rInput
,
&
rGenerator
);
else
if
(
rFilterName
==
"Plucker eBook"
)
return
libebook
::
PLKRDocument
::
parse
(
&
rInput
,
&
rGenerator
);
else
if
(
rFilterName
==
"eReader eBook"
)
return
libebook
::
PMLDocument
::
parse
(
&
rInput
,
&
rGenerator
);
else
if
(
rFilterName
==
"TealDoc"
)
return
libebook
::
TDDocument
::
parse
(
&
rInput
,
&
rGenerator
);
else
if
(
rFilterName
==
"zTXT"
)
return
libebook
::
ZTXTDocument
::
parse
(
&
rInput
,
&
rGenerator
);
return
false
;
}
// XImporter
void
SAL_CALL
EBookImportFilter
::
setTargetDocument
(
const
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
RuntimeException
,
std
::
exception
)
bool
EBookImportFilter
::
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
{
SAL_INFO
(
"writerperfect"
,
"EBookImportFilter::getTargetDocument"
);
mxDoc
=
xDoc
;
}
// XExtendedFilterDetection
OUString
SAL_CALL
EBookImportFilter
::
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"EBookImportFilter::detect"
);
OUString
sTypeName
;
sal_Int32
nLength
=
Descriptor
.
getLength
();
sal_Int32
location
=
nLength
;
const
PropertyValue
*
pValue
=
Descriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"TypeName"
)
location
=
i
;
else
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
!
xInputStream
.
is
())
return
OUString
();
WPXSvInputStream
input
(
xInputStream
);
if
(
libebook
::
FB2Document
::
isSupported
(
&
input
))
sTypeName
=
"writer_FictionBook_2"
;
else
if
(
libebook
::
PDBDocument
::
isSupported
(
&
input
))
sTypeName
=
"writer_PalmDoc"
;
else
if
(
libebook
::
PLKRDocument
::
isSupported
(
&
input
))
sTypeName
=
"writer_Plucker_eBook"
;
else
if
(
libebook
::
PMLDocument
::
isSupported
(
&
input
))
sTypeName
=
"writer_eReader_eBook"
;
else
if
(
libebook
::
TDDocument
::
isSupported
(
&
input
))
sTypeName
=
"writer_TealDoc"
;
else
if
(
libebook
::
ZTXTDocument
::
isSupported
(
&
input
))
sTypeName
=
"writer_zTXT"
;
if
(
!
sTypeName
.
isEmpty
())
{
if
(
location
==
nLength
)
{
Descriptor
.
realloc
(
nLength
+
1
);
Descriptor
[
location
].
Name
=
"TypeName"
;
}
Descriptor
[
location
].
Value
<<=
sTypeName
;
}
return
sTypeName
;
rTypeName
=
""
;
if
(
libebook
::
FB2Document
::
isSupported
(
&
rInput
))
rTypeName
=
"writer_FictionBook_2"
;
else
if
(
libebook
::
PDBDocument
::
isSupported
(
&
rInput
))
rTypeName
=
"writer_PalmDoc"
;
else
if
(
libebook
::
PLKRDocument
::
isSupported
(
&
rInput
))
rTypeName
=
"writer_Plucker_eBook"
;
else
if
(
libebook
::
PMLDocument
::
isSupported
(
&
rInput
))
rTypeName
=
"writer_eReader_eBook"
;
else
if
(
libebook
::
TDDocument
::
isSupported
(
&
rInput
))
rTypeName
=
"writer_TealDoc"
;
else
if
(
libebook
::
ZTXTDocument
::
isSupported
(
&
rInput
))
rTypeName
=
"writer_zTXT"
;
return
!
rTypeName
.
isEmpty
();
}
// XInitialization
void
SAL_CALL
EBookImportFilter
::
initialize
(
const
Sequence
<
Any
>&
aArguments
)
throw
(
Exception
,
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"EBookImportFilter::initialize"
);
Sequence
<
PropertyValue
>
aAnySeq
;
sal_Int32
nLength
=
aArguments
.
getLength
();
if
(
nLength
&&
(
aArguments
[
0
]
>>=
aAnySeq
)
)
{
const
PropertyValue
*
pValue
=
aAnySeq
.
getConstArray
();
nLength
=
aAnySeq
.
getLength
();
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"Type"
)
{
pValue
[
i
].
Value
>>=
msFilterName
;
break
;
}
}
}
}
OUString
EBookImportFilter_getImplementationName
()
throw
(
RuntimeException
)
{
...
...
writerperfect/source/writer/EBookImportFilter.hxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -10,58 +10,19 @@
#ifndef EBOOKIMPORTFILTER_HXX
#define EBOOKIMPORTFILTER_HXX
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include
<cppuhelper/implbase5.hxx>
#include
"ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class
EBookImportFilter
:
public
cppu
::
WeakImplHelper5
<
com
::
sun
::
star
::
document
::
XFilter
,
com
::
sun
::
star
::
document
::
XImporter
,
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
,
com
::
sun
::
star
::
lang
::
XInitialization
,
com
::
sun
::
star
::
lang
::
XServiceInfo
>
class
EBookImportFilter
:
public
writerperfect
::
writer
::
ImportFilterBase
{
protected
:
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
mxContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>
mxDoc
;
OUString
msFilterName
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
>
mxHandler
;
sal_Bool
SAL_CALL
importImpl
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
public
:
EBookImportFilter
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
&
rxContext
)
:
mxContext
(
rxContext
)
{}
virtual
~
EBookImportFilter
()
{}
// XFilter
virtual
sal_Bool
SAL_CALL
filter
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
virtual
void
SAL_CALL
cancel
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XImporter
virtual
void
SAL_CALL
setTargetDocument
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
//XExtendedFilterDetection
virtual
OUString
SAL_CALL
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
com
::
sun
::
star
::
beans
::
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XInitialization
virtual
void
SAL_CALL
initialize
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>&
aArguments
)
throw
(
::
com
::
sun
::
star
::
uno
::
Exception
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
:
writerperfect
::
writer
::
ImportFilterBase
(
rxContext
)
{}
// XServiceInfo
virtual
OUString
SAL_CALL
getImplementationName
(
)
...
...
@@ -71,6 +32,9 @@ public:
virtual
::
com
::
sun
::
star
::
uno
::
Sequence
<
OUString
>
SAL_CALL
getSupportedServiceNames
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
private
:
virtual
bool
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
SAL_OVERRIDE
;
virtual
bool
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
rFilterName
,
WPXDocumentInterface
&
rGenerator
)
SAL_OVERRIDE
;
};
OUString
EBookImportFilter_getImplementationName
()
...
...
writerperfect/source/writer/ImportFilterBase.cxx
0 → 100644
Dosyayı görüntüle @
8657b48a
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
#include <writerperfect/DocumentHandler.hxx>
#include <writerperfect/WPXSvInputStream.hxx>
#include <xmloff/attrlist.hxx>
#include "ImportFilterBase.hxx"
namespace
writerperfect
{
namespace
writer
{
using
com
::
sun
::
star
::
uno
::
Reference
;
using
com
::
sun
::
star
::
io
::
XInputStream
;
using
com
::
sun
::
star
::
io
::
XSeekable
;
using
com
::
sun
::
star
::
uno
::
Sequence
;
using
com
::
sun
::
star
::
uno
::
Any
;
using
com
::
sun
::
star
::
uno
::
UNO_QUERY
;
using
com
::
sun
::
star
::
uno
::
XInterface
;
using
com
::
sun
::
star
::
uno
::
Exception
;
using
com
::
sun
::
star
::
uno
::
RuntimeException
;
using
com
::
sun
::
star
::
beans
::
PropertyValue
;
using
com
::
sun
::
star
::
document
::
XFilter
;
using
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
;
using
com
::
sun
::
star
::
document
::
XImporter
;
using
com
::
sun
::
star
::
xml
::
sax
::
InputSource
;
using
com
::
sun
::
star
::
xml
::
sax
::
XAttributeList
;
using
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
;
using
com
::
sun
::
star
::
xml
::
sax
::
XParser
;
using
writerperfect
::
DocumentHandler
;
using
writerperfect
::
WPXSvInputStream
;
ImportFilterImpl
::
ImportFilterImpl
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
&
rxContext
)
:
mxContext
(
rxContext
)
{
}
ImportFilterImpl
::~
ImportFilterImpl
()
{
}
sal_Bool
SAL_CALL
ImportFilterImpl
::
filter
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"ImportFilterImpl::filter"
);
sal_Int32
nLength
=
aDescriptor
.
getLength
();
const
PropertyValue
*
pValue
=
aDescriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
rtl
::
OUString
sFilterName
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"FilterName"
)
pValue
[
i
].
Value
>>=
sFilterName
;
else
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
!
xInputStream
.
is
()
)
{
OSL_ASSERT
(
false
);
return
sal_False
;
}
// An XML import service: what we push sax messages to..
Reference
<
XDocumentHandler
>
xInternalHandler
(
mxContext
->
getServiceManager
()
->
createInstanceWithContext
(
"com.sun.star.comp.Writer.XMLOasisImporter"
,
mxContext
),
css
::
uno
::
UNO_QUERY_THROW
);
// The XImporter sets up an empty target document for XDocumentHandler to write to..
Reference
<
XImporter
>
xImporter
(
xInternalHandler
,
UNO_QUERY
);
xImporter
->
setTargetDocument
(
mxDoc
);
// OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
// writes to in-memory target doc
DocumentHandler
xHandler
(
xInternalHandler
);
WPXSvInputStream
input
(
xInputStream
);
OdtGenerator
exporter
(
&
xHandler
,
ODF_FLAT_XML
);
doRegisterHandlers
(
exporter
);
return
doImportDocument
(
input
,
sFilterName
,
exporter
);
}
void
SAL_CALL
ImportFilterImpl
::
cancel
(
)
throw
(
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"ImportFilterImpl::cancel"
);
}
// XImporter
void
SAL_CALL
ImportFilterImpl
::
setTargetDocument
(
const
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"ImportFilterImpl::setTargetDocument"
);
mxDoc
=
xDoc
;
}
// XExtendedFilterDetection
OUString
SAL_CALL
ImportFilterImpl
::
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"ImportFilterImpl::detect"
);
OUString
sTypeName
;
sal_Int32
nLength
=
Descriptor
.
getLength
();
sal_Int32
location
=
nLength
;
const
PropertyValue
*
pValue
=
Descriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"TypeName"
)
location
=
i
;
else
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
!
xInputStream
.
is
())
return
OUString
();
WPXSvInputStream
input
(
xInputStream
);
if
(
doDetectFormat
(
input
,
sTypeName
)
)
{
assert
(
!
sTypeName
.
isEmpty
());
if
(
location
==
nLength
)
{
Descriptor
.
realloc
(
nLength
+
1
);
Descriptor
[
location
].
Name
=
"TypeName"
;
}
Descriptor
[
location
].
Value
<<=
sTypeName
;
}
return
sTypeName
;
}
// XInitialization
void
SAL_CALL
ImportFilterImpl
::
initialize
(
const
Sequence
<
Any
>&
aArguments
)
throw
(
Exception
,
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"ImportFilterImpl::initialize"
);
Sequence
<
PropertyValue
>
aAnySeq
;
sal_Int32
nLength
=
aArguments
.
getLength
();
if
(
nLength
&&
(
aArguments
[
0
]
>>=
aAnySeq
)
)
{
const
PropertyValue
*
pValue
=
aAnySeq
.
getConstArray
();
nLength
=
aAnySeq
.
getLength
();
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"Type"
)
{
pValue
[
i
].
Value
>>=
msFilterName
;
break
;
}
}
}
}
void
ImportFilterImpl
::
doRegisterHandlers
(
OdtGenerator
&
)
{
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
writerperfect/source/writer/ImportFilterBase.hxx
0 → 100644
Dosyayı görüntüle @
8657b48a
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_WRITERPERFECT_SOURCE_WRITER_IMPORTFILTERBASE_HXX
#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_IMPORTFILTERBASE_HXX
#include <libodfgen/libodfgen.hxx>
#include <libwpd/libwpd.h>
#include <libwpd-stream/libwpd-stream.h>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase4.hxx>
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
beans
{
struct
PropertyValue
;
}
namespace
lang
{
class
XComponent
;
}
namespace
uno
{
class
XComponentContext
;
}
namespace
xml
{
namespace
sax
{
class
XDocumentHandler
;
}
}
}
}
}
namespace
writerperfect
{
namespace
writer
{
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class
ImportFilterImpl
:
public
cppu
::
WeakImplHelper4
<
com
::
sun
::
star
::
document
::
XFilter
,
com
::
sun
::
star
::
document
::
XImporter
,
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
,
com
::
sun
::
star
::
lang
::
XInitialization
>
{
public
:
ImportFilterImpl
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
&
rxContext
);
virtual
~
ImportFilterImpl
();
// XFilter
virtual
sal_Bool
SAL_CALL
filter
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
virtual
void
SAL_CALL
cancel
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XImporter
virtual
void
SAL_CALL
setTargetDocument
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
//XExtendedFilterDetection
virtual
OUString
SAL_CALL
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
com
::
sun
::
star
::
beans
::
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XInitialization
virtual
void
SAL_CALL
initialize
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>&
aArguments
)
throw
(
::
com
::
sun
::
star
::
uno
::
Exception
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
private
:
virtual
bool
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
=
0
;
virtual
bool
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
rFilterName
,
WPXDocumentInterface
&
rGenerator
)
=
0
;
virtual
void
doRegisterHandlers
(
OdtGenerator
&
rGenerator
);
private
:
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
mxContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>
mxDoc
;
OUString
msFilterName
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
>
mxHandler
;
};
/** A base class for import filters.
*/
typedef
cppu
::
ImplInheritanceHelper1
<
ImportFilterImpl
,
com
::
sun
::
star
::
lang
::
XServiceInfo
>
ImportFilterBase
;
}
}
#endif // INCLUDED_WRITERPERFECT_SOURCE_WRITER_IMPORTFILTERBASE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
writerperfect/source/writer/MSWorksImportFilter.cxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -9,182 +9,39 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
#include <writerperfect/DocumentHandler.hxx>
#include <writerperfect/WPXSvInputStream.hxx>
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
#include <libwps/libwps.h>
#include <libodfgen/libodfgen.hxx>
#include "MSWorksImportFilter.hxx"
#include <iostream>
using
namespace
::
com
::
sun
::
star
::
uno
;
using
com
::
sun
::
star
::
uno
::
Sequence
;
using
com
::
sun
::
star
::
uno
::
Reference
;
using
com
::
sun
::
star
::
uno
::
Any
;
using
com
::
sun
::
star
::
uno
::
UNO_QUERY
;
using
com
::
sun
::
star
::
uno
::
XInterface
;
using
com
::
sun
::
star
::
uno
::
Exception
;
using
com
::
sun
::
star
::
uno
::
RuntimeException
;
using
com
::
sun
::
star
::
beans
::
PropertyValue
;
using
com
::
sun
::
star
::
document
::
XFilter
;
using
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
;
using
com
::
sun
::
star
::
ucb
::
XCommandEnvironment
;
using
com
::
sun
::
star
::
io
::
XInputStream
;
using
com
::
sun
::
star
::
document
::
XImporter
;
using
com
::
sun
::
star
::
xml
::
sax
::
InputSource
;
using
com
::
sun
::
star
::
xml
::
sax
::
XAttributeList
;
using
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
;
using
com
::
sun
::
star
::
xml
::
sax
::
XParser
;
using
com
::
sun
::
star
::
uno
::
XComponentContext
;
using
writerperfect
::
DocumentHandler
;
using
writerperfect
::
WPXSvInputStream
;
sal_Bool
SAL_CALL
MSWorksImportFilter
::
importImpl
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
)
bool
MSWorksImportFilter
::
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
,
WPXDocumentInterface
&
rGenerator
)
{
SAL_INFO
(
"writerperfect"
,
"MSWorksImportFilter::importImpl"
);
sal_Int32
nLength
=
aDescriptor
.
getLength
();
const
PropertyValue
*
pValue
=
aDescriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
!
xInputStream
.
is
()
)
{
OSL_ASSERT
(
false
);
return
sal_False
;
}
// An XML import service: what we push sax messages to..
Reference
<
XDocumentHandler
>
xInternalHandler
(
mxContext
->
getServiceManager
()
->
createInstanceWithContext
(
"com.sun.star.comp.Writer.XMLOasisImporter"
,
mxContext
),
css
::
uno
::
UNO_QUERY_THROW
);
// The XImporter sets up an empty target document for XDocumentHandler to write to..
Reference
<
XImporter
>
xImporter
(
xInternalHandler
,
UNO_QUERY
);
xImporter
->
setTargetDocument
(
mxDoc
);
// OO Document Handler: abstract class to handle document SAX messages, concrete implementation here
// writes to in-memory target doc
DocumentHandler
xHandler
(
xInternalHandler
);
WPXSvInputStream
input
(
xInputStream
);
OdtGenerator
collector
(
&
xHandler
,
ODF_FLAT_XML
);
if
(
WPS_OK
==
WPSDocument
::
parse
(
&
input
,
&
collector
))
return
sal_True
;
return
sal_False
;
return
WPS_OK
==
WPSDocument
::
parse
(
&
rInput
,
&
rGenerator
);
}
sal_Bool
SAL_CALL
MSWorksImportFilter
::
filter
(
const
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
RuntimeException
,
std
::
exception
)
bool
MSWorksImportFilter
::
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
{
SAL_INFO
(
"writerperfect"
,
"MSWorksImportFilter::filter"
);
return
importImpl
(
aDescriptor
);
}
void
SAL_CALL
MSWorksImportFilter
::
cancel
(
)
throw
(
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"MSWorksImportFilter::cancel"
);
}
// XImporter
void
SAL_CALL
MSWorksImportFilter
::
setTargetDocument
(
const
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"MSWorksImportFilter::getTargetDocument"
);
mxDoc
=
xDoc
;
}
// XExtendedFilterDetection
OUString
SAL_CALL
MSWorksImportFilter
::
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"MSWorksImportFilter::detect"
);
WPSConfidence
confidence
=
WPS_CONFIDENCE_NONE
;
OUString
sTypeName
;
sal_Int32
nLength
=
Descriptor
.
getLength
();
sal_Int32
location
=
nLength
;
const
PropertyValue
*
pValue
=
Descriptor
.
getConstArray
();
Reference
<
XInputStream
>
xInputStream
;
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"TypeName"
)
location
=
i
;
else
if
(
pValue
[
i
].
Name
==
"InputStream"
)
pValue
[
i
].
Value
>>=
xInputStream
;
}
if
(
!
xInputStream
.
is
())
return
OUString
();
WPXSvInputStream
input
(
xInputStream
);
confidence
=
WPSDocument
::
isFileFormatSupported
(
&
input
);
const
WPSConfidence
confidence
=
WPSDocument
::
isFileFormatSupported
(
&
rInput
);
if
((
confidence
==
WPS_CONFIDENCE_EXCELLENT
)
||
(
confidence
==
WPS_CONFIDENCE_GOOD
))
sTypeName
=
"writer_MS_Works_Document"
;
if
(
!
sTypeName
.
isEmpty
())
{
if
(
location
==
nLength
)
{
Descriptor
.
realloc
(
nLength
+
1
);
Descriptor
[
location
].
Name
=
"TypeName"
;
}
Descriptor
[
location
].
Value
<<=
sTypeName
;
rTypeName
=
"writer_MS_Works_Document"
;
return
true
;
}
return
sTypeNam
e
;
return
fals
e
;
}
// XInitialization
void
SAL_CALL
MSWorksImportFilter
::
initialize
(
const
Sequence
<
Any
>&
aArguments
)
throw
(
Exception
,
RuntimeException
,
std
::
exception
)
{
SAL_INFO
(
"writerperfect"
,
"MSWorksImportFilter::initialize"
);
Sequence
<
PropertyValue
>
aAnySeq
;
sal_Int32
nLength
=
aArguments
.
getLength
();
if
(
nLength
&&
(
aArguments
[
0
]
>>=
aAnySeq
)
)
{
const
PropertyValue
*
pValue
=
aAnySeq
.
getConstArray
();
nLength
=
aAnySeq
.
getLength
();
for
(
sal_Int32
i
=
0
;
i
<
nLength
;
i
++
)
{
if
(
pValue
[
i
].
Name
==
"Type"
)
{
pValue
[
i
].
Value
>>=
msFilterName
;
break
;
}
}
}
}
OUString
MSWorksImportFilter_getImplementationName
()
throw
(
RuntimeException
)
{
...
...
writerperfect/source/writer/MSWorksImportFilter.hxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -10,58 +10,19 @@
#ifndef _MSWORKSIMPORTFILTER_HXX
#define _MSWORKSIMPORTFILTER_HXX
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include
<cppuhelper/implbase5.hxx>
#include
"ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class
MSWorksImportFilter
:
public
cppu
::
WeakImplHelper5
<
com
::
sun
::
star
::
document
::
XFilter
,
com
::
sun
::
star
::
document
::
XImporter
,
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
,
com
::
sun
::
star
::
lang
::
XInitialization
,
com
::
sun
::
star
::
lang
::
XServiceInfo
>
class
MSWorksImportFilter
:
public
writerperfect
::
writer
::
ImportFilterBase
{
protected
:
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
mxContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>
mxDoc
;
OUString
msFilterName
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
>
mxHandler
;
sal_Bool
SAL_CALL
importImpl
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
public
:
MSWorksImportFilter
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
&
rxContext
)
:
mxContext
(
rxContext
)
{}
virtual
~
MSWorksImportFilter
()
{}
// XFilter
virtual
sal_Bool
SAL_CALL
filter
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
virtual
void
SAL_CALL
cancel
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XImporter
virtual
void
SAL_CALL
setTargetDocument
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
//XExtendedFilterDetection
virtual
OUString
SAL_CALL
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
com
::
sun
::
star
::
beans
::
PropertyValue
>&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XInitialization
virtual
void
SAL_CALL
initialize
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>&
aArguments
)
throw
(
::
com
::
sun
::
star
::
uno
::
Exception
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
:
writerperfect
::
writer
::
ImportFilterBase
(
rxContext
)
{}
// XServiceInfo
virtual
OUString
SAL_CALL
getImplementationName
(
)
...
...
@@ -71,6 +32,9 @@ public:
virtual
::
com
::
sun
::
star
::
uno
::
Sequence
<
OUString
>
SAL_CALL
getSupportedServiceNames
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
private
:
virtual
bool
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
SAL_OVERRIDE
;
virtual
bool
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
rFilterName
,
WPXDocumentInterface
&
rGenerator
)
SAL_OVERRIDE
;
};
OUString
MSWorksImportFilter_getImplementationName
()
...
...
writerperfect/source/writer/MWAWImportFilter.cxx
Dosyayı görüntüle @
8657b48a
This diff is collapsed.
Click to expand it.
writerperfect/source/writer/MWAWImportFilter.hxx
Dosyayı görüntüle @
8657b48a
...
...
@@ -10,58 +10,19 @@
#ifndef _MWAWIMPORTFILTER_HXX
#define _MWAWIMPORTFILTER_HXX
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include
<cppuhelper/implbase5.hxx>
#include
"ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class
MWAWImportFilter
:
public
cppu
::
WeakImplHelper5
<
com
::
sun
::
star
::
document
::
XFilter
,
com
::
sun
::
star
::
document
::
XImporter
,
com
::
sun
::
star
::
document
::
XExtendedFilterDetection
,
com
::
sun
::
star
::
lang
::
XInitialization
,
com
::
sun
::
star
::
lang
::
XServiceInfo
>
class
MWAWImportFilter
:
public
writerperfect
::
writer
::
ImportFilterBase
{
protected
:
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
mxContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>
mxDoc
;
OUString
msFilterName
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XDocumentHandler
>
mxHandler
;
sal_Bool
SAL_CALL
importImpl
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>
&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
public
:
MWAWImportFilter
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
&
rxContext
)
:
mxContext
(
rxContext
)
{}
virtual
~
MWAWImportFilter
()
{}
// XFilter
virtual
sal_Bool
SAL_CALL
filter
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>
&
aDescriptor
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
virtual
void
SAL_CALL
cancel
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XImporter
virtual
void
SAL_CALL
setTargetDocument
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XComponent
>
&
xDoc
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
//XExtendedFilterDetection
virtual
OUString
SAL_CALL
detect
(
com
::
sun
::
star
::
uno
::
Sequence
<
com
::
sun
::
star
::
beans
::
PropertyValue
>
&
Descriptor
)
throw
(
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
// XInitialization
virtual
void
SAL_CALL
initialize
(
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>
&
aArguments
)
throw
(
::
com
::
sun
::
star
::
uno
::
Exception
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
:
writerperfect
::
writer
::
ImportFilterBase
(
rxContext
)
{}
// XServiceInfo
virtual
OUString
SAL_CALL
getImplementationName
(
)
...
...
@@ -71,6 +32,10 @@ public:
virtual
::
com
::
sun
::
star
::
uno
::
Sequence
<
OUString
>
SAL_CALL
getSupportedServiceNames
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
,
std
::
exception
)
SAL_OVERRIDE
;
private
:
virtual
bool
doDetectFormat
(
WPXInputStream
&
rInput
,
OUString
&
rTypeName
)
SAL_OVERRIDE
;
virtual
bool
doImportDocument
(
WPXInputStream
&
rInput
,
const
rtl
::
OUString
&
rFilterName
,
WPXDocumentInterface
&
rGenerator
)
SAL_OVERRIDE
;
virtual
void
doRegisterHandlers
(
OdtGenerator
&
rGenerator
)
SAL_OVERRIDE
;
};
OUString
MWAWImportFilter_getImplementationName
()
...
...
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