[Libreoffice-commits] core.git: include/sfx2 sc/source sd/source sfx2/sdi sfx2/source sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed May 18 08:52:48 UTC 2016


 include/sfx2/classificationhelper.hxx     |    2 ++
 sc/source/ui/view/formatsh.cxx            |    8 +++++++-
 sd/source/ui/view/drviews2.cxx            |    8 +++++++-
 sfx2/sdi/sfx.sdi                          |    2 +-
 sfx2/source/view/classificationhelper.cxx |   10 ++++++++++
 sw/inc/editsh.hxx                         |    3 ++-
 sw/source/core/edit/edfcol.cxx            |    4 ++--
 sw/source/uibase/app/docsh2.cxx           |    9 ++++++++-
 8 files changed, 39 insertions(+), 7 deletions(-)

New commits:
commit ff42ad90bae398285eb630c34be230a4f0619d68
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed May 18 09:16:30 2016 +0200

    sfx2 classification: add Type parameter to the UNO command
    
    So that sc/sd/sw doesn't have to hardcode
    SfxClassificationPolicyType::IntellectualProperty.
    
    Change-Id: Ib7c2376622ecaa8c7fc8401cec2ba16d12b8b8d2
    Reviewed-on: https://gerrit.libreoffice.org/25078
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index de889fe..6497d08 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -76,6 +76,8 @@ public:
     /// The selected category has some content for the document footer.
     bool HasDocumentFooter();
     void UpdateInfobar(SfxViewFrame& rViewFrame);
+    /// Does a best-effort conversion of rType to SfxClassificationPolicyType.
+    static SfxClassificationPolicyType stringToPolicyType(const OUString& rType);
 
     /// Brief text located at the top of each document's pages.
     static const OUString& PROP_DOCHEADER();
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 4bec4fb..b7af7e0 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -974,7 +974,13 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
         {
             const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue();
             SfxClassificationHelper aHelper(pDocSh->getDocProperties());
-            aHelper.SetBACName(rName, SfxClassificationPolicyType::IntellectualProperty);
+            auto eType = SfxClassificationPolicyType::IntellectualProperty;
+            if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET)
+            {
+                const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue();
+                eType = SfxClassificationHelper::stringToPolicyType(rType);
+            }
+            aHelper.SetBACName(rName, eType);
         }
         else
             SAL_WARN("sc.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index d3bf567..4060695 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1151,12 +1151,18 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             if (pArgs && pArgs->GetItemState(nSId, false, &pItem) == SfxItemState::SET)
             {
                 const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+                auto eType = SfxClassificationPolicyType::IntellectualProperty;
+                if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET)
+                {
+                    const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue();
+                    eType = SfxClassificationHelper::stringToPolicyType(rType);
+                }
                 if (SfxViewFrame* pViewFrame = GetViewFrame())
                 {
                     if (SfxObjectShell* pObjectShell = pViewFrame->GetObjectShell())
                     {
                         SfxClassificationHelper aHelper(pObjectShell->getDocProperties());
-                        aHelper.SetBACName(rName, SfxClassificationPolicyType::IntellectualProperty);
+                        aHelper.SetBACName(rName, eType);
                     }
                 }
             }
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index ee79105..2c80801 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4388,7 +4388,7 @@ SfxBoolItem StyleWatercanMode SID_STYLE_WATERCAN
 ]
 
 SfxVoidItem ClassificationApply SID_CLASSIFICATION_APPLY
-(SfxStringItem Name SID_CLASSIFICATION_APPLY)
+(SfxStringItem Name SID_CLASSIFICATION_APPLY, SfxStringItem Type SID_TYPE_NAME)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index bb6febe..c8d2715 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -745,6 +745,16 @@ void SfxClassificationHelper::UpdateInfobar(SfxViewFrame& rViewFrame)
     }
 }
 
+SfxClassificationPolicyType SfxClassificationHelper::stringToPolicyType(const OUString& rType)
+{
+    if (rType == PROP_PREFIX_EXPORTCONTROL())
+        return SfxClassificationPolicyType::ExportControl;
+    else if (rType == PROP_PREFIX_NATIONALSECURITY())
+        return SfxClassificationPolicyType::NationalSecurity;
+    else
+        return SfxClassificationPolicyType::IntellectualProperty;
+}
+
 const OUString& SfxClassificationHelper::PROP_DOCHEADER()
 {
     static OUString sProp("Marking:document-header");
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index ccc3231..47d472b 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -99,6 +99,7 @@ class SwAuthEntry;
 class SwRewriter;
 struct SwConversionArgs;
 enum class SvtScriptType;
+enum class SfxClassificationPolicyType;
 namespace com { namespace sun { namespace star { namespace uno {
     template < class > class Sequence;
 }}}}
@@ -359,7 +360,7 @@ public:
     SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId )
         { return static_cast<SwCharFormat*>(SwEditShell::GetFormatFromPool( nId )); }
 
-    void SetClassification(const OUString& rName);
+    void SetClassification(const OUString& rName, SfxClassificationPolicyType eType);
 
     void Insert2(SwField&, const bool bForceExpandHints = false);
 
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index ee6d242..0093c40 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -171,7 +171,7 @@ SwTextFormatColl& SwEditShell::GetTextFormatColl( sal_uInt16 nFormatColl) const
     return *((*(GetDoc()->GetTextFormatColls()))[nFormatColl]);
 }
 
-void SwEditShell::SetClassification(const OUString& rName)
+void SwEditShell::SetClassification(const OUString& rName, SfxClassificationPolicyType eType)
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
     if (!pDocShell)
@@ -182,7 +182,7 @@ void SwEditShell::SetClassification(const OUString& rName)
     bool bHadWatermark = !aHelper.GetDocumentWatermark().isEmpty();
 
     // This updates the infobar as well.
-    aHelper.SetBACName(rName, SfxClassificationPolicyType::IntellectualProperty);
+    aHelper.SetBACName(rName, eType);
 
     bool bHeaderIsNeeded = aHelper.HasDocumentHeader();
     bool bFooterIsNeeded = aHelper.HasDocumentFooter();
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 83fca39..17dfe23 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -56,6 +56,7 @@
 #include <editeng/langitem.hxx>
 #include <svx/fmshell.hxx>
 #include <sfx2/linkmgr.hxx>
+#include <sfx2/classificationhelper.hxx>
 
 #include <svtools/htmlcfg.hxx>
 #include <svx/ofaitem.hxx>
@@ -1145,7 +1146,13 @@ void SwDocShell::Execute(SfxRequest& rReq)
             {
                 SwWrtShell* pSh = GetWrtShell();
                 const OUString& rValue = static_cast<const SfxStringItem*>(pItem)->GetValue();
-                pSh->SetClassification(rValue);
+                auto eType = SfxClassificationPolicyType::IntellectualProperty;
+                if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET)
+                {
+                    const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue();
+                    eType = SfxClassificationHelper::stringToPolicyType(rType);
+                }
+                pSh->SetClassification(rValue, eType);
             }
             else
                 SAL_WARN("sw.ui", "missing parameter for SID_CLASSIFICATION_APPLY");


More information about the Libreoffice-commits mailing list