30#include <com/sun/star/frame/XModel.hpp>
31#include <com/sun/star/uri/XUriReference.hpp>
32#include <com/sun/star/uri/UriReferenceFactory.hpp>
33#include <com/sun/star/rdf/Statement.hpp>
34#include <com/sun/star/rdf/XLiteral.hpp>
35#include <com/sun/star/rdf/XRepositorySupplier.hpp>
36#include <com/sun/star/rdf/XDocumentRepository.hpp>
38#include <rtl/ustrbuf.hxx>
49 uno::Reference<rdf::XURI>
const & i_xURI)
51 OSL_ENSURE(i_xURI.is(),
"makeCURIE: null URI");
52 if (!i_xURI.is())
throw uno::RuntimeException();
54 const OUString Namespace( i_xURI->getNamespace() );
55 OSL_ENSURE(!Namespace.isEmpty(),
"makeCURIE: no namespace");
56 if (Namespace.isEmpty())
throw uno::RuntimeException();
59 return i_pExport->
EnsureNamespace(Namespace) +
":" + i_xURI->getLocalName();
68 uno::Reference< rdf::XURI >
const xModelURI(
69 rExport.
GetModel(), uno::UNO_QUERY_THROW );
70 OUString
const baseURI( xModelURI->getStringValue() );
73 uno::Reference<uri::XUriReferenceFactory>
const xUriFactory =
74 uri::UriReferenceFactory::create( xContext );
76 uno::Reference< uri::XUriReference >
const xBaseURI(
77 xUriFactory->parse(baseURI), uno::UNO_SET_THROW );
78 uno::Reference< uri::XUriReference >
const xAbsoluteURI(
79 xUriFactory->parse(rURI), uno::UNO_SET_THROW );
80 uno::Reference< uri::XUriReference >
const xRelativeURI(
81 xUriFactory->makeRelative(xBaseURI, xAbsoluteURI,
true,
true,
false),
83 OUString
const relativeURI(xRelativeURI->getUriReference());
89 : m_rExport(i_rExport), m_Counter(0)
92 uno::UNO_QUERY_THROW);
93 m_xRepository.set(xRS->getRDFRepository(), uno::UNO_QUERY_THROW);
98 uno::Reference<rdf::XBlankNode>
const & i_xBlankNode)
100 OSL_ENSURE(i_xBlankNode.is(),
"null BlankNode?");
101 if (!i_xBlankNode.is())
throw uno::RuntimeException();
104 if (rEntry.isEmpty())
106 rEntry =
"_:b" + OUString::number(++
m_Counter);
113 uno::Reference<rdf::XMetadatable>
const & i_xMetadatable)
117 beans::Pair< uno::Sequence<rdf::Statement>,
sal_Bool >
const
118 RDFaResult(
m_xRepository->getStatementRDFa(i_xMetadatable) );
120 uno::Sequence<rdf::Statement>
const & rStatements( RDFaResult.First );
122 if (!rStatements.hasElements())
128 const uno::Reference<rdf::XURI> xSubjectURI(rStatements[0].Subject,
130 const uno::Reference<rdf::XBlankNode> xSubjectBNode(
131 rStatements[0].Subject, uno::UNO_QUERY);
132 if (!xSubjectURI.is() && !xSubjectBNode.is())
134 throw uno::RuntimeException();
136 const OUString about( xSubjectURI.is()
141 const uno::Reference<rdf::XLiteral> xContent(
142 rStatements[0].
Object, uno::UNO_QUERY_THROW );
143 const uno::Reference<rdf::XURI> xDatatype(xContent->getDatatype());
146 const OUString datatype(
151 if (RDFaResult.Second)
154 xContent->getValue());
157 ::std::vector<OUString> curies;
158 for (rdf::Statement
const& rStatement : rStatements)
163 ::comphelper::intersperse(curies.begin(), curies.end(),
172 catch (uno::Exception &)
OUString EnsureNamespace(OUString const &i_rNamespace)
ensures that the given namespace is in scope at the next started element.
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
const css::uno::Reference< css::frame::XModel > & GetModel() const
OUString LookupBlankNode(css::uno::Reference< css::rdf::XBlankNode > const &i_xBlankNode)
RDFaExportHelper(SvXMLExport &i_rExport)
BlankNodeMap_t m_BlankNodeMap
void AddRDFa(css::uno::Reference< css::rdf::XMetadatable > const &i_xMetadatable)
css::uno::Reference< css::rdf::XDocumentRepository > m_xRepository
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XComponentContext > getProcessComponentContext()
static OUString getRelativeReference(SvXMLExport const &rExport, OUString const &rURI)
static OUString makeCURIE(SvXMLExport *i_pExport, uno::Reference< rdf::XURI > const &i_xURI)
constexpr sal_uInt16 XML_NAMESPACE_XHTML