View | Details | Raw Unified | Return to issue 11215
Collapse All | Expand All

(-) (+420 lines)
Added Link Here
1
#ifndef _OSL_DIAGNOSE_H_
2
#include <osl/diagnose.h>
3
#endif
4
#ifndef _RTL_TENCINFO_H_
5
#include <rtl/tencinfo.h>
6
#endif
7
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
8
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
9
#endif
10
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
11
#include <com/sun/star/io/XInputStream.hpp>
12
#endif
13
#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
14
#include <com/sun/star/xml/sax/XAttributeList.hpp>
15
#endif
16
#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
17
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
18
#endif
19
#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
20
#include <com/sun/star/xml/sax/XParser.hpp>
21
#endif
22
#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP
23
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
24
#endif
25
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
26
#include <com/sun/star/io/XInputStream.hpp>
27
#endif
28
#ifndef _ATTRLIST_HPP_
29
#include <xmloff/attrlist.hxx>
30
#endif
31
#ifndef _XMLKYWD_HPP
32
#include <xmloff/xmlkywd.hxx>
33
#endif
34
35
#ifndef _UCBHELPER_CONTENT_HXX
36
#include <ucbhelper/content.hxx>
37
#endif
38
39
#include <tools/stream.hxx>
40
41
#include "LotusWordProImportFilter.hxx"
42
43
#include <vector>
44
45
using namespace ::rtl;
46
using rtl::OString;
47
using rtl::OUStringBuffer;
48
using rtl::OUString;
49
using com::sun::star::uno::Sequence;
50
using com::sun::star::uno::Reference;
51
using com::sun::star::lang::XComponent;
52
using com::sun::star::uno::Any;
53
using com::sun::star::uno::UNO_QUERY;
54
using com::sun::star::uno::XInterface;
55
using com::sun::star::uno::Exception;
56
using com::sun::star::uno::RuntimeException;
57
using com::sun::star::io::XInputStream;
58
using com::sun::star::lang::XMultiServiceFactory;
59
using com::sun::star::beans::PropertyValue;
60
using com::sun::star::document::XFilter;
61
using com::sun::star::document::XExtendedFilterDetection;
62
using com::sun::star::ucb::XCommandEnvironment;
63
64
using com::sun::star::document::XImporter;
65
using com::sun::star::xml::sax::XAttributeList;
66
using com::sun::star::xml::sax::XDocumentHandler;
67
using com::sun::star::xml::sax::XParser;
68
69
//                                 W     o     r     d     P     r     o
70
static const sal_Int8 header[] = { 0x57, 0x6f, 0x72, 0x64, 0x50, 0x72, 0x6f };
71
72
const sal_Int32 MAXCHARS = 65534;
73
74
 // Simple xml importer, currently the importer is very very simple
75
 // it only extracts pure text from the wordpro file. Absolutely no formating
76
 // information is currently imported.
77
 // To reflect the current state of this importer the sax events sent 
78
 // to the document handler are also the simplest possible. In addition to
79
 // the the basic attributes set up for the 'office:document' element
80
 // all the imported text is inserted into 'text:p' elements. 
81
 // The parser extracts the pure text and creates simple a simple 'text:p'
82
 // element to contain that text. In the event of the text exceeding 
83
 // MAXCHARS new 'text:p' elements are created as needed 
84
class SimpleXMLImporter
85
{
86
private:
87
88
    Reference< XDocumentHandler > m_xDocHandler;
89
    std::vector< OUString > m_vStringChunks;
90
    SvStream& m_InputStream; 
91
92
    bool CheckValidData( sal_Int8 nChar )
93
    {
94
        if( ( nChar >= 0x20 && nChar <= 0x7E ) && ( nChar != 0X40 ) )
95
            return  true;
96
        return false;				   
97
    } 
98
99
    void addAttribute( SvXMLAttributeList* pAttrList, const char* key, const char* val )
100
    {
101
        pAttrList->AddAttribute( OUString::createFromAscii( key ), OUString::createFromAscii( val ) );
102
    }
103
104
    void writeTextChunk( const OUString& sChunk )
105
    {
106
        SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
107
        Reference < XAttributeList > xAttrList(pAttrList);
108
109
        pAttrList->AddAttribute( OUString(RTL_CONSTASCII_USTRINGPARAM("text:style-name")),  OUString(RTL_CONSTASCII_USTRINGPARAM("Standard")));
110
111
        m_xDocHandler->startElement( OUString(RTL_CONSTASCII_USTRINGPARAM("text:p")), xAttrList  );
112
        m_xDocHandler->characters( sChunk );
113
        m_xDocHandler->endElement( OUString(RTL_CONSTASCII_USTRINGPARAM("text:p") ) );
114
    }
115
116
    void writeDocContentPreamble()
117
    {
118
        SvXMLAttributeList *pDocContentPropList = new SvXMLAttributeList();
119
	Reference < XAttributeList > xDocContentList(pDocContentPropList);
120
        addAttribute( pDocContentPropList, "xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" );
121
        addAttribute( pDocContentPropList, "xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
122
        addAttribute( pDocContentPropList, "xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" );
123
        addAttribute( pDocContentPropList, "xmlns:table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" );
124
        addAttribute( pDocContentPropList, "xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" );
125
        addAttribute( pDocContentPropList, "xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" );
126
        addAttribute( pDocContentPropList, "xmlns:xlink", "http://www.w3.org/1999/xlink" );
127
        addAttribute( pDocContentPropList, "xmlns:dc", "http://purl.org/dc/elements/1.1/" );
128
        addAttribute( pDocContentPropList, "xmlns:meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0" );
129
        addAttribute( pDocContentPropList, "xmlns:number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" );
130
        addAttribute( pDocContentPropList, "xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" );
131
        addAttribute( pDocContentPropList, "xmlns:chart", "urn:oasis:names:tc:opendocument:xmlns:chart:1.0" );
132
        addAttribute( pDocContentPropList, "xmlns:dr3d", "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" );
133
        addAttribute( pDocContentPropList, "xmlns:math", "http://www.w3.org/1998/Math/MathML" );
134
        addAttribute( pDocContentPropList, "xmlns:form", "urn:oasis:names:tc:opendocument:xmlns:form:1.0" );
135
        addAttribute( pDocContentPropList, "xmlns:script", "urn:oasis:names:tc:opendocument:xmlns:script:1.0" );
136
        addAttribute( pDocContentPropList, "xmlns:ooo", "http://openoffice.org/2004/office" );
137
        addAttribute( pDocContentPropList, "xmlns:ooow", "http://openoffice.org/2004/writer" );
138
        addAttribute( pDocContentPropList, "xmlns:oooc", "http://openoffice.org/2004/calc" );
139
        addAttribute( pDocContentPropList, "xmlns:dom", "http://www.w3.org/2001/xml-events" );
140
        addAttribute( pDocContentPropList, "xmlns:xforms", "http://www.w3.org/2002/xforms" );
141
        addAttribute( pDocContentPropList, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
142
        addAttribute( pDocContentPropList, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
143
        addAttribute( pDocContentPropList, "office:version", "1.0");
144
        m_xDocHandler->startElement(OUString(RTL_CONSTASCII_USTRINGPARAM("office:document-content" ) ), xDocContentList );
145
    }
146
147
    void parseDoc()
148
    {
149
        UINT8 nDelim, nDummy, nLen, nData;
150
        UINT16 nOpcode;
151
        int nCount = 0;
152
        OUStringBuffer sBuf( MAXCHARS );
153
        sal_Int32 nChars = 0;
154
155
        while( !m_InputStream.IsEof())
156
        {
157
            m_InputStream >> nDelim;
158
            if( nDelim == 0x40 )
159
            {
160
                m_InputStream >> nDummy >> nOpcode;
161
                switch( nOpcode )
162
                {
163
                    case 0xC00B:  // Dictionary Word
164
                        m_InputStream >> nLen >> nDummy;
165
                        while( nLen > 0 && !m_InputStream.IsEof() )
166
                        {
167
                            UINT8 nChar;
168
                            m_InputStream >> nChar;
169
                            if( CheckValidData( nChar ) )
170
                            {
171
                                sBuf.appendAscii( (sal_Char*)(&nChar),1 );
172
                                if ( ++nChars >=  MAXCHARS )
173
                                {
174
                                    m_vStringChunks.push_back( sBuf.makeStringAndClear() ); 
175
                                    nChars = 0;
176
                                }
177
                            }
178
                            nLen--;
179
                        }
180
                        break;
181
182
                    case 0x0242:  // Non Dictionary word
183
                        m_InputStream >> nData;
184
                        if( nData == 0x02 )
185
                        { 
186
                            m_InputStream >> nLen >> nDummy;
187
                            while( nLen > 0 && !m_InputStream.IsEof() )
188
                            {
189
                                m_InputStream >> nData;
190
                                if( CheckValidData( nData ) )
191
                                {
192
                                    sBuf.appendAscii( (sal_Char*)(&nData),1 );
193
                                    if ( ++nChars >=  MAXCHARS )
194
                                    {
195
                                        m_vStringChunks.push_back( sBuf.makeStringAndClear() ); 
196
                                        nChars = 0;
197
                                    }
198
                                }
199
                                nLen--;
200
                            }
201
                        }
202
                        break;
203
                }
204
            }   
205
        }
206
        if ( nChars )
207
            m_vStringChunks.push_back( sBuf.makeStringAndClear() ); 
208
    }
209
210
    void writeXML()
211
    {
212
        if ( m_vStringChunks.size() )
213
        {
214
            m_xDocHandler->startDocument();
215
            SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
216
            writeDocContentPreamble(); // writes "office:document-content" elem
217
            Reference < XAttributeList > xAttrList(pAttrList);
218
219
            m_xDocHandler->startElement( OUString(RTL_CONSTASCII_USTRINGPARAM("office:body")), xAttrList  );
220
221
            // process strings imported
222
            std::vector< OUString >::const_iterator it = m_vStringChunks.begin();
223
            std::vector< OUString >::const_iterator it_end = m_vStringChunks.end();
224
            for ( ; it!=it_end; ++it )
225
                writeTextChunk( *it );
226
227
            m_xDocHandler->endElement( OUString(RTL_CONSTASCII_USTRINGPARAM("office:body") ) );
228
            m_xDocHandler->endElement( OUString(RTL_CONSTASCII_USTRINGPARAM("office:document-content")));
229
            m_xDocHandler->endDocument();
230
        }
231
    }
232
public:
233
234
    SimpleXMLImporter( const Reference< XDocumentHandler >&  xDocHandler, SvStream& rStream ) : m_xDocHandler( xDocHandler ), m_InputStream( rStream ) {}
235
236
    void import()
237
    {
238
        parseDoc();
239
        writeXML();
240
    }
241
};
242
243
sal_Bool SAL_CALL LotusWordProImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
244
	throw (RuntimeException)
245
{
246
	
247
	sal_Int32 nLength = aDescriptor.getLength();
248
	const PropertyValue * pValue = aDescriptor.getConstArray();
249
	OUString sURL;
250
	Reference < XInputStream > xInputStream;
251
	for ( sal_Int32 i = 0 ; i < nLength; i++)
252
	{
253
	    if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
254
		pValue[i].Value >>= xInputStream;
255
	    else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
256
		pValue[i].Value >>= sURL;
257
	    rtl_TextEncoding encoding = RTL_TEXTENCODING_INFO_ASCII;
258
	}
259
	if ( !xInputStream.is() )
260
	{
261
	    OSL_ASSERT( 0 );
262
	    return sal_False;
263
	}
264
265
	OString sFileName;
266
	sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII);
267
268
        SvFileStream inputStream( sURL, STREAM_READ );
269
        if ( inputStream.IsEof() || ( inputStream.GetError() != SVSTREAM_OK ) )
270
             return sal_False;
271
272
	// An XML import service: what we push sax messages to..
273
	OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.XMLImporter" ) );
274
275
	Reference< XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
276
	Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
277
        xImporter->setTargetDocument(mxDoc);
278
279
        SimpleXMLImporter xmlImporter( xInternalHandler, inputStream );
280
        xmlImporter.import();
281
         
282
	return sal_True; 
283
}
284
285
sal_Bool SAL_CALL LotusWordProImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 
286
	throw (RuntimeException)
287
{
288
	return importImpl ( aDescriptor );
289
}
290
void SAL_CALL LotusWordProImportFilter::cancel(  ) 
291
	throw (RuntimeException)
292
{
293
}
294
295
// XImporter
296
void SAL_CALL LotusWordProImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
297
	throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
298
{
299
	meType = FILTER_IMPORT;
300
	mxDoc = xDoc;
301
}
302
303
// XExtendedFilterDetection
304
OUString SAL_CALL LotusWordProImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
305
	throw( com::sun::star::uno::RuntimeException )
306
{
307
308
	OUString sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "" ) );
309
	sal_Int32 nLength = Descriptor.getLength();
310
	sal_Int32 location = nLength;
311
	OUString sURL;
312
	const PropertyValue * pValue = Descriptor.getConstArray();
313
	Reference < XInputStream > xInputStream;
314
	for ( sal_Int32 i = 0 ; i < nLength; i++)
315
	{
316
		if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "TypeName" ) ) )
317
			location=i;
318
		else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
319
			pValue[i].Value >>= xInputStream;
320
		else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
321
			pValue[i].Value >>= sURL;
322
323
	    rtl_TextEncoding encoding = RTL_TEXTENCODING_INFO_ASCII;
324
	}
325
326
        Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
327
        if (!xInputStream.is())
328
        {
329
		try
330
		{
331
			::ucb::Content aContent(sURL, xEnv);
332
	                xInputStream = aContent.openStream();
333
		}
334
		catch ( Exception& )
335
		{
336
			return ::rtl::OUString();
337
		}
338
		
339
                if (!xInputStream.is())
340
                    return ::rtl::OUString();
341
        }
342
343
        Sequence< ::sal_Int8 > aData;			
344
        sal_Int32 nLen = sizeof( header ) / sizeof( header[0] );
345
        if ( ( nLen == xInputStream->readBytes(  aData, nLen ) ) )
346
            if ( memcmp( ( void* )header, (void*) aData.getConstArray(), nLen ) == 0 ) 
347
                sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer_LotusWordPro_Document" ) );
348
        return sTypeName;
349
}
350
351
352
// XInitialization
353
void SAL_CALL LotusWordProImportFilter::initialize( const Sequence< Any >& aArguments ) 
354
	throw (Exception, RuntimeException)
