summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2009-09-09 11:45:13 +0200
committerMathias Bauer <mba@openoffice.org>2009-09-09 11:45:13 +0200
commite7c6e5d2c248cfb935c91882a3a1e64fea7550b4 (patch)
treed2f45902cbd12ac6b651e486687130e01272d79f /xmloff
parent2484e4f7faa1f052ff48d2192ffb5931a71faa8f (diff)
parentd1886d07b439e7197f731c9d98c0b2ec31c62faa (diff)
merge commit to DEV300_m57
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/RDFaExportHelper.hxx83
-rw-r--r--xmloff/inc/RDFaImportHelper.hxx91
-rw-r--r--xmloff/inc/SchXMLImport.hxx1
-rw-r--r--xmloff/inc/txtflde.hxx18
-rw-r--r--xmloff/inc/xmlkywd.hxx7
-rw-r--r--xmloff/inc/xmlnmspe.hxx5
-rw-r--r--xmloff/inc/xmloff/SchXMLExportHelper.hxx7
-rw-r--r--xmloff/inc/xmloff/SchXMLImportHelper.hxx7
-rw-r--r--xmloff/inc/xmloff/table/XMLTableExport.hxx2
-rw-r--r--xmloff/inc/xmloff/txtimp.hxx4
-rw-r--r--xmloff/inc/xmloff/txtparae.hxx35
-rw-r--r--xmloff/inc/xmloff/txtprmap.hxx2
-rw-r--r--xmloff/inc/xmloff/xmlexp.hxx28
-rw-r--r--xmloff/inc/xmloff/xmlimp.hxx20
-rw-r--r--xmloff/inc/xmloff/xmlimppr.hxx1
-rw-r--r--xmloff/inc/xmloff/xmlmetai.hxx5
-rw-r--r--xmloff/inc/xmloff/xmltoken.hxx17
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx245
-rw-r--r--xmloff/source/chart/SchXMLChartContext.hxx10
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx160
-rw-r--r--xmloff/source/chart/SchXMLImport.cxx42
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx60
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.hxx22
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.cxx257
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.hxx20
-rw-r--r--xmloff/source/chart/SchXMLTableContext.cxx71
-rw-r--r--xmloff/source/chart/SchXMLTableContext.hxx6
-rw-r--r--xmloff/source/chart/SchXMLTools.cxx181
-rw-r--r--xmloff/source/chart/SchXMLTools.hxx17
-rw-r--r--xmloff/source/chart/transporttypes.hxx22
-rw-r--r--xmloff/source/core/RDFaExportHelper.cxx218
-rw-r--r--xmloff/source/core/RDFaImportHelper.cxx458
-rw-r--r--xmloff/source/core/makefile.mk5
-rw-r--r--xmloff/source/core/xmlexp.cxx225
-rw-r--r--xmloff/source/core/xmlimp.cxx79
-rw-r--r--xmloff/source/core/xmltoken.cxx17
-rw-r--r--xmloff/source/draw/sdpropls.cxx29
-rw-r--r--xmloff/source/draw/sdpropls.hxx2
-rw-r--r--xmloff/source/draw/shapeexport.cxx3
-rw-r--r--xmloff/source/draw/shapeexport2.cxx25
-rw-r--r--xmloff/source/draw/shapeexport4.cxx26
-rw-r--r--xmloff/source/draw/ximpshap.cxx19
-rw-r--r--xmloff/source/forms/elementexport.cxx6
-rw-r--r--xmloff/source/forms/formattributes.cxx1
-rw-r--r--xmloff/source/forms/formattributes.hxx1
-rw-r--r--xmloff/source/forms/strings.hxx1
-rw-r--r--xmloff/source/meta/xmlmetai.cxx15
-rw-r--r--xmloff/source/table/XMLTableExport.cxx4
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx141
-rw-r--r--xmloff/source/text/XMLTextFrameContext.hxx3
-rw-r--r--xmloff/source/text/XMLTextMarkImportContext.cxx60
-rw-r--r--xmloff/source/text/txtflde.cxx76
-rw-r--r--xmloff/source/text/txtimp.cxx296
-rw-r--r--xmloff/source/text/txtimppr.cxx13
-rw-r--r--xmloff/source/text/txtparae.cxx144
-rw-r--r--xmloff/source/text/txtparai.cxx372
-rw-r--r--xmloff/source/text/txtparai.hxx7
-rw-r--r--xmloff/source/text/txtprmap.cxx2
-rw-r--r--xmloff/source/text/txtstyli.cxx24
59 files changed, 2780 insertions, 938 deletions
diff --git a/xmloff/inc/RDFaExportHelper.hxx b/xmloff/inc/RDFaExportHelper.hxx
new file mode 100644
index 000000000000..f7a708b68a0a
--- /dev/null
+++ b/xmloff/inc/RDFaExportHelper.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RDFaExportHelper.hxx,v $
+ * $Revision: 1.1.2.1 $
+ *
+ * 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 RDFAEXPORTHELPER_HXX
+#define RDFAEXPORTHELPER_HXX
+
+#include <com/sun/star/uno/Reference.h>
+
+#include <rtl/ustring.hxx>
+
+#include <map>
+
+
+namespace com { namespace sun { namespace star {
+ namespace rdf { class XBlankNode; }
+ namespace rdf { class XMetadatable; }
+ namespace rdf { class XDocumentRepository; }
+} } }
+
+class SvXMLExport;
+
+namespace xmloff {
+
+class SAL_DLLPRIVATE RDFaExportHelper
+{
+private:
+ SvXMLExport & m_rExport;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::rdf::XDocumentRepository> m_xRepository;
+
+ ::rtl::OUString m_RDFsLabel;
+
+ typedef ::std::map< ::rtl::OUString, ::rtl::OUString >
+ BlankNodeMap_t;
+
+ BlankNodeMap_t m_BlankNodeMap;
+
+ long m_Counter;
+
+ ::rtl::OUString
+ LookupBlankNode( ::com::sun::star::uno::Reference<
+ ::com::sun::star::rdf::XBlankNode> const & i_xBlankNode);
+
+public:
+ RDFaExportHelper(SvXMLExport & i_rExport);
+
+ void
+ AddRDFa(::com::sun::star::uno::Reference<
+ ::com::sun::star::rdf::XMetadatable> const & i_xMetadatable);
+};
+
+} // namespace xmloff
+
+#endif // RDFAEXPORTHELPER_HXX
+
diff --git a/xmloff/inc/RDFaImportHelper.hxx b/xmloff/inc/RDFaImportHelper.hxx
new file mode 100644
index 000000000000..c038917597c8
--- /dev/null
+++ b/xmloff/inc/RDFaImportHelper.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RDFaImportHelper.hxx,v $
+ * $Revision: 1.1.2.1 $
+ *
+ * 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 RDFAIMPORTHELPER_HXX
+#define RDFAIMPORTHELPER_HXX
+
+#include <com/sun/star/uno/Reference.h>
+
+#include <vector>
+
+
+namespace rtl { class OUString; }
+
+namespace com { namespace sun { namespace star {
+ namespace uno { class XComponentContext; }
+ namespace rdf { class XMetadatable; }
+ namespace rdf { class XRepositorySupplier; }
+} } }
+
+class SvXMLImport;
+
+namespace xmloff {
+
+struct RDFaEntry;
+
+class SAL_DLLPRIVATE RDFaImportHelper
+{
+
+private:
+ const SvXMLImport & m_rImport;
+
+ typedef ::std::vector< RDFaEntry > RDFaEntries_t;
+
+ RDFaEntries_t m_RDFaEntries;
+
+ const SvXMLImport & GetImport() const { return m_rImport; }
+
+
+public:
+ RDFaImportHelper(const SvXMLImport & i_rImport);
+
+ ~RDFaImportHelper();
+
+ /** Add a RDFa statement; parameters are XML attribute values */
+ void AddRDFa(
+ ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable>
+ i_xObject,
+ ::rtl::OUString const & i_rAbout,
+ ::rtl::OUString const & i_rProperty,
+ ::rtl::OUString const & i_rContent,
+ ::rtl::OUString const & i_rDatatype);
+
+ /** Insert all added statements into the RDF repository.
+ <p> This is done <em>after</em> the input file has been read,
+ to prevent collision between generated ids and ids in the file.</p>
+ */
+ void InsertRDFa( ::com::sun::star::uno::Reference<
+ ::com::sun::star::rdf::XRepositorySupplier > const & i_xModel);
+};
+
+} // namespace xmloff
+
+#endif // RDFAIMPORTHELPER_HXX
+
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 2267452d93e7..ebecb4d19bb5 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -102,6 +102,7 @@ enum SchXMLAxisElemTokenMap
enum SchXMLChartAttrMap
{
+ XML_TOK_CHART_HREF,
XML_TOK_CHART_CLASS,
XML_TOK_CHART_WIDTH,
XML_TOK_CHART_HEIGHT,
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx
index 4355e249d649..15062560da24 100644
--- a/xmloff/inc/txtflde.hxx
+++ b/xmloff/inc/txtflde.hxx
@@ -38,9 +38,7 @@
#include <com/sun/star/uno/Reference.h>
#include "xmlnmspe.hxx"
-#ifndef _RTL_USTRING
#include <rtl/ustring.hxx>
-#endif
#include <xmloff/xmltoken.hxx>
#include <map>
@@ -148,6 +146,8 @@ enum FieldIdEnum {
FIELD_ID_COMBINED_CHARACTERS, // combined characters (asian typography)
+ FIELD_ID_META, // text:meta-field (RDF metadata)
+
FIELD_ID_MEASURE, // for measure shapes
FIELD_ID_TABLE_FORMULA, // DEPRECATED: table formulas (Writer 2.0)
@@ -182,14 +182,16 @@ public:
/// Export this field and the surrounding span element with the formatting.
/// To be called for every field in the document body.
void ExportField(const ::com::sun::star::uno::Reference <
- ::com::sun::star::text::XTextField > & rTextField );
+ ::com::sun::star::text::XTextField > & rTextField,
+ sal_Bool bProgress );
/// collect styles (character styles, data styles, ...) for this field
/// (if appropriate).
/// Also collect used field masters (if pUsedMasters is set)
/// to be called for every field during style export.
void ExportFieldAutoStyle(const ::com::sun::star::uno::Reference <
- ::com::sun::star::text::XTextField > & rTextField );
+ ::com::sun::star::text::XTextField > & rTextField,
+ sal_Bool bProgress );
/// export field declarations.
/// to be called once at beginning of document body.
@@ -239,7 +241,8 @@ protected:
::com::sun::star::beans::XPropertySet> & rPropSet,
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet> & rRangePropSet,
- enum FieldIdEnum nToken);
+ enum FieldIdEnum nToken,
+ sal_Bool bProgress );
/// export an empty element
void ExportElement(enum ::xmloff::token::XMLTokenEnum eElement, /// element token
@@ -257,6 +260,11 @@ protected:
::com::sun::star::beans::XPropertySet> & rPropSet,
const ::rtl::OUString& rContent);
+ /// export text:meta-field (RDF metadata)
+ void ExportMetaField( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet> & i_xMeta,
+ bool i_bAutoStyles, sal_Bool i_bProgress );
+
/// export a boolean attribute
void ProcessBoolean(
enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
diff --git a/xmloff/inc/xmlkywd.hxx b/xmloff/inc/xmlkywd.hxx
index c228ed26eb41..e0bd8868f181 100644
--- a/xmloff/inc/xmlkywd.hxx
+++ b/xmloff/inc/xmlkywd.hxx
@@ -1991,4 +1991,11 @@ XML_CONSTASCII_ACTION( sXML_readonly, "readonly" );
XML_CONSTASCII_ACTION( sXML_page_continuation, "page-continuation" );
+XML_CONSTASCII_ACTION( sXML_contains, "contains" );
+XML_CONSTASCII_ACTION( sXML_does_not_contain, "does-not-contain" );
+XML_CONSTASCII_ACTION( sXML_begins_with, "begins-with" );
+XML_CONSTASCII_ACTION( sXML_does_not_begin_with, "does-not-begin-with" );
+XML_CONSTASCII_ACTION( sXML_ends_with, "ends-with" );
+XML_CONSTASCII_ACTION( sXML_does_not_end_with, "does-not-end-with" );
+
#endif
diff --git a/xmloff/inc/xmlnmspe.hxx b/xmloff/inc/xmlnmspe.hxx
index 82e62cab6ab9..a79890f19a7d 100644
--- a/xmloff/inc/xmlnmspe.hxx
+++ b/xmloff/inc/xmlnmspe.hxx
@@ -79,9 +79,10 @@ XML_NAMESPACE( ANIMATION, 31U )
XML_NAMESPACE( XML, 32U )
XML_NAMESPACE( REPORT, 33U )
XML_NAMESPACE( OF, 34U ) // OpenFormula aka ODFF
-XML_NAMESPACE( RDFA, 35U )
+XML_NAMESPACE( XHTML, 35U )
+XML_NAMESPACE( GRDDL, 36U )
-#define _XML_OLD_NAMESPACE_BASE 36U
+#define _XML_OLD_NAMESPACE_BASE 37U
// namespaces used in the technical preview (SO 5.2)
XML_OLD_NAMESPACE( FO, 0U )
diff --git a/xmloff/inc/xmloff/SchXMLExportHelper.hxx b/xmloff/inc/xmloff/SchXMLExportHelper.hxx
index b886e499d329..2082ce59de03 100644
--- a/xmloff/inc/xmloff/SchXMLExportHelper.hxx
+++ b/xmloff/inc/xmloff/SchXMLExportHelper.hxx
@@ -233,13 +233,6 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc );
- // if no data provider exists by, now the model (as XChild) is asked for its
- // parent which creates the data provider that is finally set at the chart
- // document
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- GetDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument > & xChartDoc );
-
::com::sun::star::awt::Size getPageSize(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc ) const;
diff --git a/xmloff/inc/xmloff/SchXMLImportHelper.hxx b/xmloff/inc/xmloff/SchXMLImportHelper.hxx
index 0b8df9580e9e..d62368739c8a 100644
--- a/xmloff/inc/xmloff/SchXMLImportHelper.hxx
+++ b/xmloff/inc/xmloff/SchXMLImportHelper.hxx
@@ -143,13 +143,6 @@ public:
sal_Int32 GetLengthOfSeries();
void ResizeChartData( sal_Int32 nSeries, sal_Int32 nDataPoints = -1 );
- // if no data provider exists by, now the model (as XChild) is asked for its
- // parent which creates the data provider that is finally set at the chart
- // document
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- GetDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument > & xChartDoc );
-
/** @param bPushLastChartType If </FALSE>, in case a new chart type has to
be added (because it does not exist yet), it is appended at the
end of the chart-type container. When </TRUE>, a new chart type
diff --git a/xmloff/inc/xmloff/table/XMLTableExport.hxx b/xmloff/inc/xmloff/table/XMLTableExport.hxx
index cca3ff29d33b..028166358069 100644
--- a/xmloff/inc/xmloff/table/XMLTableExport.hxx
+++ b/xmloff/inc/xmloff/table/XMLTableExport.hxx
@@ -75,7 +75,7 @@ typedef ::std::map< const ::com::sun::star::uno::Reference< com::sun::star::tabl
class XMLOFF_DLLPUBLIC XMLTableExport : public UniRefBase
{
public:
- XMLTableExport(SvXMLExport& rExp, const rtl::Reference< XMLPropertySetMapper >& xCellPropertySetMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef );
+ XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExportPropertyMapper >& xCellExportPropertySetMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef );
virtual ~XMLTableExport();
// This method collects all automatic styles for the given table
diff --git a/xmloff/inc/xmloff/txtimp.hxx b/xmloff/inc/xmloff/txtimp.hxx
index fa81e97defeb..7e041d0bdc91 100644
--- a/xmloff/inc/xmloff/txtimp.hxx
+++ b/xmloff/inc/xmloff/txtimp.hxx
@@ -253,6 +253,10 @@ enum XMLTextPElemTokens
enum XMLTextPAttrTokens
{
XML_TOK_TEXT_P_XMLID,
+ XML_TOK_TEXT_P_ABOUT,
+ XML_TOK_TEXT_P_PROPERTY,
+ XML_TOK_TEXT_P_CONTENT,
+ XML_TOK_TEXT_P_DATATYPE,
XML_TOK_TEXT_P_STYLE_NAME,
XML_TOK_TEXT_P_COND_STYLE_NAME,
XML_TOK_TEXT_P_LEVEL,
diff --git a/xmloff/inc/xmloff/txtparae.hxx b/xmloff/inc/xmloff/txtparae.hxx
index 37da59a1df76..a7c7df50ee64 100644
--- a/xmloff/inc/xmloff/txtparae.hxx
+++ b/xmloff/inc/xmloff/txtparae.hxx
@@ -38,9 +38,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <xmloff/uniref.hxx>
#include <xmloff/xmlexppr.hxx>
-#ifndef _XMLOFF_STYLEEXP_HXX
#include <xmloff/styleexp.hxx>
-#endif
#include <xmloff/xmltoken.hxx>
#include <xmloff/SinglePropertySetInfoCache.hxx>
#include <xmloff/XMLStringVector.hxx>
@@ -125,7 +123,11 @@ class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public XMLStyleExport
protected:
const ::rtl::OUString sActualSize;
- const ::rtl::OUString sAlternativeText;
+ // --> OD 2009-07-22 #i73249#
+// const ::rtl::OUString sAlternativeText;
+ const ::rtl::OUString sTitle;
+ const ::rtl::OUString sDescription;
+ // <--
const ::rtl::OUString sAnchorCharStyleName;
const ::rtl::OUString sAnchorPageNo;
const ::rtl::OUString sAnchorType;
@@ -264,6 +266,12 @@ public:
const ::com::sun::star::uno::Reference <
::com::sun::star::beans::XPropertySetInfo > & rPropSetInfo );
+ void exportTextRangeEnumeration(
+ const ::com::sun::star::uno::Reference <
+ ::com::sun::star::container::XEnumeration > & rRangeEnum,
+ sal_Bool bAutoStyles, sal_Bool bProgress,
+ sal_Bool bPrvChrIsSpc = sal_True );
+
protected:
sal_Int32 addTextFrameAttributes(
@@ -316,16 +324,11 @@ protected:
const ::com::sun::star::uno::Reference <
::com::sun::star::text::XTextContent > & rTextContent,
sal_Bool bAutoStyles, sal_Bool bProgress );
- void exportTextRangeEnumeration(
- const ::com::sun::star::uno::Reference <
- ::com::sun::star::container::XEnumeration > & rRangeEnum,
- sal_Bool bAutoStyles, sal_Bool bProgress,
- sal_Bool bPrvChrIsSpc = sal_True );
void exportTextField(
const ::com::sun::star::uno::Reference <
::com::sun::star::text::XTextRange > & rTextRange,
- sal_Bool bAutoStyles );
+ sal_Bool bAutoStyles, sal_Bool bProgress );
void exportAnyTextFrame(
const ::com::sun::star::uno::Reference <
@@ -484,6 +487,12 @@ protected:
::com::sun::star::beans::XPropertySet> & rPortionPropSet,
sal_Bool bAutoStyles );
+ /// export a text:meta
+ void exportMeta(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet> & i_xMeta,
+ sal_Bool i_bAutoStyles, sal_Bool i_isProgress );
+
public:
XMLTextParagraphExport(
@@ -600,8 +609,12 @@ public:
virtual void exportTextAutoStyles();
void exportEvents( const ::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > & rPropSet );
- void exportAlternativeText( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & rPropSet,
- const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > & rPropSetInfo );
+ // --> OD 2009-07-22 #i73249#
+// void exportAlternativeText( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & rPropSet,
+// const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > & rPropSetInfo );
+ void exportTitleAndDescription( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & rPropSet,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > & rPropSetInfo );
+ // <--
// This method exports the given XText
void exportText(
diff --git a/xmloff/inc/xmloff/txtprmap.hxx b/xmloff/inc/xmloff/txtprmap.hxx
index 12a39ba952fb..ddf420176c57 100644
--- a/xmloff/inc/xmloff/txtprmap.hxx
+++ b/xmloff/inc/xmloff/txtprmap.hxx
@@ -71,7 +71,7 @@
#define CTF_FONTFAMILY (XML_TEXT_CTF_START + 36)
#define CTF_FONTPITCH (XML_TEXT_CTF_START + 37)
#define CTF_FONTCHARSET (XML_TEXT_CTF_START + 38)
-// (XML_TEXT_CTF_START + 39)
+#define CTF_TEXTWRITINGMODE (XML_TEXT_CTF_START + 39)
#define CTF_SYNCHEIGHT_MIN (XML_TEXT_CTF_START + 40)
#define CTF_FRAMEHEIGHT_ABS (XML_TEXT_CTF_START + 41)
#define CTF_FRAMEHEIGHT_REL (XML_TEXT_CTF_START + 42)
diff --git a/xmloff/inc/xmloff/xmlexp.hxx b/xmloff/inc/xmloff/xmlexp.hxx
index 95ceb1712423..276627e80354 100644
--- a/xmloff/inc/xmloff/xmlexp.hxx
+++ b/xmloff/inc/xmloff/xmlexp.hxx
@@ -92,6 +92,7 @@ class XMLErrors;
namespace rtl { class OUString; }
namespace com { namespace sun { namespace star {
+ namespace uno { class XComponentContext; }
namespace frame { class XModel; }
namespace container { class XIndexContainer; }
} } }
@@ -362,6 +363,22 @@ public:
// XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ /** ensures that the given namespace is in scope at the next started
+ element.
+
+ <p>If the namespace is not yet declared, the necessary attribute will
+ be added, as well.</p>
+
+ @param i_rNamespace the namespace to be declared
+ @param i_rPreferredPrefix (opt.) preferred prefix for the namespace
+
+ @returns the actual prefix that the namespace is associated with
+ */
+ ::rtl::OUString
+ EnsureNamespace(::rtl::OUString const & i_rNamespace,
+ ::rtl::OUString const & i_rPreferredPrefix
+ = ::rtl::OUString::createFromAscii("gen") );
+
// Check if common attribute list is empty.
#ifndef DBG_UTIL
void CheckAttrList() {}
@@ -553,6 +570,9 @@ public:
// #110680#
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceFactory();
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ GetComponentContext() const;
+
// --> OD 2006-03-10 #i51726#
SvtModuleOptions::EFactory GetModelType() const
{
@@ -570,13 +590,17 @@ public:
/// returns the currently configured default version for odf export
SvtSaveOptions::ODFDefaultVersion getDefaultVersion() const;
- /// relative path of stream in package, e.g. "someobject/content.xml"
- ::rtl::OUString GetStreamPath() const;
+ /// name of stream in package, e.g., "content.xml"
+ ::rtl::OUString GetStreamName() const;
/// add xml:id attribute (for RDF metadata)
void AddAttributeXmlId(::com::sun::star::uno::Reference<
::com::sun::star::uno::XInterface> const & i_xIfc);
+ /// add RDFa attributes for a metadatable text content
+ void AddAttributesRDFa( ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextContent> const & i_xTextContent);
+
// --> OD 2008-11-26 #158694#
sal_Bool exportTextNumberElement() const;
// <--
diff --git a/xmloff/inc/xmloff/xmlimp.hxx b/xmloff/inc/xmloff/xmlimp.hxx
index e496b34d79f2..717f117be415 100644
--- a/xmloff/inc/xmloff/xmlimp.hxx
+++ b/xmloff/inc/xmloff/xmlimp.hxx
@@ -61,8 +61,10 @@
namespace rtl { class OUString; }
namespace com { namespace sun { namespace star {
+ namespace uno { class XComponentContext; }
namespace frame { class XModel; }
namespace io { class XOutputStream; }
+ namespace rdf { class XMetadatable; }
} } }
namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
@@ -346,7 +348,7 @@ public:
sal_uInt16 getImportFlags() const { return mnImportFlags; }
sal_Bool IsFormsSupported() const { return mbIsFormsSupported; }
- rtl::OUString GetAbsoluteReference(const rtl::OUString& rValue);
+ rtl::OUString GetAbsoluteReference(const rtl::OUString& rValue) const;
sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
@@ -400,6 +402,9 @@ public:
// #110680#
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceFactory();
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ GetComponentContext() const;
+
// --> OD 2004-08-10 #i28749#
sal_Bool IsShapePositionInHoriL2R() const;
// <--
@@ -411,14 +416,23 @@ public:
String GetBaseURL() const;
String GetDocumentBase() const;
- /// relative path of stream in package, e.g. "someobject/content.xml"
- ::rtl::OUString GetStreamPath() const;
+ /// name of stream in package, e.g., "content.xml"
+ ::rtl::OUString GetStreamName() const;
/// set the XmlId attribute of given UNO object (for RDF metadata)
void SetXmlId(::com::sun::star::uno::Reference<
::com::sun::star::uno::XInterface> const & i_xIfc,
::rtl::OUString const & i_rXmlId);
+ /// Add a RDFa statement; parameters are XML attribute values
+ void AddRDFa(
+ ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable>
+ i_xObject,
+ ::rtl::OUString const & i_rAbout,
+ ::rtl::OUString const & i_rProperty,
+ ::rtl::OUString const & i_rContent,
+ ::rtl::OUString const & i_rDatatype);
+
// #i31958# XForms helper method
// (to be implemented by applications suporting XForms)
virtual void initXForms();
diff --git a/xmloff/inc/xmloff/xmlimppr.hxx b/xmloff/inc/xmloff/xmlimppr.hxx
index ff6d167e737c..4bf1a9865c85 100644
--- a/xmloff/inc/xmloff/xmlimppr.hxx
+++ b/xmloff/inc/xmloff/xmlimppr.hxx
@@ -80,6 +80,7 @@ class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper : public UniRefBase
protected:
UniReference< XMLPropertySetMapper > maPropMapper;
+ SvXMLImport& GetImport() const { return rImport;}
public:
diff --git a/xmloff/inc/xmloff/xmlmetai.hxx b/xmloff/inc/xmloff/xmlmetai.hxx
index 9423b7424b73..7cc1c6b054ec 100644
--- a/xmloff/inc/xmloff/xmlmetai.hxx
+++ b/xmloff/inc/xmloff/xmlmetai.hxx
@@ -35,6 +35,7 @@
#include "xmloff/dllapi.h"
#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
@@ -76,6 +77,10 @@ protected:
void initDocumentProperties();
// set the BuildId property at the importer
void setBuildId(const ::rtl::OUString & i_rBuildId);
+
+public:
+ static void setBuildId(const ::rtl::OUString & rGenerator,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xImportInfo );
};
#endif // _XMLOFF_XMLMETAI_HXX
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index 120a6be84e7a..66abd40a44f4 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -138,9 +138,11 @@ namespace xmloff { namespace token {
XML_NP_OF,
XML_N_OF,
- // ODF 1.2 metadata: RDFa
- XML_NP_RDFA,
- XML_N_RDFA,
+ // ODF 1.2 metadata: RDFa and GRDDL
+ XML_NP_XHTML,
+ XML_N_XHTML,
+ XML_NP_GRDDL,
+ XML_N_GRDDL,
// units
XML_UNIT_MM,
@@ -3041,6 +3043,7 @@ namespace xmloff { namespace token {
XML_META_FIELD,
XML_ABOUT,
XML_DATATYPE,
+ XML_TRANSFORMATION,
// ODF 1.2 numbered-paragraph
XML_LIST_ID,
@@ -3071,6 +3074,7 @@ namespace xmloff { namespace token {
XML_AT_LABELS,
XML_AT_AXIS,
XML_AT_LABELS_AND_AXIS,
+ XML_FILLED_RADAR,
// MathML only
XML_MATHVARIANT,
@@ -3078,6 +3082,13 @@ namespace xmloff { namespace token {
XML_MATHWEIGHT,
XML_MATHCOLOR,
+ XML_CONTAINS,
+ XML_DOES_NOT_CONTAIN,
+ XML_BEGINS_WITH,
+ XML_DOES_NOT_BEGIN_WITH,
+ XML_ENDS_WITH,
+ XML_DOES_NOT_END_WITH,
+
XML_TOKEN_END
};
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index d6072560297a..d103876b9350 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -228,6 +228,57 @@ void lcl_removeEmptyChartTypeGroups( const uno::Reference< chart2::XChartDocumen
}
}
+uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex )
+{
+ const sal_Unicode aSpace( ' ' );
+
+ // count number of entries
+ ::std::vector< sal_Int32 > aVec;
+ sal_Int32 nLastPos = 0;
+ sal_Int32 nPos = 0;
+ while( nPos != -1 )
+ {
+ nPos = rStr.indexOf( aSpace, nLastPos );
+ if( nPos > nLastPos )
+ {
+ aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
+ }
+ if( nPos != -1 )
+ nLastPos = nPos + 1;
+ }
+ // last entry
+ if( nLastPos != 0 &&
+ rStr.getLength() > nLastPos )
+ {
+ aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() );
+ }
+
+ const sal_Int32 nVecSize = aVec.size();
+ uno::Sequence< sal_Int32 > aSeq( nVecSize );
+
+ if(!bAddOneToEachOldIndex)
+ {
+ sal_Int32* pSeqArr = aSeq.getArray();
+ for( nPos = 0; nPos < nVecSize; ++nPos )
+ {
+ pSeqArr[ nPos ] = aVec[ nPos ];
+ }
+ }
+ else if( bAddOneToEachOldIndex )
+ {
+ aSeq.realloc( nVecSize+1 );
+ aSeq[0]=0;
+
+ sal_Int32* pSeqArr = aSeq.getArray();
+ for( nPos = 0; nPos < nVecSize; ++nPos )
+ {
+ pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
+ }
+ }
+
+ return aSeq;
+}
+
} // anonymous namespace
static __FAR_DATA SvXMLEnumMapEntry aXMLLegendAlignmentMap[] =
@@ -249,7 +300,8 @@ SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
mrImportHelper( rImpHelper ),
- mbHasOwnTable( sal_True ),
+ m_bHasRangeAtPlotArea( false ),
+ m_bHasTableElement( false ),
mbAllRangeAddressesAvailable( sal_True ),
mbColHasLabels( sal_False ),
mbRowHasLabels( sal_False ),
@@ -269,7 +321,6 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
awt::Size aChartSize;
// this flag is necessarry for pie charts in the core
sal_Bool bSetSwitchData = sal_False;
- sal_Bool bDomainForDefaultDataNeeded = sal_False;
::rtl::OUString sAutoStyleName;
::rtl::OUString aOldChartTypeName;
@@ -284,6 +335,10 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
{
+ case XML_TOK_CHART_HREF:
+ m_aXLinkHRefAttributeToIndicateDataProvider = aValue;
+ break;
+
case XML_TOK_CHART_CLASS:
{
rtl::OUString sClassName;
@@ -302,15 +357,9 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
case XML_CHART_CLASS_CIRCLE:
bSetSwitchData = sal_True;
break;
- case XML_CHART_CLASS_SCATTER:
- bDomainForDefaultDataNeeded = sal_True;
- break;
case XML_CHART_CLASS_STOCK:
mbIsStockChart = true;
break;
- case XML_CHART_CLASS_BUBBLE:
- DBG_ERROR( "Bubble chart not supported yet" );
- break;
default:
break;
}
@@ -321,10 +370,6 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
// service is taken from add-in-name attribute
bHasAddin = true;
- // for service charts assume domain in base type
- // if base type doesn't use a domain this is ok,
- // the data just grows bigger
- bDomainForDefaultDataNeeded = sal_True;
aOldChartTypeName = sClassName;
maChartTypeServiceName = sClassName;
}
@@ -361,7 +406,7 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
maChartTypeServiceName = SchXMLTools::GetChartTypeByClassName( aChartClass_Bar, false /* bUseOldNames */ );
}
- InitChart (aChartSize, bDomainForDefaultDataNeeded, aOldChartTypeName, bSetSwitchData);
+ InitChart (aChartSize, aOldChartTypeName, bSetSwitchData);
if( bHasAddin )
{
@@ -617,14 +662,21 @@ bool lcl_SpecialHandlingForDonutChartNeeded(
} // anonymous namespace
-void SchXMLChartContext::ChangeDiagramAccordingToTemplate(
- const uno::Reference< chart2::XChartDocument >& xNewDoc )
+
+void lcl_ApplyDataFromRectangularRangeToDiagram(
+ const uno::Reference< chart2::XChartDocument >& xNewDoc
+ , const rtl::OUString& rRectangularRange
+ , ::com::sun::star::chart::ChartDataRowSource eDataRowSource
+ , bool bRowHasLabels, bool bColHasLabels
+ , bool bSwitchOnLabelsAndCategoriesForOwnData
+ , const rtl::OUString& sColTrans
+ , const rtl::OUString& sRowTrans )
{
if( !xNewDoc.is() )
return;
uno::Reference< chart2::XDiagram > xNewDia( xNewDoc->getFirstDiagram());
- uno::Reference< chart2::data::XDataProvider > xDataProvider( mrImportHelper.GetDataProvider( xNewDoc ) );
+ uno::Reference< chart2::data::XDataProvider > xDataProvider( xNewDoc->getDataProvider() );
if( !xNewDia.is() || !xDataProvider.is() )
return;
@@ -633,11 +685,11 @@ void SchXMLChartContext::ChangeDiagramAccordingToTemplate(
return;
sal_Bool bFirstCellAsLabel =
- (meDataRowSource==chart::ChartDataRowSource_COLUMNS)? mbRowHasLabels : mbColHasLabels;
+ (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels;
sal_Bool bHasCateories =
- (meDataRowSource==chart::ChartDataRowSource_COLUMNS)? mbColHasLabels : mbRowHasLabels;
+ (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bColHasLabels : bRowHasLabels;
- if( mbHasOwnTable )
+ if( bSwitchOnLabelsAndCategoriesForOwnData )
{
bFirstCellAsLabel = true;
bHasCateories = true;
@@ -646,25 +698,25 @@ void SchXMLChartContext::ChangeDiagramAccordingToTemplate(
uno::Sequence< beans::PropertyValue > aArgs( 3 );
aArgs[0] = beans::PropertyValue(
::rtl::OUString::createFromAscii("CellRangeRepresentation"),
- -1, uno::makeAny( msChartAddress ),
+ -1, uno::makeAny( rRectangularRange ),
beans::PropertyState_DIRECT_VALUE );
aArgs[1] = beans::PropertyValue(
::rtl::OUString::createFromAscii("DataRowSource"),
- -1, uno::makeAny( meDataRowSource ),
+ -1, uno::makeAny( eDataRowSource ),
beans::PropertyState_DIRECT_VALUE );
aArgs[2] = beans::PropertyValue(
::rtl::OUString::createFromAscii("FirstCellAsLabel"),
-1, uno::makeAny( bFirstCellAsLabel ),
beans::PropertyState_DIRECT_VALUE );
- if( msColTrans.getLength() || msRowTrans.getLength() )
+ if( sColTrans.getLength() || sRowTrans.getLength() )
{
aArgs.realloc( aArgs.getLength() + 1 );
aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue(
::rtl::OUString::createFromAscii("SequenceMapping"),
- -1, uno::makeAny( msColTrans.getLength()
- ? GetNumberSequenceFromString( msColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
- : GetNumberSequenceFromString( msRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
+ -1, uno::makeAny( sColTrans.getLength()
+ ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
+ : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
beans::PropertyState_DIRECT_VALUE );
}
@@ -777,21 +829,36 @@ void SchXMLChartContext::EndElement()
if(!xNewDoc.is())
return;
- // if we already have an internal data provider, we know that we cannot have
- // external data here. If we can have external data but know that we have
- // internal data due to missing ranges, we must create an internal data
- // provider
+ bool bHasOwnData = false;
+ if( m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
+ bHasOwnData = true;
+ else if( m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
+ bHasOwnData = false;
+ else if( m_aXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself if data are available
+ bHasOwnData = m_bHasTableElement;
+ else
+ bHasOwnData = !m_bHasRangeAtPlotArea;
+
if( xNewDoc->hasInternalDataProvider())
- mbHasOwnTable = true;
- else if( mbHasOwnTable )
+ {
+ if( !m_bHasTableElement && !m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) )
+ {
+ //#i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area
+ bool bSwitchSuccessful = SchXMLTools::switchBackToDataProviderFromParent( xNewDoc, maLSequencesPerIndex );
+ bHasOwnData = !bSwitchSuccessful;
+ }
+ else
+ bHasOwnData = true;//e.g. in case of copy->paste from calc to impress
+ }
+ else if( bHasOwnData )
{
xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
}
- if( mbHasOwnTable )
+ if( bHasOwnData )
msChartAddress = ::rtl::OUString::createFromAscii("all");
- bool bPostProcessTable = false;
- if( !mbHasOwnTable && mbAllRangeAddressesAvailable )
+ bool bSwitchRangesFromOuterToInternalIfNecessary = false;
+ if( !bHasOwnData && mbAllRangeAddressesAvailable )
{
// special handling for stock chart (merge series together)
if( mbIsStockChart )
@@ -799,24 +866,28 @@ void SchXMLChartContext::EndElement()
}
else if( msChartAddress.getLength() )
{
- // in this case there are range addresses that are simply wrong.
+ //own data or only rectangular range available
+
bool bOlderThan2_3 = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( Reference< frame::XModel >( xNewDoc, uno::UNO_QUERY ));
- bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && mbHasOwnTable && (meDataRowSource==chart::ChartDataRowSource_ROWS));
+ bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (meDataRowSource==chart::ChartDataRowSource_ROWS)); // in this case there are range addresses that are simply wrong.
+
if( mbAllRangeAddressesAvailable && !bSpecialHandlingForDonutChart && !mbIsStockChart &&
!bOldFileWithOwnDataFromRows )
{
- // note: mbRowHasLabels means the first row contains labels, that
- // means we have "column-descriptions", (analogously mbColHasLabels
- // means we have "row-descriptions")
- SchXMLTableHelper::applyTable( maTable, xNewDoc );
- bPostProcessTable = true;
+ //bHasOwnData is true in this case!
+ //e.g. for normal files with own data or also in case of copy paste scenario (e.g. calc to impress)
+ if( xNewDoc->hasInternalDataProvider() )
+ SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
+ bSwitchRangesFromOuterToInternalIfNecessary = true;
}
else
{
+ //apply data from rectangular range
+
// apply data read from the table sub-element to the chart
// if the data provider supports the XChartDataArray interface like
// the internal data provider
- uno::Reference< chart::XChartDataArray > xChartData( mrImportHelper.GetDataProvider( xNewDoc ), uno::UNO_QUERY );
+ uno::Reference< chart::XChartDataArray > xChartData( xNewDoc->getDataProvider(), uno::UNO_QUERY );
if( xChartData.is())
SchXMLTableHelper::applyTableSimple( maTable, xChartData );
@@ -826,29 +897,32 @@ void SchXMLChartContext::EndElement()
{
if( bOlderThan2_3 && xDiaProp.is() )//for older charts the hidden cells were removed by calc on the fly
xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IncludeHiddenCells")),uno::makeAny(false));
- ChangeDiagramAccordingToTemplate( xNewDoc );
+
+ // note: mbRowHasLabels means the first row contains labels, that means we have "column-descriptions",
+ // (analogously mbColHasLabels means we have "row-descriptions")
+ lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
}
catch( uno::Exception & )
{
//try to fallback to internal data
- DBG_ERROR( "Exception during import SchXMLChartContext::ChangeDiagramAccordingToTemplate try to fallback to internal data" );
- if(!mbHasOwnTable)
+ DBG_ERROR( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram try to fallback to internal data" );
+ if(!bHasOwnData)
{
- mbHasOwnTable = true;
+ bHasOwnData = true;
msChartAddress = ::rtl::OUString::createFromAscii("all");
if( !xNewDoc->hasInternalDataProvider() )
{
xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
- xChartData = uno::Reference< chart::XChartDataArray >( mrImportHelper.GetDataProvider( xNewDoc ), uno::UNO_QUERY );
+ xChartData = uno::Reference< chart::XChartDataArray >( xNewDoc->getDataProvider(), uno::UNO_QUERY );
if( xChartData.is())
SchXMLTableHelper::applyTableSimple( maTable, xChartData );
try
{
- ChangeDiagramAccordingToTemplate( xNewDoc );
+ lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
}
catch( uno::Exception & )
{
- DBG_ERROR( "Exception during import SchXMLChartContext::ChangeDiagramAccordingToTemplate fallback to internal data failed also" );
+ DBG_ERROR( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram fallback to internal data failed also" );
}
}
}
@@ -904,16 +978,23 @@ void SchXMLChartContext::EndElement()
SchXMLSeries2Context::setStylesToStatisticsObjects( maSeriesDefaultsAndStyles
, pStylesCtxt, pStyle, sCurrStyleName );
}
+ }
+
+ //#i98319# call switchRangesFromOuterToInternalIfNecessary before the data point styles are applied, otherwise in copy->paste scenario the data point styles do get lost
+ if( bSwitchRangesFromOuterToInternalIfNecessary )
+ {
+ if( xNewDoc->hasInternalDataProvider() )
+ SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( maTable, maLSequencesPerIndex, xNewDoc, meDataRowSource );
+ }
+ if( pStylesCtxt )
+ {
// ... then iterate over data-point attributes, so the latter are not overwritten
SchXMLSeries2Context::setStylesToDataPoints( maSeriesDefaultsAndStyles
, pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, bSpecialHandlingForDonutChart, bSwitchOffLinesForScatter );
}
}
- if( bPostProcessTable )
- SchXMLTableHelper::postProcessTable( maTable, maLSequencesPerIndex, xNewDoc, meDataRowSource );
-
if( xProp.is())
xProp->setPropertyValue( rtl::OUString::createFromAscii( "RefreshAddInAllowed" ) , uno::makeAny( sal_True) );
}
@@ -1014,8 +1095,9 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
{
case XML_TOK_CHART_PLOT_AREA:
pContext = new SchXMLPlotAreaContext( mrImportHelper, GetImport(), rLocalName,
+ m_aXLinkHRefAttributeToIndicateDataProvider,
maSeriesAddresses, msCategoriesAddress,
- msChartAddress, mbHasOwnTable, mbAllRangeAddressesAvailable,
+ msChartAddress, m_bHasRangeAtPlotArea, mbAllRangeAddressesAvailable,
mbColHasLabels, mbRowHasLabels,
meDataRowSource,
maSeriesDefaultsAndStyles,
@@ -1057,6 +1139,7 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
{
SchXMLTableContext * pTableContext =
new SchXMLTableContext( mrImportHelper, GetImport(), rLocalName, maTable );
+ m_bHasTableElement = true;
// #i85913# take into account column- and row- mapping for
// charts with own data only for those which were not copied
// from a place where they got data from the container. Note,
@@ -1071,12 +1154,12 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
if( msColTrans.getLength() > 0 )
{
OSL_ASSERT( msRowTrans.getLength() == 0 );
- pTableContext->setColumnPermutation( GetNumberSequenceFromString( msColTrans, true ));
+ pTableContext->setColumnPermutation( lcl_getNumberSequenceFromString( msColTrans, true ));
msColTrans = OUString();
}
else if( msRowTrans.getLength() > 0 )
{
- pTableContext->setRowPermutation( GetNumberSequenceFromString( msRowTrans, true ));
+ pTableContext->setRowPermutation( lcl_getNumberSequenceFromString( msRowTrans, true ));
msRowTrans = OUString();
}
}
@@ -1116,7 +1199,6 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
*/
void SchXMLChartContext::InitChart(
awt::Size aChartSize,
- sal_Bool /* bDomainForDefaultDataNeeded */,
const OUString & rChartTypeServiceName, // currently the old service name
sal_Bool /* bSetSwitchData */ )
{
@@ -1155,57 +1237,6 @@ void SchXMLChartContext::InitChart(
}
}
-uno::Sequence< sal_Int32 > SchXMLChartContext::GetNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex )
-{
- const sal_Unicode aSpace( ' ' );
-
- // count number of entries
- ::std::vector< sal_Int32 > aVec;
- sal_Int32 nLastPos = 0;
- sal_Int32 nPos = 0;
- while( nPos != -1 )
- {
- nPos = rStr.indexOf( aSpace, nLastPos );
- if( nPos > nLastPos )
- {
- aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
- }
- if( nPos != -1 )
- nLastPos = nPos + 1;
- }
- // last entry
- if( nLastPos != 0 &&
- rStr.getLength() > nLastPos )
- {
- aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() );
- }
-
- const sal_Int32 nVecSize = aVec.size();
- uno::Sequence< sal_Int32 > aSeq( nVecSize );
-
- if(!bAddOneToEachOldIndex)
- {
- sal_Int32* pSeqArr = aSeq.getArray();
- for( nPos = 0; nPos < nVecSize; ++nPos )
- {
- pSeqArr[ nPos ] = aVec[ nPos ];
- }
- }
- else if( bAddOneToEachOldIndex )
- {
- aSeq.realloc( nVecSize+1 );
- aSeq[0]=0;
-
- sal_Int32* pSeqArr = aSeq.getArray();
- for( nPos = 0; nPos < nVecSize; ++nPos )
- {
- pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
- }
- }
-
- return aSeq;
-}
-
// ----------------------------------------
SchXMLTitleContext::SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
index 596646e6b35a..c02f623ebe10 100644
--- a/xmloff/source/chart/SchXMLChartContext.hxx
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -114,7 +114,9 @@ private:
::rtl::OUString maMainTitle, maSubTitle;
com::sun::star::awt::Point maMainTitlePos, maSubTitlePos, maLegendPos;
- sal_Bool mbHasOwnTable;
+ ::rtl::OUString m_aXLinkHRefAttributeToIndicateDataProvider;
+ bool m_bHasRangeAtPlotArea;
+ bool m_bHasTableElement;
sal_Bool mbAllRangeAddressesAvailable;
sal_Bool mbColHasLabels;
sal_Bool mbRowHasLabels;
@@ -139,20 +141,14 @@ private:
a locked controller. This includes setting the draw page size and setting
the chart type.
@param aChartSize The size the draw page will be set to.
- @param bDomainForDefaultDataNeeded This flag indicates wether the chart's data set
- has to contain a domain value.
@param aServiceName The name of the service the diagram is initialized with.
@param bSetWitchData Indicates wether the data set takes it's data series from
rows or from columns.
*/
void InitChart (com::sun::star::awt::Size aChartSize,
- sal_Bool bDomainForDefaultDataNeeded,
const ::rtl::OUString & rChartTypeServiceName,
sal_Bool bSetSwitchData);
- void ChangeDiagramAccordingToTemplate(
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xNewDoc );
- ::com::sun::star::uno::Sequence< sal_Int32 > GetNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex );
void MergeSeriesForStockChart();
};
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 46dd7e3da973..3290cb31db96 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -353,8 +353,10 @@ bool lcl_isSeriesAttachedToFirstAxis(
OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::XChartDocument > & xDoc )
{
OUString aResult = rRange;
+ if( !xDoc.is() )
+ return aResult;
Reference< chart2::data::XRangeXMLConversion > xConversion(
- SchXMLExportHelper::GetDataProvider( xDoc ), uno::UNO_QUERY );
+ xDoc->getDataProvider(), uno::UNO_QUERY );
if( xConversion.is())
aResult = xConversion->convertRangeToXML( rRange );
return aResult;
@@ -837,6 +839,28 @@ void lcl_exportNumberFormat( const OUString& rPropertyName, const Reference< bea
return aResult;
}
+bool lcl_exportDomainForThisSequence( const Reference< chart2::data::XDataSequence > xValues, rtl::OUString& rFirstRangeForThisDomainIndex, SvXMLExport& rExport )
+{
+ bool bDomainExported = false;
+ if( xValues.is())
+ {
+ Reference< chart2::XChartDocument > xNewDoc( rExport.GetModel(), uno::UNO_QUERY );
+ OUString aRange( lcl_ConvertRange( xValues->getSourceRangeRepresentation(), xNewDoc ) );
+
+ //work around error in OOo 2.0 (problems with multiple series having a domain element)
+ if( !rFirstRangeForThisDomainIndex.getLength() || !aRange.equals(rFirstRangeForThisDomainIndex) )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aRange);
+ SvXMLElementExport aDomain( rExport, XML_NAMESPACE_CHART, XML_DOMAIN, sal_True, sal_True );
+ bDomainExported = true;
+ }
+
+ if( !rFirstRangeForThisDomainIndex.getLength() )
+ rFirstRangeForThisDomainIndex = aRange;
+ }
+ return bDomainExported;
+}
+
} // anonymous namespace
struct SchXMLDataPointStruct
@@ -1092,6 +1116,16 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha
if( bExportContent )
{
+ //export data provider in xlink:href attribute
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
+ {
+ OUString aDataProviderURL( RTL_CONSTASCII_USTRINGPARAM( ".." ) );
+ if( xNewDoc->hasInternalDataProvider() )
+ aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aDataProviderURL );
+ }
+
OUString sChartType( xDiagram->getDiagramType() );
// attributes
@@ -2488,7 +2522,8 @@ void SchXMLExportHelper::exportSeries(
return;
Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
- OUString aFirstXRange;
+ OUString aFirstXDomainRange;
+ OUString aFirstYDomainRange;
std::vector< XMLPropertyState > aPropertyStates;
@@ -2537,7 +2572,6 @@ void SchXMLExportHelper::exportSeries(
xSource->getDataSequences());
sal_Int32 nMainSequenceIndex = -1;
sal_Int32 nSeriesLength = 0;
- sal_Int32 nSeqIdx=0;
sal_Int32 nAttachedAxis = chart::ChartAxisAssign::PRIMARY_Y;
sal_Bool bHasMeanValueLine = false;
chart::ChartRegressionCurveType eRegressionType( chart::ChartRegressionCurveType_NONE );
@@ -2550,29 +2584,32 @@ void SchXMLExportHelper::exportSeries(
{
Reference< chart2::data::XDataSequence > xValuesSeq;
Reference< chart2::data::XDataSequence > xLabelSeq;
- for( ;nMainSequenceIndex==-1 && nSeqIdx<aSeqCnt.getLength();
- ++nSeqIdx )
+ sal_Int32 nSeqIdx=0;
+ for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
{
OUString aRole;
Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() );
- Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
- if( xSeqProp.is())
- xSeqProp->getPropertyValue(OUString::createFromAscii("Role")) >>= aRole;
- // "main" sequence
- if( aRole.equals( aLabelRole ))
+ if( nMainSequenceIndex==-1 )
{
- xValuesSeq.set( xTempValueSeq );
- xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
- // "main" sequence attributes exported, now go on with domains
- nMainSequenceIndex = nSeqIdx;
- break;
+ Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
+ if( xSeqProp.is())
+ xSeqProp->getPropertyValue(OUString::createFromAscii("Role")) >>= aRole;
+ // "main" sequence
+ if( aRole.equals( aLabelRole ))
+ {
+ xValuesSeq.set( xTempValueSeq );
+ xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
+ nMainSequenceIndex = nSeqIdx;
+ }
}
+ sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0));
+ if( nSeriesLength < nSequenceLength )
+ nSeriesLength = nSequenceLength;
}
// have found the main sequence, then xValuesSeq and
// xLabelSeq contain those. Otherwise both are empty
{
- nSeriesLength = (xValuesSeq.is()? xValuesSeq->getData().getLength() : sal_Int32(0));
// get property states for autostyles
try
{
@@ -2688,46 +2725,36 @@ void SchXMLExportHelper::exportSeries(
}
// export domain elements if we have a series parent element
- if( nMainSequenceIndex>-1 )
+ if( pSeries )
{
// domain elements
if( bExportContent )
{
- for( nSeqIdx=0; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
+ bool bIsScatterChart = aChartType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType"));
+ bool bIsBubbleChart = aChartType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType"));
+ Reference< chart2::data::XDataSequence > xYValuesForBubbleChart;
+ if( bIsBubbleChart )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii("values-y" ) ) );
+ if( xSequence.is() )
+ {
+ xYValuesForBubbleChart = xSequence->getValues();
+ if( !lcl_exportDomainForThisSequence( xYValuesForBubbleChart, aFirstYDomainRange, mrExport ) )
+ xYValuesForBubbleChart = 0;
+ }
+ }
+ if( bIsScatterChart || bIsBubbleChart )
{
- if( nSeqIdx != nMainSequenceIndex )
+ Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii("values-x" ) ) );
+ if( xSequence.is() )
{
- bool bExportDomain = false;
- //@todo: roles should be exported
- Reference< chart2::data::XDataSequence > xSeq( aSeqCnt[nSeqIdx]->getValues() );
- if( xSeq.is())
- {
- OUString aXRange( lcl_ConvertRange(
- xSeq->getSourceRangeRepresentation(), xNewDoc ) );
- //work around error in OOo 2.0 (problems with multiple series having a domain element)
- if( !aFirstXRange.getLength() || !aXRange.equals(aFirstXRange) )
- {
- bExportDomain = true;
- mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aXRange);
- m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xSeq ));
- }
-
- if( !aFirstXRange.getLength() )
- aFirstXRange = aXRange;
- }
-// xSeq.set( aSeqCnt[nSeqIdx]->getLabel());
-// if( xSeq.is())
-// mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS,
-// lcl_ConvertRange(
-// xSeq->getSourceRangeRepresentation(),
-// xNewDoc ));
- if( bExportDomain )
- {
- SvXMLElementExport aDomain( mrExport, XML_NAMESPACE_CHART,
- XML_DOMAIN, sal_True, sal_True );
- }
+ Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
+ if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ) )
+ m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xValues ));
}
}
+ if( xYValuesForBubbleChart.is() )
+ m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xYValuesForBubbleChart ));
}
}
@@ -3506,7 +3533,7 @@ void SchXMLExport::_ExportContent()
// check if we have own data. If so we must not export the complete
// range string, as this is our only indicator for having own or
// external data. @todo: fix this in the file format!
- Reference< lang::XServiceInfo > xDPServiceInfo( maExportHelper.GetDataProvider( xNewDoc ), uno::UNO_QUERY );
+ Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
if( ! (xDPServiceInfo.is() &&
xDPServiceInfo->getImplementationName().equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ))))
@@ -3566,45 +3593,12 @@ void SchXMLExport::SetProgress( sal_Int32 nPercentage )
mxStatusIndicator->setValue( nPercentage );
}
-// static
-Reference< chart2::data::XDataProvider > SchXMLExportHelper::GetDataProvider(
- const Reference< chart2::XChartDocument > & xDoc )
-{
- Reference< chart2::data::XDataProvider > xResult;
- if( xDoc.is())
- {
- xResult.set( xDoc->getDataProvider());
- // allowed to attach a new data provider in export?
-// if( ! xResult.is())
-// {
-// Reference< container::XChild > xChild( xDoc, uno::UNO_QUERY );
-// if( xChild.is())
-// {
-// Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
-// if( xFact.is())
-// {
-// xResult.set(
-// xFact->createInstance( OUString::createFromAscii("com.sun.star.chart2.data.DataProvider")),
-// uno::UNO_QUERY );
-// if( xResult.is())
-// {
-// Reference< chart2::data::XDataReceiver > xReceiver( xDoc, uno::UNO_QUERY );
-// if( xReceiver.is())
-// xReceiver->attachDataProvider( xResult );
-// }
-// }
-// }
-// }
- }
- return xResult;
-}
-
void SchXMLExportHelper::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
{
if( xChartDoc.is())
try
{
- Reference< chart2::data::XDataProvider > xDataProvider( GetDataProvider( xChartDoc ));
+ Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
OSL_ENSURE( xDataProvider.is(), "No DataProvider" );
if( xDataProvider.is())
{
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index ca79b12a3e2d..dd955e6d69d5 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -35,6 +35,8 @@
#include "SchXMLChartContext.hxx"
#include "contexts.hxx"
#include "XMLChartPropertySetMapper.hxx"
+#include "SchXMLTools.hxx"
+
#include <tools/debug.hxx>
#include <rtl/ustrbuf.hxx>
// header for class ByteString
@@ -346,6 +348,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap()
{
static __FAR_DATA SvXMLTokenMapEntry aChartAttrTokenMap[] =
{
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_CHART_HREF },
{ XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_CHART_CLASS },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_CHART_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_CHART_HEIGHT },
@@ -614,38 +617,6 @@ void SchXMLImportHelper::ResizeChartData( sal_Int32 nSeries, sal_Int32 nDataPoin
}
}
-// static
-Reference< chart2::data::XDataProvider > SchXMLImportHelper::GetDataProvider(
- const Reference< chart2::XChartDocument > & xDoc )
-{
- Reference< chart2::data::XDataProvider > xResult;
- if( xDoc.is())
- {
- try
- {
- xResult.set( xDoc->getDataProvider());
-// if( ! xResult.is())
-// {
-// Reference< container::XChild > xChild( xDoc, uno::UNO_QUERY_THROW );
-// Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
-// if( xFact.is())
-// {
-// Reference< chart2::data::XDataReceiver > xReceiver( xDoc, uno::UNO_QUERY_THROW );
-// xResult.set(
-// xFact->createInstance( OUString::createFromAscii("com.sun.star.chart2.data.DataProvider")),
-// uno::UNO_QUERY_THROW );
-// xReceiver->attachDataProvider( xResult );
-// }
-// }
- }
- catch( const uno::Exception & )
- {
- // didn't get a data provider from the container
- }
- }
- return xResult;
-}
-
//static
void SchXMLImportHelper::DeleteDataSeries(
const Reference< chart2::XDataSeries > & xSeries,
@@ -796,6 +767,8 @@ SchXMLImport::SchXMLImport(
sal_uInt16 nImportFlags ) :
SvXMLImport( xServiceFactory, nImportFlags )
{
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+
mbIsGraphicLoadOnDemandSupported = false;
}
@@ -807,6 +780,8 @@ SchXMLImport::SchXMLImport(
sal_Bool /*bLoadDoc*/, sal_Bool bShowProgress )
: SvXMLImport( xServiceFactory, xModel, rGrfContainer )
{
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+
// get status indicator (if requested)
if( bShowProgress )
{
@@ -899,6 +874,9 @@ SvXMLImportContext* SchXMLImport::CreateStylesContext(
const OUString& rLocalName,
const Reference<xml::sax::XAttributeList>& xAttrList )
{
+ //#i103287# make sure that the version information is set before importing all the properties (especially stroke-opacity!)
+ SchXMLTools::setBuildIDAtImportInfo( GetModel(), getImportInfo() );
+
SvXMLStylesContext* pStylesCtxt =
new SvXMLStylesContext( *(this), XML_NAMESPACE_OFFICE, rLocalName, xAttrList );
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index bcf1f7abb3bf..8bb4712b4159 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -108,8 +108,10 @@ struct lcl_AxisHasCategories : public ::std::unary_function< SchXMLAxis, bool >
OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
{
OUString aResult = rRange;
+ if(!xDoc.is())
+ return aResult;
uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
- SchXMLImportHelper::GetDataProvider( xDoc ), uno::UNO_QUERY );
+ xDoc->getDataProvider(), uno::UNO_QUERY );
if( xConversion.is())
aResult = xConversion->convertRangeFromXML( rRange );
return aResult;
@@ -177,10 +179,11 @@ SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
SchXMLPlotAreaContext::SchXMLPlotAreaContext(
SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
uno::Sequence< chart::ChartSeriesAddress >& rSeriesAddresses,
::rtl::OUString& rCategoriesAddress,
::rtl::OUString& rChartAddress,
- sal_Bool & rHasOwnTable,
+ bool& rbHasRangeAtPlotArea,
sal_Bool & rAllRangeAddressesAvailable,
sal_Bool & rColHasLabels,
sal_Bool & rRowHasLabels,
@@ -195,28 +198,27 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext(
mrCategoriesAddress( rCategoriesAddress ),
mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
mnNumOfLinesProp( 0 ),
- mnNumOfLinesReadBySeries( 0 ),
mbStockHasVolume( sal_False ),
mnSeries( 0 ),
- mnMaxSeriesLength( 0 ),
+ m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
maSceneImportHelper( rImport ),
mbHasSize(false),
mbHasPosition(false),
mbPercentStacked(false),
m_bAxisPositionAttributeImported(false),
+ m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
mrChartAddress( rChartAddress ),
- mrHasOwnTable( rHasOwnTable ),
- mrAllRangeAddressesAvailable( rAllRangeAddressesAvailable ),
+ m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
mrColHasLabels( rColHasLabels ),
mrRowHasLabels( rRowHasLabels ),
mrDataRowSource( rDataRowSource ),
- mnFirstFirstDomainIndex( -1 ),
maChartTypeServiceName( aChartTypeServiceName ),
mrLSequencesPerIndex( rLSequencesPerIndex ),
- mnCurrentDataIndex( 0 ),
mbGlobalChartTypeUsedBySeries( false ),
maChartSize( rChartSize )
{
+ m_rbHasRangeAtPlotArea = false;
+
// get Diagram
uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
if( xDoc.is())
@@ -342,7 +344,7 @@ void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttri
case XML_TOK_PA_CHART_ADDRESS:
mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
// indicator for getting data from the outside
- mrHasOwnTable = sal_False;
+ m_rbHasRangeAtPlotArea = true;
break;
case XML_TOK_PA_DS_HAS_LABELS:
{
@@ -518,7 +520,17 @@ void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttri
}
//
- if( mrHasOwnTable && mxNewDoc.is())
+ bool bCreateInternalDataProvider = false;
+ if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
+ bCreateInternalDataProvider = true;
+ else if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
+ bCreateInternalDataProvider = false;
+ else if( m_rXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
+ bCreateInternalDataProvider = true;
+ else if( !m_rbHasRangeAtPlotArea )
+ bCreateInternalDataProvider = true;
+
+ if( bCreateInternalDataProvider && mxNewDoc.is() )
{
// we have no complete range => we have own data, so switch the data
// provider to internal. Clone is not necessary, as we don't have any
@@ -578,14 +590,11 @@ SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext(
mrImportHelper, GetImport(), rLocalName,
mxNewDoc, maAxes,
mrSeriesDefaultsAndStyles.maSeriesStyleList,
- mnSeries, mnMaxSeriesLength,
- mnNumOfLinesReadBySeries, mbStockHasVolume,
- maFirstFirstDomainAddress,
- mnFirstFirstDomainIndex,
- mrAllRangeAddressesAvailable,
+ mnSeries,
+ mbStockHasVolume,
+ m_aGlobalSeriesImportInfo,
maChartTypeServiceName,
mrLSequencesPerIndex,
- mnCurrentDataIndex,
mbGlobalChartTypeUsedBySeries, maChartSize );
}
mnSeries++;
@@ -632,7 +641,7 @@ void SchXMLPlotAreaContext::EndElement()
if( mrCategoriesAddress.getLength() && mxNewDoc.is())
{
uno::Reference< chart2::data::XDataProvider > xDataProvider(
- mrImportHelper.GetDataProvider( mxNewDoc ));
+ mxNewDoc->getDataProvider() );
// @todo: correct coordinate system index
sal_Int32 nDimension( 0 );
::std::vector< SchXMLAxis >::const_iterator aIt(
@@ -659,15 +668,8 @@ void SchXMLPlotAreaContext::EndElement()
maSceneImportHelper.setSceneAttributes( xDiaProp );
}
- // if the property NumberOfLines and the number of series containing
- // class="chart:line" as attribute are both different from 0 they must
- // be equal
- OSL_ASSERT( mnNumOfLinesProp == 0 || mnNumOfLinesReadBySeries == 0 ||
- mnNumOfLinesProp == mnNumOfLinesReadBySeries );
-
// set correct number of lines at series
- if( ! mrAllRangeAddressesAvailable &&
- mnNumOfLinesReadBySeries == 0 &&
+ if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable &&
mnNumOfLinesProp > 0 &&
maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ColumnChartType" )))
{
@@ -1533,7 +1535,7 @@ SvXMLImportContext* SchXMLAxisContext::CreateChildContext(
break;
case XML_TOK_AXIS_CATEGORIES:
- pContext = new SchXMLCategoriesDomainContext( mrImportHelper, GetImport(),
+ pContext = new SchXMLCategoriesContext( mrImportHelper, GetImport(),
p_nPrefix, rLocalName,
mrCategoriesAddress );
maCurrentAxis.bHasCategories = true;
@@ -1640,7 +1642,7 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
// ========================================
-SchXMLCategoriesDomainContext::SchXMLCategoriesDomainContext(
+SchXMLCategoriesContext::SchXMLCategoriesContext(
SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport,
sal_uInt16 nPrefix,
@@ -1652,11 +1654,11 @@ SchXMLCategoriesDomainContext::SchXMLCategoriesDomainContext(
{
}
-SchXMLCategoriesDomainContext::~SchXMLCategoriesDomainContext()
+SchXMLCategoriesContext::~SchXMLCategoriesContext()
{
}
-void SchXMLCategoriesDomainContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+void SchXMLCategoriesContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
{
sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
index 2d14f9c644dc..ed01ad2fa8da 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
@@ -74,11 +74,12 @@ class SchXMLPlotAreaContext : public SvXMLImportContext
public:
SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
::com::sun::star::uno::Sequence<
::com::sun::star::chart::ChartSeriesAddress >& rSeriesAddresses,
::rtl::OUString& rCategoriesAddress,
::rtl::OUString& rChartAddress,
- sal_Bool & rHasOwnTable,
+ bool& bHasRangeAtPlotArea,
sal_Bool & rAllRangeAddressesAvailable,
sal_Bool & rColHasLabels,
sal_Bool & rRowHasLabels,
@@ -107,10 +108,10 @@ private:
rtl::OUString& mrCategoriesAddress;
SeriesDefaultsAndStyles& mrSeriesDefaultsAndStyles;
sal_Int32 mnNumOfLinesProp;
- sal_Int32 mnNumOfLinesReadBySeries;
sal_Bool mbStockHasVolume;
sal_Int32 mnSeries;
- sal_Int32 mnMaxSeriesLength;
+ GlobalSeriesImportInfo m_aGlobalSeriesImportInfo;
+
SchXML3DSceneAttributesHelper maSceneImportHelper;
::com::sun::star::awt::Size maSize;
::com::sun::star::awt::Point maPosition;
@@ -119,19 +120,16 @@ private:
bool mbPercentStacked;
bool m_bAxisPositionAttributeImported;
::rtl::OUString msAutoStyleName;
+ const ::rtl::OUString& m_rXLinkHRefAttributeToIndicateDataProvider;
::rtl::OUString& mrChartAddress;
- sal_Bool & mrHasOwnTable;
- sal_Bool & mrAllRangeAddressesAvailable;
+ bool& m_rbHasRangeAtPlotArea;
sal_Bool & mrColHasLabels;
sal_Bool & mrRowHasLabels;
::com::sun::star::chart::ChartDataRowSource & mrDataRowSource;
- ::rtl::OUString maFirstFirstDomainAddress;
- sal_Int32 mnFirstFirstDomainIndex;
-
::rtl::OUString maChartTypeServiceName;
tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
- sal_Int32 mnCurrentDataIndex;
+
bool mbGlobalChartTypeUsedBySeries;
::com::sun::star::awt::Size maChartSize;
};
@@ -203,19 +201,19 @@ public:
// ----------------------------------------
-class SchXMLCategoriesDomainContext : public SvXMLImportContext
+class SchXMLCategoriesContext : public SvXMLImportContext
{
private:
SchXMLImportHelper& mrImportHelper;
rtl::OUString& mrAddress;
public:
- SchXMLCategoriesDomainContext( SchXMLImportHelper& rImpHelper,
+ SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport,
sal_uInt16 nPrefix,
const rtl::OUString& rLocalName,
rtl::OUString& rAddress );
- virtual ~SchXMLCategoriesDomainContext();
+ virtual ~SchXMLCategoriesContext();
virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
};
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 07dda88800c4..4633a149e4df 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -81,11 +81,10 @@ using ::rtl::OUStringBuffer;
namespace
{
-OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::XChartDocument > & xDoc )
+OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::data::XDataProvider >& xDataProvider )
{
OUString aResult = rRange;
- Reference< chart2::data::XRangeXMLConversion > xConversion(
- SchXMLImportHelper::GetDataProvider( xDoc ), uno::UNO_QUERY );
+ Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
if( xConversion.is())
aResult = xConversion->convertRangeFromXML( rRange );
return aResult;
@@ -234,6 +233,54 @@ void lcl_insertErrorBarLSequencesToMap(
}
}
+Reference< chart2::data::XLabeledDataSequence > lcl_createAndAddSequenceToSeries( const rtl::OUString& rRole
+ , const rtl::OUString& rRange
+ , const Reference< chart2::data::XDataProvider >& xDataProvider
+ , const Reference< chart2::XDataSeries >& xSeries )
+{
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq;
+
+ Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY );
+ Reference< chart2::data::XDataSink > xSeriesSink( xSeries, uno::UNO_QUERY );
+
+ if( !(rRange.getLength() && xDataProvider.is() && xSeriesSource.is() && xSeriesSink.is()) )
+ return xLabeledSeq;
+
+ // create a new sequence
+ xLabeledSeq = SchXMLTools::GetNewLabeledDataSequence();
+
+ // set values at the new sequence
+ Reference< chart2::data::XDataSequence > xSeq;
+ try
+ {
+ xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider )));
+ SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, rRange );
+ }
+ catch( const lang::IllegalArgumentException & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, ::rtl::OUStringToOString(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
+ if( xSeqProp.is())
+ xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( rRole));
+ xLabeledSeq->setValues( xSeq );
+
+ // add new sequence to data series / push to front to have the correct sequence order if charttype is changed afterwards
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeq( xSeriesSource->getDataSequences());
+ sal_Int32 nOldCount = aOldSeq.getLength();
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 );
+ aNewSeq[0]=xLabeledSeq;
+ for( sal_Int32 nN=0; nN<nOldCount; nN++ )
+ aNewSeq[nN+1] = aOldSeq[nN];
+ xSeriesSink->setData( aNewSeq );
+
+ return xLabeledSeq;
+}
+
} // anonymous namespace
// ================================================================================
@@ -245,15 +292,10 @@ SchXMLSeries2Context::SchXMLSeries2Context(
std::vector< SchXMLAxis >& rAxes,
::std::list< DataRowPointStyle >& rStyleList,
sal_Int32 nSeriesIndex,
- sal_Int32& rMaxSeriesLength,
- sal_Int32& rNumOfLines,
- sal_Bool& rStockHasVolume,
- ::rtl::OUString& rFirstFirstDomainAddress,
- sal_Int32& rFirstFirstDomainIndex,
- sal_Bool& rAllRangeAddressesAvailable,
+ sal_Bool bStockHasVolume,
+ GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
const OUString & aGlobalChartTypeName,
tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
- sal_Int32& rCurrentDataIndex,
bool& rGlobalChartTypeUsedBySeries,
const awt::Size & rChartSize ) :
SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
@@ -264,18 +306,13 @@ SchXMLSeries2Context::SchXMLSeries2Context(
m_xSeries(0),
mnSeriesIndex( nSeriesIndex ),
mnDataPointIndex( 0 ),
- mrMaxSeriesLength( rMaxSeriesLength ),
- mrNumOfLines( rNumOfLines ),
- mrStockHasVolume( rStockHasVolume ),
- mrFirstFirstDomainAddress(rFirstFirstDomainAddress),
- mrFirstFirstDomainIndex(rFirstFirstDomainIndex),
- mrAllRangeAddressesAvailable( rAllRangeAddressesAvailable ),
+ m_bStockHasVolume( bStockHasVolume ),
+ m_rGlobalSeriesImportInfo(rGlobalSeriesImportInfo),
mpAttachedAxis( NULL ),
maGlobalChartTypeName( aGlobalChartTypeName ),
maSeriesChartTypeName( aGlobalChartTypeName ),
m_bHasDomainContext(false),
mrLSequencesPerIndex( rLSequencesPerIndex ),
- mrCurrentDataIndex( rCurrentDataIndex ),
mrGlobalChartTypeUsedBySeries( rGlobalChartTypeUsedBySeries ),
mbSymbolSizeIsMissingInFile(false),
maChartSize( rChartSize )
@@ -304,7 +341,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
if( mxNewDoc.is())
- xRangeConversion.set( mrImportHelper.GetDataProvider( mxNewDoc ), uno::UNO_QUERY );
+ xRangeConversion.set( mxNewDoc->getDataProvider(), uno::UNO_QUERY );
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -369,10 +406,10 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
OSL_ASSERT( mxNewDoc.is());
if( mxNewDoc.is())
{
- if( mrAllRangeAddressesAvailable && ! bHasRange )
- mrAllRangeAddressesAvailable = sal_False;
+ if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange )
+ m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False;
- Reference< chart2::data::XDataProvider > xDataProvider( mrImportHelper.GetDataProvider( mxNewDoc ));
+ Reference< chart2::data::XDataProvider > xDataProvider( mxNewDoc->getDataProvider() );
if( xDataProvider.is())
{
bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
@@ -383,7 +420,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
else
{
if( bIsCandleStick
- && mrStockHasVolume
+ && m_bStockHasVolume
&& mnSeriesIndex == 0 )
{
maSeriesChartTypeName = OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" );
@@ -424,7 +461,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
if( bHasRange )
try
{
- xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( m_aSeriesRange, mxNewDoc )));
+ xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( m_aSeriesRange, xDataProvider )));
SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, m_aSeriesRange );
}
catch( const lang::IllegalArgumentException & ex )
@@ -438,16 +475,17 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
if( xSeqProp.is())
{
- //@todo: set correct role ("main role" dependent on chart type)
- xSeqProp->setPropertyValue(OUString::createFromAscii("Role"),
- uno::makeAny( OUString::createFromAscii("values-y")));
+ OUString aMainRole( OUString::createFromAscii("values-y") );
+ if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) )
+ aMainRole = OUString::createFromAscii("values-size");
+ xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( aMainRole ));
}
xLabeledSeq->setValues( xSeq );
// register for setting local data if external data provider is not present
maPostponedSequences.insert(
tSchXMLLSequencesPerIndex::value_type(
- tSchXMLIndexWithPart( mrCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
+ tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
// label
if( bHasLabelRange )
@@ -456,7 +494,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
{
Reference< chart2::data::XDataSequence > xLabelSequence(
xDataProvider->createDataSequenceByRangeRepresentation(
- lcl_ConvertRange( m_aSeriesLabelRange, mxNewDoc )));
+ lcl_ConvertRange( m_aSeriesLabelRange, xDataProvider )));
xLabeledSeq->setLabel( xLabelSequence );
SchXMLTools::setXMLRangePropertyAtDataSequence( xLabelSequence, m_aSeriesLabelRange );
}
@@ -475,7 +513,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
// used for the internal data.
maPostponedSequences.insert(
tSchXMLLSequencesPerIndex::value_type(
- tSchXMLIndexWithPart( mrCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq ));
+ tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq ));
Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 );
@@ -519,47 +557,91 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
}
}
+struct DomainInfo
+{
+ DomainInfo( const rtl::OUString& rRole, const rtl::OUString& rRange, sal_Int32 nIndex )
+ : aRole(rRole), aRange(rRange), nIndexForLocalData(nIndex)
+ {}
+
+ rtl::OUString aRole;
+ rtl::OUString aRange;
+ sal_Int32 nIndexForLocalData;
+};
+
void SchXMLSeries2Context::EndElement()
{
// special handling for different chart types. This is necessary as the
// roles are not yet saved in the file format
- OUString aXValuesRange( mrFirstFirstDomainAddress );
- sal_Int32 nCurrentDataIndexBeforeDomains = mrCurrentDataIndex;
- sal_Int32 nDomainOffset = 0;
- bool bCreateXValues = false;
- bool bHasOwnDomains = false;
+ sal_Int32 nDomainCount = maDomainAddresses.size();
+ bool bIsScatterChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType"));
+ bool bIsBubbleChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType"));
bool bDeleteSeries = false;
- if( maDomainAddresses.size() == 1 ||
- maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType")) )
+ std::vector< DomainInfo > aDomainInfos;
+
+ //different handling for different chart types necessary
+ if( bIsScatterChart || ( nDomainCount==1 && !bIsBubbleChart ) )
{
- bCreateXValues = true;
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
+ bool bCreateXValues = true;
if( !maDomainAddresses.empty() )
{
- aXValuesRange = maDomainAddresses.front();
- bHasOwnDomains = true;
- if(!mrFirstFirstDomainAddress.getLength())
+ if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
{
- mrFirstFirstDomainAddress=aXValuesRange;
- mrFirstFirstDomainIndex=mrCurrentDataIndex;
+ m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
+ m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
}
+ aDomainInfo.aRange = maDomainAddresses.front();
+ aDomainInfo.nIndexForLocalData = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
}
- else if( !mrFirstFirstDomainAddress.getLength() && !m_bHasDomainContext && mnSeriesIndex==0 )
+ else if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() && !m_bHasDomainContext && mnSeriesIndex==0 )
{
if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) ) //wrong old chart files:
{
//for xy charts the first series needs to have a domain
//if this by error iss not the case the first series is taken s x values
//needed for wrong files created while having an addin (e.g. BoxPlot)
- mrFirstFirstDomainAddress = m_aSeriesRange;
- mrFirstFirstDomainIndex = mrCurrentDataIndex;
+ m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = m_aSeriesRange;
+ m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
bDeleteSeries = true;
bCreateXValues = false;//they will be created for the next series
}
}
+ if( bCreateXValues )
+ aDomainInfos.push_back( aDomainInfo );
+ }
+ else if( bIsBubbleChart )
+ {
+ if( nDomainCount>1 )
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), maDomainAddresses[1], m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
+ if( !m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
+ {
+ //for bubble chart the second domain contains the x values which should become an index smaller than y values for own data table
+ //->so second first
+ m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress = maDomainAddresses[1];
+ m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ }
+ aDomainInfos.push_back( aDomainInfo );
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ }
+ else if( m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress, m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex ) ;
+ aDomainInfos.push_back( aDomainInfo );
+ }
+ if( nDomainCount>0)
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-y"), maDomainAddresses.front(), m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
+ if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
+ {
+ m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
+ m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ }
+ aDomainInfos.push_back( aDomainInfo );
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ }
}
-
- if( mrMaxSeriesLength < mnDataPointIndex )
- mrMaxSeriesLength = mnDataPointIndex;
if( bDeleteSeries )
{
@@ -583,71 +665,22 @@ void SchXMLSeries2Context::EndElement()
}
}
- if( bCreateXValues && aXValuesRange.getLength())
+ Reference< chart2::data::XDataProvider > xDataProvider;
+ if ( mxNewDoc.is() ) {
+ xDataProvider = mxNewDoc->getDataProvider();
+ }
+ for( std::vector< DomainInfo >::reverse_iterator aIt( aDomainInfos.rbegin() ); aIt!= aDomainInfos.rend(); ++aIt )
{
- Reference< chart2::data::XDataProvider > xDataProvider( mrImportHelper.GetDataProvider( mxNewDoc ));
- if( !(m_xSeries.is() && xDataProvider.is()))
- return;
-
- Reference< chart2::data::XDataSource > xSeriesSource( m_xSeries,uno::UNO_QUERY );
- if( ! xSeriesSource.is())
- return;
-
- // assume we have a scatter chart
-
- // create new sequence for x-values
- Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
- SchXMLTools::GetNewLabeledDataSequence());
-
- // values
- Reference< chart2::data::XDataSequence > xSeq;
- try
- {
- xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( aXValuesRange, mxNewDoc )));
- SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, aXValuesRange );
- }
- catch( const lang::IllegalArgumentException & ex )
- {
- (void)ex; // avoid warning for pro build
- OSL_ENSURE( false, ::rtl::OUStringToOString(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) +
- ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
- }
-
- Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
- if( xSeqProp.is())
- {
- xSeqProp->setPropertyValue(OUString::createFromAscii("Role"),
- uno::makeAny( OUString::createFromAscii("values-x")));
- }
- xLabeledSeq->setValues( xSeq );
-
- // register for setting local data if external data provider is not present
- if( bHasOwnDomains )
- {
- mrLSequencesPerIndex.insert(
- tSchXMLLSequencesPerIndex::value_type(
- tSchXMLIndexWithPart( mrCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
- ++mrCurrentDataIndex;
-
- nDomainOffset = mrCurrentDataIndex - nCurrentDataIndexBeforeDomains;
- }
- else
+ DomainInfo aDomainInfo( *aIt );
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq =
+ lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, xDataProvider, m_xSeries );
+ if( xLabeledSeq.is() )
{
+ // register for setting local data if external data provider is not present
mrLSequencesPerIndex.insert(
tSchXMLLSequencesPerIndex::value_type(
- tSchXMLIndexWithPart( mrFirstFirstDomainIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
+ tSchXMLIndexWithPart( aDomainInfo.nIndexForLocalData, SCH_XML_PART_VALUES ), xLabeledSeq ));
}
-
- // @todo? export and import labels for domains?
-
- // add new sequence to data series
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( xSeriesSource->getDataSequences());
- aSeq.realloc( aSeq.getLength() + 1 );
- aSeq[aSeq.getLength()-1] = xLabeledSeq;
- Reference< chart2::data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY );
- if( xSink.is())
- xSink->setData( aSeq );
}
if( !bDeleteSeries )
@@ -655,18 +688,14 @@ void SchXMLSeries2Context::EndElement()
for( tSchXMLLSequencesPerIndex::const_iterator aIt( maPostponedSequences.begin());
aIt != maPostponedSequences.end(); ++aIt )
{
- sal_Int32 nNewIndex = aIt->first.first + nDomainOffset;
+ sal_Int32 nNewIndex = aIt->first.first + nDomainCount;
mrLSequencesPerIndex.insert(
tSchXMLLSequencesPerIndex::value_type(
tSchXMLIndexWithPart( nNewIndex, aIt->first.second ), aIt->second ));
}
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
}
maPostponedSequences.clear();
-
- if( bHasOwnDomains )
- mrCurrentDataIndex += nDomainOffset;
- else
- ++mrCurrentDataIndex;
}
SvXMLImportContext* SchXMLSeries2Context::CreateChildContext(
diff --git a/xmloff/source/chart/SchXMLSeries2Context.hxx b/xmloff/source/chart/SchXMLSeries2Context.hxx
index f540179186ca..f0c8996de539 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.hxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.hxx
@@ -62,12 +62,10 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > m_xSeries;
sal_Int32 mnSeriesIndex;
sal_Int32 mnDataPointIndex;
- sal_Int32& mrMaxSeriesLength;
- sal_Int32& mrNumOfLines;
- sal_Bool& mrStockHasVolume;
- ::rtl::OUString& mrFirstFirstDomainAddress;
- sal_Int32& mrFirstFirstDomainIndex;
- sal_Bool& mrAllRangeAddressesAvailable;
+ sal_Bool m_bStockHasVolume;
+
+ GlobalSeriesImportInfo& m_rGlobalSeriesImportInfo;
+
SchXMLAxis* mpAttachedAxis;
sal_Int32 mnAttachedAxis;
::rtl::OUString msAutoStyleName;
@@ -78,7 +76,6 @@ private:
::rtl::OUString m_aSeriesLabelRange;
bool m_bHasDomainContext;
tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
- sal_Int32& mrCurrentDataIndex;
tSchXMLLSequencesPerIndex maPostponedSequences;
bool& mrGlobalChartTypeUsedBySeries;
bool mbSymbolSizeIsMissingInFile;
@@ -92,15 +89,10 @@ public:
std::vector< SchXMLAxis >& rAxes,
::std::list< DataRowPointStyle >& rStyleList,
sal_Int32 nSeriesIndex,
- sal_Int32& rMaxSeriesLength,
- sal_Int32& rNumOfLines,
- sal_Bool& rStockHasVolume,
- ::rtl::OUString& rFirstFirstDomainAddress,
- sal_Int32& rFirstFirstDomainIndex,
- sal_Bool& rAllRangeAddressesAvailable,
+ sal_Bool bStockHasVolume,
+ GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
const ::rtl::OUString & aGlobalChartTypeName,
tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
- sal_Int32& rCurrentDataIndex,
bool& rGlobalChartTypeUsedBySeries,
const ::com::sun::star::awt::Size & rChartSize );
virtual ~SchXMLSeries2Context();
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index 046da76497d7..a1c021171a92 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -343,37 +343,6 @@ void lcl_fillRangeMapping(
}
}
-void lcl_copyProperties(
- const Reference< beans::XPropertySet > & xSource,
- const Reference< beans::XPropertySet > & xDestination )
-{
- if( ! (xSource.is() && xDestination.is()))
- return;
-
- try
- {
- Reference< beans::XPropertySetInfo > xSrcInfo( xSource->getPropertySetInfo(), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySetInfo > xDestInfo( xDestination->getPropertySetInfo(), uno::UNO_QUERY_THROW );
- Sequence< beans::Property > aProperties( xSrcInfo->getProperties());
- const sal_Int32 nLength = aProperties.getLength();
- for( sal_Int32 i = 0; i < nLength; ++i )
- {
- OUString aName( aProperties[i].Name);
- if( xDestInfo->hasPropertyByName( aName ))
- {
- beans::Property aProp( xDestInfo->getPropertyByName( aName ));
- if( (aProp.Attributes & beans::PropertyAttribute::READONLY) == 0 )
- xDestination->setPropertyValue(
- aName, xSource->getPropertyValue( aName ));
- }
- }
- }
- catch( const uno::Exception & )
- {
- OSL_ENSURE( false, "Copying property sets failed!" );
- }
-}
-
Reference< chart2::data::XDataSequence >
lcl_reassignDataSequence(
const Reference< chart2::data::XDataSequence > & xSequence,
@@ -967,7 +936,15 @@ void SchXMLTableHelper::applyTableSimple(
sal_Int32 nColumnCount = 0;
sal_Int32 nCol = 0, nRow = 0;
if( nRowCount )
+ {
nColumnCount = rTable.aData[ 0 ].size();
+ ::std::vector< ::std::vector< SchXMLCell > >::const_iterator iRow = rTable.aData.begin();
+ while( iRow != rTable.aData.end() )
+ {
+ nColumnCount = ::std::max( nColumnCount, static_cast<sal_Int32>(iRow->size()) );
+ iRow++;
+ }
+ }
// #i27909# avoid illegal index access for empty tables
if( nColumnCount == 0 || nRowCount == 0 )
@@ -981,7 +958,8 @@ void SchXMLTableHelper::applyTableSimple(
// set labels
::std::vector< ::std::vector< SchXMLCell > >::const_iterator iRow = rTable.aData.begin();
- for( nCol = 1; nCol < nColumnCount; nCol++ )
+ sal_Int32 nColumnCountOnFirstRow = iRow->size();
+ for( nCol = 1; nCol < nColumnCountOnFirstRow; nCol++ )
{
aLabels[ nCol - 1 ] = (*iRow)[ nCol ].aString;
}
@@ -1016,7 +994,7 @@ void SchXMLTableHelper::applyTableSimple(
// ----------------------------------------
-void SchXMLTableHelper::applyTable(
+void SchXMLTableHelper::applyTableToInternalDataProvider(
const SchXMLTable& rTable,
uno::Reference< chart2::XChartDocument > xChartDoc )
{
@@ -1031,19 +1009,12 @@ void SchXMLTableHelper::applyTable(
// prerequisite for this method: all objects (data series, domains, etc.)
// need their own range string.
- // If the range-strings are valid (starting with "local-table") they should
- // be interpreted like given, otherwise (when the ranges refer to Calc- or
- // Writer-ranges, but the container is not available like when pasting a
- // chart from Calc to Impress) the range is ignored, and every object gets
- // one table column in the order of appearance, which is: 1. categories,
- // 2. data series: 2.a) domains, 2.b) values (main-role, usually y-values)
-
// apply all data read in the table to the chart data-array of the internal
// data provider
lcl_applyXMLTableToInternalDataprovider( rTable, xDataArray );
}
-void SchXMLTableHelper::postProcessTable(
+void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
const SchXMLTable& rTable,
const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
uno::Reference< chart2::XChartDocument > xChartDoc,
@@ -1051,6 +1022,14 @@ void SchXMLTableHelper::postProcessTable(
{
if( ! (xChartDoc.is() && xChartDoc->hasInternalDataProvider()))
return;
+
+ // If the range-strings are valid (starting with "local-table") they should
+ // be interpreted like given, otherwise (when the ranges refer to Calc- or
+ // Writer-ranges, but the container is not available like when pasting a
+ // chart from Calc to Impress) the range is ignored, and every object gets
+ // one table column in the order of appearance, which is: 1. categories,
+ // 2. data series: 2.a) domains, 2.b) values (main-role, usually y-values)
+
Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider());
// create a mapping from original ranges to new ranges
@@ -1079,7 +1058,7 @@ void SchXMLTableHelper::postProcessTable(
lcl_reassignDataSequence( xSeq, xDataProv, aRangeMap, aRange ));
if( xNewSeq != xSeq )
{
- lcl_copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSeq );
}
@@ -1099,7 +1078,7 @@ void SchXMLTableHelper::postProcessTable(
Reference< chart2::data::XDataSequence > xNewSequence(
xDataProv->createDataSequenceByRangeRepresentation(
OUString(RTL_CONSTASCII_USTRINGPARAM("categories"))));
- lcl_copyProperties(
+ SchXMLTools::copyProperties(
xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSequence );
bCategoriesApplied = true;
@@ -1110,7 +1089,7 @@ void SchXMLTableHelper::postProcessTable(
OUString aRep( OUString::valueOf( aLSeqIt->first.first ));
Reference< chart2::data::XDataSequence > xNewSequence(
xDataProv->createDataSequenceByRangeRepresentation( aRep ));
- lcl_copyProperties(
+ SchXMLTools::copyProperties(
xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSequence );
}
@@ -1131,7 +1110,7 @@ void SchXMLTableHelper::postProcessTable(
lcl_reassignDataSequence( xSeq, xDataProv, aRangeMap, aRange ));
if( xNewSeq != xSeq )
{
- lcl_copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setLabel( xNewSeq );
}
@@ -1143,7 +1122,7 @@ void SchXMLTableHelper::postProcessTable(
Reference< chart2::data::XDataSequence > xNewSeq(
xDataProv->createDataSequenceByRangeRepresentation( aRep ));
- lcl_copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setLabel( xNewSeq );
}
diff --git a/xmloff/source/chart/SchXMLTableContext.hxx b/xmloff/source/chart/SchXMLTableContext.hxx
index 8a9ea5c369a0..7cff3e7ecff7 100644
--- a/xmloff/source/chart/SchXMLTableContext.hxx
+++ b/xmloff/source/chart/SchXMLTableContext.hxx
@@ -108,14 +108,14 @@ public:
table, the addresses of series, the addresses of labels,
the cell-range-address for the categories
*/
- static void applyTable( const SchXMLTable& rTable,
+ static void applyTableToInternalDataProvider( const SchXMLTable& rTable,
com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc );
- /** Second part of applyTable that has to be called after the data series
+ /** Second part of applyTableToInternalDataProvider that has to be called after the data series
got their styles set. This function reorders local data to fit the
correct data structure.
*/
- static void postProcessTable( const SchXMLTable& rTable,
+ static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable,
const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc,
::com::sun::star::chart::ChartDataRowSource eDataRowSource );
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index 7915c9e4e8c1..a1700c65d316 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -53,9 +53,12 @@
#include <xmloff/xmlprmap.hxx>
#include <xmloff/xmlexp.hxx>
#include "xmlnmspe.hxx"
+#include <xmloff/xmlmetai.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
@@ -101,9 +104,19 @@ rtl::OUString lcl_getGeneratorFromModel( const uno::Reference< frame::XModel >&
uno::Reference< document::XDocumentProperties > xChartDocumentProperties(
xChartDocumentPropertiesSupplier->getDocumentProperties());
if( xChartDocumentProperties.is() )
- {
aGenerator = xChartDocumentProperties->getGenerator();
- }
+ }
+ return aGenerator;
+}
+
+rtl::OUString lcl_getGeneratorFromModelOrItsParent( const uno::Reference< frame::XModel >& xChartModel )
+{
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ if( !aGenerator.getLength() ) //try to get the missing info from the parent document
+ {
+ uno::Reference< container::XChild > xChild( xChartModel, uno::UNO_QUERY );
+ if( xChild.is() )
+ aGenerator = lcl_getGeneratorFromModel( uno::Reference< frame::XModel >( xChild->getParent(), uno::UNO_QUERY) );
}
return aGenerator;
}
@@ -123,6 +136,24 @@ sal_Int32 lcl_getBuildIDFromGenerator( const ::rtl::OUString& rGenerator )
return nBuildId;
}
+Reference< chart2::data::XDataSequence > lcl_createNewSequenceFromCachedXMLRange( const Reference< chart2::data::XDataSequence >& xSeq, const Reference< chart2::data::XDataProvider >& xDataProvider )
+{
+ Reference< chart2::data::XDataSequence > xRet;
+ OUString aRange;
+ Reference< chart2::data::XRangeXMLConversion > xRangeConversion( xDataProvider, uno::UNO_QUERY );
+ if( xRangeConversion.is() )
+ {
+ if( xSeq.is() && SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) )
+ {
+ xRet.set( xDataProvider->createDataSequenceByRangeRepresentation(
+ xRangeConversion->convertRangeFromXML( aRange )) );
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xRet, uno::UNO_QUERY ));
+ }
+ }
+ return xRet;
+}
+
} // anonymous namespace
// ----------------------------------------
@@ -138,6 +169,7 @@ static __FAR_DATA SvXMLEnumMapEntry aXMLChartClassMap[] =
{ XML_RING, XML_CHART_CLASS_RING },
{ XML_SCATTER, XML_CHART_CLASS_SCATTER },
{ XML_RADAR, XML_CHART_CLASS_RADAR },
+ { XML_FILLED_RADAR, XML_CHART_CLASS_FILLED_RADAR },
{ XML_BAR, XML_CHART_CLASS_BAR },
{ XML_STOCK, XML_CHART_CLASS_STOCK },
{ XML_BUBBLE, XML_CHART_CLASS_BUBBLE },
@@ -182,9 +214,15 @@ const tMakeStringStringMap& lcl_getChartTypeNameMap()
( ::rtl::OUString::createFromAscii( "com.sun.star.chart.NetDiagram" )
, ::rtl::OUString::createFromAscii( "com.sun.star.chart2.NetChartType" ) )
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.FilledNetDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.FilledNetChartType" ) )
+
( ::rtl::OUString::createFromAscii( "com.sun.star.chart.StockDiagram" )
, ::rtl::OUString::createFromAscii( "com.sun.star.chart2.CandleStickChartType" ) )
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.BubbleDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.BubbleChartType" ) )
+
;
return g_aChartTypeNameMap;
}
@@ -241,8 +279,13 @@ OUString GetChartTypeByClassName(
else
aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Scatter"));
}
+
+ else if( IsXMLToken( rClassName, XML_BUBBLE ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Bubble"));
else if( IsXMLToken( rClassName, XML_RADAR ))
aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Net"));
+ else if( IsXMLToken( rClassName, XML_FILLED_RADAR ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("FilledNet"));
else if( IsXMLToken( rClassName, XML_STOCK ))
{
if( bUseOldNames )
@@ -306,8 +349,12 @@ XMLTokenEnum getTokenByChartType(
else if( (bUseOldNames && aServiceName.equalsAscii("XY")) ||
(!bUseOldNames && aServiceName.equalsAscii("Scatter")))
eResult = XML_SCATTER;
+ else if( aServiceName.equalsAscii("Bubble"))
+ eResult = XML_BUBBLE;
else if( aServiceName.equalsAscii("Net"))
eResult = XML_RADAR;
+ else if( aServiceName.equalsAscii("FilledNet"))
+ eResult = XML_FILLED_RADAR;
else if( (bUseOldNames && aServiceName.equalsAscii("Stock")) ||
(!bUseOldNames && aServiceName.equalsAscii("CandleStick")))
eResult = XML_STOCK;
@@ -583,6 +630,75 @@ bool getXMLRangePropertyFromDataSequence(
return bResult;
}
+void copyProperties(
+ const Reference< beans::XPropertySet > & xSource,
+ const Reference< beans::XPropertySet > & xDestination )
+{
+ if( ! (xSource.is() && xDestination.is()) )
+ return;
+
+ try
+ {
+ Reference< beans::XPropertySetInfo > xSrcInfo( xSource->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySetInfo > xDestInfo( xDestination->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+ Sequence< beans::Property > aProperties( xSrcInfo->getProperties());
+ const sal_Int32 nLength = aProperties.getLength();
+ for( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ OUString aName( aProperties[i].Name);
+ if( xDestInfo->hasPropertyByName( aName ))
+ {
+ beans::Property aProp( xDestInfo->getPropertyByName( aName ));
+ if( (aProp.Attributes & beans::PropertyAttribute::READONLY) == 0 )
+ xDestination->setPropertyValue(
+ aName, xSource->getPropertyValue( aName ));
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ OSL_ENSURE( false, "Copying property sets failed!" );
+ }
+}
+
+bool switchBackToDataProviderFromParent( const Reference< chart2::XChartDocument >& xChartDoc, const tSchXMLLSequencesPerIndex & rLSequencesPerIndex )
+{
+ //return whether the switch is successful
+ if( !xChartDoc.is() || !xChartDoc->hasInternalDataProvider() )
+ return false;
+ Reference< chart2::data::XDataProvider > xDataProviderFromParent( SchXMLTools::getDataProviderFromParent( xChartDoc ) );
+ if( !xDataProviderFromParent.is() )
+ return false;
+ uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartDoc, uno::UNO_QUERY );
+ if( !xDataReceiver.is() )
+ return false;
+
+ xDataReceiver->attachDataProvider( xDataProviderFromParent );
+
+ for( tSchXMLLSequencesPerIndex::const_iterator aLSeqIt( rLSequencesPerIndex.begin() );
+ aLSeqIt != rLSequencesPerIndex.end(); ++aLSeqIt )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( aLSeqIt->second );
+ if( !xLabeledSeq.is() )
+ continue;
+ Reference< chart2::data::XDataSequence > xNewSeq;
+ xNewSeq = lcl_createNewSequenceFromCachedXMLRange( xLabeledSeq->getValues(), xDataProviderFromParent );
+ if( xNewSeq.is() )
+ xLabeledSeq->setValues( xNewSeq );
+ xNewSeq = lcl_createNewSequenceFromCachedXMLRange( xLabeledSeq->getLabel(), xDataProviderFromParent );
+ if( xNewSeq.is() )
+ xLabeledSeq->setLabel( xNewSeq );
+ }
+ return true;
+}
+
+void setBuildIDAtImportInfo( uno::Reference< frame::XModel > xModel, Reference< beans::XPropertySet > xImportInfo )
+{
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModelOrItsParent(xModel) );
+ if( aGenerator.getLength() )
+ SvXMLMetaDocumentContext::setBuildId( aGenerator, xImportInfo );
+}
+
bool isDocumentGeneratedWithOpenOfficeOlderThan3_0( const uno::Reference< frame::XModel >& xChartModel )
{
bool bResult = isDocumentGeneratedWithOpenOfficeOlderThan2_3( xChartModel );
@@ -616,29 +732,62 @@ bool isDocumentGeneratedWithOpenOfficeOlderThan2_3( const uno::Reference< frame:
//if there is a meta stream at the chart object it was not written with an older OpenOffice version < 2.3
if( !aGenerator.getLength() )
{
- //if there is no meta stream at the chart object we need to check the version from the parent document
- //and we need to check whether the document was created with OpenOffice.org at all
+ //if there is no meta stream at the chart object we need to check whether the parent document is OpenOffice at all
uno::Reference< container::XChild > xChild( xChartModel, uno::UNO_QUERY );
if( xChild.is() )
{
- ::rtl::OUString aParentGenerator( lcl_getGeneratorFromModel( uno::Reference< frame::XModel >( xChild->getParent(), uno::UNO_QUERY) ) );
- if( aParentGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project") ) ) != -1 )
+ aGenerator = lcl_getGeneratorFromModel( uno::Reference< frame::XModel >( xChild->getParent(), uno::UNO_QUERY) );
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project") ) ) != -1 )
{
- sal_Int32 nBuilId = lcl_getBuildIDFromGenerator( aParentGenerator );
- if( nBuilId<=9161 ) //9161 is build id of OpenOffice.org 2.2.1
- bResult= true;
+ //the chart application has not created files without a meta stream since OOo 2.3 (OOo 2.3 has written a metastream already)
+ //only the report builder extension has created some files with OOo 3.1 that do not have a meta stream
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/31") ) ) != -1 )
+ bResult = false;//#i100102# probably generated with OOo 3.1 by the report designer
+ else
+ bResult= true; //in this case the OLE chart was created by an older version, as OLE objects are sometimes stream copied the version can differ from the parents version, so the parents version is not a reliable indicator
}
- else if(
- ( aParentGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org 1") ) ) == 0 )
- || ( aParentGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice 6") ) ) == 0 )
- || ( aParentGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice 7") ) ) == 0 )
- || ( aParentGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarSuite 6") ) ) == 0 )
- || ( aParentGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarSuite 7") ) ) == 0 )
- )
+ else if( isDocumentGeneratedWithOpenOfficeOlderThan2_0(xChartModel) )
bResult= true;
}
}
return bResult;
}
+bool isDocumentGeneratedWithOpenOfficeOlderThan2_0( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel)
+{
+ bool bResult = false;
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModelOrItsParent(xChartModel) );
+ if( ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org 1") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice 6") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice 7") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarSuite 6") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarSuite 7") ) ) == 0 )
+ )
+ bResult= true;
+ return bResult;
+}
+
+Reference< chart2::data::XDataProvider > getDataProviderFromParent( const Reference< chart2::XChartDocument >& xChartDoc )
+{
+ Reference< chart2::data::XDataProvider > xRet;
+ uno::Reference< container::XChild > xChild( xChartDoc, uno::UNO_QUERY );
+ if( xChild.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
+ if( xFact.is() )
+ {
+ const OUString aDataProviderServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"));
+ const uno::Sequence< OUString > aServiceNames( xFact->getAvailableServiceNames());
+ const OUString * pBegin = aServiceNames.getConstArray();
+ const OUString * pEnd = pBegin + aServiceNames.getLength();
+ if( ::std::find( pBegin, pEnd, aDataProviderServiceName ) != pEnd )
+ {
+ xRet = Reference< chart2::data::XDataProvider >(
+ xFact->createInstance( aDataProviderServiceName ), uno::UNO_QUERY );
+ }
+ }
+ }
+ return xRet;
+}
+
} // namespace SchXMLTools
diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx
index dad5a396b6c4..89d17fc440d9 100644
--- a/xmloff/source/chart/SchXMLTools.hxx
+++ b/xmloff/source/chart/SchXMLTools.hxx
@@ -53,10 +53,14 @@ class SvXMLExport;
namespace SchXMLTools
{
+ bool isDocumentGeneratedWithOpenOfficeOlderThan2_0( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
bool isDocumentGeneratedWithOpenOfficeOlderThan2_3( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
bool isDocumentGeneratedWithOpenOfficeOlderThan2_4( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
bool isDocumentGeneratedWithOpenOfficeOlderThan3_0( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
+ void setBuildIDAtImportInfo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel
+ , ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xImportInfo );
+
enum SchXMLChartTypeEnum
{
XML_CHART_CLASS_LINE,
@@ -65,9 +69,10 @@ namespace SchXMLTools
XML_CHART_CLASS_RING,
XML_CHART_CLASS_SCATTER,
XML_CHART_CLASS_RADAR,
+ XML_CHART_CLASS_FILLED_RADAR,
XML_CHART_CLASS_BAR,
XML_CHART_CLASS_STOCK,
- XML_CHART_CLASS_BUBBLE, // not yet implemented
+ XML_CHART_CLASS_BUBBLE,
XML_CHART_CLASS_ADDIN,
XML_CHART_CLASS_UNKNOWN
};
@@ -127,6 +132,16 @@ namespace SchXMLTools
::com::sun::star::chart2::data::XDataSequence > & xDataSequence,
::rtl::OUString & rOutXMLRange,
bool bClearProp = false );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > getDataProviderFromParent( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+
+ bool switchBackToDataProviderFromParent( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc
+ , const tSchXMLLSequencesPerIndex & rLSequencesPerIndex );
+
+ void copyProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xDestination );
}
#endif // SCH_XML_TOOLS_HXX_
diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx
index 41bb93fe4401..6046ec4606fc 100644
--- a/xmloff/source/chart/transporttypes.hxx
+++ b/xmloff/source/chart/transporttypes.hxx
@@ -136,9 +136,25 @@ struct SchXMLAxis
// ----------------------------------------
-// struct PostponedStyleObject
-// {
-// };
+struct GlobalSeriesImportInfo
+{
+ GlobalSeriesImportInfo( sal_Bool& rAllRangeAddressesAvailable )
+ : rbAllRangeAddressesAvailable( rAllRangeAddressesAvailable )
+ , nCurrentDataIndex( 0 )
+ , nFirstFirstDomainIndex( -1 )
+ , nFirstSecondDomainIndex( -1 )
+ {}
+
+ sal_Bool& rbAllRangeAddressesAvailable;
+
+ sal_Int32 nCurrentDataIndex;
+
+ ::rtl::OUString aFirstFirstDomainAddress;
+ sal_Int32 nFirstFirstDomainIndex;
+
+ ::rtl::OUString aFirstSecondDomainAddress;
+ sal_Int32 nFirstSecondDomainIndex;
+};
struct DataRowPointStyle
{
diff --git a/xmloff/source/core/RDFaExportHelper.cxx b/xmloff/source/core/RDFaExportHelper.cxx
new file mode 100644
index 000000000000..abd33ec80625
--- /dev/null
+++ b/xmloff/source/core/RDFaExportHelper.cxx
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RDFaExportHelper.cxx,v $
+ * $Revision: 1.1.2.4 $
+ *
+ * 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_xmloff.hxx"
+
+#include "RDFaExportHelper.hxx"
+
+#include "xmlnmspe.hxx"
+
+#include <xmloff/xmlexp.hxx>
+#include <xmloff/xmltoken.hxx>
+
+#include <comphelper/stlunosequence.hxx>
+#include <comphelper/stl_types.hxx>
+
+#include <com/sun/star/rdf/Statement.hpp>
+#include <com/sun/star/rdf/URIs.hpp>
+#include <com/sun/star/rdf/URI.hpp>
+#include <com/sun/star/rdf/XLiteral.hpp>
+#include <com/sun/star/rdf/XRepositorySupplier.hpp>
+#include <com/sun/star/rdf/XDocumentRepository.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <boost/bind.hpp>
+#include <boost/iterator_adaptors.hpp>
+#ifndef BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_ // from iterator_adaptors.hpp
+// N.B.: the check for the header guard _of a specific version of boost_
+// is here so this may work on different versions of boost,
+// which sadly put the goods in different header files
+#include <boost/iterator/transform_iterator.hpp>
+#endif
+
+#include <functional>
+#include <algorithm>
+
+
+using namespace ::com::sun::star;
+
+namespace xmloff {
+
+static const char s_prefix [] = "_:b";
+
+static ::rtl::OUString
+makeCURIE(SvXMLExport * i_pExport,
+ uno::Reference<rdf::XURI> const & i_xURI)
+{
+ OSL_ENSURE(i_xURI.is(), "makeCURIE: null URI");
+ if (!i_xURI.is()) throw uno::RuntimeException();
+
+ const ::rtl::OUString Namespace( i_xURI->getNamespace() );
+ OSL_ENSURE(Namespace.getLength(), "makeCURIE: no namespace");
+ if (!Namespace.getLength()) throw uno::RuntimeException();
+
+ ::rtl::OUStringBuffer buf;
+ buf.append( i_pExport->EnsureNamespace(Namespace) );
+ buf.append( static_cast<sal_Unicode>(':') );
+ // N.B.: empty LocalName is valid!
+ buf.append( i_xURI->getLocalName() );
+
+ return buf.makeStringAndClear();
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+RDFaExportHelper::RDFaExportHelper(SvXMLExport & i_rExport)
+ : m_rExport(i_rExport), m_xRepository(0), m_Counter(0)
+{
+ const uno::Reference<rdf::XRepositorySupplier> xRS( m_rExport.GetModel(),
+ uno::UNO_QUERY);
+ OSL_ENSURE(xRS.is(), "AddRDFa: model is no rdf::XRepositorySupplier");
+ if (!xRS.is()) throw uno::RuntimeException();
+ m_xRepository.set(xRS->getRDFRepository(), uno::UNO_QUERY_THROW);
+
+ const uno::Reference<rdf::XURI> xLabel(
+ rdf::URI::createKnown(m_rExport.GetComponentContext(),
+ rdf::URIs::RDFS_LABEL));
+ m_RDFsLabel = xLabel->getStringValue();
+}
+
+::rtl::OUString
+RDFaExportHelper::LookupBlankNode(
+ uno::Reference<rdf::XBlankNode> const & i_xBlankNode)
+{
+ OSL_ENSURE(i_xBlankNode.is(), "null BlankNode?");
+ if (!i_xBlankNode.is()) throw uno::RuntimeException();
+ ::rtl::OUString & rEntry(
+ m_BlankNodeMap[ i_xBlankNode->getStringValue() ] );
+ if (!rEntry.getLength())
+ {
+ ::rtl::OUStringBuffer buf;
+ buf.appendAscii(s_prefix);
+ buf.append(++m_Counter);
+ rEntry = buf.makeStringAndClear();
+ }
+ return rEntry;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+void
+RDFaExportHelper::AddRDFa(
+ uno::Reference<rdf::XMetadatable> const & i_xMetadatable)
+{
+ try
+ {
+ uno::Sequence<rdf::Statement> stmts(
+ m_xRepository->getStatementRDFa(i_xMetadatable) );
+
+ if (0 == stmts.getLength())
+ {
+ return; // no RDFa
+ }
+
+ // all stmts have the same subject, so we only handle first one
+ const uno::Reference<rdf::XURI> xSubjectURI(stmts[0].Subject,
+ uno::UNO_QUERY);
+ const uno::Reference<rdf::XBlankNode> xSubjectBNode(stmts[0].Subject,
+ uno::UNO_QUERY);
+ if (!xSubjectURI.is() && !xSubjectBNode.is())
+ {
+ throw uno::RuntimeException();
+ }
+ static const sal_Unicode s_OpenBracket ('[');
+ static const sal_Unicode s_CloseBracket(']');
+ const ::rtl::OUString about( xSubjectURI.is()
+ ? m_rExport.GetRelativeReference(xSubjectURI->getStringValue())
+ : ::rtl::OUStringBuffer().append(s_OpenBracket).append(
+ LookupBlankNode(xSubjectBNode)).append(s_CloseBracket)
+ .makeStringAndClear()
+ );
+
+ rdf::Statement* const iter
+ ( ::std::partition( ::comphelper::stl_begin(stmts),
+ ::comphelper::stl_end(stmts),
+ ::boost::bind(&::rtl::OUString::equals, m_RDFsLabel,
+ ::boost::bind(&rdf::XNode::getStringValue,
+ ::boost::bind(&rdf::Statement::Predicate, _1))) ) );
+
+ if (iter != ::comphelper::stl_end(stmts))
+ {
+ // from iter to end, all stmts should have same object
+ const uno::Reference<rdf::XLiteral> xContent(
+ (*iter).Object, uno::UNO_QUERY_THROW );
+ const uno::Reference<rdf::XURI> xDatatype(xContent->getDatatype());
+ if (xDatatype.is())
+ {
+ const ::rtl::OUString datatype(
+ makeCURIE(&m_rExport, xDatatype) );
+ m_rExport.AddAttribute(XML_NAMESPACE_XHTML,
+ token::XML_DATATYPE, datatype);
+ }
+ if (iter != ::comphelper::stl_begin(stmts)) // there is rdfs:label
+ {
+ m_rExport.AddAttribute(XML_NAMESPACE_XHTML, token::XML_CONTENT,
+ xContent->getValue());
+ }
+ }
+ else
+ {
+ OSL_ENSURE(false,"invalid RDFa: every property is rdfs:label");
+ return;
+ }
+
+ ::rtl::OUStringBuffer property;
+ ::comphelper::intersperse(
+ ::boost::make_transform_iterator(
+ iter, // omit RDFsLabel predicates!
+ ::boost::bind(&makeCURIE, &m_rExport,
+ ::boost::bind(&rdf::Statement::Predicate, _1))),
+ // argh, this must be the same type :(
+ ::boost::make_transform_iterator(
+ ::comphelper::stl_end(stmts),
+ ::boost::bind(&makeCURIE, &m_rExport,
+ ::boost::bind(&rdf::Statement::Predicate, _1))),
+ ::comphelper::OUStringBufferAppender(property),
+ ::rtl::OUString::createFromAscii(" "));
+
+ m_rExport.AddAttribute(XML_NAMESPACE_XHTML, token::XML_PROPERTY,
+ property.makeStringAndClear());
+
+ m_rExport.AddAttribute(XML_NAMESPACE_XHTML, token::XML_ABOUT, about);
+ }
+ catch (uno::Exception &)
+ {
+ OSL_ENSURE(false, "AddRDFa: exception");
+ }
+}
+
+} // namespace xmloff
+
diff --git a/xmloff/source/core/RDFaImportHelper.cxx b/xmloff/source/core/RDFaImportHelper.cxx
new file mode 100644
index 000000000000..7191a6db6739
--- /dev/null
+++ b/xmloff/source/core/RDFaImportHelper.cxx
@@ -0,0 +1,458 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RDFaImportHelper.cxx,v $
+ * $Revision: 1.1.2.6 $
+ *
+ * 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_xmloff.hxx"
+
+#include "RDFaImportHelper.hxx"
+
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/nmspmap.hxx>
+
+#include <comphelper/sequenceasvector.hxx>
+
+#include <tools/string.hxx> // for GetAbsoluteReference
+
+#include <com/sun/star/rdf/URI.hpp>
+#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
+#include <com/sun/star/rdf/XDocumentRepository.hpp>
+
+#include <rtl/ustring.hxx>
+
+#include <boost/bind.hpp>
+#include <boost/iterator_adaptors.hpp>
+#ifndef BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_ // from iterator_adaptors.hpp
+// N.B.: the check for the header guard _of a specific version of boost_
+// is here so this may work on different versions of boost,
+// which sadly put the goods in different header files
+#include <boost/iterator/transform_iterator.hpp>
+#endif
+
+#include <map>
+#include <iterator>
+#include <functional>
+#include <algorithm>
+
+
+using namespace ::com::sun::star;
+
+namespace xmloff {
+
+/** a bit of context for parsing RDFa attributes */
+class SAL_DLLPRIVATE RDFaReader
+{
+ const SvXMLImport & m_rImport;
+
+ const SvXMLImport & GetImport() const { return m_rImport; }
+
+ //FIXME: this is an ugly hack to workaround buggy SvXMLImport::GetAbsolute
+ ::rtl::OUString GetAbsoluteReference(::rtl::OUString const & i_rURI) const
+ {
+ if (!i_rURI.getLength() || i_rURI[0] == '#')
+ {
+ return GetImport().GetBaseURL() + i_rURI;
+ }
+ else
+ {
+ return GetImport().GetAbsoluteReference(i_rURI);
+ }
+ }
+
+public:
+ RDFaReader(SvXMLImport const & i_rImport)
+ : m_rImport(i_rImport)
+ { }
+
+ // returns URI or blank node!
+ ::rtl::OUString ReadCURIE(::rtl::OUString const & i_rCURIE) const;
+
+ std::vector< ::rtl::OUString >
+ ReadCURIEs(::rtl::OUString const & i_rCURIEs) const;
+
+ ::rtl::OUString
+ ReadURIOrSafeCURIE( ::rtl::OUString const & i_rURIOrSafeCURIE) const;
+};
+
+/** helper to insert RDFa statements into the RDF repository */
+class SAL_DLLPRIVATE RDFaInserter
+{
+ const uno::Reference<uno::XComponentContext> m_xContext;
+ uno::Reference< rdf::XDocumentRepository > m_xRepository;
+
+ typedef ::std::map< ::rtl::OUString, uno::Reference< rdf::XBlankNode > >
+ BlankNodeMap_t;
+
+ BlankNodeMap_t m_BlankNodeMap;
+
+public:
+ RDFaInserter(uno::Reference<uno::XComponentContext> const & i_xContext,
+ uno::Reference< rdf::XDocumentRepository > const & i_xRepository)
+ : m_xContext(i_xContext)
+ , m_xRepository(i_xRepository)
+ {}
+
+ uno::Reference< rdf::XBlankNode >
+ LookupBlankNode(::rtl::OUString const & i_rNodeId );
+
+ uno::Reference< rdf::XURI >
+ MakeURI( ::rtl::OUString const & i_rURI) const;
+
+ uno::Reference< rdf::XResource>
+ MakeResource( ::rtl::OUString const & i_rResource);
+
+ void InsertRDFaEntry(struct RDFaEntry const & i_rEntry);
+};
+
+/** store metadatable object and its RDFa attributes */
+struct SAL_DLLPRIVATE RDFaEntry
+{
+ uno::Reference<rdf::XMetadatable> m_xObject;
+ ::rtl::OUString m_About;
+ ::std::vector< ::rtl::OUString > m_Properties;
+ ::rtl::OUString m_Content;
+ ::rtl::OUString m_Datatype;
+
+ RDFaEntry(uno::Reference<rdf::XMetadatable> i_xObject,
+ ::rtl::OUString const & i_rAbout,
+ ::std::vector< ::rtl::OUString > const & i_rProperties,
+ ::rtl::OUString const & i_rContent,
+ ::rtl::OUString const & i_rDatatype)
+ : m_xObject(i_xObject)
+ , m_About(i_rAbout)
+ , m_Properties(i_rProperties)
+ , m_Content(i_rContent)
+ , m_Datatype(i_rDatatype)
+ { }
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+
+static inline bool isWS(const sal_Unicode i_Char)
+{
+ return ('\t' == i_Char) || ('\n' == i_Char) || ('\r' == i_Char)
+ || (' ' == i_Char);
+}
+
+static ::rtl::OUString splitAtWS(::rtl::OUString & io_rString)
+{
+ const sal_Int32 len( io_rString.getLength() );
+ sal_Int32 idxstt(0);
+ while ((idxstt < len) && ( isWS(io_rString[idxstt])))
+ ++idxstt; // skip leading ws
+ sal_Int32 idxend(idxstt);
+ while ((idxend < len) && (!isWS(io_rString[idxend])))
+ ++idxend; // the CURIE
+ const ::rtl::OUString ret(io_rString.copy(idxstt, idxend - idxstt));
+ io_rString = io_rString.copy(idxend); // rest
+ return ret;
+}
+
+::rtl::OUString
+RDFaReader::ReadCURIE(::rtl::OUString const & i_rCURIE) const
+{
+ // the RDFa spec says that a prefix is required (it may be empty: ":foo")
+ const sal_Int32 idx( i_rCURIE.indexOf(':') );
+ if (idx >= 0)
+ {
+ ::rtl::OUString Prefix;
+ ::rtl::OUString LocalName;
+ ::rtl::OUString Namespace;
+ sal_uInt16 nKey( GetImport().GetNamespaceMap()._GetKeyByAttrName(
+ i_rCURIE, &Prefix, &LocalName, &Namespace) );
+ if (Prefix.equalsAscii("_"))
+ {
+ // eeek, it's a bnode!
+ // "_" is not a valid URI scheme => we can identify bnodes
+ return i_rCURIE;
+ }
+ else
+ {
+ OSL_ENSURE(XML_NAMESPACE_NONE != nKey, "no namespace?");
+ if ((XML_NAMESPACE_UNKNOWN != nKey) &&
+ (XML_NAMESPACE_XMLNS != nKey))
+ {
+ // N.B.: empty LocalName is valid!
+ const ::rtl::OUString URI(Namespace + LocalName);
+// return GetImport().GetAbsoluteReference(URI);
+ return GetAbsoluteReference(URI);
+ }
+ else
+ {
+ OSL_TRACE( "ReadCURIE: invalid CURIE: invalid prefix" );
+ return ::rtl::OUString();
+ }
+ }
+ }
+ else
+ {
+ OSL_TRACE( "ReadCURIE: invalid CURIE: no prefix" );
+ return ::rtl::OUString();
+ }
+}
+
+::std::vector< ::rtl::OUString >
+RDFaReader::ReadCURIEs(::rtl::OUString const & i_rCURIEs) const
+{
+ std::vector< ::rtl::OUString > vec;
+ ::rtl::OUString CURIEs(i_rCURIEs);
+ do {
+ ::rtl::OUString curie( splitAtWS(CURIEs) );
+ if (curie.getLength())
+ {
+ const ::rtl::OUString uri(ReadCURIE(curie));
+ if (uri.getLength())
+ {
+ vec.push_back(uri);
+ }
+ }
+ }
+ while (CURIEs.getLength());
+ if (!vec.size())
+ {
+ OSL_TRACE( "ReadCURIEs: invalid CURIEs" );
+ }
+ return vec;
+}
+
+::rtl::OUString
+RDFaReader::ReadURIOrSafeCURIE(::rtl::OUString const & i_rURIOrSafeCURIE) const
+{
+ const sal_Int32 len(i_rURIOrSafeCURIE.getLength());
+ if (len && (i_rURIOrSafeCURIE[0] == '['))
+ {
+ if ((len >= 2) && (i_rURIOrSafeCURIE[len - 1] == ']'))
+ {
+ return ReadCURIE(i_rURIOrSafeCURIE.copy(1, len - 2));
+ }
+ else
+ {
+ OSL_TRACE( "ReadURIOrSafeCURIE: invalid SafeCURIE" );
+ return ::rtl::OUString();
+ }
+ }
+ else
+ {
+ if (i_rURIOrSafeCURIE.matchAsciiL("_:", 2)) // blank node
+ {
+ OSL_TRACE( "ReadURIOrSafeCURIE: invalid URI: scheme is _" );
+ return ::rtl::OUString();
+ }
+ else
+ {
+// return GetImport().GetAbsoluteReference(i_rURIOrSafeCURIE);
+ return GetAbsoluteReference(i_rURIOrSafeCURIE);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+uno::Reference< rdf::XBlankNode >
+RDFaInserter::LookupBlankNode(::rtl::OUString const & i_rNodeId )
+{
+ uno::Reference< rdf::XBlankNode > & rEntry( m_BlankNodeMap[ i_rNodeId ] );
+ if (!rEntry.is())
+ {
+ rEntry = m_xRepository->createBlankNode();
+ }
+ return rEntry;
+}
+
+uno::Reference< rdf::XURI >
+RDFaInserter::MakeURI( ::rtl::OUString const & i_rURI) const
+{
+ if (i_rURI.matchAsciiL("_:", 2)) // blank node
+ {
+ OSL_TRACE("MakeURI: cannot create URI for blank node");
+ return 0;
+ }
+ else
+ {
+ try
+ {
+ return rdf::URI::create( m_xContext, i_rURI );
+ }
+ catch (uno::Exception &)
+ {
+ OSL_ENSURE(false, "MakeURI: cannot create URI");
+ return 0;
+ }
+ }
+}
+
+uno::Reference< rdf::XResource>
+RDFaInserter::MakeResource( ::rtl::OUString const & i_rResource)
+{
+ if (i_rResource.matchAsciiL("_:", 2)) // blank node
+ {
+ // we cannot use the blank node label as-is: it must be distinct
+ // from labels in other graphs, so create fresh ones per XML stream
+ // N.B.: content.xml and styles.xml are distinct graphs
+ ::rtl::OUString name( i_rResource.copy(2) );
+ const uno::Reference< rdf::XBlankNode > xBNode( LookupBlankNode(name) );
+ OSL_ENSURE(xBNode.is(), "no blank node?");
+ return uno::Reference<rdf::XResource>( xBNode, uno::UNO_QUERY);
+ }
+ else
+ {
+ return uno::Reference<rdf::XResource>( MakeURI( i_rResource ),
+ uno::UNO_QUERY);
+ }
+}
+
+/** i wrote this because c++ implementations cannot agree on which variant
+ of boost::bind and std::mem_fun_ref applied to Reference::is compiles */
+class ref_is_null :
+ public ::std::unary_function<sal_Bool, const uno::Reference<rdf::XURI> & >
+{
+public:
+ sal_Bool operator() (const uno::Reference<rdf::XURI> & i_rRef)
+ {
+ return !i_rRef.is();
+ }
+};
+
+void RDFaInserter::InsertRDFaEntry(
+ struct RDFaEntry const & i_rEntry)
+{
+ OSL_ENSURE(i_rEntry.m_xObject.is(),
+ "InsertRDFaEntry: invalid arg: null object");
+ if (!i_rEntry.m_xObject.is()) return;
+
+ const uno::Reference< rdf::XResource > xSubject(
+ MakeResource( i_rEntry.m_About ) );
+ if (!xSubject.is())
+ {
+ return; // invalid
+ }
+
+ ::comphelper::SequenceAsVector< uno::Reference< rdf::XURI > > predicates;
+
+ predicates.reserve(i_rEntry.m_Properties.size());
+
+ ::std::remove_copy_if(
+ ::boost::make_transform_iterator(i_rEntry.m_Properties.begin(),
+ ::boost::bind(&RDFaInserter::MakeURI, this, _1)),
+ // argh, this must be the same type :(
+ ::boost::make_transform_iterator(i_rEntry.m_Properties.end(),
+ ::boost::bind(&RDFaInserter::MakeURI, this, _1)),
+ ::std::back_inserter(predicates),
+ ref_is_null() );
+ // compiles only on wntmsci12
+// ::boost::bind( ::std::logical_not<sal_Bool>(), ::boost::bind<sal_Bool>(&uno::Reference<rdf::XURI>::is, _1)));
+ // compiles on unxsoli4, wntsci12, but not unxlngi6
+// ::boost::bind( ::std::logical_not<sal_Bool>(), ::boost::bind<sal_Bool, com::sun::star::uno::Reference<rdf::XURI> >(&uno::Reference<rdf::XURI>::is, _1)));
+ // compiles on unxsoli4, unxlngi6, but not wntsci12
+// ::std::not1( ::std::mem_fun_ref(&uno::Reference<rdf::XURI>::is)) );
+
+ if (!predicates.size())
+ {
+ return; // invalid
+ }
+
+ uno::Reference<rdf::XURI> xDatatype;
+ if (i_rEntry.m_Datatype.getLength())
+ {
+ xDatatype = MakeURI( i_rEntry.m_Datatype );
+ }
+
+ try
+ {
+ // N.B.: this will call xMeta->ensureMetadataReference, which is why
+ // this must be done _after_ importing the whole XML file,
+ // to prevent collision between generated ids and ids in the file
+ m_xRepository->setStatementRDFa(xSubject, predicates.getAsConstList(),
+ i_rEntry.m_xObject, i_rEntry.m_Content, xDatatype);
+ }
+ catch (uno::Exception &)
+ {
+ OSL_ENSURE(false, "InsertRDFaEntry: setStatementRDFa failed?");
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+RDFaImportHelper::RDFaImportHelper(const SvXMLImport & i_rImport)
+ : m_rImport(i_rImport)
+{
+}
+
+RDFaImportHelper::~RDFaImportHelper()
+{
+}
+
+void
+RDFaImportHelper::AddRDFa(
+ uno::Reference<rdf::XMetadatable> i_xObject,
+ ::rtl::OUString const & i_rAbout,
+ ::rtl::OUString const & i_rProperty,
+ ::rtl::OUString const & i_rContent,
+ ::rtl::OUString const & i_rDatatype)
+{
+ if (!i_rProperty.getLength())
+ {
+ OSL_TRACE("AddRDFa: invalid input: xhtml:property empty");
+ return;
+ }
+ if (!i_xObject.is())
+ {
+ OSL_ENSURE(false, "AddRDFa: invalid arg: null textcontent");
+ return;
+ }
+ // must parse CURIEs here: need namespace declaration context
+ RDFaReader reader(GetImport());
+ const ::rtl::OUString about( reader.ReadURIOrSafeCURIE(i_rAbout) );
+ if (!about.getLength()) return;
+ const ::std::vector< ::rtl::OUString > properties(
+ reader.ReadCURIEs(i_rProperty) );
+ if (!properties.size()) return;
+ const ::rtl::OUString datatype( i_rDatatype.getLength()
+ ? reader.ReadCURIE(i_rDatatype)
+ : ::rtl::OUString() );
+ m_RDFaEntries.push_back(RDFaEntry(i_xObject,
+ about, properties, i_rContent, datatype));
+}
+
+void RDFaImportHelper::InsertRDFa(
+ uno::Reference< rdf::XRepositorySupplier> const & i_xModel)
+{
+ OSL_ENSURE(i_xModel.is(), "InsertRDFa: invalid arg: model null");
+ if (!i_xModel.is()) return;
+ const uno::Reference< rdf::XDocumentRepository > xRepository(
+ i_xModel->getRDFRepository(), uno::UNO_QUERY);
+ OSL_ENSURE(xRepository.is(), "InsertRDFa: no DocumentRepository?");
+ if (!xRepository.is()) return;
+ RDFaInserter inserter(GetImport().GetComponentContext(), xRepository);
+ ::std::for_each(m_RDFaEntries.begin(), m_RDFaEntries.end(),
+ ::boost::bind(&RDFaInserter::InsertRDFaEntry, &inserter, _1));
+}
+
+} // namespace xmloff
+
diff --git a/xmloff/source/core/makefile.mk b/xmloff/source/core/makefile.mk
index c68981c27496..b9cb8e9c1b60 100644
--- a/xmloff/source/core/makefile.mk
+++ b/xmloff/source/core/makefile.mk
@@ -77,7 +77,10 @@ SLOFILES = \
$(SLO)$/XMLEmbeddedObjectImportContext.obj \
$(SLO)$/XMLBase64Export.obj \
$(SLO)$/XMLBase64ImportContext.obj \
- $(SLO)$/XMLBasicExportFilter.obj
+ $(SLO)$/XMLBasicExportFilter.obj \
+ $(SLO)$/RDFaImportHelper.obj \
+ $(SLO)$/RDFaExportHelper.obj \
+
# --- Targets -------------------------------------------------------
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 7f46b1c5c25c..733ad909ef4f 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -63,9 +63,7 @@
#include <xmloff/SettingsExportHelper.hxx>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
-#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP
#include <com/sun/star/document/XEventsSupplier.hpp>
-#endif
#include <com/sun/star/document/XViewDataSupplier.hpp>
#include <GradientStyle.hxx>
#include <HatchStyle.hxx>
@@ -73,16 +71,10 @@
#include <TransGradientStyle.hxx>
#include <MarkerStyle.hxx>
#include <DashStyle.hxx>
-#ifndef _XMLOFF_XMLFONTAUTOSTYLEPOOL_HXX
-#include <xmloff/XMLFontAutoStylePool>
-#endif
+#include <xmloff/XMLFontAutoStylePool.hxx>
#include "XMLImageMapExport.hxx"
-#ifndef _XMLOFF_XMLBASE64EXPORT_HXX_
#include "XMLBase64Export.hxx"
-#endif
-#ifndef _XMLOFF_XMLERROR_HXX_
#include "xmlerror.hxx"
-#endif
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include "XMLFilterServiceNames.h"
@@ -105,6 +97,7 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/rdf/XMetadatable.hpp>
+#include "RDFaExportHelper.hxx"
using ::rtl::OUString;
@@ -126,6 +119,9 @@ sal_Char __READONLY_DATA sXML_1_2[] = "1.2";
const sal_Char *sOpenOfficeOrgProject ="OpenOffice.org_project";
+const sal_Char s_grddl_xsl[] =
+ "http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl";
+
#define LOGFILE_AUTHOR "mb93740"
#define XML_MODEL_SERVICE_WRITER "com.sun.star.text.TextDocument"
@@ -223,6 +219,19 @@ public:
/// relative path of stream in package, e.g. "someobject/content.xml"
::rtl::OUString mStreamPath;
+ const uno::Reference< uno::XComponentContext > mxComponentContext;
+
+ /// name of stream in package, e.g., "content.xml"
+ ::rtl::OUString mStreamName;
+
+ /// stack of backed up namespace maps
+ /// long: depth at which namespace map has been backed up into the stack
+ ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps;
+ /// counts depth (number of open elements/start tags)
+ long mDepth;
+
+ ::std::auto_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper;
+
// --> OD 2008-11-26 #158694#
sal_Bool mbExportTextNumberElement;
// <--
@@ -243,14 +252,20 @@ SvXMLExport_Impl::SvXMLExport_Impl()
// --> PB 2007-07-06 #i146851#
,mbSaveBackwardCompatibleODF( sal_True )
// <--
- ,mStreamPath()
+ ,mxComponentContext( ::comphelper::getProcessComponentContext() )
+ ,mStreamName()
+ ,mNamespaceMaps()
+ ,mDepth(0)
+ ,mpRDFaHelper() // lazy
// --> OD 2008-11-26 #158694#
,mbExportTextNumberElement( sal_False )
// <--
,mbNullDateInitialized( sal_False )
{
+ OSL_ENSURE(mxComponentContext.is(), "SvXMLExport: no ComponentContext");
+ if (!mxComponentContext.is()) throw uno::RuntimeException();
mxUriReferenceFactory = uri::UriReferenceFactory::create(
- comphelper_getProcessComponentContext());
+ mxComponentContext );
}
//==============================================================================
@@ -325,9 +340,17 @@ void SvXMLExport::_InitCtor()
mpNamespaceMap->Add( GetXMLToken(XML_NP_XSI), GetXMLToken(XML_N_XSI), XML_NAMESPACE_XSI );
mpNamespaceMap->Add( GetXMLToken(XML_NP_FIELD), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
}
+ // RDFa: needed for content and header/footer styles
if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
{
- mpNamespaceMap->Add( GetXMLToken(XML_NP_RDFA), GetXMLToken(XML_N_RDFA), XML_NAMESPACE_RDFA );
+ mpNamespaceMap->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 )
+ {
+ mpNamespaceMap->Add( GetXMLToken(XML_NP_GRDDL),
+ GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL );
}
mxAttrList = (xml::sax::XAttributeList*)mpAttrList;
@@ -762,9 +785,7 @@ void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArgumen
aBaseURL.insertName( sName );
msOrigFileName = aBaseURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
}
- OSL_ENSURE(sName.getLength(), "no StreamName ???");
- mpImpl->mStreamPath = sRelPath.getLength() ? sRelPath +
- ::rtl::OUString::createFromAscii("/") + sName : sName;
+ mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
// --> OD 2006-09-26 #i69627#
const ::rtl::OUString sOutlineStyleAsNormalListStyle(
@@ -914,6 +935,54 @@ uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
///////////////////////////////////////////////////////////////////////
+::rtl::OUString
+SvXMLExport::EnsureNamespace(::rtl::OUString const & i_rNamespace,
+ ::rtl::OUString const & i_rPreferredPrefix)
+{
+ ::rtl::OUString sPrefix;
+ sal_uInt16 nKey( _GetNamespaceMap().GetKeyByName( i_rNamespace ) );
+ if( XML_NAMESPACE_UNKNOWN == nKey )
+ {
+ // There is no prefix for the namespace, so
+ // we have to generate one and have to add it.
+ sPrefix = i_rPreferredPrefix;
+ nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix );
+ sal_Int32 n( 0 );
+ ::rtl::OUStringBuffer buf;
+ while( nKey != USHRT_MAX )
+ {
+ buf.append( i_rPreferredPrefix );
+ buf.append( ++n );
+ sPrefix = buf.makeStringAndClear();
+ nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix );
+ }
+
+ if (mpImpl->mNamespaceMaps.empty()
+ || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
+ {
+ // top was created for lower depth... need a new namespace map!
+ mpImpl->mNamespaceMaps.push(
+ ::std::make_pair(mpNamespaceMap, mpImpl->mDepth) );
+ mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
+ }
+
+ // add the namespace to the map and as attribute
+ mpNamespaceMap->Add( sPrefix, i_rNamespace );
+ buf.append( GetXMLToken(XML_XMLNS) );
+ buf.append( sal_Unicode(':') );
+ buf.append( sPrefix );
+ AddAttribute( buf.makeStringAndClear(), i_rNamespace );
+ }
+ else
+ {
+ // If there is a prefix for the namespace, reuse that.
+ sPrefix = _GetNamespaceMap().GetPrefixByKey( nKey );
+ }
+ return sPrefix;
+}
+
+///////////////////////////////////////////////////////////////////////
+
void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey,
const sal_Char *pName,
const sal_Char *pValue )
@@ -921,9 +990,8 @@ void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey,
OUString sName( OUString::createFromAscii( pName ) );
OUString sValue( OUString::createFromAscii( pValue ) );
- mpAttrList->AddAttribute( mpNamespaceMap->GetQNameByKey( nPrefixKey,
- sName ),
- sValue );
+ mpAttrList->AddAttribute(
+ _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), sValue );
}
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
@@ -931,16 +999,15 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
{
OUString sName( OUString::createFromAscii( pName ) );
- mpAttrList->AddAttribute( mpNamespaceMap->GetQNameByKey( nPrefixKey,
- sName ),
- rValue );
+ mpAttrList->AddAttribute(
+ _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), rValue );
}
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
const OUString& rValue )
{
- mpAttrList->AddAttribute( mpNamespaceMap->GetQNameByKey( nPrefixKey, rName ),
- rValue );
+ mpAttrList->AddAttribute(
+ _GetNamespaceMap().GetQNameByKey( nPrefixKey, rName ), rValue );
}
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
@@ -948,7 +1015,7 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
const OUString& rValue )
{
mpAttrList->AddAttribute(
- mpNamespaceMap->GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
+ _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
rValue );
}
@@ -957,7 +1024,7 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
enum XMLTokenEnum eValue)
{
mpAttrList->AddAttribute(
- mpNamespaceMap->GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
+ _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
GetXMLToken(eValue) );
}
@@ -1307,6 +1374,13 @@ sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
{
enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS);
+
+ if ( EXPORT_SETTINGS != nExportMode ) // meta, content, styles
+ {
+ AddAttribute( XML_NAMESPACE_GRDDL, XML_TRANSFORMATION,
+ OUString::createFromAscii(s_grddl_xsl) );
+ }
+
if( EXPORT_META == nExportMode )
{
// export only meta
@@ -2159,7 +2233,8 @@ void SvXMLExport::StartElement(sal_uInt16 nPrefix,
enum ::xmloff::token::XMLTokenEnum eName,
sal_Bool bIgnWSOutside )
{
- StartElement(mpNamespaceMap->GetQNameByKey( nPrefix, GetXMLToken(eName) ), bIgnWSOutside);
+ StartElement(_GetNamespaceMap().GetQNameByKey( nPrefix,
+ GetXMLToken(eName) ), bIgnWSOutside);
}
void SvXMLExport::StartElement(const OUString& rName,
@@ -2188,6 +2263,7 @@ void SvXMLExport::StartElement(const OUString& rName,
}
}
ClearAttrList();
+ ++mpImpl->mDepth; // increment nesting depth counter
}
void SvXMLExport::Characters(const ::rtl::OUString& rChars)
@@ -2218,12 +2294,26 @@ void SvXMLExport::EndElement(sal_uInt16 nPrefix,
enum ::xmloff::token::XMLTokenEnum eName,
sal_Bool bIgnWSInside )
{
- EndElement(mpNamespaceMap->GetQNameByKey( nPrefix, GetXMLToken(eName) ), bIgnWSInside);
+ EndElement(_GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
+ bIgnWSInside);
}
void SvXMLExport::EndElement(const OUString& rName,
sal_Bool bIgnWSInside )
{
+ // decrement nesting depth counter & (maybe) restore namespace map
+ --mpImpl->mDepth;
+ if (!mpImpl->mNamespaceMaps.empty() &&
+ (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
+ {
+ delete mpNamespaceMap;
+ mpNamespaceMap = mpImpl->mNamespaceMaps.top().first;
+ mpImpl->mNamespaceMaps.pop();
+ }
+ OSL_ENSURE(mpImpl->mNamespaceMaps.empty() ||
+ (mpImpl->mNamespaceMaps.top().second < mpImpl->mDepth),
+ "SvXMLExport: NamespaceMaps corrupted");
+
if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
{
try
@@ -2319,6 +2409,12 @@ void SvXMLExport::DisposingModel()
return mxServiceFactory;
}
+uno::Reference< uno::XComponentContext >
+SvXMLExport::GetComponentContext() const
+{
+ return mpImpl->mxComponentContext;
+}
+
::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLExport::getInterfaceToIdentifierMapper()
{
return mpImpl->maInterfaceToIdentifierMapper;
@@ -2346,23 +2442,9 @@ SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const
return SvtSaveOptions::ODFVER_012;
}
-::rtl::OUString SvXMLExport::GetStreamPath() const
-{
- return mpImpl->mStreamPath;
-}
-
-//FIXME: where to put this???
-static bool splitXmlId(::rtl::OUString const & i_XmlId,
- ::rtl::OUString & o_StreamName, ::rtl::OUString& o_Idref )
+::rtl::OUString SvXMLExport::GetStreamName() const
{
- const sal_Int32 idx(i_XmlId.indexOf(static_cast<sal_Unicode>('#')));
- if ((idx <= 0) || (idx >= i_XmlId.getLength() - 1)) {
- return false;
- } else {
- o_StreamName = (i_XmlId.copy(0, idx));
- o_Idref = (i_XmlId.copy(idx+1));
- return true;
- }
+ return mpImpl->mStreamName;
}
void
@@ -2380,30 +2462,69 @@ SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
// OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
if ( xMeta.is() )
{
- const ::rtl::OUString XmlId( xMeta->getXmlId() );
- if ( !XmlId.equalsAscii("") )
+ const beans::StringPair mdref( xMeta->getMetadataReference() );
+ if ( !mdref.Second.equalsAscii("") )
{
- ::rtl::OUString StreamName;
- ::rtl::OUString Idref;
- if( splitXmlId(XmlId, StreamName, Idref) )
+ const ::rtl::OUString streamName( GetStreamName() );
+ if ( streamName.getLength() )
{
- if ( GetStreamPath().equals(StreamName) )
+ if ( streamName.equals(mdref.First) )
{
- AddAttribute( XML_NAMESPACE_XML, XML_ID, Idref );
+ AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
}
else
{
- OSL_ENSURE(false, "xml:id: invalid stream name");
+ OSL_ENSURE(false, "SvXMLExport::AddAttributeXmlId: "
+ "invalid stream name");
}
}
else
{
- OSL_ENSURE(false, "xml:id invalid?");
+ // FIXME: this is ugly
+ // there is no stream name (e.g. XSLT, flat-xml format)!
+ // but how do we ensure uniqueness in this case?
+ // a) just omit styles.xml ids -- they are unlikely anyway...
+ // b) somehow find out whether we are currently exporting styles
+ // or content, and prefix "s" or "c" => unique
+ if ( mdref.First.equalsAscii("content.xml") )
+ {
+ AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
+ }
+ else
+ {
+ OSL_TRACE("SvXMLExport::AddAttributeXmlId: "
+ "no stream name given: dropping styles.xml xml:id");
+ }
}
}
}
}
+void
+SvXMLExport::AddAttributesRDFa(
+ uno::Reference<text::XTextContent> const & i_xTextContent)
+{
+ // check version >= 1.2
+ switch (getDefaultVersion()) {
+ case SvtSaveOptions::ODFVER_011: // fall thru
+ case SvtSaveOptions::ODFVER_010: return;
+ default: break;
+ }
+
+ const uno::Reference<rdf::XMetadatable> xMeta(
+ i_xTextContent, uno::UNO_QUERY);
+ if (!xMeta.is() || !xMeta->getMetadataReference().Second.getLength())
+ {
+ return; // no xml:id => no RDFa
+ }
+
+ if (!mpImpl->mpRDFaHelper.get())
+ {
+ mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
+ }
+ mpImpl->mpRDFaHelper->AddRDFa(xMeta);
+}
+
// --> OD 2008-11-26 #158694#
sal_Bool SvXMLExport::exportTextNumberElement() const
{
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index c744e21f6a6c..cd3f411c3c88 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -64,9 +64,12 @@
#include <tools/string.hxx> // used in StartElement for logging
#include <cppuhelper/implbase1.hxx>
#include <comphelper/extract.hxx>
+#include <comphelper/processfactory.hxx>
#include <vcl/fontcvt.hxx>
#include <com/sun/star/rdf/XMetadatable.hpp>
+#include <com/sun/star/rdf/XRepositorySupplier.hpp>
+#include "RDFaImportHelper.hxx"
#define LOGFILE_AUTHOR "unknown"
@@ -111,6 +114,7 @@ sal_Char __READONLY_DATA sXML_np__xforms[] = "_xforms";
sal_Char __READONLY_DATA sXML_np__xsd[] = "_xsd";
sal_Char __READONLY_DATA sXML_np__xsi[] = "_xsi";
sal_Char __READONLY_DATA sXML_np__field[] = "_field";
+sal_Char __READONLY_DATA sXML_np__xhtml[] = "_xhtml";
sal_Char __READONLY_DATA sXML_np__fo_old[] = "__fo";
sal_Char __READONLY_DATA sXML_np__xlink_old[] = "__xlink";
@@ -169,8 +173,8 @@ public:
INetURLObject aBaseURL;
INetURLObject aDocBase;
- /// relative path of stream in package, e.g. "someobject/content.xml"
- ::rtl::OUString mStreamPath;
+ /// name of stream in package, e.g., "content.xml"
+ ::rtl::OUString mStreamName;
::rtl::OUString aODFVersion;
@@ -183,18 +187,28 @@ public:
sal_Bool mbTextDocInOOoFileFormat;
// <--
+ const uno::Reference< uno::XComponentContext > mxComponentContext;
+
+ std::auto_ptr< xmloff::RDFaImportHelper > mpRDFaHelper;
+
SvXMLImport_Impl() :
hBatsFontConv( 0 ), hMathFontConv( 0 ),
mbOwnGraphicResolver( false ),
mbOwnEmbeddedResolver( false ),
- mStreamPath(),
+ mStreamName(),
// --> OD 2004-08-11 #i28749#
mbShapePositionInHoriL2R( sal_False ),
// <--
// --> OD 2007-12-19 #152540#
- mbTextDocInOOoFileFormat( sal_False )
+ mbTextDocInOOoFileFormat( sal_False ),
// <--
- {}
+ mxComponentContext( ::comphelper::getProcessComponentContext() ),
+ mpRDFaHelper() // lazy
+ {
+ OSL_ENSURE(mxComponentContext.is(), "SvXMLImport: no ComponentContext");
+ if (!mxComponentContext.is()) throw uno::RuntimeException();
+ }
+
~SvXMLImport_Impl()
{
if( hBatsFontConv )
@@ -222,7 +236,6 @@ void SvXMLImport::_InitCtor()
if( mnImportFlags != 0 )
{
// implicit "xml" namespace prefix
- const ::rtl::OUString Xml;
mpNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML),
XML_NAMESPACE_XML );
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
@@ -294,6 +307,9 @@ void SvXMLImport::_InitCtor()
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__field ) ), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__of ) ),
GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
+ mpNamespaceMap->Add(
+ OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xhtml ) ),
+ GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
}
msPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
@@ -527,6 +543,16 @@ void SAL_CALL SvXMLImport::endDocument( void )
// #i9518# All the stuff that accesses the document has to be done here, not in the dtor,
// because the SvXMLImport dtor might not be called until after the document has been closed.
+ if (mpImpl->mpRDFaHelper.get())
+ {
+ const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
+ uno::UNO_QUERY);
+ if (xRS.is())
+ {
+ mpImpl->mpRDFaHelper->InsertRDFa( xRS );
+ }
+ }
+
if (mpNumImport)
{
delete mpNumImport;
@@ -935,9 +961,7 @@ void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen
mpImpl->aBaseURL.insertName( sRelPath );
mpImpl->aBaseURL.insertName( sName );
}
- OSL_ENSURE(sName.getLength(), "no StreamName ???");
- mpImpl->mStreamPath = sRelPath.getLength() ? sRelPath +
- ::rtl::OUString::createFromAscii("/") + sName : sName;
+ mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
// --> OD 2004-08-10 #i28749# - retrieve property <ShapePositionInHoriL2R>
sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("ShapePositionInHoriL2R" ) );
if( xPropertySetInfo->hasPropertyByName(sPropName) )
@@ -1562,7 +1586,7 @@ const SvXMLStylesContext *SvXMLImport::GetMasterStyles() const
return (const SvXMLStylesContext *)&mxMasterStyles;
}
-OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue)
+OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const
{
if( rValue.getLength() == 0 || rValue[0] == '#' )
return rValue;
@@ -1753,6 +1777,13 @@ void SvXMLImport::DisposingModel()
// #110680#
return mxServiceFactory;
}
+
+uno::Reference< uno::XComponentContext >
+SvXMLImport::GetComponentContext() const
+{
+ return mpImpl->mxComponentContext;
+}
+
String SvXMLImport::GetBaseURL() const
{
return mpImpl->aBaseURL.GetMainURL( INetURLObject::NO_DECODE );
@@ -1763,9 +1794,9 @@ String SvXMLImport::GetDocumentBase() const
return mpImpl->aDocBase.GetMainURL( INetURLObject::NO_DECODE );
}
-::rtl::OUString SvXMLImport::GetStreamPath() const
+::rtl::OUString SvXMLImport::GetStreamName() const
{
- return mpImpl->mStreamPath;
+ return mpImpl->mStreamName;
}
// --> OD 2004-08-10 #i28749#
@@ -1854,13 +1885,12 @@ void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
//FIXME: not yet
// OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
if (xMeta.is()) {
- ::rtl::OUStringBuffer XmlId( GetStreamPath() );
- XmlId.appendAscii("#");
- XmlId.append(i_rXmlId);
+ const beans::StringPair mdref( GetStreamName(), i_rXmlId );
try {
- xMeta->setXmlId(XmlId.makeStringAndClear());
+ xMeta->setMetadataReference(mdref);
} catch (lang::IllegalArgumentException &) {
// probably duplicate; ignore
+ OSL_TRACE("SvXMLImport::SetXmlId: cannot set xml:id");
}
}
} catch (uno::Exception &) {
@@ -1868,3 +1898,20 @@ void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
}
}
+void
+SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
+ ::rtl::OUString const & i_rAbout,
+ ::rtl::OUString const & i_rProperty,
+ ::rtl::OUString const & i_rContent,
+ ::rtl::OUString const & i_rDatatype)
+{
+ // N.B.: we only get called if i_xObject had xhtml:about attribute
+ // (an empty attribute value is valid)
+ if (!mpImpl->mpRDFaHelper.get())
+ {
+ mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
+ }
+ mpImpl->mpRDFaHelper->AddRDFa(i_xObject,
+ i_rAbout, i_rProperty, i_rContent, i_rDatatype);
+}
+
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 52359e15da3e..35b0cc1ec741 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -146,9 +146,11 @@ namespace xmloff { namespace token {
TOKEN( "of", XML_NP_OF ),
TOKEN( "urn:oasis:names:tc:opendocument:xmlns:of:1.2", XML_N_OF ),
- // ODF 1.2 metadata: RDFa
- TOKEN( "rdfa", XML_NP_RDFA ),
- TOKEN( "http://docs.oasis-open.org/opendocument/meta/rdfa#", XML_N_RDFA ),
+ // ODF 1.2 metadata: RDFa and GRDDL
+ TOKEN( "xhtml", XML_NP_XHTML ),
+ TOKEN( "http://www.w3.org/1999/xhtml", XML_N_XHTML ),
+ TOKEN( "grddl", XML_NP_GRDDL ),
+ TOKEN( "http://www.w3.org/2003/g/data-view#", XML_N_GRDDL ),
// units
TOKEN( "mm", XML_UNIT_MM ),
@@ -3043,6 +3045,7 @@ namespace xmloff { namespace token {
TOKEN( "meta-field", XML_META_FIELD ),
TOKEN( "about", XML_ABOUT ),
TOKEN( "datatype", XML_DATATYPE ),
+ TOKEN( "transformation", XML_TRANSFORMATION ),
// ODF 1.2 numbered-paragraph
TOKEN( "list-id", XML_LIST_ID ),
@@ -3073,12 +3076,20 @@ namespace xmloff { namespace token {
TOKEN( "at-labels", XML_AT_LABELS ),
TOKEN( "at-axis", XML_AT_AXIS ),
TOKEN( "at-labels-and-axis", XML_AT_LABELS_AND_AXIS ),
+ TOKEN( "filled-radar", XML_FILLED_RADAR ),
TOKEN( "mathvariant", XML_MATHVARIANT ),
TOKEN( "mathsize", XML_MATHSIZE ),
TOKEN( "mathweight", XML_MATHWEIGHT ),
TOKEN( "mathcolor", XML_MATHCOLOR ),
+ TOKEN( "contains", XML_CONTAINS ),
+ TOKEN( "does-not-contain", XML_DOES_NOT_CONTAIN ),
+ TOKEN( "begins-with", XML_BEGINS_WITH ),
+ TOKEN( "does-not-begin-with", XML_DOES_NOT_BEGIN_WITH ),
+ TOKEN( "ends-with", XML_ENDS_WITH ),
+ TOKEN( "does-not-end-with", XML_DOES_NOT_END_WITH ),
+
#if OSL_DEBUG_LEVEL > 0
{ 0, NULL, NULL, XML_TOKEN_END }
#else
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index 60b921ea8aaa..dcdfdbaa05d2 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -268,7 +268,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
GMAP( "ControlDataStyle", XML_NAMESPACE_STYLE,XML_DATA_STYLE_NAME, XML_TYPE_STRING|MID_FLAG_NO_PROPERTY_EXPORT|MID_FLAG_SPECIAL_ITEM, CTF_SD_CONTROL_SHAPE_DATA_STYLE ),
GMAP( "ControlTextEmphasis", XML_NAMESPACE_STYLE,XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ),
GMAP( "ImageScaleMode", XML_NAMESPACE_STYLE,XML_REPEAT, XML_SD_TYPE_IMAGE_SCALE_MODE|MID_FLAG_MULTI_PROPERTY, 0 ),
- GMAP( "ControlWritingMode", XML_NAMESPACE_STYLE,XML_WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT|MID_FLAG_MULTI_PROPERTY, 0 ),
+ GMAP( "ControlWritingMode", XML_NAMESPACE_STYLE,XML_WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT|MID_FLAG_MULTI_PROPERTY, CTF_CONTROLWRITINGMODE ),
// special entries for floating frames
GMAP( "FrameIsAutoScroll", XML_NAMESPACE_DRAW, XML_FRAME_DISPLAY_SCROLLBAR, XML_TYPE_BOOL|MID_FLAG_MULTI_PROPERTY, CTF_FRAME_DISPLAY_SCROLLBAR ),
@@ -1230,6 +1230,10 @@ void XMLShapeExportPropertyMapper::ContextFilter(
XMLPropertyState* pClip11State = NULL;
XMLPropertyState* pClipState = NULL;
+ XMLPropertyState* pShapeWritingMode = NULL;
+ XMLPropertyState* pTextWritingMode = NULL;
+ XMLPropertyState* pControlWritingMode = NULL;
+
// filter properties
for( std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
aIter != rProperties.end();
@@ -1261,14 +1265,24 @@ void XMLShapeExportPropertyMapper::ContextFilter(
break;
case CTF_WRITINGMODE:
{
+ pShapeWritingMode = property;
text::WritingMode eWritingMode;
if( property->maValue >>= eWritingMode )
{
if( text::WritingMode_LR_TB == eWritingMode )
+ {
property->mnIndex = -1;
+ pShapeWritingMode = 0;
+ }
}
}
break;
+ case CTF_CONTROLWRITINGMODE:
+ pControlWritingMode = property;
+ break;
+ case CTF_TEXTWRITINGMODE:
+ pTextWritingMode = property;
+ break;
case CTF_REPEAT_OFFSET_X:
pRepeatOffsetX = property;
break;
@@ -1353,6 +1367,19 @@ void XMLShapeExportPropertyMapper::ContextFilter(
}
}
+ // check for duplicate writing mode
+ if( pShapeWritingMode && (pTextWritingMode || pControlWritingMode) )
+ {
+ if( pTextWritingMode )
+ pTextWritingMode->mnIndex = -1;
+ if( pControlWritingMode )
+ pControlWritingMode->mnIndex = -1;
+ }
+ else if( pTextWritingMode && pControlWritingMode )
+ {
+ pControlWritingMode->mnIndex = -1;
+ }
+
// do not export visual area for internal ole objects
if( pOLEIsInternal )
{
diff --git a/xmloff/source/draw/sdpropls.hxx b/xmloff/source/draw/sdpropls.hxx
index bf27e669f1ca..eed5eee69b51 100644
--- a/xmloff/source/draw/sdpropls.hxx
+++ b/xmloff/source/draw/sdpropls.hxx
@@ -142,7 +142,7 @@ extern const XMLPropertyMapEntry aXMLSDPresPageProps_onlyHeadersFooter[];
//////////////////////////////////////////////////////////////////////////////
#define CTF_NUMBERINGRULES 1000
-//#define CTF_NUMBERINGRULES_NAME 1001
+#define CTF_CONTROLWRITINGMODE 1001
#define CTF_WRITINGMODE 1002
#define CTF_REPEAT_OFFSET_X 1003
#define CTF_REPEAT_OFFSET_Y 1004
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 0b6c7dd170e7..3a0e01631f28 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -1213,7 +1213,8 @@ const rtl::Reference< XMLTableExport >& XMLShapeExport::GetShapeTableExport()
if( !mxShapeTableExport.is() )
{
rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ) );
- rtl::Reference< XMLPropertySetMapper > xPropertySetMapper( new XMLShapePropertySetMapper( xFactory.get() ) );
+ UniReference < XMLPropertySetMapper > xMapper( new XMLShapePropertySetMapper( xFactory.get() ) );
+ rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( new XMLShapeExportPropertyMapper( xMapper, (XMLTextListAutoStylePool*)&mrExport.GetTextParagraphExport()->GetListAutoStylePool(), mrExport ) );
mxShapeTableExport = new XMLTableExport( mrExport, xPropertySetMapper, xFactory );
}
diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx
index a7bb8bd7fcec..b2e81d333fba 100644
--- a/xmloff/source/draw/shapeexport2.cxx
+++ b/xmloff/source/draw/shapeexport2.cxx
@@ -49,6 +49,7 @@
#endif
#include "sdpropls.hxx"
#include <tools/debug.hxx>
+#include <tools/urlobj.hxx>
#include <rtl/ustrbuf.hxx>
#include <xmloff/xmlexp.hxx>
#include <xmloff/xmluconv.hxx>
@@ -1166,8 +1167,30 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
OUString aStreamURL;
OUString aStr;
+ xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aStreamURL;
xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= sImageURL;
- aStr = mrExport.AddEmbeddedGraphicObject( sImageURL );
+
+ OUString aResolveURL( sImageURL );
+ const rtl::OUString sPackageURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.Package:") );
+
+ // sj: trying to preserve the filename
+ if ( aStreamURL.match( sPackageURL, 0 ) )
+ {
+ rtl::OUString sRequestedName( aStreamURL.copy( sPackageURL.getLength(), aStreamURL.getLength() - sPackageURL.getLength() ) );
+ sal_Int32 nLastIndex = sRequestedName.lastIndexOf( '/' ) + 1;
+ if ( ( nLastIndex > 0 ) && ( nLastIndex < sRequestedName.getLength() ) )
+ sRequestedName = sRequestedName.copy( nLastIndex, sRequestedName.getLength() - nLastIndex );
+ nLastIndex = sRequestedName.lastIndexOf( '.' );
+ if ( nLastIndex >= 0 )
+ sRequestedName = sRequestedName.copy( 0, nLastIndex );
+ if ( sRequestedName.getLength() )
+ {
+ aResolveURL = aResolveURL.concat( OUString(RTL_CONSTASCII_USTRINGPARAM("?requestedName=")));
+ aResolveURL = aResolveURL.concat( sRequestedName );
+ }
+ }
+
+ aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL );
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr );
if( aStr.getLength() )
diff --git a/xmloff/source/draw/shapeexport4.cxx b/xmloff/source/draw/shapeexport4.cxx
index d38bb3761868..e2e804eefb43 100644
--- a/xmloff/source/draw/shapeexport4.cxx
+++ b/xmloff/source/draw/shapeexport4.cxx
@@ -1130,21 +1130,21 @@ void XMLShapeExport::ImpExportTableShape( const uno::Reference< drawing::XShape
{
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TEMPLATE_NAME, sTemplate );
- const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
-
- while( pEntry->msApiName ) try
+ for( const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; pEntry->msApiName; pEntry++ )
{
- sal_Bool bBool = sal_False;
- const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
+ try
+ {
+ sal_Bool bBool = sal_False;
+ const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
- xPropSet->getPropertyValue( sAPIPropertyName ) >>= bBool;
- if( bBool )
- mrExport.AddAttribute(pEntry->mnNameSpace, pEntry->meXMLName, XML_TRUE );
- pEntry++;
- }
- catch( uno::Exception& )
- {
- DBG_ERROR("XMLShapeExport::ImpExportTableShape(), exception caught!");
+ xPropSet->getPropertyValue( sAPIPropertyName ) >>= bBool;
+ if( bBool )
+ mrExport.AddAttribute(pEntry->mnNameSpace, pEntry->meXMLName, XML_TRUE );
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR("XMLShapeExport::ImpExportTableShape(), exception caught!");
+ }
}
}
}
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 27ca5c4beafe..65aad96bad86 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3584,16 +3584,17 @@ void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Referenc
}
const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
- int i = 0;
- while( pEntry->msApiName && (i < 6) ) try
- {
- const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
- xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i++] ) );
- pEntry++;
- }
- catch( Exception& )
+ for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ )
{
- DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
+ try
+ {
+ const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
+ xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
+ }
}
}
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index 0769798159c4..d3dc170e58d5 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -529,15 +529,15 @@ namespace xmloff
{
static sal_Int32 nBooleanPropertyAttributeIds[] =
{ // attribute flags
- CCA_CURRENT_SELECTED, CCA_DISABLED, CCA_DROPDOWN, CCA_PRINTABLE, CCA_READONLY, CCA_SELECTED, CCA_TAB_STOP
+ CCA_CURRENT_SELECTED, CCA_DISABLED, CCA_DROPDOWN, CCA_PRINTABLE, CCA_READONLY, CCA_SELECTED, CCA_TAB_STOP, CCA_ENABLEVISIBLE
};
static const ::rtl::OUString* pBooleanPropertyNames[] =
{ // property names
- &PROPERTY_STATE, &PROPERTY_ENABLED, &PROPERTY_DROPDOWN, &PROPERTY_PRINTABLE, &PROPERTY_READONLY, &PROPERTY_DEFAULT_STATE, &PROPERTY_TABSTOP
+ &PROPERTY_STATE, &PROPERTY_ENABLED, &PROPERTY_DROPDOWN, &PROPERTY_PRINTABLE, &PROPERTY_READONLY, &PROPERTY_DEFAULT_STATE, &PROPERTY_TABSTOP, &PROPERTY_ENABLEVISIBLE
};
static sal_Bool nBooleanPropertyAttrFlags[] =
{ // attribute defaults
- BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE | BOOLATTR_INVERSE_SEMANTICS, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_VOID
+ BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE | BOOLATTR_INVERSE_SEMANTICS, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_VOID, BOOLATTR_DEFAULT_FALSE
};
#if OSL_DEBUG_LEVEL > 0
sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]);
diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx
index da5f3207ddda..0c2431590b63 100644
--- a/xmloff/source/forms/formattributes.cxx
+++ b/xmloff/source/forms/formattributes.cxx
@@ -60,6 +60,7 @@ namespace xmloff
case CCA_CURRENT_SELECTED: return "current-selected";
case CCA_CURRENT_VALUE: return "current-value";
case CCA_DISABLED: return "disabled";
+ case CCA_ENABLEVISIBLE: return "visible";
case CCA_DROPDOWN: return "dropdown";
case CCA_FOR: return "for";
case CCA_IMAGE_DATA: return "image-data";
diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx
index 5d55948be328..eba2855d3b5e 100644
--- a/xmloff/source/forms/formattributes.hxx
+++ b/xmloff/source/forms/formattributes.hxx
@@ -69,6 +69,7 @@ namespace xmloff
#define CCA_VALUE 0x00200000
#define CCA_ORIENTATION 0x00400000
#define CCA_VISUAL_EFFECT 0x00800000
+ #define CCA_ENABLEVISIBLE 0x01000000
// flags for database control atttributes
#define DA_BOUND_COLUMN 0x00000001
diff --git a/xmloff/source/forms/strings.hxx b/xmloff/source/forms/strings.hxx
index 2e525829fa1a..59413ed0b924 100644
--- a/xmloff/source/forms/strings.hxx
+++ b/xmloff/source/forms/strings.hxx
@@ -115,6 +115,7 @@ namespace xmloff
XMLFORM_CONSTASCII_STRING( PROPERTY_TABSTOP, "Tabstop" );
XMLFORM_CONSTASCII_STRING( PROPERTY_STATE, "State" );
XMLFORM_CONSTASCII_STRING( PROPERTY_ENABLED, "Enabled" );
+ XMLFORM_CONSTASCII_STRING( PROPERTY_ENABLEVISIBLE, "EnableVisible" );
XMLFORM_CONSTASCII_STRING( PROPERTY_MAXTEXTLENGTH, "MaxTextLen" );
XMLFORM_CONSTASCII_STRING( PROPERTY_LINECOUNT, "LineCount" );
XMLFORM_CONSTASCII_STRING( PROPERTY_TABINDEX, "TabIndex" );
diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx
index 4eda35e38a23..c903cf2dc1ba 100644
--- a/xmloff/source/meta/xmlmetai.cxx
+++ b/xmloff/source/meta/xmlmetai.cxx
@@ -209,7 +209,13 @@ void SvXMLMetaDocumentContext::initDocumentProperties()
}
}
-void SvXMLMetaDocumentContext::setBuildId(::rtl::OUString const& i_rBuildId)
+void SvXMLMetaDocumentContext::setBuildId(const ::rtl::OUString & i_rBuildId)
+{
+ SvXMLMetaDocumentContext::setBuildId( i_rBuildId, GetImport().getImportInfo() );
+}
+
+//static
+void SvXMLMetaDocumentContext::setBuildId(::rtl::OUString const& i_rBuildId, const uno::Reference<beans::XPropertySet>& xImportInfo )
{
OUString sBuildId;
// skip to second product
@@ -258,14 +264,13 @@ void SvXMLMetaDocumentContext::setBuildId(::rtl::OUString const& i_rBuildId)
if ( sBuildId.getLength() ) try
{
- uno::Reference<beans::XPropertySet> xSet(GetImport().getImportInfo());
- if( xSet.is() )
+ if( xImportInfo.is() )
{
const OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("BuildId"));
uno::Reference< beans::XPropertySetInfo > xSetInfo(
- xSet->getPropertySetInfo());
+ xImportInfo->getPropertySetInfo());
if( xSetInfo.is() && xSetInfo->hasPropertyByName( aPropName ) )
- xSet->setPropertyValue( aPropName, uno::makeAny( sBuildId ) );
+ xImportInfo->setPropertyValue( aPropName, uno::makeAny( sBuildId ) );
}
}
catch( uno::Exception& )
diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx
index 1fe2127e1a6e..de930d6dd288 100644
--- a/xmloff/source/table/XMLTableExport.cxx
+++ b/xmloff/source/table/XMLTableExport.cxx
@@ -150,7 +150,7 @@ sal_Int32 StringStatisticHelper::getModeString( OUString& rStyleName )
// class XMLTableExport
// --------------------------------------------------------------------
-XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< XMLPropertySetMapper >& xCellPropertySetMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef )
+XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExportPropertyMapper >& xExportPropertyMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef )
: mrExport( rExp )
, mbExportTables( false )
{
@@ -174,7 +174,7 @@ XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< XMLPrope
(void)e;
}
- mxCellExportPropertySetMapper = new SvXMLExportPropertyMapper( xCellPropertySetMapper.get() );
+ mxCellExportPropertySetMapper = xExportPropertyMapper;
mxCellExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
mxRowExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef.get() ) );
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index c53885e73187..c3ff9abebd90 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -124,44 +124,45 @@ inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl(
{
}
-class XMLTextFrameDescContext_Impl : public SvXMLImportContext
+// --> OD 2009-07-22 #i73249#
+class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext
{
- OUString& rDesc;
+ OUString& mrTitleOrDesc;
public:
TYPEINFO();
- XMLTextFrameDescContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
- OUString& rD );
- virtual ~XMLTextFrameDescContext_Impl();
+ XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ OUString& rTitleOrDesc );
+ virtual ~XMLTextFrameTitleOrDescContext_Impl();
virtual void Characters( const OUString& rText );
};
-TYPEINIT1( XMLTextFrameDescContext_Impl, SvXMLImportContext );
+TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext );
-XMLTextFrameDescContext_Impl::XMLTextFrameDescContext_Impl(
+XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl(
SvXMLImport& rImport,
- sal_uInt16 nPrfx, const OUString& rLName,
- const Reference< XAttributeList > &,
- OUString& rD ) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- rDesc( rD )
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ OUString& rTitleOrDesc )
+ : SvXMLImportContext( rImport, nPrfx, rLName )
+ , mrTitleOrDesc( rTitleOrDesc )
{
}
-XMLTextFrameDescContext_Impl::~XMLTextFrameDescContext_Impl()
+XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl()
{
}
-void XMLTextFrameDescContext_Impl::Characters( const OUString& rText )
+void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText )
{
- rDesc += rText;
+ mrTitleOrDesc += rText;
}
+// <--
// ------------------------------------------------------------------------
@@ -385,7 +386,11 @@ class XMLTextFrameContext_Impl : public SvXMLImportContext
const ::rtl::OUString sAnchorPageNo;
const ::rtl::OUString sGraphicURL;
const ::rtl::OUString sGraphicFilter;
- const ::rtl::OUString sAlternativeText;
+ // --> OD 2009-07-22 #i73249#
+// const ::rtl::OUString sAlternativeText;
+ const ::rtl::OUString sTitle;
+ const ::rtl::OUString sDescription;
+ // <--
const ::rtl::OUString sFrameStyleName;
const ::rtl::OUString sGraphicRotation;
const ::rtl::OUString sTextBoxServiceName;
@@ -461,6 +466,9 @@ public:
const ::rtl::OUString& rName,
const ::rtl::OUString& rTargetFrameName,
sal_Bool bMap );
+ // --> OD 2009-07-22 #i73249#
+ void SetTitle( const ::rtl::OUString& rTitle );
+ // <--
void SetDesc( const ::rtl::OUString& rDesc );
::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
@@ -829,7 +837,11 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
, sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
, sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
, sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
-, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
+// --> OD 2009-07-22 #i73249#
+//, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
+, sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
+, sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
+// <--
, sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
, sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
, sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
@@ -1135,12 +1147,15 @@ SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext(
}
}
}
+ // --> OD 2009-08-17 #i100480#
+ // correction of condition which also avoids warnings.
if( !pContext &&
- ( XML_TEXT_FRAME_OBJECT == nType &&
- (XML_NAMESPACE_OFFICE == nPrefix &&
- IsXMLToken( rLocalName, XML_DOCUMENT )) ||
- (XML_NAMESPACE_MATH == nPrefix &&
- IsXMLToken(rLocalName, XML_MATH) ) ) )
+ ( XML_TEXT_FRAME_OBJECT == nType &&
+ ( ( XML_NAMESPACE_OFFICE == nPrefix &&
+ IsXMLToken( rLocalName, XML_DOCUMENT ) ) ||
+ ( XML_NAMESPACE_MATH == nPrefix &&
+ IsXMLToken( rLocalName, XML_MATH ) ) ) ) )
+ // <--
{
if( !xPropSet.is() && !bCreateFailed )
{
@@ -1262,18 +1277,31 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
}
}
+// --> OD 2009-07-22 #i73249#
+void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle )
+{
+ if ( xPropSet.is() )
+ {
+ Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ if( xPropSetInfo->hasPropertyByName( sTitle ) )
+ {
+ xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) );
+ }
+ }
+}
+
void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc )
{
if ( xPropSet.is() )
{
- Reference< XPropertySetInfo > xPropSetInfo =
- xPropSet->getPropertySetInfo();
- if( xPropSetInfo->hasPropertyByName( sAlternativeText ) )
+ Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ if( xPropSetInfo->hasPropertyByName( sDescription ) )
{
- xPropSet->setPropertyValue( sAlternativeText, makeAny( rDesc ) );
+ xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) );
}
}
}
+// <--
//-----------------------------------------------------------------------------------------------------
@@ -1312,6 +1340,10 @@ XMLTextFrameContext::XMLTextFrameContext(
: SvXMLImportContext( rImport, nPrfx, rLName )
, m_xAttrList( new SvXMLAttributeList( xAttrList ) )
, m_pHyperlink( 0 )
+// --> OD 2009-07-22 #i73249#
+, m_sTitle()
+, m_sDesc()
+// <--
, m_eDefaultAnchorType( eATyp )
// --> OD 2006-03-10 #i51726#
, m_HasAutomaticStyleWithoutParentStyle( sal_False )
@@ -1374,9 +1406,20 @@ void XMLTextFrameContext::EndElement()
{
pImpl->CreateIfNotThere();
- // alternative text
+ // --> OD 2009-07-22 #i73249#
+// // alternative text
+// if( m_sDesc.getLength() )
+// pImpl->SetDesc( m_sDesc );
+ // svg:title
+ if( m_sTitle.getLength() )
+ {
+ pImpl->SetTitle( m_sTitle );
+ }
if( m_sDesc.getLength() )
+ {
pImpl->SetDesc( m_sDesc );
+ }
+ // <--
if( m_pHyperlink )
{
@@ -1494,10 +1537,40 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
// the child is a writer frame
if( XML_NAMESPACE_SVG == p_nPrefix )
{
- bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
- if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) )
- pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName,
- xAttrList, m_sDesc );
+ // --> OD 2009-07-22 #i73249#
+// bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
+// if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) )
+// pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName,
+// xAttrList, m_sDesc );
+ const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
+ if ( bOld )
+ {
+ if ( IsXMLToken( rLocalName, XML_DESC ) )
+ {
+ pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
+ p_nPrefix,
+ rLocalName,
+ m_sTitle );
+ }
+ }
+ else
+ {
+ if( IsXMLToken( rLocalName, XML_TITLE ) )
+ {
+ pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
+ p_nPrefix,
+ rLocalName,
+ m_sTitle );
+ }
+ else if ( IsXMLToken( rLocalName, XML_DESC ) )
+ {
+ pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
+ p_nPrefix,
+ rLocalName,
+ m_sDesc );
+ }
+ }
+ // <--
}
else if( XML_NAMESPACE_DRAW == p_nPrefix )
{
diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx
index 9b620a993590..51e41d45367c 100644
--- a/xmloff/source/text/XMLTextFrameContext.hxx
+++ b/xmloff/source/text/XMLTextFrameContext.hxx
@@ -53,6 +53,9 @@ class XMLTextFrameContext : public SvXMLImportContext
SvXMLAttributeList *m_pAttrList;
XMLTextFrameContextHyperlink_Impl *m_pHyperlink;
+ // --> OD 2009-07-22 #i73249#
+ ::rtl::OUString m_sTitle;
+ // <--
::rtl::OUString m_sDesc;
::com::sun::star::text::TextContentAnchorType m_eDefaultAnchorType;
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index 04201990b797..1091636c9d3f 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -308,39 +308,57 @@ Reference<XInterface> XMLTextMarkImportContext::CreateAndInsertMark(
const OUString& i_rXmlId)
{
// create mark
- Reference<XMultiServiceFactory> xFactory(rImport.GetModel(),UNO_QUERY);
- if( xFactory.is() )
+ const Reference<XMultiServiceFactory> xFactory(rImport.GetModel(),
+ UNO_QUERY);
+ Reference<XInterface> xIfc;
+
+ if (xFactory.is())
{
- Reference<XInterface> xIfc = xFactory->createInstance(sServiceName);
+ xIfc = xFactory->createInstance(sServiceName);
- // set name
- Reference<XNamed> xNamed(xIfc, UNO_QUERY);
+ if (!xIfc.is())
+ {
+ OSL_ENSURE(false, "CreateAndInsertMark: cannot create service?");
+ return 0;
+ }
+
+ // set name (unless there is no name (text:meta))
+ const Reference<XNamed> xNamed(xIfc, UNO_QUERY);
if (xNamed.is())
{
xNamed->setName(sMarkName);
+ }
+ else
+ {
+ if (sMarkName.getLength())
+ {
+ OSL_ENSURE(false, "name given, but XNamed not supported?");
+ return 0;
+ }
+ }
- // xml:id for RDF metadata
- rImport.SetXmlId(xIfc, i_rXmlId);
+ // xml:id for RDF metadata
+ rImport.SetXmlId(xIfc, i_rXmlId);
- // cast to XTextContent and attach to document
- Reference<XTextContent> xTextContent(xIfc, UNO_QUERY);
- if (xTextContent.is())
+ // cast to XTextContent and attach to document
+ const Reference<XTextContent> xTextContent(xIfc, UNO_QUERY);
+ if (xTextContent.is())
+ {
+ try
{
- try
- {
// if inserting marks, bAbsorb==sal_False will cause
// collapsing of the given XTextRange.
- rImport.GetTextImport()->GetText()->insertTextContent(rRange,
- xTextContent, sal_True);
- }
- catch (com::sun::star::lang::IllegalArgumentException e)
- {
- // ignore
- }
+ rImport.GetTextImport()->GetText()->insertTextContent(rRange,
+ xTextContent, sal_True);
+ }
+ catch (com::sun::star::lang::IllegalArgumentException &)
+ {
+ OSL_ENSURE(false, "CreateAndInsertMark: cannot insert?");
+ return 0;
}
}
- return xIfc;
- } else return NULL;
+ }
+ return xIfc;
}
sal_Bool XMLTextMarkImportContext::FindName(
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index e8344e757aed..a2b0146a6cfa 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -44,9 +44,6 @@
#include <xmloff/xmlnume.hxx>
#include "numehelp.hxx"
-#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX
-#include <xmloff/maptypes.hxx>
-#endif
#include <xmloff/families.hxx>
#include <xmloff/XMLEventExport.hxx>
#include "XMLTextCharStyleNamesElementExport.hxx"
@@ -65,9 +62,7 @@
#include <com/sun/star/text/XDependentTextField.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
-#ifndef _COM_SUN_STAR_TEXT_SETVARIABLETYPE_HPP
#include <com/sun/star/text/SetVariableType.hpp>
-#endif
#include <com/sun/star/text/PlaceholderType.hpp>
#include <com/sun/star/text/FilenameDisplayFormat.hpp>
#include <com/sun/star/text/ChapterFormat.hpp>
@@ -78,6 +73,7 @@
#include <com/sun/star/util/NumberFormat.hpp>
#include <com/sun/star/text/BibliographyDataType.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/rdf/XMetadatable.hpp>
#include <rtl/ustrbuf.hxx>
#include <tools/debug.hxx>
#include <rtl/math.hxx>
@@ -152,6 +148,7 @@ static sal_Char __READONLY_DATA FIELD_SERVICE_BIBLIOGRAPHY[] = "Bibliography";
static sal_Char __READONLY_DATA FIELD_SERVICE_SCRIPT[] = "Script";
static sal_Char __READONLY_DATA FIELD_SERVICE_ANNOTATION[] = "Annotation";
static sal_Char __READONLY_DATA FIELD_SERVICE_COMBINED_CHARACTERS[] = "CombinedCharacters";
+static sal_Char __READONLY_DATA FIELD_SERVICE_META[] = "MetaField";
static sal_Char __READONLY_DATA FIELD_SERVICE_MEASURE[] = "Measure";
static sal_Char __READONLY_DATA FIELD_SERVICE_TABLE_FORMULA[] = "TableFormula";
static sal_Char __READONLY_DATA FIELD_SERVICE_DROP_DOWN[] = "DropDown";
@@ -219,6 +216,7 @@ SvXMLEnumStringMapEntry __READONLY_DATA aFieldServiceNameMapping[] =
ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION, FIELD_ID_ANNOTATION ),
ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS, FIELD_ID_COMBINED_CHARACTERS ),
+ ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META, FIELD_ID_META ),
// non-writer fields
ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME, FIELD_ID_SHEET_NAME ),
@@ -604,6 +602,7 @@ enum FieldIdEnum XMLTextFieldExport::MapFieldName(
case FIELD_ID_TEMPLATE_NAME:
case FIELD_ID_CHAPTER:
case FIELD_ID_FILE_NAME:
+ case FIELD_ID_META:
case FIELD_ID_SHEET_NAME:
case FIELD_ID_MEASURE:
case FIELD_ID_URL:
@@ -646,6 +645,9 @@ sal_Bool XMLTextFieldExport::IsStringField(
return !bRet;
}
+ case FIELD_ID_META://FIXME ?????? no idea...
+ return 0 > GetIntProperty(sPropertyNumberFormat, xPropSet);
+
case FIELD_ID_DATABASE_DISPLAY:
// TODO: depends on... ???
// workaround #no-bug#: no data type
@@ -738,7 +740,7 @@ sal_Bool XMLTextFieldExport::IsStringField(
/// export the styles needed by the given field. Called on first pass
/// through document
void XMLTextFieldExport::ExportFieldAutoStyle(
- const Reference<XTextField> & rTextField)
+ const Reference<XTextField> & rTextField, sal_Bool bProgress )
{
// get property set
Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
@@ -831,6 +833,10 @@ void XMLTextFieldExport::ExportFieldAutoStyle(
}
break;
+ case FIELD_ID_META:
+ // recurse into content (does not export element, so can be done first)
+ ExportMetaField(xPropSet, true, bProgress);
+ // fall-through: for the meta-field itself!
case FIELD_ID_DOCINFO_PRINT_TIME:
case FIELD_ID_DOCINFO_PRINT_DATE:
case FIELD_ID_DOCINFO_CREATION_DATE:
@@ -948,7 +954,8 @@ void XMLTextFieldExport::ExportFieldAutoStyle(
}
/// export the given field to XML. Called on second pass through document
-void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField )
+void XMLTextFieldExport::ExportField(
+ const Reference<XTextField> & rTextField, sal_Bool bProgress )
{
// get property set
Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
@@ -1026,7 +1033,8 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField )
sal_False, sal_False);
// finally, export the field itself
- ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken );
+ ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
+ bProgress );
}
}
@@ -1035,7 +1043,8 @@ void XMLTextFieldExport::ExportFieldHelper(
const Reference<XTextField> & rTextField,
const Reference<XPropertySet> & rPropSet,
const Reference<XPropertySet> &,
- enum FieldIdEnum nToken)
+ enum FieldIdEnum nToken,
+ sal_Bool bProgress )
{
// get property set info (because some attributes are not support
// in all implementations)
@@ -1738,11 +1747,17 @@ void XMLTextFieldExport::ExportFieldHelper(
{
// The style with the combined characters attribute has
// already been handled in the ExportField method. So all that
- // is left to do now is to exprot the characters.
+ // is left to do now is to export the characters.
GetExport().Characters(sPresentation);
break;
}
+ case FIELD_ID_META:
+ {
+ ExportMetaField(rPropSet, false, bProgress);
+ break;
+ }
+
case FIELD_ID_MEASURE:
{
ProcessString(XML_KIND, MapMeasureKind(GetInt16Property(sPropertyMeasureKind, rPropSet)));
@@ -2248,6 +2263,47 @@ void XMLTextFieldExport::ExportMacro(
GetExport().Characters(rContent);
}
+// FIXME: this is untested
+void XMLTextFieldExport::ExportMetaField(
+ const Reference<XPropertySet> & i_xMeta,
+ bool i_bAutoStyles, sal_Bool i_bProgress )
+{
+ bool doExport(!i_bAutoStyles); // do not export element if autostyles
+ // check version >= 1.2
+ switch (GetExport().getDefaultVersion()) {
+ case SvtSaveOptions::ODFVER_011: // fall thru
+ case SvtSaveOptions::ODFVER_010: doExport = false; break;
+ default: break;
+ }
+
+ const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
+ const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
+
+ if (doExport)
+ {
+ const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
+
+ // style:data-style-name
+ ProcessValueAndType(sal_False,
+ GetIntProperty(sPropertyNumberFormat, i_xMeta),
+ sEmpty, sEmpty, 0.0, sal_False, sal_False, sal_True,
+ sal_False, sal_False /*, sal_False*/ );
+
+ // text:meta-field without xml:id is invalid
+ xMeta->ensureMetadataReference();
+
+ // xml:id for RDF metadata
+ GetExport().AddAttributeXmlId(xMeta);
+ }
+
+ SvXMLElementExport aElem( GetExport(), doExport,
+ XML_NAMESPACE_TEXT, XML_META_FIELD, sal_False, sal_False );
+
+ // recurse to export content
+ GetExport().GetTextParagraphExport()->
+ exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_bProgress );
+}
+
/// export all data-style related attributes
void XMLTextFieldExport::ProcessValueAndType(
sal_Bool bIsString, /// do we process a string or a number?
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 04ac465daa3f..add97d20efda 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -327,7 +327,11 @@ static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] =
static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] =
{
- { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_P_XMLID },
+ { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_P_XMLID },
+ { XML_NAMESPACE_XHTML, XML_ABOUT, XML_TOK_TEXT_P_ABOUT },
+ { XML_NAMESPACE_XHTML, XML_PROPERTY, XML_TOK_TEXT_P_PROPERTY },
+ { XML_NAMESPACE_XHTML, XML_CONTENT, XML_TOK_TEXT_P_CONTENT },
+ { XML_NAMESPACE_XHTML, XML_DATATYPE, XML_TOK_TEXT_P_DATATYPE },
{ XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_P_STYLE_NAME },
{ XML_NAMESPACE_TEXT, XML_COND_STYLE_NAME,
XML_TOK_TEXT_P_COND_STYLE_NAME },
@@ -927,6 +931,134 @@ OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars,
return bConverted ? sChars.makeStringAndClear() : rChars;
}
+// --> OD 2006-10-12 #i69629#
+// helper method to determine, if a paragraph style has a list style (inclusive
+// an empty one) inherits a list style (inclusive an empty one) from one of its parents
+// --> OD 2007-01-29 #i73973#
+// apply special case, that found list style equals the chapter numbering, also
+// to the found list styles of the parent styles.
+sal_Bool lcl_HasListStyle( OUString sStyleName,
+ const Reference < XNameContainer >& xParaStyles,
+ SvXMLImport& rImport,
+ const OUString& sNumberingStyleName,
+ const OUString& sOutlineStyleName )
+{
+ sal_Bool bRet( sal_False );
+
+ if ( !xParaStyles->hasByName( sStyleName ) )
+ {
+ // error case
+ return sal_True;
+ }
+
+ Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ),
+ UNO_QUERY );
+ if ( !xPropState.is() )
+ {
+ // error case
+ return sal_False;
+ }
+
+ if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
+ {
+ // list style found
+ bRet = sal_True;
+ // special case: the set list style equals the chapter numbering
+ Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
+ if ( xPropSet.is() )
+ {
+ OUString sListStyle;
+ xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
+ if ( sListStyle.getLength() != 0 &&
+ sListStyle == sOutlineStyleName )
+ {
+ bRet = sal_False;
+ }
+ }
+ }
+ else
+ {
+ // --> OD 2007-12-07 #i77708#
+ sal_Int32 nUPD( 0 );
+ sal_Int32 nBuild( 0 );
+ // --> OD 2008-03-19 #i86058#
+// rImport.getBuildIds( nUPD, nBuild );
+ const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
+ // <--
+ // <--
+ // search list style at parent
+ Reference<XStyle> xStyle( xPropState, UNO_QUERY );
+ while ( xStyle.is() )
+ {
+ OUString aParentStyle( xStyle->getParentStyle() );
+ if ( aParentStyle.getLength() > 0 )
+ {
+ aParentStyle =
+ rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
+ aParentStyle );
+ }
+ if ( aParentStyle.getLength() == 0 ||
+ !xParaStyles->hasByName( aParentStyle ) )
+ {
+ // no list style found
+ break;
+ }
+ else
+ {
+ xPropState = Reference< XPropertyState >(
+ xParaStyles->getByName( aParentStyle ),
+ UNO_QUERY );
+ if ( !xPropState.is() )
+ {
+ // error case
+ return sal_True;
+ }
+ if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
+ {
+ // list style found
+ bRet = sal_True;
+ // --> OD 2007-01-29 #i73973#
+ // special case: the found list style equals the chapter numbering
+ Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
+ if ( xPropSet.is() )
+ {
+ OUString sListStyle;
+ xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
+ if ( sListStyle.getLength() != 0 &&
+ sListStyle == sOutlineStyleName )
+ {
+ bRet = sal_False;
+ }
+ // --> OD 2007-12-07 #i77708#
+ // special handling for text documents from OOo version prior OOo 2.4
+ // --> OD 2008-03-19 #i86058#
+ // check explicitly on certain versions and on import of
+ // text documents in OpenOffice.org file format
+ else if ( sListStyle.getLength() == 0 &&
+ ( rImport.IsTextDocInOOoFileFormat() ||
+ ( bBuildIdFound &&
+ ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
+ ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
+ {
+ bRet = sal_False;
+ }
+ // <--
+ }
+ // <--
+ break;
+ }
+ else
+ {
+ // search list style at parent
+ xStyle = Reference<XStyle>( xPropState, UNO_QUERY );
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+// <--
OUString XMLTextImportHelper::SetStyleAndAttrs(
SvXMLImport& rImport,
const Reference < XTextCursor >& rCursor,
@@ -1237,14 +1369,20 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
// Some minor rework and adjust access to paragraph styles
if ( bPara )
{
+ // --> OD 2009-08-18 #i103817#
+ sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
+ const bool bHasOutlineLevelProp( xPropSetInfo->hasPropertyByName( sOutlineLevel ) );
+ if ( bHasOutlineLevelProp )
+ {
+ xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
+ }
+ // <--
//if ( bPara && nOutlineLevel != -1 ) //#outline level,removed by zhaojianwei
if ( nOutlineLevel > 0 ) //add by zhaojianwei
{
//#outline level,removed by zhaojianwei
- if ( xPropSetInfo->hasPropertyByName( sOutlineLevel ) )
+ if ( bHasOutlineLevelProp )
{
- sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
- xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
// In case that the value equals the value of its paragraph style
// attribute outline level, the paragraph attribute value is left unset
if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel )
@@ -1323,15 +1461,33 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
{
AddOutlineStyleCandidate( nOutlineLevel, sStyleName );
}
+ // --> OD 2009-08-18 #i103817#
+ // Assure that heading applies the outline style
+ if ( ( !pStyle || !pStyle->IsListStyleSet() ) &&
+ !bOutlineStyleCandidate &&
+ xChapterNumbering.is() )
+ {
+ OUString sEmptyStr;
+ if ( !lcl_HasListStyle( sStyleName,
+ xParaStyles, GetXMLImport(),
+ sNumberingStyleName,
+ sEmptyStr ) )
+ {
+ // heading not in a list --> apply outline style
+ xPropSet->setPropertyValue( sNumberingRules,
+ makeAny(xChapterNumbering) );
+ xPropSet->setPropertyValue( sNumberingLevel,
+ makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
+ }
+ }
+ // <--
}
// <--
}
//-> #outlinelevel added by zhaojianwei
//handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
- else if( xPropSetInfo->hasPropertyByName( sOutlineLevel ) )
+ else if( bHasOutlineLevelProp )
{
- sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
- xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 )
{
sal_Int16 nZero = 0;
@@ -1424,132 +1580,6 @@ void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel
// <--
// --> OD 2006-10-12 #i69629#
-// helper method to determine, if a paragraph style has a list style (inclusive
-// an empty one) inherits a list style (inclusive an empty one) from one of its parents
-// --> OD 2007-01-29 #i73973#
-// apply special case, that found list style equals the chapter numbering, also
-// to the found list styles of the parent styles.
-sal_Bool lcl_HasListStyle( OUString sStyleName,
- const Reference < XNameContainer >& xParaStyles,
- SvXMLImport& rImport,
- const OUString& sNumberingStyleName,
- const OUString& sOutlineStyleName )
-{
- sal_Bool bRet( sal_False );
-
- if ( !xParaStyles->hasByName( sStyleName ) )
- {
- // error case
- return sal_True;
- }
-
- Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ),
- UNO_QUERY );
- if ( !xPropState.is() )
- {
- // error case
- return sal_False;
- }
-
- if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
- {
- // list style found
- bRet = sal_True;
- // special case: the set list style equals the chapter numbering
- Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
- if ( xPropSet.is() )
- {
- OUString sListStyle;
- xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
- if ( sListStyle == sOutlineStyleName )
- {
- bRet = sal_False;
- }
- }
- }
- else
- {
- // --> OD 2007-12-07 #i77708#
- sal_Int32 nUPD( 0 );
- sal_Int32 nBuild( 0 );
- // --> OD 2008-03-19 #i86058#
-// rImport.getBuildIds( nUPD, nBuild );
- const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
- // <--
- // <--
- // search list style at parent
- Reference<XStyle> xStyle( xPropState, UNO_QUERY );
- while ( xStyle.is() )
- {
- OUString aParentStyle( xStyle->getParentStyle() );
- if ( aParentStyle.getLength() > 0 )
- {
- aParentStyle =
- rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
- aParentStyle );
- }
- if ( aParentStyle.getLength() == 0 ||
- !xParaStyles->hasByName( aParentStyle ) )
- {
- // no list style found
- break;
- }
- else
- {
- xPropState = Reference< XPropertyState >(
- xParaStyles->getByName( aParentStyle ),
- UNO_QUERY );
- if ( !xPropState.is() )
- {
- // error case
- return sal_True;
- }
- if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
- {
- // list style found
- bRet = sal_True;
- // --> OD 2007-01-29 #i73973#
- // special case: the found list style equals the chapter numbering
- Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
- if ( xPropSet.is() )
- {
- OUString sListStyle;
- xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
- if ( sListStyle == sOutlineStyleName )
- {
- bRet = sal_False;
- }
- // --> OD 2007-12-07 #i77708#
- // special handling for text documents from OOo version prior OOo 2.4
- // --> OD 2008-03-19 #i86058#
- // check explicitly on certain versions and on import of
- // text documents in OpenOffice.org file format
- else if ( sListStyle.getLength() == 0 &&
- ( rImport.IsTextDocInOOoFileFormat() ||
- ( bBuildIdFound &&
- ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
- ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
- {
- bRet = sal_False;
- }
- // <--
- }
- // <--
- break;
- }
- else
- {
- // search list style at parent
- xStyle = Reference<XStyle>( xPropState, UNO_QUERY );
- }
- }
- }
- }
-
- return bRet;
-}
-// <--
-// --> OD 2006-10-12 #i69629#
void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels )
{
if ( ( mpOutlineStylesCandidates != NULL || bSetEmptyLevels ) &&
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx
index 5ccf3652eebe..4dca73940dba 100644
--- a/xmloff/source/text/txtimppr.cxx
+++ b/xmloff/source/text/txtimppr.cxx
@@ -39,6 +39,7 @@
#include <tools/string.hxx>
#include <xmloff/XMLFontStylesContext.hxx>
#include <xmloff/txtprmap.hxx>
+#include <xmloff/xmlimp.hxx>
#include "txtimppr.hxx"
#define XML_LINE_LEFT 0
@@ -120,11 +121,21 @@ sal_Bool XMLTextImportPropertyMapper::handleSpecialItem(
case CTF_FONTFAMILYNAME:
case CTF_FONTFAMILYNAME_CJK:
case CTF_FONTFAMILYNAME_CTL:
- case CTF_TEXT_DISPLAY:
bRet = getPropertySetMapper()->importXML( rValue, rProperty,
rUnitConverter );
break;
+ case CTF_TEXT_DISPLAY:
+ bRet = getPropertySetMapper()->importXML( rValue, rProperty,
+ rUnitConverter );
+ if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
+ {
+ sal_Bool bHidden;
+ rProperty.maValue >>= bHidden;
+ bHidden = !bHidden;
+ rProperty.maValue <<= bHidden;
+ }
+ break;
default:
bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
rProperties, rValue, rUnitConverter, rNamespaceMap );
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 3f243e52cbdc..d9b66ffa3653 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -65,15 +65,11 @@
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
-#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
-#endif
#include <com/sun/star/text/SizeType.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
-#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP
#include <com/sun/star/text/TextContentAnchorType.hpp>
-#endif
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
@@ -111,28 +107,23 @@
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlexp.hxx>
#include "txtflde.hxx"
-#ifndef _XMLOFF_TXTPRMAP_HXX
#include <xmloff/txtprmap.hxx>
-#endif
#include "XMLImageMapExport.hxx"
#include "XMLTextNumRuleInfo.hxx"
#include "XMLTextListAutoStylePool.hxx"
-#ifndef _XMLOFF_TXTPARAE_HXX
#include <xmloff/txtparae.hxx>
-#endif
#include "XMLSectionExport.hxx"
#include "XMLIndexMarkExport.hxx"
#include <xmloff/XMLEventExport.hxx>
#include "XMLRedlineExport.hxx"
-#ifndef _XMLOFF_MULTIPROPERTYSETHELPER_HXX
#include "MultiPropertySetHelper.hxx"
-#endif
#include <xmloff/formlayerexport.hxx>
#include "XMLTextCharStyleNamesElementExport.hxx"
// --> OD 2008-04-25 #refactorlists#
#include <txtlists.hxx>
// <--
+#include <com/sun/star/rdf/XMetadatable.hpp>
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
@@ -975,23 +966,29 @@ void XMLTextParagraphExport::exportListChange(
// <text:list-header> or <text:list-item>
GetExport().CheckAttrList();
- if ( nListLevelsToBeOpened == 1 &&
- rNextInfo.HasStartValue() )
+ // --> OD 2009-06-24 #i97309#
+ // export start value in case of <bRestartNumberingAtContinuedRootList>
+ // at correct list item
+ if ( nListLevelsToBeOpened == 1 )
{
- OUStringBuffer aBuffer;
- aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
- GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
- aBuffer.makeStringAndClear() );
- }
- else if ( bRestartNumberingAtContinuedRootList )
- {
- OUStringBuffer aBuffer;
- aBuffer.append( (sal_Int32)nRestartValueForContinuedRootList );
- GetExport().AddAttribute( XML_NAMESPACE_TEXT,
- XML_START_VALUE,
- aBuffer.makeStringAndClear() );
- bRestartNumberingAtContinuedRootList = false;
+ if ( rNextInfo.HasStartValue() )
+ {
+ OUStringBuffer aBuffer;
+ aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
+ GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
+ aBuffer.makeStringAndClear() );
+ }
+ else if ( bRestartNumberingAtContinuedRootList )
+ {
+ OUStringBuffer aBuffer;
+ aBuffer.append( (sal_Int32)nRestartValueForContinuedRootList );
+ GetExport().AddAttribute( XML_NAMESPACE_TEXT,
+ XML_START_VALUE,
+ aBuffer.makeStringAndClear() );
+ bRestartNumberingAtContinuedRootList = false;
+ }
}
+ // <--
eLName = ( rNextInfo.IsNumbered() || nListLevelsToBeOpened > 1 )
? XML_LIST_ITEM
@@ -1131,7 +1128,11 @@ XMLTextParagraphExport::XMLTextParagraphExport(
// <--
sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")),
- sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
+ // --> OD 2009-07-22 #i73249#
+// sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
+ sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")),
+ sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")),
+ // <--
sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")),
sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")),
sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")),
@@ -1460,7 +1461,8 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgres
{
Any aAny = xTextFieldsEnum->nextElement();
Reference< XTextField > xTextField = *(Reference<XTextField>*)aAny.getValue();
- exportTextField( xTextField->getAnchor(), bAutoStyles );
+ exportTextField( xTextField->getAnchor(), bAutoStyles,
+ bIsProgress );
try
{
Reference < XPropertySet > xSet( xTextField, UNO_QUERY );
@@ -1905,6 +1907,7 @@ void XMLTextParagraphExport::exportParagraph(
{
// xml:id for RDF metadata
GetExport().AddAttributeXmlId(rTextContent);
+ GetExport().AddAttributesRDFa(rTextContent);
OUString sStyle;
if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) )
@@ -2142,6 +2145,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
sal_Bool bAutoStyles, sal_Bool bIsProgress,
sal_Bool bPrvChrIsSpc )
{
+ static OUString sMeta(RTL_CONSTASCII_USTRINGPARAM("Meta")); // FIXME
sal_Bool bPrevCharIsSpace = bPrvChrIsSpc;
while( rTextEnum->hasMoreElements() )
@@ -2162,7 +2166,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
}
else if( sType.equals(sTextField))
{
- exportTextField( xTxtRange, bAutoStyles );
+ exportTextField( xTxtRange, bAutoStyles, bIsProgress );
bPrevCharIsSpace = sal_False;
}
else if( sType.equals( sFrame ) )
@@ -2217,6 +2221,10 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
{
exportRuby(xPropSet, bAutoStyles);
}
+ else if (sType.equals(sMeta))
+ {
+ exportMeta(xPropSet, bAutoStyles, bIsProgress);
+ }
else if (sType.equals(sTextFieldStart))
{
Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
@@ -2286,7 +2294,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
Reference<XServiceInfo> xServiceInfo( xTxtRange, UNO_QUERY );
if( xServiceInfo->supportsService( sTextFieldService ) )
{
- exportTextField( xTxtRange, bAutoStyles );
+ exportTextField( xTxtRange, bAutoStyles, bIsProgress );
bPrevCharIsSpace = sal_False;
}
else
@@ -2308,7 +2316,7 @@ void XMLTextParagraphExport::exportTable(
void XMLTextParagraphExport::exportTextField(
const Reference < XTextRange > & rTextRange,
- sal_Bool bAutoStyles )
+ sal_Bool bAutoStyles, sal_Bool bIsProgress )
{
Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
// non-Writer apps need not support Property TextField, so test first
@@ -2320,11 +2328,11 @@ void XMLTextParagraphExport::exportTextField(
{
if( bAutoStyles )
{
- pFieldExport->ExportFieldAutoStyle( xTxtFld );
+ pFieldExport->ExportFieldAutoStyle( xTxtFld, bIsProgress );
}
else
{
- pFieldExport->ExportField( xTxtFld );
+ pFieldExport->ExportField( xTxtFld, bIsProgress );
}
}
else
@@ -2778,6 +2786,10 @@ void XMLTextParagraphExport::_exportTextFrame(
// image map
GetExport().GetImageMapExport().Export( rPropSet );
+ // --> OD 2009-07-22 #i73249#
+ // svg:title and svg:desc
+ exportTitleAndDescription( rPropSet, rPropSetInfo );
+ // <--
}
void XMLTextParagraphExport::exportContour(
@@ -2969,8 +2981,10 @@ void XMLTextParagraphExport::_exportTextGraphic(
// image map
GetExport().GetImageMapExport().Export( rPropSet );
- // svg:desc
- exportAlternativeText( rPropSet, rPropSetInfo );
+ // --> OD 2009-07-22 #i73249#
+ // svg:title and svg:desc
+ exportTitleAndDescription( rPropSet, rPropSetInfo );
+ // <--
// draw:contour
exportContour( rPropSet, rPropSetInfo );
@@ -2999,23 +3013,39 @@ void XMLTextParagraphExport::exportEvents( const Reference < XPropertySet > & rP
if (rPropSet->getPropertySetInfo()->hasPropertyByName(sImageMap))
GetExport().GetImageMapExport().Export( rPropSet );
}
-void XMLTextParagraphExport::exportAlternativeText(
+
+// --> OD 2009-07-22 #i73249#
+void XMLTextParagraphExport::exportTitleAndDescription(
const Reference < XPropertySet > & rPropSet,
const Reference < XPropertySetInfo > & rPropSetInfo )
{
// svg:title
- if( rPropSetInfo->hasPropertyByName( sAlternativeText ) )
+ if( rPropSetInfo->hasPropertyByName( sTitle ) )
{
- OUString sAltText;
- rPropSet->getPropertyValue( sAlternativeText ) >>= sAltText;
- if( sAltText.getLength() )
+ OUString sObjTitle;
+ rPropSet->getPropertyValue( sTitle ) >>= sObjTitle;
+ if( sObjTitle.getLength() )
{
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
XML_TITLE, sal_True, sal_False );
- GetExport().Characters( sAltText );
+ GetExport().Characters( sObjTitle );
+ }
+ }
+
+ // svg:description
+ if( rPropSetInfo->hasPropertyByName( sDescription ) )
+ {
+ OUString sObjDesc;
+ rPropSet->getPropertyValue( sDescription ) >>= sObjDesc;
+ if( sObjDesc.getLength() )
+ {
+ SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
+ XML_DESC, sal_True, sal_False );
+ GetExport().Characters( sObjDesc );
}
}
}
+// <--
void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
const Reference < XPropertySet >&,
@@ -3634,7 +3664,41 @@ void XMLTextParagraphExport::exportRuby(
}
}
+// FIXME: this is untested
+void XMLTextParagraphExport::exportMeta(
+ const Reference<XPropertySet> & i_xMeta,
+ sal_Bool i_bAutoStyles, sal_Bool i_isProgress)
+{
+ bool doExport(!i_bAutoStyles); // do not export element if autostyles
+ // check version >= 1.2
+ switch (GetExport().getDefaultVersion()) {
+ case SvtSaveOptions::ODFVER_011: // fall thru
+ case SvtSaveOptions::ODFVER_010: doExport = false; break;
+ default: break;
+ }
+
+ const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
+ const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
+
+ if (doExport)
+ {
+ const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
+ const Reference<XTextContent> xTextContent( i_xMeta, UNO_QUERY_THROW );
+
+ // text:meta with neither xml:id nor RDFa is invalid
+ xMeta->ensureMetadataReference();
+ // xml:id and RDFa for RDF metadata
+ GetExport().AddAttributeXmlId(xMeta);
+ GetExport().AddAttributesRDFa(xTextContent);
+ }
+
+ SvXMLElementExport aElem( GetExport(), doExport,
+ XML_NAMESPACE_TEXT, XML_META, sal_False, sal_False );
+
+ // recurse to export content
+ exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_isProgress );
+}
void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 31d2891f9f79..6fb213f43642 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -671,34 +671,33 @@ SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext(
// ---------------------------------------------------------------------
-/** text:meta and text:meta-field
-//FIXME neither finished nor tested
+/** for text:meta and text:meta-field
+//FIXME not tested
*/
-class XMLMetaImportContext : public SvXMLImportContext
+class XMLMetaImportContextBase : public SvXMLImportContext
{
- XMLHints_Impl& mrHints;
-// XMLStyleHint_Impl *pHint;
+ XMLHints_Impl& m_rHints;
- sal_Bool& mrIgnoreLeadingSpace;
+ sal_Bool& m_rIgnoreLeadingSpace;
/// start position
- Reference<XTextRange> mxStart;
+ Reference<XTextRange> m_xStart;
- OUString mXmlId;
+protected:
+ OUString m_XmlId;
public:
TYPEINFO();
- XMLMetaImportContext(
+ XMLMetaImportContextBase(
SvXMLImport& i_rImport,
sal_uInt16 i_nPrefix,
const OUString& i_rLocalName,
const Reference< xml::sax::XAttributeList > & i_xAttrList,
-// enum XMLTextPElemTokens nTok,
XMLHints_Impl& i_rHints,
sal_Bool & i_rIgnoreLeadingSpace );
- virtual ~XMLMetaImportContext();
+ virtual ~XMLMetaImportContextBase();
virtual void EndElement();
@@ -707,25 +706,30 @@ public:
const Reference< xml::sax::XAttributeList > & i_xAttrList );
virtual void Characters( const OUString& i_rChars );
+
+ virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
+ OUString const & i_rLocalName, OUString const & i_rValue);
+
+ virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange)
+ = 0;
};
-TYPEINIT1( XMLMetaImportContext , SvXMLImportContext );
+TYPEINIT1( XMLMetaImportContextBase, SvXMLImportContext );
-XMLMetaImportContext::XMLMetaImportContext(
+XMLMetaImportContextBase::XMLMetaImportContextBase(
SvXMLImport& i_rImport,
sal_uInt16 i_nPrefix,
const OUString& i_rLocalName,
const Reference< xml::sax::XAttributeList > & i_xAttrList,
XMLHints_Impl& i_rHints,
sal_Bool & i_rIgnoreLeadingSpace )
- : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ),
- mrHints( i_rHints ),
- mrIgnoreLeadingSpace( i_rIgnoreLeadingSpace ),
- mxStart()
+ : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName )
+ , m_rHints( i_rHints )
+ , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
+ , m_xStart()
{
-//FIXME: RDFa (text:meta)
const sal_Int16 nAttrCount(i_xAttrList.is() ? i_xAttrList->getLength() : 0);
- for( sal_Int16 i=0; i < nAttrCount; i++ )
+ for ( sal_Int16 i=0; i < nAttrCount; i++ )
{
const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) );
const OUString& rValue( i_xAttrList->getValueByIndex( i ) );
@@ -734,49 +738,61 @@ XMLMetaImportContext::XMLMetaImportContext(
sal_uInt16 nPrefix =
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
&sLocalName );
-// FIXME: only meta-field
- if( XML_NAMESPACE_TEXT == nPrefix &&
- IsXMLToken( sLocalName, XML_DATA_STYLE_NAME ) )
- {
-// pHint->SetStyleName( rValue );
- break;
- }
- else if ( (XML_NAMESPACE_XML == nPrefix) &&
- IsXMLToken(sLocalName, XML_ID) )
- {
- mXmlId = rValue;
- }
+ ProcessAttribute(nPrefix, sLocalName, rValue);
}
- //FIXME meta-field xml:id mandatory
- mxStart = GetImport().GetTextImport()->GetCursorAsRange()->getStart();
+ m_xStart = GetImport().GetTextImport()->GetCursorAsRange()->getStart();
}
-XMLMetaImportContext::~XMLMetaImportContext()
+XMLMetaImportContextBase::~XMLMetaImportContextBase()
{
}
-void XMLMetaImportContext::EndElement()
+void XMLMetaImportContextBase::EndElement()
{
- OSL_ENSURE(mxStart.is(), "no mxStart?");
+ OSL_ENSURE(m_xStart.is(), "no mxStart?");
+ if (!m_xStart.is()) return;
- Reference<XTextRange> xEndRange(
+ const Reference<XTextRange> xEndRange(
GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
// create range for insertion
- Reference<XTextCursor> xInsertionCursor(
+ const Reference<XTextCursor> xInsertionCursor(
GetImport().GetTextImport()->GetText()->createTextCursorByRange(
xEndRange) );
- xInsertionCursor->gotoRange(mxStart, sal_True);
+ xInsertionCursor->gotoRange(m_xStart, sal_True);
- Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY);
+ const Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY);
- OUString sName;
+ InsertMeta(xInsertionRange);
//FIXME
- // insert bookmark
-// XMLTextMarkImportContext::CreateAndInsertMark
+#if 0
+ Reference<XMultiServiceFactory> xFactory(rImport.GetModel(), UNO_QUERY);
+ if ( xFactory.is() )
+ {
+ Reference<XInterface> xIfc = xFactory->createInstance(sServiceName);
+
+ // xml:id for RDF metadata
+ rImport.SetXmlId(xIfc, i_rXmlId);
+
+ // cast to XTextContent and attach to document
+ Reference<XTextContent> xTextContent(xIfc, UNO_QUERY);
+ if (xTextContent.is())
+ {
+ try
+ {
+ rImport.GetTextImport()->GetText()->insertTextContent(
+ xInsertionRange, xTextContent, sal_True);
+ }
+ catch (com::sun::star::lang::IllegalArgumentException &)
+ {
+ OSL_ENSURE(false, "XMLMetaImportContext::EndElement: iae");
+ }
+ }
+ }
+#endif
}
-SvXMLImportContext * XMLMetaImportContext::CreateChildContext(
+SvXMLImportContext * XMLMetaImportContextBase::CreateChildContext(
sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
const Reference< xml::sax::XAttributeList > & i_xAttrList )
{
@@ -785,15 +801,236 @@ SvXMLImportContext * XMLMetaImportContext::CreateChildContext(
sal_uInt16 nToken = rTokenMap.Get( i_nPrefix, i_rLocalName );
return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix,
- i_rLocalName, i_xAttrList, nToken, mrHints, mrIgnoreLeadingSpace );
+ i_rLocalName, i_xAttrList, nToken, m_rHints, m_rIgnoreLeadingSpace );
}
-void XMLMetaImportContext::Characters( const OUString& i_rChars )
+void XMLMetaImportContextBase::Characters( const OUString& i_rChars )
{
- //FIXME do we need to call ConvertStarFonts?
- GetImport().GetTextImport()->InsertString( i_rChars, mrIgnoreLeadingSpace );
+ GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
}
+void XMLMetaImportContextBase::ProcessAttribute(sal_uInt16 const i_nPrefix,
+ OUString const & i_rLocalName, OUString const & i_rValue)
+{
+ if ( (XML_NAMESPACE_XML == i_nPrefix) &&
+ IsXMLToken(i_rLocalName, XML_ID) )
+ {
+ m_XmlId = i_rValue;
+ }
+}
+
+
+// ---------------------------------------------------------------------
+
+/** text:meta
+//FIXME not tested
+ */
+class XMLMetaImportContext : public XMLMetaImportContextBase
+{
+ // RDFa
+ bool m_bHaveAbout;
+ ::rtl::OUString m_sAbout;
+ ::rtl::OUString m_sProperty;
+ ::rtl::OUString m_sContent;
+ ::rtl::OUString m_sDatatype;
+
+public:
+ TYPEINFO();
+
+ XMLMetaImportContext(
+ SvXMLImport& i_rImport,
+ sal_uInt16 i_nPrefix,
+ const OUString& i_rLocalName,
+ const Reference< xml::sax::XAttributeList > & i_xAttrList,
+ XMLHints_Impl& i_rHints,
+ sal_Bool & i_rIgnoreLeadingSpace );
+
+ virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
+ OUString const & i_rLocalName, OUString const & i_rValue);
+
+ virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange);
+};
+
+TYPEINIT1( XMLMetaImportContext, XMLMetaImportContextBase );
+
+XMLMetaImportContext::XMLMetaImportContext(
+ SvXMLImport& i_rImport,
+ sal_uInt16 i_nPrefix,
+ const OUString& i_rLocalName,
+ const Reference< xml::sax::XAttributeList > & i_xAttrList,
+ XMLHints_Impl& i_rHints,
+ sal_Bool & i_rIgnoreLeadingSpace )
+ : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName,
+ i_xAttrList, i_rHints, i_rIgnoreLeadingSpace )
+ , m_bHaveAbout(false)
+{
+}
+
+void XMLMetaImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix,
+ OUString const & i_rLocalName, OUString const & i_rValue)
+{
+ if ( XML_NAMESPACE_XHTML == i_nPrefix )
+ {
+ // RDFa
+ if ( IsXMLToken( i_rLocalName, XML_ABOUT) )
+ {
+ m_sAbout = i_rValue;
+ m_bHaveAbout = true;
+ }
+ else if ( IsXMLToken( i_rLocalName, XML_PROPERTY) )
+ {
+ m_sProperty = i_rValue;
+ }
+ else if ( IsXMLToken( i_rLocalName, XML_CONTENT) )
+ {
+ m_sContent = i_rValue;
+ }
+ else if ( IsXMLToken( i_rLocalName, XML_DATATYPE) )
+ {
+ m_sDatatype = i_rValue;
+ }
+ }
+ else
+ {
+ XMLMetaImportContextBase::ProcessAttribute(
+ i_nPrefix, i_rLocalName, i_rValue);
+ }
+}
+
+void XMLMetaImportContext::InsertMeta(
+ const Reference<XTextRange> & i_xInsertionRange)
+{
+ OSL_ENSURE(!m_bHaveAbout == !m_sProperty.getLength(),
+ "XMLMetaImportContext::InsertMeta: invalid RDFa?");
+ if (m_XmlId.getLength() || (m_bHaveAbout && m_sProperty.getLength()))
+ {
+ // insert mark
+ const uno::Reference<rdf::XMetadatable> xMeta(
+ XMLTextMarkImportContext::CreateAndInsertMark(
+ GetImport(),
+ OUString::createFromAscii(
+ "com.sun.star.text.InContentMetadata"),
+ OUString(),
+ i_xInsertionRange, m_XmlId),
+ uno::UNO_QUERY);
+ OSL_ENSURE(xMeta.is(), "cannot insert Meta?");
+
+ if (xMeta.is() && m_bHaveAbout)
+ {
+ GetImport().AddRDFa(xMeta,
+ m_sAbout, m_sProperty, m_sContent, m_sDatatype);
+ }
+ }
+ else
+ {
+ OSL_TRACE("invalid <text:meta>: no xml:id, no valid RDFa");
+ }
+}
+
+// ---------------------------------------------------------------------
+
+/** text:meta-field
+//FIXME not tested
+ */
+class XMLMetaFieldImportContext : public XMLMetaImportContextBase
+{
+ OUString m_DataStyleName;
+
+public:
+ TYPEINFO();
+
+ XMLMetaFieldImportContext(
+ SvXMLImport& i_rImport,
+ sal_uInt16 i_nPrefix,
+ const OUString& i_rLocalName,
+ const Reference< xml::sax::XAttributeList > & i_xAttrList,
+ XMLHints_Impl& i_rHints,
+ sal_Bool & i_rIgnoreLeadingSpace );
+
+ virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
+ OUString const & i_rLocalName, OUString const & i_rValue);
+
+ virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange);
+};
+
+TYPEINIT1( XMLMetaFieldImportContext, XMLMetaImportContextBase );
+
+XMLMetaFieldImportContext::XMLMetaFieldImportContext(
+ SvXMLImport& i_rImport,
+ sal_uInt16 i_nPrefix,
+ const OUString& i_rLocalName,
+ const Reference< xml::sax::XAttributeList > & i_xAttrList,
+ XMLHints_Impl& i_rHints,
+ sal_Bool & i_rIgnoreLeadingSpace )
+ : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName,
+ i_xAttrList, i_rHints, i_rIgnoreLeadingSpace )
+{
+}
+
+void XMLMetaFieldImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix,
+ OUString const & i_rLocalName, OUString const & i_rValue)
+{
+ if( XML_NAMESPACE_STYLE == i_nPrefix &&
+ IsXMLToken( i_rLocalName, XML_DATA_STYLE_NAME ) )
+ {
+ m_DataStyleName = i_rValue;
+ }
+ else
+ {
+ XMLMetaImportContextBase::ProcessAttribute(
+ i_nPrefix, i_rLocalName, i_rValue);
+ }
+}
+
+void XMLMetaFieldImportContext::InsertMeta(
+ const Reference<XTextRange> & i_xInsertionRange)
+{
+ if (m_XmlId.getLength()) // valid?
+ {
+ // insert mark
+ const Reference<XPropertySet> xPropertySet(
+ XMLTextMarkImportContext::CreateAndInsertMark(
+ GetImport(),
+ OUString::createFromAscii(
+ "com.sun.star.text.textfield.MetadataField"),
+ OUString(),
+ i_xInsertionRange, m_XmlId),
+ UNO_QUERY);
+ OSL_ENSURE(xPropertySet.is(), "cannot insert MetaField?");
+ if (!xPropertySet.is()) return;
+
+ if (m_DataStyleName.getLength())
+ {
+ sal_Bool isDefaultLanguage(sal_True);
+
+ const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey(
+ m_DataStyleName, & isDefaultLanguage) );
+
+ if (-1 != nKey)
+ {
+ static ::rtl::OUString sPropertyIsFixedLanguage(
+ ::rtl::OUString::createFromAscii("IsFixedLanguage") );
+ Any any;
+ any <<= nKey;
+ xPropertySet->setPropertyValue(
+ OUString::createFromAscii("NumberFormat"), any);
+ if ( xPropertySet->getPropertySetInfo()->
+ hasPropertyByName( sPropertyIsFixedLanguage ) )
+ {
+ any <<= static_cast<bool>(!isDefaultLanguage);
+ xPropertySet->setPropertyValue( sPropertyIsFixedLanguage,
+ any );
+ }
+ }
+ }
+ }
+ else
+ {
+ OSL_TRACE("invalid <text:meta-field>: no xml:id");
+ }
+}
+
+
// ---------------------------------------------------------------------
@@ -1574,13 +1811,17 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
sal_False);
break;
- case XML_TOK_TEXT_META:
- case XML_TOK_TEXT_META_FIELD:
// FIXME: should test before enabling...
#if 0
+ case XML_TOK_TEXT_META:
pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName,
xAttrList, rHints, rIgnoreLeadingSpace );
break;
+
+ case XML_TOK_TEXT_META_FIELD:
+ pContext = new XMLMetaFieldImportContext(rImport, nPrefix, rLocalName,
+ xAttrList, rHints, rIgnoreLeadingSpace );
+ break;
#endif
default:
@@ -1657,6 +1898,7 @@ XMLParaContext::XMLParaContext(
sal_Bool bHead ) :
SvXMLImportContext( rImport, nPrfx, rLName ),
xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
+ m_bHaveAbout(false),
nOutlineLevel( IsXMLToken( rLName, XML_H ) ? 1 : -1 ),
pHints( 0 ),
// --> OD 2007-07-25 #i73509#
@@ -1686,9 +1928,21 @@ XMLParaContext::XMLParaContext(
&aLocalName );
switch( rTokenMap.Get( nPrefix, aLocalName ) )
{
-//FIXME: RDFa
case XML_TOK_TEXT_P_XMLID:
- sXmlId = rValue;
+ m_sXmlId = rValue;
+ break;
+ case XML_TOK_TEXT_P_ABOUT:
+ m_sAbout = rValue;
+ m_bHaveAbout = true;
+ break;
+ case XML_TOK_TEXT_P_PROPERTY:
+ m_sProperty = rValue;
+ break;
+ case XML_TOK_TEXT_P_CONTENT:
+ m_sContent = rValue;
+ break;
+ case XML_TOK_TEXT_P_DATATYPE:
+ m_sDatatype = rValue;
break;
case XML_TOK_TEXT_P_STYLE_NAME:
sStyleName = rValue;
@@ -1785,7 +2039,8 @@ XMLParaContext::~XMLParaContext()
xAttrCursor->gotoRange( xEnd, sal_True );
// xml:id for RDF metadata
- if (sXmlId.getLength() > 0) {
+ if (m_sXmlId.getLength() || m_bHaveAbout || m_sProperty.getLength())
+ {
try {
const uno::Reference<container::XEnumerationAccess> xEA
(xAttrCursor, uno::UNO_QUERY_THROW);
@@ -1795,12 +2050,17 @@ XMLParaContext::~XMLParaContext()
if (xEnum->hasMoreElements()) {
uno::Reference<rdf::XMetadatable> xMeta;
xEnum->nextElement() >>= xMeta;
-//FIXME not yet
-// OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
- GetImport().SetXmlId(xMeta, sXmlId);
+ OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
+ GetImport().SetXmlId(xMeta, m_sXmlId);
+ if (m_bHaveAbout)
+ {
+ GetImport().AddRDFa(xMeta,
+ m_sAbout, m_sProperty, m_sContent, m_sDatatype);
+ }
OSL_ENSURE(!xEnum->hasMoreElements(), "xml:id: > 1 paragraph?");
}
} catch (uno::Exception &) {
+ OSL_TRACE("XMLParaContext::~XMLParaContext: exception");
}
}
diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx
index 781055d2f297..6eaeeee1ee46 100644
--- a/xmloff/source/text/txtparai.hxx
+++ b/xmloff/source/text/txtparai.hxx
@@ -50,7 +50,12 @@ class XMLParaContext : public SvXMLImportContext
::com::sun::star::text::XTextRange > xStart; // xub_StrLen nStart;
::rtl::OUString sStyleName;
::rtl::OUString sId;
- ::rtl::OUString sXmlId;
+ ::rtl::OUString m_sXmlId;
+ ::rtl::OUString m_sAbout;
+ ::rtl::OUString m_sProperty;
+ ::rtl::OUString m_sContent;
+ ::rtl::OUString m_sDatatype;
+ bool m_bHaveAbout;
sal_Int8 nOutlineLevel;
XMLHints_Impl *pHints;
// --> OD 2007-07-25 #i73509#
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 18946de8c3a6..c82e4d09e271 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -372,7 +372,7 @@ XMLPropertyMapEntry aXMLParaPropMap[] =
// RES_PARATR_SNAPTOGRID
MP_E( "SnapToGrid", STYLE, SNAP_TO_LAYOUT_GRID, XML_TYPE_BOOL, 0 ),
- MP_ED( "WritingMode", STYLE, WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT, 0 ),
+ MP_ED( "WritingMode", STYLE, WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT, CTF_TEXTWRITINGMODE ),
MP_E( "ParaIsConnectBorder", STYLE, JOIN_BORDER, XML_TYPE_BOOL, 0 ),
diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx
index b5eb0a7bdfcb..c41d54bb00ed 100644
--- a/xmloff/source/text/txtstyli.cxx
+++ b/xmloff/source/text/txtstyli.cxx
@@ -547,30 +547,6 @@ void XMLTextStyleContext::FillPropertySet(
struct XMLPropertyState& rState = GetProperties()[nIndex];
Any rAny = rState.maValue;
sal_Int32 nMapperIndex = rState.mnIndex;
- if( i == 3 )
- {
- if( SvXMLImport::OOo_2x != GetImport().getGeneratorVersion() )
- continue;
- sal_Bool bHidden;
- rAny >>= bHidden;
- bHidden = !bHidden;
- Any aAny( rAny );
- aAny <<= bHidden;
- // get property set mapper
- UniReference<XMLPropertySetMapper> rPropMapper =
- xImpPrMap->getPropertySetMapper();
-
- // set property
- OUString rPropertyName(
- rPropMapper->GetEntryAPIName(nMapperIndex) );
- if( !xInfo.is() )
- xInfo = rPropSet->getPropertySetInfo();
- if ( xInfo->hasPropertyByName( rPropertyName ) )
- {
- rPropSet->setPropertyValue( rPropertyName, aAny );
- }
- continue;
- }
// Now check for font name in rState and set corrected value,
// if necessary.