summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-11-03 21:57:18 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-11-04 02:49:36 +0100
commit40918d0321f9e9a958fa80f309213e199cf21bce (patch)
treedbb18d1a99abc825111b1898446f5f66e97fe3b2 /svx
parent8f1f4d5a6f4b376975e9e2f318e8c92d4bade90a (diff)
TSCP: add a full text. value of the header/footer as doc. property
Change-Id: I4742066c34802017790c1c21ec04a7760d4fe1f7 Reviewed-on: https://gerrit.libreoffice.org/44279 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/Library_svx.mk1
-rw-r--r--svx/source/dialog/ClassificationCommon.cxx79
2 files changed, 80 insertions, 0 deletions
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index c04dfc8e6dc4..6bdbadaf2e3b 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -117,6 +117,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/dialog/crashreportdlg \
svx/source/dialog/crashreportui) \
svx/source/dialog/ctredlin \
+ svx/source/dialog/ClassificationCommon \
svx/source/dialog/ClassificationDialog \
svx/source/dialog/ClassificationEditView \
svx/source/dialog/databaseregistrationui \
diff --git a/svx/source/dialog/ClassificationCommon.cxx b/svx/source/dialog/ClassificationCommon.cxx
new file mode 100644
index 000000000000..60cfcf520ab4
--- /dev/null
+++ b/svx/source/dialog/ClassificationCommon.cxx
@@ -0,0 +1,79 @@
+/* -*- 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/.
+ *
+ */
+
+#include <svx/ClassificationCommon.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+using namespace css;
+
+namespace svx {
+namespace classification {
+
+OUString convertClassificationResultToString(std::vector<svx::ClassificationResult> const & rResults)
+{
+ OUString sRepresentation = "";
+
+ for (svx::ClassificationResult const & rResult : rResults)
+ {
+ switch (rResult.meType)
+ {
+ case svx::ClassificationType::CATEGORY:
+ case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
+ case svx::ClassificationType::MARKING:
+ case svx::ClassificationType::TEXT:
+ sRepresentation += rResult.msName;
+ break;
+
+ case svx::ClassificationType::PARAGRAPH:
+ sRepresentation += " ";
+ break;
+ }
+ }
+ return sRepresentation;
+}
+
+bool lcl_containsProperty(const uno::Sequence<beans::Property> & rProperties, const OUString& rName)
+{
+ return std::find_if(rProperties.begin(), rProperties.end(), [&](const beans::Property& rProperty)
+ {
+ return rProperty.Name == rName;
+ }) != rProperties.end();
+}
+
+bool addOrInsertDocumentProperty(uno::Reference<beans::XPropertyContainer> const & rxPropertyContainer, OUString const & rsKey, OUString const & rsValue)
+{
+ uno::Reference<beans::XPropertySet> xPropertySet(rxPropertyContainer, uno::UNO_QUERY);
+
+ try
+ {
+ if (lcl_containsProperty(xPropertySet->getPropertySetInfo()->getProperties(), rsKey))
+ xPropertySet->setPropertyValue(rsKey, uno::makeAny(rsValue));
+ else
+ rxPropertyContainer->addProperty(rsKey, beans::PropertyAttribute::REMOVABLE, uno::makeAny(rsValue));
+ }
+ catch (const uno::Exception& /*rException*/)
+ {
+ return false;
+ }
+ return true;
+}
+
+void insertFullTextualRepresentationAsDocumentProperty(uno::Reference<beans::XPropertyContainer> const & rxPropertyContainer,
+ sfx::ClassificationKeyCreator const & rKeyCreator,
+ std::vector<svx::ClassificationResult> const & rResults)
+{
+ OUString sString = svx::classification::convertClassificationResultToString(rResults);
+ addOrInsertDocumentProperty(rxPropertyContainer, rKeyCreator.makeFullTextualRepresentationKey(), sString);
+}
+
+}} // end svx::classification namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */