From 94ccba3eebc83b58e74e18f0e028c6a995ce6aa6 Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Mon, 9 Jul 2007 10:56:41 +0000 Subject: Bring module to HEAD. --- reportdesign/source/filter/xml/dbloader2.cxx | 138 ++ reportdesign/source/filter/xml/dbloader2.hxx | 197 +++ reportdesign/source/filter/xml/makefile.mk | 99 ++ reportdesign/source/filter/xml/xmlAutoStyle.cxx | 118 ++ reportdesign/source/filter/xml/xmlAutoStyle.hxx | 76 + reportdesign/source/filter/xml/xmlCell.cxx | 327 ++++ reportdesign/source/filter/xml/xmlCell.hxx | 84 + reportdesign/source/filter/xml/xmlColumn.cxx | 223 +++ reportdesign/source/filter/xml/xmlColumn.hxx | 74 + reportdesign/source/filter/xml/xmlComponent.cxx | 164 ++ reportdesign/source/filter/xml/xmlComponent.hxx | 76 + reportdesign/source/filter/xml/xmlCondPrtExpr.cxx | 131 ++ reportdesign/source/filter/xml/xmlCondPrtExpr.hxx | 70 + .../source/filter/xml/xmlControlProperty.cxx | 392 +++++ .../source/filter/xml/xmlControlProperty.hxx | 106 ++ reportdesign/source/filter/xml/xmlEnums.hxx | 183 +++ reportdesign/source/filter/xml/xmlExport.cxx | 1667 ++++++++++++++++++++ reportdesign/source/filter/xml/xmlExport.hxx | 327 ++++ reportdesign/source/filter/xml/xmlFixedContent.cxx | 239 +++ reportdesign/source/filter/xml/xmlFixedContent.hxx | 81 + .../source/filter/xml/xmlFormatCondition.cxx | 158 ++ .../source/filter/xml/xmlFormatCondition.hxx | 69 + .../source/filter/xml/xmlFormattedField.cxx | 139 ++ .../source/filter/xml/xmlFormattedField.hxx | 67 + reportdesign/source/filter/xml/xmlFunction.cxx | 156 ++ reportdesign/source/filter/xml/xmlFunction.hxx | 81 + reportdesign/source/filter/xml/xmlGroup.cxx | 251 +++ reportdesign/source/filter/xml/xmlGroup.hxx | 80 + reportdesign/source/filter/xml/xmlHelper.cxx | 487 ++++++ reportdesign/source/filter/xml/xmlHelper.hxx | 112 ++ reportdesign/source/filter/xml/xmlImage.cxx | 142 ++ reportdesign/source/filter/xml/xmlImage.hxx | 65 + reportdesign/source/filter/xml/xmlMasterFields.cxx | 146 ++ reportdesign/source/filter/xml/xmlMasterFields.hxx | 67 + .../source/filter/xml/xmlPropertyHandler.cxx | 75 + .../source/filter/xml/xmlPropertyHandler.hxx | 62 + reportdesign/source/filter/xml/xmlReport.cxx | 254 +++ reportdesign/source/filter/xml/xmlReport.hxx | 73 + .../source/filter/xml/xmlReportElement.cxx | 173 ++ .../source/filter/xml/xmlReportElement.hxx | 70 + .../source/filter/xml/xmlReportElementBase.cxx | 137 ++ .../source/filter/xml/xmlReportElementBase.hxx | 81 + reportdesign/source/filter/xml/xmlRow.cxx | 213 +++ reportdesign/source/filter/xml/xmlRow.hxx | 73 + reportdesign/source/filter/xml/xmlSection.cxx | 193 +++ reportdesign/source/filter/xml/xmlSection.hxx | 76 + reportdesign/source/filter/xml/xmlStyleImport.cxx | 503 ++++++ reportdesign/source/filter/xml/xmlStyleImport.hxx | 190 +++ reportdesign/source/filter/xml/xmlSubDocument.cxx | 134 ++ reportdesign/source/filter/xml/xmlSubDocument.hxx | 77 + reportdesign/source/filter/xml/xmlTable.cxx | 341 ++++ reportdesign/source/filter/xml/xmlTable.hxx | 111 ++ reportdesign/source/filter/xml/xmlfilter.cxx | 1068 +++++++++++++ reportdesign/source/filter/xml/xmlfilter.hxx | 277 ++++ reportdesign/source/filter/xml/xmlservices.cxx | 116 ++ 55 files changed, 11089 insertions(+) create mode 100644 reportdesign/source/filter/xml/dbloader2.cxx create mode 100644 reportdesign/source/filter/xml/dbloader2.hxx create mode 100644 reportdesign/source/filter/xml/makefile.mk create mode 100644 reportdesign/source/filter/xml/xmlAutoStyle.cxx create mode 100644 reportdesign/source/filter/xml/xmlAutoStyle.hxx create mode 100644 reportdesign/source/filter/xml/xmlCell.cxx create mode 100644 reportdesign/source/filter/xml/xmlCell.hxx create mode 100644 reportdesign/source/filter/xml/xmlColumn.cxx create mode 100644 reportdesign/source/filter/xml/xmlColumn.hxx create mode 100644 reportdesign/source/filter/xml/xmlComponent.cxx create mode 100644 reportdesign/source/filter/xml/xmlComponent.hxx create mode 100644 reportdesign/source/filter/xml/xmlCondPrtExpr.cxx create mode 100644 reportdesign/source/filter/xml/xmlCondPrtExpr.hxx create mode 100644 reportdesign/source/filter/xml/xmlControlProperty.cxx create mode 100644 reportdesign/source/filter/xml/xmlControlProperty.hxx create mode 100644 reportdesign/source/filter/xml/xmlEnums.hxx create mode 100644 reportdesign/source/filter/xml/xmlExport.cxx create mode 100644 reportdesign/source/filter/xml/xmlExport.hxx create mode 100644 reportdesign/source/filter/xml/xmlFixedContent.cxx create mode 100644 reportdesign/source/filter/xml/xmlFixedContent.hxx create mode 100644 reportdesign/source/filter/xml/xmlFormatCondition.cxx create mode 100644 reportdesign/source/filter/xml/xmlFormatCondition.hxx create mode 100644 reportdesign/source/filter/xml/xmlFormattedField.cxx create mode 100644 reportdesign/source/filter/xml/xmlFormattedField.hxx create mode 100644 reportdesign/source/filter/xml/xmlFunction.cxx create mode 100644 reportdesign/source/filter/xml/xmlFunction.hxx create mode 100644 reportdesign/source/filter/xml/xmlGroup.cxx create mode 100644 reportdesign/source/filter/xml/xmlGroup.hxx create mode 100644 reportdesign/source/filter/xml/xmlHelper.cxx create mode 100644 reportdesign/source/filter/xml/xmlHelper.hxx create mode 100644 reportdesign/source/filter/xml/xmlImage.cxx create mode 100644 reportdesign/source/filter/xml/xmlImage.hxx create mode 100644 reportdesign/source/filter/xml/xmlMasterFields.cxx create mode 100644 reportdesign/source/filter/xml/xmlMasterFields.hxx create mode 100644 reportdesign/source/filter/xml/xmlPropertyHandler.cxx create mode 100644 reportdesign/source/filter/xml/xmlPropertyHandler.hxx create mode 100644 reportdesign/source/filter/xml/xmlReport.cxx create mode 100644 reportdesign/source/filter/xml/xmlReport.hxx create mode 100644 reportdesign/source/filter/xml/xmlReportElement.cxx create mode 100644 reportdesign/source/filter/xml/xmlReportElement.hxx create mode 100644 reportdesign/source/filter/xml/xmlReportElementBase.cxx create mode 100644 reportdesign/source/filter/xml/xmlReportElementBase.hxx create mode 100644 reportdesign/source/filter/xml/xmlRow.cxx create mode 100644 reportdesign/source/filter/xml/xmlRow.hxx create mode 100644 reportdesign/source/filter/xml/xmlSection.cxx create mode 100644 reportdesign/source/filter/xml/xmlSection.hxx create mode 100644 reportdesign/source/filter/xml/xmlStyleImport.cxx create mode 100644 reportdesign/source/filter/xml/xmlStyleImport.hxx create mode 100644 reportdesign/source/filter/xml/xmlSubDocument.cxx create mode 100644 reportdesign/source/filter/xml/xmlSubDocument.hxx create mode 100644 reportdesign/source/filter/xml/xmlTable.cxx create mode 100644 reportdesign/source/filter/xml/xmlTable.hxx create mode 100644 reportdesign/source/filter/xml/xmlfilter.cxx create mode 100644 reportdesign/source/filter/xml/xmlfilter.hxx create mode 100644 reportdesign/source/filter/xml/xmlservices.cxx (limited to 'reportdesign/source/filter/xml') diff --git a/reportdesign/source/filter/xml/dbloader2.cxx b/reportdesign/source/filter/xml/dbloader2.cxx new file mode 100644 index 000000000000..afe665418c01 --- /dev/null +++ b/reportdesign/source/filter/xml/dbloader2.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dbloader2.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPTXML_DBLOADER2_HXX +#include "dbloader2.hxx" +#endif +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include +#endif +// ------------------------------------------------------------------------- +namespace rptxml +{ + +using namespace ::ucbhelper; +using namespace ::com::sun::star::task; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::registry; +using namespace ::com::sun::star::embed; +using namespace ::com::sun::star::ui::dialogs; +using ::com::sun::star::awt::XWindow; + +// ------------------------------------------------------------------------- +ORptTypeDetection::ORptTypeDetection(Reference< XComponentContext > const & xContext) +: m_xContext(xContext) +{ +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ORptTypeDetection::detect( Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (RuntimeException) +{ + + ::comphelper::SequenceAsHashMap aTemp(Descriptor); + ::rtl::OUString sTemp = aTemp.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")),::rtl::OUString()); + + if ( sTemp.getLength() ) + { + INetURLObject aURL(sTemp); + if ( aURL.GetExtension().equalsIgnoreAsciiCaseAscii("orp") ) + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBaseReport")); + else + { + try + { + Reference xProp(::comphelper::OStorageHelper::GetStorageFromURL(sTemp,ElementModes::READ,Reference< XMultiServiceFactory >(m_xContext->getServiceManager(),UNO_QUERY)),UNO_QUERY); + if ( xProp.is() ) + { + ::rtl::OUString sMediaType; + xProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")) ) >>= sMediaType; + if ( sMediaType.equalsAscii(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII) ) + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBaseReport")); + ::comphelper::disposeComponent(xProp); + } // if ( xProp.is() ) + } + catch(Exception&) + { + } + } + } + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL + ORptTypeDetection::create(Reference< XComponentContext > const & xContext) +{ + return *(new ORptTypeDetection(xContext)); +} +// ------------------------------------------------------------------------- +// XServiceInfo +::rtl::OUString SAL_CALL ORptTypeDetection::getImplementationName() throw( ) +{ + return getImplementationName_Static(); +} +// ------------------------------------------------------------------------- + +// XServiceInfo +sal_Bool SAL_CALL ORptTypeDetection::supportsService(const ::rtl::OUString& ServiceName) throw( ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ------------------------------------------------------------------------- +// XServiceInfo +Sequence< ::rtl::OUString > SAL_CALL ORptTypeDetection::getSupportedServiceNames(void) throw( ) +{ + return getSupportedServiceNames_Static(); +} +// ------------------------------------------------------------------------- +// ORegistryServiceManager_Static +Sequence< ::rtl::OUString > ORptTypeDetection::getSupportedServiceNames_Static(void) throw( RuntimeException ) +{ + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExtendedTypeDetection"); + return aSNS; +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +}//rptxml +// ----------------------------------------------------------------------------- + diff --git a/reportdesign/source/filter/xml/dbloader2.hxx b/reportdesign/source/filter/xml/dbloader2.hxx new file mode 100644 index 000000000000..ec9289f60c21 --- /dev/null +++ b/reportdesign/source/filter/xml/dbloader2.hxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dbloader2.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef RPTXML_DBLOADER2_HXX +#define RPTXML_DBLOADER2_HXX + +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include +#endif +#ifndef _URLOBJ_HXX //autogen +#include +#endif +#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATORFACTORY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAMELOADER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XLOADEVENTLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEXTENDEDFILTERDETECTION_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _SV_SVAPP_HXX +#include +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include +#endif +#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX +#include +#endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include +#endif +#ifndef _COMPHELPER_DOCUMENTCONSTANTS_HXX +#include +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include +#endif +#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_ +#include +#endif +#ifndef _OSL_FILE_HXX_ +#include +#endif +#ifndef _UCBHELPER_CONTENTBROKER_HXX +#include +#endif +#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium +#include +#endif +#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX +#include +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include +#endif +#ifndef _COMPHELPER_STORAGEHELPER_HXX +#include +#endif +#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_ +#include +#endif +#ifndef _SV_MSGBOX_HXX +#include +#endif + +// ------------------------------------------------------------------------- +namespace rptxml +{ + + class ORptTypeDetection : public ::cppu::WeakImplHelper2< ::com::sun::star::document::XExtendedFilterDetection, ::com::sun::star::lang::XServiceInfo> +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; +public: + ORptTypeDetection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName() throw( ); + sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( ); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ); + + // static methods + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ) + { + return ::rtl::OUString::createFromAscii("com.sun.star.comp.report.ORptTypeDetection"); + } + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + + virtual ::rtl::OUString SAL_CALL detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (::com::sun::star::uno::RuntimeException); +}; +} +#endif diff --git a/reportdesign/source/filter/xml/makefile.mk b/reportdesign/source/filter/xml/makefile.mk new file mode 100644 index 000000000000..2b4054d6bc9f --- /dev/null +++ b/reportdesign/source/filter/xml/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.2 $ +# +# last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 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 +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=reportdesign +TARGET=rptxml + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.INCLUDE : settings.mk + +# --- Types ------------------------------------- + +UNOTYPES=\ + com.sun.star.uno.RuntimeException \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XInterface \ + com.sun.star.uno.XWeak \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.io.XInputStream \ + com.sun.star.io.XOutputStream \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.XInitialization \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.XServiceInfo \ + com.sun.star.loader.XImplementationLoader \ + com.sun.star.registry.XImplementationRegistration \ + com.sun.star.registry.XSimpleRegistry \ + com.sun.star.document.XFilter \ + com.sun.star.document.XExporter \ + com.sun.star.container.XIndexAccess +# --- Files ------------------------------------- + +SLOFILES= $(SLO)$/xmlfilter.obj \ + $(SLO)$/xmlReport.obj \ + $(SLO)$/xmlSubDocument.obj \ + $(SLO)$/xmlMasterFields.obj \ + $(SLO)$/xmlGroup.obj \ + $(SLO)$/xmlHelper.obj \ + $(SLO)$/xmlSection.obj \ + $(SLO)$/xmlComponent.obj \ + $(SLO)$/xmlControlProperty.obj \ + $(SLO)$/xmlFormattedField.obj \ + $(SLO)$/xmlFixedText.obj \ + $(SLO)$/xmlReportElement.obj \ + $(SLO)$/xmlReportElementBase.obj \ + $(SLO)$/xmlCondPrtExpr.obj \ + $(SLO)$/xmlImage.obj \ + $(SLO)$/xmlFunction.obj \ + $(SLO)$/xmlStyleImport.obj \ + $(SLO)$/xmlAutoStyle.obj \ + $(SLO)$/xmlExport.obj \ + $(SLO)$/dbloader2.obj \ + $(SLO)$/xmlFormatCondition.obj \ + $(SLO)$/xmlPropertyHandler.obj \ + $(SLO)$/xmlColumn.obj \ + $(SLO)$/xmlCell.obj \ + $(SLO)$/xmlTable.obj \ + $(SLO)$/xmlFixedContent.obj \ + $(SLO)$/xmlservices.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/reportdesign/source/filter/xml/xmlAutoStyle.cxx b/reportdesign/source/filter/xml/xmlAutoStyle.cxx new file mode 100644 index 000000000000..984c79280af1 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlAutoStyle.cxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlAutoStyle.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLAUTOSTYLE_HXX +#include "xmlAutoStyle.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_XMLEXPORT_HXX +#include "xmlExport.hxx" +#endif +#ifndef _XMLOFF_FAMILIES_HXX_ +#include +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; + +void OXMLAutoStylePoolP::exportStyleAttributes( + SvXMLAttributeList& rAttrList, + sal_Int32 nFamily, + const ::std::vector< XMLPropertyState >& rProperties, + const SvXMLExportPropertyMapper& rPropExp + , const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap + ) const +{ + SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap ); + if ( nFamily == XML_STYLE_FAMILY_TABLE_CELL ) + { + UniReference< XMLPropertySetMapper > aPropMapper = rORptExport.GetCellStylePropertyMapper(); + ::std::vector< XMLPropertyState >::const_iterator i = rProperties.begin(); + ::std::vector< XMLPropertyState >::const_iterator aEnd = rProperties.end(); + for (; i != aEnd ; ++i) + { + sal_Int16 nContextID = aPropMapper->GetEntryContextId(i->mnIndex); + switch (nContextID) + { + case CTF_RPT_NUMBERFORMAT : + { + rtl::OUString sAttrValue; + if ( i->maValue >>= sAttrValue ) + { + if ( sAttrValue.getLength() ) + { + rORptExport.AddAttribute( + aPropMapper->GetEntryNameSpace(i->mnIndex), + aPropMapper->GetEntryXMLName(i->mnIndex), + sAttrValue ); + } + } + break; + } + default: + break; + } + } + } +} +DBG_NAME( rpt_OXMLAutoStylePoolP ) +// ----------------------------------------------------------------------------- +OXMLAutoStylePoolP::OXMLAutoStylePoolP(ORptExport& rTempORptExport): + SvXMLAutoStylePoolP(rTempORptExport), + rORptExport(rTempORptExport) +{ + DBG_CTOR( rpt_OXMLAutoStylePoolP,NULL); + +} +// ----------------------------------------------------------------------------- +OXMLAutoStylePoolP::~OXMLAutoStylePoolP() +{ + + DBG_DTOR( rpt_OXMLAutoStylePoolP,NULL); +} +// ----------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlAutoStyle.hxx b/reportdesign/source/filter/xml/xmlAutoStyle.hxx new file mode 100644 index 000000000000..5de31999d8d0 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlAutoStyle.hxx @@ -0,0 +1,76 @@ +#ifndef RPT_XMLAUTOSTYLE_HXX +#define RPT_XMLAUTOSTYLE_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlAutoStyle.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX +#include +#endif +#ifndef _XMLOFF_XMLASTPLP_HXX +#include +#endif +#ifndef _XMLOFF_XMLTYPES_HXX +#include +#endif +#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX +#include +#endif + +namespace rptxml +{ + class ORptExport; + class OXMLAutoStylePoolP : public SvXMLAutoStylePoolP + { + ORptExport& rORptExport; + + virtual void exportStyleAttributes( + SvXMLAttributeList& rAttrList, + sal_Int32 nFamily, + const ::std::vector< XMLPropertyState >& rProperties, + const SvXMLExportPropertyMapper& rPropExp, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap + ) const; + + OXMLAutoStylePoolP(const OXMLAutoStylePoolP&); + void operator =(const OXMLAutoStylePoolP&); + public: + OXMLAutoStylePoolP(ORptExport& rXMLExport); + virtual ~OXMLAutoStylePoolP(); + }; +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- +#endif // RPT_XMLAUTOSTYLE_HXX + diff --git a/reportdesign/source/filter/xml/xmlCell.cxx b/reportdesign/source/filter/xml/xmlCell.cxx new file mode 100644 index 000000000000..9eed081a3dce --- /dev/null +++ b/reportdesign/source/filter/xml/xmlCell.cxx @@ -0,0 +1,327 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlCell.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLCELL_HXX +#include "xmlCell.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef _COMPHELPER_NAMECONTAINER_HXX_ +#include +#endif +#ifndef _COMPHELPER_GENERICPROPERTYSET_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_ +#include +#endif +#include +#include +#ifndef RPT_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef RPT_XMLTABLE_HXX +#include "xmlTable.hxx" +#endif +#ifndef RPT_XMLFIXEDTEXT_HXX +#include "xmlFixedText.hxx" +#endif +#ifndef RPT_XMLFORMATTEDFIELD_HXX +#include "xmlFormattedField.hxx" +#endif +#ifndef RPT_XMLIMAGE_HXX +#include "xmlImage.hxx" +#endif +#ifndef RPT_XMLSUBDOCUMENT_HXX +#include "xmlSubDocument.hxx" +#endif +#ifndef RPT_XMLFIXEDCONTENT_HXX +#include "xmlFixedContent.hxx" +#endif + +namespace rptxml +{ + using namespace ::comphelper; + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace uno; + using namespace beans; + using namespace xml::sax; + +DBG_NAME( rpt_OXMLCell ) + +OXMLCell::OXMLCell( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,OXMLTable* _pContainer + ,OXMLCell* _pCell) : + SvXMLImportContext( rImport, nPrfx, _sLocalName ) + ,m_pContainer(_pContainer) + ,m_pCell(_pCell) + ,m_bShape(false) +{ + DBG_CTOR( rpt_OXMLCell,NULL); + if ( !m_pCell ) + m_pCell = this; + + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_COLUMN_STYLE_NAME: + m_sStyleName = sValue; + break; + case XML_TOK_NUMBER_COLUMNS_SPANNED: + m_pContainer->setColumnSpanned(sValue.toInt32()); + break; + case XML_TOK_NUMBER_ROWS_SPANNED: + m_pContainer->setRowSpanned(sValue.toInt32()); + break; + default: + break; + } + } +} +// ----------------------------------------------------------------------------- +OXMLCell::~OXMLCell() +{ + DBG_DTOR( rpt_OXMLCell,NULL); +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLCell::CreateChildContext( + sal_uInt16 _nPrefix, + const OUString& _rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetCellElemTokenMap(); + Reference xFactor(rImport.GetModel(),uno::UNO_QUERY); + static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & ")); + + sal_uInt16 nToken = rTokenMap.Get( _nPrefix, _rLocalName ); + switch( nToken ) + { + case XML_TOK_FIXED_CONTENT: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLFixedContent( rImport, _nPrefix, _rLocalName,*m_pCell,m_pContainer); + } + break; + case XML_TOK_PAGE_NUMBER: + m_sText += s_sStringConcat + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PageNumber()")); + break; + case XML_TOK_PAGE_COUNT: + m_sText += s_sStringConcat + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PageCount()")); + break; + case XML_TOK_FORMATTED_TEXT: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD); + Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY); + + OSL_ENSURE(xControl.is(),"Could not create FormattedField!"); + setComponent(xControl.get()); + if ( xControl.is() ) + pContext = new OXMLFormattedField( rImport, _nPrefix, _rLocalName,xAttrList,xControl.get(),m_pContainer,XML_TOK_PAGE_COUNT == nToken); + } + break; + case XML_TOK_IMAGE: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + Reference< XImageControl > xControl(xFactor->createInstance(SERVICE_IMAGECONTROL),uno::UNO_QUERY); + + OSL_ENSURE(xControl.is(),"Could not create ImageControl!"); + setComponent(xControl.get()); + if ( xControl.is() ) + pContext = new OXMLImage( rImport, _nPrefix, _rLocalName,xAttrList,xControl.get(),m_pContainer); + } + break; + case XML_TOK_SUB_DOCUMENT: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + Reference< XReportDefinition > xControl(xFactor->createInstance(SERVICE_REPORTDEFINITION),uno::UNO_QUERY); + + OSL_ENSURE(xControl.is(),"Could not create ReportDefinition!"); + setComponent(xControl.get()); + if ( xControl.is() ) + pContext = new OXMLSubDocument( rImport, _nPrefix, _rLocalName,xControl.get(),m_pContainer); + } + break; + + case XML_TOK_P: + pContext = new OXMLCell( rImport, _nPrefix, _rLocalName,xAttrList ,m_pContainer,this); + break; + case XML_TOK_CUSTOM_SHAPE: + { + UniReference< XMLShapeImportHelper > xShapeImportHelper = rImport.GetShapeImport(); + uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get(); + pContext = xShapeImportHelper->CreateGroupChildContext(rImport,_nPrefix,_rLocalName,xAttrList,xShapes); + m_bShape = true; + } + break; + default: + break; + } + + if ( m_xComponent.is() ) + m_pContainer->addCell(m_xComponent); + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLCell::EndElement() +{ + if ( m_bShape ) + { + m_xComponent.set(m_pContainer->getSection()->getByIndex(m_pContainer->getSection()->getCount()-1),uno::UNO_QUERY); + m_pContainer->addCell(m_xComponent); + m_pCell->setComponent(m_xComponent); + } + else if ( m_pCell != this && m_sText.getLength() ) + { + ORptFilter& rImport = GetOwnImport(); + Reference xFactor(rImport.GetModel(),uno::UNO_QUERY); + uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD); + Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY); + xControl->setDataField(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + m_sText); + + OSL_ENSURE(xControl.is(),"Could not create FormattedField!"); + setComponent(xControl.get()); + m_xComponent = xControl.get(); + m_pContainer->getSection()->add(m_xComponent.get()); + m_pContainer->addCell(m_xComponent); + } + // check if we have a FixedLine + else if ( m_sStyleName.getLength() && !m_xComponent.is() && m_pCell == this ) + { + ORptFilter& rImport = GetOwnImport(); + Reference xFactor(rImport.GetModel(),uno::UNO_QUERY); + Reference xFixedLine(xFactor->createInstance(SERVICE_FIXEDLINE),uno::UNO_QUERY); + m_xComponent = xFixedLine.get(); + m_pContainer->getSection()->add(m_xComponent.get()); + m_pContainer->addCell(m_xComponent); + XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,GetImport().GetAutoStyles()->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,m_sStyleName)); + if ( pAutoStyle ) + { + uno::Reference xBorderProp = OXMLHelper::createBorderPropertySet(); + try + { + pAutoStyle->FillPropertySet(xBorderProp); + table::BorderLine aRight,aLeft; + xBorderProp->getPropertyValue(PROPERTY_BORDERRIGHT) >>= aRight; + xBorderProp->getPropertyValue(PROPERTY_BORDERLEFT) >>= aLeft; + xFixedLine->setOrientation( (aRight.OuterLineWidth != 0 || aLeft.OuterLineWidth != 0) ? 1 : 0); + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"OXMLCell::EndElement -> exception catched"); + } + } + } + else + OXMLHelper::copyStyleElements(m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get()); +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLCell::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +void OXMLCell::setComponent(const uno::Reference< report::XReportComponent >& _xComponent) +{ + m_pCell->m_xComponent = _xComponent; + m_xComponent = _xComponent; +} +// ----------------------------------------------------------------------------- +void OXMLCell::Characters( const ::rtl::OUString& rChars ) +{ + if ( rChars.getLength() ) + { + static const ::rtl::OUString s_Quote(RTL_CONSTASCII_USTRINGPARAM("\"")); + if ( m_sText.getLength() ) + { + static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & ")); + m_sText += s_sStringConcat; + } + + m_sText += s_Quote + rChars + s_Quote; + } +} + +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + diff --git a/reportdesign/source/filter/xml/xmlCell.hxx b/reportdesign/source/filter/xml/xmlCell.hxx new file mode 100644 index 000000000000..6e7d929386c7 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlCell.hxx @@ -0,0 +1,84 @@ +#ifndef RPT_XMLCELL_HXX +#define RPT_XMLCELL_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlCell.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCOMPONENT_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLTable; + class OXMLCell : public SvXMLImportContext + { + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > m_xComponent; + OXMLTable* m_pContainer; + OXMLCell* m_pCell; + ::rtl::OUString m_sStyleName; + ::rtl::OUString m_sText; + bool m_bShape; + + ORptFilter& GetOwnImport(); + OXMLCell(const OXMLCell&); + void operator =(const OXMLCell&); + public: + + OXMLCell( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,OXMLTable* _pContainer + ,OXMLCell* _pCell = NULL); + virtual ~OXMLCell(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void Characters( const ::rtl::OUString& rChars ); + virtual void EndElement(); + + void setComponent(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent >& _xComponent); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLCELL_HXX diff --git a/reportdesign/source/filter/xml/xmlColumn.cxx b/reportdesign/source/filter/xml/xmlColumn.cxx new file mode 100644 index 000000000000..a0d934c72e20 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlColumn.cxx @@ -0,0 +1,223 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlColumn.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLCOLUMN_HXX +#include "xmlColumn.hxx" +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCELL_HXX +#include "xmlCell.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef RPT_XMLTABLE_HXX +#include "xmlTable.hxx" +#endif +#ifndef _COMPHELPER_NAMECONTAINER_HXX_ +#include +#endif +#ifndef _COMPHELPER_GENERICPROPERTYSET_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_ +#include +#endif +#ifndef RPT_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif + +#define PROPERTY_ID_WIDTH 1 +#define PROPERTY_ID_HEIGHT 2 + +namespace rptxml +{ + using namespace ::comphelper; + using namespace ::rtl; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::xml::sax; + +DBG_NAME( rpt_OXMLRowColumn ) + +OXMLRowColumn::OXMLRowColumn( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,OXMLTable* _pContainer + ) : + SvXMLImportContext( rImport, nPrfx, _sLocalName ) + ,m_pContainer(_pContainer) +{ + DBG_CTOR( rpt_OXMLRowColumn,NULL); + + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_COLUMN_STYLE_NAME: + fillStyle(sValue); + break; + default: + break; + } + } +} +// ----------------------------------------------------------------------------- + +OXMLRowColumn::~OXMLRowColumn() +{ + DBG_DTOR( rpt_OXMLRowColumn,NULL); +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLRowColumn::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_COLUMN: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRowColumn( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + case XML_TOK_ROW: + m_pContainer->incrementRowIndex(); + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRowColumn( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + case XML_TOK_CELL: + m_pContainer->incrementColumnIndex(); + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLCell( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + case XML_TOK_COV_CELL: + m_pContainer->incrementColumnIndex(); + m_pContainer->addCell(NULL); + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLRowColumn::fillStyle(const ::rtl::OUString& _sStyleName) +{ + if ( _sStyleName.getLength() ) + { + const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles(); + if ( pAutoStyles ) + { + PropertySetInfo* pInfo = new PropertySetInfo(); + static PropertyMapEntry pMap[] = + { + {PROPERTY_WIDTH, static_cast(PROPERTY_WIDTH.length), PROPERTY_ID_WIDTH, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0}, + {PROPERTY_HEIGHT, static_cast(PROPERTY_HEIGHT.length), PROPERTY_ID_HEIGHT, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0}, + { NULL, 0, 0, NULL, 0, 0 } + }; + pInfo->add(pMap); + Reference xProp = GenericPropertySet_CreateInstance(pInfo); + XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_COLUMN,_sStyleName)); + if ( pAutoStyle ) + { + pAutoStyle->FillPropertySet(xProp); + sal_Int32 nWidth = 0; + xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth; + m_pContainer->addWidth(nWidth); + } + else + { + pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_ROW,_sStyleName)); + if ( pAutoStyle ) + { + pAutoStyle->FillPropertySet(xProp); + sal_Int32 nHeight = 0; + xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight; + m_pContainer->addHeight(nHeight); + } + } + } + } +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLRowColumn::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +void OXMLRowColumn::EndElement() +{ +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlColumn.hxx b/reportdesign/source/filter/xml/xmlColumn.hxx new file mode 100644 index 000000000000..4d2f6a0c44c9 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlColumn.hxx @@ -0,0 +1,74 @@ +#ifndef RPT_XMLCOLUMN_HXX +#define RPT_XMLCOLUMN_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlColumn.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLTable; + class OXMLRowColumn : public SvXMLImportContext + { + OXMLTable* m_pContainer; + + ORptFilter& GetOwnImport(); + + void fillStyle(const ::rtl::OUString& _sStyleName); + OXMLRowColumn(const OXMLRowColumn&); + void operator =(const OXMLRowColumn&); + public: + + OXMLRowColumn( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,OXMLTable* _pContainer + ); + virtual ~OXMLRowColumn(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLCOLUMN_HXX diff --git a/reportdesign/source/filter/xml/xmlComponent.cxx b/reportdesign/source/filter/xml/xmlComponent.cxx new file mode 100644 index 000000000000..82c68faf1725 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlComponent.cxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlComponent.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLCOMPONENT_HXX +#include "xmlComponent.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef _COMPHELPER_NAMECONTAINER_HXX_ +#include +#endif +#ifndef _COMPHELPER_GENERICPROPERTYSET_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCONTROLMODEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_ +#include +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::comphelper; + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::xml::sax; + DBG_NAME( rpt_OXMLComponent ) +OXMLComponent::OXMLComponent( ORptFilter& _rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XReportComponent > & _xComponent + ) : + SvXMLImportContext( _rImport, nPrfx, _sLocalName ) + ,m_xComponent(_xComponent) +{ + DBG_CTOR( rpt_OXMLComponent,NULL); + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); + + const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = _rImport.GetComponentElemTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + + for(sal_Int16 i = 0; i < nLength; ++i) + { + try + { + ::rtl::OUString sLocalName; + const ::rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + ::rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_NAME: + m_xComponent->setName(sValue); + break; + case XML_TOK_TEXT_STYLE_NAME: + m_sTextStyleName = sValue; + break; + case XML_TOK_TRANSFORM: + break; + default: + break; + } + } + catch(const Exception&) + { + OSL_ENSURE(0,"Exception catched while putting props into report component!"); + } + } +} +// ----------------------------------------------------------------------------- + +OXMLComponent::~OXMLComponent() +{ + DBG_DTOR( rpt_OXMLComponent,NULL); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +ORptFilter& OXMLComponent::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlComponent.hxx b/reportdesign/source/filter/xml/xmlComponent.hxx new file mode 100644 index 000000000000..dacbe84523ea --- /dev/null +++ b/reportdesign/source/filter/xml/xmlComponent.hxx @@ -0,0 +1,76 @@ +#ifndef RPT_XMLCOMPONENT_HXX +#define RPT_XMLCOMPONENT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlComponent.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCOMPONENT_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLComponent : public SvXMLImportContext + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > m_xComponent; + ::rtl::OUString m_sName; + ::rtl::OUString m_sTextStyleName; + + ORptFilter& GetOwnImport(); + + OXMLComponent(const OXMLComponent&); + void operator =(const OXMLComponent&); + public: + + OXMLComponent( ORptFilter& rImport + , sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent >& _xComponent + ); + virtual ~OXMLComponent(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLCOMPONENT_HXX diff --git a/reportdesign/source/filter/xml/xmlCondPrtExpr.cxx b/reportdesign/source/filter/xml/xmlCondPrtExpr.cxx new file mode 100644 index 000000000000..c4ff4df81415 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlCondPrtExpr.cxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlCondPrtExpr.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLCONDPRTEXPR_HXX +#include "xmlCondPrtExpr.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCONTROLPROPERTY_HXX +#include "xmlControlProperty.hxx" +#endif +#ifndef RPT_XMLCOMPONENT_HXX +#include "xmlComponent.hxx" +#endif +#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace report; + using namespace uno; + using namespace xml::sax; +DBG_NAME( rpt_OXMLCondPrtExpr ) + +OXMLCondPrtExpr::OXMLCondPrtExpr( ORptFilter& _rImport, + sal_uInt16 nPrfx + ,const OUString& rLName + ,const uno::Reference< xml::sax::XAttributeList > & _xAttrList + ,const Reference< XPropertySet > & _xComponent ) : + SvXMLImportContext( _rImport, nPrfx, rLName ) +,m_xComponent(_xComponent) +{ + DBG_CTOR( rpt_OXMLCondPrtExpr,NULL); + + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); + const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = _rImport.GetFunctionElemTokenMap(); + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + const rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_FUNCTION_FORMULA: + m_xComponent->setPropertyValue(PROPERTY_CONDITIONALPRINTEXPRESSION,uno::makeAny(ORptFilter::convertFormula(sValue))); + break; + default: + break; + } + + } + } + catch(const Exception&) + { + OSL_ENSURE(0,"Exception catched while putting Function props!"); + } +} +// ----------------------------------------------------------------------------- + +OXMLCondPrtExpr::~OXMLCondPrtExpr() +{ + + DBG_DTOR( rpt_OXMLCondPrtExpr,NULL); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +void OXMLCondPrtExpr::Characters( const ::rtl::OUString& rChars ) +{ + m_xComponent->setPropertyValue(PROPERTY_CONDITIONALPRINTEXPRESSION,makeAny(rChars)); +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx b/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx new file mode 100644 index 000000000000..b0163b53d3b1 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx @@ -0,0 +1,70 @@ +#ifndef RPT_XMLCONDPRTEXPR_HXX +#define RPT_XMLCONDPRTEXPR_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlCondPrtExpr.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLCondPrtExpr : public SvXMLImportContext + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent; + OXMLCondPrtExpr(const OXMLCondPrtExpr&); + void operator =(const OXMLCondPrtExpr&); + public: + + OXMLCondPrtExpr( ORptFilter& _rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & _xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xComponent); + virtual ~OXMLCondPrtExpr(); + + // This method is called for all characters that are contained in the + // current element. The default is to ignore them. + virtual void Characters( const ::rtl::OUString& rChars ); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLCONDPRTEXPR_HXX diff --git a/reportdesign/source/filter/xml/xmlControlProperty.cxx b/reportdesign/source/filter/xml/xmlControlProperty.cxx new file mode 100644 index 000000000000..aae7ea764f82 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlControlProperty.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlControlProperty.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLCONTROLPROPERTY_HXX +#include "xmlControlProperty.hxx" +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef _DATETIME_HXX +#include +#endif +#ifndef _UNOTOOLS_DATETIME_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include +#endif + +#define TYPE_DATE 1 +#define TYPE_TIME 2 +#define TYPE_DATETIME 3 + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::xml::sax; + +DBG_NAME( rpt_OXMLControlProperty ) + +OXMLControlProperty::OXMLControlProperty( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XPropertySet >& _xControl + ,OXMLControlProperty* _pContainer) : + SvXMLImportContext( rImport, nPrfx, _sLocalName ) + ,m_xControl(_xControl) + ,m_pContainer(_pContainer) + ,m_bIsList(sal_False) +{ + DBG_CTOR( rpt_OXMLControlProperty,NULL); + + m_aPropType = ::getVoidCppuType(); + + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + OSL_ENSURE(m_xControl.is(),"Control is NULL!"); + + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetControlPropertyElemTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_LIST_PROPERTY: + m_bIsList = sValue.equalsAscii("true"); + break; + case XML_TOK_VALUE_TYPE: + { + // needs to be translated into a ::com::sun::star::uno::Type + DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Type, MapString2Type ); + static MapString2Type s_aTypeNameMap; + if (!s_aTypeNameMap.size()) + { + s_aTypeNameMap[GetXMLToken( XML_BOOLEAN)] = ::getBooleanCppuType(); + s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::getCppuType( static_cast< double* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_DOUBLE)] = ::getCppuType( static_cast< double* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_STRING)] = ::getCppuType( static_cast< ::rtl::OUString* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_INT)] = ::getCppuType( static_cast< sal_Int32* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_SHORT)] = ::getCppuType( static_cast< sal_Int16* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_DATE)] = ::getCppuType( static_cast< com::sun::star::util::Date* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_TIME)] = ::getCppuType( static_cast< com::sun::star::util::Time* >(NULL) ); + s_aTypeNameMap[GetXMLToken( XML_VOID)] = ::getVoidCppuType(); + } + + const ConstMapString2TypeIterator aTypePos = s_aTypeNameMap.find(sValue); + OSL_ENSURE(s_aTypeNameMap.end() != aTypePos, "OXMLControlProperty::OXMLControlProperty: invalid type!"); + if (s_aTypeNameMap.end() != aTypePos) + m_aPropType = aTypePos->second; + } + break; + case XML_TOK_PROPERTY_NAME: + m_aSetting.Name = sValue; + break; + default: + break; + } + } + +} +// ----------------------------------------------------------------------------- + +OXMLControlProperty::~OXMLControlProperty() +{ + DBG_DTOR( rpt_OXMLControlProperty,NULL); +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLControlProperty::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetControlPropertyElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_LIST_PROPERTY: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLControlProperty( rImport, nPrefix, rLocalName,xAttrList,m_xControl); + break; + case XML_TOK_VALUE: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLControlProperty( rImport, nPrefix, rLocalName,xAttrList,m_xControl,this ); + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLControlProperty::EndElement() +{ + if ( m_aSetting.Name.getLength() && m_xControl.is() ) + { + if ( m_bIsList && !m_aSequence.getLength() ) + m_aSetting.Value <<= m_aSequence; + try + { + m_xControl->setPropertyValue(m_aSetting.Name,m_aSetting.Value); + } + catch(const Exception&) + { + OSL_ENSURE(0,"Unknown property found!"); + } + } +} +// ----------------------------------------------------------------------------- +void OXMLControlProperty::Characters( const ::rtl::OUString& rChars ) +{ + if ( m_pContainer ) + m_pContainer->addValue(rChars); +} +// ----------------------------------------------------------------------------- +void OXMLControlProperty::addValue(const ::rtl::OUString& _sValue) +{ + Any aValue; + if( TypeClass_VOID != m_aPropType.getTypeClass() ) + aValue = convertString(m_aPropType, _sValue); + + if ( !m_bIsList ) + m_aSetting.Value = aValue; + else + { + sal_Int32 nPos = m_aSequence.getLength(); + m_aSequence.realloc(nPos+1); + m_aSequence[nPos] = aValue; + } +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLControlProperty::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +Any OXMLControlProperty::convertString(const ::com::sun::star::uno::Type& _rExpectedType, const ::rtl::OUString& _rReadCharacters) +{ + ORptFilter& rImporter = GetOwnImport(); + Any aReturn; + switch (_rExpectedType.getTypeClass()) + { + case TypeClass_BOOLEAN: // sal_Bool + { + sal_Bool bValue; + #if OSL_DEBUG_LEVEL > 0 + sal_Bool bSuccess = + #endif + rImporter.GetMM100UnitConverter().convertBool(bValue, _rReadCharacters); + OSL_ENSURE(bSuccess, + ::rtl::OString("OXMLControlProperty::convertString: could not convert \"") + += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US) + += ::rtl::OString("\" into a boolean!")); + aReturn <<= bValue; + } + break; + case TypeClass_SHORT: // sal_Int16 + case TypeClass_LONG: // sal_Int32 + { // it's a real int32/16 property + sal_Int32 nValue(0); + #if OSL_DEBUG_LEVEL > 0 + sal_Bool bSuccess = + #endif + rImporter.GetMM100UnitConverter().convertNumber(nValue, _rReadCharacters); + OSL_ENSURE(bSuccess, + ::rtl::OString("OXMLControlProperty::convertString: could not convert \"") + += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US) + += ::rtl::OString("\" into an integer!")); + if (TypeClass_SHORT == _rExpectedType.getTypeClass()) + aReturn <<= (sal_Int16)nValue; + else + aReturn <<= (sal_Int32)nValue; + break; + } + case TypeClass_HYPER: + { + OSL_ENSURE(sal_False, "OXMLControlProperty::convertString: 64-bit integers not implemented yet!"); + } + break; + case TypeClass_DOUBLE: + { + double nValue = 0.0; + #if OSL_DEBUG_LEVEL > 0 + sal_Bool bSuccess = + #endif + rImporter.GetMM100UnitConverter().convertDouble(nValue, _rReadCharacters); + OSL_ENSURE(bSuccess, + ::rtl::OString("OXMLControlProperty::convertString: could not convert \"") + += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US) + += ::rtl::OString("\" into a double!")); + aReturn <<= (double)nValue; + } + break; + case TypeClass_STRING: + aReturn <<= _rReadCharacters; + break; + case TypeClass_STRUCT: + { + // recognized structs: + static ::com::sun::star::uno::Type s_aDateType = ::getCppuType(static_cast< ::com::sun::star::util::Date* >(NULL)); + static ::com::sun::star::uno::Type s_aTimeType = ::getCppuType(static_cast< ::com::sun::star::util::Time* >(NULL)); + static ::com::sun::star::uno::Type s_aDateTimeType = ::getCppuType(static_cast< ::com::sun::star::util::DateTime* >(NULL)); + sal_Int32 nType = 0; + if ( _rExpectedType.equals(s_aDateType) ) + nType = TYPE_DATE; + else if ( _rExpectedType.equals(s_aTimeType) ) + nType = TYPE_TIME; + else if ( _rExpectedType.equals(s_aDateTimeType) ) + nType = TYPE_DATETIME; + if ( !nType ) + { + // first extract the double + double nValue = 0; + #if OSL_DEBUG_LEVEL > 0 + sal_Bool bSuccess = + #endif + rImporter.GetMM100UnitConverter().convertDouble(nValue, _rReadCharacters); + OSL_ENSURE(bSuccess, + ::rtl::OString("OPropertyImport::convertString: could not convert \"") + += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US) + += ::rtl::OString("\" into a double!")); + + // then convert it into the target type + switch (nType) + { + case TYPE_DATE: + { + OSL_ENSURE(((sal_uInt32)nValue) - nValue == 0, + "OPropertyImport::convertString: a Date value with a fractional part?"); + aReturn <<= implGetDate(nValue); + } + break; + case TYPE_TIME: + { + OSL_ENSURE(((sal_uInt32)nValue) == 0, + "OPropertyImport::convertString: a Time value with more than a fractional part?"); + aReturn <<= implGetTime(nValue); + } + break; + case TYPE_DATETIME: + { + ::com::sun::star::util::Time aTime = implGetTime(nValue); + ::com::sun::star::util::Date aDate = implGetDate(nValue); + + ::com::sun::star::util::DateTime aDateTime; + aDateTime.HundredthSeconds = aTime.HundredthSeconds; + aDateTime.Seconds = aTime.Seconds; + aDateTime.Minutes = aTime.Minutes; + aDateTime.Hours = aTime.Hours; + aDateTime.Day = aDate.Day; + aDateTime.Month = aDate.Month; + aDateTime.Year = aDate.Year; + aReturn <<= aDateTime; + } + break; + default: + break; + } + } + else + OSL_ENSURE(sal_False, "OPropertyImport::convertString: unsupported property type!"); + } + break; + default: + OSL_ENSURE(sal_False, "OXMLControlProperty::convertString: invalid type class!"); + } + + return aReturn; +} +//--------------------------------------------------------------------- +::com::sun::star::util::Time OXMLControlProperty::implGetTime(double _nValue) +{ + ::com::sun::star::util::Time aTime; + sal_uInt32 nIntValue = sal_Int32(_nValue * 8640000); + nIntValue *= 8640000; + aTime.HundredthSeconds = (sal_uInt16)( nIntValue % 100 ); + nIntValue /= 100; + aTime.Seconds = (sal_uInt16)( nIntValue % 60 ); + nIntValue /= 60; + aTime.Minutes = (sal_uInt16)( nIntValue % 60 ); + nIntValue /= 60; + OSL_ENSURE(nIntValue < 24, "OPropertyImport::implGetTime: more than a day?"); + aTime.Hours = static_cast< sal_uInt16 >( nIntValue ); + + return aTime; +} + +//--------------------------------------------------------------------- +::com::sun::star::util::Date OXMLControlProperty::implGetDate(double _nValue) +{ + Date aToolsDate((sal_uInt32)_nValue); + ::com::sun::star::util::Date aDate; + ::utl::typeConvert(aToolsDate, aDate); + return aDate; +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlControlProperty.hxx b/reportdesign/source/filter/xml/xmlControlProperty.hxx new file mode 100644 index 000000000000..9dcdbbf01e25 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlControlProperty.hxx @@ -0,0 +1,106 @@ +#ifndef RPT_XMLCONTROLPROPERTY_HXX +#define RPT_XMLCONTROLPROPERTY_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlControlProperty.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLControlProperty : public SvXMLImportContext + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xControl; + ::com::sun::star::beans::PropertyValue m_aSetting; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSequence; + OXMLControlProperty* m_pContainer; + ::com::sun::star::uno::Type m_aPropType; // the type of the property the instance imports currently + sal_Bool m_bIsList; + + ORptFilter& GetOwnImport(); + ::com::sun::star::uno::Any convertString(const ::com::sun::star::uno::Type& _rExpectedType, const ::rtl::OUString& _rReadCharacters); + OXMLControlProperty(const OXMLControlProperty&); + void operator =(const OXMLControlProperty&); + public: + + OXMLControlProperty( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xControl + ,OXMLControlProperty* _pContainer = NULL); + virtual ~OXMLControlProperty(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); + + virtual void Characters( const ::rtl::OUString& rChars ); + + + /** adds value to property + @param _sValue + The value to add. + */ + void addValue(const ::rtl::OUString& _sValue); + + private: + static ::com::sun::star::util::Time implGetTime(double _nValue); + static ::com::sun::star::util::Date implGetDate(double _nValue); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLCONTROLPROPERTY_HXX diff --git a/reportdesign/source/filter/xml/xmlEnums.hxx b/reportdesign/source/filter/xml/xmlEnums.hxx new file mode 100644 index 000000000000..8e0a6dfbce3f --- /dev/null +++ b/reportdesign/source/filter/xml/xmlEnums.hxx @@ -0,0 +1,183 @@ +#ifndef RPT_XMLENUMS_HXX +#define RPT_XMLENUMS_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlEnums.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#define PROGRESS_BAR_STEP 20 + +namespace rptxml +{ + enum XMLDocTokens + { + XML_TOK_DOC_AUTOSTYLES, + XML_TOK_DOC_SETTINGS, + XML_TOK_DOC_REPORT, + XML_TOK_DOC_STYLES, + XML_TOK_DOC_FONTDECLS, + XML_TOK_DOC_MASTERSTYLES + }; + enum XMLReportToken + { + XML_TOK_REPORT_HEADER, + XML_TOK_PAGE_HEADER , + XML_TOK_GROUP, + XML_TOK_DETAIL , + XML_TOK_PAGE_FOOTER , + XML_TOK_REPORT_FOOTER, + XML_TOK_HEADER_ON_NEW_PAGE , + XML_TOK_FOOTER_ON_NEW_PAGE , + XML_TOK_COMMAND_TYPE , + XML_TOK_COMMAND , + XML_TOK_FILTER , + XML_TOK_CAPTION , + XML_TOK_ESCAPE_PROCESSING , + XML_TOK_REPORT_FUNCTION , + XML_TOK_REPORT_ELEMENT , + XML_TOK_REPORT_MIMETYPE + }; + enum XMLGroup + { + XML_TOK_START_NEW_COLUMN , + XML_TOK_RESET_PAGE_NUMBER , + XML_TOK_PRINT_HEADER_ON_EACH_PAGE , + XML_TOK_GROUP_EXPRESSION , + XML_TOK_GROUP_HEADER , + XML_TOK_GROUP_GROUP , + XML_TOK_GROUP_DETAIL , + XML_TOK_GROUP_FOOTER , + XML_TOK_SORT_ASCENDING , + XML_TOK_GROUP_FUNCTION , + XML_TOK_GROUP_KEEP_TOGETHER + }; + enum XMLSection + { + XML_TOK_SECTION_NAME, + XML_TOK_TABLE, + XML_TOK_CONDITIONAL_PRINT_EXPRESSION, + XML_TOK_VISIBLE , + XML_TOK_FORCE_NEW_PAGE , + XML_TOK_FORCE_NEW_COLUMN , + XML_TOK_KEEP_TOGETHER , + XML_TOK_REPEAT_SECTION, + XML_TOK_PAGE_PRINT_OPTION, + XML_TOK_SECT_STYLE_NAME + }; + + enum XMLCell + { + XML_TOK_P, + XML_TOK_FIXED_CONTENT, + XML_TOK_FORMATTED_TEXT, + XML_TOK_IMAGE, + XML_TOK_SUB_DOCUMENT, + XML_TOK_CUSTOM_SHAPE, + XML_TOK_PAGE_NUMBER, + XML_TOK_PAGE_COUNT, + XML_TOK_TEXT_TAB_STOP, + XML_TOK_TEXT_LINE_BREAK, + XML_TOK_TEXT_S + }; + + enum XMLComponent + { + XML_TOK_NAME + ,XML_TOK_TABLE_COLUMNS + ,XML_TOK_TABLE_ROWS + ,XML_TOK_COLUMN_STYLE_NAME + ,XML_TOK_COLUMN + ,XML_TOK_ROW + ,XML_TOK_CELL + ,XML_TOK_COV_CELL + ,XML_TOK_NUMBER_COLUMNS_SPANNED + ,XML_TOK_NUMBER_ROWS_SPANNED + ,XML_TOK_TEXT_STYLE_NAME + ,XML_TOK_TRANSFORM + }; + enum XMLReportElement + { + XML_TOK_PRINT_ONLY_WHEN_GROUP_CHANGE + ,XML_TOK_REP_CONDITIONAL_PRINT_EXPRESSION + ,XML_TOK_PRINT_REPEATED_VALUES + ,XML_TOK_COMPONENT + ,XML_TOK_FORMATCONDITION + }; + enum XMLControlProperty + { + XML_TOK_PROPERTY_NAME + ,XML_TOK_VALUE_TYPE + ,XML_TOK_LIST_PROPERTY + ,XML_TOK_VALUE + ,XML_TOK_CURRENCY + ,XML_TOK_DATE_VALUE + ,XML_TOK_TIME_VALUE + ,XML_TOK_STRING_VALUE + ,XML_TOK_BOOLEAN_VALUE + ,XML_TOK_PROPERTIES + ,XML_TOK_SIZE + ,XML_TOK_IMAGE_DATA + ,XML_TOK_IMAGE_POSITION + ,XML_TOK_IMAGE_ALIGN + ,XML_TOK_SCALE + ,XML_TOK_LABEL + ,XML_TOK_DATA_FORMULA + ,XML_TOK_PRESERVE_IRI + ,XML_TOK_SELECT_PAGE + }; + enum XMLFunction + { + XML_TOK_FUNCTION_NAME + ,XML_TOK_FUNCTION_FORMULA + ,XML_TOK_PRE_EVALUATED + ,XML_TOK_INITIAL_FORMULA + ,XML_TOK_DEEP_TRAVERSING + }; + enum XMLSubDocument + { + XML_TOK_MASTER_DETAIL_FIELDS + ,XML_TOK_MASTER_DETAIL_FIELD + ,XML_TOK_MASTER + ,XML_TOK_SUB_DETAIL + }; + enum XMLFormatConidition + { + XML_TOK_FORMAT_STYLE_NAME + ,XML_TOK_ENABLED + ,XML_TOK_FORMULA + }; + +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- +#endif // RPT_XMLENUMS_HXX diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx new file mode 100644 index 000000000000..38e3baf3eae4 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -0,0 +1,1667 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlExport.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLEXPORT_HXX +#include "xmlExport.hxx" +#endif +#ifndef RPT_XMLAUTOSTYLE_HXX +#include "xmlAutoStyle.hxx" +#endif +#ifndef _XMLOFF_PROGRESSBARHELPER_HXX +#include +#endif +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef _XMLOFF_TEXTPRMAP_HXX_ +#include +#endif +#include +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#include "xmlstrings.hrc" +#ifndef RPT_XMLPROPHANDLER_HXX +#include "xmlPropertyHandler.hxx" +#endif +#ifndef _COM_SUN_STAR_AWT_IMAGEPOSITION_HPP_ +#include +#endif +#include +#include +#include +#ifndef _COM_SUN_STAR_REPORT_XFIXEDTEXT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XImageControl_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XSHAPE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XFUNCTION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include +#endif +#include +#include +#include +#ifndef _REPORT_RPTUIDEF_HXX +#include "RptDef.hxx" +#endif +// for locking SolarMutex: svapp + mutex +#ifndef _SV_SVAPP_HXX +#include +#endif +#ifndef _VOS_MUTEX_HXX_ +#include +#endif + +#include + +//-------------------------------------------------------------------------- +namespace rptxml +{ + using namespace xmloff; + using namespace comphelper; + using namespace ::com::sun::star; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::util; + using namespace ::com::sun::star::xml; + + //--------------------------------------------------------------------- + Reference< XInterface > ORptExportHelper::create(Reference< XComponentContext > const & xContext) + { + return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_SETTINGS )); + } + //--------------------------------------------------------------------- + ::rtl::OUString ORptExportHelper::getImplementationName_Static( ) throw (RuntimeException) + { + return ::rtl::OUString::createFromAscii("com.sun.star.comp.report.XMLSettingsExporter"); + } + //--------------------------------------------------------------------- + Sequence< ::rtl::OUString > ORptExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) + { + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter"); + return aSupported; + } + //--------------------------------------------------------------------- + Reference< XInterface > ORptContentExportHelper::create(Reference< XComponentContext > const & xContext) + { + return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_CONTENT )); + } + //--------------------------------------------------------------------- + ::rtl::OUString ORptContentExportHelper::getImplementationName_Static( ) throw (RuntimeException) + { + return ::rtl::OUString::createFromAscii("com.sun.star.comp.report.XMLContentExporter"); + } + //--------------------------------------------------------------------- + Sequence< ::rtl::OUString > ORptContentExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) + { + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter"); + return aSupported; + } + + //--------------------------------------------------------------------- + Reference< XInterface > ORptStylesExportHelper::create(Reference< XComponentContext > const & xContext) + { + return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES | + EXPORT_FONTDECLS|EXPORT_OASIS )); + } + //--------------------------------------------------------------------- + ::rtl::OUString ORptStylesExportHelper::getImplementationName_Static( ) throw (RuntimeException) + { + return ::rtl::OUString::createFromAscii("com.sun.star.comp.report.XMLStylesExporter"); + } + //--------------------------------------------------------------------- + Sequence< ::rtl::OUString > ORptStylesExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) + { + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter"); + return aSupported; + } + + //--------------------------------------------------------------------- + Reference< XInterface > ODBFullExportHelper::create(Reference< XComponentContext > const & xContext) + { + return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_ALL)); + } + //--------------------------------------------------------------------- + ::rtl::OUString ODBFullExportHelper::getImplementationName_Static( ) throw (RuntimeException) + { + return ::rtl::OUString::createFromAscii("com.sun.star.comp.report.XMLFullExporter"); + } + //--------------------------------------------------------------------- + Sequence< ::rtl::OUString > ODBFullExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) + { + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter"); + return aSupported; + } + + //--------------------------------------------------------------------- + ::rtl::OUString lcl_implGetPropertyXMLType(const Type& _rType) + { + // possible types we can write (either because we recognize them directly or because we convert _rValue + // into one of these types) + static const ::rtl::OUString s_sTypeBoolean (RTL_CONSTASCII_USTRINGPARAM("boolean")); + static const ::rtl::OUString s_sTypeShort (RTL_CONSTASCII_USTRINGPARAM("short")); + static const ::rtl::OUString s_sTypeInteger (RTL_CONSTASCII_USTRINGPARAM("int")); + static const ::rtl::OUString s_sTypeLong (RTL_CONSTASCII_USTRINGPARAM("long")); + static const ::rtl::OUString s_sTypeDouble (RTL_CONSTASCII_USTRINGPARAM("double")); + static const ::rtl::OUString s_sTypeString (RTL_CONSTASCII_USTRINGPARAM("string")); + + // handle the type description + switch (_rType.getTypeClass()) + { + case TypeClass_STRING: + return s_sTypeString; + case TypeClass_DOUBLE: + return s_sTypeDouble; + case TypeClass_BOOLEAN: + return s_sTypeBoolean; + case TypeClass_BYTE: + case TypeClass_SHORT: + return s_sTypeShort; + case TypeClass_LONG: + return s_sTypeInteger; + case TypeClass_HYPER: + return s_sTypeLong; + case TypeClass_ENUM: + return s_sTypeInteger; + + default: + return s_sTypeDouble; + } + } + + class OSpecialHanldeXMLExportPropertyMapper : public SvXMLExportPropertyMapper + { + public: + OSpecialHanldeXMLExportPropertyMapper(const UniReference< XMLPropertySetMapper >& rMapper) : SvXMLExportPropertyMapper(rMapper ) + { + } + /** this method is called for every item that has the + MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ + virtual void handleSpecialItem( + SvXMLAttributeList& /*rAttrList*/, + const XMLPropertyState& /*rProperty*/, + const SvXMLUnitConverter& /*rUnitConverter*/, + const SvXMLNamespaceMap& /*rNamespaceMap*/, + const ::std::vector< XMLPropertyState >* /*pProperties*/ = 0, + sal_uInt32 /*nIdx*/ = 0 ) const + { + // nothing to do here + } + }; +// ----------------------------------------------------------------------------- +void lcl_adjustColumnSpanOverRows(ORptExport::TSectionsGrid& _rGrid) +{ + ORptExport::TSectionsGrid::iterator aSectionIter = _rGrid.begin(); + ORptExport::TSectionsGrid::iterator aSectionEnd = _rGrid.end(); + for (;aSectionIter != aSectionEnd ; ++aSectionIter) + { + ORptExport::TGrid::iterator aRowIter = aSectionIter->second.begin(); + ORptExport::TGrid::iterator aRowEnd = aSectionIter->second.end(); + for (; aRowIter != aRowEnd; ++aRowIter) + { + if ( aRowIter->first ) + { + ::std::vector< ORptExport::TCell >::iterator aColIter = aRowIter->second.begin(); + ::std::vector< ORptExport::TCell >::iterator aColEnd = aRowIter->second.end(); + for (; aColIter != aColEnd; ++aColIter) + { + if ( aColIter->nRowSpan > 1 ) + { + sal_Int32 nColSpan = aColIter->nColSpan; + sal_Int32 nColIndex = aColIter - aRowIter->second.begin(); + for (sal_Int32 i = 1; i < aColIter->nRowSpan; ++i) + { + (aRowIter+i)->second[nColIndex].nColSpan = nColSpan; + } + } + } + } + } + } +} +// ----------------------------------------------------------------------------- +ORptExport::ORptExport(const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nExportFlag) +: SvXMLExport( _rxMSF,MAP_100TH_MM,XML_REPORT, EXPORT_OASIS) +,m_bAllreadyFilled(sal_False) +{ + setExportFlags( EXPORT_OASIS | nExportFlag); + GetMM100UnitConverter().setCoreMeasureUnit(MAP_100TH_MM); + GetMM100UnitConverter().setXMLMeasureUnit(MAP_CM); + + // (getExportFlags() & EXPORT_CONTENT) != 0 ? : XML_N_OOO + _GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE ), XML_NAMESPACE_OFFICE ); + _GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO ); + + _GetNamespaceMap().Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT ); + _GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG ); + _GetNamespaceMap().Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM ); + _GetNamespaceMap().Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW ); + _GetNamespaceMap().Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT ); + + + if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 ) + _GetNamespaceMap().Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO ); + + if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 ) + { + _GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK ); + } + if( (getExportFlags() & EXPORT_SETTINGS) != 0 ) + { + _GetNamespaceMap().Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG ); + } + + if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 ) + { + _GetNamespaceMap().Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE ); + } + + _GetNamespaceMap().Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE ); + _GetNamespaceMap().Add( GetXMLToken(XML_NP_NUMBER), GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER ); + + m_sTableStyle = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME) ); + m_sColumnStyle = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_COLUMN) ); + m_sCellStyle = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_REPORT, GetXMLToken(XML_STYLE_NAME) ); + + + m_xPropHdlFactory = new OXMLRptPropHdlFactory(); + UniReference < XMLPropertyHandlerFactory> xFac = new ::xmloff::OControlPropertyHandlerFactory(); + UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper1 = new XMLPropertySetMapper(OXMLHelper::GetTableStyleProps(),xFac); + UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper2 = new XMLTextPropertySetMapper(TEXT_PROP_MAP_TABLE_DEFAULTS ); + xTableStylesPropertySetMapper1->AddMapperEntry(xTableStylesPropertySetMapper2); + + m_xTableStylesExportPropertySetMapper = new SvXMLExportPropertyMapper(xTableStylesPropertySetMapper1); + //m_xTableStylesExportPropertySetMapper->ChainExportMapper(xTableStylesPropertySetMapper2); + + m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylePropertyMap(); + m_xCellStylesExportPropertySetMapper = new OSpecialHanldeXMLExportPropertyMapper(m_xCellStylesPropertySetMapper); + m_xCellStylesExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this)); + + UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetColumnStyleProps(), m_xPropHdlFactory); + m_xColumnStylesExportPropertySetMapper = new OSpecialHanldeXMLExportPropertyMapper(xColumnStylesPropertySetMapper); + + UniReference < XMLPropertySetMapper > xRowStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetRowStyleProps(), m_xPropHdlFactory); + m_xRowStylesExportPropertySetMapper = new OSpecialHanldeXMLExportPropertyMapper(xRowStylesPropertySetMapper); + + UniReference < XMLPropertySetMapper > xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA )); + m_xParaPropMapper = new OSpecialHanldeXMLExportPropertyMapper( xPropMapper); + + ::rtl::OUString sFamily( GetXMLToken(XML_PARAGRAPH) ); + ::rtl::OUString aPrefix( String( 'P' ) ); + GetAutoStylePool()->AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily, + m_xParaPropMapper, aPrefix ); + + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), + m_xCellStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX))); + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME)), + m_xColumnStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX))); + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME)), + m_xRowStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX))); + GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_TABLE, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME)), + m_xTableStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX))); +} +// ----------------------------------------------------------------------------- +Reference< XInterface > ORptExport::create(Reference< XComponentContext > const & xContext) +{ + return *(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))); +} + +// ----------------------------------------------------------------------------- +::rtl::OUString ORptExport::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ExportFilter")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ORptExport::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > ORptExport::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter")); + + return aServices; +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL ORptExport::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL ORptExport::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +void ORptExport::exportFunctions(const Reference& _xFunctions) +{ + const sal_Int32 nCount = _xFunctions->getCount(); + for (sal_Int32 i = 0; i< nCount; ++i) + { + uno::Reference< report::XFunction> xFunction(_xFunctions->getByIndex(i),uno::UNO_QUERY_THROW); + OSL_ENSURE(xFunction.is(),"Function object is NULL!"); + + exportFormula(XML_FORMULA,xFunction->getFormula()); + beans::Optional< ::rtl::OUString> aInitial = xFunction->getInitialFormula(); + if ( aInitial.IsPresent ) + exportFormula(XML_INITIAL_FORMULA ,aInitial.Value ); + AddAttribute( XML_NAMESPACE_REPORT, XML_NAME , xFunction->getName() ); + if ( xFunction->getPreEvaluated() ) + AddAttribute( XML_NAMESPACE_REPORT, XML_PRE_EVALUATED , XML_TRUE ); + if ( xFunction->getDeepTraversing() ) + AddAttribute( XML_NAMESPACE_REPORT, XML_DEEP_TRAVERSING , XML_TRUE ); + + SvXMLElementExport aFunction(*this,XML_NAMESPACE_REPORT, XML_FUNCTION, sal_True, sal_True); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportMasterDetailFields(const Reference& _xReportDefinition) +{ + uno::Sequence< ::rtl::OUString> aMasterFields = _xReportDefinition->getMasterFields(); + if ( aMasterFields.getLength() ) + { + SvXMLElementExport aElement(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, sal_True, sal_True); + uno::Sequence< ::rtl::OUString> aDetailFields = _xReportDefinition->getDetailFields(); + + OSL_ENSURE(aDetailFields.getLength() == aMasterFields.getLength(),"not equal length for amster and detail fields!"); + + const ::rtl::OUString* pDetailFieldsIter = aDetailFields.getConstArray(); + const ::rtl::OUString* pIter = aMasterFields.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aMasterFields.getLength(); + for(;pIter != pEnd;++pIter,++pDetailFieldsIter) + { + AddAttribute( XML_NAMESPACE_REPORT, XML_MASTER , *pIter ); + if ( pDetailFieldsIter->getLength() ) + AddAttribute( XML_NAMESPACE_REPORT, XML_DETAIL , *pDetailFieldsIter ); + SvXMLElementExport aPair(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELD, sal_True, sal_True); + } + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportReport(const Reference& _xReportDefinition) +{ + if ( _xReportDefinition.is() ) + { + exportFunctions(_xReportDefinition->getFunctions().get()); + + if ( _xReportDefinition->getReportHeaderOn() ) + { + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_HEADER, sal_True, sal_True); + exportSection(_xReportDefinition->getReportHeader()); + } // if ( _xReportDefinition->getReportHeaderOn() ) + if ( _xReportDefinition->getPageHeaderOn() ) + { + ::rtl::OUStringBuffer sValue; + sal_uInt16 nRet = _xReportDefinition->getPageHeaderOption(); + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear()); + + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_HEADER, sal_True, sal_True); + exportSection(_xReportDefinition->getPageHeader(),true); + } // if ( _xReportDefinition->getPageHeaderOn() ) + + exportGroup(_xReportDefinition,0); + + if ( _xReportDefinition->getPageFooterOn() ) + { + ::rtl::OUStringBuffer sValue; + sal_uInt16 nRet = _xReportDefinition->getPageFooterOption(); + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear()); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_FOOTER, sal_True, sal_True); + exportSection(_xReportDefinition->getPageFooter(),true); + } // if ( _xReportDefinition->getPageFooterOn() ) + if ( _xReportDefinition->getReportFooterOn() ) + { + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_FOOTER, sal_True, sal_True); + exportSection(_xReportDefinition->getReportFooter()); + } // if ( _xReportDefinition->getReportFooterOn() ) + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportImagePosition(sal_Int16 _nImagePosition) +{ + OSL_ENSURE( ( _nImagePosition >= awt::ImagePosition::LeftTop ) && ( _nImagePosition <= awt::ImagePosition::Centered ), + "ORptExport::export: don't know this image position!" ); + + if ( ( _nImagePosition < awt::ImagePosition::LeftTop ) || ( _nImagePosition > awt::ImagePosition::Centered ) ) + // this is important to prevent potential buffer overflows below, so don't optimize + _nImagePosition = awt::ImagePosition::Centered; + + if ( _nImagePosition == awt::ImagePosition::Centered ) + { + AddAttribute( XML_NAMESPACE_FORM, XML_IMAGE_POSITION , GetXMLToken( XML_CENTER ) ); + } + else + { + XMLTokenEnum eXmlImagePositions[] = + { + XML_START, XML_END, XML_TOP, XML_BOTTOM + }; + XMLTokenEnum eXmlImageAligns[] = + { + XML_START, XML_CENTER, XML_END + }; + + XMLTokenEnum eXmlImagePosition = eXmlImagePositions[ _nImagePosition / 3 ]; + XMLTokenEnum eXmlImageAlign = eXmlImageAligns [ _nImagePosition % 3 ]; + + AddAttribute( XML_NAMESPACE_FORM, XML_IMAGE_POSITION , GetXMLToken( eXmlImagePosition ) ); + AddAttribute( XML_NAMESPACE_FORM, XML_IMAGE_ALIGN , GetXMLToken( eXmlImageAlign ) ); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportComponent(const Reference& _xReportComponent) +{ + OSL_ENSURE(_xReportComponent.is(),"No component interface!"); + if ( !_xReportComponent.is() ) + return; + + AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,_xReportComponent->getName()); + + SvXMLElementExport aElem(*this,XML_NAMESPACE_REPORT, XML_REPORT_COMPONENT, sal_False, sal_False); +} +// ----------------------------------------------------------------------------- +void ORptExport::exportFormatConditions(const Reference& _xReportElement) +{ + OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF"); + ::rtl::OUString sDataField = convertFormula(_xReportElement->getDataField()); + sal_Int32 nCount = _xReportElement->getCount(); + try + { + for (sal_Int32 i = 0; i < nCount ; ++i) + { + uno::Reference< report::XFormatCondition > xCond(_xReportElement->getByIndex(i),uno::UNO_QUERY); + if ( !xCond->getEnabled() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_ENABLED,XML_FALSE); + + AddAttribute(XML_NAMESPACE_REPORT, XML_FORMULA,xCond->getFormula()); + + exportStyleName(xCond.get(),GetAttrList(),m_sCellStyle); + SvXMLElementExport aElem(*this,XML_NAMESPACE_REPORT, XML_FORMAT_CONDITION, sal_True, sal_True); + } // for (sal_Int32 i = 0; i < nCount ; ++i) + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"Can not access format condition!"); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportReportElement(const Reference& _xReportElement) +{ + OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF"); + if ( _xReportElement->getPrintWhenGroupChange() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PRINT_ONLY_WHEN_GROUP_CHANGE, XML_TRUE ); + + if ( !_xReportElement->getPrintRepeatedValues() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PRINT_REPEATED_VALUES,XML_FALSE); + + SvXMLElementExport aElem(*this,XML_NAMESPACE_REPORT, XML_REPORT_ELEMENT, sal_False, sal_False); + if ( _xReportElement->getCount() ) + { + exportFormatConditions(_xReportElement); + } + + ::rtl::OUString sExpr = _xReportElement->getConditionalPrintExpression(); + if ( sExpr.getLength() ) + { + exportFormula(XML_FORMULA,sExpr); + SvXMLElementExport aPrintExpr(*this,XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, sal_False, sal_False); + } // if ( sExpr.getLength() ) + + // only export when parent exists + uno::Reference< report::XSection> xParent(_xReportElement->getParent(),uno::UNO_QUERY); + if ( xParent.is() ) + exportComponent(_xReportElement.get()); +} +// ----------------------------------------------------------------------------- +void lcl_calculate(const ::std::vector& _aPosX,const ::std::vector& _aPosY,ORptExport::TGrid& _rColumns) +{ + sal_Int32 nCountX = _aPosX.size() - 1; + sal_Int32 nCountY = _aPosY.size() - 1; + for (sal_Int32 j = 0; j < nCountY; ++j) + { + sal_Int32 nHeight = _aPosY[j+1] - _aPosY[j]; + if ( nHeight ) + for (sal_Int32 i = 0; i < nCountX ; ++i) + { + _rColumns[j].second[i] = ORptExport::TCell(_aPosX[i+1] - _aPosX[i],nHeight,1,1); + _rColumns[j].second[i].bSet = sal_True; + } + } +} +// ----------------------------------------------------------------------------- +void ORptExport::collectStyleNames(sal_Int32 _nFamily,const ::std::vector< sal_Int32>& _aSize, ORptExport::TStringVec& _rStyleNames) +{ + ::std::vector< XMLPropertyState > aPropertyStates; + aPropertyStates.push_back(XMLPropertyState(0)); + ::std::vector::const_iterator aIter = _aSize.begin(); + ::std::vector::const_iterator aIter2 = aIter + 1; + ::std::vector::const_iterator aEnd = _aSize.end(); + for (;aIter2 != aEnd ; ++aIter,++aIter2) + { + sal_Int32 nValue = static_cast(*aIter2 - *aIter); + aPropertyStates[0].maValue <<= nValue; + _rStyleNames.push_back(GetAutoStylePool()->Add(_nFamily, aPropertyStates )); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportSectionAutoStyle(const Reference& _xProp) +{ + OSL_ENSURE(_xProp != NULL,"Section is NULL -> GPF"); + exportAutoStyle(_xProp); + + Reference xReport = _xProp->getReportDefinition(); + awt::Size aSize = rptui::getStyleProperty(xReport,PROPERTY_PAPERSIZE); + sal_Int32 nOffset = rptui::getStyleProperty(xReport,PROPERTY_LEFTMARGIN); + sal_Int32 nCount = _xProp->getCount(); + + ::std::vector aColumnPos; + aColumnPos.reserve(2*(nCount + 1)); + aColumnPos.push_back(nOffset); + aColumnPos.push_back(aSize.Width - rptui::getStyleProperty(xReport,PROPERTY_RIGHTMARGIN)); + + ::std::vector aRowPos; + aRowPos.reserve(2*(nCount + 1)); + aRowPos.push_back(0); + aRowPos.push_back(_xProp->getHeight()); + + sal_Int32 i; + for (i = 0 ; i< nCount ; ++i) + { + Reference xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY); + uno::Reference< XShape> xShape(xReportElement,uno::UNO_QUERY); + if ( xShape.is() ) + continue; + OSL_ENSURE( xReportElement.is(),"NULL Element in Section!" ); + if ( !xReportElement.is() ) + continue; + sal_Int32 nX = xReportElement->getPositionX(); + aColumnPos.push_back(nX); + Reference xFixedLine(xReportElement,uno::UNO_QUERY); + if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical + { + sal_Int32 nWidth = static_cast(xReportElement->getWidth()*0.5); + nX += nWidth; + aColumnPos.push_back(nX); + nX += xReportElement->getWidth() - nWidth; + } + else + nX += xReportElement->getWidth(); + aColumnPos.push_back(nX); // --nX why? + + sal_Int32 nY = xReportElement->getPositionY(); + aRowPos.push_back(nY); + nY += xReportElement->getHeight(); + aRowPos.push_back(nY); // --nY why? + } + + ::std::sort(aColumnPos.begin(),aColumnPos.end(),::std::less()); + aColumnPos.erase(::std::unique(aColumnPos.begin(),aColumnPos.end()),aColumnPos.end()); + + ::std::sort(aRowPos.begin(),aRowPos.end(),::std::less()); + aRowPos.erase(::std::unique(aRowPos.begin(),aRowPos.end()),aRowPos.end()); + + TSectionsGrid::iterator aInsert = m_aSectionsGrid.insert( + TSectionsGrid::value_type( + _xProp.get(), + TGrid(aRowPos.size() - 1,TGrid::value_type(sal_False,TRow(aColumnPos.size() - 1))) + ) + ).first; + lcl_calculate(aColumnPos,aRowPos,aInsert->second); + + TGridStyleMap::iterator aPos = m_aColumnStyleNames.insert(TGridStyleMap::value_type(_xProp.get(),TStringVec())).first; + collectStyleNames(XML_STYLE_FAMILY_TABLE_COLUMN,aColumnPos,aPos->second); + aPos = m_aRowStyleNames.insert(TGridStyleMap::value_type(_xProp.get(),TStringVec())).first; + collectStyleNames(XML_STYLE_FAMILY_TABLE_ROW,aRowPos,aPos->second); + + sal_Int32 x1 = 0; + sal_Int32 y1 = 0; + sal_Int32 x2 = 0; + sal_Int32 y2 = 0; + sal_Int32 xi = 0; + sal_Int32 yi = 0; + bool isOverlap = false; + + for (i = 0 ; i< nCount ; ++i) + { + Reference xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY); + uno::Reference< XShape> xShape(xReportElement,uno::UNO_QUERY); + if ( xShape.is() ) + continue; + sal_Int32 nPos = xReportElement->getPositionX(); + x1 = (::std::find(aColumnPos.begin(),aColumnPos.end(),nPos) - aColumnPos.begin()); + Reference xFixedLine(xReportElement,uno::UNO_QUERY); + if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical + nPos += static_cast(xReportElement->getWidth()*0.5); + else + nPos += xReportElement->getWidth(); // -1 why + x2 = (::std::find(aColumnPos.begin(),aColumnPos.end(),nPos) - aColumnPos.begin()); + + nPos = xReportElement->getPositionY(); + y1 = (::std::find(aRowPos.begin(),aRowPos.end(),nPos) - aRowPos.begin()); + nPos += xReportElement->getHeight(); // -1 why? + y2 = (::std::find(aRowPos.begin(),aRowPos.end(),nPos) - aRowPos.begin()); + + isOverlap = false; + yi = y1; + while(yi < y2 && !isOverlap) // find overlapping controls + { + xi = x1; + while(xi < x2 && !isOverlap) + { + if ( aInsert->second[yi].second[xi].xElement.is() ) + { + isOverlap = true; + } + ++xi; + } + ++yi; + } + + if (!isOverlap) + { + yi = y1; + while(yi < y2) + { + xi = x1; + while(xi < x2) + { + aInsert->second[yi].second[xi] = TCell(); + ++xi; + } + aInsert->second[yi].first = sal_True; + ++yi; + } + + if (x2 - x1 != 0 && y2 - y1 != 0) + { + awt::Size aElementSize = xReportElement->getSize(); + if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical + aElementSize.Width = static_cast(xFixedLine->getWidth()*0.5); + + sal_Int32 nColSpan = x2 - x1; + sal_Int32 nRowSpan = y2 - y1; + aInsert->second[y1].second[x1] = + TCell( + aElementSize.Width , // -1 why? + aElementSize.Height, // -1 why? + nColSpan, + nRowSpan, + xReportElement + ); + } + } + } + + lcl_adjustColumnSpanOverRows(m_aSectionsGrid); + exportReportComponentAutoStyles(_xProp); +} +// ----------------------------------------------------------------------------- +void ORptExport::exportReportComponentAutoStyles(const Reference& _xProp) +{ + sal_Int32 nCount = _xProp->getCount(); + for (sal_Int32 i = 0 ; i< nCount ; ++i) + { + Reference xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY); + Reference< report::XShape > xShape(xReportElement,uno::UNO_QUERY); + if ( xShape.is() ) + { + UniReference< XMLShapeExport > xShapeExport = GetShapeExport(); + xShapeExport->seekShapes(_xProp.get()); + vos::OGuard aGuard(Application::GetSolarMutex()); + xShapeExport->collectShapeAutoStyles(xShape.get()); + } + else + { + exportAutoStyle(xReportElement.get()); + + Reference xFormattedField(xReportElement,uno::UNO_QUERY); + if ( xFormattedField.is() ) + { + try + { + const sal_Int32 nFormatCount = xFormattedField->getCount(); + for (sal_Int32 j = 0; j < nFormatCount ; ++j) + { + uno::Reference< report::XFormatCondition > xCond(xFormattedField->getByIndex(j),uno::UNO_QUERY); + exportAutoStyle(xCond.get()); + } // for (sal_Int32 j = 0; j < nCount ; ++j) + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"Can not access format condition!"); + } + } + } + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportSection(const Reference& _xSection,bool bHeader) +{ + OSL_ENSURE(_xSection.is(),"Section is NULL -> GPF"); + ::rtl::OUStringBuffer sValue; + AddAttribute(XML_NAMESPACE_TABLE, XML_NAME,_xSection->getName()); + + if ( !_xSection->getVisible() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_VISIBLE,XML_FALSE); + + if ( !bHeader ) + { + sal_uInt16 nRet = _xSection->getForceNewPage(); + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetForceNewPageOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_FORCE_NEW_PAGE,sValue.makeStringAndClear()); + + nRet = _xSection->getNewRowOrCol(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_FORCE_NEW_COLUMN,sValue.makeStringAndClear()); + if ( _xSection->getKeepTogether() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER, XML_TRUE ); + } + + exportStyleName(_xSection.get(),GetAttrList(),m_sTableStyle); + + /// TODO export as table layout + SvXMLElementExport aComponents(*this,XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True); + + ::rtl::OUString sExpr = _xSection->getConditionalPrintExpression(); + if ( sExpr.getLength() ) + { + exportFormula(XML_FORMULA,sExpr); + SvXMLElementExport aPrintExpr(*this,XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, sal_True, sal_False); + } + + exportContainer(_xSection); +} +// ----------------------------------------------------------------------------- +void ORptExport::exportTableColumns(const Reference< XSection>& _xSection) +{ + SvXMLElementExport aColumns(*this,XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, sal_True, sal_True); + TGridStyleMap::iterator aColFind = m_aColumnStyleNames.find(_xSection.get()); + OSL_ENSURE(aColFind != m_aColumnStyleNames.end(),"ORptExport::exportTableColumns: Section not found in m_aColumnStyleNames!"); + if ( aColFind == m_aColumnStyleNames.end() ) + return; + + TStringVec::iterator aColIter = aColFind->second.begin(); + TStringVec::iterator aColEnd = aColFind->second.end(); + for (; aColIter != aColEnd; ++aColIter) + { + AddAttribute( m_sTableStyle,*aColIter ); + SvXMLElementExport aColumn(*this,XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::exportContainer(const Reference< XSection>& _xSection) +{ + OSL_ENSURE(_xSection.is(),"Section is NULL -> GPF"); + + exportTableColumns(_xSection); + + TSectionsGrid::iterator aFind = m_aSectionsGrid.find(_xSection.get()); + OSL_ENSURE(aFind != m_aSectionsGrid.end(),"ORptExport::exportContainer: Section not found in grid!"); + if ( aFind == m_aSectionsGrid.end() ) + return; + TGrid::iterator aRowIter = aFind->second.begin(); + TGrid::iterator aRowEnd = aFind->second.end(); + + sal_Int32 nEmptyCellColSpan = 0; + TGridStyleMap::iterator aRowFind = m_aRowStyleNames.find(_xSection.get()); + TStringVec::iterator aHeightIter = aRowFind->second.begin(); + OSL_ENSURE(aRowFind->second.size() == aFind->second.size(),"Different count for rows"); + + bool bShapeHandled = false; + ::std::map aRowSpan; + for (sal_Int32 j = 0; aRowIter != aRowEnd; ++aRowIter,++j,++aHeightIter) + { + AddAttribute( m_sTableStyle,*aHeightIter ); + SvXMLElementExport aRow(*this,XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True); + if ( aRowIter->first ) + { + ::std::vector< TCell >::iterator aColIter = aRowIter->second.begin(); + ::std::vector< TCell >::iterator aColEnd = aRowIter->second.end(); + nEmptyCellColSpan = 0; + for (; aColIter != aColEnd; ++aColIter) + { + sal_Bool bCoveredCell = sal_False; + sal_Int32 nColSpan = 0; + sal_Int32 nColIndex = aColIter - aRowIter->second.begin(); + ::std::map::iterator aRowSpanFind = aRowSpan.find(nColIndex); + if ( aRowSpanFind != aRowSpan.end() ) + { +#if OSL_DEBUG_LEVEL > 0 + sal_Int32 nRowSpan = aRowSpanFind->second; + nRowSpan = nRowSpan; + sal_Int32 nColSpanTemp = aColIter->nColSpan; + (void) nColSpanTemp; +#endif + nColSpan = 1; + if ( !--(aRowSpanFind->second) ) + aRowSpan.erase(aRowSpanFind); + + if ( aColIter->nColSpan > 1 ) + nColSpan += aColIter->nColSpan - 1; + + bCoveredCell = sal_True; + aColIter = aColIter + (aColIter->nColSpan - 1); + } + else if ( aColIter->bSet ) + { + if ( nEmptyCellColSpan > 0 ) + { + AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nEmptyCellColSpan) ); + bCoveredCell = sal_True; + nColSpan = nEmptyCellColSpan - 1; + nEmptyCellColSpan = 0; + } + sal_Int32 nSpan = aColIter->nColSpan; + if ( nSpan > 1 ) + { + AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nSpan) ); + nColSpan = nSpan - 1; + bCoveredCell = sal_True; + } + nSpan = aColIter->nRowSpan; + if ( nSpan > 1 ) + { + AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_ROWS_SPANNED,implConvertNumber(nSpan) ); + aRowSpan[nColIndex] = nSpan - 1; + } + if ( aColIter->xElement.is() ) + exportStyleName(aColIter->xElement.get(),GetAttrList(),m_sTableStyle); + + // start + Reference xFormattedField(aColIter->xElement,uno::UNO_QUERY); + if ( xFormattedField.is() ) + { + sal_Int32 nFormatKey = xFormattedField->getFormatKey(); + if ( 0 != nFormatKey ) + { + ::rtl::OUString sEmpty; + if ( util::NumberFormat::TEXT == nFormatKey ) + XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(*this, sEmpty, sEmpty); + else + XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(*this, nFormatKey, 0.0); + } + } + SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_False); + + if ( aColIter->xElement.is() ) + { + // start + SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_False, sal_False); + Reference xElement(aColIter->xElement,uno::UNO_QUERY); + Reference xReportComponent = aColIter->xElement; + + if ( !bShapeHandled ) + { + bShapeHandled = true; + exportShapes(_xSection); + } + uno::Reference< XShape > xShape(xElement,uno::UNO_QUERY); + uno::Reference< XFixedLine > xFixedLine(xElement,uno::UNO_QUERY); + if ( !xShape.is() && !xFixedLine.is() ) + { + Reference xReportElement(xElement,uno::UNO_QUERY); + Reference xReportDefinition(xElement,uno::UNO_QUERY); + Reference xSection(xElement,uno::UNO_QUERY); + + XMLTokenEnum eToken = XML_SECTION; + sal_Bool bExportData = sal_False; + if ( xElement->supportsService(SERVICE_FIXEDTEXT) ) + { + eToken = XML_FIXED_CONTENT; + } + else if ( xElement->supportsService(SERVICE_FORMATTEDFIELD) ) + { + eToken = XML_FORMATTED_TEXT; + bExportData = sal_True; + } + else if ( xElement->supportsService(SERVICE_IMAGECONTROL) ) + { + eToken = XML_IMAGE; + Reference< XImageControl > xProp(xElement,uno::UNO_QUERY); + ::rtl::OUString sTargetLocation = xProp->getImageURL(); + if ( sTargetLocation.getLength() ) + { + sTargetLocation = GetRelativeReference(sTargetLocation); + AddAttribute(XML_NAMESPACE_FORM, XML_IMAGE_DATA,sTargetLocation); + } + bExportData = sal_True; + if ( xProp->getScaleImage() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_SCALE, XML_TRUE ); + } + else if ( xReportDefinition.is() ) + { + eToken = XML_SUB_DOCUMENT; + } + else if ( xSection.is() ) + { + } + + bool bPageSet = false; + if ( bExportData ) + { + bPageSet = exportFormula(XML_FORMULA,xReportElement->getDataField()); + if ( bPageSet ) + { + ::rtl::OUString sFieldData = xReportElement->getDataField(); + static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()")); + static const ::rtl::OUString s_sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()")); + static const ::rtl::OUString s_sReportPrefix(RTL_CONSTASCII_USTRINGPARAM("rpt:")); + static const ::rtl::OUString s_sConcatOperator(RTL_CONSTASCII_USTRINGPARAM("&")); + sFieldData = sFieldData.copy(s_sReportPrefix.getLength(),sFieldData.getLength() - s_sReportPrefix.getLength()); + sal_Int32 nPageNumberIndex = sFieldData.indexOf(s_sPageNumber); + if ( nPageNumberIndex != -1 ) + { + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString sToken = sFieldData.getToken( 0, '&', nIndex ); + sToken = sToken.trim(); + if ( sToken.getLength() ) + { + if ( sToken == s_sPageNumber ) + { + static const ::rtl::OUString s_sCurrent(RTL_CONSTASCII_USTRINGPARAM("current")); + AddAttribute(XML_NAMESPACE_TEXT, XML_SELECT_PAGE, s_sCurrent ); + SvXMLElementExport aPageNumber(*this,XML_NAMESPACE_TEXT, XML_PAGE_NUMBER, sal_False, sal_False); + Characters(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"))); + } + else if ( sToken == s_sPageCount ) + { + SvXMLElementExport aPageNumber(*this,XML_NAMESPACE_TEXT, XML_PAGE_COUNT, sal_False, sal_False); + Characters(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"))); + } + else + { + + if ( sToken.indexOf('"') == 0 && sToken.lastIndexOf('"') == sToken.getLength()-1 ) + sToken = sToken.copy(1,sToken.getLength()-2); + + sal_Bool bPrevCharIsSpace = sal_False; + GetTextParagraphExport()->exportText(sToken,bPrevCharIsSpace); + } + } + } + while ( nIndex >= 0 ); + } + } + else if ( eToken == XML_IMAGE ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PRESERVE_IRI, XML_TRUE ); + } + + if ( !bPageSet ) + { + // start + SvXMLElementExport aComponents(*this,XML_NAMESPACE_REPORT, eToken, sal_False, sal_False); + if ( eToken == XML_FIXED_CONTENT ) + exportParagraph(xReportElement); + if ( xReportElement.is() ) + exportReportElement(xReportElement); + + if ( eToken == XML_GROUP && xSection.is() ) + exportContainer(xSection); + else if ( eToken == XML_SUB_DOCUMENT ) + { + exportMasterDetailFields(xReportDefinition); + exportReport(xReportDefinition); + } + else if ( xSection.is() ) + exportSection(xSection); + } + } + } + aColIter = aColIter + (aColIter->nColSpan - 1); + } + else + ++nEmptyCellColSpan; + if ( bCoveredCell ) + { + for (sal_Int32 k = 0; k < nColSpan; ++k) + { + SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, sal_True, sal_True); + } + + } + } // for (sal_Int32 i = 0 ; i< nCount ; ++i) + if ( nEmptyCellColSpan ) + { + { + AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nEmptyCellColSpan) ); + SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True); + if ( !bShapeHandled ) + { + bShapeHandled = true; + exportShapes(_xSection); + } + } + for (sal_Int32 k = 0; k < nEmptyCellColSpan; ++k) + { + SvXMLElementExport aCoveredCell(*this,XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, sal_True, sal_True); + } + nEmptyCellColSpan = 0; + } + } + else + { // empty rows + nEmptyCellColSpan = aRowIter->second.size(); + if ( nEmptyCellColSpan ) + { + { + AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nEmptyCellColSpan) ); + SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True); + if ( !bShapeHandled ) + { + bShapeHandled = true; + exportShapes(_xSection); + } + } + for (sal_Int32 k = 1; k < nEmptyCellColSpan; ++k) + { + SvXMLElementExport aCoveredCell(*this,XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, sal_True, sal_True); + } + nEmptyCellColSpan = 0; + } + } + } +} +// ----------------------------------------------------------------------------- +::rtl::OUString ORptExport::convertFormula(const ::rtl::OUString& _sFormula) +{ + ::rtl::OUString sFormula = _sFormula; + //sal_Int32 nLength = _sFormula.getLength(); + //if ( nLength ) + //{ + // sal_Int32 nPos = 0; + // if ( _sFormula.matchAsciiL("=",1) != 0 ) + // { + // nPos = 1; + // --nLength; + // } + // bool bFormula = _sFormula.indexOf('[') != -1 || _sFormula.indexOf('(') != -1; + // if ( bFormula ) + // sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + _sFormula.copy(nPos,nLength); + // else + // sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("field:[")) + _sFormula.copy(nPos,nLength) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("]"));; + //} + return sFormula; +} +// ----------------------------------------------------------------------------- +bool ORptExport::exportFormula(enum ::xmloff::token::XMLTokenEnum eName,const ::rtl::OUString& _sFormula) +{ + ::rtl::OUString sFieldData = convertFormula(_sFormula); + static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()")); + static const ::rtl::OUString s_sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()")); + sal_Int32 nPageNumberIndex = sFieldData.indexOf(s_sPageNumber); + sal_Int32 nPageCountIndex = sFieldData.indexOf(s_sPageCount); + bool bRet = nPageNumberIndex != -1 || nPageCountIndex != -1; + if ( !bRet ) + AddAttribute(XML_NAMESPACE_REPORT, eName,sFieldData); + + return bRet; +} +// ----------------------------------------------------------------------------- +void ORptExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt,const ::rtl::OUString& _sName) +{ + Reference xFind(_xProp); + TPropertyStyleMap::iterator aFind = m_aAutoStyleNames.find(xFind); + if ( aFind != m_aAutoStyleNames.end() ) + { + _rAtt.AddAttribute( _sName, + aFind->second ); + m_aAutoStyleNames.erase(aFind); + } +} +// ----------------------------------------------------------------------------- +sal_Bool ORptExport::exportGroup(const Reference& _xReportDefinition,sal_Int32 _nPos,sal_Bool _bExportAutoStyle) +{ + sal_Bool bGroupExported = sal_False; + if ( _xReportDefinition.is() ) + { + Reference< XGroups > xGroups = _xReportDefinition->getGroups(); + if ( xGroups.is() ) + { + sal_Int32 nCount = xGroups->getCount(); + if ( _nPos >= 0 && _nPos < nCount ) + { + bGroupExported = sal_True; + Reference xGroup(xGroups->getByIndex(_nPos),uno::UNO_QUERY); + OSL_ENSURE(xGroup.is(),"No Group prepare for GPF"); + if ( _bExportAutoStyle ) + { + if ( xGroup->getHeaderOn() ) + exportSectionAutoStyle(xGroup->getHeader()); + exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle); + if ( xGroup->getFooterOn() ) + exportSectionAutoStyle(xGroup->getFooter()); + } + else + { + if ( xGroup->getSortAscending() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_ASCENDING, XML_TRUE ); + + if ( xGroup->getStartNewColumn() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_START_NEW_COLUMN, XML_TRUE); + if ( xGroup->getResetPageNumber() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER, XML_TRUE ); + + ::rtl::OUString sFormula(RTL_CONSTASCII_USTRINGPARAM("rpt:HASCHANGED(\"")); + sFormula += xGroup->getExpression(); + sFormula += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\")")); + AddAttribute(XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION,sFormula); + sal_Int16 nRet = xGroup->getKeepTogether(); + ::rtl::OUStringBuffer sValue; + const SvXMLEnumMapEntry* aXML_KeepTogetherEnumMap = OXMLHelper::GetKeepTogetherOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_KeepTogetherEnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER,sValue.makeStringAndClear()); + + SvXMLElementExport aGroup(*this,XML_NAMESPACE_REPORT, XML_GROUP, sal_True, sal_True); + exportFunctions(xGroup->getFunctions().get()); + if ( xGroup->getHeaderOn() ) + { + Reference xSection = xGroup->getHeader(); + if ( xSection->getRepeatSection() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE ); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_HEADER, sal_True, sal_True); + exportSection(xSection); + } + exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle); + if ( xGroup->getFooterOn() ) + { + Reference xSection = xGroup->getFooter(); + if ( xSection->getRepeatSection() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE ); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_FOOTER, sal_True, sal_True); + exportSection(xSection); + } // if ( xGroup->getFooterOn() ) + } + } + else if ( _bExportAutoStyle ) + { + exportSectionAutoStyle(_xReportDefinition->getDetail()); + } + else + { + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_DETAIL, sal_True, sal_True); + exportSection(_xReportDefinition->getDetail()); + } + } + } + return bGroupExported; +} +// ----------------------------------------------------------------------------- +void ORptExport::exportAutoStyle(XPropertySet* _xProp) +{ + uno::Reference xFormat(_xProp,uno::UNO_QUERY); + if ( xFormat.is() ) + { + try + { + awt::FontDescriptor aFont = xFormat->getFontDescriptor(); + GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet ); + } + catch(beans::UnknownPropertyException&) + { + // not interested in + } + } + uno::Reference< report::XShape> xShape(_xProp,uno::UNO_QUERY); + if ( xShape.is() ) + { + ::std::vector< XMLPropertyState > aPropertyStates( m_xParaPropMapper->Filter(_xProp) ); + if ( !aPropertyStates.empty() ) + m_aAutoStyleNames.insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, aPropertyStates ))); + } + ::std::vector< XMLPropertyState > aPropertyStates( m_xCellStylesExportPropertySetMapper->Filter(_xProp) ); + Reference xFixedLine(_xProp,uno::UNO_QUERY); + if ( xFixedLine.is() ) + { + uno::Reference xBorderProp = OXMLHelper::createBorderPropertySet(); + table::BorderLine aValue; + aValue.Color = COL_BLACK; + aValue.InnerLineWidth = aValue.LineDistance = 0; + aValue.OuterLineWidth = 2; + + awt::Point aPos = xFixedLine->getPosition(); + awt::Size aSize = xFixedLine->getSize(); + sal_Int32 nSectionHeight = xFixedLine->getSection()->getHeight(); + + ::rtl::OUString sBorderProp; + ::std::vector< ::rtl::OUString> aProps; + if ( xFixedLine->getOrientation() == 1 ) // vertical + { + // check if border should be left + if ( !aPos.X ) + { + sBorderProp = PROPERTY_BORDERLEFT; + aProps.push_back(PROPERTY_BORDERRIGHT); + } + else + { + sBorderProp = PROPERTY_BORDERRIGHT; + aProps.push_back(PROPERTY_BORDERLEFT); + } + aProps.push_back(PROPERTY_BORDERTOP); + aProps.push_back(PROPERTY_BORDERBOTTOM); + } + else // horizontal + { + // check if border should be bottom + if ( (aPos.Y + aSize.Height) == nSectionHeight ) + { + sBorderProp = PROPERTY_BORDERBOTTOM; + aProps.push_back(PROPERTY_BORDERTOP); + } + else + { + sBorderProp = PROPERTY_BORDERTOP; + aProps.push_back(PROPERTY_BORDERBOTTOM); + } + aProps.push_back(PROPERTY_BORDERRIGHT); + aProps.push_back(PROPERTY_BORDERLEFT); + } + + xBorderProp->setPropertyValue(sBorderProp,uno::makeAny(aValue)); + + aValue.Color = aValue.OuterLineWidth = 0; + uno::Any aEmpty; + aEmpty <<= aValue; + ::std::for_each(aProps.begin(),aProps.end(), + ::boost::bind(&beans::XPropertySet::setPropertyValue,xBorderProp,_1,aEmpty)); + + ::std::vector< XMLPropertyState > aBorderStates(m_xCellStylesExportPropertySetMapper->Filter(xBorderProp)); + ::std::copy(aBorderStates.begin(),aBorderStates.end(),::std::back_inserter(aPropertyStates)); + } + else + { + sal_Int32 nTextAlignIndex = m_xCellStylesExportPropertySetMapper->getPropertySetMapper()->FindEntryIndex( CTF_SD_SHAPE_PARA_ADJUST ); + if ( nTextAlignIndex != -1 ) + { + ::std::vector< XMLPropertyState >::iterator aIter = aPropertyStates.begin(); + ::std::vector< XMLPropertyState >::iterator aEnd = aPropertyStates.end(); + for (; aIter != aEnd; ++aIter) + { + if ( aIter->mnIndex == nTextAlignIndex ) + { + sal_Int16 nTextAlign = 0; + aIter->maValue >>= nTextAlign; + switch(nTextAlign) + { + case awt::TextAlign::LEFT: + nTextAlign = style::ParagraphAdjust_LEFT; + break; + case awt::TextAlign::CENTER: + nTextAlign = style::ParagraphAdjust_CENTER; + break; + case awt::TextAlign::RIGHT: + nTextAlign = style::ParagraphAdjust_RIGHT; + break; + default: + OSL_ENSURE(0,"Illegal text alignment value!"); + break; + } + aIter->maValue <<= nTextAlign; + break; + } + } + } + Reference xFormattedField(_xProp,uno::UNO_QUERY); + if ( xFormattedField.is() && !aPropertyStates.empty() ) + { + sal_Int32 nNumberFormat = xFormattedField->getFormatKey(); + { + sal_Int32 nStyleMapIndex = m_xCellStylesExportPropertySetMapper->getPropertySetMapper()->FindEntryIndex( CTF_RPT_NUMBERFORMAT ); + addDataStyle(nNumberFormat); + XMLPropertyState aNumberStyleState( nStyleMapIndex, uno::makeAny( getDataStyleName(nNumberFormat) ) ); + aPropertyStates.push_back( aNumberStyleState ); + } + } + } + + + if ( !aPropertyStates.empty() ) + m_aAutoStyleNames.insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( XML_STYLE_FAMILY_TABLE_CELL, aPropertyStates ))); +} +// ----------------------------------------------------------------------------- +void ORptExport::exportAutoStyle(const Reference& _xProp) +{ + ::std::vector< XMLPropertyState > aPropertyStates( m_xTableStylesExportPropertySetMapper->Filter(_xProp.get()) ); + if ( !aPropertyStates.empty() ) + m_aAutoStyleNames.insert( TPropertyStyleMap::value_type(_xProp.get(),GetAutoStylePool()->Add( XML_STYLE_FAMILY_TABLE_TABLE, aPropertyStates ))); +} +// ----------------------------------------------------------------------------- +void ORptExport::SetBodyAttributes() +{ + Reference xProp(getReportDefinition()); + if ( xProp.is() ) + { + ::rtl::OUStringBuffer sValue; + const SvXMLEnumMapEntry* aXML_CommnadTypeEnumMap = OXMLHelper::GetCommandTypeOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, static_cast(xProp->getCommandType()),aXML_CommnadTypeEnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND_TYPE,sValue.makeStringAndClear()); + + ::rtl::OUString sComamnd = xProp->getCommand(); + if ( sComamnd.getLength() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND, sComamnd); + + ::rtl::OUString sFilter( xProp->getFilter() ); + if ( sFilter.getLength() ) + AddAttribute( XML_NAMESPACE_REPORT, XML_FILTER, sFilter ); + + AddAttribute(XML_NAMESPACE_OFFICE, XML_MIMETYPE,xProp->getMimeType()); + + sal_Bool bEscapeProcessing( xProp->getEscapeProcessing() ); + if ( !bEscapeProcessing ) + AddAttribute( XML_NAMESPACE_REPORT, XML_ESCAPE_PROCESSING, ::xmloff::token::GetXMLToken( XML_FALSE ) ); + + ::rtl::OUString sName = xProp->getCaption(); + if ( sName.getLength() ) + AddAttribute(XML_NAMESPACE_OFFICE, XML_CAPTION,sName); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::_ExportContent() +{ + exportReport(getReportDefinition()); +} +// ----------------------------------------------------------------------------- +void ORptExport::_ExportMasterStyles() +{ + GetPageExport()->exportMasterStyles( sal_True ); +} +// ----------------------------------------------------------------------------- +void ORptExport::collectComponentStyles() +{ + if ( m_bAllreadyFilled ) + return; + + m_bAllreadyFilled = sal_True; + Reference xProp(getReportDefinition()); + if ( xProp.is() ) + { + uno::Reference< report::XSection> xParent(xProp->getParent(),uno::UNO_QUERY); + if ( xParent.is() ) + exportAutoStyle(xProp.get()); + + if ( xProp->getReportHeaderOn() ) + exportSectionAutoStyle(xProp->getReportHeader()); + if ( xProp->getPageHeaderOn() ) + exportSectionAutoStyle(xProp->getPageHeader()); + + exportGroup(xProp,0,sal_True); + + if ( xProp->getPageFooterOn() ) + exportSectionAutoStyle(xProp->getPageFooter()); + if ( xProp->getReportFooterOn() ) + exportSectionAutoStyle(xProp->getReportFooter()); + } +} +// ----------------------------------------------------------------------------- +void ORptExport::_ExportAutoStyles() +{ + // there are no styles that require their own autostyles + if ( getExportFlags() & EXPORT_CONTENT ) + { + collectComponentStyles(); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE + ,GetDocHandler() + ,GetMM100UnitConverter() + ,GetNamespaceMap() + ); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN + ,GetDocHandler() + ,GetMM100UnitConverter() + ,GetNamespaceMap() + ); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW + ,GetDocHandler() + ,GetMM100UnitConverter() + ,GetNamespaceMap() + ); + + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL + ,GetDocHandler() + ,GetMM100UnitConverter() + ,GetNamespaceMap() + ); + + + /*GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_REPORT_ID + ,GetDocHandler() + ,GetMM100UnitConverter() + ,GetNamespaceMap() + );*/ + exportDataStyles(); + GetShapeExport()->exportAutoStyles(); + } + // exported in _ExportMasterStyles + if( (getExportFlags() & EXPORT_MASTERSTYLES) != 0 ) + GetPageExport()->collectAutoStyles( sal_False ); + if( (getExportFlags() & EXPORT_MASTERSTYLES) != 0 ) + GetPageExport()->exportAutoStyles(); +} +// ----------------------------------------------------------------------------- +void ORptExport::_ExportStyles(BOOL bUsed) +{ + SvXMLExport::_ExportStyles(bUsed); + + // write draw:style-name for object graphic-styles + GetShapeExport()->ExportGraphicDefaults(); +} +// ----------------------------------------------------------------------------- +sal_uInt32 ORptExport::exportDoc(enum ::xmloff::token::XMLTokenEnum eClass) +{ + return SvXMLExport::exportDoc( eClass ); +} +// ----------------------------------------------------------------------------- +void ORptExport::GetViewSettings(Sequence& /*aProps*/) +{ + /*Reference xReport(getReportDefinition()); + if ( xReport.is() && (Reference xController = xReport->getCurrentController()).is() ) + { + xController->getViewData() >>= aProps; + }*/ +} +// ----------------------------------------------------------------------------- +void ORptExport::GetConfigurationSettings(Sequence& /*aProps*/) +{ +} +// ----------------------------------------------------------------------------- +::rtl::OUString ORptExport::implConvertNumber(sal_Int32 _nValue) +{ + ::rtl::OUStringBuffer aBuffer; + GetMM100UnitConverter().convertNumber(aBuffer, _nValue); + return aBuffer.makeStringAndClear(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ORptExport::implConvertMeasure(sal_Int32 _nValue) +{ + ::rtl::OUStringBuffer aBuffer; + GetMM100UnitConverter().convertMeasure(aBuffer, _nValue); + return aBuffer.makeStringAndClear(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ORptExport::implConvertAny(const Any& _rValue) +{ + ::rtl::OUStringBuffer aBuffer; + switch (_rValue.getValueTypeClass()) + { + case TypeClass_STRING: + { // extract the string + ::rtl::OUString sCurrentValue; + _rValue >>= sCurrentValue; + aBuffer.append(sCurrentValue); + } + break; + case TypeClass_DOUBLE: + // let the unit converter format is as string + GetMM100UnitConverter().convertDouble(aBuffer, getDouble(_rValue)); + break; + case TypeClass_BOOLEAN: + aBuffer = getBOOL(_rValue) ? ::xmloff::token::GetXMLToken(XML_TRUE) : ::xmloff::token::GetXMLToken(XML_FALSE); + break; + case TypeClass_BYTE: + case TypeClass_SHORT: + case TypeClass_LONG: + // let the unit converter format is as string + GetMM100UnitConverter().convertNumber(aBuffer, getINT32(_rValue)); + break; + default: + OSL_ENSURE(0,"ORptExport::implConvertAny: Invalid type"); + } + + return aBuffer.makeStringAndClear(); +} +// ----------------------------------------------------------------------------- +UniReference < XMLPropertySetMapper > ORptExport::GetCellStylePropertyMapper() const +{ + return m_xCellStylesPropertySetMapper; +} +// ----------------------------------------------------------------------------- +SvXMLAutoStylePoolP* ORptExport::CreateAutoStylePool() +{ + return new OXMLAutoStylePoolP(*this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ORptExport::setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException) +{ + m_xReportDefinition.set(xDoc,UNO_QUERY_THROW); + OSL_ENSURE(m_xReportDefinition.is(),"DataSource is NULL!"); + + SetNumberFormatsSupplier(OXMLHelper::GetNumberFormatsSupplier(m_xReportDefinition)); + + SvXMLExport::setSourceDocument(xDoc); +} +// ----------------------------------------------------------------------------- +void ORptExport::_ExportFontDecls() +{ + GetFontAutoStylePool(); // make sure the pool is created + collectComponentStyles(); + SvXMLExport::_ExportFontDecls(); +} +// ----------------------------------------------------------------------------- +void ORptExport::exportParagraph(const Reference< XReportControlModel >& _xReportElement) +{ + OSL_PRECOND(_xReportElement.is(),"Element is null!"); + // start + SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_False, sal_False); + Reference< XFixedText > xFT(_xReportElement,UNO_QUERY); + if ( xFT.is() ) + { + ::rtl::OUString sExpr = xFT->getLabel(); + sal_Bool bPrevCharIsSpace = sal_False; + GetTextParagraphExport()->exportText(sExpr,bPrevCharIsSpace); + } +} +// ----------------------------------------------------------------------------- +XMLShapeExport* ORptExport::CreateShapeExport() +{ + XMLShapeExport* pShapeExport = new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) ); + return pShapeExport; +} +// ----------------------------------------------------------------------------- +void ORptExport::exportShapes(const Reference< XSection>& _xSection) +{ + UniReference< XMLShapeExport > xShapeExport = GetShapeExport(); + const sal_Int32 nCount = _xSection->getCount(); + awt::Point aRefPoint; + aRefPoint.X = rptui::getStyleProperty(_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN); + for (sal_Int32 i = 0; i < nCount; ++i) + { + uno::Reference< XShape > xShape(_xSection->getByIndex(i),uno::UNO_QUERY); + if ( xShape.is() ) + { + SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_False, sal_False); + AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, XML_PARAGRAPH ); + xShapeExport->exportShape(xShape.get(),SEF_DEFAULT,&aRefPoint); + } + } +} + +// ----------------------------------------------------------------------------- +}// rptxml +// ----------------------------------------------------------------------------- + diff --git a/reportdesign/source/filter/xml/xmlExport.hxx b/reportdesign/source/filter/xml/xmlExport.hxx new file mode 100644 index 000000000000..f2b2d120b39b --- /dev/null +++ b/reportdesign/source/filter/xml/xmlExport.hxx @@ -0,0 +1,327 @@ +#ifndef RPT_XMLEXPORT_HXX +#define RPT_XMLEXPORT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlExport.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTDEFINITION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XSECTION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCONTROLMODEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XFORMATTEDFIELD_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ +#include +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif +#ifndef _UNOTOOLS_TEMPFILE_HXX +#include +#endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include +#endif +#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX +#include +#endif +#ifndef _XMLOFF_XMLEXP_HXX +#include +#endif +#ifndef _XMLOFF_XMLIMP_HXX +#include +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include +#endif +#include + +namespace rptxml +{ +using namespace ::rtl; +using namespace ::xmloff::token; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::report; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::xml::sax; +// ------------- +// - ORptExport - +// ------------- +#define PROGRESS_BAR_STEP 20 + +class ORptExport : public SvXMLExport +{ +public: + struct TCell + { + sal_Int32 nWidth; + sal_Int32 nHeight; + sal_Int32 nColSpan; + sal_Int32 nRowSpan; + Reference xElement; + bool bSet; + TCell( sal_Int32 _nWidth, + sal_Int32 _nHeight, + sal_Int32 _nColSpan, + sal_Int32 _nRowSpan, + Reference _xElement = Reference()) : + nWidth(_nWidth) + ,nHeight(_nHeight) + ,nColSpan(_nColSpan) + ,nRowSpan(_nRowSpan) + ,xElement(_xElement) + ,bSet(xElement.is()) + {} + + TCell( ) : + nWidth(0) + ,nHeight(0) + ,nColSpan(1) + ,nRowSpan(1) + ,bSet(true) + {} + }; + typedef ::std::pair< ::rtl::OUString ,::rtl::OUString> TStringPair; + typedef struct + { + ::rtl::OUString sText; + ::rtl::OUString sField; + ::rtl::OUString sDecimal; + ::rtl::OUString sThousand; + } TDelimiter; + typedef ::std::vector< ::rtl::OUString> TStringVec; + typedef ::std::map< Reference ,::rtl::OUString > TPropertyStyleMap; + typedef ::std::map< Reference , TStringVec> TGridStyleMap; + typedef ::std::vector< TCell > TRow; + typedef ::std::vector< ::std::pair< sal_Bool, TRow > > TGrid; + typedef ::std::map< Reference ,TGrid > TSectionsGrid; +private: + ::std::auto_ptr< TStringPair > m_aAutoIncrement; + ::std::auto_ptr< TDelimiter > m_aDelimiter; + ::std::vector< Any > m_aDataSourceSettings; + TSectionsGrid m_aSectionsGrid; + + TPropertyStyleMap m_aAutoStyleNames; + TGridStyleMap m_aColumnStyleNames; + TGridStyleMap m_aRowStyleNames; + + ::rtl::OUString m_sCharSet; + ::rtl::OUString m_sTableStyle; + ::rtl::OUString m_sCellStyle; + ::rtl::OUString m_sColumnStyle; + Any m_aPreviewMode; + UniReference < SvXMLExportPropertyMapper> m_xExportHelper; + UniReference < SvXMLExportPropertyMapper> m_xSectionPropMapper; + UniReference < SvXMLExportPropertyMapper> m_xTableStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper> m_xCellStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper> m_xColumnStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper> m_xRowStylesExportPropertySetMapper; + UniReference < SvXMLExportPropertyMapper > m_xParaPropMapper; + UniReference < XMLPropertyHandlerFactory > m_xPropHdlFactory; + + mutable UniReference < XMLPropertySetMapper > m_xControlStylePropertyMapper; + mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper; + mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper; + Reference m_xReportDefinition; + sal_Bool m_bAllreadyFilled; + + void exportReport(const Reference& _xReportDefinition); /// + void exportFunctions(const Reference& _xFunctions); /// + void exportMasterDetailFields(const Reference& _xReportDefinition); + void exportComponent(const Reference& _xReportComponent); + void exportImagePosition(sal_Int16 _nImagePosition); + sal_Bool exportGroup(const Reference& _xReportDefinition,sal_Int32 _nPos,sal_Bool _bExportAutoStyle = sal_False); + void exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt,const ::rtl::OUString& _sName); + void exportSection(const Reference& _xProp,bool bHeader = false); + void exportContainer(const Reference< XSection>& _xSection); + void exportShapes(const Reference< XSection>& _xSection); + void exportTableColumns(const Reference< XSection>& _xSection); + void exportSectionAutoStyle(const Reference& _xProp); + void exportReportElement(const Reference& _xReportElement); + void exportFormatConditions(const Reference& _xReportElement); + void exportAutoStyle(XPropertySet* _xProp); + void exportAutoStyle(const Reference& _xProp); + void exportReportComponentAutoStyles(const Reference& _xProp); + void collectComponentStyles(); + void collectStyleNames(sal_Int32 _nFamily,const ::std::vector< sal_Int32>& _aSize, ORptExport::TStringVec& _rStyleNames); + void exportParagraph(const Reference< XReportControlModel >& _xReportElement); + bool exportFormula(enum ::xmloff::token::XMLTokenEnum eName,const ::rtl::OUString& _sFormula); + ::rtl::OUString convertFormula(const ::rtl::OUString& _sFormula); + + ::rtl::OUString implConvertAny(const Any& _rValue); + ::rtl::OUString implConvertNumber(sal_Int32 _nValue); + ::rtl::OUString implConvertMeasure(sal_Int32 _nValue); + +private: + ORptExport(); + virtual void SetBodyAttributes(); +protected: + + virtual void _ExportStyles( BOOL bUsed ); + virtual void _ExportAutoStyles(); + virtual void _ExportContent(); + virtual void _ExportMasterStyles(); + virtual void _ExportFontDecls(); + virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ); + virtual SvXMLAutoStylePoolP* CreateAutoStylePool(); + virtual XMLShapeExport* CreateShapeExport(); + + virtual void GetViewSettings(com::sun::star::uno::Sequence& aProps); + virtual void GetConfigurationSettings(com::sun::star::uno::Sequence& aProps); + + virtual ~ORptExport(){}; +public: + + ORptExport(const Reference< XMultiServiceFactory >& _rxMSF, sal_uInt16 nExportFlag = (EXPORT_CONTENT | EXPORT_AUTOSTYLES | EXPORT_FONTDECLS)); + // XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + + // XExporter + virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + inline Reference getReportDefinition() const { return m_xReportDefinition; } + + UniReference < XMLPropertySetMapper > GetCellStylePropertyMapper() const; +}; + +/** Exports only settings + * \ingroup reportdesign_source_filter_xml + * + */ +class ORptExportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; + +/** Exports only content + * \ingroup reportdesign_source_filter_xml + * + */ +class ORptContentExportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; + +/** Exports only styles + * \ingroup reportdesign_source_filter_xml + * + */ +class ORptStylesExportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; + +/** Exports all + * \ingroup reportdesign_source_filter_xml + * + */ +class ODBFullExportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- +#endif // RPT_XMLEXPORT_HXX diff --git a/reportdesign/source/filter/xml/xmlFixedContent.cxx b/reportdesign/source/filter/xml/xmlFixedContent.cxx new file mode 100644 index 000000000000..cf91fec0983a --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFixedContent.cxx @@ -0,0 +1,239 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFixedContent.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLFIXEDCONTENT_HXX +#include "xmlFixedContent.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLREPORTELEMENT_HXX +#include "xmlReportElement.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XSHAPE_HPP_ +#include +#endif +#ifndef RPT_XMLFIXEDTEXT_HXX +#include "xmlFixedText.hxx" +#endif +#ifndef RPT_XMLCELL_HXX +#include "xmlCell.hxx" +#endif +#ifndef RPT_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef _COM_SUN_STAR_REPORT_XSHAPE_HPP_ +#include +#endif +#include +#ifndef RPT_XMLTABLE_HXX +#include "xmlTable.hxx" +#endif +#include + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + +class OXMLCharContent : public XMLCharContext +{ + OXMLFixedContent* m_pFixedContent; + OXMLCharContent(const OXMLCharContent&); + void operator =(const OXMLCharContent&); +public: + OXMLCharContent( + SvXMLImport& rImport, + OXMLFixedContent* _pFixedContent, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList, + sal_Unicode c, + sal_Bool bCount ); + OXMLCharContent( + SvXMLImport& rImport, + OXMLFixedContent* _pFixedContent, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int16 nControl ); + + virtual void InsertControlCharacter(sal_Int16 _nControl); + virtual void InsertString(const ::rtl::OUString& _sString); +}; +OXMLCharContent::OXMLCharContent( + SvXMLImport& rImport, + OXMLFixedContent* _pFixedContent, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList, + sal_Unicode c, + sal_Bool bCount ) + : XMLCharContext(rImport,nPrfx,rLName,xAttrList,c,bCount) + ,m_pFixedContent(_pFixedContent) +{ +} +// ----------------------------------------------------------------------------- +OXMLCharContent::OXMLCharContent( + SvXMLImport& rImport, + OXMLFixedContent* _pFixedContent, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int16 nControl ) + : XMLCharContext(rImport,nPrfx,rLName,xAttrList,nControl) + ,m_pFixedContent(_pFixedContent) +{ +} +// ----------------------------------------------------------------------------- +void OXMLCharContent::InsertControlCharacter(sal_Int16 _nControl) +{ + switch( _nControl ) + { + case ControlCharacter::LINE_BREAK: + m_pFixedContent->Characters(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"))); + break; + default: + OSL_ENSURE(0,"Not supported control character"); + break; + } +} +// ----------------------------------------------------------------------------- +void OXMLCharContent::InsertString(const ::rtl::OUString& _sString) +{ + m_pFixedContent->Characters(_sString); +} +// ----------------------------------------------------------------------------- + +DBG_NAME( rpt_OXMLFixedContent ) + +OXMLFixedContent::OXMLFixedContent( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName + ,OXMLCell& _rCell + ,OXMLTable* _pContainer + ,bool _bInP) : + OXMLReportElementBase( rImport, nPrfx, rLName,NULL,_pContainer) +,m_rCell(_rCell) +,m_bInP(_bInP) +{ + DBG_CTOR( rpt_OXMLFixedContent,NULL); +} +// ----------------------------------------------------------------------------- + +OXMLFixedContent::~OXMLFixedContent() +{ + + DBG_DTOR( rpt_OXMLFixedContent,NULL); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLFixedContent::_CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(nPrefix,rLocalName,xAttrList); + if ( pContext ) + return pContext; + const SvXMLTokenMap& rTokenMap = m_rImport.GetCellElemTokenMap(); + Reference xFactor = m_rImport.getServiceFactory(); + + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); + switch( nToken ) + { + case XML_TOK_P: + pContext = new OXMLFixedContent(m_rImport,nPrefix, rLocalName,m_rCell,m_pContainer,true); + break; + case XML_TOK_TEXT_TAB_STOP: + pContext = new OXMLCharContent( m_rImport, this,nPrefix, + rLocalName, xAttrList, + 0x0009, sal_False ); + break; + + case XML_TOK_TEXT_LINE_BREAK: + pContext = new OXMLCharContent( m_rImport, this,nPrefix, + rLocalName, xAttrList, + ControlCharacter::LINE_BREAK ); + break; + + case XML_TOK_TEXT_S: + pContext = new OXMLCharContent( m_rImport, this,nPrefix, + rLocalName, xAttrList, + 0x0020, sal_True ); + break; + } + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLFixedContent::EndElement() +{ + if ( m_bInP ) + { + Reference xFactor(m_rImport.GetModel(),uno::UNO_QUERY); + Reference< XFixedText > xControl(xFactor->createInstance(SERVICE_FIXEDTEXT),uno::UNO_QUERY); + OSL_ENSURE(xControl.is(),"Could not create FixedContent!"); + m_xComponent = xControl.get(); + m_pContainer->addCell(m_xComponent); + m_rCell.setComponent(m_xComponent); + xControl->setLabel(m_sLabel); + OXMLReportElementBase::EndElement(); + } +} +// ----------------------------------------------------------------------------- +void OXMLFixedContent::Characters( const ::rtl::OUString& rChars ) +{ + m_sLabel += rChars; +} + +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlFixedContent.hxx b/reportdesign/source/filter/xml/xmlFixedContent.hxx new file mode 100644 index 000000000000..3b42b2f0ee95 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFixedContent.hxx @@ -0,0 +1,81 @@ +#ifndef RPT_XMLFIXEDCONTENT_HXX +#define RPT_XMLFIXEDCONTENT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFixedContent.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#include "xmlReportElementBase.hxx" +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include +#endif + + +namespace rptxml +{ + class ORptFilter; + class OXMLCell; + class OXMLFixedContent : public OXMLReportElementBase + { + ::rtl::OUString m_sLabel; + OXMLCell& m_rCell; + bool m_bInP; + + protected: + virtual SvXMLImportContext* _CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + OXMLFixedContent(const OXMLFixedContent&); + void operator =(const OXMLFixedContent&); + public: + + OXMLFixedContent( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName + ,OXMLCell& _rCell + ,OXMLTable* _pContainer + ,bool _bInP = false); + virtual ~OXMLFixedContent(); + + // This method is called for all characters that are contained in the + // current element. The default is to ignore them. + virtual void Characters( const ::rtl::OUString& rChars ); + + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLFIXEDCONTENT_HXX diff --git a/reportdesign/source/filter/xml/xmlFormatCondition.cxx b/reportdesign/source/filter/xml/xmlFormatCondition.cxx new file mode 100644 index 000000000000..a0124195cd84 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFormatCondition.cxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFormatCondition.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLFORMATCONDITION_HXX +#include "xmlFormatCondition.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCONTROLFORMAT_HPP_ +#include +#endif +#ifndef _COMPHELPER_GENERICPROPERTYSET_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_ +#include +#endif +#ifndef RPT_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::comphelper; + using namespace ::com::sun::star; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; + using namespace ::com::sun::star::beans; + +DBG_NAME( rpt_OXMLFormatCondition ) + +OXMLFormatCondition::OXMLFormatCondition( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & _xAttrList + ,const Reference< XFormatCondition > & _xComponent ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +,m_xComponent(_xComponent) +{ + DBG_CTOR( rpt_OXMLFormatCondition,NULL); + + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetFormatElemTokenMap(); + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_ENABLED: + m_xComponent->setEnabled(sValue == s_sTRUE); + break; + case XML_TOK_FORMULA: + m_xComponent->setFormula(ORptFilter::convertFormula(sValue)); + break; + case XML_TOK_FORMAT_STYLE_NAME: + m_sStyleName = sValue; + break; + default: + break; + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the report definition props"); + } +} +// ----------------------------------------------------------------------------- + +OXMLFormatCondition::~OXMLFormatCondition() +{ + + DBG_DTOR( rpt_OXMLFormatCondition,NULL); +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLFormatCondition::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +void OXMLFormatCondition::EndElement() +{ + OXMLHelper::copyStyleElements(m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get()); +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlFormatCondition.hxx b/reportdesign/source/filter/xml/xmlFormatCondition.hxx new file mode 100644 index 000000000000..18c612fe4e1a --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFormatCondition.hxx @@ -0,0 +1,69 @@ +#ifndef RPT_XMLFORMATCONDITION_HXX +#define RPT_XMLFORMATCONDITION_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFormatCondition.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XFORMATCONDITION_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLFormatCondition : public SvXMLImportContext + { + ::rtl::OUString m_sStyleName; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormatCondition > m_xComponent; + ORptFilter& GetOwnImport(); + OXMLFormatCondition(const OXMLFormatCondition&); + void operator =(const OXMLFormatCondition&); + public: + + OXMLFormatCondition( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormatCondition >& _xComponent + ); + virtual ~OXMLFormatCondition(); + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLFORMATTEDFIELD_HXX diff --git a/reportdesign/source/filter/xml/xmlFormattedField.cxx b/reportdesign/source/filter/xml/xmlFormattedField.cxx new file mode 100644 index 000000000000..fd266ec65443 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFormattedField.cxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFormattedField.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLFORMATTEDFIELD_HXX +#include "xmlFormattedField.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCONTROLPROPERTY_HXX +#include "xmlControlProperty.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLREPORTELEMENT_HXX +#include "xmlReportElement.hxx" +#endif +#ifndef RPT_XMLCOMPONENT_HXX +#include "xmlComponent.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace xml::sax; +DBG_NAME( rpt_OXMLFormattedField ) + +OXMLFormattedField::OXMLFormattedField( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName + ,const uno::Reference< xml::sax::XAttributeList > & _xAttrList + ,const uno::Reference< XFormattedField > & _xComponent + ,OXMLTable* _pContainer + ,bool _bPageCount) : + OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer) +{ + DBG_CTOR( rpt_OXMLFormattedField,NULL); + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetControlElemTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_DATA_FORMULA: + _xComponent->setDataField(ORptFilter::convertFormula(sValue)); + break; + case XML_TOK_SELECT_PAGE: + { + static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("rpt:PageNumber()")); + _xComponent->setDataField(s_sPageNumber); + } + break; + default: + break; + } + } + if ( _bPageCount ) + { + static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("rpt:PageCount()")); + _xComponent->setDataField(s_sPageNumber); + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the report definition props"); + } +} +// ----------------------------------------------------------------------------- +OXMLFormattedField::~OXMLFormattedField() +{ + DBG_DTOR( rpt_OXMLFormattedField,NULL); +} +// ----------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlFormattedField.hxx b/reportdesign/source/filter/xml/xmlFormattedField.hxx new file mode 100644 index 000000000000..1fbcd1af3e47 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFormattedField.hxx @@ -0,0 +1,67 @@ +#ifndef RPT_XMLFORMATTEDFIELD_HXX +#define RPT_XMLFORMATTEDFIELD_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFormattedField.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#include "xmlReportElementBase.hxx" +#endif +#ifndef _COM_SUN_STAR_REPORT_XFORMATTEDFIELD_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLFormattedField : public OXMLReportElementBase + { + OXMLFormattedField(const OXMLFormattedField&); + void operator =(const OXMLFormattedField&); + public: + + OXMLFormattedField( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormattedField >& _xComponent + ,OXMLTable* _pContainer + ,bool _bPageCount); + virtual ~OXMLFormattedField(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLFORMATTEDFIELD_HXX diff --git a/reportdesign/source/filter/xml/xmlFunction.cxx b/reportdesign/source/filter/xml/xmlFunction.cxx new file mode 100644 index 000000000000..4f60d7a26e31 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFunction.cxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFunction.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLFUNCTION_HXX +#include "xmlFunction.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#include "xmlstrings.hrc" +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::xml::sax; + +DBG_NAME( rpt_OXMLFunction ) + +OXMLFunction::OXMLFunction( ORptFilter& _rImport + ,sal_uInt16 nPrfx + ,const OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XFunctionsSupplier >& _xFunctions + ) : + SvXMLImportContext( _rImport, nPrfx, _sLocalName ) + ,m_xFunctions(_xFunctions->getFunctions()) +{ + DBG_CTOR( rpt_OXMLFunction,NULL); + + OSL_ENSURE(m_xFunctions.is(),"Functions is NULL!"); + m_xFunction = m_xFunctions->createFunction(); + + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + + const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = _rImport.GetFunctionElemTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + try + { + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_FUNCTION_NAME: + m_xFunction->setName(sValue); + break; + case XML_TOK_FUNCTION_FORMULA: + m_xFunction->setFormula(ORptFilter::convertFormula(sValue)); + break; + case XML_TOK_PRE_EVALUATED: + m_xFunction->setPreEvaluated(sValue == s_sTRUE); + break; + case XML_TOK_INITIAL_FORMULA: + m_xFunction->setInitialFormula(beans::Optional< ::rtl::OUString>(sal_True,ORptFilter::convertFormula(sValue))); + break; + case XML_TOK_DEEP_TRAVERSING: + m_xFunction->setDeepTraversing(sValue == s_sTRUE); + break; + default: + break; + } + } + catch(const Exception&) + { + OSL_ENSURE(0,"Exception catched while putting Function props!"); + } + } +} +// ----------------------------------------------------------------------------- + +OXMLFunction::~OXMLFunction() +{ + DBG_DTOR( rpt_OXMLFunction,NULL); +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLFunction::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +void OXMLFunction::EndElement() +{ + try + { + m_xFunctions->insertByIndex(m_xFunctions->getCount(),uno::makeAny(m_xFunction)); + m_xFunction.clear(); + }catch(uno::Exception&) + { + OSL_ENSURE(0,"Exception catched!"); + } +} +// ----------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlFunction.hxx b/reportdesign/source/filter/xml/xmlFunction.hxx new file mode 100644 index 000000000000..42066872e004 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlFunction.hxx @@ -0,0 +1,81 @@ +#ifndef RPT_XMLFUNCTION_HXX +#define RPT_XMLFUNCTION_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlFunction.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XFUNCTIONSSUPPLIER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XFUNCTIONS_HPP_ +#include +#endif + + +namespace rptxml +{ + class ORptFilter; + class OXMLFunction : public SvXMLImportContext + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctions > m_xFunctions; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > m_xFunction; + + ORptFilter& GetOwnImport(); + + OXMLFunction(const OXMLFunction&); + void operator =(const OXMLFunction&); + public: + + OXMLFunction( ORptFilter& rImport + , sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier >& _xFunctions + ); + virtual ~OXMLFunction(); + + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLFunction_HXX diff --git a/reportdesign/source/filter/xml/xmlGroup.cxx b/reportdesign/source/filter/xml/xmlGroup.cxx new file mode 100644 index 000000000000..104bebcdda7d --- /dev/null +++ b/reportdesign/source/filter/xml/xmlGroup.cxx @@ -0,0 +1,251 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlGroup.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLGROUP_HXX +#include "xmlGroup.hxx" +#endif +#ifndef RPT_XMLSECTION_HXX +#include "xmlSection.hxx" +#endif +#ifndef RPT_XMLFUNCTION_HXX +#include "xmlFunction.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include +#endif +#ifndef _COMPHELPER_NAMECONTAINER_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_GROUPON_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_KEEPTOGETHER_HPP_ +#include +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::xml::sax; + + sal_uInt16 lcl_getKeepTogetherOption(const ::rtl::OUString& _sValue) + { + sal_uInt16 nRet = report::KeepTogether::NO; + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetKeepTogetherOptions(); + SvXMLUnitConverter::convertEnum( nRet, _sValue, aXML_EnumMap ); + return nRet; + } +DBG_NAME( rpt_OXMLGroup ) + +OXMLGroup::OXMLGroup( ORptFilter& _rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ) : + SvXMLImportContext( _rImport, nPrfx, _sLocalName ) +{ + DBG_CTOR( rpt_OXMLGroup,NULL); + + m_xGroups = _rImport.getReportDefinition()->getGroups(); + OSL_ENSURE(m_xGroups.is(),"Groups is NULL!"); + m_xGroup = m_xGroups->createGroup(); + + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + + const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = _rImport.GetGroupElemTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + for(sal_Int16 i = 0; i < nLength; ++i) + { + ::rtl::OUString sLocalName; + const ::rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + ::rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + try + { + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_START_NEW_COLUMN: + m_xGroup->setStartNewColumn(sValue == s_sTRUE); + break; + case XML_TOK_RESET_PAGE_NUMBER: + m_xGroup->setResetPageNumber(sValue == s_sTRUE); + break; + case XML_TOK_SORT_ASCENDING: + m_xGroup->setSortAscending(sValue == s_sTRUE); + break; + case XML_TOK_GROUP_EXPRESSION: + { + sal_Int32 nLen = sValue.getLength(); + if ( nLen ) + { + const static ::rtl::OUString s_sChanged(RTL_CONSTASCII_USTRINGPARAM("rpt:HASCHANGED(\"")); + sal_Int32 nPos = sValue.indexOf(s_sChanged); + if ( nPos == -1 ) + nPos = 5; + else + { + nPos = s_sChanged.getLength(); + --nLen; + } + sValue = sValue.copy(nPos,nLen-nPos-1); + m_xGroup->setExpression(sValue); + } + } + break; + case XML_TOK_GROUP_KEEP_TOGETHER: + m_xGroup->setKeepTogether(lcl_getKeepTogetherOption(sValue)); + break; + default: + break; + } + } + catch(const Exception&) + { + OSL_ENSURE(0,"Exception catched while putting group props!"); + } + } +} +// ----------------------------------------------------------------------------- + +OXMLGroup::~OXMLGroup() +{ + + DBG_DTOR( rpt_OXMLGroup,NULL); +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLGroup::CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetGroupElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_GROUP_FUNCTION: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLFunction( rImport, nPrefix, rLocalName,xAttrList,m_xGroup.get()); + } + break; + case XML_TOK_GROUP_HEADER: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + m_xGroup->setHeaderOn(sal_True); + pContext = new OXMLSection( rImport, nPrefix, rLocalName,xAttrList,m_xGroup->getHeader()); + } + break; + case XML_TOK_GROUP_GROUP: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLGroup( rImport, nPrefix, rLocalName,xAttrList); + break; + case XML_TOK_GROUP_DETAIL: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + Reference m_xComponent = rImport.getReportDefinition(); + pContext = new OXMLSection( rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getDetail()); + } + break; + + case XML_TOK_GROUP_FOOTER: + { + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + m_xGroup->setFooterOn(sal_True); + pContext = new OXMLSection( rImport, nPrefix, rLocalName,xAttrList,m_xGroup->getFooter()); + } + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLGroup::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +void OXMLGroup::EndElement() +{ + try + { + // the group elements end in the reverse order + m_xGroups->insertByIndex(0,uno::makeAny(m_xGroup)); + }catch(uno::Exception&) + { + OSL_ENSURE(0,"Exception catched!"); + } +} +// ----------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlGroup.hxx b/reportdesign/source/filter/xml/xmlGroup.hxx new file mode 100644 index 000000000000..76c98a4720f3 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlGroup.hxx @@ -0,0 +1,80 @@ +#ifndef RPT_XMLGROUP_HXX +#define RPT_XMLGROUP_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlGroup.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XGROUPS_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLGroup : public SvXMLImportContext + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroups > m_xGroups; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > m_xGroup; + + ORptFilter& GetOwnImport(); + + OXMLGroup(const OXMLGroup&); + void operator =(const OXMLGroup&); + public: + + OXMLGroup( ORptFilter& rImport + , sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ); + virtual ~OXMLGroup(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLGROUP_HXX diff --git a/reportdesign/source/filter/xml/xmlHelper.cxx b/reportdesign/source/filter/xml/xmlHelper.cxx new file mode 100644 index 000000000000..20d8861ae88e --- /dev/null +++ b/reportdesign/source/filter/xml/xmlHelper.cxx @@ -0,0 +1,487 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlHelper.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_FAMILIES_HXX_ +#include +#endif +#include +#include +#include +#include +#include +#include +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_AWT_IMAGEPOSITION_HPP_ +#include +#endif +#ifndef _XMLOFF_PRSTYLEI_HXX_ +#include +#endif +#include "xmlstrings.hrc" +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef _XMLOFF_CONTEXTID_HXX_ +#include +#endif +#ifndef _XMLOFF_TEXTPRMAP_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_ +#include +#endif +#include +#ifndef _XMLOFF_XMLCONSTANTSPROPERTYHANDLER_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_FORCENEWPAGE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_REPORTPRINTOPTION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_GROUPON_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_KEEPTOGETHER_HPP_ +#include +#endif +#ifndef _XMLOFF_XMLEMENT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCONTROLFORMAT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FORM_LISTSOURCETYPE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DRAWING_TEXTVERTICALADJUST_HPP_ +#include +#endif +#ifndef _XMLOFF_ENUMPROPERTYHANDLER_HXX +#include +#endif + +#define XML_RPT_ALGINMENT (XML_DB_TYPES_START+1) +namespace rptxml +{ + using namespace ::xmloff::token; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star; + using namespace ::com::sun::star::sdb; + using namespace ::com::sun::star::form; + using namespace ::com::sun::star::beans; + +OPropertyHandlerFactory::OPropertyHandlerFactory() +{ +} +// ----------------------------------------------------------------------------- +OPropertyHandlerFactory::~OPropertyHandlerFactory() +{ +} +// ----------------------------------------------------------------------------- +const XMLPropertyHandler* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType) const +{ + const XMLPropertyHandler* pHandler = NULL; + + switch(_nType) + { + case XML_RPT_ALGINMENT: + { + static SvXMLEnumMapEntry __READONLY_DATA pXML_VerticalAlign_Enum[] = + { + { XML_TOP, drawing::TextVerticalAdjust_TOP }, + { XML_MIDDLE, drawing::TextVerticalAdjust_CENTER }, + { XML_BOTTOM, drawing::TextVerticalAdjust_BOTTOM }, + { XML_JUSTIFY, drawing::TextVerticalAdjust_BLOCK }, + { XML_TOKEN_INVALID, 0 } + }; + + pHandler = new XMLEnumPropertyHdl( pXML_VerticalAlign_Enum, ::getCppuType((const com::sun::star::drawing::TextVerticalAdjust*)0) ); + } + break; + default: + ; + } + + if ( !pHandler ) + pHandler = OControlPropertyHandlerFactory::GetPropertyHandler(_nType); + return pHandler; +} +// ----------------------------------------------------------------------------- +#define MAP_CONST( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TEXT, context } +#define MAP_CONST_T( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TABLE, context } +#define MAP_CONST_ASCII_T( name, prefix, token, type, context ) { name, sizeof(name)-1,XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TABLE, context } +#define MAP_CONST_P( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_PARAGRAPH, context } +#define MAP_CONST_S( name, prefix, token, type, context ) { name, sizeof(name)-1, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_SECTION, context } +#define MAP_CONST_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TEXT, context } +#define GMAP( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_GRAPHIC, context } +#define MAP_CONST_C_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TABLE_CELL, context } +#define MAP_CONST_C( name, prefix, token, type, context ) { name, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TABLE_CELL, context } +#define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0 ,0} +// ----------------------------------------------------------------------------- +UniReference < XMLPropertySetMapper > OXMLHelper::GetCellStylePropertyMap() +{ + static const XMLPropertyMapEntry s_aXMLCellStylesProperties[] = + { + MAP_CONST_C( PROPERTY_FORMATKEY, STYLE, DATA_STYLE_NAME, XML_TYPE_NUMBER | MID_FLAG_SPECIAL_ITEM, CTF_RPT_NUMBERFORMAT ), + + MAP_CONST_P( PROPERTY_CONTROLBACKGROUND, + FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ), + MAP_CONST_P( PROPERTY_CONTROLBACKGROUNDTRANSPARENT, + FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ), + MAP_CONST_C_ASCII( "BorderLeft", FO, BORDER_LEFT, XML_TYPE_BORDER, 0 ), + MAP_CONST_C_ASCII( "BorderRight", FO, BORDER_RIGHT, XML_TYPE_BORDER, 0 ), + MAP_CONST_C_ASCII( "BorderTop", FO, BORDER_TOP, XML_TYPE_BORDER, 0 ), + MAP_CONST_C_ASCII( "BorderBottom", FO, BORDER_BOTTOM, XML_TYPE_BORDER, 0 ), + MAP_END() + }; + return new XMLPropertySetMapper((XMLPropertyMapEntry*)s_aXMLCellStylesProperties,new OPropertyHandlerFactory()); +} +// ----------------------------------------------------------------------------- +const XMLPropertyMapEntry* OXMLHelper::GetTableStyleProps() +{ + static const XMLPropertyMapEntry aXMLTableStylesProperties[] = + { + MAP_CONST_T( PROPERTY_BACKCOLOR, FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ), + MAP_CONST_T( PROPERTY_BACKTRANSPARENT,FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT | MID_FLAG_MERGE_ATTRIBUTE, 0 ), + // MAP_CONST_T( PROPERTY_KEEPTOGETHER, STYLE, MAY_BREAK_BETWEEN_ROWS, XML_TYPE_BOOL , 0 ), + MAP_END() + }; + return aXMLTableStylesProperties; +} +// ----------------------------------------------------------------------------- +const XMLPropertyMapEntry* OXMLHelper::GetRowStyleProps() +{ + static const XMLPropertyMapEntry aXMLStylesProperties[] = + { + MAP_CONST_S( "Height", STYLE, ROW_HEIGHT, XML_TYPE_PROP_TABLE_ROW|XML_TYPE_MEASURE, 0), + MAP_END() + }; + return aXMLStylesProperties; +} +// ----------------------------------------------------------------------------- +const XMLPropertyMapEntry* OXMLHelper::GetColumnStyleProps() +{ + static const XMLPropertyMapEntry aXMLColumnStylesProperties[] = + { + //MAP( "IsManualPageBreak", XML_NAMESPACE_FO, XML_BREAK_BEFORE, XML_TYPE_PROP_TABLE_COLUMN|XML_SC_TYPE_BREAKBEFORE, 0), + //MAP( "IsVisible", XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TYPE_PROP_TABLE_COLUMN|XML_SC_TYPE_EQUAL|MID_FLAG_SPECIAL_ITEM, CTF_SC_ISVISIBLE ), + MAP_CONST_S( "Width", STYLE, COLUMN_WIDTH, XML_TYPE_PROP_TABLE_COLUMN|XML_TYPE_MEASURE, 0 ), + // MAP( "OptimalWidth", XML_NAMESPACE_STYLE, XML_USE_OPTIMAL_COLUMN_WIDTH, XML_TYPE_PROP_TABLE_COLUMN|XML_TYPE_BOOL, 0), + MAP_END() + }; + return aXMLColumnStylesProperties; +} +// ----------------------------------------------------------------------------- +const SvXMLEnumMapEntry* OXMLHelper::GetReportPrintOptions() +{ + static SvXMLEnumMapEntry s_aXML_EnumMap[] = + { + // { XML_ALL_PAGES, report::ReportPrintOption::ALL_PAGES }, // default + { XML_NOT_WITH_REPORT_HEADER, report::ReportPrintOption::NOT_WITH_REPORT_HEADER }, + { XML_NOT_WITH_REPORT_FOOTER, report::ReportPrintOption::NOT_WITH_REPORT_FOOTER }, + { XML_NOT_WITH_REPORT_HEADER_NOR_FOOTER, report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER }, + { XML_TOKEN_INVALID, 0 } + }; + return s_aXML_EnumMap; +} +// ----------------------------------------------------------------------------- +const SvXMLEnumMapEntry* OXMLHelper::GetForceNewPageOptions() +{ + static SvXMLEnumMapEntry s_aXML_EnumMap[] = + { + // { XML_NONE, report::ForceNewPage::NONE }, // default + { XML_BEFORE_SECTION, report::ForceNewPage::BEFORE_SECTION }, + { XML_AFTER_SECTION, report::ForceNewPage::AFTER_SECTION }, + { XML_BEFORE_AFTER_SECTION, report::ForceNewPage::BEFORE_AFTER_SECTION }, + { XML_TOKEN_INVALID, 0 } + }; + return s_aXML_EnumMap; +} +// ----------------------------------------------------------------------------- +//// ----------------------------------------------------------------------------- +//const SvXMLEnumMapEntry* OXMLHelper::GetGroupOnOptions() +//{ +// static SvXMLEnumMapEntry s_aXML_EnumMap[] = +// { +// // { XML_DEFAULT ,report::GroupOn::DEFAULT }, // default +// { XML_PREFIX_CHARACTERS ,report::GroupOn::PREFIX_CHARACTERS }, +// { XML_YEAR ,report::GroupOn::YEAR }, +// { XML_QUARTAL , report::GroupOn::QUARTAL }, +// { XML_MONTH , report::GroupOn::MONTH }, +// { XML_WEEK , report::GroupOn::WEEK }, +// { XML_DAY , report::GroupOn::DAY }, +// { XML_HOUR , report::GroupOn::HOUR }, +// { XML_MINUTE , report::GroupOn::MINUTE }, +// { XML_INTERVAL , report::GroupOn::INTERVAL }, +// { XML_TOKEN_INVALID, 0 } +// }; +// return s_aXML_EnumMap; +//} +// ----------------------------------------------------------------------------- +const SvXMLEnumMapEntry* OXMLHelper::GetKeepTogetherOptions() +{ + static SvXMLEnumMapEntry s_aXML_EnumMap[] = + { + // { XML_NO, report::KeepTogether::NO }, // default + { XML_WHOLE_GROUP, report::KeepTogether::WHOLE_GROUP }, + { XML_WITH_FIRST_DETAIL, report::KeepTogether::WITH_FIRST_DETAIL }, + { XML_TOKEN_INVALID, 0 } + }; + return s_aXML_EnumMap; +} +// ----------------------------------------------------------------------------- +const SvXMLEnumMapEntry* OXMLHelper::GetImagePositionOptions() +{ + static SvXMLEnumMapEntry s_aXML_EnumMap[] = + { + { XML_START, 0 }, + { XML_END, 1 }, + { XML_TOP, 2 }, + { XML_BOTTOM, 3 }, + { XML_CENTER, (sal_uInt16)-1 }, + { XML_TOKEN_INVALID, 0 } + }; + return s_aXML_EnumMap; +} +// ----------------------------------------------------------------------------- +const SvXMLEnumMapEntry* OXMLHelper::GetImageAlignOptions() +{ + static SvXMLEnumMapEntry s_aXML_EnumMap[] = + { + { XML_START, 0 }, + { XML_CENTER, 1 }, + { XML_END, 2 }, + { XML_TOKEN_INVALID, 0 } + }; + return s_aXML_EnumMap; +} +// ----------------------------------------------------------------------------- +const SvXMLEnumMapEntry* OXMLHelper::GetCommandTypeOptions() +{ + static SvXMLEnumMapEntry s_aXML_EnumMap[] = + { + { XML_TABLE, CommandType::TABLE }, + { XML_QUERY, CommandType::QUERY }, + // { XML_COMMAND, CommandType::COMMAND }, // default + { XML_TOKEN_INVALID, 0 } + }; + return s_aXML_EnumMap; +} +// ----------------------------------------------------------------------------- +uno::Reference< util::XNumberFormatsSupplier > OXMLHelper::GetNumberFormatsSupplier(const uno::Reference& _xReportDefinition) +{ + uno::Reference< util::XNumberFormatsSupplier > xSupplier; + uno::Reference< uno::XInterface> xParent = _xReportDefinition->getParent(); + if ( xParent.is() ) + { + uno::Reference< sdb::XOfficeDatabaseDocument > xDatabaseDocument(xParent,uno::UNO_QUERY); + if ( !xDatabaseDocument.is() ) + { + uno::Reference< container::XChild> xChild(xParent,uno::UNO_QUERY); + while( !xDatabaseDocument.is() && xChild.is() ) + { + xParent = xChild->getParent(); + xDatabaseDocument.set(xParent,uno::UNO_QUERY); + xChild.set(xParent,uno::UNO_QUERY); + } + } + if ( xDatabaseDocument.is() ) + { + uno::Reference xProp(xDatabaseDocument->getDataSource(),uno::UNO_QUERY); + if ( xProp.is() ) + xSupplier.set(xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormatsSupplier"))),uno::UNO_QUERY); + } + } + else + { + ::comphelper::MediaDescriptor aDescriptor( _xReportDefinition->getArgs() ); + uno::Sequence aComponentData; + aComponentData = aDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ComponentData")),aComponentData); + if ( aComponentData.getLength() ) + { + ::comphelper::SequenceAsHashMap aComponentDataMap( aComponentData ); + uno::Reference xConnection; + xConnection = aComponentDataMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")),xConnection); + xSupplier = dbtools::getNumberFormats(xConnection); + } + } + return xSupplier; +} +// ----------------------------------------------------------------------------- +#define PROPERTY_ID_FONTNAME 1 +#define PROPERTY_ID_FONTHEIGHT 2 +#define PROPERTY_ID_FONTWIDTH 3 +#define PROPERTY_ID_FONTSTYLENAME 4 +#define PROPERTY_ID_FONTFAMILY 5 +#define PROPERTY_ID_FONTCHARSET 6 +#define PROPERTY_ID_FONTPITCH 7 +#define PROPERTY_ID_FONTCHARWIDTH 8 +#define PROPERTY_ID_FONTWEIGHT 9 +#define PROPERTY_ID_FONTSLANT 10 +#define PROPERTY_ID_FONTUNDERLINE 11 +#define PROPERTY_ID_FONTSTRIKEOUT 12 +#define PROPERTY_ID_FONTORIENTATION 13 +#define PROPERTY_ID_FONTKERNING 14 +#define PROPERTY_ID_FONTWORDLINEMODE 15 +#define PROPERTY_ID_FONTTYPE 16 +void OXMLHelper::copyStyleElements(const ::rtl::OUString& _sStyleName,const SvXMLStylesContext* _pAutoStyles,const uno::Reference& _xProp) +{ + if ( !_xProp.is() || !_sStyleName.getLength() || !_pAutoStyles ) + return; + XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,_pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,_sStyleName)); + if ( pAutoStyle ) + { + ::com::sun::star::awt::FontDescriptor aFont; + static comphelper::PropertyMapEntry pMap[] = + { + {PROPERTY_FONTNAME, static_cast(PROPERTY_FONTNAME.length), PROPERTY_ID_FONTNAME, &::getCppuType(&aFont.Name) ,PropertyAttribute::BOUND,0}, + {PROPERTY_CHARFONTHEIGHT, static_cast(PROPERTY_CHARFONTHEIGHT.length), PROPERTY_ID_FONTHEIGHT, &::getCppuType(&aFont.Height) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTWIDTH, static_cast(PROPERTY_FONTWIDTH.length), PROPERTY_ID_FONTWIDTH, &::getCppuType(&aFont.Width) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTSTYLENAME, static_cast(PROPERTY_FONTSTYLENAME.length), PROPERTY_ID_FONTSTYLENAME, &::getCppuType(&aFont.StyleName) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTFAMILY, static_cast(PROPERTY_FONTFAMILY.length), PROPERTY_ID_FONTFAMILY, &::getCppuType(&aFont.Family) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTCHARSET, static_cast(PROPERTY_FONTCHARSET.length), PROPERTY_ID_FONTCHARSET, &::getCppuType(&aFont.CharSet) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTPITCH, static_cast(PROPERTY_FONTPITCH.length), PROPERTY_ID_FONTPITCH, &::getCppuType(&aFont.Pitch) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTCHARWIDTH, static_cast(PROPERTY_FONTCHARWIDTH.length), PROPERTY_ID_FONTCHARWIDTH, &::getCppuType(&aFont.CharacterWidth),PropertyAttribute::BOUND,0}, + {PROPERTY_FONTWEIGHT, static_cast(PROPERTY_FONTWEIGHT.length), PROPERTY_ID_FONTWEIGHT, &::getCppuType(&aFont.Weight) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTSLANT, static_cast(PROPERTY_FONTSLANT.length), PROPERTY_ID_FONTSLANT, &::getCppuType(&aFont.Slant) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTUNDERLINE, static_cast(PROPERTY_FONTUNDERLINE.length), PROPERTY_ID_FONTUNDERLINE, &::getCppuType(&aFont.Underline) ,PropertyAttribute::BOUND,0}, + {PROPERTY_CHARSTRIKEOUT, static_cast(PROPERTY_CHARSTRIKEOUT.length), PROPERTY_ID_FONTSTRIKEOUT, &::getCppuType(&aFont.Strikeout) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTORIENTATION, static_cast(PROPERTY_FONTORIENTATION.length), PROPERTY_ID_FONTORIENTATION, &::getCppuType(&aFont.Orientation) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTKERNING, static_cast(PROPERTY_FONTKERNING.length), PROPERTY_ID_FONTKERNING, &::getCppuType(&aFont.Kerning) ,PropertyAttribute::BOUND,0}, + {PROPERTY_CHARWORDMODE, static_cast(PROPERTY_CHARWORDMODE.length), PROPERTY_ID_FONTWORDLINEMODE, &::getCppuType(&aFont.WordLineMode) ,PropertyAttribute::BOUND,0}, + {PROPERTY_FONTTYPE, static_cast(PROPERTY_FONTTYPE.length), PROPERTY_ID_FONTTYPE, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0}, + //{PROPERTY_BACKGROUNDCOLOR, static_cast(PROPERTY_BACKGROUNDCOLOR.length), PROPERTY_ID_BACKGROUNDCOLOR, &::getCppuType(&nBackgroundColor) ,PropertyAttribute::BOUND,0},, + //{PROPERTY_PARAADJUST, static_cast(PROPERTY_PARAADJUST.length), PROPERTY_ID_ALIGN, &::getCppuType(&nAlign) ,PropertyAttribute::BOUND,0},, + //{PROPERTY_CONTROLBORDER, static_cast(PROPERTY_CONTROLBORDER.length), PROPERTY_ID_BORDER, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},, + //{PROPERTY_CONTROLBORDERCOLOR, static_cast(PROPERTY_CONTROLBORDERCOLOR.length), PROPERTY_ID_BORDERCOLOR, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},, + //{PROPERTY_CHARCOLOR, static_cast(PROPERTY_TEXTCOLOR.length), PROPERTY_ID_TEXTCOLOR, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},, + //{PROPERTY_FORMATKEY, static_cast(PROPERTY_FORMATKEY.length), PROPERTY_ID_FORMATKEY, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},, + //{PROPERTY_CHARUNDERLINECOLOR, static_cast(PROPERTY_CHARUNDERLINECOLOR.length), PROPERTY_ID_TEXTLINECOLOR, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},, + { NULL, 0, 0, NULL, 0, 0 } + }; + try + { + uno::Reference xProp = comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap)); + pAutoStyle->FillPropertySet(xProp); + xProp->getPropertyValue(PROPERTY_FONTNAME) >>= aFont.Name; + xProp->getPropertyValue(PROPERTY_CHARFONTHEIGHT) >>= aFont.Height; + xProp->getPropertyValue(PROPERTY_FONTWIDTH) >>= aFont.Width; + xProp->getPropertyValue(PROPERTY_FONTSTYLENAME) >>= aFont.StyleName; + xProp->getPropertyValue(PROPERTY_FONTFAMILY) >>= aFont.Family; + xProp->getPropertyValue(PROPERTY_FONTCHARSET) >>= aFont.CharSet; + xProp->getPropertyValue(PROPERTY_FONTPITCH) >>= aFont.Pitch; + xProp->getPropertyValue(PROPERTY_FONTCHARWIDTH) >>= aFont.CharacterWidth; + xProp->getPropertyValue(PROPERTY_FONTWEIGHT) >>= aFont.Weight; + xProp->getPropertyValue(PROPERTY_FONTSLANT) >>= aFont.Slant; + xProp->getPropertyValue(PROPERTY_FONTUNDERLINE) >>= aFont.Underline; + xProp->getPropertyValue(PROPERTY_CHARSTRIKEOUT) >>= aFont.Strikeout; + xProp->getPropertyValue(PROPERTY_FONTORIENTATION) >>= aFont.Orientation; + xProp->getPropertyValue(PROPERTY_FONTKERNING) >>= aFont.Kerning; + xProp->getPropertyValue(PROPERTY_CHARWORDMODE) >>= aFont.WordLineMode; + xProp->getPropertyValue(PROPERTY_FONTTYPE) >>= aFont.Type; + uno::Reference xReportControlModel(_xProp,uno::UNO_QUERY); + if ( xReportControlModel.is() ) + try + { + xReportControlModel->setFontDescriptor(aFont); + } + catch(beans::UnknownPropertyException){} + pAutoStyle->FillPropertySet(_xProp); + if ( xReportControlModel.is() ) + { + sal_Int16 nTextAlign = xReportControlModel->getParaAdjust(); + switch(nTextAlign) + { + case style::ParagraphAdjust_LEFT: + nTextAlign = awt::TextAlign::LEFT; + break; + case style::ParagraphAdjust_CENTER: + nTextAlign = awt::TextAlign::CENTER; + break; + case style::ParagraphAdjust_RIGHT: + nTextAlign = awt::TextAlign::RIGHT; + break; + default: + OSL_ENSURE(0,"Illegal text alignment value!"); + break; + } + xReportControlModel->setParaAdjust(nTextAlign); + } + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"OXMLHelper::copyStyleElements -> exception catched"); + } + } +} +// ----------------------------------------------------------------------------- +uno::Reference OXMLHelper::createBorderPropertySet() +{ + static comphelper::PropertyMapEntry pMap[] = + { + {PROPERTY_BORDERLEFT, static_cast(PROPERTY_BORDERLEFT.length), 0, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0}, + {PROPERTY_BORDERRIGHT, static_cast(PROPERTY_BORDERRIGHT.length), 1, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0}, + {PROPERTY_BORDERTOP, static_cast(PROPERTY_BORDERTOP.length), 2, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0}, + {PROPERTY_BORDERBOTTOM, static_cast(PROPERTY_BORDERBOTTOM.length), 3, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0}, + { NULL, 0, 0, NULL, 0, 0 } + }; + return comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap)); +} +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlHelper.hxx b/reportdesign/source/filter/xml/xmlHelper.hxx new file mode 100644 index 000000000000..fcf26c146e98 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlHelper.hxx @@ -0,0 +1,112 @@ +#ifndef RPT_XMLHELPER_HXX +#define RPT_XMLHELPER_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlHelper.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX +#include +#endif +#ifndef _XMLOFF_CONTEXTID_HXX_ +#include +#endif +#ifndef _XMLOFF_FORMS_CONTROLPROPERTYHDL_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTDEFINITION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ +#include +#endif + +#include + +#define CTF_RPT_NUMBERFORMAT (XML_DB_CTF_START + 1) +#define CTF_RPT_PARAVERTALIGNMENT (XML_DB_CTF_START + 2) + +#define XML_STYLE_FAMILY_REPORT_ID 700 +#define XML_STYLE_FAMILY_REPORT_NAME "report-element" +#define XML_STYLE_FAMILY_REPORT_PREFIX "rptelem" + + +class SvXMLImport; +class SvXMLExport; +class SvXMLStylesContext; +namespace rptxml +{ + class OPropertyHandlerFactory : public ::xmloff::OControlPropertyHandlerFactory + { + OPropertyHandlerFactory(const OPropertyHandlerFactory&); + void operator =(const OPropertyHandlerFactory&); + protected: + mutable ::std::auto_ptr m_pDisplayHandler; + mutable ::std::auto_ptr m_pTextAlignHandler; + public: + OPropertyHandlerFactory(); + virtual ~OPropertyHandlerFactory(); + + virtual const XMLPropertyHandler* GetPropertyHandler(sal_Int32 _nType) const; + }; + + class OXMLHelper + { + public: + static UniReference < XMLPropertySetMapper > GetCellStylePropertyMap(); + + static const SvXMLEnumMapEntry* GetReportPrintOptions(); + static const SvXMLEnumMapEntry* GetForceNewPageOptions(); + static const SvXMLEnumMapEntry* GetKeepTogetherOptions(); + static const SvXMLEnumMapEntry* GetImagePositionOptions(); + static const SvXMLEnumMapEntry* GetImageAlignOptions(); + static const SvXMLEnumMapEntry* GetCommandTypeOptions(); + + static const XMLPropertyMapEntry* GetTableStyleProps(); + static const XMLPropertyMapEntry* GetColumnStyleProps(); + + static const XMLPropertyMapEntry* GetRowStyleProps(); + + static com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > GetNumberFormatsSupplier(const com::sun::star::uno::Reference< com::sun::star::report::XReportDefinition>& _xReportDefinition); + + static void copyStyleElements(const ::rtl::OUString& _sStyleName,const SvXMLStylesContext* _pAutoStyles,const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet>& _xProp); + static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet> createBorderPropertySet(); + }; +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- +#endif // RPT_XMLHELPER_HXX + diff --git a/reportdesign/source/filter/xml/xmlImage.cxx b/reportdesign/source/filter/xml/xmlImage.cxx new file mode 100644 index 000000000000..9f68a974eaf0 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlImage.cxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlImage.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLIMAGE_HXX +#include "xmlImage.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCOMPONENT_HXX +#include "xmlComponent.hxx" +#endif +#ifndef RPT_XMLREPORTELEMENT_HXX +#include "xmlReportElement.hxx" +#endif +#ifndef RPT_XMLCONTROLPROPERTY_HXX +#include "xmlControlProperty.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; +DBG_NAME( rpt_OXMLImage ) + +OXMLImage::OXMLImage( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & _xAttrList + ,const Reference< XImageControl > & _xComponent + ,OXMLTable* _pContainer) : + OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer) +{ + DBG_CTOR( rpt_OXMLImage,NULL); + + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); + const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap(); + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_IMAGE_DATA: + _xComponent->setImageURL(rImport.GetAbsoluteReference( sValue )); + break; + case XML_TOK_PRESERVE_IRI: + _xComponent->setPreserveIRI(s_sTRUE == sValue); + break; + case XML_TOK_SCALE: + _xComponent->setScaleImage(s_sTRUE == sValue); + break; + case XML_TOK_DATA_FORMULA: + { + sal_Int32 nLen = sValue.getLength(); + if ( nLen ) + { + sValue = sValue.copy(5,nLen-6); + _xComponent->setDataField(sValue); + } + } + break; + default: + break; + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the image props"); + } +} +// ----------------------------------------------------------------------------- + +OXMLImage::~OXMLImage() +{ + + DBG_DTOR( rpt_OXMLImage,NULL); +} +// ----------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlImage.hxx b/reportdesign/source/filter/xml/xmlImage.hxx new file mode 100644 index 000000000000..2a5fc0e6eb4f --- /dev/null +++ b/reportdesign/source/filter/xml/xmlImage.hxx @@ -0,0 +1,65 @@ +#ifndef RPT_XMLIMAGE_HXX +#define RPT_XMLIMAGE_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlImage.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#include "xmlReportElementBase.hxx" +#endif +#ifndef _COM_SUN_STAR_REPORT_XImageControl_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLImage : public OXMLReportElementBase + { + OXMLImage(const OXMLImage&); + void operator =(const OXMLImage&); + public: + + OXMLImage( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XImageControl >& _xComponent + ,OXMLTable* _pContainer); + virtual ~OXMLImage(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLIMAGE_HXX diff --git a/reportdesign/source/filter/xml/xmlMasterFields.cxx b/reportdesign/source/filter/xml/xmlMasterFields.cxx new file mode 100644 index 000000000000..b5f87575f317 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlMasterFields.cxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlMasterFields.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLMASTERFIELDS_HXX +#include "xmlMasterFields.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLSUBDOCUMENT_HXX +#include "xmlSubDocument.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; +DBG_NAME( rpt_OXMLMasterFields ) + +OXMLMasterFields::OXMLMasterFields( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & _xAttrList + ,OXMLSubDocument* _pSubDocument + ) : + SvXMLImportContext( rImport, nPrfx, rLName) +,m_pSubDocument(_pSubDocument) +{ + DBG_CTOR( rpt_OXMLMasterFields,NULL); + + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetSubDocumentElemTokenMap(); + + ::rtl::OUString sMasterField,sDetailField; + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_MASTER: + sMasterField = sValue; + break; + case XML_TOK_SUB_DETAIL: + sDetailField = sValue; + break; + default: + break; + } + } + if ( !sDetailField.getLength() ) + sDetailField = sMasterField; + m_pSubDocument->addFieldPair(::std::pair< ::rtl::OUString,::rtl::OUString >(sMasterField,sDetailField)); +} +// ----------------------------------------------------------------------------- + +OXMLMasterFields::~OXMLMasterFields() +{ + DBG_DTOR( rpt_OXMLMasterFields,NULL); +} + +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLMasterFields::CreateChildContext( + sal_uInt16 _nPrefix, + const OUString& _rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + const SvXMLTokenMap& rTokenMap = static_cast(GetImport()).GetSubDocumentElemTokenMap(); + + switch( rTokenMap.Get( _nPrefix, _rLocalName ) ) + { + case XML_TOK_MASTER_DETAIL_FIELD: + { + GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLMasterFields(static_cast(GetImport()), _nPrefix, _rLocalName,xAttrList ,m_pSubDocument); + } + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName ); + + return pContext; +} + +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlMasterFields.hxx b/reportdesign/source/filter/xml/xmlMasterFields.hxx new file mode 100644 index 000000000000..a2f2dae27267 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlMasterFields.hxx @@ -0,0 +1,67 @@ +#ifndef RPT_XMLMASTERFIELDS_HXX +#define RPT_XMLMASTERFIELDS_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlMasterFields.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +namespace rptxml +{ + class ORptFilter; + class OXMLSubDocument; + class OXMLMasterFields : public SvXMLImportContext + { + OXMLSubDocument* m_pSubDocument; + OXMLMasterFields(const OXMLMasterFields&); + void operator =(const OXMLMasterFields&); + public: + + OXMLMasterFields( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,OXMLSubDocument* _pSubDocument); + virtual ~OXMLMasterFields(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLMasterFields_HXX diff --git a/reportdesign/source/filter/xml/xmlPropertyHandler.cxx b/reportdesign/source/filter/xml/xmlPropertyHandler.cxx new file mode 100644 index 000000000000..dcf8e6e8cbd0 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlPropertyHandler.cxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlPropertyHandler.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#include "xmlPropertyHandler.hxx" +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif + +//-------------------------------------------------------------------------- +namespace rptxml +{ +//-------------------------------------------------------------------------- + using namespace ::com::sun::star; + using namespace xmloff; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::uno; +DBG_NAME( rpt_OXMLRptPropHdlFactory ) + +OXMLRptPropHdlFactory::OXMLRptPropHdlFactory() +{ + DBG_CTOR( rpt_OXMLRptPropHdlFactory,NULL); + +} +// ----------------------------------------------------------------------------- +OXMLRptPropHdlFactory::~OXMLRptPropHdlFactory() +{ + + DBG_DTOR( rpt_OXMLRptPropHdlFactory,NULL); +} +// ----------------------------------------------------------------------------- +}// rptxml +// ----------------------------------------------------------------------------- + diff --git a/reportdesign/source/filter/xml/xmlPropertyHandler.hxx b/reportdesign/source/filter/xml/xmlPropertyHandler.hxx new file mode 100644 index 000000000000..4629327a2980 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlPropertyHandler.hxx @@ -0,0 +1,62 @@ +#ifndef RPT_XMLPROPHANDLER_HXX +#define RPT_XMLPROPHANDLER_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlPropertyHandler.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX +#include +#endif +#ifndef _XMLOFF_CONTEXTID_HXX_ +#include +#endif +#ifndef _XMLOFF_PROPERTYHANDLERFACTORY_HXX +#include +#endif + +namespace rptxml +{ + class OXMLRptPropHdlFactory : public XMLPropertyHandlerFactory + { + private: + OXMLRptPropHdlFactory(const OXMLRptPropHdlFactory&); + void operator =(const OXMLRptPropHdlFactory&); + public: + OXMLRptPropHdlFactory(); + virtual ~OXMLRptPropHdlFactory(); + }; +// ----------------------------------------------------------------------------- +}// rptxml +// ----------------------------------------------------------------------------- +#endif //RPT_XMLPROPHANDLER_HXX + diff --git a/reportdesign/source/filter/xml/xmlReport.cxx b/reportdesign/source/filter/xml/xmlReport.cxx new file mode 100644 index 000000000000..339d00dd9414 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlReport.cxx @@ -0,0 +1,254 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlReport.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLREPORT_HXX +#include "xmlReport.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_XMLGROUP_HXX +#include "xmlGroup.hxx" +#endif +#ifndef RPT_XMLSECTION_HXX +#include "xmlSection.hxx" +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLFUNCTION_HXX +#include "xmlFunction.hxx" +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include +#endif + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace uno; + using namespace xml::sax; + + Sequence< ::rtl::OUString> lcl_getColumnNames(const ::rtl::OUString& _sValue) + { + String sColumns = _sValue; + Sequence< ::rtl::OUString> aSeq(sColumns.GetTokenCount(',')); + ::rtl::OUString* pIter = aSeq.getArray(); + ::rtl::OUString* pEnd = pIter + aSeq.getLength(); + for(;pIter != pEnd;++pIter) + *pIter = sColumns.GetToken(','); + return aSeq; + } +DBG_NAME( rpt_OXMLReport ) + +OXMLReport::OXMLReport( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & _xAttrList + ,const uno::Reference< report::XReportDefinition >& _xComponent + ,OXMLTable* _pContainer) : + OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer) + ,m_xComponent(_xComponent) +{ + DBG_CTOR( rpt_OXMLReport,NULL); + OSL_ENSURE(m_xComponent.is(),"No Report definition!"); + + impl_initRuntimeDefaults(); + + const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = m_rImport.GetReportElemTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_COMMAND_TYPE: + { + sal_uInt16 nRet = static_cast(sdb::CommandType::COMMAND); + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetCommandTypeOptions(); + SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap ); + m_xComponent->setCommandType(nRet); + } + break; + case XML_TOK_COMMAND: + m_xComponent->setCommand(sValue); + break; + case XML_TOK_FILTER: + m_xComponent->setFilter(sValue); + break; + case XML_TOK_CAPTION: + m_xComponent->setCaption(sValue); + break; + case XML_TOK_ESCAPE_PROCESSING: + m_xComponent->setEscapeProcessing(sValue == s_sTRUE); + break; + case XML_TOK_REPORT_MIMETYPE: + m_xComponent->setMimeType(sValue); + break; + default: + break; + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the report definition props"); + } +} +// ----------------------------------------------------------------------------- + +OXMLReport::~OXMLReport() +{ + DBG_DTOR( rpt_OXMLReport,NULL); +} + +// ----------------------------------------------------------------------------- + +void OXMLReport::impl_initRuntimeDefaults() const +{ + OSL_PRECOND( m_xComponent.is(), "OXMLReport::impl_initRuntimeDefaults: no component!" ); + if ( !m_xComponent.is() ) + return; + + try + { + m_xComponent->setCommandType( sdb::CommandType::COMMAND ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// ----------------------------------------------------------------------------- + +SvXMLImportContext* OXMLReport::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList); + if ( pContext ) + return pContext; + const SvXMLTokenMap& rTokenMap = m_rImport.GetReportElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_REPORT_FUNCTION: + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLFunction( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get()); + } + break; + case XML_TOK_REPORT_HEADER: + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + m_xComponent->setReportHeaderOn(sal_True); + pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getReportHeader()); + } + break; + case XML_TOK_PAGE_HEADER: + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + m_xComponent->setPageHeaderOn(sal_True); + pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getPageHeader()); + } + break; + case XML_TOK_GROUP: + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLGroup( m_rImport, nPrefix, rLocalName,xAttrList); + break; + case XML_TOK_DETAIL: + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getDetail()); + } + break; + case XML_TOK_PAGE_FOOTER: + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + m_xComponent->setPageFooterOn(sal_True); + pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getPageFooter(),sal_False); + } + break; + case XML_TOK_REPORT_FOOTER: + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + m_xComponent->setReportFooterOn(sal_True); + pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getReportFooter()); + } + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + + return pContext; +} +// ----------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlReport.hxx b/reportdesign/source/filter/xml/xmlReport.hxx new file mode 100644 index 000000000000..64c3b88dc73b --- /dev/null +++ b/reportdesign/source/filter/xml/xmlReport.hxx @@ -0,0 +1,73 @@ +#ifndef RPT_XMLREPORT_HXX +#define RPT_XMLREPORT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlReport.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#include "xmlReportElementBase.hxx" +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLReport : public OXMLReportElementBase + { + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xComponent; + OXMLReport(const OXMLReport&); + void operator =(const OXMLReport&); + public: + + OXMLReport( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xComponent + ,OXMLTable* _pContainer); + virtual ~OXMLReport(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + private: + /** initializes our object's properties whose runtime (API) default is different from the file + format default. + */ + void impl_initRuntimeDefaults() const; + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLREPORT_HXX diff --git a/reportdesign/source/filter/xml/xmlReportElement.cxx b/reportdesign/source/filter/xml/xmlReportElement.cxx new file mode 100644 index 000000000000..9aa731c16e9a --- /dev/null +++ b/reportdesign/source/filter/xml/xmlReportElement.cxx @@ -0,0 +1,173 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlReportElement.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLREPORTELEMENT_HXX +#include "xmlReportElement.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCOMPONENT_HXX +#include "xmlComponent.hxx" +#endif +#ifndef RPT_XMLCONDPRTEXPR_HXX +#include "xmlCondPrtExpr.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef RPT_XMLFORMATCONDITION_HXX +#include "xmlFormatCondition.hxx" +#endif + + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace report; + using namespace uno; + using namespace xml::sax; +DBG_NAME( rpt_OXMLReportElement ) + +OXMLReportElement::OXMLReportElement( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & _xAttrList + ,const Reference< XReportControlModel > & _xComponent) : + SvXMLImportContext( rImport, nPrfx, rLName ) +,m_xComponent(_xComponent) +{ + DBG_CTOR( rpt_OXMLReportElement,NULL); + + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetReportElementElemTokenMap(); + + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_PRINT_ONLY_WHEN_GROUP_CHANGE: + m_xComponent->setPrintWhenGroupChange(s_sTRUE == sValue); + break; + case XML_TOK_PRINT_REPEATED_VALUES: + m_xComponent->setPrintRepeatedValues(sValue == s_sTRUE ? sal_True : sal_False); + break; + default: + break; + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the report definition props"); + } +} +// ----------------------------------------------------------------------------- + +OXMLReportElement::~OXMLReportElement() +{ + + DBG_DTOR( rpt_OXMLReportElement,NULL); +} +// ----------------------------------------------------------------------------- + +SvXMLImportContext* OXMLReportElement::CreateChildContext( + sal_uInt16 _nPrefix, + const OUString& _rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetReportElementElemTokenMap(); + + switch( rTokenMap.Get( _nPrefix, _rLocalName ) ) + { + case XML_TOK_COMPONENT: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLComponent( rImport, _nPrefix, _rLocalName,xAttrList,m_xComponent.get()); + break; + case XML_TOK_REP_CONDITIONAL_PRINT_EXPRESSION: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLCondPrtExpr( rImport, _nPrefix, _rLocalName,xAttrList,m_xComponent.get()); + break; + case XML_TOK_FORMATCONDITION: + { + uno::Reference< report::XFormatCondition > xNewCond = m_xComponent->createFormatCondition(); + m_xComponent->insertByIndex(m_xComponent->getCount(),uno::makeAny(xNewCond)); + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLFormatCondition( rImport, _nPrefix, _rLocalName,xAttrList,xNewCond); + } + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName ); + + + return pContext; +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLReportElement::GetOwnImport() +{ + return static_cast(GetImport()); +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlReportElement.hxx b/reportdesign/source/filter/xml/xmlReportElement.hxx new file mode 100644 index 000000000000..108babbdc4be --- /dev/null +++ b/reportdesign/source/filter/xml/xmlReportElement.hxx @@ -0,0 +1,70 @@ +#ifndef RPT_XMLREPORTELEMENT_HXX +#define RPT_XMLREPORTELEMENT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlReportElement.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCONTROLMODEL_HPP_ +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLReportElement : public SvXMLImportContext + { + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel > m_xComponent; + ORptFilter& GetOwnImport(); + OXMLReportElement(const OXMLReportElement&); + void operator =(const OXMLReportElement&); + public: + + OXMLReportElement( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel >& _xComponent); + virtual ~OXMLReportElement(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLREPORTELEMENT_HXX diff --git a/reportdesign/source/filter/xml/xmlReportElementBase.cxx b/reportdesign/source/filter/xml/xmlReportElementBase.cxx new file mode 100644 index 000000000000..d53e2b6ad47d --- /dev/null +++ b/reportdesign/source/filter/xml/xmlReportElementBase.cxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlReportElementBase.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#include "xmlReportElementBase.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef RPT_XMLCONTROLPROPERTY_HXX +#include "xmlControlProperty.hxx" +#endif +#ifndef RPT_XMLREPORTELEMENT_HXX +#include "xmlReportElement.hxx" +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLTABLE_HXX +#include "xmlTable.hxx" +#endif + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; + +OXMLReportElementBase::OXMLReportElementBase( ORptFilter& rImport + ,sal_uInt16 nPrfx + , const OUString& rLName + ,const Reference< XReportComponent > & _xComponent + ,OXMLTable* _pContainer) : + SvXMLImportContext( rImport, nPrfx, rLName ) +,m_rImport(rImport) +,m_pContainer(_pContainer) +,m_xComponent(_xComponent) +{ +} +// ----------------------------------------------------------------------------- + +OXMLReportElementBase::~OXMLReportElementBase() +{ +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLReportElementBase::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList); + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return pContext; +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLReportElementBase::_CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_REPORT_ELEMENT: + { + uno::Reference xReportModel(m_xComponent,uno::UNO_QUERY); + if ( xReportModel.is() ) + { + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLReportElement( m_rImport, nPrefix, rLocalName,xAttrList,xReportModel); + } + } + break; + case XML_TOK_PROPERTIES: + m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLControlProperty( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get()); + break; + default: + break; + } + + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLReportElementBase::EndElement() +{ + try + { + if ( m_pContainer && m_pContainer->getSection().is() && m_xComponent.is() ) + m_pContainer->getSection()->add(m_xComponent.get()); + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception caught while inserting a new control!"); + } +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlReportElementBase.hxx b/reportdesign/source/filter/xml/xmlReportElementBase.hxx new file mode 100644 index 000000000000..db4ff4677491 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlReportElementBase.hxx @@ -0,0 +1,81 @@ +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#define RPT_XMLREPORTELEMENTBASE_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlReportElementBase.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTCOMPONENT_HPP_ +#include +#endif + + +namespace rptxml +{ + class ORptFilter; + class OXMLTable; + class OXMLReportElementBase : public SvXMLImportContext + { + OXMLReportElementBase(const OXMLReportElementBase&); + void operator =(const OXMLReportElementBase&); + protected: + ORptFilter& m_rImport; + OXMLTable* m_pContainer; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > m_xComponent; + + virtual SvXMLImportContext* _CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + public: + + OXMLReportElementBase( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent >& _xComponent + ,OXMLTable* _pContainer); + virtual ~OXMLReportElementBase(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLREPORTELEMENTBASE_HXX diff --git a/reportdesign/source/filter/xml/xmlRow.cxx b/reportdesign/source/filter/xml/xmlRow.cxx new file mode 100644 index 000000000000..638e48fb9c2c --- /dev/null +++ b/reportdesign/source/filter/xml/xmlRow.cxx @@ -0,0 +1,213 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlRow.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLCOLUMN_HXX +#include "xmlColumn.hxx" +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef _COMPHELPER_NAMECONTAINER_HXX_ +#include +#endif +#ifndef _COMPHELPER_GENERICPROPERTYSET_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_ +#include +#endif +#ifndef RPT_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif + +namespace rptxml +{ + using namespace ::comphelper; + using namespace ::rtl; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::xml::sax; + +DBG_NAME( rpt_OXMLRow ) + +OXMLRow::OXMLRow( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,OXMLTable* _pContainer) : + SvXMLImportContext( rImport, nPrfx, _sLocalName ) + ,m_pContainer(_pContainer) +{ + DBG_CTOR( rpt_OXMLRow,NULL); + + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap(); + + const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; + for(sal_Int16 i = 0; i < nLength; ++i) + { + OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_COLUMN_STYLE_NAME: + m_sStyleName = sValue; + break; + case XML_TOK_NUMBER_ROWS_SPANNED: + m_pContainer->setRowSpanned(sValue.toInt32()); + break; + default: + break; + } + } + +} +// ----------------------------------------------------------------------------- + +OXMLRow::~OXMLRow() +{ + DBG_DTOR( rpt_OXMLRow,NULL); +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLRow::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetControlPropertyElemTokenMap(); + + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_COLUMN: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRow( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + case XML_TOK_ROW: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRow( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + case XML_TOK_CELL: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRow( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + case XML_TOK_COV_CELL: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRow( rImport, nPrefix, rLocalName,xAttrList,m_pContainer); + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLRow::EndElement() +{ + if ( m_sStyleName.getLength() ) + { + const SvXMLStylesContext* pAutoStyles = GetImport().GetAutoStyles(); + if ( pAutoStyles ) + { + PropertySetInfo* pInfo = new PropertySetInfo(); + static PropertyMapEntry pMap[] = + { + {PROPERTY_WIDTH, static_cast(PROPERTY_WIDTH.length), 0, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0}, + {PROPERTY_HEIGHT, static_cast(PROPERTY_HEIGHT.length), 0, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0}, + { NULL, 0, 0, NULL, 0, 0 } + }; + pInfo->add(pMap); + Reference xProp = GenericPropertySet_CreateInstance(pInfo); + XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_COLUMN,m_sStyleName)); + if ( pAutoStyle ) + { + pAutoStyle->FillPropertySet(xProp); + sal_Int32 nWidth = 0; + xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth; + m_pContainer->addWidth(nWidth); + } + else + { + pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_ROW,m_sStyleName)); + if ( pAutoStyle ) + { + pAutoStyle->FillPropertySet(xProp); + sal_Int32 nHeight = 0; + xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight; + m_pContainer->addHeight(nHeight); + } + } + } + } +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLRow::GetOwnImport() +{ + return static_cast(GetImport()); +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlRow.hxx b/reportdesign/source/filter/xml/xmlRow.hxx new file mode 100644 index 000000000000..35f9a11c05e3 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlRow.hxx @@ -0,0 +1,73 @@ +#ifndef RPT_XMLCOLUMN_HXX +#define RPT_XMLCOLUMN_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlRow.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif + +namespace rptxml +{ + class ORptFilter; + class OXMLTable; + class OXMLRowColumn : public SvXMLImportContext + { + ::rtl::OUString m_sStyleName; + OXMLTable* m_pContainer; + + ORptFilter& GetOwnImport(); + OXMLRowColumn(const OXMLRowColumn&); + void operator =(const OXMLRowColumn&); + public: + + OXMLRowColumn( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,OXMLTable* _pContainer = NULL); + virtual ~OXMLRowColumn(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLCOLUMN_HXX diff --git a/reportdesign/source/filter/xml/xmlSection.cxx b/reportdesign/source/filter/xml/xmlSection.cxx new file mode 100644 index 000000000000..81350d805884 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlSection.cxx @@ -0,0 +1,193 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlSection.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLSECTION_HXX +#include "xmlSection.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCOLUMN_HXX +#include "xmlColumn.hxx" +#endif +#ifndef RPT_XMLCondPrtExpr_HXX +#include "xmlCondPrtExpr.hxx" +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_REPORTPRINTOPTION_HPP_ +#include +#endif +#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef RPT_XMLTABLE_HXX +#include "xmlTable.hxx" +#endif + + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::xmloff; + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; + + sal_uInt16 lcl_getReportPrintOption(const ::rtl::OUString& _sValue) + { + sal_uInt16 nRet = report::ReportPrintOption::ALL_PAGES; + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); + SvXMLUnitConverter::convertEnum( nRet, _sValue, aXML_EnumMap ); + return nRet; + } + + +DBG_NAME( rpt_OXMLSection ) + +OXMLSection::OXMLSection( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& _sLocalName, + const uno::Reference< xml::sax::XAttributeList > & _xAttrList + ,const uno::Reference< report::XSection >& _xSection + ,sal_Bool _bPageHeader) +:SvXMLImportContext( rImport, nPrfx, _sLocalName ) +,m_xSection(_xSection) +,m_bPageHeader(_bPageHeader) +{ + DBG_CTOR( rpt_OXMLSection,NULL); + + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetSectionElemTokenMap(); + + const sal_Int16 nLength = (m_xSection.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + rtl::OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + + case XML_TOK_PAGE_PRINT_OPTION: + if ( _bPageHeader ) + m_xSection->getReportDefinition()->setPageHeaderOption(lcl_getReportPrintOption(sValue)); + else + m_xSection->getReportDefinition()->setPageFooterOption(lcl_getReportPrintOption(sValue)); + break; + + default: + OSL_ENSURE(0,"OXMLSection: Unknown attribute!"); + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the section props"); + } +} +// ----------------------------------------------------------------------------- +OXMLSection::~OXMLSection() +{ + DBG_DTOR( rpt_OXMLSection,NULL); +} +// ----------------------------------------------------------------------------- + +SvXMLImportContext* OXMLSection::CreateChildContext( + sal_uInt16 _nPrefix, + const OUString& _rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetSectionElemTokenMap(); + uno::Reference xFactor = rImport.getServiceFactory(); + + switch( rTokenMap.Get( _nPrefix, _rLocalName ) ) + { + case XML_TOK_CONDITIONAL_PRINT_EXPRESSION: + pContext = new OXMLCondPrtExpr( rImport, _nPrefix, _rLocalName,xAttrList,m_xSection.get()); + break; + case XML_TOK_TABLE: + pContext = new OXMLTable( rImport, _nPrefix, _rLocalName,xAttrList,m_xSection); + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( rImport, _nPrefix, _rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLSection::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlSection.hxx b/reportdesign/source/filter/xml/xmlSection.hxx new file mode 100644 index 000000000000..8efe91e4f577 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlSection.hxx @@ -0,0 +1,76 @@ +#ifndef RPT_XMLSECTION_HXX +#define RPT_XMLSECTION_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlSection.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XSECTION_HPP_ +#include +#endif +#include + +namespace rptxml +{ + class ORptFilter; + class OXMLSection : public SvXMLImportContext + { + private: + ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > m_xSection; + sal_Bool m_bPageHeader; + ORptFilter& GetOwnImport(); + + OXMLSection(const OXMLSection&); + void operator =(const OXMLSection&); + public: + + OXMLSection( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection + ,sal_Bool _bPageHeader = sal_True); + virtual ~OXMLSection(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLSECTION_HXX diff --git a/reportdesign/source/filter/xml/xmlStyleImport.cxx b/reportdesign/source/filter/xml/xmlStyleImport.cxx new file mode 100644 index 000000000000..f82f2aafc533 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlStyleImport.cxx @@ -0,0 +1,503 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlStyleImport.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_XMLIMPPR_HXX +#include +#endif +#include +#ifndef _XMLOFF_FAMILIES_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLNUMFI_HXX +#include +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _COM_SUN_STAR_STYLE_XSTYLEFAMILIESSUPPLIER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_ +#include +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLPROPERTYSETCONTEXT_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#include +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + +#define XML_LINE_LEFT 0 +#define XML_LINE_RIGHT 1 +#define XML_LINE_TOP 2 +#define XML_LINE_BOTTOM 3 + +namespace rptxml +{ + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::style; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace xmloff::token; + +// ----------------------------------------------------------------------------- + +class OSpecialHanldeXMLImportPropertyMapper : public SvXMLImportPropertyMapper +{ +public: + OSpecialHanldeXMLImportPropertyMapper(const UniReference< XMLPropertySetMapper >& rMapper,SvXMLImport& _rImport) : SvXMLImportPropertyMapper(rMapper ,_rImport) + { + } + /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */ + virtual sal_Bool handleSpecialItem( + XMLPropertyState& /*rProperty*/, + ::std::vector< XMLPropertyState >& /*rProperties*/, + const ::rtl::OUString& /*rValue*/, + const SvXMLUnitConverter& /*rUnitConverter*/, + const SvXMLNamespaceMap& /*rNamespaceMap*/ ) const + { + // nothing to do here + return sal_True; + } +}; + +TYPEINIT1( OControlStyleContext, XMLPropStyleContext ); +TYPEINIT1( OReportStylesContext, SvXMLStylesContext ); +DBG_NAME( rpt_OControlStyleContext ) + +OControlStyleContext::OControlStyleContext( ORptFilter& rImport, + sal_uInt16 nPrfx, const OUString& rLName, + const Reference< XAttributeList > & xAttrList, + SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle ) : + XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ), + sNumberFormat(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormat"))), + pStyles(&rStyles), + m_nNumberFormat(-1), + m_rImport(rImport), + bConditionalFormatCreated(sal_False), + bParentSet(sal_False) +{ + DBG_CTOR( rpt_OControlStyleContext,NULL); + +} +// ----------------------------------------------------------------------------- + +OControlStyleContext::~OControlStyleContext() +{ + + DBG_DTOR( rpt_OControlStyleContext,NULL); +} +// ----------------------------------------------------------------------------- + +void OControlStyleContext::FillPropertySet(const Reference< XPropertySet > & rPropSet ) +{ + if ( !IsDefaultStyle() ) + { + if ( GetFamily() == XML_STYLE_FAMILY_TABLE_CELL ) + { + if ((m_nNumberFormat == -1) && m_sDataStyleName.getLength()) + { + SvXMLNumFormatContext* pStyle = PTR_CAST(SvXMLNumFormatContext,pStyles->FindStyleChildContext( + XML_STYLE_FAMILY_DATA_STYLE, m_sDataStyleName, sal_True)); + if ( !pStyle ) + { + OReportStylesContext* pMyStyles = PTR_CAST(OReportStylesContext,GetOwnImport().GetAutoStyles()); + if ( pMyStyles ) + pStyle = PTR_CAST(SvXMLNumFormatContext,pMyStyles-> + FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, m_sDataStyleName, sal_True)); + else + DBG_ERROR("not possible to get style"); + } + if ( pStyle ) + { + m_nNumberFormat = pStyle->GetKey(); + AddProperty(CTF_RPT_NUMBERFORMAT, uno::makeAny(m_nNumberFormat)); + } + } + } + } + XMLPropStyleContext::FillPropertySet(rPropSet); +} +// ----------------------------------------------------------------------------- +void OControlStyleContext::SetDefaults() +{ +} +// ----------------------------------------------------------------------------- + +void OControlStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue) +{ + sal_Int32 nIndex(static_cast(pStyles)->GetIndex(nContextID)); + DBG_ASSERT(nIndex != -1, "Property not found in Map"); + XMLPropertyState aPropState(nIndex, rValue); + GetProperties().push_back(aPropState); // has to be insertes in a sort order later +} +// ----------------------------------------------------------------------------- +void OControlStyleContext::SetAttribute( sal_uInt16 nPrefixKey, + const OUString& rLocalName, + const OUString& rValue ) +{ + // TODO: use a map here + if( IsXMLToken(rLocalName, XML_DATA_STYLE_NAME ) ) + m_sDataStyleName = rValue; + else if ( IsXMLToken(rLocalName, XML_MASTER_PAGE_NAME ) ) + sPageStyle = rValue; + else + XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); +} +// ----------------------------------------------------------------------------- +ORptFilter& OControlStyleContext::GetOwnImport() const +{ + return m_rImport; +} +// ----------------------------------------------------------------------------- +DBG_NAME( rpt_OReportStylesContext ) + +OReportStylesContext::OReportStylesContext( ORptFilter& rImport, + sal_uInt16 nPrfx , + const OUString& rLName , + const Reference< XAttributeList > & xAttrList, + const sal_Bool bTempAutoStyles ) : + SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ), + m_sTableStyleFamilyName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ))), + m_sColumnStyleFamilyName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ))), + m_sRowStyleFamilyName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME ))), + m_sCellStyleFamilyName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME ))), + m_rImport(rImport), + m_nNumberFormatIndex(-1), + bAutoStyles(bTempAutoStyles) +{ + DBG_CTOR( rpt_OReportStylesContext,NULL); + +} +// ----------------------------------------------------------------------------- + +OReportStylesContext::~OReportStylesContext() +{ + + DBG_DTOR( rpt_OReportStylesContext,NULL); +} +// ----------------------------------------------------------------------------- + +void OReportStylesContext::EndElement() +{ + SvXMLStylesContext::EndElement(); + if (bAutoStyles) + GetImport().GetTextImport()->SetAutoStyles( this ); + else + GetImport().GetStyles()->CopyStylesToDoc(sal_True); +} +// ----------------------------------------------------------------------------- + +UniReference < SvXMLImportPropertyMapper > + OReportStylesContext::GetImportPropertyMapper( + sal_uInt16 nFamily ) const +{ + UniReference < SvXMLImportPropertyMapper > xMapper(SvXMLStylesContext::GetImportPropertyMapper(nFamily)); + + if (!xMapper.is()) + { + ORptFilter& rImport = GetOwnImport(); + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_CELL: + { + if( !m_xCellImpPropMapper.is() ) + { + m_xCellImpPropMapper = + new XMLTextImportPropertyMapper/*OSpecialHanldeXMLImportPropertyMapper*/( rImport.GetCellStylesPropertySetMapper(), m_rImport , const_cast(m_rImport.GetFontDecls())); + + m_xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(m_rImport, const_cast(m_rImport.GetFontDecls()))); + } + xMapper = m_xCellImpPropMapper; + } + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + { + if( !m_xColumnImpPropMapper.is() ) + m_xColumnImpPropMapper = + new SvXMLImportPropertyMapper( rImport.GetColumnStylesPropertySetMapper(), m_rImport ); + + xMapper = m_xColumnImpPropMapper; + } + break; + case XML_STYLE_FAMILY_TABLE_ROW: + { + if( !m_xRowImpPropMapper.is() ) + m_xRowImpPropMapper =new OSpecialHanldeXMLImportPropertyMapper( rImport.GetRowStylesPropertySetMapper(), m_rImport ); + xMapper = m_xRowImpPropMapper; + } + break; + case XML_STYLE_FAMILY_TABLE_TABLE: + { + if( !m_xTableImpPropMapper.is() ) + { + UniReference < XMLPropertyHandlerFactory> xFac = new ::xmloff::OControlPropertyHandlerFactory(); + m_xTableImpPropMapper = new SvXMLImportPropertyMapper( new XMLPropertySetMapper(OXMLHelper::GetTableStyleProps(), xFac), m_rImport ); + //m_xTableImpPropMapper = new SvXMLImportPropertyMapper( rImport.GetTableStylesPropertySetMapper(), m_rImport ); + } + xMapper = m_xTableImpPropMapper; + } + break; + default: + break; + } + } + + return xMapper; +} +// ----------------------------------------------------------------------------- +SvXMLStyleContext *OReportStylesContext::CreateDefaultStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLStyleContext *pStyle = 0; + + switch( nFamily ) + { + case XML_STYLE_FAMILY_SD_GRAPHICS_ID: + // There are no writer specific defaults for graphic styles! + pStyle = new XMLGraphicsDefaultStyle( GetImport(), nPrefix, + rLocalName, xAttrList, *this ); + break; + default: + pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily, + nPrefix, + rLocalName, + xAttrList ); + break; + } + return pStyle; +} +// ---------------------------------------------------------------------------- +SvXMLStyleContext *OReportStylesContext::CreateStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLStyleContext *pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily, nPrefix, + rLocalName, + xAttrList ); + if (!pStyle) + { + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + case XML_STYLE_FAMILY_TABLE_COLUMN: + case XML_STYLE_FAMILY_TABLE_ROW: + case XML_STYLE_FAMILY_TABLE_CELL: + pStyle = new OControlStyleContext( GetOwnImport(), nPrefix, rLocalName, + xAttrList, *this, nFamily ); + break; + default: + OSL_ENSURE(0,"OReportStylesContext::CreateStyleStyleChildContext: Unknown style family. PLease check."); + break; + } + } + + return pStyle; +} +// ----------------------------------------------------------------------------- +Reference < XNameContainer > + OReportStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const +{ + Reference < XNameContainer > xStyles(SvXMLStylesContext::GetStylesContainer(nFamily)); + if (!xStyles.is()) + { + OUString sName; + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + { + if( m_xTableStyles.is() ) + xStyles.set(m_xTableStyles); + else + sName = + OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TableStyles" ) )); + } + break; + case XML_STYLE_FAMILY_TABLE_CELL: + { + if( m_xCellStyles.is() ) + xStyles.set(m_xCellStyles); + else + sName = + OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) )); + } + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + { + if( m_xColumnStyles.is() ) + xStyles.set(m_xColumnStyles); + else + sName = + OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnStyles" ) )); + } + break; + case XML_STYLE_FAMILY_TABLE_ROW: + { + if( m_xRowStyles.is() ) + xStyles.set(m_xRowStyles); + else + sName = + OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowStyles" ) )); + } + break; + case XML_STYLE_FAMILY_SD_GRAPHICS_ID: + xStyles = ((SvXMLImport *)&GetImport())->GetTextImport()->GetFrameStyles(); + break; + default: + OSL_ENSURE(0,"OReportStylesContext::CreateStyleStyleChildContext: Unknown style family. PLease check."); + break; + } + if( !xStyles.is() && sName.getLength() && GetOwnImport().GetModel().is() ) + { + Reference< XStyleFamiliesSupplier > xFamiliesSupp( + GetOwnImport().GetModel(), UNO_QUERY ); + if (xFamiliesSupp.is()) + { + Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies()); + + xStyles.set(xFamilies->getByName( sName ), uno::UNO_QUERY); + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + m_xTableStyles.set(xStyles); + break; + case XML_STYLE_FAMILY_TABLE_CELL: + m_xCellStyles.set(xStyles); + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + m_xColumnStyles.set(xStyles); + break; + case XML_STYLE_FAMILY_TABLE_ROW: + m_xRowStyles.set(xStyles); + break; + default: + break; + } + } + } + } + + return xStyles; +} +// ----------------------------------------------------------------------------- + +OUString OReportStylesContext::GetServiceName( sal_uInt16 nFamily ) const +{ + rtl::OUString sServiceName = SvXMLStylesContext::GetServiceName(nFamily); + if (!sServiceName.getLength()) + { + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + sServiceName = m_sTableStyleFamilyName; + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + sServiceName = m_sColumnStyleFamilyName; + break; + case XML_STYLE_FAMILY_TABLE_ROW: + sServiceName = m_sRowStyleFamilyName; + break; + case XML_STYLE_FAMILY_TABLE_CELL: + sServiceName = m_sCellStyleFamilyName; + break; + default: + break; + } + } + return sServiceName; +} +// ----------------------------------------------------------------------------- + +sal_Int32 OReportStylesContext::GetIndex(const sal_Int16 nContextID) +{ + if ( nContextID == CTF_RPT_NUMBERFORMAT ) + { + if (m_nNumberFormatIndex == -1) + m_nNumberFormatIndex = + GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID); + return m_nNumberFormatIndex; + } + return -1; +} +// ----------------------------------------------------------------------------- +ORptFilter& OReportStylesContext::GetOwnImport() const +{ + return m_rImport; +} +// ----------------------------------------------------------------------------- +sal_uInt16 OReportStylesContext::GetFamily( const ::rtl::OUString& rFamily ) const +{ + sal_uInt16 nFamily = SvXMLStylesContext::GetFamily(rFamily); + return nFamily; +} +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlStyleImport.hxx b/reportdesign/source/filter/xml/xmlStyleImport.hxx new file mode 100644 index 000000000000..55ee77e4d267 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlStyleImport.hxx @@ -0,0 +1,190 @@ +#ifndef RPT_XMLSTYLEIMPORT_HXX +#define RPT_XMLSTYLEIMPORT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlStyleImport.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + + +#ifndef _RTL_USTRING_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLIMP_HXX +#include +#endif +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX +#include +#endif +#ifndef _XMLOFF_PRSTYLEI_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLIMPPR_HXX +#include +#endif +#ifndef _XMLTEXTMASTERPAGECONTEXT_HXX +#include +#endif +#ifndef _XMLTEXTMASTERSTYLESCONTEXT_HXX +#include +#endif +#ifndef _XMLOFF_CONTEXTID_HXX_ +#include +#endif +#ifndef _XMLOFF_FORMS_CONTROLPROPERTYHDL_HXX_ +#include +#endif +#include + +namespace rptxml +{ + class ORptFilter; + + class OControlStyleContext : public XMLPropStyleContext + { + ::rtl::OUString m_sDataStyleName; + ::rtl::OUString sPageStyle; + const rtl::OUString sNumberFormat; + SvXMLStylesContext* pStyles; + // std::vector aMaps; + com::sun::star::uno::Any aConditionalFormat; + sal_Int32 m_nNumberFormat; + ORptFilter& m_rImport; + sal_Bool bConditionalFormatCreated : 1; + sal_Bool bParentSet : 1; + + ORptFilter& GetOwnImport() const; + + OControlStyleContext(const OControlStyleContext&); + void operator =(const OControlStyleContext&); + protected: + + virtual void SetAttribute( sal_uInt16 nPrefixKey, + const ::rtl::OUString& rLocalName, + const ::rtl::OUString& rValue ); + + public: + + TYPEINFO(); + + OControlStyleContext( ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle = sal_False ); + + virtual ~OControlStyleContext(); + + + virtual void FillPropertySet(const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropSet ); + + virtual void SetDefaults(); + + void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue); + + sal_Int32 GetNumberFormat() { return m_nNumberFormat; } + }; + + class OReportStylesContext : public SvXMLStylesContext + { + const ::rtl::OUString m_sTableStyleFamilyName; + const ::rtl::OUString m_sColumnStyleFamilyName; + const ::rtl::OUString m_sRowStyleFamilyName; + const ::rtl::OUString m_sCellStyleFamilyName; + ORptFilter& m_rImport; + sal_Int32 m_nNumberFormatIndex; + sal_Int32 nMasterPageNameIndex; + sal_Bool bAutoStyles : 1; + + //mutable UniReference < SvXMLImportPropertyMapper > m_xControlImpPropMapper; + mutable UniReference < SvXMLImportPropertyMapper > m_xCellImpPropMapper; + mutable UniReference < SvXMLImportPropertyMapper > m_xColumnImpPropMapper; + mutable UniReference < SvXMLImportPropertyMapper > m_xRowImpPropMapper; + mutable UniReference < SvXMLImportPropertyMapper > m_xTableImpPropMapper; + + mutable ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > m_xCellStyles; + mutable ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > m_xColumnStyles; + mutable ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > m_xRowStyles; + mutable ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > m_xTableStyles; + + ORptFilter& GetOwnImport() const; + + OReportStylesContext(const OReportStylesContext&); + void operator =(const OReportStylesContext&); + protected: + + // Create a style context. + virtual SvXMLStyleContext *CreateStyleStyleChildContext( + sal_uInt16 nFamily, + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + public: + + TYPEINFO(); + + OReportStylesContext( ORptFilter& rImport, sal_uInt16 nPrfx , + const ::rtl::OUString& rLName , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, + const sal_Bool bAutoStyles ); + virtual ~OReportStylesContext(); + + virtual void EndElement(); + + virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper( + sal_uInt16 nFamily ) const; + virtual ::com::sun::star::uno::Reference < + ::com::sun::star::container::XNameContainer > + GetStylesContainer( sal_uInt16 nFamily ) const; + virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const; + virtual sal_uInt16 GetFamily( const ::rtl::OUString& rFamily ) const; + + sal_Int32 GetIndex(const sal_Int16 nContextID); + }; +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- +#endif // RPT_XMLSTYLEIMPORT_HXX diff --git a/reportdesign/source/filter/xml/xmlSubDocument.cxx b/reportdesign/source/filter/xml/xmlSubDocument.cxx new file mode 100644 index 000000000000..bd3789e786c9 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlSubDocument.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlSubDocument.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLSUBDOCUMENT_HXX +#include "xmlSubDocument.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLMASTERFIELDS_HXX +#include "xmlMasterFields.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif + + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::com::sun::star; + using namespace ::com::sun::star::report; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::xml::sax; +DBG_NAME( rpt_OXMLSubDocument ) + +OXMLSubDocument::OXMLSubDocument( ORptFilter& rImport, + sal_uInt16 nPrfx + ,const OUString& rLName + ,const Reference< XReportDefinition > & _xComponent + ,OXMLTable* _pContainer) : + OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer) +,m_xComponent(_xComponent) +{ + DBG_CTOR( rpt_OXMLSubDocument,NULL); + OSL_ENSURE(m_xComponent.is(),"Component is NULL!"); +} +// ----------------------------------------------------------------------------- + +OXMLSubDocument::~OXMLSubDocument() +{ + DBG_DTOR( rpt_OXMLSubDocument,NULL); +} + +// ----------------------------------------------------------------------------- +SvXMLImportContext* OXMLSubDocument::CreateChildContext( + sal_uInt16 _nPrefix, + const OUString& _rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = OXMLReportElementBase::CreateChildContext(_nPrefix,_rLocalName,xAttrList); + if ( pContext ) + return pContext; + const SvXMLTokenMap& rTokenMap = static_cast(GetImport()).GetSubDocumentElemTokenMap(); + + switch( rTokenMap.Get( _nPrefix, _rLocalName ) ) + { + case XML_TOK_MASTER_DETAIL_FIELDS: + { + GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLMasterFields(static_cast(GetImport()), _nPrefix, _rLocalName,xAttrList ,this); + } + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +void OXMLSubDocument::EndElement() +{ + if ( !m_aMasterFields.empty() ) + m_xComponent->setMasterFields(Sequence< ::rtl::OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size())); + if ( !m_aDetailFields.empty() ) + m_xComponent->setDetailFields(Sequence< ::rtl::OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size())); +} +// ----------------------------------------------------------------------------- +void OXMLSubDocument::addFieldPair(const ::std::pair< ::rtl::OUString,::rtl::OUString >& _aPair) +{ + m_aMasterFields.push_back(_aPair.first); + m_aDetailFields.push_back(_aPair.second); +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlSubDocument.hxx b/reportdesign/source/filter/xml/xmlSubDocument.hxx new file mode 100644 index 000000000000..be1ed9387515 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlSubDocument.hxx @@ -0,0 +1,77 @@ +#ifndef RPT_XMLSUBDOCUMENT_HXX +#define RPT_XMLSUBDOCUMENT_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlSubDocument.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef RPT_XMLREPORTELEMENTBASE_HXX +#include "xmlReportElementBase.hxx" +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTDEFINITION_HPP_ +#include +#endif +#include + +namespace rptxml +{ + class ORptFilter; + class OXMLSubDocument : public OXMLReportElementBase + { + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xComponent; + ::std::vector< ::rtl::OUString> m_aMasterFields; + ::std::vector< ::rtl::OUString> m_aDetailFields; + OXMLSubDocument(const OXMLSubDocument&); + void operator =(const OXMLSubDocument&); + public: + + OXMLSubDocument( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xComponent + ,OXMLTable* _pContainer); + virtual ~OXMLSubDocument(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); + + void addFieldPair(const ::std::pair< ::rtl::OUString,::rtl::OUString >& _aPair); + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLSubDocument_HXX diff --git a/reportdesign/source/filter/xml/xmlTable.cxx b/reportdesign/source/filter/xml/xmlTable.cxx new file mode 100644 index 000000000000..48269d7a6f27 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlTable.cxx @@ -0,0 +1,341 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlTable.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef RPT_XMLTABLE_HXX +#include "xmlTable.hxx" +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef _REPORT_RPTUIDEF_HXX +#include "RptDef.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLCOLUMN_HXX +#include "xmlColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_REPORT_FORCENEWPAGE_HPP_ +#include +#endif +#ifndef RPT_XMLCONDPRTEXPR_HXX +#include "xmlCondPrtExpr.hxx" +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#include "xmlstrings.hrc" +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include +#endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#include +#include + +namespace rptxml +{ + using namespace ::rtl; + using namespace ::xmloff; + using namespace ::com::sun::star; + using ::com::sun::star::uno::Reference; + using namespace ::com::sun::star::xml::sax; + using ::com::sun::star::xml::sax::XAttributeList; + + sal_uInt16 lcl_getForceNewPageOption(const ::rtl::OUString& _sValue) + { + sal_uInt16 nRet = report::ForceNewPage::NONE; + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetForceNewPageOptions(); + SvXMLUnitConverter::convertEnum( nRet,_sValue,aXML_EnumMap ); + return nRet; + } +DBG_NAME( rpt_OXMLTable ) + +OXMLTable::OXMLTable( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const OUString& _sLocalName + ,const Reference< XAttributeList > & _xAttrList + ,const uno::Reference< report::XSection >& _xSection + ) +:SvXMLImportContext( rImport, nPrfx, _sLocalName ) +,m_xSection(_xSection) +,m_nColSpan(1) +,m_nRowSpan(0) +,m_nRowIndex(0) +,m_nColumnIndex(0) +{ + DBG_CTOR( rpt_OXMLTable,NULL); + OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); + const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); + const SvXMLTokenMap& rTokenMap = rImport.GetSectionElemTokenMap(); + + const sal_Int16 nLength = (m_xSection.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; + static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); + try + { + for(sal_Int16 i = 0; i < nLength; ++i) + { + rtl::OUString sLocalName; + const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); + rtl::OUString sValue = _xAttrList->getValueByIndex( i ); + + switch( rTokenMap.Get( nPrefix, sLocalName ) ) + { + case XML_TOK_VISIBLE: + m_xSection->setVisible(sValue == s_sTRUE); + break; + case XML_TOK_FORCE_NEW_PAGE: + m_xSection->setForceNewPage(lcl_getForceNewPageOption(sValue)); + break; + case XML_TOK_FORCE_NEW_COLUMN: + m_xSection->setNewRowOrCol(lcl_getForceNewPageOption(sValue)); + break; + case XML_TOK_KEEP_TOGETHER: + m_xSection->setKeepTogether(sValue == s_sTRUE); + break; + case XML_TOK_REPEAT_SECTION: + m_xSection->setRepeatSection(sValue == s_sTRUE ); + break; + case XML_TOK_SECTION_NAME: + m_xSection->setName(sValue); + break; + case XML_TOK_SECT_STYLE_NAME: + m_sStyleName = sValue; + break; + default: + break; + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched while filling the section props"); + } +} +// ----------------------------------------------------------------------------- +OXMLTable::~OXMLTable() +{ + DBG_DTOR( rpt_OXMLTable,NULL); +} +// ----------------------------------------------------------------------------- + +SvXMLImportContext* OXMLTable::CreateChildContext( + sal_uInt16 _nPrefix, + const OUString& _rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + ORptFilter& rImport = GetOwnImport(); + const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap(); + Reference xFactor = rImport.getServiceFactory(); + + switch( rTokenMap.Get( _nPrefix, _rLocalName ) ) + { + case XML_TOK_TABLE_COLUMNS: + case XML_TOK_TABLE_ROWS: + pContext = new OXMLRowColumn( rImport, _nPrefix, _rLocalName,xAttrList ,this); + break; + case XML_TOK_ROW: + incrementRowIndex(); + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRowColumn( rImport, _nPrefix, _rLocalName,xAttrList,this); + break; + case XML_TOK_COLUMN: + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new OXMLRowColumn( rImport, _nPrefix, _rLocalName,xAttrList,this); + break; + default: + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( rImport, _nPrefix, _rLocalName ); + + return pContext; +} +// ----------------------------------------------------------------------------- +ORptFilter& OXMLTable::GetOwnImport() +{ + return static_cast(GetImport()); +} +// ----------------------------------------------------------------------------- +void OXMLTable::EndElement() +{ + try + { + if ( m_xSection.is() ) + { + if ( m_sStyleName.getLength() ) + { + const SvXMLStylesContext* pAutoStyles = GetImport().GetAutoStyles(); + if ( pAutoStyles ) + { + XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_TABLE,m_sStyleName)); + if ( pAutoStyle ) + { + pAutoStyle->FillPropertySet(m_xSection.get()); + } + } + } // if ( m_sStyleName.getLength() ) + // set height + ::std::vector::iterator aIter = m_aHeight.begin(); + ::std::vector::iterator aEnd = m_aHeight.end(); + sal_Int32 nHeight = 0; + for (; aIter != aEnd; ++aIter) + nHeight += *aIter; + m_xSection->setHeight( nHeight ); + // set positions, widths, and heights + sal_Int32 nLeftMargin = rptui::getStyleProperty(m_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN); + sal_Int32 nPosY = 0; + ::std::vector< ::std::vector >::iterator aRowIter = m_aGrid.begin(); + ::std::vector< ::std::vector >::iterator aRowEnd = m_aGrid.end(); + for (sal_Int32 i = 0; aRowIter != aRowEnd; ++aRowIter,++i) + { + sal_Int32 nPosX = nLeftMargin; + ::std::vector::iterator aColIter = (*aRowIter).begin(); + ::std::vector::iterator aColEnd = (*aRowIter).end(); + for (sal_Int32 j = 0; aColIter != aColEnd; ++aColIter,++j) + { + TCell& rCell = *aColIter; + if ( rCell.xElement.is()) + { + uno::Reference xShape(rCell.xElement,uno::UNO_QUERY); + if ( xShape.is() ) + { + xShape->setPositionX(xShape->getPositionX() + nLeftMargin); + } + else + { + sal_Int32 nWidth = rCell.nWidth; + sal_Int32 nColSpan = rCell.nColSpan; + if ( nColSpan > 1 ) + { + ::std::vector::iterator aWidthIter = aColIter + 1; + while ( nColSpan > 1 ) + { + nWidth += (aWidthIter++)->nWidth; + --nColSpan; + } + } + nHeight = rCell.nHeight; + sal_Int32 nRowSpan = rCell.nRowSpan; + if ( nRowSpan > 1 ) + { + ::std::vector< ::std::vector >::iterator aHeightIter = aRowIter + 1; + while( nRowSpan > 1) + { + nHeight += (*aHeightIter)[j].nHeight; + ++aHeightIter; + --nRowSpan; + } + } + Reference xFixedLine(rCell.xElement,uno::UNO_QUERY); + if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical + { + OSL_ENSURE(static_cast(j+1) < m_aWidth.size(),"Illegal pos of col iter. There should be an empty cell for the next line part."); + nWidth += m_aWidth[j+1]; + + } + try + { + rCell.xElement->setSize(awt::Size(nWidth,nHeight)); + rCell.xElement->setPosition(awt::Point(nPosX,nPosY)); + } + catch(beans::PropertyVetoException) + { + OSL_ENSURE(0,"Could set the correct positions!"); + } + } + } + nPosX += m_aWidth[j]; + } + nPosY += m_aHeight[i]; + } + } // if ( m_xComponent.is() ) + } + catch(Exception&) + { + OSL_ENSURE(0,"OXMLTable::EndElement -> exception catched"); + } +} +// ----------------------------------------------------------------------------- +void OXMLTable::addCell(const Reference& _xElement) +{ + OSL_ENSURE(static_cast(m_nRowIndex-1 ) < m_aGrid.size() && static_cast( m_nColumnIndex-1 ) < m_aGrid[m_nRowIndex-1].size(), + "OXMLTable::addCell: Invalid column and row index"); + if ( static_cast(m_nRowIndex-1 ) < m_aGrid.size() && static_cast( m_nColumnIndex-1 ) < m_aGrid[m_nRowIndex-1].size() ) + { + TCell& rCell = m_aGrid[m_nRowIndex-1][m_nColumnIndex-1]; + rCell.xElement = _xElement; + rCell.nWidth = m_aWidth[m_nColumnIndex-1]; + rCell.nHeight = m_aHeight[m_nRowIndex-1]; + rCell.nColSpan = m_nColSpan; + rCell.nRowSpan = m_nRowSpan; + } + + m_nColSpan = m_nRowSpan = 1; +} +// ----------------------------------------------------------------------------- +void OXMLTable::incrementRowIndex() +{ + ++m_nRowIndex; + m_nColumnIndex = 0; + m_aGrid.push_back(::std::vector(m_aWidth.size())); +} +//---------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlTable.hxx b/reportdesign/source/filter/xml/xmlTable.hxx new file mode 100644 index 000000000000..bda48ceefe4f --- /dev/null +++ b/reportdesign/source/filter/xml/xmlTable.hxx @@ -0,0 +1,111 @@ +#ifndef RPT_XMLTABLE_HXX +#define RPT_XMLTABLE_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlTable.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XSECTION_HPP_ +#include +#endif +#include + +namespace rptxml +{ + class ORptFilter; + class OXMLTable : public SvXMLImportContext + { + public: + struct TCell + { + sal_Int32 nWidth; + sal_Int32 nHeight; + sal_Int32 nColSpan; + sal_Int32 nRowSpan; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> xElement; + TCell() : nWidth(0),nHeight(0),nColSpan(1),nRowSpan(1){} + }; + private: + ::std::vector< ::std::vector > m_aGrid; + ::std::vector m_aHeight; + ::std::vector m_aWidth; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > m_xSection; + ::rtl::OUString m_sStyleName; + sal_Int32 m_nColSpan; + sal_Int32 m_nRowSpan; + sal_Int32 m_nRowIndex; + sal_Int32 m_nColumnIndex; + ORptFilter& GetOwnImport(); + + OXMLTable(const OXMLTable&); + void operator =(const OXMLTable&); + public: + + OXMLTable( ORptFilter& rImport + ,sal_uInt16 nPrfx + ,const ::rtl::OUString& rLName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection + ); + virtual ~OXMLTable(); + + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + + virtual void EndElement(); + + inline void addHeight(sal_Int32 _nHeight) { m_aHeight.push_back( _nHeight ); } + inline void addWidth(sal_Int32 _nWidth) { m_aWidth.push_back( _nWidth ); } + + inline void setColumnSpanned(sal_Int32 _nColSpan) { m_nColSpan = _nColSpan; } + inline void setRowSpanned( sal_Int32 _nRowSpan) { m_nRowSpan = _nRowSpan; } + + void incrementRowIndex(); + inline void incrementColumnIndex() { ++m_nColumnIndex; } + + inline sal_Int32 getRowIndex() const { return m_nRowIndex; } + inline sal_Int32 getColumnIndex() const { return m_nColumnIndex; } + + void addCell(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xElement); + + inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getSection() const { return m_xSection; } + }; +// ----------------------------------------------------------------------------- +} // namespace rptxml +// ----------------------------------------------------------------------------- + +#endif // RPT_XMLTABLE_HXX diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx new file mode 100644 index 000000000000..df9197e60a2a --- /dev/null +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -0,0 +1,1068 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlfilter.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPIOEXCEPTION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_ +#include +#endif +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef RPT_XMLGROUP_HXX +#include "xmlGroup.hxx" +#endif +#ifndef RPT_XMLREPORT_HXX +#include "xmlReport.hxx" +#endif +#ifndef RPT_XMLHELPER_HXX +#include "xmlHelper.hxx" +#endif +#ifndef _SV_SVAPP_HXX +#include +#endif +#ifndef _SV_WINDOW_HXX +#include +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include +#endif +#ifndef _XMLOFF_XMLNMSPE_HXX +#include +#endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include +#endif +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include +#endif +#ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX_ +#include +#endif +#ifndef _RTL_LOGFILE_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_ +#include +#endif +#ifndef _XMLOFF_PROGRESSBARHELPER_HXX +#include +#endif +#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium +#include +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ +#include +#endif +#ifndef _URLOBJ_HXX //autogen wg. INetURLObject +#include +#endif +#ifndef _XMLOFF_DOCUMENTSETTINGSCONTEXT_HXX +#include +#endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_ +#include +#endif +#ifndef _SV_SVAPP_HXX //autogen +#include +#endif +#ifndef _VOS_MUTEX_HXX_ +#include +#endif +#ifndef _SFXECODE_HXX +#include +#endif +#ifndef RPT_XMLENUMS_HXX +#include "xmlEnums.hxx" +#endif +#ifndef RPT_XMLSTYLEIMPORT_HXX +#include "xmlStyleImport.hxx" +#endif +#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC +#include "xmlstrings.hrc" +#endif +#ifndef RPT_XMLPROPHANDLER_HXX +#include "xmlPropertyHandler.hxx" +#endif +#include +#ifndef REPORTDESIGN_API_REPORTDEFINITION_HXX +#include "ReportDefinition.hxx" +#endif + + + +//-------------------------------------------------------------------------- +namespace rptxml +{ +using namespace ::com::sun::star::uno; +using ::com::sun::star::uno::Reference; +using namespace ::com::sun::star; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::report; +using namespace ::com::sun::star::xml::sax; +using namespace xmloff; + sal_Char __READONLY_DATA sXML_np__rpt[] = "_report"; + sal_Char __READONLY_DATA sXML_np___rpt[] = "__report"; + + using namespace ::com::sun::star::util; + +class RptMLMasterStylesContext_Impl : public XMLTextMasterStylesContext +{ + ORptFilter& m_rImport; + RptMLMasterStylesContext_Impl(const RptMLMasterStylesContext_Impl&); + void operator =(const RptMLMasterStylesContext_Impl&); +public: + + TYPEINFO(); + + RptMLMasterStylesContext_Impl( + ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName , + const uno::Reference< xml::sax::XAttributeList > & xAttrList ); + virtual ~RptMLMasterStylesContext_Impl(); + virtual void EndElement(); +}; + +TYPEINIT1( RptMLMasterStylesContext_Impl, XMLTextMasterStylesContext ); + +RptMLMasterStylesContext_Impl::RptMLMasterStylesContext_Impl( + ORptFilter& rImport, sal_uInt16 nPrfx, + const ::rtl::OUString& rLName , + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) : + XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList ) + ,m_rImport(rImport) +{ +} + +RptMLMasterStylesContext_Impl::~RptMLMasterStylesContext_Impl() +{ +} + +void RptMLMasterStylesContext_Impl::EndElement() +{ + FinishStyles( sal_True ); + m_rImport.FinishStyles(); +} + /// read a component (file + filter version) +sal_Int32 ReadThroughComponent( + const uno::Reference& xInputStream, + const uno::Reference& xModelComponent, + const sal_Char* /*pStreamName*/, + const uno::Reference & rFactory, + const uno::Reference< XDocumentHandler >& _xFilter, + sal_Bool /*bEncrypted*/ ) +{ + DBG_ASSERT(xInputStream.is(), "input stream missing"); + DBG_ASSERT(xModelComponent.is(), "document missing"); + DBG_ASSERT(rFactory.is(), "factory missing"); + + RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "rptxml", "oj", "ReadThroughComponent" ); + + // prepare ParserInputSrouce + InputSource aParserInput; + aParserInput.aInputStream = xInputStream; + + // get parser + uno::Reference< XParser > xParser( + rFactory->createInstance( + ::rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ), + UNO_QUERY ); + DBG_ASSERT( xParser.is(), "Can't create parser" ); + if( !xParser.is() ) + return 1; + RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" ); + + // get filter + DBG_ASSERT( _xFilter.is(), "Can't instantiate filter component." ); + if( !_xFilter.is() ) + return 1; + + // connect parser and filter + xParser->setDocumentHandler( _xFilter ); + + // connect model and filter + uno::Reference < XImporter > xImporter( _xFilter, UNO_QUERY ); + xImporter->setTargetDocument( xModelComponent ); + + +#ifdef TIMELOG + // if we do profiling, we want to know the stream + RTL_LOGFILE_TRACE_AUTHOR1( "rptxml", "oj", + "ReadThroughComponent : parsing \"%s\"", pStreamName ); +#endif + + // finally, parser the stream + try + { + xParser->parseStream( aParserInput ); + } + catch( SAXParseException& + +#if OSL_DEBUG_LEVEL > 1 +r +#endif +) + { +#if OSL_DEBUG_LEVEL > 1 + ByteString aError( "SAX parse exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + aError += ByteString::CreateFromInt32( r.LineNumber ); + aError += ','; + aError += ByteString::CreateFromInt32( r.ColumnNumber ); + + DBG_ERROR( aError.GetBuffer() ); +#endif + return 1; + } + catch( SAXException& ) + { + return 1; + } + catch( packages::zip::ZipIOException& ) + { + return ERRCODE_IO_BROKENPACKAGE; + } + catch( IOException& ) + { + return 1; + } + catch( Exception& ) + { + return 1; + } + + // success! + return 0; +} + +/// read a component (storage version) +sal_Int32 ReadThroughComponent( + uno::Reference< embed::XStorage > xStorage, + const uno::Reference& xModelComponent, + const sal_Char* pStreamName, + const sal_Char* pCompatibilityStreamName, + const uno::Reference & rFactory, + const ::rtl::OUString& _sFilterName) +{ + DBG_ASSERT( xStorage.is(), "Need storage!"); + DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!"); + + if ( xStorage.is() ) + { + uno::Reference< io::XStream > xDocStream; + sal_Bool bEncrypted = sal_False; + + try + { + // open stream (and set parser input) + ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii(pStreamName); + if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) + { + // stream name not found! Then try the compatibility name. + // if no stream can be opened, return immediatly with OK signal + + // do we even have an alternative name? + if ( NULL == pCompatibilityStreamName ) + return 0; + + // if so, does the stream exist? + sStreamName = ::rtl::OUString::createFromAscii(pCompatibilityStreamName); + if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) + return 0; + } + + // get input stream + xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); + + uno::Reference< beans::XPropertySet > xProps( xDocStream, uno::UNO_QUERY_THROW ); + uno::Any aAny = xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) ); + aAny >>= bEncrypted; + } + catch( packages::WrongPasswordException& ) + { + return ERRCODE_SFX_WRONGPASSWORD; + } + catch ( uno::Exception& ) + { + return 1; // TODO/LATER: error handling + } + + + uno::Reference< XDocumentHandler > xFilter(rFactory->createInstance(_sFilterName),uno::UNO_QUERY); + uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); + // read from the stream + return ReadThroughComponent( xInputStream + ,xModelComponent + ,pStreamName + ,rFactory + ,xFilter + ,bEncrypted ); + } + + // TODO/LATER: better error handling + return 1; +} + +//--------------------------------------------------------------------- +uno::Reference< uno::XInterface > ORptImportHelper::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return static_cast< XServiceInfo* >(new ORptFilter(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),IMPORT_SETTINGS )); +} +//--------------------------------------------------------------------- +::rtl::OUString ORptImportHelper::getImplementationName_Static( ) throw (RuntimeException) +{ + return ::rtl::OUString(SERVICE_SETTINGSIMPORTER); +} +//--------------------------------------------------------------------- +Sequence< ::rtl::OUString > ORptImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = SERVICE_IMPORTFILTER; + return aSupported; +} +//--------------------------------------------------------------------- +Reference< XInterface > ORptContentImportHelper::create(const Reference< XComponentContext > & xContext) +{ + return static_cast< XServiceInfo* >(new ORptFilter(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS | + IMPORT_FONTDECLS )); +} +//--------------------------------------------------------------------- +::rtl::OUString ORptContentImportHelper::getImplementationName_Static( ) throw (RuntimeException) +{ + return ::rtl::OUString(SERVICE_CONTENTIMPORTER); +} +//--------------------------------------------------------------------- +Sequence< ::rtl::OUString > ORptContentImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = SERVICE_IMPORTFILTER; + return aSupported; +} + +//--------------------------------------------------------------------- +Reference< XInterface > ORptStylesImportHelper::create(Reference< XComponentContext > const & xContext) +{ + return static_cast< XServiceInfo* >(new ORptFilter(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY), + IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES | + IMPORT_FONTDECLS )); +} +//--------------------------------------------------------------------- +::rtl::OUString ORptStylesImportHelper::getImplementationName_Static( ) throw (RuntimeException) +{ + return ::rtl::OUString(SERVICE_STYLESIMPORTER); +} +//--------------------------------------------------------------------- +Sequence< ::rtl::OUString > ORptStylesImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = SERVICE_IMPORTFILTER; + return aSupported; +} + +// ------------- +// - ORptFilter - +// ------------- + +ORptFilter::ORptFilter( const uno::Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nImportFlags ) + :SvXMLImport(_rxMSF,nImportFlags) +{ + GetMM100UnitConverter().setCoreMeasureUnit(MAP_100TH_MM); + GetMM100UnitConverter().setXMLMeasureUnit(MAP_CM); + GetNamespaceMap().Add( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__rpt) ), + GetXMLToken(XML_N_RPT), + XML_NAMESPACE_REPORT ); + + GetNamespaceMap().Add( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np___rpt) ), + GetXMLToken(XML_N_RPT_OASIS), + XML_NAMESPACE_REPORT ); + + m_xPropHdlFactory = new OXMLRptPropHdlFactory; + m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylePropertyMap(); + m_xColumnStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetColumnStyleProps(), m_xPropHdlFactory); + m_xRowStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetRowStyleProps(), m_xPropHdlFactory); + m_xTableStylesPropertySetMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_DEFAULTS ); +} + +// ----------------------------------------------------------------------------- + +ORptFilter::~ORptFilter() throw() +{ +} +//------------------------------------------------------------------------------ +uno::Reference< XInterface > ORptFilter::create(uno::Reference< XComponentContext > const & xContext) +{ + return *(new ORptFilter(uno::Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))); +} + +// ----------------------------------------------------------------------------- +::rtl::OUString ORptFilter::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OReportFilter")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ORptFilter::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > ORptFilter::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_IMPORTFILTER; + + return aServices; +} + +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL ORptFilter::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL ORptFilter::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL ORptFilter::filter( const Sequence< PropertyValue >& rDescriptor ) + throw (RuntimeException) +{ + Window* pFocusWindow = Application::GetFocusWindow(); + sal_Bool bRet = sal_False; + + if( pFocusWindow ) + pFocusWindow->EnterWait(); + + if ( GetModel().is() ) + bRet = implImport( rDescriptor ); + + if ( pFocusWindow ) + pFocusWindow->LeaveWait(); + + return bRet; +} +// ----------------------------------------------------------------------------- +sal_Bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) + throw (RuntimeException) +{ + ::rtl::OUString sFileName; + uno::Reference< embed::XStorage > xStorage; + uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier; + + const PropertyValue* pIter = rDescriptor.getConstArray(); + const PropertyValue* pEnd = pIter + rDescriptor.getLength(); + for(;pIter != pEnd;++pIter) + { + if( pIter->Name.equalsAscii( "FileName" ) ) + pIter->Value >>= sFileName; + else if( pIter->Name.equalsAscii( "Storage" ) ) + pIter->Value >>= xStorage; + else if( pIter->Name.equalsAscii( "ComponentData" ) ) + { + Sequence< PropertyValue > aComponent; + pIter->Value >>= aComponent; + const PropertyValue* pComponentIter = aComponent.getConstArray(); + const PropertyValue* pComponentEnd = pComponentIter + aComponent.getLength(); + for(;pComponentIter != pComponentEnd;++pComponentIter) + { + if( pComponentIter->Name.equalsAscii( "ActiveConnection" ) ) + { + uno::Reference xCon(pComponentIter->Value,uno::UNO_QUERY); + xNumberFormatsSupplier = ::dbtools::getNumberFormats(xCon); + break; + } + } + } + } + + if ( sFileName.getLength() != 0 ) + { + uno::Reference xCom(GetModel(),UNO_QUERY); + + SfxMediumRef pMedium = new SfxMedium( + sFileName, ( STREAM_READ | STREAM_NOCREATE ), FALSE, 0 ); + + if( pMedium ) + { + try + { + xStorage = pMedium->GetStorage(); + // nError = pMedium->GetError(); + } + catch(const Exception&) + { + } + } // if( pMedium ) + } // if ( bRet = (sFileName.getLength() != 0) ) + sal_Bool bRet = xStorage.is(); + if ( bRet ) + { + m_xReportDefinition.set(GetModel(),UNO_QUERY_THROW); + OSL_ENSURE(m_xReportDefinition.is(),"ReportDefinition is NULL!"); + if ( !m_xReportDefinition.is() ) + return sal_False; + + m_pReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition); + if ( !m_pReportModel ) + return sal_False; + + if ( !xNumberFormatsSupplier.is() ) + xNumberFormatsSupplier = OXMLHelper::GetNumberFormatsSupplier(m_xReportDefinition); + SetNumberFormatsSupplier(xNumberFormatsSupplier); + + + uno::Reference xModel(GetModel(),UNO_QUERY); + sal_Int32 nRet = ReadThroughComponent( xStorage + ,xModel + ,"settings.xml" + ,"Settings.xml" + ,getServiceFactory() + ,SERVICE_SETTINGSIMPORTER + ); + if ( nRet == 0 ) + nRet = ReadThroughComponent( + xStorage, xModel, "styles.xml", "Styles.xml", getServiceFactory(), + SERVICE_STYLESIMPORTER ); + + if ( nRet == 0 ) + nRet = ReadThroughComponent( xStorage + ,xModel + ,"content.xml" + ,"Content.xml" + ,getServiceFactory() + ,SERVICE_CONTENTIMPORTER + ); + + bRet = nRet == 0; + + if ( bRet ) + { + uno::Reference< XModifiable > xModi(GetModel(),UNO_QUERY); + if ( xModi.is() ) + xModi->setModified(sal_False); + } + else + { + switch( nRet ) + { + case ERRCODE_IO_BROKENPACKAGE: + if( xStorage.is() ) + { + // TODO/LATER: no way to transport the error outside from the filter! + break; + } + // fall through intented + default: + { + // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly! But for now this is the only way! + ErrorHandler::HandleError( nRet ); + if( nRet & ERRCODE_WARNING_MASK ) + bRet = sal_True; + } + } + } + } + + return bRet; +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* ORptFilter::CreateContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + const SvXMLTokenMap& rTokenMap = GetDocElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLocalName ) ) + { + case XML_TOK_DOC_SETTINGS: + GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = new XMLDocumentSettingsContext( *this, nPrefix, rLocalName,xAttrList ); + break; + case XML_TOK_DOC_REPORT: + GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + { + const SvXMLStylesContext* pAutoStyles = GetAutoStyles(); + if ( pAutoStyles ) + { + XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_PAGE_MASTER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pm1")))); + if ( pAutoStyle ) + { + pAutoStyle->FillPropertySet(getReportDefinition().get()); + } + } + pContext = new OXMLReport( *this, nPrefix, rLocalName,xAttrList,getReportDefinition(),NULL ); + } + break; + case XML_TOK_DOC_STYLES: + GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = CreateStylesContext( rLocalName, xAttrList, sal_False); + break; + case XML_TOK_DOC_AUTOSTYLES: + GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = CreateStylesContext( rLocalName, xAttrList, sal_True); + break; + case XML_TOK_DOC_FONTDECLS: + GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = CreateFontDeclsContext( rLocalName,xAttrList ); + break; + case XML_TOK_DOC_MASTERSTYLES: + { + SvXMLStylesContext* pStyleContext = new RptMLMasterStylesContext_Impl(*this, nPrefix, rLocalName,xAttrList);//CreateMasterStylesContext( rLocalName,xAttrList ); + pContext = pStyleContext; + SetMasterStyles( pStyleContext ); + } + break; + default: + break; + } + + if ( !pContext ) + pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); + + return pContext; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetDocElemTokenMap() const +{ + if ( !m_pDocElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, + //{ XML_NAMESPACE_OOO, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, + { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, + //{ XML_NAMESPACE_OOO, XML_STYLES, XML_TOK_DOC_STYLES }, + { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, + //{ XML_NAMESPACE_OOO, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, + { XML_NAMESPACE_OFFICE, XML_REPORT, XML_TOK_DOC_REPORT }, + { XML_NAMESPACE_OOO, XML_REPORT, XML_TOK_DOC_REPORT }, + { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS }, + { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES }, + //{ XML_NAMESPACE_OOO, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS }, + XML_TOKEN_MAP_END + }; + m_pDocElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pDocElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetReportElemTokenMap() const +{ + if ( !m_pReportElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_REPORT, XML_REPORT_HEADER, XML_TOK_REPORT_HEADER }, + { XML_NAMESPACE_REPORT, XML_PAGE_HEADER , XML_TOK_PAGE_HEADER }, + { XML_NAMESPACE_REPORT, XML_GROUP, XML_TOK_GROUP }, + { XML_NAMESPACE_REPORT, XML_DETAIL , XML_TOK_DETAIL }, + { XML_NAMESPACE_REPORT, XML_PAGE_FOOTER , XML_TOK_PAGE_FOOTER }, + { XML_NAMESPACE_REPORT, XML_REPORT_FOOTER, XML_TOK_REPORT_FOOTER }, + { XML_NAMESPACE_REPORT, XML_HEADER_ON_NEW_PAGE, XML_TOK_HEADER_ON_NEW_PAGE }, + { XML_NAMESPACE_REPORT, XML_FOOTER_ON_NEW_PAGE, XML_TOK_FOOTER_ON_NEW_PAGE }, + { XML_NAMESPACE_REPORT, XML_COMMAND_TYPE, XML_TOK_COMMAND_TYPE }, + { XML_NAMESPACE_REPORT, XML_COMMAND, XML_TOK_COMMAND }, + { XML_NAMESPACE_REPORT, XML_FILTER, XML_TOK_FILTER }, + { XML_NAMESPACE_REPORT, XML_CAPTION, XML_TOK_CAPTION }, + { XML_NAMESPACE_REPORT, XML_ESCAPE_PROCESSING, XML_TOK_ESCAPE_PROCESSING }, + { XML_NAMESPACE_REPORT, XML_FUNCTION, XML_TOK_REPORT_FUNCTION }, + { XML_NAMESPACE_OFFICE, XML_MIMETYPE, XML_TOK_REPORT_MIMETYPE }, + XML_TOKEN_MAP_END + }; + m_pReportElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pReportElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetSubDocumentElemTokenMap() const +{ + if ( !m_pSubDocumentElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, XML_TOK_MASTER_DETAIL_FIELDS}, + { XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELD, XML_TOK_MASTER_DETAIL_FIELD}, + { XML_NAMESPACE_REPORT, XML_MASTER, XML_TOK_MASTER}, + { XML_NAMESPACE_REPORT, XML_DETAIL, XML_TOK_SUB_DETAIL}, + XML_TOKEN_MAP_END + }; + m_pSubDocumentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pSubDocumentElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetFunctionElemTokenMap() const +{ + if ( !m_pFunctionElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_REPORT, XML_NAME, XML_TOK_FUNCTION_NAME }, + { XML_NAMESPACE_REPORT, XML_FORMULA, XML_TOK_FUNCTION_FORMULA}, + { XML_NAMESPACE_REPORT, XML_PRE_EVALUATED, XML_TOK_PRE_EVALUATED }, + { XML_NAMESPACE_REPORT, XML_INITIAL_FORMULA,XML_TOK_INITIAL_FORMULA }, + { XML_NAMESPACE_REPORT, XML_DEEP_TRAVERSING,XML_TOK_DEEP_TRAVERSING }, + XML_TOKEN_MAP_END + }; + m_pFunctionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pFunctionElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetFormatElemTokenMap() const +{ + if ( !m_pFormatElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_REPORT, XML_ENABLED , XML_TOK_ENABLED }, + { XML_NAMESPACE_REPORT, XML_FORMULA , XML_TOK_FORMULA }, + { XML_NAMESPACE_REPORT, XML_STYLE_NAME , XML_TOK_FORMAT_STYLE_NAME }, + XML_TOKEN_MAP_END + }; + m_pFormatElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pFormatElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetGroupElemTokenMap() const +{ + if ( !m_pGroupElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_REPORT, XML_START_NEW_COLUMN , XML_TOK_START_NEW_COLUMN }, + { XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER , XML_TOK_RESET_PAGE_NUMBER }, + { XML_NAMESPACE_REPORT, XML_PRINT_HEADER_ON_EACH_PAGE , XML_TOK_PRINT_HEADER_ON_EACH_PAGE }, + { XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER , XML_TOK_RESET_PAGE_NUMBER }, + { XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION , XML_TOK_GROUP_EXPRESSION }, + { XML_NAMESPACE_REPORT, XML_GROUP_HEADER , XML_TOK_GROUP_HEADER }, + { XML_NAMESPACE_REPORT, XML_GROUP , XML_TOK_GROUP_GROUP }, + { XML_NAMESPACE_REPORT, XML_DETAIL , XML_TOK_GROUP_DETAIL }, + { XML_NAMESPACE_REPORT, XML_GROUP_FOOTER , XML_TOK_GROUP_FOOTER }, + { XML_NAMESPACE_REPORT, XML_SORT_ASCENDING , XML_TOK_SORT_ASCENDING }, + { XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER , XML_TOK_GROUP_KEEP_TOGETHER }, + { XML_NAMESPACE_REPORT, XML_FUNCTION , XML_TOK_GROUP_FUNCTION }, + //{ XML_NAMESPACE_REPORT, XML_ , XML_TOK_ }, + XML_TOKEN_MAP_END + }; + m_pGroupElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pGroupElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetReportElementElemTokenMap() const +{ + if ( !m_pElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_REPORT, XML_PRINT_REPEATED_VALUES ,XML_TOK_PRINT_REPEATED_VALUES }, + { XML_NAMESPACE_REPORT, XML_PRINT_ONLY_WHEN_GROUP_CHANGE,XML_TOK_PRINT_ONLY_WHEN_GROUP_CHANGE }, + { XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION,XML_TOK_REP_CONDITIONAL_PRINT_EXPRESSION }, + { XML_NAMESPACE_REPORT, XML_REPORT_COMPONENT ,XML_TOK_COMPONENT }, + { XML_NAMESPACE_REPORT, XML_FORMAT_CONDITION ,XML_TOK_FORMATCONDITION }, + XML_TOKEN_MAP_END + }; + m_pElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetControlElemTokenMap() const +{ + if ( !m_pControlElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_FORM, XML_LABEL ,XML_TOK_LABEL }, + { XML_NAMESPACE_FORM, XML_PROPERTIES ,XML_TOK_PROPERTIES }, + { XML_NAMESPACE_FORM, XML_SIZE ,XML_TOK_SIZE }, + { XML_NAMESPACE_FORM, XML_IMAGE_DATA ,XML_TOK_IMAGE_DATA }, + { XML_NAMESPACE_REPORT, XML_SCALE ,XML_TOK_SCALE }, + { XML_NAMESPACE_FORM, XML_IMAGE_POSITION ,XML_TOK_IMAGE_POSITION }, + { XML_NAMESPACE_FORM, XML_IMAGE_ALIGN ,XML_TOK_IMAGE_ALIGN }, + { XML_NAMESPACE_REPORT, XML_REPORT_ELEMENT ,XML_TOK_REPORT_ELEMENT }, + { XML_NAMESPACE_REPORT, XML_FORMULA ,XML_TOK_DATA_FORMULA }, + { XML_NAMESPACE_REPORT, XML_PRESERVE_IRI ,XML_TOK_PRESERVE_IRI }, + { XML_NAMESPACE_REPORT, XML_SELECT_PAGE ,XML_TOK_SELECT_PAGE }, + XML_TOKEN_MAP_END + }; + m_pControlElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pControlElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetControlPropertyElemTokenMap() const +{ + if ( !m_pControlElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_FORM, XML_PROPERTY_NAME ,XML_TOK_PROPERTY_NAME }, + { XML_NAMESPACE_OOO, XML_VALUE_TYPE ,XML_TOK_VALUE_TYPE }, + { XML_NAMESPACE_FORM, XML_LIST_PROPERTY ,XML_TOK_LIST_PROPERTY }, + { XML_NAMESPACE_OOO, XML_VALUE ,XML_TOK_VALUE }, + { XML_NAMESPACE_OOO, XML_CURRENCY ,XML_TOK_CURRENCY }, + { XML_NAMESPACE_OOO, XML_DATE_VALUE ,XML_TOK_DATE_VALUE }, + { XML_NAMESPACE_OOO, XML_TIME_VALUE ,XML_TOK_TIME_VALUE }, + { XML_NAMESPACE_OOO, XML_STRING_VALUE ,XML_TOK_STRING_VALUE }, + { XML_NAMESPACE_OOO, XML_BOOLEAN_VALUE ,XML_TOK_BOOLEAN_VALUE }, + XML_TOKEN_MAP_END + }; + m_pControlElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pControlElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetComponentElemTokenMap() const +{ + if ( !m_pComponentElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_DRAW, XML_NAME , XML_TOK_NAME }, + { XML_NAMESPACE_DRAW, XML_TEXT_STYLE_NAME , XML_TOK_TEXT_STYLE_NAME }, + { XML_NAMESPACE_REPORT, XML_TRANSFORM , XML_TOK_TRANSFORM }, + XML_TOKEN_MAP_END + }; + m_pComponentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pComponentElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetColumnTokenMap() const +{ + if ( !m_pColumnTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_TABLE, XML_NAME , XML_TOK_NAME }, + { XML_NAMESPACE_TABLE, XML_STYLE_NAME , XML_TOK_COLUMN_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN , XML_TOK_COLUMN }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW , XML_TOK_ROW }, + { XML_NAMESPACE_TABLE, XML_TABLE_CELL , XML_TOK_CELL }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS , XML_TOK_TABLE_COLUMNS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROWS , XML_TOK_TABLE_ROWS }, + { XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL , XML_TOK_COV_CELL }, + { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED , XML_TOK_NUMBER_COLUMNS_SPANNED }, + { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED , XML_TOK_NUMBER_ROWS_SPANNED }, + XML_TOKEN_MAP_END + }; + m_pColumnTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pColumnTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetSectionElemTokenMap() const +{ + if ( !m_pSectionElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_TABLE, XML_TABLE , XML_TOK_TABLE }, + { XML_NAMESPACE_TABLE, XML_NAME , XML_TOK_SECTION_NAME }, + { XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, XML_TOK_CONDITIONAL_PRINT_EXPRESSION}, + { XML_NAMESPACE_REPORT, XML_VISIBLE , XML_TOK_VISIBLE }, + { XML_NAMESPACE_REPORT, XML_FORCE_NEW_PAGE , XML_TOK_FORCE_NEW_PAGE }, + { XML_NAMESPACE_REPORT, XML_FORCE_NEW_COLUMN , XML_TOK_FORCE_NEW_COLUMN }, + { XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER , XML_TOK_KEEP_TOGETHER }, + { XML_NAMESPACE_REPORT, XML_REPEAT_SECTION , XML_TOK_REPEAT_SECTION }, + { XML_NAMESPACE_TABLE, XML_STYLE_NAME , XML_TOK_SECT_STYLE_NAME }, + { XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION , XML_TOK_PAGE_PRINT_OPTION }, + + XML_TOKEN_MAP_END + }; + m_pSectionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pSectionElemTokenMap; +} +// ----------------------------------------------------------------------------- +const SvXMLTokenMap& ORptFilter::GetCellElemTokenMap() const +{ + if ( !m_pCellElemTokenMap.get() ) + { + static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= + { + { XML_NAMESPACE_TEXT, XML_P , XML_TOK_P }, + { XML_NAMESPACE_REPORT, XML_FIXED_CONTENT , XML_TOK_FIXED_CONTENT }, + { XML_NAMESPACE_REPORT, XML_FORMATTED_TEXT , XML_TOK_FORMATTED_TEXT }, + { XML_NAMESPACE_REPORT, XML_IMAGE , XML_TOK_IMAGE }, + { XML_NAMESPACE_REPORT, XML_SUB_DOCUMENT , XML_TOK_SUB_DOCUMENT }, + { XML_NAMESPACE_DRAW, XML_CUSTOM_SHAPE , XML_TOK_CUSTOM_SHAPE }, + { XML_NAMESPACE_TEXT, XML_PAGE_NUMBER , XML_TOK_PAGE_NUMBER }, + { XML_NAMESPACE_TEXT, XML_PAGE_COUNT , XML_TOK_PAGE_COUNT }, + { XML_NAMESPACE_TEXT, XML_TAB , XML_TOK_TEXT_TAB_STOP }, + { XML_NAMESPACE_TEXT, XML_LINE_BREAK , XML_TOK_TEXT_LINE_BREAK }, + { XML_NAMESPACE_TEXT, XML_S , XML_TOK_TEXT_S }, + XML_TOKEN_MAP_END + }; + m_pCellElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); + } + return *m_pCellElemTokenMap; +} +// ----------------------------------------------------------------------------- +SvXMLImportContext* ORptFilter::CreateStylesContext(const ::rtl::OUString& rLocalName, + const uno::Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ) +{ + SvXMLImportContext* pContext = bIsAutoStyle ? GetAutoStyles() : GetStyles(); + if ( !pContext ) + { + pContext = new OReportStylesContext(*this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, bIsAutoStyle); + if (bIsAutoStyle) + //xAutoStyles = pContext; + SetAutoStyles((SvXMLStylesContext*)pContext); + else + //xStyles = pContext; + SetStyles((SvXMLStylesContext*)pContext); + } + return pContext; +} +// ----------------------------------------------------------------------------- +SvXMLImport& ORptFilter::getGlobalContext() +{ + return *this; +} +// ----------------------------------------------------------------------------- +void ORptFilter::enterEventContext() +{ +} +// ----------------------------------------------------------------------------- +void ORptFilter::leaveEventContext() +{ +} +// ----------------------------------------------------------------------------- +SvXMLImportContext *ORptFilter::CreateFontDeclsContext( + const ::rtl::OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + XMLFontStylesContext *pFSContext = + new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE, + rLocalName, xAttrList, + gsl_getSystemTextEncoding() ); + SetFontDecls( pFSContext ); + return pFSContext; +} +// ----------------------------------------------------------------------------- +XMLShapeImportHelper* ORptFilter::CreateShapeImport() +{ + return new XMLShapeImportHelper( *this,GetModel() ); +} +// ----------------------------------------------------------------------------- +void ORptFilter::FinishStyles() +{ + if( GetStyles() ) + GetStyles()->FinishStyles( sal_True ); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ORptFilter::convertFormula(const ::rtl::OUString& _sFormula) +{ + //sal_Int32 nLen = _sFormula.getLength(); + //if ( nLen ) + //{ + // const static ::rtl::OUString s_sField(RTL_CONSTASCII_USTRINGPARAM("field:[")); + // sal_Int32 nPos = _sFormula.indexOf(s_sField); + // if ( nPos == -1 ) + // nPos = 4; // "rpt:" + // else + // { + // nPos = s_sField.getLength(); + // --nLen; // eat "]" + // } + // return _sFormula.copy(nPos,nLen-nPos); + //} + return _sFormula; +} +// ----------------------------------------------------------------------------- +void SAL_CALL ORptFilter::startDocument( void ) + throw( xml::sax::SAXException, uno::RuntimeException ) +{ + m_xReportDefinition.set(GetModel(),UNO_QUERY_THROW); + OSL_ENSURE(m_xReportDefinition.is(),"ReportDefinition is NULL!"); + if ( m_xReportDefinition.is() ) + { + m_pReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition); + OSL_ENSURE(m_pReportModel,"Report model is NULL!"); + + uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier = OXMLHelper::GetNumberFormatsSupplier(m_xReportDefinition); + SetNumberFormatsSupplier(xNumberFormatsSupplier); + } +} +// ----------------------------------------------------------------------------- +void ORptFilter::endDocument( void ) + throw( xml::sax::SAXException, uno::RuntimeException ) +{ + DBG_ASSERT( GetModel().is(), "model missing; maybe startDocument wasn't called?" ); + if( !GetModel().is() ) + return; + + // this method will modify the document directly -> lock SolarMutex + vos::OGuard aGuard(Application::GetSolarMutex()); + // Clear the shape import to sort the shapes (and not in the + // destructor that might be called after the import has finished + // for Java filters. + if( HasShapeImport() ) + ClearShapeImport(); + + // delegate to parent: takes care of error handling + SvXMLImport::endDocument(); +} +// ----------------------------------------------------------------------------- +}// rptxml +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/filter/xml/xmlfilter.hxx b/reportdesign/source/filter/xml/xmlfilter.hxx new file mode 100644 index 000000000000..da3cd6b24246 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlfilter.hxx @@ -0,0 +1,277 @@ +#ifndef RPT_XMLFILTER_HXX +#define RPT_XMLFILTER_HXX +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlfilter.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_REPORT_XREPORTDEFINITION_HPP_ +#include +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif +#ifndef _UNOTOOLS_TEMPFILE_HXX +#include +#endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include +#endif +#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX +#include +#endif +#ifndef _XMLOFF_XMLIMP_HXX +#include +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include +#endif +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include +#endif +#include +#include + +#ifndef _XMLOFF_PROPERTYHANDLERFACTORY_HXX +#include +#endif +#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX +#include +#endif + +namespace rptui +{ + class OReportModel; +} +namespace rptxml +{ +using namespace ::xmloff::token; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::report; +using namespace ::com::sun::star::xml::sax; + +// ------------- +// - ORptFilter - +// ------------- +class ORptFilter : public SvXMLImport +{ +public: + DECLARE_STL_USTRINGACCESS_MAP(Sequence,TPropertyNameMap); + +private: + com::sun::star::uno::Any m_aViewSettings; + Reference< XComponent > m_xSrcDoc; + mutable ::std::auto_ptr m_pDocElemTokenMap; + mutable ::std::auto_ptr m_pReportElemTokenMap; + mutable ::std::auto_ptr m_pGroupsElemTokenMap; + mutable ::std::auto_ptr m_pGroupElemTokenMap; + mutable ::std::auto_ptr m_pSectionElemTokenMap; + mutable ::std::auto_ptr m_pComponentElemTokenMap; + mutable ::std::auto_ptr m_pElemTokenMap; + mutable ::std::auto_ptr m_pControlElemTokenMap; + mutable ::std::auto_ptr m_pFunctionElemTokenMap; + mutable ::std::auto_ptr m_pSubDocumentElemTokenMap; + mutable ::std::auto_ptr m_pFormatElemTokenMap; + mutable ::std::auto_ptr m_pColumnTokenMap; + mutable ::std::auto_ptr m_pCellElemTokenMap; + + UniReference < XMLPropertyHandlerFactory > m_xPropHdlFactory; + UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > m_xRowStylesPropertySetMapper; + UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper; + + Reference m_xReportDefinition; + ::boost::shared_ptr m_pReportModel; + sal_Int32 m_nPreviewMode; + + sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException); + + SvXMLImportContext* CreateStylesContext(const ::rtl::OUString& rLocalName, + const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ); + SvXMLImportContext *CreateFontDeclsContext(const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); +protected: + // SvXMLImport + virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + virtual XMLShapeImportHelper* CreateShapeImport(); + + virtual ~ORptFilter() throw(); +public: + + ORptFilter( const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nImportFlags = IMPORT_ALL ); + + // XFilter + virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + + inline Reference< XMultiServiceFactory > getORB() { return SvXMLImport::getServiceFactory(); } + inline Reference getReportDefinition() const { return m_xReportDefinition; } + /** return the SdrModel of the real model + * + * \return + */ + ::boost::shared_ptr getSdrModel() const { return m_pReportModel; } + void FinishStyles(); + + virtual void SAL_CALL startDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL endDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + const SvXMLTokenMap& GetDocElemTokenMap() const; + const SvXMLTokenMap& GetReportElemTokenMap() const; + const SvXMLTokenMap& GetGroupElemTokenMap() const; + const SvXMLTokenMap& GetSectionElemTokenMap() const; + const SvXMLTokenMap& GetComponentElemTokenMap() const; + const SvXMLTokenMap& GetReportElementElemTokenMap() const; + const SvXMLTokenMap& GetControlElemTokenMap() const; + const SvXMLTokenMap& GetControlPropertyElemTokenMap() const; + const SvXMLTokenMap& GetFunctionElemTokenMap() const; + const SvXMLTokenMap& GetFormatElemTokenMap() const; + const SvXMLTokenMap& GetSubDocumentElemTokenMap() const; + const SvXMLTokenMap& GetColumnTokenMap() const; + const SvXMLTokenMap& GetCellElemTokenMap() const; + + inline UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const { return m_xCellStylesPropertySetMapper; } + inline UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const { return m_xColumnStylesPropertySetMapper; } + inline UniReference < XMLPropertySetMapper > GetRowStylesPropertySetMapper() const { return m_xRowStylesPropertySetMapper; } + inline UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const { return m_xTableStylesPropertySetMapper; } + static ::rtl::OUString convertFormula(const ::rtl::OUString& _sFormula); + + virtual SvXMLImport& getGlobalContext(); + + virtual void enterEventContext(); + virtual void leaveEventContext(); +}; + +/** Imports only settings + * \ingroup reportdesign_source_filter_xml + * + */ +class ORptImportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; + +/** Imports only content + * \ingroup reportdesign_source_filter_xml + * + */ +class ORptContentImportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; + +/** Imports only styles + * \ingroup reportdesign_source_filter_xml + * + */ +class ORptStylesImportHelper +{ +public: + static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); +}; + +// ----------------------------------------------------------------------------- +} // rptxml +// ----------------------------------------------------------------------------- +#endif // RPT_XMLFILTER_HXX diff --git a/reportdesign/source/filter/xml/xmlservices.cxx b/reportdesign/source/filter/xml/xmlservices.cxx new file mode 100644 index 000000000000..d429ffcc6c64 --- /dev/null +++ b/reportdesign/source/filter/xml/xmlservices.cxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlservices.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2007-07-09 11:56:18 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif +#ifndef _CPPUHELPER_IMPLEMENATIONENTRY_HXX_ +#include +#endif + +#ifndef RPT_XMLFILTER_HXX +#include "xmlfilter.hxx" +#endif +#ifndef RPT_XMLEXPORT_HXX +#include "xmlExport.hxx" +#endif + +#ifndef RPTXML_DBLOADER2_HXX +#include "dbloader2.hxx" +#endif + + + +/********************************************************************************************/ + +using namespace ::rtl; +using namespace ::rptxml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; +/********************************************************************************************/ +// registry functions +namespace +{ + +cppu::ImplementationEntry entries[] = { + { &ORptFilter::create, &ORptFilter::getImplementationName_Static, &ORptFilter::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptTypeDetection::create, &ORptTypeDetection::getImplementationName_Static, &ORptTypeDetection::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ODBFullExportHelper::create, &ODBFullExportHelper::getImplementationName_Static, &ODBFullExportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptExportHelper::create, &ORptExportHelper::getImplementationName_Static, &ORptExportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptExport::create, &ORptExport::getImplementationName_Static, &ORptExport::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptContentExportHelper::create, &ORptContentExportHelper::getImplementationName_Static, &ORptContentExportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptStylesExportHelper::create, &ORptStylesExportHelper::getImplementationName_Static, &ORptStylesExportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + + { &ORptImportHelper::create, &ORptImportHelper::getImplementationName_Static, &ORptImportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptContentImportHelper::create, &ORptContentImportHelper::getImplementationName_Static, &ORptContentImportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &ORptStylesImportHelper::create, &ORptStylesImportHelper::getImplementationName_Static, &ORptStylesImportHelper::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } +}; +} + +extern "C" void * SAL_CALL component_getFactory( + char const * implName, void * serviceManager, void * registryKey) +{ + return cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} + +extern "C" void SAL_CALL component_getImplementationEnvironment( + char const ** envTypeName, uno_Environment **) +{ + *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +extern "C" sal_Bool SAL_CALL component_writeInfo( + void * serviceManager, void * registryKey) +{ + return cppu::component_writeInfoHelper( + serviceManager, registryKey, entries); +} -- cgit