2000-09-18 23:31:44 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: xmlexp.cxx,v $
|
|
|
|
*
|
2001-05-18 12:58:34 +00:00
|
|
|
* $Revision: 1.66 $
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
2001-05-18 12:58:34 +00:00
|
|
|
* last change: $Author: mib $ $Date: 2001-05-18 13:46:50 $
|
2000-09-18 23:31:44 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifdef PRECOMPILED
|
|
|
|
#include "filt_pch.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
2001-01-22 11:27:59 +00:00
|
|
|
#ifndef _OSL_MUTEX_HXX_
|
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#include <rtl/uuid.h>
|
2000-09-18 23:31:44 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2000-11-29 14:57:15 +00:00
|
|
|
#ifndef _URLOBJ_HXX
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
2001-05-09 11:22:39 +00:00
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
2001-05-18 12:58:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
|
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
#ifndef _XMLOFF_ATTRLIST_HXX
|
|
|
|
#include "attrlist.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_NMSPMAP_HXX
|
|
|
|
#include "nmspmap.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLUCONV_HXX
|
|
|
|
#include "xmluconv.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNMSPE_HXX
|
|
|
|
#include "xmlnmspe.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLKYWD_HXX
|
|
|
|
#include "xmlkywd.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLEXP_HXX
|
|
|
|
#include "xmlexp.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNUMFE_HXX
|
|
|
|
#include "xmlnumfe.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLMETAE_HXX
|
|
|
|
#include "xmlmetae.hxx"
|
|
|
|
#endif
|
|
|
|
|
2000-11-28 10:33:02 +00:00
|
|
|
#ifndef _XMLOFF_XMLBASICE_HXX
|
|
|
|
#include "xmlscripte.hxx"
|
|
|
|
#endif
|
|
|
|
|
2000-10-18 10:40:33 +00:00
|
|
|
#ifndef _XMLOFF_FAMILIES_HXX_
|
|
|
|
#include "families.hxx"
|
|
|
|
#endif
|
|
|
|
|
2000-12-19 17:56:47 +00:00
|
|
|
#ifndef _XMLOFF_XMLEVENTEXPORT_HXX
|
|
|
|
#include "XMLEventExport.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLSTARBASICEXPORTHANDLER_HXX
|
|
|
|
#include "XMLStarBasicExportHandler.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-03-11 14:52:23 +00:00
|
|
|
#ifndef _XMLOFF_SETTINGSEXPORTHELPER_HXX
|
|
|
|
#include "SettingsExportHelper.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-05-17 13:07:36 +00:00
|
|
|
#ifndef _XMLOFF_XMLTOKEN_HXX
|
|
|
|
#include "xmltoken.hxx"
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#endif
|
2000-11-29 13:32:08 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
|
|
|
|
#include <com/sun/star/container/XIndexContainer.hpp>
|
|
|
|
#endif
|
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
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XVIEWDATASUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/document/XViewDataSupplier.hpp>
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
#ifndef _XMLOFF_GRADIENTSTYLE_HXX
|
|
|
|
#include <GradientStyle.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_HATCHSTYLE_HXX
|
|
|
|
#include <HatchStyle.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_IMAGESTYLE_HXX
|
|
|
|
#include <ImageStyle.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_TRANSGRADIENTSTYLE_HXX
|
|
|
|
#include <TransGradientStyle.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_MARKERSTYLE_HXX
|
|
|
|
#include <MarkerStyle.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_DASHSTYLE_HXX
|
|
|
|
#include <DashStyle.hxx>
|
|
|
|
#endif
|
2000-11-13 07:44:24 +00:00
|
|
|
#ifndef _XMLOFF_XMLFONTAUTOSTYLEPOOL_HXX
|
|
|
|
#include "XMLFontAutoStylePool"
|
|
|
|
#endif
|
2001-03-28 09:28:16 +00:00
|
|
|
#ifndef _XMLOFF_XMLIMAGEMAPEXPORT_HXX_
|
|
|
|
#include "XMLImageMapExport.hxx"
|
|
|
|
#endif
|
2001-05-18 12:58:34 +00:00
|
|
|
#ifndef _XMLOFF_XMLBASE64EXPORT_HXX_
|
|
|
|
#include "XMLBase64Export.hxx"
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
|
|
|
|
#endif
|
2001-05-09 11:22:39 +00:00
|
|
|
#ifndef _XMLOFF_XMLFILTERSERVICENAMES_H
|
|
|
|
#include "XMLFilterServiceNames.h"
|
|
|
|
#endif
|
|
|
|
#ifndef _XMLOFF_XMLEMBEDDEDOBJECTEXPORTFILTER_HXX
|
|
|
|
#include "XMLEmbeddedObjectExportFilter.hxx"
|
|
|
|
#endif
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
using namespace ::rtl;
|
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
|
|
|
|
|
|
|
sal_Char __READONLY_DATA sXML_1_0[] = "1.0";
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void SvXMLExport::_InitCtor()
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_OFFICE, sXML_np_office,
|
|
|
|
sXML_n_office, XML_NAMESPACE_OFFICE );
|
2001-03-05 10:47:18 +00:00
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_FO, sXML_np_fo,
|
|
|
|
sXML_n_fo, XML_NAMESPACE_FO );
|
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_XLINK, sXML_np_xlink,
|
|
|
|
sXML_n_xlink, XML_NAMESPACE_XLINK );
|
|
|
|
}
|
2001-03-14 14:08:53 +00:00
|
|
|
if( (getExportFlags() & EXPORT_SETTINGS) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_CONFIG, sXML_np_config,
|
|
|
|
sXML_n_config, XML_NAMESPACE_CONFIG );
|
|
|
|
}
|
|
|
|
|
2001-03-05 10:47:18 +00:00
|
|
|
if( (getExportFlags() & EXPORT_META) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_DC, sXML_np_dc,
|
|
|
|
sXML_n_dc, XML_NAMESPACE_DC );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_META, sXML_np_meta,
|
|
|
|
sXML_n_meta, XML_NAMESPACE_META );
|
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_STYLE, sXML_np_style,
|
|
|
|
sXML_n_style, XML_NAMESPACE_STYLE );
|
|
|
|
}
|
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 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_TEXT, sXML_np_text,
|
|
|
|
sXML_n_text, XML_NAMESPACE_TEXT );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_DRAW, sXML_np_draw,
|
|
|
|
sXML_n_draw, XML_NAMESPACE_DRAW );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_DR3D, sXML_np_dr3d,
|
|
|
|
sXML_n_dr3d, XML_NAMESPACE_DR3D );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_SVG, sXML_np_svg,
|
|
|
|
sXML_n_svg, XML_NAMESPACE_SVG );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_CHART, sXML_np_chart,
|
|
|
|
sXML_n_chart, XML_NAMESPACE_CHART );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_TABLE, sXML_np_table,
|
|
|
|
sXML_n_table, XML_NAMESPACE_TABLE );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_NUMBER, sXML_np_number,
|
|
|
|
sXML_n_number, XML_NAMESPACE_NUMBER );
|
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_MATH, sXML_np_math,
|
|
|
|
sXML_n_math, XML_NAMESPACE_MATH );
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_FORM, sXML_namespace_form,
|
|
|
|
sXML_url_form, XML_NAMESPACE_FORM );
|
|
|
|
}
|
|
|
|
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS) ) != 0 )
|
|
|
|
{
|
|
|
|
pNamespaceMap->AddAtIndex( XML_NAMESPACE_SCRIPT, sXML_namespace_script,
|
|
|
|
sXML_url_script, XML_NAMESPACE_SCRIPT );
|
|
|
|
}
|
2000-11-14 09:13:10 +00:00
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
|
|
|
|
xAttrList = (xml::sax::XAttributeList*)pAttrList;
|
2000-11-29 13:32:08 +00:00
|
|
|
|
2000-11-29 14:57:15 +00:00
|
|
|
sPicturesPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#Pictures/" ) );
|
2001-01-03 10:07:00 +00:00
|
|
|
sObjectsPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#./" ) );
|
2000-11-29 14:57:15 +00:00
|
|
|
sGraphicObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
|
2001-01-26 10:22:48 +00:00
|
|
|
sEmbeddedObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2001-03-01 15:31:32 +00:00
|
|
|
SvXMLExport::SvXMLExport( MapUnit eDfltUnit, const sal_Char * pClass, sal_uInt16 nExportFlags ) :
|
2001-01-12 15:16:13 +00:00
|
|
|
pImpl( 0 ), mpClass( pClass ),
|
|
|
|
sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
|
|
|
|
sWS( OUString::createFromAscii( sXML_WS ) ),
|
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit ) ),
|
|
|
|
pAttrList( new SvXMLAttributeList ),
|
|
|
|
bExtended( sal_False ),
|
2001-01-17 10:00:14 +00:00
|
|
|
pNumExport(0L),
|
2001-01-12 15:16:13 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-02-13 15:55:00 +00:00
|
|
|
pEventExport( NULL ),
|
2001-03-28 09:28:16 +00:00
|
|
|
pImageMapExport( NULL ),
|
2001-03-01 15:31:32 +00:00
|
|
|
bSaveLinkedSections(sal_True),
|
|
|
|
mnExportFlags( nExportFlags )
|
2001-01-12 15:16:13 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLExport::SvXMLExport(
|
|
|
|
const OUString &rFileName,
|
|
|
|
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
|
|
|
|
MapUnit eDfltUnit ) :
|
2001-01-12 15:16:13 +00:00
|
|
|
pImpl( 0 ), mpClass( NULL ),
|
2000-09-18 23:31:44 +00:00
|
|
|
sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
|
|
|
|
sWS( OUString::createFromAscii( sXML_WS ) ),
|
|
|
|
sOrigFileName( rFileName ),
|
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit ) ),
|
|
|
|
pAttrList( new SvXMLAttributeList ),
|
|
|
|
bExtended( sal_False ),
|
|
|
|
xHandler( rHandler ),
|
2000-11-10 17:15:59 +00:00
|
|
|
xExtHandler( rHandler, uno::UNO_QUERY ),
|
2001-03-02 19:17:53 +00:00
|
|
|
pNumExport(0L),
|
2000-12-19 17:56:47 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-02-13 15:55:00 +00:00
|
|
|
pEventExport( NULL ),
|
2001-03-28 09:28:16 +00:00
|
|
|
pImageMapExport( NULL ),
|
2001-03-02 19:17:53 +00:00
|
|
|
bSaveLinkedSections(sal_True),
|
|
|
|
mnExportFlags( EXPORT_ALL )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
2001-01-17 12:42:42 +00:00
|
|
|
|
|
|
|
if (xNumberFormatsSupplier.is())
|
|
|
|
pNumExport = new SvXMLNumFmtExport(rHandler, xNumberFormatsSupplier);
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2000-12-03 09:16:56 +00:00
|
|
|
SvXMLExport::SvXMLExport(
|
|
|
|
const OUString &rFileName,
|
|
|
|
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
|
|
|
|
const Reference< XModel >& rModel,
|
|
|
|
sal_Int16 eDfltUnit ) :
|
2001-01-12 15:16:13 +00:00
|
|
|
pImpl( 0 ), mpClass( NULL ),
|
2000-12-03 09:16:56 +00:00
|
|
|
sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
|
|
|
|
sWS( OUString::createFromAscii( sXML_WS ) ),
|
|
|
|
sOrigFileName( rFileName ),
|
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit) ) ),
|
|
|
|
pAttrList( new SvXMLAttributeList ),
|
|
|
|
bExtended( sal_False ),
|
|
|
|
xHandler( rHandler ),
|
|
|
|
xExtHandler( rHandler, uno::UNO_QUERY ),
|
|
|
|
xModel( rModel ),
|
|
|
|
pNumExport(0L),
|
|
|
|
xNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
2000-12-19 17:56:47 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-02-13 15:55:00 +00:00
|
|
|
pEventExport( NULL ),
|
2001-03-28 09:28:16 +00:00
|
|
|
pImageMapExport( NULL ),
|
2001-03-02 19:17:53 +00:00
|
|
|
bSaveLinkedSections(sal_True),
|
|
|
|
mnExportFlags( EXPORT_ALL )
|
2000-12-03 09:16:56 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
2001-01-17 12:42:42 +00:00
|
|
|
|
|
|
|
if (xNumberFormatsSupplier.is())
|
|
|
|
pNumExport = new SvXMLNumFmtExport(rHandler, xNumberFormatsSupplier);
|
2000-12-03 09:16:56 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLExport::SvXMLExport(
|
|
|
|
const OUString &rFileName,
|
|
|
|
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
|
|
|
|
const Reference< XModel >& rModel,
|
2001-01-12 15:16:13 +00:00
|
|
|
const Reference< document::XGraphicObjectResolver >& rEmbeddedGraphicObjects,
|
2000-09-18 23:31:44 +00:00
|
|
|
sal_Int16 eDfltUnit ) :
|
2001-01-12 15:16:13 +00:00
|
|
|
pImpl( 0 ), mpClass( NULL ),
|
2000-09-18 23:31:44 +00:00
|
|
|
sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
|
|
|
|
sWS( OUString::createFromAscii( sXML_WS ) ),
|
|
|
|
sOrigFileName( rFileName ),
|
|
|
|
pNamespaceMap( new SvXMLNamespaceMap ),
|
|
|
|
pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit) ) ),
|
|
|
|
pAttrList( new SvXMLAttributeList ),
|
|
|
|
bExtended( sal_False ),
|
|
|
|
xHandler( rHandler ),
|
|
|
|
xExtHandler( rHandler, uno::UNO_QUERY ),
|
2001-01-12 15:16:13 +00:00
|
|
|
xGraphicResolver( rEmbeddedGraphicObjects ),
|
2000-09-18 23:31:44 +00:00
|
|
|
xModel( rModel ),
|
|
|
|
pNumExport(0L),
|
2000-11-10 17:15:59 +00:00
|
|
|
xNumberFormatsSupplier (rModel, uno::UNO_QUERY),
|
2000-12-19 17:56:47 +00:00
|
|
|
pProgressBarHelper( NULL ),
|
2001-02-13 15:55:00 +00:00
|
|
|
pEventExport( NULL ),
|
2001-03-28 09:28:16 +00:00
|
|
|
pImageMapExport( NULL ),
|
2001-03-02 19:17:53 +00:00
|
|
|
bSaveLinkedSections(sal_True),
|
|
|
|
mnExportFlags( EXPORT_ALL )
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
_InitCtor();
|
2001-01-17 12:42:42 +00:00
|
|
|
|
|
|
|
if (xNumberFormatsSupplier.is())
|
|
|
|
pNumExport = new SvXMLNumFmtExport(rHandler, xNumberFormatsSupplier);
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvXMLExport::~SvXMLExport()
|
|
|
|
{
|
2001-03-28 09:28:16 +00:00
|
|
|
delete pImageMapExport;
|
2001-02-28 10:32:54 +00:00
|
|
|
delete pEventExport;
|
2000-09-18 23:31:44 +00:00
|
|
|
delete pNamespaceMap;
|
|
|
|
delete pUnitConv;
|
2001-04-20 07:07:16 +00:00
|
|
|
if (pProgressBarHelper || pNumExport)
|
2001-03-30 09:49:34 +00:00
|
|
|
{
|
|
|
|
if (xExportInfo.is())
|
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xExportInfo->getPropertySetInfo();
|
|
|
|
if (xPropertySetInfo.is())
|
|
|
|
{
|
2001-04-20 07:07:16 +00:00
|
|
|
if (pProgressBarHelper)
|
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));
|
|
|
|
if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
|
|
|
|
xPropertySetInfo->hasPropertyByName(sProgressCurrent))
|
|
|
|
{
|
|
|
|
sal_Int32 nProgressMax(pProgressBarHelper->GetReference());
|
|
|
|
sal_Int32 nProgressCurrent(pProgressBarHelper->GetValue());
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= nProgressMax;
|
|
|
|
xExportInfo->setPropertyValue(sProgressMax, aAny);
|
|
|
|
aAny <<= nProgressCurrent;
|
|
|
|
xExportInfo->setPropertyValue(sProgressCurrent, aAny);
|
|
|
|
}
|
|
|
|
}
|
2001-04-20 09:37:39 +00:00
|
|
|
if (pNumExport && (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;
|
|
|
|
pNumExport->GetWasUsed(aWasUsed);
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= aWasUsed;
|
|
|
|
xExportInfo->setPropertyValue(sWrittenNumberFormats, aAny);
|
|
|
|
}
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-10 17:15:59 +00:00
|
|
|
delete pProgressBarHelper;
|
2001-04-20 07:07:16 +00:00
|
|
|
delete pNumExport;
|
2001-03-30 09:49:34 +00:00
|
|
|
}
|
2001-05-17 13:07:36 +00:00
|
|
|
|
|
|
|
xmloff::token::ResetTokens();
|
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)
|
|
|
|
{
|
|
|
|
xModel = uno::Reference< frame::XModel >::query( xDoc );
|
|
|
|
if( !xModel.is() )
|
|
|
|
throw lang::IllegalArgumentException();
|
|
|
|
|
|
|
|
if(!xNumberFormatsSupplier.is() )
|
|
|
|
{
|
|
|
|
xNumberFormatsSupplier = xNumberFormatsSupplier.query( xModel );
|
|
|
|
if(xNumberFormatsSupplier.is() && xHandler.is())
|
|
|
|
pNumExport = new SvXMLNumFmtExport(xHandler, xNumberFormatsSupplier);
|
|
|
|
}
|
2001-04-20 09:37:39 +00:00
|
|
|
if (xExportInfo.is() && pNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
|
2001-04-20 07:07:16 +00:00
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xExportInfo->getPropertySetInfo();
|
|
|
|
if (xPropertySetInfo.is())
|
|
|
|
{
|
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::Any aAny = xExportInfo->getPropertyValue(sWrittenNumberFormats);
|
|
|
|
uno::Sequence<sal_Int32> aWasUsed;
|
|
|
|
if(aAny >>= aWasUsed)
|
|
|
|
pNumExport->SetWasUsed(aWasUsed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
const sal_Int32 nAnyCount = aArguments.getLength();
|
|
|
|
const uno::Any* pAny = aArguments.getConstArray();
|
|
|
|
|
|
|
|
for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
|
|
|
|
{
|
|
|
|
if( pAny->getValueType() == ::getCppuType((const uno::Reference< task::XStatusIndicator >*)0) )
|
|
|
|
{
|
|
|
|
*pAny >>= xStatusIndicator;
|
|
|
|
}
|
|
|
|
else if( pAny->getValueType() == ::getCppuType((const uno::Reference< document::XGraphicObjectResolver >*)0) )
|
|
|
|
{
|
|
|
|
*pAny >>= xGraphicResolver;
|
|
|
|
}
|
|
|
|
else if( pAny->getValueType() == ::getCppuType((const uno::Reference< document::XEmbeddedObjectResolver >*)0) )
|
|
|
|
{
|
|
|
|
*pAny >>= xEmbeddedResolver;
|
|
|
|
}
|
|
|
|
else if( pAny->getValueType() == ::getCppuType((const uno::Reference< xml::sax::XDocumentHandler >*)0))
|
|
|
|
{
|
|
|
|
*pAny >>= xHandler;
|
|
|
|
*pAny >>= xExtHandler;
|
|
|
|
|
|
|
|
if (xNumberFormatsSupplier.is() && pNumExport == NULL)
|
|
|
|
pNumExport = new SvXMLNumFmtExport(xHandler, xNumberFormatsSupplier);
|
|
|
|
}
|
2001-03-20 19:08:37 +00:00
|
|
|
else if( pAny->getValueType() == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0))
|
|
|
|
{
|
|
|
|
*pAny >>= xExportInfo;
|
|
|
|
}
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XFilter
|
|
|
|
sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const sal_Int32 nPropCount = aDescriptor.getLength();
|
|
|
|
const beans::PropertyValue* pProps = aDescriptor.getConstArray();
|
|
|
|
|
|
|
|
for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
|
|
|
|
{
|
|
|
|
const OUString& rPropName = pProps->Name;
|
|
|
|
const Any& rValue = pProps->Value;
|
|
|
|
|
|
|
|
if( rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FileName" ) ) )
|
|
|
|
{
|
|
|
|
if( !(rValue >>= sOrigFileName ) )
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exportDoc( mpClass );
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
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-01-12 15:16:13 +00:00
|
|
|
#ifdef DEBUG
|
2001-05-07 05:03:01 +00:00
|
|
|
ByteString aError( "uno Exception catched while exporting:\n" );
|
2001-01-12 15:16:13 +00:00
|
|
|
aError += ByteString( String( e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aError.GetBuffer() );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-03-22 11:17:07 +00:00
|
|
|
return sal_False;
|
2001-01-12 15:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SvXMLExport::cancel() throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
DBG_ERROR( "not supported" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// XServiceInfo
|
|
|
|
OUString SAL_CALL SvXMLExport::getImplementationName( ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aSeq;
|
|
|
|
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 ) );
|
|
|
|
|
|
|
|
pAttrList->AddAttribute( pNamespaceMap->GetQNameByKey( nPrefixKey,
|
|
|
|
sName ),
|
|
|
|
sCDATA, sValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
|
|
|
OUString sName( OUString::createFromAscii( pName ) );
|
|
|
|
|
|
|
|
pAttrList->AddAttribute( pNamespaceMap->GetQNameByKey( nPrefixKey,
|
|
|
|
sName ),
|
|
|
|
sCDATA, rValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
|
|
|
pAttrList->AddAttribute( pNamespaceMap->GetQNameByKey( nPrefixKey, rName ),
|
|
|
|
sCDATA, rValue );
|
|
|
|
}
|
|
|
|
|
2001-05-16 14:21:01 +00:00
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
|
|
|
|
enum XMLTokenEnum eName,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
|
|
|
pAttrList->AddAttribute(
|
|
|
|
pNamespaceMap->GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
|
|
|
|
sCDATA, rValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
|
|
|
|
enum XMLTokenEnum eName,
|
|
|
|
enum XMLTokenEnum eValue)
|
|
|
|
{
|
|
|
|
pAttrList->AddAttribute(
|
|
|
|
pNamespaceMap->GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
|
|
|
|
sCDATA, GetXMLToken(eValue) );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
|
|
|
|
{
|
|
|
|
if( xAttrList.is())
|
|
|
|
pAttrList->AppendAttributeList( xAttrList );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::ClearAttrList()
|
|
|
|
{
|
|
|
|
pAttrList->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
void SvXMLExport::CheckAttrList()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( !pAttrList->getLength(),
|
|
|
|
"XMLExport::CheckAttrList: list is not empty" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void SvXMLExport::ImplExportMeta()
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
|
|
|
{
|
|
|
|
// <office:meta>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, sXML_meta,
|
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
_ExportMeta();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-05 08:28:51 +00:00
|
|
|
void SvXMLExport::ImplExportSettings()
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
|
|
|
{
|
2001-03-11 14:52:23 +00:00
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, sXML_settings,
|
|
|
|
sal_True, sal_True );
|
|
|
|
XMLSettingsExportHelper aSettingsExportHelper(*this);
|
|
|
|
_ExportViewSettings(aSettingsExportHelper);
|
|
|
|
_ExportConfigurationSettings(aSettingsExportHelper);
|
2001-03-05 08:28:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::ImplExportStyles( sal_Bool bUsed )
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
|
|
|
// AddAttributeASCII( XML_NAMESPACE_NONE, sXML_id, sXML_styles_id );
|
|
|
|
{
|
|
|
|
// <style:styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, sXML_styles,
|
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
_ExportStyles( sal_False );
|
|
|
|
}
|
2001-03-01 15:31:32 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-03-01 15:31:32 +00:00
|
|
|
void SvXMLExport::ImplExportAutoStyles( sal_Bool bUsed )
|
|
|
|
{
|
2000-09-18 23:31:44 +00:00
|
|
|
// AddAttributeASCII( XML_NAMESPACE_NONE, sXML_id, sXML_auto_styles_id );
|
|
|
|
{
|
|
|
|
// <style:automatic-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
|
|
|
|
sXML_automatic_styles, sal_True, sal_True );
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_type, sXML_simple );
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_href, sXML_styles_href );
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_actuate, sXML_onLoad );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, sXML_role,
|
|
|
|
pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE,
|
|
|
|
OUString::createFromAscii(sXML_stylesheet)) );
|
|
|
|
{
|
|
|
|
// <style:use-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
|
|
|
|
sXML_use_styles, sal_True, sal_True );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
_ExportAutoStyles();
|
|
|
|
}
|
2001-03-01 15:31:32 +00:00
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
|
2001-03-01 15:31:32 +00:00
|
|
|
void SvXMLExport::ImplExportMasterStyles( sal_Bool bUsed )
|
|
|
|
{
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <style:master-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, sXML_master_styles,
|
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
_ExportMasterStyles();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_type, sXML_simple );
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_href, sXML_auto_styles_href );
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_actuate, sXML_onLoad );
|
|
|
|
AddAttribute( XML_NAMESPACE_XLINK, sXML_role,
|
|
|
|
pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE,
|
|
|
|
OUString::createFromAscii(sXML_stylesheet) ) );
|
|
|
|
{
|
|
|
|
// <style:use-styles>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
|
|
|
|
sXML_use_styles, sal_True, sal_True );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::ImplExportContent()
|
|
|
|
{
|
|
|
|
CheckAttrList();
|
|
|
|
|
2000-12-20 12:17:23 +00:00
|
|
|
CheckAttrList();
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
// <office:body ...>
|
2001-02-23 14:48:23 +00:00
|
|
|
SetBodyAttributes();
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, sXML_body,
|
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
_ExportContent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-23 14:48:23 +00:00
|
|
|
void SvXMLExport::SetBodyAttributes()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
sal_uInt32 SvXMLExport::exportDoc( const sal_Char *pClass )
|
|
|
|
{
|
|
|
|
xHandler->startDocument();
|
|
|
|
|
|
|
|
// <?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 )
|
2000-09-18 23:31:44 +00:00
|
|
|
sal_uInt16 nPos = pNamespaceMap->GetFirstIndex();
|
|
|
|
while( USHRT_MAX != nPos )
|
|
|
|
{
|
|
|
|
pAttrList->AddAttribute( pNamespaceMap->GetAttrNameByIndex( nPos ),
|
|
|
|
sCDATA,
|
|
|
|
pNamespaceMap->GetNameByIndex( nPos ) );
|
|
|
|
nPos = pNamespaceMap->GetNextIndex( nPos );
|
|
|
|
}
|
|
|
|
|
2001-03-19 15:30:27 +00:00
|
|
|
// office:class = ...
|
|
|
|
if( pClass )
|
|
|
|
AddAttributeASCII( XML_NAMESPACE_OFFICE, sXML_class, pClass );
|
|
|
|
|
|
|
|
// office:version = ...
|
|
|
|
if( !bExtended )
|
2001-05-09 11:22:39 +00:00
|
|
|
AddAttributeASCII( XML_NAMESPACE_OFFICE, sXML_version, sXML_1_0 );
|
2001-03-19 15:30:27 +00:00
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
2001-03-04 15:01:11 +00:00
|
|
|
char* pRootService;
|
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
|
|
|
|
pRootService = sXML_document_meta;
|
|
|
|
}
|
2001-03-05 08:28:51 +00:00
|
|
|
else if ( EXPORT_SETTINGS == nExportMode )
|
|
|
|
{
|
|
|
|
// export only settings
|
|
|
|
pRootService = sXML_document_settings;
|
|
|
|
}
|
2001-03-04 15:01:11 +00:00
|
|
|
else if( EXPORT_STYLES == nExportMode )
|
|
|
|
{
|
|
|
|
// export only styles
|
|
|
|
pRootService = sXML_document_styles;
|
|
|
|
}
|
|
|
|
else if( EXPORT_CONTENT == nExportMode )
|
|
|
|
{
|
|
|
|
// export only content
|
|
|
|
pRootService = sXML_document_content;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// the god'ol one4all element
|
|
|
|
pRootService = sXML_document;
|
|
|
|
}
|
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
if( (getExportFlags() && EXPORT_NODOCTYPE) == 0 &&
|
|
|
|
xExtHandler.is() )
|
2001-04-24 14:34:42 +00:00
|
|
|
{
|
|
|
|
OUStringBuffer aDocType(
|
|
|
|
sizeof(sXML_xml_doctype_prefix) +
|
|
|
|
sizeof(sXML_xml_doctype_suffix) + 30 );
|
|
|
|
|
|
|
|
aDocType.appendAscii( sXML_xml_doctype_prefix );
|
|
|
|
OUString sLName( OUString::createFromAscii(pRootService) );
|
|
|
|
aDocType.append( GetNamespaceMap().GetQNameByKey(
|
|
|
|
XML_NAMESPACE_OFFICE, sLName ) );
|
|
|
|
aDocType.appendAscii( sXML_xml_doctype_suffix );
|
|
|
|
xExtHandler->unknown( aDocType.makeStringAndClear() );
|
|
|
|
}
|
|
|
|
|
2001-03-04 15:01:11 +00:00
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, pRootService, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xHandler->endDocument();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::_ExportMeta()
|
|
|
|
{
|
|
|
|
SfxXMLMetaExport aMeta( GetDocHandler(), xModel );
|
|
|
|
aMeta.Export( GetNamespaceMap() );
|
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:23 +00:00
|
|
|
void SvXMLExport::_ExportViewSettings(const XMLSettingsExportHelper& rSettingsExportHelper)
|
2001-02-14 05:24:00 +00:00
|
|
|
{
|
2001-03-11 14:52:23 +00:00
|
|
|
uno::Sequence<beans::PropertyValue> aProps;
|
|
|
|
GetViewSettings(aProps);
|
2001-04-04 04:26:04 +00:00
|
|
|
uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
|
|
|
|
if(xViewDataSupplier.is())
|
|
|
|
{
|
2001-04-26 09:50:03 +00:00
|
|
|
uno::Reference<container::XIndexAccess> xIndexAccess;
|
|
|
|
xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
|
|
|
|
xIndexAccess = xViewDataSupplier->getViewData();
|
2001-04-04 04:26:04 +00:00
|
|
|
if(xIndexAccess.is())
|
|
|
|
{
|
|
|
|
sal_Int32 nOldLength(aProps.getLength());
|
|
|
|
aProps.realloc(nOldLength + 1);
|
|
|
|
beans::PropertyValue aProp;
|
|
|
|
aProp.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Views"));
|
|
|
|
aProp.Value <<= xIndexAccess;
|
|
|
|
aProps[nOldLength] = aProp;
|
|
|
|
}
|
|
|
|
}
|
2001-03-11 14:52:23 +00:00
|
|
|
OUString sViewSettings(RTL_CONSTASCII_USTRINGPARAM(sXML_view_settings));
|
|
|
|
rSettingsExportHelper.exportSettings(aProps, sViewSettings);
|
2001-02-14 05:24:00 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:23 +00:00
|
|
|
void SvXMLExport::_ExportConfigurationSettings(const XMLSettingsExportHelper& rSettingsExportHelper)
|
2001-03-05 08:28:51 +00:00
|
|
|
{
|
2001-03-11 14:52:23 +00:00
|
|
|
uno::Sequence<beans::PropertyValue> aProps;
|
|
|
|
GetConfigurationSettings(aProps);
|
2001-03-29 16:31:46 +00:00
|
|
|
OUString sConfigurationSettings(RTL_CONSTASCII_USTRINGPARAM(sXML_configuration_settings));
|
|
|
|
rSettingsExportHelper.exportSettings(aProps, sConfigurationSettings);
|
2001-03-05 08:28:51 +00:00
|
|
|
}
|
|
|
|
|
2000-11-20 10:09:30 +00:00
|
|
|
void SvXMLExport::_ExportScripts()
|
|
|
|
{
|
2000-11-28 10:33:02 +00:00
|
|
|
// <office:script>
|
|
|
|
SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, sXML_script,
|
|
|
|
sal_True, sal_True );
|
|
|
|
|
|
|
|
XMLBasicExport aBasicExp( *this );
|
|
|
|
aBasicExp.Export();
|
2001-02-21 19:30:19 +00:00
|
|
|
|
|
|
|
// export document events
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
void SvXMLExport::_ExportStyles( sal_Bool bUsed )
|
|
|
|
{
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
XMLGradientStyle aGradientStyle( &xHandler, *pNamespaceMap, *pUnitConv );
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
XMLHatchStyle aHatchStyle( xHandler, *pNamespaceMap, *pUnitConv );
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
XMLTransGradientStyle aTransGradientstyle( xHandler, *pNamespaceMap, *pUnitConv );
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
XMLMarkerStyle aMarkerStyle( xHandler, *pNamespaceMap, *pUnitConv );
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
XMLDashStyle aDashStyle( &xHandler, *pNamespaceMap, *pUnitConv );
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
return new SvXMLAutoStylePoolP();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:23 +00:00
|
|
|
void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& aProps)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& aProps)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-04 13:47:21 +00:00
|
|
|
void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat )
|
|
|
|
{
|
|
|
|
if(pNumExport)
|
|
|
|
pNumExport->SetUsed(nNumberFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::exportDataStyles()
|
|
|
|
{
|
|
|
|
if(pNumExport)
|
|
|
|
pNumExport->Export(*pNamespaceMap, sal_False);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvXMLExport::exportAutoDataStyles()
|
|
|
|
{
|
|
|
|
if(pNumExport)
|
|
|
|
pNumExport->Export(*pNamespaceMap, sal_True);
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat ) const
|
2000-09-18 23:31:44 +00:00
|
|
|
{
|
|
|
|
OUString sTemp;
|
|
|
|
if(pNumExport)
|
|
|
|
sTemp = pNumExport->GetStyleName(nNumberFormat);
|
|
|
|
return sTemp;
|
|
|
|
}
|
|
|
|
|
2000-11-29 13:32:08 +00:00
|
|
|
OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
|
|
|
|
{
|
|
|
|
OUString sRet( rGraphicObjectURL );
|
2001-01-12 15:16:13 +00:00
|
|
|
if( 0 == rGraphicObjectURL.compareTo( sGraphicObjectProtocol, sGraphicObjectProtocol.getLength() ) && xGraphicResolver.is() )
|
2000-11-29 13:32:08 +00:00
|
|
|
{
|
2001-01-12 15:16:13 +00:00
|
|
|
sRet = xGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL );
|
2000-11-29 13:32:08 +00:00
|
|
|
}
|
2000-11-29 14:57:15 +00:00
|
|
|
else
|
2000-12-01 10:16:41 +00:00
|
|
|
sRet = INetURLObject::AbsToRel( sRet );
|
2000-11-29 13:32:08 +00:00
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2001-01-26 10:22:48 +00:00
|
|
|
OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
|
|
|
|
{
|
|
|
|
OUString sRet;
|
|
|
|
if( 0 == rEmbeddedObjectURL.compareTo( sEmbeddedObjectProtocol,
|
|
|
|
sEmbeddedObjectProtocol.getLength() ) &&
|
|
|
|
xEmbeddedResolver.is() )
|
|
|
|
{
|
|
|
|
sRet =
|
|
|
|
xEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL );
|
|
|
|
}
|
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2001-05-18 12:58:34 +00:00
|
|
|
sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
if( 0 == rEmbeddedObjectURL.compareTo( sEmbeddedObjectProtocol,
|
|
|
|
sEmbeddedObjectProtocol.getLength() ) &&
|
|
|
|
xEmbeddedResolver.is() )
|
|
|
|
{
|
|
|
|
Reference < XNameAccess > xNA( xEmbeddedResolver, UNO_QUERY );
|
|
|
|
if( xNA.is() )
|
|
|
|
{
|
|
|
|
Any aAny = xNA->getByName( rEmbeddedObjectURL );
|
|
|
|
Reference < XInputStream > xIn;
|
|
|
|
aAny >>= xIn;
|
|
|
|
if( xIn.is() )
|
|
|
|
{
|
|
|
|
XMLBase64Export aBase64Exp( *this );
|
|
|
|
bRet = aBase64Exp.exportXML( xIn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2001-03-30 09:49:34 +00:00
|
|
|
ProgressBarHelper* SvXMLExport::GetProgressBarHelper()
|
|
|
|
{
|
|
|
|
if (!pProgressBarHelper)
|
|
|
|
{
|
|
|
|
pProgressBarHelper = new ProgressBarHelper(xStatusIndicator, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "XML Export" )));
|
|
|
|
|
|
|
|
if (pProgressBarHelper && xExportInfo.is())
|
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xExportInfo->getPropertySetInfo();
|
|
|
|
if (xPropertySetInfo.is())
|
|
|
|
{
|
|
|
|
OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
|
|
|
|
OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
|
|
|
|
OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
|
|
|
|
if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
|
|
|
|
xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
|
|
|
|
xPropertySetInfo->hasPropertyByName(sProgressRange))
|
|
|
|
{
|
|
|
|
uno::Any aAny;
|
|
|
|
sal_Int32 nProgressMax(0);
|
|
|
|
sal_Int32 nProgressCurrent(0);
|
|
|
|
sal_Int32 nProgressRange(0);
|
|
|
|
aAny = xExportInfo->getPropertyValue(sProgressRange);
|
|
|
|
if (aAny >>= nProgressRange)
|
|
|
|
pProgressBarHelper->SetRange(nProgressRange);
|
|
|
|
aAny = xExportInfo->getPropertyValue(sProgressMax);
|
|
|
|
if (aAny >>= nProgressMax)
|
|
|
|
pProgressBarHelper->SetReference(nProgressMax);
|
|
|
|
aAny = xExportInfo->getPropertyValue(sProgressCurrent);
|
|
|
|
if (aAny >>= nProgressCurrent)
|
|
|
|
pProgressBarHelper->SetValue(nProgressCurrent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pProgressBarHelper;
|
|
|
|
}
|
|
|
|
|
2000-12-19 17:56:47 +00:00
|
|
|
XMLEventExport& SvXMLExport::GetEventExport()
|
|
|
|
{
|
|
|
|
if( NULL == pEventExport)
|
|
|
|
{
|
|
|
|
// create EventExport on demand
|
|
|
|
pEventExport = new XMLEventExport(*this, NULL);
|
|
|
|
|
|
|
|
// and register standard handlers + names
|
|
|
|
OUString sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
|
|
|
|
pEventExport->AddHandler(sStarBasic, new XMLStarBasicExportHandler());
|
|
|
|
pEventExport->AddTranslationTable(aStandardEventTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *pEventExport;
|
|
|
|
}
|
|
|
|
|
2001-03-28 09:28:16 +00:00
|
|
|
XMLImageMapExport& SvXMLExport::GetImageMapExport()
|
|
|
|
{
|
|
|
|
// image map export, create on-demand
|
|
|
|
if( NULL == pImageMapExport )
|
|
|
|
{
|
|
|
|
pImageMapExport = new XMLImageMapExport(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *pImageMapExport;
|
|
|
|
}
|
|
|
|
|
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() )
|
|
|
|
return (SvXMLExport*)xUT->getSomething( SvXMLExport::getUnoTunnelId() );
|
|
|
|
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 ) )
|
|
|
|
{
|
|
|
|
return (sal_Int64)this;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-05-09 11:22:39 +00:00
|
|
|
sal_Bool SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent >& rComp )
|
|
|
|
{
|
|
|
|
OUString sFilterService;
|
|
|
|
|
|
|
|
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 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pEntry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OSL_ENSURE( sFilterService.getLength(), "no export filter for own object" );
|
|
|
|
|
|
|
|
if( !sFilterService.getLength() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
Reference < XDocumentHandler > xHdl =
|
|
|
|
new XMLEmbeddedObjectExportFilter( xHandler );
|
|
|
|
|
|
|
|
Sequence < Any > aArgs( 1 );
|
|
|
|
aArgs[0] <<= xHdl;
|
|
|
|
|
|
|
|
Reference< lang::XMultiServiceFactory > xServiceFactory =
|
|
|
|
comphelper::getProcessServiceFactory();
|
|
|
|
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-04-30 12:37:27 +00:00
|
|
|
void SvXMLElementExport::StartElement( SvXMLExport& rExp,
|
|
|
|
sal_uInt16 nPrefixKey,
|
|
|
|
const OUString& rLName,
|
|
|
|
sal_Bool bIWSOutside )
|
|
|
|
{
|
|
|
|
aName = rExp.GetNamespaceMap().GetQNameByKey( nPrefixKey, rLName );
|
|
|
|
|
|
|
|
if( bIWSOutside )
|
|
|
|
rExport.GetDocHandler()->ignorableWhitespace( rExport.sWS );
|
|
|
|
rExport.GetDocHandler()->startElement( aName, rExport.GetXAttrList() );
|
|
|
|
rExport.ClearAttrList();
|
|
|
|
}
|
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 )
|
|
|
|
StartElement( rExp, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:31:44 +00:00
|
|
|
SvXMLElementExport::~SvXMLElementExport()
|
|
|
|
{
|
2001-04-30 12:37:27 +00:00
|
|
|
if( bDoSomething )
|
|
|
|
{
|
|
|
|
if( bIgnWS )
|
|
|
|
rExport.GetDocHandler()->ignorableWhitespace( rExport.sWS );
|
|
|
|
rExport.GetDocHandler()->endElement( aName );
|
|
|
|
}
|
2000-09-18 23:31:44 +00:00
|
|
|
}
|
|
|
|
|