[Libreoffice-commits] core.git: sc/source

David Tardon dtardon at redhat.com
Tue Nov 5 08:29:49 CET 2013


 sc/source/core/data/documentimport.cxx |   38 +++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 2fb0b401ae351744773a19872377c076831f8c62
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Nov 5 08:27:55 2013 +0100

    fix STL debug build again
    
    Change-Id: Ic616a83adcdf12c64ee3f5a00bf254be847b3c7e

diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 3b33f46..a5fa521 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);
     }
 };
 


More information about the Libreoffice-commits mailing list