summaryrefslogtreecommitdiff
path: root/reportdesign/source/filter/xml
diff options
context:
space:
mode:
Diffstat (limited to 'reportdesign/source/filter/xml')
-rw-r--r--reportdesign/source/filter/xml/dbloader2.cxx125
-rw-r--r--reportdesign/source/filter/xml/dbloader2.hxx102
-rw-r--r--reportdesign/source/filter/xml/makefile.mk70
-rw-r--r--reportdesign/source/filter/xml/xmlAutoStyle.cxx99
-rw-r--r--reportdesign/source/filter/xml/xmlAutoStyle.hxx61
-rw-r--r--reportdesign/source/filter/xml/xmlCell.cxx293
-rw-r--r--reportdesign/source/filter/xml/xmlCell.hxx74
-rw-r--r--reportdesign/source/filter/xml/xmlColumn.cxx190
-rw-r--r--reportdesign/source/filter/xml/xmlColumn.hxx64
-rw-r--r--reportdesign/source/filter/xml/xmlComponent.cxx117
-rw-r--r--reportdesign/source/filter/xml/xmlComponent.hxx60
-rw-r--r--reportdesign/source/filter/xml/xmlCondPrtExpr.cxx103
-rw-r--r--reportdesign/source/filter/xml/xmlCondPrtExpr.hxx58
-rw-r--r--reportdesign/source/filter/xml/xmlControlProperty.cxx360
-rw-r--r--reportdesign/source/filter/xml/xmlControlProperty.hxx86
-rw-r--r--reportdesign/source/filter/xml/xmlEnums.hxx179
-rw-r--r--reportdesign/source/filter/xml/xmlExport.cxx1672
-rw-r--r--reportdesign/source/filter/xml/xmlExport.hxx281
-rw-r--r--reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx455
-rw-r--r--reportdesign/source/filter/xml/xmlExportDocumentHandler.hxx105
-rw-r--r--reportdesign/source/filter/xml/xmlFixedContent.cxx241
-rw-r--r--reportdesign/source/filter/xml/xmlFixedContent.hxx71
-rw-r--r--reportdesign/source/filter/xml/xmlFormatCondition.cxx118
-rw-r--r--reportdesign/source/filter/xml/xmlFormatCondition.hxx57
-rw-r--r--reportdesign/source/filter/xml/xmlFormattedField.cxx105
-rw-r--r--reportdesign/source/filter/xml/xmlFormattedField.hxx55
-rw-r--r--reportdesign/source/filter/xml/xmlFunction.cxx141
-rw-r--r--reportdesign/source/filter/xml/xmlFunction.hxx67
-rw-r--r--reportdesign/source/filter/xml/xmlGroup.cxx279
-rw-r--r--reportdesign/source/filter/xml/xmlGroup.hxx66
-rw-r--r--reportdesign/source/filter/xml/xmlHelper.cxx418
-rw-r--r--reportdesign/source/filter/xml/xmlHelper.hxx93
-rw-r--r--reportdesign/source/filter/xml/xmlImage.cxx130
-rw-r--r--reportdesign/source/filter/xml/xmlImage.hxx55
-rw-r--r--reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx397
-rw-r--r--reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx105
-rw-r--r--reportdesign/source/filter/xml/xmlMasterFields.cxx121
-rw-r--r--reportdesign/source/filter/xml/xmlMasterFields.hxx57
-rw-r--r--reportdesign/source/filter/xml/xmlPropertyHandler.cxx57
-rw-r--r--reportdesign/source/filter/xml/xmlPropertyHandler.hxx49
-rw-r--r--reportdesign/source/filter/xml/xmlReport.cxx236
-rw-r--r--reportdesign/source/filter/xml/xmlReport.hxx70
-rw-r--r--reportdesign/source/filter/xml/xmlReportElement.cxx143
-rw-r--r--reportdesign/source/filter/xml/xmlReportElement.hxx58
-rw-r--r--reportdesign/source/filter/xml/xmlReportElementBase.cxx115
-rw-r--r--reportdesign/source/filter/xml/xmlReportElementBase.hxx76
-rw-r--r--reportdesign/source/filter/xml/xmlRow.cxx184
-rw-r--r--reportdesign/source/filter/xml/xmlRow.hxx63
-rw-r--r--reportdesign/source/filter/xml/xmlSection.cxx158
-rw-r--r--reportdesign/source/filter/xml/xmlSection.hxx64
-rw-r--r--reportdesign/source/filter/xml/xmlStyleImport.cxx459
-rw-r--r--reportdesign/source/filter/xml/xmlStyleImport.hxx166
-rw-r--r--reportdesign/source/filter/xml/xmlSubDocument.cxx164
-rw-r--r--reportdesign/source/filter/xml/xmlSubDocument.hxx71
-rw-r--r--reportdesign/source/filter/xml/xmlTable.cxx323
-rw-r--r--reportdesign/source/filter/xml/xmlTable.hxx99
-rw-r--r--reportdesign/source/filter/xml/xmlfilter.cxx1137
-rw-r--r--reportdesign/source/filter/xml/xmlfilter.hxx247
-rw-r--r--reportdesign/source/filter/xml/xmlservices.cxx101
59 files changed, 11170 insertions, 0 deletions
diff --git a/reportdesign/source/filter/xml/dbloader2.cxx b/reportdesign/source/filter/xml/dbloader2.cxx
new file mode 100644
index 000000000000..cd709789ca2c
--- /dev/null
+++ b/reportdesign/source/filter/xml/dbloader2.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "dbloader2.hxx"
+#include <comphelper/sequence.hxx>
+// -------------------------------------------------------------------------
+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<XPropertySet> 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..4df384584eb0
--- /dev/null
+++ b/reportdesign/source/filter/xml/dbloader2.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef RPTXML_DBLOADER2_HXX
+#define RPTXML_DBLOADER2_HXX
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/urlobj.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrameLoader.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/frame/XLoadEventListener.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <vcl/svapp.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <osl/file.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <sfx2/docfile.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/task/XJobExecutor.hpp>
+#include <vcl/msgbox.hxx>
+
+// -------------------------------------------------------------------------
+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..41761d7a7822
--- /dev/null
+++ b/reportdesign/source/filter/xml/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=reportdesign
+TARGET=rptxml
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+SLOFILES= $(SLO)$/xmlfilter.obj \
+ $(SLO)$/xmlReport.obj \
+ $(SLO)$/xmlMasterFields.obj \
+ $(SLO)$/xmlGroup.obj \
+ $(SLO)$/xmlHelper.obj \
+ $(SLO)$/xmlSection.obj \
+ $(SLO)$/xmlComponent.obj \
+ $(SLO)$/xmlControlProperty.obj \
+ $(SLO)$/xmlFormattedField.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)$/xmlSubDocument.obj \
+ $(SLO)$/xmlservices.obj \
+ $(SLO)$/xmlImportDocumentHandler.obj \
+ $(SLO)$/xmlExportDocumentHandler.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..f802b3460684
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlAutoStyle.cxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlAutoStyle.hxx"
+#include "xmlHelper.hxx"
+#include "xmlExport.hxx"
+#include <xmloff/families.hxx>
+#include <tools/debug.hxx>
+
+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..a0010cf886ad
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlAutoStyle.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLAUTOSTYLE_HXX
+#define RPT_XMLAUTOSTYLE_HXX
+
+#include <xmloff/maptype.hxx>
+#include <xmloff/xmlaustp.hxx>
+#include <xmloff/xmltypes.hxx>
+#include <xmloff/xmlprmap.hxx>
+
+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..6e0529a72bf0
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlCell.cxx
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlCell.hxx"
+#include "xmlHelper.hxx"
+#include <xmloff/xmluconv.hxx>
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include <tools/debug.hxx>
+#include "xmlStyleImport.hxx"
+#include <comphelper/namecontainer.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#include <com/sun/star/report/XShape.hpp>
+#include <com/sun/star/report/XFixedLine.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#ifndef RPT_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#include "xmlTable.hxx"
+#include "xmlFormattedField.hxx"
+#include "xmlImage.hxx"
+#include "xmlFixedContent.hxx"
+#include "xmlSubDocument.hxx"
+
+namespace rptxml
+{
+ using namespace ::comphelper;
+ 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 ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,OXMLTable* _pContainer
+ ,OXMLCell* _pCell) :
+ SvXMLImportContext( rImport, nPrfx, _sLocalName )
+ ,m_pContainer(_pContainer)
+ ,m_pCell(_pCell)
+ ,m_nCurrentCount(0)
+ ,m_bContainsShape(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)
+ {
+ ::rtl::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_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 ::rtl::OUString& _rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ ORptFilter& rImport = GetOwnImport();
+ const SvXMLTokenMap& rTokenMap = rImport.GetCellElemTokenMap();
+ Reference<XMultiServiceFactory> xFactor(rImport.GetModel(),uno::UNO_QUERY);
+ static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & "));
+
+ const 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 );
+ if ( !m_bContainsShape )
+ m_nCurrentCount = m_pContainer->getSection()->getCount();
+ uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD);
+ Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY);
+ pContext = new OXMLSubDocument( rImport, _nPrefix, _rLocalName,xControl.get(),m_pContainer, this /* give the current cell as parent*/ );
+ }
+ break;
+
+ case XML_TOK_P:
+ pContext = new OXMLCell( rImport, _nPrefix, _rLocalName,xAttrList ,m_pContainer,this);
+ break;
+ case XML_TOK_CUSTOM_SHAPE:
+ case XML_TOK_FRAME:
+ {
+ if ( !m_bContainsShape )
+ m_nCurrentCount = m_pContainer->getSection()->getCount();
+ UniReference< XMLShapeImportHelper > xShapeImportHelper = rImport.GetShapeImport();
+ uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get();
+ pContext = xShapeImportHelper->CreateGroupChildContext(rImport,_nPrefix,_rLocalName,xAttrList,xShapes);
+ m_bContainsShape = 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_bContainsShape )
+ {
+ const sal_Int32 nCount = m_pContainer->getSection()->getCount();
+ for (sal_Int32 i = m_nCurrentCount; i < nCount; ++i)
+ {
+ uno::Reference<report::XShape> xShape(m_pContainer->getSection()->getByIndex(i),uno::UNO_QUERY);
+ if ( xShape.is() )
+ m_pContainer->addCell(xShape.get());
+ }
+ }
+ if ( m_pCell != this && m_sText.getLength() )
+ {
+ ORptFilter& rImport = GetOwnImport();
+ Reference<XMultiServiceFactory> 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<XMultiServiceFactory> xFactor(rImport.GetModel(),uno::UNO_QUERY);
+ Reference<XFixedLine> 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<beans::XPropertySet> 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(GetOwnImport().isOldFormat(),m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get());
+}
+// -----------------------------------------------------------------------------
+ORptFilter& OXMLCell::GetOwnImport()
+{
+ return static_cast<ORptFilter&>(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;
+ }
+}
+
+void OXMLCell::setContainsShape(bool _bContainsShape)
+{
+ m_bContainsShape = _bContainsShape;
+}
+
+//----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
+
diff --git a/reportdesign/source/filter/xml/xmlCell.hxx b/reportdesign/source/filter/xml/xmlCell.hxx
new file mode 100644
index 000000000000..84c0e54afec3
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlCell.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLCELL_HXX
+#define RPT_XMLCELL_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/report/XReportComponent.hpp>
+
+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;
+ sal_Int32 m_nCurrentCount;
+ bool m_bContainsShape;
+
+ 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);
+ void setContainsShape(bool _bContainsShapes);
+ };
+// -----------------------------------------------------------------------------
+} // 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..499c142a1385
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlColumn.cxx
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+
+#ifndef RPT_XMLCOLUMN_HXX
+#include "xmlColumn.hxx"
+#endif
+#include <xmloff/xmluconv.hxx>
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlCell.hxx"
+#include <tools/debug.hxx>
+#include "xmlStyleImport.hxx"
+#include "xmlTable.hxx"
+#include <comphelper/namecontainer.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#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 ::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 ::rtl::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)
+ {
+ ::rtl::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_COLUMN_STYLE_NAME:
+ fillStyle(sValue);
+ break;
+ default:
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+OXMLRowColumn::~OXMLRowColumn()
+{
+ DBG_DTOR( rpt_OXMLRowColumn,NULL);
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLRowColumn::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::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<sal_uInt16>(PROPERTY_WIDTH.length), PROPERTY_ID_WIDTH, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_HEIGHT, static_cast<sal_uInt16>(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<XPropertySet> 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<ORptFilter&>(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..b144ac7db435
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlColumn.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLCOLUMN_HXX
+#define RPT_XMLCOLUMN_HXX
+
+#include <xmloff/xmlictxt.hxx>
+
+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..e2f80dc5d240
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlComponent.cxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlComponent.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlHelper.hxx"
+#ifndef RPT_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#include "xmlStyleImport.hxx"
+#include <ucbhelper/content.hxx>
+#include <tools/debug.hxx>
+#include <comphelper/namecontainer.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/report/XReportControlModel.hpp>
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#include <tools/debug.hxx>
+
+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 );
+ const ::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);
+}
+// -----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
diff --git a/reportdesign/source/filter/xml/xmlComponent.hxx b/reportdesign/source/filter/xml/xmlComponent.hxx
new file mode 100644
index 000000000000..97374e8955bc
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlComponent.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLCOMPONENT_HXX
+#define RPT_XMLCOMPONENT_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/report/XReportComponent.hpp>
+
+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;
+
+ 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..c54a031435fe
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlCondPrtExpr.cxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlCondPrtExpr.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlControlProperty.hxx"
+#include "xmlComponent.hxx"
+#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#include <tools/debug.hxx>
+
+namespace rptxml
+{
+ 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 ::rtl::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)
+ {
+ ::rtl::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..b402c535a260
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLCONDPRTEXPR_HXX
+#define RPT_XMLCONDPRTEXPR_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+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..115fb3bba2f1
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlControlProperty.cxx
@@ -0,0 +1,360 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlControlProperty.hxx"
+#include <xmloff/xmluconv.hxx>
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+#include <unotools/datetime.hxx>
+#include <com/sun/star/util/DateTime.hpp>
+
+#define TYPE_DATE 1
+#define TYPE_TIME 2
+#define TYPE_DATETIME 3
+
+namespace rptxml
+{
+ 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 ::rtl::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)
+ {
+ ::rtl::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_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 ::rtl::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<ORptFilter&>(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..7d256e033c40
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlControlProperty.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLCONTROLPROPERTY_HXX
+#define RPT_XMLCONTROLPROPERTY_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+
+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..8f4a9bc2a422
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlEnums.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLENUMS_HXX
+#define RPT_XMLENUMS_HXX
+
+#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,
+ XML_TOK_DOC_META
+ };
+ 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 ,
+ XML_TOK_REPORT_NAME ,
+ XML_TOK_MASTER_DETAIL_FIELDS ,
+ XML_TOK_SUB_FRAME
+ };
+ 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_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,
+ XML_TOK_FRAME
+ };
+
+ 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
+ ,XML_TOK_CONDITIONAL_PRINT_EXPRESSION
+ };
+ 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_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..2c946d5280da
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -0,0 +1,1672 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+
+#include "xmlExport.hxx"
+#include "xmlAutoStyle.hxx"
+#include <xmloff/ProgressBarHelper.hxx>
+#include <comphelper/sequence.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/txtimp.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <comphelper/types.hxx>
+#include "xmlEnums.hxx"
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/txtprmap.hxx>
+#include <xmloff/numehelp.hxx>
+#include "xmlHelper.hxx"
+#include "xmlstrings.hrc"
+#include "xmlPropertyHandler.hxx"
+#include <com/sun/star/awt/ImagePosition.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/report/GroupOn.hpp>
+#include <com/sun/star/report/XFixedText.hpp>
+#include <com/sun/star/report/XImageControl.hpp>
+#include <com/sun/star/report/XShape.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/report/XFunction.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/report/XFixedLine.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include "RptDef.hxx"
+// for locking SolarMutex: svapp + mutex
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+#include <boost/bind.hpp>
+
+//--------------------------------------------------------------------------
+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 > ORptMetaExportHelper::create(Reference< XComponentContext > const & xContext)
+ {
+ return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_META ));
+ }
+ //---------------------------------------------------------------------
+ ::rtl::OUString ORptMetaExportHelper::getImplementationName_Static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.report.XMLMetaExporter");
+ }
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ORptMetaExportHelper::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;
+ }
+
+ //---------------------------------------------------------------------
+
+ 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 );
+ }
+ // RDFa: needed for content and header/footer styles
+ if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
+ {
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_XHTML),GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
+ }
+ // GRDDL: to convert RDFa and meta.xml to RDF
+ if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
+ {
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_GRDDL),GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL );
+ }
+
+ _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);
+ // m_xParaPropMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
+
+ ::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<XIndexAccess>& _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!");
+ exportFunction(xFunction);
+ }
+}
+// -----------------------------------------------------------------------------
+void ORptExport::exportFunction(const uno::Reference< XFunction>& _xFunction)
+{
+ exportFormula(XML_FORMULA,_xFunction->getFormula());
+ beans::Optional< ::rtl::OUString> aInitial = _xFunction->getInitialFormula();
+ if ( aInitial.IsPresent && aInitial.Value.getLength() )
+ 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<XReportComponent>& _xReportComponet)
+{
+ const uno::Sequence< ::rtl::OUString> aMasterFields = _xReportComponet->getMasterFields();
+ if ( aMasterFields.getLength() )
+ {
+ SvXMLElementExport aElement(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, sal_True, sal_True);
+ const uno::Sequence< ::rtl::OUString> aDetailFields = _xReportComponet->getDetailFields();
+
+ OSL_ENSURE(aDetailFields.getLength() == aMasterFields.getLength(),"not equal length for master 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>& _xReportDefinition)
+{
+ if ( _xReportDefinition.is() )
+ {
+ exportFunctions(_xReportDefinition->getFunctions().get());
+ exportGroupsExpressionAsFunction(_xReportDefinition->getGroups());
+ //exportMasterDetailFields(_xReportDefinition.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::exportComponent(const Reference<XReportComponent>& _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<XReportControlModel>& _xReportElement)
+{
+ OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF");
+ ::rtl::OUString sDataField = convertFormula(_xReportElement->getDataField());
+ const 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<XReportControlModel>& _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_True, sal_True);
+ 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_True, sal_True);
+ } // 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<sal_Int32>& _aPosX,const ::std::vector<sal_Int32>& _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<sal_Int32>::const_iterator aIter = _aSize.begin();
+ ::std::vector<sal_Int32>::const_iterator aIter2 = aIter + 1;
+ ::std::vector<sal_Int32>::const_iterator aEnd = _aSize.end();
+ for (;aIter2 != aEnd ; ++aIter,++aIter2)
+ {
+ sal_Int32 nValue = static_cast<sal_Int32>(*aIter2 - *aIter);
+ aPropertyStates[0].maValue <<= nValue;
+ _rStyleNames.push_back(GetAutoStylePool()->Add(_nFamily, aPropertyStates ));
+ }
+}
+// -----------------------------------------------------------------------------
+void ORptExport::exportSectionAutoStyle(const Reference<XSection>& _xProp)
+{
+ OSL_ENSURE(_xProp != NULL,"Section is NULL -> GPF");
+ exportAutoStyle(_xProp);
+
+ Reference<XReportDefinition> xReport = _xProp->getReportDefinition();
+ const awt::Size aSize = rptui::getStyleProperty<awt::Size>(xReport,PROPERTY_PAPERSIZE);
+ const sal_Int32 nOffset = rptui::getStyleProperty<sal_Int32>(xReport,PROPERTY_LEFTMARGIN);
+ const sal_Int32 nCount = _xProp->getCount();
+
+ ::std::vector<sal_Int32> aColumnPos;
+ aColumnPos.reserve(2*(nCount + 1));
+ aColumnPos.push_back(nOffset);
+ aColumnPos.push_back(aSize.Width - rptui::getStyleProperty<sal_Int32>(xReport,PROPERTY_RIGHTMARGIN));
+
+ ::std::vector<sal_Int32> 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<XReportComponent> 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> xFixedLine(xReportElement,uno::UNO_QUERY);
+ if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
+ {
+ sal_Int32 nWidth = static_cast<sal_Int32>(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<sal_Int32>());
+ aColumnPos.erase(::std::unique(aColumnPos.begin(),aColumnPos.end()),aColumnPos.end());
+
+ ::std::sort(aRowPos.begin(),aRowPos.end(),::std::less<sal_Int32>());
+ 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<XReportComponent> 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> xFixedLine(xReportElement,uno::UNO_QUERY);
+ if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
+ nPos += static_cast<sal_Int32>(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<sal_Int32>(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<XSection>& _xProp)
+{
+ const sal_Int32 nCount = _xProp->getCount();
+ for (sal_Int32 i = 0 ; i< nCount ; ++i)
+ {
+ const Reference<XReportComponent> xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY);
+ const 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> 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(),xFormattedField);
+ } // 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>& _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<sal_Int32,sal_Int32> 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<sal_Int32,sal_Int32>::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 <table:table-cell>
+ Reference<XFormattedField> xFormattedField(aColIter->xElement,uno::UNO_QUERY);
+ if ( xFormattedField.is() )
+ {
+ sal_Int32 nFormatKey = xFormattedField->getFormatKey();
+ if ( 0 != nFormatKey )
+ {
+ XMLNumberFormatAttributesExportHelper aHelper(GetNumberFormatsSupplier(),*this);
+ sal_Bool bIsStandard = sal_False;
+ ::rtl::OUString sEmpty;
+ if ( util::NumberFormat::TEXT == aHelper.GetCellType(nFormatKey,bIsStandard) )
+ aHelper.SetNumberFormatAttributes(sEmpty, sEmpty);
+ else
+ aHelper.SetNumberFormatAttributes(nFormatKey, 0.0,sal_False);
+ }
+ }
+ SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_False);
+
+ if ( aColIter->xElement.is() )
+ {
+ // start <text:p>
+ SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_True,sal_False);
+ Reference<XServiceInfo> xElement(aColIter->xElement,uno::UNO_QUERY);
+ Reference<XReportComponent> xReportComponent = aColIter->xElement;
+
+ if ( !bShapeHandled )
+ {
+ bShapeHandled = true;
+ exportShapes(_xSection,false);
+ }
+ uno::Reference< XShape > xShape(xElement,uno::UNO_QUERY);
+ uno::Reference< XFixedLine > xFixedLine(xElement,uno::UNO_QUERY);
+ if ( !xShape.is() && !xFixedLine.is() )
+ {
+ Reference<XReportControlModel> xReportElement(xElement,uno::UNO_QUERY);
+ Reference<XReportDefinition> xReportDefinition(xElement,uno::UNO_QUERY);
+ Reference< XImageControl > xImage(xElement,uno::UNO_QUERY);
+ Reference<XSection> 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;
+ ::rtl::OUString sTargetLocation = xImage->getImageURL();
+ if ( sTargetLocation.getLength() )
+ {
+ sTargetLocation = GetRelativeReference(sTargetLocation);
+ AddAttribute(XML_NAMESPACE_FORM, XML_IMAGE_DATA,sTargetLocation);
+ }
+ bExportData = sal_True;
+ ::rtl::OUStringBuffer sValue;
+ const SvXMLEnumMapEntry* aXML_ImageScaleEnumMap = OXMLHelper::GetImageScaleOptions();
+ if ( SvXMLUnitConverter::convertEnum( sValue, xImage->getScaleMode(),aXML_ImageScaleEnumMap ) )
+ AddAttribute(XML_NAMESPACE_REPORT, XML_SCALE, sValue.makeStringAndClear() );
+ }
+ 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 )
+ eToken = XML_FIXED_CONTENT;
+ else if ( eToken == XML_IMAGE )
+ AddAttribute(XML_NAMESPACE_REPORT, XML_PRESERVE_IRI, xImage->getPreserveIRI() ? XML_TRUE : XML_FALSE );
+ }
+
+ //if ( !bPageSet )
+ {
+ // start <report:eToken>
+ 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 && xReportDefinition.is() )
+ {
+ SvXMLElementExport aOfficeElement( *this, XML_NAMESPACE_OFFICE, XML_BODY,sal_True, sal_True );
+ SvXMLElementExport aElem( *this, sal_True,
+ XML_NAMESPACE_OFFICE, XML_REPORT,
+ sal_True, sal_True );
+
+ exportReportAttributes(xReportDefinition);
+ exportReport(xReportDefinition);
+ }
+ else if ( xSection.is() )
+ exportSection(xSection);
+ }
+ }
+ } // if ( aColIter->xElement.is() )
+ else if ( !bShapeHandled )
+ {
+ bShapeHandled = true;
+ exportShapes(_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;
+ if ( _sFormula.equalsAsciiL("rpt:",4) )
+ sFormula = ::rtl::OUString();
+ //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)
+{
+ const ::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<XPropertySet> 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>& _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> 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 sExpression = xGroup->getExpression();
+ if ( sExpression.getLength() )
+ {
+ static ::rtl::OUString s_sQuote(RTL_CONSTASCII_USTRINGPARAM("\"\""));
+ sal_Int32 nIndex = sExpression.indexOf('"');
+ while ( nIndex > -1 )
+ {
+ sExpression = sExpression.replaceAt(nIndex,1,s_sQuote);
+ nIndex = sExpression.indexOf('"',nIndex+2);
+ }
+ ::rtl::OUString sFormula(RTL_CONSTASCII_USTRINGPARAM("rpt:HASCHANGED(\""));
+
+ TGroupFunctionMap::iterator aGroupFind = m_aGroupFunctionMap.find(xGroup);
+ if ( aGroupFind != m_aGroupFunctionMap.end() )
+ sExpression = aGroupFind->second->getName();
+ sFormula += sExpression;
+ sFormula += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\")"));
+ sExpression = sFormula;
+ }
+ AddAttribute(XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION,sExpression);
+ 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> 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> 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,const Reference<XFormattedField>& _xParentFormattedField)
+{
+ const uno::Reference<report::XReportControlFormat> xFormat(_xProp,uno::UNO_QUERY);
+ if ( xFormat.is() )
+ {
+ try
+ {
+ const awt::FontDescriptor aFont = xFormat->getFontDescriptor();
+ OSL_ENSURE(aFont.Name.getLength(),"No Font Name !");
+ GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet );
+ }
+ catch(beans::UnknownPropertyException&)
+ {
+ // not interested in
+ }
+ }
+ const 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> xFixedLine(_xProp,uno::UNO_QUERY);
+ if ( xFixedLine.is() )
+ {
+ uno::Reference<beans::XPropertySet> 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;
+ // }
+ // }
+ //}
+ const Reference<XFormattedField> xFormattedField(_xProp,uno::UNO_QUERY);
+ if ( (_xParentFormattedField.is() || xFormattedField.is()) && !aPropertyStates.empty() )
+ {
+ sal_Int32 nNumberFormat = 0;
+ if ( _xParentFormattedField.is() )
+ nNumberFormat = _xParentFormattedField->getFormatKey();
+ else
+ 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<XSection>& _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<XReportDefinition> xProp(getReportDefinition());
+ exportReportAttributes(xProp);
+}
+// -----------------------------------------------------------------------------
+void ORptExport::exportReportAttributes(const Reference<XReportDefinition>& _xReport)
+{
+ if ( _xReport.is() )
+ {
+ ::rtl::OUStringBuffer sValue;
+ const SvXMLEnumMapEntry* aXML_CommnadTypeEnumMap = OXMLHelper::GetCommandTypeOptions();
+ if ( SvXMLUnitConverter::convertEnum( sValue, static_cast<sal_uInt16>(_xReport->getCommandType()),aXML_CommnadTypeEnumMap ) )
+ AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND_TYPE,sValue.makeStringAndClear());
+
+ ::rtl::OUString sComamnd = _xReport->getCommand();
+ if ( sComamnd.getLength() )
+ AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND, sComamnd);
+
+ ::rtl::OUString sFilter( _xReport->getFilter() );
+ if ( sFilter.getLength() )
+ AddAttribute( XML_NAMESPACE_REPORT, XML_FILTER, sFilter );
+
+ AddAttribute(XML_NAMESPACE_OFFICE, XML_MIMETYPE,_xReport->getMimeType());
+
+ sal_Bool bEscapeProcessing( _xReport->getEscapeProcessing() );
+ if ( !bEscapeProcessing )
+ AddAttribute( XML_NAMESPACE_REPORT, XML_ESCAPE_PROCESSING, ::xmloff::token::GetXMLToken( XML_FALSE ) );
+
+ ::rtl::OUString sName = _xReport->getCaption();
+ if ( sName.getLength() )
+ AddAttribute(XML_NAMESPACE_OFFICE, XML_CAPTION,sName);
+ sName = _xReport->getName();
+ if ( sName.getLength() )
+ AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,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<XReportDefinition> 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 );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ORptExport::implConvertNumber(sal_Int32 _nValue)
+{
+ ::rtl::OUStringBuffer aBuffer;
+ GetMM100UnitConverter().convertNumber(aBuffer, _nValue);
+ 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!");
+
+ 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 <text:p>
+ SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_False, sal_False);
+ if ( Reference<XFormattedField>(_xReportElement,uno::UNO_QUERY).is() )
+ {
+ ::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 );
+ }
+ }
+ 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,bool _bAddParagraph)
+{
+ UniReference< XMLShapeExport > xShapeExport = GetShapeExport();
+ xShapeExport->seekShapes(_xSection.get());
+ const sal_Int32 nCount = _xSection->getCount();
+ ::std::auto_ptr<SvXMLElementExport> pParagraphContent;
+ if ( _bAddParagraph )
+ pParagraphContent.reset(new SvXMLElementExport(*this,XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False));
+
+ awt::Point aRefPoint;
+ aRefPoint.X = rptui::getStyleProperty<sal_Int32>(_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() )
+ {
+ ::std::auto_ptr<SvXMLElementExport> pSubDocument;
+ uno::Reference< frame::XModel> xModel(xShape->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model"))),uno::UNO_QUERY);
+ if ( xModel.is() ) // special handling for chart object
+ {
+ pSubDocument.reset(new SvXMLElementExport(*this,XML_NAMESPACE_REPORT, XML_SUB_DOCUMENT, sal_False, sal_False));
+ exportMasterDetailFields(xShape.get());
+ exportReportElement(xShape.get());
+ }
+
+ AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, XML_PARAGRAPH );
+ xShapeExport->exportShape(xShape.get(),SEF_DEFAULT|SEF_EXPORT_NO_WS,&aRefPoint);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xGroups)
+{
+ if ( _xGroups.is() )
+ {
+ uno::Reference< XFunctions> xFunctions = _xGroups->getReportDefinition()->getFunctions();
+ const sal_Int32 nCount = _xGroups->getCount();
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ {
+ uno::Reference< XGroup> xGroup(_xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
+ const ::sal_Int16 nGroupOn = xGroup->getGroupOn();
+ if ( nGroupOn != report::GroupOn::DEFAULT )
+ {
+ uno::Reference< XFunction> xFunction = xFunctions->createFunction();
+ ::rtl::OUString sFunction,sPrefix,sPostfix;
+ ::rtl::OUString sExpression = xGroup->getExpression();
+ ::rtl::OUString sFunctionName;
+ switch(nGroupOn)
+ {
+ case report::GroupOn::PREFIX_CHARACTERS:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LEFT"));
+ sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval());
+ break;
+ case report::GroupOn::YEAR:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YEAR"));
+ break;
+ case report::GroupOn::QUARTAL:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT((MONTH"));
+ sPostfix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-1)/3)+1"));
+ sFunctionName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QUARTAL_")) + sExpression;
+ break;
+ case report::GroupOn::MONTH:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MONTH"));
+ break;
+ case report::GroupOn::WEEK:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WEEK"));
+ break;
+ case report::GroupOn::DAY:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DAY"));
+ break;
+ case report::GroupOn::HOUR:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HOUR"));
+ break;
+ case report::GroupOn::MINUTE:
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MINUTE"));
+ break;
+ case report::GroupOn::INTERVAL:
+ {
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT"));
+ uno::Reference< XFunction> xCountFunction = xFunctions->createFunction();
+ xCountFunction->setInitialFormula(beans::Optional< ::rtl::OUString>(sal_True,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:1"))));
+ ::rtl::OUString sCountName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_count_")) + sExpression;
+ xCountFunction->setName(sCountName);
+ xCountFunction->setFormula(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[")) + sCountName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("] + 1")));
+ exportFunction(xCountFunction);
+ sExpression = sCountName;
+ sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" / ")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval());
+ sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression;
+ }
+ break;
+ default:
+ ;
+ }
+ if ( !sFunctionName.getLength() )
+ sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression;
+ if ( sFunction.getLength() )
+ {
+ sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'};
+ for(sal_uInt32 j= 0; j < sizeof(pReplaceChars)/sizeof(pReplaceChars[0]);++j)
+ sFunctionName = sFunctionName.replace(pReplaceChars[j],'_');
+
+ xFunction->setName(sFunctionName);
+ sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFunction;
+ sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("(["));
+ sFunction += sExpression;
+ sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("]"));
+
+ if ( sPrefix.getLength() )
+ sFunction += sPrefix;
+ sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+ if ( sPostfix.getLength() )
+ sFunction += sPostfix;
+ xFunction->setFormula(sFunction);
+ exportFunction(xFunction);
+ m_aGroupFunctionMap.insert(TGroupFunctionMap::value_type(xGroup,xFunction));
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+}// rptxml
+// -----------------------------------------------------------------------------
+
diff --git a/reportdesign/source/filter/xml/xmlExport.hxx b/reportdesign/source/filter/xml/xmlExport.hxx
new file mode 100644
index 000000000000..d6c8aea1dcc2
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlExport.hxx
@@ -0,0 +1,281 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef RPT_XMLEXPORT_HXX
+#define RPT_XMLEXPORT_HXX
+
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/report/XReportDefinition.hpp>
+#include <com/sun/star/report/XSection.hpp>
+#include <com/sun/star/report/XReportControlModel.hpp>
+#include <com/sun/star/report/XFormattedField.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase5.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <osl/diagnose.h>
+#include <unotools/tempfile.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <xmloff/xmlexp.hxx>
+#include <xmloff/xmlimp.hxx>
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <memory>
+
+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::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<XReportComponent> xElement;
+ bool bSet;
+ TCell( sal_Int32 _nWidth,
+ sal_Int32 _nHeight,
+ sal_Int32 _nColSpan,
+ sal_Int32 _nRowSpan,
+ Reference<XReportComponent> _xElement = Reference<XReportComponent>()) :
+ 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<XPropertySet> ,::rtl::OUString > TPropertyStyleMap;
+ typedef ::std::map< Reference<XPropertySet> , TStringVec> TGridStyleMap;
+ typedef ::std::vector< TCell > TRow;
+ typedef ::std::vector< ::std::pair< sal_Bool, TRow > > TGrid;
+ typedef ::std::map< Reference<XPropertySet> ,TGrid > TSectionsGrid;
+ typedef ::std::map< Reference<XGroup> ,Reference<XFunction> > TGroupFunctionMap;
+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;
+ TGroupFunctionMap m_aGroupFunctionMap;
+
+ ::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<XReportDefinition> m_xReportDefinition;
+ sal_Bool m_bAllreadyFilled;
+
+ void exportReport(const Reference<XReportDefinition>& _xReportDefinition); /// <element name="office:report">
+ void exportReportAttributes(const Reference<XReportDefinition>& _xReport);
+ void exportFunctions(const Reference<XIndexAccess>& _xFunctions); /// <ref name="rpt-function"/>
+ void exportFunction(const Reference< XFunction>& _xFunction);
+ void exportMasterDetailFields(const Reference<XReportComponent>& _xReportComponet);
+ void exportComponent(const Reference<XReportComponent>& _xReportComponent);
+ sal_Bool exportGroup(const Reference<XReportDefinition>& _xReportDefinition,sal_Int32 _nPos,sal_Bool _bExportAutoStyle = sal_False);
+ void exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt,const ::rtl::OUString& _sName);
+ void exportSection(const Reference<XSection>& _xProp,bool bHeader = false);
+ void exportContainer(const Reference< XSection>& _xSection);
+ void exportShapes(const Reference< XSection>& _xSection,bool _bAddParagraph = true);
+ void exportTableColumns(const Reference< XSection>& _xSection);
+ void exportSectionAutoStyle(const Reference<XSection>& _xProp);
+ void exportReportElement(const Reference<XReportControlModel>& _xReportElement);
+ void exportFormatConditions(const Reference<XReportControlModel>& _xReportElement);
+ void exportAutoStyle(XPropertySet* _xProp,const Reference<XFormattedField>& _xParentFormattedField = Reference<XFormattedField>());
+ void exportAutoStyle(const Reference<XSection>& _xProp);
+ void exportReportComponentAutoStyles(const Reference<XSection>& _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);
+ void exportGroupsExpressionAsFunction(const Reference< XGroups>& _xGroups);
+ ::rtl::OUString convertFormula(const ::rtl::OUString& _sFormula);
+
+ ::rtl::OUString implConvertNumber(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 ~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<XReportDefinition> 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 only meta data
+ * \ingroup reportdesign_source_filter_xml
+ *
+ */
+class ORptMetaExportHelper
+{
+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/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
new file mode 100644
index 000000000000..be664b5694e1
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
@@ -0,0 +1,455 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+
+#include "xmlExportDocumentHandler.hxx"
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <xmloff/attrlist.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlement.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <unotools/saveopt.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <connectivity/dbtools.hxx>
+#include <rtl/ustrbuf.hxx>
+
+namespace rptxml
+{
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+void lcl_exportPrettyPrinting(const uno::Reference< xml::sax::XDocumentHandler >& _xDelegatee)
+{
+ SvtSaveOptions aSaveOpt;
+ if ( aSaveOpt.IsPrettyPrinting() )
+ {
+ static const ::rtl::OUString s_sWhitespaces(RTL_CONSTASCII_USTRINGPARAM(" "));
+ _xDelegatee->ignorableWhitespace(s_sWhitespaces);
+ }
+}
+
+::rtl::OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute)
+{
+ ::rtl::OUStringBuffer sQName;
+ // ...if it's in our map, make the prefix
+ sQName.append ( xmloff::token::GetXMLToken(_eNamespace) );
+ sQName.append ( sal_Unicode(':') );
+ sQName.append ( xmloff::token::GetXMLToken(_eAttribute) );
+ return sQName.makeStringAndClear();
+}
+
+void lcl_correctCellAddress(const ::rtl::OUString & _sName, const uno::Reference< xml::sax::XAttributeList > & xAttribs)
+{
+ SvXMLAttributeList* pList = SvXMLAttributeList::getImplementation(xAttribs);
+ ::rtl::OUString sCellAddress = pList->getValueByName(_sName);
+ const sal_Int32 nPos = sCellAddress.lastIndexOf('$');
+ if ( nPos != -1 )
+ {
+ sCellAddress = sCellAddress.copy(0,nPos);
+ sCellAddress += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$65535"));
+ pList->RemoveAttribute(_sName);
+ pList->AddAttribute(_sName,sCellAddress);
+ }
+}
+
+ExportDocumentHandler::ExportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) :
+ m_xContext(context)
+ ,m_nCurrentCellIndex(0)
+ ,m_nColumnCount(0)
+ ,m_bTableRowsStarted(false)
+ ,m_bFirstRowExported(false)
+ ,m_bExportChar(false)
+ ,m_bCountColumnHeader(false)
+{
+}
+// -----------------------------------------------------------------------------
+ExportDocumentHandler::~ExportDocumentHandler()
+{
+ if ( m_xProxy.is() )
+ {
+ m_xProxy->setDelegator( NULL );
+ m_xProxy.clear();
+ }
+}
+IMPLEMENT_GET_IMPLEMENTATION_ID(ExportDocumentHandler)
+IMPLEMENT_FORWARD_REFCOUNT( ExportDocumentHandler, ExportDocumentHandler_BASE )
+//------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ExportDocumentHandler::getImplementationName( ) throw(uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------
+sal_Bool SAL_CALL ExportDocumentHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
+}
+
+//------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL ExportDocumentHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSupported;
+ if ( m_xServiceInfo.is() )
+ aSupported = m_xServiceInfo->getSupportedServiceNames();
+ return ::comphelper::concatSequences(getSupportedServiceNames_static(),aSupported);
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString ExportDocumentHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ExportDocumentHandler"));
+}
+
+//------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > ExportDocumentHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ExportDocumentHandler"));
+ return aSupported;
+}
+
+//------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL ExportDocumentHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
+{
+ return *(new ExportDocumentHandler( _rxContext ));
+}
+// xml::sax::XDocumentHandler:
+void SAL_CALL ExportDocumentHandler::startDocument() throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->startDocument();
+}
+
+void SAL_CALL ExportDocumentHandler::endDocument() throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->endDocument();
+}
+
+void SAL_CALL ExportDocumentHandler::startElement(const ::rtl::OUString & _sName, const uno::Reference< xml::sax::XAttributeList > & xAttribs) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ bool bExport = true;
+ if ( _sName.equalsAscii("office:chart") )
+ {
+ SvXMLAttributeList* pList = new SvXMLAttributeList();
+ uno::Reference< xml::sax::XAttributeList > xNewAttribs = pList;
+ ::rtl::OUStringBuffer sValue;
+ static SvXMLEnumMapEntry aXML_CommnadTypeEnumMap[] =
+ {
+ { XML_TABLE, sdb::CommandType::TABLE },
+ { XML_QUERY, sdb::CommandType::QUERY },
+ // { XML_COMMAND, CommandType::COMMAND }, // default
+ { XML_TOKEN_INVALID, 0 }
+ };
+ if ( SvXMLUnitConverter::convertEnum( sValue, static_cast<sal_uInt16>(m_xDatabaseDataProvider->getCommandType()),aXML_CommnadTypeEnumMap ) )
+ {
+ pList->AddAttribute(lcl_createAttribute(XML_NP_RPT,XML_COMMAND_TYPE),sValue.makeStringAndClear());
+ }
+ const ::rtl::OUString sComamnd = m_xDatabaseDataProvider->getCommand();
+ if ( sComamnd.getLength() )
+ pList->AddAttribute(lcl_createAttribute(XML_NP_RPT,XML_COMMAND),sComamnd);
+
+ const ::rtl::OUString sFilter( m_xDatabaseDataProvider->getFilter() );
+ if ( sFilter.getLength() )
+ pList->AddAttribute(lcl_createAttribute(XML_NP_RPT,XML_FILTER),sFilter);
+
+ const sal_Bool bEscapeProcessing( m_xDatabaseDataProvider->getEscapeProcessing() );
+ if ( !bEscapeProcessing )
+ pList->AddAttribute(lcl_createAttribute(XML_NP_RPT,XML_ESCAPE_PROCESSING),::xmloff::token::GetXMLToken( XML_FALSE ));
+
+ pList->AddAttribute(lcl_createAttribute(XML_NP_OFFICE,XML_MIMETYPE),MIMETYPE_OASIS_OPENDOCUMENT_CHART);
+
+ m_xDelegatee->startElement(lcl_createAttribute(XML_NP_OFFICE,XML_REPORT),xNewAttribs);
+
+ const ::rtl::OUString sTableCalc = lcl_createAttribute(XML_NP_TABLE,XML_CALCULATION_SETTINGS);
+ m_xDelegatee->startElement(sTableCalc,NULL);
+ pList = new SvXMLAttributeList();
+ uno::Reference< xml::sax::XAttributeList > xNullAttr = pList;
+ pList->AddAttribute(lcl_createAttribute(XML_NP_TABLE,XML_DATE_VALUE),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1900-01-01")));
+
+ const ::rtl::OUString sNullDate = lcl_createAttribute(XML_NP_TABLE,XML_NULL_DATE);
+ m_xDelegatee->startElement(sNullDate,xNullAttr);
+ m_xDelegatee->endElement(sNullDate);
+ m_xDelegatee->endElement(sTableCalc);
+ bExport = false;
+ }
+ else if ( _sName.equalsAscii("table:table") )
+ {
+ m_xDelegatee->startElement(lcl_createAttribute(XML_NP_RPT,XML_DETAIL),NULL);
+ lcl_exportPrettyPrinting(m_xDelegatee);
+ }
+ else if ( _sName.equalsAscii("table:table-header-rows") )
+ {
+ m_bCountColumnHeader = true;
+ }
+ else if ( m_bCountColumnHeader && _sName.equalsAscii("table:table-cell") )
+ {
+ ++m_nColumnCount;
+ }
+ else if ( _sName.equalsAscii("table:table-rows") )
+ {
+ m_xDelegatee->startElement(_sName,xAttribs);
+ exportTableRows();
+ bExport = false;
+ m_bTableRowsStarted = true;
+ m_bFirstRowExported = true;
+ }
+ else if ( m_bTableRowsStarted && m_bFirstRowExported && (_sName.equalsAscii("table:table-row") || _sName.equalsAscii("table:table-cell")) )
+ bExport = false;
+ else if ( _sName.equalsAscii("chart:plot-area"))
+ {
+ SvXMLAttributeList* pList = SvXMLAttributeList::getImplementation(xAttribs);
+ pList->RemoveAttribute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("table:cell-range-address")));
+ }
+ else if ( _sName.equalsAscii("chart:categories"))
+ {
+ static ::rtl::OUString s_sCellAddress(lcl_createAttribute(XML_NP_TABLE,XML_CELL_RANGE_ADDRESS));
+ lcl_correctCellAddress(s_sCellAddress,xAttribs);
+ }
+ else if ( _sName.equalsAscii("chart:series"))
+ {
+ static ::rtl::OUString s_sCellAddress(lcl_createAttribute(XML_NP_CHART,XML_VALUES_CELL_RANGE_ADDRESS));
+ lcl_correctCellAddress(s_sCellAddress,xAttribs);
+ }
+ else if ( m_bTableRowsStarted && !m_bFirstRowExported && _sName.equalsAscii("table:table-cell") )
+ {
+ SvXMLAttributeList* pList = SvXMLAttributeList::getImplementation(xAttribs);
+ static ::rtl::OUString s_sValue(lcl_createAttribute(XML_NP_OFFICE,XML_VALUE));
+ pList->RemoveAttribute(s_sValue);
+ }
+ else if ( m_bTableRowsStarted && _sName.equalsAscii("text:p") )
+ {
+ bExport = false;
+ }
+ if ( bExport )
+ m_xDelegatee->startElement(_sName,xAttribs);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ExportDocumentHandler::endElement(const ::rtl::OUString & _sName) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ bool bExport = true;
+ ::rtl::OUString sNewName = _sName;
+ if ( _sName.equalsAscii("office:chart") )
+ {
+ sNewName = lcl_createAttribute(XML_NP_OFFICE,XML_REPORT);
+ }
+ else if ( _sName.equalsAscii("table:table") )
+ {
+ m_xDelegatee->endElement(_sName);
+ lcl_exportPrettyPrinting(m_xDelegatee);
+ sNewName = lcl_createAttribute(XML_NP_RPT,XML_DETAIL);
+ }
+ else if ( _sName.equalsAscii("table:table-header-rows") )
+ {
+ m_bCountColumnHeader = false;
+ }
+ else if ( _sName.equalsAscii("table:table-rows") )
+ m_bTableRowsStarted = false;
+ else if ( m_bTableRowsStarted && m_bFirstRowExported && (_sName.equalsAscii("table:table-row") || _sName.equalsAscii("table:table-cell")) )
+ bExport = false;
+ else if ( m_bTableRowsStarted && _sName.equalsAscii("table:table-row") )
+ m_bFirstRowExported = true;
+ else if ( m_bTableRowsStarted && _sName.equalsAscii("text:p") )
+ {
+ bExport = !m_bFirstRowExported;
+ }
+
+ if ( bExport )
+ m_xDelegatee->endElement(sNewName);
+}
+
+void SAL_CALL ExportDocumentHandler::characters(const ::rtl::OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ if ( !(m_bTableRowsStarted || m_bFirstRowExported) )
+ {
+ m_xDelegatee->characters(aChars);
+ }
+ else if ( m_bExportChar )
+ {
+ static const ::rtl::OUString s_sZero(RTL_CONSTASCII_USTRINGPARAM("0"));
+ m_xDelegatee->characters(s_sZero);
+ }
+}
+
+void SAL_CALL ExportDocumentHandler::ignorableWhitespace(const ::rtl::OUString & aWhitespaces) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->ignorableWhitespace(aWhitespaces);
+}
+
+void SAL_CALL ExportDocumentHandler::processingInstruction(const ::rtl::OUString & aTarget, const ::rtl::OUString & aData) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->processingInstruction(aTarget,aData);
+}
+
+void SAL_CALL ExportDocumentHandler::setDocumentLocator(const uno::Reference< xml::sax::XLocator > & xLocator) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->setDocumentLocator(xLocator);
+}
+void SAL_CALL ExportDocumentHandler::initialize( const uno::Sequence< uno::Any >& _aArguments ) throw (uno::Exception, uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ comphelper::SequenceAsHashMap aArgs(_aArguments);
+ m_xDelegatee = aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentHandler")),m_xDelegatee);
+ m_xModel = aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model")),m_xModel);
+
+ OSL_ENSURE(m_xDelegatee.is(),"No document handler avialable!");
+ if ( !m_xDelegatee.is() || !m_xModel.is() )
+ throw uno::Exception();
+
+ m_xDatabaseDataProvider.set(m_xModel->getDataProvider(),uno::UNO_QUERY);
+ if ( !m_xDatabaseDataProvider.is() || !m_xDatabaseDataProvider->getActiveConnection().is() )
+ throw uno::Exception();
+
+ uno::Reference< reflection::XProxyFactory > xProxyFactory( m_xContext->getServiceManager()->createInstanceWithContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory")),m_xContext),
+ uno::UNO_QUERY);
+ m_xProxy = xProxyFactory->createProxy(m_xDelegatee.get());
+ ::comphelper::query_aggregation(m_xProxy,m_xDelegatee);
+ m_xTypeProvider.set(m_xDelegatee,uno::UNO_QUERY);
+ m_xServiceInfo.set(m_xDelegatee,uno::UNO_QUERY);
+
+ // set ourself as delegator
+ m_xProxy->setDelegator( *this );
+ const ::rtl::OUString sCommand = m_xDatabaseDataProvider->getCommand();
+ if ( sCommand.getLength() )
+ m_aColumns = ::dbtools::getFieldNamesByCommandDescriptor(m_xDatabaseDataProvider->getActiveConnection()
+ ,m_xDatabaseDataProvider->getCommandType()
+ ,sCommand);
+
+ uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xDatabaseDataProvider,uno::UNO_QUERY);
+ if ( xDataProvider.is() )
+ {
+ m_aColumns.realloc(1);
+ uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions();
+ for(sal_Int32 i = 0 ; i < aColumnNames.getLength();++i)
+ {
+ if ( aColumnNames[i].getLength() )
+ {
+ sal_Int32 nCount = m_aColumns.getLength();
+ m_aColumns.realloc(nCount+1);
+ m_aColumns[nCount] = aColumnNames[i];
+ }
+ }
+ }
+}
+// --------------------------------------------------------------------------------
+uno::Any SAL_CALL ExportDocumentHandler::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
+{
+ uno::Any aReturn = ExportDocumentHandler_BASE::queryInterface(_rType);
+ return aReturn.hasValue() ? aReturn : (m_xProxy.is() ? m_xProxy->queryAggregation(_rType) : aReturn);
+}
+// --------------------------------------------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL ExportDocumentHandler::getTypes( ) throw (uno::RuntimeException)
+{
+ if ( m_xTypeProvider.is() )
+ return ::comphelper::concatSequences(
+ ExportDocumentHandler_BASE::getTypes(),
+ m_xTypeProvider->getTypes()
+ );
+ return ExportDocumentHandler_BASE::getTypes();
+}
+// -----------------------------------------------------------------------------
+void ExportDocumentHandler::exportTableRows()
+{
+ const ::rtl::OUString sRow( lcl_createAttribute(XML_NP_TABLE, XML_TABLE_ROW) );
+ m_xDelegatee->startElement(sRow,NULL);
+
+ const ::rtl::OUString sValueType( lcl_createAttribute(XML_NP_OFFICE, XML_VALUE_TYPE) );
+
+ const static ::rtl::OUString s_sFieldPrefix(RTL_CONSTASCII_USTRINGPARAM("field:["));
+ const static ::rtl::OUString s_sFieldPostfix(RTL_CONSTASCII_USTRINGPARAM("]"));
+ const ::rtl::OUString sCell( lcl_createAttribute(XML_NP_TABLE, XML_TABLE_CELL) );
+ const ::rtl::OUString sP( lcl_createAttribute(XML_NP_TEXT, XML_P) );
+ const ::rtl::OUString sFtext(lcl_createAttribute(XML_NP_RPT,XML_FORMATTED_TEXT) );
+ const ::rtl::OUString sRElement(lcl_createAttribute(XML_NP_RPT,XML_REPORT_ELEMENT) );
+ const ::rtl::OUString sRComponent( lcl_createAttribute(XML_NP_RPT,XML_REPORT_COMPONENT) ) ;
+ const ::rtl::OUString sFormulaAttrib( lcl_createAttribute(XML_NP_RPT,XML_FORMULA) );
+ const static ::rtl::OUString s_sString(RTL_CONSTASCII_USTRINGPARAM("string"));
+ const static ::rtl::OUString s_sFloat(RTL_CONSTASCII_USTRINGPARAM("float"));
+
+ SvXMLAttributeList* pCellAtt = new SvXMLAttributeList();
+ uno::Reference< xml::sax::XAttributeList > xCellAtt = pCellAtt;
+ pCellAtt->AddAttribute(sValueType,s_sString);
+
+ bool bRemoveString = true;
+ ::rtl::OUString sFormula;
+ const sal_Int32 nCount = m_aColumns.getLength();
+ if ( m_nColumnCount > nCount )
+ {
+ const sal_Int32 nEmptyCellCount = m_nColumnCount - nCount;
+ for(sal_Int32 i = 0; i < nEmptyCellCount ; ++i)
+ {
+ m_xDelegatee->startElement(sCell,xCellAtt);
+ if ( bRemoveString )
+ {
+ bRemoveString = false;
+ pCellAtt->RemoveAttribute(sValueType);
+ pCellAtt->AddAttribute(sValueType,s_sFloat);
+ } // if ( i == 0 )
+ m_xDelegatee->startElement(sP,NULL);
+ m_xDelegatee->endElement(sP);
+ m_xDelegatee->endElement(sCell);
+ }
+ }
+ for(sal_Int32 i = 0; i < nCount ; ++i)
+ {
+ sFormula = s_sFieldPrefix;
+ sFormula += m_aColumns[i];
+ sFormula += s_sFieldPostfix;
+ SvXMLAttributeList* pList = new SvXMLAttributeList();
+ uno::Reference< xml::sax::XAttributeList > xAttribs = pList;
+ pList->AddAttribute(sFormulaAttrib,sFormula);
+
+ m_xDelegatee->startElement(sCell,xCellAtt);
+ if ( bRemoveString )
+ {
+ bRemoveString = false;
+ pCellAtt->RemoveAttribute(sValueType);
+ pCellAtt->AddAttribute(sValueType,s_sFloat);
+ }
+ m_xDelegatee->startElement(sP,NULL);
+ m_xDelegatee->startElement(sFtext,xAttribs);
+ m_xDelegatee->startElement(sRElement,NULL);
+ m_xDelegatee->startElement(sRComponent,NULL);
+
+ m_xDelegatee->endElement(sRComponent);
+ m_xDelegatee->endElement(sRElement);
+ m_xDelegatee->endElement(sFtext);
+ m_xDelegatee->endElement(sP);
+ m_xDelegatee->endElement(sCell);
+ } // for(sal_Int32 i = 0; i < nCount ; ++i)
+
+ m_xDelegatee->endElement(sRow);
+}
+// -----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.hxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.hxx
new file mode 100644
index 000000000000..9fa0f1b939d9
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_EXPORTDOCUMENTHANDLER_HXX_INCLUDED
+#define RPT_EXPORTDOCUMENTHANDLER_HXX_INCLUDED
+
+#include "sal/config.h"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include <cppuhelper/implbase3.hxx>
+#include "com/sun/star/xml/sax/XDocumentHandler.hpp"
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include "com/sun/star/chart2/data/XDatabaseDataProvider.hpp"
+#include <comphelper/uno3.hxx>
+
+namespace rptxml
+{
+typedef ::cppu::WeakAggImplHelper3< ::com::sun::star::xml::sax::XDocumentHandler
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XServiceInfo> ExportDocumentHandler_BASE;
+
+class ExportDocumentHandler : public ExportDocumentHandler_BASE
+{
+public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::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(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+public:
+ explicit ExportDocumentHandler(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
+
+private:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // ::com::sun::star::xml::sax::XDocumentHandler:
+ virtual void SAL_CALL startDocument() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL endDocument() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL startElement(const ::rtl::OUString & aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL endElement(const ::rtl::OUString & aName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL characters(const ::rtl::OUString & aChars) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString & aWhitespaces) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL processingInstruction(const ::rtl::OUString & aTarget, const ::rtl::OUString & aData) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL setDocumentLocator(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > & xLocator) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ void exportTableRows();
+private:
+ ExportDocumentHandler(ExportDocumentHandler &); // not defined
+ void operator =(ExportDocumentHandler &); // not defined
+
+ virtual ~ExportDocumentHandler();
+
+ ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xDelegatee;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxy;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDatabaseDataProvider > m_xDatabaseDataProvider;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aColumns;
+ sal_Int32 m_nCurrentCellIndex;
+ sal_Int32 m_nColumnCount;
+ bool m_bTableRowsStarted;
+ bool m_bFirstRowExported;
+ bool m_bExportChar;
+ bool m_bCountColumnHeader;
+};
+// -----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
+#endif // RPT_EXPORTDOCUMENTHANDLER_HXX_INCLUDED
diff --git a/reportdesign/source/filter/xml/xmlFixedContent.cxx b/reportdesign/source/filter/xml/xmlFixedContent.cxx
new file mode 100644
index 000000000000..5c19db5c44d7
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFixedContent.cxx
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlFixedContent.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlReportElement.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/report/XShape.hpp>
+#include "xmlCell.hxx"
+#include "xmlstrings.hrc"
+#include <com/sun/star/report/XShape.hpp>
+#include <com/sun/star/report/XFormattedField.hpp>
+#include <com/sun/star/report/XFixedText.hpp>
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include "xmlTable.hxx"
+#include <xmloff/XMLCharContext.hxx>
+
+namespace rptxml
+{
+ 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 ::rtl::OUString& rLName
+ ,OXMLCell& _rCell
+ ,OXMLTable* _pContainer
+ ,OXMLFixedContent* _pInP) :
+ OXMLReportElementBase( rImport, nPrfx, rLName,NULL,_pContainer)
+,m_rCell(_rCell)
+,m_pInP(_pInP)
+,m_bFormattedField(false)
+{
+ DBG_CTOR( rpt_OXMLFixedContent,NULL);
+}
+// -----------------------------------------------------------------------------
+
+OXMLFixedContent::~OXMLFixedContent()
+{
+
+ DBG_DTOR( rpt_OXMLFixedContent,NULL);
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLFixedContent::_CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(nPrefix,rLocalName,xAttrList);
+ if ( pContext )
+ return pContext;
+
+ static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & "));
+ const SvXMLTokenMap& rTokenMap = m_rImport.GetCellElemTokenMap();
+ Reference<XMultiServiceFactory> xFactor = m_rImport.getServiceFactory();
+
+ m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ const sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
+ switch( nToken )
+ {
+ case XML_TOK_P:
+ pContext = new OXMLFixedContent(m_rImport,nPrefix, rLocalName,m_rCell,m_pContainer,this);
+ 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;
+ case XML_TOK_PAGE_NUMBER:
+ m_sPageText += s_sStringConcat + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PageNumber()"));
+ m_bFormattedField = true;
+ break;
+ case XML_TOK_PAGE_COUNT:
+ m_sPageText += s_sStringConcat + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PageCount()"));
+ m_bFormattedField = true;
+ break;
+ default:
+ ;
+ }
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+void OXMLFixedContent::EndElement()
+{
+ if ( m_pInP )
+ {
+ const Reference<XMultiServiceFactory> xFactor(m_rImport.GetModel(),uno::UNO_QUERY);
+ if ( m_bFormattedField )
+ {
+ 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_sPageText);
+ OSL_ENSURE(xControl.is(),"Could not create FormattedField!");
+ m_pInP->m_xComponent = xControl.get();
+ m_xComponent = xControl.get();
+ }
+ else
+ {
+ Reference< XFixedText > xControl(xFactor->createInstance(SERVICE_FIXEDTEXT),uno::UNO_QUERY);
+ OSL_ENSURE(xControl.is(),"Could not create FixedContent!");
+ m_pInP->m_xComponent = xControl.get();
+ m_xComponent = xControl.get();
+ xControl->setLabel(m_sLabel);
+ }
+
+ m_pContainer->addCell(m_xComponent);
+ m_rCell.setComponent(m_xComponent);
+
+ OXMLReportElementBase::EndElement();
+ }
+}
+// -----------------------------------------------------------------------------
+void OXMLFixedContent::Characters( const ::rtl::OUString& rChars )
+{
+ m_sLabel += rChars;
+ if ( rChars.getLength() )
+ {
+ static const ::rtl::OUString s_Quote(RTL_CONSTASCII_USTRINGPARAM("\""));
+ if ( m_sPageText.getLength() )
+ {
+ static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & "));
+ m_sPageText += s_sStringConcat;
+ }
+
+ m_sPageText += s_Quote + rChars + s_Quote;
+ }
+}
+
+//----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
diff --git a/reportdesign/source/filter/xml/xmlFixedContent.hxx b/reportdesign/source/filter/xml/xmlFixedContent.hxx
new file mode 100644
index 000000000000..0637e01ef674
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFixedContent.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLFIXEDCONTENT_HXX
+#define RPT_XMLFIXEDCONTENT_HXX
+
+#include "xmlReportElementBase.hxx"
+#include <com/sun/star/drawing/XShapes.hpp>
+
+
+namespace rptxml
+{
+ class ORptFilter;
+ class OXMLCell;
+ class OXMLFixedContent : public OXMLReportElementBase
+ {
+ ::rtl::OUString m_sPageText; // page count and page number
+ ::rtl::OUString m_sLabel;
+ OXMLCell& m_rCell;
+ OXMLFixedContent* m_pInP; // if set than we are in text-p element
+ bool m_bFormattedField;
+
+ 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
+ ,OXMLFixedContent* _pInP = NULL);
+ 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..d9261ea72dd1
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFormatCondition.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlFormatCondition.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmlEnums.hxx"
+#include "xmlHelper.hxx"
+#include <com/sun/star/report/XReportControlFormat.hpp>
+#include <comphelper/genericpropertyset.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef RPT_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#include "xmlStyleImport.hxx"
+#include <tools/debug.hxx>
+
+namespace rptxml
+{
+ 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 ::rtl::OUString& rLName,
+ const Reference< XAttributeList > & _xAttrList
+ ,const Reference< XFormatCondition > & _xComponent ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+,m_rImport(rImport)
+,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)
+ {
+ ::rtl::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_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);
+}
+// -----------------------------------------------------------------------------
+void OXMLFormatCondition::EndElement()
+{
+ OXMLHelper::copyStyleElements(m_rImport.isOldFormat(),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..ed151240ecaa
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFormatCondition.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLFORMATCONDITION_HXX
+#define RPT_XMLFORMATCONDITION_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/report/XFormatCondition.hpp>
+
+namespace rptxml
+{
+ class ORptFilter;
+ class OXMLFormatCondition : public SvXMLImportContext
+ {
+ ORptFilter& m_rImport;
+ ::rtl::OUString m_sStyleName;
+ ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormatCondition > m_xComponent;
+ 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..210d4bd7409b
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFormattedField.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlFormattedField.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlControlProperty.hxx"
+#include "xmlHelper.hxx"
+#include <xmloff/xmluconv.hxx>
+#include "xmlReportElement.hxx"
+#include "xmlComponent.hxx"
+#include <tools/debug.hxx>
+
+
+namespace rptxml
+{
+ using namespace ::com::sun::star;
+ using namespace xml::sax;
+DBG_NAME( rpt_OXMLFormattedField )
+
+OXMLFormattedField::OXMLFormattedField( ORptFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::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)
+ {
+ ::rtl::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_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..1d4ddae5629d
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFormattedField.hxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLFORMATTEDFIELD_HXX
+#define RPT_XMLFORMATTEDFIELD_HXX
+
+#include "xmlReportElementBase.hxx"
+#include <com/sun/star/report/XFormattedField.hpp>
+
+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..02771159f0db
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFunction.cxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlFunction.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlHelper.hxx"
+#include "xmlEnums.hxx"
+#include "xmlstrings.hrc"
+#include <tools/debug.hxx>
+
+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;
+
+DBG_NAME( rpt_OXMLFunction )
+
+OXMLFunction::OXMLFunction( ORptFilter& _rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& _sLocalName
+ ,const Reference< XAttributeList > & _xAttrList
+ ,const Reference< XFunctionsSupplier >& _xFunctions
+ ,bool _bAddToReport
+ ) :
+ SvXMLImportContext( _rImport, nPrfx, _sLocalName )
+ ,m_xFunctions(_xFunctions->getFunctions())
+ ,m_bAddToReport(_bAddToReport)
+{
+ 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)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
+ const 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:
+ if ( sValue.getLength() )
+ 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<ORptFilter&>(GetImport());
+}
+// -----------------------------------------------------------------------------
+void OXMLFunction::EndElement()
+{
+ if ( m_bAddToReport )
+ {
+ GetOwnImport().insertFunction(m_xFunction);
+ m_xFunction.clear();
+ }
+ else
+ {
+ 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..017965e608a7
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlFunction.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLFUNCTION_HXX
+#define RPT_XMLFUNCTION_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/report/XFunctionsSupplier.hpp>
+#include <com/sun/star/report/XFunctions.hpp>
+
+
+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;
+ bool m_bAddToReport;
+
+ 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
+ ,bool _bAddToReport = false
+ );
+ 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..26d1b7f61252
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlGroup.cxx
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlGroup.hxx"
+#include "xmlSection.hxx"
+#include "xmlFunction.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmlHelper.hxx"
+#include "xmlEnums.hxx"
+#include <ucbhelper/content.hxx>
+#include <comphelper/namecontainer.hxx>
+#include <com/sun/star/report/GroupOn.hpp>
+#include <com/sun/star/report/KeepTogether.hpp>
+#include <tools/debug.hxx>
+
+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();
+ m_xGroup->setSortAscending(sal_False);// the default value has to be set
+ 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();
+ static ::rtl::OUString s_sQuote(RTL_CONSTASCII_USTRINGPARAM("\"\""));
+ static ::rtl::OUString s_sSingleQuote(RTL_CONSTASCII_USTRINGPARAM("\""));
+ sal_Int32 nIndex = sValue.indexOf(s_sQuote,nPos);
+ while ( nIndex > -1 )
+ {
+ sValue = sValue.replaceAt(nIndex,2,s_sSingleQuote);
+ nIndex = sValue.indexOf(s_sQuote,nIndex+2);
+ }
+ nLen = sValue.getLength() - 1;
+ }
+ sValue = sValue.copy(nPos,nLen-nPos-1);
+ const ORptFilter::TGroupFunctionMap& aFunctions = _rImport.getFunctions();
+ ORptFilter::TGroupFunctionMap::const_iterator aFind = aFunctions.find(sValue);
+ if ( aFind != aFunctions.end() )
+ {
+ sal_Int32 nIndex = 0;
+ const ::rtl::OUString sCompleteFormula = aFind->second->getFormula();
+ ::rtl::OUString sExpression = sCompleteFormula.getToken(1,'[',nIndex);
+ nIndex = 0;
+ sExpression = sExpression.getToken(0,']',nIndex);
+ nIndex = 0;
+ const ::rtl::OUString sFormula = sCompleteFormula.getToken(0,'(',nIndex);
+ ::sal_Int16 nGroupOn = report::GroupOn::DEFAULT;
+
+ if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:LEFT")))
+ {
+ nGroupOn = report::GroupOn::PREFIX_CHARACTERS;
+ ::rtl::OUString sInterval = sCompleteFormula.getToken(1,';',nIndex);
+ nIndex = 0;
+ sInterval = sInterval.getToken(0,')',nIndex);
+ m_xGroup->setGroupInterval(sInterval.toInt32());
+ }
+ else if ( sFormula == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:YEAR")))
+ nGroupOn = report::GroupOn::YEAR;
+ else if ( sFormula == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:MONTH")))
+ {
+ nGroupOn = report::GroupOn::MONTH;
+ }
+ else if ( sCompleteFormula.matchIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:INT((MONTH")),0)
+ && sCompleteFormula.endsWithIgnoreAsciiCaseAsciiL("-1)/3)+1",8) )
+ {
+ nGroupOn = report::GroupOn::QUARTAL;
+ }
+ else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:WEEK")))
+ nGroupOn = report::GroupOn::WEEK;
+ else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:DAY")))
+ nGroupOn = report::GroupOn::DAY;
+ else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:HOUR")))
+ nGroupOn = report::GroupOn::HOUR;
+ else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:MINUTE")))
+ nGroupOn = report::GroupOn::MINUTE;
+ else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:INT")))
+ {
+ nGroupOn = report::GroupOn::INTERVAL;
+ _rImport.removeFunction(sExpression);
+ sExpression = sExpression.copy(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT_count_")).getLength());
+
+ nIndex = 0;
+ ::rtl::OUString sInterval = sCompleteFormula.getToken(1,'/',nIndex);
+ nIndex = 0;
+ sInterval = sInterval.getToken(0,')',nIndex);
+ m_xGroup->setGroupInterval(sInterval.toInt32());
+ }
+
+ m_xGroup->setGroupOn(nGroupOn);
+
+ _rImport.removeFunction(sValue);
+ sValue = sExpression;
+ }
+ 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<XReportDefinition> 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<ORptFilter&>(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..03ae2dbbc7c0
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlGroup.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLGROUP_HXX
+#define RPT_XMLGROUP_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/report/XGroups.hpp>
+
+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..0409ca67a067
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlHelper.cxx
@@ -0,0 +1,418 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlHelper.hxx"
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/families.hxx>
+#include <xmloff/controlpropertyhdl.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/propertysethelper.hxx>
+#include <comphelper/mediadescriptor.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/awt/ImagePosition.hpp>
+#include <com/sun/star/awt/ImageScaleMode.hpp>
+#include <xmloff/prstylei.hxx>
+#include "xmlstrings.hrc"
+#include "xmlEnums.hxx"
+#include <xmloff/contextid.hxx>
+#include <xmloff/txtprmap.hxx>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <xmloff/XMLConstantsPropertyHandler.hxx>
+#include <com/sun/star/report/ForceNewPage.hpp>
+#include <com/sun/star/report/ReportPrintOption.hpp>
+#include <com/sun/star/report/GroupOn.hpp>
+#include <com/sun/star/report/KeepTogether.hpp>
+#include <xmloff/xmlement.hxx>
+#include <com/sun/star/report/XReportControlFormat.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <xmloff/EnumPropertyHdl.hxx>
+
+#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;
+DBG_NAME(rpt_OPropertyHandlerFactory)
+OPropertyHandlerFactory::OPropertyHandlerFactory()
+{
+ DBG_CTOR(rpt_OPropertyHandlerFactory,NULL);
+}
+// -----------------------------------------------------------------------------
+OPropertyHandlerFactory::~OPropertyHandlerFactory()
+{
+ DBG_DTOR(rpt_OPropertyHandlerFactory,NULL);
+}
+// -----------------------------------------------------------------------------
+const XMLPropertyHandler* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType) const
+{
+ const XMLPropertyHandler* pHandler = NULL;
+ sal_Int32 nType = _nType;
+ nType &= MID_FLAG_MASK;
+
+ switch(nType)
+ {
+ case XML_RPT_ALGINMENT:
+ {
+ static SvXMLEnumMapEntry __READONLY_DATA pXML_VerticalAlign_Enum[] =
+ {
+ { XML_TOP, style::VerticalAlignment_TOP },
+ { XML_MIDDLE, style::VerticalAlignment_MIDDLE },
+ { XML_BOTTOM, style::VerticalAlignment_BOTTOM },
+ { XML_TOKEN_INVALID, 0 }
+ };
+
+ pHandler = new XMLEnumPropertyHdl( pXML_VerticalAlign_Enum, ::getCppuType((const com::sun::star::style::VerticalAlignment*)0) );
+ }
+ break;
+ case (XML_SD_TYPES_START+34):
+ pHandler = new xmloff::ImageScaleModeHandler();
+ default:
+ ;
+ }
+
+ if ( !pHandler )
+ pHandler = OControlPropertyHandlerFactory::GetPropertyHandler(_nType);
+ else
+ PutHdlCache(nType, pHandler);
+ 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, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_T( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TABLE, context, SvtSaveOptions::ODFVER_010 }
+#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, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_P( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_PARAGRAPH, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_S( name, prefix, token, type, context ) { name, sizeof(name)-1, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_SECTION, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
+#define GMAP( name, prefix, token, type, context ) { name.ascii, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_GRAPHIC, context, SvtSaveOptions::ODFVER_010 }
+#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, SvtSaveOptions::ODFVER_010 }
+#define MAP_CONST_C( name, prefix, token, type, context ) { name, name.length, XML_NAMESPACE_##prefix, XML_##token, type|XML_TYPE_PROP_TABLE_CELL, context, SvtSaveOptions::ODFVER_010 }
+#define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0 ,0, SvtSaveOptions::ODFVER_010}
+// -----------------------------------------------------------------------------
+UniReference < XMLPropertySetMapper > OXMLHelper::GetCellStylePropertyMap(bool _bOldFormat)
+{
+ if ( _bOldFormat )
+ {
+ 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_C( PROPERTY_CONTROLBACKGROUND,
+ FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
+ MAP_CONST_C( PROPERTY_VERTICALALIGN, STYLE, VERTICAL_ALIGN, XML_RPT_ALGINMENT, 0 ),
+ MAP_CONST_C( PROPERTY_CONTROLBACKGROUNDTRANSPARENT,
+ FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
+ 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());
+ }
+ else
+ {
+ 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_C( PROPERTY_CONTROLBACKGROUND,
+ FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
+ MAP_CONST_C( PROPERTY_CONTROLBACKGROUNDTRANSPARENT,
+ FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
+ MAP_CONST_C( PROPERTY_VERTICALALIGN,
+ STYLE, VERTICAL_ALIGN, XML_RPT_ALGINMENT, 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::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::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;
+}
+// -----------------------------------------------------------------------------
+#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 bool _bOld,const ::rtl::OUString& _sStyleName,const SvXMLStylesContext* _pAutoStyles,const uno::Reference<beans::XPropertySet>& _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<sal_uInt16>(PROPERTY_FONTNAME.length), PROPERTY_ID_FONTNAME, &::getCppuType(&aFont.Name) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_CHARFONTHEIGHT, static_cast<sal_uInt16>(PROPERTY_CHARFONTHEIGHT.length), PROPERTY_ID_FONTHEIGHT, &::getCppuType(&aFont.Height) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTWIDTH, static_cast<sal_uInt16>(PROPERTY_FONTWIDTH.length), PROPERTY_ID_FONTWIDTH, &::getCppuType(&aFont.Width) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTSTYLENAME, static_cast<sal_uInt16>(PROPERTY_FONTSTYLENAME.length), PROPERTY_ID_FONTSTYLENAME, &::getCppuType(&aFont.StyleName) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTFAMILY, static_cast<sal_uInt16>(PROPERTY_FONTFAMILY.length), PROPERTY_ID_FONTFAMILY, &::getCppuType(&aFont.Family) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTCHARSET, static_cast<sal_uInt16>(PROPERTY_FONTCHARSET.length), PROPERTY_ID_FONTCHARSET, &::getCppuType(&aFont.CharSet) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTPITCH, static_cast<sal_uInt16>(PROPERTY_FONTPITCH.length), PROPERTY_ID_FONTPITCH, &::getCppuType(&aFont.Pitch) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTCHARWIDTH, static_cast<sal_uInt16>(PROPERTY_FONTCHARWIDTH.length), PROPERTY_ID_FONTCHARWIDTH, &::getCppuType(&aFont.CharacterWidth),PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTWEIGHT, static_cast<sal_uInt16>(PROPERTY_FONTWEIGHT.length), PROPERTY_ID_FONTWEIGHT, &::getCppuType(&aFont.Weight) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_CHARPOSTURE, static_cast<sal_uInt16>(PROPERTY_CHARPOSTURE.length), PROPERTY_ID_FONTSLANT, &::getCppuType(&aFont.Slant) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTUNDERLINE, static_cast<sal_uInt16>(PROPERTY_FONTUNDERLINE.length), PROPERTY_ID_FONTUNDERLINE, &::getCppuType(&aFont.Underline) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_CHARSTRIKEOUT, static_cast<sal_uInt16>(PROPERTY_CHARSTRIKEOUT.length), PROPERTY_ID_FONTSTRIKEOUT, &::getCppuType(&aFont.Strikeout) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTORIENTATION, static_cast<sal_uInt16>(PROPERTY_FONTORIENTATION.length), PROPERTY_ID_FONTORIENTATION, &::getCppuType(&aFont.Orientation) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTKERNING, static_cast<sal_uInt16>(PROPERTY_FONTKERNING.length), PROPERTY_ID_FONTKERNING, &::getCppuType(&aFont.Kerning) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_CHARWORDMODE, static_cast<sal_uInt16>(PROPERTY_CHARWORDMODE.length), PROPERTY_ID_FONTWORDLINEMODE, &::getCppuType(&aFont.WordLineMode) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_FONTTYPE, static_cast<sal_uInt16>(PROPERTY_FONTTYPE.length), PROPERTY_ID_FONTTYPE, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},
+ //{PROPERTY_BACKGROUNDCOLOR, static_cast<sal_uInt16>(PROPERTY_BACKGROUNDCOLOR.length), PROPERTY_ID_BACKGROUNDCOLOR, &::getCppuType(&nBackgroundColor) ,PropertyAttribute::BOUND,0},,
+ //{PROPERTY_PARAADJUST, static_cast<sal_uInt16>(PROPERTY_PARAADJUST.length), PROPERTY_ID_ALIGN, &::getCppuType(&nAlign) ,PropertyAttribute::BOUND,0},,
+ //{PROPERTY_CONTROLBORDER, static_cast<sal_uInt16>(PROPERTY_CONTROLBORDER.length), PROPERTY_ID_BORDER, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},,
+ //{PROPERTY_CONTROLBORDERCOLOR, static_cast<sal_uInt16>(PROPERTY_CONTROLBORDERCOLOR.length), PROPERTY_ID_BORDERCOLOR, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},,
+ //{PROPERTY_CHARCOLOR, static_cast<sal_uInt16>(PROPERTY_TEXTCOLOR.length), PROPERTY_ID_TEXTCOLOR, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},,
+ //{PROPERTY_FORMATKEY, static_cast<sal_uInt16>(PROPERTY_FORMATKEY.length), PROPERTY_ID_FORMATKEY, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},,
+ //{PROPERTY_CHARUNDERLINECOLOR, static_cast<sal_uInt16>(PROPERTY_CHARUNDERLINECOLOR.length), PROPERTY_ID_TEXTLINECOLOR, &::getCppuType(&aFont.Type) ,PropertyAttribute::BOUND,0},,
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ try
+ {
+ pAutoStyle->FillPropertySet(_xProp);
+ if ( _bOld && _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_CHARHIDDEN) )
+ _xProp->setPropertyValue(PROPERTY_CHARHIDDEN,uno::makeAny(sal_False));
+
+ uno::Reference<beans::XPropertySet> 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_CHARPOSTURE) >>= 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<report::XReportControlFormat> xReportControlModel(_xProp,uno::UNO_QUERY);
+ if ( xReportControlModel.is() && aFont.Name.getLength() )
+ {
+ try
+ {
+ xReportControlModel->setFontDescriptor(aFont);
+ }
+ catch(beans::UnknownPropertyException){}
+ }
+ }
+ catch(uno::Exception&)
+ {
+ OSL_ENSURE(0,"OXMLHelper::copyStyleElements -> exception catched");
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+uno::Reference<beans::XPropertySet> OXMLHelper::createBorderPropertySet()
+{
+ static comphelper::PropertyMapEntry pMap[] =
+ {
+ {PROPERTY_BORDERLEFT, static_cast<sal_uInt16>(PROPERTY_BORDERLEFT.length), 0, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_BORDERRIGHT, static_cast<sal_uInt16>(PROPERTY_BORDERRIGHT.length), 1, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_BORDERTOP, static_cast<sal_uInt16>(PROPERTY_BORDERTOP.length), 2, &::getCppuType((const table::BorderLine*)0) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_BORDERBOTTOM, static_cast<sal_uInt16>(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));
+}
+// -----------------------------------------------------------------------------
+SvXMLTokenMap* OXMLHelper::GetReportElemTokenMap()
+{
+ 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_NAMESPACE_DRAW, XML_NAME, XML_TOK_REPORT_NAME },
+ { XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, XML_TOK_MASTER_DETAIL_FIELDS },
+ { XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_SUB_FRAME },
+ XML_TOKEN_MAP_END
+ };
+ return new SvXMLTokenMap( aElemTokenMap );
+}
+// -----------------------------------------------------------------------------
+SvXMLTokenMap* OXMLHelper::GetSubDocumentElemTokenMap()
+{
+ static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
+ {
+ { 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
+ };
+ return new SvXMLTokenMap( aElemTokenMap );
+}
+// -----------------------------------------------------------------------------
+const SvXMLEnumMapEntry* OXMLHelper::GetImageScaleOptions()
+{
+ static SvXMLEnumMapEntry s_aXML_EnumMap[] =
+ {
+ // { XML_NONE, awt::ImageScaleMode::None }, // default
+ { XML_ISOTROPIC, awt::ImageScaleMode::Isotropic },
+ { XML_ANISOTROPIC, awt::ImageScaleMode::Anisotropic },
+ { XML_TOKEN_INVALID, 0 }
+ };
+ return s_aXML_EnumMap;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+} // rptxml
+// -----------------------------------------------------------------------------
diff --git a/reportdesign/source/filter/xml/xmlHelper.hxx b/reportdesign/source/filter/xml/xmlHelper.hxx
new file mode 100644
index 000000000000..cbcd2d93afe1
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlHelper.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLHELPER_HXX
+#define RPT_XMLHELPER_HXX
+
+#include <xmloff/xmlprmap.hxx>
+#include <xmloff/contextid.hxx>
+#include <xmloff/controlpropertyhdl.hxx>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/report/XReportDefinition.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+
+#include <memory>
+
+#define CTF_RPT_NUMBERFORMAT (XML_DB_CTF_START + 1)
+
+#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;
+class SvXMLTokenMap;
+namespace rptxml
+{
+ class OPropertyHandlerFactory : public ::xmloff::OControlPropertyHandlerFactory
+ {
+ OPropertyHandlerFactory(const OPropertyHandlerFactory&);
+ void operator =(const OPropertyHandlerFactory&);
+ protected:
+ mutable ::std::auto_ptr<XMLConstantsPropertyHandler> m_pDisplayHandler;
+ mutable ::std::auto_ptr<XMLPropertyHandler> m_pTextAlignHandler;
+ public:
+ OPropertyHandlerFactory();
+ virtual ~OPropertyHandlerFactory();
+
+ virtual const XMLPropertyHandler* GetPropertyHandler(sal_Int32 _nType) const;
+ };
+
+ class OXMLHelper
+ {
+ public:
+ static UniReference < XMLPropertySetMapper > GetCellStylePropertyMap(bool _bOldFormat = false);
+
+ static const SvXMLEnumMapEntry* GetReportPrintOptions();
+ static const SvXMLEnumMapEntry* GetForceNewPageOptions();
+ static const SvXMLEnumMapEntry* GetKeepTogetherOptions();
+ static const SvXMLEnumMapEntry* GetCommandTypeOptions();
+ static const SvXMLEnumMapEntry* GetImageScaleOptions();
+
+ static const XMLPropertyMapEntry* GetTableStyleProps();
+ static const XMLPropertyMapEntry* GetColumnStyleProps();
+
+ static const XMLPropertyMapEntry* GetRowStyleProps();
+
+ static void copyStyleElements(const bool _bOld,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();
+
+ static SvXMLTokenMap* GetReportElemTokenMap();
+ static SvXMLTokenMap* GetSubDocumentElemTokenMap();
+
+ };
+// -----------------------------------------------------------------------------
+} // 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..1f489bc947fd
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlImage.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlImage.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmlEnums.hxx"
+#include "xmlComponent.hxx"
+#include "xmlReportElement.hxx"
+#include "xmlControlProperty.hxx"
+#include "xmlHelper.hxx"
+#include <tools/debug.hxx>
+#include <unotools/pathoptions.hxx>
+
+#include <comphelper/componentcontext.hxx>
+#include <com/sun/star/awt/ImageScaleMode.hpp>
+
+namespace rptxml
+{
+ 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 ::rtl::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)
+ {
+ ::rtl::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_IMAGE_DATA:
+ {
+ SvtPathOptions aPathOptions;
+ sValue = aPathOptions.SubstituteVariable(sValue);
+ _xComponent->setImageURL(rImport.GetAbsoluteReference( sValue ));
+ }
+
+ break;
+ case XML_TOK_PRESERVE_IRI:
+ _xComponent->setPreserveIRI(s_sTRUE == sValue);
+ break;
+ case XML_TOK_SCALE:
+ {
+ sal_uInt16 nRet = awt::ImageScaleMode::None;
+ if ( s_sTRUE == sValue )
+ {
+ nRet = awt::ImageScaleMode::Anisotropic;
+ }
+ else
+ {
+ const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetImageScaleOptions();
+ SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
+ }
+ _xComponent->setScaleMode( nRet );
+ }
+ break;
+ case XML_TOK_DATA_FORMULA:
+ _xComponent->setDataField(ORptFilter::convertFormula(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..1c4cc9a193dd
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlImage.hxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLIMAGE_HXX
+#define RPT_XMLIMAGE_HXX
+
+#include "xmlReportElementBase.hxx"
+#ifndef _COM_SUN_STAR_REPORT_XImageControl_HPP_
+#include <com/sun/star/report/XImageControl.hpp>
+#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/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
new file mode 100644
index 000000000000..92ee79509dea
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+
+#include "xmlImportDocumentHandler.hxx"
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <xmloff/attrlist.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlement.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmltkmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+
+#include "xmlHelper.hxx"
+#include "xmlEnums.hxx"
+
+#include <connectivity/dbtools.hxx>
+
+namespace rptxml
+{
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+::rtl::OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute);
+
+ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context)
+ :m_bImportedChart( false )
+ ,m_xContext(context)
+{
+}
+// -----------------------------------------------------------------------------
+ImportDocumentHandler::~ImportDocumentHandler()
+{
+ if ( m_xProxy.is() )
+ {
+ m_xProxy->setDelegator( NULL );
+ m_xProxy.clear();
+ }
+}
+IMPLEMENT_GET_IMPLEMENTATION_ID(ImportDocumentHandler)
+IMPLEMENT_FORWARD_REFCOUNT( ImportDocumentHandler, ImportDocumentHandler_BASE )
+//------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ImportDocumentHandler::getImplementationName( ) throw(uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------
+sal_Bool SAL_CALL ImportDocumentHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
+}
+
+//------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL ImportDocumentHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSupported;
+ if ( m_xServiceInfo.is() )
+ aSupported = m_xServiceInfo->getSupportedServiceNames();
+ return ::comphelper::concatSequences(getSupportedServiceNames_static(),aSupported);
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString ImportDocumentHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ImportDocumentHandler"));
+}
+
+//------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > ImportDocumentHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ImportDocumentHandler"));
+ return aSupported;
+}
+
+//------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL ImportDocumentHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
+{
+ return *(new ImportDocumentHandler( _rxContext ));
+}
+// xml::sax::XDocumentHandler:
+void SAL_CALL ImportDocumentHandler::startDocument() throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->startDocument();
+}
+
+void SAL_CALL ImportDocumentHandler::endDocument() throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->endDocument();
+ uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW);
+ if ( xReceiver.is() && m_bImportedChart )
+ {
+ // this fills the chart again
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "CellRangeRepresentation", ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) );
+ aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
+ aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
+ aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
+
+ uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xModel->getDataProvider(),uno::UNO_QUERY);
+ if ( xDataProvider.is() )
+ {
+ const uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions();
+ aArgs.put( "ColumnDescriptions", uno::makeAny( aColumnNames ) );
+ }
+
+ xReceiver->attachDataProvider( m_xDatabaseDataProvider.get() );
+ xReceiver->setArguments( aArgs.getPropertyValues() );
+ }
+}
+
+void SAL_CALL ImportDocumentHandler::startElement(const ::rtl::OUString & _sName, const uno::Reference< xml::sax::XAttributeList > & _xAttrList) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ uno::Reference< xml::sax::XAttributeList > xNewAttribs = _xAttrList;
+ bool bExport = true;
+ if ( _sName.equalsAscii("office:report") )
+ {
+ 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)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_Int32 nColonPos = sAttrName.indexOf( sal_Unicode(':') );
+ if( -1L == nColonPos )
+ sLocalName = sAttrName;
+ else
+ sLocalName = sAttrName.copy( nColonPos + 1L );
+ const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( m_pReportElemTokenMap->Get( XML_NAMESPACE_REPORT, sLocalName ) )
+ {
+ case XML_TOK_COMMAND_TYPE:
+ {
+ sal_uInt16 nRet = static_cast<sal_uInt16>(sdb::CommandType::COMMAND);
+ const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetCommandTypeOptions();
+ SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
+ m_xDatabaseDataProvider->setCommandType(nRet);
+ }
+ break;
+ case XML_TOK_COMMAND:
+ m_xDatabaseDataProvider->setCommand(sValue);
+ break;
+ case XML_TOK_FILTER:
+ m_xDatabaseDataProvider->setFilter(sValue);
+ break;
+ case XML_TOK_ESCAPE_PROCESSING:
+ m_xDatabaseDataProvider->setEscapeProcessing(sValue == s_sTRUE);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ catch(uno::Exception&)
+ {
+ // OSL_ENSURE(0,"Exception catched while filling the report definition props");
+ }
+ m_xDelegatee->startElement(lcl_createAttribute(XML_NP_OFFICE,XML_CHART),NULL);
+ bExport = false;
+ m_bImportedChart = true;
+ }
+ else if ( _sName.equalsAscii("rpt:master-detail-field") )
+ {
+ const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
+ ::std::auto_ptr<SvXMLTokenMap> pMasterElemTokenMap( OXMLHelper::GetSubDocumentElemTokenMap());
+ try
+ {
+ ::rtl::OUString sMasterField,sDetailField;
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_Int32 nColonPos = sAttrName.indexOf( sal_Unicode(':') );
+ if( -1L == nColonPos )
+ sLocalName = sAttrName;
+ else
+ sLocalName = sAttrName.copy( nColonPos + 1L );
+ const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+
+ switch( pMasterElemTokenMap->Get( XML_NAMESPACE_REPORT, sLocalName ) )
+ {
+ case XML_TOK_MASTER:
+ sMasterField = sValue;
+ break;
+ case XML_TOK_SUB_DETAIL:
+ sDetailField = sValue;
+ break;
+ }
+ }
+ if ( !sDetailField.getLength() )
+ sDetailField = sMasterField;
+ m_aMasterFields.push_back(sMasterField);
+ m_aDetailFields.push_back(sDetailField);
+ }
+ catch(uno::Exception&)
+ {
+ OSL_ENSURE(0,"Exception catched while filling the report definition props");
+ }
+ bExport = false;
+ }
+ else if ( _sName.equalsAscii("rpt:detail")
+ || _sName.equalsAscii("rpt:formatted-text")
+ || _sName.equalsAscii("rpt:master-detail-fields")
+ || _sName.equalsAscii("rpt:report-component")
+ || _sName.equalsAscii("rpt:report-element"))
+ bExport = false;
+ else if ( _sName.equalsAscii("chart:plot-area"))
+ {
+ sal_Bool bHasCategories = sal_True;
+ const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
+ ::std::auto_ptr<SvXMLTokenMap> pMasterElemTokenMap( OXMLHelper::GetSubDocumentElemTokenMap());
+ for(sal_Int16 i = 0; i < nLength; ++i)
+ {
+ ::rtl::OUString sLocalName;
+ const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
+ const sal_Int32 nColonPos = sAttrName.indexOf( sal_Unicode(':') );
+ if( -1L == nColonPos )
+ sLocalName = sAttrName;
+ else
+ sLocalName = sAttrName.copy( nColonPos + 1L );
+ if ( sLocalName.equalsAscii("data-source-has-labels") )
+ {
+ const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
+ bHasCategories = sValue.equalsAscii("both");
+ break;
+ }
+ } // for(sal_Int16 i = 0; i < nLength; ++i)
+ beans::PropertyValue* pArgIter = m_aArguments.getArray();
+ beans::PropertyValue* pArgEnd = pArgIter + m_aArguments.getLength();
+ for(;pArgIter != pArgEnd;++pArgIter)
+ {
+ if ( pArgIter->Name.equalsAscii("HasCategories") )
+ {
+ pArgIter->Value <<= bHasCategories;
+ break;
+ }
+ } // for(;pArgIter != pArgEnd;++pArgIter)
+
+
+ SvXMLAttributeList* pList = new SvXMLAttributeList();
+ xNewAttribs = pList;
+ pList->AppendAttributeList(_xAttrList);
+ pList->AddAttribute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("table:cell-range-address")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("local-table.$A$1:.$Z$65536")));
+
+ }
+
+ if ( bExport )
+ m_xDelegatee->startElement(_sName,xNewAttribs);
+}
+
+void SAL_CALL ImportDocumentHandler::endElement(const ::rtl::OUString & _sName) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ bool bExport = true;
+ ::rtl::OUString sNewName = _sName;
+ if ( _sName.equalsAscii("office:report") )
+ {
+ sNewName = lcl_createAttribute(XML_NP_OFFICE,XML_CHART);
+ }
+ else if ( _sName.equalsAscii("rpt:master-detail-fields") )
+ {
+ if ( !m_aMasterFields.empty() )
+ m_xDatabaseDataProvider->setMasterFields(uno::Sequence< ::rtl::OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
+ if ( !m_aDetailFields.empty() )
+ m_xDatabaseDataProvider->setDetailFields(uno::Sequence< ::rtl::OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size()));
+ bExport = false;
+ }
+ else if ( _sName.equalsAscii("rpt:detail")
+ || _sName.equalsAscii("rpt:formatted-text")
+ || _sName.equalsAscii("rpt:master-detail-field")
+ || _sName.equalsAscii("rpt:report-component")
+ || _sName.equalsAscii("rpt:report-element"))
+ bExport = false;
+
+ if ( bExport )
+ m_xDelegatee->endElement(sNewName);
+}
+
+void SAL_CALL ImportDocumentHandler::characters(const ::rtl::OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->characters(aChars);
+}
+
+void SAL_CALL ImportDocumentHandler::ignorableWhitespace(const ::rtl::OUString & aWhitespaces) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->ignorableWhitespace(aWhitespaces);
+}
+
+void SAL_CALL ImportDocumentHandler::processingInstruction(const ::rtl::OUString & aTarget, const ::rtl::OUString & aData) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->processingInstruction(aTarget,aData);
+}
+
+void SAL_CALL ImportDocumentHandler::setDocumentLocator(const uno::Reference< xml::sax::XLocator > & xLocator) throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ m_xDelegatee->setDocumentLocator(xLocator);
+}
+void SAL_CALL ImportDocumentHandler::initialize( const uno::Sequence< uno::Any >& _aArguments ) throw (uno::Exception, uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ comphelper::SequenceAsHashMap aArgs(_aArguments);
+ m_xDelegatee = aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentHandler")),m_xDelegatee);
+ m_xModel = aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model")),m_xModel);
+
+ OSL_ENSURE(m_xDelegatee.is(),"No document handler avialable!");
+ if ( !m_xDelegatee.is() || !m_xModel.is() )
+ throw uno::Exception();
+
+ m_xDatabaseDataProvider.set(m_xModel->getDataProvider(),uno::UNO_QUERY);
+ if ( !m_xDatabaseDataProvider.is() )
+ {
+ const static ::rtl::OUString s_sDatabaseDataProvider(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DatabaseDataProvider"));
+ m_xDatabaseDataProvider.set(m_xContext->getServiceManager()->createInstanceWithContext(s_sDatabaseDataProvider
+ ,m_xContext),uno::UNO_QUERY);
+ if ( !m_xDatabaseDataProvider.is() )
+ throw uno::Exception();
+
+ m_xDatabaseDataProvider->setRowLimit(10);
+
+ uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW);
+ xReceiver->attachDataProvider(m_xDatabaseDataProvider.get());
+ } // if ( !m_xDatabaseDataProvider.is() )
+
+ m_aArguments = m_xDatabaseDataProvider->detectArguments(NULL);
+
+ uno::Reference< reflection::XProxyFactory > xProxyFactory( m_xContext->getServiceManager()->createInstanceWithContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory")),m_xContext),
+ uno::UNO_QUERY);
+ m_xProxy = xProxyFactory->createProxy(m_xDelegatee.get());
+ ::comphelper::query_aggregation(m_xProxy,m_xDelegatee);
+ m_xTypeProvider.set(m_xDelegatee,uno::UNO_QUERY);
+ m_xServiceInfo.set(m_xDelegatee,uno::UNO_QUERY);
+
+ // set ourself as delegator
+ m_xProxy->setDelegator( *this );
+
+ m_pReportElemTokenMap.reset(OXMLHelper::GetReportElemTokenMap());
+}
+// --------------------------------------------------------------------------------
+uno::Any SAL_CALL ImportDocumentHandler::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
+{
+ uno::Any aReturn = ImportDocumentHandler_BASE::queryInterface(_rType);
+ return aReturn.hasValue() ? aReturn : (m_xProxy.is() ? m_xProxy->queryAggregation(_rType) : aReturn);
+}
+// --------------------------------------------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL ImportDocumentHandler::getTypes( ) throw (uno::RuntimeException)
+{
+ if ( m_xTypeProvider.is() )
+ return ::comphelper::concatSequences(
+ ImportDocumentHandler_BASE::getTypes(),
+ m_xTypeProvider->getTypes()
+ );
+ return ImportDocumentHandler_BASE::getTypes();
+}
+
+// -----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
+
diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx
new file mode 100644
index 000000000000..579a1b79b231
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_IMPORTDOCUMENTHANDLER_HXX_INCLUDED
+#define RPT_IMPORTDOCUMENTHANDLER_HXX_INCLUDED
+
+#include "sal/config.h"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include <cppuhelper/implbase3.hxx>
+#include "com/sun/star/xml/sax/XDocumentHandler.hpp"
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include "com/sun/star/chart2/data/XDatabaseDataProvider.hpp"
+#include <comphelper/uno3.hxx>
+#include <memory>
+
+class SvXMLTokenMap;
+namespace rptxml
+{
+typedef ::cppu::WeakAggImplHelper3< ::com::sun::star::xml::sax::XDocumentHandler
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XServiceInfo> ImportDocumentHandler_BASE;
+
+class ImportDocumentHandler : public ImportDocumentHandler_BASE
+{
+public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::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(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+public:
+ explicit ImportDocumentHandler(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
+
+private:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // ::com::sun::star::xml::sax::XDocumentHandler:
+ virtual void SAL_CALL startDocument() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL endDocument() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL startElement(const ::rtl::OUString & aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL endElement(const ::rtl::OUString & aName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL characters(const ::rtl::OUString & aChars) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString & aWhitespaces) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL processingInstruction(const ::rtl::OUString & aTarget, const ::rtl::OUString & aData) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+ virtual void SAL_CALL setDocumentLocator(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > & xLocator) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+private:
+ ImportDocumentHandler(ImportDocumentHandler &); // not defined
+ void operator =(ImportDocumentHandler &); // not defined
+
+ virtual ~ImportDocumentHandler();
+
+ ::osl::Mutex m_aMutex;
+ bool m_bImportedChart;
+ ::std::vector< ::rtl::OUString> m_aMasterFields;
+ ::std::vector< ::rtl::OUString> m_aDetailFields;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArguments;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xDelegatee;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxy;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDatabaseDataProvider > m_xDatabaseDataProvider;
+
+ ::std::auto_ptr<SvXMLTokenMap> m_pReportElemTokenMap;
+};
+// -----------------------------------------------------------------------------
+} // namespace rptxml
+// -----------------------------------------------------------------------------
+#endif // RPT_IMPORTDOCUMENTHANDLER_HXX_INCLUDED
diff --git a/reportdesign/source/filter/xml/xmlMasterFields.cxx b/reportdesign/source/filter/xml/xmlMasterFields.cxx
new file mode 100644
index 000000000000..2067aec4ee7e
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlMasterFields.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlMasterFields.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlReport.hxx"
+#include <tools/debug.hxx>
+
+
+namespace rptxml
+{
+ 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 ::rtl::OUString& rLName,
+ const Reference< XAttributeList > & _xAttrList
+ ,IMasterDetailFieds* _pReport
+ ) :
+ SvXMLImportContext( rImport, nPrfx, rLName)
+,m_pReport(_pReport)
+{
+ 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)
+ {
+ ::rtl::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_MASTER:
+ sMasterField = sValue;
+ break;
+ case XML_TOK_SUB_DETAIL:
+ sDetailField = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+ if ( !sDetailField.getLength() )
+ sDetailField = sMasterField;
+ if ( sMasterField.getLength() )
+ m_pReport->addMasterDetailPair(::std::pair< ::rtl::OUString,::rtl::OUString >(sMasterField,sDetailField));
+}
+// -----------------------------------------------------------------------------
+
+OXMLMasterFields::~OXMLMasterFields()
+{
+ DBG_DTOR( rpt_OXMLMasterFields,NULL);
+}
+
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLMasterFields::CreateChildContext(
+ sal_uInt16 _nPrefix,
+ const ::rtl::OUString& _rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ const SvXMLTokenMap& rTokenMap = static_cast<ORptFilter&>(GetImport()).GetSubDocumentElemTokenMap();
+
+ switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
+ {
+ case XML_TOK_MASTER_DETAIL_FIELD:
+ {
+ GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()), _nPrefix, _rLocalName,xAttrList ,m_pReport);
+ }
+ 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..41ec58ec1602
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlMasterFields.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLMASTERFIELDS_HXX
+#define RPT_XMLMASTERFIELDS_HXX
+
+#include <xmloff/xmlictxt.hxx>
+namespace rptxml
+{
+ class ORptFilter;
+ class IMasterDetailFieds;
+ class OXMLMasterFields : public SvXMLImportContext
+ {
+ IMasterDetailFieds* m_pReport;
+ 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
+ ,IMasterDetailFieds* _pReport);
+ 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..0310edf0830a
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlPropertyHandler.cxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+
+#include "xmlPropertyHandler.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/txtimp.hxx>
+#include <xmloff/nmspmap.hxx>
+
+//--------------------------------------------------------------------------
+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..7ecbb9ff9448
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlPropertyHandler.hxx
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLPROPHANDLER_HXX
+#define RPT_XMLPROPHANDLER_HXX
+
+#include <xmloff/xmlprmap.hxx>
+#include <xmloff/contextid.hxx>
+#include <xmloff/prhdlfac.hxx>
+
+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..e2bfa0deee8c
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlReport.cxx
@@ -0,0 +1,236 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlReport.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmlHelper.hxx"
+#include "xmlGroup.hxx"
+#include "xmlSection.hxx"
+#include "xmlEnums.hxx"
+#include "xmlFunction.hxx"
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include "xmlMasterFields.hxx"
+
+namespace rptxml
+{
+ using namespace ::com::sun::star;
+ using namespace uno;
+ using namespace xml::sax;
+
+DBG_NAME( rpt_OXMLReport )
+
+OXMLReport::OXMLReport( ORptFilter& rImport,
+ sal_uInt16 nPrfx, const ::rtl::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)
+ {
+ ::rtl::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_COMMAND_TYPE:
+ {
+ sal_uInt16 nRet = static_cast<sal_uInt16>(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;
+ case XML_TOK_REPORT_NAME:
+ m_xComponent->setName(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 ::rtl::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(),true);
+ }
+ break;
+ case XML_TOK_MASTER_DETAIL_FIELDS:
+ m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLMasterFields(m_rImport, nPrefix, rLocalName,xAttrList ,this);
+ 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;
+}
+// -----------------------------------------------------------------------------
+void OXMLReport::EndElement()
+{
+ Reference< XFunctions > xFunctions = m_xComponent->getFunctions();
+ const ORptFilter::TGroupFunctionMap& aFunctions = m_rImport.getFunctions();
+ ORptFilter::TGroupFunctionMap::const_iterator aIter = aFunctions.begin();
+ const ORptFilter::TGroupFunctionMap::const_iterator aEnd = aFunctions.end();
+ for (; aIter != aEnd; ++aIter)
+ xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(aIter->second));
+
+ 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 OXMLReport::addMasterDetailPair(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/xmlReport.hxx b/reportdesign/source/filter/xml/xmlReport.hxx
new file mode 100644
index 000000000000..232350559c4b
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlReport.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLREPORT_HXX
+#define RPT_XMLREPORT_HXX
+
+#include "xmlReportElementBase.hxx"
+#include <vector>
+
+namespace rptxml
+{
+ class ORptFilter;
+ class OXMLReport : public OXMLReportElementBase, public IMasterDetailFieds
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xComponent;
+ ::std::vector< ::rtl::OUString> m_aMasterFields;
+ ::std::vector< ::rtl::OUString> m_aDetailFields;
+ 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 );
+
+ virtual void EndElement();
+
+ virtual void addMasterDetailPair(const ::std::pair< ::rtl::OUString,::rtl::OUString >& _aPair);
+
+ 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..5cd4e3800047
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlReportElement.cxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlReportElement.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlComponent.hxx"
+#include "xmlCondPrtExpr.hxx"
+#include <tools/debug.hxx>
+#include "xmlFormatCondition.hxx"
+
+
+namespace rptxml
+{
+ 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 ::rtl::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)
+ {
+ ::rtl::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_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 ::rtl::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<ORptFilter&>(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..7ca0b5c0b71c
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlReportElement.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLREPORTELEMENT_HXX
+#define RPT_XMLREPORTELEMENT_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/report/XReportControlModel.hpp>
+
+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..cbc9c6d7f739
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlReportElementBase.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlReportElementBase.hxx"
+#include "xmlfilter.hxx"
+#include "xmlControlProperty.hxx"
+#include "xmlReportElement.hxx"
+#include "xmlEnums.hxx"
+#include "xmlTable.hxx"
+
+namespace rptxml
+{
+ 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 ::rtl::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 ::rtl::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 ::rtl::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<report::XReportControlModel> 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..970d20dd8180
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlReportElementBase.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLREPORTELEMENTBASE_HXX
+#define RPT_XMLREPORTELEMENTBASE_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/report/XReportComponent.hpp>
+#include <vector>
+
+namespace rptxml
+{
+ class ORptFilter;
+ class OXMLTable;
+
+ class SAL_NO_VTABLE IMasterDetailFieds
+ {
+ public:
+ virtual void addMasterDetailPair(const ::std::pair< ::rtl::OUString,::rtl::OUString >& _aPair) = 0;
+ };
+
+ 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..66ef1ee51054
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlRow.cxx
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+
+#ifndef RPT_XMLCOLUMN_HXX
+#include "xmlColumn.hxx"
+#endif
+#include <xmloff/xmluconv.hxx>
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include <tools/debug.hxx>
+#include "xmlStyleImport.hxx"
+#include <comphelper/namecontainer.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef RPT_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+
+namespace rptxml
+{
+ using namespace ::comphelper;
+ 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 ::rtl::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)
+ {
+ ::rtl::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_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 ::rtl::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<sal_uInt16>(PROPERTY_WIDTH.length), 0, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0},
+ {PROPERTY_HEIGHT, static_cast<sal_uInt16>(PROPERTY_HEIGHT.length), 0, &::getCppuType(static_cast< sal_Int32* >( NULL )) ,PropertyAttribute::BOUND,0},
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ pInfo->add(pMap);
+ Reference<XPropertySet> 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<ORptFilter&>(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..97c98c81e11f
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlRow.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLCOLUMN_HXX
+#define RPT_XMLCOLUMN_HXX
+
+#include <xmloff/xmlictxt.hxx>
+
+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..d888ed5f9cf4
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlSection.cxx
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlSection.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmlHelper.hxx"
+#include "xmlEnums.hxx"
+#ifndef RPT_XMLCOLUMN_HXX
+#include "xmlColumn.hxx"
+#endif
+#ifndef RPT_XMLCondPrtExpr_HXX
+#include "xmlCondPrtExpr.hxx"
+#endif
+#include "xmlStyleImport.hxx"
+#include <connectivity/dbtools.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/report/ReportPrintOption.hpp>
+#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#include "xmlTable.hxx"
+
+
+namespace rptxml
+{
+ 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 ::rtl::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;
+ 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 );
+ const 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;
+ case XML_TOK_REPEAT_SECTION:
+ m_xSection->setRepeatSection(sValue == s_sTRUE );
+ 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 ::rtl::OUString& _rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ ORptFilter& rImport = GetOwnImport();
+ const SvXMLTokenMap& rTokenMap = rImport.GetSectionElemTokenMap();
+ uno::Reference<lang::XMultiServiceFactory> xFactor = rImport.getServiceFactory();
+
+ switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
+ {
+ 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<ORptFilter&>(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..3f42e3b6a0da
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlSection.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLSECTION_HXX
+#define RPT_XMLSECTION_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/report/XSection.hpp>
+#include <vector>
+
+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..c406694e04d5
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlStyleImport.cxx
@@ -0,0 +1,459 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlStyleImport.hxx"
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmlimppr.hxx>
+#include <xmloff/txtimppr.hxx>
+#include <xmloff/families.hxx>
+#include <xmloff/xmlnumfi.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <comphelper/extract.hxx>
+#include <xmloff/xmlprcon.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/XMLGraphicsDefaultStyle.hxx>
+#include <tools/debug.hxx>
+#include "xmlfilter.hxx"
+#include "xmlHelper.hxx"
+#include <tools/debug.hxx>
+
+#define XML_LINE_LEFT 0
+#define XML_LINE_RIGHT 1
+#define XML_LINE_TOP 2
+#define XML_LINE_BOTTOM 3
+
+namespace rptxml
+{
+
+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 ::rtl::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 = const_cast< SvXMLNumFormatContext*>(dynamic_cast<const SvXMLNumFormatContext*>(pStyles->FindStyleChildContext(
+ XML_STYLE_FAMILY_DATA_STYLE, m_sDataStyleName, sal_False)));
+ 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<OReportStylesContext *>(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 ::rtl::OUString& rLocalName,
+ const ::rtl::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 ::rtl::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<XMLFontStylesContext*>(m_rImport.GetFontDecls()));
+
+ m_xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(m_rImport, const_cast<XMLFontStylesContext*>(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 ::rtl::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 ::rtl::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())
+ {
+ ::rtl::OUString sName;
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ {
+ if( m_xTableStyles.is() )
+ xStyles.set(m_xTableStyles);
+ else
+ sName =
+ ::rtl::OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TableStyles" ) ));
+ }
+ break;
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ {
+ if( m_xCellStyles.is() )
+ xStyles.set(m_xCellStyles);
+ else
+ sName =
+ ::rtl::OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) ));
+ }
+ break;
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ {
+ if( m_xColumnStyles.is() )
+ xStyles.set(m_xColumnStyles);
+ else
+ sName =
+ ::rtl::OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnStyles" ) ));
+ }
+ break;
+ case XML_STYLE_FAMILY_TABLE_ROW:
+ {
+ if( m_xRowStyles.is() )
+ xStyles.set(m_xRowStyles);
+ else
+ sName =
+ ::rtl::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;
+}
+// -----------------------------------------------------------------------------
+
+::rtl::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..125168aa9447
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlStyleImport.hxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef RPT_XMLSTYLEIMPORT_HXX
+#define RPT_XMLSTYLEIMPORT_HXX
+
+#include <rtl/ustring.hxx>
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/xmlictxt.hxx>
+#include <xmloff/maptype.hxx>
+#include <xmloff/prstylei.hxx>
+#include <xmloff/xmlimppr.hxx>
+#ifndef _XMLTEXTMASTERPAGECONTEXT_HXX
+#include <xmloff/XMLTextMasterPageContext.hxx>
+#endif
+#ifndef _XMLTEXTMASTERSTYLESCONTEXT_HXX
+#include <xmloff/XMLTextMasterStylesContext.hxx>
+#endif
+#include <xmloff/contextid.hxx>
+#include <xmloff/controlpropertyhdl.hxx>
+#include <vector>
+
+namespace rptxml
+{
+ class ORptFilter;
+
+ class OControlStyleContext : public XMLPropStyleContext
+ {
+ ::rtl::OUString m_sDataStyleName;
+ ::rtl::OUString sPageStyle;
+ const rtl::OUString sNumberFormat;
+ SvXMLStylesContext* pStyles;
+ // std::vector<ScXMLMapContent> 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..a999a0376cbb
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlSubDocument.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlSubDocument.hxx"
+#include "xmlCell.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlEnums.hxx"
+#include "xmlMasterFields.hxx"
+#include "xmlTable.hxx"
+#include <tools/debug.hxx>
+#include <comphelper/property.hxx>
+#include <com/sun/star/report/XReportControlModel.hpp>
+
+namespace rptxml
+{
+ 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 ::rtl::OUString& rLName
+ ,const Reference< XReportComponent > & _xComponent
+ ,OXMLTable* _pContainer
+ ,OXMLCell* _pCellParent) :
+ OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
+,m_xFake(_xComponent)
+,m_pCellParent(_pCellParent)
+,m_nCurrentCount(0)
+,m_bContainsShape(false)
+{
+ DBG_CTOR( rpt_OXMLSubDocument,NULL);
+
+}
+// -----------------------------------------------------------------------------
+
+OXMLSubDocument::~OXMLSubDocument()
+{
+ DBG_DTOR( rpt_OXMLSubDocument,NULL);
+}
+
+// -----------------------------------------------------------------------------
+SvXMLImportContext* OXMLSubDocument::_CreateChildContext(
+ sal_uInt16 _nPrefix,
+ const ::rtl::OUString& _rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(_nPrefix,_rLocalName,xAttrList);
+ if ( pContext )
+ return pContext;
+ const SvXMLTokenMap& rTokenMap = static_cast<ORptFilter&>(GetImport()).GetReportElemTokenMap();
+
+ switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
+ {
+ case XML_TOK_MASTER_DETAIL_FIELDS:
+ {
+ GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()), _nPrefix, _rLocalName,xAttrList ,this);
+ }
+ break;
+ case XML_TOK_SUB_FRAME:
+ {
+ if ( !m_bContainsShape )
+ m_nCurrentCount = m_pContainer->getSection()->getCount();
+ UniReference< XMLShapeImportHelper > xShapeImportHelper = GetImport().GetShapeImport();
+ uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get();
+ pContext = xShapeImportHelper->CreateGroupChildContext(GetImport(),_nPrefix,_rLocalName,xAttrList,xShapes);
+ m_bContainsShape = true;
+ if (m_pCellParent)
+ {
+ // #i94115 say to the parent Cell it contains shapes
+ m_pCellParent->setContainsShape(true);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+void OXMLSubDocument::EndElement()
+{
+ if ( m_bContainsShape )
+ {
+ m_xComponent.set(m_pContainer->getSection()->getByIndex(m_nCurrentCount),uno::UNO_QUERY);
+ if ( m_xComponent.is() )
+ {
+ // #i94115# this is no longer need.
+ // m_pContainer->addCell(m_xComponent.get());
+
+ 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()));
+
+ m_xComponent->setName(m_xFake->getName());
+ m_xComponent->setPrintRepeatedValues(m_xFake->getPrintRepeatedValues());
+ uno::Reference< report::XReportControlModel > xFakeModel(m_xFake,uno::UNO_QUERY);
+ uno::Reference< report::XReportControlModel > xComponentModel(m_xComponent,uno::UNO_QUERY);
+ if ( xComponentModel.is() && xFakeModel.is() )
+ {
+ const sal_Int32 nCount = xFakeModel->getCount();
+ try
+ {
+ for (sal_Int32 i = 0; i < nCount ; ++i)
+ {
+ uno::Reference< report::XFormatCondition > xCond(xFakeModel->getByIndex(i),uno::UNO_QUERY);
+ uno::Reference< report::XFormatCondition > xNewCond = xComponentModel->createFormatCondition();
+ ::comphelper::copyProperties(xCond.get(),xNewCond.get());
+ xComponentModel->insertByIndex(xComponentModel->getCount(),uno::makeAny(xNewCond));
+ } // for (sal_Int32 i = 0; i < nCount ; ++i)
+ }
+ catch(uno::Exception&)
+ {
+ OSL_ENSURE(0,"Can not access format condition!");
+ }
+
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OXMLSubDocument::addMasterDetailPair(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..874dfd909b2a
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlSubDocument.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLSUBDOCUMENT_HXX
+#define RPT_XMLSUBDOCUMENT_HXX
+
+#include "xmlReportElementBase.hxx"
+#include <com/sun/star/report/XReportComponent.hpp>
+#include <vector>
+
+namespace rptxml
+{
+ class ORptFilter;
+ class OXMLCell;
+ class OXMLSubDocument : public OXMLReportElementBase, public IMasterDetailFieds
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> m_xComponent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> m_xFake;
+ ::std::vector< ::rtl::OUString> m_aMasterFields;
+ ::std::vector< ::rtl::OUString> m_aDetailFields;
+ OXMLCell* m_pCellParent;
+ sal_Int32 m_nCurrentCount;
+ bool m_bContainsShape;
+
+ OXMLSubDocument(const OXMLSubDocument&);
+ void operator =(const OXMLSubDocument&);
+
+ virtual SvXMLImportContext* _CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ public:
+
+ OXMLSubDocument( ORptFilter& rImport
+ ,sal_uInt16 nPrfx
+ ,const ::rtl::OUString& rLName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent >& _xComponent
+ ,OXMLTable* _pContainer
+ ,OXMLCell* _pCellParent);
+ virtual ~OXMLSubDocument();
+
+ virtual void EndElement();
+ virtual void addMasterDetailPair(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..c693daa98eba
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlTable.cxx
@@ -0,0 +1,323 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include "xmlTable.hxx"
+#include "xmlfilter.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "RptDef.hxx"
+#include "xmlHelper.hxx"
+#include "xmlEnums.hxx"
+#ifndef RPT_XMLCOLUMN_HXX
+#include "xmlColumn.hxx"
+#endif
+#include <com/sun/star/report/ForceNewPage.hpp>
+#include "xmlCondPrtExpr.hxx"
+#include "xmlStyleImport.hxx"
+#include "xmlstrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <tools/debug.hxx>
+#ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC
+#include "xmlstrings.hrc"
+#endif
+#include <com/sun/star/report/XShape.hpp>
+#include <com/sun/star/report/XFixedLine.hpp>
+
+#define MIN_WIDTH 80
+#define MIN_HEIGHT 20
+
+namespace rptxml
+{
+ 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 ::rtl::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 );
+ const 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_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 ::rtl::OUString& _rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+ ORptFilter& rImport = GetOwnImport();
+ const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap();
+ Reference<XMultiServiceFactory> 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;
+ case XML_TOK_CONDITIONAL_PRINT_EXPRESSION:
+ pContext = new OXMLCondPrtExpr( rImport, _nPrefix, _rLocalName,xAttrList,m_xSection.get());
+ break;
+ default:
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( rImport, _nPrefix, _rLocalName );
+
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+ORptFilter& OXMLTable::GetOwnImport()
+{
+ return static_cast<ORptFilter&>(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<sal_Int32>::iterator aIter = m_aHeight.begin();
+ ::std::vector<sal_Int32>::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<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN);
+ sal_Int32 nPosY = 0;
+ ::std::vector< ::std::vector<TCell> >::iterator aRowIter = m_aGrid.begin();
+ ::std::vector< ::std::vector<TCell> >::iterator aRowEnd = m_aGrid.end();
+ for (sal_Int32 i = 0; aRowIter != aRowEnd; ++aRowIter,++i)
+ {
+ sal_Int32 nPosX = nLeftMargin;
+ ::std::vector<TCell>::iterator aColIter = (*aRowIter).begin();
+ ::std::vector<TCell>::iterator aColEnd = (*aRowIter).end();
+ for (sal_Int32 j = 0; aColIter != aColEnd; ++aColIter,++j)
+ {
+ TCell& rCell = *aColIter;
+ if ( !rCell.xElements.empty())
+ {
+ ::std::vector< uno::Reference< report::XReportComponent> >::iterator aCellIter = rCell.xElements.begin();
+ const ::std::vector< uno::Reference< report::XReportComponent> >::iterator aCellEnd = rCell.xElements.end();
+ for (;aCellIter != aCellEnd ; ++aCellIter)
+ {
+ uno::Reference<report::XShape> xShape(*aCellIter,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<TCell>::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<TCell> >::iterator aHeightIter = aRowIter + 1;
+ while( nRowSpan > 1)
+ {
+ nHeight += (*aHeightIter)[j].nHeight;
+ ++aHeightIter;
+ --nRowSpan;
+ }
+ }
+ Reference<XFixedLine> xFixedLine(*aCellIter,uno::UNO_QUERY);
+ if ( xFixedLine.is() )
+ {
+ if ( xFixedLine->getOrientation() == 1 ) // vertical
+ {
+ OSL_ENSURE(static_cast<sal_uInt32>(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];
+ if ( nWidth < MIN_WIDTH )
+ nWidth = MIN_WIDTH;
+ }
+ else if ( nHeight < MIN_HEIGHT )
+ nHeight = MIN_HEIGHT;
+ }
+ try
+ {
+ (*aCellIter)->setSize(awt::Size(nWidth,nHeight));
+ (*aCellIter)->setPosition(awt::Point(nPosX,nPosY));
+ }
+ catch(beans::PropertyVetoException)
+ {
+ OSL_ENSURE(0,"Could not set the correct position or size!");
+ }
+ }
+ }
+ }
+ 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<XReportComponent>& _xElement)
+{
+ uno::Reference<report::XShape> xShape(_xElement,uno::UNO_QUERY);
+ OSL_ENSURE(static_cast<sal_uInt32>(m_nRowIndex-1 ) < m_aGrid.size() && static_cast<sal_uInt32>( m_nColumnIndex-1 ) < m_aGrid[m_nRowIndex-1].size(),
+ "OXMLTable::addCell: Invalid column and row index");
+ if ( static_cast<sal_uInt32>(m_nRowIndex-1 ) < m_aGrid.size() && static_cast<sal_uInt32>( m_nColumnIndex-1 ) < m_aGrid[m_nRowIndex-1].size() )
+ {
+ TCell& rCell = m_aGrid[m_nRowIndex-1][m_nColumnIndex-1];
+ if ( _xElement.is() )
+ rCell.xElements.push_back( _xElement );
+ if ( !xShape.is() )
+ {
+ rCell.nWidth = m_aWidth[m_nColumnIndex-1];
+ rCell.nHeight = m_aHeight[m_nRowIndex-1];
+ rCell.nColSpan = m_nColSpan;
+ rCell.nRowSpan = m_nRowSpan;
+ }
+ }
+
+ if ( !xShape.is() )
+ m_nColSpan = m_nRowSpan = 1;
+}
+// -----------------------------------------------------------------------------
+void OXMLTable::incrementRowIndex()
+{
+ ++m_nRowIndex;
+ m_nColumnIndex = 0;
+ m_aGrid.push_back(::std::vector<TCell>(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..978723be6758
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlTable.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLTABLE_HXX
+#define RPT_XMLTABLE_HXX
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/report/XSection.hpp>
+#include <vector>
+
+namespace rptxml
+{
+ class ORptFilter;
+ class OXMLTable : public SvXMLImportContext
+ {
+ public:
+ struct TCell
+ {
+ sal_Int32 nWidth;
+ sal_Int32 nHeight;
+ sal_Int32 nColSpan;
+ sal_Int32 nRowSpan;
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> > xElements;
+ TCell() : nWidth(0),nHeight(0),nColSpan(1),nRowSpan(1){}
+ };
+ private:
+ ::std::vector< ::std::vector<TCell> > m_aGrid;
+ ::std::vector<sal_Int32> m_aHeight;
+ ::std::vector<sal_Int32> 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..74e6e1dd9341
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlfilter.cxx
@@ -0,0 +1,1137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include "xmlfilter.hxx"
+#include "xmlGroup.hxx"
+#include "xmlReport.hxx"
+#include "xmlHelper.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <connectivity/dbtools.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/txtimp.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/XMLFontStylesContext.hxx>
+#include <rtl/logfile.hxx>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <comphelper/genericpropertyset.hxx>
+#include <comphelper/mediadescriptor.hxx>
+#include <xmloff/ProgressBarHelper.hxx>
+#include <sfx2/docfile.hxx>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <tools/urlobj.hxx>
+#include <xmloff/DocumentSettingsContext.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmlmetai.hxx>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+#include <svtools/sfxecode.hxx>
+#include "xmlEnums.hxx"
+#include "xmlStyleImport.hxx"
+#include "xmlstrings.hrc"
+#include "xmlPropertyHandler.hxx"
+#include <xmloff/txtprmap.hxx>
+#include "ReportDefinition.hxx"
+
+
+#define MAP_LEN(x) x, sizeof(x) - 1
+//--------------------------------------------------------------------------
+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 );
+DBG_NAME(rpt_RptMLMasterStylesContext_Impl)
+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)
+{
+ DBG_CTOR(rpt_RptMLMasterStylesContext_Impl,NULL);
+}
+
+RptMLMasterStylesContext_Impl::~RptMLMasterStylesContext_Impl()
+{
+ DBG_DTOR(rpt_RptMLMasterStylesContext_Impl,NULL);
+}
+
+void RptMLMasterStylesContext_Impl::EndElement()
+{
+ FinishStyles( sal_True );
+ m_rImport.FinishStyles();
+}
+ /// read a component (file + filter version)
+sal_Int32 ReadThroughComponent(
+ const uno::Reference<XInputStream>& xInputStream,
+ const uno::Reference<XComponent>& xModelComponent,
+ const sal_Char* /*pStreamName*/,
+ const uno::Reference<XMultiServiceFactory> & 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<XComponent>& xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ const uno::Reference<XMultiServiceFactory> & rFactory,
+ const Reference< document::XGraphicObjectResolver > & _xGraphicObjectResolver,
+ const Reference<document::XEmbeddedObjectResolver>& _xEmbeddedObjectResolver,
+ const ::rtl::OUString& _sFilterName
+ ,const uno::Reference<beans::XPropertySet>& _xProp)
+{
+ 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 );
+ xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) ) >>= bEncrypted;
+ }
+ catch( packages::WrongPasswordException& )
+ {
+ return ERRCODE_SFX_WRONGPASSWORD;
+ }
+ catch ( uno::Exception& )
+ {
+ return 1; // TODO/LATER: error handling
+ }
+
+ sal_Int32 nArgs = 0;
+ if( _xGraphicObjectResolver.is())
+ nArgs++;
+ if( _xEmbeddedObjectResolver.is())
+ nArgs++;
+ if ( _xProp.is() )
+ nArgs++;
+
+ uno::Sequence< uno::Any > aFilterCompArgs( nArgs );
+
+ nArgs = 0;
+ if( _xGraphicObjectResolver.is())
+ aFilterCompArgs[nArgs++] <<= _xGraphicObjectResolver;
+ if( _xEmbeddedObjectResolver.is())
+ aFilterCompArgs[ nArgs++ ] <<= _xEmbeddedObjectResolver;
+ if ( _xProp.is() )
+ aFilterCompArgs[ nArgs++ ] <<= _xProp;
+
+ Reference< xml::sax::XDocumentHandler > xDocHandler(
+ rFactory->createInstanceWithArguments( _sFilterName, aFilterCompArgs ),
+ uno::UNO_QUERY_THROW );
+ uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream();
+ // read from the stream
+ return ReadThroughComponent( xInputStream
+ ,xModelComponent
+ ,pStreamName
+ ,rFactory
+ ,xDocHandler
+ ,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;
+}
+
+//---------------------------------------------------------------------
+Reference< XInterface > ORptMetaImportHelper::create(Reference< XComponentContext > const & xContext)
+{
+ return static_cast< XServiceInfo* >(new ORptFilter(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),
+ IMPORT_META));
+}
+//---------------------------------------------------------------------
+::rtl::OUString ORptMetaImportHelper::getImplementationName_Static( ) throw (RuntimeException)
+{
+ return ::rtl::OUString(SERVICE_METAIMPORTER);
+}
+//---------------------------------------------------------------------
+Sequence< ::rtl::OUString > ORptMetaImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = SERVICE_IMPORTFILTER;
+ return aSupported;
+}
+
+// -------------
+// - ORptFilter -
+// -------------
+DBG_NAME(rpt_ORptFilter)
+ORptFilter::ORptFilter( const uno::Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nImportFlags )
+ :SvXMLImport(_rxMSF,nImportFlags)
+{
+ DBG_CTOR(rpt_ORptFilter,NULL);
+ 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(true);
+ 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()
+{
+ DBG_DTOR(rpt_ORptFilter,NULL);
+}
+//------------------------------------------------------------------------------
+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<sdbc::XConnection> xCon(pComponentIter->Value,uno::UNO_QUERY);
+ xNumberFormatsSupplier = ::dbtools::getNumberFormats(xCon);
+ break;
+ }
+ }
+ }
+ }
+
+ if ( sFileName.getLength() != 0 )
+ {
+ uno::Reference<XComponent> 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;
+
+#if OSL_DEBUG_LEVEL > 1
+ uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
+ uno::Sequence< ::rtl::OUString> aSeq = xAccess->getElementNames();
+ const ::rtl::OUString* pDebugIter = aSeq.getConstArray();
+ const ::rtl::OUString* pDebugEnd = pDebugIter + aSeq.getLength();
+ for(;pDebugIter != pDebugEnd;++pDebugIter)
+ {
+ (void)*pDebugIter;
+ }
+#endif
+
+ Reference< document::XGraphicObjectResolver > xGraphicObjectResolver;
+ uno::Reference<document::XEmbeddedObjectResolver> xEmbeddedObjectResolver;
+ uno::Reference< lang::XMultiServiceFactory > xServiceFactory( getServiceFactory(), uno::UNO_QUERY);
+ if( xServiceFactory.is())
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] <<= xStorage;
+ xGraphicObjectResolver.set(
+ xServiceFactory->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Svx.GraphicImportHelper")), aArgs ), uno::UNO_QUERY );
+
+ uno::Reference< lang::XMultiServiceFactory > xReportServiceFactory( m_xReportDefinition, uno::UNO_QUERY);
+ aArgs[0] <<= beans::NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage")),uno::makeAny(xStorage));
+ xEmbeddedObjectResolver.set( xReportServiceFactory->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")),aArgs) , uno::UNO_QUERY);
+ }
+
+ static const ::rtl::OUString s_sOld(RTL_CONSTASCII_USTRINGPARAM("OldFormat"));
+ static comphelper::PropertyMapEntry pMap[] =
+ {
+ { MAP_LEN( "OldFormat" ), 1, &::getCppuType((const sal_Bool*)0), beans::PropertyAttribute::BOUND, 0 },
+ { MAP_LEN( "StreamName"), 0, &::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN("PrivateData"), 0, &::getCppuType( (uno::Reference<XInterface> *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN( "BaseURI"), 0, &::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN( "StreamRelPath"), 0, &::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ ::comphelper::MediaDescriptor aDescriptor(rDescriptor);
+ uno::Reference<beans::XPropertySet> xProp = comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap));
+ const ::rtl::OUString sVal( aDescriptor.getUnpackedValueOrDefault(aDescriptor.PROP_DOCUMENTBASEURL(),::rtl::OUString()) );
+ xProp->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(sVal));
+ const ::rtl::OUString sHierarchicalDocumentName( aDescriptor.getUnpackedValueOrDefault(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HierarchicalDocumentName")),::rtl::OUString()) );
+ xProp->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath")), uno::makeAny(sHierarchicalDocumentName));
+
+ uno::Reference<XComponent> xModel(GetModel(),UNO_QUERY);
+ static const ::rtl::OUString s_sMeta(RTL_CONSTASCII_USTRINGPARAM("meta.xml"));
+ static const rtl::OUString s_sStreamName(RTL_CONSTASCII_USTRINGPARAM("StreamName"));
+ xProp->setPropertyValue(s_sStreamName, uno::makeAny(s_sMeta));
+ sal_Int32 nRet = ReadThroughComponent( xStorage
+ ,xModel
+ ,"meta.xml"
+ ,"Meta.xml"
+ ,getServiceFactory()
+ ,xGraphicObjectResolver
+ ,xEmbeddedObjectResolver
+ ,SERVICE_METAIMPORTER
+ ,xProp
+ );
+
+
+ try
+ {
+ xProp->setPropertyValue(s_sOld,uno::makeAny(!(xStorage->hasByName(s_sMeta) || xStorage->isStreamElement( s_sMeta ))));
+ }
+ catch(uno::Exception&)
+ {
+ xProp->setPropertyValue(s_sOld,uno::makeAny(sal_True));
+ }
+
+ if ( nRet == 0 )
+ {
+ xProp->setPropertyValue(s_sStreamName, uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("settings.xml"))));
+ nRet = ReadThroughComponent( xStorage
+ ,xModel
+ ,"settings.xml"
+ ,"Settings.xml"
+ ,getServiceFactory()
+ ,xGraphicObjectResolver
+ ,xEmbeddedObjectResolver
+ ,SERVICE_SETTINGSIMPORTER
+ ,xProp
+ );
+ }
+ if ( nRet == 0 )
+ {
+ xProp->setPropertyValue(s_sStreamName, uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("styles.xml"))));
+ nRet = ReadThroughComponent(xStorage
+ ,xModel
+ ,"styles.xml"
+ ,"Styles.xml"
+ ,getServiceFactory()
+ ,xGraphicObjectResolver
+ ,xEmbeddedObjectResolver
+ ,SERVICE_STYLESIMPORTER
+ ,xProp);
+ }
+
+ if ( nRet == 0 )
+ {
+ xProp->setPropertyValue(s_sStreamName, uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml"))));
+ nRet = ReadThroughComponent( xStorage
+ ,xModel
+ ,"content.xml"
+ ,"Content.xml"
+ ,getServiceFactory()
+ ,xGraphicObjectResolver
+ ,xEmbeddedObjectResolver
+ ,SERVICE_CONTENTIMPORTER
+ ,xProp
+ );
+ }
+
+
+ bRet = nRet == 0;
+
+ if ( bRet )
+ {
+ m_xReportDefinition->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:
+ // don't use the autostyles from the styles-document for the progress
+ if ( ! IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) )
+ 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;
+ case XML_TOK_DOC_META:
+ GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+ pContext = CreateMetaContext( rLocalName,xAttrList );
+ 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_OFFICE, XML_DOCUMENT_META, XML_TOK_DOC_META },
+ //{ 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() )
+ m_pReportElemTokenMap.reset(OXMLHelper::GetReportElemTokenMap());
+ return *m_pReportElemTokenMap;
+}
+// -----------------------------------------------------------------------------
+const SvXMLTokenMap& ORptFilter::GetSubDocumentElemTokenMap() const
+{
+ if ( !m_pSubDocumentElemTokenMap.get() )
+ m_pSubDocumentElemTokenMap.reset(OXMLHelper::GetSubDocumentElemTokenMap());
+ 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_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_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, XML_TOK_CONDITIONAL_PRINT_EXPRESSION},
+ 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_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_DRAW, XML_FRAME , XML_TOK_FRAME },
+ { 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!");
+
+ SvXMLImport::startDocument();
+ }
+}
+// -----------------------------------------------------------------------------
+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();
+}
+// -----------------------------------------------------------------------------
+void ORptFilter::removeFunction(const ::rtl::OUString& _sFunctionName)
+{
+ m_aFunctions.erase(_sFunctionName);
+}
+// -----------------------------------------------------------------------------
+void ORptFilter::insertFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > & _xFunction)
+{
+ m_aFunctions.insert(TGroupFunctionMap::value_type(_xFunction->getName(),_xFunction));
+}
+// -----------------------------------------------------------------------------
+SvXMLImportContext* ORptFilter::CreateMetaContext(const ::rtl::OUString& rLocalName,const uno::Reference<xml::sax::XAttributeList>&)
+{
+ SvXMLImportContext* pContext = NULL;
+
+ if ( (getImportFlags() & IMPORT_META) )
+ {
+ uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
+ getServiceFactory()->createInstance(::rtl::OUString::createFromAscii(
+ "com.sun.star.xml.dom.SAXDocumentBuilder")),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
+ pContext = new SvXMLMetaDocumentContext(*this,XML_NAMESPACE_OFFICE, rLocalName,xDPS->getDocumentProperties(), xDocBuilder);
+ }
+ return pContext;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORptFilter::isOldFormat() const
+{
+ sal_Bool bOldFormat = sal_True;
+ uno::Reference<beans::XPropertySet> xProp = getImportInfo();
+ if ( xProp.is() )
+ {
+ const static ::rtl::OUString s_sOld(RTL_CONSTASCII_USTRINGPARAM("OldFormat"));
+ if ( xProp->getPropertySetInfo()->hasPropertyByName(s_sOld))
+ {
+ xProp->getPropertyValue(s_sOld) >>= bOldFormat;
+ }
+ } // if ( xProp.is() )
+ return bOldFormat;
+}
+
+// -----------------------------------------------------------------------------
+}// rptxml
+// -----------------------------------------------------------------------------
diff --git a/reportdesign/source/filter/xml/xmlfilter.hxx b/reportdesign/source/filter/xml/xmlfilter.hxx
new file mode 100644
index 000000000000..30837681b028
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlfilter.hxx
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef RPT_XMLFILTER_HXX
+#define RPT_XMLFILTER_HXX
+
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase5.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/report/XReportDefinition.hpp>
+#include <osl/diagnose.h>
+#include <unotools/tempfile.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <xmloff/xmlimp.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+#include <xmloff/prhdlfac.hxx>
+#include <xmloff/xmlprmap.hxx>
+
+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<PropertyValue>,TPropertyNameMap);
+ DECLARE_STL_USTRINGACCESS_MAP( Reference<XFunction> ,TGroupFunctionMap);
+private:
+
+ TGroupFunctionMap m_aFunctions;
+ com::sun::star::uno::Any m_aViewSettings;
+ Reference< XComponent > m_xSrcDoc;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pReportElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pGroupsElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pGroupElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pSectionElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pControlElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pFunctionElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pSubDocumentElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pFormatElemTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnTokenMap;
+ mutable ::std::auto_ptr<SvXMLTokenMap> m_pCellElemTokenMap;
+
+ UniReference < XMLPropertyHandlerFactory > m_xPropHdlFactory;
+ UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
+ UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
+ UniReference < XMLPropertySetMapper > m_xRowStylesPropertySetMapper;
+ UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
+
+ Reference<XReportDefinition> m_xReportDefinition;
+ ::boost::shared_ptr<rptui::OReportModel> m_pReportModel;
+
+ sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
+
+ SvXMLImportContext* CreateStylesContext(const ::rtl::OUString& rLocalName,
+ const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle );
+ SvXMLImportContext* CreateMetaContext(const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ 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<XReportDefinition> getReportDefinition() const { return m_xReportDefinition; }
+ /** return the SdrModel of the real model
+ *
+ * \return
+ */
+ ::boost::shared_ptr<rptui::OReportModel> 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);
+ /** inserts a new function
+ *
+ * \param _xFunction
+ */
+ void insertFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > & _xFunction);
+ void removeFunction(const ::rtl::OUString& _sFunctionName);
+ inline const TGroupFunctionMap& getFunctions() const { return m_aFunctions; }
+
+ virtual SvXMLImport& getGlobalContext();
+
+ virtual void enterEventContext();
+ virtual void leaveEventContext();
+
+ sal_Bool isOldFormat() const;
+};
+
+/** 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);
+};
+
+/** Imports only meta data
+ * \ingroup reportdesign_source_filter_xml
+ *
+ */
+class ORptMetaImportHelper
+{
+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..bebf5f69a05b
--- /dev/null
+++ b/reportdesign/source/filter/xml/xmlservices.cxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_reportdesign.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+#include <cppuhelper/implementationentry.hxx>
+#include "xmlfilter.hxx"
+#include "xmlExport.hxx"
+#include "dbloader2.hxx"
+#include "xmlExportDocumentHandler.hxx"
+#include "xmlImportDocumentHandler.hxx"
+
+
+/********************************************************************************************/
+
+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 },
+ { &ORptMetaExportHelper::create, &ORptMetaExportHelper::getImplementationName_Static, &ORptMetaExportHelper::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 },
+ { &ExportDocumentHandler::create, &ExportDocumentHandler::getImplementationName_Static, &ExportDocumentHandler::getSupportedServiceNames_static,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { &ImportDocumentHandler::create, &ImportDocumentHandler::getImplementationName_Static, &ImportDocumentHandler::getSupportedServiceNames_static,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { &ORptMetaImportHelper::create, &ORptMetaImportHelper::getImplementationName_Static, &ORptMetaImportHelper::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);
+}