summaryrefslogtreecommitdiff
path: root/sc/inc/cellvalues.hxx
blob: b545fcdd91155ca87115952333e1ea9b3908dae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* -*- 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_CELLVALUES_HXX
#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.
 */
class CellValues
{
    CellValuesImpl* mpImpl;

    CellValues( const CellValues& ); // disabled
    CellValues& operator= ( const CellValues& ); // disabled

public:
    CellValues();
    ~CellValues();

    /**
     * Transfer values from specified column.  The transferred segment in the
     * source column becomes empty after this call.
     *
     * @param rCol source column to transfer values from.
     * @param nRow top row position in the source column.
     * @param nLen length of the segment to transfer.
     */
    void transferFrom( ScColumn& rCol, SCROW nRow, size_t nLen );

    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

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */