summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2013-11-05 08:27:55 +0100
committerDavid Tardon <dtardon@redhat.com>2013-11-05 08:29:26 +0100
commit2fb0b401ae351744773a19872377c076831f8c62 (patch)
tree4e3c179afef990d6b663908d1a605ad90e2a78f0
parent206dfc8949f727375d3f63a306c5c4e76d3e49b2 (diff)
fix STL debug build again
Change-Id: Ic616a83adcdf12c64ee3f5a00bf254be847b3c7e
-rw-r--r--sc/source/core/data/documentimport.cxx38
1 files changed, 29 insertions, 9 deletions
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 3b33f467f5f1..a5fa5218c74a 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -403,19 +403,39 @@ namespace {
class CellStoreInitializer
{
+ // The pimpl pattern here is intentional.
+ //
+ // The problem with having the attributes in CellStoreInitializer
+ // directly is that, as a functor, it might be copied around. In
+ // that case miPos in _copied_ object points ot maAttrs in the
+ // original object, not in the copy. So later, deep in mdds, we end
+ // up comparing iterators from different sequences.
+ //
+ // This could be solved by defining copy constructor and operator=,
+ // but given the limited usage of the class, I think it is simpler
+ // to let copies share the state.
+ struct Impl
+ {
+ sc::CellTextAttrStoreType maAttrs;
+ sc::CellTextAttrStoreType::iterator miPos;
+ sal_uInt16 mnScriptNumeric;
+
+ Impl(const sal_uInt32 nMaxRowCount, const sal_uInt16 nScriptNumeric)
+ : maAttrs(nMaxRowCount), miPos(maAttrs.begin()), mnScriptNumeric(nScriptNumeric)
+ {}
+ };
+
ScDocument& mrDoc;
sc::StartListeningContext& mrListenCxt;
- sc::CellTextAttrStoreType maAttrs;
- sc::CellTextAttrStoreType::iterator miPos;
- sal_uInt16 mnScriptNumeric;
public:
CellStoreInitializer(ScDocument& rDoc, sc::StartListeningContext& rCxt, sal_uInt16 nScriptNumeric) :
mrDoc(rDoc),
mrListenCxt(rCxt),
- maAttrs(MAXROWCOUNT),
- miPos(maAttrs.begin()),
- mnScriptNumeric(nScriptNumeric) {}
+ mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric))
+ {}
+
+ boost::shared_ptr<Impl> mpImpl;
void operator() (const sc::CellStoreType::value_type& node)
{
@@ -425,9 +445,9 @@ public:
// Fill with default values for non-empty cell segments.
sc::CellTextAttr aDefault;
if (node.type == sc::element_type_numeric)
- aDefault.mnScriptType = mnScriptNumeric;
+ aDefault.mnScriptType = mpImpl->mnScriptNumeric;
std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
- miPos = maAttrs.set(miPos, node.position, aDefaults.begin(), aDefaults.end());
+ mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
if (node.type == sc::element_type_formula)
{
@@ -444,7 +464,7 @@ public:
void swap(sc::CellTextAttrStoreType& rAttrs)
{
- maAttrs.swap(rAttrs);
+ mpImpl->maAttrs.swap(rAttrs);
}
};