[Libreoffice-commits] .: Branch 'gr2' - 63 commits - chart2/source sc/inc sc/qa sc/source sc/uiconfig

Martin Hosken mhosken at kemper.freedesktop.org
Thu Mar 10 00:04:19 PST 2011


 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx              |    6 
 chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx |    6 
 chart2/source/controller/dialogs/DataBrowser.cxx                         |    2 
 chart2/source/controller/dialogs/ObjectNameProvider.cxx                  |    2 
 chart2/source/controller/dialogs/res_DataLabel.cxx                       |    2 
 chart2/source/controller/dialogs/tp_Scale.cxx                            |    2 
 chart2/source/controller/main/ChartController_Properties.cxx             |    2 
 chart2/source/controller/main/ChartRenderer.cxx                          |    2 
 chart2/source/controller/main/ChartTransferable.cxx                      |    2 
 chart2/source/tools/CommonConverters.cxx                                 |    4 
 chart2/source/tools/LegendHelper.cxx                                     |    2 
 chart2/source/tools/ThreeDHelper.cxx                                     |    4 
 chart2/source/tools/WrappedPropertySet.cxx                               |    4 
 chart2/source/view/axes/TickmarkHelper.cxx                               |   11 
 chart2/source/view/axes/VCartesianAxis.cxx                               |    2 
 chart2/source/view/charttypes/AreaChart.cxx                              |    2 
 chart2/source/view/charttypes/BarChart.cxx                               |   10 
 chart2/source/view/charttypes/BubbleChart.cxx                            |    2 
 chart2/source/view/main/ChartView.cxx                                    |    4 
 chart2/source/view/main/Clipping.cxx                                     |    2 
 chart2/source/view/main/DrawModelWrapper.cxx                             |    2 
 chart2/source/view/main/NumberFormatterWrapper.cxx                       |    2 
 chart2/source/view/main/VDataSeries.cxx                                  |    2 
 chart2/source/view/main/VLegendSymbolFactory.cxx                         |    2 
 sc/inc/address.hxx                                                       |    3 
 sc/inc/cell.hxx                                                          |    2 
 sc/inc/clipparam.hxx                                                     |    2 
 sc/inc/column.hxx                                                        |    2 
 sc/inc/compiler.hxx                                                      |    2 
 sc/inc/document.hxx                                                      |    3 
 sc/inc/miscuno.hxx                                                       |    8 
 sc/inc/rangenam.hxx                                                      |   87 +-
 sc/inc/rangeutl.hxx                                                      |   13 
 sc/qa/unit/ucalc.cxx                                                     |  378 +++++++++
 sc/source/core/data/attarray.cxx                                         |   10 
 sc/source/core/data/attrib.cxx                                           |   10 
 sc/source/core/data/cell.cxx                                             |   10 
 sc/source/core/data/cell2.cxx                                            |   49 -
 sc/source/core/data/column.cxx                                           |   17 
 sc/source/core/data/column2.cxx                                          |    6 
 sc/source/core/data/column3.cxx                                          |  387 +++++-----
 sc/source/core/data/conditio.cxx                                         |   12 
 sc/source/core/data/dociter.cxx                                          |    6 
 sc/source/core/data/docpool.cxx                                          |    2 
 sc/source/core/data/documen2.cxx                                         |  108 +-
 sc/source/core/data/documen3.cxx                                         |   42 -
 sc/source/core/data/documen4.cxx                                         |   10 
 sc/source/core/data/documen8.cxx                                         |   12 
 sc/source/core/data/documen9.cxx                                         |    6 
 sc/source/core/data/document.cxx                                         |  221 ++---
 sc/source/core/data/dpdimsave.cxx                                        |    4 
 sc/source/core/data/dpgroup.cxx                                          |   18 
 sc/source/core/data/dpobject.cxx                                         |    8 
 sc/source/core/data/dpoutput.cxx                                         |   10 
 sc/source/core/data/dpsave.cxx                                           |    4 
 sc/source/core/data/dpsdbtab.cxx                                         |    2 
 sc/source/core/data/dpshttab.cxx                                         |   13 
 sc/source/core/data/dptabdat.cxx                                         |   10 
 sc/source/core/data/dptabres.cxx                                         |   18 
 sc/source/core/data/dptabsrc.cxx                                         |   50 -
 sc/source/core/data/drwlayer.cxx                                         |   14 
 sc/source/core/data/fillinfo.cxx                                         |    4 
 sc/source/core/data/funcdesc.cxx                                         |    2 
 sc/source/core/data/global.cxx                                           |    6 
 sc/source/core/data/markdata.cxx                                         |    4 
 sc/source/core/data/olinetab.cxx                                         |   12 
 sc/source/core/data/patattr.cxx                                          |   12 
 sc/source/core/data/postit.cxx                                           |    4 
 sc/source/core/data/sortparam.cxx                                        |    2 
 sc/source/core/data/stlpool.cxx                                          |    6 
 sc/source/core/data/stlsheet.cxx                                         |    2 
 sc/source/core/data/table1.cxx                                           |   18 
 sc/source/core/data/table2.cxx                                           |   70 +
 sc/source/core/data/table3.cxx                                           |   14 
 sc/source/core/data/table4.cxx                                           |   12 
 sc/source/core/data/table5.cxx                                           |    2 
 sc/source/core/data/table6.cxx                                           |   12 
 sc/source/core/data/tabprotection.cxx                                    |    4 
 sc/source/core/data/userdat.cxx                                          |    2 
 sc/source/core/data/validat.cxx                                          |    8 
 sc/source/core/inc/interpre.hxx                                          |    1 
 sc/source/core/inc/jumpmatrix.hxx                                        |    2 
 sc/source/core/tool/addincfg.cxx                                         |    2 
 sc/source/core/tool/addincol.cxx                                         |    6 
 sc/source/core/tool/address.cxx                                          |   13 
 sc/source/core/tool/adiasync.cxx                                         |    2 
 sc/source/core/tool/autoform.cxx                                         |   16 
 sc/source/core/tool/callform.cxx                                         |    2 
 sc/source/core/tool/cellform.cxx                                         |    2 
 sc/source/core/tool/charthelper.cxx                                      |    2 
 sc/source/core/tool/chartlis.cxx                                         |    4 
 sc/source/core/tool/chartlock.cxx                                        |    6 
 sc/source/core/tool/chgtrack.cxx                                         |   16 
 sc/source/core/tool/compiler.cxx                                         |   71 -
 sc/source/core/tool/consoli.cxx                                          |    2 
 sc/source/core/tool/detfunc.cxx                                          |   10 
 sc/source/core/tool/doubleref.cxx                                        |    2 
 sc/source/core/tool/editutil.cxx                                         |    2 
 sc/source/core/tool/filtopt.cxx                                          |    4 
 sc/source/core/tool/inputopt.cxx                                         |    2 
 sc/source/core/tool/interpr1.cxx                                         |   61 -
 sc/source/core/tool/interpr2.cxx                                         |    2 
 sc/source/core/tool/interpr3.cxx                                         |   36 
 sc/source/core/tool/interpr4.cxx                                         |    6 
 sc/source/core/tool/interpr5.cxx                                         |   33 
 sc/source/core/tool/interpr7.cxx                                         |   38 
 sc/source/core/tool/makefile.mk                                          |    1 
 sc/source/core/tool/progress.cxx                                         |    6 
 sc/source/core/tool/queryparam.cxx                                       |    2 
 sc/source/core/tool/rangenam.cxx                                         |  262 ++++--
 sc/source/core/tool/rangeseq.cxx                                         |    2 
 sc/source/core/tool/rangeutl.cxx                                         |   40 -
 sc/source/core/tool/rechead.cxx                                          |    4 
 sc/source/core/tool/zforauto.cxx                                         |    2 
 sc/source/filter/dif/difimp.cxx                                          |    2 
 sc/source/filter/excel/excform.cxx                                       |    6 
 sc/source/filter/excel/namebuff.cxx                                      |    2 
 sc/source/filter/excel/read.cxx                                          |    4 
 sc/source/filter/excel/tokstack.cxx                                      |    6 
 sc/source/filter/excel/xecontent.cxx                                     |    2 
 sc/source/filter/excel/xename.cxx                                        |   11 
 sc/source/filter/excel/xiname.cxx                                        |    5 
 sc/source/filter/excel/xlformula.cxx                                     |    2 
 sc/source/filter/excel/xlstyle.cxx                                       |    4 
 sc/source/filter/html/htmlimp.cxx                                        |   17 
 sc/source/filter/html/htmlpars.cxx                                       |    4 
 sc/source/filter/inc/fapihelper.hxx                                      |    3 
 sc/source/filter/lotus/lotform.cxx                                       |    6 
 sc/source/filter/lotus/lotread.cxx                                       |    2 
 sc/source/filter/lotus/tool.cxx                                          |    6 
 sc/source/filter/rtf/eeimpars.cxx                                        |    5 
 sc/source/filter/starcalc/scflt.cxx                                      |   26 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx                             |    2 
 sc/source/filter/xcl97/XclImpChangeTrack.cxx                             |   10 
 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx                   |    6 
 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx                   |   24 
 sc/source/filter/xml/XMLExportDataPilot.cxx                              |    2 
 sc/source/filter/xml/XMLExportIterator.cxx                               |    4 
 sc/source/filter/xml/XMLStylesExportHelper.cxx                           |    4 
 sc/source/filter/xml/XMLStylesImportHelper.cxx                           |    6 
 sc/source/filter/xml/XMLTableShapeResizer.cxx                            |    2 
 sc/source/filter/xml/XMLTrackedChangesContext.cxx                        |    2 
 sc/source/filter/xml/xmlcelli.cxx                                        |    2 
 sc/source/filter/xml/xmlexprt.cxx                                        |    7 
 sc/source/filter/xml/xmlimprt.cxx                                        |    8 
 sc/source/filter/xml/xmlstyle.cxx                                        |    4 
 sc/source/filter/xml/xmlstyli.cxx                                        |    5 
 sc/source/filter/xml/xmlsubti.cxx                                        |    2 
 sc/source/ui/Accessibility/AccessibleContextBase.cxx                     |   16 
 sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx                     |    6 
 sc/source/ui/Accessibility/AccessibleTableBase.cxx                       |   28 
 sc/source/ui/Accessibility/AccessibleText.cxx                            |   42 -
 sc/source/ui/app/client.cxx                                              |    6 
 sc/source/ui/app/drwtrans.cxx                                            |    6 
 sc/source/ui/app/inputhdl.cxx                                            |   10 
 sc/source/ui/app/inputwin.cxx                                            |   40 -
 sc/source/ui/app/scmod.cxx                                               |    6 
 sc/source/ui/app/scmod2.cxx                                              |    2 
 sc/source/ui/app/transobj.cxx                                            |   12 
 sc/source/ui/app/wtcdummy.cxx                                            |    8 
 sc/source/ui/dbgui/consdlg.cxx                                           |    2 
 sc/source/ui/dbgui/dapidata.cxx                                          |    2 
 sc/source/ui/dbgui/filtdlg.cxx                                           |    4 
 sc/source/ui/dbgui/pvfundlg.cxx                                          |    3 
 sc/source/ui/dbgui/pvlaydlg.cxx                                          |    8 
 sc/source/ui/dbgui/scendlg.src                                           |    1 
 sc/source/ui/dbgui/sfiltdlg.cxx                                          |   38 
 sc/source/ui/dbgui/tpsubt.cxx                                            |    4 
 sc/source/ui/docshell/arealink.cxx                                       |   12 
 sc/source/ui/docshell/dbdocfun.cxx                                       |   16 
 sc/source/ui/docshell/dbdocimp.cxx                                       |    6 
 sc/source/ui/docshell/docfunc.cxx                                        |   62 -
 sc/source/ui/docshell/docsh.cxx                                          |   22 
 sc/source/ui/docshell/docsh3.cxx                                         |   12 
 sc/source/ui/docshell/docsh4.cxx                                         |   17 
 sc/source/ui/docshell/docsh5.cxx                                         |    2 
 sc/source/ui/docshell/docsh8.cxx                                         |    8 
 sc/source/ui/docshell/externalrefmgr.cxx                                 |   86 +-
 sc/source/ui/docshell/impex.cxx                                          |    5 
 sc/source/ui/docshell/servobj.cxx                                        |    7 
 sc/source/ui/drawfunc/drawsh4.cxx                                        |    2 
 sc/source/ui/drawfunc/drawsh5.cxx                                        |    4 
 sc/source/ui/drawfunc/drformsh.src                                       |    3 
 sc/source/ui/drawfunc/drtxtob2.cxx                                       |    2 
 sc/source/ui/drawfunc/fuconarc.cxx                                       |    2 
 sc/source/ui/drawfunc/fuconpol.cxx                                       |    2 
 sc/source/ui/drawfunc/fuconrec.cxx                                       |    4 
 sc/source/ui/drawfunc/fuins2.cxx                                         |    4 
 sc/source/ui/drawfunc/futext.cxx                                         |    2 
 sc/source/ui/drawfunc/objdraw.src                                        |    6 
 sc/source/ui/inc/namedlg.hxx                                             |    2 
 sc/source/ui/miscdlgs/conflictsdlg.cxx                                   |    2 
 sc/source/ui/miscdlgs/instbdlg.src                                       |    2 
 sc/source/ui/miscdlgs/namepast.cxx                                       |   19 
 sc/source/ui/miscdlgs/sharedocdlg.cxx                                    |    2 
 sc/source/ui/namedlg/namedlg.cxx                                         |   88 --
 sc/source/ui/navipi/content.cxx                                          |   55 -
 sc/source/ui/optdlg/tpusrlst.cxx                                         |    4 
 sc/source/ui/pagedlg/areasdlg.cxx                                        |   88 +-
 sc/source/ui/pagedlg/tphf.cxx                                            |    2 
 sc/source/ui/src/autofmt.src                                             |   11 
 sc/source/ui/src/hdrcont.src                                             |   19 
 sc/source/ui/src/namedlg.src                                             |    5 
 sc/source/ui/src/optdlg.src                                              |    7 
 sc/source/ui/src/sc.src                                                  |    1 
 sc/source/ui/src/scwarngs.src                                            |    1 
 sc/source/ui/src/solvrdlg.src                                            |    2 
 sc/source/ui/src/subtdlg.src                                             |    4 
 sc/source/ui/src/textdlgs.src                                            |    3 
 sc/source/ui/src/toolbox.src                                             |    4 
 sc/source/ui/styleui/styledlg.cxx                                        |    2 
 sc/source/ui/styleui/styledlg.src                                        |    1 
 sc/source/ui/undo/undoblk.cxx                                            |    4 
 sc/source/ui/undo/undoblk3.cxx                                           |   47 -
 sc/source/ui/undo/undocell.cxx                                           |    4 
 sc/source/ui/undo/undodat.cxx                                            |    4 
 sc/source/ui/undo/undotab.cxx                                            |    4 
 sc/source/ui/unoobj/afmtuno.cxx                                          |    4 
 sc/source/ui/unoobj/celllistsource.cxx                                   |    4 
 sc/source/ui/unoobj/cellsuno.cxx                                         |   48 -
 sc/source/ui/unoobj/cellvaluebinding.cxx                                 |    8 
 sc/source/ui/unoobj/chart2uno.cxx                                        |   10 
 sc/source/ui/unoobj/chartuno.cxx                                         |    2 
 sc/source/ui/unoobj/cursuno.cxx                                          |    4 
 sc/source/ui/unoobj/dapiuno.cxx                                          |    2 
 sc/source/ui/unoobj/datauno.cxx                                          |   22 
 sc/source/ui/unoobj/docuno.cxx                                           |   12 
 sc/source/ui/unoobj/fielduno.cxx                                         |    8 
 sc/source/ui/unoobj/fmtuno.cxx                                           |    2 
 sc/source/ui/unoobj/nameuno.cxx                                          |  193 ++--
 sc/source/ui/unoobj/scdetect.cxx                                         |    2 
 sc/source/ui/unoobj/servuno.cxx                                          |    2 
 sc/source/ui/unoobj/shapeuno.cxx                                         |    8 
 sc/source/ui/unoobj/styleuno.cxx                                         |    6 
 sc/source/ui/unoobj/targuno.cxx                                          |    2 
 sc/source/ui/unoobj/viewuno.cxx                                          |    4 
 sc/source/ui/vba/vbarange.cxx                                            |   15 
 sc/source/ui/view/cellsh.cxx                                             |    8 
 sc/source/ui/view/cellsh1.cxx                                            |   31 
 sc/source/ui/view/cellsh2.cxx                                            |   12 
 sc/source/ui/view/cellsh3.cxx                                            |   10 
 sc/source/ui/view/cellsh4.cxx                                            |    8 
 sc/source/ui/view/dbfunc.cxx                                             |    2 
 sc/source/ui/view/dbfunc3.cxx                                            |   10 
 sc/source/ui/view/drawvie4.cxx                                           |    2 
 sc/source/ui/view/drawview.cxx                                           |   16 
 sc/source/ui/view/editsh.cxx                                             |   10 
 sc/source/ui/view/formatsh.cxx                                           |   14 
 sc/source/ui/view/gridwin.cxx                                            |   24 
 sc/source/ui/view/gridwin2.cxx                                           |    2 
 sc/source/ui/view/gridwin3.cxx                                           |    4 
 sc/source/ui/view/gridwin4.cxx                                           |    8 
 sc/source/ui/view/gridwin5.cxx                                           |    2 
 sc/source/ui/view/hdrcont.cxx                                            |   10 
 sc/source/ui/view/notemark.cxx                                           |    2 
 sc/source/ui/view/output.cxx                                             |   12 
 sc/source/ui/view/output2.cxx                                            |   32 
 sc/source/ui/view/preview.cxx                                            |    4 
 sc/source/ui/view/prevwsh.cxx                                            |    8 
 sc/source/ui/view/printfun.cxx                                           |   26 
 sc/source/ui/view/select.cxx                                             |    6 
 sc/source/ui/view/spelldialog.cxx                                        |    2 
 sc/source/ui/view/spelleng.cxx                                           |    2 
 sc/source/ui/view/tabcont.cxx                                            |   10 
 sc/source/ui/view/tabview.cxx                                            |   16 
 sc/source/ui/view/tabview2.cxx                                           |    4 
 sc/source/ui/view/tabview3.cxx                                           |   22 
 sc/source/ui/view/tabview5.cxx                                           |    6 
 sc/source/ui/view/tabvwsh2.cxx                                           |   20 
 sc/source/ui/view/tabvwsh3.cxx                                           |    6 
 sc/source/ui/view/tabvwsh4.cxx                                           |   34 
 sc/source/ui/view/tabvwsh5.cxx                                           |    8 
 sc/source/ui/view/tabvwsh9.cxx                                           |    2 
 sc/source/ui/view/tabvwsha.cxx                                           |    2 
 sc/source/ui/view/tabvwshb.cxx                                           |    8 
 sc/source/ui/view/tabvwshc.cxx                                           |    2 
 sc/source/ui/view/tabvwshd.cxx                                           |    2 
 sc/source/ui/view/tabvwshe.cxx                                           |    6 
 sc/source/ui/view/tabvwshf.cxx                                           |    2 
 sc/source/ui/view/tabvwshg.cxx                                           |    1 
 sc/source/ui/view/tabvwshh.cxx                                           |    4 
 sc/source/ui/view/viewdata.cxx                                           |   32 
 sc/source/ui/view/viewfun2.cxx                                           |    2 
 sc/source/ui/view/viewfun3.cxx                                           |   16 
 sc/source/ui/view/viewfun4.cxx                                           |    6 
 sc/source/ui/view/viewfun5.cxx                                           |   14 
 sc/source/ui/view/viewfun7.cxx                                           |   22 
 sc/source/ui/view/viewfunc.cxx                                           |   26 
 sc/uiconfig/scalc/menubar/menubar.xml                                    |    1 
 289 files changed, 2496 insertions(+), 2021 deletions(-)

New commits:
commit e8133a3dc31e15c5e9766ff3979086e3f230666f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 9 11:02:22 2011 +0000

    silence some warnings

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 0a1eebc..8e370d6 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6692,12 +6692,12 @@ void ScInterpreter::ScOffset()
             nRowNew = (long) ::rtl::math::approxFloor(GetDoubleWithDefault( -1.0 ));
         nColPlus = (long) ::rtl::math::approxFloor(GetDouble());
         nRowPlus = (long) ::rtl::math::approxFloor(GetDouble());
-        SCCOL nCol1;
-        SCROW nRow1;
-        SCTAB nTab1;
-        SCCOL nCol2;
-        SCROW nRow2;
-        SCTAB nTab2;
+        SCCOL nCol1(0);
+        SCROW nRow1(0);
+        SCTAB nTab1(0);
+        SCCOL nCol2(0);
+        SCROW nRow2(0);
+        SCTAB nTab2(0);
         if (nColNew == 0 || nRowNew == 0)
         {
             PushIllegalArgument();
commit 7f077d11ff36d8df79c08d00236eae8253188f82
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Mar 8 17:23:59 2011 -0500

    Simple in-line comment.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index abfd2c3..5269d55 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1112,6 +1112,7 @@ void Test::testExternalRef()
                            aCachedRange.aStart.Col() == 0 && aCachedRange.aEnd.Col() == 1 &&
                            aCachedRange.aStart.Row() == 0 && aCachedRange.aEnd.Row() == 3);
 
+    // Unload the external document shell.
     xExtDocSh->DoClose();
     CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.",
                            findLoadedDocShellByName(aExtDocName) == NULL);
commit 5704038d6bc3f17120907c951777b5cec94ac7d5
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Mar 8 17:14:26 2011 -0500

    Added unit test for external references.
    
    For now, we just test its caching behavior with in-memory document.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 6eaf77d..abfd2c3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -69,6 +69,7 @@
 
 #include "docsh.hxx"
 #include "funcdesc.hxx"
+#include "externalrefmgr.hxx"
 
 #include "dpshttab.hxx"
 #include "dpobject.hxx"
@@ -236,6 +237,7 @@ public:
     void testMatrix();
     void testDataPilot();
     void testSheetCopy();
+    void testExternalRef();
 
     /**
      * Make sure the sheet streams are invalidated properly.
@@ -265,6 +267,7 @@ public:
     CPPUNIT_TEST(testMatrix);
     CPPUNIT_TEST(testDataPilot);
     CPPUNIT_TEST(testSheetCopy);
+    CPPUNIT_TEST(testExternalRef);
     CPPUNIT_TEST(testGraphicsInGroup);
     CPPUNIT_TEST(testStreamValid);
     CPPUNIT_TEST(testFunctionLists);
@@ -886,6 +889,236 @@ void Test::testSheetCopy()
     m_pDoc->DeleteTab(0);
 }
 
+ScDocShell* findLoadedDocShellByName(const OUString& rName)
+{
+    TypeId aType(TYPE(ScDocShell));
+    ScDocShell* pShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(&aType, false));
+    while (pShell)
+    {
+        SfxMedium* pMedium = pShell->GetMedium();
+        if (pMedium)
+        {
+            OUString aName = pMedium->GetName();
+            if (aName.equals(rName))
+                return pShell;
+        }
+        pShell = static_cast<ScDocShell*>(SfxObjectShell::GetNext(*pShell, &aType, false));
+    }
+    return NULL;
+}
+
+ScRange getCachedRange(const ScExternalRefCache::TableTypeRef& pCacheTab)
+{
+    ScRange aRange;
+
+    vector<SCROW> aRows;
+    pCacheTab->getAllRows(aRows);
+    vector<SCROW>::const_iterator itrRow = aRows.begin(), itrRowEnd = aRows.end();
+    bool bFirst = true;
+    for (; itrRow != itrRowEnd; ++itrRow)
+    {
+        SCROW nRow = *itrRow;
+        vector<SCCOL> aCols;
+        pCacheTab->getAllCols(nRow, aCols);
+        vector<SCCOL>::const_iterator itrCol = aCols.begin(), itrColEnd = aCols.end();
+        for (; itrCol != itrColEnd; ++itrCol)
+        {
+            SCCOL nCol = *itrCol;
+            if (bFirst)
+            {
+                aRange.aStart = ScAddress(nCol, nRow, 0);
+                aRange.aEnd = aRange.aStart;
+                bFirst = false;
+            }
+            else
+            {
+                if (nCol < aRange.aStart.Col())
+                    aRange.aStart.SetCol(nCol);
+                else if (aRange.aEnd.Col() < nCol)
+                    aRange.aEnd.SetCol(nCol);
+
+                if (nRow < aRange.aStart.Row())
+                    aRange.aStart.SetRow(nRow);
+                else if (aRange.aEnd.Row() < nRow)
+                    aRange.aEnd.SetRow(nRow);
+            }
+        }
+    }
+    return aRange;
+}
+
+void Test::testExternalRef()
+{
+    ScDocShellRef xExtDocSh = new ScDocShell;
+    OUString aExtDocName(RTL_CONSTASCII_USTRINGPARAM("file:///extdata.fake"));
+    OUString aExtSh1Name(RTL_CONSTASCII_USTRINGPARAM("Data1"));
+    OUString aExtSh2Name(RTL_CONSTASCII_USTRINGPARAM("Data2"));
+    OUString aExtSh3Name(RTL_CONSTASCII_USTRINGPARAM("Data3"));
+    SfxMedium* pMed = new SfxMedium(aExtDocName, STREAM_STD_READWRITE);
+    xExtDocSh->DoInitNew(pMed);
+    CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
+                           findLoadedDocShellByName(aExtDocName) != NULL);
+
+    // Populate the external source document.
+    ScDocument* pExtDoc = xExtDocSh->GetDocument();
+    pExtDoc->InsertTab(0, aExtSh1Name);
+    pExtDoc->InsertTab(1, aExtSh2Name);
+    pExtDoc->InsertTab(2, aExtSh3Name);
+
+    OUString name(RTL_CONSTASCII_USTRINGPARAM("Name"));
+    OUString value(RTL_CONSTASCII_USTRINGPARAM("Value"));
+    OUString andy(RTL_CONSTASCII_USTRINGPARAM("Andy"));
+    OUString bruce(RTL_CONSTASCII_USTRINGPARAM("Bruce"));
+    OUString charlie(RTL_CONSTASCII_USTRINGPARAM("Charlie"));
+    OUString david(RTL_CONSTASCII_USTRINGPARAM("David"));
+    OUString edward(RTL_CONSTASCII_USTRINGPARAM("Edward"));
+    OUString frank(RTL_CONSTASCII_USTRINGPARAM("Frank"));
+    OUString george(RTL_CONSTASCII_USTRINGPARAM("George"));
+    OUString henry(RTL_CONSTASCII_USTRINGPARAM("Henry"));
+
+    // Sheet 1
+    pExtDoc->SetString(0, 0, 0, name);
+    pExtDoc->SetString(0, 1, 0, andy);
+    pExtDoc->SetString(0, 2, 0, bruce);
+    pExtDoc->SetString(0, 3, 0, charlie);
+    pExtDoc->SetString(0, 4, 0, david);
+    pExtDoc->SetString(1, 0, 0, value);
+    double val = 10;
+    pExtDoc->SetValue(1, 1, 0, val);
+    val = 11;
+    pExtDoc->SetValue(1, 2, 0, val);
+    val = 12;
+    pExtDoc->SetValue(1, 3, 0, val);
+    val = 13;
+    pExtDoc->SetValue(1, 4, 0, val);
+
+    // Sheet 2 remains empty.
+
+    // Sheet 3
+    pExtDoc->SetString(0, 0, 2, name);
+    pExtDoc->SetString(0, 1, 2, edward);
+    pExtDoc->SetString(0, 2, 2, frank);
+    pExtDoc->SetString(0, 3, 2, george);
+    pExtDoc->SetString(0, 4, 2, henry);
+    pExtDoc->SetString(1, 0, 2, value);
+    val = 99;
+    pExtDoc->SetValue(1, 1, 2, val);
+    val = 98;
+    pExtDoc->SetValue(1, 2, 2, val);
+    val = 97;
+    pExtDoc->SetValue(1, 3, 2, val);
+    val = 96;
+    pExtDoc->SetValue(1, 4, 2, val);
+
+    // Test external refernces on the main document while the external
+    // document is still in memory.
+    OUString test;
+    m_pDoc->InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM("Test Sheet")));
+    m_pDoc->SetString(0, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.A1")));
+    m_pDoc->GetString(0, 0, 0, test);
+    CPPUNIT_ASSERT_MESSAGE("Value is different from the original", test.equals(name));
+
+    // After the initial access to the external document, the external ref
+    // manager should create sheet cache entries for *all* sheets from that
+    // document.  Note that the doc may have more than 3 sheets but ensure
+    // that the first 3 are what we expect.
+    ScExternalRefManager* pRefMgr = m_pDoc->GetExternalRefManager();
+    sal_uInt16 nFileId = pRefMgr->getExternalFileId(aExtDocName);
+    vector<OUString> aTabNames;
+    pRefMgr->getAllCachedTableNames(nFileId, aTabNames);
+    CPPUNIT_ASSERT_MESSAGE("There should be at least 3 sheets.", aTabNames.size() >= 3);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected sheet name.", aTabNames[0].equals(aExtSh1Name));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected sheet name.", aTabNames[1].equals(aExtSh2Name));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected sheet name.", aTabNames[2].equals(aExtSh3Name));
+
+    m_pDoc->SetString(1, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.B1")));
+    m_pDoc->GetString(1, 0, 0, test);
+    CPPUNIT_ASSERT_MESSAGE("Value is different from the original", test.equals(value));
+
+    m_pDoc->SetString(0, 1, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.A2")));
+    m_pDoc->SetString(0, 2, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.A3")));
+    m_pDoc->SetString(0, 3, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.A4")));
+    m_pDoc->SetString(0, 4, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.A5")));
+    m_pDoc->SetString(0, 5, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.A6")));
+
+    {
+        // Referencing an empty cell should display '0'.
+        const char* pChecks[] = { "Andy", "Bruce", "Charlie", "David", "0" };
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pChecks); ++i)
+        {
+            m_pDoc->GetString(0, static_cast<SCROW>(i+1), 0, test);
+            CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", test.equalsAscii(pChecks[i]));
+        }
+    }
+    m_pDoc->SetString(1, 1, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.B2")));
+    m_pDoc->SetString(1, 2, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.B3")));
+    m_pDoc->SetString(1, 3, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.B4")));
+    m_pDoc->SetString(1, 4, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.B5")));
+    m_pDoc->SetString(1, 5, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data1.B6")));
+    {
+        double pChecks[] = { 10, 11, 12, 13, 0 };
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pChecks); ++i)
+        {
+            m_pDoc->GetValue(1, static_cast<SCROW>(i+1), 0, val);
+            CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", val == pChecks[i]);
+        }
+    }
+
+    m_pDoc->SetString(2, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.A1")));
+    m_pDoc->SetString(2, 1, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.A2")));
+    m_pDoc->SetString(2, 2, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.A3")));
+    m_pDoc->SetString(2, 3, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.A4")));
+    {
+        const char* pChecks[] = { "Name", "Edward", "Frank", "George" };
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pChecks); ++i)
+        {
+            m_pDoc->GetString(2, static_cast<SCROW>(i), 0, test);
+            CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", test.equalsAscii(pChecks[i]));
+        }
+    }
+
+    m_pDoc->SetString(3, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.B1")));
+    m_pDoc->SetString(3, 1, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.B2")));
+    m_pDoc->SetString(3, 2, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.B3")));
+    m_pDoc->SetString(3, 3, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("='file:///extdata.fake'#Data3.B4")));
+    {
+        const char* pChecks[] = { "Value", "99", "98", "97" };
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pChecks); ++i)
+        {
+            m_pDoc->GetString(3, static_cast<SCROW>(i), 0, test);
+            CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", test.equalsAscii(pChecks[i]));
+        }
+    }
+
+    // At this point, all accessed cell data from the external document should
+    // have been cached.
+    ScExternalRefCache::TableTypeRef pCacheTab = pRefMgr->getCacheTable(
+        nFileId, aExtSh1Name, false);
+    CPPUNIT_ASSERT_MESSAGE("Cache table for sheet 1 should exist.", pCacheTab.get() != NULL);
+    ScRange aCachedRange = getCachedRange(pCacheTab);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected cached data range.",
+                           aCachedRange.aStart.Col() == 0 && aCachedRange.aEnd.Col() == 1 &&
+                           aCachedRange.aStart.Row() == 0 && aCachedRange.aEnd.Row() == 4);
+
+    // Sheet2 is not referenced at all; the cache table shouldn't even exist.
+    pCacheTab = pRefMgr->getCacheTable(nFileId, aExtSh2Name, false);
+    CPPUNIT_ASSERT_MESSAGE("Cache table for sheet 2 should *not* exist.", pCacheTab.get() == NULL);
+
+    // Sheet3's row 5 is not referenced; it should not be cached.
+    pCacheTab = pRefMgr->getCacheTable(nFileId, aExtSh3Name, false);
+    CPPUNIT_ASSERT_MESSAGE("Cache table for sheet 3 should exist.", pCacheTab.get() != NULL);
+    aCachedRange = getCachedRange(pCacheTab);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected cached data range.",
+                           aCachedRange.aStart.Col() == 0 && aCachedRange.aEnd.Col() == 1 &&
+                           aCachedRange.aStart.Row() == 0 && aCachedRange.aEnd.Row() == 3);
+
+    xExtDocSh->DoClose();
+    CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.",
+                           findLoadedDocShellByName(aExtDocName) == NULL);
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testStreamValid()
 {
     m_pDoc->InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet1")));
commit 51bf6bf654860d564e3c5f82ab989b5912252996
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Mar 7 22:20:20 2011 -0500

    Typo.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8685b34..6eaf77d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -906,8 +906,7 @@ void Test::testStreamValid()
     m_pDoc->GetString(0, 1, 0, test);
     CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet1.A2", test.equals(a2));
 
-    // Put formulas into Sheet2 to Sheet4 to references values from Sheet1.
-
+    // Put formulas into Sheet2 to Sheet4 to reference values from Sheet1.
     m_pDoc->SetString(0, 0, 1, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A1")));
     m_pDoc->SetString(0, 1, 1, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A2")));
     m_pDoc->SetString(0, 0, 2, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A1")));
commit e98dd6643b15a156dbf3574343f3c076ad7ac277
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Mar 7 18:40:10 2011 -0500

    Properly invalidate cached sheet XML streams during reference update.
    
    Failure to invalidate sheet streams during reference update caused
    formula cross referenceing between sheets to totallly get borked.
    
    The bug was originally reported in i#116833.

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 110c848..38e85ef 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -440,7 +440,7 @@ public:
     BOOL			HasRelNameReference() const;
     BOOL			HasColRowName() const;
 
-    void			UpdateReference(UpdateRefMode eUpdateRefMode,
+    bool			UpdateReference(UpdateRefMode eUpdateRefMode,
                                     const ScRange& r,
                                     SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
                                     ScDocument* pUndoDoc = NULL,
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 35d26b0..e4ab44b 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -285,7 +285,7 @@ public:
 
     void        ResetChanged( SCROW nStartRow, SCROW nEndRow );
 
-    void        UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
+    bool        UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
                                      SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
                                      SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
                                      ScDocument* pUndoDoc = NULL );
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index dca9b79..8685b34 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -946,14 +946,12 @@ void Test::testStreamValid()
     pCell = m_pDoc->GetCell(ScAddress(0, 2, 0));
     CPPUNIT_ASSERT_MESSAGE("Cell A3 should be empty.", pCell == NULL);
 
-#if 0 // This currently fails.
     // After the move, Sheet1, Sheet2, and Sheet4 should have their stream
     // invalidated, whereas Sheet3's stream should still be valid.
     CPPUNIT_ASSERT_MESSAGE("Stream should have been invalidated.", !m_pDoc->IsStreamValid(0));
     CPPUNIT_ASSERT_MESSAGE("Stream should have been invalidated.", !m_pDoc->IsStreamValid(1));
     CPPUNIT_ASSERT_MESSAGE("Stream should have been invalidated.", !m_pDoc->IsStreamValid(3));
     CPPUNIT_ASSERT_MESSAGE("Stream should still be valid.", m_pDoc->IsStreamValid(2));
-#endif
 
     m_pDoc->DeleteTab(3);
     m_pDoc->DeleteTab(2);
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index a47dd14..06f53dc 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -825,11 +825,13 @@ BOOL ScFormulaCell::HasColRowName() const
     return (pCode->GetNextColRowName() != NULL);
 }
 
-void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
+bool ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
                                     const ScRange& r,
                                     SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
                                     ScDocument* pUndoDoc, const ScAddress* pUndoCellPos )
 {
+    bool bCellStateChanged = false;
+
     SCCOL nCol1 = r.aStart.Col();
     SCROW nRow1 = r.aStart.Row();
     SCTAB nTab1 = r.aStart.Tab();
@@ -858,6 +860,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
                     nCol = 0;
                 else if ( nCol > MAXCOL )
                     nCol = MAXCOL;
+                bCellStateChanged = aPos.Col() != nCol;
                 aPos.SetCol( nCol );
             }
         }
@@ -871,6 +874,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
                     nRow = 0;
                 else if ( nRow > MAXROW )
                     nRow = MAXROW;
+                bCellStateChanged = aPos.Row() != nRow;
                 aPos.SetRow( nRow );
             }
         }
@@ -885,6 +889,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
                     nTab = 0;
                 else if ( nTab > nMaxTab )
                     nTab = nMaxTab;
+                bCellStateChanged = aPos.Tab() != nTab;
                 aPos.SetTab( nTab );
             }
         }
@@ -912,8 +917,8 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
     if( bHasRefs || bOnRefMove )
     {
         ScTokenArray* pOld = pUndoDoc ? pCode->Clone() : NULL;
-        bool bValChanged = false;
         ScRangeData* pRangeData;
+        bool bValChanged = false;
         bool bRangeModified = false;    // any range, not only shared formula
         bool bRefSizeChanged = false;
         if ( bHasRefs )
@@ -932,6 +937,9 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
             bRangeModified = false;
             bRefSizeChanged = false;
         }
+
+        bCellStateChanged |= bValChanged;
+
         if ( bOnRefMove )
             bOnRefMove = (bValChanged || (aPos != aOldPos));
             // Cell may reference itself, e.g. ocColumn, ocRow without parameter
@@ -1118,6 +1126,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
 
         delete pOld;
     }
+    return bCellStateChanged;
 }
 
 void ScFormulaCell::UpdateInsertTab(SCTAB nTable)
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 9e13354..86415b3 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1617,10 +1617,11 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
 }
 
 
-void ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
+bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
              SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
              ScDocument* pUndoDoc )
 {
+    bool bUpdated = false;
     if (pItems)
     {
         ScRange aRange( ScAddress( nCol1, nRow1, nTab1 ),
@@ -1632,7 +1633,8 @@ void ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
             {
                 ScFormulaCell* pCell = (ScFormulaCell*) pItems[nIndex].pCell;
                 if( pCell->GetCellType() == CELLTYPE_FORMULA)
-                    pCell->UpdateReference(	eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc );
+                    bUpdated |= pCell->UpdateReference(
+                        eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc );
             }
         }
         else
@@ -1653,7 +1655,8 @@ void ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
                     ScBaseCell* pCell = pItems[i].pCell;
                     if( pCell->GetCellType() == CELLTYPE_FORMULA)
                     {
-                        ((ScFormulaCell*)pCell)->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc );
+                        bUpdated |= ((ScFormulaCell*)pCell)->UpdateReference(
+                            eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc );
                         if ( nRow != pItems[i].nRow )
                             Search( nRow, i );  // Listener removed/inserted?
                     }
@@ -1671,7 +1674,8 @@ void ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
                         // When deleting rows on several sheets, the formula's position may be updated with the first call,
                         // so the undo position must be passed from here.
                         ScAddress aUndoPos( nCol, nRow, nTab );
-                        ((ScFormulaCell*)pCell)->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc, &aUndoPos );
+                        bUpdated |= ((ScFormulaCell*)pCell)->UpdateReference(
+                            eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc, &aUndoPos );
                         if ( nRow != pItems[i].nRow )
                             Search( nRow, i );  // Listener removed/inserted?
                     }
@@ -1679,6 +1683,7 @@ void ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
             }
         }
     }
+    return bUpdated;
 }
 
 
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index f4e71bd..bd25fa3 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1280,6 +1280,7 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
                      SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
                      ScDocument* pUndoDoc, BOOL bIncludeDraw, bool bUpdateNoteCaptionPos )
 {
+    bool bUpdated = false;
     SCCOL i;
     SCCOL iMax;
     if ( eUpdateRefMode == URM_COPY )
@@ -1293,8 +1294,8 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
         iMax = MAXCOL;
     }
     for ( ; i<=iMax; i++)
-        aCol[i].UpdateReference( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2,
-                                    nDx, nDy, nDz, pUndoDoc );
+        bUpdated |= aCol[i].UpdateReference(
+            eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, pUndoDoc );
 
     if ( bIncludeDraw )
         UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos );
@@ -1379,6 +1380,9 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
                                     PAINT_GRID ) );
         }
     }
+
+    if (bUpdated && IsStreamValid())
+        SetStreamValid(false);
 }
 
 void ScTable::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 808f952..bc00fe8 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -177,6 +177,11 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
     DecRecalcLevel( false );
 
     InvalidatePageBreaks();
+
+    if (IsStreamValid())
+        // TODO: In the future we may want to check if the table has been
+        // really modified before setting the stream invalid.
+        SetStreamValid(false);
 }
 
 
@@ -222,6 +227,11 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
     DecRecalcLevel();
 
     InvalidatePageBreaks();
+
+    if (IsStreamValid())
+        // TODO: In the future we may want to check if the table has been
+        // really modified before setting the stream invalid.
+        SetStreamValid(false);
 }
 
 
@@ -309,6 +319,11 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
     DecRecalcLevel();
 
     InvalidatePageBreaks();
+
+    if (IsStreamValid())
+        // TODO: In the future we may want to check if the table has been
+        // really modified before setting the stream invalid.
+        SetStreamValid(false);
 }
 
 
@@ -369,6 +384,11 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
     DecRecalcLevel();
 
     InvalidatePageBreaks();
+
+    if (IsStreamValid())
+        // TODO: In the future we may want to check if the table has been
+        // really modified before setting the stream invalid.
+        SetStreamValid(false);
 }
 
 
@@ -395,6 +415,11 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USH
             ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
         }
     }
+
+    if (IsStreamValid())
+        // TODO: In the future we may want to check if the table has been
+        // really modified before setting the stream invalid.
+        SetStreamValid(false);
 }
 
 
@@ -418,6 +443,11 @@ void ScTable::DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark )
         SfxItemPoolCache aCache( pPool, &aSet );
         ApplySelectionCache( &aCache, rMark );
     }
+
+    if (IsStreamValid())
+        // TODO: In the future we may want to check if the table has been
+        // really modified before setting the stream invalid.
+        SetStreamValid(false);
 }
 
 
commit fb3202dfb4df995fc0cb08be29e24a8923939193
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Mar 7 22:08:43 2011 -0500

    New unit test for sheet stream's validity during reference update.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 57b64c3..dca9b79 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -238,6 +238,11 @@ public:
     void testSheetCopy();
 
     /**
+     * Make sure the sheet streams are invalidated properly.
+     */
+    void testStreamValid();
+
+    /**
      * Test built-in cell functions to make sure their categories and order
      * are correct.
      */
@@ -261,6 +266,7 @@ public:
     CPPUNIT_TEST(testDataPilot);
     CPPUNIT_TEST(testSheetCopy);
     CPPUNIT_TEST(testGraphicsInGroup);
+    CPPUNIT_TEST(testStreamValid);
     CPPUNIT_TEST(testFunctionLists);
     CPPUNIT_TEST(testCVEs);
     CPPUNIT_TEST_SUITE_END();
@@ -880,6 +886,81 @@ void Test::testSheetCopy()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testStreamValid()
+{
+    m_pDoc->InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet1")));
+    m_pDoc->InsertTab(1, OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet2")));
+    m_pDoc->InsertTab(2, OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet3")));
+    m_pDoc->InsertTab(3, OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet4")));
+    CPPUNIT_ASSERT_MESSAGE("We should have 4 sheet instances.", m_pDoc->GetTableCount() == 4);
+
+    OUString a1(RTL_CONSTASCII_USTRINGPARAM("A1"));
+    OUString a2(RTL_CONSTASCII_USTRINGPARAM("A2"));
+    OUString test;
+
+    // Put values into Sheet1.
+    m_pDoc->SetString(0, 0, 0, a1);
+    m_pDoc->SetString(0, 1, 0, a2);
+    m_pDoc->GetString(0, 0, 0, test);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet1.A1", test.equals(a1));
+    m_pDoc->GetString(0, 1, 0, test);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet1.A2", test.equals(a2));
+
+    // Put formulas into Sheet2 to Sheet4 to references values from Sheet1.
+
+    m_pDoc->SetString(0, 0, 1, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A1")));
+    m_pDoc->SetString(0, 1, 1, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A2")));
+    m_pDoc->SetString(0, 0, 2, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A1")));
+    m_pDoc->SetString(0, 0, 3, OUString(RTL_CONSTASCII_USTRINGPARAM("=Sheet1.A2")));
+
+    m_pDoc->GetString(0, 0, 1, test);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet2.A1", test.equals(a1));
+    m_pDoc->GetString(0, 1, 1, test);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet2.A2", test.equals(a2));
+    m_pDoc->GetString(0, 0, 2, test);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet3.A1", test.equals(a1));
+    m_pDoc->GetString(0, 0, 3, test);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected value in Sheet3.A1", test.equals(a2));
+
+    // Set all sheet streams valid after all the initial cell values are in
+    // place. In reality we need to have real XML streams stored in order to
+    // claim they are valid, but we are just testing the flag values here.
+    m_pDoc->SetStreamValid(0, true);
+    m_pDoc->SetStreamValid(1, true);
+    m_pDoc->SetStreamValid(2, true);
+    m_pDoc->SetStreamValid(3, true);
+    CPPUNIT_ASSERT_MESSAGE("Stream is expected to be valid.", m_pDoc->IsStreamValid(0));
+    CPPUNIT_ASSERT_MESSAGE("Stream is expected to be valid.", m_pDoc->IsStreamValid(1));
+    CPPUNIT_ASSERT_MESSAGE("Stream is expected to be valid.", m_pDoc->IsStreamValid(2));
+    CPPUNIT_ASSERT_MESSAGE("Stream is expected to be valid.", m_pDoc->IsStreamValid(3));
+
+    // Now, insert a new row at row 2 position on Sheet1.  This will move cell
+    // A2 downward but cell A1 remains unmoved.
+    m_pDoc->InsertRow(0, 0, MAXCOL, 0, 1, 2);
+    m_pDoc->GetString(0, 0, 0, test);
+    CPPUNIT_ASSERT_MESSAGE("Cell A1 should not have moved.", test.equals(a1));
+    m_pDoc->GetString(0, 3, 0, test);
+    CPPUNIT_ASSERT_MESSAGE("the old cell A2 should now be at A4.", test.equals(a2));
+    const ScBaseCell* pCell = m_pDoc->GetCell(ScAddress(0, 1, 0));
+    CPPUNIT_ASSERT_MESSAGE("Cell A2 should be empty.", pCell == NULL);
+    pCell = m_pDoc->GetCell(ScAddress(0, 2, 0));
+    CPPUNIT_ASSERT_MESSAGE("Cell A3 should be empty.", pCell == NULL);
+
+#if 0 // This currently fails.
+    // After the move, Sheet1, Sheet2, and Sheet4 should have their stream
+    // invalidated, whereas Sheet3's stream should still be valid.
+    CPPUNIT_ASSERT_MESSAGE("Stream should have been invalidated.", !m_pDoc->IsStreamValid(0));
+    CPPUNIT_ASSERT_MESSAGE("Stream should have been invalidated.", !m_pDoc->IsStreamValid(1));
+    CPPUNIT_ASSERT_MESSAGE("Stream should have been invalidated.", !m_pDoc->IsStreamValid(3));
+    CPPUNIT_ASSERT_MESSAGE("Stream should still be valid.", m_pDoc->IsStreamValid(2));
+#endif
+
+    m_pDoc->DeleteTab(3);
+    m_pDoc->DeleteTab(2);
+    m_pDoc->DeleteTab(1);
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFunctionLists()
 {
     const char* aDataBase[] = {
commit 45d2d1678dd9b4d64fdb2ee8242e06d436353b3e
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Mar 7 17:03:32 2011 -0500

    More BOOL to bool conversion.

diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 546c785..a47dd14 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -927,10 +927,10 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
         }
         else
         {
-            bValChanged = FALSE;
+            bValChanged = false;
             pRangeData = NULL;
-            bRangeModified = FALSE;
-            bRefSizeChanged = FALSE;
+            bRangeModified = false;
+            bRefSizeChanged = false;
         }
         if ( bOnRefMove )
             bOnRefMove = (bValChanged || (aPos != aOldPos));
@@ -1043,16 +1043,16 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
                 FALSE;
         }
 
-        BOOL bNeedDirty;
+        bool bNeedDirty = false;
         // NeedDirty bei Aenderungen ausser Copy und Move/Insert ohne RelNames
         if ( bRangeModified || pRangeData || bColRowNameCompile ||
                 (bValChanged && eUpdateRefMode != URM_COPY &&
                  (eUpdateRefMode != URM_MOVE || bHasRelName) &&
                  (!bIsInsert || bHasRelName || bInDeleteUndo ||
                   bRefSizeChanged)) || bOnRefMove)
-            bNeedDirty = TRUE;
+            bNeedDirty = true;
         else
-            bNeedDirty = FALSE;
+            bNeedDirty = false;
         if (pUndoDoc && (bValChanged || pRangeData || bOnRefMove))
         {
             //  Copy the cell to aUndoPos, which is its current position in the document,
@@ -1070,7 +1070,7 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
                 pUndoDoc->PutCell( aUndoPos, pFCell );
             }
         }
-        bValChanged = FALSE;
+        bValChanged = false;
         if ( pRangeData )
         {   // Replace shared formula with own formula
             pDocument->RemoveFromFormulaTree( this );   // update formula count
@@ -1082,13 +1082,13 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
             aComp2.SetGrammar(pDocument->GetGrammar());
             aComp2.UpdateSharedFormulaReference( eUpdateRefMode, aOldPos, r,
                 nDx, nDy, nDz );
-            bValChanged = TRUE;
-            bNeedDirty = TRUE;
+            bValChanged = true;
+            bNeedDirty = true;
         }
         if ( ( bCompile = (bCompile || bValChanged || bRangeModified || bColRowNameCompile) ) != 0 )
         {
             CompileTokenArray( bNewListening ); // kein Listening
-            bNeedDirty = TRUE;
+            bNeedDirty = true;
         }
         if ( !bInDeleteUndo )
         {   // In ChangeTrack Delete-Reject listeners are established in
commit ca6e1763134fbf786c23a1a46b74588084dfe334
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Mar 7 16:40:08 2011 -0500

    BOOL to bool conversion.

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 53d9a71..97df780 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -433,7 +433,7 @@ public:
     ScRangeData* UpdateReference( UpdateRefMode eUpdateRefMode,
                                   const ScAddress& rOldPos, const ScRange&,
                                   SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-                                  BOOL& rChanged, BOOL& rRefSizeChanged );
+                                  bool& rChanged, bool& rRefSizeChanged );
 
     /// Only once for converted shared formulas,
     /// token array has to be compiled afterwards.
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 42a3b6a..546c785 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -912,10 +912,10 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
     if( bHasRefs || bOnRefMove )
     {
         ScTokenArray* pOld = pUndoDoc ? pCode->Clone() : NULL;
-        BOOL bValChanged;
+        bool bValChanged = false;
         ScRangeData* pRangeData;
-        BOOL bRangeModified;            // any range, not only shared formula
-        BOOL bRefSizeChanged;
+        bool bRangeModified = false;    // any range, not only shared formula
+        bool bRefSizeChanged = false;
         if ( bHasRefs )
         {
             ScCompiler aComp(pDocument, aPos, *pCode);
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 71beebc..7e66ca3 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4100,9 +4100,9 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddr
 ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                                  const ScAddress& rOldPos, const ScRange& r,
                                  SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
-                                 BOOL& rChanged, BOOL& rRefSizeChanged )
+                                 bool& rChanged, bool& rRefSizeChanged )
 {
-    rChanged = rRefSizeChanged = FALSE;
+    rChanged = rRefSizeChanged = false;
     if ( eUpdateRefMode == URM_COPY )
     {   // Normally nothing has to be done here since RelRefs are used, also
         // SharedFormulas don't need any special handling, except if they
@@ -4124,7 +4124,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                         SingleDoubleRefModifier( rRef ).Ref() )
                         != UR_NOTHING
                     )
-                    rChanged = TRUE;
+                    rChanged = true;
             }
         }
         // Check for SharedFormulas.
@@ -4164,7 +4164,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                     if (!bValid)
                     {
                         pRangeData = pName;
-                        rChanged = TRUE;
+                        rChanged = true;
                     }
                 }
             }
@@ -4193,7 +4193,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                 {
                     pRangeData = pName;     // maybe need a replacement of shared with own code
 #if ! SC_PRESERVE_SHARED_FORMULAS_IF_POSSIBLE
-                    rChanged = TRUE;
+                    rChanged = true;
 #endif
                 }
             }
@@ -4218,7 +4218,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                                         SingleDoubleRefModifier(
                                             t->GetSingleRef()).Ref())
                                     != UR_NOTHING)
-                                rChanged = TRUE;
+                                rChanged = true;
                         }
                         break;
                     default:
@@ -4231,11 +4231,11 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                                         aPos, r, nDx, nDy, nDz,
                                         t->GetDoubleRef()) != UR_NOTHING)
                             {
-                                rChanged = TRUE;
+                                rChanged = true;
                                 if (rRef.Ref2.nCol - rRef.Ref1.nCol != nCols ||
                                         rRef.Ref2.nRow - rRef.Ref1.nRow != nRows ||
                                         rRef.Ref2.nTab - rRef.Ref1.nTab != nTabs)
-                                    rRefSizeChanged = TRUE;
+                                    rRefSizeChanged = true;
                             }
                         }
                 }
@@ -4269,7 +4269,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                     if ( rRef.IsRelName() )
                     {
                         ScRefUpdate::MoveRelWrap( pDoc, aPos, MAXCOL, MAXROW, aMod.Ref() );
-                        rChanged = TRUE;
+                        rChanged = true;
                     }
                     else
                     {
@@ -4278,7 +4278,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                                     r, nDx, nDy, nDz, aMod.Ref() )
                                 != UR_NOTHING
                             )
-                            rChanged = TRUE;
+                            rChanged = true;
                     }
 #if SC_PRESERVE_SHARED_FORMULAS_IF_POSSIBLE
                     if ( bEasyShared )
@@ -4299,7 +4299,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                     if ( rRef.Ref1.IsRelName() || rRef.Ref2.IsRelName() )
                     {
                         ScRefUpdate::MoveRelWrap( pDoc, aPos, MAXCOL, MAXROW, rRef );
-                        rChanged = TRUE;
+                        rChanged = true;
                     }
                     else
                     {
@@ -4308,12 +4308,12 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
                                 != UR_NOTHING
                             )
                         {
-                            rChanged = TRUE;
+                            rChanged = true;
                             if (rRef.Ref2.nCol - rRef.Ref1.nCol != nCols ||
                                     rRef.Ref2.nRow - rRef.Ref1.nRow != nRows ||
                                     rRef.Ref2.nTab - rRef.Ref1.nTab != nTabs)
                             {
-                                rRefSizeChanged = TRUE;
+                                rRefSizeChanged = true;
 #if SC_PRESERVE_SHARED_FORMULAS_IF_POSSIBLE
                                 bEasyShared = FALSE;
 #endif
@@ -4339,7 +4339,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
             if ( bEasyShared )
                 pRangeData = 0;
             else
-                rChanged = TRUE;
+                rChanged = true;
         }
 #endif
 #undef SC_PRESERVE_SHARED_FORMULAS_IF_POSSIBLE
commit 05ca8133462680b2ad33665a402948ec981d45da
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Mar 6 22:57:37 2011 +0100

    First try of removing "using namespace ::com::sun::star::uno"

diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index 302fe8e..bf8478a 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -67,7 +67,6 @@
 #define XML_LINE_BLTR 1
 
 using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::xml::sax;
 using namespace ::com::sun::star::style;
 using namespace ::com::sun::star::frame;
@@ -78,6 +77,7 @@ using namespace ::formula;
 
 using rtl::OUString;
 using com::sun::star::uno::Reference;
+using com::sun::star::uno::UNO_QUERY;
 
 ScXMLCellImportPropertyMapper::ScXMLCellImportPropertyMapper(
         const UniReference< XMLPropertySetMapper >& rMapper,
commit 62e50b05cb60794dab7d9440044595d0374a7f95
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Mar 7 12:09:37 2011 -0500

    Duh!  I forgot to loop.  Silly me.
    
    This caused saving of a document to ods to cause a crash unconditionally.

diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 0632a5d..048a0b1 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -673,8 +673,9 @@ sal_Int32 SAL_CALL ScNamedRangesObj::getCount() throw(uno::RuntimeException)
         if (pNames)
         {
             ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
-            if (lcl_UserVisibleName(*itr))
-                ++nRet;
+            for (; itr != itrEnd; ++itr)
+                if (lcl_UserVisibleName(*itr))
+                    ++nRet;
         }
     }
     return nRet;
commit a0989369a146cfe2e7d98e0617c4472e8c3f1da9
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Mar 6 22:32:31 2011 +0100

    There were 2 times "using ::rtl::OUString"

diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index 01b4b0e..302fe8e 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -66,7 +66,6 @@
 #define XML_LINE_TLBR 0
 #define XML_LINE_BLTR 1
 
-using ::rtl::OUString;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::xml::sax;
commit 36b14b32711c4bf88eea8a78468ee2f140b2b80a
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Sun Mar 6 16:28:04 2011 +0100

    Fix windows build breakage

diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 385af19..4ced952 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1126,7 +1126,7 @@ namespace {
 
 bool eraseUnusedSharedName(ScRangeName* pRangeName, ScTable* pTab[], USHORT nLevel)
 {
-    ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+    ScRangeName::iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
     for (; itr != itrEnd; ++itr)
     {
         if (!itr->HasType(RT_SHARED))
commit 9c66eed7a8876b24018c1453ea4c4edd8a05d4a6
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 16:02:19 2011 -0500

    GetRangeAtBlock() to findByRange(), favor std::find_if over manual loop.

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 9802d5a..d434f2c 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -190,7 +190,7 @@ public:
     ScRangeName(ScDocument* pDoc = NULL);
     ScRangeName(const ScRangeName& r);
 
-    SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock(const ScRange& rRange) const;
+    SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange& rRange) const;
     SC_DLLPUBLIC ScRangeData* findByName(const rtl::OUString& rName);
     SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
     ScRangeData* findByUpperName(const rtl::OUString& rName);
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 13ddba7..51906fd 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -108,7 +108,7 @@ const ScRangeData* ScDocument::GetRangeAtBlock( const ScRange& rBlock, String* p
     const ScRangeData* pData = NULL;
     if ( pRangeName )
     {
-        pData = pRangeName->GetRangeAtBlock( rBlock );
+        pData = pRangeName->findByRange( rBlock );
         if (pData && pName)
             *pName = pData->GetName();
     }
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index b64b094..1166297 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -50,6 +50,7 @@
 
 using namespace formula;
 using ::std::pair;
+using ::std::unary_function;
 using ::rtl::OUString;
 
 //========================================================================
@@ -662,69 +663,103 @@ bool operator<(const ScRangeData& left, const ScRangeData& right)
     return left.GetName() < right.GetName();
 }
 
+namespace {
+
+/**
+ * Predicate to check if the name references the specified range.
+ */
+class MatchByRange : public unary_function<ScRangeData, bool>
+{
+    const ScRange& mrRange;
+public:
+    MatchByRange(const ScRange& rRange) : mrRange(rRange) {}
+    bool operator() (const ScRangeData& r) const
+    {
+        return r.IsRangeAtBlock(mrRange);
+    }
+};
+
+class MatchByName : public unary_function<ScRangeData, bool>
+{
+    const OUString& mrName;
+public:
+    MatchByName(const OUString& rName) : mrName(rName) {}
+    bool operator() (const ScRangeData& r) const
+    {
+        return mrName.equals(r.GetName());
+    }
+};
+
+class MatchByUpperName : public unary_function<ScRangeData, bool>
+{
+    const OUString& mrName;
+public:
+    MatchByUpperName(const OUString& rName) : mrName(rName) {}
+    bool operator() (const ScRangeData& r) const
+    {
+        return mrName.equals(r.GetUpperName());
+    }
+};
+
+class MatchByIndex : public unary_function<ScRangeData, bool>
+{
+    USHORT mnIndex;
+public:
+    MatchByIndex(USHORT nIndex) : mnIndex(nIndex) {}
+    bool operator() (const ScRangeData& r) const
+    {
+        return mnIndex == r.GetIndex();
+    }
+};
+
+}
+
 ScRangeName::ScRangeName(ScDocument* pDoc) :
     mpDoc(pDoc) {}
 
 ScRangeName::ScRangeName(const ScRangeName& r) :
     maData(r.maData), mpDoc(r.mpDoc), mnSharedMaxIndex(r.mnSharedMaxIndex) {}
 
-const ScRangeData* ScRangeName::GetRangeAtBlock(const ScRange& rRange) const
+const ScRangeData* ScRangeName::findByRange(const ScRange& rRange) const
 {
-    DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
-    for (; itr != itrEnd; ++itr)
-    {
-        if (itr->IsRangeAtBlock(rRange))
-            return &(*itr);
-    }
-    return NULL;
+    DataType::const_iterator itr = std::find_if(
+        maData.begin(), maData.end(), MatchByRange(rRange));
+    return itr == maData.end() ? NULL : &(*itr);
 }
 
 ScRangeData* ScRangeName::findByName(const OUString& rName)
 {
-    DataType::iterator itr = maData.begin(), itrEnd = maData.end();
-    for (; itr != itrEnd; ++itr)
-    {
-        String aName;
-        itr->GetName(aName);
-        if (rName.equals(aName))
-            return &(*itr);
-    }
-    return NULL;
+    DataType::iterator itr = std::find_if(
+        maData.begin(), maData.end(), MatchByName(rName));
+    return itr == maData.end() ? NULL : &(*itr);
 }
 
 const ScRangeData* ScRangeName::findByName(const OUString& rName) const
 {
-    DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
-    for (; itr != itrEnd; ++itr)
-    {
-        String aName;
-        itr->GetName(aName);
-        if (rName.equals(aName))
-            return &(*itr);
-    }
-    return NULL;
+    DataType::const_iterator itr = std::find_if(
+        maData.begin(), maData.end(), MatchByName(rName));
+    return itr == maData.end() ? NULL : &(*itr);
 }
 
 ScRangeData* ScRangeName::findByUpperName(const OUString& rName)
 {
-    DataType::iterator itr = maData.begin(), itrEnd = maData.end();
-    for (; itr != itrEnd; ++itr)
-    {
-        if (rName.equals(itr->GetUpperName()))
-            return &(*itr);
-    }
-    return NULL;
+    DataType::iterator itr = std::find_if(
+        maData.begin(), maData.end(), MatchByUpperName(rName));
+    return itr == maData.end() ? NULL : &(*itr);
 }
 
 const ScRangeData* ScRangeName::findByUpperName(const OUString& rName) const
 {
-    DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
-    for (; itr != itrEnd; ++itr)
-    {
-        if (rName.equals(itr->GetUpperName()))
-            return &(*itr);
-    }
-    return NULL;
+    DataType::const_iterator itr = std::find_if(
+        maData.begin(), maData.end(), MatchByUpperName(rName));
+    return itr == maData.end() ? NULL : &(*itr);
+}
+
+ScRangeData* ScRangeName::findByIndex(USHORT i)
+{
+    DataType::iterator itr = std::find_if(
+        maData.begin(), maData.end(), MatchByIndex(i));
+    return itr == maData.end() ? NULL : &(*itr);
 }
 
 void ScRangeName::UpdateReference(
@@ -756,15 +791,6 @@ void ScRangeName::UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY)
         itr->UpdateGrow(rArea, nGrowX, nGrowY);
 }
 
-ScRangeData* ScRangeName::findByIndex(USHORT i)
-{
-    DataType::iterator itr = maData.begin(), itrEnd = maData.end();
-    for (; itr != itrEnd; ++itr)
-        if (itr->GetIndex() == i)
-            return &(*itr);
-    return NULL;
-}
-
 sal_uInt16 ScRangeName::GetSharedMaxIndex()
 {
     return mnSharedMaxIndex;
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 60b42bc..eaec8e0 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1466,7 +1466,7 @@ XclExpWebQueryBuffer::XclExpWebQueryBuffer( const XclExpRoot& rRoot )
                     String aRangeName;
                     ScRange aScDestRange;
                     ScUnoConversion::FillScRange( aScDestRange, aDestRange );
-                    if( const ScRangeData* pRangeData = rRoot.GetNamedRanges().GetRangeAtBlock( aScDestRange ) )
+                    if( const ScRangeData* pRangeData = rRoot.GetNamedRanges().findByRange( aScDestRange ) )
                     {
                         aRangeName = pRangeData->GetName();
                     }
commit c0fe1adf4688d0b384976990de6409cb5f3adff5
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 15:32:27 2011 -0500

    Fixed a build breakage.

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 8e850e3..f4e71bd 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1446,7 +1446,7 @@ void ScTable::SetTabNo(SCTAB nNewTab)
 }
 
 BOOL ScTable::IsRangeNameInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                               size_t nIndex) const
+                               USHORT nIndex) const
 {
     BOOL bInUse = FALSE;
     for (SCCOL i = nCol1; !bInUse && (i <= nCol2) && (ValidCol(i)); i++)
commit 1b45c153f1712a839bb962e000b5bb147c95ca8a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 14:47:31 2011 -0500

    Changed ScRangeData's index back to USHORT for now.

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 4b7d657..110c848 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -459,7 +459,7 @@ public:
     void			UpdateRenameTab(SCTAB nTable, const String& rName);
     BOOL 			TestTabRefAbs(SCTAB nTable);
     void			UpdateCompile( BOOL bForceIfNameInUse = FALSE );
-    BOOL			IsRangeNameInUse(size_t nIndex) const;
+    BOOL			IsRangeNameInUse(USHORT nIndex) const;
     void            FindRangeNamesInUse(std::set<USHORT>& rIndexes) const;
     void 			ReplaceRangeNamesInUse( const ScRangeData::IndexMap& rMap );
     BOOL			IsSubTotal() const 						{ return bSubTotal; }
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index b6260f3..35d26b0 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -299,7 +299,7 @@ public:
     void        UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
 
     void        SetTabNo(SCTAB nNewTab);
-    bool        IsRangeNameInUse(SCROW nRow1, SCROW nRow2, size_t nIndex) const;
+    bool    IsRangeNameInUse(SCROW nRow1, SCROW nRow2, sal_uInt16 nIndex) const;
     void        FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
     void        ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScRangeData::IndexMap& rMap );
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index ce0809b..25d423a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -479,7 +479,7 @@ public:
     void		UpdateCompile( BOOL bForceIfNameInUse = FALSE );
     void		SetTabNo(SCTAB nNewTab);
     BOOL		IsRangeNameInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                                 size_t nIndex) const;
+                                 USHORT nIndex) const;
     void        FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                  std::set<USHORT>& rIndexes) const;
     void 		ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 9db1d64..42a3b6a 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1529,7 +1529,7 @@ BOOL lcl_IsRangeNameInUse(size_t nIndex, ScTokenArray* pCode, ScRangeName* pName
     return FALSE;
 }
 
-BOOL ScFormulaCell::IsRangeNameInUse(size_t nIndex) const
+BOOL ScFormulaCell::IsRangeNameInUse(USHORT nIndex) const
 {
     return lcl_IsRangeNameInUse( nIndex, pCode, pDocument->GetRangeName() );
 }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 6f47ee5..9e13354 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1841,7 +1841,7 @@ void ScColumn::SetTabNo(SCTAB nNewTab)
 }
 
 
-bool ScColumn::IsRangeNameInUse(SCROW nRow1, SCROW nRow2, size_t nIndex) const
+bool ScColumn::IsRangeNameInUse(SCROW nRow1, SCROW nRow2, sal_uInt16 nIndex) const
 {
     bool bInUse = false;
     if (pItems)
commit f6988dcce4e8da9c95741d3750d66be520162642
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 14:21:56 2011 -0500

    Renamed FindIndex to findByIndex to be consistent with findByName.

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 85e64fa..9802d5a 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -195,12 +195,12 @@ public:
     SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
     ScRangeData* findByUpperName(const rtl::OUString& rName);
     const ScRangeData* findByUpperName(const rtl::OUString& rName) const;
+    SC_DLLPUBLIC ScRangeData* findByIndex(USHORT i);
     void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange& rRange,
                          SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
     void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0);
     void UpdateTranspose(const ScRange& rSource, const ScAddress& rDest);
     void UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY);
