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 #ifndef INCLUDED_SC_INC_MTVELEMENTS_HXX
11 #define INCLUDED_SC_INC_MTVELEMENTS_HXX
12 
13 #include "formulacell.hxx"
14 #include <svl/broadcast.hxx>
15 #include <svl/sharedstring.hxx>
16 #include <editeng/editobj.hxx>
17 #include "calcmacros.hxx"
18 #include "postit.hxx"
19 #include "celltextattr.hxx"
20 #include <osl/mutex.hxx>
21 
22 #if DEBUG_COLUMN_STORAGE
23 #ifdef NDEBUG
24 #undef NDEBUG
25 #endif
26 #define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
27 #endif
28 
29 #include <mdds/multi_type_vector_macro.hpp>
30 #include <mdds/multi_type_vector.hpp>
31 #include <mdds/multi_type_vector_custom_func1.hpp>
32 #include <mdds/multi_type_vector_custom_func3.hpp>
33 
34 #include <unordered_map>
35 #include <memory>
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 
55 const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_double;
58 
60 
61 typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
62 typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
63 typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
64 typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
65 typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
66 typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
67 
69 typedef mdds::mtv::double_element_block numeric_block;
70 typedef mdds::mtv::uint16_element_block uint16_block;
71 
73 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
74 }
75 
77 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, nullptr, sc::cellnote_block)
78 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, nullptr, sc::broadcaster_block)
79 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, nullptr, sc::formula_block)
80 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, nullptr, sc::edittext_block)
81 
82 namespace svl {
83 
84 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
85 
86 }
87 
88 namespace sc {
89 
91 {
93 public:
95  CellStoreEvent(ScColumn* pCol);
96 
97  void element_block_acquired(const mdds::mtv::base_element_block* block);
98  void element_block_released(const mdds::mtv::base_element_block* block);
99 };
100 
102 typedef mdds::mtv::custom_block_func1<sc::cellnote_block> CNoteFunc;
103 typedef mdds::multi_type_vector<CNoteFunc> CellNoteStoreType;
104 
106 typedef mdds::mtv::custom_block_func1<sc::broadcaster_block> BCBlkFunc;
107 typedef mdds::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
108 
110 typedef mdds::mtv::custom_block_func1<sc::celltextattr_block> CTAttrFunc;
111 typedef mdds::multi_type_vector<CTAttrFunc> CellTextAttrStoreType;
112 
114 typedef mdds::mtv::custom_block_func3<sc::string_block, sc::edittext_block, sc::formula_block> CellFunc;
115 typedef mdds::multi_type_vector<CellFunc, CellStoreEvent> CellStoreType;
116 
121 {
122  CellNoteStoreType::iterator miCellNotePos;
123  BroadcasterStoreType::iterator miBroadcasterPos;
124  CellTextAttrStoreType::iterator miCellTextAttrPos;
125  CellStoreType::iterator miCellPos;
126 
127  ColumnBlockPosition(): miCellPos() {}
128 };
129 
131 {
132  CellNoteStoreType::const_iterator miCellNotePos;
133  CellTextAttrStoreType::const_iterator miCellTextAttrPos;
134  CellStoreType::const_iterator miCellPos;
135 
136  ColumnBlockConstPosition(): miCellPos() {}
137 };
138 
140 {
141  typedef std::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType;
142  typedef std::unordered_map<SCTAB, ColumnsType> TablesType;
143 
145  TablesType maTables;
146  osl::Mutex maMtxTables;
147 
148 public:
150 
152 
153  void clear();
154 };
155 
160 {
161  struct Impl;
162  std::unique_ptr<Impl> mpImpl;
163 
164 public:
168 
170  void invalidate(); // discards cached positions
171 };
172 
173 ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
174 
175 }
176 
177 #endif
178 
179 /* 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:46
mdds::mtv::noncopyable_managed_element_block< element_type_cellnote, ScPostIt > cellnote_block
Custom element blocks.
Definition: mtvelements.hxx:61
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:64
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:104
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:52
BroadcasterStoreType::iterator miBroadcasterPos
const mdds::mtv::element_t element_type_formula
Definition: mtvelements.hxx:50
mdds::multi_type_vector< BCBlkFunc > BroadcasterStoreType
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:65
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
Definition: mtvelements.cxx:56
mdds::mtv::uint16_element_block uint16_block
Definition: mtvelements.hxx:70
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:63
mdds::mtv::noncopyable_managed_element_block< element_type_formula, ScFormulaCell > formula_block
Definition: mtvelements.hxx:66
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:69
sal_Int16 SCCOL
Definition: types.hxx:22
const mdds::mtv::element_t element_type_empty
Definition: mtvelements.hxx:56
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
Definition: mtvelements.hxx:55
std::unordered_map< SCTAB, ColumnsType > TablesType
CellStoreType::iterator miCellPos
const mdds::mtv::element_t element_type_uint16
Definition: mtvelements.hxx:57
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: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:62
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::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
mdds::mtv::custom_block_func1< sc::broadcaster_block > BCBlkFunc
Broadcaster storage container.
sal_Int16 SCTAB
Definition: types.hxx:23
void element_block_released(const mdds::mtv::base_element_block *block)
Definition: mtvelements.cxx:39
std::unique_ptr< Impl > mpImpl