355
{
356
	Sequence < PropertyValue > aAnySeq;
357
	sal_Int32 nLength = aArguments.getLength();
358
	if ( nLength && ( aArguments[0] >>= aAnySeq ) )
359
	{
360
		const PropertyValue * pValue = aAnySeq.getConstArray();
361
		nLength = aAnySeq.getLength();
362
		for ( sal_Int32 i = 0 ; i < nLength; i++)
363
		{
364
			if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "Type" ) ) )
365
			{
366
				pValue[i].Value >>= msFilterName;
367
				break;
368
			}
369
		}
370
	}
371
}
372
OUString LotusWordProImportFilter_getImplementationName ()
373
	throw (RuntimeException)
374
{
375
	return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.LotusWordProImportFilter" ) );
376
}
377
378
#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
379
#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection"
380
sal_Bool SAL_CALL LotusWordProImportFilter_supportsService( const OUString& ServiceName ) 
381
	throw (RuntimeException)
382
{
383
	return (ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME1 ) ) ||
384
		ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME2 ) ) );
385
}
386
Sequence< OUString > SAL_CALL LotusWordProImportFilter_getSupportedServiceNames(  ) 
387
	throw (RuntimeException)
388
{
389
	Sequence < OUString > aRet(2);
390
//	Sequence < OUString > aRet(1);
391
        OUString* pArray = aRet.getArray();
392
        pArray[0] =  OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME1 ) );
393
	pArray[1] =  OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME2 ) ); 
394
        return aRet;
395
}
396
#undef SERVICE_NAME2
397
#undef SERVICE_NAME1
398
399
Reference< XInterface > SAL_CALL LotusWordProImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
400
	throw( Exception )
401
{
402
	return (cppu::OWeakObject*) new LotusWordProImportFilter( rSMgr );
403
}
404
405
// XServiceInfo
406
OUString SAL_CALL LotusWordProImportFilter::getImplementationName(  ) 
407
	throw (RuntimeException)
408
{
409
	return LotusWordProImportFilter_getImplementationName();
410
}
411
sal_Bool SAL_CALL LotusWordProImportFilter::supportsService( const OUString& rServiceName ) 
412
	throw (RuntimeException)
413
{
414
    return LotusWordProImportFilter_supportsService( rServiceName );
415
}
416
Sequence< OUString > SAL_CALL LotusWordProImportFilter::getSupportedServiceNames(  ) 
417
	throw (RuntimeException)
418
{
419
    return LotusWordProImportFilter_getSupportedServiceNames();
420
}
(-) (+104 lines)
Added Link Here
1
#ifndef _WORDPERFECTIMPORTFILTER_HXX
2
#define _WORDPERFECTIMPORTFILTER_HXX
3
4
#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
5
#include <com/sun/star/document/XFilter.hpp>
6
#endif
7
#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
8
#include <com/sun/star/document/XImporter.hpp>
9
#endif
10
#ifndef _COM_SUN_STAR_DOCUMENT_XEXTENDEDFILTERDETECTION_HPP_
11
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
12
#endif
13
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
14
#include <com/sun/star/lang/XInitialization.hpp>
15
#endif
16
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
17
#include <com/sun/star/lang/XServiceInfo.hpp>
18
#endif
19
#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
20
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
21
#endif
22
#ifndef _CPPUHELPER_IMPLBASE5_HXX_
23
#include <cppuhelper/implbase5.hxx>
24
#endif
25
#include <rtl/ustrbuf.hxx>
26
27
enum FilterType 
28
{
29
	FILTER_IMPORT,
30
	FILTER_EXPORT
31
};
32
/* This component will be instantiated for both import or export. Whether it calls
33
 * setSourceDocument or setTargetDocument determines which Impl function the filter
34
 * member calls */
35
class LotusWordProImportFilter : public cppu::WeakImplHelper5 
36
< 
37
	com::sun::star::document::XFilter,
38
	com::sun::star::document::XImporter,
39
	com::sun::star::document::XExtendedFilterDetection,
40
	com::sun::star::lang::XInitialization,
41
	com::sun::star::lang::XServiceInfo
42
>
43
{
44
private:
45
46
protected:
47
	// oo.org declares
48
	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
49
	::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
50
	::rtl::OUString msFilterName;
51
	::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
52
53
	FilterType meType;
54
55
	sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 
56
		throw (::com::sun::star::uno::RuntimeException);
57
58
public:
59
	LotusWordProImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
60
        : mxMSF( rxMSF ) {}
61
	virtual ~LotusWordProImportFilter() {}
62
63
	// XFilter
64
        virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 
65
		throw (::com::sun::star::uno::RuntimeException);
66
        virtual void SAL_CALL cancel(  ) 
67
		throw (::com::sun::star::uno::RuntimeException);
68
69
	// XImporter
70
        virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) 
71
		throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
72
73
 	//XExtendedFilterDetection
74
	virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor ) 
75
		throw( com::sun::star::uno::RuntimeException );
76
77
	// XInitialization
78
        virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 
79
		throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
80
81
	// XServiceInfo
82
        virtual ::rtl::OUString SAL_CALL getImplementationName(  ) 
83
		throw (::com::sun::star::uno::RuntimeException);
84
        virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 
85
		throw (::com::sun::star::uno::RuntimeException);
86
        virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) 
87
		throw (::com::sun::star::uno::RuntimeException);
88
89
};
90
91
::rtl::OUString LotusWordProImportFilter_getImplementationName()
92
	throw ( ::com::sun::star::uno::RuntimeException );
93
94
sal_Bool SAL_CALL LotusWordProImportFilter_supportsService( const ::rtl::OUString& ServiceName ) 
95
	throw ( ::com::sun::star::uno::RuntimeException );
96
97
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL LotusWordProImportFilter_getSupportedServiceNames(  ) 
98
	throw ( ::com::sun::star::uno::RuntimeException );
99
100
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
101
SAL_CALL LotusWordProImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
102
	throw ( ::com::sun::star::uno::Exception );
