2000-09-18 23:31:44 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: xmlimp.cxx,v $
|
|
|
|
*
|
2003-04-28 15:08:15 +00:00
|
|
|
* $Revision: 1.71 $
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2003-04-28 15:08:15 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2003-04-28 16:08:15 $
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2000-12-01 10:16:41 +00:00
|
|
|
#ifndef _URLOBJ_HXX
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
#ifndef _OSL_MUTEX_HXX_
|
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#include <rtl/uuid.h>
|
|
|
|
#include <rtl/memory.h>
|
|
|
|
|
|
|
|
#ifndef _SVARRAY_HXX
|
|
|
|
#include <svtools/svarray.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_NMSPMAP_HXX
|
|
|
|
#include "nmspmap.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLUCONV_HXX
|
|
|
|
#include "xmluconv.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNMSPE_HXX
|
|
|
|
#include "xmlnmspe.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLKYWD_HXX
|
|
|
|
#include "xmlkywd.hxx"
|
|
|
|
#endif
|
2001-06-29 20:07:26 +00:00
|
|
|
#ifndef _XMLOFF_XMLTOKEN_HXX
|
|
|
|
#include "xmltoken.hxx"
|
|
|
|
#endif
|
2000-12-15 11:14:46 +00:00
|
|
|
#ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX_
|
|
|
|
#include "XMLFontStylesContext.hxx"
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLICTXT_HXX
|
|
|
|
#include "xmlictxt.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLIMP_HXX
|
|
|
|
#include "xmlimp.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLNUMFI_HXX
|
|
|
|
#include "xmlnumfi.hxx"
|
|
|
|
#endif
|
2000-12-19 17:56:47 +00:00
|
|
|
#ifndef _XMLOFF_XMLEVENTIMPORTHELPER_HXX
|
|
|
|
#include "XMLEventImportHelper.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLSTARBASICCONTEXTFACTORY_HXX
|
|
|
|
#include "XMLStarBasicContextFactory.hxx"
|
|
|
|
#endif
|
2002-11-19 12:14:43 +00:00
|
|
|
#ifndef _XMLOFF_XMLSCRIPTCONTEXTFACTORY_HXX
|
|
|
|
#include "XMLScriptContextFactory.hxx"
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2000-12-02 09:26:15 +00:00
|
|
|
#ifndef _XMLOFF_PROGRESSBARHELPER_HXX
|
|
|
|
#include "ProgressBarHelper.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-05-17 13:07:36 +00:00
|
|
|
#ifndef _XMLOFF_XMLTOKEN_HXX
|
|
|
|
#include "xmltoken.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-09-18 15:28:34 +00:00
|
|
|
#ifndef _XMLOFF_XMLERROR_HXX
|
|
|
|
#include "xmlerror.hxx"
|
|
|
|
#endif
|
|
|
|
|
2002-06-04 07:27:50 +00:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#endif
|
2000-12-02 09:26:15 +00:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
|
2000-09-18 23:31:44 +00:00
|
|
|
#endif
|
2001-05-18 12:58:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
|
|
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
|
|
|
#endif
|
2001-06-12 13:27:58 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XBINARYSTREAMRESOLVER_HPP_
|
|
|
|
#include <com/sun/star/document/XBinaryStreamResolver.hpp>
|
|
|
|
#endif
|
2001-09-13 14:18:52 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
|
|
|
|
#include <com/sun/star/lang/XEventListener.hpp>
|
|
|
|
#endif
|
2001-09-18 15:28:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_XML_SAX_XLOCATOR_HPP_
|
|
|
|
#include <com/sun/star/xml/sax/XLocator.hpp>
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-04-20 07:07:16 +00:00
|
|
|
#ifndef _COMPHELPER_NAMECONTAINER_HXX_
|
|
|
|
#include <comphelper/namecontainer.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-07-26 13:55:49 +00:00
|
|
|
#ifndef _RTL_LOGFILE_HXX_
|
|
|
|
#include <rtl/logfile.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _STRING_HXX
|
|
|
|
#include <tools/string.hxx> // used in StartElement for logging
|
|
|
|
#endif
|
2001-09-13 14:18:52 +00:00
|
|
|
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
|
|
|
#endif
|
2002-07-01 13:17:28 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
|
|
|
#endif
|
2001-07-26 13:55:49 +00:00
|
|
|
|
2001-07-25 05:46:27 +00:00
|
|
|
#ifdef CONV_STAR_FONTS
|
|
|
|
#ifndef _VCL_FONTCVT_HXX
|
|
|
|
#include <vcl/fontcvt.hxx>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::osl;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::frame;
|
|
|
|
using namespace ::com::sun::star::uno;
|
2001-01-17 10:00:14 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
2001-05-18 12:58:34 +00:00
|
|
|
using namespace ::com::sun::star::io;
|
|
|
|
using namespace ::com::sun::star::container;
|
2002-06-04 07:27:50 +00:00
|
|
|
using namespace ::com::sun::star::document;
|
2001-06-29 20:07:26 +00:00
|
|
|
using namespace ::xmloff::token;
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
sal_Char __READONLY_DATA sXML_np__office[] = "_office";
|
|
|
|
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";
|
2000-11-24 16:00:21 +00:00
|
|
|
sal_Char __READONLY_DATA sXML_np__dr3d[] = "_dr3d";
|
2000-09-18 23:31:44 +00:00
|
|
|
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__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";
|
2000-11-14 09:28:59 +00:00
|
|
|
sal_Char __READONLY_DATA sXML_np__math[] = "_math";
|
2000-12-19 17:56:47 +00:00
|
|
|
sal_Char __READONLY_DATA sXML_np__script[] = "_script";
|
2001-03-19 09:30:30 +00:00
|
|
|
sal_Char __READONLY_DATA sXML_np__config[] = "_config";
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
|
2001-08-03 15:24:00 +00:00
|
|
|
#define LOGFILE_AUTHOR "mb93740"
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-07-25 05:46:27 +00:00
|
|
|
#ifdef CONV_STAR_FONTS
|
2001-09-13 14:18:52 +00:00
|
|
|
|
|
|
|
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& rEventObject )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if (pImport)
|
|
|
|
pImport->DisposingModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
2001-07-25 05:46:27 +00:00
|
|
|
class SvXMLImport_Impl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FontToSubsFontConverter hBatsFontConv;
|
|
|
|
FontToSubsFontConverter hMathFontConv;
|
|
|
|
|
2002-06-04 07:27:50 +00:00
|
|
|
bool mbOwnGraphicResolver;
|
|
|
|
bool mbOwnEmbeddedResolver;
|
|
|
|
|
|
|
|
SvXMLImport_Impl() : hBatsFontConv( 0 ), hMathFontConv( 0 ), mbOwnGraphicResolver( false ), mbOwnEmbeddedResolver( false ) {}
|
2001-07-25 05:46:27 +00:00
|
|
|
~SvXMLImport_Impl()
|
|
|
|
{
|
|
|
|
if( hBatsFontConv )
|
|
|
|
DestroyFontToSubsFontConverter( hBatsFontConv );
|
|
|
|
if( hMathFontConv )
|
|
|
|
DestroyFontToSubsFontConverter( hMathFontConv );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
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 >& xAttrList )
|
|
|
|
{
|
|
|
|
return new SvXMLImportContext( *this, nPrefix, rLocalName );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::_InitCtor()
|
|
|
|
{
|
2001-07-10 16:04:42 +00:00
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
|
|
|
|
GetXMLToken(XML_N_OFFICE),
|
|
|
|
XML_NAMESPACE_OFFICE );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style) ),
|
|
|
|
GetXMLToken(XML_N_STYLE),
|
|
|
|
XML_NAMESPACE_STYLE );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text) ),
|
|
|
|
GetXMLToken(XML_N_TEXT),
|
|
|
|
XML_NAMESPACE_TEXT );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table ) ),
|
|
|
|
GetXMLToken(XML_N_TABLE),
|
|
|
|
XML_NAMESPACE_TABLE );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ),
|
|
|
|
GetXMLToken(XML_N_DRAW),
|
|
|
|
XML_NAMESPACE_DRAW );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM (sXML_np__dr3d ) ),
|
|
|
|
GetXMLToken(XML_N_DR3D),
|
|
|
|
XML_NAMESPACE_DR3D );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__fo) ),
|
|
|
|
GetXMLToken(XML_N_FO),
|
|
|
|
XML_NAMESPACE_FO );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink) ),
|
|
|
|
GetXMLToken(XML_N_XLINK),
|
|
|
|
XML_NAMESPACE_XLINK );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dc) ),
|
|
|
|
GetXMLToken(XML_N_DC),
|
|
|
|
XML_NAMESPACE_DC );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__meta) ),
|
|
|
|
GetXMLToken(XML_N_META),
|
|
|
|
XML_NAMESPACE_META );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__number) ),
|
|
|
|
GetXMLToken(XML_N_NUMBER),
|
|
|
|
XML_NAMESPACE_NUMBER );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__svg) ),
|
|
|
|
GetXMLToken(XML_N_SVG),
|
|
|
|
XML_NAMESPACE_SVG );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__chart) ),
|
|
|
|
GetXMLToken(XML_N_CHART),
|
|
|
|
XML_NAMESPACE_CHART );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ),
|
|
|
|
GetXMLToken(XML_N_MATH),
|
|
|
|
XML_NAMESPACE_MATH );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_namespace_form) ),
|
|
|
|
GetXMLToken(XML_N_FORM),
|
|
|
|
XML_NAMESPACE_FORM );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ),
|
|
|
|
GetXMLToken(XML_N_SCRIPT),
|
|
|
|
XML_NAMESPACE_SCRIPT );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__config) ),
|
|
|
|
GetXMLToken(XML_N_CONFIG),
|
|
|
|
XML_NAMESPACE_CONFIG );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
// namespaces used in the technical preview (SO 5.2)
|
2001-07-10 16:04:42 +00:00
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__fo_old) ),
|
|
|
|
GetXMLToken(XML_N_FO_OLD),
|
|
|
|
XML_NAMESPACE_FO );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink_old) ),
|
|
|
|
GetXMLToken(XML_N_XLINK_OLD),
|
|
|
|
XML_NAMESPACE_XLINK );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office) ),
|
|
|
|
GetXMLToken(XML_N_OFFICE_OLD),
|
|
|
|
XML_NAMESPACE_OFFICE );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style_old) ),
|
|
|
|
GetXMLToken(XML_N_STYLE_OLD),
|
|
|
|
XML_NAMESPACE_STYLE );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text_old) ),
|
|
|
|
GetXMLToken(XML_N_TEXT_OLD),
|
|
|
|
XML_NAMESPACE_TEXT );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table_old) ),
|
|
|
|
GetXMLToken(XML_N_TABLE_OLD),
|
|
|
|
XML_NAMESPACE_TABLE );
|
|
|
|
pNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__meta_old) ),
|
|
|
|
GetXMLToken(XML_N_META_OLD),
|
|
|
|
XML_NAMESPACE_META );
|
2000-12-01 10:16:41 +00:00
|
|
|
sPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
|
2001-01-17 10:00:14 +00:00
|
|
|
|
|
|
|
if (xNumberFormatsSupplier.is())
|
|
|
|
pNumImport = new SvXMLNumFmtHelper(xNumberFormatsSupplier);
|
2001-09-13 14:18:52 +00:00
|
|
|
|
|
|
|
if (xModel.is() && !pEventListener)
|
|
|
|
{
|
|
|
|
pEventListener = new SvXMLImportEventListener(this);
|
|
|
|
xModel->addEventListener(pEventListener);
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2001-03-01 15:31:32 +00:00
|
|
|
SvXMLImport::SvXMLImport( sal_uInt16 nImportFlags ) throw () :
|
2002-06-04 07:27:50 +00:00
|
|
|
pImpl( new SvXMLImport_Impl() ),
|
2000-09-18 23:31:44 +00:00
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
|
|
|
|
pContexts( new SvXMLImportContexts_Impl ),
|
2000-11-10 17:15:59 +00:00
|
|
|
pNumImport( NULL ),
|
2001-01-17 10:00:14 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-03-01 15:31:32 +00:00
|
|
|
pEventImportHelper( NULL ),
|
2001-09-13 14:18:52 +00:00
|
|
|
pEventListener( NULL ),
|
|
|
|
pXMLErrors( NULL ),
|
2001-04-26 17:04:11 +00:00
|
|
|
mnImportFlags( nImportFlags ),
|
|
|
|
mbIsFormsSupported( sal_True )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
|
|
|
}
|
|
|
|
|
2000-12-03 09:16:56 +00:00
|
|
|
SvXMLImport::SvXMLImport( const Reference< XModel > & rModel ) throw () :
|
2002-06-04 07:27:50 +00:00
|
|
|
pImpl( new SvXMLImport_Impl() ),
|
2000-12-03 09:16:56 +00:00
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
|
|
|
|
pContexts( new SvXMLImportContexts_Impl ),
|
|
|
|
pNumImport( NULL ),
|
|
|
|
xModel( rModel ),
|
|
|
|
xNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
2000-12-19 17:56:47 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-03-02 19:17:53 +00:00
|
|
|
pEventImportHelper( NULL ),
|
2001-09-13 14:18:52 +00:00
|
|
|
pEventListener( NULL ),
|
|
|
|
pXMLErrors( NULL ),
|
2001-04-26 17:04:11 +00:00
|
|
|
mnImportFlags( IMPORT_ALL ),
|
|
|
|
mbIsFormsSupported( sal_True )
|
2000-12-03 09:16:56 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
|
|
|
}
|
|
|
|
|
2000-12-01 10:16:41 +00:00
|
|
|
SvXMLImport::SvXMLImport( const Reference< XModel > & rModel,
|
2001-01-12 15:16:13 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > & rGraphicObjects ) throw () :
|
2002-06-04 07:27:50 +00:00
|
|
|
pImpl( new SvXMLImport_Impl() ),
|
2000-09-18 23:31:44 +00:00
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
|
|
|
|
pContexts( new SvXMLImportContexts_Impl ),
|
|
|
|
pNumImport( NULL ),
|
|
|
|
xModel( rModel ),
|
2001-01-12 15:16:13 +00:00
|
|
|
xGraphicResolver( rGraphicObjects ),
|
2000-11-10 17:15:59 +00:00
|
|
|
xNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
2000-12-19 17:56:47 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-03-02 19:17:53 +00:00
|
|
|
pEventImportHelper( NULL ),
|
2001-09-13 14:18:52 +00:00
|
|
|
pEventListener( NULL ),
|
|
|
|
pXMLErrors( NULL ),
|
2001-04-26 17:04:11 +00:00
|
|
|
mnImportFlags( IMPORT_ALL ),
|
|
|
|
mbIsFormsSupported( sal_True )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLImport::~SvXMLImport() throw ()
|
|
|
|
{
|
2001-10-30 14:59:24 +00:00
|
|
|
delete pXMLErrors;
|
2000-09-18 23:31:44 +00:00
|
|
|
delete pNamespaceMap;
|
|
|
|
delete pUnitConv;
|
|
|
|
delete pContexts;
|
2001-01-17 10:00:14 +00:00
|
|
|
delete pEventImportHelper;
|
2001-03-28 09:47:41 +00:00
|
|
|
// delete pImageMapImportHelper;
|
2000-12-15 11:14:46 +00:00
|
|
|
|
2003-04-08 14:41:01 +00:00
|
|
|
// #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 pNumImport;
|
|
|
|
delete pProgressBarHelper;
|
2001-05-17 13:07:36 +00:00
|
|
|
|
|
|
|
xmloff::token::ResetTokens();
|
2001-07-25 05:46:27 +00:00
|
|
|
|
|
|
|
if( pImpl )
|
|
|
|
delete pImpl;
|
2002-06-04 07:27:50 +00:00
|
|
|
|
2001-09-13 14:18:52 +00:00
|
|
|
if (pEventListener && xModel.is())
|
|
|
|
xModel->removeEventListener(pEventListener);
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 (SvXMLImport*)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_Int64)this;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::startDocument( void )
|
|
|
|
throw( xml::sax::SAXException, uno::RuntimeException )
|
|
|
|
{
|
2001-08-03 15:24:00 +00:00
|
|
|
RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "{ SvXMLImport::startDocument" );
|
2002-06-04 07:27:50 +00:00
|
|
|
|
|
|
|
if( !xGraphicResolver.is() || !xEmbeddedResolver.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xFactory( xModel, UNO_QUERY );
|
|
|
|
if( xFactory.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if( !xGraphicResolver.is() )
|
|
|
|
{
|
|
|
|
xGraphicResolver = Reference< XGraphicObjectResolver >::query(
|
|
|
|
xFactory->createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(
|
2002-06-06 10:11:21 +00:00
|
|
|
// #99870# Import... instead of Export...
|
|
|
|
"com.sun.star.document.ImportGraphicObjectResolver"))));
|
2002-06-11 07:07:05 +00:00
|
|
|
pImpl->mbOwnGraphicResolver = xGraphicResolver.is();
|
2002-06-04 07:27:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !xEmbeddedResolver.is() )
|
|
|
|
{
|
|
|
|
xEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
|
|
|
|
xFactory->createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(
|
2002-06-06 10:11:21 +00:00
|
|
|
// #99870# Import... instead of Export...
|
|
|
|
"com.sun.star.document.ImportEmbeddedObjectResolver"))));
|
2002-06-11 07:07:05 +00:00
|
|
|
pImpl->mbOwnEmbeddedResolver = xEmbeddedResolver.is();
|
2002-06-04 07:27:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::endDocument( void )
|
|
|
|
throw( xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
2001-08-03 15:24:00 +00:00
|
|
|
RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "} SvXMLImport::startDocument" );
|
2001-09-28 15:39:54 +00:00
|
|
|
|
2003-04-08 14:41:01 +00:00
|
|
|
// #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 (pNumImport)
|
|
|
|
{
|
|
|
|
delete pNumImport;
|
|
|
|
pNumImport = NULL;
|
|
|
|
}
|
|
|
|
if (xImportInfo.is())
|
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->getPropertySetInfo();
|
|
|
|
if (xPropertySetInfo.is())
|
|
|
|
{
|
|
|
|
if (pProgressBarHelper)
|
|
|
|
{
|
|
|
|
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(pProgressBarHelper->GetReference());
|
|
|
|
sal_Int32 nProgressCurrent(pProgressBarHelper->GetValue());
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= nProgressMax;
|
|
|
|
xImportInfo->setPropertyValue(sProgressMax, aAny);
|
|
|
|
aAny <<= nProgressCurrent;
|
|
|
|
xImportInfo->setPropertyValue(sProgressCurrent, aAny);
|
|
|
|
}
|
|
|
|
if (xPropertySetInfo->hasPropertyByName(sRepeat))
|
|
|
|
xImportInfo->setPropertyValue(sRepeat, cppu::bool2any(pProgressBarHelper->GetRepeat()));
|
|
|
|
// pProgressBarHelper is deleted in dtor
|
|
|
|
}
|
|
|
|
OUString sNumberStyles(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
|
|
|
|
if (xNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
|
|
|
|
{
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= xNumberStyles;
|
|
|
|
xImportInfo->setPropertyValue(sNumberStyles, aAny);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( xFontDecls.Is() )
|
|
|
|
((SvXMLStylesContext *)&xFontDecls)->Clear();
|
|
|
|
if( xStyles.Is() )
|
|
|
|
((SvXMLStylesContext *)&xStyles)->Clear();
|
|
|
|
if( xAutoStyles.Is() )
|
|
|
|
((SvXMLStylesContext *)&xAutoStyles)->Clear();
|
|
|
|
if( xMasterStyles.Is() )
|
|
|
|
((SvXMLStylesContext *)&xMasterStyles)->Clear();
|
|
|
|
|
|
|
|
// The shape import helper does the z-order sorting in the dtor,
|
|
|
|
// so it must be deleted here, too.
|
|
|
|
mxShapeImport = NULL;
|
|
|
|
|
2002-06-04 07:27:50 +00:00
|
|
|
if( pImpl->mbOwnGraphicResolver )
|
|
|
|
{
|
|
|
|
Reference< lang::XComponent > xComp( xGraphicResolver, UNO_QUERY );
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pImpl->mbOwnEmbeddedResolver )
|
|
|
|
{
|
|
|
|
Reference< lang::XComponent > xComp( xEmbeddedResolver, UNO_QUERY );
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
|
2001-09-28 15:39:54 +00:00
|
|
|
if ( pXMLErrors != NULL )
|
|
|
|
{
|
|
|
|
pXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
2003-03-27 17:21:03 +00:00
|
|
|
if( ( rAttrName.getLength() >= 5 ) &&
|
|
|
|
( rAttrName.compareToAscii( sXML_xmlns, 5 ) == 0 ) &&
|
2000-09-18 23:31:44 +00:00
|
|
|
( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
|
|
|
|
{
|
|
|
|
if( !pRewindMap )
|
|
|
|
{
|
|
|
|
pRewindMap = pNamespaceMap;
|
|
|
|
pNamespaceMap = new SvXMLNamespaceMap( *pNamespaceMap );
|
|
|
|
}
|
|
|
|
const OUString& rAttrValue = xAttrList->getValueByIndex( i );
|
2003-03-27 17:21:03 +00:00
|
|
|
|
|
|
|
OUString aPrefix( ( rAttrName.getLength() == 5 )
|
|
|
|
? OUString()
|
|
|
|
: rAttrName.copy( 6 ) );
|
|
|
|
pNamespaceMap->Add( aPrefix, rAttrValue );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get element's namespace and local name.
|
|
|
|
OUString aLocalName;
|
|
|
|
USHORT nPrefix =
|
|
|
|
pNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
|
|
|
|
|
|
|
|
// If there are contexts already, call a CreateChildContext at the topmost
|
|
|
|
// context. Otherwise, create a default context.
|
|
|
|
SvXMLImportContext *pContext;
|
|
|
|
USHORT nCount = pContexts->Count();
|
|
|
|
if( nCount > 0 )
|
|
|
|
{
|
|
|
|
pContext = (*pContexts)[nCount - 1]->CreateChildContext( nPrefix,
|
|
|
|
aLocalName,
|
|
|
|
xAttrList );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-26 13:55:49 +00:00
|
|
|
#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 );
|
2001-08-03 15:24:00 +00:00
|
|
|
RTL_LOGFILE_TRACE_AUTHOR1( "xmloff", LOGFILE_AUTHOR,
|
|
|
|
"SvXMLImport::StartElement( \"%s\", ... )",
|
|
|
|
aString.GetBuffer() );
|
2001-07-26 13:55:49 +00:00
|
|
|
#endif
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
pContext = CreateContext( nPrefix, aLocalName, xAttrList );
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
|
|
|
pContexts->Insert( pContext, nCount );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::endElement( const OUString& rName )
|
|
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
USHORT nCount = pContexts->Count();
|
|
|
|
DBG_ASSERT( nCount, "SvXMLImport::endElement: no context left" );
|
|
|
|
if( nCount > 0 )
|
|
|
|
{
|
|
|
|
// Get topmost context and remove it from the stack.
|
|
|
|
SvXMLImportContext *pContext = (*pContexts)[nCount-1];
|
|
|
|
pContexts->Remove( nCount-1, 1 );
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
// Non product only: check if endElement call matches startELement call.
|
|
|
|
OUString aLocalName;
|
|
|
|
USHORT nPrefix =
|
|
|
|
pNamespaceMap->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 pNamespaceMap;
|
|
|
|
pNamespaceMap = pRewindMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::characters( const OUString& rChars )
|
|
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
USHORT nCount = pContexts->Count();
|
|
|
|
if( nCount > 0 )
|
|
|
|
{
|
|
|
|
(*pContexts)[nCount - 1]->Characters( rChars );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::ignorableWhitespace( const OUString& rWhitespaces )
|
|
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::processingInstruction( const OUString& rTarget,
|
|
|
|
const OUString& rData )
|
|
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
|
|
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
xLocator = 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& rComment )
|
|
|
|
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& sString )
|
|
|
|
throw(xml::sax::SAXException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-11-16 17:16:04 +00:00
|
|
|
void SvXMLImport::SetStatisticAttributes(const uno::Reference< xml::sax::XAttributeList > & xAttribs)
|
|
|
|
{
|
2002-12-02 11:56:24 +00:00
|
|
|
GetProgressBarHelper()->SetRepeat(sal_False);
|
|
|
|
GetProgressBarHelper()->SetReference(0);
|
2000-11-16 17:16:04 +00:00
|
|
|
}
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// XImporter
|
|
|
|
void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
|
|
|
|
throw(lang::IllegalArgumentException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
xModel = uno::Reference< frame::XModel >::query( xDoc );
|
|
|
|
if( !xModel.is() )
|
|
|
|
throw lang::IllegalArgumentException();
|
2001-09-13 14:18:52 +00:00
|
|
|
if (xModel.is() && !pEventListener)
|
|
|
|
{
|
|
|
|
pEventListener = new SvXMLImportEventListener(this);
|
|
|
|
xModel->addEventListener(pEventListener);
|
|
|
|
}
|
2001-01-17 10:00:14 +00:00
|
|
|
|
|
|
|
DBG_ASSERT( !pNumImport, "number format import already exists." );
|
|
|
|
if( pNumImport )
|
|
|
|
{
|
|
|
|
delete pNumImport;
|
|
|
|
pNumImport = 0;
|
|
|
|
}
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
2002-11-05 15:15:20 +00:00
|
|
|
// XFilter
|
|
|
|
sal_Bool SAL_CALL SvXMLImport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLImport::cancel( )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
// 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++ )
|
|
|
|
{
|
2001-10-16 11:32:03 +00:00
|
|
|
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() )
|
|
|
|
xGraphicResolver = xTmpGraphicResolver;
|
|
|
|
|
|
|
|
uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
|
|
|
|
xValue, UNO_QUERY );
|
|
|
|
if( xTmpObjectResolver.is() )
|
|
|
|
xEmbeddedResolver = xTmpObjectResolver;
|
|
|
|
|
|
|
|
uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
|
|
|
|
if( xTmpPropSet.is() )
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
2001-10-16 11:32:03 +00:00
|
|
|
xImportInfo = xTmpPropSet;
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->getPropertySetInfo();
|
|
|
|
if (xPropertySetInfo.is())
|
2001-04-20 07:07:16 +00:00
|
|
|
{
|
2001-10-16 11:32:03 +00:00
|
|
|
OUString sNumberStyles(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
|
|
|
|
if (xPropertySetInfo->hasPropertyByName(sNumberStyles))
|
2001-04-20 07:07:16 +00:00
|
|
|
{
|
2001-10-16 11:32:03 +00:00
|
|
|
uno::Any aAny = xImportInfo->getPropertyValue(sNumberStyles);
|
|
|
|
aAny >>= xNumberStyles;
|
2001-04-20 07:07:16 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-20 19:08:37 +00:00
|
|
|
}
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XServiceInfo
|
|
|
|
OUString SAL_CALL SvXMLImport::getImplementationName()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
2001-09-13 13:55:31 +00:00
|
|
|
sal_Bool SAL_CALL SvXMLImport::supportsService( const OUString& rServiceName )
|
2001-01-12 15:16:13 +00:00
|
|
|
throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2001-09-13 13:55:31 +00:00
|
|
|
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);
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
2001-09-13 13:55:31 +00:00
|
|
|
uno::Sequence<OUString> aSeq(2);
|
|
|
|
OUString* pSeq = aSeq.getArray();
|
|
|
|
aSeq[0] = OUString(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportFilter"));
|
|
|
|
aSeq[1] = OUString(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter"));
|
2001-01-12 15:16:13 +00:00
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
XMLTextImportHelper* SvXMLImport::CreateTextImport()
|
|
|
|
{
|
2001-09-21 15:27:53 +00:00
|
|
|
return new XMLTextImportHelper( xModel, *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XMLShapeImportHelper* SvXMLImport::CreateShapeImport()
|
|
|
|
{
|
2001-02-08 13:30:12 +00:00
|
|
|
return new XMLShapeImportHelper( *this, xModel );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2001-07-24 16:06:10 +00:00
|
|
|
#ifndef SVX_LIGHT
|
2000-09-18 23:31:44 +00:00
|
|
|
SchXMLImportHelper* SvXMLImport::CreateChartImport()
|
|
|
|
{
|
|
|
|
return new SchXMLImportHelper();
|
|
|
|
}
|
2001-07-24 16:06:10 +00:00
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-07-24 16:06:10 +00:00
|
|
|
#ifndef SVX_LIGHT
|
2000-12-18 14:22:38 +00:00
|
|
|
#if SUPD>615 || defined(PRIV_DEBUG)
|
|
|
|
::xmloff::OFormLayerXMLImport* SvXMLImport::CreateFormImport()
|
|
|
|
{
|
|
|
|
return new ::xmloff::OFormLayerXMLImport(*this);
|
|
|
|
}
|
|
|
|
#endif
|
2001-07-24 16:06:10 +00:00
|
|
|
#endif // #ifndef SVX_LIGHT
|
|
|
|
|
2000-12-18 14:22:38 +00:00
|
|
|
|
2000-10-16 12:30:27 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Get or create fill/line/lineend-style-helper
|
|
|
|
//
|
|
|
|
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
|
|
|
|
{
|
|
|
|
if( !xGradientHelper.is() )
|
|
|
|
{
|
|
|
|
if( xModel.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( xModel, UNO_QUERY);
|
|
|
|
if( xServiceFact.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) ), UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xGradientHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
|
|
|
|
{
|
|
|
|
if( !xHatchHelper.is() )
|
|
|
|
{
|
|
|
|
if( xModel.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( xModel, UNO_QUERY);
|
|
|
|
if( xServiceFact.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xHatchHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) ), UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xHatchHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
|
|
|
|
{
|
|
|
|
if( !xBitmapHelper.is() )
|
|
|
|
{
|
|
|
|
if( xModel.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( xModel, UNO_QUERY);
|
|
|
|
if( xServiceFact.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xBitmapHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) ), UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xBitmapHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
|
|
|
|
{
|
|
|
|
if( !xTransGradientHelper.is() )
|
|
|
|
{
|
|
|
|
if( xModel.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( xModel, UNO_QUERY);
|
|
|
|
if( xServiceFact.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xTransGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) ), UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xTransGradientHelper;
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2000-10-16 12:30:27 +00:00
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
|
|
|
|
{
|
|
|
|
if( !xMarkerHelper.is() )
|
|
|
|
{
|
|
|
|
if( xModel.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( xModel, UNO_QUERY);
|
|
|
|
if( xServiceFact.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xMarkerHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) ), UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xMarkerHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
|
|
|
|
{
|
|
|
|
if( !xDashHelper.is() )
|
|
|
|
{
|
|
|
|
if( xModel.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFact( xModel, UNO_QUERY);
|
|
|
|
if( xServiceFact.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xDashHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) ) ), UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xDashHelper;
|
|
|
|
}
|
2000-12-01 10:16:41 +00:00
|
|
|
|
2001-06-12 13:27:58 +00:00
|
|
|
::rtl::OUString SvXMLImport::ResolveGraphicObjectURL( const ::rtl::OUString& rURL,
|
|
|
|
sal_Bool bLoadOnDemand )
|
2000-12-01 10:16:41 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString sRet;
|
|
|
|
|
|
|
|
if( 0 == rURL.compareTo( ::rtl::OUString( '#' ), 1 ) )
|
|
|
|
{
|
2001-01-12 15:16:13 +00:00
|
|
|
if( !bLoadOnDemand && xGraphicResolver.is() )
|
2000-12-01 10:16:41 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString aTmp( sPackageProtocol );
|
2001-01-12 15:16:13 +00:00
|
|
|
aTmp += rURL.copy( 1 );
|
|
|
|
sRet = xGraphicResolver->resolveGraphicObjectURL( aTmp );
|
2000-12-01 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !sRet.getLength() )
|
|
|
|
{
|
|
|
|
sRet = sPackageProtocol;
|
|
|
|
sRet += rURL.copy( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !sRet.getLength() )
|
|
|
|
sRet = INetURLObject::RelToAbs( rURL );
|
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
2000-12-15 11:14:46 +00:00
|
|
|
|
2001-06-19 14:08:23 +00:00
|
|
|
Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
|
2001-06-12 13:27:58 +00:00
|
|
|
{
|
2001-06-19 14:08:23 +00:00
|
|
|
Reference< XOutputStream > xOStm;
|
|
|
|
Reference< document::XBinaryStreamResolver > xStmResolver( xGraphicResolver, UNO_QUERY );
|
2001-06-12 13:27:58 +00:00
|
|
|
|
2001-06-19 14:08:23 +00:00
|
|
|
if( xStmResolver.is() )
|
|
|
|
xOStm = xStmResolver->createOutputStream();
|
2001-06-12 13:27:58 +00:00
|
|
|
|
2001-06-19 14:08:23 +00:00
|
|
|
return xOStm;
|
|
|
|
}
|
2001-06-12 13:27:58 +00:00
|
|
|
|
2001-06-19 14:08:23 +00:00
|
|
|
::rtl::OUString SvXMLImport::ResolveGraphicObjectURLFromBase64(
|
|
|
|
const Reference < XOutputStream >& rOut )
|
|
|
|
{
|
|
|
|
OUString sURL;
|
|
|
|
Reference< document::XBinaryStreamResolver > xStmResolver( xGraphicResolver, UNO_QUERY );
|
|
|
|
if( xStmResolver.is() )
|
|
|
|
sURL = xStmResolver->resolveOutputStream( rOut );
|
2001-06-12 13:27:58 +00:00
|
|
|
|
2001-06-19 14:08:23 +00:00
|
|
|
return sURL;
|
2001-06-12 13:27:58 +00:00
|
|
|
}
|
|
|
|
|
2001-01-26 10:22:48 +00:00
|
|
|
::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURL(
|
|
|
|
const ::rtl::OUString& rURL,
|
|
|
|
const ::rtl::OUString& rClassId )
|
|
|
|
{
|
|
|
|
::rtl::OUString sRet;
|
|
|
|
|
|
|
|
if( 0 == rURL.compareTo( ::rtl::OUString( '#' ), 1 ) &&
|
|
|
|
xEmbeddedResolver.is() )
|
|
|
|
{
|
|
|
|
OUString sURL( rURL );
|
|
|
|
if( rClassId.getLength() )
|
|
|
|
{
|
|
|
|
sURL += OUString( '!' );
|
|
|
|
sURL += rClassId;
|
|
|
|
}
|
|
|
|
sRet = xEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
|
|
|
|
}
|
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2001-05-18 12:58:34 +00:00
|
|
|
Reference < XOutputStream > SvXMLImport::ResolveEmbeddedObjectURLFromBase64(
|
|
|
|
const ::rtl::OUString& rURL )
|
|
|
|
{
|
|
|
|
Reference < XOutputStream > xOLEStream;
|
|
|
|
|
|
|
|
if( 0 == rURL.compareTo( ::rtl::OUString( '#' ), 1 ) &&
|
|
|
|
xEmbeddedResolver.is() )
|
|
|
|
{
|
|
|
|
Reference< XNameAccess > xNA( xEmbeddedResolver, UNO_QUERY );
|
|
|
|
if( xNA.is() )
|
|
|
|
{
|
|
|
|
Any aAny = xNA->getByName( rURL );
|
|
|
|
aAny >>= xOLEStream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xOLEStream;
|
|
|
|
}
|
|
|
|
|
2001-03-22 11:41:50 +00:00
|
|
|
void SvXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps)
|
2001-03-16 10:36:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-03-22 11:41:50 +00:00
|
|
|
void SvXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps)
|
2001-03-16 10:36:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-03-30 09:49:34 +00:00
|
|
|
ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
|
|
|
|
{
|
|
|
|
if (!pProgressBarHelper)
|
|
|
|
{
|
2001-09-25 09:29:18 +00:00
|
|
|
pProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_False);
|
2001-03-30 09:49:34 +00:00
|
|
|
|
|
|
|
if (pProgressBarHelper && xImportInfo.is())
|
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->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));
|
2002-07-01 13:17:28 +00:00
|
|
|
OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
|
2001-03-30 09:49:34 +00:00
|
|
|
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 = xImportInfo->getPropertyValue(sProgressRange);
|
|
|
|
if (aAny >>= nProgressRange)
|
|
|
|
pProgressBarHelper->SetRange(nProgressRange);
|
|
|
|
aAny = xImportInfo->getPropertyValue(sProgressMax);
|
|
|
|
if (aAny >>= nProgressMax)
|
|
|
|
pProgressBarHelper->SetReference(nProgressMax);
|
|
|
|
aAny = xImportInfo->getPropertyValue(sProgressCurrent);
|
|
|
|
if (aAny >>= nProgressCurrent)
|
|
|
|
pProgressBarHelper->SetValue(nProgressCurrent);
|
|
|
|
}
|
2002-07-01 13:17:28 +00:00
|
|
|
if (xPropertySetInfo->hasPropertyByName(sRepeat))
|
|
|
|
{
|
|
|
|
uno::Any aAny = xImportInfo->getPropertyValue(sRepeat);
|
|
|
|
if (aAny.getValueType() == getBooleanCppuType())
|
|
|
|
pProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
|
|
|
|
else
|
|
|
|
DBG_ERRORFILE("why is it no boolean?");
|
|
|
|
}
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pProgressBarHelper;
|
|
|
|
}
|
|
|
|
|
2001-04-20 07:07:16 +00:00
|
|
|
void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
|
|
|
|
{
|
|
|
|
if (!xNumberStyles.is())
|
2001-06-13 16:19:29 +00:00
|
|
|
xNumberStyles = uno::Reference< container::XNameContainer >( comphelper::NameContainer_createInstance( ::getCppuType((const sal_Int32*)0)) );
|
2001-04-20 07:07:16 +00:00
|
|
|
if (xNumberStyles.is())
|
|
|
|
{
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= nKey;
|
2001-06-13 16:19:29 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xNumberStyles->insertByName(rName, aAny);
|
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR("Numberformat could not be inserted");
|
|
|
|
}
|
2001-04-20 07:07:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_ERROR("not possible to create NameContainer");
|
|
|
|
}
|
|
|
|
|
2000-12-19 17:56:47 +00:00
|
|
|
XMLEventImportHelper& SvXMLImport::GetEventImport()
|
|
|
|
{
|
2001-07-24 16:06:10 +00:00
|
|
|
#ifndef SVX_LIGHT
|
2000-12-19 17:56:47 +00:00
|
|
|
if (!pEventImportHelper)
|
|
|
|
{
|
|
|
|
// construct event helper and register StarBasic handler and standard
|
|
|
|
// event tables
|
|
|
|
pEventImportHelper = new XMLEventImportHelper();
|
2001-06-29 20:07:26 +00:00
|
|
|
OUString sStarBasic(GetXMLToken(XML_STARBASIC));
|
2000-12-19 17:56:47 +00:00
|
|
|
pEventImportHelper->RegisterFactory(sStarBasic,
|
|
|
|
new XMLStarBasicContextFactory());
|
2002-11-19 12:14:43 +00:00
|
|
|
OUString sScript(GetXMLToken(XML_SCRIPT));
|
|
|
|
pEventImportHelper->RegisterFactory(sScript,
|
|
|
|
new XMLScriptContextFactory());
|
2000-12-19 17:56:47 +00:00
|
|
|
pEventImportHelper->AddTranslationTable(aStandardEventTable);
|
2001-08-03 17:14:08 +00:00
|
|
|
|
|
|
|
// register StarBasic event handler with capitalized spelling
|
|
|
|
OUString sStarBasicCap(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
|
|
|
|
pEventImportHelper->RegisterFactory(sStarBasicCap,
|
|
|
|
new XMLStarBasicContextFactory());
|
2000-12-19 17:56:47 +00:00
|
|
|
}
|
2001-07-24 16:06:10 +00:00
|
|
|
#endif
|
2000-12-19 17:56:47 +00:00
|
|
|
|
|
|
|
return *pEventImportHelper;
|
|
|
|
}
|
|
|
|
|
2000-12-15 11:14:46 +00:00
|
|
|
void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls )
|
|
|
|
{
|
|
|
|
xFontDecls = pFontDecls;
|
|
|
|
GetTextImport()->SetFontDecls( pFontDecls );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles )
|
|
|
|
{
|
|
|
|
xStyles = pStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles )
|
|
|
|
{
|
2001-04-20 07:07:16 +00:00
|
|
|
if (pAutoStyles && xNumberStyles.is() && (mnImportFlags & IMPORT_CONTENT) )
|
|
|
|
{
|
|
|
|
uno::Reference<xml::sax::XAttributeList> xAttrList;
|
|
|
|
uno::Sequence< ::rtl::OUString > aNames = xNumberStyles->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 = xNumberStyles->getByName(*pNames);
|
|
|
|
if (aAny >>= nKey)
|
|
|
|
{
|
|
|
|
pContext = new SvXMLNumFormatContext( *this, XML_NAMESPACE_NUMBER,
|
|
|
|
*pNames, xAttrList, nKey, *pAutoStyles );
|
|
|
|
pAutoStyles->AddStyle(*pContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-12-15 11:14:46 +00:00
|
|
|
xAutoStyles = pAutoStyles;
|
|
|
|
GetTextImport()->SetAutoStyles( pAutoStyles );
|
|
|
|
GetShapeImport()->SetAutoStylesContext( pAutoStyles );
|
2001-07-24 16:06:10 +00:00
|
|
|
#ifndef SVX_LIGHT
|
2000-12-15 18:19:13 +00:00
|
|
|
GetChartImport()->SetAutoStylesContext( pAutoStyles );
|
2001-05-28 14:16:59 +00:00
|
|
|
GetFormImport()->setAutoStyleContext( pAutoStyles );
|
2001-07-24 16:06:10 +00:00
|
|
|
#endif
|
2000-12-15 11:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles )
|
|
|
|
{
|
|
|
|
xMasterStyles = pMasterStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLFontStylesContext *SvXMLImport::GetFontDecls()
|
|
|
|
{
|
|
|
|
return (XMLFontStylesContext *)&xFontDecls;
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLStylesContext *SvXMLImport::GetStyles()
|
|
|
|
{
|
|
|
|
return (SvXMLStylesContext *)&xStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLStylesContext *SvXMLImport::GetAutoStyles()
|
|
|
|
{
|
|
|
|
return (SvXMLStylesContext *)&xAutoStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLStylesContext *SvXMLImport::GetMasterStyles()
|
|
|
|
{
|
|
|
|
return (SvXMLStylesContext *)&xMasterStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
const XMLFontStylesContext *SvXMLImport::GetFontDecls() const
|
|
|
|
{
|
|
|
|
return (const XMLFontStylesContext *)&xFontDecls;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SvXMLStylesContext *SvXMLImport::GetStyles() const
|
|
|
|
{
|
|
|
|
return (const SvXMLStylesContext *)&xStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const
|
|
|
|
{
|
|
|
|
return (const SvXMLStylesContext *)&xAutoStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SvXMLStylesContext *SvXMLImport::GetMasterStyles() const
|
|
|
|
{
|
|
|
|
return (const SvXMLStylesContext *)&xMasterStyles;
|
|
|
|
}
|
2001-06-25 10:44:38 +00:00
|
|
|
|
|
|
|
OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue)
|
|
|
|
{
|
|
|
|
return INetURLObject::RelToAbs( rValue );
|
|
|
|
}
|
2001-07-27 12:44:08 +00:00
|
|
|
|
|
|
|
void SvXMLImport::_CreateNumberFormatsSupplier()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( !xNumberFormatsSupplier.is(),
|
|
|
|
"number formats supplier already exists!" );
|
2001-09-13 14:18:52 +00:00
|
|
|
if(xModel.is())
|
|
|
|
xNumberFormatsSupplier =
|
|
|
|
uno::Reference< util::XNumberFormatsSupplier> (xModel, uno::UNO_QUERY);
|
2001-07-27 12:44:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SvXMLImport::_CreateDataStylesImport()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pNumImport == NULL, "data styles import already exists!" );
|
|
|
|
uno::Reference<util::XNumberFormatsSupplier> xNum =
|
|
|
|
GetNumberFormatsSupplier();
|
|
|
|
if ( xNum.is() )
|
|
|
|
pNumImport = new SvXMLNumFmtHelper(xNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-25 05:46:27 +00:00
|
|
|
#ifdef CONV_STAR_FONTS
|
|
|
|
sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
|
|
|
|
{
|
|
|
|
sal_Unicode cNew = c;
|
2002-06-04 07:27:50 +00:00
|
|
|
if( !pImpl->hBatsFontConv )
|
2001-07-25 05:46:27 +00:00
|
|
|
{
|
|
|
|
OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) );
|
|
|
|
pImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats,
|
|
|
|
FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
|
|
|
|
OSL_ENSURE( pImpl->hBatsFontConv, "Got no symbol font converter" );
|
|
|
|
}
|
|
|
|
if( pImpl->hBatsFontConv )
|
|
|
|
{
|
|
|
|
cNew = ConvertFontToSubsFontChar( pImpl->hBatsFontConv, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
return cNew;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
|
|
|
|
{
|
|
|
|
sal_Unicode cNew = c;
|
2002-06-04 07:27:50 +00:00
|
|
|
if( !pImpl->hMathFontConv )
|
2001-07-25 05:46:27 +00:00
|
|
|
{
|
|
|
|
OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) );
|
|
|
|
pImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath,
|
|
|
|
FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
|
|
|
|
OSL_ENSURE( pImpl->hMathFontConv, "Got no symbol font converter" );
|
|
|
|
}
|
|
|
|
if( pImpl->hMathFontConv )
|
|
|
|
{
|
|
|
|
cNew = ConvertFontToSubsFontChar( pImpl->hMathFontConv, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
return cNew;
|
|
|
|
}
|
2001-09-18 15:28:34 +00:00
|
|
|
#endif
|
2001-09-13 14:18:52 +00:00
|
|
|
|
2001-09-18 15:28:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SvXMLImport::SetError(
|
|
|
|
sal_Int32 nId,
|
|
|
|
const Sequence<OUString>& rMsgParams,
|
|
|
|
const OUString& rExceptionMessage,
|
|
|
|
const Reference<xml::sax::XLocator>& rLocator )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2001-09-18 15:28:34 +00:00
|
|
|
// 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;
|
|
|
|
|
2001-09-28 15:39:54 +00:00
|
|
|
// create error list on demand
|
2001-09-18 15:28:34 +00:00
|
|
|
if ( pXMLErrors == NULL )
|
|
|
|
pXMLErrors = new XMLErrors();
|
|
|
|
|
|
|
|
// save error information
|
2001-09-28 15:39:54 +00:00
|
|
|
// use document locator (if none supplied)
|
|
|
|
pXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
|
|
|
|
rLocator.is() ? rLocator : xLocator );
|
2001-09-18 15:28:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::SetError(
|
|
|
|
sal_Int32 nId,
|
|
|
|
const Sequence<OUString>& rMsgParams)
|
|
|
|
{
|
|
|
|
OUString sEmpty;
|
|
|
|
SetError( nId, rMsgParams, sEmpty, NULL );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XMLErrors* SvXMLImport::GetErrors()
|
|
|
|
{
|
|
|
|
return pXMLErrors;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLImport::DisposingModel()
|
|
|
|
{
|
2003-04-28 15:08:15 +00:00
|
|
|
if( xFontDecls.Is() )
|
|
|
|
((SvXMLStylesContext *)&xFontDecls)->Clear();
|
|
|
|
if( xStyles.Is() )
|
|
|
|
((SvXMLStylesContext *)&xStyles)->Clear();
|
|
|
|
if( xAutoStyles.Is() )
|
|
|
|
((SvXMLStylesContext *)&xAutoStyles)->Clear();
|
|
|
|
if( xMasterStyles.Is() )
|
|
|
|
((SvXMLStylesContext *)&xMasterStyles)->Clear();
|
|
|
|
|
2001-09-13 14:18:52 +00:00
|
|
|
xModel = 0;
|
|
|
|
pEventListener = NULL;
|
|
|
|
}
|