summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-10-08 20:01:58 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-10-08 23:24:52 -0400
commited0e3fdcc13e0925c16aa81f6aa461892f15d81a (patch)
tree1083627576987de7c9fc88cb6cbf254034da50c4
parent281cd4c4a0d4ffb0a99ae8239b11a2ebbb872a8c (diff)
Start sharing common code between DeleteContents of ScViewFunc/ScDocFunc.
The goal is to have ScViewFunc::DeleteContents() simply call ScDocFunc::DeleteContents() while doing the view only stuff in the ScViewFunc variant. This is just a step toward that goal. Change-Id: I2e574f9eb2b2be5340dbfb6f10739dfc2406faae
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/source/ui/docshell/docfunc.cxx15
-rw-r--r--sc/source/ui/docshell/docfuncutil.cxx39
-rw-r--r--sc/source/ui/inc/docfuncutil.hxx21
-rw-r--r--sc/source/ui/view/viewfunc.cxx12
5 files changed, 67 insertions, 21 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 55988a153df5..20460ee5b146 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -404,6 +404,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/docshell/dbdocfun \
sc/source/ui/docshell/dbdocimp \
sc/source/ui/docshell/docfunc \
+ sc/source/ui/docshell/docfuncutil \
sc/source/ui/docshell/docsh \
sc/source/ui/docshell/docsh2 \
sc/source/ui/docshell/docsh3 \
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index f3a6245ca7d4..fedbd20fbc85 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -86,6 +86,7 @@
#include <rowheightcontext.hxx>
#include <cellvalues.hxx>
#include <undoconvert.hxx>
+#include <docfuncutil.hxx>
#include <memory>
#include <utility>
@@ -595,17 +596,8 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, InsertDeleteFlags nFlag
if ( rDoc.ExtendMerge( aExtendedRange, true ) )
bMulti = false;
- // keine Objekte auf geschuetzten Tabellen
- bool bObjects = false;
- if ( nFlags & IDF_OBJECTS )
- {
- bObjects = true;
- SCTAB nTabCount = rDoc.GetTableCount();
- ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
- for (; itr != itrEnd && *itr < nTabCount; ++itr)
- if (rDoc.IsTabProtected(*itr))
- bObjects = false;
- }
+ // no objects on protected tabs
+ bool bObjects = (nFlags & IDF_OBJECTS) && !sc::DocFuncUtil::hasProtectedTab(rDoc, rMark);
sal_uInt16 nExtFlags = 0; // extra flags are needed only if attributes are deleted
if ( nFlags & IDF_ATTRIB )
@@ -674,7 +666,6 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, InsertDeleteFlags nFlag
}
}
-//! HideAllCursors(); // falls Zusammenfassung aufgehoben wird
rDoc.DeleteSelection( nFlags, aMultiMark );
// add undo action after drawing undo is complete (objects and note captions)
diff --git a/sc/source/ui/docshell/docfuncutil.cxx b/sc/source/ui/docshell/docfuncutil.cxx
new file mode 100644
index 000000000000..570ed521f8c5
--- /dev/null
+++ b/sc/source/ui/docshell/docfuncutil.cxx
@@ -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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <docfuncutil.hxx>
+#include <document.hxx>
+#include <markdata.hxx>
+
+namespace sc {
+
+bool DocFuncUtil::hasProtectedTab( const ScDocument& rDoc, const ScMarkData& rMark )
+{
+ SCTAB nTabCount = rDoc.GetTableCount();
+ ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nTabCount; ++itr)
+ if (rDoc.IsTabProtected(*itr))
+ return true;
+
+ return false;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/docfuncutil.hxx b/sc/source/ui/inc/docfuncutil.hxx
new file mode 100644
index 000000000000..20927a05ba88
--- /dev/null
+++ b/sc/source/ui/inc/docfuncutil.hxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+class ScDocument;
+class ScMarkData;
+
+namespace sc {
+
+class DocFuncUtil
+{
+public:
+ static bool hasProtectedTab( const ScDocument& rDoc, const ScMarkData& rMark );
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index c3782e46561f..201b7205fad8 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -76,6 +76,8 @@
#include "cellsuno.hxx"
#include "tokenarray.hxx"
#include <rowheightcontext.hxx>
+#include <docfuncutil.hxx>
+
#include <boost/scoped_ptr.hpp>
static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh )
@@ -1800,15 +1802,7 @@ void ScViewFunc::DeleteContents( InsertDeleteFlags nFlags, bool bRecord )
}
// no objects on protected tabs
- bool bObjects = false;
- if ( nFlags & IDF_OBJECTS )
- {
- bObjects = true;
- ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
- for (; itr != itrEnd; ++itr)
- if (pDoc->IsTabProtected(*itr))
- bObjects = false;
- }
+ bool bObjects = (nFlags & IDF_OBJECTS) && !sc::DocFuncUtil::hasProtectedTab(*pDoc, aFuncMark);
sal_uInt16 nExtFlags = 0; // extra flags are needed only if attributes are deleted
if ( nFlags & IDF_ATTRIB )