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/custom_func1.hpp>
31#include <mdds/multi_type_vector/custom_func3.hpp>
32
33#include <unordered_map>
34#include <memory>
35#include <mutex>
36
37class ScDocument;
38class ScColumn;
39struct ScRefCellValue;
40
41namespace sc {
42
44
45const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
46const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1;
47
48const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2;
49const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
50const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
51
52const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5;
53const mdds::mtv::element_t element_type_sparkline = mdds::mtv::element_type_user_start + 6;
54
56const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_double;
59
61
62typedef mdds::mtv::noncopyable_managed_element_block<element_type_sparkline, sc::SparklineCell> sparkline_block;
63typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
64typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
65typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
66typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
67typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
68typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
69
71typedef mdds::mtv::double_element_block numeric_block;
72typedef mdds::mtv::uint16_element_block uint16_block;
73
74} // end sc namespace
75
78namespace sc {
79MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
80MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SparklineCell, sc::element_type_sparkline, nullptr, sc::sparkline_block)
81}
82
84MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, nullptr, sc::cellnote_block)
85MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, nullptr, sc::broadcaster_block)
86MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, nullptr, sc::formula_block)
87MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, nullptr, sc::edittext_block)
88
89namespace svl {
90MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
91}
92
93namespace sc {
94
96{
98public:
101
102 void element_block_acquired(const mdds::mtv::base_element_block* block);
103 void element_block_released(const mdds::mtv::base_element_block* block);
104
106 void stop();
107
108 void swap(CellStoreEvent& other);
109
110 const ScColumn* getColumn() const;
111};
112
114{
116 static constexpr mdds::mtv::lu_factor_t loop_unrolling = mdds::mtv::lu_factor_t::lu16;
117};
118
120typedef mdds::mtv::custom_block_func1<sc::sparkline_block> CSparklineFunction;
121typedef mdds::mtv::soa::multi_type_vector<CSparklineFunction> SparklineStoreType;
122
124typedef mdds::mtv::custom_block_func1<sc::cellnote_block> CNoteFunc;
125typedef mdds::mtv::soa::multi_type_vector<CNoteFunc> CellNoteStoreType;
126
128typedef mdds::mtv::custom_block_func1<sc::broadcaster_block> BCBlkFunc;
129typedef mdds::mtv::soa::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
130
132typedef mdds::mtv::custom_block_func1<sc::celltextattr_block> CTAttrFunc;
133typedef mdds::mtv::soa::multi_type_vector<CTAttrFunc> CellTextAttrStoreType;
134
136typedef mdds::mtv::custom_block_func3<sc::string_block, sc::edittext_block, sc::formula_block> CellFunc;
137typedef mdds::mtv::soa::multi_type_vector<CellFunc, CellStoreTrait> CellStoreType;
138
143{
144 CellNoteStoreType::iterator miCellNotePos;
145 SparklineStoreType::iterator miSparklinePos;
146 BroadcasterStoreType::iterator miBroadcasterPos;
147 CellTextAttrStoreType::iterator miCellTextAttrPos;
148 CellStoreType::iterator miCellPos;
149
151};
152
154{
155 CellNoteStoreType::const_iterator miCellNotePos;
156 SparklineStoreType::const_iterator miSparklinePos;
157 CellTextAttrStoreType::const_iterator miCellTextAttrPos;
158 CellStoreType::const_iterator miCellPos;
159
161};
162
164{
165 typedef std::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType;
166 typedef std::unordered_map<SCTAB, ColumnsType> TablesType;
167
170 std::mutex maMtxTables;
171
172public:
174
176
177 void clear();
178};
179
184{
185 struct Impl;
186 std::unique_ptr<Impl> mpImpl;
187
188public:
192
194 void invalidate(); // discards cached positions
195};
196
197ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
198
199}
200
201/* 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:72
mdds::mtv::custom_block_func1< sc::celltextattr_block > CTAttrFunc
Cell text attribute container.
const mdds::mtv::element_t element_type_celltextattr
Definition: mtvelements.hxx:46
const mdds::mtv::element_t element_type_edittext
Definition: mtvelements.hxx:49
mdds::mtv::double_element_block numeric_block
Mapped standard element blocks (for convenience).
Definition: mtvelements.hxx:71
mdds::mtv::noncopyable_managed_element_block< element_type_formula, ScFormulaCell > formula_block
Definition: mtvelements.hxx:68
mdds::mtv::soa::multi_type_vector< CNoteFunc > CellNoteStoreType
const mdds::mtv::element_t element_type_formula
Definition: mtvelements.hxx:50
mdds::mtv::custom_block_func1< sc::cellnote_block > CNoteFunc
Cell note container.
const mdds::mtv::element_t element_type_uint16
Definition: mtvelements.hxx:58
mdds::mtv::custom_block_func1< sc::sparkline_block > CSparklineFunction
Sparkline 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:65
mdds::mtv::soa::multi_type_vector< BCBlkFunc > BroadcasterStoreType
mdds::mtv::soa::multi_type_vector< CellFunc, CellStoreTrait > CellStoreType
mdds::mtv::noncopyable_managed_element_block< element_type_broadcaster, SvtBroadcaster > broadcaster_block
Definition: mtvelements.hxx:64
const mdds::mtv::element_t element_type_sparkline
Definition: mtvelements.hxx:53
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
Definition: mtvelements.hxx:56
mdds::mtv::custom_block_func1< sc::broadcaster_block > BCBlkFunc
Broadcaster storage container.
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:66
mdds::mtv::noncopyable_managed_element_block< element_type_edittext, EditTextObject > edittext_block
Definition: mtvelements.hxx:67
mdds::mtv::noncopyable_managed_element_block< element_type_cellnote, ScPostIt > cellnote_block
Definition: mtvelements.hxx:63
const mdds::mtv::element_t element_type_string
Definition: mtvelements.hxx:48
mdds::mtv::noncopyable_managed_element_block< element_type_sparkline, sc::SparklineCell > sparkline_block
Custom element blocks.
Definition: mtvelements.hxx:62
mdds::mtv::soa::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
mdds::mtv::custom_block_func3< sc::string_block, sc::edittext_block, sc::formula_block > CellFunc
Cell container.
const mdds::mtv::element_t element_type_cellnote
Definition: mtvelements.hxx:52
const mdds::mtv::element_t element_type_empty
Definition: mtvelements.hxx:57
mdds::mtv::soa::multi_type_vector< CSparklineFunction > SparklineStoreType
const mdds::mtv::element_t element_type_broadcaster
Custom element type IDs for multi_type_vector.
Definition: mtvelements.hxx:45
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
static constexpr mdds::mtv::lu_factor_t loop_unrolling
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
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21