summaryrefslogtreecommitdiff
path: root/xmloff/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/core')
-rw-r--r--xmloff/source/core/RDFaExportHelper.cxx61
-rw-r--r--xmloff/source/core/RDFaImportHelper.cxx98
-rw-r--r--xmloff/source/core/makefile.mk7
-rw-r--r--xmloff/source/core/xmlexp.cxx16
-rw-r--r--xmloff/source/core/xmlimp.cxx23
-rw-r--r--xmloff/source/core/xmlkywd.cxx38
6 files changed, 124 insertions, 119 deletions
diff --git a/xmloff/source/core/RDFaExportHelper.cxx b/xmloff/source/core/RDFaExportHelper.cxx
index e755b287d3..e88cb6b84b 100644
--- a/xmloff/source/core/RDFaExportHelper.cxx
+++ b/xmloff/source/core/RDFaExportHelper.cxx
@@ -95,11 +95,6 @@ RDFaExportHelper::RDFaExportHelper(SvXMLExport & i_rExport)
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
@@ -128,19 +123,21 @@ RDFaExportHelper::AddRDFa(
{
try
{
- uno::Sequence<rdf::Statement> stmts(
- m_xRepository->getStatementRDFa(i_xMetadatable) );
+ beans::Pair< uno::Sequence<rdf::Statement>, sal_Bool > const
+ RDFaResult( m_xRepository->getStatementRDFa(i_xMetadatable) );
+
+ uno::Sequence<rdf::Statement> const & rStatements( RDFaResult.First );
- if (0 == stmts.getLength())
+ if (0 == rStatements.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,
+ const uno::Reference<rdf::XURI> xSubjectURI(rStatements[0].Subject,
uno::UNO_QUERY);
+ const uno::Reference<rdf::XBlankNode> xSubjectBNode(
+ rStatements[0].Subject, uno::UNO_QUERY);
if (!xSubjectURI.is() && !xSubjectBNode.is())
{
throw uno::RuntimeException();
@@ -154,47 +151,31 @@ RDFaExportHelper::AddRDFa(
.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))
+ const uno::Reference<rdf::XLiteral> xContent(
+ rStatements[0].Object, uno::UNO_QUERY_THROW );
+ const uno::Reference<rdf::XURI> xDatatype(xContent->getDatatype());
+ if (xDatatype.is())
{
- // 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());
- }
+ const ::rtl::OUString datatype(
+ makeCURIE(&m_rExport, xDatatype) );
+ m_rExport.AddAttribute(XML_NAMESPACE_XHTML,
+ token::XML_DATATYPE, datatype);
}
- else
+ if (RDFaResult.Second) // there is xhtml:content
{
- OSL_ENSURE(false,"invalid RDFa: every property is rdfs:label");
- return;
+ m_rExport.AddAttribute(XML_NAMESPACE_XHTML, token::XML_CONTENT,
+ xContent->getValue());
}
::rtl::OUStringBuffer property;
::comphelper::intersperse(
::boost::make_transform_iterator(
- iter, // omit RDFsLabel predicates!
+ ::comphelper::stl_begin(rStatements),
::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),
+ ::comphelper::stl_end(rStatements),
::boost::bind(&makeCURIE, &m_rExport,
::boost::bind(&rdf::Statement::Predicate, _1))),
::comphelper::OUStringBufferAppender(property),
diff --git a/xmloff/source/core/RDFaImportHelper.cxx b/xmloff/source/core/RDFaImportHelper.cxx
index 4257f36c33..a217b3115e 100644
--- a/xmloff/source/core/RDFaImportHelper.cxx
+++ b/xmloff/source/core/RDFaImportHelper.cxx
@@ -126,28 +126,39 @@ public:
void InsertRDFaEntry(struct RDFaEntry const & i_rEntry);
};
-/** store metadatable object and its RDFa attributes */
-struct SAL_DLLPRIVATE RDFaEntry
+/** store parsed RDFa attributes */
+struct SAL_DLLPRIVATE ParsedRDFaAttributes
{
- 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,
+ ParsedRDFaAttributes(
::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_About(i_rAbout)
, m_Properties(i_rProperties)
, m_Content(i_rContent)
, m_Datatype(i_rDatatype)
{ }
};
+/** store metadatable object and its RDFa attributes */
+struct SAL_DLLPRIVATE RDFaEntry
+{
+ uno::Reference<rdf::XMetadatable> m_xObject;
+ ::boost::shared_ptr<ParsedRDFaAttributes> m_pRDFaAttributes;
+
+ RDFaEntry(uno::Reference<rdf::XMetadatable> const & i_xObject,
+ ::boost::shared_ptr<ParsedRDFaAttributes> const& i_pRDFaAttributes)
+ : m_xObject(i_xObject)
+ , m_pRDFaAttributes(i_pRDFaAttributes)
+ { }
+};
+
////////////////////////////////////////////////////////////////////////////
@@ -344,7 +355,7 @@ void RDFaInserter::InsertRDFaEntry(
if (!i_rEntry.m_xObject.is()) return;
const uno::Reference< rdf::XResource > xSubject(
- MakeResource( i_rEntry.m_About ) );
+ MakeResource( i_rEntry.m_pRDFaAttributes->m_About ) );
if (!xSubject.is())
{
return; // invalid
@@ -352,13 +363,15 @@ void RDFaInserter::InsertRDFaEntry(
::comphelper::SequenceAsVector< uno::Reference< rdf::XURI > > predicates;
- predicates.reserve(i_rEntry.m_Properties.size());
+ predicates.reserve(i_rEntry.m_pRDFaAttributes->m_Properties.size());
::std::remove_copy_if(
- ::boost::make_transform_iterator(i_rEntry.m_Properties.begin(),
+ ::boost::make_transform_iterator(
+ i_rEntry.m_pRDFaAttributes->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::make_transform_iterator(
+ i_rEntry.m_pRDFaAttributes->m_Properties.end(),
::boost::bind(&RDFaInserter::MakeURI, this, _1)),
::std::back_inserter(predicates),
ref_is_null() );
@@ -375,9 +388,9 @@ void RDFaInserter::InsertRDFaEntry(
}
uno::Reference<rdf::XURI> xDatatype;
- if (i_rEntry.m_Datatype.getLength())
+ if (i_rEntry.m_pRDFaAttributes->m_Datatype.getLength())
{
- xDatatype = MakeURI( i_rEntry.m_Datatype );
+ xDatatype = MakeURI( i_rEntry.m_pRDFaAttributes->m_Datatype );
}
try
@@ -386,7 +399,8 @@ void RDFaInserter::InsertRDFaEntry(
// 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);
+ i_rEntry.m_xObject,
+ i_rEntry.m_pRDFaAttributes->m_Content, xDatatype);
}
catch (uno::Exception &)
{
@@ -405,9 +419,8 @@ RDFaImportHelper::~RDFaImportHelper()
{
}
-void
-RDFaImportHelper::AddRDFa(
- uno::Reference<rdf::XMetadatable> i_xObject,
+::boost::shared_ptr<ParsedRDFaAttributes>
+RDFaImportHelper::ParseRDFa(
::rtl::OUString const & i_rAbout,
::rtl::OUString const & i_rProperty,
::rtl::OUString const & i_rContent,
@@ -416,25 +429,58 @@ RDFaImportHelper::AddRDFa(
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;
+ return ::boost::shared_ptr<ParsedRDFaAttributes>();
}
// must parse CURIEs here: need namespace declaration context
RDFaReader reader(GetImport());
const ::rtl::OUString about( reader.ReadURIOrSafeCURIE(i_rAbout) );
- if (!about.getLength()) return;
+ if (!about.getLength()) {
+ return ::boost::shared_ptr<ParsedRDFaAttributes>();
+ }
const ::std::vector< ::rtl::OUString > properties(
reader.ReadCURIEs(i_rProperty) );
- if (!properties.size()) return;
+ if (!properties.size()) {
+ return ::boost::shared_ptr<ParsedRDFaAttributes>();
+ }
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));
+ return ::boost::shared_ptr<ParsedRDFaAttributes>(
+ new ParsedRDFaAttributes(about, properties, i_rContent, datatype));
+}
+
+void
+RDFaImportHelper::AddRDFa(
+ uno::Reference<rdf::XMetadatable> const & i_xObject,
+ ::boost::shared_ptr<ParsedRDFaAttributes> & i_pRDFaAttributes)
+{
+ if (!i_xObject.is())
+ {
+ OSL_ENSURE(false, "AddRDFa: invalid arg: null textcontent");
+ return;
+ }
+ if (!i_pRDFaAttributes.get())
+ {
+ OSL_ENSURE(false, "AddRDFa: invalid arg: null RDFa attributes");
+ return;
+ }
+ m_RDFaEntries.push_back(RDFaEntry(i_xObject, i_pRDFaAttributes));
+}
+
+void
+RDFaImportHelper::ParseAndAddRDFa(
+ uno::Reference<rdf::XMetadatable> const & i_xObject,
+ ::rtl::OUString const & i_rAbout,
+ ::rtl::OUString const & i_rProperty,
+ ::rtl::OUString const & i_rContent,
+ ::rtl::OUString const & i_rDatatype)
+{
+ ::boost::shared_ptr<ParsedRDFaAttributes> pAttributes(
+ ParseRDFa(i_rAbout, i_rProperty, i_rContent, i_rDatatype) );
+ if (pAttributes.get())
+ {
+ AddRDFa(i_xObject, pAttributes);
+ }
}
void RDFaImportHelper::InsertRDFa(
diff --git a/xmloff/source/core/makefile.mk b/xmloff/source/core/makefile.mk
index b881f9610f..4d663d3218 100644
--- a/xmloff/source/core/makefile.mk
+++ b/xmloff/source/core/makefile.mk
@@ -38,12 +38,6 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
.INCLUDE: $(PRJ)$/util$/makefile.pmk
-# --- to build xmlkywd.obj in obj, too -----------------------------
-
-OBJFILES = $(OBJ)$/xmlkywd.obj
-LIB2TARGET =$(LB)$/xmlkywd.lib
-LIB2OBJFILES =$(OBJFILES)
-
# --- Files --------------------------------------------------------
SLOFILES = \
@@ -59,7 +53,6 @@ SLOFILES = \
$(SLO)$/xmlexp.obj \
$(SLO)$/xmlictxt.obj \
$(SLO)$/xmlimp.obj \
- $(SLO)$/xmlkywd.obj \
$(SLO)$/xmltkmap.obj \
$(SLO)$/xmltoken.obj \
$(SLO)$/xmluconv.obj \
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index a87141adf2..25965187f4 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -2535,6 +2535,22 @@ SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const
}
void
+SvXMLExport::AddAttributeIdLegacy(
+ sal_uInt16 const nLegacyPrefix, ::rtl::OUString const& rValue)
+{
+ switch (getDefaultVersion()) {
+ case SvtSaveOptions::ODFVER_011: // fall thru
+ case SvtSaveOptions::ODFVER_010: break;
+ default: // ODF 1.2: xml:id
+ AddAttribute(XML_NAMESPACE_XML, XML_ID, rValue);
+ }
+ // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
+ // backward compatibility: in ODF 1.2 write _both_ id attrs
+ AddAttribute(nLegacyPrefix, XML_ID, rValue);
+ // FIXME: this function simply assumes that rValue is unique
+}
+
+void
SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
{
// check version >= 1.2
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index dda82a237f..e128bfc556 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -38,7 +38,6 @@
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmluconv.hxx>
#include "xmlnmspe.hxx"
-#include "xmlkywd.hxx"
#include <xmloff/xmltoken.hxx>
#include <xmloff/XMLFontStylesContext.hxx>
#include <xmloff/xmlictxt.hxx>
@@ -110,6 +109,7 @@ sal_Char __READONLY_DATA sXML_np__number[] = "_number";
sal_Char __READONLY_DATA sXML_np__svg[] = "_svg";
sal_Char __READONLY_DATA sXML_np__chart[] = "_chart";
sal_Char __READONLY_DATA sXML_np__math[] = "_math";
+sal_Char __READONLY_DATA sXML_np__form[] = "_form";
sal_Char __READONLY_DATA sXML_np__script[] = "_script";
sal_Char __READONLY_DATA sXML_np__config[] = "_config";
sal_Char __READONLY_DATA sXML_np__db[] = "_db";
@@ -293,7 +293,7 @@ void SvXMLImport::_InitCtor()
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ),
GetXMLToken(XML_N_MATH),
XML_NAMESPACE_MATH );
- mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_namespace_form) ),
+ mpNamespaceMap->Add(OUString(RTL_CONSTASCII_USTRINGPARAM( sXML_np__form )),
GetXMLToken(XML_N_FORM),
XML_NAMESPACE_FORM );
mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ),
@@ -675,7 +675,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName,
}
}
else if( ( rAttrName.getLength() >= 5 ) &&
- ( rAttrName.compareToAscii( sXML_xmlns, 5 ) == 0 ) &&
+ ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) &&
( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
{
if( !pRewindMap )
@@ -1985,6 +1985,16 @@ void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
}
}
+SAL_DLLPRIVATE ::xmloff::RDFaImportHelper &
+SvXMLImport::GetRDFaImportHelper()
+{
+ if (!mpImpl->mpRDFaHelper.get())
+ {
+ mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
+ }
+ return *mpImpl->mpRDFaHelper;
+}
+
void
SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
::rtl::OUString const & i_rAbout,
@@ -1994,11 +2004,8 @@ SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
{
// 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,
+ ::xmloff::RDFaImportHelper & rRDFaHelper( GetRDFaImportHelper() );
+ rRDFaHelper.ParseAndAddRDFa(i_xObject,
i_rAbout, i_rProperty, i_rContent, i_rDatatype);
}
diff --git a/xmloff/source/core/xmlkywd.cxx b/xmloff/source/core/xmlkywd.cxx
deleted file mode 100644
index 78203ee781..0000000000
--- a/xmloff/source/core/xmlkywd.cxx
+++ /dev/null
@@ -1,38 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmloff.hxx"
-
-#ifndef _XMLOFF_XMLKYWD_HXX
-#define XML_DEFINE_KEYWORDS
-#include "xmlkywd.hxx"
-#undef XML_DEFINE_KEYWORDS
-#endif
-
-
-