LibreOffice Module sc (master) 1
mtvelements.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#pragma once
11
12#include "formulacell.hxx"
13#include <svl/broadcast.hxx>
14#include <svl/sharedstring.hxx>
15#include <editeng/editobj.hxx>
16#include "calcmacros.hxx"
17#include "postit.hxx"
18#include "SparklineCell.hxx"
19#include "celltextattr.hxx"
20
21#if DEBUG_COLUMN_STORAGE
22#ifdef NDEBUG
23#undef NDEBUG
24#endif
25#define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
26#endif
27
28#include <mdds/multi_type_vector/macro.hpp>
29#include <mdds/multi_type_vector/soa/main.hpp>
30#include <mdds/multi_type_vector/block_funcs.hpp>
31
32#include <unordered_map>
33#include <memory>
34#include <mutex>
35
36class ScDocument;
37class ScColumn;
38struct ScRefCellValue;
39
40namespace sc {
41
43
44const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
45const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1;
46
47const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2;
48const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
49const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
50
51const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5;
52const mdds::mtv::element_t element_type_sparkline = mdds::mtv::element_type_user_start + 6;
53
55const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_double;
58
60
61typedef mdds::mtv::noncopyable_managed_element_block<element_type_sparkline, sc::SparklineCell> sparkline_block;
62typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
63typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
64typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
65typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
66typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
67typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
68
70typedef mdds::mtv::double_element_block numeric_block;
71typedef mdds::mtv::uint16_element_block uint16_block;
72
73} // end sc namespace
74
77namespace sc {
78MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
79MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SparklineCell, sc::element_type_sparkline, nullptr, sc::sparkline_block)
80}
81
83MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, nullptr, sc::cellnote_block)
84MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, nullptr, sc::broadcaster_block)
85MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, nullptr, sc::formula_block)
86MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, nullptr, sc::edittext_block)
87
88namespace svl {
89MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
90}
91
92namespace sc {
93
95{
97public:
100
101 void element_block_acquired(const mdds::mtv::base_element_block* block);
102 void element_block_released(const mdds::mtv::base_element_block* block);
103
105 void stop();
106
107 void swap(CellStoreEvent& other);
108
109 const ScColumn* getColumn() const;
110};
111
112struct SparklineTraits : public mdds::mtv::default_traits
113{
114 using block_funcs = mdds::mtv::element_block_funcs<sc::sparkline_block>;
115};
116
117struct CellNodeTraits : public mdds::mtv::default_traits
118{
119 using block_funcs = mdds::mtv::element_block_funcs<sc::cellnote_block>;
120};
121
122struct BroadcasterTraits : public mdds::mtv::default_traits
123{
124 using block_funcs = mdds::mtv::element_block_funcs<sc::broadcaster_block>;
125};
126
127struct CellTextAttrTraits : public mdds::mtv::default_traits
128{
129 using block_funcs = mdds::mtv::element_block_funcs<sc::celltextattr_block>;
130};
131
132struct CellStoreTraits : public mdds::mtv::default_traits
133{
135 using block_funcs = mdds::mtv::element_block_funcs<
137};
138
140typedef mdds::mtv::soa::multi_type_vector<SparklineTraits> SparklineStoreType;
141
143typedef mdds::mtv::soa::multi_type_vector<CellNodeTraits> CellNoteStoreType;
144
146typedef mdds::mtv::soa::multi_type_vector<BroadcasterTraits> BroadcasterStoreType;
147
149typedef mdds::mtv::soa::multi_type_vector<CellTextAttrTraits> CellTextAttrStoreType;
150
152typedef mdds::mtv::soa::multi_type_vector<CellStoreTraits> CellStoreType;
153
158{
159 CellNoteStoreType::iterator miCellNotePos;
160 SparklineStoreType::iterator miSparklinePos;
161 BroadcasterStoreType::iterator miBroadcasterPos;
162 CellTextAttrStoreType::iterator miCellTextAttrPos;
163 CellStoreType::iterator miCellPos;
164
166};
167
169{
170 CellNoteStoreType::const_iterator miCellNotePos;
171 SparklineStoreType::const_iterator miSparklinePos;
172 CellTextAttrStoreType::const_iterator miCellTextAttrPos;
173 CellStoreType::const_iterator miCellPos;
174
176};
177
179{
180 typedef std::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType;
181 typedef std::unordered_map<SCTAB, ColumnsType> TablesType;
182
185 std::mutex maMtxTables;
186
187public:
189
191
192 void clear();
193};
194
199{
200 struct Impl;
201 std::unique_ptr<Impl> mpImpl;
202
203public:
207
209 void invalidate(); // discards cached positions
210};
211
212ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
213
214}
215
216/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Additional class containing cell annotation data.
Definition: postit.hxx:58
const ScColumn * getColumn() const
Definition: mtvelements.cxx:64
void element_block_released(const mdds::mtv::base_element_block *block)
Definition: mtvelements.cxx:39
void swap(CellStoreEvent &other)
Definition: mtvelements.cxx:59
void stop()
Stop processing events.
Definition: mtvelements.cxx:54
void element_block_acquired(const mdds::mtv::base_element_block *block)
Definition: mtvelements.cxx:24
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
Definition: mtvelements.cxx:71
std::unordered_map< SCCOL, ColumnBlockPosition > ColumnsType
std::unordered_map< SCTAB, ColumnsType > TablesType
ColumnBlockPositionSet(ScDocument &rDoc)
Definition: mtvelements.cxx:69
Set of column block positions only for one table.
ColumnBlockPosition * getBlockPosition(SCCOL nCol)
std::unique_ptr< Impl > mpImpl
TableColumnBlockPositionSet(ScDocument &rDoc, SCTAB nTab)
CAUTION! The following defines must be in the same namespace as the respective type.
mdds::mtv::uint16_element_block uint16_block
Definition: mtvelements.hxx:71
const mdds::mtv::element_t element_type_celltextattr
Definition: mtvelements.hxx:45
const mdds::mtv::element_t element_type_edittext
Definition: mtvelements.hxx:48
mdds::mtv::double_element_block numeric_block
Mapped standard element blocks (for convenience).
Definition: mtvelements.hxx:70
mdds::mtv::soa::multi_type_vector< CellNodeTraits > CellNoteStoreType
Cell note container.
mdds::mtv::soa::multi_type_vector< SparklineTraits > SparklineStoreType
Sparkline container.
mdds::mtv::noncopyable_managed_element_block< element_type_formula, ScFormulaCell > formula_block
Definition: mtvelements.hxx:67
const mdds::mtv::element_t element_type_formula
Definition: mtvelements.hxx:49
const mdds::mtv::element_t element_type_uint16
Definition: mtvelements.hxx:57
mdds::mtv::soa::multi_type_vector< CellStoreTraits > CellStoreType
Cell container.
ScRefCellValue toRefCell(const sc::CellStoreType::const_iterator &itPos, size_t nOffset)
mdds::mtv::default_element_block< element_type_celltextattr, CellTextAttr > celltextattr_block
Definition: mtvelements.hxx:64
mdds::mtv::noncopyable_managed_element_block< element_type_broadcaster, SvtBroadcaster > broadcaster_block
Definition: mtvelements.hxx:63
const mdds::mtv::element_t element_type_sparkline
Definition: mtvelements.hxx:52
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
Definition: mtvelements.hxx:55
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:65
mdds::mtv::noncopyable_managed_element_block< element_type_edittext, EditTextObject > edittext_block
Definition: mtvelements.hxx:66
mdds::mtv::noncopyable_managed_element_block< element_type_cellnote, ScPostIt > cellnote_block
Definition: mtvelements.hxx:62
mdds::mtv::soa::multi_type_vector< CellTextAttrTraits > CellTextAttrStoreType
Cell text attribute container.
mdds::mtv::soa::multi_type_vector< BroadcasterTraits > BroadcasterStoreType
Broadcaster storage container.
const mdds::mtv::element_t element_type_string
Definition: mtvelements.hxx:47
mdds::mtv::noncopyable_managed_element_block< element_type_sparkline, sc::SparklineCell > sparkline_block
Custom element blocks.
Definition: mtvelements.hxx:61
const mdds::mtv::element_t element_type_cellnote
Definition: mtvelements.hxx:51
const mdds::mtv::element_t element_type_empty
Definition: mtvelements.hxx:56
const mdds::mtv::element_t element_type_broadcaster
Custom element type IDs for multi_type_vector.
Definition: mtvelements.hxx:44
These need to be in global namespace just like their respective types are.
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
mdds::mtv::element_block_funcs< sc::broadcaster_block > block_funcs
mdds::mtv::element_block_funcs< sc::cellnote_block > block_funcs
mdds::mtv::element_block_funcs< numeric_block, sc::string_block, sc::edittext_block, sc::formula_block > block_funcs
mdds::mtv::element_block_funcs< sc::celltextattr_block > block_funcs
SparklineStoreType::const_iterator miSparklinePos
CellNoteStoreType::const_iterator miCellNotePos
CellTextAttrStoreType::const_iterator miCellTextAttrPos
CellStoreType::const_iterator miCellPos
Store position data for column array storage.
SparklineStoreType::iterator miSparklinePos
CellTextAttrStoreType::iterator miCellTextAttrPos
BroadcasterStoreType::iterator miBroadcasterPos
CellStoreType::iterator miCellPos
CellNoteStoreType::iterator miCellNotePos
mdds::mtv::element_block_funcs< sc::sparkline_block > block_funcs
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21