[Libreoffice-commits] core.git: Branch 'feature/cib_contract3756' - include/sfx2 offapi/com sc/source sd/sdi sd/source sfx2/source sw/sdi sw/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 23 17:35:53 UTC 2019


 include/sfx2/sfxsids.hrc                         |    1 
 include/sfx2/viewsh.hxx                          |    1 
 offapi/com/sun/star/document/MediaDescriptor.idl |    8 +++++++
 offapi/com/sun/star/frame/XModel2.idl            |    2 -
 sc/source/ui/docshell/docsh4.cxx                 |    2 -
 sc/source/ui/drawfunc/chartsh.cxx                |    3 ++
 sc/source/ui/drawfunc/graphsh.cxx                |    6 +++++
 sd/sdi/_drvwsh.sdi                               |    1 
 sd/source/ui/view/drviews7.cxx                   |    3 ++
 sd/source/ui/view/drviewsj.cxx                   |    5 ++++
 sfx2/source/appl/appuno.cxx                      |   14 +++++++++++++
 sfx2/source/doc/objserv.cxx                      |   16 ++++++++++++---
 sfx2/source/doc/sfxbasemodel.cxx                 |    5 ++++
 sfx2/source/view/viewsh.cxx                      |   24 +++++++++++++++++++++--
 sw/sdi/wrtapp.sdi                                |    1 
 sw/source/uibase/app/apphdl.cxx                  |    7 ++++++
 sw/source/uibase/app/docsh.cxx                   |    6 ++---
 sw/source/uibase/shells/grfsh.cxx                |    2 -
 18 files changed, 96 insertions(+), 11 deletions(-)

New commits:
commit e447a34ddaba0bf6b88b608c7510404ce93b3b3d
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Oct 22 11:32:09 2019 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Wed Oct 23 19:34:31 2019 +0200

    Add document-level option to lock down file export
    
    Setting this option will disable any export command
    (File->Export*, File->Send*, graphic/chart export context menu,
    save as, mailmerge wizard, ...)
    
    Change-Id: I07a2a3b9179b494ac839e7d1e407194600679aa1
    Reviewed-on: https://gerrit.libreoffice.org/81316
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    (cherry picked from commit ec0a3db0cbb5413d10e70c9843e679bbf2327c15)
    Reviewed-on: https://gerrit.libreoffice.org/81389
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 6124255f2756..0b5eeb73a32b 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -259,6 +259,7 @@ class SvxSearchItem;
 #define SID_NO_FILE_SYNC                    (SID_SFX_START + 1729)
 #define SID_NO_THUMBNAIL                    (SID_SFX_START + 1730)
 #define SID_LOCK_CONTENT_EXTRACTION         (SID_SFX_START + 1731)
+#define SID_LOCK_EXPORT                     (SID_SFX_START + 1732)
 // Used to export a temporary file for preview in Mail Merge Wizard, where saving the data source is
 // not required for preview, but interferes with not-yet-saved embedded data source for main document.
 #define SID_NO_EMBEDDED_DS                  TypedWhichId<SfxBoolItem>(SID_SFX_START + 1731)
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index fff76219ea3b..525cc111d216 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -289,6 +289,7 @@ public:
     void                        AddRemoveClipboardListener( const css::uno::Reference < css::datatransfer::clipboard::XClipboardListener>&, bool );
     css::uno::Reference< css::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier() const;
     bool isContentExtractionLocked();
+    bool isExportLocked();
 
     SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const;
     SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const css::uno::Reference < css::ui::XContextMenuInterceptor >& xInterceptor );
diff --git a/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl
index 0a4ba28f611b..f7c248d85803 100644
--- a/offapi/com/sun/star/document/MediaDescriptor.idl
+++ b/offapi/com/sun/star/document/MediaDescriptor.idl
@@ -568,6 +568,14 @@ service MediaDescriptor
         @since LibreOffice 6.4
      */
     [optional,property] boolean LockContentExtraction;
+
+    /** Setting this option will prevent exporting document content to any file.
+        Export, Send, save as, etc will be disabled,
+        as well as individual graphic/chart export and mail merge.
+
+        @since LibreOffice 6.4
+     */
+    [optional,property] boolean LockExport;
 };
 
 
diff --git a/offapi/com/sun/star/frame/XModel2.idl b/offapi/com/sun/star/frame/XModel2.idl
index 0a5944e0e6f0..6e6e90666ec0 100644
--- a/offapi/com/sun/star/frame/XModel2.idl
+++ b/offapi/com/sun/star/frame/XModel2.idl
@@ -142,9 +142,9 @@ interface XModel2 : com::sun::star::frame::XModel
             <ul>
                 <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsDir</li>
                 <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsName</li>
-                <li>com::sun::star::document::MediaDescriptor::LockContentExtraction</li>
                 <li>com::sun::star::document::MediaDescriptor::EncryptionData</li>
                 <li>com::sun::star::document::MediaDescriptor::LockContentExtraction</li>
+                <li>com::sun::star::document::MediaDescriptor::LockExport</li>
             </ul>
 
         @throws com::sun::star::lang::IllegalArgumentException When trying to set an unsupported property
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 40d694e6df8a..54acb863a18d 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1977,7 +1977,7 @@ void ScDocShell::GetState( SfxItemSet &rSet )
 
             case SID_SHARE_DOC:
                 {
-                    if ( IsReadOnly() )
+                    if ( IsReadOnly() || GetBestViewShell()->isExportLocked() )
                     {
                         rSet.DisableItem( nWhich );
                     }
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index 0e9bfe3521f1..b70ce15e57c2 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -73,6 +73,9 @@ void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
             bEnable = true;
     }
 
+    if (GetViewShell()->isExportLocked())
+        bEnable = false;
+
     if( !bEnable )
         rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
 }
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index 8fcbc8a586bd..c3c5dd4b5f5c 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -145,6 +145,9 @@ void ScGraphicShell::GetExternalEditState( SfxItemSet& rSet )
             bEnable = true;
     }
 
+    if (GetViewShell()->isExportLocked())
+        bEnable = false;
+
     if( !bEnable )
         rSet.DisableItem( SID_EXTERNAL_EDIT );
 }
@@ -304,6 +307,9 @@ void ScGraphicShell::GetSaveGraphicState(SfxItemSet &rSet)
             bEnable = true;
     }
 
+    if (GetViewShell()->isExportLocked())
+        bEnable = false;
+
     if( !bEnable )
         rSet.DisableItem( SID_SAVE_GRAPHIC );
 }
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index b49088f395c0..6a30f87e9b59 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -2785,6 +2785,7 @@ interface DrawView
     SID_PRESENTATION_MINIMIZER
     [
         ExecMethod = FuTemporary ;
+        StateMethod = GetMenuState ;
     ]
     SID_GO_TO_NEXT_PAGE
     [
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index e405a987fc84..7372d2327ff0 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1596,6 +1596,9 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
             rSet.DisableItem(SID_SAVE_BACKGROUND);
     }
 
+    if (GetViewShell()->isExportLocked())
+        rSet.DisableItem(SID_PRESENTATION_MINIMIZER);
+
     GetModeSwitchingMenuState (rSet);
 }
 
diff --git a/sd/source/ui/view/drviewsj.cxx b/sd/source/ui/view/drviewsj.cxx
index 80882a93394e..ee65cb87fa94 100644
--- a/sd/source/ui/view/drviewsj.cxx
+++ b/sd/source/ui/view/drviewsj.cxx
@@ -508,6 +508,11 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
         rSet.DisableItem(SID_COPY);
         rSet.DisableItem(SID_CUT);
     }
+    if(GetViewShell()->isExportLocked())
+    {
+        rSet.DisableItem(SID_SAVE_GRAPHIC);
+        rSet.DisableItem(SID_EXTERNAL_EDIT);
+    }
 }
 
 } // end of namespace sd
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 069d1b1fe47c..a868a4ff5337 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -170,6 +170,7 @@ static char const sDocumentService[] = "DocumentService";
 static char const sFilterProvider[] = "FilterProvider";
 static char const sImageFilter[] = "ImageFilter";
 static char const sLockContentExtraction[] = "LockContentExtraction";
+static char const sLockExport[] = "LockExport";
 
 static bool isMediaDescriptor( sal_uInt16 nSlotId )
 {
@@ -854,6 +855,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
                 if (bOK)
                     rSet.Put( SfxBoolItem( SID_LOCK_CONTENT_EXTRACTION, bVal ) );
             }
+            else if (aName == sLockExport)
+            {
+                bool bVal = false;
+                bool bOK = (rProp.Value >>= bVal);
+                DBG_ASSERT( bOK, "invalid type for LockExport" );
+                if (bOK)
+                    rSet.Put( SfxBoolItem( SID_LOCK_EXPORT, bVal ) );
+            }
 #ifdef DBG_UTIL
             else
                 --nFoundArgs;
@@ -1627,6 +1636,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
             pValue[nActProp].Name = sLockContentExtraction;
             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
         }
+        if ( rSet.GetItemState( SID_LOCK_EXPORT, false, &pItem ) == SfxItemState::SET )
+        {
+            pValue[nActProp].Name = sLockExport;
+            pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
+        }
     }
 
     rArgs = aSequ;
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index bff9327367b7..75f4f0a0f695 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1129,7 +1129,8 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
         {
             case SID_DOCTEMPLATE :
             {
-                if ( !GetFactory().GetTemplateFilter() )
+                SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+                if ( pFrame && pFrame->GetViewShell()->isExportLocked())
                     rSet.DisableItem( nWhich );
                 break;
             }
@@ -1232,7 +1233,9 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
 
             case SID_SAVEASDOC:
             {
-                if( !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) )
+                SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+                if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT)
+                    || (pFrame && pFrame->GetViewShell()->isExportLocked()))
                 {
                     rSet.DisableItem( nWhich );
                     break;
@@ -1246,7 +1249,9 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
 
             case SID_SAVEACOPY:
             {
-                if( !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) )
+                SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+                if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT)
+                    || (pFrame && pFrame->GetViewShell()->isExportLocked()))
                 {
                     rSet.DisableItem( nWhich );
                     break;
@@ -1258,13 +1263,18 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
                 break;
             }
 
+            case SID_EXPORTDOC:
             case SID_EXPORTDOCASPDF:
             case SID_DIRECTEXPORTDOCASPDF:
             case SID_EXPORTDOCASEPUB:
             case SID_DIRECTEXPORTDOCASEPUB:
             case SID_REDACTDOC:
             case SID_AUTOREDACTDOC:
+            case SID_SAVEASREMOTE:
             {
+                SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+                if (pFrame && pFrame->GetViewShell()->isExportLocked())
+                    rSet.DisableItem( nWhich );
                 break;
             }
 
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 4516eba7d4c3..b858ac6707e8 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1088,6 +1088,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
             rArg.Value >>= bValue;
             pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_CONTENT_EXTRACTION, bValue));
         }
+        else if (rArg.Name == "LockExport")
+        {
+            rArg.Value >>= bValue;
+            pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_EXPORT, bValue));
+        }
         else
         {
             throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name,
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 4866fcabc4bc..e8638badac64 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -673,16 +673,27 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
     {
         switch ( nSID )
         {
-#if HAVE_FEATURE_MACOSX_SANDBOX
+
             case SID_BLUETOOTH_SENDDOC:
             case SID_MAIL_SENDDOC:
             case SID_MAIL_SENDDOCASFORMAT:
             case SID_MAIL_SENDDOCASMS:
             case SID_MAIL_SENDDOCASOOO:
             case SID_MAIL_SENDDOCASPDF:
+            {
+#if HAVE_FEATURE_MACOSX_SANDBOX
                 rSet.DisableItem(nSID);
-                break;
 #endif
+                if (isExportLocked())
+                    rSet.DisableItem(nSID);
+                break;
+            }
+            case SID_WEBHTML:
+            {
+                if (isExportLocked())
+                    rSet.DisableItem(nSID);
+                break;
+            }
             // Printer functions
             case SID_PRINTDOC:
             case SID_PRINTDOCDIRECT:
@@ -1745,6 +1756,15 @@ bool SfxViewShell::isContentExtractionLocked()
     return aArgs.getOrDefault("LockContentExtraction", false);
 }
 
+bool SfxViewShell::isExportLocked()
+{
+    Reference<XModel> xModel = GetCurrentDocument();
+    if (!xModel.is())
+        return false;
+    comphelper::NamedValueCollection aArgs(xModel->getArgs());
+    return aArgs.getOrDefault("LockExport", false);
+}
+
 Reference < XController > SfxViewShell::GetController() const
 {
     return pImpl->m_pController.get();
diff --git a/sw/sdi/wrtapp.sdi b/sw/sdi/wrtapp.sdi
index e3680a229843..138c22fb4ecb 100644
--- a/sw/sdi/wrtapp.sdi
+++ b/sw/sdi/wrtapp.sdi
@@ -60,6 +60,7 @@ interface StarWriter
     FN_MAILMERGE_WIZARD
     [
         ExecMethod = ExecOther ;
+        StateMethod = StateOther ;
     ]
 
     FN_MAILMERGE_FIRST_ENTRY
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index bc5bbf8020bb..a2a2ff35b455 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -155,6 +155,13 @@ void SwModule::StateOther(SfxItemSet &rSet)
                 rSet.Put( SfxBoolItem( nWhich, m_pModuleConfig->
                                             IsInsTableFormatNum( bWebView )));
             break;
+            case FN_MAILMERGE_WIZARD:
+            {
+                SwView* pView = ::GetActiveView();
+                if (pView && pView->GetViewShell()->isExportLocked())
+                    rSet.DisableItem(nWhich);
+                break;
+            }
             case FN_MAILMERGE_FIRST_ENTRY:
             case FN_MAILMERGE_PREV_ENTRY:
             case FN_MAILMERGE_NEXT_ENTRY:
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index a373ec9e3a71..3ad2d9fa5b33 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1062,7 +1062,7 @@ void SwDocShell::GetState(SfxItemSet& rSet)
         case FN_OUTLINE_TO_IMPRESS:
             {
                 SvtModuleOptions aMOpt;
-                if ( !aMOpt.IsImpress() )
+                if ( !aMOpt.IsImpress() || GetViewShell()->isExportLocked() )
                     rSet.DisableItem( nWhich );
             }
             [[fallthrough]];
@@ -1084,12 +1084,12 @@ void SwDocShell::GetState(SfxItemSet& rSet)
             break;
 
         case FN_NEW_GLOBAL_DOC:
-            if ( dynamic_cast< const SwGlobalDocShell *>( this ) !=  nullptr )
+            if ( dynamic_cast< const SwGlobalDocShell *>( this ) !=  nullptr || GetViewShell()->isExportLocked() )
                 rSet.DisableItem( nWhich );
             break;
 
         case FN_NEW_HTML_DOC:
-            if( dynamic_cast< const SwWebDocShell *>( this ) !=  nullptr )
+            if( dynamic_cast< const SwWebDocShell *>( this ) !=  nullptr || GetViewShell()->isExportLocked()  )
                 rSet.DisableItem( nWhich );
             break;
 
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index 19c1a6558fc1..9bc4d34fcf1b 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -769,7 +769,7 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet)
 
         case SID_SAVE_GRAPHIC:
         case SID_EXTERNAL_EDIT:
-            if( rSh.GetGraphicType() == GraphicType::NONE )
+            if( rSh.GetGraphicType() == GraphicType::NONE || GetView().isExportLocked())
                 bDisable = true;
             break;
 


More information about the Libreoffice-commits mailing list