-    SC_DLLPUBLIC ScRangeData* FindIndex(USHORT i);
     sal_uInt16 GetSharedMaxIndex();
     void SetSharedMaxIndex(sal_uInt16 nInd);
 
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 0e9e9d6..0089d62 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -784,7 +784,7 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
             }
             else if ( t->GetType() == svIndex )
             {
-                ScRangeData* pRangeData = rDoc.GetRangeName()->FindIndex( t->GetIndex() );
+                ScRangeData* pRangeData = rDoc.GetRangeName()->findByIndex( t->GetIndex() );
                 if( pRangeData )
                 {
                     if( pRangeData->HasReferences() )
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 2c71c3a..9db1d64 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1361,7 +1361,7 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD
     {
         if( t->GetOpCode() == ocName )
         {
-            ScRangeData* pName = pDocument->GetRangeName()->FindIndex( t->GetIndex() );
+            ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
             if (pName)
             {
                 if (pName->IsModified())
@@ -1446,7 +1446,7 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY
     {
         if( t->GetOpCode() == ocName )
         {
-            ScRangeData* pName = pDocument->GetRangeName()->FindIndex( t->GetIndex() );
+            ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
             if (pName)
             {
                 if (pName->IsModified())
@@ -1519,7 +1519,7 @@ BOOL lcl_IsRangeNameInUse(size_t nIndex, ScTokenArray* pCode, ScRangeName* pName
             else
             {
                 //  RangeData kann Null sein in bestimmten Excel-Dateien
-                ScRangeData* pSubName = pNames->FindIndex(p->GetIndex());
+                ScRangeData* pSubName = pNames->findByIndex(p->GetIndex());
                 if (pSubName && lcl_IsRangeNameInUse(nIndex,
                                     pSubName->GetCode(), pNames))
                     return TRUE;
@@ -1543,7 +1543,7 @@ void lcl_FindRangeNamesInUse(std::set<USHORT>& rIndexes, ScTokenArray* pCode, Sc
             USHORT nTokenIndex = p->GetIndex();
             rIndexes.insert( nTokenIndex );
 
-            ScRangeData* pSubName = pNames->FindIndex(p->GetIndex());
+            ScRangeData* pSubName = pNames->findByIndex(p->GetIndex());
             if (pSubName)
                 lcl_FindRangeNamesInUse(rIndexes, pSubName->GetCode(), pNames);
         }
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 272090a..c2a3f5f 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -84,7 +84,7 @@ BOOL lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, USHORT nRecursion
                 case svIndex:
                 {
                     if( t->GetOpCode() == ocName )      // DB areas always absolute
-                        if( ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( t->GetIndex() ) )
+                        if( ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex( t->GetIndex() ) )
                             if( (nRecursion < 42) && lcl_HasRelRef( pDoc, pRangeData->GetCode(), nRecursion + 1 ) )
                                 return TRUE;
                 }
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a98e207..385af19 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1003,7 +1003,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
                     {
                         ScRangeData* pData = new ScRangeData( *itr );
                         pData->SetDocument(this);
-                        if ( pRangeName->FindIndex( pData->GetIndex() ) )
+                        if ( pRangeName->findByIndex( pData->GetIndex() ) )
                             pData->SetIndex(0);		// need new index, done in Insert
                         if (!pRangeName->insert(pData))
                         {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index d8e5bc3..99779db 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1864,7 +1864,7 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
         {
             ScRangeData* pData = new ScRangeData( *itr );
             pData->SetDocument(this);
-            if ( pRangeName->FindIndex( pData->GetIndex() ) )
+            if ( pRangeName->findByIndex( pData->GetIndex() ) )
                 pData->SetIndex(0);     // need new index, done in Insert
             if ( pRangeName->insert(pData) )
             {
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index d762c8c..08cb3cc 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -702,7 +702,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
         }
         else if (t->GetOpCode() == ocName)
         {
-            ScRangeData* pName = pDocument->GetRangeName()->FindIndex( t->GetIndex() );
+            ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
             if (pName && pName->IsReference(aRange))
             {
                 bRef = TRUE;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 64a50a5..71beebc 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3887,7 +3887,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula, const String& r
 
 BOOL ScCompiler::HandleRange()
 {
-    ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( pToken->GetIndex() );
+    ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex( pToken->GetIndex() );
     if (pRangeData)
     {
         USHORT nErr = pRangeData->GetErrCode();
@@ -4012,7 +4012,7 @@ BOOL ScCompiler::HasModifiedRange()
         OpCode eOpCode = t->GetOpCode();
         if ( eOpCode == ocName )
         {
-             ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+             ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex());
 
             if (pRangeData && pRangeData->IsModified())
                 return TRUE;
@@ -4135,7 +4135,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
         {
             if( j->GetOpCode() == ocName )
             {
-                ScRangeData* pName = pDoc->GetRangeName()->FindIndex( j->GetIndex() );
+                ScRangeData* pName = pDoc->GetRangeName()->findByIndex( j->GetIndex() );
                 if (pName && pName->HasType(RT_SHARED))
                     pRangeData = pName;
             }
@@ -4188,7 +4188,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
         {
             if( t->GetOpCode() == ocName )
             {
-                ScRangeData* pName = pDoc->GetRangeName()->FindIndex( t->GetIndex() );
+                ScRangeData* pName = pDoc->GetRangeName()->findByIndex( t->GetIndex() );
                 if (pName && pName->HasType(RT_SHAREDMOD))
                 {
                     pRangeData = pName;     // maybe need a replacement of shared with own code
@@ -4481,7 +4481,7 @@ ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, BOOL bIsName )
         {
             if (!bIsName)
             {
-                ScRangeData* pName = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+                ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
                 if (pName && pName->HasType(RT_SHAREDMOD))
                     pRangeData = pName;
             }
@@ -4592,7 +4592,7 @@ ScRangeData* ScCompiler::UpdateDeleteTab(SCTAB nTable, BOOL /* bIsMove */, BOOL
         {
             if (!bIsName)
             {
-                ScRangeData* pName = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+                ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
                 if (pName && pName->HasType(RT_SHAREDMOD))
                     pRangeData = pName;
             }
@@ -4802,7 +4802,7 @@ ScRangeData* ScCompiler::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab,
         {
             if (!bIsName)
             {
-                ScRangeData* pName = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+                ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
                 if (pName && pName->HasType(RT_SHAREDMOD))
                     pRangeData = pName;
             }
@@ -5056,7 +5056,7 @@ void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken
     {
         case ocName:
         {
-            ScRangeData* pData = pDoc->GetRangeName()->FindIndex(_pTokenP->GetIndex());
+            ScRangeData* pData = pDoc->GetRangeName()->findByIndex(_pTokenP->GetIndex());
             if (pData)
             {
                 if (pData->HasType(RT_SHARED))
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index a36d523..b64b094 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -666,7 +666,7 @@ ScRangeName::ScRangeName(ScDocument* pDoc) :
     mpDoc(pDoc) {}
 
 ScRangeName::ScRangeName(const ScRangeName& r) :
-    maData(r.maData), mpDoc(r.mpDoc) {}
+    maData(r.maData), mpDoc(r.mpDoc), mnSharedMaxIndex(r.mnSharedMaxIndex) {}
 
 const ScRangeData* ScRangeName::GetRangeAtBlock(const ScRange& rRange) const
 {
@@ -756,7 +756,7 @@ void ScRangeName::UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY)
         itr->UpdateGrow(rArea, nGrowX, nGrowY);
 }
 
-ScRangeData* ScRangeName::FindIndex(USHORT i)
+ScRangeData* ScRangeName::findByIndex(USHORT i)
 {
     DataType::iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
@@ -845,7 +845,7 @@ void ScRangeName::clear()
 
 bool ScRangeName::operator== (const ScRangeName& r) const
 {
-    return maData == r.maData;
+    return maData == r.maData && mpDoc == r.mpDoc && mnSharedMaxIndex == r.mnSharedMaxIndex;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx
index f9e9327..e60983b 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -382,7 +382,7 @@ sal_uInt16 XclExpNameManagerImpl::InsertName( USHORT nScNameIdx )
 {
     sal_uInt16 nNameIdx = FindNameIdx( maNameMap, nScNameIdx );
     if( nNameIdx == 0 )
-        if( const ScRangeData* pRangeData = GetNamedRanges().FindIndex( nScNameIdx ) )
+        if( const ScRangeData* pRangeData = GetNamedRanges().findByIndex( nScNameIdx ) )
             nNameIdx = CreateName( *pRangeData );
     return nNameIdx;
 }
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 78a2b90..b814d02 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -699,7 +699,7 @@ const ScTokenArray* XclTokenArrayHelper::GetSharedFormula( const XclRoot& rRoot,
     if( rScTokArr.GetLen() == 1 )
         if( const FormulaToken* pScToken = rScTokArr.GetArray()[ 0 ] )
             if( pScToken->GetOpCode() == ocName )
-                if( ScRangeData* pData = rRoot.GetNamedRanges().FindIndex( pScToken->GetIndex() ) )
+                if( ScRangeData* pData = rRoot.GetNamedRanges().findByIndex( pScToken->GetIndex() ) )
                     if( pData->HasType( RT_SHARED ) )
                         return pData->GetCode();
     return 0;
commit 187336c1bf1de45b4739e24cc1484ea5eb9c89c2
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 14:07:14 2011 -0500

    Removed the Insert() method; let's use insert() across the board.

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index a343607..85e64fa 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -84,7 +84,6 @@ private:
     SCROW           mnMaxRow;
     SCCOL           mnMaxCol;
 
-    friend class ScRangeName;
     ScRangeData( USHORT nIndex );
 public:
     typedef ::std::map<sal_uInt16, sal_uInt16> IndexMap;
@@ -212,7 +211,6 @@ public:
     SC_DLLPUBLIC size_t size() const;
     bool empty() const;
     SC_DLLPUBLIC bool insert(ScRangeData* p);
-    SC_DLLPUBLIC bool Insert(ScRangeData* p);
     void erase(const ScRangeData& r);
     void erase(const iterator& itr);
     void clear();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7c19673..57b64c3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -417,7 +417,7 @@ void Test::testNamedRange()
     ScRangeData* pNew = new ScRangeData(m_pDoc,
         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Divisor")),
         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$A$1:$A$1048576")), aA1, 0, formula::FormulaGrammar::GRAM_PODF_A1);
-    bool bSuccess = pNewRanges->Insert(pNew);
+    bool bSuccess = pNewRanges->insert(pNew);
     CPPUNIT_ASSERT_MESSAGE ("insertion failed", bSuccess);
 
     m_pDoc->SetRangeName(pNewRanges);
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 7b8e91d..a98e207 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1005,7 +1005,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
                         pData->SetDocument(this);
                         if ( pRangeName->FindIndex( pData->GetIndex() ) )
                             pData->SetIndex(0);		// need new index, done in Insert
-                        if (!pRangeName->Insert(pData))
+                        if (!pRangeName->insert(pData))
                         {
                             OSL_FAIL("can't insert name");     // shouldn't happen
                             delete pData;
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 6d1a013..a36d523 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -828,11 +828,6 @@ bool ScRangeName::insert(ScRangeData* p)
     return r.second;
 }
 
-bool ScRangeName::Insert(ScRangeData* p)
-{
-    return insert(p);
-}
-
 void ScRangeName::erase(const ScRangeData& r)
 {
     maData.erase(r);
diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx
index 72a6b8b..46fbafb 100644
--- a/sc/source/filter/excel/namebuff.cxx
+++ b/sc/source/filter/excel/namebuff.cxx
@@ -129,7 +129,7 @@ void ShrfmlaBuffer::Store( const ScRange& rRange, const ScTokenArray& rToken )
     pData->SetMaxCol(rMaxPos.Col());
     pData->SetMaxRow(rMaxPos.Row());
     pData->SetIndex( static_cast< USHORT >( mnCurrIdx ) );
-    pExcRoot->pIR->GetNamedRanges().Insert( pData );
+    pExcRoot->pIR->GetNamedRanges().insert( pData );
     index_hash[rRange.aStart] = static_cast< USHORT >( mnCurrIdx );
     index_list.push_front (rRange);
     ++mnCurrIdx;
diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx
index d0d7e0d..03a49ac 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -222,7 +222,7 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) :
         ScRangeData* pData = new ScRangeData( GetDocPtr(), maScName, *pTokArr, ScAddress(), nNameType );
         pData->GuessPosition();             // calculate base position for relative refs
         pData->SetIndex( nXclNameIdx );     // used as unique identifier in formulas
-        rRangeNames.Insert( pData );        // takes ownership of pData
+        rRangeNames.insert( pData );        // takes ownership of pData
         if( nXclTab != EXC_NAME_GLOBAL )
         {
             if (GetBiff() == EXC_BIFF8)
diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index f2080cb..b717b50 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -132,7 +132,7 @@ void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const String& rName, const
     ScTokenArray aTokArray;
     aTokArray.AddDoubleReference( aRefData );
     ScRangeData* pRangeData = new ScRangeData( pDoc, rName, aTokArray );
-    if( !pDoc->GetRangeName()->Insert( pRangeData ) )
+    if( !pDoc->GetRangeName()->insert( pRangeData ) )
         delete pRangeData;
 }
 
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 970e247..76c7f51 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -513,7 +513,7 @@ void LotusRangeList::Append( LotusRange* pLR, const String& rName )
     ScRangeData*	pData = new ScRangeData(
         pLotusRoot->pDoc, rName, aTokArray );
 
-    pLotusRoot->pScRangeName->Insert( pData );
+    pLotusRoot->pScRangeName->insert( pData );
 
     pLR->SetId( nIdCnt );
 
@@ -575,7 +575,7 @@ void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rC
     pData->SetIndex( nIntCount );
     nIntCount++;
 
-    pLotusRoot->pScRangeName->Insert( pData );
+    pLotusRoot->pScRangeName->insert( pData );
 }
 
 
@@ -639,7 +639,7 @@ BOOL RangeNameBufferWK3::FindAbs( const String& rRef, UINT16& rIndex )
                 pData->SetIndex( rIndex );
                 nIntCount++;
 
-                pLotusRoot->pScRangeName->Insert( pData );
+                pLotusRoot->pScRangeName->insert( pData );
             }
 
             return TRUE;
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index b518df4..70a2df1 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -408,7 +408,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNu
                 {
                     ScRangeData* pData = new ScRangeData( mpDoc, *pE->pName,
                         ScAddress( nCol, nRow, nTab ) );
-                    pRangeNames->Insert( pData );
+                    pRangeNames->insert( pData );
                 }
             }
         }
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx
index 54970f5..f0f79c2 100644
--- a/sc/source/filter/starcalc/scflt.cxx
+++ b/sc/source/filter/starcalc/scflt.cxx
@@ -1112,9 +1112,9 @@ void Sc10Import::ImportNameCollection()
     for (USHORT i = 0; i < pNameCollection->GetCount(); i++)
     {
         Sc10NameData*	pName = pNameCollection->At( i );
-        pRN->Insert( new ScRangeData(	pDoc,
-                                        SC10TOSTRING( pName->Name ),
-                                        SC10TOSTRING( pName->Reference ) ) );
+        pRN->insert(
+            new ScRangeData(
+                pDoc, SC10TOSTRING(pName->Name), SC10TOSTRING(pName->Reference)));
     }
 }
 
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7cd88f7..0ab3980 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1678,7 +1678,7 @@ void ScPosWnd::DoEnter()
                         String aContent;
                         aSelection.Format( aContent, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
                         ScRangeData* pNew = new ScRangeData( pDoc, aText, aContent, aCursor );
-                        if ( aNewRanges.Insert(pNew) )
+                        if ( aNewRanges.insert(pNew) )
                         {
                             ScDocFunc aFunc(*pDocShell);
                             aFunc.ModifyRangeNames( aNewRanges );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index e251ceb..e9de219 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4581,7 +4581,7 @@ void ScDocFunc::CreateOneName( ScRangeName& rList,
             {
                 ScRangeData* pData = new ScRangeData( pDoc, aName, aContent,
                         ScAddress( nPosX, nPosY, nTab));
-                if (!rList.Insert(pData))
+                if (!rList.insert(pData))
                 {
                     OSL_FAIL("nanu?");
                     delete pData;
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 21db698..b467ab8 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -440,7 +440,7 @@ IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
                     else
                         pSaveObj->Clear();
 
-                    if ( !aLocalRangeName.Insert( pNewEntry ) )
+                    if ( !aLocalRangeName.insert( pNewEntry ) )
                         delete pNewEntry;
 
                     UpdateNames();
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index bec356b..0632a5d 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -569,7 +569,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName,
             // GRAM_PODF_A1 for API compatibility.
             ScRangeData* pNew = new ScRangeData( pDoc, aName, aContent,
                                                 aPos, nNewType,formula::FormulaGrammar::GRAM_PODF_A1 );
-            if ( pNewRanges->Insert(pNew) )
+            if ( pNewRanges->insert(pNew) )
             {
                 ScDocFunc aFunc(*pDocShell);
                 aFunc.SetNewRangeNames(pNewRanges, mbModifyAndBroadcast);
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index b5ea95d..db3c302 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2941,7 +2941,7 @@ BOOL ScViewFunc::InsertName( const String& rName, const String& rSymbol,
             pList->erase(*pData);
         }
 
-        if ( pList->Insert( pNewEntry ) )
+        if ( pList->insert( pNewEntry ) )
         {
             pNewEntry = NULL;	// nicht loeschen
             bOk = TRUE;
commit 8bc312adf347ea3b18512034bdc8db270c4c3e46
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 13:50:54 2011 -0500

    Finally removed the old ScRangeName code for good!
    
    Plus some build breakage fix.

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 0abb705..a343607 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -67,7 +67,7 @@ typedef USHORT RangeType;
 
 class ScTokenArray;
 
-class ScRangeData : public ScDataObject
+class ScRangeData
 {
 private:
     String			aName;
@@ -106,10 +106,7 @@ public:
                                 // rTarget is ABSPOS jump label
                     ScRangeData(const ScRangeData& rScRangeData);
 
-    SC_DLLPUBLIC virtual        ~ScRangeData();
-
-
-    virtual	ScDataObject* Clone() const;
+    SC_DLLPUBLIC ~ScRangeData();
 
     BOOL			operator== (const ScRangeData& rData) const;
 
@@ -177,12 +174,8 @@ extern "C" int SAL_CALL ScRangeData_QsortNameCompare( const void*, const void* )
                             { return ScRangeData_QsortNameCompare(a,b); }
 #endif
 
-#define NEW_RANGE_NAME 1
-
 bool operator< (const ScRangeData& left, const ScRangeData& right);
 
-#if NEW_RANGE_NAME
-
 class ScRangeName
 {
 private:
@@ -226,52 +219,6 @@ public:
     bool operator== (const ScRangeName& r) const;
 };
 
-#else
-
-class ScRangeName : public ScSortedCollection
-{
-private:
-    ScDocument* pDoc;
-    USHORT nSharedMaxIndex;
-
-    using ScSortedCollection::Clone;    // calcwarnings: shouldn't be used
-
-public:
-    ScRangeName(USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE,
-                ScDocument* pDocument = NULL) :
-        ScSortedCollection	( nLim, nDel, bDup ),
-        pDoc				( pDocument ),
-        nSharedMaxIndex		( 1 ) {}			// must not be 0!!
-
-    ScRangeName(const ScRangeName& rScRangeName, ScDocument* pDocument);
-
-    virtual	ScDataObject*     Clone(ScDocument* pDocP) const
-                             { return new ScRangeName(*this, pDocP); }
-    ScRangeData*			operator[]( const USHORT nIndex) const
-                             { return (ScRangeData*)At(nIndex); }
-    virtual	short			Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
-    virtual	BOOL			IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const;
-
-    SC_DLLPUBLIC ScRangeData*			GetRangeAtBlock( const ScRange& ) const;
-
-    SC_DLLPUBLIC BOOL					SearchName( const String& rName, USHORT& rPos ) const;
-                            // SearchNameUpper must be called with an upper-case search string
-    BOOL					SearchNameUpper( const String& rUpperName, USHORT& rPos ) const;
-    void					UpdateReference(UpdateRefMode eUpdateRefMode,
-                                const ScRange& rRange,
-                                SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
-    void 					UpdateTabRef(SCTAB nTable, USHORT nFlag, SCTAB nNewTable = 0);
-    void					UpdateTranspose( const ScRange& rSource, const ScAddress& rDest );
-    void					UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
-    virtual	BOOL			Insert(ScDataObject* pScDataObject);
-    SC_DLLPUBLIC ScRangeData* 			FindIndex(USHORT nIndex);
-    USHORT 					GetSharedMaxIndex()				{ return nSharedMaxIndex; }
-    void 					SetSharedMaxIndex(USHORT nInd)	{ nSharedMaxIndex = nInd; }
-    USHORT 					GetEntryIndex();
-};
-
-#endif
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9435b2e..d8e5bc3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1838,7 +1838,6 @@ void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
 
 void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames)
 {
-    sal_uInt16 nClipRangeNameCount = pClipDoc->pRangeName->GetCount();
     ScClipRangeNameData aClipRangeNames;
 
     ScRangeName::const_iterator itr = pClipDoc->pRangeName->begin();
@@ -1852,12 +1851,11 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
             A proper solution would ask the user how to proceed.
             The adjustment of the indices in the formulas is done later.
         */
-        ScRangeData* pClipRangeData = (*pClipDoc->pRangeName)[i];
-        USHORT k;
-        if ( pRangeName->SearchName( itr->GetName(), k ) )
+        const ScRangeData* pExistingData = pRangeName->findByName(itr->GetName());
+        if (pExistingData)
         {
             USHORT nOldIndex = itr->GetIndex();
-            USHORT nNewIndex = ((*pRangeName)[k])->GetIndex();
+            USHORT nNewIndex = pExistingData->GetIndex();
             aClipRangeNames.insert(nOldIndex, nNewIndex);
             if ( !aClipRangeNames.mbReplace )
                 aClipRangeNames.mbReplace = ( nOldIndex != nNewIndex );
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 09ec3b1..6d1a013 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -167,7 +167,6 @@ ScRangeData::ScRangeData( ScDocument* pDok,
 }
 
 ScRangeData::ScRangeData(const ScRangeData& rScRangeData) :
-    ScDataObject(),
     aName 	(rScRangeData.aName),
     aUpperName  (rScRangeData.aUpperName),
     pCode		(rScRangeData.pCode ? rScRangeData.pCode->Clone() : new ScTokenArray()),		// echte Kopie erzeugen (nicht copy-ctor)
@@ -185,11 +184,6 @@ ScRangeData::~ScRangeData()
     delete pCode;
 }
 
-ScDataObject* ScRangeData::Clone() const
-{
-    return new ScRangeData(*this);
-}
-
 void ScRangeData::GuessPosition()
 {
     //	setzt eine Position, mit der alle relative Referenzen bei CalcAbsIfRel
@@ -663,8 +657,6 @@ ScRangeData_QsortNameCompare( const void* p1, const void* p2 )
             (*(const ScRangeData**)p2)->GetName() );
 }
 
-#if NEW_RANGE_NAME
-
 bool operator<(const ScRangeData& left, const ScRangeData& right)
 {
     return left.GetName() < right.GetName();
@@ -861,134 +853,4 @@ bool ScRangeName::operator== (const ScRangeName& r) const
     return maData == r.maData;
 }
 
-#else
-
-ScRangeName::ScRangeName(const ScRangeName& rScRangeName, ScDocument* pDocument) :
-                ScSortedCollection ( rScRangeName ),
-                pDoc ( pDocument ),
-                nSharedMaxIndex (rScRangeName.nSharedMaxIndex)
-{
-    for (USHORT i = 0; i < nCount; i++)
-    {
-        ((ScRangeData*)At(i))->SetDocument(pDocument);
-        ((ScRangeData*)At(i))->SetIndex(((ScRangeData*)rScRangeName.At(i))->GetIndex());
-    }
-}
-
-short ScRangeName::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const
-{
-    USHORT i1 = ((ScRangeData*)pKey1)->GetIndex();
-    USHORT i2 = ((ScRangeData*)pKey2)->GetIndex();
-    return (short) i1 - (short) i2;
-}
-
-BOOL ScRangeName::SearchNameUpper( const String& rUpperName, USHORT& rIndex ) const
-{
-    // SearchNameUpper must be called with an upper-case search string
-
-    USHORT i = 0;
-    while (i < nCount)
-    {
-        if ( ((*this)[i])->GetUpperName() == rUpperName )
-        {
-            rIndex = i;
-            return TRUE;
-        }
-        i++;
-    }
-    return FALSE;
-}
-
-BOOL ScRangeName::SearchName( const String& rName, USHORT& rIndex ) const
-{
-    if ( nCount > 0 )
-        return SearchNameUpper( ScGlobal::pCharClass->upper( rName ), rIndex );
-    else
-        return FALSE;
-}
-
-void ScRangeName::UpdateReference(	UpdateRefMode eUpdateRefMode,
-                                    const ScRange& rRange,
-                                    SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
-{
-    for (USHORT i=0; i<nCount; i++)
-        ((ScRangeData*)pItems[i])->UpdateReference(eUpdateRefMode, rRange,
-                                                   nDx, nDy, nDz);
-}
-
-void ScRangeName::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest )
-{
-    for (USHORT i=0; i<nCount; i++)
-        ((ScRangeData*)pItems[i])->UpdateTranspose( rSource, rDest );
-}
-
-void ScRangeName::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
-{
-    for (USHORT i=0; i<nCount; i++)
-        ((ScRangeData*)pItems[i])->UpdateGrow( rArea, nGrowX, nGrowY );
-}
-
-BOOL ScRangeName::IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const
-{
-    return *(ScRangeData*)pKey1 == *(ScRangeData*)pKey2;
-}
-
-BOOL ScRangeName::Insert(ScDataObject* pScDataObject)
-{
-    if (!((ScRangeData*)pScDataObject)->GetIndex())		// schon gesetzt?
-    {
-        ((ScRangeData*)pScDataObject)->SetIndex( GetEntryIndex() );
-    }
-
-    return ScSortedCollection::Insert(pScDataObject);
-}
-
-// Suche nach einem freien Index
-
-USHORT ScRangeName::GetEntryIndex()
-{
-    USHORT nLast = 0;
-    for ( USHORT i = 0; i < nCount; i++ )
-    {
-        USHORT nIdx = ((ScRangeData*)pItems[i])->GetIndex();
-        if( nIdx > nLast )
-        {
-            nLast = nIdx;
-        }
-    }
-    return nLast + 1;
-}
-
-ScRangeData* ScRangeName::FindIndex( USHORT nIndex )
-{
-    ScRangeData aDataObj( nIndex );
-    USHORT n;
-    if( Search( &aDataObj, n ) )
-        return (*this)[ n ];
-    else
-        return NULL;
-}
-
-
-ScRangeData* ScRangeName::GetRangeAtBlock( const ScRange& rBlock ) const
-{
-    if ( pItems )
-    {
-        for ( USHORT i = 0; i < nCount; i++ )
-            if ( ((ScRangeData*)pItems[i])->IsRangeAtBlock( rBlock ) )
-                return (ScRangeData*)pItems[i];
-    }
-    return NULL;
-}
-
-void ScRangeName::UpdateTabRef(SCTAB nOldTable, USHORT nFlag, SCTAB nNewTable)
-{
-    for (USHORT i=0; i<nCount; i++)
-        ((ScRangeData*)pItems[i])->UpdateTabRef(nOldTable, nFlag, nNewTable);
-}
-
-#endif
-
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 86cd65c85a74b2524a7de82d4b40277cd6846581
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 13:34:00 2011 -0500

    Adjusted ScDocument::CopyRangeNamesFromClip() for the ScRangeName change.

diff --git a/sc/inc/clipparam.hxx b/sc/inc/clipparam.hxx
index 883f17b..aa73901 100644
--- a/sc/inc/clipparam.hxx
+++ b/sc/inc/clipparam.hxx
@@ -78,7 +78,7 @@ struct ScClipParam
 struct ScClipRangeNameData
 {
     ScRangeData::IndexMap       maRangeMap;
-    ::std::vector<ScRangeData*> mpRangeNames;
+    ::std::vector<ScRangeData*> mpRangeNames; // Don't insert NULL pointers.
     bool                        mbReplace;
 
     ScClipRangeNameData();
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ddbdad0..9435b2e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1838,15 +1838,12 @@ void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
 
 void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames)
 {
-#if NEW_RANGE_NAME
-#else
     sal_uInt16 nClipRangeNameCount = pClipDoc->pRangeName->GetCount();
     ScClipRangeNameData aClipRangeNames;
 
-    // array containing range names which might need update of indices
-    aClipRangeNames.mpRangeNames.resize(nClipRangeNameCount, NULL);
-
-    for (sal_uInt16 i = 0; i < nClipRangeNameCount; ++i)        //! DB-Bereiche Pivot-Bereiche auch
+    ScRangeName::const_iterator itr = pClipDoc->pRangeName->begin();
+    ScRangeName::const_iterator itrEnd = pClipDoc->pRangeName->end();
+    for (; itr != itrEnd; ++itr)        //! DB-Bereiche Pivot-Bereiche auch
     {
         /*  Copy only if the name doesn't exist in this document.
             If it exists we use the already existing name instead,
@@ -1857,10 +1854,9 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
         */
         ScRangeData* pClipRangeData = (*pClipDoc->pRangeName)[i];
         USHORT k;
-        if ( pRangeName->SearchName( pClipRangeData->GetName(), k ) )
+        if ( pRangeName->SearchName( itr->GetName(), k ) )
         {
-            aClipRangeNames.mpRangeNames[i] = NULL;  // range name not inserted
-            USHORT nOldIndex = pClipRangeData->GetIndex();
+            USHORT nOldIndex = itr->GetIndex();
             USHORT nNewIndex = ((*pRangeName)[k])->GetIndex();
             aClipRangeNames.insert(nOldIndex, nNewIndex);
             if ( !aClipRangeNames.mbReplace )
@@ -1868,14 +1864,14 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
         }
         else
         {
-            ScRangeData* pData = new ScRangeData( *pClipRangeData );
+            ScRangeData* pData = new ScRangeData( *itr );
             pData->SetDocument(this);
             if ( pRangeName->FindIndex( pData->GetIndex() ) )
                 pData->SetIndex(0);     // need new index, done in Insert
-            if ( pRangeName->Insert( pData ) )
+            if ( pRangeName->insert(pData) )
             {
-                aClipRangeNames.mpRangeNames[i] = pData;
-                USHORT nOldIndex = pClipRangeData->GetIndex();
+                aClipRangeNames.mpRangeNames.push_back(pData);
+                USHORT nOldIndex = itr->GetIndex();
                 USHORT nNewIndex = pData->GetIndex();
                 aClipRangeNames.insert(nOldIndex, nNewIndex);
                 if ( !aClipRangeNames.mbReplace )
@@ -1884,14 +1880,12 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
             else
             {   // must be an overflow
                 delete pData;
-                aClipRangeNames.mpRangeNames[i] = NULL;
-                aClipRangeNames.insert(pClipRangeData->GetIndex(), 0);
+                aClipRangeNames.insert(itr->GetIndex(), 0);
                 aClipRangeNames.mbReplace = true;
             }
         }
     }
     rRangeNames = aClipRangeNames;
-#endif
 }
 
 void ScDocument::UpdateRangeNamesInFormulas(
@@ -1906,11 +1900,9 @@ void ScDocument::UpdateRangeNamesInFormulas(
 
     // first update all inserted named formulas if they contain other
     // range names and used indices changed
-    size_t nRangeNameCount = rRangeNames.mpRangeNames.size();
-    for (size_t i = 0; i < nRangeNameCount; ++i)        //! DB-Bereiche Pivot-Bereiche auch
+    for (size_t i = 0, n = rRangeNames.mpRangeNames.size(); i < n; ++i)        //! DB-Bereiche Pivot-Bereiche auch
     {
-        if ( rRangeNames.mpRangeNames[i] )
-            rRangeNames.mpRangeNames[i]->ReplaceRangeNamesInUse(rRangeNames.maRangeMap);
+        rRangeNames.mpRangeNames[i]->ReplaceRangeNamesInUse(rRangeNames.maRangeMap);
     }
     // then update the formulas, they might need just the updated range names
     for ( size_t nRange = 0, n = rDestRanges.size(); nRange < n; ++nRange )
commit 5b67ac86c0636772e8c8aa2b70ecdbbc33ab6cbb
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 12:52:56 2011 -0500

    Extracted duplicated code blocks into a separate method.

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f25645f..ddbdad0 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1762,6 +1762,29 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
     GetClipParam().mbCutMode = false;
 }
 
+namespace {
+
+void copyUsedNamesToClip(ScRangeName* pClipRangeName, ScRangeName* pRangeName, const std::set<USHORT>& rUsedNames)
+{
+    pClipRangeName->clear();
+    ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+    for (; itr != itrEnd; ++itr)        //! DB-Bereiche Pivot-Bereiche auch !!!
+    {
+        USHORT nIndex = itr->GetIndex();
+        bool bInUse = (rUsedNames.count(nIndex) > 0);
+        if (!bInUse)
+            continue;
+
+        ScRangeData* pData = new ScRangeData(*itr);
+        if (!pClipRangeName->insert(pData))
+            delete pData;
+        else
+            pData->SetIndex(nIndex);
+    }
+}
+
+}
+
 void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs)
 {
     std::set<USHORT> aUsedNames;        // indexes of named ranges that are used in the copied cells
@@ -1772,21 +1795,7 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
                     rClipRange.aStart.Col(), rClipRange.aStart.Row(),
                     rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames);
 
-    pClipDoc->pRangeName->clear();
-    ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
-    for (; itr != itrEnd; ++itr)        //! DB-Bereiche Pivot-Bereiche auch !!!
-    {
-        USHORT nIndex = itr->GetIndex();
-        bool bInUse = (aUsedNames.count(nIndex) > 0);
-        if (bInUse)
-        {
-            ScRangeData* pData = new ScRangeData(*itr);
-            if (!pClipDoc->pRangeName->insert(pData))
-                delete pData;
-            else
-                pData->SetIndex(nIndex);
-        }
-    }
+    copyUsedNamesToClip(pClipDoc->pRangeName, pRangeName, aUsedNames);
 }
 
 void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab)
@@ -1800,21 +1809,7 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
             rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
     }
 
-    pClipDoc->pRangeName->clear();
-    ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
-    for (; itr != itrEnd; ++itr)
-    {
-        USHORT nIndex = itr->GetIndex();
-        bool bInUse = (aUsedNames.count(nIndex) > 0);
-        if (bInUse)
-        {
-            ScRangeData* pData = new ScRangeData(*itr);
-            if (!pClipDoc->pRangeName->insert(pData))
-                delete pData;
-            else
-                pData->SetIndex(nIndex);
-        }
-    }
+    copyUsedNamesToClip(pClipDoc->pRangeName, pRangeName, aUsedNames);
 }
 
 ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc) :
commit ca3474ac7e2d849aabf03bac6d13de657bd6127d
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Mar 5 12:39:31 2011 -0500

    Adjusted ScDocument::CopyRangeNamesToClip() for the ScRangeName change.

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1b13a62..f25645f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1764,8 +1764,6 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
 
 void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs)
 {
-#if NEW_RANGE_NAME
-#else
     std::set<USHORT> aUsedNames;        // indexes of named ranges that are used in the copied cells
     for (SCTAB i = 0; i <= MAXTAB; ++i)
         if (pTab[i] && pClipDoc->pTab[i])
@@ -1774,49 +1772,49 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
                     rClipRange.aStart.Col(), rClipRange.aStart.Row(),
                     rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames);
 
-    pClipDoc->pRangeName->FreeAll();
-    for (USHORT i = 0; i < pRangeName->GetCount(); i++)        //! DB-Bereiche Pivot-Bereiche auch !!!
+    pClipDoc->pRangeName->clear();
+    ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+    for (; itr != itrEnd; ++itr)        //! DB-Bereiche Pivot-Bereiche auch !!!
     {
-        USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
-        bool bInUse = ( aUsedNames.find(nIndex) != aUsedNames.end() );
+        USHORT nIndex = itr->GetIndex();
+        bool bInUse = (aUsedNames.count(nIndex) > 0);
         if (bInUse)
         {
-            ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
-            if (!pClipDoc->pRangeName->Insert(pData))
+            ScRangeData* pData = new ScRangeData(*itr);
+            if (!pClipDoc->pRangeName->insert(pData))
                 delete pData;
             else
                 pData->SetIndex(nIndex);
         }
     }
-#endif
 }
 
 void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab)
 {
-#if NEW_RANGE_NAME
-#else
     // Indexes of named ranges that are used in the copied cells
     std::set<USHORT> aUsedNames;
     if ( pTab[nTab] && pClipDoc->pTab[nTab] )
     {
-        pTab[nTab]->FindRangeNamesInUse( rClipRange.aStart.Col(), rClipRange.aStart.Row(), rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
+        pTab[nTab]->FindRangeNamesInUse(
+            rClipRange.aStart.Col(), rClipRange.aStart.Row(),
+            rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
     }
 
-    pClipDoc->pRangeName->FreeAll();
-    for ( USHORT i = 0; i < pRangeName->GetCount(); i++ )
+    pClipDoc->pRangeName->clear();
+    ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+    for (; itr != itrEnd; ++itr)
     {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list