[Libreoffice-commits] core.git: 3 commits - include/sfx2 sfx2/Library_sfx.mk sfx2/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Feb 17 09:05:32 UTC 2016
include/sfx2/classificationhelper.hxx | 39 +++++++++++++
include/sfx2/sfx.hrc | 1
sfx2/Library_sfx.mk | 1
sfx2/source/view/classificationhelper.cxx | 87 ++++++++++++++++++++++++++++++
sfx2/source/view/view.src | 5 +
sfx2/source/view/viewfrm.cxx | 15 +++++
6 files changed, 148 insertions(+)
New commits:
commit 291a10ec557a765a4d3090330964fd1cb7a82f6b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Feb 17 09:15:50 2016 +0100
sfx2 classification infobar: improve message
Change-Id: If8fe5b145014055639a9a2eadd8fded7ebf7c2b3
diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc
index 582ad1e..a0d1ae3 100644
--- a/include/sfx2/sfx.hrc
+++ b/include/sfx2/sfx.hrc
@@ -153,6 +153,7 @@
#define STR_READONLY_DOCUMENT (RID_SFX_START+128)
#define STR_PASSWD_MIN_LEN1 (RID_SFX_START+129)
#define STR_MODULENOTINSTALLED (RID_SFX_START+130)
+#define STR_CLASSIFIED_DOCUMENT (RID_SFX_START+131)
#define STR_ACCTITLE_PRODUCTIVITYTOOLS (RID_SFX_START+157)
#define SFX_THUMBNAIL_TEXT (RID_SFX_START+158)
diff --git a/sfx2/source/view/view.src b/sfx2/source/view/view.src
index 1cb6c13..26dbbbd 100644
--- a/sfx2/source/view/view.src
+++ b/sfx2/source/view/view.src
@@ -91,6 +91,11 @@ String STR_READONLY_DOCUMENT
Text [ en-US ] = "This document is open in read-only mode." ;
};
+String STR_CLASSIFIED_DOCUMENT
+{
+ Text [ en-US ] = "The classification label of this document is %1." ;
+};
+
PushButton BT_CHECKOUT
{
Pos = MAP_APPFONT( 0 , 0 );
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 55b525d..0585085 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1351,7 +1351,11 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
OUString aBACName = aHelper.GetBACName();
OUString aImpactLevel = aHelper.GetImpactLevel();
if (!aBACName.isEmpty() && !aImpactLevel.isEmpty())
- AppendInfoBar("classification", aBACName);
+ {
+ OUString aMessage = SfxResId(STR_CLASSIFIED_DOCUMENT);
+ aMessage = aMessage.replaceFirst("%1", aBACName);
+ AppendInfoBar("classification", aMessage);
+ }
}
break;
commit 823e8d658759ba5ea3c63b20dbe9ffd79f2f5c23
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Feb 17 09:14:06 2016 +0100
sfx2: add initial classification infobar
Change-Id: Idd4b886e246cb41d3a3b871eeb368c0620b110ae
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 5eb776a..55b525d 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -21,6 +21,7 @@
#include <osl/file.hxx>
#include <sfx2/infobar.hxx>
#include <sfx2/viewfrm.hxx>
+#include <sfx2/classificationhelper.hxx>
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/DispatchRecorder.hpp>
@@ -1343,6 +1344,16 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
+ if (SfxClassificationHelper::IsClassified(*xObjSh.get()))
+ {
+ // Document has BAILS properties, display an infobar accordingly.
+ SfxClassificationHelper aHelper(*xObjSh.get());
+ OUString aBACName = aHelper.GetBACName();
+ OUString aImpactLevel = aHelper.GetImpactLevel();
+ if (!aBACName.isEmpty() && !aImpactLevel.isEmpty())
+ AppendInfoBar("classification", aBACName);
+ }
+
break;
}
commit 89b928d43a5db1ad3bf761cdb24013c6bcf32e8b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Feb 17 09:13:42 2016 +0100
sfx2: introduce initial SfxClassificationHelper
A document's metadata has predefinied keys like title, and has
user-defined ones as well. The BAILS specification at
<http://www.tscp.org/wp-content/uploads/2013/08/TSCP_BAILSv1.pdf>
describes a mechanism to use the generic user-defined key-value pairs to
embed classification-related (read: is it public? is it internal only?
etc) information in a standard way.
One approach in handling these in LO would be to let code here and there
parse these user-defined key-value pairs again and again. An other one
would be to handle these as first-class properties, even if the majority
of the users would never need them. A middle between the above two
approaches is this class: all these properties are still just
user-defined properties, but if the document has them, then all related
code is supposed to be implemented in this central class.
Change-Id: Ib0297a5e91779b330c310a153f1a1628759dd028
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
new file mode 100644
index 0000000..8662742
--- /dev/null
+++ b/include/sfx2/classificationhelper.hxx
@@ -0,0 +1,39 @@
+/* -*- 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_SFX2_CLASSIFICATIONHELPER_HXX
+#define INCLUDED_SFX2_CLASSIFICATIONHELPER_HXX
+
+#include <memory>
+
+#include <rtl/ustring.hxx>
+#include <sfx2/dllapi.h>
+
+class SfxObjectShell;
+
+/// Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties.
+class SFX2_DLLPUBLIC SfxClassificationHelper
+{
+ struct Impl;
+ std::unique_ptr<Impl> m_pImpl;
+
+public:
+ /// Does the document have any BAILS properties?
+ static bool IsClassified(SfxObjectShell& rObjectShell);
+
+ SfxClassificationHelper(SfxObjectShell& rObjectShell);
+ ~SfxClassificationHelper();
+ OUString GetBACName();
+ /// Impact level is a string, as the scale can be integer-based, but can be also low/high.
+ OUString GetImpactLevel();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 2440cdc..418a836 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -290,6 +290,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/styles/StyleManager \
sfx2/source/toolbox/imgmgr \
sfx2/source/toolbox/tbxitem \
+ sfx2/source/view/classificationhelper \
sfx2/source/view/frame \
sfx2/source/view/frame2 \
sfx2/source/view/frmload \
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
new file mode 100644
index 0000000..c4e2245
--- /dev/null
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -0,0 +1,87 @@
+/* -*- 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 <sfx2/classificationhelper.hxx>
+
+#include <map>
+
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+#include <sfx2/objsh.hxx>
+#include <o3tl/make_unique.hxx>
+
+using namespace com::sun::star;
+
+/// Implementation details of SfxClassificationHelper.
+struct SfxClassificationHelper::Impl
+{
+ std::map<OUString, OUString> m_aLabels;
+};
+
+bool SfxClassificationHelper::IsClassified(SfxObjectShell& rObjectShell)
+{
+ uno::Reference<document::XDocumentProperties> xDocumentProperties = rObjectShell.getDocProperties();
+ uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
+ if (!xPropertyContainer.is())
+ return false;
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
+ uno::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties();
+ for (const beans::Property& rProperty : aProperties)
+ {
+ if (rProperty.Name.startsWith("urn:bails:"))
+ return true;
+ }
+
+ return false;
+}
+
+SfxClassificationHelper::SfxClassificationHelper(SfxObjectShell& rObjectShell)
+ : m_pImpl(o3tl::make_unique<Impl>())
+{
+ uno::Reference<document::XDocumentProperties> xDocumentProperties = rObjectShell.getDocProperties();
+ uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
+ if (!xPropertyContainer.is())
+ return;
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
+ uno::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties();
+ for (const beans::Property& rProperty : aProperties)
+ {
+ uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name);
+ OUString aValue;
+ if (aAny >>= aValue)
+ m_pImpl->m_aLabels[rProperty.Name] = aValue;
+ }
+}
+
+SfxClassificationHelper::~SfxClassificationHelper()
+{
+}
+
+OUString SfxClassificationHelper::GetBACName()
+{
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Name");
+ if (it != m_pImpl->m_aLabels.end())
+ return it->second;
+
+ return OUString();
+}
+
+OUString SfxClassificationHelper::GetImpactLevel()
+{
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
+ if (it != m_pImpl->m_aLabels.end())
+ return it->second;
+
+ return OUString();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list