Kaydet (Commit) c7bdee8d authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Define block types for string, edit text and formula cell elements.

Also, remove the custom_ prefix from block names.

Change-Id: If3dfdbdacc2d0113fa8d631bec7a914b51668115
üst ac84ffb3
...@@ -21,8 +21,8 @@ class ScColumnTextWidthIterator : boost::noncopyable ...@@ -21,8 +21,8 @@ class ScColumnTextWidthIterator : boost::noncopyable
size_t mnCurPos; size_t mnCurPos;
sc::CellTextAttrStoreType::iterator miBlockCur; sc::CellTextAttrStoreType::iterator miBlockCur;
sc::CellTextAttrStoreType::iterator miBlockEnd; sc::CellTextAttrStoreType::iterator miBlockEnd;
sc::custom_celltextattr_block::iterator miDataCur; sc::celltextattr_block::iterator miDataCur;
sc::custom_celltextattr_block::iterator miDataEnd; sc::celltextattr_block::iterator miDataEnd;
public: public:
ScColumnTextWidthIterator(ScColumn& rCol, SCROW nStartRow, SCROW nEndRow); ScColumnTextWidthIterator(ScColumn& rCol, SCROW nStartRow, SCROW nEndRow);
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#define SC_MTVELEMENTS_HXX #define SC_MTVELEMENTS_HXX
#include "address.hxx" #include "address.hxx"
#include "formulacell.hxx"
#include "svl/broadcast.hxx" #include "svl/broadcast.hxx"
#include "editeng/editobj.hxx"
#define DEBUG_COLUMN_STORAGE 0 #define DEBUG_COLUMN_STORAGE 0
...@@ -25,6 +27,7 @@ ...@@ -25,6 +27,7 @@
#include <mdds/multi_type_vector_macro.hpp> #include <mdds/multi_type_vector_macro.hpp>
#include <mdds/multi_type_vector.hpp> #include <mdds/multi_type_vector.hpp>
#include <mdds/multi_type_vector_custom_func1.hpp> #include <mdds/multi_type_vector_custom_func1.hpp>
#include <mdds/multi_type_vector_custom_func3.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
...@@ -47,29 +50,53 @@ struct CellTextAttr ...@@ -47,29 +50,53 @@ struct CellTextAttr
const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start; const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1; const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1;
const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2;
const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3;
const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4;
const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_numeric;
// Custom element blocks. // Custom element blocks.
typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> custom_broadcaster_block; typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> custom_celltextattr_block; typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
typedef mdds::mtv::default_element_block<element_type_string, rtl::OUString> string_block;
typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
// This needs to be in the same namespace as CellTextAttr. // This needs to be in the same namespace as CellTextAttr.
MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), custom_celltextattr_block) MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block)
} }
// This needs to be in global namespace just like SvtBroacaster is. // These need to be in global namespace just like their respective types are.
MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, NULL, sc::custom_broadcaster_block) MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, NULL, sc::broadcaster_block)
MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, NULL, sc::formula_block)
MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, NULL, sc::edittext_block)
namespace rtl {
MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(OUString, sc::element_type_string, OUString(), sc::string_block)
}
namespace sc { namespace sc {
// Broadcaster storage container // Broadcaster storage container
typedef mdds::mtv::custom_block_func1<sc::element_type_broadcaster, sc::custom_broadcaster_block> BCBlkFunc; typedef mdds::mtv::custom_block_func1<sc::element_type_broadcaster, sc::broadcaster_block> BCBlkFunc;
typedef mdds::multi_type_vector<BCBlkFunc> BroadcasterStoreType; typedef mdds::multi_type_vector<BCBlkFunc> BroadcasterStoreType;
// Cell text attribute container. // Cell text attribute container.
typedef mdds::mtv::custom_block_func1<sc::element_type_celltextattr, sc::custom_celltextattr_block> CTAttrFunc; typedef mdds::mtv::custom_block_func1<sc::element_type_celltextattr, sc::celltextattr_block> CTAttrFunc;
typedef mdds::multi_type_vector<CTAttrFunc> CellTextAttrStoreType; typedef mdds::multi_type_vector<CTAttrFunc> CellTextAttrStoreType;
// Cell container
typedef mdds::mtv::custom_block_func3<
sc::element_type_string, sc::string_block,
sc::element_type_edittext, sc::edittext_block,
sc::element_type_formula, sc::formula_block> CellFunc;
typedef mdds::multi_type_vector<CellFunc> CellStoreType;
/** /**
* Store position data for column array storage. * Store position data for column array storage.
*/ */
......
...@@ -1429,7 +1429,7 @@ void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& r ...@@ -1429,7 +1429,7 @@ void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& r
nRowPos = static_cast<size_t>(nRow2); // End row position. nRowPos = static_cast<size_t>(nRow2); // End row position.
// Keep copying until we hit the end row position. // Keep copying until we hit the end row position.
sc::custom_celltextattr_block::const_iterator itData, itDataEnd; sc::celltextattr_block::const_iterator itData, itDataEnd;
for (; itBlk != itBlkEnd; ++itBlk, nBlockStart = nBlockEnd, nOffsetInBlock = 0) for (; itBlk != itBlkEnd; ++itBlk, nBlockStart = nBlockEnd, nOffsetInBlock = 0)
{ {
nBlockEnd = nBlockStart + itBlk->size; nBlockEnd = nBlockStart + itBlk->size;
...@@ -1446,15 +1446,15 @@ void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& r ...@@ -1446,15 +1446,15 @@ void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& r
} }
// Non-empty block. // Non-empty block.
itData = sc::custom_celltextattr_block::begin(*itBlk->data); itData = sc::celltextattr_block::begin(*itBlk->data);
itDataEnd = sc::custom_celltextattr_block::end(*itBlk->data); itDataEnd = sc::celltextattr_block::end(*itBlk->data);
std::advance(itData, nOffsetInBlock); std::advance(itData, nOffsetInBlock);
if (nBlockStart <= nRowPos && nRowPos < nBlockEnd) if (nBlockStart <= nRowPos && nRowPos < nBlockEnd)
{ {
// This block contains the end row. Only copy partially. // This block contains the end row. Only copy partially.
size_t nOffset = nRowPos - nBlockStart + 1; size_t nOffset = nRowPos - nBlockStart + 1;
itDataEnd = sc::custom_celltextattr_block::begin(*itBlk->data); itDataEnd = sc::celltextattr_block::begin(*itBlk->data);
std::advance(itDataEnd, nOffset); std::advance(itDataEnd, nOffset);
rDestCol.maCellTextAttrs.set(nBlockStart + nOffsetInBlock, itData, itDataEnd); rDestCol.maCellTextAttrs.set(nBlockStart + nOffsetInBlock, itData, itDataEnd);
...@@ -1667,8 +1667,8 @@ sal_uInt8 ScColumn::GetRangeScriptType( ...@@ -1667,8 +1667,8 @@ sal_uInt8 ScColumn::GetRangeScriptType(
if (itPos->type == sc::element_type_celltextattr) if (itPos->type == sc::element_type_celltextattr)
{ {
sc::custom_celltextattr_block::iterator it = sc::custom_celltextattr_block::begin(*itPos->data); sc::celltextattr_block::iterator it = sc::celltextattr_block::begin(*itPos->data);
sc::custom_celltextattr_block::iterator itEnd = sc::custom_celltextattr_block::end(*itPos->data); sc::celltextattr_block::iterator itEnd = sc::celltextattr_block::end(*itPos->data);
std::advance(it, aRet.second); std::advance(it, aRet.second);
for (; it != itEnd; ++it, ++nRow) for (; it != itEnd; ++it, ++nRow)
{ {
...@@ -1699,8 +1699,8 @@ sal_uInt8 ScColumn::GetRangeScriptType( ...@@ -1699,8 +1699,8 @@ sal_uInt8 ScColumn::GetRangeScriptType(
continue; continue;
} }
sc::custom_celltextattr_block::iterator it = sc::custom_celltextattr_block::begin(*itPos->data); sc::celltextattr_block::iterator it = sc::celltextattr_block::begin(*itPos->data);
sc::custom_celltextattr_block::iterator itEnd = sc::custom_celltextattr_block::end(*itPos->data); sc::celltextattr_block::iterator itEnd = sc::celltextattr_block::end(*itPos->data);
for (; it != itEnd; ++it, ++nRow) for (; it != itEnd; ++it, ++nRow)
{ {
if (nRow > nRow2) if (nRow > nRow2)
...@@ -2031,7 +2031,7 @@ void startListening( ...@@ -2031,7 +2031,7 @@ void startListening(
case sc::element_type_broadcaster: case sc::element_type_broadcaster:
{ {
// Broadcaster already exists here. // Broadcaster already exists here.
SvtBroadcaster* pBC = sc::custom_broadcaster_block::at(*itBlockPos->data, nElemPos); SvtBroadcaster* pBC = sc::broadcaster_block::at(*itBlockPos->data, nElemPos);
rLst.StartListening(*pBC); rLst.StartListening(*pBC);
} }
break; break;
...@@ -2124,7 +2124,7 @@ void ScColumn::EndListening( sc::EndListeningContext& rCxt, SCROW nRow, SvtListe ...@@ -2124,7 +2124,7 @@ void ScColumn::EndListening( sc::EndListeningContext& rCxt, SCROW nRow, SvtListe
if (it->type != sc::element_type_broadcaster) if (it->type != sc::element_type_broadcaster)
return; return;
SvtBroadcaster* pBC = sc::custom_broadcaster_block::at(*it->data, aPos.second); SvtBroadcaster* pBC = sc::broadcaster_block::at(*it->data, aPos.second);
OSL_ASSERT(pBC); OSL_ASSERT(pBC);
rListener.EndListening(*pBC); rListener.EndListening(*pBC);
......
...@@ -147,11 +147,11 @@ void ScColumnTextWidthIterator::getDataIterators(size_t nOffsetInBlock) ...@@ -147,11 +147,11 @@ void ScColumnTextWidthIterator::getDataIterators(size_t nOffsetInBlock)
OSL_ENSURE(miBlockCur != miBlockEnd, "block is at end position"); OSL_ENSURE(miBlockCur != miBlockEnd, "block is at end position");
#if 0 #if 0
// Does not compile // Does not compile
OSL_ENSURE(miBlockCur->type == sc::custom_celltextattr_block, OSL_ENSURE(miBlockCur->type == sc::celltextattr_block,
"wrong block type - unsigned short block expected."); "wrong block type - unsigned short block expected.");
#endif #endif
miDataCur = sc::custom_celltextattr_block::begin(*miBlockCur->data); miDataCur = sc::celltextattr_block::begin(*miBlockCur->data);
miDataEnd = sc::custom_celltextattr_block::end(*miBlockCur->data); miDataEnd = sc::celltextattr_block::end(*miBlockCur->data);
std::advance(miDataCur, nOffsetInBlock); std::advance(miDataCur, nOffsetInBlock);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment