[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Mar 11 12:42:51 UTC 2016


 sc/inc/clipoptions.hxx           |   25 +++++++++++++++++++++++++
 sc/inc/document.hxx              |    5 +++++
 sc/source/core/data/documen2.cxx |    1 +
 sc/source/core/data/documen3.cxx |    7 +++++++
 sc/source/ui/view/cliputil.cxx   |   29 ++++++++++++++++++++++++++---
 sc/source/ui/view/viewfun3.cxx   |   12 ++++++++++++
 6 files changed, 76 insertions(+), 3 deletions(-)

New commits:
commit e75979eaed5c417da5f33f7259f070afbaa674b8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 11 13:40:59 2016 +0100

    sc: handle classification during copy&paste
    
    This is the same feature as done for sw and sd internal copy already.
    
    Change-Id: I6b8bd1228510fb2fb65ed1c2ab5e8307c38664b2

diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index bb4fc02..c79d173 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -15,12 +15,34 @@
 #include "dpobject.hxx"
 #include "globstr.hrc"
 #include "clipparam.hxx"
+#include "clipoptions.hxx"
 #include "rangelst.hxx"
 #include "viewutil.hxx"
 #include "markdata.hxx"
 #include <gridwin.hxx>
 
 #include <vcl/waitobj.hxx>
+#include <sfx2/classificationhelper.hxx>
+
+namespace
+{
+
+/// Paste only if SfxClassificationHelper recommends so.
+bool lcl_checkClassification(ScDocument* pSourceDoc, ScDocument* pDestinationDoc)
+{
+    if (!pSourceDoc || !pDestinationDoc)
+        return true;
+
+    ScClipOptions* pSourceOptions = pSourceDoc->GetClipOptions();
+    SfxObjectShell* pDestinationShell = pDestinationDoc->GetDocumentShell();
+    if (!pSourceOptions || !pDestinationShell)
+        return true;
+
+    SfxClassificationCheckPasteResult eResult = SfxClassificationHelper::CheckPaste(pSourceOptions->m_xDocumentProperties, pDestinationShell->getDocProperties());
+    return SfxClassificationHelper::ShowPasteInfo(eResult);
+}
+
+}
 
 void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
 {
@@ -64,9 +86,10 @@ void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTab
                 // For multi-range paste, we paste values by default.
                 nFlags &= ~InsertDeleteFlags::FORMULA;
 
-            pTabViewShell->PasteFromClip( nFlags, pClipDoc,
-                    ScPasteFunc::NONE, false, false, false, INS_NONE, InsertDeleteFlags::NONE,
-                    bShowDialog );      // allow warning dialog
+            if (lcl_checkClassification(pClipDoc, pThisDoc))
+                pTabViewShell->PasteFromClip( nFlags, pClipDoc,
+                        ScPasteFunc::NONE, false, false, false, INS_NONE, InsertDeleteFlags::NONE,
+                        bShowDialog );      // allow warning dialog
         }
     }
     pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
commit 9db5512084bb0df58322d755b7b1770a9779ab57
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 11 11:17:42 2016 +0100

    sc: make metadata available in copy result
    
    Calc had the same problem as Writer: metadata is part of the doc shell,
    but the clipboard document has no doc shell. So need to store this info
    in ScDocument in some way in the clipboard case.
    
    10:45 <@moggi> vmiklos: I would most likely add a ScClipOptions similar to ScDocOptions and only populate it in the clip document
    
    Change-Id: I4ad01faa55cfb6fb58213d67003c8c0f9849800d

diff --git a/sc/inc/clipoptions.hxx b/sc/inc/clipoptions.hxx
new file mode 100644
index 0000000..d4ccb59
--- /dev/null
+++ b/sc/inc/clipoptions.hxx
@@ -0,0 +1,25 @@
+/* -*- 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_SC_INC_CLIPOPTIONS_HXX
+#define INCLUDED_SC_INC_CLIPOPTIONS_HXX
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+/// Stores options which are only relevant for clipboard documents.
+class SC_DLLPUBLIC ScClipOptions
+{
+public:
+    /// Document properties.
+    css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e486b04..7da2b4d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -117,6 +117,7 @@ class ScBroadcastAreaSlotMachine;
 class ScChangeViewSettings;
 class ScChartCollection;
 class ScChartListenerCollection;
+class ScClipOptions;
 class ScConditionalFormat;
 class ScConditionalFormatList;
 class ScDBCollection;
@@ -351,6 +352,7 @@ private:
     ScViewOptions*      pViewOptions;                   // view options
     ScDocOptions*       pDocOptions;                    // document options
     ScExtDocOptions*    pExtDocOptions;                 // for import etc.
+    std::unique_ptr<ScClipOptions> mpClipOptions;       // clipboard options
     ScConsolidateParam* pConsolidateDlgData;
 
     ScRecursionHelper*  pRecursionHelper;               // information for recursive and iterative cell formulas
@@ -506,6 +508,9 @@ public:
     ScExtDocOptions*        GetExtDocOptions()  { return pExtDocOptions; }
     SC_DLLPUBLIC void                   SetExtDocOptions( ScExtDocOptions* pNewOptions );
 
+    ScClipOptions*          GetClipOptions()    { return mpClipOptions.get(); }
+    void                    SetClipOptions(const ScClipOptions& rClipOptions);
+
     SC_DLLPUBLIC void       GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
     void                    SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 3745486..fd8c5cd 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -99,6 +99,7 @@
 #include "interpre.hxx"
 #include <tokenstringcontext.hxx>
 #include "docsh.hxx"
+#include "clipoptions.hxx"
 #include <listenercontext.hxx>
 
 using namespace com::sun::star;
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index aa9fbb7..9f10d88 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -41,6 +41,7 @@
 #include "chartlock.hxx"
 #include "refupdat.hxx"
 #include "docoptio.hxx"
+#include "clipoptions.hxx"
 #include "viewopti.hxx"
 #include "scextopt.hxx"
 #include "brdcst.hxx"
@@ -75,6 +76,7 @@
 #include "globalnames.hxx"
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
+#include <o3tl/make_unique.hxx>
 #include <memory>
 
 using namespace com::sun::star;
@@ -1953,6 +1955,11 @@ void ScDocument::SetExtDocOptions( ScExtDocOptions* pNewOptions )
     pExtDocOptions = pNewOptions;
 }
 
+void ScDocument::SetClipOptions(const ScClipOptions& rClipOptions)
+{
+    mpClipOptions = o3tl::make_unique<ScClipOptions>(rClipOptions);
+}
+
 void ScDocument::DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
                                     SCCOL nEndCol, SCROW nEndRow )
 {
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 24b91a9..77cb01b 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -66,8 +66,10 @@
 #include "undodat.hxx"
 #include "drawview.hxx"
 #include "cliputil.hxx"
+#include "clipoptions.hxx"
 #include <gridwin.hxx>
 #include <memory>
+#include <com/sun/star/util/XCloneable.hpp>
 
 using namespace com::sun::star;
 
@@ -225,6 +227,16 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
                 // and lose the 'if' above
                 aClipParam.setSourceDocID( pDoc->GetDocumentID() );
 
+            if (SfxObjectShell* pObjectShell = pDoc->GetDocumentShell())
+            {
+                // Copy document properties from pObjectShell to pClipDoc (to its clip options, as it has no object shell).
+                uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(pObjectShell->GetModel(), uno::UNO_QUERY);
+                uno::Reference<util::XCloneable> xCloneable(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY);
+                ScClipOptions aOptions;
+                aOptions.m_xDocumentProperties.set(xCloneable->createClone(), uno::UNO_QUERY);
+                pClipDoc->SetClipOptions(aOptions);
+            }
+
             pDoc->CopyToClip( aClipParam, pClipDoc, &rMark, false, false, bIncludeObjects, true, bUseRangeForVBA );
             if ( !bUseRangeForVBA && pDoc && pClipDoc )
             {


More information about the Libreoffice-commits mailing list