[Libreoffice-commits] core.git: sw/inc sw/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Fri Nov 10 23:47:01 UTC 2017
sw/inc/rdfhelper.hxx | 4 ++++
sw/source/core/doc/rdfhelper.cxx | 9 +++++++++
sw/source/core/edit/edfcol.cxx | 4 ++++
3 files changed, 17 insertions(+)
New commits:
commit 8a5a9e05cce756e9f7aa11b86972939a8a70a839
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Fri Nov 10 13:06:51 2017 +0900
TSCP: bail out quickly in paragraph classification check on save
Before saving a document we need to check that the document level
classification is at the higher or same level as the individual
paragraph level classification is. The trouble here is tha this
can be quite a costly operation, so bail out quickly if we don't
detect that no paragraph classification has been applied to the
content by checking if we have the RDF metadata present or not.
Change-Id: Iaef29de7e138937a5c1881cf34c9075fb37ba87d
Reviewed-on: https://gerrit.libreoffice.org/44573
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/sw/inc/rdfhelper.hxx b/sw/inc/rdfhelper.hxx
index 33c10eece3ed..bf72a5be40be 100644
--- a/sw/inc/rdfhelper.hxx
+++ b/sw/inc/rdfhelper.hxx
@@ -45,6 +45,10 @@ public:
const css::uno::Reference<css::rdf::XResource>& xSubject,
const OUString& rKey, const OUString& rValue);
+ /// Check if a graph of type rType exists.
+ static bool hasMetadataGraph(const css::uno::Reference<css::frame::XModel>& 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<css::frame::XModel>& xModel,
const OUString& rType,
diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx
index 3e146c80db39..4834dd2a5a12 100644
--- a/sw/source/core/doc/rdfhelper.cxx
+++ b/sw/source/core/doc/rdfhelper.cxx
@@ -73,6 +73,15 @@ void SwRDFHelper::addStatement(const css::uno::Reference<css::frame::XModel>& xM
xGraph->addStatement(xSubject, xKey, xValue);
}
+bool SwRDFHelper::hasMetadataGraph(const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rType)
+{
+ uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
+ uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, rType);
+ uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel, uno::UNO_QUERY);
+ uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType);
+ return aGraphNames.hasElements();
+}
+
void SwRDFHelper::removeStatement(const css::uno::Reference<css::frame::XModel>& xModel,
const OUString& rType,
const css::uno::Reference<css::rdf::XResource>& xSubject,
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index fc7ffcfa9b86..00fb5766c836 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -2035,6 +2035,10 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass()
if (!pDocShell)
return;
+ // bail out as early as possible if we don't have paragraph classification
+ if (!SwRDFHelper::hasMetadataGraph(pDocShell->GetBaseModel(), MetaNS))
+ return;
+
SfxClassificationHelper aHelper(pDocShell->getDocProperties());
const OUString sHighestParaClass = lcl_GetHighestClassificationParagraphClass(GetCursor());
More information about the Libreoffice-commits
mailing list