Kaydet (Commit) 95d1b054 authored tarafından David Tardon's avatar David Tardon

fix build with debug STL

Failed with:
/usr/include/c++/4.8.1/debug/safe_iterator.h:510:error: attempt to compare
iterators from different sequences.

Objects involved in the operation:
...

The problem is that miPos in _copied_ object points ot maAttrs in the
original object, not in the copy (and std::for_each takes a copy of the
functor). This could be solved by defining copy constructor and
operator=, but given the limited usage of the class, it is simpler to
let copies share the state.

Change-Id: Icf3f02ecd2fe4ce6dd77f3cde226d32beb4d4b3f
üst 3b35ad42
...@@ -294,11 +294,21 @@ namespace { ...@@ -294,11 +294,21 @@ namespace {
class CellTextAttrInitializer class CellTextAttrInitializer
{ {
sc::CellTextAttrStoreType maAttrs; struct Impl
sc::CellTextAttrStoreType::iterator miPos; {
sal_uInt16 mnScriptNumeric; 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)
{}
};
boost::shared_ptr<Impl> mpImpl;
public: public:
CellTextAttrInitializer(sal_uInt16 nScriptNumeric) : maAttrs(MAXROWCOUNT), miPos(maAttrs.begin()), mnScriptNumeric(nScriptNumeric) {} CellTextAttrInitializer(sal_uInt16 nScriptNumeric) : mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric)) {}
void operator() (const sc::CellStoreType::value_type& node) void operator() (const sc::CellStoreType::value_type& node)
{ {
...@@ -308,14 +318,14 @@ public: ...@@ -308,14 +318,14 @@ public:
// Fill with default values for non-empty cell segments. // Fill with default values for non-empty cell segments.
sc::CellTextAttr aDefault; sc::CellTextAttr aDefault;
if (node.type == sc::element_type_numeric) if (node.type == sc::element_type_numeric)
aDefault.mnScriptType = mnScriptNumeric; aDefault.mnScriptType = mpImpl->mnScriptNumeric;
std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault); 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());
} }
void swap(sc::CellTextAttrStoreType& rAttrs) void swap(sc::CellTextAttrStoreType& rAttrs)
{ {
maAttrs.swap(rAttrs); mpImpl->maAttrs.swap(rAttrs);
} }
}; };
......
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