<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Kohei,</div><div><br></div><div>Help!</div><div><br></div><div>From calc/sc/inc/rangelst.hxx:</div><div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef ScRange* ScRangePtr;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef ::std::vector< ScRangePtr > ScRangeListBase;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>class SC_DLLPUBLIC ScRangeList : public ScRangeListBase, public SvRefBase { ... }</div></div><div><br></div><div>I'm changing the definition of ScRangeListBase from a DECLARE_LIST() to a ::std:vector<>. For the most part the change is going well; however, we have a method in the class named "Join" that looks like it's trying to merge two lists together.</div><div><br></div><div>My issues are related to nOldPos:</div><div><br></div><div>1) I might need to write code to do the GetPos(); this just returns the Index to the address given. This is easy and not a big concern.</div><div><br></div><div>2) The Remove( nOldPos ) can be replaced with an erase( begin() + nOldPos ); however, at this point I believe that it's removing the object because it's in both lists (they have the same address). I'm thinking that destroying one instance will destroy the 2nd which would make this code incorrect. (I know, it's been working for years; I just don't see how).</div><div><br></div><div>3) Why is this recursive? This my have something to do with ScRange acting like a ScRangeList; which is my next task to find out why.</div><div><br></div><div>4) All the comments being in German isn't helping... </div><div><br></div><div>5) I'm thinking the Seek() is related to updating the position for the List <span class="Apple-style-span" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; ">iterator. vector<> uses a different </span><span class="Apple-style-span" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; ">iterator process so this can be removed; however, do I need to do something to update the vector<>'s </span><span class="Apple-style-span" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; ">iterator?</span></div><div><br></div>The code in question is calc/sc/core/tool/rangelst.cxx:<div><br></div><div><div>void ScRangeList::Join( const ScRange& r, bool bIsInList )</div><div>{</div><div> if ( empty() )</div><div> {</div><div> Append( r );</div><div> return ;</div><div> }</div><div> SCCOL nCol1 = r.aStart.Col();</div><div> SCROW nRow1 = r.aStart.Row();</div><div> SCTAB nTab1 = r.aStart.Tab();</div><div> SCCOL nCol2 = r.aEnd.Col();</div><div> SCROW nRow2 = r.aEnd.Row();</div><div> SCTAB nTab2 = r.aEnd.Tab();</div><div> ScRangePtr pOver = (ScRangePtr) &r;<span class="Apple-tab-span" style="white-space:pre">                </span>// fies aber wahr wenn bInList</div><div> size_t nOldPos = 0;</div><div> if ( bIsInList )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// merken um ggbf. zu loeschen bzw. wiederherzustellen</div><div> nOldPos = GetPos( pOver );</div><div> }</div><div> bool bJoinedInput = false;</div><div><br></div><div> size_t nRanges = size();</div><div> for ( size_t i = 0; i < nRanges; ++i )</div><div> {</div><div> ScRangePtr p = at( i );</div><div> if ( p == pOver )</div><div> continue;<span class="Apple-tab-span" style="white-space:pre">                        </span>// derselbe, weiter mit dem naechsten</div><div> bool bJoined = false;</div><div> if ( p->In( r ) )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// Range r in Range p enthalten oder identisch</div><div> if ( bIsInList )</div><div> bJoined = true;<span class="Apple-tab-span" style="white-space:pre">                </span>// weg mit Range r</div><div> else</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// das war's dann</div><div> bJoinedInput = true;<span class="Apple-tab-span" style="white-space:pre">        </span>// nicht anhaengen</div><div> break;<span class="Apple-tab-span" style="white-space:pre">        </span>// for</div><div> }</div><div> }</div><div> else if ( r.In( *p ) )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// Range p in Range r enthalten, r zum neuen Range machen</div><div> *p = r;</div><div> bJoined = true;</div><div> }</div><div> if ( !bJoined && p->aStart.Tab() == nTab1 && p->aEnd.Tab() == nTab2 )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// 2D</div><div> if ( p->aStart.Col() == nCol1 && p->aEnd.Col() == nCol2 )</div><div> {</div><div> if ( p->aStart.Row() == nRow2+1 )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// oben</div><div> p->aStart.SetRow( nRow1 );</div><div> bJoined = true;</div><div> }</div><div> else if ( p->aEnd.Row() == nRow1-1 )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// unten</div><div> p->aEnd.SetRow( nRow2 );</div><div> bJoined = true;</div><div> }</div><div> }</div><div> else if ( p->aStart.Row() == nRow1 && p->aEnd.Row() == nRow2 )</div><div> {</div><div> if ( p->aStart.Col() == nCol2+1 )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// links</div><div> p->aStart.SetCol( nCol1 );</div><div> bJoined = true;</div><div> }</div><div> else if ( p->aEnd.Col() == nCol1-1 )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// rechts</div><div> p->aEnd.SetCol( nCol2 );</div><div> bJoined = true;</div><div> }</div><div> }</div><div> }</div><div> if ( bJoined )</div><div> {</div><div> if ( bIsInList )</div><div> {<span class="Apple-tab-span" style="white-space:pre">        </span>// innerhalb der Liste Range loeschen</div><div> Remove( nOldPos );</div><div> delete pOver;</div><div> pOver = NULL;</div><div> if ( nOldPos )</div><div> nOldPos--;<span class="Apple-tab-span" style="white-space:pre">                        </span>// Seek richtig aufsetzen</div><div> }</div><div> bJoinedInput = true;</div><div> Join( *p, true );<span class="Apple-tab-span" style="white-space:pre">                        </span>// rekursiv!</div><div> }</div><div> }</div><div> if ( bIsInList )</div><div> Seek( nOldPos );</div><div> else if ( !bJoinedInput )</div><div> Append( r );</div><div>}</div></div><div><br></div><div>Joe P</div><div><br></div><div>PS: We have a 2nd Join for the PairLIst that looks the same.</div></body></html>