summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-09-16 19:50:19 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-10-02 21:32:24 -0400
commitdd617c0bbe4906e8d6e589289f42415738f00006 (patch)
tree86bb5f56e14cd30a947366ff504c2389b2a8ef47 /sc/inc
parent8030c21def37f965a35b534038659fd0b513887c (diff)
New feature to allow converting formula cells to static values.
You used to have to convert formula cells to static values by copying them and pasting them as values onto the original place. Why not just allow converting them in place? This is something I've always wanted to implement.
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/cellvalues.hxx60
-rw-r--r--sc/inc/column.hxx7
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/formulacell.hxx1
-rw-r--r--sc/inc/globstr.hrc3
-rw-r--r--sc/inc/sc.hrc5
-rw-r--r--sc/inc/table.hxx8
7 files changed, 86 insertions, 3 deletions
diff --git a/sc/inc/cellvalues.hxx b/sc/inc/cellvalues.hxx
index 4f4c50fab4fd..b545fcdd9115 100644
--- a/sc/inc/cellvalues.hxx
+++ b/sc/inc/cellvalues.hxx
@@ -11,13 +11,29 @@
#define INCLUDED_SC_INC_CELLVALUES_HXX
#include "address.hxx"
+#include <global.hxx>
class ScColumn;
+namespace svl {
+
+class SharedString;
+
+}
+
namespace sc {
struct CellValuesImpl;
+struct CellValueSpan
+{
+ SCROW mnRow1;
+ SCROW mnRow2;
+ CellType meType;
+
+ CellValueSpan( SCROW nRow1, SCROW nRow2, CellType eType );
+};
+
/**
* Think of this as a mini-ScColumn like storage that only stores cell
* values in a column.
@@ -45,16 +61,60 @@ public:
void transferTo( ScColumn& rCol, SCROW nRow );
void copyTo( ScColumn& rCol, SCROW nRow ) const;
+ void swapNonEmpty( ScColumn& rCol );
void assign( const std::vector<double>& rVals );
size_t size() const;
+ void reset( size_t nSize );
+ void setValue( size_t nRow, double fVal );
+ void setValue( size_t nRow, const svl::SharedString& rStr );
+
+ void swap( CellValues& r );
+
+ std::vector<CellValueSpan> getNonEmptySpans() const;
+
private:
void copyCellsTo( ScColumn& rCol, SCROW nRow ) const;
void copyCellTextAttrsTo( ScColumn& rCol, SCROW nRow ) const;
};
+/**
+ * Stores cell values for multiple tables.
+ */
+class TableValues
+{
+ struct Impl;
+
+ Impl* mpImpl;
+
+ TableValues( const TableValues& ); // disabled
+ TableValues& operator= ( const TableValues& ); // disabled
+
+public:
+
+ TableValues();
+ TableValues( const ScRange& rRange );
+ ~TableValues();
+
+ const ScRange& getRange() const;
+
+ /**
+ * Swap the entire column.
+ */
+ void swap( SCTAB nTab, SCCOL nCol, CellValues& rColValue );
+
+ /**
+ * Swap non-empty blocks with the column storage.
+ */
+ void swapNonEmpty( SCTAB nTab, SCCOL nCol, ScColumn& rCol );
+
+ std::vector<CellValueSpan> getNonEmptySpans( SCTAB nTab, SCCOL nCol ) const;
+
+ void swap( TableValues& rOther );
+};
+
}
#endif
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 893ef1391e68..c694513ad491 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -60,6 +60,7 @@ class EditTextIterator;
struct NoteEntry;
class DocumentStreamAccess;
class CellValues;
+class TableValues;
struct RowSpan;
class RowHeightContext;
class CompileFormulaContext;
@@ -153,6 +154,7 @@ friend class sc::SingleColumnSpanSet;
friend class sc::ColumnSpanSet;
friend class sc::EditTextIterator;
friend class sc::CellValues;
+friend class sc::TableValues;
ScColumn(const ScColumn&); // disabled
ScColumn& operator= (const ScColumn&); // disabled
@@ -601,6 +603,11 @@ public:
void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest );
void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc );
+ void ConvertFormulaToValue(
+ sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo );
+
+ void SwapNonEmpty(
+ sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
#if DEBUG_COLUMN_STORAGE
void DumpFormulaGroups() const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 1d14b9f0382b..41fcffbd5f27 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -75,6 +75,7 @@ struct FormulaGroupContext;
class DocumentStreamAccess;
class DocumentLinkManager;
class CellValues;
+class TableValues;
class RowHeightContext;
struct SetFormulaDirtyContext;
class RefMovedHint;
@@ -2110,6 +2111,10 @@ public:
void SetCalcConfig( const ScCalcConfig& rConfig );
const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
+ void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
+
+ void SwapNonEmpty( sc::TableValues& rValues );
+
private:
/**
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index b765ff07b63f..475bea34c9a2 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -300,6 +300,7 @@ public:
sal_uInt16 GetRawError(); // don't interpret, just return code or result error
bool GetErrorOrValue( sal_uInt16& rErr, double& rVal );
sc::FormulaResultValue GetResult();
+ sc::FormulaResultValue GetResult() const;
sal_uInt8 GetMatrixFlag() const { return cMatrixFlag;}
ScTokenArray* GetCode() { return pCode;}
const ScTokenArray* GetCode() const { return pCode;}
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 0b2a6606b2d7..eab98cc892bc 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -693,8 +693,9 @@
#define STR_PRINT_PREVIEW_EMPTY_RANGE 530
#define STR_UNDO_CONDFORMAT 531
+#define STR_UNDO_FORMULA_TO_VALUE 532
-#define SC_GLOBSTR_STR_COUNT 532 /**< the count of permanently resident strings */
+#define SC_GLOBSTR_STR_COUNT 533 /**< the count of permanently resident strings */
#endif
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 420d1492497a..2d7d228762e9 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -275,8 +275,9 @@
// functions
-#define SID_OPEN_CALC (SC_FUNCTION_START + 4)
-#define FILE_MENU_END (SC_FUNCTION_START + 20)
+#define SID_OPEN_CALC (SC_FUNCTION_START + 4)
+#define SID_CONVERT_FORMULA_TO_VALUE (SC_FUNCTION_START + 5)
+#define FILE_MENU_END (SC_FUNCTION_START + 20)
#define EDIT_MENU_START (FILE_MENU_END)
#define FID_DELETE_CELL (EDIT_MENU_START + 2)
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index fb5d6f9dcada..e0c6e2170b52 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -69,6 +69,7 @@ struct RefUpdateMoveTabContext;
struct NoteEntry;
class DocumentStreamAccess;
class CellValues;
+class TableValues;
class RowHeightContext;
class CompileFormulaContext;
struct SetFormulaDirtyContext;
@@ -934,6 +935,13 @@ public:
void TransferCellValuesTo( SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
void CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
+ void ConvertFormulaToValue(
+ sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+ sc::TableValues* pUndo );
+
+ void SwapNonEmpty(
+ sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
+
#if DEBUG_COLUMN_STORAGE
void DumpFormulaGroups( SCCOL nCol ) const;
#endif