docxexportfilter.cxx (efeef26f) docxexportfilter.cxx (68128652)
1/**************************************************************
1/**************************************************************
2 *
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
19 *
20 *************************************************************/
21
22
23
24#include "docxexportfilter.hxx"
25#include "rtfexportfilter.hxx"
26#include "rtfimportfilter.hxx"
27#include "docxexport.hxx"

--- 6 unchanged lines hidden (view full) ---

34
35using namespace ::comphelper;
36using namespace ::com::sun::star;
37using ::rtl::OUString;
38
39#define S( x ) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
40
41DocxExportFilter::DocxExportFilter( const uno::Reference< lang::XMultiServiceFactory >& rMSF )
20 *************************************************************/
21
22
23
24#include "docxexportfilter.hxx"
25#include "rtfexportfilter.hxx"
26#include "rtfimportfilter.hxx"
27#include "docxexport.hxx"

--- 6 unchanged lines hidden (view full) ---

34
35using namespace ::comphelper;
36using namespace ::com::sun::star;
37using ::rtl::OUString;
38
39#define S( x ) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
40
41DocxExportFilter::DocxExportFilter( const uno::Reference< lang::XMultiServiceFactory >& rMSF )
42 : oox::core::XmlFilterBase( rMSF )
42 : oox::core::XmlFilterBase( rMSF )
43{
44}
45
46bool DocxExportFilter::exportDocument()
47{
43{
44}
45
46bool DocxExportFilter::exportDocument()
47{
48 OSL_TRACE(, "DocxExportFilter::exportDocument()\n" ); // DEBUG remove me
48 OSL_TRACE(, "DocxExportFilter::exportDocument()\n" ); // DEBUG remove me
49
49
50 // get SwDoc*
51 uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY );
52 SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
53 if ( !pTxtDoc )
54 return false;
50 // get SwDoc*
51 uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY );
52 SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
53 if ( !pTxtDoc )
54 return false;
55
55
56 SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
57 if ( !pDoc )
58 return false;
56 SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
57 if ( !pDoc )
58 return false;
59
59
60 // get SwPaM*
61 // FIXME so far we get SwPaM for the entire document; probably we should
62 // be able to output just the selection as well - though no idea how to
63 // get the correct SwPaM* then...
64 SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
65 aPam.SetMark();
66 aPam.Move( fnMoveBackward, fnGoDoc );
60 // get SwPaM*
61 // FIXME so far we get SwPaM for the entire document; probably we should
62 // be able to output just the selection as well - though no idea how to
63 // get the correct SwPaM* then...
64 SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
65 aPam.SetMark();
66 aPam.Move( fnMoveBackward, fnGoDoc );
67
67
68 SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() );
68 SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() );
69
69
70 // export the document
71 // (in a separate block so that it's destructed before the commit)
72 {
73 DocxExport aExport( this, pDoc, pCurPam, &aPam );
74 aExport.ExportDocument( true ); // FIXME support exporting selection only
75 }
70 // export the document
71 // (in a separate block so that it's destructed before the commit)
72 {
73 DocxExport aExport( this, pDoc, pCurPam, &aPam );
74 aExport.ExportDocument( true ); // FIXME support exporting selection only
75 }
76
76
77 commit();
77 commit();
78
78
79 // delete the pCurPam
80 if ( pCurPam )
81 {
82 while ( pCurPam->GetNext() != pCurPam )
83 delete pCurPam->GetNext();
84 delete pCurPam;
85 }
79 // delete the pCurPam
80 if ( pCurPam )
81 {
82 while ( pCurPam->GetNext() != pCurPam )
83 delete pCurPam->GetNext();
84 delete pCurPam;
85 }
86
86
87 return true;
87 return true;
88}
89
90//////////////////////////////////////////////////////////////////////////
91// UNO stuff so that the filter is registered
92//////////////////////////////////////////////////////////////////////////
93
94#define IMPL_NAME "com.sun.star.comp.Writer.DocxExport"
95
96OUString DocxExport_getImplementationName()
97{
88}
89
90//////////////////////////////////////////////////////////////////////////
91// UNO stuff so that the filter is registered
92//////////////////////////////////////////////////////////////////////////
93
94#define IMPL_NAME "com.sun.star.comp.Writer.DocxExport"
95
96OUString DocxExport_getImplementationName()
97{
98 return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPL_NAME ) );
98 return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPL_NAME ) );
99}
100
101OUString DocxExportFilter::implGetImplementationName() const
102{
99}
100
101OUString DocxExportFilter::implGetImplementationName() const
102{
103 return DocxExport_getImplementationName();
103 return DocxExport_getImplementationName();
104}
105
106uno::Sequence< OUString > SAL_CALL DocxExport_getSupportedServiceNames() throw()
107{
104}
105
106uno::Sequence< OUString > SAL_CALL DocxExport_getSupportedServiceNames() throw()
107{
108 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ExportFilter" ) );
109 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
110 return aSeq;
108 const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ExportFilter" ) );
109 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
110 return aSeq;
111}
112
113uno::Reference< uno::XInterface > SAL_CALL DocxExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
114{
111}
112
113uno::Reference< uno::XInterface > SAL_CALL DocxExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
114{
115 return (cppu::OWeakObject*) new DocxExportFilter( rSMgr );
115 return (cppu::OWeakObject*) new DocxExportFilter( rSMgr );
116}
117
118#ifdef __cplusplus
119extern "C"
120{
121#endif
122
123SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
124{
116}
117
118#ifdef __cplusplus
119extern "C"
120{
121#endif
122
123SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
124{
125 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
125 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
126}
127
128// ------------------------
129// - component_getFactory -
130// ------------------------
131
132SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
133{
126}
127
128// ------------------------
129// - component_getFactory -
130// ------------------------
131
132SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
133{
134 OSL_TRACE("%s, pImplName is '%s'", OSL_THIS_FUNC, pImplName);
135 uno::Reference< lang::XSingleServiceFactory > xFactory;
136 void* pRet = 0;
134 OSL_TRACE("%s, pImplName is '%s'", OSL_THIS_FUNC, pImplName);
135 uno::Reference< lang::XSingleServiceFactory > xFactory;
136 void* pRet = 0;
137
137
138 if ( rtl_str_compare( pImplName, IMPL_NAME ) == 0 )
139 {
140 const OUString aServiceName( OUString::createFromAscii( IMPL_NAME ) );
138 if ( rtl_str_compare( pImplName, IMPL_NAME ) == 0 )
139 {
140 const OUString aServiceName( OUString::createFromAscii( IMPL_NAME ) );
141
141
142 xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
143 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
144 DocxExport_getImplementationName(),
145 DocxExport_createInstance,
146 DocxExport_getSupportedServiceNames() ) );
147 } else if ( rtl_str_compare( pImplName, IMPL_NAME_RTFEXPORT ) == 0 ) {
148 const OUString aServiceName( OUString::createFromAscii( IMPL_NAME_RTFEXPORT ) );
142 xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
143 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
144 DocxExport_getImplementationName(),
145 DocxExport_createInstance,
146 DocxExport_getSupportedServiceNames() ) );
147 } else if ( rtl_str_compare( pImplName, IMPL_NAME_RTFEXPORT ) == 0 ) {
148 const OUString aServiceName( OUString::createFromAscii( IMPL_NAME_RTFEXPORT ) );
149
149
150 xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
151 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
152 RtfExport_getImplementationName(),
153 RtfExport_createInstance,
154 RtfExport_getSupportedServiceNames() ) );
155 } else if ( rtl_str_compare( pImplName, IMPL_NAME_RTFIMPORT ) == 0 ) {
156 const OUString aServiceName( OUString::createFromAscii( IMPL_NAME_RTFIMPORT ) );
150 xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
151 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
152 RtfExport_getImplementationName(),
153 RtfExport_createInstance,
154 RtfExport_getSupportedServiceNames() ) );
155 } else if ( rtl_str_compare( pImplName, IMPL_NAME_RTFIMPORT ) == 0 ) {
156 const OUString aServiceName( OUString::createFromAscii( IMPL_NAME_RTFIMPORT ) );
157
157
158 xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
159 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
160 RtfImport_getImplementationName(),
161 RtfImport_createInstance,
162 RtfImport_getSupportedServiceNames() ) );
163 }
158 xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
159 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
160 RtfImport_getImplementationName(),
161 RtfImport_createInstance,
162 RtfImport_getSupportedServiceNames() ) );
163 }
164
164
165 if ( xFactory.is() )
166 {
167 xFactory->acquire();
168 pRet = xFactory.get();
169 }
165 if ( xFactory.is() )
166 {
167 xFactory->acquire();
168 pRet = xFactory.get();
169 }
170
170
171 return pRet;
171 return pRet;
172}
173
174#ifdef __cplusplus
175}
176#endif
177
172}
173
174#ifdef __cplusplus
175}
176#endif
177
178/* vi:set tabstop=4 shiftwidth=4 expandtab: */
178/* vim: set noet sw=4 ts=4: */