2000-09-18 23:31:44 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* $RCSfile: xmlexp.cxx,v $
|
|
|
|
* $Revision: 1.137 $
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* 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.
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* 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).
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2008-04-10 20:39:57 +00:00
|
|
|
* 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.
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 09:22:44 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_xmloff.hxx"
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
#ifdef PRECOMPILED
|
|
|
|
#include "filt_pch.hxx"
|
|
|
|
#endif
|
2004-11-26 18:30:25 +00:00
|
|
|
#include "unointerfacetouniqueidentifiermapper.hxx"
|
2001-01-22 11:27:59 +00:00
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#include <rtl/uuid.h>
|
2000-09-18 23:31:44 +00:00
|
|
|
#include <tools/debug.hxx>
|
2000-11-29 14:57:15 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
2004-07-13 07:06:44 +00:00
|
|
|
#include <comphelper/genericpropertyset.hxx>
|
2001-05-18 12:58:34 +00:00
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
2001-06-12 13:27:58 +00:00
|
|
|
#include <com/sun/star/document/XBinaryStreamResolver.hpp>
|
2001-11-26 06:58:54 +00:00
|
|
|
#include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
|
2006-04-27 08:43:08 +00:00
|
|
|
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
|
|
|
|
#include <com/sun/star/uri/UriReferenceFactory.hpp>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
2007-08-03 11:53:22 +00:00
|
|
|
#include <comphelper/configurationhelper.hxx>
|
2007-06-27 13:57:25 +00:00
|
|
|
#include <xmloff/attrlist.hxx>
|
|
|
|
#include <xmloff/nmspmap.hxx>
|
|
|
|
#include <xmloff/xmluconv.hxx>
|
2000-09-18 23:31:44 +00:00
|
|
|
#include "xmlnmspe.hxx"
|
2007-06-27 13:57:25 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
|
|
|
#include <xmloff/xmlexp.hxx>
|
|
|
|
#include <xmloff/xmlnumfe.hxx>
|
|
|
|
#include <xmloff/xmlmetae.hxx>
|
|
|
|
#include <xmloff/families.hxx>
|
|
|
|
#include <xmloff/XMLEventExport.hxx>
|
2000-12-19 17:56:47 +00:00
|
|
|
#include "XMLStarBasicExportHandler.hxx"
|
2002-11-19 12:14:43 +00:00
|
|
|
#include "XMLScriptExportHandler.hxx"
|
2007-06-27 13:57:25 +00:00
|
|
|
#include <xmloff/SettingsExportHelper.hxx>
|
2000-09-18 23:31:44 +00:00
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
2000-11-29 13:32:08 +00:00
|
|
|
#include <com/sun/star/container/XIndexContainer.hpp>
|
2001-02-21 19:30:19 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP
|
|
|
|
#include <com/sun/star/document/XEventsSupplier.hpp>
|
|
|
|
#endif
|
2001-04-04 04:26:04 +00:00
|
|
|
#include <com/sun/star/document/XViewDataSupplier.hpp>
|
2000-09-18 23:31:44 +00:00
|
|
|
#include <GradientStyle.hxx>
|
|
|
|
#include <HatchStyle.hxx>
|
|
|
|
#include <ImageStyle.hxx>
|
|
|
|
#include <TransGradientStyle.hxx>
|
|
|
|
#include <MarkerStyle.hxx>
|
|
|
|
#include <DashStyle.hxx>
|
2000-11-13 07:44:24 +00:00
|
|
|
#ifndef _XMLOFF_XMLFONTAUTOSTYLEPOOL_HXX
|
2007-06-27 13:57:25 +00:00
|
|
|
#include <xmloff/XMLFontAutoStylePool>
|
2000-11-13 07:44:24 +00:00
|
|
|
#endif
|
2001-03-28 09:28:16 +00:00
|
|
|
#include "XMLImageMapExport.hxx"
|
2001-05-18 12:58:34 +00:00
|
|
|
#ifndef _XMLOFF_XMLBASE64EXPORT_HXX_
|
|
|
|
#include "XMLBase64Export.hxx"
|
|
|
|
#endif
|
2001-09-18 15:28:34 +00:00
|
|
|
#ifndef _XMLOFF_XMLERROR_HXX_
|
|
|
|
#include "xmlerror.hxx"
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
|
2004-07-13 07:06:44 +00:00
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
2001-05-09 11:22:39 +00:00
|
|
|
#include "XMLFilterServiceNames.h"
|
|
|
|
#include "XMLEmbeddedObjectExportFilter.hxx"
|
2004-11-09 12:06:48 +00:00
|
|
|
#include "XMLBasicExportFilter.hxx"
|
2001-09-25 16:03:25 +00:00
|
|
|
#include <vos/mutex.hxx>
|
2001-07-26 13:55:49 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2001-09-13 14:18:52 +00:00
|
|
|
#include <cppuhelper/implbase1.hxx>
|
2001-10-19 10:46:32 +00:00
|
|
|
#include <comphelper/extract.hxx>
|
2004-07-13 07:06:44 +00:00
|
|
|
#include "PropertySetMerger.hxx"
|
2001-10-19 10:46:32 +00:00
|
|
|
|
2005-01-11 11:06:02 +00:00
|
|
|
#include "svtools/urihelper.hxx"
|
2004-11-16 09:07:39 +00:00
|
|
|
#include "xformsexport.hxx"
|
|
|
|
|
2008-02-26 12:32:31 +00:00
|
|
|
#include <unotools/docinfohelper.hxx>
|
|
|
|
#include <unotools/bootstrap.hxx>
|
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#include <tools/inetdef.hxx>
|
|
|
|
#include <com/sun/star/document/XDocumentProperties.hpp>
|
|
|
|
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
|
|
|
|
2008-03-12 09:29:35 +00:00
|
|
|
using ::rtl::OUString;
|
|
|
|
|
2001-01-22 11:27:59 +00:00
|
|
|
using namespace ::osl;
|
2000-09-18 23:31:44 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::frame;
|
2000-11-29 13:32:08 +00:00
|
|
|
using namespace ::com::sun::star::container;
|
2001-05-09 11:22:39 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::document;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::xml::sax;
|
2001-05-18 12:58:34 +00:00
|
|
|
using namespace ::com::sun::star::io;
|
2001-05-16 14:21:01 +00:00
|
|
|
using namespace ::xmloff::token;
|
2001-05-09 11:22:39 +00:00
|
|
|
|
2007-11-01 12:39:22 +00:00
|
|
|
sal_Char __READONLY_DATA sXML_1_1[] = "1.1";
|
2001-05-09 11:22:39 +00:00
|
|
|
|
2008-02-26 12:32:31 +00:00
|
|
|
const sal_Char *sOpenOfficeOrgProject ="OpenOffice.org_project";
|
|
|
|
|
2001-08-03 15:24:00 +00:00
|
|
|
#define LOGFILE_AUTHOR "mb93740"
|
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
#define XML_MODEL_SERVICE_WRITER "com.sun.star.text.TextDocument"
|
|
|
|
#define XML_MODEL_SERVICE_CALC "com.sun.star.sheet.SpreadsheetDocument"
|
|
|
|
#define XML_MODEL_SERVICE_DRAW "com.sun.star.drawing.DrawingDocument"
|
|
|
|
#define XML_MODEL_SERVICE_IMPRESS "com.sun.star.presentation.PresentationDocument"
|
|
|
|
#define XML_MODEL_SERVICE_MATH "com.sun.star.formula.FormulaProperties"
|
|
|
|
#define XML_MODEL_SERVICE_CHART "com.sun.star.chart.ChartDocument"
|
|
|
|
|
2007-08-03 11:53:22 +00:00
|
|
|
#define XML_USEPRETTYPRINTING "UsePrettyPrinting"
|
|
|
|
|
|
|
|
#define C2U(cChar) OUString( RTL_CONSTASCII_USTRINGPARAM(cChar) )
|
2001-09-18 15:28:34 +00:00
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
struct XMLServiceMapEntry_Impl
|
|
|
|
{
|
|
|
|
const sal_Char *sModelService;
|
|
|
|
sal_Int32 nModelServiceLen;
|
|
|
|
const sal_Char *sFilterService;
|
|
|
|
sal_Int32 nFilterServiceLen;
|
|
|
|
};
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
#define SERVICE_MAP_ENTRY( app ) \
|
|
|
|
{ XML_MODEL_SERVICE_##app, sizeof(XML_MODEL_SERVICE_##app)-1, \
|
|
|
|
XML_EXPORT_FILTER_##app, sizeof(XML_EXPORT_FILTER_##app)-1 }
|
|
|
|
|
|
|
|
const XMLServiceMapEntry_Impl aServiceMap[] =
|
|
|
|
{
|
|
|
|
SERVICE_MAP_ENTRY( WRITER ),
|
|
|
|
SERVICE_MAP_ENTRY( CALC ),
|
|
|
|
SERVICE_MAP_ENTRY( IMPRESS ),// Impress supports DrawingDocument, too, so
|
|
|
|
SERVICE_MAP_ENTRY( DRAW ), // it must appear before Draw
|
|
|
|
SERVICE_MAP_ENTRY( MATH ),
|
|
|
|
SERVICE_MAP_ENTRY( CHART ),
|
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-09-13 14:18:52 +00:00
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
class SvXMLExportEventListener : public cppu::WeakImplHelper1<
|
|
|
|
com::sun::star::lang::XEventListener >
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
SvXMLExport* pExport;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SvXMLExportEventListener(SvXMLExport* pExport);
|
|
|
|
virtual ~SvXMLExportEventListener();
|
|
|
|
|
|
|
|
// XEventListener
|
|
|
|
virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
};
|
|
|
|
|
|
|
|
SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport)
|
|
|
|
: pExport(pTempExport)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLExportEventListener::~SvXMLExportEventListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// XEventListener
|
2006-06-20 10:39:29 +00:00
|
|
|
void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& )
|
2001-09-13 14:18:52 +00:00
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if (pExport)
|
2004-11-02 13:38:12 +00:00
|
|
|
{
|
2001-09-13 14:18:52 +00:00
|
|
|
pExport->DisposingModel();
|
2004-11-02 13:38:12 +00:00
|
|
|
pExport = NULL;
|
|
|
|
}
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
2004-11-26 18:30:25 +00:00
|
|
|
class SvXMLExport_Impl
|
|
|
|
{
|
|
|
|
public:
|
2006-04-27 08:43:08 +00:00
|
|
|
SvXMLExport_Impl();
|
|
|
|
|
2004-11-26 18:30:25 +00:00
|
|
|
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
|
2007-08-03 11:53:22 +00:00
|
|
|
uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory;
|
|
|
|
rtl::OUString msPackageURI;
|
2006-10-13 11:15:34 +00:00
|
|
|
// --> OD 2006-09-27 #i69627#
|
2007-08-03 11:53:22 +00:00
|
|
|
sal_Bool mbOutlineStyleAsNormalListStyle;
|
|
|
|
// <--
|
|
|
|
// --> PB 2007-07-06 #i146851#
|
|
|
|
sal_Bool mbSaveBackwardCompatibleODF;
|
2006-10-13 11:15:34 +00:00
|
|
|
// <--
|
2008-03-12 09:29:35 +00:00
|
|
|
|
|
|
|
uno::Reference< embed::XStorage > mxTargetStorage;
|
2004-11-26 18:30:25 +00:00
|
|
|
};
|
2007-08-03 11:53:22 +00:00
|
|
|
|
2006-04-27 08:43:08 +00:00
|
|
|
SvXMLExport_Impl::SvXMLExport_Impl()
|
2006-10-13 11:15:34 +00:00
|
|
|
// --> OD 2006-09-27 #i69627#
|
|
|
|
: mbOutlineStyleAsNormalListStyle( false )
|
|
|
|
// <--
|
2007-08-03 11:53:22 +00:00
|
|
|
// --> PB 2007-07-06 #i146851#
|
|
|
|
,mbSaveBackwardCompatibleODF( sal_True )
|
|
|
|
// <--
|
2006-04-27 08:43:08 +00:00
|
|
|
{
|
|
|
|
mxUriReferenceFactory = uri::UriReferenceFactory::create(
|
|
|
|
comphelper_getProcessComponentContext());
|
|
|
|
}
|
2004-11-26 18:30:25 +00:00
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler = rHandler;
|
|
|
|
mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
|
2004-07-13 07:06:44 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::_InitCtor()
|
|
|
|
{
|
2004-08-02 13:12:38 +00:00
|
|
|
if( (getExportFlags() & ~EXPORT_OASIS) != 0 )
|
2004-07-13 07:06:44 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
|
2004-07-13 07:06:44 +00:00
|
|
|
}
|
2001-03-05 10:47:18 +00:00
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
2001-03-14 14:08:53 +00:00
|
|
|
if( (getExportFlags() & EXPORT_SETTINGS) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
|
2001-03-14 14:08:53 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
if( (getExportFlags() & (EXPORT_META|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
|
2001-03-05 10:47:18 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META), XML_NAMESPACE_META );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
// namespaces for documents
|
2001-03-05 10:47:18 +00:00
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
|
|
|
|
{
|
2008-03-05 15:46:25 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_DR3D), GetXMLToken(XML_N_DR3D), XML_NAMESPACE_DR3D );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_CHART), GetXMLToken(XML_N_CHART), XML_NAMESPACE_CHART );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_NUMBER),GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS) ) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_SCRIPT), GetXMLToken(XML_N_SCRIPT), XML_NAMESPACE_SCRIPT );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
|
2001-03-05 10:47:18 +00:00
|
|
|
}
|
2004-11-16 09:07:39 +00:00
|
|
|
if( (getExportFlags() & EXPORT_CONTENT ) != 0 )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_XFORMS_1_0), GetXMLToken(XML_N_XFORMS_1_0), XML_NAMESPACE_XFORMS );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_XSD), GetXMLToken(XML_N_XSD), XML_NAMESPACE_XSD );
|
|
|
|
mpNamespaceMap->Add( GetXMLToken(XML_NP_XSI), GetXMLToken(XML_N_XSI), XML_NAMESPACE_XSI );
|
2004-11-16 09:07:39 +00:00
|
|
|
}
|
2000-11-14 09:13:10 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
mxAttrList = (xml::sax::XAttributeList*)mpAttrList;
|
2000-11-29 13:32:08 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
msPicturesPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#Pictures/" ) );
|
|
|
|
msObjectsPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#./" ) );
|
|
|
|
msGraphicObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
|
|
|
|
msEmbeddedObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
|
2001-09-13 14:18:52 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxModel.is() && !mxEventListener.is())
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2004-05-14 15:10:42 +00:00
|
|
|
mxEventListener.set( new SvXMLExportEventListener(this));
|
2006-06-20 10:39:29 +00:00
|
|
|
mxModel->addEventListener(mxEventListener);
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
2006-03-27 09:04:05 +00:00
|
|
|
|
|
|
|
// --> OD 2006-03-10 #i51726# - determine model type
|
|
|
|
_DetermineModelType();
|
|
|
|
// <--
|
2007-04-16 12:08:45 +00:00
|
|
|
|
|
|
|
mbEnableExperimentalOdfExport = getenv("ENABLE_EXPERIMENTAL_ODF_EXPORT") != NULL;
|
2007-08-03 11:53:22 +00:00
|
|
|
|
|
|
|
// --> PB 2007-07-06 #146851# - load mbSaveBackwardCompatibleODF from configuration
|
|
|
|
|
|
|
|
// cl: but only if we do export to current oasis format, old openoffice format *must* always be compatible
|
|
|
|
if( (getExportFlags() & EXPORT_OASIS) != 0 )
|
|
|
|
{
|
|
|
|
sal_Bool bTemp = sal_True;
|
|
|
|
if ( ::comphelper::ConfigurationHelper::readDirectKey(
|
|
|
|
getServiceFactory(),
|
|
|
|
C2U("org.openoffice.Office.Common/"), C2U("Save/Document"), C2U("SaveBackwardCompatibleODF"),
|
|
|
|
::comphelper::ConfigurationHelper::E_READONLY ) >>= bTemp )
|
|
|
|
{
|
|
|
|
mpImpl->mbSaveBackwardCompatibleODF = bTemp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// <--
|
2006-03-27 09:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// --> OD 2006-03-14 #i51726#
|
|
|
|
void SvXMLExport::_DetermineModelType()
|
|
|
|
{
|
|
|
|
meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if ( mxModel.is() )
|
2006-03-27 09:04:05 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel );
|
2006-03-27 09:04:05 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
2006-03-27 09:04:05 +00:00
|
|
|
// <--
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
SvXMLExport::SvXMLExport(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
|
|
MapUnit eDfltUnit, const enum XMLTokenEnum eClass, sal_uInt16 nExportFlags )
|
2006-06-20 10:39:29 +00:00
|
|
|
: mpImpl( new SvXMLExport_Impl ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
mxServiceFactory(xServiceFactory),
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList( new SvXMLAttributeList ),
|
|
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
2006-06-20 10:39:29 +00:00
|
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ),
|
|
|
|
mpNumExport(0L),
|
|
|
|
mpProgressBarHelper( NULL ),
|
|
|
|
mpEventExport( NULL ),
|
|
|
|
mpImageMapExport( NULL ),
|
|
|
|
mpXMLErrors( NULL ),
|
|
|
|
mbExtended( sal_False ),
|
|
|
|
meClass( eClass ),
|
2001-09-13 14:18:52 +00:00
|
|
|
mnExportFlags( nExportFlags ),
|
2006-06-20 10:39:29 +00:00
|
|
|
mnErrorFlags( ERROR_NO ),
|
|
|
|
msWS( GetXMLToken(XML_WS) ),
|
|
|
|
mbSaveLinkedSections(sal_True)
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
2004-05-03 12:33:10 +00:00
|
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
2001-01-12 15:16:13 +00:00
|
|
|
_InitCtor();
|
|
|
|
}
|
|
|
|
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLExport::SvXMLExport(
|
2004-05-03 12:33:10 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
|
|
const OUString &rFileName,
|
|
|
|
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
|
|
|
|
MapUnit eDfltUnit )
|
2006-06-20 10:39:29 +00:00
|
|
|
: mpImpl( new SvXMLExport_Impl ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
mxServiceFactory(xServiceFactory),
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler( rHandler ),
|
|
|
|
mxExtHandler( rHandler, uno::UNO_QUERY ),
|
|
|
|
mpAttrList( new SvXMLAttributeList ),
|
|
|
|
msOrigFileName( rFileName ),
|
|
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
2006-06-20 10:39:29 +00:00
|
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ),
|
|
|
|
mpNumExport(0L),
|
|
|
|
mpProgressBarHelper( NULL ),
|
|
|
|
mpEventExport( NULL ),
|
|
|
|
mpImageMapExport( NULL ),
|
|
|
|
mpXMLErrors( NULL ),
|
|
|
|
mbExtended( sal_False ),
|
|
|
|
meClass( XML_TOKEN_INVALID ),
|
2004-07-13 07:06:44 +00:00
|
|
|
mnExportFlags( 0 ),
|
2006-06-20 10:39:29 +00:00
|
|
|
mnErrorFlags( ERROR_NO ),
|
|
|
|
msWS( GetXMLToken(XML_WS) ),
|
|
|
|
mbSaveLinkedSections(sal_True)
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
2004-05-03 12:33:10 +00:00
|
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
2000-09-18 23:31:44 +00:00
|
|
|
_InitCtor();
|
2001-01-17 12:42:42 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxNumberFormatsSupplier.is())
|
|
|
|
mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
2000-12-03 09:16:56 +00:00
|
|
|
SvXMLExport::SvXMLExport(
|
2004-05-03 12:33:10 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
|
|
const OUString &rFileName,
|
|
|
|
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
|
|
|
|
const Reference< XModel >& rModel,
|
|
|
|
sal_Int16 eDfltUnit )
|
2006-06-20 10:39:29 +00:00
|
|
|
: mpImpl( new SvXMLExport_Impl ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
mxServiceFactory(xServiceFactory),
|
2006-06-20 10:39:29 +00:00
|
|
|
mxModel( rModel ),
|
|
|
|
mxHandler( rHandler ),
|
|
|
|
mxExtHandler( rHandler, uno::UNO_QUERY ),
|
|
|
|
mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
|
|
|
mpAttrList( new SvXMLAttributeList ),
|
|
|
|
msOrigFileName( rFileName ),
|
|
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit) ) ),
|
2006-06-20 10:39:29 +00:00
|
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ),
|
|
|
|
mpNumExport(0L),
|
|
|
|
mpProgressBarHelper( NULL ),
|
|
|
|
mpEventExport( NULL ),
|
|
|
|
mpImageMapExport( NULL ),
|
|
|
|
mpXMLErrors( NULL ),
|
|
|
|
mbExtended( sal_False ),
|
|
|
|
meClass( XML_TOKEN_INVALID ),
|
2004-07-13 07:06:44 +00:00
|
|
|
mnExportFlags( 0 ),
|
2006-06-20 10:39:29 +00:00
|
|
|
mnErrorFlags( ERROR_NO ),
|
|
|
|
msWS( GetXMLToken(XML_WS) ),
|
|
|
|
mbSaveLinkedSections(sal_True)
|
2000-12-03 09:16:56 +00:00
|
|
|
{
|
2004-05-03 12:33:10 +00:00
|
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
2000-12-03 09:16:56 +00:00
|
|
|
_InitCtor();
|
2001-01-17 12:42:42 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxNumberFormatsSupplier.is())
|
|
|
|
mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
|
2000-12-03 09:16:56 +00:00
|
|
|
}
|
|
|
|
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLExport::SvXMLExport(
|
2004-05-03 12:33:10 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
|
|
|
|
const OUString &rFileName,
|
|
|
|
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
|
|
|
|
const Reference< XModel >& rModel,
|
|
|
|
const Reference< document::XGraphicObjectResolver >& rEmbeddedGraphicObjects,
|
|
|
|
sal_Int16 eDfltUnit )
|
2006-06-20 10:39:29 +00:00
|
|
|
: mpImpl( new SvXMLExport_Impl ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
mxServiceFactory(xServiceFactory),
|
2006-06-20 10:39:29 +00:00
|
|
|
mxModel( rModel ),
|
|
|
|
mxHandler( rHandler ),
|
|
|
|
mxExtHandler( rHandler, uno::UNO_QUERY ),
|
|
|
|
mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
|
|
|
mxGraphicResolver( rEmbeddedGraphicObjects ),
|
|
|
|
mpAttrList( new SvXMLAttributeList ),
|
|
|
|
msOrigFileName( rFileName ),
|
|
|
|
mpNamespaceMap( new SvXMLNamespaceMap ),
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
2006-06-20 10:39:29 +00:00
|
|
|
mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ),
|
|
|
|
mpNumExport(0L),
|
|
|
|
mpProgressBarHelper( NULL ),
|
|
|
|
mpEventExport( NULL ),
|
|
|
|
mpImageMapExport( NULL ),
|
|
|
|
mpXMLErrors( NULL ),
|
|
|
|
mbExtended( sal_False ),
|
|
|
|
meClass( XML_TOKEN_INVALID ),
|
2004-07-13 07:06:44 +00:00
|
|
|
mnExportFlags( 0 ),
|
2006-06-20 10:39:29 +00:00
|
|
|
mnErrorFlags( ERROR_NO ),
|
|
|
|
msWS( GetXMLToken(XML_WS) ),
|
|
|
|
mbSaveLinkedSections(sal_True)
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
2004-05-03 12:33:10 +00:00
|
|
|
DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
|
2000-09-18 23:31:44 +00:00
|
|
|
_InitCtor();
|
2001-01-17 12:42:42 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxNumberFormatsSupplier.is())
|
|
|
|
mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLExport::~SvXMLExport()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
delete mpXMLErrors;
|
|
|
|
delete mpImageMapExport;
|
|
|
|
delete mpEventExport;
|
|
|
|
delete mpNamespaceMap;
|
|
|
|
delete mpUnitConv;
|
|
|
|
if (mpProgressBarHelper || mpNumExport)
|
2001-03-30 09:49:34 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxExportInfo.is())
|
2001-03-30 09:49:34 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
|
2001-03-30 09:49:34 +00:00
|
|
|
if (xPropertySetInfo.is())
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mpProgressBarHelper)
|
2001-03-30 09:49:34 +00:00
|
|
|
{
|
2001-04-20 07:07:16 +00:00
|
|
|
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-04-20 07:07:16 +00:00
|
|
|
if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
|
|
|
|
xPropertySetInfo->hasPropertyByName(sProgressCurrent))
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
|
|
|
|
sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
|
2001-04-20 07:07:16 +00:00
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= nProgressMax;
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->setPropertyValue(sProgressMax, aAny);
|
2001-04-20 07:07:16 +00:00
|
|
|
aAny <<= nProgressCurrent;
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->setPropertyValue(sProgressCurrent, aAny);
|
2001-04-20 07:07:16 +00:00
|
|
|
}
|
2002-07-01 13:17:28 +00:00
|
|
|
if (xPropertySetInfo->hasPropertyByName(sRepeat))
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
|
2001-04-20 07:07:16 +00:00
|
|
|
}
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
|
2001-04-20 07:07:16 +00:00
|
|
|
{
|
2001-04-20 09:37:39 +00:00
|
|
|
OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
|
2001-04-20 07:07:16 +00:00
|
|
|
if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
|
|
|
|
{
|
|
|
|
uno::Sequence<sal_Int32> aWasUsed;
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNumExport->GetWasUsed(aWasUsed);
|
2001-04-20 07:07:16 +00:00
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= aWasUsed;
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->setPropertyValue(sWrittenNumberFormats, aAny);
|
2001-04-20 07:07:16 +00:00
|
|
|
}
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 10:39:29 +00:00
|
|
|
delete mpProgressBarHelper;
|
|
|
|
delete mpNumExport;
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
2001-05-17 13:07:36 +00:00
|
|
|
|
|
|
|
xmloff::token::ResetTokens();
|
2001-09-13 14:18:52 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxEventListener.is() && mxModel.is())
|
|
|
|
mxModel->removeEventListener(mxEventListener);
|
2004-11-26 18:30:25 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
delete mpImpl;
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// XExporter
|
|
|
|
void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
|
|
|
|
throw(lang::IllegalArgumentException, uno::RuntimeException)
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxModel = uno::Reference< frame::XModel >::query( xDoc );
|
|
|
|
if( !mxModel.is() )
|
2001-01-12 15:16:13 +00:00
|
|
|
throw lang::IllegalArgumentException();
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxModel.is() && ! mxEventListener.is())
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2004-05-14 15:10:42 +00:00
|
|
|
mxEventListener.set( new SvXMLExportEventListener(this));
|
2006-06-20 10:39:29 +00:00
|
|
|
mxModel->addEventListener(mxEventListener);
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
2001-01-12 15:16:13 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if(!mxNumberFormatsSupplier.is() )
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxNumberFormatsSupplier = mxNumberFormatsSupplier.query( mxModel );
|
|
|
|
if(mxNumberFormatsSupplier.is() && mxHandler.is())
|
|
|
|
mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxExportInfo.is())
|
2001-04-20 07:07:16 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
|
2001-04-20 07:07:16 +00:00
|
|
|
if (xPropertySetInfo.is())
|
|
|
|
{
|
2001-10-19 10:46:32 +00:00
|
|
|
OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM(XML_USEPRETTYPRINTING));
|
|
|
|
if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting))
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting);
|
2001-10-19 10:46:32 +00:00
|
|
|
if (::cppu::any2bool(aAny))
|
|
|
|
mnExportFlags |= EXPORT_PRETTY;
|
|
|
|
else
|
|
|
|
mnExportFlags &= ~EXPORT_PRETTY;
|
|
|
|
}
|
2007-08-03 11:53:22 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
|
2001-04-20 07:07:16 +00:00
|
|
|
{
|
2001-10-19 10:46:32 +00:00
|
|
|
OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
|
|
|
|
if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats);
|
2001-10-19 10:46:32 +00:00
|
|
|
uno::Sequence<sal_Int32> aWasUsed;
|
|
|
|
if(aAny >>= aWasUsed)
|
2006-06-20 10:39:29 +00:00
|
|
|
mpNumExport->SetWasUsed(aWasUsed);
|
2001-10-19 10:46:32 +00:00
|
|
|
}
|
2001-04-20 07:07:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-10-12 15:12:09 +00:00
|
|
|
|
2007-08-03 11:53:22 +00:00
|
|
|
// --> PB 2007-07-06 #i146851#
|
|
|
|
if ( mpImpl->mbSaveBackwardCompatibleODF )
|
|
|
|
mnExportFlags |= EXPORT_SAVEBACKWARDCOMPATIBLE;
|
|
|
|
else
|
|
|
|
mnExportFlags &= ~EXPORT_SAVEBACKWARDCOMPATIBLE;
|
|
|
|
// <--
|
|
|
|
|
2001-10-12 15:12:09 +00:00
|
|
|
// namespaces for user defined attributes
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
|
2001-10-12 15:12:09 +00:00
|
|
|
if( xFactory.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference < XInterface > xIfc =
|
|
|
|
xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"com.sun.star.xml.NamespaceMap")) );
|
|
|
|
if( xIfc.is() )
|
|
|
|
{
|
|
|
|
Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY );
|
|
|
|
if( xNamespaceMap.is() )
|
|
|
|
{
|
|
|
|
Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() );
|
|
|
|
|
|
|
|
OUString* pPrefix = aPrefixes.getArray();
|
|
|
|
const sal_Int32 nCount = aPrefixes.getLength();
|
|
|
|
sal_Int32 nIndex;
|
|
|
|
OUString aURL;
|
|
|
|
|
|
|
|
for( nIndex = 0; nIndex < nCount; nIndex++, *pPrefix++ )
|
|
|
|
{
|
|
|
|
if( xNamespaceMap->getByName( *pPrefix ) >>= aURL )
|
|
|
|
_GetNamespaceMap().Add( *pPrefix, aURL, XML_NAMESPACE_UNKNOWN );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2006-03-27 09:04:05 +00:00
|
|
|
|
|
|
|
// --> OD 2006-03-10 #i51726# - determine model type
|
|
|
|
_DetermineModelType();
|
|
|
|
// <--
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XInitialize
|
|
|
|
void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments )
|
|
|
|
throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2001-10-16 11:32:03 +00:00
|
|
|
// #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
// status indicator
|
|
|
|
uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
|
|
|
|
if ( xTmpStatus.is() )
|
2006-06-20 10:39:29 +00:00
|
|
|
mxStatusIndicator = xTmpStatus;
|
2001-10-16 11:32:03 +00:00
|
|
|
|
|
|
|
// graphic resolver
|
|
|
|
uno::Reference<document::XGraphicObjectResolver> xTmpGraphic(
|
|
|
|
xValue, UNO_QUERY );
|
|
|
|
if ( xTmpGraphic.is() )
|
2006-06-20 10:39:29 +00:00
|
|
|
mxGraphicResolver = xTmpGraphic;
|
2001-10-16 11:32:03 +00:00
|
|
|
|
|
|
|
// object resolver
|
|
|
|
uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
|
|
|
|
xValue, UNO_QUERY );
|
|
|
|
if ( xTmpObjectResolver.is() )
|
2006-06-20 10:39:29 +00:00
|
|
|
mxEmbeddedResolver = xTmpObjectResolver;
|
2001-10-16 11:32:03 +00:00
|
|
|
|
|
|
|
// document handler
|
|
|
|
uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler(
|
|
|
|
xValue, UNO_QUERY );
|
|
|
|
if( xTmpDocHandler.is() )
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler = xTmpDocHandler;
|
|
|
|
*pAny >>= mxExtHandler;
|
2001-01-12 15:16:13 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxNumberFormatsSupplier.is() && mpNumExport == NULL)
|
|
|
|
mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
2001-10-16 11:32:03 +00:00
|
|
|
|
|
|
|
// property set to transport data across
|
|
|
|
uno::Reference<beans::XPropertySet> xTmpPropertySet(
|
|
|
|
xValue, UNO_QUERY );
|
|
|
|
if( xTmpPropertySet.is() )
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo = xTmpPropertySet;
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
2004-07-13 07:06:44 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if( mxExportInfo.is() )
|
2004-07-13 07:06:44 +00:00
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->getPropertySetInfo();
|
2004-07-13 07:06:44 +00:00
|
|
|
OUString sPropName(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
|
|
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
|
|
|
|
aAny >>= msOrigFileName;
|
|
|
|
mpImpl->msPackageURI = msOrigFileName;
|
2004-07-13 07:06:44 +00:00
|
|
|
}
|
|
|
|
OUString sRelPath;
|
|
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
|
|
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
|
2004-07-13 07:06:44 +00:00
|
|
|
aAny >>= sRelPath;
|
|
|
|
}
|
|
|
|
OUString sName;
|
|
|
|
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
|
|
|
|
if( xPropertySetInfo->hasPropertyByName(sPropName) )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
|
2004-07-13 07:06:44 +00:00
|
|
|
aAny >>= sName;
|
|
|
|
}
|
2006-06-20 10:39:29 +00:00
|
|
|
if( msOrigFileName.getLength() && sName.getLength() )
|
2004-07-13 07:06:44 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
INetURLObject aBaseURL( msOrigFileName );
|
2004-07-13 07:06:44 +00:00
|
|
|
if( sRelPath.getLength() )
|
|
|
|
aBaseURL.insertName( sRelPath );
|
|
|
|
aBaseURL.insertName( sName );
|
2006-06-20 10:39:29 +00:00
|
|
|
msOrigFileName = aBaseURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
|
2004-07-13 07:06:44 +00:00
|
|
|
}
|
2006-10-13 11:15:34 +00:00
|
|
|
|
|
|
|
// --> OD 2006-09-26 #i69627#
|
|
|
|
OUString sOutlineStyleAsNormalListStyle(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("OutlineStyleAsNormalListStyle") );
|
|
|
|
if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) )
|
|
|
|
{
|
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle );
|
|
|
|
aAny >>= (mpImpl->mbOutlineStyleAsNormalListStyle);
|
|
|
|
}
|
|
|
|
// <--
|
2008-03-12 09:29:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
OUString sTargetStorage( RTL_CONSTASCII_USTRINGPARAM("TargetStorage") );
|
|
|
|
if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) )
|
|
|
|
mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage;
|
2004-07-13 07:06:44 +00:00
|
|
|
}
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XFilter
|
|
|
|
sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor ) throw(uno::RuntimeException)
|
|
|
|
{
|
2001-08-03 15:24:00 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogContext, "xmloff", LOGFILE_AUTHOR,
|
|
|
|
"SvXMLExport::filter" );
|
2001-07-26 13:55:49 +00:00
|
|
|
|
2001-07-26 10:32:47 +00:00
|
|
|
// check for xHandler first... should have been supplied in initialize
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !mxHandler.is() )
|
2001-07-26 10:32:47 +00:00
|
|
|
return sal_False;
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
try
|
|
|
|
{
|
2004-07-13 07:06:44 +00:00
|
|
|
const sal_uInt32 nTest =
|
|
|
|
EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS;
|
2006-06-20 10:39:29 +00:00
|
|
|
if( (mnExportFlags & nTest) == nTest && !msOrigFileName.getLength() )
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
2004-07-13 07:06:44 +00:00
|
|
|
// evaluate descriptor only for flat files and if a base URI
|
|
|
|
// has not been provided already
|
|
|
|
const sal_Int32 nPropCount = aDescriptor.getLength();
|
|
|
|
const beans::PropertyValue* pProps = aDescriptor.getConstArray();
|
2001-01-12 15:16:13 +00:00
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
|
2002-11-11 13:32:05 +00:00
|
|
|
{
|
2004-07-13 07:06:44 +00:00
|
|
|
const OUString& rPropName = pProps->Name;
|
|
|
|
const Any& rValue = pProps->Value;
|
|
|
|
|
|
|
|
if( rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FileName" ) ) )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !(rValue >>= msOrigFileName ) )
|
2004-07-13 07:06:44 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
else if (rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterName" ) ) )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !(rValue >>= msFilterName ) )
|
2004-07-13 07:06:44 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
2002-11-11 13:32:05 +00:00
|
|
|
}
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
2001-07-26 13:55:49 +00:00
|
|
|
#ifdef TIMELOG
|
2004-04-27 14:58:12 +00:00
|
|
|
if (GetModel().is())
|
|
|
|
{
|
|
|
|
// print a trace message with the URL
|
|
|
|
ByteString aUrl( (String) GetModel()->getURL(),
|
|
|
|
RTL_TEXTENCODING_ASCII_US );
|
|
|
|
RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "%s", aUrl.GetBuffer() );
|
|
|
|
|
|
|
|
// we also want a trace message with the document class
|
|
|
|
ByteString aClass( (String)GetXMLToken(meClass),
|
|
|
|
RTL_TEXTENCODING_ASCII_US );
|
|
|
|
RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "class=\"%s\"",
|
|
|
|
aClass.GetBuffer() );
|
|
|
|
}
|
2001-07-26 13:55:49 +00:00
|
|
|
#endif
|
2001-08-03 15:24:00 +00:00
|
|
|
|
2001-06-18 14:08:14 +00:00
|
|
|
exportDoc( meClass );
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception e )
|
|
|
|
{
|
2001-05-07 05:03:01 +00:00
|
|
|
// We must catch exceptions, because according to the
|
|
|
|
// API definition export must not throw one!
|
2001-09-25 12:08:43 +00:00
|
|
|
Sequence<OUString> aSeq(0);
|
|
|
|
SetError( XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API,
|
|
|
|
aSeq, e.Message, NULL );
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
2001-09-25 12:08:43 +00:00
|
|
|
// return true only if no error occured
|
|
|
|
return (GetErrorFlags() & (ERROR_DO_NOTHING|ERROR_ERROR_OCCURED)) == 0;
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLExport::cancel() throw(uno::RuntimeException)
|
|
|
|
{
|
2001-09-18 15:28:34 +00:00
|
|
|
// stop export
|
|
|
|
Sequence<OUString> aEmptySeq;
|
|
|
|
SetError(XMLERROR_CANCEL|XMLERROR_FLAG_SEVERE, aEmptySeq);
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 13:32:05 +00:00
|
|
|
::rtl::OUString SAL_CALL SvXMLExport::getName( )
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
return msFilterName;
|
2002-11-11 13:32:05 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SAL_CALL SvXMLExport::setName( const ::rtl::OUString& )
|
2002-11-11 13:32:05 +00:00
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// do nothing, because it is not possible to set the FilterName
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-12 15:16:13 +00:00
|
|
|
// XServiceInfo
|
|
|
|
OUString SAL_CALL SvXMLExport::getImplementationName( ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
2001-09-13 13:55:31 +00:00
|
|
|
sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName ) throw(uno::RuntimeException)
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
2001-09-13 13:55:31 +00:00
|
|
|
return
|
|
|
|
rServiceName.equalsAsciiL(
|
|
|
|
"com.sun.star.document.ExportFilter",
|
|
|
|
sizeof("com.sun.star.document.ExportFilter")-1 ) ||
|
|
|
|
rServiceName.equalsAsciiL(
|
|
|
|
"com.sun.star.xml.XMLExportFilter",
|
|
|
|
sizeof("com.sun.star.xml.XMLExportFilter")-1);
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
2001-09-13 13:55:31 +00:00
|
|
|
uno::Sequence<OUString> aSeq(2);
|
|
|
|
aSeq[0] = OUString(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
|
|
|
|
aSeq[1] = OUString(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter"));
|
2001-01-12 15:16:13 +00:00
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey,
|
|
|
|
const sal_Char *pName,
|
|
|
|
const sal_Char *pValue )
|
|
|
|
{
|
|
|
|
OUString sName( OUString::createFromAscii( pName ) );
|
|
|
|
OUString sValue( OUString::createFromAscii( pValue ) );
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute( mpNamespaceMap->GetQNameByKey( nPrefixKey,
|
2000-09-18 23:31:44 +00:00
|
|
|
sName ),
|
2003-03-27 17:21:03 +00:00
|
|
|
sValue );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
|
|
|
OUString sName( OUString::createFromAscii( pName ) );
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute( mpNamespaceMap->GetQNameByKey( nPrefixKey,
|
2000-09-18 23:31:44 +00:00
|
|
|
sName ),
|
2003-03-27 17:21:03 +00:00
|
|
|
rValue );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute( mpNamespaceMap->GetQNameByKey( nPrefixKey, rName ),
|
2003-03-27 17:21:03 +00:00
|
|
|
rValue );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 14:21:01 +00:00
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
|
|
|
|
enum XMLTokenEnum eName,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute(
|
|
|
|
mpNamespaceMap->GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
|
2003-03-27 17:21:03 +00:00
|
|
|
rValue );
|
2001-05-16 14:21:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
|
|
|
|
enum XMLTokenEnum eName,
|
|
|
|
enum XMLTokenEnum eValue)
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute(
|
|
|
|
mpNamespaceMap->GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
|
2003-03-27 17:21:03 +00:00
|
|
|
GetXMLToken(eValue) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( const ::rtl::OUString& rQName,
|
|
|
|
const ::rtl::OUString& rValue )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute(
|
2003-03-27 17:21:03 +00:00
|
|
|
rQName,
|
|
|
|
rValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( const ::rtl::OUString& rQName,
|
|
|
|
enum ::xmloff::token::XMLTokenEnum eValue )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute(
|
2003-03-27 17:21:03 +00:00
|
|
|
rQName,
|
|
|
|
GetXMLToken(eValue) );
|
2001-05-16 14:21:01 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
|
|
|
|
{
|
|
|
|
if( xAttrList.is())
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AppendAttributeList( xAttrList );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::ClearAttrList()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->Clear();
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
void SvXMLExport::CheckAttrList()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
DBG_ASSERT( !mpAttrList->getLength(),
|
2000-09-18 23:31:44 +00:00
|
|
|
"XMLExport::CheckAttrList: list is not empty" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void SvXMLExport::ImplExportMeta()
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
2008-02-26 12:32:31 +00:00
|
|
|
_ExportMeta();
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2001-03-05 08:28:51 +00:00
|
|
|
void SvXMLExport::ImplExportSettings()
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
2007-04-18 06:48:32 +00:00
|
|
|
uno::Sequence<beans::PropertyValue> aViewProps;
|
|
|
|
GetViewSettingsAndViews(aViewProps);
|
|
|
|
|
|
|
|
uno::Sequence<beans::PropertyValue> aConfigProps;
|
|
|
|
GetConfigurationSettings(aConfigProps);
|
|
|
|
|
2001-03-05 08:28:51 +00:00
|
|
|
{
|
2007-04-18 06:48:32 +00:00
|
|
|
SvXMLElementExport aElem( *this,
|
|
|
|
aViewProps.getLength() || aConfigProps.getLength(),
|
|
|
|
XML_NAMESPACE_OFFICE, XML_SETTINGS,
|
2001-03-11 14:52:23 +00:00
|
|
|
sal_True, sal_True );
|
|
|
|
XMLSettingsExportHelper aSettingsExportHelper(*this);
|
2007-04-18 06:48:32 +00:00
|
|
|
if( aViewProps.getLength() )
|
|
|
|
_ExportViewSettings2(aSettingsExportHelper, aViewProps );
|
|
|
|
if( aConfigProps.getLength() )
|
|
|
|
_ExportConfigurationSettings2(aSettingsExportHelper, aConfigProps );
|
2001-03-05 08:28:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::ImplExportStyles( sal_Bool )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
// AddAttribute( XML_NAMESPACE_NONE, XML_ID, XML_STYLES_ID );
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <style:styles>
|
2001-06-29 20:07:26 +00:00
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_STYLES,
|
2000-09-18 23:31:44 +00:00
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
_ExportStyles( sal_False );
|
|
|
|
}
|
2005-01-05 10:36:05 +00:00
|
|
|
|
|
|
|
// transfer style names (+ families) TO other components (if appropriate)
|
|
|
|
OUString sStyleNames( RTL_CONSTASCII_USTRINGPARAM("StyleNames") );
|
|
|
|
OUString sStyleFamilies( RTL_CONSTASCII_USTRINGPARAM("StyleFamilies") );
|
|
|
|
if( ( ( mnExportFlags & EXPORT_CONTENT ) == 0 )
|
2006-06-20 10:39:29 +00:00
|
|
|
&& mxExportInfo.is()
|
|
|
|
&& mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
|
|
|
|
&& mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
|
2005-01-05 10:36:05 +00:00
|
|
|
{
|
|
|
|
Sequence<sal_Int32> aStyleFamilies;
|
|
|
|
Sequence<OUString> aStyleNames;
|
|
|
|
mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) );
|
|
|
|
mxExportInfo->setPropertyValue( sStyleFamilies,
|
2005-01-05 10:36:05 +00:00
|
|
|
makeAny( aStyleFamilies ) );
|
|
|
|
}
|
2001-03-01 15:31:32 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::ImplExportAutoStyles( sal_Bool )
|
2001-03-01 15:31:32 +00:00
|
|
|
{
|
2005-01-05 10:36:05 +00:00
|
|
|
// transfer style names (+ families) FROM other components (if appropriate)
|
|
|
|
OUString sStyleNames( RTL_CONSTASCII_USTRINGPARAM("StyleNames") );
|
|
|
|
OUString sStyleFamilies( RTL_CONSTASCII_USTRINGPARAM("StyleFamilies") );
|
|
|
|
if( ( ( mnExportFlags & EXPORT_STYLES ) == 0 )
|
2006-06-20 10:39:29 +00:00
|
|
|
&& mxExportInfo.is()
|
|
|
|
&& mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
|
|
|
|
&& mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
|
2005-01-05 10:36:05 +00:00
|
|
|
{
|
|
|
|
Sequence<sal_Int32> aStyleFamilies;
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies;
|
2005-01-05 10:36:05 +00:00
|
|
|
Sequence<OUString> aStyleNames;
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames;
|
2005-01-05 10:36:05 +00:00
|
|
|
mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames );
|
|
|
|
}
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
// AddAttributeASCII( XML_NAMESPACE_NONE, XML_ID, XML_AUTO_STYLES_ID );
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <style:automatic-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_AUTOMATIC_STYLES, sal_True, sal_True );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-06-29 20:07:26 +00:00
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, XML_STYLES_HREF );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_ROLE,
|
2000-09-18 23:31:44 +00:00
|
|
|
pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE,
|
2001-06-29 20:07:26 +00:00
|
|
|
GetXMLToken(XML_STYLESHEET)) );
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <style:use-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_USE_STYLES, sal_True, sal_True );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
_ExportAutoStyles();
|
|
|
|
}
|
2001-03-01 15:31:32 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::ImplExportMasterStyles( sal_Bool )
|
2001-03-01 15:31:32 +00:00
|
|
|
{
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <style:master-styles>
|
2001-06-29 20:07:26 +00:00
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_MASTER_STYLES,
|
2000-09-18 23:31:44 +00:00
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
_ExportMasterStyles();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2001-06-29 20:07:26 +00:00
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, XML_AUTO_STYLES_HREF );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, XML_ROLE,
|
2000-09-18 23:31:44 +00:00
|
|
|
pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE,
|
2001-06-29 20:07:26 +00:00
|
|
|
GetXMLToken(XML_STYLESHEET) ) );
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <style:use-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
|
2001-06-29 20:07:26 +00:00
|
|
|
XML_USE_STYLES, sal_True, sal_True );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::ImplExportContent()
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
2000-12-20 12:17:23 +00:00
|
|
|
CheckAttrList();
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
SvXMLElementExport aElemrnt( *this, XML_NAMESPACE_OFFICE, XML_BODY,
|
2000-09-18 23:31:44 +00:00
|
|
|
sal_True, sal_True );
|
2004-07-13 07:06:44 +00:00
|
|
|
{
|
|
|
|
XMLTokenEnum eClass = meClass;
|
|
|
|
if( XML_TEXT_GLOBAL == eClass )
|
|
|
|
{
|
|
|
|
AddAttribute( XML_NAMESPACE_TEXT, XML_GLOBAL,
|
|
|
|
GetXMLToken( XML_TRUE ) );
|
|
|
|
eClass = XML_TEXT;
|
|
|
|
}
|
2004-08-20 07:13:47 +00:00
|
|
|
// <office:body ...>
|
|
|
|
SetBodyAttributes();
|
2004-07-13 07:06:44 +00:00
|
|
|
SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID,
|
|
|
|
XML_NAMESPACE_OFFICE, eClass,
|
|
|
|
sal_True, sal_True );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
_ExportContent();
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-23 14:48:23 +00:00
|
|
|
void SvXMLExport::SetBodyAttributes()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-06-18 14:08:14 +00:00
|
|
|
sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
2002-06-04 07:27:50 +00:00
|
|
|
bool bOwnGraphicResolver = false;
|
|
|
|
bool bOwnEmbeddedResolver = false;
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
|
2002-06-04 07:27:50 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
|
2002-06-04 07:27:50 +00:00
|
|
|
if( xFactory.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !mxGraphicResolver.is() )
|
2002-06-04 07:27:50 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
|
2002-06-04 07:27:50 +00:00
|
|
|
xFactory->createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"com.sun.star.document.ExportGraphicObjectResolver"))));
|
2006-06-20 10:39:29 +00:00
|
|
|
bOwnGraphicResolver = mxGraphicResolver.is();
|
2002-06-04 07:27:50 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !mxEmbeddedResolver.is() )
|
2002-06-04 07:27:50 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
|
2002-06-04 07:27:50 +00:00
|
|
|
xFactory->createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"com.sun.star.document.ExportEmbeddedObjectResolver"))));
|
2006-06-20 10:39:29 +00:00
|
|
|
bOwnEmbeddedResolver = mxEmbeddedResolver.is();
|
2002-06-04 07:27:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-13 07:06:44 +00:00
|
|
|
if( (getExportFlags() & EXPORT_OASIS) == 0 )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xFactory = getServiceFactory();
|
|
|
|
if( xFactory.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::comphelper::PropertyMapEntry aInfoMap[] =
|
|
|
|
{
|
|
|
|
{ "Class", sizeof("Class")-1, 0,
|
|
|
|
&::getCppuType((::rtl::OUString*)0),
|
|
|
|
PropertyAttribute::MAYBEVOID, 0},
|
|
|
|
{ NULL, 0, 0, NULL, 0, 0 }
|
|
|
|
};
|
|
|
|
Reference< XPropertySet > xConvPropSet(
|
|
|
|
::comphelper::GenericPropertySet_CreateInstance(
|
|
|
|
new ::comphelper::PropertySetInfo( aInfoMap ) ) );
|
|
|
|
|
|
|
|
Any aAny;
|
|
|
|
aAny <<= GetXMLToken( eClass );
|
|
|
|
xConvPropSet->setPropertyValue(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM("Class")), aAny );
|
|
|
|
|
|
|
|
Reference< XPropertySet > xPropSet =
|
2006-06-20 10:39:29 +00:00
|
|
|
mxExportInfo.is()
|
2007-05-22 15:09:34 +00:00
|
|
|
? PropertySetMerger_CreateInstance( mxExportInfo,
|
|
|
|
xConvPropSet )
|
|
|
|
: xConvPropSet;
|
2004-07-13 07:06:44 +00:00
|
|
|
|
2004-11-17 09:32:28 +00:00
|
|
|
Sequence<Any> aArgs( 3 );
|
2006-06-20 10:39:29 +00:00
|
|
|
aArgs[0] <<= mxHandler;
|
2004-07-13 07:06:44 +00:00
|
|
|
aArgs[1] <<= xPropSet;
|
2006-06-20 10:39:29 +00:00
|
|
|
aArgs[2] <<= mxModel;
|
2004-07-13 07:06:44 +00:00
|
|
|
|
|
|
|
// get filter component
|
|
|
|
Reference< xml::sax::XDocumentHandler > xTmpDocHandler(
|
|
|
|
xFactory->createInstanceWithArguments(
|
|
|
|
OUString::createFromAscii("com.sun.star.comp.Oasis2OOoTransformer"),
|
|
|
|
aArgs), UNO_QUERY);
|
|
|
|
OSL_ENSURE( xTmpDocHandler.is(),
|
|
|
|
"can't instantiate OASIS transformer component" );
|
|
|
|
if( xTmpDocHandler.is() )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler = xTmpDocHandler;
|
|
|
|
mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
|
2004-07-13 07:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-04 07:27:50 +00:00
|
|
|
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler->startDocument();
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
// <?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
// xHandler->processingInstruction( S2U( sXML_xml ), S2U( sXML_xml_pi ) );
|
|
|
|
|
|
|
|
// <office:document ...>
|
|
|
|
CheckAttrList();
|
|
|
|
|
2001-03-19 15:30:27 +00:00
|
|
|
// namespace attributes
|
|
|
|
// ( The namespace decls should be first attributes in the element;
|
|
|
|
// some faulty XML parsers (JAXP1.1) have a problem with this,
|
|
|
|
// also it's more elegant )
|
2006-06-20 10:39:29 +00:00
|
|
|
sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
|
2000-09-18 23:31:44 +00:00
|
|
|
while( USHRT_MAX != nPos )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
|
|
|
|
mpNamespaceMap->GetNameByKey( nPos ) );
|
|
|
|
nPos = mpNamespaceMap->GetNextKey( nPos );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
|
2001-03-19 15:30:27 +00:00
|
|
|
|
|
|
|
// office:version = ...
|
2006-06-20 10:39:29 +00:00
|
|
|
if( !mbExtended )
|
2001-06-29 20:07:26 +00:00
|
|
|
AddAttribute( XML_NAMESPACE_OFFICE, XML_VERSION,
|
2007-11-01 12:39:22 +00:00
|
|
|
OUString::createFromAscii(sXML_1_1) );
|
2001-03-19 15:30:27 +00:00
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
|
2001-03-23 05:56:35 +00:00
|
|
|
const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS);
|
2001-03-04 15:01:11 +00:00
|
|
|
if( EXPORT_META == nExportMode )
|
|
|
|
{
|
|
|
|
// export only meta
|
2001-06-29 20:07:26 +00:00
|
|
|
eRootService = XML_DOCUMENT_META;
|
2001-03-04 15:01:11 +00:00
|
|
|
}
|
2001-03-05 08:28:51 +00:00
|
|
|
else if ( EXPORT_SETTINGS == nExportMode )
|
|
|
|
{
|
|
|
|
// export only settings
|
2001-06-29 20:07:26 +00:00
|
|
|
eRootService = XML_DOCUMENT_SETTINGS;
|
2001-03-05 08:28:51 +00:00
|
|
|
}
|
2001-03-04 15:01:11 +00:00
|
|
|
else if( EXPORT_STYLES == nExportMode )
|
|
|
|
{
|
|
|
|
// export only styles
|
2001-06-29 20:07:26 +00:00
|
|
|
eRootService = XML_DOCUMENT_STYLES;
|
2001-03-04 15:01:11 +00:00
|
|
|
}
|
|
|
|
else if( EXPORT_CONTENT == nExportMode )
|
|
|
|
{
|
|
|
|
// export only content
|
2001-06-29 20:07:26 +00:00
|
|
|
eRootService = XML_DOCUMENT_CONTENT;
|
2001-03-04 15:01:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// the god'ol one4all element
|
2001-06-29 20:07:26 +00:00
|
|
|
eRootService = XML_DOCUMENT;
|
2004-07-13 07:06:44 +00:00
|
|
|
// office:mimetype = ... (only for stream containing the content)
|
|
|
|
if( eClass != XML_TOKEN_INVALID )
|
|
|
|
{
|
2007-08-03 09:21:53 +00:00
|
|
|
OUString aTmp( RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.") );
|
2004-07-13 07:06:44 +00:00
|
|
|
aTmp += GetXMLToken( eClass );
|
|
|
|
AddAttribute( XML_NAMESPACE_OFFICE, XML_MIMETYPE, aTmp );
|
|
|
|
}
|
2001-03-04 15:01:11 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
// if( (getExportFlags() & EXPORT_NODOCTYPE) == 0 &&
|
|
|
|
// xExtHandler.is() )
|
|
|
|
// {
|
|
|
|
// OUStringBuffer aDocType(
|
|
|
|
// GetXMLToken(XML_XML_DOCTYPE_PREFIX).getLength() +
|
|
|
|
// GetXMLToken(XML_XML_DOCTYPE_SUFFIX).getLength() + 30 );
|
|
|
|
//
|
|
|
|
// aDocType.append( GetXMLToken(XML_XML_DOCTYPE_PREFIX) );
|
|
|
|
// aDocType.append( GetNamespaceMap().GetQNameByKey(
|
|
|
|
// XML_NAMESPACE_OFFICE, GetXMLToken(eRootService) ) );
|
|
|
|
// aDocType.append( GetXMLToken(XML_XML_DOCTYPE_SUFFIX) );
|
|
|
|
// xExtHandler->unknown( aDocType.makeStringAndClear() );
|
|
|
|
// }
|
2001-04-24 14:34:42 +00:00
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, sal_True, sal_True );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
// meta information
|
2001-03-01 15:31:32 +00:00
|
|
|
if( mnExportFlags & EXPORT_META )
|
|
|
|
ImplExportMeta();
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-03-05 08:28:51 +00:00
|
|
|
// settings
|
2001-03-01 15:31:32 +00:00
|
|
|
if( mnExportFlags & EXPORT_SETTINGS )
|
2001-03-05 08:28:51 +00:00
|
|
|
ImplExportSettings();
|
2001-02-14 05:24:00 +00:00
|
|
|
|
2000-12-07 11:09:22 +00:00
|
|
|
// scripts
|
2001-03-01 15:31:32 +00:00
|
|
|
if( mnExportFlags & EXPORT_SCRIPTS )
|
|
|
|
_ExportScripts();
|
|
|
|
|
|
|
|
// font declerations
|
|
|
|
if( mnExportFlags & EXPORT_FONTDECLS )
|
|
|
|
_ExportFontDecls();
|
2000-12-07 11:09:22 +00:00
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
// styles
|
2001-03-01 15:31:32 +00:00
|
|
|
if( mnExportFlags & EXPORT_STYLES )
|
|
|
|
ImplExportStyles( sal_False );
|
|
|
|
|
|
|
|
// autostyles
|
|
|
|
if( mnExportFlags & EXPORT_AUTOSTYLES )
|
|
|
|
ImplExportAutoStyles( sal_False );
|
|
|
|
|
|
|
|
// masterstyles
|
|
|
|
if( mnExportFlags & EXPORT_MASTERSTYLES )
|
|
|
|
ImplExportMasterStyles( sal_False );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
// contnt
|
2001-03-01 15:31:32 +00:00
|
|
|
if( mnExportFlags & EXPORT_CONTENT )
|
|
|
|
ImplExportContent();
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler->endDocument();
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2002-06-04 07:27:50 +00:00
|
|
|
if( bOwnGraphicResolver )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< XComponent > xComp( mxGraphicResolver, UNO_QUERY );
|
2002-06-04 07:27:50 +00:00
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bOwnEmbeddedResolver )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
|
2002-06-04 07:27:50 +00:00
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-26 12:32:31 +00:00
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::_ExportMeta()
|
|
|
|
{
|
2008-02-26 12:32:31 +00:00
|
|
|
OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
|
|
|
|
Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
|
|
|
|
UNO_QUERY);
|
|
|
|
if (xDocPropsSupplier.is()) {
|
|
|
|
Reference<XDocumentProperties> xDocProps(
|
|
|
|
xDocPropsSupplier->getDocumentProperties());
|
|
|
|
if (!xDocProps.is()) throw;
|
|
|
|
// update generator here
|
|
|
|
xDocProps->setGenerator(generator);
|
|
|
|
SvXMLMetaExport * pMeta = new SvXMLMetaExport(*this, xDocProps);
|
|
|
|
uno::Reference<xml::sax::XDocumentHandler> xMeta(pMeta);
|
|
|
|
pMeta->Export();
|
|
|
|
} else {
|
|
|
|
// office:meta
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_META,
|
|
|
|
sal_True, sal_True );
|
|
|
|
{
|
|
|
|
// BM: #i60323# export generator even if xInfoProp is empty (which is the
|
|
|
|
// case for charts). The generator does not depend on xInfoProp
|
|
|
|
SvXMLElementExport anElem( *this, XML_NAMESPACE_META, XML_GENERATOR,
|
|
|
|
sal_True, sal_True );
|
|
|
|
Characters(generator);
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 06:48:32 +00:00
|
|
|
void SvXMLExport::_ExportViewSettings(const XMLSettingsExportHelper& rSettingsExportHelper )
|
|
|
|
{
|
|
|
|
uno::Sequence<beans::PropertyValue> aViewProps;
|
|
|
|
GetViewSettingsAndViews(aViewProps);
|
|
|
|
if( aViewProps.getLength() )
|
|
|
|
_ExportViewSettings2(rSettingsExportHelper, aViewProps );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::_ExportViewSettings2(const XMLSettingsExportHelper& rSettingsExportHelper, uno::Sequence<beans::PropertyValue>& rProps )
|
2001-02-14 05:24:00 +00:00
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
OUString sViewSettings(GetXMLToken(XML_VIEW_SETTINGS));
|
2007-04-18 06:48:32 +00:00
|
|
|
rSettingsExportHelper.exportSettings(rProps, sViewSettings);
|
2001-02-14 05:24:00 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 06:48:32 +00:00
|
|
|
void SvXMLExport::_ExportConfigurationSettings(const XMLSettingsExportHelper& rSettingsExportHelper )
|
|
|
|
{
|
|
|
|
uno::Sequence<beans::PropertyValue> aConfigProps;
|
|
|
|
GetConfigurationSettings(aConfigProps);
|
|
|
|
if( aConfigProps.getLength() )
|
|
|
|
_ExportConfigurationSettings2(rSettingsExportHelper, aConfigProps );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::_ExportConfigurationSettings2(const XMLSettingsExportHelper& rSettingsExportHelper, uno::Sequence<beans::PropertyValue>& rProps )
|
2001-03-05 08:28:51 +00:00
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
OUString sConfigurationSettings(GetXMLToken(XML_CONFIGURATION_SETTINGS));
|
2007-04-18 06:48:32 +00:00
|
|
|
rSettingsExportHelper.exportSettings(rProps, sConfigurationSettings);
|
2001-03-05 08:28:51 +00:00
|
|
|
}
|
|
|
|
|
2000-11-20 10:09:30 +00:00
|
|
|
void SvXMLExport::_ExportScripts()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, sal_True, sal_True );
|
2004-11-09 12:06:48 +00:00
|
|
|
|
|
|
|
// export Basic macros (only for FlatXML)
|
|
|
|
if ( mnExportFlags & EXPORT_EMBEDDED )
|
|
|
|
{
|
|
|
|
::rtl::OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) );
|
|
|
|
aValue += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":Basic" ) );
|
|
|
|
AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, aValue );
|
|
|
|
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, sal_True, sal_True );
|
2004-11-09 11:14:51 +00:00
|
|
|
|
2004-11-09 12:06:48 +00:00
|
|
|
// initialize Basic
|
2006-06-20 10:39:29 +00:00
|
|
|
if ( mxModel.is() )
|
2004-11-09 12:06:48 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
|
2004-11-09 12:06:48 +00:00
|
|
|
if ( xPSet.is() )
|
|
|
|
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) );
|
|
|
|
}
|
2000-11-28 10:33:02 +00:00
|
|
|
|
2004-11-09 12:06:48 +00:00
|
|
|
Reference< document::XExporter > xExporter;
|
|
|
|
Reference< lang::XMultiServiceFactory > xMSF( getServiceFactory() );
|
|
|
|
if ( xMSF.is() )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
|
2004-11-09 12:06:48 +00:00
|
|
|
Sequence < Any > aArgs( 1 );
|
|
|
|
aArgs[0] <<= xHdl;
|
|
|
|
xExporter.set( xMSF->createInstanceWithArguments(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicExporter" ) ), aArgs ),
|
|
|
|
UNO_QUERY );
|
|
|
|
}
|
|
|
|
|
|
|
|
OSL_ENSURE( xExporter.is(),
|
|
|
|
"SvXMLExport::_ExportScripts: can't instantiate export filter component for Basic macros" );
|
|
|
|
|
|
|
|
if ( xExporter.is() )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< XComponent > xComp( mxModel, UNO_QUERY );
|
2004-11-09 12:06:48 +00:00
|
|
|
xExporter->setSourceDocument( xComp );
|
|
|
|
Reference< XFilter > xFilter( xExporter, UNO_QUERY );
|
|
|
|
if ( xFilter.is() )
|
|
|
|
{
|
|
|
|
Sequence < PropertyValue > aMediaDesc( 0 );
|
|
|
|
xFilter->filter( aMediaDesc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-21 19:30:19 +00:00
|
|
|
|
|
|
|
// export document events
|
2004-11-09 12:06:48 +00:00
|
|
|
Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
|
|
|
|
GetEventExport().Export( xEvents, sal_True );
|
2000-11-20 10:09:30 +00:00
|
|
|
}
|
|
|
|
|
2000-11-13 07:44:24 +00:00
|
|
|
void SvXMLExport::_ExportFontDecls()
|
|
|
|
{
|
|
|
|
if( mxFontAutoStylePool.is() )
|
|
|
|
mxFontAutoStylePool->exportXML();
|
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::_ExportStyles( sal_Bool )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
|
|
|
|
if( xFact.is())
|
|
|
|
{
|
|
|
|
// export (fill-)gradient-styles
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable") ) ), uno::UNO_QUERY );
|
|
|
|
if( xGradient.is() )
|
|
|
|
{
|
2001-10-19 17:43:58 +00:00
|
|
|
XMLGradientStyleExport aGradientStyle( *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
if( xGradient->hasElements() )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
|
|
|
|
sal_Int32 nCount = aNamesSeq.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const OUString& rStrName = aNamesSeq[ i ];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = xGradient->getByName( rStrName );
|
|
|
|
|
|
|
|
aGradientStyle.exportXML( rStrName, aValue );
|
|
|
|
}
|
|
|
|
catch( container::NoSuchElementException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// export (fill-)hatch-styles
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xHatch( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable") ) ), uno::UNO_QUERY );
|
|
|
|
if( xHatch.is() )
|
|
|
|
{
|
2001-10-19 17:43:58 +00:00
|
|
|
XMLHatchStyleExport aHatchStyle( *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
if( xHatch->hasElements() )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
|
|
|
|
sal_Int32 nCount = aNamesSeq.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const OUString& rStrName = aNamesSeq[ i ];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = xHatch->getByName( rStrName );
|
|
|
|
|
|
|
|
aHatchStyle.exportXML( rStrName, aValue );
|
|
|
|
}
|
|
|
|
catch( container::NoSuchElementException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// export (fill-)bitmap-styles
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable") ) ), uno::UNO_QUERY );
|
|
|
|
if( xBitmap.is() )
|
|
|
|
{
|
2000-12-01 10:16:41 +00:00
|
|
|
XMLImageStyle aImageStyle;
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
if( xBitmap->hasElements() )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
|
|
|
|
sal_Int32 nCount = aNamesSeq.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const OUString& rStrName = aNamesSeq[ i ];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = xBitmap->getByName( rStrName );
|
|
|
|
|
2000-12-01 10:16:41 +00:00
|
|
|
aImageStyle.exportXML( rStrName, aValue, *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
catch( container::NoSuchElementException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// export transparency-gradient -styles
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ), uno::UNO_QUERY );
|
|
|
|
if( xTransGradient.is() )
|
|
|
|
{
|
2001-10-19 17:43:58 +00:00
|
|
|
XMLTransGradientStyleExport aTransGradientstyle( *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
if( xTransGradient->hasElements() )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
|
|
|
|
sal_Int32 nCount = aNamesSeq.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const OUString& rStrName = aNamesSeq[ i ];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = xTransGradient->getByName( rStrName );
|
|
|
|
|
|
|
|
aTransGradientstyle.exportXML( rStrName, aValue );
|
|
|
|
}
|
|
|
|
catch( container::NoSuchElementException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// export marker-styles
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xMarker( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable") ) ), uno::UNO_QUERY );
|
|
|
|
if( xMarker.is() )
|
|
|
|
{
|
2001-10-19 17:43:58 +00:00
|
|
|
XMLMarkerStyleExport aMarkerStyle( *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
if( xMarker->hasElements() )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
|
|
|
|
sal_Int32 nCount = aNamesSeq.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const OUString& rStrName = aNamesSeq[ i ];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = xMarker->getByName( rStrName );
|
|
|
|
|
|
|
|
aMarkerStyle.exportXML( rStrName, aValue );
|
|
|
|
}
|
|
|
|
catch( container::NoSuchElementException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
|
|
|
|
// export dash-styles
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< container::XNameAccess > xDashes( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable") ) ), uno::UNO_QUERY );
|
|
|
|
if( xDashes.is() )
|
|
|
|
{
|
2001-10-19 17:43:58 +00:00
|
|
|
XMLDashStyleExport aDashStyle( *this );
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
if( xDashes->hasElements() )
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
|
|
|
|
sal_Int32 nCount = aNamesSeq.getLength();
|
|
|
|
for( sal_Int32 i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
const OUString& rStrName = aNamesSeq[ i ];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aValue = xDashes->getByName( rStrName );
|
|
|
|
|
|
|
|
aDashStyle.exportXML( rStrName, aValue );
|
|
|
|
}
|
|
|
|
catch( container::NoSuchElementException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( lang::ServiceNotRegisteredException& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLTextParagraphExport* SvXMLExport::CreateTextParagraphExport()
|
|
|
|
{
|
|
|
|
return new XMLTextParagraphExport( *this, *(GetAutoStylePool().get()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLShapeExport* SvXMLExport::CreateShapeExport()
|
|
|
|
{
|
|
|
|
return new XMLShapeExport(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLAutoStylePoolP* SvXMLExport::CreateAutoStylePool()
|
|
|
|
{
|
2001-10-25 19:57:03 +00:00
|
|
|
return new SvXMLAutoStylePoolP(*this);
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2000-10-19 03:11:55 +00:00
|
|
|
XMLPageExport* SvXMLExport::CreatePageExport()
|
|
|
|
{
|
|
|
|
return new XMLPageExport( *this );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
SchXMLExportHelper* SvXMLExport::CreateChartExport()
|
|
|
|
{
|
|
|
|
return new SchXMLExportHelper(*this,*GetAutoStylePool().get());
|
|
|
|
}
|
|
|
|
|
2000-11-13 07:44:24 +00:00
|
|
|
XMLFontAutoStylePool* SvXMLExport::CreateFontAutoStylePool()
|
|
|
|
{
|
|
|
|
return new XMLFontAutoStylePool( *this );
|
|
|
|
}
|
|
|
|
|
2000-12-18 15:13:37 +00:00
|
|
|
xmloff::OFormLayerXMLExport* SvXMLExport::CreateFormExport()
|
2000-11-17 17:59:48 +00:00
|
|
|
{
|
|
|
|
return new xmloff::OFormLayerXMLExport(*this);
|
|
|
|
}
|
|
|
|
|
2007-04-18 06:48:32 +00:00
|
|
|
void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
|
|
|
|
{
|
|
|
|
GetViewSettings(rProps);
|
|
|
|
uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
|
|
|
|
if(xViewDataSupplier.is())
|
|
|
|
{
|
|
|
|
uno::Reference<container::XIndexAccess> xIndexAccess;
|
|
|
|
xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
|
|
|
|
xIndexAccess = xViewDataSupplier->getViewData();
|
|
|
|
sal_Bool bAdd = sal_False;
|
|
|
|
uno::Any aAny;
|
|
|
|
if(xIndexAccess.is() && xIndexAccess->hasElements() )
|
|
|
|
{
|
|
|
|
sal_Int32 nCount = xIndexAccess->getCount();
|
|
|
|
for (sal_Int32 i = 0; i < nCount; i++)
|
|
|
|
{
|
|
|
|
aAny = xIndexAccess->getByIndex(i);
|
|
|
|
uno::Sequence<beans::PropertyValue> aProps;
|
|
|
|
if( aAny >>= aProps )
|
|
|
|
{
|
|
|
|
if( aProps.getLength() > 0 )
|
|
|
|
{
|
|
|
|
bAdd = sal_True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bAdd )
|
|
|
|
{
|
|
|
|
sal_Int32 nOldLength(rProps.getLength());
|
|
|
|
rProps.realloc(nOldLength + 1);
|
|
|
|
beans::PropertyValue aProp;
|
|
|
|
aProp.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Views"));
|
|
|
|
aProp.Value <<= xIndexAccess;
|
|
|
|
rProps[nOldLength] = aProp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
|
2001-03-11 14:52:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
|
2001-03-11 14:52:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ )
|
2001-05-04 13:47:21 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if(mpNumExport)
|
|
|
|
mpNumExport->SetUsed(nNumberFormat);
|
2001-05-04 13:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::exportDataStyles()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if(mpNumExport)
|
|
|
|
mpNumExport->Export(sal_False);
|
2001-05-04 13:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::exportAutoDataStyles()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if(mpNumExport)
|
|
|
|
mpNumExport->Export(sal_True);
|
2001-05-28 14:16:04 +00:00
|
|
|
|
|
|
|
if (mxFormExport.is())
|
|
|
|
mxFormExport->exportAutoControlNumberStyles();
|
2001-05-04 13:47:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ ) const
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
OUString sTemp;
|
2006-06-20 10:39:29 +00:00
|
|
|
if(mpNumExport)
|
|
|
|
sTemp = mpNumExport->GetStyleName(nNumberFormat);
|
2000-09-18 23:31:44 +00:00
|
|
|
return sTemp;
|
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
|
2004-09-08 12:39:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-11-21 16:32:32 +00:00
|
|
|
sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
return ( mpNumExport != NULL )
|
|
|
|
? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
|
2002-11-21 16:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-29 13:32:08 +00:00
|
|
|
OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
|
|
|
|
{
|
|
|
|
OUString sRet( rGraphicObjectURL );
|
2006-06-20 10:39:29 +00:00
|
|
|
if( 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
|
|
|
|
msGraphicObjectProtocol.getLength() ) &&
|
|
|
|
mxGraphicResolver.is() )
|
2000-11-29 13:32:08 +00:00
|
|
|
{
|
2001-06-19 14:30:45 +00:00
|
|
|
if( (getExportFlags() & EXPORT_EMBEDDED) == 0 )
|
2006-06-20 10:39:29 +00:00
|
|
|
sRet = mxGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL );
|
2001-06-19 14:30:45 +00:00
|
|
|
else
|
|
|
|
sRet = OUString();
|
2000-11-29 13:32:08 +00:00
|
|
|
}
|
2000-11-29 14:57:15 +00:00
|
|
|
else
|
2004-07-13 07:06:44 +00:00
|
|
|
sRet = GetRelativeReference( sRet );
|
2000-11-29 13:32:08 +00:00
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2001-06-12 13:27:58 +00:00
|
|
|
sal_Bool SvXMLExport::AddEmbeddedGraphicObjectAsBase64( const OUString& rGraphicObjectURL )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
|
2001-06-19 14:30:45 +00:00
|
|
|
if( (getExportFlags() & EXPORT_EMBEDDED) != 0 &&
|
2006-06-20 10:39:29 +00:00
|
|
|
0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
|
|
|
|
msGraphicObjectProtocol.getLength() ) &&
|
|
|
|
mxGraphicResolver.is() )
|
2001-06-12 13:27:58 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference< XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
|
2001-06-12 13:27:58 +00:00
|
|
|
|
|
|
|
if( xStmResolver.is() )
|
|
|
|
{
|
|
|
|
Reference< XInputStream > xIn( xStmResolver->getInputStream( rGraphicObjectURL ) );
|
|
|
|
|
|
|
|
if( xIn.is() )
|
|
|
|
{
|
|
|
|
XMLBase64Export aBase64Exp( *this );
|
2001-06-19 14:30:45 +00:00
|
|
|
bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
|
2001-06-12 13:27:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2001-01-26 10:22:48 +00:00
|
|
|
OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
|
|
|
|
{
|
|
|
|
OUString sRet;
|
2006-06-20 10:39:29 +00:00
|
|
|
if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
|
|
|
|
msEmbeddedObjectProtocol.getLength() ) ||
|
|
|
|
0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
|
|
|
|
msGraphicObjectProtocol.getLength() ) ) &&
|
|
|
|
mxEmbeddedResolver.is() )
|
2001-01-26 10:22:48 +00:00
|
|
|
{
|
|
|
|
sRet =
|
2006-06-20 10:39:29 +00:00
|
|
|
mxEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL );
|
2001-01-26 10:22:48 +00:00
|
|
|
}
|
2005-03-15 10:18:34 +00:00
|
|
|
else
|
|
|
|
sRet = GetRelativeReference( rEmbeddedObjectURL );
|
2001-01-26 10:22:48 +00:00
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2001-05-18 12:58:34 +00:00
|
|
|
sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
2006-06-20 10:39:29 +00:00
|
|
|
if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
|
|
|
|
msEmbeddedObjectProtocol.getLength() ) ||
|
|
|
|
0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
|
|
|
|
msGraphicObjectProtocol.getLength() ) ) &&
|
|
|
|
mxEmbeddedResolver.is() )
|
2001-05-18 12:58:34 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
|
2001-05-18 12:58:34 +00:00
|
|
|
if( xNA.is() )
|
|
|
|
{
|
|
|
|
Any aAny = xNA->getByName( rEmbeddedObjectURL );
|
|
|
|
Reference < XInputStream > xIn;
|
|
|
|
aAny >>= xIn;
|
|
|
|
if( xIn.is() )
|
|
|
|
{
|
|
|
|
XMLBase64Export aBase64Exp( *this );
|
2001-06-19 14:30:45 +00:00
|
|
|
bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
|
2001-05-18 12:58:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2004-07-13 07:06:44 +00:00
|
|
|
OUString SvXMLExport::EncodeStyleName(
|
|
|
|
const OUString& rName,
|
|
|
|
sal_Bool *pEncoded ) const
|
|
|
|
{
|
|
|
|
return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
|
|
|
|
}
|
|
|
|
|
2001-03-30 09:49:34 +00:00
|
|
|
ProgressBarHelper* SvXMLExport::GetProgressBarHelper()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if (!mpProgressBarHelper)
|
2001-03-30 09:49:34 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_True);
|
2001-03-30 09:49:34 +00:00
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
if (mxExportInfo.is())
|
2001-03-30 09:49:34 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
|
2001-03-30 09:49:34 +00:00
|
|
|
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);
|
2006-06-20 10:39:29 +00:00
|
|
|
aAny = mxExportInfo->getPropertyValue(sProgressRange);
|
2001-03-30 09:49:34 +00:00
|
|
|
if (aAny >>= nProgressRange)
|
2006-06-20 10:39:29 +00:00
|
|
|
mpProgressBarHelper->SetRange(nProgressRange);
|
|
|
|
aAny = mxExportInfo->getPropertyValue(sProgressMax);
|
2001-03-30 09:49:34 +00:00
|
|
|
if (aAny >>= nProgressMax)
|
2006-06-20 10:39:29 +00:00
|
|
|
mpProgressBarHelper->SetReference(nProgressMax);
|
|
|
|
aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
|
2001-03-30 09:49:34 +00:00
|
|
|
if (aAny >>= nProgressCurrent)
|
2006-06-20 10:39:29 +00:00
|
|
|
mpProgressBarHelper->SetValue(nProgressCurrent);
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
2002-07-01 13:17:28 +00:00
|
|
|
if (xPropertySetInfo->hasPropertyByName(sRepeat))
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
|
2002-07-01 13:17:28 +00:00
|
|
|
if (aAny.getValueType() == getBooleanCppuType())
|
2006-06-20 10:39:29 +00:00
|
|
|
mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
|
2002-07-01 13:17:28 +00:00
|
|
|
else
|
|
|
|
DBG_ERRORFILE("why is it no boolean?");
|
|
|
|
}
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 10:39:29 +00:00
|
|
|
return mpProgressBarHelper;
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
|
|
|
|
2000-12-19 17:56:47 +00:00
|
|
|
XMLEventExport& SvXMLExport::GetEventExport()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
if( NULL == mpEventExport)
|
2000-12-19 17:56:47 +00:00
|
|
|
{
|
|
|
|
// create EventExport on demand
|
2006-06-20 10:39:29 +00:00
|
|
|
mpEventExport = new XMLEventExport(*this, NULL);
|
2000-12-19 17:56:47 +00:00
|
|
|
|
|
|
|
// and register standard handlers + names
|
|
|
|
OUString sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
|
2006-06-20 10:39:29 +00:00
|
|
|
mpEventExport->AddHandler(sStarBasic, new XMLStarBasicExportHandler());
|
2002-11-19 12:14:43 +00:00
|
|
|
OUString sScript(RTL_CONSTASCII_USTRINGPARAM("Script"));
|
2006-06-20 10:39:29 +00:00
|
|
|
mpEventExport->AddHandler(sScript, new XMLScriptExportHandler());
|
|
|
|
mpEventExport->AddTranslationTable(aStandardEventTable);
|
2000-12-19 17:56:47 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
return *mpEventExport;
|
2000-12-19 17:56:47 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 09:28:16 +00:00
|
|
|
XMLImageMapExport& SvXMLExport::GetImageMapExport()
|
|
|
|
{
|
|
|
|
// image map export, create on-demand
|
2006-06-20 10:39:29 +00:00
|
|
|
if( NULL == mpImageMapExport )
|
2001-03-28 09:28:16 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mpImageMapExport = new XMLImageMapExport(*this);
|
2001-03-28 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 10:39:29 +00:00
|
|
|
return *mpImageMapExport;
|
2001-03-28 09:28:16 +00:00
|
|
|
}
|
|
|
|
|
2001-01-22 11:27:59 +00:00
|
|
|
// XUnoTunnel & co
|
|
|
|
const uno::Sequence< sal_Int8 > & SvXMLExport::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;
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLExport* SvXMLExport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
|
|
|
|
{
|
|
|
|
uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
|
|
|
|
if( xUT.is() )
|
2006-06-20 10:39:29 +00:00
|
|
|
{
|
|
|
|
return
|
|
|
|
reinterpret_cast<SvXMLExport*>(
|
|
|
|
sal::static_int_cast<sal_IntPtr>(
|
|
|
|
xUT->getSomething( SvXMLExport::getUnoTunnelId())));
|
|
|
|
}
|
2001-01-22 11:27:59 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XUnoTunnel
|
|
|
|
sal_Int64 SAL_CALL SvXMLExport::getSomething( const uno::Sequence< sal_Int8 >& rId )
|
|
|
|
throw( uno::RuntimeException )
|
|
|
|
{
|
|
|
|
if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
|
|
|
|
rId.getConstArray(), 16 ) )
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
|
2001-01-22 11:27:59 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
sal_Bool SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent >& rComp )
|
|
|
|
{
|
|
|
|
OUString sFilterService;
|
2007-05-22 15:09:34 +00:00
|
|
|
bool bIsChart = false;
|
2001-05-09 11:22:39 +00:00
|
|
|
|
|
|
|
Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
|
|
|
|
if( xServiceInfo.is() )
|
|
|
|
{
|
|
|
|
const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
|
|
|
|
while( pEntry->sModelService )
|
|
|
|
{
|
|
|
|
OUString sModelService( pEntry->sModelService,
|
|
|
|
pEntry->nModelServiceLen,
|
|
|
|
RTL_TEXTENCODING_ASCII_US );
|
|
|
|
if( xServiceInfo->supportsService( sModelService ) )
|
|
|
|
{
|
|
|
|
sFilterService = OUString( pEntry->sFilterService,
|
|
|
|
pEntry->nFilterServiceLen,
|
|
|
|
RTL_TEXTENCODING_ASCII_US );
|
2007-05-22 15:09:34 +00:00
|
|
|
bIsChart = sModelService.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( XML_MODEL_SERVICE_CHART ));
|
2001-05-09 11:22:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
pEntry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OSL_ENSURE( sFilterService.getLength(), "no export filter for own object" );
|
|
|
|
|
|
|
|
if( !sFilterService.getLength() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
Reference < XDocumentHandler > xHdl =
|
2006-06-20 10:39:29 +00:00
|
|
|
new XMLEmbeddedObjectExportFilter( mxHandler );
|
2001-05-09 11:22:39 +00:00
|
|
|
|
|
|
|
Sequence < Any > aArgs( 1 );
|
2007-05-22 15:09:34 +00:00
|
|
|
// #144135# the filters for embedded objects in flat format are always
|
|
|
|
// instantiated as Oasis filters and transformed afterwards. Therefore, all
|
|
|
|
// special handling that is done if the exportFlags do not contain
|
|
|
|
// EXPORT_OASIS must be changed to properties being passed in the info
|
|
|
|
// propertyset
|
|
|
|
|
|
|
|
if( ! (getExportFlags() & EXPORT_OASIS) &&
|
|
|
|
bIsChart )
|
|
|
|
{
|
|
|
|
static ::comphelper::PropertyMapEntry aInfoMap[] =
|
|
|
|
{
|
|
|
|
{ RTL_CONSTASCII_STRINGPARAM("ExportTableNumberList"), 0, &::getBooleanCppuType(), PropertyAttribute::MAYBEVOID, 0},
|
|
|
|
{ NULL, 0, 0, NULL, 0, 0 }
|
|
|
|
};
|
|
|
|
Reference< XPropertySet > xInfoProp(
|
|
|
|
::comphelper::GenericPropertySet_CreateInstance(
|
|
|
|
new ::comphelper::PropertySetInfo( aInfoMap )));
|
|
|
|
|
|
|
|
if( bIsChart )
|
|
|
|
xInfoProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ExportTableNumberList")), makeAny( true ));
|
|
|
|
|
|
|
|
aArgs.realloc( 2 );
|
|
|
|
aArgs[1] <<= xInfoProp;
|
|
|
|
}
|
2001-05-09 11:22:39 +00:00
|
|
|
aArgs[0] <<= xHdl;
|
|
|
|
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
// Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory();
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFactory = getServiceFactory();
|
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
Reference< document::XExporter > xExporter(
|
|
|
|
xServiceFactory->createInstanceWithArguments( sFilterService, aArgs),
|
|
|
|
UNO_QUERY);
|
|
|
|
OSL_ENSURE( xExporter.is(),
|
|
|
|
"can't instantiate export filter component for own object" );
|
|
|
|
if( !xExporter.is() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
xExporter->setSourceDocument( rComp );
|
|
|
|
|
|
|
|
Reference<XFilter> xFilter( xExporter, UNO_QUERY );
|
|
|
|
|
|
|
|
Sequence < PropertyValue > aMediaDesc( 0 );
|
|
|
|
return xFilter->filter( aMediaDesc );
|
|
|
|
}
|
|
|
|
|
2001-06-25 11:39:27 +00:00
|
|
|
OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
|
|
|
|
{
|
2006-04-27 08:43:08 +00:00
|
|
|
OUString sValue( rValue );
|
2006-05-22 09:51:39 +00:00
|
|
|
// #i65474# handling of fragment URLs ("#....") is undefined
|
|
|
|
// they are stored 'as is'
|
|
|
|
if(sValue.getLength() && sValue.getStr()[0] != '#')
|
2006-04-27 08:43:08 +00:00
|
|
|
{
|
2006-05-22 09:51:39 +00:00
|
|
|
try
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
uno::Reference< uri::XUriReference > xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
|
2006-05-22 09:51:39 +00:00
|
|
|
if( xUriRef.is() && !xUriRef->isAbsolute() )
|
|
|
|
{
|
|
|
|
//#i61943# relative URLs need special handling
|
2006-06-20 10:39:29 +00:00
|
|
|
INetURLObject aTemp( mpImpl->msPackageURI );
|
2006-05-22 09:51:39 +00:00
|
|
|
bool bWasAbsolute = false;
|
|
|
|
sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DECODE_TO_IURI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
2006-04-27 08:43:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 10:39:29 +00:00
|
|
|
return URIHelper::simpleNormalizedMakeRelative(msOrigFileName, sValue);
|
2001-06-25 11:39:27 +00:00
|
|
|
}
|
|
|
|
|
2001-09-13 14:18:52 +00:00
|
|
|
void SvXMLExport::StartElement(sal_uInt16 nPrefix,
|
|
|
|
enum ::xmloff::token::XMLTokenEnum eName,
|
|
|
|
sal_Bool bIgnWSOutside )
|
2001-09-14 13:08:06 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
StartElement(mpNamespaceMap->GetQNameByKey( nPrefix, GetXMLToken(eName) ), bIgnWSOutside);
|
2001-09-14 13:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::StartElement(const OUString& rName,
|
|
|
|
sal_Bool bIgnWSOutside )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
|
|
|
if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-19 10:46:32 +00:00
|
|
|
if( bIgnWSOutside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY))
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler->ignorableWhitespace( msWS );
|
|
|
|
mxHandler->startElement( rName, GetXAttrList() );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
2001-11-26 06:58:54 +00:00
|
|
|
catch ( SAXInvalidCharacterException& e )
|
|
|
|
{
|
|
|
|
Sequence<OUString> aPars(1);
|
|
|
|
aPars[0] = rName;
|
|
|
|
SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL );
|
|
|
|
}
|
2001-09-18 15:28:34 +00:00
|
|
|
catch ( SAXException& e )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2001-09-18 15:28:34 +00:00
|
|
|
Sequence<OUString> aPars(1);
|
|
|
|
aPars[0] = rName;
|
|
|
|
SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
|
|
|
|
aPars, e.Message, NULL );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-12 12:58:48 +00:00
|
|
|
ClearAttrList();
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::Characters(const ::rtl::OUString& rChars)
|
|
|
|
{
|
|
|
|
if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler->characters(rChars);
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
2001-11-26 06:58:54 +00:00
|
|
|
catch ( SAXInvalidCharacterException& e )
|
|
|
|
{
|
|
|
|
Sequence<OUString> aPars(1);
|
|
|
|
aPars[0] = rChars;
|
|
|
|
SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL );
|
|
|
|
}
|
2001-09-18 15:28:34 +00:00
|
|
|
catch ( SAXException& e )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2001-09-24 13:33:45 +00:00
|
|
|
Sequence<OUString> aPars(1);
|
2001-09-18 15:28:34 +00:00
|
|
|
aPars[0] = rChars;
|
|
|
|
SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
|
|
|
|
aPars, e.Message, NULL );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::EndElement(sal_uInt16 nPrefix,
|
|
|
|
enum ::xmloff::token::XMLTokenEnum eName,
|
|
|
|
sal_Bool bIgnWSInside )
|
2001-09-14 13:08:06 +00:00
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
EndElement(mpNamespaceMap->GetQNameByKey( nPrefix, GetXMLToken(eName) ), bIgnWSInside);
|
2001-09-14 13:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::EndElement(const OUString& rName,
|
|
|
|
sal_Bool bIgnWSInside )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
|
|
|
if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-19 10:46:32 +00:00
|
|
|
if( bIgnWSInside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY))
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler->ignorableWhitespace( msWS );
|
|
|
|
mxHandler->endElement( rName );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
2001-09-18 15:28:34 +00:00
|
|
|
catch ( SAXException& e )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2001-09-18 15:28:34 +00:00
|
|
|
Sequence<OUString> aPars(1);
|
|
|
|
aPars[0] = rName;
|
|
|
|
SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
|
|
|
|
aPars, e.Message, NULL );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-24 13:33:45 +00:00
|
|
|
void SvXMLExport::IgnorableWhitespace()
|
|
|
|
{
|
2001-10-19 10:46:32 +00:00
|
|
|
if ((mnExportFlags & EXPORT_PRETTY) != EXPORT_PRETTY)
|
|
|
|
return;
|
|
|
|
|
2001-09-24 13:33:45 +00:00
|
|
|
if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxHandler->ignorableWhitespace( msWS );
|
2001-09-24 13:33:45 +00:00
|
|
|
}
|
|
|
|
catch ( SAXException& e )
|
|
|
|
{
|
|
|
|
Sequence<OUString> aPars(0);
|
|
|
|
SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
|
|
|
|
aPars, e.Message, NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-18 15:28:34 +00:00
|
|
|
void SvXMLExport::SetError(
|
|
|
|
sal_Int32 nId,
|
|
|
|
const Sequence<OUString>& rMsgParams,
|
|
|
|
const OUString& rExceptionMessage,
|
|
|
|
const Reference<XLocator>& rLocator )
|
2001-09-13 14:18:52 +00:00
|
|
|
{
|
2001-09-25 16:03:25 +00:00
|
|
|
// allow multi-threaded access to the cancel() method
|
|
|
|
static ::vos::OMutex aMutex;
|
|
|
|
::vos::OGuard aGuard(aMutex);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
// create error lsit on demand
|
2006-06-20 10:39:29 +00:00
|
|
|
if ( mpXMLErrors == NULL )
|
|
|
|
mpXMLErrors = new XMLErrors();
|
2001-09-18 15:28:34 +00:00
|
|
|
|
|
|
|
// save error information
|
2006-06-20 10:39:29 +00:00
|
|
|
mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
2001-09-18 15:28:34 +00:00
|
|
|
void SvXMLExport::SetError(
|
|
|
|
sal_Int32 nId,
|
|
|
|
const Sequence<OUString>& rMsgParams)
|
|
|
|
{
|
|
|
|
OUString sEmpty;
|
|
|
|
SetError( nId, rMsgParams, sEmpty, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-13 14:18:52 +00:00
|
|
|
XMLErrors* SvXMLExport::GetErrors()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
return mpXMLErrors;
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::DisposingModel()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
mxModel.clear();
|
2006-03-27 09:04:05 +00:00
|
|
|
// --> OD 2006-03-13 #i51726#
|
|
|
|
meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;;
|
|
|
|
// <--
|
2004-05-14 15:10:42 +00:00
|
|
|
mxEventListener.clear();
|
2001-09-13 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
2004-05-03 12:33:10 +00:00
|
|
|
// #110680#
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLExport::getServiceFactory()
|
|
|
|
{
|
|
|
|
// #110680#
|
|
|
|
return mxServiceFactory;
|
|
|
|
}
|
|
|
|
|
2004-11-26 18:30:25 +00:00
|
|
|
::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLExport::getInterfaceToIdentifierMapper()
|
|
|
|
{
|
2006-06-20 10:39:29 +00:00
|
|
|
return mpImpl->maInterfaceToIdentifierMapper;
|
2004-11-26 18:30:25 +00:00
|
|
|
}
|
|
|
|
|
2006-10-13 11:15:34 +00:00
|
|
|
// --> OD 2006-09-27 #i69627#
|
|
|
|
const sal_Bool SvXMLExport::writeOutlineStyleAsNormalListStyle() const
|
|
|
|
{
|
|
|
|
return mpImpl->mbOutlineStyleAsNormalListStyle;
|
|
|
|
}
|
|
|
|
// <--
|
|
|
|
|
2008-03-12 09:29:35 +00:00
|
|
|
uno::Reference< embed::XStorage > SvXMLExport::GetTargetStorage()
|
|
|
|
{
|
|
|
|
return mpImpl->mxTargetStorage;
|
|
|
|
}
|
|
|
|
|
2001-09-13 14:18:52 +00:00
|
|
|
//=============================================================================
|
|
|
|
|
2001-04-30 12:37:27 +00:00
|
|
|
void SvXMLElementExport::StartElement( SvXMLExport& rExp,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
const OUString& rLName,
|
|
|
|
sal_Bool bIWSOutside )
|
|
|
|
{
|
2001-09-18 16:33:48 +00:00
|
|
|
aName = rExp.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
|
|
|
|
rExp.StartElement(aName, bIWSOutside);
|
2001-04-30 12:37:27 +00:00
|
|
|
}
|
2000-12-19 17:56:47 +00:00
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
const sal_Char *pLName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
2001-04-30 12:37:27 +00:00
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( sal_True )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
OUString sLName( OUString::createFromAscii(pLName) );
|
2001-04-30 12:37:27 +00:00
|
|
|
StartElement( rExp, nPrefixKey, sLName, bIWSOutside );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2000-10-19 13:25:20 +00:00
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
const OUString& rLName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
2001-04-30 12:37:27 +00:00
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( sal_True )
|
2000-10-19 13:25:20 +00:00
|
|
|
{
|
2001-04-30 12:37:27 +00:00
|
|
|
StartElement( rExp, nPrefixKey, rLName, bIWSOutside );
|
|
|
|
}
|
2000-10-19 13:25:20 +00:00
|
|
|
|
2001-05-16 14:21:01 +00:00
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
enum XMLTokenEnum eLName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( sal_True )
|
|
|
|
{
|
|
|
|
StartElement( rExp, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
|
|
|
|
}
|
|
|
|
|
2001-04-30 12:37:27 +00:00
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
sal_Bool bDoSth,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
const sal_Char *pLName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( bDoSth )
|
|
|
|
{
|
|
|
|
if( bDoSomething )
|
|
|
|
{
|
|
|
|
OUString sLName( OUString::createFromAscii(pLName) );
|
|
|
|
StartElement( rExp, nPrefixKey, sLName, bIWSOutside );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
sal_Bool bDoSth,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
const OUString& rLName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( bDoSth )
|
|
|
|
{
|
|
|
|
if( bDoSomething )
|
|
|
|
StartElement( rExp, nPrefixKey, rLName, bIWSOutside );
|
2000-10-19 13:25:20 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 14:21:01 +00:00
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
sal_Bool bDoSth,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
enum XMLTokenEnum eLName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( bDoSth )
|
|
|
|
{
|
|
|
|
if( bDoSomething )
|
2001-09-18 15:28:34 +00:00
|
|
|
StartElement( rExport, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
|
2001-05-16 14:21:01 +00:00
|
|
|
}
|
|
|
|
|
2003-03-27 17:21:03 +00:00
|
|
|
SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
|
|
|
|
const OUString& rQName,
|
|
|
|
sal_Bool bIWSOutside,
|
|
|
|
sal_Bool bIWSInside ) :
|
|
|
|
rExport( rExp ),
|
|
|
|
bIgnWS( bIWSInside ),
|
|
|
|
bDoSomething( sal_True )
|
|
|
|
{
|
|
|
|
aName = rQName;
|
|
|
|
rExp.StartElement( rQName, bIWSOutside );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLElementExport::~SvXMLElementExport()
|
|
|
|
{
|
2001-04-30 12:37:27 +00:00
|
|
|
if( bDoSomething )
|
|
|
|
{
|
2001-09-18 15:28:34 +00:00
|
|
|
rExport.EndElement( aName, bIgnWS );
|
2001-04-30 12:37:27 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|