Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <string.h>
30 : :
31 : : #include <com/sun/star/beans/XPropertySetInfo.hpp>
32 : : #include <tools/debug.hxx>
33 : : #include <tools/urlobj.hxx>
34 : : #include <osl/mutex.hxx>
35 : : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
36 : : #include <xmloff/nmspmap.hxx>
37 : : #include <xmloff/xmluconv.hxx>
38 : : #include "xmloff/xmlnmspe.hxx"
39 : : #include <xmloff/xmltoken.hxx>
40 : : #include <xmloff/XMLFontStylesContext.hxx>
41 : : #include <xmloff/xmlictxt.hxx>
42 : : #include <xmloff/xmlimp.hxx>
43 : : #include <xmloff/xmlnumfi.hxx>
44 : : #include "XMLEventImportHelper.hxx"
45 : : #include "XMLStarBasicContextFactory.hxx"
46 : : #include "XMLScriptContextFactory.hxx"
47 : : #include "StyleMap.hxx"
48 : : #include <xmloff/ProgressBarHelper.hxx>
49 : : #include "xmloff/xmlerror.hxx"
50 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 : : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
52 : : #include <com/sun/star/io/XOutputStream.hpp>
53 : : #include <com/sun/star/util/MeasureUnit.hpp>
54 : : #include <com/sun/star/document/XBinaryStreamResolver.hpp>
55 : : #include <com/sun/star/document/XStorageBasedDocument.hpp>
56 : : #include <com/sun/star/xml/sax/XLocator.hpp>
57 : : #include <com/sun/star/packages/zip/ZipIOException.hpp>
58 : : #include <comphelper/namecontainer.hxx>
59 : : #include <comphelper/servicehelper.hxx>
60 : : #include <rtl/logfile.hxx>
61 : : #include <cppuhelper/implbase1.hxx>
62 : : #include <comphelper/extract.hxx>
63 : : #include <comphelper/processfactory.hxx>
64 : : #include <comphelper/documentconstants.hxx>
65 : : #include <comphelper/storagehelper.hxx>
66 : : #include <unotools/fontcvt.hxx>
67 : :
68 : : #include <com/sun/star/rdf/XMetadatable.hpp>
69 : : #include <com/sun/star/rdf/XRepositorySupplier.hpp>
70 : : #include "RDFaImportHelper.hxx"
71 : :
72 : : #define LOGFILE_AUTHOR "unknown"
73 : :
74 : : using ::com::sun::star::beans::XPropertySetInfo;
75 : :
76 : : using ::rtl::OUString;
77 : : using ::rtl::OUStringBuffer;
78 : :
79 : : using namespace ::osl;
80 : : using namespace ::com::sun::star;
81 : : using namespace ::com::sun::star::frame;
82 : : using namespace ::com::sun::star::uno;
83 : : using namespace ::com::sun::star::util;
84 : : using namespace ::com::sun::star::io;
85 : : using namespace ::com::sun::star::container;
86 : : using namespace ::com::sun::star::document;
87 : : using namespace ::xmloff::token;
88 : :
89 : : sal_Char const sXML_np__office[] = "_office";
90 : : sal_Char const sXML_np__office_ext[] = "_office_ooo";
91 : : sal_Char const sXML_np__ooo[] = "_ooo";
92 : : sal_Char const sXML_np__ooow[] = "_ooow";
93 : : sal_Char const sXML_np__oooc[] = "_oooc";
94 : : sal_Char const sXML_np__of[] = "_of";
95 : : sal_Char const sXML_np__style[] = "_style";
96 : : sal_Char const sXML_np__text[] = "_text";
97 : : sal_Char const sXML_np__table[] = "_table";
98 : : sal_Char const sXML_np__table_ext[] = "_table_ooo";
99 : : sal_Char const sXML_np__draw[] = "_draw";
100 : : sal_Char const sXML_np__draw_ext[] = "_draw_ooo";
101 : : sal_Char const sXML_np__dr3d[] = "_dr3d";
102 : : sal_Char const sXML_np__fo[] = "_fo";
103 : : sal_Char const sXML_np__xlink[] = "_xlink";
104 : : sal_Char const sXML_np__dc[] = "_dc";
105 : : sal_Char const sXML_np__dom[] = "_dom";
106 : : sal_Char const sXML_np__meta[] = "_meta";
107 : : sal_Char const sXML_np__number[] = "_number";
108 : : sal_Char const sXML_np__svg[] = "_svg";
109 : : sal_Char const sXML_np__chart[] = "_chart";
110 : : sal_Char const sXML_np__math[] = "_math";
111 : : sal_Char const sXML_np__form[] = "_form";
112 : : sal_Char const sXML_np__script[] = "_script";
113 : : sal_Char const sXML_np__config[] = "_config";
114 : : sal_Char const sXML_np__db[] = "_db";
115 : : sal_Char const sXML_np__xforms[] = "_xforms";
116 : : sal_Char const sXML_np__formx[] = "_formx";
117 : : sal_Char const sXML_np__xsd[] = "_xsd";
118 : : sal_Char const sXML_np__xsi[] = "_xsi";
119 : : sal_Char const sXML_np__field[] = "_field";
120 : : sal_Char const sXML_np__xhtml[] = "_xhtml";
121 : : sal_Char const sXML_np__css3text[] = "_css3text";
122 : :
123 : : sal_Char const sXML_np__fo_old[] = "__fo";
124 : : sal_Char const sXML_np__xlink_old[] = "__xlink";
125 : : sal_Char const sXML_np__office_old[] = "__office";
126 : : sal_Char const sXML_np__style_old[] = "__style";
127 : : sal_Char const sXML_np__text_old[] = "__text";
128 : : sal_Char const sXML_np__table_old[] = "__table";
129 : : sal_Char const sXML_np__meta_old[] = "__meta";
130 : :
131 : :
132 : :
133 : : class SvXMLImportEventListener : public cppu::WeakImplHelper1<
134 : : com::sun::star::lang::XEventListener >
135 : : {
136 : : private:
137 : : SvXMLImport* pImport;
138 : :
139 : : public:
140 : : SvXMLImportEventListener(SvXMLImport* pImport);
141 : : virtual ~SvXMLImportEventListener();
142 : :
143 : : // XEventListener
144 : : virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
145 : : };
146 : :
147 : 724 : SvXMLImportEventListener::SvXMLImportEventListener(SvXMLImport* pTempImport)
148 : 724 : : pImport(pTempImport)
149 : : {
150 : 724 : }
151 : :
152 : 724 : SvXMLImportEventListener::~SvXMLImportEventListener()
153 : : {
154 [ - + ]: 1448 : }
155 : :
156 : : // XEventListener
157 : 26 : void SAL_CALL SvXMLImportEventListener::disposing( const lang::EventObject& )
158 : : throw(uno::RuntimeException)
159 : : {
160 [ + - ]: 26 : if (pImport)
161 : : {
162 : 26 : pImport->DisposingModel();
163 : 26 : pImport = NULL;
164 : : }
165 : 26 : }
166 : :
167 : : //==============================================================================
168 : :
169 : : class SAL_DLLPRIVATE SvXMLImport_Impl
170 : : {
171 : : public:
172 : : FontToSubsFontConverter hBatsFontConv;
173 : : FontToSubsFontConverter hMathFontConv;
174 : :
175 : : bool mbOwnGraphicResolver;
176 : : bool mbOwnEmbeddedResolver;
177 : : INetURLObject aBaseURL;
178 : : INetURLObject aDocBase;
179 : :
180 : : /// name of stream in package, e.g., "content.xml"
181 : : ::rtl::OUString mStreamName;
182 : :
183 : : ::rtl::OUString aODFVersion;
184 : :
185 : : // Boolean, indicating that position attributes
186 : : // of shapes are given in horizontal left-to-right layout. This is the case
187 : : // for the OpenOffice.org file format. (#i28749#)
188 : : sal_Bool mbShapePositionInHoriL2R;
189 : : sal_Bool mbTextDocInOOoFileFormat;
190 : :
191 : : const uno::Reference< uno::XComponentContext > mxComponentContext;
192 : :
193 : : uno::Reference< embed::XStorage > mxSourceStorage;
194 : :
195 : : std::auto_ptr< xmloff::RDFaImportHelper > mpRDFaHelper;
196 : :
197 : 1206 : SvXMLImport_Impl() :
198 : : hBatsFontConv( 0 ), hMathFontConv( 0 ),
199 : : mbOwnGraphicResolver( false ),
200 : : mbOwnEmbeddedResolver( false ),
201 : : mStreamName(),
202 : : // Convert drawing object positions from OOo file format to OASIS (#i28749#)
203 : : mbShapePositionInHoriL2R( sal_False ),
204 : : mbTextDocInOOoFileFormat( sal_False ),
205 : : mxComponentContext( ::comphelper::getProcessComponentContext() ),
206 [ + - ][ + - ]: 1206 : mpRDFaHelper() // lazy
[ + - ]
207 : : {
208 : : OSL_ENSURE(mxComponentContext.is(), "SvXMLImport: no ComponentContext");
209 [ - + ][ # # ]: 1206 : if (!mxComponentContext.is()) throw uno::RuntimeException();
210 : 1206 : }
211 : :
212 : 1206 : ~SvXMLImport_Impl()
213 [ + - ][ + - ]: 1206 : {
214 [ - + ]: 1206 : if( hBatsFontConv )
215 [ # # ]: 0 : DestroyFontToSubsFontConverter( hBatsFontConv );
216 [ - + ]: 1206 : if( hMathFontConv )
217 [ # # ]: 0 : DestroyFontToSubsFontConverter( hMathFontConv );
218 : 1206 : }
219 : :
220 : : ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
221 : : };
222 : :
223 : 2412 : class SvXMLImportContexts_Impl : public std::vector<SvXMLImportContext *> {};
224 : :
225 : 2252 : SvXMLImportContext *SvXMLImport::CreateContext( sal_uInt16 nPrefix,
226 : : const OUString& rLocalName,
227 : : const uno::Reference< xml::sax::XAttributeList >& )
228 : : {
229 [ + - ]: 2252 : return new SvXMLImportContext( *this, nPrefix, rLocalName );
230 : : }
231 : :
232 : 1206 : void SvXMLImport::_InitCtor()
233 : : {
234 [ + + ]: 1206 : if( mnImportFlags != 0 )
235 : : {
236 : : // implicit "xml" namespace prefix
237 [ + - ][ + - ]: 786 : mpNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML),
238 [ + - ]: 786 : XML_NAMESPACE_XML );
239 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
240 [ + - ]: 786 : GetXMLToken(XML_N_OFFICE),
241 [ + - ][ + - ]: 786 : XML_NAMESPACE_OFFICE );
242 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office_ext ) ),
243 [ + - ]: 786 : GetXMLToken(XML_N_OFFICE_EXT),
244 [ + - ][ + - ]: 786 : XML_NAMESPACE_OFFICE_EXT );
245 [ + - ][ + - ]: 786 : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
[ + - ]
246 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style) ),
247 [ + - ]: 786 : GetXMLToken(XML_N_STYLE),
248 [ + - ][ + - ]: 786 : XML_NAMESPACE_STYLE );
249 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text) ),
250 [ + - ]: 786 : GetXMLToken(XML_N_TEXT),
251 [ + - ][ + - ]: 786 : XML_NAMESPACE_TEXT );
252 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table ) ),
253 [ + - ]: 786 : GetXMLToken(XML_N_TABLE),
254 [ + - ][ + - ]: 786 : XML_NAMESPACE_TABLE );
255 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table_ext ) ),
256 [ + - ]: 786 : GetXMLToken(XML_N_TABLE_EXT),
257 [ + - ][ + - ]: 786 : XML_NAMESPACE_TABLE_EXT );
258 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ),
259 [ + - ]: 786 : GetXMLToken(XML_N_DRAW),
260 [ + - ][ + - ]: 786 : XML_NAMESPACE_DRAW );
261 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw_ext ) ),
262 [ + - ]: 786 : GetXMLToken(XML_N_DRAW_EXT),
263 [ + - ][ + - ]: 786 : XML_NAMESPACE_DRAW_EXT );
264 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM (sXML_np__dr3d ) ),
265 [ + - ]: 786 : GetXMLToken(XML_N_DR3D),
266 [ + - ][ + - ]: 786 : XML_NAMESPACE_DR3D );
267 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__fo) ),
268 [ + - ]: 786 : GetXMLToken(XML_N_FO_COMPAT),
269 [ + - ][ + - ]: 786 : XML_NAMESPACE_FO );
270 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink) ),
271 [ + - ]: 786 : GetXMLToken(XML_N_XLINK),
272 [ + - ][ + - ]: 786 : XML_NAMESPACE_XLINK );
273 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dc) ),
274 [ + - ]: 786 : GetXMLToken(XML_N_DC),
275 [ + - ][ + - ]: 786 : XML_NAMESPACE_DC );
276 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dom ) ),
277 [ + - ]: 786 : GetXMLToken(XML_N_DOM),
278 [ + - ][ + - ]: 786 : XML_NAMESPACE_DOM );
279 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__meta) ),
280 [ + - ]: 786 : GetXMLToken(XML_N_META),
281 [ + - ][ + - ]: 786 : XML_NAMESPACE_META );
282 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__number) ),
283 [ + - ]: 786 : GetXMLToken(XML_N_NUMBER),
284 [ + - ][ + - ]: 786 : XML_NAMESPACE_NUMBER );
285 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__svg) ),
286 [ + - ]: 786 : GetXMLToken(XML_N_SVG_COMPAT),
287 [ + - ][ + - ]: 786 : XML_NAMESPACE_SVG );
288 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__chart) ),
289 [ + - ]: 786 : GetXMLToken(XML_N_CHART),
290 [ + - ][ + - ]: 786 : XML_NAMESPACE_CHART );
291 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ),
292 [ + - ]: 786 : GetXMLToken(XML_N_MATH),
293 [ + - ][ + - ]: 786 : XML_NAMESPACE_MATH );
294 : : mpNamespaceMap->Add(OUString(RTL_CONSTASCII_USTRINGPARAM( sXML_np__form )),
295 [ + - ]: 786 : GetXMLToken(XML_N_FORM),
296 [ + - ][ + - ]: 786 : XML_NAMESPACE_FORM );
297 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ),
298 [ + - ]: 786 : GetXMLToken(XML_N_SCRIPT),
299 [ + - ][ + - ]: 786 : XML_NAMESPACE_SCRIPT );
300 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__config) ),
301 [ + - ]: 786 : GetXMLToken(XML_N_CONFIG),
302 [ + - ][ + - ]: 786 : XML_NAMESPACE_CONFIG );
303 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xforms) ),
304 [ + - ]: 786 : GetXMLToken(XML_N_XFORMS_1_0),
305 [ + - ][ + - ]: 786 : XML_NAMESPACE_XFORMS );
306 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__formx) ),
307 [ + - ]: 786 : GetXMLToken( XML_N_FORMX ),
308 [ + - ][ + - ]: 786 : XML_NAMESPACE_FORMX );
309 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsd) ),
310 [ + - ]: 786 : GetXMLToken(XML_N_XSD),
311 [ + - ][ + - ]: 786 : XML_NAMESPACE_XSD );
312 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsi) ),
313 [ + - ]: 786 : GetXMLToken(XML_N_XSI),
314 [ + - ][ + - ]: 786 : XML_NAMESPACE_XFORMS );
315 [ + - ][ + - ]: 786 : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooow ) ), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
[ + - ]
316 [ + - ][ + - ]: 786 : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__oooc ) ), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
[ + - ]
317 [ + - ][ + - ]: 786 : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__field ) ), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
[ + - ]
318 : : mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__of ) ),
319 [ + - ][ + - ]: 786 : GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
[ + - ]
320 : : mpNamespaceMap->Add(
321 : : OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xhtml ) ),
322 [ + - ][ + - ]: 786 : GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
[ + - ]
323 : : mpNamespaceMap->Add(
324 : : OUString( RTL_CONSTASCII_USTRINGPARAM( sXML_np__css3text ) ),
325 [ + - ][ + - ]: 786 : GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT );
[ + - ]
326 : :
327 [ + - ][ + - ]: 786 : mpNamespaceMap->Add( OUString("_calc_libo"), GetXMLToken(XML_N_CALC_EXT), XML_NAMESPACE_CALC_EXT);
328 : : }
329 : :
330 [ + - ]: 1206 : msPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
331 : :
332 [ - + ]: 1206 : if (mxNumberFormatsSupplier.is())
333 [ # # ][ # # ]: 0 : mpNumImport = new SvXMLNumFmtHelper(mxNumberFormatsSupplier, getServiceFactory());
[ # # ]
334 : :
335 [ - + ][ # # ]: 1206 : if (mxModel.is() && !mxEventListener.is())
[ - + ]
336 : : {
337 [ # # ][ # # ]: 0 : mxEventListener.set(new SvXMLImportEventListener(this));
[ # # ]
338 [ # # ][ # # ]: 0 : mxModel->addEventListener(mxEventListener);
339 : : }
340 : :
341 [ + - ]: 1206 : ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
342 : :
343 : 1206 : }
344 : :
345 : : // #110680#
346 : 1206 : SvXMLImport::SvXMLImport(
347 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
348 : : sal_uInt16 nImportFlags ) throw ()
349 : 0 : : mpImpl( new SvXMLImport_Impl() ),
350 [ + - ]: 1206 : mpNamespaceMap( new SvXMLNamespaceMap ),
351 : :
352 : : mpUnitConv( new SvXMLUnitConverter( xServiceFactory,
353 [ + - ]: 1206 : util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH) ),
354 : :
355 [ + - ]: 1206 : mpContexts( new SvXMLImportContexts_Impl ),
356 : : mpNumImport( NULL ),
357 : : mpProgressBarHelper( NULL ),
358 : : mpEventImportHelper( NULL ),
359 : : mpXMLErrors( NULL ),
360 : : mpStyleMap(0),
361 : : mnImportFlags( nImportFlags ),
362 : : mnErrorFlags(0),
363 : : // #110680#
364 : : mxServiceFactory(xServiceFactory),
365 : : mbIsFormsSupported( sal_True ),
366 : : mbIsTableShapeSupported( false ),
367 [ + - ][ + - ]: 4824 : mbIsGraphicLoadOnDemandSupported( true )
[ + - ][ + - ]
[ + - ]
368 : : {
369 : : DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
370 [ + - ]: 1206 : _InitCtor();
371 : 1206 : }
372 : :
373 [ + - ][ + - ]: 1206 : SvXMLImport::~SvXMLImport() throw ()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
374 : : {
375 [ + + ][ + - ]: 1206 : delete mpXMLErrors;
376 [ + - ][ + - ]: 1206 : delete mpNamespaceMap;
377 [ + - ][ + - ]: 1206 : delete mpUnitConv;
378 [ + + ][ + - ]: 1206 : delete mpEventImportHelper;
379 [ + - ]: 1206 : if( mpContexts )
380 : : {
381 [ - + ]: 1206 : while( !mpContexts->empty() )
382 : : {
383 [ # # ]: 0 : SvXMLImportContext *pContext = mpContexts->back();
384 [ # # ]: 0 : mpContexts->pop_back();
385 [ # # ]: 0 : if( pContext )
386 [ # # ]: 0 : pContext->ReleaseRef();
387 : : }
388 [ + - ]: 1206 : delete mpContexts;
389 : : }
390 : :
391 : : // #i9518# the import component might not be deleted until after the document has been closed,
392 : : // so the stuff that accesses the document has been moved to endDocument.
393 : :
394 : : // pNumImport is allocated in the ctor, so it must also be deleted here in case the component
395 : : // is created and deleted without actually importing.
396 [ - + ][ # # ]: 1206 : delete mpNumImport;
397 [ + + ][ + - ]: 1206 : delete mpProgressBarHelper;
398 : :
399 [ + - ]: 1206 : xmloff::token::ResetTokens();
400 : :
401 [ + - ]: 1206 : if( mpImpl )
402 [ + - ][ + - ]: 1206 : delete mpImpl;
403 : :
404 [ + + ][ + - ]: 1206 : if (mxEventListener.is() && mxModel.is())
[ + + ]
405 [ + - ][ + - ]: 698 : mxModel->removeEventListener(mxEventListener);
406 [ - + ]: 1206 : }
407 : :
408 : : namespace
409 : : {
410 : : class theSvXMLImportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvXMLImportUnoTunnelId> {};
411 : : }
412 : :
413 : : // XUnoTunnel & co
414 : 0 : const uno::Sequence< sal_Int8 > & SvXMLImport::getUnoTunnelId() throw()
415 : : {
416 : 0 : return theSvXMLImportUnoTunnelId::get().getSeq();
417 : : }
418 : :
419 : : // XUnoTunnel
420 : 0 : sal_Int64 SAL_CALL SvXMLImport::getSomething( const uno::Sequence< sal_Int8 >& rId )
421 : : throw( uno::RuntimeException )
422 : : {
423 [ # # # # ]: 0 : if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
[ # # ]
424 : 0 : rId.getConstArray(), 16 ) )
425 : : {
426 : 0 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
427 : : }
428 : 0 : return 0;
429 : : }
430 : :
431 : 1153 : void SAL_CALL SvXMLImport::startDocument( void )
432 : : throw( xml::sax::SAXException, uno::RuntimeException )
433 : : {
434 : : RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "{ SvXMLImport::startDocument" );
435 : :
436 [ + + ][ + + ]: 1153 : if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
[ + + ]
437 : : {
438 [ + - ]: 745 : Reference< lang::XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
439 [ + + ]: 745 : if( xFactory.is() )
440 : : {
441 : : try
442 : : {
443 [ + + ]: 275 : if( !mxGraphicResolver.is() )
444 : : {
445 : : mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
446 [ + - ]: 263 : xFactory->createInstance(
447 : : OUString(RTL_CONSTASCII_USTRINGPARAM(
448 : : // #99870# Import... instead of Export...
449 [ + - ][ + + ]: 263 : "com.sun.star.document.ImportGraphicObjectResolver"))));
[ + - ][ + - ]
450 : 198 : mpImpl->mbOwnGraphicResolver = mxGraphicResolver.is();
451 : : }
452 : :
453 [ + - ]: 210 : if( !mxEmbeddedResolver.is() )
454 : : {
455 : : mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
456 [ + - ]: 210 : xFactory->createInstance(
457 : : OUString(RTL_CONSTASCII_USTRINGPARAM(
458 : : // #99870# Import... instead of Export...
459 [ + - ][ + - ]: 275 : "com.sun.star.document.ImportEmbeddedObjectResolver"))));
[ + - ][ + - ]
[ - + ]
460 : 210 : mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
461 : : }
462 : : }
463 [ + - ]: 65 : catch( com::sun::star::uno::Exception& )
464 : : {
465 : : }
466 : 745 : }
467 : : }
468 : 1153 : }
469 : :
470 : 1145 : void SAL_CALL SvXMLImport::endDocument( void )
471 : : throw( xml::sax::SAXException, uno::RuntimeException)
472 : : {
473 : : RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "} SvXMLImport::startDocument" );
474 : :
475 : : // #i9518# All the stuff that accesses the document has to be done here, not in the dtor,
476 : : // because the SvXMLImport dtor might not be called until after the document has been closed.
477 : :
478 [ + + ]: 1145 : if (mpImpl->mpRDFaHelper.get())
479 : : {
480 : : const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
481 [ + - ]: 12 : uno::UNO_QUERY);
482 [ + - ]: 12 : if (xRS.is())
483 : : {
484 [ + - ]: 12 : mpImpl->mpRDFaHelper->InsertRDFa( xRS );
485 : 12 : }
486 : : }
487 : :
488 [ + + ]: 1145 : if (mpNumImport)
489 : : {
490 [ + - ]: 319 : delete mpNumImport;
491 : 319 : mpNumImport = NULL;
492 : : }
493 [ + + ]: 1145 : if (mxImportInfo.is())
494 : : {
495 [ + - ][ + - ]: 736 : uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
496 [ + - ]: 736 : if (xPropertySetInfo.is())
497 : : {
498 [ + + ]: 736 : if (mpProgressBarHelper)
499 : : {
500 [ + - ]: 442 : OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
501 [ + - ]: 442 : OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
502 [ + - ]: 442 : OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
503 [ + - ][ + - ]: 842 : if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
[ + + ][ + - ]
[ + + ]
504 [ + - ][ + - ]: 400 : xPropertySetInfo->hasPropertyByName(sProgressCurrent))
505 : : {
506 : 400 : sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
507 : 400 : sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
508 : 400 : uno::Any aAny;
509 [ + - ]: 400 : aAny <<= nProgressMax;
510 [ + - ][ + - ]: 400 : mxImportInfo->setPropertyValue(sProgressMax, aAny);
511 [ + - ]: 400 : aAny <<= nProgressCurrent;
512 [ + - ][ + - ]: 400 : mxImportInfo->setPropertyValue(sProgressCurrent, aAny);
513 : : }
514 [ + - ][ + - ]: 442 : if (xPropertySetInfo->hasPropertyByName(sRepeat))
[ - + ]
515 [ # # ][ # # ]: 442 : mxImportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
[ # # ]
516 : : // pProgressBarHelper is deleted in dtor
517 : : }
518 [ + - ]: 736 : OUString sNumberStyles(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
519 [ + + ][ + - ]: 736 : if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
[ + - ][ + + ]
[ + + ]
520 : : {
521 : 192 : uno::Any aAny;
522 [ + - ]: 192 : aAny <<= mxNumberStyles;
523 [ + - ][ + - ]: 192 : mxImportInfo->setPropertyValue(sNumberStyles, aAny);
524 : 736 : }
525 : 736 : }
526 : : }
527 : :
528 [ + + ]: 1145 : if( mxFontDecls.Is() )
529 : 312 : ((SvXMLStylesContext *)&mxFontDecls)->Clear();
530 [ + + ]: 1145 : if( mxStyles.Is() )
531 : 157 : ((SvXMLStylesContext *)&mxStyles)->Clear();
532 [ + + ]: 1145 : if( mxAutoStyles.Is() )
533 : 332 : ((SvXMLStylesContext *)&mxAutoStyles)->Clear();
534 [ + + ]: 1145 : if( mxMasterStyles.Is() )
535 : 63 : ((SvXMLStylesContext *)&mxMasterStyles)->Clear();
536 : :
537 : : // possible form-layer related knittings which can only be done when
538 : : // the whole document exists
539 [ + + ]: 1145 : if ( mxFormImport.is() )
540 : 354 : mxFormImport->documentDone();
541 : :
542 : : // The shape import helper does the z-order sorting in the dtor,
543 : : // so it must be deleted here, too.
544 : 1145 : mxShapeImport = NULL;
545 : :
546 [ + + ]: 1145 : if( mpImpl->mbOwnGraphicResolver )
547 : : {
548 [ + - ]: 198 : Reference< lang::XComponent > xComp( mxGraphicResolver, UNO_QUERY );
549 [ + - ][ + - ]: 198 : xComp->dispose();
550 : : }
551 : :
552 [ + + ]: 1145 : if( mpImpl->mbOwnEmbeddedResolver )
553 : : {
554 [ + - ]: 198 : Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
555 [ + - ][ + - ]: 198 : xComp->dispose();
556 : : }
557 [ + + ]: 1145 : if( mpStyleMap )
558 : : {
559 : 174 : mpStyleMap->release();
560 : 174 : mpStyleMap = 0;
561 : : }
562 : :
563 [ + + ]: 1145 : if ( mpXMLErrors != NULL )
564 : : {
565 : 4 : mpXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
566 : : }
567 : 1145 : }
568 : :
569 : 90047 : void SAL_CALL SvXMLImport::startElement( const OUString& rName,
570 : : const uno::Reference< xml::sax::XAttributeList >& xAttrList )
571 : : throw(xml::sax::SAXException, uno::RuntimeException)
572 : : {
573 : 90047 : SvXMLNamespaceMap *pRewindMap = 0;
574 : :
575 : : // Process namespace attributes. This must happen before creating the
576 : : // context, because namespace decaration apply to the element name itself.
577 [ + + ][ + - ]: 90047 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ + - ]
578 [ + + ]: 272278 : for( sal_Int16 i=0; i < nAttrCount; i++ )
579 : : {
580 [ + - ][ + - ]: 182231 : const OUString& rAttrName = xAttrList->getNameByIndex( i );
581 [ + + ]: 182231 : if ( rAttrName == "office:version" )
582 : : {
583 [ + - ][ + - ]: 736 : mpImpl->aODFVersion = xAttrList->getValueByIndex( i );
584 : :
585 : : // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
586 [ + - ][ - + ]: 736 : if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( mpImpl->aODFVersion ) )
[ - + ][ + + ]
587 : : {
588 : : throw xml::sax::SAXException(
589 : : ::rtl::OUString(
590 : : RTL_CONSTASCII_USTRINGPARAM( "Inconsistent ODF versions in content.xml and manifest.xml!" ) ),
591 : : uno::Reference< uno::XInterface >(),
592 : : uno::makeAny(
593 : : packages::zip::ZipIOException(
594 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
595 : : "Inconsistent ODF versions in content.xml and manifest.xml!" ) ),
596 [ # # ][ # # ]: 0 : Reference< XInterface >() ) ) );
[ # # ][ # # ]
[ # # ]
597 : : }
598 : : }
599 [ + - + + : 398344 : else if( ( rAttrName.getLength() >= 5 ) &&
+ - + - ]
[ + + ]
600 [ + - ]: 181495 : ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) &&
601 : 35354 : ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
602 : : {
603 [ + + ]: 17677 : if( !pRewindMap )
604 : : {
605 : 1267 : pRewindMap = mpNamespaceMap;
606 [ + - ][ + - ]: 1267 : mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
607 : : }
608 [ + - ][ + - ]: 17677 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
609 : :
610 : 17677 : OUString aPrefix( ( rAttrName.getLength() == 5 )
611 : : ? OUString()
612 [ - + ]: 17677 : : rAttrName.copy( 6 ) );
613 : : // Add namespace, but only if it is known.
614 [ + - ]: 17677 : sal_uInt16 nKey = mpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
615 : : // If namespace is unknown, try to match a name with similar
616 : : // TC Id an version
617 [ + + ]: 17677 : if( XML_NAMESPACE_UNKNOWN == nKey )
618 : : {
619 : 4784 : OUString aTestName( rAttrValue );
620 [ + + ][ + - ]: 4784 : if( SvXMLNamespaceMap::NormalizeURI( aTestName ) )
621 [ + - ]: 4784 : nKey = mpNamespaceMap->AddIfKnown( aPrefix, aTestName );
622 : : }
623 : : // If that namespace is not known, too, add it as unknown
624 [ + + ]: 17677 : if( XML_NAMESPACE_UNKNOWN == nKey )
625 [ + - ]: 17677 : mpNamespaceMap->Add( aPrefix, rAttrValue );
626 : :
627 : : }
628 : 182231 : }
629 : :
630 : : // Get element's namespace and local name.
631 : 90047 : OUString aLocalName;
632 : : sal_uInt16 nPrefix =
633 [ + - ]: 90047 : mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
634 : :
635 : : // If there are contexts already, call a CreateChildContext at the topmost
636 : : // context. Otherwise, create a default context.
637 : : SvXMLImportContext *pContext;
638 : 90047 : sal_uInt16 nCount = mpContexts->size();
639 [ + + ]: 90047 : if( nCount > 0 )
640 : : {
641 [ + - ]: 88894 : pContext = (*mpContexts)[nCount - 1]->CreateChildContext( nPrefix,
642 : : aLocalName,
643 [ + - ]: 88894 : xAttrList );
644 : : DBG_ASSERT( pContext && pContext->GetPrefix() == nPrefix,
645 : : "SvXMLImport::startElement: created context has wrong prefix" );
646 : : }
647 : : else
648 : : {
649 : : #ifdef TIMELOG
650 : : // If we do profiling, we want a trace message for the first element
651 : : // in order to identify the stream.
652 : : rtl::OString aString(rtl::OUStringToOString(rName, RTL_TEXTENCODING_ASCII_US));
653 : : RTL_LOGFILE_TRACE_AUTHOR1( "xmloff", LOGFILE_AUTHOR,
654 : : "SvXMLImport::StartElement( \"%s\", ... )",
655 : : aString.getStr() );
656 : : #endif
657 : :
658 [ + - ]: 1153 : pContext = CreateContext( nPrefix, aLocalName, xAttrList );
659 [ - + ][ # # ]: 1153 : if( (nPrefix & XML_NAMESPACE_UNKNOWN_FLAG) != 0 &&
[ # # ][ - + ]
660 [ # # ][ # # ]: 0 : IS_TYPE( SvXMLImportContext, pContext ) )
661 : : {
662 [ # # ]: 0 : OUString aMsg( RTL_CONSTASCII_USTRINGPARAM( "Root element unknown" ) );
663 : 0 : Reference<xml::sax::XLocator> xDummyLocator;
664 [ # # ]: 0 : Sequence < OUString > aParams(1);
665 [ # # ]: 0 : aParams.getArray()[0] = rName;
666 : :
667 : : SetError( XMLERROR_FLAG_SEVERE|XMLERROR_UNKNOWN_ROOT,
668 [ # # ][ # # ]: 0 : aParams, aMsg, xDummyLocator );
669 : : }
670 : : }
671 : :
672 : : DBG_ASSERT( pContext, "SvXMLImport::startElement: missing context" );
673 [ - + ]: 90047 : if( !pContext )
674 [ # # ][ # # ]: 0 : pContext = new SvXMLImportContext( *this, nPrefix, aLocalName );
675 : :
676 : 90047 : pContext->AddRef();
677 : :
678 : : // Remeber old namespace map.
679 [ + + ]: 90047 : if( pRewindMap )
680 : 1267 : pContext->SetRewindMap( pRewindMap );
681 : :
682 : : // Call a startElement at the new context.
683 [ + - ]: 90047 : pContext->StartElement( xAttrList );
684 : :
685 : : // Push context on stack.
686 [ + - ]: 90047 : mpContexts->push_back( pContext );
687 : 90047 : }
688 : :
689 : 90047 : void SAL_CALL SvXMLImport::endElement( const OUString&
690 : : #ifdef DBG_UTIL
691 : : rName
692 : : #endif
693 : : )
694 : : throw(xml::sax::SAXException, uno::RuntimeException)
695 : : {
696 : 90047 : sal_uInt16 nCount = mpContexts->size();
697 : : DBG_ASSERT( nCount, "SvXMLImport::endElement: no context left" );
698 [ + - ]: 90047 : if( nCount > 0 )
699 : : {
700 : : // Get topmost context and remove it from the stack.
701 : 90047 : SvXMLImportContext *pContext = mpContexts->back();
702 : 90047 : mpContexts->pop_back();
703 : :
704 : : #ifdef DBG_UTIL
705 : : // Non product only: check if endElement call matches startELement call.
706 : : OUString aLocalName;
707 : : sal_uInt16 nPrefix =
708 : : mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
709 : : DBG_ASSERT( pContext->GetPrefix() == nPrefix,
710 : : "SvXMLImport::endElement: popped context has wrong prefix" );
711 : : DBG_ASSERT( pContext->GetLocalName() == aLocalName,
712 : : "SvXMLImport::endElement: popped context has wrong lname" );
713 : : #endif
714 : :
715 : : // Call a EndElement at the current context.
716 : 90047 : pContext->EndElement();
717 : :
718 : : // Get a namespace map to rewind.
719 : 90047 : SvXMLNamespaceMap *pRewindMap = pContext->GetRewindMap();
720 : :
721 : : // Delete the current context.
722 : 90047 : pContext->ReleaseRef();
723 : 90047 : pContext = 0;
724 : :
725 : : // Rewind a namespace map.
726 [ + + ]: 90047 : if( pRewindMap )
727 : : {
728 [ + - ]: 1267 : delete mpNamespaceMap;
729 : 1267 : mpNamespaceMap = pRewindMap;
730 : : }
731 : : }
732 : 90047 : }
733 : :
734 : 68297 : void SAL_CALL SvXMLImport::characters( const OUString& rChars )
735 : : throw(xml::sax::SAXException, uno::RuntimeException)
736 : : {
737 [ + - ]: 68297 : if( !mpContexts->empty() )
738 : : {
739 : 68297 : mpContexts->back()->Characters( rChars );
740 : : }
741 : 68297 : }
742 : :
743 : 0 : void SAL_CALL SvXMLImport::ignorableWhitespace( const OUString& )
744 : : throw(xml::sax::SAXException, uno::RuntimeException)
745 : : {
746 : 0 : }
747 : :
748 : 0 : void SAL_CALL SvXMLImport::processingInstruction( const OUString&,
749 : : const OUString& )
750 : : throw(xml::sax::SAXException, uno::RuntimeException)
751 : : {
752 : 0 : }
753 : :
754 : 1066 : void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
755 : : throw(xml::sax::SAXException, uno::RuntimeException)
756 : : {
757 : 1066 : mxLocator = rLocator;
758 : 1066 : }
759 : :
760 : : // XExtendedDocumentHandler
761 : 0 : void SAL_CALL SvXMLImport::startCDATA( void ) throw(xml::sax::SAXException, uno::RuntimeException)
762 : : {
763 : 0 : }
764 : :
765 : 0 : void SAL_CALL SvXMLImport::endCDATA( void ) throw(uno::RuntimeException)
766 : : {
767 : 0 : }
768 : :
769 : 84 : void SAL_CALL SvXMLImport::comment( const OUString& )
770 : : throw(xml::sax::SAXException, uno::RuntimeException)
771 : : {
772 : 84 : }
773 : :
774 : 0 : void SAL_CALL SvXMLImport::allowLineBreak( void )
775 : : throw(xml::sax::SAXException, uno::RuntimeException)
776 : : {
777 : 0 : }
778 : :
779 : 2411 : void SAL_CALL SvXMLImport::unknown( const OUString& )
780 : : throw(xml::sax::SAXException, uno::RuntimeException)
781 : : {
782 : 2411 : }
783 : :
784 : 195 : void SvXMLImport::SetStatistics(const uno::Sequence< beans::NamedValue> &)
785 : : {
786 : 195 : GetProgressBarHelper()->SetRepeat(sal_False);
787 : 195 : GetProgressBarHelper()->SetReference(0);
788 : 195 : }
789 : :
790 : : ///////////////////////////////////////////////////////////////////////
791 : :
792 : : // XImporter
793 : 756 : void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
794 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
795 : : {
796 [ + - ]: 756 : mxModel = uno::Reference< frame::XModel >::query( xDoc );
797 [ - + ]: 756 : if( !mxModel.is() )
798 [ # # ]: 0 : throw lang::IllegalArgumentException();
799 [ + - ][ + + ]: 756 : if (mxModel.is() && !mxEventListener.is())
[ + + ]
800 : : {
801 [ + - ][ + - ]: 724 : mxEventListener.set(new SvXMLImportEventListener(this));
802 : 724 : mxModel->addEventListener(mxEventListener);
803 : : }
804 : :
805 : : DBG_ASSERT( !mpNumImport, "number format import already exists." );
806 [ - + ]: 756 : if( mpNumImport )
807 : : {
808 [ # # ]: 0 : delete mpNumImport;
809 : 0 : mpNumImport = 0;
810 : : }
811 : 756 : }
812 : :
813 : : // XFilter
814 : 0 : sal_Bool SAL_CALL SvXMLImport::filter( const uno::Sequence< beans::PropertyValue >& )
815 : : throw (uno::RuntimeException)
816 : : {
817 : 0 : return sal_False;
818 : : }
819 : :
820 : 0 : void SAL_CALL SvXMLImport::cancel( )
821 : : throw (uno::RuntimeException)
822 : : {
823 : 0 : }
824 : :
825 : : // XInitialize
826 : 772 : void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
827 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
828 : : {
829 : 772 : const sal_Int32 nAnyCount = aArguments.getLength();
830 : 772 : const uno::Any* pAny = aArguments.getConstArray();
831 : :
832 [ + + ]: 3056 : for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
833 : : {
834 : 2284 : Reference<XInterface> xValue;
835 [ + - ]: 2284 : *pAny >>= xValue;
836 : :
837 : : uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
838 [ + - ]: 2284 : xValue, UNO_QUERY );
839 [ + + ]: 2284 : if( xTmpStatusIndicator.is() )
840 [ + - ]: 276 : mxStatusIndicator = xTmpStatusIndicator;
841 : :
842 : : uno::Reference<document::XGraphicObjectResolver> xTmpGraphicResolver(
843 [ + - ]: 2284 : xValue, UNO_QUERY );
844 [ + + ]: 2284 : if( xTmpGraphicResolver.is() )
845 [ + - ]: 420 : mxGraphicResolver = xTmpGraphicResolver;
846 : :
847 : : uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
848 [ + - ]: 2284 : xValue, UNO_QUERY );
849 [ + + ]: 2284 : if( xTmpObjectResolver.is() )
850 [ + - ]: 408 : mxEmbeddedResolver = xTmpObjectResolver;
851 : :
852 [ + - ]: 2284 : uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
853 [ + + ]: 2284 : if( xTmpPropSet.is() )
854 : : {
855 [ + - ]: 722 : mxImportInfo = xTmpPropSet;
856 [ + - ][ + - ]: 722 : uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
857 [ + - ]: 722 : if (xPropertySetInfo.is())
858 : : {
859 [ + - ]: 722 : OUString sPropName(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
860 [ + - ][ + - ]: 722 : if (xPropertySetInfo->hasPropertyByName(sPropName))
[ + + ]
861 : : {
862 [ + - ][ + - ]: 624 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
863 [ + - ]: 624 : aAny >>= mxNumberStyles;
864 : : }
865 : :
866 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
867 [ + - ][ + + ]: 722 : if (xPropertySetInfo->hasPropertyByName(sPropName))
[ + - ]
868 : : {
869 : 680 : Reference < XInterface > xIfc;
870 [ + - ][ + - ]: 680 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
871 [ + - ]: 680 : aAny >>= xIfc;
872 : :
873 : 680 : StyleMap *pSMap = StyleMap::getImplementation( xIfc );
874 [ + + ]: 680 : if( pSMap )
875 : : {
876 : 87 : mpStyleMap = pSMap;
877 : 87 : mpStyleMap->acquire();
878 : 680 : }
879 : : }
880 : 722 : OUString sBaseURI;
881 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
882 [ + - ][ + + ]: 722 : if (xPropertySetInfo->hasPropertyByName(sPropName))
[ + - ]
883 : : {
884 [ + - ][ + - ]: 714 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
885 : 714 : aAny >>= sBaseURI;
886 [ + - ]: 714 : mpImpl->aBaseURL.SetURL( sBaseURI );
887 [ + - ]: 714 : mpImpl->aDocBase.SetURL( sBaseURI );
888 : : }
889 : 722 : OUString sRelPath;
890 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
891 [ + - ][ + + ]: 722 : if( xPropertySetInfo->hasPropertyByName(sPropName) )
[ + - ]
892 : : {
893 [ + - ][ + - ]: 680 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
894 : 680 : aAny >>= sRelPath;
895 : : }
896 : 722 : OUString sName;
897 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
898 [ + - ][ + - ]: 722 : if( xPropertySetInfo->hasPropertyByName(sPropName) )
[ + - ]
899 : : {
900 [ + - ][ + - ]: 722 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
901 : 722 : aAny >>= sName;
902 : : }
903 [ + + ][ + - ]: 722 : if( !sBaseURI.isEmpty() && !sName.isEmpty() )
[ + + ]
904 : : {
905 [ - + ]: 702 : if( !sRelPath.isEmpty() )
906 [ # # ]: 0 : mpImpl->aBaseURL.insertName( sRelPath );
907 [ + - ]: 702 : mpImpl->aBaseURL.insertName( sName );
908 : : }
909 : 722 : mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
910 : : // Retrieve property <ShapePositionInHoriL2R> (#i28749#)
911 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("ShapePositionInHoriL2R" ) );
912 [ + - ][ + + ]: 722 : if( xPropertySetInfo->hasPropertyByName(sPropName) )
[ + - ]
913 : : {
914 [ + - ][ + - ]: 252 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
915 : 252 : aAny >>= (mpImpl->mbShapePositionInHoriL2R);
916 : : }
917 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("TextDocInOOoFileFormat" ) );
918 [ + - ][ + + ]: 722 : if( xPropertySetInfo->hasPropertyByName(sPropName) )
[ + - ]
919 : : {
920 [ + - ][ + - ]: 252 : uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
921 : 252 : aAny >>= (mpImpl->mbTextDocInOOoFileFormat);
922 : : }
923 : :
924 [ + - ]: 722 : sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("SourceStorage" ) );
925 [ + - ][ + + ]: 722 : if( xPropertySetInfo->hasPropertyByName(sPropName) )
[ + - ]
926 [ + - ][ + - ]: 722 : mxImportInfo->getPropertyValue(sPropName) >>= mpImpl->mxSourceStorage;
[ + - ]
927 : 722 : }
928 : : }
929 : 2284 : }
930 : 772 : }
931 : :
932 : : // XServiceInfo
933 : 0 : OUString SAL_CALL SvXMLImport::getImplementationName()
934 : : throw(uno::RuntimeException)
935 : : {
936 : 0 : OUString aStr;
937 : 0 : return aStr;
938 : : }
939 : :
940 : 0 : sal_Bool SAL_CALL SvXMLImport::supportsService( const OUString& rServiceName )
941 : : throw(::com::sun::star::uno::RuntimeException)
942 : : {
943 : : return
944 : : rServiceName.equalsAsciiL(
945 : : "com.sun.star.document.ImportFilter",
946 : 0 : sizeof("com.sun.star.document.ImportFilter")-1 ) ||
947 : : rServiceName.equalsAsciiL(
948 : : "com.sun.star.xml.XMLImportFilter",
949 [ # # ][ # # ]: 0 : sizeof("com.sun.star.xml.XMLImportFilter")-1);
950 : : }
951 : :
952 : 0 : uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
953 : : throw(uno::RuntimeException)
954 : : {
955 : 0 : uno::Sequence<OUString> aSeq(2);
956 [ # # ]: 0 : aSeq[0] = OUString(
957 [ # # ]: 0 : RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportFilter"));
958 [ # # ]: 0 : aSeq[1] = OUString(
959 [ # # ]: 0 : RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter"));
960 : 0 : return aSeq;
961 : : }
962 : :
963 : : ///////////////////////////////////////////////////////////////////////
964 : :
965 : 228 : XMLTextImportHelper* SvXMLImport::CreateTextImport()
966 : : {
967 [ + - ]: 228 : return new XMLTextImportHelper( mxModel, *this );
968 : : }
969 : :
970 : 76 : XMLShapeImportHelper* SvXMLImport::CreateShapeImport()
971 : : {
972 [ + - ]: 76 : return new XMLShapeImportHelper( *this, mxModel );
973 : : }
974 : :
975 : 354 : SchXMLImportHelper* SvXMLImport::CreateChartImport()
976 : : {
977 [ + - ]: 354 : return new SchXMLImportHelper();
978 : : }
979 : :
980 : 354 : ::xmloff::OFormLayerXMLImport* SvXMLImport::CreateFormImport()
981 : : {
982 [ + - ]: 354 : return new ::xmloff::OFormLayerXMLImport(*this);
983 : : }
984 : :
985 : :
986 : : ///////////////////////////////////////////////////////////////////////////////
987 : : //
988 : : // Get or create fill/line/lineend-style-helper
989 : : //
990 : :
991 : 33 : const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
992 : : {
993 [ + + ]: 33 : if( !mxGradientHelper.is() )
994 : : {
995 [ + - ]: 9 : if( mxModel.is() )
996 : : {
997 [ + - ]: 9 : Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
998 [ + - ]: 9 : if( xServiceFact.is() )
999 : : {
1000 : : try
1001 : : {
1002 [ + - ]: 9 : mxGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1003 [ + - ][ + - ]: 9 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) ), UNO_QUERY);
[ + - ][ + - ]
[ # # ]
1004 : : }
1005 [ # # ]: 0 : catch( lang::ServiceNotRegisteredException& )
1006 : : {}
1007 : 9 : }
1008 : : }
1009 : : }
1010 : :
1011 : 33 : return mxGradientHelper;
1012 : : }
1013 : :
1014 : 36 : const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
1015 : : {
1016 [ + + ]: 36 : if( !mxHatchHelper.is() )
1017 : : {
1018 [ + - ]: 12 : if( mxModel.is() )
1019 : : {
1020 [ + - ]: 12 : Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1021 [ + - ]: 12 : if( xServiceFact.is() )
1022 : : {
1023 : : try
1024 : : {
1025 [ + - ]: 12 : mxHatchHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1026 [ + - ][ + - ]: 12 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) ), UNO_QUERY);
[ + - ][ + - ]
[ # # ]
1027 : : }
1028 [ # # ]: 0 : catch( lang::ServiceNotRegisteredException& )
1029 : : {}
1030 : 12 : }
1031 : : }
1032 : : }
1033 : :
1034 : 36 : return mxHatchHelper;
1035 : : }
1036 : :
1037 : 12 : const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
1038 : : {
1039 [ + + ]: 12 : if( !mxBitmapHelper.is() )
1040 : : {
1041 [ + - ]: 6 : if( mxModel.is() )
1042 : : {
1043 [ + - ]: 6 : Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1044 [ + - ]: 6 : if( xServiceFact.is() )
1045 : : {
1046 : : try
1047 : : {
1048 [ + - ]: 6 : mxBitmapHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1049 [ + - ][ + - ]: 6 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) ), UNO_QUERY);
[ + - ][ + - ]
[ # # ]
1050 : : }
1051 [ # # ]: 0 : catch( lang::ServiceNotRegisteredException& )
1052 : : {}
1053 : 6 : }
1054 : : }
1055 : : }
1056 : :
1057 : 12 : return mxBitmapHelper;
1058 : : }
1059 : :
1060 : 14 : const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
1061 : : {
1062 [ + + ]: 14 : if( !mxTransGradientHelper.is() )
1063 : : {
1064 [ + - ]: 7 : if( mxModel.is() )
1065 : : {
1066 [ + - ]: 7 : Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1067 [ + - ]: 7 : if( xServiceFact.is() )
1068 : : {
1069 : : try
1070 : : {
1071 [ + - ]: 7 : mxTransGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1072 [ + - ][ + - ]: 7 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) ), UNO_QUERY);
[ + - ][ + - ]
[ # # ]
1073 : : }
1074 [ # # ]: 0 : catch( lang::ServiceNotRegisteredException& )
1075 : : {}
1076 : 7 : }
1077 : : }
1078 : : }
1079 : :
1080 : 14 : return mxTransGradientHelper;
1081 : : }
1082 : :
1083 : 22 : const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
1084 : : {
1085 [ + - ]: 22 : if( !mxMarkerHelper.is() )
1086 : : {
1087 [ + - ]: 22 : if( mxModel.is() )
1088 : : {
1089 [ + - ]: 22 : Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1090 [ + - ]: 22 : if( xServiceFact.is() )
1091 : : {
1092 : : try
1093 : : {
1094 [ + - ]: 22 : mxMarkerHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1095 [ + - ][ + - ]: 22 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) ), UNO_QUERY);
[ + - ][ + - ]
[ # # ]
1096 : : }
1097 [ # # ]: 0 : catch( lang::ServiceNotRegisteredException& )
1098 : : {}
1099 : 22 : }
1100 : : }
1101 : : }
1102 : :
1103 : 22 : return mxMarkerHelper;
1104 : : }
1105 : :
1106 : 3 : const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
1107 : : {
1108 [ + - ]: 3 : if( !mxDashHelper.is() )
1109 : : {
1110 [ + - ]: 3 : if( mxModel.is() )
1111 : : {
1112 [ + - ]: 3 : Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1113 [ + - ]: 3 : if( xServiceFact.is() )
1114 : : {
1115 : : try
1116 : : {
1117 [ + - ]: 3 : mxDashHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1118 [ + - ][ + - ]: 3 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) ) ), UNO_QUERY);
[ + - ][ + - ]
[ # # ]
1119 : : }
1120 [ # # ]: 0 : catch( lang::ServiceNotRegisteredException& )
1121 : : {}
1122 : 3 : }
1123 : : }
1124 : : }
1125 : :
1126 : 3 : return mxDashHelper;
1127 : : }
1128 : :
1129 : 196 : sal_Bool SvXMLImport::IsPackageURL( const ::rtl::OUString& rURL ) const
1130 : : {
1131 : :
1132 : : // if, and only if, only parts are imported, then we're in a package
1133 : 196 : const sal_uInt32 nTest = IMPORT_META|IMPORT_STYLES|IMPORT_CONTENT|IMPORT_SETTINGS;
1134 [ - + ]: 196 : if( (mnImportFlags & nTest) == nTest )
1135 : 0 : return sal_False;
1136 : :
1137 : : // Some quick tests: Some may rely on the package structure!
1138 : 196 : sal_Int32 nLen = rURL.getLength();
1139 [ - + ][ - + ]: 196 : if( (nLen > 0 && '/' == rURL[0]) )
[ + - ]
1140 : : // RFC2396 net_path or abs_path
1141 : 0 : return sal_False;
1142 [ + - ][ + + ]: 196 : else if( nLen > 1 && '.' == rURL[0] )
[ + + ]
1143 : : {
1144 [ - + ]: 6 : if( '.' == rURL[1] )
1145 : : // ../: We are never going up one level, so we know
1146 : : // it's not an external URI
1147 : 0 : return sal_False;
1148 [ + - ]: 6 : else if( '/' == rURL[1] )
1149 : : // we are remaining on a level, so it's an package URI
1150 : 6 : return sal_True;
1151 : : }
1152 : :
1153 : : // Now check for a RFC2396 schema
1154 : 190 : sal_Int32 nPos = 1;
1155 [ + - ]: 1520 : while( nPos < nLen )
1156 : : {
1157 [ + - + ]: 1520 : switch( rURL[nPos] )
1158 : : {
1159 : : case '/':
1160 : : // a relative path segement
1161 : 190 : return sal_True;
1162 : : case ':':
1163 : : // a schema
1164 : 0 : return sal_False;
1165 : : default:
1166 : 1330 : break;
1167 : : // we don't care about any other characters
1168 : : }
1169 : 1330 : ++nPos;
1170 : : }
1171 : :
1172 : 196 : return sal_True;
1173 : : }
1174 : :
1175 : 192 : ::rtl::OUString SvXMLImport::ResolveGraphicObjectURL( const ::rtl::OUString& rURL,
1176 : : sal_Bool bLoadOnDemand )
1177 : : {
1178 : 192 : ::rtl::OUString sRet;
1179 : :
1180 [ + - ][ + - ]: 192 : if( IsPackageURL( rURL ) )
1181 : : {
1182 [ + + ][ + - ]: 192 : if( !bLoadOnDemand && mxGraphicResolver.is() )
[ + + ]
1183 : : {
1184 : 180 : ::rtl::OUString aTmp( msPackageProtocol );
1185 : 180 : aTmp += rURL;
1186 [ + - ][ + - ]: 180 : sRet = mxGraphicResolver->resolveGraphicObjectURL( aTmp );
1187 : : }
1188 : :
1189 [ + + ]: 192 : if( sRet.isEmpty() )
1190 : : {
1191 : 12 : sRet = msPackageProtocol;
1192 : 12 : sRet += rURL;
1193 : : }
1194 : : }
1195 : :
1196 [ - + ]: 192 : if( sRet.isEmpty() )
1197 [ # # ]: 0 : sRet = GetAbsoluteReference( rURL );
1198 : :
1199 : 192 : return sRet;
1200 : : }
1201 : :
1202 : 0 : Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
1203 : : {
1204 : 0 : Reference< XOutputStream > xOStm;
1205 [ # # ]: 0 : Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1206 : :
1207 [ # # ]: 0 : if( xStmResolver.is() )
1208 [ # # ][ # # ]: 0 : xOStm = xStmResolver->createOutputStream();
[ # # ]
1209 : :
1210 : 0 : return xOStm;
1211 : : }
1212 : :
1213 : 0 : ::rtl::OUString SvXMLImport::ResolveGraphicObjectURLFromBase64(
1214 : : const Reference < XOutputStream >& rOut )
1215 : : {
1216 : 0 : OUString sURL;
1217 [ # # ]: 0 : Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1218 [ # # ]: 0 : if( xStmResolver.is() )
1219 [ # # ][ # # ]: 0 : sURL = xStmResolver->resolveOutputStream( rOut );
1220 : :
1221 : 0 : return sURL;
1222 : : }
1223 : :
1224 : 2 : ::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURL(
1225 : : const ::rtl::OUString& rURL,
1226 : : const ::rtl::OUString& rClassId )
1227 : : {
1228 : 2 : ::rtl::OUString sRet;
1229 : :
1230 [ + - ][ + - ]: 2 : if( IsPackageURL( rURL ) )
1231 : : {
1232 [ + - ]: 2 : if ( mxEmbeddedResolver.is() )
1233 : : {
1234 : 2 : OUString sURL( rURL );
1235 [ - + ]: 2 : if( !rClassId.isEmpty() )
1236 : : {
1237 : 0 : sURL += OUString( sal_Unicode('!') );
1238 : 0 : sURL += rClassId;
1239 : : }
1240 [ + - ][ + - ]: 2 : sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
1241 : : }
1242 : : }
1243 : : else
1244 [ # # ]: 0 : sRet = GetAbsoluteReference( rURL );
1245 : :
1246 : 2 : return sRet;
1247 : : }
1248 : :
1249 : 11 : Reference< embed::XStorage > SvXMLImport::GetSourceStorage()
1250 : : {
1251 : 11 : return mpImpl->mxSourceStorage;
1252 : : }
1253 : :
1254 : : Reference < XOutputStream >
1255 : 0 : SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64()
1256 : : {
1257 : 0 : Reference < XOutputStream > xOLEStream;
1258 : :
1259 [ # # ]: 0 : if( mxEmbeddedResolver.is() )
1260 : : {
1261 [ # # ]: 0 : Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1262 [ # # ]: 0 : if( xNA.is() )
1263 : : {
1264 [ # # ]: 0 : OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
1265 [ # # ][ # # ]: 0 : Any aAny = xNA->getByName( aURL );
1266 [ # # ]: 0 : aAny >>= xOLEStream;
1267 : 0 : }
1268 : : }
1269 : :
1270 : 0 : return xOLEStream;
1271 : : }
1272 : :
1273 : 0 : ::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
1274 : : {
1275 : 0 : ::rtl::OUString sRet;
1276 : :
1277 [ # # ]: 0 : if( mxEmbeddedResolver.is() )
1278 : : {
1279 [ # # ]: 0 : OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
1280 [ # # ][ # # ]: 0 : sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( aURL );
1281 : : }
1282 : :
1283 : 0 : return sRet;
1284 : : }
1285 : :
1286 : 547 : void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily,
1287 : : const OUString& rName,
1288 : : const OUString& rDisplayName )
1289 : : {
1290 [ + + ]: 547 : if( !mpStyleMap )
1291 : : {
1292 [ + - ]: 87 : mpStyleMap = new StyleMap;
1293 : 87 : mpStyleMap->acquire();
1294 [ + - ]: 87 : if( mxImportInfo.is() )
1295 : : {
1296 : : OUString sPrivateData(
1297 [ + - ]: 87 : RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
1298 : : Reference< beans::XPropertySetInfo > xPropertySetInfo =
1299 [ + - ][ + - ]: 87 : mxImportInfo->getPropertySetInfo();
1300 [ + - ][ + - ]: 174 : if( xPropertySetInfo.is() &&
[ + - ]
1301 [ + - ][ + - ]: 87 : xPropertySetInfo->hasPropertyByName(sPrivateData) )
1302 : : {
1303 : : Reference < XInterface > xIfc(
1304 [ + - ][ + - ]: 87 : static_cast< XUnoTunnel *>( mpStyleMap ) );
1305 : 87 : Any aAny;
1306 [ + - ]: 87 : aAny <<= xIfc;
1307 [ + - ][ + - ]: 87 : mxImportInfo->setPropertyValue( sPrivateData, aAny );
1308 : 87 : }
1309 : : }
1310 : : }
1311 : :
1312 : 547 : StyleMap::key_type aKey( nFamily, rName );
1313 : 547 : StyleMap::value_type aValue( aKey, rDisplayName );
1314 [ + - ]: 547 : ::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
1315 : : SAL_WARN_IF( !aRes.second,
1316 : : "xmloff",
1317 : 547 : "duplicate style name" );
1318 : :
1319 : 547 : }
1320 : :
1321 : 6095 : OUString SvXMLImport::GetStyleDisplayName( sal_uInt16 nFamily,
1322 : : const OUString& rName ) const
1323 : : {
1324 : 6095 : OUString sName( rName );
1325 [ + + ][ + + ]: 6095 : if( mpStyleMap && !rName.isEmpty() )
[ + + ]
1326 : : {
1327 : 2967 : StyleMap::key_type aKey( nFamily, rName );
1328 [ + - ]: 2967 : StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
1329 [ + + ][ + - ]: 2967 : if( aIter != mpStyleMap->end() )
1330 [ + - ]: 2967 : sName = (*aIter).second;
1331 : : }
1332 : 6095 : return sName;
1333 : : }
1334 : :
1335 : 0 : void SvXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
1336 : : {
1337 : 0 : }
1338 : :
1339 : 0 : void SvXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
1340 : : {
1341 : 0 : }
1342 : :
1343 : 0 : void SvXMLImport::SetDocumentSpecificSettings(const ::rtl::OUString& _rSettingsGroupName, const uno::Sequence<beans::PropertyValue>& _rSettings)
1344 : : {
1345 : : (void)_rSettingsGroupName;
1346 : : (void)_rSettings;
1347 : 0 : }
1348 : :
1349 : 2881 : ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
1350 : : {
1351 [ + + ]: 2881 : if (!mpProgressBarHelper)
1352 : : {
1353 [ + - ]: 444 : mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_False);
1354 : :
1355 [ + + ]: 444 : if (mxImportInfo.is())
1356 : : {
1357 [ + - ][ + - ]: 442 : uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1358 [ + - ]: 442 : if (xPropertySetInfo.is())
1359 : : {
1360 [ + - ]: 442 : OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
1361 [ + - ]: 442 : OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
1362 [ + - ]: 442 : OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
1363 [ + - ]: 442 : OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
1364 [ + - ][ + - ]: 1242 : if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
[ + + ][ + - ]
[ + - ][ + + ]
1365 [ + - ][ + - ]: 400 : xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1366 [ + - ][ + - ]: 400 : xPropertySetInfo->hasPropertyByName(sProgressRange))
1367 : : {
1368 : 400 : uno::Any aAny;
1369 : 400 : sal_Int32 nProgressMax(0);
1370 : 400 : sal_Int32 nProgressCurrent(0);
1371 : 400 : sal_Int32 nProgressRange(0);
1372 [ + - ][ + - ]: 400 : aAny = mxImportInfo->getPropertyValue(sProgressRange);
1373 [ + + ]: 400 : if (aAny >>= nProgressRange)
1374 : 261 : mpProgressBarHelper->SetRange(nProgressRange);
1375 [ + - ][ + - ]: 400 : aAny = mxImportInfo->getPropertyValue(sProgressMax);
1376 [ + + ]: 400 : if (aAny >>= nProgressMax)
1377 : 233 : mpProgressBarHelper->SetReference(nProgressMax);
1378 [ + - ][ + - ]: 400 : aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
1379 [ + + ]: 400 : if (aAny >>= nProgressCurrent)
1380 [ + - ]: 400 : mpProgressBarHelper->SetValue(nProgressCurrent);
1381 : : }
1382 [ + - ][ + - ]: 442 : if (xPropertySetInfo->hasPropertyByName(sRepeat))
[ - + ]
1383 : : {
1384 [ # # ][ # # ]: 0 : uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
1385 [ # # ][ # # ]: 0 : if (aAny.getValueType() == getBooleanCppuType())
1386 [ # # ]: 0 : mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1387 : : else {
1388 : : SAL_WARN( "xmloff.core", "why is it no boolean?" );
1389 : 0 : }
1390 : 442 : }
1391 : 442 : }
1392 : : }
1393 : : }
1394 : 2881 : return mpProgressBarHelper;
1395 : : }
1396 : :
1397 : 470 : void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
1398 : : {
1399 [ + + ]: 470 : if (!mxNumberStyles.is())
1400 [ + - ][ + - ]: 105 : mxNumberStyles = uno::Reference< container::XNameContainer >( comphelper::NameContainer_createInstance( ::getCppuType((const sal_Int32*)0)) );
[ # # ]
1401 [ + - ]: 470 : if (mxNumberStyles.is())
1402 : : {
1403 : 470 : uno::Any aAny;
1404 [ + - ]: 470 : aAny <<= nKey;
1405 : : try
1406 : : {
1407 [ + - ][ + - ]: 470 : mxNumberStyles->insertByName(rName, aAny);
1408 : : }
1409 [ # # ]: 0 : catch ( uno::Exception& )
1410 : : {
1411 : : OSL_FAIL("Numberformat could not be inserted");
1412 : 470 : }
1413 : : }
1414 : : else {
1415 : : OSL_FAIL("not possible to create NameContainer");
1416 : : }
1417 : 470 : }
1418 : :
1419 : 50 : XMLEventImportHelper& SvXMLImport::GetEventImport()
1420 : : {
1421 [ + + ]: 50 : if (!mpEventImportHelper)
1422 : : {
1423 : : // construct event helper and register StarBasic handler and standard
1424 : : // event tables
1425 [ + - ][ + - ]: 12 : mpEventImportHelper = new XMLEventImportHelper();
1426 [ + - ]: 12 : OUString sStarBasic(GetXMLToken(XML_STARBASIC));
1427 : : mpEventImportHelper->RegisterFactory(sStarBasic,
1428 [ + - ][ + - ]: 12 : new XMLStarBasicContextFactory());
[ + - ]
1429 [ + - ]: 12 : OUString sScript(GetXMLToken(XML_SCRIPT));
1430 : : mpEventImportHelper->RegisterFactory(sScript,
1431 [ + - ][ + - ]: 12 : new XMLScriptContextFactory());
[ + - ]
1432 [ + - ]: 12 : mpEventImportHelper->AddTranslationTable(aStandardEventTable);
1433 : :
1434 : : // register StarBasic event handler with capitalized spelling
1435 [ + - ]: 12 : OUString sStarBasicCap(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
1436 : : mpEventImportHelper->RegisterFactory(sStarBasicCap,
1437 [ + - ][ + - ]: 12 : new XMLStarBasicContextFactory());
[ + - ]
1438 : : }
1439 : :
1440 : 50 : return *mpEventImportHelper;
1441 : : }
1442 : :
1443 : 312 : void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls )
1444 : : {
1445 : 312 : mxFontDecls = pFontDecls;
1446 [ + - ][ + - ]: 312 : GetTextImport()->SetFontDecls( pFontDecls );
1447 : 312 : }
1448 : :
1449 : 157 : void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles )
1450 : : {
1451 : 157 : mxStyles = pStyles;
1452 : 157 : }
1453 : :
1454 : 332 : void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles )
1455 : : {
1456 [ + - ][ + + ]: 332 : if (pAutoStyles && mxNumberStyles.is() && (mnImportFlags & IMPORT_CONTENT) )
[ + + ][ + + ]
1457 : : {
1458 : 93 : uno::Reference<xml::sax::XAttributeList> xAttrList;
1459 [ + - ][ + - ]: 93 : uno::Sequence< ::rtl::OUString > aNames = mxNumberStyles->getElementNames();
1460 : 93 : sal_uInt32 nCount(aNames.getLength());
1461 [ + - ]: 93 : if (nCount)
1462 : : {
1463 : 93 : const OUString* pNames = aNames.getConstArray();
1464 [ + - ]: 93 : if ( pNames )
1465 : : {
1466 : : SvXMLStyleContext* pContext;
1467 : 93 : uno::Any aAny;
1468 : 93 : sal_Int32 nKey(0);
1469 [ + + ]: 517 : for (sal_uInt32 i = 0; i < nCount; i++, pNames++)
1470 : : {
1471 [ + - ][ + - ]: 424 : aAny = mxNumberStyles->getByName(*pNames);
1472 [ + - ]: 424 : if (aAny >>= nKey)
1473 : : {
1474 : : pContext = new SvXMLNumFormatContext( *this, XML_NAMESPACE_NUMBER,
1475 [ + - ][ + - ]: 424 : *pNames, xAttrList, nKey, *pAutoStyles );
1476 [ + - ]: 424 : pAutoStyles->AddStyle(*pContext);
1477 : : }
1478 : 93 : }
1479 : : }
1480 [ + - ]: 93 : }
1481 : : }
1482 : 332 : mxAutoStyles = pAutoStyles;
1483 [ + - ][ + - ]: 332 : GetTextImport()->SetAutoStyles( pAutoStyles );
1484 [ + - ][ + - ]: 332 : GetShapeImport()->SetAutoStylesContext( pAutoStyles );
1485 [ + - ]: 332 : GetChartImport()->SetAutoStylesContext( pAutoStyles );
1486 [ + - ][ + - ]: 332 : GetFormImport()->setAutoStyleContext( pAutoStyles );
1487 : 332 : }
1488 : :
1489 : 63 : void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles )
1490 : : {
1491 : 63 : mxMasterStyles = pMasterStyles;
1492 : 63 : }
1493 : :
1494 : 923 : XMLFontStylesContext *SvXMLImport::GetFontDecls()
1495 : : {
1496 : 923 : return (XMLFontStylesContext *)&mxFontDecls;
1497 : : }
1498 : :
1499 : 409 : SvXMLStylesContext *SvXMLImport::GetStyles()
1500 : : {
1501 : 409 : return (SvXMLStylesContext *)&mxStyles;
1502 : : }
1503 : :
1504 : 6581 : SvXMLStylesContext *SvXMLImport::GetAutoStyles()
1505 : : {
1506 : 6581 : return (SvXMLStylesContext *)&mxAutoStyles;
1507 : : }
1508 : :
1509 : 130 : const XMLFontStylesContext *SvXMLImport::GetFontDecls() const
1510 : : {
1511 : 130 : return (const XMLFontStylesContext *)&mxFontDecls;
1512 : : }
1513 : :
1514 : 0 : const SvXMLStylesContext *SvXMLImport::GetStyles() const
1515 : : {
1516 : 0 : return (const SvXMLStylesContext *)&mxStyles;
1517 : : }
1518 : :
1519 : 228 : const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const
1520 : : {
1521 : 228 : return (const SvXMLStylesContext *)&mxAutoStyles;
1522 : : }
1523 : :
1524 : 551 : OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const
1525 : : {
1526 [ + + ][ - + ]: 551 : if( rValue.isEmpty() || rValue[0] == '#' )
[ + + ]
1527 : 362 : return rValue;
1528 : :
1529 [ + - ]: 189 : INetURLObject aAbsURL;
1530 [ + - ][ + + ]: 189 : if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
1531 [ + - ]: 185 : return aAbsURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
1532 : : else
1533 [ + - ]: 551 : return rValue;
1534 : : }
1535 : :
1536 : 201 : sal_Bool SvXMLImport::IsODFVersionConsistent( const ::rtl::OUString& aODFVersion )
1537 : : {
1538 : : // the check returns sal_False only if the storage version could be retrieved
1539 : 201 : sal_Bool bResult = sal_True;
1540 : :
1541 [ + - ][ + - ]: 201 : if ( !aODFVersion.isEmpty() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
[ + + ][ + - ]
[ + + # # ]
1542 : : {
1543 : : // check the consistency only for the ODF1.2 and later ( according to content.xml )
1544 : : // manifest.xml might have no version, it should be checked here and the correct version should be set
1545 : : try
1546 : : {
1547 [ + - ]: 187 : uno::Reference< document::XStorageBasedDocument > xDoc( mxModel, uno::UNO_QUERY_THROW );
1548 [ + - ][ + + ]: 187 : uno::Reference< embed::XStorage > xStor = xDoc->getDocumentStorage();
1549 [ + - ]: 159 : uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
1550 : :
1551 : : // the check should be done only for OASIS format
1552 : 159 : ::rtl::OUString aMediaType;
1553 [ + - ][ + - ]: 159 : xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ) ) >>= aMediaType;
[ + - ]
1554 [ + + ][ + - ]: 159 : if ( ::comphelper::OStorageHelper::GetXStorageFormat( xStor ) >= SOFFICE_FILEFORMAT_8 )
1555 : : {
1556 : 147 : sal_Bool bRepairPackage = sal_False;
1557 : : try
1558 : : {
1559 [ + - ]: 147 : xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) ) )
1560 [ + - ][ + - ]: 147 : >>= bRepairPackage;
[ # # ]
1561 [ # # ]: 0 : } catch ( uno::Exception& )
1562 : : {}
1563 : :
1564 : : // check only if not in Repair mode
1565 [ + - ]: 147 : if ( !bRepairPackage )
1566 : : {
1567 : 147 : ::rtl::OUString aStorVersion;
1568 [ + - ]: 147 : xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) )
1569 [ + - ][ + - ]: 147 : >>= aStorVersion;
1570 : :
1571 : : // if the storage version is set in manifest.xml, it must be the same as in content.xml
1572 : : // if not, set it explicitly to be used further ( it will work even for readonly storage )
1573 : : // This workaround is not nice, but I see no other way to handle it, since there are
1574 : : // ODF1.2 documents without version in manifest.xml
1575 [ + - ]: 147 : if ( !aStorVersion.isEmpty() )
1576 : 147 : bResult = aODFVersion.equals( aStorVersion );
1577 : : else
1578 [ # # ]: 0 : xStorProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ),
1579 [ # # ][ # # ]: 0 : uno::makeAny( aODFVersion ) );
[ # # ]
1580 : :
1581 [ + - ]: 147 : if ( bResult )
1582 : : {
1583 : 147 : sal_Bool bInconsistent = sal_False;
1584 [ + - ]: 147 : xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsInconsistent" ) ) )
1585 [ + - ][ + - ]: 147 : >>= bInconsistent;
1586 : 147 : bResult = !bInconsistent;
1587 : 147 : }
1588 : : }
1589 [ - + ]: 187 : }
1590 : : }
1591 : 28 : catch( uno::Exception& )
1592 : : {}
1593 : : }
1594 : :
1595 : 201 : return bResult;
1596 : : }
1597 : :
1598 : 861 : void SvXMLImport::_CreateNumberFormatsSupplier()
1599 : : {
1600 : : DBG_ASSERT( !mxNumberFormatsSupplier.is(),
1601 : : "number formats supplier already exists!" );
1602 [ + - ]: 861 : if(mxModel.is())
1603 : : mxNumberFormatsSupplier =
1604 [ + - ]: 861 : uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
1605 : 861 : }
1606 : :
1607 : :
1608 : 873 : void SvXMLImport::_CreateDataStylesImport()
1609 : : {
1610 : : DBG_ASSERT( mpNumImport == NULL, "data styles import already exists!" );
1611 : : uno::Reference<util::XNumberFormatsSupplier> xNum =
1612 [ + - ]: 873 : GetNumberFormatsSupplier();
1613 [ + + ]: 873 : if ( xNum.is() )
1614 [ + - ][ + - ]: 873 : mpNumImport = new SvXMLNumFmtHelper(xNum, getServiceFactory());
[ + - ]
1615 : 873 : }
1616 : :
1617 : :
1618 : 0 : sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
1619 : : {
1620 : 0 : sal_Unicode cNew = c;
1621 [ # # ]: 0 : if( !mpImpl->hBatsFontConv )
1622 : : {
1623 [ # # ]: 0 : OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) );
1624 : : mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats,
1625 [ # # ][ # # ]: 0 : FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
[ # # ]
1626 : 0 : OSL_ENSURE( mpImpl->hBatsFontConv, "Got no symbol font converter" );
1627 : : }
1628 [ # # ]: 0 : if( mpImpl->hBatsFontConv )
1629 : : {
1630 : 0 : cNew = ConvertFontToSubsFontChar( mpImpl->hBatsFontConv, c );
1631 : : }
1632 : :
1633 : 0 : return cNew;
1634 : : }
1635 : :
1636 : 0 : sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
1637 : : {
1638 : 0 : sal_Unicode cNew = c;
1639 [ # # ]: 0 : if( !mpImpl->hMathFontConv )
1640 : : {
1641 [ # # ]: 0 : OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) );
1642 : : mpImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath,
1643 [ # # ][ # # ]: 0 : FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
[ # # ]
1644 : 0 : OSL_ENSURE( mpImpl->hMathFontConv, "Got no symbol font converter" );
1645 : : }
1646 [ # # ]: 0 : if( mpImpl->hMathFontConv )
1647 : : {
1648 : 0 : cNew = ConvertFontToSubsFontChar( mpImpl->hMathFontConv, c );
1649 : : }
1650 : :
1651 : 0 : return cNew;
1652 : : }
1653 : :
1654 : :
1655 : :
1656 : 73 : void SvXMLImport::SetError(
1657 : : sal_Int32 nId,
1658 : : const Sequence<OUString>& rMsgParams,
1659 : : const OUString& rExceptionMessage,
1660 : : const Reference<xml::sax::XLocator>& rLocator )
1661 : : {
1662 : : // maintain error flags
1663 [ + - ]: 73 : if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
1664 : 73 : mnErrorFlags |= ERROR_ERROR_OCCURRED;
1665 [ - + ]: 73 : if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
1666 : 0 : mnErrorFlags |= ERROR_WARNING_OCCURRED;
1667 [ - + ]: 73 : if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
1668 : 0 : mnErrorFlags |= ERROR_DO_NOTHING;
1669 : :
1670 : : // create error list on demand
1671 [ + + ]: 73 : if ( mpXMLErrors == NULL )
1672 [ + - ]: 4 : mpXMLErrors = new XMLErrors();
1673 : :
1674 : : // save error information
1675 : : // use document locator (if none supplied)
1676 : : mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
1677 [ + - ]: 73 : rLocator.is() ? rLocator : mxLocator );
1678 : 73 : }
1679 : :
1680 : 0 : void SvXMLImport::SetError(
1681 : : sal_Int32 nId,
1682 : : const Sequence<OUString>& rMsgParams)
1683 : : {
1684 : 0 : OUString sEmpty;
1685 [ # # ][ # # ]: 0 : SetError( nId, rMsgParams, sEmpty, NULL );
1686 : 0 : }
1687 : :
1688 : 0 : void SvXMLImport::SetError(
1689 : : sal_Int32 nId)
1690 : : {
1691 [ # # ]: 0 : Sequence<OUString> aSeq(0);
1692 [ # # ][ # # ]: 0 : SetError( nId, aSeq );
1693 : 0 : }
1694 : :
1695 : 0 : void SvXMLImport::SetError(
1696 : : sal_Int32 nId,
1697 : : const OUString& rMsg1)
1698 : : {
1699 [ # # ]: 0 : Sequence<OUString> aSeq(1);
1700 [ # # ]: 0 : OUString* pSeq = aSeq.getArray();
1701 : 0 : pSeq[0] = rMsg1;
1702 [ # # ][ # # ]: 0 : SetError( nId, aSeq );
1703 : 0 : }
1704 : :
1705 : 0 : void SvXMLImport::SetError(
1706 : : sal_Int32 nId,
1707 : : const OUString& rMsg1,
1708 : : const OUString& rMsg2)
1709 : : {
1710 [ # # ]: 0 : Sequence<OUString> aSeq(2);
1711 [ # # ]: 0 : OUString* pSeq = aSeq.getArray();
1712 : 0 : pSeq[0] = rMsg1;
1713 : 0 : pSeq[1] = rMsg2;
1714 [ # # ][ # # ]: 0 : SetError( nId, aSeq );
1715 : 0 : }
1716 : :
1717 : 26 : void SvXMLImport::DisposingModel()
1718 : : {
1719 [ - + ]: 26 : if( mxFontDecls.Is() )
1720 : 0 : ((SvXMLStylesContext *)&mxFontDecls)->Clear();
1721 [ + + ]: 26 : if( mxStyles.Is() )
1722 : 1 : ((SvXMLStylesContext *)&mxStyles)->Clear();
1723 [ - + ]: 26 : if( mxAutoStyles.Is() )
1724 : 0 : ((SvXMLStylesContext *)&mxAutoStyles)->Clear();
1725 [ - + ]: 26 : if( mxMasterStyles.Is() )
1726 : 0 : ((SvXMLStylesContext *)&mxMasterStyles)->Clear();
1727 : :
1728 : 26 : mxModel.set(0);
1729 : 26 : mxEventListener.set(NULL);
1730 : 26 : }
1731 : :
1732 : 30 : ::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLImport::getInterfaceToIdentifierMapper()
1733 : : {
1734 : 30 : return mpImpl->maInterfaceToIdentifierMapper;
1735 : : }
1736 : :
1737 : 1828 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLImport::getServiceFactory()
1738 : : {
1739 : : // #110680#
1740 : 1828 : return mxServiceFactory;
1741 : : }
1742 : :
1743 : : uno::Reference< uno::XComponentContext >
1744 : 12 : SvXMLImport::GetComponentContext() const
1745 : : {
1746 : 12 : return mpImpl->mxComponentContext;
1747 : : }
1748 : :
1749 : 2 : ::rtl::OUString SvXMLImport::GetBaseURL() const
1750 : : {
1751 : 2 : return mpImpl->aBaseURL.GetMainURL( INetURLObject::NO_DECODE );
1752 : : }
1753 : :
1754 : 0 : ::rtl::OUString SvXMLImport::GetDocumentBase() const
1755 : : {
1756 : 0 : return mpImpl->aDocBase.GetMainURL( INetURLObject::NO_DECODE );
1757 : : }
1758 : :
1759 : 188 : ::rtl::OUString SvXMLImport::GetStreamName() const
1760 : : {
1761 : 188 : return mpImpl->mStreamName;
1762 : : }
1763 : :
1764 : : // Convert drawing object positions from OOo file format to OASIS (#i28749#)
1765 : 506 : sal_Bool SvXMLImport::IsShapePositionInHoriL2R() const
1766 : : {
1767 : 506 : return mpImpl->mbShapePositionInHoriL2R;
1768 : : }
1769 : :
1770 : 84 : sal_Bool SvXMLImport::IsTextDocInOOoFileFormat() const
1771 : : {
1772 : 84 : return mpImpl->mbTextDocInOOoFileFormat;
1773 : : }
1774 : :
1775 : 0 : void SvXMLImport::initXForms()
1776 : : {
1777 : : // dummy method; to be implemented by derived classes supporting XForms
1778 : 0 : }
1779 : :
1780 : 1492 : bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const
1781 : : {
1782 : 1492 : bool bRet = false;
1783 [ + + ]: 1492 : if( mxImportInfo.is() ) try
1784 : : {
1785 [ + - ]: 1332 : const OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("BuildId"));
1786 [ + - ][ + - ]: 1332 : Reference< XPropertySetInfo > xSetInfo( mxImportInfo->getPropertySetInfo() );
1787 [ + - ][ + - ]: 1332 : if( xSetInfo.is() && xSetInfo->hasPropertyByName( aPropName ) )
[ + - ][ + - ]
[ + - ]
1788 : : {
1789 : 1332 : OUString aBuildId;
1790 [ + - ][ + - ]: 1332 : mxImportInfo->getPropertyValue( aPropName ) >>= aBuildId;
1791 [ + + ]: 1332 : if( !aBuildId.isEmpty() )
1792 : : {
1793 : 821 : sal_Int32 nIndex = aBuildId.indexOf('$');
1794 [ + - ]: 821 : if( nIndex != -1 )
1795 : : {
1796 : 821 : rUPD = aBuildId.copy( 0, nIndex ).toInt32();
1797 : 821 : rBuild = aBuildId.copy( nIndex+1 ).toInt32();
1798 : 821 : bRet = true;
1799 : : }
1800 : 1332 : }
1801 [ # # ]: 1332 : }
1802 : : }
1803 : 0 : catch( Exception& )
1804 : : {
1805 : : }
1806 : 1492 : return bRet;
1807 : : }
1808 : :
1809 : 32 : sal_uInt16 SvXMLImport::getGeneratorVersion() const
1810 : : {
1811 : : sal_Int32 nUPD, nBuild;
1812 : :
1813 [ + - ][ + - ]: 32 : if( getBuildIds( nUPD, nBuild ) )
1814 : : {
1815 [ + - ]: 32 : if( nUPD == 680 )
1816 : 32 : return OOo_2x;
1817 : :
1818 [ # # ][ # # ]: 0 : if( nUPD >= 640 && nUPD <= 645 )
1819 : 0 : return OOo_1x;
1820 : : }
1821 : :
1822 : 32 : return OOo_Current;
1823 : : }
1824 : :
1825 : 8 : bool SvXMLImport::isGraphicLoadOnDemandSupported() const
1826 : : {
1827 : 8 : return mbIsGraphicLoadOnDemandSupported;
1828 : : }
1829 : :
1830 : 99 : ::rtl::OUString SvXMLImport::GetODFVersion() const
1831 : : {
1832 : 99 : return mpImpl->aODFVersion;
1833 : : }
1834 : :
1835 : : // xml:id for RDF metadata
1836 : 2141 : void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
1837 : : ::rtl::OUString const & i_rXmlId)
1838 : : {
1839 [ + + ]: 2141 : if (!i_rXmlId.isEmpty()) {
1840 : : try {
1841 : : const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
1842 [ + - ]: 188 : uno::UNO_QUERY);
1843 : : //FIXME: not yet
1844 [ + - ]: 188 : if (xMeta.is()) {
1845 [ + - ]: 188 : const beans::StringPair mdref( GetStreamName(), i_rXmlId );
1846 : : try {
1847 [ + - ][ + - ]: 188 : xMeta->setMetadataReference(mdref);
1848 [ # # ]: 0 : } catch (lang::IllegalArgumentException &) {
1849 : : // probably duplicate; ignore
1850 : : OSL_TRACE("SvXMLImport::SetXmlId: cannot set xml:id");
1851 : 188 : }
1852 [ # # ]: 188 : }
1853 : 0 : } catch (uno::Exception &) {
1854 : : OSL_FAIL("SvXMLImport::SetXmlId: exception?");
1855 : : }
1856 : : }
1857 [ # # ]: 2141 : }
1858 : :
1859 : : SAL_DLLPRIVATE ::xmloff::RDFaImportHelper &
1860 : 88 : SvXMLImport::GetRDFaImportHelper()
1861 : : {
1862 [ + + ]: 88 : if (!mpImpl->mpRDFaHelper.get())
1863 : : {
1864 [ + - ]: 12 : mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
1865 : : }
1866 : 88 : return *mpImpl->mpRDFaHelper;
1867 : : }
1868 : :
1869 : : void
1870 : 72 : SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
1871 : : ::rtl::OUString const & i_rAbout,
1872 : : ::rtl::OUString const & i_rProperty,
1873 : : ::rtl::OUString const & i_rContent,
1874 : : ::rtl::OUString const & i_rDatatype)
1875 : : {
1876 : : // N.B.: we only get called if i_xObject had xhtml:about attribute
1877 : : // (an empty attribute value is valid)
1878 : 72 : ::xmloff::RDFaImportHelper & rRDFaHelper( GetRDFaImportHelper() );
1879 : : rRDFaHelper.ParseAndAddRDFa(i_xObject,
1880 : 72 : i_rAbout, i_rProperty, i_rContent, i_rDatatype);
1881 : 72 : }
1882 : :
1883 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|