1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef SC_MTVELEMENTS_HXX
11 #define SC_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"
20 #include "osl/mutex.hxx"
22 #if DEBUG_COLUMN_STORAGE
26 #define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
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>
37 struct ScRefCellValue
;
43 sal_uInt16 mnTextWidth
;
44 sal_uInt8 mnScriptType
;
47 CellTextAttr(const CellTextAttr
& r
);
48 CellTextAttr(sal_uInt16 nTextWidth
, sal_uInt8 nScriptType
);
51 /// Custom element type IDs for multi_type_vector.
53 const mdds::mtv::element_t element_type_broadcaster
= mdds::mtv::element_type_user_start
;
54 const mdds::mtv::element_t element_type_celltextattr
= mdds::mtv::element_type_user_start
+ 1;
56 const mdds::mtv::element_t element_type_string
= mdds::mtv::element_type_user_start
+ 2;
57 const mdds::mtv::element_t element_type_edittext
= mdds::mtv::element_type_user_start
+ 3;
58 const mdds::mtv::element_t element_type_formula
= mdds::mtv::element_type_user_start
+ 4;
60 const mdds::mtv::element_t element_type_cellnote
= mdds::mtv::element_type_user_start
+ 5;
62 /// Mapped standard element types (for convenience).
63 const mdds::mtv::element_t element_type_numeric
= mdds::mtv::element_type_numeric
;
64 const mdds::mtv::element_t element_type_empty
= mdds::mtv::element_type_empty
;
66 /// Custom element blocks.
68 typedef mdds::mtv::noncopyable_managed_element_block
<element_type_cellnote
, ScPostIt
> cellnote_block
;
69 typedef mdds::mtv::noncopyable_managed_element_block
<element_type_broadcaster
, SvtBroadcaster
> broadcaster_block
;
70 typedef mdds::mtv::default_element_block
<element_type_celltextattr
, CellTextAttr
> celltextattr_block
;
71 typedef mdds::mtv::default_element_block
<element_type_string
, svl::SharedString
> string_block
;
72 typedef mdds::mtv::noncopyable_managed_element_block
<element_type_edittext
, EditTextObject
> edittext_block
;
73 typedef mdds::mtv::noncopyable_managed_element_block
<element_type_formula
, ScFormulaCell
> formula_block
;
75 /// Mapped standard element blocks (for convenience).
76 typedef mdds::mtv::numeric_element_block numeric_block
;
78 /// This needs to be in the same namespace as CellTextAttr.
79 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr
, element_type_celltextattr
, CellTextAttr(), celltextattr_block
)
82 /// These need to be in global namespace just like their respective types are.
83 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt
, sc::element_type_cellnote
, NULL
, sc::cellnote_block
)
84 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster
, sc::element_type_broadcaster
, NULL
, sc::broadcaster_block
)
85 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell
, sc::element_type_formula
, NULL
, sc::formula_block
)
86 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject
, sc::element_type_edittext
, NULL
, sc::edittext_block
)
90 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString
, sc::element_type_string
, SharedString(), sc::string_block
)
96 /// Cell note container
97 typedef mdds::mtv::custom_block_func1
<sc::cellnote_block
> CNoteFunc
;
98 typedef mdds::multi_type_vector
<CNoteFunc
> CellNoteStoreType
;
100 /// Broadcaster storage container
101 typedef mdds::mtv::custom_block_func1
<sc::broadcaster_block
> BCBlkFunc
;
102 typedef mdds::multi_type_vector
<BCBlkFunc
> BroadcasterStoreType
;
104 /// Cell text attribute container.
105 typedef mdds::mtv::custom_block_func1
<sc::celltextattr_block
> CTAttrFunc
;
106 typedef mdds::multi_type_vector
<CTAttrFunc
> CellTextAttrStoreType
;
109 typedef mdds::mtv::custom_block_func3
<sc::string_block
, sc::edittext_block
, sc::formula_block
> CellFunc
;
110 typedef mdds::multi_type_vector
<CellFunc
> CellStoreType
;
113 * Store position data for column array storage.
115 struct ColumnBlockPosition
117 CellNoteStoreType::iterator miCellNotePos
;
118 BroadcasterStoreType::iterator miBroadcasterPos
;
119 CellTextAttrStoreType::iterator miCellTextAttrPos
;
120 CellStoreType::iterator miCellPos
;
122 ColumnBlockPosition(): miCellPos() {}
125 struct ColumnBlockConstPosition
127 CellNoteStoreType::const_iterator miCellNotePos
;
128 BroadcasterStoreType::const_iterator miBroadcasterPos
;
129 CellTextAttrStoreType::const_iterator miCellTextAttrPos
;
130 CellStoreType::const_iterator miCellPos
;
132 ColumnBlockConstPosition(): miCellPos() {}
135 class ColumnBlockPositionSet
137 typedef boost::unordered_map
<SCCOL
, ColumnBlockPosition
> ColumnsType
;
138 typedef boost::unordered_map
<SCTAB
, ColumnsType
> TablesType
;
142 osl::Mutex maMtxTables
;
145 ColumnBlockPositionSet(ScDocument
& rDoc
);
147 ColumnBlockPosition
* getBlockPosition(SCTAB nTab
, SCCOL nCol
);
152 ScRefCellValue
toRefCell( const sc::CellStoreType::const_iterator
& itPos
, size_t nOffset
);
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */