[Libreoffice-commits] core.git: include/sfx2 include/svx sd/source svx/Library_svx.mk svx/source sw/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Sat Nov 4 01:50:08 UTC 2017
include/sfx2/classificationhelper.hxx | 5 +
include/svx/ClassificationCommon.hxx | 37 +++++++++++++
sd/source/ui/view/drviews2.cxx | 6 ++
svx/Library_svx.mk | 1
svx/source/dialog/ClassificationCommon.cxx | 79 +++++++++++++++++++++++++++++
sw/source/core/edit/edfcol.cxx | 9 ++-
6 files changed, 134 insertions(+), 3 deletions(-)
New commits:
commit 40918d0321f9e9a958fa80f309213e199cf21bce
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Fri Nov 3 21:57:18 2017 +0900
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 at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 6467976c952b..0ea432ffbe99 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -182,6 +182,11 @@ public:
{
return aKey.startsWith(makeIntellectualPropertyPartKey());
}
+
+ OUString makeFullTextualRepresentationKey() const
+ {
+ return getPolicyKey() + "FullTexturalRepresentation";
+ }
};
}
diff --git a/include/svx/ClassificationCommon.hxx b/include/svx/ClassificationCommon.hxx
new file mode 100644
index 000000000000..04e0494cc7ad
--- /dev/null
+++ b/include/svx/ClassificationCommon.hxx
@@ -0,0 +1,37 @@
+/* -*- 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_SVX_CLASSIFICATIONCOMMON_HXX
+#define INCLUDED_SVX_CLASSIFICATIONCOMMON_HXX
+
+#include <sal/config.h>
+#include <svx/svxdllapi.h>
+#include <svx/ClassificationField.hxx>
+#include <vector>
+#include <sfx2/classificationhelper.hxx>
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+
+namespace svx {
+namespace classification {
+
+SVX_DLLPUBLIC OUString convertClassificationResultToString(std::vector<svx::ClassificationResult> const & rResults);
+
+SVX_DLLPUBLIC bool addOrInsertDocumentProperty(css::uno::Reference<css::beans::XPropertyContainer> const & rxPropertyContainer,
+ OUString const & rsKey, OUString const & rsValue);
+
+SVX_DLLPUBLIC void insertFullTextualRepresentationAsDocumentProperty(css::uno::Reference<css::beans::XPropertyContainer> const & rxPropertyContainer,
+ sfx::ClassificationKeyCreator const & rKeyCreator,
+ std::vector<svx::ClassificationResult> const & rResults);
+
+}} // end svx::classification namespace
+
+#endif // INCLUDED_SVX_CLASSIFICATIONCOMMON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index d01957dcf10c..8a0c20a41889 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -59,6 +59,7 @@
#include <svx/SpellDialogChildWindow.hxx>
#include <svx/compressgraphicdialog.hxx>
#include <svx/ClassificationDialog.hxx>
+#include <svx/ClassificationCommon.hxx>
#include <svx/dialogs.hrc>
#include <svx/bmpmask.hxx>
#include <svx/colrctrl.hxx>
@@ -473,8 +474,13 @@ public:
aHelper.SetBACName(rResult.msName, SfxClassificationHelper::getPolicyType());
}
+ // Initialize key creator
sfx::ClassificationKeyCreator aKeyCreator(SfxClassificationHelper::getPolicyType());
+ // Insert full text as document property
+ svx::classification::insertFullTextualRepresentationAsDocumentProperty(xPropertyContainer, aKeyCreator, rResults);
+
+ // Insert Object into master page
Outliner* pOutliner = m_rDrawViewShell.GetDoc()->GetInternalOutliner();
OutlinerMode eOutlinerMode = pOutliner->GetMode();
pOutliner->Init(OutlinerMode::TextObject);
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: */
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index fe2700004fe5..30abe8ff5801 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -54,6 +54,7 @@
#include <editeng/formatbreakitem.hxx>
#include <editeng/unoprnms.hxx>
#include <sfx2/classificationhelper.hxx>
+#include <svx/ClassificationCommon.hxx>
#include <svl/cryptosign.hxx>
#include <vcl/svapp.hxx>
@@ -85,7 +86,6 @@
#include <UndoParagraphSignature.hxx>
#include <txtatr.hxx>
-#include <officecfg/Office/Common.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#define WATERMARK_NAME "PowerPlusWaterMarkObject"
@@ -681,6 +681,11 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
}
}
+ sfx::ClassificationKeyCreator aCreator(SfxClassificationHelper::getPolicyType());
+
+ // Insert full text as document property
+ svx::classification::insertFullTextualRepresentationAsDocumentProperty(xPropertyContainer, aCreator, rResults);
+
for (const OUString& rPageStyleName : aUsedPageStyles)
{
uno::Reference<beans::XPropertySet> xPageStyle(xStyleFamily->getByName(rPageStyleName), uno::UNO_QUERY);
@@ -706,8 +711,6 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
sal_Int32 nParagraph = -1;
- sfx::ClassificationKeyCreator aCreator(SfxClassificationHelper::getPolicyType());
-
for (svx::ClassificationResult const & rResult : rResults)
{
switch(rResult.meType)
More information about the Libreoffice-commits
mailing list