Bump version to 4.3-4
[LibreOffice.git] / sc / inc / mtvelements.hxx
blobb09f70dc5dbb4a633a0aa3b3e3e1f34f6be7e125
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_SC_INC_MTVELEMENTS_HXX
11 #define INCLUDED_SC_INC_MTVELEMENTS_HXX
13 #include "address.hxx"
14 #include "formulacell.hxx"
15 #include <svl/broadcast.hxx>
16 #include <svl/sharedstring.hxx>
17 #include <editeng/editobj.hxx>
18 #include "calcmacros.hxx"
19 #include "postit.hxx"
20 #include <osl/mutex.hxx>
22 #if DEBUG_COLUMN_STORAGE
23 #ifdef NDEBUG
24 #undef NDEBUG
25 #endif
26 #define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
27 #endif
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>
34 #include <boost/unordered_map.hpp>
36 class ScDocument;
37 struct ScRefCellValue;
39 namespace sc {
41 struct CellTextAttr
43 sal_uInt16 mnTextWidth;
44 sal_uInt8 mnScriptType;
46 CellTextAttr();
47 CellTextAttr(const CellTextAttr& r);
50 /// Custom element type IDs for multi_type_vector.
52 const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
53 const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1;
55 const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2;
56 const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
57 const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
59 const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5;
61 /// Mapped standard element types (for convenience).
62 const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_numeric;
63 const mdds::mtv::element_t element_type_empty = mdds::mtv::element_type_empty;
65 /// Custom element blocks.
67 typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
68 typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
69 typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
70 typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
71 typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
72 typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
74 /// Mapped standard element blocks (for convenience).
75 typedef mdds::mtv::numeric_element_block numeric_block;
77 /// This needs to be in the same namespace as CellTextAttr.
78 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
81 /// These need to be in global namespace just like their respective types are.
82 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, NULL, sc::cellnote_block)
83 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, NULL, sc::broadcaster_block)
84 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, NULL, sc::formula_block)
85 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, NULL, sc::edittext_block)
87 namespace svl {
89 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
93 namespace sc {
95 /// Cell note container
96 typedef mdds::mtv::custom_block_func1<sc::cellnote_block> CNoteFunc;
97 typedef mdds::multi_type_vector<CNoteFunc> CellNoteStoreType;
99 /// Broadcaster storage container
100 typedef mdds::mtv::custom_block_func1<sc::broadcaster_block> BCBlkFunc;
101 typedef mdds::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
103 /// Cell text attribute container.
104 typedef mdds::mtv::custom_block_func1<sc::celltextattr_block> CTAttrFunc;
105 typedef mdds::multi_type_vector<CTAttrFunc> CellTextAttrStoreType;
107 /// Cell container
108 typedef mdds::mtv::custom_block_func3<sc::string_block, sc::edittext_block, sc::formula_block> CellFunc;
109 typedef mdds::multi_type_vector<CellFunc> CellStoreType;
112 * Store position data for column array storage.
114 struct ColumnBlockPosition
116 CellNoteStoreType::iterator miCellNotePos;
117 BroadcasterStoreType::iterator miBroadcasterPos;
118 CellTextAttrStoreType::iterator miCellTextAttrPos;
119 CellStoreType::iterator miCellPos;
121 ColumnBlockPosition(): miCellPos() {}
124 struct ColumnBlockConstPosition
126 CellNoteStoreType::const_iterator miCellNotePos;
127 BroadcasterStoreType::const_iterator miBroadcasterPos;
128 CellTextAttrStoreType::const_iterator miCellTextAttrPos;
129 CellStoreType::const_iterator miCellPos;
131 ColumnBlockConstPosition(): miCellPos() {}
134 class ColumnBlockPositionSet
136 typedef boost::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType;
137 typedef boost::unordered_map<SCTAB, ColumnsType> TablesType;
139 ScDocument& mrDoc;
140 TablesType maTables;
141 osl::Mutex maMtxTables;
143 public:
144 ColumnBlockPositionSet(ScDocument& rDoc);
146 ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
148 void clear();
151 ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
155 #endif
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */