From 5bd7cc788d0b0f4a2595f32f4897abe6e39ce6c8 Mon Sep 17 00:00:00 2001
From: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Date: Fri, 10 Nov 2017 16:26:56 +0900
Subject: TSCP: Remember the origin and on save, act accordingly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If we created the document classification via pop-up (BAF policy)
then the highest classification needs to apply the classification
from the BAF policy. In other case the classification was set via
the advanced classification dialog, we only need to reset the
document properties.

Change-Id: I0aa0c010e8de3c16920b64a97e5e4dd2e643c2cd
Reviewed-on: https://gerrit.libreoffice.org/44576
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
---
 svx/source/dialog/ClassificationCommon.cxx | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'svx/source/dialog')

diff --git a/svx/source/dialog/ClassificationCommon.cxx b/svx/source/dialog/ClassificationCommon.cxx
index 15734d7adc11..53200046d3e5 100644
--- a/svx/source/dialog/ClassificationCommon.cxx
+++ b/svx/source/dialog/ClassificationCommon.cxx
@@ -105,6 +105,31 @@ void insertFullTextualRepresentationAsDocumentProperty(
     addOrInsertDocumentProperty(rxPropertyContainer, rKeyCreator.makeFullTextualRepresentationKey(),
                                 sString);
 }
+
+void insertCreationOrigin(uno::Reference<beans::XPropertyContainer> const & rxPropertyContainer,
+                          sfx::ClassificationKeyCreator const & rKeyCreator,
+                          sfx::ClassificationCreationOrigin eOrigin)
+{
+    // Nothing to do if origin is "NONE"
+    if (eOrigin == sfx::ClassificationCreationOrigin::NONE)
+        return;
+
+    OUString sValue = (eOrigin == sfx::ClassificationCreationOrigin::BAF_POLICY) ? OUString("BAF_POLICY") : OUString("MANUAL");
+    addOrInsertDocumentProperty(rxPropertyContainer, rKeyCreator.makeCreationOriginKey(), sValue);
+}
+
+sfx::ClassificationCreationOrigin getCreationOriginProperty(uno::Reference<beans::XPropertyContainer> const & rxPropertyContainer,
+                                                            sfx::ClassificationKeyCreator const & rKeyCreator)
+{
+    OUString sValue = getProperty(rxPropertyContainer, rKeyCreator.makeCreationOriginKey());
+    if (sValue.isEmpty())
+        return sfx::ClassificationCreationOrigin::NONE;
+
+    return (sValue == "BAF_POLICY")
+                ? sfx::ClassificationCreationOrigin::BAF_POLICY
+                : sfx::ClassificationCreationOrigin::MANUAL;
+}
+
 }
 } // end svx::classification namespace
 
-- 
cgit