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 "celltextattr.hxx"
19 
20 #if DEBUG_COLUMN_STORAGE
21 #ifdef NDEBUG
22 #undef NDEBUG
23 #endif
24 #define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
25 #endif
26 
27 #include <mdds/multi_type_vector_macro.hpp>
28 #include <mdds/multi_type_vector.hpp>
29 #include <mdds/multi_type_vector_custom_func1.hpp>
30 #include <mdds/multi_type_vector_custom_func3.hpp>
31 
32 #include <unordered_map>
33 #include <memory>
34 #include <mutex>
35 
36 class ScDocument;
37 class ScColumn;
38 struct ScRefCellValue;
39 
40 namespace sc {
41 
43 
44 const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
45 const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1;
46 
47 const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2;
48 const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
49 const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
50 
51 const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5;
52 
54 const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_double;
57 
59 
60 typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
61 typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
62 typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
63 typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
64 typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
65 typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
66 
68 typedef mdds::mtv::double_element_block numeric_block;
69 typedef mdds::mtv::uint16_element_block uint16_block;
70 
72 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
73 }
74 
76 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, nullptr, sc::cellnote_block)
77 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, nullptr, sc::broadcaster_block)
78 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, nullptr, sc::formula_block)
79 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, nullptr, sc::edittext_block)
80 
81 namespace svl {
82 
83 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
84 
85 }
86 
87 namespace sc {
88 
90 {
92 public:
94  CellStoreEvent(ScColumn* pCol);
95 
96  void element_block_acquired(const mdds::mtv::base_element_block* block);
97  void element_block_released(const mdds::mtv::base_element_block* block);
98 };
99 
101 typedef mdds::mtv::custom_block_func1<sc::cellnote_block> CNoteFunc;
102 typedef mdds::multi_type_vector<CNoteFunc> CellNoteStoreType;
103 
105 typedef mdds::mtv::custom_block_func1<sc::broadcaster_block> BCBlkFunc;
106 typedef mdds::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
107 
109 typedef mdds::mtv::custom_block_func1<sc::celltextattr_block> CTAttrFunc;
110 typedef mdds::multi_type_vector<CTAttrFunc> CellTextAttrStoreType;
111 
113 typedef mdds::mtv::custom_block_func3<sc::string_block, sc::edittext_block, sc::formula_block> CellFunc;
114 typedef mdds::multi_type_vector<CellFunc, CellStoreEvent> CellStoreType;
115 
120 {
121  CellNoteStoreType::iterator miCellNotePos;
122  BroadcasterStoreType::iterator miBroadcasterPos;
123  CellTextAttrStoreType::iterator miCellTextAttrPos;
124  CellStoreType::iterator miCellPos;
125 
126  ColumnBlockPosition(): miCellPos() {}
127 };
128 
130 {
131  CellNoteStoreType::const_iterator miCellNotePos;
132  CellTextAttrStoreType::const_iterator miCellTextAttrPos;
133  CellStoreType::const_iterator miCellPos;
134 
135  ColumnBlockConstPosition(): miCellPos() {}
136 };
137 
139 {
140  typedef std::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType;
141  typedef std::unordered_map<SCTAB, ColumnsType> TablesType;
142 
144  TablesType maTables;
145  std::mutex maMtxTables;
146 
147 public:
149 
151 
152  void clear();
153 };
154 
159 {
160  struct Impl;
161  std::unique_ptr<Impl> mpImpl;
162 
163 public:
167 
169  void invalidate(); // discards cached positions
170 };
171 
172 ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
173 
174 }
175 
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CellTextAttrStoreType::const_iterator miCellTextAttrPos
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:45
mdds::mtv::noncopyable_managed_element_block< element_type_cellnote, ScPostIt > cellnote_block
Custom element blocks.
Definition: mtvelements.hxx:60
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:63
Store position data for column array storage.
ColumnBlockPositionSet(ScDocument &rDoc)
Definition: mtvelements.cxx:54
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
mdds::multi_type_vector< CellFunc, CellStoreEvent > CellStoreType
void element_block_acquired(const mdds::mtv::base_element_block *block)
Definition: mtvelements.cxx:24
const mdds::mtv::element_t element_type_cellnote
Definition: mtvelements.hxx:51
BroadcasterStoreType::iterator miBroadcasterPos
const mdds::mtv::element_t element_type_formula
Definition: mtvelements.hxx:49
mdds::multi_type_vector< BCBlkFunc > BroadcasterStoreType
Additional class containing cell annotation data.
Definition: postit.hxx:161
mdds::mtv::noncopyable_managed_element_block< element_type_edittext, EditTextObject > edittext_block
Definition: mtvelements.hxx:64
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
Definition: mtvelements.cxx:56
mdds::mtv::uint16_element_block uint16_block
Definition: mtvelements.hxx:69
Set of column block positions only for one table.
mdds::multi_type_vector< CNoteFunc > CellNoteStoreType
mdds::mtv::default_element_block< element_type_celltextattr, CellTextAttr > celltextattr_block
Definition: mtvelements.hxx:62
mdds::mtv::noncopyable_managed_element_block< element_type_formula, ScFormulaCell > formula_block
Definition: mtvelements.hxx:65
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:68
sal_Int16 SCCOL
Definition: types.hxx:21
const mdds::mtv::element_t element_type_empty
Definition: mtvelements.hxx:55
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
Definition: mtvelements.hxx:54
std::unordered_map< SCTAB, ColumnsType > TablesType
CellStoreType::iterator miCellPos
const mdds::mtv::element_t element_type_uint16
Definition: mtvelements.hxx:56
TableColumnBlockPositionSet(ScDocument &rDoc, SCTAB nTab)
mdds::mtv::custom_block_func1< sc::cellnote_block > CNoteFunc
Cell note container.
std::unordered_map< SCCOL, ColumnBlockPosition > ColumnsType
const mdds::mtv::element_t element_type_edittext
Definition: mtvelements.hxx:48
const mdds::mtv::element_t element_type_broadcaster
Custom element type IDs for multi_type_vector.
Definition: mtvelements.hxx:44
CellNoteStoreType::iterator miCellNotePos
mdds::mtv::noncopyable_managed_element_block< element_type_broadcaster, SvtBroadcaster > broadcaster_block
Definition: mtvelements.hxx:61
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:47
mdds::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
mdds::mtv::custom_block_func1< sc::broadcaster_block > BCBlkFunc
Broadcaster storage container.
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