From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- sw/inc/rdfhelper.hxx | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 sw/inc/rdfhelper.hxx (limited to 'sw/inc/rdfhelper.hxx') diff --git a/sw/inc/rdfhelper.hxx b/sw/inc/rdfhelper.hxx new file mode 100644 index 000000000..ee346c499 --- /dev/null +++ b/sw/inc/rdfhelper.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SW_INC_RDFHELPER_HXX +#define INCLUDED_SW_INC_RDFHELPER_HXX + +#include + +#include + +#include "swdllapi.h" + +#include +#include + +class SwTextNode; + +namespace com::sun::star { + namespace frame { + class XModel; + } + namespace rdf { + class XDocumentMetadataAccess; + class XResource; + class XURI; + } +} + +/// Provides access to RDF metadata on core objects. +class SW_DLLPUBLIC SwRDFHelper +{ +public: + /// Gets all graph-names in RDF of a given type. + static css::uno::Sequence> + getGraphNames(const css::uno::Reference& xDocumentMetadataAccess, + const css::uno::Reference& xType); + + /// Gets all graph-names in RDF of a given type. + static css::uno::Sequence> + getGraphNames(const css::uno::Reference& xModel, const OUString& rType); + + /// Gets all (XResource, key, value) statements in RDF graphs given the graph-names. + static std::map + getStatements(const css::uno::Reference& xModel, + const css::uno::Sequence>& rGraphNames, + const css::uno::Reference& xSubject); + + /// Gets all (XResource, key, value) statements in RDF graphs of type rType. + static std::map + getStatements(const css::uno::Reference& xModel, const OUString& rType, + const css::uno::Reference& xSubject); + + /// Add an (XResource, key, value) statement in the graph of type rType -- or if it does not exist, create a graph at rPath first. + static void addStatement(const css::uno::Reference& xModel, + const OUString& rType, const OUString& rPath, + const css::uno::Reference& xSubject, + const OUString& rKey, const OUString& rValue); + + /// Check if a graph of type rType exists. + static bool hasMetadataGraph(const css::uno::Reference& xModel, + const OUString& rType); + + /// Remove an (XResource, key, value) statement in the graph of type rType, if it exists. + static void removeStatement(const css::uno::Reference& xModel, + const OUString& rType, + const css::uno::Reference& xSubject, + const OUString& rKey, const OUString& rValue); + + /// Clone all statements in the graph of type rType, if any exists, from one subject to another. + static void cloneStatements(const css::uno::Reference& xSrcModel, + const css::uno::Reference& xDstModel, + const OUString& rType, + const css::uno::Reference& xSrcSubject, + const css::uno::Reference& xDstSubject); + + /// Remove all statements in the graph of type rType, if any exists. + static void clearStatements(const css::uno::Reference& xModel, + const OUString& rType, + const css::uno::Reference& xSubject); + + /// Gets all (rTextNode, key, value) statements in RDF graphs of type rType. + static std::map getTextNodeStatements(const OUString& rType, SwTextNode& rTextNode); + + /// Add an (rTextNode, key, value) statement in the graph of type rType -- or if it does not exist, create a graph at rPath first. + static void addTextNodeStatement(const OUString& rType, const OUString& rPath, SwTextNode& rTextNode, const OUString& rKey, const OUString& rValue); + + /// Remove an (rTextNode, key, value) statement in the graph of type rType. + static void removeTextNodeStatement(const OUString& rType, SwTextNode& rTextNode, const OUString& rKey, const OUString& rValue); + + /// Update an (rTextNode, key, value) statement in the graph of type rType from old value to new. Creates the graph at rPath if doesn't exist. + static void updateTextNodeStatement(const OUString& rType, const OUString& rPath, SwTextNode& rTextNode, const OUString& rKey, const OUString& rOldValue, const OUString& rNewValue); + +}; + +#endif // INCLUDED_SW_INC_RDFHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3