summaryrefslogtreecommitdiffstats
path: root/sc/inc
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2016-02-06 03:12:20 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-02-10 23:08:04 +0000
commitbc20c6d0f397c0c1aef6ef7d6f750c2f81af8db6 (patch)
tree72d84f3356709b4e4413bf28e40f83b3565a2608 /sc/inc
parentupdate emoji autocorrect files from po-files (diff)
downloadcore-bc20c6d0f397c0c1aef6ef7d6f750c2f81af8db6.tar.gz
core-bc20c6d0f397c0c1aef6ef7d6f750c2f81af8db6.zip
Refactor ScMarkData for tdf#50916
Made the container for storing multimarks dynamic. Also let the full row marks to be stored in a dedicated ScMarkArray object rather than in the multimarks container. Unit tests for ScMarkData and ScMultiSel will come in a follow up patch. Change-Id: I300ff80bebd6f4f39c284c1e8cb7deece82c1bec Reviewed-on: https://gerrit.libreoffice.org/22163 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/markarr.hxx1
-rw-r--r--sc/inc/markdata.hxx9
-rw-r--r--sc/inc/markmulti.hxx84
-rw-r--r--sc/inc/segmenttree.hxx2
4 files changed, 92 insertions, 4 deletions
diff --git a/sc/inc/markarr.hxx b/sc/inc/markarr.hxx
index 2988fe4b74cb..386b97adaa8a 100644
--- a/sc/inc/markarr.hxx
+++ b/sc/inc/markarr.hxx
@@ -41,6 +41,7 @@ friend class ScDocument; // for FillInfo
public:
ScMarkArray();
+ ScMarkArray( ScMarkArray&& rArray );
~ScMarkArray();
void Reset( bool bMarked = false );
bool GetMark( SCROW nRow ) const;
diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 6e3eafc3aee8..0392971f0a1c 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -22,6 +22,7 @@
#include "address.hxx"
#include "rangelst.hxx"
+#include "markmulti.hxx"
#include "scdllapi.h"
#include <set>
@@ -50,7 +51,7 @@ private:
ScRange aMarkRange; // area
ScRange aMultiRange; // maximum area altogether
- ScMarkArray* pMultiSel; // multi selection
+ ScMultiSel aMultiSel; // multi selection
bool bMarked:1; // rectangle marked
bool bMultiMarked:1;
@@ -72,7 +73,8 @@ public:
void ResetMark();
void SetMarkArea( const ScRange& rRange );
- void SetMultiMarkArea( const ScRange& rRange, bool bMark = true );
+ // bSetupMulti must be set to true only for recursive calls to SetMultiMarkArea
+ void SetMultiMarkArea( const ScRange& rRange, bool bMark = true, bool bSetupMulti = false );
void MarkToMulti();
void MarkToSimple();
@@ -102,7 +104,8 @@ public:
bool GetMarkingFlag() const { return bMarking; }
// for FillInfo / Document etc.
- const ScMarkArray* GetArray() const { return pMultiSel; }
+ const ScMultiSel& GetMultiSelData() const { return aMultiSel; }
+ ScMarkArray GetMarkArray( SCCOL nCol ) const;
bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const;
void FillRangeListWithMarks( ScRangeList* pList, bool bClear ) const;
diff --git a/sc/inc/markmulti.hxx b/sc/inc/markmulti.hxx
new file mode 100644
index 000000000000..22f0ee5d1dad
--- /dev/null
+++ b/sc/inc/markmulti.hxx
@@ -0,0 +1,84 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SC_INC_MARKMULTI_HXX
+#define INCLUDED_SC_INC_MARKMULTI_HXX
+
+#include "address.hxx"
+#include "segmenttree.hxx"
+#include "markarr.hxx"
+
+#include <map>
+
+class ScMultiSel
+{
+
+private:
+ typedef std::map<SCCOL, ScMarkArray> MapType;
+ MapType aMultiSelContainer;
+ ScMarkArray aRowSel;
+
+friend class ScMultiSelIter;
+
+public:
+ ScMultiSel();
+ ScMultiSel( const ScMultiSel& rMultiSel );
+ ~ScMultiSel();
+
+ ScMultiSel& operator=(const ScMultiSel& rMultiSel);
+ ScMultiSel& operator=(const ScMultiSel&& rMultiSel) = delete;
+
+ SCCOL size() const
+ {
+ return static_cast<SCCOL>( aMultiSelContainer.size() );
+ }
+
+ bool HasMarks( SCCOL nCol ) const;
+ bool HasOneMark( SCCOL nCol, SCROW& rStartRow, SCROW& rEndRow ) const;
+ bool GetMark( SCCOL nCol, SCROW nRow ) const;
+ bool IsAllMarked( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
+ bool HasEqualRowsMarked( SCCOL nCol1, SCCOL nCol2 ) const;
+ SCsROW GetNextMarked( SCCOL nCol, SCsROW nRow, bool bUp ) const;
+ void SetMarkArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow, bool bMark );
+ bool IsRowMarked( SCROW nRow ) const;
+ bool IsRowRangeMarked( SCROW nStartRow, SCROW nEndRow ) const;
+ bool IsEmpty() const { return ( !aMultiSelContainer.size() && !aRowSel.HasMarks() ); }
+ ScMarkArray GetMarkArray( SCCOL nCol ) const;
+ void Clear();
+ void MarkAllCols( SCROW nStartRow, SCROW nEndRow );
+ bool HasAnyMarks() const;
+};
+
+class ScMultiSelIter
+{
+
+private:
+ ScFlatBoolRowSegments aRowSegs;
+ SCROW nNextSegmentStart;
+public:
+ ScMultiSelIter( const ScMultiSel& rMultiSel, SCCOL nCol );
+ ~ScMultiSelIter();
+
+ bool Next( SCROW& rTop, SCROW& rBottom );
+ const ScFlatBoolRowSegments& GetRowSegments() const { return aRowSegs; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/segmenttree.hxx b/sc/inc/segmenttree.hxx
index 72d45b63afb6..3a2d1283b002 100644
--- a/sc/inc/segmenttree.hxx
+++ b/sc/inc/segmenttree.hxx
@@ -68,7 +68,7 @@ public:
bool setTrue(SCROW nRow1, SCROW nRow2);
bool setFalse(SCROW nRow1, SCROW nRow2);
- bool getRangeData(SCROW nRow, RangeData& rData);
+ bool getRangeData(SCROW nRow, RangeData& rData) const;
bool getRangeDataLeaf(SCROW nRow, RangeData& rData);
void removeSegment(SCROW nRow1, SCROW nRow2);
void insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary);