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 
37 class ScDocument;
38 class ScColumn;
39 struct ScRefCellValue;
40 
41 namespace sc {
42 
44 
45 const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
46 const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1;
47 
48 const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2;
49 const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
50 const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
51 
52 const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5;
53 const mdds::mtv::element_t element_type_sparkline = mdds::mtv::element_type_user_start + 6;
54 
56 const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_double;
59 
61 
62 typedef mdds::mtv::noncopyable_managed_element_block<element_type_sparkline, sc::SparklineCell> sparkline_block;
63 typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
64 typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
65 typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
66 typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
67 typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
68 typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
69 
71 typedef mdds::mtv::double_element_block numeric_block;
72 typedef mdds::mtv::uint16_element_block uint16_block;
73 
74 } // end sc namespace
75 
78 namespace sc {
79 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
80 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SparklineCell, sc::element_type_sparkline, nullptr, sc::sparkline_block)
81 }
82 
84 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, nullptr, sc::cellnote_block)
85 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, nullptr, sc::broadcaster_block)
86 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, nullptr, sc::formula_block)
87 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, nullptr, sc::edittext_block)
88 
89 namespace svl {
90 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
91 }
92 
93 namespace sc {
94 
96 {
98 public:
100  CellStoreEvent(ScColumn* pCol);
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 
120 typedef mdds::mtv::custom_block_func1<sc::sparkline_block> CSparklineFunction;
121 typedef mdds::mtv::soa::multi_type_vector<CSparklineFunction> SparklineStoreType;
122 
124 typedef mdds::mtv::custom_block_func1<sc::cellnote_block> CNoteFunc;
125 typedef mdds::mtv::soa::multi_type_vector<CNoteFunc> CellNoteStoreType;
126 
128 typedef mdds::mtv::custom_block_func1<sc::broadcaster_block> BCBlkFunc;
129 typedef mdds::mtv::soa::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
130 
132 typedef mdds::mtv::custom_block_func1<sc::celltextattr_block> CTAttrFunc;
133 typedef mdds::mtv::soa::multi_type_vector<CTAttrFunc> CellTextAttrStoreType;
134 
136 typedef mdds::mtv::custom_block_func3<sc::string_block, sc::edittext_block, sc::formula_block> CellFunc;
137 typedef 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 
150  ColumnBlockPosition(): miCellPos() {}
151 };
152 
154 {
155  CellNoteStoreType::const_iterator miCellNotePos;
156  SparklineStoreType::const_iterator miSparklinePos;
157  CellTextAttrStoreType::const_iterator miCellTextAttrPos;
158  CellStoreType::const_iterator miCellPos;
159 
160  ColumnBlockConstPosition(): miCellPos() {}
161 };
162 
164 {
165  typedef std::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType;
166  typedef std::unordered_map<SCTAB, ColumnsType> TablesType;
167 
169  TablesType maTables;
170  std::mutex maMtxTables;
171 
172 public:
174 
176 
177  void clear();
178 };
179 
184 {
185  struct Impl;
186  std::unique_ptr<Impl> mpImpl;
187 
188 public:
192 
194  void invalidate(); // discards cached positions
195 };
196 
197 ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
198 
199 }
200 
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CellTextAttrStoreType::const_iterator miCellTextAttrPos
mdds::mtv::soa::multi_type_vector< CNoteFunc > CellNoteStoreType
CellStoreType::const_iterator miCellPos
ColumnBlockPosition * getBlockPosition(SCCOL nCol)
mdds::mtv::custom_block_func1< sc::celltextattr_block > CTAttrFunc
Cell text attribute container.
CellTextAttrStoreType::iterator miCellTextAttrPos
const mdds::mtv::element_t element_type_celltextattr
Definition: mtvelements.hxx:46
SparklineStoreType::const_iterator miSparklinePos
void stop()
Stop processing events.
Definition: mtvelements.cxx:54
mdds::mtv::noncopyable_managed_element_block< element_type_cellnote, ScPostIt > cellnote_block
Definition: mtvelements.hxx:63
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:66
Store position data for column array storage.
ColumnBlockPositionSet(ScDocument &rDoc)
Definition: mtvelements.cxx:69
mdds::mtv::noncopyable_managed_element_block< element_type_sparkline, sc::SparklineCell > sparkline_block
Custom element blocks.
Definition: mtvelements.hxx:62
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
mdds::mtv::soa::multi_type_vector< BCBlkFunc > BroadcasterStoreType
void element_block_acquired(const mdds::mtv::base_element_block *block)
Definition: mtvelements.cxx:24
mdds::mtv::custom_block_func1< sc::sparkline_block > CSparklineFunction
Sparkline container.
const mdds::mtv::element_t element_type_cellnote
Definition: mtvelements.hxx:52
mdds::mtv::soa::multi_type_vector< CSparklineFunction > SparklineStoreType
BroadcasterStoreType::iterator miBroadcasterPos
const mdds::mtv::element_t element_type_formula
Definition: mtvelements.hxx:50
Additional class containing cell annotation data.
Definition: postit.hxx:160
mdds::mtv::noncopyable_managed_element_block< element_type_edittext, EditTextObject > edittext_block
Definition: mtvelements.hxx:67
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
Definition: mtvelements.cxx:71
mdds::mtv::uint16_element_block uint16_block
Definition: mtvelements.hxx:72
Set of column block positions only for one table.
mdds::mtv::default_element_block< element_type_celltextattr, CellTextAttr > celltextattr_block
Definition: mtvelements.hxx:65
mdds::mtv::noncopyable_managed_element_block< element_type_formula, ScFormulaCell > formula_block
Definition: mtvelements.hxx:68
mdds::mtv::custom_block_func3< sc::string_block, sc::edittext_block, sc::formula_block > CellFunc
Cell container.
mdds::mtv::double_element_block numeric_block
Mapped standard element blocks (for convenience).
Definition: mtvelements.hxx:71
sal_Int16 SCCOL
Definition: types.hxx:21
CAUTION! The following defines must be in the same namespace as the respective type.
const mdds::mtv::element_t element_type_empty
Definition: mtvelements.hxx:57
SparklineStoreType::iterator miSparklinePos
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
Definition: mtvelements.hxx:56
void swap(CellStoreEvent &other)
Definition: mtvelements.cxx:59
std::unordered_map< SCTAB, ColumnsType > TablesType
const ScColumn * getColumn() const
Definition: mtvelements.cxx:64
CellStoreType::iterator miCellPos
mdds::mtv::soa::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
const mdds::mtv::element_t element_type_uint16
Definition: mtvelements.hxx:58
TableColumnBlockPositionSet(ScDocument &rDoc, SCTAB nTab)
mdds::mtv::custom_block_func1< sc::cellnote_block > CNoteFunc
Cell note container.
const mdds::mtv::element_t element_type_sparkline
Definition: mtvelements.hxx:53
mdds::mtv::soa::multi_type_vector< CellFunc, CellStoreTrait > CellStoreType
std::unordered_map< SCCOL, ColumnBlockPosition > ColumnsType
const mdds::mtv::element_t element_type_edittext
Definition: mtvelements.hxx:49
const mdds::mtv::element_t element_type_broadcaster
Custom element type IDs for multi_type_vector.
Definition: mtvelements.hxx:45
CellNoteStoreType::iterator miCellNotePos
mdds::mtv::noncopyable_managed_element_block< element_type_broadcaster, SvtBroadcaster > broadcaster_block
Definition: mtvelements.hxx:64
These need to be in global namespace just like their respective types are.
ScRefCellValue toRefCell(const sc::CellStoreType::const_iterator &itPos, size_t nOffset)
CellNoteStoreType::const_iterator miCellNotePos
const mdds::mtv::element_t element_type_string
Definition: mtvelements.hxx:48
mdds::mtv::custom_block_func1< sc::broadcaster_block > BCBlkFunc
Broadcaster storage container.
static constexpr mdds::mtv::lu_factor_t loop_unrolling
sal_Int16 SCTAB
Definition: types.hxx:22
void element_block_released(const mdds::mtv::base_element_block *block)
Definition: mtvelements.cxx:39
std::unique_ptr< Impl > mpImpl