2009-09-14 15:11:29 +0200 oc r276125 : #i105049# MacroSignatur needs Macro 2009-09-09 17:09:46 +0200 jl r276005 : #i103989# could not signe encrypted doc containing a formular object 2009-09-09 13:11:24 +0200 jl r275985 : #i103989# could not signe encrypted doc containing a formular object 2009-09-08 15:54:02 +0200 mav r275934 : #i103906# fix the automation test scenario ( tempfile should be writable for the user ) 2009-09-07 14:01:39 +0200 mav r275895 : #i103906# fix the problem with reload 2009-09-07 09:34:48 +0200 mav r275871 : #i104786# do the ODF version check only for ODF documents 2009-09-07 08:19:06 +0200 mav r275870 : #i104389# fix text 2009-09-06 22:24:21 +0200 mav r275867 : #i104786# check the consistency of ODF version 2009-09-06 22:23:24 +0200 mav r275866 : #i104786# check the consistency of ODF version 2009-09-06 22:23:00 +0200 mav r275865 : #i104786# check the consistency of ODF version 2009-09-06 22:22:36 +0200 mav r275864 : #i104786# check the consistency of ODF version 2009-09-06 22:22:03 +0200 mav r275863 : #i104786# check the consistency of ODF version 2009-09-02 17:09:30 +0200 mav r275722 : #i104715# let repairing mechanics use the streams correctly 2009-09-01 16:52:49 +0200 mav r275670 : #i104389# notify user not to trust the corrupted document 2009-09-01 16:31:37 +0200 mav r275668 : #i104389# use vnd.sun.star.zip: protocol to access zip files 2009-09-01 16:30:32 +0200 mav r275667 : #i104389# use vnd.sun.star.zip: protocol to access zip files 2009-09-01 16:22:13 +0200 jl r275666 : #i104339# small content change 2009-09-01 14:20:42 +0200 jl r275660 : #i103519# remove some debug output 2009-09-01 13:51:52 +0200 jl r275659 : #i103519# NSS uses '\' for escaping in distinguished names 2009-09-01 12:49:47 +0200 mav r275655 : #i104389# use zip-mode to read from jar files 2009-09-01 12:40:22 +0200 mav r275653 : #i104389# use zip-mode to read from jar files 2009-09-01 12:32:29 +0200 mav r275652 : #i104389# use constants 2009-08-31 21:58:00 +0200 mav r275637 : #i10000# fix warning 2009-08-31 21:11:17 +0200 mav r275636 : #i104227# adding of scripting signature removes the document signature 2009-08-31 20:55:05 +0200 mav r275635 : #i103905# ZipStorage supports Compressed property 2009-08-31 20:53:55 +0200 mav r275634 : #i103905# adjust macro signature transfer to usage of ZipStorage 2009-08-31 15:30:49 +0200 jl r275609 : #i103989# warning is shown as long the user does not click 'OK' 2009-08-31 14:36:10 +0200 jl r275608 : #i103989# changed warning text when signing macro and there is a document signature. This warning is only displayed once 2009-08-31 13:34:41 +0200 mav r275603 : #i104452# disable macros in repaired documents 2009-08-31 13:33:42 +0200 mav r275602 : #i104452# disable macros in repaired documents 2009-08-31 13:03:56 +0200 jl r275600 : #i45212# signature dialog could not be started when using read-only documents 2009-08-31 09:26:13 +0200 mav r275583 : #i104578# store the additional entry as the last one to workaround parsing problem in OOo3.1 and later 2009-08-30 20:54:25 +0200 mav r275562 : #i10000# adopt for unix 2009-08-30 10:56:00 +0200 mav r275561 : CWS-TOOLING: rebase CWS encsig09 to trunk@275331 (milestone: DEV300:m56) 2009-08-28 16:34:00 +0200 mav r275539 : #i104578# write necessary info in manifest.xml for ODF1.2 encrypted document 2009-08-28 14:04:22 +0200 mav r275533 : #104587# fix handling of readonly streams 2009-08-28 13:58:10 +0200 mav r275531 : #i104389# fix the broken document handling 2009-08-28 11:40:39 +0200 mav r275522 : #i104389# fix the signature streams check 2009-08-27 21:48:12 +0200 mav r275509 : #i103927# show the warning 2009-08-27 21:47:48 +0200 mav r275508 : #i103927# show the warning 2009-08-27 16:45:59 +0200 jl r275495 : #i45212# remove unused variable 2009-08-27 16:34:00 +0200 jl r275494 : #i103989# 2009-08-27 13:54:28 +0200 jl r275482 : #i103519# fixed replacement of 'S' by 'ST' 2009-08-27 12:32:21 +0200 mav r275472 : #i10000# fix warning 2009-08-27 11:58:11 +0200 mav r275467 : #i104389# handle the entry path correctly 2009-08-26 17:18:35 +0200 jl r275438 : #i103519# subject and issuer distinguished names were not properly displayed. The strings were obtained by system functions (Windows, NSS), which use quotes to escape the values, when they contain special characters 2009-08-26 11:00:20 +0200 mav r275403 : #i10000# fix warnings 2009-08-26 08:25:45 +0200 mav r275392 : #i10000# fix warning 2009-08-26 08:02:22 +0200 mav r275391 : #i10000# adopt for linux 2009-08-26 07:40:30 +0200 mav r275390 : #i10000# fix warning 2009-08-26 07:35:28 +0200 mav r275389 : #i10000# use correct include file name 2009-08-25 15:01:41 +0200 jl r275356 : #i103989# better check for mimetype of streams 2009-08-25 09:07:09 +0200 mav r275335 : CWS-TOOLING: rebase CWS encsig09 to trunk@274622 (milestone: DEV300:m54) 2009-08-24 18:17:02 +0200 mav r275329 : #i103927# check the nonencrypted streams 2009-08-24 18:14:14 +0200 mav r275328 : #i103927# check the nonencrypted streams 2009-08-24 17:59:34 +0200 mav r275327 : #i103927#,#i104389# check the package consistency and nonencrypted streams 2009-08-24 16:18:28 +0200 jl r275323 : #i103989# added comment 2009-08-24 13:08:47 +0200 jl r275305 : #i45212# #i66276# only write the X509Certificate element once and allow to add remove several certificates at a time 2009-08-21 12:57:28 +0200 ufi r275239 : 104339 2009-08-21 08:39:05 +0200 jl r275213 : #i10398# comparing URIs of signed files with the 'element list' 2009-08-20 13:39:47 +0200 jl r275178 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 13:35:39 +0200 jl r275177 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 13:29:06 +0200 jl r275176 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 13:26:21 +0200 jl r275175 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 12:05:09 +0200 ufi r275170 : i104339 2009-08-19 12:24:54 +0200 jl r275146 : #i10398# displaying 'old signature' icon and status in signature dialog 2009-08-18 15:18:48 +0200 jl r275111 : #i103989# document signatures containing manifest.xml are now validated according to the final ODF1.2 spec 2009-08-18 11:41:06 +0200 mav r275087 : #i103927# detect if encrypted ODF1.2 document contains nonencrypted streams 2009-08-18 11:35:13 +0200 mav r275085 : #i103927# detect if encrypted ODF1.2 document contains nonencrypted streams 2009-08-14 17:32:41 +0200 jl r274999 : #i103989# using c14n tranformation for XML streams 2009-08-14 15:27:43 +0200 jl r274987 : #i103989# remove special handling for encrypted document streams in UriBindingHelper::OpenInputStream, since we use zip storage this is not necessary anymore 2009-08-14 15:08:10 +0200 jl r274983 : #i103989# Showing a message when adding or removing a macro signature, that the document signature will be removed 2009-08-14 14:57:27 +0200 jl r274982 : #i103989# accesing Sequence at invalid index 2009-08-11 08:55:02 +0200 mav r274846 : #i103905# let signing service know if there is already a valid document signature 2009-08-10 11:33:37 +0200 jl r274799 : #i103905# do not truncate the stream 2009-08-10 10:43:47 +0200 mav r274797 : #i103905# provide the storage version 2009-08-07 16:58:46 +0200 jl r274780 : #i103989# 2009-08-07 16:56:19 +0200 jl r274779 : #i103989# using odf version string etc. 2009-08-07 15:20:53 +0200 mav r274771 : #i103905# provide the storage version 2009-08-07 15:19:12 +0200 mav r274770 : #i103905# provide the storage version 2009-08-07 12:41:45 +0200 mav r274758 : #103930# do not store thumbnail in case of encrypted document 2009-08-07 12:36:52 +0200 mav r274757 : #i103905# provide the storage version 2009-08-07 12:15:54 +0200 mav r274754 : #i103760# the signed state is not lost on saving 2009-08-07 12:06:19 +0200 mav r274753 : #i103760# avoid warning regarding signature removal on export 2009-08-07 12:06:01 +0200 mav r274752 : #i103760# avoid warning regarding signature removal on export 2009-08-06 08:47:34 +0200 mav r274703 : #i103905# allow to transport ODF version to the signing component 2009-08-05 21:34:42 +0200 mav r274701 : #i103905# allow to transport ODF version to the signing component 2009-08-05 15:48:17 +0200 mav r274683 : #i103905# allow to transport ODF version to the signing component 2009-08-05 14:58:12 +0200 jl r274673 : #i103989# documentsignature now signes all streams except documentsignatures.xml, all streams are processed as binary files 2009-08-05 12:00:32 +0200 mav r274648 : #i103905# allow to transport ODF version to the signing component 2009-08-04 10:57:04 +0200 jl r274612 : #i103989# added XInitialization 2009-07-31 10:32:27 +0200 mav r274516 : #i103905# use zip storage to sign documents 2009-07-30 14:01:33 +0200 mav r274489 : #i103906# optimize the usage of temporary medium 2009-07-30 14:00:28 +0200 mav r274488 : #i103906# optimize the usage of temporary medium 2009-07-30 13:59:09 +0200 mav r274487 : #i103906# optimize the usage of temporary medium 2009-07-30 13:50:44 +0200 mav r274485 : #i103906# optimize the usage of temporary medium 2009-07-30 13:49:53 +0200 mav r274484 : #i103906# optimize the usage of temporary medium 2009-07-30 13:49:13 +0200 mav r274483 : #i103906# optimize the usage of temporary medium 2009-07-30 13:47:09 +0200 mav r274482 : #i103905#,#i103906# let the signing process use zip-storage; optimize the usage of temporary medium 2009-07-21 09:10:31 +0200 mav r274159 : CWS-TOOLING: rebase CWS encsig09 to trunk@273468 (milestone: DEV300:m51) 2009-05-05 08:39:01 +0200 mav r271496 : #i100832# allow to sign macros only when there are any
1986 lines
66 KiB
C++
1986 lines
66 KiB
C++
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: xmlimp.cxx,v $
|
|
* $Revision: 1.112.2.2 $
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_xmloff.hxx"
|
|
#include <com/sun/star/beans/XPropertySetInfo.hpp>
|
|
#include <tools/debug.hxx>
|
|
#include <tools/urlobj.hxx>
|
|
#include <osl/mutex.hxx>
|
|
#include <rtl/uuid.h>
|
|
#include <rtl/memory.h>
|
|
#include <svtools/svarray.hxx>
|
|
#include "unointerfacetouniqueidentifiermapper.hxx"
|
|
#include <xmloff/nmspmap.hxx>
|
|
#include <xmloff/xmluconv.hxx>
|
|
#include "xmlnmspe.hxx"
|
|
#include "xmlkywd.hxx"
|
|
#include <xmloff/xmltoken.hxx>
|
|
#include <xmloff/XMLFontStylesContext.hxx>
|
|
#include <xmloff/xmlictxt.hxx>
|
|
#include <xmloff/xmlimp.hxx>
|
|
#include <xmloff/xmlnumfi.hxx>
|
|
#include "XMLEventImportHelper.hxx"
|
|
#include "XMLStarBasicContextFactory.hxx"
|
|
#include "XMLScriptContextFactory.hxx"
|
|
#include "StyleMap.hxx"
|
|
#include <xmloff/ProgressBarHelper.hxx>
|
|
#include <xmloff/xmltoken.hxx>
|
|
#include "xmlerror.hxx"
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
|
#include <com/sun/star/document/XBinaryStreamResolver.hpp>
|
|
#include <com/sun/star/document/XStorageBasedDocument.hpp>
|
|
#include <com/sun/star/xml/sax/XLocator.hpp>
|
|
#include <com/sun/star/packages/zip/ZipIOException.hpp>
|
|
#include <comphelper/namecontainer.hxx>
|
|
#include <rtl/logfile.hxx>
|
|
#include <tools/string.hxx> // used in StartElement for logging
|
|
#include <cppuhelper/implbase1.hxx>
|
|
#include <comphelper/extract.hxx>
|
|
#include <comphelper/processfactory.hxx>
|
|
#include <comphelper/documentconstants.hxx>
|
|
#include <comphelper/storagehelper.hxx>
|
|
#include <vcl/fontcvt.hxx>
|
|
|
|
#include <com/sun/star/rdf/XMetadatable.hpp>
|
|
#include <com/sun/star/rdf/XRepositorySupplier.hpp>
|
|
#include "RDFaImportHelper.hxx"
|
|
|
|
#define LOGFILE_AUTHOR "unknown"
|
|
|
|
using ::com::sun::star::beans::XPropertySetInfo;
|
|
|
|
using ::rtl::OUString;
|
|
using ::rtl::OUStringBuffer;
|
|
|
|
using namespace ::osl;
|
|
using namespace ::com::sun::star;
|
|
using namespace ::com::sun::star::frame;
|
|
using namespace ::com::sun::star::uno;
|
|
using namespace ::com::sun::star::util;
|
|
using namespace ::com::sun::star::io;
|
|
using namespace ::com::sun::star::container;
|
|
using namespace ::com::sun::star::document;
|
|
using namespace ::xmloff::token;
|
|
|
|
sal_Char __READONLY_DATA sXML_np__office[] = "_office";
|
|
sal_Char __READONLY_DATA sXML_np__office_ext[] = "_office_ooo";
|
|
sal_Char __READONLY_DATA sXML_np__ooo[] = "_ooo";
|
|
sal_Char __READONLY_DATA sXML_np__ooow[] = "_ooow";
|
|
sal_Char __READONLY_DATA sXML_np__oooc[] = "_oooc";
|
|
sal_Char __READONLY_DATA sXML_np__of[] = "_of";
|
|
sal_Char __READONLY_DATA sXML_np__style[] = "_style";
|
|
sal_Char __READONLY_DATA sXML_np__text[] = "_text";
|
|
sal_Char __READONLY_DATA sXML_np__table[] = "_table";
|
|
sal_Char __READONLY_DATA sXML_np__draw[] = "_draw";
|
|
sal_Char __READONLY_DATA sXML_np__dr3d[] = "_dr3d";
|
|
sal_Char __READONLY_DATA sXML_np__fo[] = "_fo";
|
|
sal_Char __READONLY_DATA sXML_np__xlink[] = "_xlink";
|
|
sal_Char __READONLY_DATA sXML_np__dc[] = "_dc";
|
|
sal_Char __READONLY_DATA sXML_np__dom[] = "_dom";
|
|
sal_Char __READONLY_DATA sXML_np__meta[] = "_meta";
|
|
sal_Char __READONLY_DATA sXML_np__number[] = "_number";
|
|
sal_Char __READONLY_DATA sXML_np__svg[] = "_svg";
|
|
sal_Char __READONLY_DATA sXML_np__chart[] = "_chart";
|
|
sal_Char __READONLY_DATA sXML_np__math[] = "_math";
|
|
sal_Char __READONLY_DATA sXML_np__script[] = "_script";
|
|
sal_Char __READONLY_DATA sXML_np__config[] = "_config";
|
|
sal_Char __READONLY_DATA sXML_np__db[] = "_db";
|
|
sal_Char __READONLY_DATA sXML_np__xforms[] = "_xforms";
|
|
sal_Char __READONLY_DATA sXML_np__xsd[] = "_xsd";
|
|
sal_Char __READONLY_DATA sXML_np__xsi[] = "_xsi";
|
|
sal_Char __READONLY_DATA sXML_np__field[] = "_field";
|
|
sal_Char __READONLY_DATA sXML_np__xhtml[] = "_xhtml";
|
|
|
|
sal_Char __READONLY_DATA sXML_np__fo_old[] = "__fo";
|
|
sal_Char __READONLY_DATA sXML_np__xlink_old[] = "__xlink";
|
|
sal_Char __READONLY_DATA sXML_np__office_old[] = "__office";
|
|
sal_Char __READONLY_DATA sXML_np__style_old[] = "__style";
|
|
sal_Char __READONLY_DATA sXML_np__text_old[] = "__text";
|
|
sal_Char __READONLY_DATA sXML_np__table_old[] = "__table";
|
|
sal_Char __READONLY_DATA sXML_np__meta_old[] = "__meta";
|
|
|
|
|
|
|
|
class SvXMLImportEventListener : public cppu::WeakImplHelper1<
|
|
com::sun::star::lang::XEventListener >
|
|
{
|
|
private:
|
|
SvXMLImport* pImport;
|
|
|
|
public:
|
|
SvXMLImportEventListener(SvXMLImport* pImport);
|
|
virtual ~SvXMLImportEventListener();
|
|
|
|
// XEventListener
|
|
virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
|
|
};
|
|
|
|
SvXMLImportEventListener::SvXMLImportEventListener(SvXMLImport* pTempImport)
|
|
: pImport(pTempImport)
|
|
{
|
|
}
|
|
|
|
SvXMLImportEventListener::~SvXMLImportEventListener()
|
|
{
|
|
}
|
|
|
|
// XEventListener
|
|
void SAL_CALL SvXMLImportEventListener::disposing( const lang::EventObject& )
|
|
throw(uno::RuntimeException)
|
|
{
|
|
if (pImport)
|
|
{
|
|
pImport->DisposingModel();
|
|
pImport = NULL;
|
|
}
|
|
}
|
|
|
|
//==============================================================================
|
|
|
|
class SvXMLImport_Impl
|
|
{
|
|
public:
|
|
FontToSubsFontConverter hBatsFontConv;
|
|
FontToSubsFontConverter hMathFontConv;
|
|
|
|
bool mbOwnGraphicResolver;
|
|
bool mbOwnEmbeddedResolver;
|
|
INetURLObject aBaseURL;
|
|
INetURLObject aDocBase;
|
|
|
|
/// name of stream in package, e.g., "content.xml"
|
|
::rtl::OUString mStreamName;
|
|
|
|
::rtl::OUString aODFVersion;
|
|
|
|
// --> OD 2004-08-10 #i28749# - boolean, indicating that position attributes
|
|
// of shapes are given in horizontal left-to-right layout. This is the case
|
|
// for the OpenOffice.org file format.
|
|
sal_Bool mbShapePositionInHoriL2R;
|
|
// <--
|
|
// --> OD 2007-12-19 #152540#
|
|
sal_Bool mbTextDocInOOoFileFormat;
|
|
// <--
|
|
|
|
const uno::Reference< uno::XComponentContext > mxComponentContext;
|
|
|
|
std::auto_ptr< xmloff::RDFaImportHelper > mpRDFaHelper;
|
|
|
|
SvXMLImport_Impl() :
|
|
hBatsFontConv( 0 ), hMathFontConv( 0 ),
|
|
mbOwnGraphicResolver( false ),
|
|
mbOwnEmbeddedResolver( false ),
|
|
mStreamName(),
|
|
// --> OD 2004-08-11 #i28749#
|
|
mbShapePositionInHoriL2R( sal_False ),
|
|
// <--
|
|
// --> OD 2007-12-19 #152540#
|
|
mbTextDocInOOoFileFormat( sal_False ),
|
|
// <--
|
|
mxComponentContext( ::comphelper::getProcessComponentContext() ),
|
|
mpRDFaHelper() // lazy
|
|
{
|
|
OSL_ENSURE(mxComponentContext.is(), "SvXMLImport: no ComponentContext");
|
|
if (!mxComponentContext.is()) throw uno::RuntimeException();
|
|
}
|
|
|
|
~SvXMLImport_Impl()
|
|
{
|
|
if( hBatsFontConv )
|
|
DestroyFontToSubsFontConverter( hBatsFontConv );
|
|
if( hMathFontConv )
|
|
DestroyFontToSubsFontConverter( hMathFontConv );
|
|
}
|
|
|
|
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
|
|
};
|
|
|
|
typedef SvXMLImportContext *SvXMLImportContextPtr;
|
|
SV_DECL_PTRARR( SvXMLImportContexts_Impl, SvXMLImportContextPtr, 20, 5 )
|
|
SV_IMPL_PTRARR( SvXMLImportContexts_Impl, SvXMLImportContextPtr )
|
|
|
|
SvXMLImportContext *SvXMLImport::CreateContext( USHORT nPrefix,
|
|
const OUString& rLocalName,
|
|
const uno::Reference< xml::sax::XAttributeList >& )
|
|
{
|
|
return new SvXMLImportContext( *this, nPrefix, rLocalName );
|
|
}
|
|
|
|
void SvXMLImport::_InitCtor()
|
|
{
|
|
if( mnImportFlags != 0 )
|
|
{
|
|
// implicit "xml" namespace prefix
|
|
mpNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML),
|
|
XML_NAMESPACE_XML );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
|
|
GetXMLToken(XML_N_OFFICE),
|
|
XML_NAMESPACE_OFFICE );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office_ext ) ),
|
|
GetXMLToken(XML_N_OFFICE_EXT),
|
|
XML_NAMESPACE_OFFICE_EXT );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style) ),
|
|
GetXMLToken(XML_N_STYLE),
|
|
XML_NAMESPACE_STYLE );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text) ),
|
|
GetXMLToken(XML_N_TEXT),
|
|
XML_NAMESPACE_TEXT );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table ) ),
|
|
GetXMLToken(XML_N_TABLE),
|
|
XML_NAMESPACE_TABLE );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ),
|
|
GetXMLToken(XML_N_DRAW),
|
|
XML_NAMESPACE_DRAW );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM (sXML_np__dr3d ) ),
|
|
GetXMLToken(XML_N_DR3D),
|
|
XML_NAMESPACE_DR3D );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__fo) ),
|
|
GetXMLToken(XML_N_FO_COMPAT),
|
|
XML_NAMESPACE_FO );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink) ),
|
|
GetXMLToken(XML_N_XLINK),
|
|
XML_NAMESPACE_XLINK );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dc) ),
|
|
GetXMLToken(XML_N_DC),
|
|
XML_NAMESPACE_DC );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dom ) ),
|
|
GetXMLToken(XML_N_DOM),
|
|
XML_NAMESPACE_DOM );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__meta) ),
|
|
GetXMLToken(XML_N_META),
|
|
XML_NAMESPACE_META );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__number) ),
|
|
GetXMLToken(XML_N_NUMBER),
|
|
XML_NAMESPACE_NUMBER );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__svg) ),
|
|
GetXMLToken(XML_N_SVG_COMPAT),
|
|
XML_NAMESPACE_SVG );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__chart) ),
|
|
GetXMLToken(XML_N_CHART),
|
|
XML_NAMESPACE_CHART );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ),
|
|
GetXMLToken(XML_N_MATH),
|
|
XML_NAMESPACE_MATH );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_namespace_form) ),
|
|
GetXMLToken(XML_N_FORM),
|
|
XML_NAMESPACE_FORM );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ),
|
|
GetXMLToken(XML_N_SCRIPT),
|
|
XML_NAMESPACE_SCRIPT );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__config) ),
|
|
GetXMLToken(XML_N_CONFIG),
|
|
XML_NAMESPACE_CONFIG );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xforms) ),
|
|
GetXMLToken(XML_N_XFORMS_1_0),
|
|
XML_NAMESPACE_XFORMS );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsd) ),
|
|
GetXMLToken(XML_N_XSD),
|
|
XML_NAMESPACE_XSD );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsi) ),
|
|
GetXMLToken(XML_N_XSI),
|
|
XML_NAMESPACE_XFORMS );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooow ) ), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__oooc ) ), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__field ) ), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
|
|
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__of ) ),
|
|
GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
|
|
mpNamespaceMap->Add(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xhtml ) ),
|
|
GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
|
|
}
|
|
|
|
msPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
|
|
|
|
if (mxNumberFormatsSupplier.is())
|
|
mpNumImport = new SvXMLNumFmtHelper(mxNumberFormatsSupplier, getServiceFactory());
|
|
|
|
if (mxModel.is() && !mxEventListener.is())
|
|
{
|
|
mxEventListener.set(new SvXMLImportEventListener(this));
|
|
mxModel->addEventListener(mxEventListener);
|
|
}
|
|
|
|
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
|
|
|
|
}
|
|
|
|
// #110680#
|
|
SvXMLImport::SvXMLImport(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
sal_uInt16 nImportFlags ) throw ()
|
|
: mpImpl( new SvXMLImport_Impl() ),
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
// #110680#
|
|
// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
|
|
|
|
mpContexts( new SvXMLImportContexts_Impl ),
|
|
mpNumImport( NULL ),
|
|
mpProgressBarHelper( NULL ),
|
|
mpEventImportHelper( NULL ),
|
|
mpXMLErrors( NULL ),
|
|
mpStyleMap(0),
|
|
mnImportFlags( nImportFlags ),
|
|
mnErrorFlags(0),
|
|
// #110680#
|
|
mxServiceFactory(xServiceFactory),
|
|
mbIsFormsSupported( sal_True ),
|
|
mbIsTableShapeSupported( false ),
|
|
mbIsGraphicLoadOnDemandSupported( true )
|
|
{
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
|
_InitCtor();
|
|
}
|
|
|
|
// #110680#
|
|
SvXMLImport::SvXMLImport(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
const Reference< XModel > & rModel ) throw ()
|
|
: mxModel( rModel ),
|
|
mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
|
mpImpl( new SvXMLImport_Impl() ),
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
|
// #110680#
|
|
// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
|
|
mpContexts( new SvXMLImportContexts_Impl ),
|
|
mpNumImport( NULL ),
|
|
mpProgressBarHelper( NULL ),
|
|
mpEventImportHelper( NULL ),
|
|
mpXMLErrors( NULL ),
|
|
mpStyleMap(0),
|
|
mnImportFlags( IMPORT_ALL ),
|
|
mnErrorFlags(0),
|
|
// #110680#
|
|
mxServiceFactory(xServiceFactory),
|
|
mbIsFormsSupported( sal_True ),
|
|
mbIsTableShapeSupported( false ),
|
|
mbIsGraphicLoadOnDemandSupported( true )
|
|
{
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
|
_InitCtor();
|
|
}
|
|
|
|
// #110680#
|
|
SvXMLImport::SvXMLImport(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
const Reference< XModel > & rModel,
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > & rGraphicObjects ) throw ()
|
|
: mxModel( rModel ),
|
|
mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
|
mxGraphicResolver( rGraphicObjects ),
|
|
mpImpl( new SvXMLImport_Impl() ),
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
|
// #110680#
|
|
// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
|
|
mpContexts( new SvXMLImportContexts_Impl ),
|
|
mpNumImport( NULL ),
|
|
mpProgressBarHelper( NULL ),
|
|
mpEventImportHelper( NULL ),
|
|
mpXMLErrors( NULL ),
|
|
mpStyleMap(0),
|
|
mnImportFlags( IMPORT_ALL ),
|
|
mnErrorFlags(0),
|
|
// #110680#
|
|
mxServiceFactory(xServiceFactory),
|
|
mbIsFormsSupported( sal_True ),
|
|
mbIsGraphicLoadOnDemandSupported( true )
|
|
{
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
|
_InitCtor();
|
|
}
|
|
|
|
SvXMLImport::~SvXMLImport() throw ()
|
|
{
|
|
delete mpXMLErrors;
|
|
delete mpNamespaceMap;
|
|
delete mpUnitConv;
|
|
delete mpEventImportHelper;
|
|
if( mpContexts )
|
|
{
|
|
while( mpContexts->Count() )
|
|
{
|
|
sal_uInt16 n = mpContexts->Count() - 1;
|
|
SvXMLImportContext *pContext = (*mpContexts)[n];
|
|
mpContexts->Remove( n, 1 );
|
|
if( pContext )
|
|
pContext->ReleaseRef();
|
|
}
|
|
delete mpContexts;
|
|
}
|
|
|
|
// delete pImageMapImportHelper;
|
|
|
|
// #i9518# the import component might not be deleted until after the document has been closed,
|
|
// so the stuff that accesses the document has been moved to endDocument.
|
|
|
|
// pNumImport is allocated in the ctor, so it must also be deleted here in case the component
|
|
// is created and deleted without actually importing.
|
|
delete mpNumImport;
|
|
delete mpProgressBarHelper;
|
|
|
|
xmloff::token::ResetTokens();
|
|
|
|
if( mpImpl )
|
|
delete mpImpl;
|
|
|
|
if (mxEventListener.is() && mxModel.is())
|
|
mxModel->removeEventListener(mxEventListener);
|
|
}
|
|
|
|
// XUnoTunnel & co
|
|
const uno::Sequence< sal_Int8 > & SvXMLImport::getUnoTunnelId() throw()
|
|
{
|
|
static uno::Sequence< sal_Int8 > * pSeq = 0;
|
|
if( !pSeq )
|
|
{
|
|
Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
|
|
if( !pSeq )
|
|
{
|
|
static uno::Sequence< sal_Int8 > aSeq( 16 );
|
|
rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
|
|
pSeq = &aSeq;
|
|
}
|
|
}
|
|
return *pSeq;
|
|
}
|
|
|
|
SvXMLImport* SvXMLImport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
|
|
{
|
|
uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
|
|
if( xUT.is() )
|
|
{
|
|
return
|
|
reinterpret_cast<SvXMLImport*>(
|
|
sal::static_int_cast<sal_IntPtr>(
|
|
xUT->getSomething( SvXMLImport::getUnoTunnelId())));
|
|
}
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
// XUnoTunnel
|
|
sal_Int64 SAL_CALL SvXMLImport::getSomething( const uno::Sequence< sal_Int8 >& rId )
|
|
throw( uno::RuntimeException )
|
|
{
|
|
if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
|
|
rId.getConstArray(), 16 ) )
|
|
{
|
|
return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::startDocument( void )
|
|
throw( xml::sax::SAXException, uno::RuntimeException )
|
|
{
|
|
RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "{ SvXMLImport::startDocument" );
|
|
|
|
if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
|
|
if( xFactory.is() )
|
|
{
|
|
try
|
|
{
|
|
if( !mxGraphicResolver.is() )
|
|
{
|
|
mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
|
|
xFactory->createInstance(
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(
|
|
// #99870# Import... instead of Export...
|
|
"com.sun.star.document.ImportGraphicObjectResolver"))));
|
|
mpImpl->mbOwnGraphicResolver = mxGraphicResolver.is();
|
|
}
|
|
|
|
if( !mxEmbeddedResolver.is() )
|
|
{
|
|
mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
|
|
xFactory->createInstance(
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(
|
|
// #99870# Import... instead of Export...
|
|
"com.sun.star.document.ImportEmbeddedObjectResolver"))));
|
|
mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
|
|
}
|
|
}
|
|
catch( com::sun::star::uno::Exception& )
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::endDocument( void )
|
|
throw( xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "} SvXMLImport::startDocument" );
|
|
|
|
// #i9518# All the stuff that accesses the document has to be done here, not in the dtor,
|
|
// because the SvXMLImport dtor might not be called until after the document has been closed.
|
|
|
|
if (mpImpl->mpRDFaHelper.get())
|
|
{
|
|
const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
|
|
uno::UNO_QUERY);
|
|
if (xRS.is())
|
|
{
|
|
mpImpl->mpRDFaHelper->InsertRDFa( xRS );
|
|
}
|
|
}
|
|
|
|
if (mpNumImport)
|
|
{
|
|
delete mpNumImport;
|
|
mpNumImport = NULL;
|
|
}
|
|
if (mxImportInfo.is())
|
|
{
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
|
|
if (xPropertySetInfo.is())
|
|
{
|
|
if (mpProgressBarHelper)
|
|
{
|
|
OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
|
|
OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
|
|
OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
|
|
if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
|
|
xPropertySetInfo->hasPropertyByName(sProgressCurrent))
|
|
{
|
|
sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
|
|
sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
|
|
uno::Any aAny;
|
|
aAny <<= nProgressMax;
|
|
mxImportInfo->setPropertyValue(sProgressMax, aAny);
|
|
aAny <<= nProgressCurrent;
|
|
mxImportInfo->setPropertyValue(sProgressCurrent, aAny);
|
|
}
|
|
if (xPropertySetInfo->hasPropertyByName(sRepeat))
|
|
mxImportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
|
|
// pProgressBarHelper is deleted in dtor
|
|
}
|
|
OUString sNumberStyles(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
|
|
if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
|
|
{
|
|
uno::Any aAny;
|
|
aAny <<= mxNumberStyles;
|
|
mxImportInfo->setPropertyValue(sNumberStyles, aAny);
|
|
}
|
|
}
|
|
}
|
|
|
|
if( mxFontDecls.Is() )
|
|
((SvXMLStylesContext *)&mxFontDecls)->Clear();
|
|
if( mxStyles.Is() )
|
|
((SvXMLStylesContext *)&mxStyles)->Clear();
|
|
if( mxAutoStyles.Is() )
|
|
((SvXMLStylesContext *)&mxAutoStyles)->Clear();
|
|
if( mxMasterStyles.Is() )
|
|
((SvXMLStylesContext *)&mxMasterStyles)->Clear();
|
|
|
|
// possible form-layer related knittings which can only be done when
|
|
// the whole document exists
|
|
if ( mxFormImport.is() )
|
|
mxFormImport->documentDone();
|
|
|
|
// The shape import helper does the z-order sorting in the dtor,
|
|
// so it must be deleted here, too.
|
|
mxShapeImport = NULL;
|
|
|
|
if( mpImpl->mbOwnGraphicResolver )
|
|
{
|
|
Reference< lang::XComponent > xComp( mxGraphicResolver, UNO_QUERY );
|
|
xComp->dispose();
|
|
}
|
|
|
|
if( mpImpl->mbOwnEmbeddedResolver )
|
|
{
|
|
Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
|
|
xComp->dispose();
|
|
}
|
|
if( mpStyleMap )
|
|
{
|
|
mpStyleMap->release();
|
|
mpStyleMap = 0;
|
|
}
|
|
|
|
if ( mpXMLErrors != NULL )
|
|
{
|
|
mpXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
|
|
}
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::startElement( const OUString& rName,
|
|
const uno::Reference< xml::sax::XAttributeList >& xAttrList )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
SvXMLNamespaceMap *pRewindMap = 0;
|
|
|
|
// Process namespace attributes. This must happen before creating the
|
|
// context, because namespace decaration apply to the element name itself.
|
|
INT16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
|
for( INT16 i=0; i < nAttrCount; i++ )
|
|
{
|
|
const OUString& rAttrName = xAttrList->getNameByIndex( i );
|
|
if ( rAttrName.equalsAscii("office:version") )
|
|
{
|
|
mpImpl->aODFVersion = xAttrList->getValueByIndex( i );
|
|
|
|
// the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
|
|
if ( mpImpl->mStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "content.xml" ) ) )
|
|
&& !IsODFVersionConsistent( mpImpl->aODFVersion ) )
|
|
{
|
|
throw xml::sax::SAXException(
|
|
::rtl::OUString(
|
|
RTL_CONSTASCII_USTRINGPARAM( "Inconsistent ODF versions in content.xml and manifest.xml!" ) ),
|
|
uno::Reference< uno::XInterface >(),
|
|
uno::makeAny(
|
|
packages::zip::ZipIOException(
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
|
|
"Inconsistent ODF versions in content.xml and manifest.xml!" ) ),
|
|
Reference< XInterface >() ) ) );
|
|
}
|
|
}
|
|
else if( ( rAttrName.getLength() >= 5 ) &&
|
|
( rAttrName.compareToAscii( sXML_xmlns, 5 ) == 0 ) &&
|
|
( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
|
|
{
|
|
if( !pRewindMap )
|
|
{
|
|
pRewindMap = mpNamespaceMap;
|
|
mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
|
|
}
|
|
const OUString& rAttrValue = xAttrList->getValueByIndex( i );
|
|
|
|
OUString aPrefix( ( rAttrName.getLength() == 5 )
|
|
? OUString()
|
|
: rAttrName.copy( 6 ) );
|
|
// Add namespace, but only if it is known.
|
|
sal_uInt16 nKey = mpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
|
|
// If namespace is unknwon, try to match a name with similar
|
|
// TC Id an version
|
|
if( XML_NAMESPACE_UNKNOWN == nKey )
|
|
{
|
|
OUString aTestName( rAttrValue );
|
|
if( SvXMLNamespaceMap::NormalizeURI( aTestName ) )
|
|
nKey = mpNamespaceMap->AddIfKnown( aPrefix, aTestName );
|
|
}
|
|
// If that namespace is not known, too, add it as unknown
|
|
if( XML_NAMESPACE_UNKNOWN == nKey )
|
|
mpNamespaceMap->Add( aPrefix, rAttrValue );
|
|
|
|
}
|
|
}
|
|
|
|
// Get element's namespace and local name.
|
|
OUString aLocalName;
|
|
USHORT nPrefix =
|
|
mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
|
|
|
|
// If there are contexts already, call a CreateChildContext at the topmost
|
|
// context. Otherwise, create a default context.
|
|
SvXMLImportContext *pContext;
|
|
USHORT nCount = mpContexts->Count();
|
|
if( nCount > 0 )
|
|
{
|
|
pContext = (*mpContexts)[nCount - 1]->CreateChildContext( nPrefix,
|
|
aLocalName,
|
|
xAttrList );
|
|
DBG_ASSERT( pContext && pContext->GetPrefix() == nPrefix,
|
|
"SvXMLImport::startElement: created context has wrong prefix" );
|
|
}
|
|
else
|
|
{
|
|
#ifdef TIMELOG
|
|
// If we do profiling, we want a trace message for the first element
|
|
// in order to identify the stream.
|
|
ByteString aString( (String)rName, RTL_TEXTENCODING_ASCII_US );
|
|
RTL_LOGFILE_TRACE_AUTHOR1( "xmloff", LOGFILE_AUTHOR,
|
|
"SvXMLImport::StartElement( \"%s\", ... )",
|
|
aString.GetBuffer() );
|
|
#endif
|
|
|
|
pContext = CreateContext( nPrefix, aLocalName, xAttrList );
|
|
if( (nPrefix & XML_NAMESPACE_UNKNOWN_FLAG) != 0 &&
|
|
IS_TYPE( SvXMLImportContext, pContext ) )
|
|
{
|
|
OUString aMsg( RTL_CONSTASCII_USTRINGPARAM( "Root element unknown" ) );
|
|
Reference<xml::sax::XLocator> xDummyLocator;
|
|
Sequence < OUString > aParams(1);
|
|
aParams.getArray()[0] = rName;
|
|
|
|
SetError( XMLERROR_FLAG_SEVERE|XMLERROR_UNKNWON_ROOT,
|
|
aParams, aMsg, xDummyLocator );
|
|
}
|
|
}
|
|
|
|
DBG_ASSERT( pContext, "SvXMLImport::startElement: missing context" );
|
|
if( !pContext )
|
|
pContext = new SvXMLImportContext( *this, nPrefix, aLocalName );
|
|
|
|
pContext->AddRef();
|
|
|
|
// Remeber old namespace map.
|
|
if( pRewindMap )
|
|
pContext->SetRewindMap( pRewindMap );
|
|
|
|
// Call a startElement at the new context.
|
|
pContext->StartElement( xAttrList );
|
|
|
|
// Push context on stack.
|
|
mpContexts->Insert( pContext, nCount );
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::endElement( const OUString&
|
|
#ifndef PRODUCT
|
|
rName
|
|
#endif
|
|
)
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
USHORT nCount = mpContexts->Count();
|
|
DBG_ASSERT( nCount, "SvXMLImport::endElement: no context left" );
|
|
if( nCount > 0 )
|
|
{
|
|
// Get topmost context and remove it from the stack.
|
|
SvXMLImportContext *pContext = (*mpContexts)[nCount-1];
|
|
mpContexts->Remove( nCount-1, 1 );
|
|
|
|
#ifndef PRODUCT
|
|
// Non product only: check if endElement call matches startELement call.
|
|
OUString aLocalName;
|
|
USHORT nPrefix =
|
|
mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
|
|
DBG_ASSERT( pContext->GetPrefix() == nPrefix,
|
|
"SvXMLImport::endElement: popped context has wrong prefix" );
|
|
DBG_ASSERT( pContext->GetLocalName() == aLocalName,
|
|
"SvXMLImport::endElement: popped context has wrong lname" );
|
|
#endif
|
|
|
|
// Call a EndElement at the current context.
|
|
pContext->EndElement();
|
|
|
|
// Get a namespace map to rewind.
|
|
SvXMLNamespaceMap *pRewindMap = pContext->GetRewindMap();
|
|
|
|
// Delete the current context.
|
|
pContext->ReleaseRef();
|
|
pContext = 0;
|
|
|
|
// Rewind a namespace map.
|
|
if( pRewindMap )
|
|
{
|
|
delete mpNamespaceMap;
|
|
mpNamespaceMap = pRewindMap;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::characters( const OUString& rChars )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
USHORT nCount = mpContexts->Count();
|
|
if( nCount > 0 )
|
|
{
|
|
(*mpContexts)[nCount - 1]->Characters( rChars );
|
|
}
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::ignorableWhitespace( const OUString& )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::processingInstruction( const OUString&,
|
|
const OUString& )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
mxLocator = rLocator;
|
|
}
|
|
|
|
// XExtendedDocumentHandler
|
|
void SAL_CALL SvXMLImport::startCDATA( void ) throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::endCDATA( void ) throw(uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::comment( const OUString& )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::allowLineBreak( void )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::unknown( const OUString& )
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
void SvXMLImport::SetStatistics(const uno::Sequence< beans::NamedValue> &)
|
|
{
|
|
GetProgressBarHelper()->SetRepeat(sal_False);
|
|
GetProgressBarHelper()->SetReference(0);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
// XImporter
|
|
void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
|
|
throw(lang::IllegalArgumentException, uno::RuntimeException)
|
|
{
|
|
mxModel = uno::Reference< frame::XModel >::query( xDoc );
|
|
if( !mxModel.is() )
|
|
throw lang::IllegalArgumentException();
|
|
if (mxModel.is() && !mxEventListener.is())
|
|
{
|
|
mxEventListener.set(new SvXMLImportEventListener(this));
|
|
mxModel->addEventListener(mxEventListener);
|
|
}
|
|
|
|
DBG_ASSERT( !mpNumImport, "number format import already exists." );
|
|
if( mpNumImport )
|
|
{
|
|
delete mpNumImport;
|
|
mpNumImport = 0;
|
|
}
|
|
}
|
|
|
|
// XFilter
|
|
sal_Bool SAL_CALL SvXMLImport::filter( const uno::Sequence< beans::PropertyValue >& )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
return sal_False;
|
|
}
|
|
|
|
void SAL_CALL SvXMLImport::cancel( )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
}
|
|
|
|
// XInitialize
|
|
void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
|
|
throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
|
|
{
|
|
const sal_Int32 nAnyCount = aArguments.getLength();
|
|
const uno::Any* pAny = aArguments.getConstArray();
|
|
|
|
for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
|
|
{
|
|
Reference<XInterface> xValue;
|
|
*pAny >>= xValue;
|
|
|
|
uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
|
|
xValue, UNO_QUERY );
|
|
if( xTmpStatusIndicator.is() )
|
|
mxStatusIndicator = xTmpStatusIndicator;
|
|
|
|
uno::Reference<document::XGraphicObjectResolver> xTmpGraphicResolver(
|
|
xValue, UNO_QUERY );
|
|
if( xTmpGraphicResolver.is() )
|
|
mxGraphicResolver = xTmpGraphicResolver;
|
|
|
|
uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
|
|
xValue, UNO_QUERY );
|
|
if( xTmpObjectResolver.is() )
|
|
mxEmbeddedResolver = xTmpObjectResolver;
|
|
|
|
uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
|
|
if( xTmpPropSet.is() )
|
|
{
|
|
mxImportInfo = xTmpPropSet;
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
|
|
if (xPropertySetInfo.is())
|
|
{
|
|
OUString sPropName(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
|
|
if (xPropertySetInfo->hasPropertyByName(sPropName))
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= mxNumberStyles;
|
|
}
|
|
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
|
|
if (xPropertySetInfo->hasPropertyByName(sPropName))
|
|
{
|
|
Reference < XInterface > xIfc;
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= xIfc;
|
|
|
|
StyleMap *pSMap = StyleMap::getImplementation( xIfc );
|
|
if( pSMap )
|
|
{
|
|
mpStyleMap = pSMap;
|
|
mpStyleMap->acquire();
|
|
}
|
|
}
|
|
OUString sBaseURI;
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
|
|
if (xPropertySetInfo->hasPropertyByName(sPropName))
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= sBaseURI;
|
|
mpImpl->aBaseURL.SetURL( sBaseURI );
|
|
mpImpl->aDocBase.SetURL( sBaseURI );
|
|
}
|
|
OUString sRelPath;
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= sRelPath;
|
|
}
|
|
OUString sName;
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= sName;
|
|
}
|
|
if( sBaseURI.getLength() && sName.getLength() )
|
|
{
|
|
if( sRelPath.getLength() )
|
|
mpImpl->aBaseURL.insertName( sRelPath );
|
|
mpImpl->aBaseURL.insertName( sName );
|
|
}
|
|
mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
|
|
// --> OD 2004-08-10 #i28749# - retrieve property <ShapePositionInHoriL2R>
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("ShapePositionInHoriL2R" ) );
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= (mpImpl->mbShapePositionInHoriL2R);
|
|
}
|
|
// <--
|
|
// --> OD 2007-12-19 #152540#
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("TextDocInOOoFileFormat" ) );
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
|
|
aAny >>= (mpImpl->mbTextDocInOOoFileFormat);
|
|
}
|
|
// <--
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// XServiceInfo
|
|
OUString SAL_CALL SvXMLImport::getImplementationName()
|
|
throw(uno::RuntimeException)
|
|
{
|
|
OUString aStr;
|
|
return aStr;
|
|
}
|
|
|
|
sal_Bool SAL_CALL SvXMLImport::supportsService( const OUString& rServiceName )
|
|
throw(::com::sun::star::uno::RuntimeException)
|
|
{
|
|
return
|
|
rServiceName.equalsAsciiL(
|
|
"com.sun.star.document.ImportFilter",
|
|
sizeof("com.sun.star.document.ImportFilter")-1 ) ||
|
|
rServiceName.equalsAsciiL(
|
|
"com.sun.star.xml.XMLImportFilter",
|
|
sizeof("com.sun.star.xml.XMLImportFilter")-1);
|
|
}
|
|
|
|
uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
|
|
throw(uno::RuntimeException)
|
|
{
|
|
uno::Sequence<OUString> aSeq(2);
|
|
aSeq[0] = OUString(
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportFilter"));
|
|
aSeq[1] = OUString(
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter"));
|
|
return aSeq;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
XMLTextImportHelper* SvXMLImport::CreateTextImport()
|
|
{
|
|
return new XMLTextImportHelper( mxModel, *this );
|
|
}
|
|
|
|
XMLShapeImportHelper* SvXMLImport::CreateShapeImport()
|
|
{
|
|
return new XMLShapeImportHelper( *this, mxModel );
|
|
}
|
|
|
|
#ifndef SVX_LIGHT
|
|
SchXMLImportHelper* SvXMLImport::CreateChartImport()
|
|
{
|
|
return new SchXMLImportHelper();
|
|
}
|
|
#endif
|
|
|
|
#ifndef SVX_LIGHT
|
|
::xmloff::OFormLayerXMLImport* SvXMLImport::CreateFormImport()
|
|
{
|
|
return new ::xmloff::OFormLayerXMLImport(*this);
|
|
}
|
|
#endif // #ifndef SVX_LIGHT
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Get or create fill/line/lineend-style-helper
|
|
//
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
|
|
{
|
|
if( !mxGradientHelper.is() )
|
|
{
|
|
if( mxModel.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
|
|
if( xServiceFact.is() )
|
|
{
|
|
try
|
|
{
|
|
mxGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) ), UNO_QUERY);
|
|
}
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
{}
|
|
}
|
|
}
|
|
}
|
|
|
|
return mxGradientHelper;
|
|
}
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
|
|
{
|
|
if( !mxHatchHelper.is() )
|
|
{
|
|
if( mxModel.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
|
|
if( xServiceFact.is() )
|
|
{
|
|
try
|
|
{
|
|
mxHatchHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) ), UNO_QUERY);
|
|
}
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
{}
|
|
}
|
|
}
|
|
}
|
|
|
|
return mxHatchHelper;
|
|
}
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
|
|
{
|
|
if( !mxBitmapHelper.is() )
|
|
{
|
|
if( mxModel.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
|
|
if( xServiceFact.is() )
|
|
{
|
|
try
|
|
{
|
|
mxBitmapHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) ), UNO_QUERY);
|
|
}
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
{}
|
|
}
|
|
}
|
|
}
|
|
|
|
return mxBitmapHelper;
|
|
}
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
|
|
{
|
|
if( !mxTransGradientHelper.is() )
|
|
{
|
|
if( mxModel.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
|
|
if( xServiceFact.is() )
|
|
{
|
|
try
|
|
{
|
|
mxTransGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) ), UNO_QUERY);
|
|
}
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
{}
|
|
}
|
|
}
|
|
}
|
|
|
|
return mxTransGradientHelper;
|
|
}
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
|
|
{
|
|
if( !mxMarkerHelper.is() )
|
|
{
|
|
if( mxModel.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
|
|
if( xServiceFact.is() )
|
|
{
|
|
try
|
|
{
|
|
mxMarkerHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) ), UNO_QUERY);
|
|
}
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
{}
|
|
}
|
|
}
|
|
}
|
|
|
|
return mxMarkerHelper;
|
|
}
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
|
|
{
|
|
if( !mxDashHelper.is() )
|
|
{
|
|
if( mxModel.is() )
|
|
{
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
|
|
if( xServiceFact.is() )
|
|
{
|
|
try
|
|
{
|
|
mxDashHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) ) ), UNO_QUERY);
|
|
}
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
{}
|
|
}
|
|
}
|
|
}
|
|
|
|
return mxDashHelper;
|
|
}
|
|
|
|
sal_Bool SvXMLImport::IsPackageURL( const ::rtl::OUString& rURL ) const
|
|
{
|
|
|
|
// if, and only if, only parts are imported, then we're in a package
|
|
const sal_uInt32 nTest = IMPORT_META|IMPORT_STYLES|IMPORT_CONTENT|IMPORT_SETTINGS;
|
|
if( (mnImportFlags & nTest) == nTest )
|
|
return sal_False;
|
|
|
|
// Some quick tests: Some may rely on the package structure!
|
|
sal_Int32 nLen = rURL.getLength();
|
|
if( (nLen > 0 && '/' == rURL[0]) )
|
|
// RFC2396 net_path or abs_path
|
|
return sal_False;
|
|
else if( nLen > 1 && '.' == rURL[0] )
|
|
{
|
|
if( '.' == rURL[1] )
|
|
// ../: We are never going up one level, so we know
|
|
// it's not an external URI
|
|
return sal_False;
|
|
else if( '/' == rURL[1] )
|
|
// we are remaining on a level, so it's an package URI
|
|
return sal_True;
|
|
}
|
|
|
|
// Now check for a RFC2396 schema
|
|
sal_Int32 nPos = 1;
|
|
while( nPos < nLen )
|
|
{
|
|
switch( rURL[nPos] )
|
|
{
|
|
case '/':
|
|
// a relative path segement
|
|
return sal_True;
|
|
case ':':
|
|
// a schema
|
|
return sal_False;
|
|
default:
|
|
break;
|
|
// we don't care about any other characters
|
|
}
|
|
++nPos;
|
|
}
|
|
|
|
return sal_True;
|
|
}
|
|
|
|
::rtl::OUString SvXMLImport::ResolveGraphicObjectURL( const ::rtl::OUString& rURL,
|
|
sal_Bool bLoadOnDemand )
|
|
{
|
|
::rtl::OUString sRet;
|
|
|
|
if( IsPackageURL( rURL ) )
|
|
{
|
|
if( !bLoadOnDemand && mxGraphicResolver.is() )
|
|
{
|
|
::rtl::OUString aTmp( msPackageProtocol );
|
|
aTmp += rURL;
|
|
sRet = mxGraphicResolver->resolveGraphicObjectURL( aTmp );
|
|
}
|
|
|
|
if( !sRet.getLength() )
|
|
{
|
|
sRet = msPackageProtocol;
|
|
sRet += rURL;
|
|
}
|
|
}
|
|
|
|
if( !sRet.getLength() )
|
|
sRet = GetAbsoluteReference( rURL );
|
|
|
|
return sRet;
|
|
}
|
|
|
|
Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
|
|
{
|
|
Reference< XOutputStream > xOStm;
|
|
Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
|
|
|
|
if( xStmResolver.is() )
|
|
xOStm = xStmResolver->createOutputStream();
|
|
|
|
return xOStm;
|
|
}
|
|
|
|
::rtl::OUString SvXMLImport::ResolveGraphicObjectURLFromBase64(
|
|
const Reference < XOutputStream >& rOut )
|
|
{
|
|
OUString sURL;
|
|
Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
|
|
if( xStmResolver.is() )
|
|
sURL = xStmResolver->resolveOutputStream( rOut );
|
|
|
|
return sURL;
|
|
}
|
|
|
|
::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURL(
|
|
const ::rtl::OUString& rURL,
|
|
const ::rtl::OUString& rClassId )
|
|
{
|
|
::rtl::OUString sRet;
|
|
|
|
if( IsPackageURL( rURL ) )
|
|
{
|
|
if ( mxEmbeddedResolver.is() )
|
|
{
|
|
OUString sURL( rURL );
|
|
if( rClassId.getLength() )
|
|
{
|
|
sURL += OUString( sal_Unicode('!') );
|
|
sURL += rClassId;
|
|
}
|
|
sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
|
|
}
|
|
}
|
|
else
|
|
sRet = GetAbsoluteReference( rURL );
|
|
|
|
return sRet;
|
|
}
|
|
|
|
Reference < XOutputStream >
|
|
SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64()
|
|
{
|
|
Reference < XOutputStream > xOLEStream;
|
|
|
|
if( mxEmbeddedResolver.is() )
|
|
{
|
|
Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
|
|
if( xNA.is() )
|
|
{
|
|
OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
|
|
Any aAny = xNA->getByName( aURL );
|
|
aAny >>= xOLEStream;
|
|
}
|
|
}
|
|
|
|
return xOLEStream;
|
|
}
|
|
|
|
::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
|
|
{
|
|
::rtl::OUString sRet;
|
|
|
|
if( mxEmbeddedResolver.is() )
|
|
{
|
|
OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
|
|
sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( aURL );
|
|
}
|
|
|
|
return sRet;
|
|
}
|
|
|
|
void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily,
|
|
const OUString& rName,
|
|
const OUString& rDisplayName )
|
|
{
|
|
if( !mpStyleMap )
|
|
{
|
|
mpStyleMap = new StyleMap;
|
|
mpStyleMap->acquire();
|
|
if( mxImportInfo.is() )
|
|
{
|
|
OUString sPrivateData(
|
|
RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
|
|
Reference< beans::XPropertySetInfo > xPropertySetInfo =
|
|
mxImportInfo->getPropertySetInfo();
|
|
if( xPropertySetInfo.is() &&
|
|
xPropertySetInfo->hasPropertyByName(sPrivateData) )
|
|
{
|
|
Reference < XInterface > xIfc(
|
|
static_cast< XUnoTunnel *>( mpStyleMap ) );
|
|
Any aAny;
|
|
aAny <<= xIfc;
|
|
mxImportInfo->setPropertyValue( sPrivateData, aAny );
|
|
}
|
|
}
|
|
}
|
|
|
|
StyleMap::key_type aKey( nFamily, rName );
|
|
StyleMap::value_type aValue( aKey, rDisplayName );
|
|
::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
|
|
OSL_ENSURE( aRes.second, "duplicate style name" );
|
|
|
|
}
|
|
|
|
OUString SvXMLImport::GetStyleDisplayName( sal_uInt16 nFamily,
|
|
const OUString& rName ) const
|
|
{
|
|
OUString sName( rName );
|
|
if( mpStyleMap && rName.getLength() )
|
|
{
|
|
StyleMap::key_type aKey( nFamily, rName );
|
|
StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
|
|
if( aIter != mpStyleMap->end() )
|
|
sName = (*aIter).second;
|
|
}
|
|
return sName;
|
|
}
|
|
|
|
void SvXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
|
|
{
|
|
}
|
|
|
|
void SvXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
|
|
{
|
|
}
|
|
|
|
void SvXMLImport::SetDocumentSpecificSettings(const ::rtl::OUString& _rSettingsGroupName, const uno::Sequence<beans::PropertyValue>& _rSettings)
|
|
{
|
|
(void)_rSettingsGroupName;
|
|
(void)_rSettings;
|
|
}
|
|
|
|
ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
|
|
{
|
|
if (!mpProgressBarHelper)
|
|
{
|
|
mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_False);
|
|
|
|
if (mxImportInfo.is())
|
|
{
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
|
|
if (xPropertySetInfo.is())
|
|
{
|
|
OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
|
|
OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
|
|
OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
|
|
OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
|
|
if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
|
|
xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
|
|
xPropertySetInfo->hasPropertyByName(sProgressRange))
|
|
{
|
|
uno::Any aAny;
|
|
sal_Int32 nProgressMax(0);
|
|
sal_Int32 nProgressCurrent(0);
|
|
sal_Int32 nProgressRange(0);
|
|
aAny = mxImportInfo->getPropertyValue(sProgressRange);
|
|
if (aAny >>= nProgressRange)
|
|
mpProgressBarHelper->SetRange(nProgressRange);
|
|
aAny = mxImportInfo->getPropertyValue(sProgressMax);
|
|
if (aAny >>= nProgressMax)
|
|
mpProgressBarHelper->SetReference(nProgressMax);
|
|
aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
|
|
if (aAny >>= nProgressCurrent)
|
|
mpProgressBarHelper->SetValue(nProgressCurrent);
|
|
}
|
|
if (xPropertySetInfo->hasPropertyByName(sRepeat))
|
|
{
|
|
uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
|
|
if (aAny.getValueType() == getBooleanCppuType())
|
|
mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
|
|
else {
|
|
DBG_ERRORFILE("why is it no boolean?");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return mpProgressBarHelper;
|
|
}
|
|
|
|
void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
|
|
{
|
|
if (!mxNumberStyles.is())
|
|
mxNumberStyles = uno::Reference< container::XNameContainer >( comphelper::NameContainer_createInstance( ::getCppuType((const sal_Int32*)0)) );
|
|
if (mxNumberStyles.is())
|
|
{
|
|
uno::Any aAny;
|
|
aAny <<= nKey;
|
|
try
|
|
{
|
|
mxNumberStyles->insertByName(rName, aAny);
|
|
}
|
|
catch ( uno::Exception& )
|
|
{
|
|
DBG_ERROR("Numberformat could not be inserted");
|
|
}
|
|
}
|
|
else {
|
|
DBG_ERROR("not possible to create NameContainer");
|
|
}
|
|
}
|
|
|
|
XMLEventImportHelper& SvXMLImport::GetEventImport()
|
|
{
|
|
#ifndef SVX_LIGHT
|
|
if (!mpEventImportHelper)
|
|
{
|
|
// construct event helper and register StarBasic handler and standard
|
|
// event tables
|
|
mpEventImportHelper = new XMLEventImportHelper();
|
|
OUString sStarBasic(GetXMLToken(XML_STARBASIC));
|
|
mpEventImportHelper->RegisterFactory(sStarBasic,
|
|
new XMLStarBasicContextFactory());
|
|
OUString sScript(GetXMLToken(XML_SCRIPT));
|
|
mpEventImportHelper->RegisterFactory(sScript,
|
|
new XMLScriptContextFactory());
|
|
mpEventImportHelper->AddTranslationTable(aStandardEventTable);
|
|
|
|
// register StarBasic event handler with capitalized spelling
|
|
OUString sStarBasicCap(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
|
|
mpEventImportHelper->RegisterFactory(sStarBasicCap,
|
|
new XMLStarBasicContextFactory());
|
|
}
|
|
#endif
|
|
|
|
return *mpEventImportHelper;
|
|
}
|
|
|
|
void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls )
|
|
{
|
|
mxFontDecls = pFontDecls;
|
|
GetTextImport()->SetFontDecls( pFontDecls );
|
|
}
|
|
|
|
void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles )
|
|
{
|
|
mxStyles = pStyles;
|
|
}
|
|
|
|
void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles )
|
|
{
|
|
if (pAutoStyles && mxNumberStyles.is() && (mnImportFlags & IMPORT_CONTENT) )
|
|
{
|
|
uno::Reference<xml::sax::XAttributeList> xAttrList;
|
|
uno::Sequence< ::rtl::OUString > aNames = mxNumberStyles->getElementNames();
|
|
sal_uInt32 nCount(aNames.getLength());
|
|
if (nCount)
|
|
{
|
|
const OUString* pNames = aNames.getConstArray();
|
|
if ( pNames )
|
|
{
|
|
SvXMLStyleContext* pContext;
|
|
uno::Any aAny;
|
|
sal_Int32 nKey(0);
|
|
for (sal_uInt32 i = 0; i < nCount; i++, pNames++)
|
|
{
|
|
aAny = mxNumberStyles->getByName(*pNames);
|
|
if (aAny >>= nKey)
|
|
{
|
|
pContext = new SvXMLNumFormatContext( *this, XML_NAMESPACE_NUMBER,
|
|
*pNames, xAttrList, nKey, *pAutoStyles );
|
|
pAutoStyles->AddStyle(*pContext);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
mxAutoStyles = pAutoStyles;
|
|
GetTextImport()->SetAutoStyles( pAutoStyles );
|
|
GetShapeImport()->SetAutoStylesContext( pAutoStyles );
|
|
#ifndef SVX_LIGHT
|
|
GetChartImport()->SetAutoStylesContext( pAutoStyles );
|
|
GetFormImport()->setAutoStyleContext( pAutoStyles );
|
|
#endif
|
|
}
|
|
|
|
void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles )
|
|
{
|
|
mxMasterStyles = pMasterStyles;
|
|
}
|
|
|
|
XMLFontStylesContext *SvXMLImport::GetFontDecls()
|
|
{
|
|
return (XMLFontStylesContext *)&mxFontDecls;
|
|
}
|
|
|
|
SvXMLStylesContext *SvXMLImport::GetStyles()
|
|
{
|
|
return (SvXMLStylesContext *)&mxStyles;
|
|
}
|
|
|
|
SvXMLStylesContext *SvXMLImport::GetAutoStyles()
|
|
{
|
|
return (SvXMLStylesContext *)&mxAutoStyles;
|
|
}
|
|
|
|
SvXMLStylesContext *SvXMLImport::GetMasterStyles()
|
|
{
|
|
return (SvXMLStylesContext *)&mxMasterStyles;
|
|
}
|
|
|
|
const XMLFontStylesContext *SvXMLImport::GetFontDecls() const
|
|
{
|
|
return (const XMLFontStylesContext *)&mxFontDecls;
|
|
}
|
|
|
|
const SvXMLStylesContext *SvXMLImport::GetStyles() const
|
|
{
|
|
return (const SvXMLStylesContext *)&mxStyles;
|
|
}
|
|
|
|
const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const
|
|
{
|
|
return (const SvXMLStylesContext *)&mxAutoStyles;
|
|
}
|
|
|
|
const SvXMLStylesContext *SvXMLImport::GetMasterStyles() const
|
|
{
|
|
return (const SvXMLStylesContext *)&mxMasterStyles;
|
|
}
|
|
|
|
OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const
|
|
{
|
|
if( rValue.getLength() == 0 || rValue[0] == '#' )
|
|
return rValue;
|
|
|
|
INetURLObject aAbsURL;
|
|
if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
|
|
return aAbsURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
|
|
else
|
|
return rValue;
|
|
}
|
|
|
|
sal_Bool SvXMLImport::IsODFVersionConsistent( const ::rtl::OUString& aODFVersion )
|
|
{
|
|
// the check returns sal_False only if the storage version could be retrieved
|
|
sal_Bool bResult = sal_True;
|
|
|
|
if ( aODFVersion.getLength() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
|
|
{
|
|
// check the consistency only for the ODF1.2 and later ( according to content.xml )
|
|
try
|
|
{
|
|
uno::Reference< document::XStorageBasedDocument > xDoc( mxModel, uno::UNO_QUERY_THROW );
|
|
uno::Reference< embed::XStorage > xStor = xDoc->getDocumentStorage();
|
|
uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
|
|
|
|
// the check should be done only for OASIS format
|
|
::rtl::OUString aMediaType;
|
|
xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ) ) >>= aMediaType;
|
|
if ( ::comphelper::OStorageHelper::GetXStorageFormat( xStor ) >= SOFFICE_FILEFORMAT_8 )
|
|
{
|
|
sal_Bool bRepairPackage = sal_False;
|
|
try
|
|
{
|
|
xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) ) )
|
|
>>= bRepairPackage;
|
|
} catch ( uno::Exception& )
|
|
{}
|
|
|
|
// check only if not in Repair mode
|
|
if ( !bRepairPackage )
|
|
{
|
|
::rtl::OUString aStorVersion;
|
|
xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) )
|
|
>>= aStorVersion;
|
|
bResult = aODFVersion.equals( aStorVersion );
|
|
}
|
|
}
|
|
}
|
|
catch( uno::Exception& )
|
|
{}
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
void SvXMLImport::_CreateNumberFormatsSupplier()
|
|
{
|
|
DBG_ASSERT( !mxNumberFormatsSupplier.is(),
|
|
"number formats supplier already exists!" );
|
|
if(mxModel.is())
|
|
mxNumberFormatsSupplier =
|
|
uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
|
|
}
|
|
|
|
|
|
void SvXMLImport::_CreateDataStylesImport()
|
|
{
|
|
DBG_ASSERT( mpNumImport == NULL, "data styles import already exists!" );
|
|
uno::Reference<util::XNumberFormatsSupplier> xNum =
|
|
GetNumberFormatsSupplier();
|
|
if ( xNum.is() )
|
|
mpNumImport = new SvXMLNumFmtHelper(xNum, getServiceFactory());
|
|
}
|
|
|
|
|
|
sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
|
|
{
|
|
sal_Unicode cNew = c;
|
|
if( !mpImpl->hBatsFontConv )
|
|
{
|
|
OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) );
|
|
mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats,
|
|
FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
|
|
OSL_ENSURE( mpImpl->hBatsFontConv, "Got no symbol font converter" );
|
|
}
|
|
if( mpImpl->hBatsFontConv )
|
|
{
|
|
cNew = ConvertFontToSubsFontChar( mpImpl->hBatsFontConv, c );
|
|
}
|
|
|
|
return cNew;
|
|
}
|
|
|
|
sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
|
|
{
|
|
sal_Unicode cNew = c;
|
|
if( !mpImpl->hMathFontConv )
|
|
{
|
|
OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) );
|
|
mpImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath,
|
|
FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
|
|
OSL_ENSURE( mpImpl->hMathFontConv, "Got no symbol font converter" );
|
|
}
|
|
if( mpImpl->hMathFontConv )
|
|
{
|
|
cNew = ConvertFontToSubsFontChar( mpImpl->hMathFontConv, c );
|
|
}
|
|
|
|
return cNew;
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId,
|
|
const Sequence<OUString>& rMsgParams,
|
|
const OUString& rExceptionMessage,
|
|
const Reference<xml::sax::XLocator>& rLocator )
|
|
{
|
|
// maintain error flags
|
|
if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
|
|
mnErrorFlags |= ERROR_ERROR_OCCURED;
|
|
if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
|
|
mnErrorFlags |= ERROR_WARNING_OCCURED;
|
|
if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
|
|
mnErrorFlags |= ERROR_DO_NOTHING;
|
|
|
|
// create error list on demand
|
|
if ( mpXMLErrors == NULL )
|
|
mpXMLErrors = new XMLErrors();
|
|
|
|
// save error information
|
|
// use document locator (if none supplied)
|
|
mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
|
|
rLocator.is() ? rLocator : mxLocator );
|
|
}
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId,
|
|
const Sequence<OUString>& rMsgParams)
|
|
{
|
|
OUString sEmpty;
|
|
SetError( nId, rMsgParams, sEmpty, NULL );
|
|
}
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId)
|
|
{
|
|
Sequence<OUString> aSeq(0);
|
|
SetError( nId, aSeq );
|
|
}
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId,
|
|
const OUString& rMsg1)
|
|
{
|
|
Sequence<OUString> aSeq(1);
|
|
OUString* pSeq = aSeq.getArray();
|
|
pSeq[0] = rMsg1;
|
|
SetError( nId, aSeq );
|
|
}
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId,
|
|
const OUString& rMsg1,
|
|
const OUString& rMsg2)
|
|
{
|
|
Sequence<OUString> aSeq(2);
|
|
OUString* pSeq = aSeq.getArray();
|
|
pSeq[0] = rMsg1;
|
|
pSeq[1] = rMsg2;
|
|
SetError( nId, aSeq );
|
|
}
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId,
|
|
const OUString& rMsg1,
|
|
const OUString& rMsg2,
|
|
const OUString& rMsg3)
|
|
{
|
|
Sequence<OUString> aSeq(3);
|
|
OUString* pSeq = aSeq.getArray();
|
|
pSeq[0] = rMsg1;
|
|
pSeq[1] = rMsg2;
|
|
pSeq[2] = rMsg3;
|
|
SetError( nId, aSeq );
|
|
}
|
|
|
|
void SvXMLImport::SetError(
|
|
sal_Int32 nId,
|
|
const OUString& rMsg1,
|
|
const OUString& rMsg2,
|
|
const OUString& rMsg3,
|
|
const OUString& rMsg4)
|
|
{
|
|
Sequence<OUString> aSeq(4);
|
|
OUString* pSeq = aSeq.getArray();
|
|
pSeq[0] = rMsg1;
|
|
pSeq[1] = rMsg2;
|
|
pSeq[2] = rMsg3;
|
|
pSeq[3] = rMsg4;
|
|
SetError( nId, aSeq );
|
|
}
|
|
|
|
XMLErrors* SvXMLImport::GetErrors()
|
|
{
|
|
return mpXMLErrors;
|
|
}
|
|
|
|
void SvXMLImport::DisposingModel()
|
|
{
|
|
if( mxFontDecls.Is() )
|
|
((SvXMLStylesContext *)&mxFontDecls)->Clear();
|
|
if( mxStyles.Is() )
|
|
((SvXMLStylesContext *)&mxStyles)->Clear();
|
|
if( mxAutoStyles.Is() )
|
|
((SvXMLStylesContext *)&mxAutoStyles)->Clear();
|
|
if( mxMasterStyles.Is() )
|
|
((SvXMLStylesContext *)&mxMasterStyles)->Clear();
|
|
|
|
mxModel.set(0);
|
|
mxEventListener.set(NULL);
|
|
}
|
|
|
|
::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLImport::getInterfaceToIdentifierMapper()
|
|
{
|
|
return mpImpl->maInterfaceToIdentifierMapper;
|
|
}
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLImport::getServiceFactory()
|
|
{
|
|
// #110680#
|
|
return mxServiceFactory;
|
|
}
|
|
|
|
uno::Reference< uno::XComponentContext >
|
|
SvXMLImport::GetComponentContext() const
|
|
{
|
|
return mpImpl->mxComponentContext;
|
|
}
|
|
|
|
String SvXMLImport::GetBaseURL() const
|
|
{
|
|
return mpImpl->aBaseURL.GetMainURL( INetURLObject::NO_DECODE );
|
|
}
|
|
|
|
String SvXMLImport::GetDocumentBase() const
|
|
{
|
|
return mpImpl->aDocBase.GetMainURL( INetURLObject::NO_DECODE );
|
|
}
|
|
|
|
::rtl::OUString SvXMLImport::GetStreamName() const
|
|
{
|
|
return mpImpl->mStreamName;
|
|
}
|
|
|
|
// --> OD 2004-08-10 #i28749#
|
|
sal_Bool SvXMLImport::IsShapePositionInHoriL2R() const
|
|
{
|
|
return mpImpl->mbShapePositionInHoriL2R;
|
|
}
|
|
// <--
|
|
|
|
// --> OD 2007-12-19 #152540#
|
|
sal_Bool SvXMLImport::IsTextDocInOOoFileFormat() const
|
|
{
|
|
return mpImpl->mbTextDocInOOoFileFormat;
|
|
}
|
|
|
|
// <--
|
|
|
|
void SvXMLImport::initXForms()
|
|
{
|
|
// dummy method; to be implemented by derived classes supporting XForms
|
|
}
|
|
|
|
bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const
|
|
{
|
|
bool bRet = false;
|
|
if( mxImportInfo.is() ) try
|
|
{
|
|
const OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("BuildId"));
|
|
Reference< XPropertySetInfo > xSetInfo( mxImportInfo->getPropertySetInfo() );
|
|
if( xSetInfo.is() && xSetInfo->hasPropertyByName( aPropName ) )
|
|
{
|
|
OUString aBuildId;
|
|
mxImportInfo->getPropertyValue( aPropName ) >>= aBuildId;
|
|
if( aBuildId.getLength() )
|
|
{
|
|
sal_Int32 nIndex = aBuildId.indexOf('$');
|
|
if( nIndex != -1 )
|
|
{
|
|
rUPD = aBuildId.copy( 0, nIndex ).toInt32();
|
|
rBuild = aBuildId.copy( nIndex+1 ).toInt32();
|
|
bRet = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch( Exception& )
|
|
{
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
sal_uInt16 SvXMLImport::getGeneratorVersion() const
|
|
{
|
|
sal_Int32 nUPD, nBuild;
|
|
|
|
if( getBuildIds( nUPD, nBuild ) )
|
|
{
|
|
if( nUPD == 680 )
|
|
return OOo_2x;
|
|
|
|
if( nUPD >= 640 && nUPD <= 645 )
|
|
return OOo_1x;
|
|
}
|
|
|
|
return OOo_Current;
|
|
}
|
|
|
|
bool SvXMLImport::isGraphicLoadOnDemandSupported() const
|
|
{
|
|
return mbIsGraphicLoadOnDemandSupported;
|
|
}
|
|
|
|
::rtl::OUString SvXMLImport::GetODFVersion() const
|
|
{
|
|
return mpImpl->aODFVersion;
|
|
}
|
|
|
|
// xml:id for RDF metadata
|
|
void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
|
|
::rtl::OUString const & i_rXmlId)
|
|
{
|
|
if (i_rXmlId.getLength() > 0) {
|
|
try {
|
|
const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
|
|
uno::UNO_QUERY);
|
|
//FIXME: not yet
|
|
// OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
|
|
if (xMeta.is()) {
|
|
const beans::StringPair mdref( GetStreamName(), i_rXmlId );
|
|
try {
|
|
xMeta->setMetadataReference(mdref);
|
|
} catch (lang::IllegalArgumentException &) {
|
|
// probably duplicate; ignore
|
|
OSL_TRACE("SvXMLImport::SetXmlId: cannot set xml:id");
|
|
}
|
|
}
|
|
} catch (uno::Exception &) {
|
|
OSL_ENSURE(false, "SvXMLImport::SetXmlId: exception?");
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
|
|
::rtl::OUString const & i_rAbout,
|
|
::rtl::OUString const & i_rProperty,
|
|
::rtl::OUString const & i_rContent,
|
|
::rtl::OUString const & i_rDatatype)
|
|
{
|
|
// N.B.: we only get called if i_xObject had xhtml:about attribute
|
|
// (an empty attribute value is valid)
|
|
if (!mpImpl->mpRDFaHelper.get())
|
|
{
|
|
mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
|
|
}
|
|
mpImpl->mpRDFaHelper->AddRDFa(i_xObject,
|
|
i_rAbout, i_rProperty, i_rContent, i_rDatatype);
|
|
}
|
|
|