103
104
#endif
(-)lotuswordpro/prj/build.lst (+4 lines)
Line 0 Link Here
1
wp	lotuswordpro : sfx2 sot svx comphelper NULL
2
wp	lotuswordpro			usr1	-	all	lwp_mkout NULL
3
wp	lotuswordpro\source\filter	nmake	-	all	lwp_filter NULL
4
wp	lotuswordpro\util		nmake	-	all	lwp_util lwp_filter NULL
(-)lotuswordpro/prj/d.lst (+3 lines)
Line 0 Link Here
1
..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*.so
2
..\%__SRC%\bin\*.dll %_DEST%\lib%_EXT%\*.dll
3
..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
(-)lotuswordpro/source/filter/genericfilter.cxx (+77 lines)
Line 0 Link Here
1
#include <stdio.h>
2
3
#include <osl/mutex.hxx>
4
#include <osl/thread.h>
5
#include <cppuhelper/factory.hxx>
6
7
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
8
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
9
#endif
10
11
#include "LotusWordProImportFilter.hxx"
12
13
using namespace ::rtl;
14
using namespace ::cppu;
15
using namespace ::com::sun::star::uno;
16
using namespace ::com::sun::star::lang;
17
using namespace ::com::sun::star::registry;
18
19
extern "C"
20
{
21
//==================================================================================================
22
void SAL_CALL component_getImplementationEnvironment(
23
	const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
24
{
25
	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
26
}
27
//==================================================================================================
28
sal_Bool SAL_CALL component_writeInfo(
29
	void * pServiceManager, void * pRegistryKey )
30
{
31
	if (pRegistryKey)
32
	{
33
		try
34
		{
35
            sal_Int32 nPos = 0;
36
            Reference< XRegistryKey > xNewKey(
37
				reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( LotusWordProImportFilter_getImplementationName() ) ); 
38
            xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
39
			
40
			const Sequence< OUString > & rSNL = LotusWordProImportFilter_getSupportedServiceNames();
41
			const OUString * pArray = rSNL.getConstArray();
42
			for ( nPos = rSNL.getLength(); nPos--; )
43
				xNewKey->createKey( pArray[nPos] );
44
45
			return sal_True;
46
		}
47
		catch (InvalidRegistryException &)
48
		{
49
			OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
50
		}
51
	}
52
	return sal_False;
53
}
54
//==================================================================================================
55
void * SAL_CALL component_getFactory(
56
	const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
57
{
58
	void * pRet = 0;
59
60
    OUString implName = OUString::createFromAscii( pImplName );
61
	if ( pServiceManager && implName.equals(LotusWordProImportFilter_getImplementationName()) )
62
	{
63
		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
64
			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
65
			OUString::createFromAscii( pImplName ),
66
			LotusWordProImportFilter_createInstance, LotusWordProImportFilter_getSupportedServiceNames() ) );
67
		
68
		if (xFactory.is())
69
		{
70
			xFactory->acquire();
71
			pRet = xFactory.get();
72
		}
73
	}
74
	
75
	return pRet;
76
}
77
}
(-)lotuswordpro/source/filter/makefile.mk (+13 lines)
Line 0 Link Here
1
PRJ=..$/..
2
3
PRJNAME=filter
4
TARGET=filter
5
ENABLE_EXCEPTIONS=true
6
7
.INCLUDE :  settings.mk
8
9
SLOFILES= \
10
	$(SLO)$/LotusWordProImportFilter.obj \
11
	$(SLO)$/genericfilter.obj
12
13
.INCLUDE :  target.mk
(-)lotuswordpro/util/lwpft.map (+8 lines)
Line 0 Link Here
1
WPFT_1_0 {
2
	global:
3
		component_getImplementationEnvironment;
4
		component_writeInfo;
5
		component_getFactory;
6
	local:
7
		*;
8
};
(-)lotuswordpro/util/makefile.mk (+27 lines)
Line 0 Link Here
1
PRJ=..
2
PRJNAME=lwpft
3
TARGET=lwpft
4
VERSION=$(UPD)
5
6
.INCLUDE :  settings.mk
7
8
LIB1TARGET= $(SLB)$/$(TARGET).lib
9
LIB1FILES= \
10
	$(SLB)$/filter.lib
11
SHL1LIBS=$(LIB1TARGET) 
12
SHL1STDLIBS+= \
13
	$(TOOLSLIB) \
14
	$(COMPHELPERLIB) \
15
	$(UCBHELPERLIB) \
16
	$(CPPUHELPERLIB) \
17
	$(CPPULIB) \
18
	$(SALLIB) \
19
	$(XMLOFFLIB)
20
21
SHL1TARGET = $(TARGET)$(UPD)$(DLLPOSTFIX)
22
SHL1IMPLIB = i$(SHL1TARGET)
23
SHL1LIBS = $(LIB1TARGET)
24
SHL1VERSIONMAP=$(TARGET).map
25
DEF1NAME=$(SHL1TARGET)
26
27
.INCLUDE :  target.mk
(-)filter.orig/source/config/fragments/fcfg_writer.mk (+2 lines)
Lines 46-51 T4_WRITER = \ Link Here
46
    writer_StarOffice_XML_Writer \
46
    writer_StarOffice_XML_Writer \
47
    $(T4_WRITER_BINFILTER) \
47
    $(T4_WRITER_BINFILTER) \
48
    writer_WordPerfect_Document \
48
    writer_WordPerfect_Document \
49
    writer_LotusWordPro_Document \
49
    writer_Text \
50
    writer_Text \
50
    writer_Text_encoded \
51
    writer_Text_encoded \
51
    writer_JustSystem_Ichitaro_10 \
52
    writer_JustSystem_Ichitaro_10 \
Lines 77-82 F4_WRITER = \ Link Here
77
	StarOffice_XML__Writer_ \
78
	StarOffice_XML__Writer_ \
78
	$(F4_WRITER_BINFILTER) \
79
	$(F4_WRITER_BINFILTER) \
79
	WordPerfect \
80
	WordPerfect \
81
	LotusWordPro \
80
	Text \
82
	Text \
81
	Text__encoded_ \
83
	Text__encoded_ \
82
	writer_JustSystem_Ichitaro_10 \
84
	writer_JustSystem_Ichitaro_10 \
(-)filter.orig/source/config/fragments/filters/LotusWordPro.xcu (+13 lines)
Line 0 Link Here
1
	<node oor:name="LotusWordPro" oor:op="replace">
2
		<prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value></prop>
3
		<prop oor:name="UIComponent"/>
4
		<prop oor:name="FilterService"><value>com.sun.star.comp.Writer.LotusWordProImportFilter</value></prop>
5
		<prop oor:name="UserData"><value>WPD</value></prop>
6
		<prop oor:name="UIName">
7
			<value xml:lang="x-default">Lotus WordPro Document</value>
8
		</prop>
9
		<prop oor:name="FileFormatVersion"><value>0</value></prop>
10
		<prop oor:name="Type"><value>writer_LotusWordPro_Document</value></prop>
11
		<prop oor:name="TemplateName"/>
12
		<prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
13
	</node>
(-)filter.orig/source/config/fragments/types/writer_LotusWordPro_Document.xcu (+12 lines)
Line 0 Link Here
1
	<node oor:name="writer_LotusWordPro_Document" oor:op="replace" >
2
		<prop oor:name="DetectService"><value>com.sun.star.comp.Writer.LotusWordProImportFilter</value></prop>
3
		<prop oor:name="URLPattern"/>
4
		<prop oor:name="Extensions"><value>lwp</value></prop>
5
		<prop oor:name="MediaType"/>
6
		<prop oor:name="Preferred"><value>false</value></prop>
7
		<prop oor:name="PreferredFilter"><value>LotusWordPro</value></prop>
8
		<prop oor:name="UIName">
9
			<value>LotusWordPro Document</value>
10
		</prop>
11
		<prop oor:name="ClipboardFormat"/>
12
	</node>
(-)officecfg/registry/data/org/openoffice/Office/UI.xcu (-1 / +1 lines)
Lines 44-50 Link Here
44
						<value xml:lang="en-US">Text documents</value>
44
						<value xml:lang="en-US">Text documents</value>
45
					</prop>
45
					</prop>
46
					<prop oor:name="Filters">
46
					<prop oor:name="Filters">
47
                                                <value oor:separator=";">HTML (StarWriter);MS WinWord 2.x (W4W);MS WinWord 6.0;MS Word 95;MS Word 95 Vorlage;MS Word 97;MS Word 97 Vorlage;StarOffice XML (Writer);StarWriter 3.0;StarWriter 3.0 Vorlage/Template;StarWriter 4.0;StarWriter 4.0 Vorlage/Template;StarWriter 5.0;StarWriter 5.0 Vorlage/Template;writer_StarOffice_XML_Writer_Template;Text;WordPerfect;writer8;writer8_template</value>
47
                                                <value oor:separator=";">HTML (StarWriter);MS WinWord 2.x (W4W);MS WinWord 6.0;MS Word 95;MS Word 95 Vorlage;MS Word 97;MS Word 97 Vorlage;StarOffice XML (Writer);StarWriter 3.0;StarWriter 3.0 Vorlage/Template;StarWriter 4.0;StarWriter 4.0 Vorlage/Template;StarWriter 5.0;StarWriter 5.0 Vorlage/Template;writer_StarOffice_XML_Writer_Template;Text;WordPerfect;writer8;writer8_template;LotusWordPro</value>
48
					</prop>
48
					</prop>
49
				</node>
49
				</node>
50
				<node oor:name="com.sun.star.sheet.SpreadsheetDocument" oor:op="replace">
50
				<node oor:name="com.sun.star.sheet.SpreadsheetDocument" oor:op="replace">
(-)scp2/source/ooo/file_library_ooo.scp (+1 lines)
Lines 1276-1281 End Link Here
1276
#endif
1366
#endif
1277
1367
1278
STD_UNO_LIB_FILE_PATCH(gid_File_Lib_Wpft,wpft)
1368
STD_UNO_LIB_FILE_PATCH(gid_File_Lib_Wpft,wpft)
1369
STD_UNO_LIB_FILE_PATCH(gid_File_Lib_Wlwp,lwpft)
1279
1370
1280
#if !defined(MACOSX) && ( !defined(SYSTEM_MOZILLA) && !defined(WITHOUT_MOZILLA) )
1371
#if !defined(MACOSX) && ( !defined(SYSTEM_MOZILLA) && !defined(WITHOUT_MOZILLA) )
1281
1372
(-)scp2/source/writer/module_writer.scp (+1 lines)
Lines 52-57 Module gid_Module_Prg_Wrt_Bin Link Here
52
    gid_File_Lib_Swd,
52
    gid_File_Lib_Swd,
53
    gid_File_Lib_Swui,
53
    gid_File_Lib_Swui,
54
    gid_File_Lib_Wpft,
54
    gid_File_Lib_Wpft,
55
    gid_File_Lib_Wlwp,
55
    gid_File_Share_Config_Sofficecfg_Writer_Menubar_Xml,
56
    gid_File_Share_Config_Sofficecfg_Writer_Menubar_Xml,
56
    gid_File_Share_Config_Sofficecfg_Writerweb_Menubar_Xml,
57
    gid_File_Share_Config_Sofficecfg_Writerweb_Menubar_Xml,
57
    gid_File_Share_Config_Sofficecfg_Writerglobal_Menubar_Xml,
58
    gid_File_Share_Config_Sofficecfg_Writerglobal_Menubar_Xml,
(-)sw/prj/build.lst (-1 / +1 lines)
Lines 1-4 Link Here
1
sw	sw	:	connectivity OOo:writerperfect svx stoc uui sch NULL
1
sw	sw	:	connectivity OOo:writerperfect OOo:lotuswordpro svx stoc uui sch NULL
2
sw	sw										usr1	-	all	sw_mkout NULL
2
sw	sw										usr1	-	all	sw_mkout NULL
3
sw	sw\inc									get		-	all	sw_inc NULL
3
sw	sw\inc									get		-	all	sw_inc NULL
4
sw	sw\prj									get		-	all	sw_prj NULL
4
sw	sw\prj									get		-	all	sw_prj NULL

Return to issue 11215