[Libreoffice-commits] core.git: Branch 'private/kohei/sort-ref-update' - 132 commits - basic/source bin/distro-install-desktop-integration bridges/Library_cpp_uno.mk bridges/source chart2/CppunitTest_chart2_export.mk chart2/qa chart2/source compilerplugins/clang configure.ac connectivity/source cui/source dbaccess/source desktop/inc desktop/Library_libreoffice.mk desktop/Module_desktop.mk desktop/source extensions/AllLangResTarget_scn.mk extensions/Library_npsoplugin.mk extensions/Module_extensions.mk extensions/source extensions/uiconfig extensions/UIConfig_scanner.mk extras/source filter/CppunitTest_filter_pict_test.mk filter/qa filter/source helpcompiler/inc helpcompiler/source helpcontent2 i18npool/source idlc/source include/comphelper include/LibreOfficeKit include/oox include/sal include/sfx2 include/svl include/svx include/test include/tools include/vcl libreofficekit/Library_libreofficekit.mk libreofficekit/Makefile libreofficekit/Module_libreofficekit.mk libreofficekit/source lotuswordpr o/source oox/source RepositoryModule_host.mk rsc/inc rsc/source sc/inc sc/Library_sc.mk scp2/source sc/qa sc/source sd/qa sd/source sfx2/source shell/Module_shell.mk smoketest/Executable_libtest.mk smoketest/libtest.cxx starmath/inc starmath/source svl/source svx/source sw/qa sw/source sysui/desktop test/source tools/source unusedcode.easy vcl/Executable_xid_fullscreen_on_all_monitors.mk vcl/qa vcl/source writerfilter/CustomTarget_source.mk writerfilter/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Jun 11 09:05:18 PDT 2014


Rebased ref, commits from common ancestor:
commit 8b81a56bc3c9b869b35cd0eee13ff9b8fea1423b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 4 16:40:35 2014 -0400

    Make reorder by row and reorder by column totally separate.
    
    We'll need to call these directly during undo and redo which is yet to
    be worked on.
    
    Change-Id: I2607c370358e1fd21eb9e283567c0be4c7731a48

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 046e82b..7957906 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -1015,7 +1015,7 @@ private:
     short       Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
     ScSortInfoArray* CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2, bool bKeepQuery );
     void        QuickSort( ScSortInfoArray*, SCsCOLROW nLo, SCsCOLROW nHi);
-    void SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress );
+    void SortReorderByColumn( ScSortInfoArray* pArray, ScProgress* pProgress );
     void SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress );
 
     bool        CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 0198c62..835fa02 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -564,14 +564,8 @@ public:
 
 }
 
-void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
+void ScTable::SortReorderByColumn( ScSortInfoArray* pArray, ScProgress* pProgress )
 {
-    if (aSortParam.bByRow)
-    {
-        SortReorderByRow(pArray, pProgress);
-        return;
-    }
-
     size_t nCount = pArray->GetCount();
     SCCOLROW nStart = pArray->GetStart();
     SCCOLROW nLast = pArray->GetLast();
@@ -1124,7 +1118,7 @@ void ScTable::Sort(const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* p
                 DecoladeRow(pArray.get(), nRow1, nLastRow);
 
             QuickSort(pArray.get(), nRow1, nLastRow);
-            SortReorder(pArray.get(), pProgress);
+            SortReorderByRow(pArray.get(), pProgress);
 
             // #i59745# update position of caption objects of cell notes --> reported at (SortReorder) ScColumn::SwapCellNotes level
         }
@@ -1146,7 +1140,7 @@ void ScTable::Sort(const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* p
             boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(nCol1, nLastCol, bKeepQuery));
 
             QuickSort(pArray.get(), nCol1, nLastCol);
-            SortReorder(pArray.get(), pProgress);
+            SortReorderByColumn(pArray.get(), pProgress);
 
             // #i59745# update position of caption objects of cell notes --> reported at (SortReorder) ScColumn::SwapCellNotes level
         }
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index deaf244..f2f3107 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -51,6 +51,48 @@
 #include <set>
 #include <memory>
 
+#include <stdio.h>
+#include <string>
+#include <sys/time.h>
+
+namespace {
+
+class stack_printer
+{
+public:
+    explicit stack_printer(const char* msg) :
+        msMsg(msg)
+    {
+        fprintf(stdout, "%s: --begin\n", msMsg.c_str());
+        mfStartTime = getTime();
+    }
+
+    ~stack_printer()
+    {
+        double fEndTime = getTime();
+        fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime - mfStartTime));
+    }
+
+    void printTime(int line) const
+    {
+        double fEndTime = getTime();
+        fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime - mfStartTime));
+    }
+
+private:
+    double getTime() const
+    {
+        timeval tv;
+        gettimeofday(&tv, NULL);
+        return tv.tv_sec + tv.tv_usec / 1000000.0;
+    }
+
+    ::std::string msMsg;
+    double mfStartTime;
+};
+
+}
+
 using namespace ::com::sun::star;
 
 bool ScDBDocFunc::AddDBRange( const OUString& rName, const ScRange& rRange, bool /* bApi */ )
@@ -425,6 +467,7 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bRecord, bool bApi, bo
 bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
                             bool bRecord, bool bPaint, bool bApi )
 {
+    stack_printer __stack_printer__("ScDBDocFunc::Sort");
     ScDocShellModificator aModificator( rDocShell );
 
     ScDocument* pDoc = rDocShell.GetDocument();
commit 9297c5607fdc3895ab049d11f28102e64ecb36b3
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 4 15:37:01 2014 -0400

    Adjust range references here as well.
    
    Change-Id: Iacc99fcc92ef5987f13716acd7ad899b6ba8c7cf

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index c6b211d..17d294f 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2993,7 +2993,6 @@ void ScTokenArray::MoveReference( const ScAddress& rPos, SCTAB nTab, SCCOL nCol1
             break;
             case svDoubleRef:
             {
-#if 0
                 ScToken* pToken = static_cast<ScToken*>(*p);
                 ScComplexRefData& rRef = pToken->GetDoubleRef();
                 ScRange aAbs = rRef.toAbs(rPos);
@@ -3002,24 +3001,23 @@ void ScTokenArray::MoveReference( const ScAddress& rPos, SCTAB nTab, SCCOL nCol1
                     // Must be a single-sheet reference.
                     break;
 
-                if (aAbs.aStart.Col() != aAbs.aEnd.Col())
-                    // Whole range must fit in a single column.
+                if (aAbs.aStart.Row() != aAbs.aEnd.Row())
+                    // Whole range must fit in a single row.
                     break;
 
-                if (aAbs.aStart.Tab() == nTab && nRow1 <= aAbs.aStart.Row() && aAbs.aEnd.Row() <= nRow2)
+                if (aAbs.aStart.Tab() == nTab && nCol1 <= aAbs.aStart.Col() && aAbs.aEnd.Col() <= nCol2)
                 {
-                    // Inside reordered row range.
-                    sc::RowReorderMapType::const_iterator it = rRowMap.find(aAbs.aStart.Col());
-                    if (it != rColMap.end())
+                    // Inside reordered column range.
+                    sc::RowReorderMapType::const_iterator it = rRowMap.find(aAbs.aStart.Row());
+                    if (it != rRowMap.end())
                     {
-                        // This column is reordered.
-                        SCCOL nNewCol = it->second;
-                        aAbs.aStart.SetCol(nNewCol);
-                        aAbs.aEnd.SetCol(nNewCol);
+                        // This row is reordered.
+                        SCCOL nNewRow = it->second;
+                        aAbs.aStart.SetRow(nNewRow);
+                        aAbs.aEnd.SetRow(nNewRow);
                         rRef.SetRange(aAbs, rPos);
                     }
                 }
-#endif
             }
             break;
             default:
commit 44d2efcc2b60341940e45b3222dd0655b351f943
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 4 15:24:34 2014 -0400

    No need to try to unshare formula cells within sorted range.
    
    Because they are already unshared during the sorting process.
    
    Change-Id: I3a485397c575deab620217505bbbad8c3307119a

diff --git a/sc/inc/listenerquery.hxx b/sc/inc/listenerquery.hxx
index f3178fc..2cbc957 100644
--- a/sc/inc/listenerquery.hxx
+++ b/sc/inc/listenerquery.hxx
@@ -10,12 +10,9 @@
 #ifndef SC_LISTENERQUERY_HXX
 #define SC_LISTENERQUERY_HXX
 
-#include <types.hxx>
-
+#include <address.hxx>
 #include <svl/listener.hxx>
 
-class ScAddress;
-
 namespace sc {
 
 /**
@@ -32,6 +29,7 @@ public:
     RefQueryFormulaGroup();
     virtual ~RefQueryFormulaGroup();
 
+    void setSkipRange( const ScRange& rRange );
     void add( const ScAddress& rPos );
 
     /**
@@ -41,7 +39,7 @@ public:
     const TabsType& getAllPositions() const;
 
 private:
-
+    ScRange maSkipRange;
     TabsType maTabs;
 };
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 1dc6695..0198c62 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -849,6 +849,8 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
     // Collect positions of all shared formula cells outside the sorted range,
     // and make them unshared before notifying them.
     sc::RefQueryFormulaGroup aFormulaGroupPos;
+    aFormulaGroupPos.setSkipRange(ScRange(aSortParam.nCol1, nRow1, nTab, aSortParam.nCol2, nRow2, nTab));
+
     std::for_each(aListeners.begin(), aListeners.end(), FormulaGroupPosCollector(aFormulaGroupPos));
     const sc::RefQueryFormulaGroup::TabsType& rGroupTabs = aFormulaGroupPos.getAllPositions();
     sc::RefQueryFormulaGroup::TabsType::const_iterator itGroupTab = rGroupTabs.begin(), itGroupTabEnd = rGroupTabs.end();
diff --git a/sc/source/core/tool/listenerquery.cxx b/sc/source/core/tool/listenerquery.cxx
index a207762..bf9d38f 100644
--- a/sc/source/core/tool/listenerquery.cxx
+++ b/sc/source/core/tool/listenerquery.cxx
@@ -13,14 +13,26 @@
 
 namespace sc {
 
-RefQueryFormulaGroup::RefQueryFormulaGroup() : SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_POS) {}
+RefQueryFormulaGroup::RefQueryFormulaGroup() :
+    SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_POS),
+    maSkipRange(ScAddress::INITIALIZE_INVALID) {}
+
 RefQueryFormulaGroup::~RefQueryFormulaGroup() {}
 
+void RefQueryFormulaGroup::setSkipRange( const ScRange& rRange )
+{
+    maSkipRange = rRange;
+}
+
 void RefQueryFormulaGroup::add( const ScAddress& rPos )
 {
     if (!rPos.IsValid())
         return;
 
+    if (maSkipRange.IsValid() && maSkipRange.In(rPos))
+        // This is within the skip range.  Skip it.
+        return;
+
     TabsType::iterator itTab = maTabs.find(rPos.Tab());
     if (itTab == maTabs.end())
     {
commit 747b4faa1d9de786555c1c9066f57bb8b82c0f5b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 4 15:16:24 2014 -0400

    Don't forget to unshare formula cells on other sheets as well.
    
    Change-Id: I2a4f6545055f0230608c7765ff41de48de6d1065

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 3787ea9..c9a8dce 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2065,6 +2065,17 @@ public:
 
     size_t GetFormulaHash( const ScAddress& rPos ) const;
 
+    /**
+     * Make specified formula cells non-grouped.
+     *
+     * @param nTab sheet index
+     * @param nCol column index
+     * @param rRows list of row indices at which formula cells are to be
+     *              unshared. This call sorts the passed row indices and
+     *              removes duplicates, which is why the caller must pass it
+     *              as reference.
+     */
+    void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
     void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
 
     ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index f79b62b..046e82b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -876,6 +876,7 @@ public:
     formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
     formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
 
+    void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
     void RegroupFormulaCells( SCCOL nCol );
 
     ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index ab79d4f..f633a47 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -293,6 +293,15 @@ bool ScDocument::HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) con
     return pTab->HasUniformRowHeight(nRow1, nRow2);
 }
 
+void ScDocument::UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows )
+{
+    ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return;
+
+    pTab->UnshareFormulaCells(nCol, rRows);
+}
+
 void ScDocument::RegroupFormulaCells( SCTAB nTab, SCCOL nCol )
 {
     ScTable* pTab = FetchTable(nTab);
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 2666075..1dc6695 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -860,7 +860,7 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
         {
             const sc::RefQueryFormulaGroup::ColType& rCol = itCol->second;
             std::vector<SCROW> aBounds(rCol);
-            sc::SharedFormulaUtil::unshareFormulaCells(aCol[itCol->first].maCells, aBounds);
+            pDocument->UnshareFormulaCells(itGroupTab->first, itCol->first, aBounds);
         }
     }
 
@@ -877,7 +877,7 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
             pDocument->RegroupFormulaCells(itGroupTab->first, itCol->first);
     }
 
-    // And columns in sorted range too.
+    // Re-group columns in the sorted range too.
     for (SCCOL i = aSortParam.nCol1; i <= aSortParam.nCol2; ++i)
         aCol[i].RegroupFormulaCells();
 }
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 3eb13f0..f39e529 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -13,6 +13,7 @@
 #include <clipparam.hxx>
 #include <bcaslot.hxx>
 #include <segmenttree.hxx>
+#include <sharedformula.hxx>
 
 bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
 {
@@ -117,6 +118,14 @@ bool ScTable::HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const
     return nRow2 <= aData.mnRow2;
 }
 
+void ScTable::UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows )
+{
+    if (!ValidCol(nCol))
+        return;
+
+    sc::SharedFormulaUtil::unshareFormulaCells(aCol[nCol].maCells, rRows);
+}
+
 void ScTable::RegroupFormulaCells( SCCOL nCol )
 {
     if (!ValidCol(nCol))
commit 9d8cb9399a4229da9d97807a3082c9ae66c8eb87
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jun 2 20:38:24 2014 -0400

    Regroup affected formula cells after sort.
    
    Change-Id: I06968502424130e53ffdf26b7d009f4525e2227d

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index c00f55e..3787ea9 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2065,6 +2065,8 @@ public:
 
     size_t GetFormulaHash( const ScAddress& rPos ) const;
 
+    void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
+
     ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;
 
     formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
diff --git a/sc/inc/listenerquery.hxx b/sc/inc/listenerquery.hxx
index 013b430..f3178fc 100644
--- a/sc/inc/listenerquery.hxx
+++ b/sc/inc/listenerquery.hxx
@@ -38,7 +38,7 @@ public:
      * Row positions in each column may contain duplicates.  Caller must
      * remove duplicates if necessary.
      */
-    const TabsType& getAllPositions();
+    const TabsType& getAllPositions() const;
 
 private:
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 45f8912..f79b62b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -876,6 +876,8 @@ public:
     formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
     formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
 
+    void RegroupFormulaCells( SCCOL nCol );
+
     ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
 
     SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 4112bb9..ab79d4f 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -293,4 +293,13 @@ bool ScDocument::HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) con
     return pTab->HasUniformRowHeight(nRow1, nRow2);
 }
 
+void ScDocument::RegroupFormulaCells( SCTAB nTab, SCCOL nCol )
+{
+    ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return;
+
+    pTab->RegroupFormulaCells(nCol);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 129167b..2666075 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -846,28 +846,40 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
     std::sort(aListeners.begin(), aListeners.end());
     aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end());
 
-    // Collect positions of all shared formula cells outside the sorted range.
+    // Collect positions of all shared formula cells outside the sorted range,
+    // and make them unshared before notifying them.
     sc::RefQueryFormulaGroup aFormulaGroupPos;
     std::for_each(aListeners.begin(), aListeners.end(), FormulaGroupPosCollector(aFormulaGroupPos));
+    const sc::RefQueryFormulaGroup::TabsType& rGroupTabs = aFormulaGroupPos.getAllPositions();
+    sc::RefQueryFormulaGroup::TabsType::const_iterator itGroupTab = rGroupTabs.begin(), itGroupTabEnd = rGroupTabs.end();
+    for (; itGroupTab != itGroupTabEnd; ++itGroupTab)
     {
-        const sc::RefQueryFormulaGroup::TabsType& rTabs = aFormulaGroupPos.getAllPositions();
-        sc::RefQueryFormulaGroup::TabsType::const_iterator itTab = rTabs.begin(), itTabEnd = rTabs.end();
-        for (; itTab != itTabEnd; ++itTab)
+        const sc::RefQueryFormulaGroup::ColsType& rCols = itGroupTab->second;
+        sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end();
+        for (; itCol != itColEnd; ++itCol)
         {
-            const sc::RefQueryFormulaGroup::ColsType& rCols = itTab->second;
-            sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end();
-            for (; itCol != itColEnd; ++itCol)
-            {
-                const sc::RefQueryFormulaGroup::ColType& rCol = itCol->second;
-                std::vector<SCROW> aBounds(rCol);
-                sc::SharedFormulaUtil::unshareFormulaCells(aCol[itCol->first].maCells, aBounds);
-            }
+            const sc::RefQueryFormulaGroup::ColType& rCol = itCol->second;
+            std::vector<SCROW> aBounds(rCol);
+            sc::SharedFormulaUtil::unshareFormulaCells(aCol[itCol->first].maCells, aBounds);
         }
     }
 
     // Notify the listeners.
     RowReorderNotifier aFunc(aRowMap, nTab, aSortParam.nCol1, aSortParam.nCol2);
     std::for_each(aListeners.begin(), aListeners.end(), aFunc);
+
+    // Re-group formulas in affected columns.
+    for (itGroupTab = rGroupTabs.begin(); itGroupTab != itGroupTabEnd; ++itGroupTab)
+    {
+        const sc::RefQueryFormulaGroup::ColsType& rCols = itGroupTab->second;
+        sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end();
+        for (; itCol != itColEnd; ++itCol)
+            pDocument->RegroupFormulaCells(itGroupTab->first, itCol->first);
+    }
+
+    // And columns in sorted range too.
+    for (SCCOL i = aSortParam.nCol1; i <= aSortParam.nCol2; ++i)
+        aCol[i].RegroupFormulaCells();
 }
 
 short ScTable::CompareCell(
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 845c720..3eb13f0 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -117,4 +117,12 @@ bool ScTable::HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const
     return nRow2 <= aData.mnRow2;
 }
 
+void ScTable::RegroupFormulaCells( SCCOL nCol )
+{
+    if (!ValidCol(nCol))
+        return;
+
+    aCol[nCol].RegroupFormulaCells();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/listenerquery.cxx b/sc/source/core/tool/listenerquery.cxx
index 549e500..a207762 100644
--- a/sc/source/core/tool/listenerquery.cxx
+++ b/sc/source/core/tool/listenerquery.cxx
@@ -50,7 +50,7 @@ void RefQueryFormulaGroup::add( const ScAddress& rPos )
     rCol.push_back(rPos.Row());
 }
 
-const RefQueryFormulaGroup::TabsType& RefQueryFormulaGroup::getAllPositions()
+const RefQueryFormulaGroup::TabsType& RefQueryFormulaGroup::getAllPositions() const
 {
     return maTabs;
 }
commit 3a60671e920195f1a0ec87bf884cd221ab2d8326
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jun 2 18:29:27 2014 -0400

    First cut on reference update on sort by row.
    
    Change-Id: I641aff45a1dee35350f25a857952ed33c11d6a93

diff --git a/include/svl/listener.hxx b/include/svl/listener.hxx
index 1c98458..8b47fda 100644
--- a/include/svl/listener.hxx
+++ b/include/svl/listener.hxx
@@ -34,6 +34,16 @@ class SVL_DLLPUBLIC SvtListener
     const SvtListener&  operator=(const SvtListener &); // n.i., ist verboten
 
 public:
+    class SVL_DLLPUBLIC QueryBase
+    {
+        sal_uInt16 mnId;
+    public:
+        QueryBase( sal_uInt16 nId );
+        virtual ~QueryBase();
+
+        sal_uInt16 getId() const;
+    };
+
     SvtListener();
     SvtListener( const SvtListener &r );
     virtual ~SvtListener();
@@ -43,9 +53,11 @@ public:
     void EndListeningAll();
     bool IsListening( SvtBroadcaster& rBroadcaster ) const;
 
+    void CopyAllBroadcasters( const SvtListener& r );
     bool HasBroadcaster() const;
 
     virtual void Notify( const SfxHint& rHint );
+    virtual void Query( QueryBase& rQuery ) const;
 };
 
 
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 9b55aa4..8e42c63 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -237,6 +237,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/core/tool/interpr6 \
     sc/source/core/tool/interpr7 \
     sc/source/core/tool/jumpmatrix \
+    sc/source/core/tool/listenerquery \
     sc/source/core/tool/lookupcache \
     sc/source/core/tool/navicfg \
     sc/source/core/tool/odffmap \
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 25efdb7..5c86bb9 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -321,6 +321,8 @@ public:
     void            SetNextTrack( ScFormulaCell* pF );
 
     virtual void Notify( const SfxHint& rHint ) SAL_OVERRIDE;
+    virtual void Query( SvtListener::QueryBase& rQuery ) const SAL_OVERRIDE;
+
     void SetCompile( bool bVal );
     ScDocument* GetDocument() const { return pDocument;}
     void            SetMatColsRows( SCCOL nCols, SCROW nRows, bool bDirtyFlag=true );
diff --git a/sc/inc/listenerquery.hxx b/sc/inc/listenerquery.hxx
new file mode 100644
index 0000000..013b430
--- /dev/null
+++ b/sc/inc/listenerquery.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_LISTENERQUERY_HXX
+#define SC_LISTENERQUERY_HXX
+
+#include <types.hxx>
+
+#include <svl/listener.hxx>
+
+class ScAddress;
+
+namespace sc {
+
+/**
+ * Used to collect positions of formula cells that belong to a formula
+ * group.
+ */
+class RefQueryFormulaGroup : public SvtListener::QueryBase
+{
+public:
+    typedef std::vector<SCROW> ColType;
+    typedef boost::unordered_map<SCCOL,ColType> ColsType;
+    typedef boost::unordered_map<SCTAB,ColsType> TabsType;
+
+    RefQueryFormulaGroup();
+    virtual ~RefQueryFormulaGroup();
+
+    void add( const ScAddress& rPos );
+
+    /**
+     * Row positions in each column may contain duplicates.  Caller must
+     * remove duplicates if necessary.
+     */
+    const TabsType& getAllPositions();
+
+private:
+
+    TabsType maTabs;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/listenerqueryids.hxx b/sc/inc/listenerqueryids.hxx
new file mode 100644
index 0000000..48f240b
--- /dev/null
+++ b/sc/inc/listenerqueryids.hxx
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_LISTENERQUERYIDS_HXX
+#define SC_LISTENERQUERYIDS_HXX
+
+#define SC_LISTENER_QUERY_FORMULA_GROUP_POS 0
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/refhint.hxx b/sc/inc/refhint.hxx
index 146adf8..67f7193 100644
--- a/sc/inc/refhint.hxx
+++ b/sc/inc/refhint.hxx
@@ -18,7 +18,11 @@ namespace sc {
 class RefHint : public SfxSimpleHint
 {
 public:
-    enum Type { Moved, ColumnReordered };
+    enum Type {
+        Moved,
+        ColumnReordered,
+        RowReordered
+    };
 
 private:
     Type meType;
@@ -73,6 +77,24 @@ public:
     SCROW getEndRow() const { return mnRow2;}
 };
 
+class RefRowReorderHint : public RefHint
+{
+    const sc::RowReorderMapType& mrRowMap;
+    SCTAB mnTab;
+    SCCOL mnCol1;
+    SCCOL mnCol2;
+
+public:
+    RefRowReorderHint( const sc::RowReorderMapType& rRowMap, SCTAB nTab, SCCOL nCol1, SCCOL nCol2 );
+    virtual ~RefRowReorderHint();
+
+    const sc::RowReorderMapType& getRowMap() const;
+
+    SCTAB getTab() const;
+    SCCOL getStartColumn() const;
+    SCCOL getEndColumn() const;
+};
+
 }
 
 #endif
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index 840b63b..b29843f 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -100,6 +100,15 @@ public:
      * @param rCell formula cell instance
      */
     static void unshareFormulaCell(const CellStoreType::position_type& aPos, ScFormulaCell& rCell);
+
+    /**
+     * Make specified formula cells non-shared ones, and split them off from
+     * their respective adjacent formula cell groups.
+     *
+     * @param rCells cell storage container
+     * @param rRows row positions at which to unshare formula cells.
+     */
+    static void unshareFormulaCells(CellStoreType& rCells, std::vector<SCROW>& rRows);
 };
 
 }
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index b6aee95..0e31a6d 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -171,6 +171,8 @@ public:
      */
     void MoveReference( const ScAddress& rPos, SCTAB nTab, SCROW nRow1, SCROW nRow2, const sc::ColReorderMapType& rColMap );
 
+    void MoveReference( const ScAddress& rPos, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, const sc::RowReorderMapType& rRowMap );
+
     /**
      * Adjust all references in named expression. In named expression, we only
      * update absolute positions, and leave relative positions intact.
diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx
index 8d37ad4..976baaf 100644
--- a/sc/inc/types.hxx
+++ b/sc/inc/types.hxx
@@ -99,6 +99,7 @@ struct RangeMatrix
 };
 
 typedef boost::unordered_map<SCCOL,SCCOL> ColReorderMapType;
+typedef boost::unordered_map<SCROW,SCROW> RowReorderMapType;
 
 }
 
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index c7e9aeb..07dbb95 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -56,6 +56,8 @@
 #include "refupdatecontext.hxx"
 #include <tokenstringcontext.hxx>
 #include <refhint.hxx>
+#include <listenerquery.hxx>
+#include <listenerqueryids.hxx>
 
 #include <boost/scoped_ptr.hpp>
 
@@ -1964,6 +1966,18 @@ void ScFormulaCell::Notify( const SfxHint& rHint )
                         aPos, rRefColReorder.getTab(), rRefColReorder.getStartRow(), rRefColReorder.getEndRow(), rRefColReorder.getColMap());
             }
             break;
+            case sc::RefHint::RowReordered:
+            {
+                const sc::RefRowReorderHint& rRefRowReorder =
+                    static_cast<const sc::RefRowReorderHint&>(rRefHint);
+                if (!IsShared() || IsSharedTop())
+                    pCode->MoveReference(
+                        aPos, rRefRowReorder.getTab(),
+                        rRefRowReorder.getStartColumn(),
+                        rRefRowReorder.getEndColumn(),
+                        rRefRowReorder.getRowMap());
+            }
+            break;
             default:
                 ;
         }
@@ -2006,6 +2020,23 @@ void ScFormulaCell::Notify( const SfxHint& rHint )
     }
 }
 
+void ScFormulaCell::Query( SvtListener::QueryBase& rQuery ) const
+{
+    switch (rQuery.getId())
+    {
+        case SC_LISTENER_QUERY_FORMULA_GROUP_POS:
+        {
+            sc::RefQueryFormulaGroup& rRefQuery =
+                static_cast<sc::RefQueryFormulaGroup&>(rQuery);
+            if (IsShared())
+                rRefQuery.add(aPos);
+        }
+        break;
+        default:
+            ;
+    }
+}
+
 void ScFormulaCell::SetDirty( bool bDirtyFlag )
 {
     if ( !IsInChangeTrack() )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b544711..129167b 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -60,6 +60,7 @@
 #include <listenercontext.hxx>
 #include <sharedformula.hxx>
 #include <refhint.hxx>
+#include <listenerquery.hxx>
 
 #include <svl/sharedstringpool.hxx>
 
@@ -531,12 +532,13 @@ void ScTable::DestroySortCollator()
 
 namespace {
 
-class ColReorderNotifier : std::unary_function<SvtListener*, void>
+template<typename _Hint, typename _ReorderMap, typename _Index>
+class ReorderNotifier : std::unary_function<SvtListener*, void>
 {
-    sc::RefColReorderHint maHint;
+    _Hint maHint;
 public:
-    ColReorderNotifier( const sc::ColReorderMapType& rColMap, SCTAB nTab, SCROW nRow1, SCROW nRow2 ) :
-        maHint(rColMap, nTab, nRow1, nRow2) {}
+    ReorderNotifier( const _ReorderMap& rMap, SCTAB nTab, _Index nPos1, _Index nPos2 ) :
+        maHint(rMap, nTab, nPos1, nPos2) {}
 
     void operator() ( SvtListener* p )
     {
@@ -544,6 +546,22 @@ public:
     }
 };
 
+typedef ReorderNotifier<sc::RefColReorderHint, sc::ColReorderMapType, SCROW> ColReorderNotifier;
+typedef ReorderNotifier<sc::RefRowReorderHint, sc::RowReorderMapType, SCROW> RowReorderNotifier;
+
+class FormulaGroupPosCollector : std::unary_function<SvtListener*, void>
+{
+    sc::RefQueryFormulaGroup& mrQuery;
+
+public:
+    FormulaGroupPosCollector( sc::RefQueryFormulaGroup& rQuery ) : mrQuery(rQuery) {}
+
+    void operator() ( SvtListener* p )
+    {
+        p->Query(mrQuery);
+    }
+};
+
 }
 
 void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
@@ -600,7 +618,7 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
     for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
     {
         SCCOL nNew = i + nStart;
-        SCROW nOld = rOldIndices[i];
+        SCCOL nOld = rOldIndices[i];
         aColMap.insert(sc::ColReorderMapType::value_type(nOld, nNew));
     }
 
@@ -636,10 +654,6 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
     ScSortInfoArray::RowsType* pRows = pArray->GetDataRows();
     assert(pRows); // In sort-by-row mode we must have data rows already populated.
 
-    // Detach all formula cells within the sorted range first.
-    sc::EndListeningContext aCxt(*pDocument);
-    DetachFormulaCells(aCxt, aSortParam.nCol1, nRow1, aSortParam.nCol2, nRow2);
-
     // Cells in the data rows only reference values in the document. Make
     // a copy before updating the document.
 
@@ -682,13 +696,13 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
                 case CELLTYPE_FORMULA:
                 {
                     assert(rCell.mpAttr);
-                    size_t n = rCellStore.size();
-                    sc::CellStoreType::iterator itBlk = rCellStore.push_back(rCell.maCell.mpFormula->Clone(aCellPos));
+                    ScAddress aOldPos = rCell.maCell.mpFormula->aPos;
+
+                    ScFormulaCell* pNew = rCell.maCell.mpFormula->Clone(aCellPos);
+                    pNew->CopyAllBroadcasters(*rCell.maCell.mpFormula);
+                    pNew->GetCode()->AdjustReferenceOnMovedOrigin(aOldPos, aCellPos);
 
-                    // Join the formula cells as we fill the container.
-                    size_t nOffset = n - itBlk->position;
-                    sc::CellStoreType::position_type aPos(itBlk, nOffset);
-                    sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
+                    sc::CellStoreType::iterator itBlk = rCellStore.push_back(pNew);
                 }
                 break;
                 default:
@@ -812,10 +826,48 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress )
             SetRowFiltered(it->mnRow1, it->mnRow2, true);
     }
 
-    // Attach all formula cells within sorted range, to have them start listening again.
-    sc::StartListeningContext aStartListenCxt(*pDocument);
-    AttachFormulaCells(
-        aStartListenCxt, aSortParam.nCol1, nRow1, aSortParam.nCol2, nRow2);
+    // Set up row reorder map (for later broadcasting of reference updates).
+    sc::RowReorderMapType aRowMap;
+    const std::vector<SCCOLROW>& rOldIndices = pArray->GetOldIndices();
+    for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
+    {
+        SCROW nNew = i + nRow1;
+        SCROW nOld = rOldIndices[i];
+        aRowMap.insert(sc::RowReorderMapType::value_type(nOld, nNew));
+    }
+
+    // Collect all listeners within sorted range ahead of time.
+    std::vector<SvtListener*> aListeners;
+    for (SCCOL nCol = aSortParam.nCol1; nCol <= aSortParam.nCol2; ++nCol)
+        aCol[nCol].CollectListeners(aListeners, nRow1, nRow2);
+
+    // Remove any duplicate listener entries.  We must ensure that we notify
+    // each unique listener only once.
+    std::sort(aListeners.begin(), aListeners.end());
+    aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end());
+
+    // Collect positions of all shared formula cells outside the sorted range.
+    sc::RefQueryFormulaGroup aFormulaGroupPos;
+    std::for_each(aListeners.begin(), aListeners.end(), FormulaGroupPosCollector(aFormulaGroupPos));
+    {
+        const sc::RefQueryFormulaGroup::TabsType& rTabs = aFormulaGroupPos.getAllPositions();
+        sc::RefQueryFormulaGroup::TabsType::const_iterator itTab = rTabs.begin(), itTabEnd = rTabs.end();
+        for (; itTab != itTabEnd; ++itTab)
+        {
+            const sc::RefQueryFormulaGroup::ColsType& rCols = itTab->second;
+            sc::RefQueryFormulaGroup::ColsType::const_iterator itCol = rCols.begin(), itColEnd = rCols.end();
+            for (; itCol != itColEnd; ++itCol)
+            {
+                const sc::RefQueryFormulaGroup::ColType& rCol = itCol->second;
+                std::vector<SCROW> aBounds(rCol);
+                sc::SharedFormulaUtil::unshareFormulaCells(aCol[itCol->first].maCells, aBounds);
+            }
+        }
+    }
+
+    // Notify the listeners.
+    RowReorderNotifier aFunc(aRowMap, nTab, aSortParam.nCol1, aSortParam.nCol2);
+    std::for_each(aListeners.begin(), aListeners.end(), aFunc);
 }
 
 short ScTable::CompareCell(
diff --git a/sc/source/core/tool/listenerquery.cxx b/sc/source/core/tool/listenerquery.cxx
new file mode 100644
index 0000000..549e500
--- /dev/null
+++ b/sc/source/core/tool/listenerquery.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <listenerquery.hxx>
+#include <listenerqueryids.hxx>
+#include <address.hxx>
+
+namespace sc {
+
+RefQueryFormulaGroup::RefQueryFormulaGroup() : SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_POS) {}
+RefQueryFormulaGroup::~RefQueryFormulaGroup() {}
+
+void RefQueryFormulaGroup::add( const ScAddress& rPos )
+{
+    if (!rPos.IsValid())
+        return;
+
+    TabsType::iterator itTab = maTabs.find(rPos.Tab());
+    if (itTab == maTabs.end())
+    {
+        std::pair<TabsType::iterator,bool> r =
+            maTabs.insert(TabsType::value_type(rPos.Tab(), ColsType()));
+        if (!r.second)
+            // Insertion failed.
+            return;
+
+        itTab = r.first;
+    }
+
+    ColsType& rCols = itTab->second;
+    ColsType::iterator itCol = rCols.find(rPos.Col());
+    if (itCol == rCols.end())
+    {
+        std::pair<ColsType::iterator,bool> r =
+            rCols.insert(ColsType::value_type(rPos.Col(), ColType()));
+        if (!r.second)
+            // Insertion failed.
+            return;
+
+        itCol = r.first;
+    }
+
+    ColType& rCol = itCol->second;
+    rCol.push_back(rPos.Row());
+}
+
+const RefQueryFormulaGroup::TabsType& RefQueryFormulaGroup::getAllPositions()
+{
+    return maTabs;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/refhint.cxx b/sc/source/core/tool/refhint.cxx
index 56e21e4..ef650ac 100644
--- a/sc/source/core/tool/refhint.cxx
+++ b/sc/source/core/tool/refhint.cxx
@@ -43,6 +43,31 @@ const sc::ColReorderMapType& RefColReorderHint::getColMap() const
 
 
 
+RefRowReorderHint::RefRowReorderHint( const sc::RowReorderMapType& rRowMap, SCTAB nTab, SCCOL nCol1, SCCOL nCol2 ) :
+    RefHint(RowReordered), mrRowMap(rRowMap), mnTab(nTab), mnCol1(nCol1), mnCol2(nCol2) {}
+
+RefRowReorderHint::~RefRowReorderHint() {}
+
+const sc::RowReorderMapType& RefRowReorderHint::getRowMap() const
+{
+    return mrRowMap;
+}
+
+SCTAB RefRowReorderHint::getTab() const
+{
+    return mnTab;
+}
+
+SCCOL RefRowReorderHint::getStartColumn() const
+{
+    return mnCol1;
+}
+
+SCCOL RefRowReorderHint::getEndColumn() const
+{
+    return mnCol2;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index ed35690..6f66365 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -297,6 +297,35 @@ void SharedFormulaUtil::unshareFormulaCell(const CellStoreType::position_type& a
     rCell.SetCellGroup(xNone);
 }
 
+void SharedFormulaUtil::unshareFormulaCells(CellStoreType& rCells, std::vector<SCROW>& rRows)
+{
+    if (rRows.empty())
+        return;
+
+    // Sort and remove duplicates.
+    std::sort(rRows.begin(), rRows.end());
+    rRows.erase(std::unique(rRows.begin(), rRows.end()), rRows.end());
+
+    // Add next cell positions to the list (to ensure that each position becomes a single cell).
+    std::vector<SCROW> aRows2;
+    std::vector<SCROW>::const_iterator it = rRows.begin(), itEnd = rRows.end();
+    for (; it != itEnd; ++it)
+    {
+        if (*it > MAXROW)
+            break;
+
+        aRows2.push_back(*it);
+
+        if (*it < MAXROW)
+            aRows2.push_back(*it+1);
+    }
+
+    // Remove duplicates again (the vector should still be sorted).
+    aRows2.erase(std::unique(aRows2.begin(), aRows2.end()), aRows2.end());
+
+    splitFormulaCellGroups(rCells, aRows2);
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 9290058..c6b211d 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2963,6 +2963,71 @@ void ScTokenArray::MoveReference(
     }
 }
 
+void ScTokenArray::MoveReference( const ScAddress& rPos, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, const sc::RowReorderMapType& rRowMap )
+{
+    FormulaToken** p = pCode;
+    FormulaToken** pEnd = p + static_cast<size_t>(nLen);
+    for (; p != pEnd; ++p)
+    {
+        switch ((*p)->GetType())
+        {
+            case svSingleRef:
+            {
+                ScToken* pToken = static_cast<ScToken*>(*p);
+                ScSingleRefData& rRef = pToken->GetSingleRef();
+                ScAddress aAbs = rRef.toAbs(rPos);
+
+                if (aAbs.Tab() == nTab && nCol1 <= aAbs.Col() && aAbs.Col() <= nCol2)
+                {
+                    // Inside reordered column range.
+                    sc::RowReorderMapType::const_iterator it = rRowMap.find(aAbs.Row());
+                    if (it != rRowMap.end())
+                    {
+                        // This column is reordered.
+                        SCROW nNewRow = it->second;
+                        aAbs.SetRow(nNewRow);
+                        rRef.SetAddress(aAbs, rPos);
+                    }
+                }
+            }
+            break;
+            case svDoubleRef:
+            {
+#if 0
+                ScToken* pToken = static_cast<ScToken*>(*p);
+                ScComplexRefData& rRef = pToken->GetDoubleRef();
+                ScRange aAbs = rRef.toAbs(rPos);
+
+                if (aAbs.aStart.Tab() != aAbs.aEnd.Tab())
+                    // Must be a single-sheet reference.
+                    break;
+
+                if (aAbs.aStart.Col() != aAbs.aEnd.Col())
+                    // Whole range must fit in a single column.
+                    break;
+
+                if (aAbs.aStart.Tab() == nTab && nRow1 <= aAbs.aStart.Row() && aAbs.aEnd.Row() <= nRow2)
+                {
+                    // Inside reordered row range.
+                    sc::RowReorderMapType::const_iterator it = rRowMap.find(aAbs.aStart.Col());
+                    if (it != rColMap.end())
+                    {
+                        // This column is reordered.
+                        SCCOL nNewCol = it->second;
+                        aAbs.aStart.SetCol(nNewCol);
+                        aAbs.aEnd.SetCol(nNewCol);
+                        rRef.SetRange(aAbs, rPos);
+                    }
+                }
+#endif
+            }
+            break;
+            default:
+                ;
+        }
+    }
+}
+
 namespace {
 
 bool adjustSingleRefInName(
diff --git a/svl/source/notify/listener.cxx b/svl/source/notify/listener.cxx
index 66207bf..f905090 100644
--- a/svl/source/notify/listener.cxx
+++ b/svl/source/notify/listener.cxx
@@ -21,6 +21,14 @@
 #include <svl/broadcast.hxx>
 #include <tools/debug.hxx>
 
+SvtListener::QueryBase::QueryBase( sal_uInt16 nId ) : mnId(nId) {}
+SvtListener::QueryBase::~QueryBase() {}
+
+sal_uInt16 SvtListener::QueryBase::getId() const
+{
+    return mnId;
+}
+
 SvtListener::SvtListener() {}
 
 SvtListener::SvtListener( const SvtListener &r ) :
@@ -75,12 +83,26 @@ bool SvtListener::IsListening( SvtBroadcaster& rBroadcaster ) const
     return maBroadcasters.count(&rBroadcaster) > 0;
 }
 
+void SvtListener::CopyAllBroadcasters( const SvtListener& r )
+{
+    BroadcastersType aCopy(r.maBroadcasters);
+    maBroadcasters.swap(aCopy);
+    BroadcastersType::iterator it = maBroadcasters.begin(), itEnd = maBroadcasters.end();
+    for (; it != itEnd; ++it)
+    {
+        SvtBroadcaster* p = *it;
+        p->Add(this);
+    }
+}
+
 bool SvtListener::HasBroadcaster() const
 {
     return !maBroadcasters.empty();
 }
 
-void SvtListener::Notify( const SfxHint& ) {}
+void SvtListener::Notify( const SfxHint& /*rHint*/ ) {}
+
+void SvtListener::Query( QueryBase& /*rQuery*/ ) const {}
 
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 56ca1b76963c44318a4f5577e15cfa5e7e1cd2a2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 11 11:45:14 2014 -0400

    fdo#77506: (finally) write a unit test for this.
    
    I've switched from using a Draw document to Writer document due to some
    instability with Draw instance in our cppunit run.  The bug is reproducible
    either way.
    
    The test is disabled for now, since the bug has yet to be fixed.
    
    Change-Id: I49e0417e1ecbc70f40aab8531237ae98ae58bdd3

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 6d83a8a..2d4713e 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -50,7 +50,7 @@ public:
     void testShapeFollowedByChart();
     void testPieChartDataLabels();
     void testSeriesIdxOrder();
-    // void testScatterPlotLabels();
+    void testScatterPlotLabels();
     void testErrorBarDataRangeODS();
     void testChartCrash();
     void testPieChartRotation();
@@ -83,7 +83,7 @@ public:
     CPPUNIT_TEST(testShapeFollowedByChart);
     CPPUNIT_TEST(testPieChartDataLabels);
     CPPUNIT_TEST(testSeriesIdxOrder);
-//  CPPUNIT_TEST(testScatterPlotLabels); TODO : This test crashes for some unknown reason.
+    CPPUNIT_TEST(testScatterPlotLabels);
     CPPUNIT_TEST(testErrorBarDataRangeODS);
     CPPUNIT_TEST(testChartCrash);
     CPPUNIT_TEST(testPieChartRotation);
@@ -714,46 +714,39 @@ void Chart2ExportTest::testSeriesIdxOrder()
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1");
 }
 
-// void Chart2ExportTest::testScatterPlotLabels()
-// {
-//     load("/chart2/qa/extras/data/odg/", "scatter-plot-labels.odg");
-//     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
-//     CPPUNIT_ASSERT(xChartDoc.is());
-//
-//     Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
-//     CPPUNIT_ASSERT(xCT.is());
-//
-//     OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel();
-//
-//     Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
-//     CPPUNIT_ASSERT(xDSCont.is());
-//     Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
-//     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength());
-//
-//     for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
-//     {
-//         uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
-//         CPPUNIT_ASSERT(xDSrc.is());
-//         uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
-//         for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
-//         {
-//             Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
-//             CPPUNIT_ASSERT(xValues.is());
-//             Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
-//             if (!xPropSet.is())
-//                 continue;
-//
-//             OUString aRoleName;
-//             xPropSet->getPropertyValue("Role") >>= aRoleName;
-//             if (aRoleName == aLabelRole)
-//             {
-//                 // TODO : Check the data series labels.
-//             }
-//         }
-//     }
-//
-//     CPPUNIT_ASSERT(false);
-// }
+void Chart2ExportTest::testScatterPlotLabels()
+{
+    load("/chart2/qa/extras/data/odt/", "scatter-plot-labels.odt");
+    Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xChartDoc.is());
+
+    Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
+    CPPUNIT_ASSERT(xCT.is());
+
+    // Make sure the original chart has 'a', 'b', 'c' as its data labels.
+    std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
+    CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
+    CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
+
+    // Reload the doc and check again.  The labels should not change.
+    reload("writer8");
+
+    xChartDoc.set(getChartDocFromWriter(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xChartDoc.is());
+
+    xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
+    CPPUNIT_ASSERT(xCT.is());
+
+#if 0
+    aLabels = getDataSeriesLabelsFromChartType(xCT);
+    CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
+    CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
+#endif
+}
 
 void Chart2ExportTest::testErrorBarDataRangeODS()
 {
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 6a52df0..71b20e7 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -67,6 +67,8 @@ public:
 
     uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape );
 
+    uno::Reference<chart::XChartDocument> getChartDocFromWriter( sal_Int32 nShape );
+
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
 
@@ -292,6 +294,46 @@ uno::Sequence < OUString > getWriterChartColumnDescriptions( Reference< lang::XC
     return seriesList;
 }
 
+std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Reference<chart2::XChartType>& xCT )
+{
+    OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel();
+
+    Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xDSCont.is());
+    Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength());
+
+    std::vector<uno::Sequence<uno::Any> > aRet;
+    for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+    {
+        uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
+        CPPUNIT_ASSERT(xDSrc.is());
+        uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+        for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+        {
+            Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
+            CPPUNIT_ASSERT(xValues.is());
+            Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
+            if (!xPropSet.is())
+                continue;
+
+            OUString aRoleName;
+            xPropSet->getPropertyValue("Role") >>= aRoleName;
+            if (aRoleName == aLabelRole)
+            {
+                Reference<chart2::data::XLabeledDataSequence> xLabel = aDataSeqs[j];
+                CPPUNIT_ASSERT(xLabel.is());
+                Reference<chart2::data::XDataSequence> xDS2 = xLabel->getLabel();
+                CPPUNIT_ASSERT(xDS2.is());
+                uno::Sequence<uno::Any> aData = xDS2->getData();
+                aRet.push_back(aData);
+            }
+        }
+    }
+
+    return aRet;
+}
+
 uno::Reference< chart::XChartDocument > ChartTest::getChartDocFromImpress( const char* pDir, const char* pName )
 {
     mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.comp.Draw.PresentationDocument");
@@ -337,6 +379,25 @@ uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromDrawImpress(
     return xChartDoc;
 }
 
+uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromWriter( sal_Int32 nShape )
+{
+    Reference<drawing::XDrawPageSupplier> xPageSupp(mxComponent, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xPageSupp.is());
+
+    Reference<drawing::XDrawPage> xPage = xPageSupp->getDrawPage();
+    CPPUNIT_ASSERT(xPage.is());
+
+    Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(nShape), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xShapeProps.is());
+
+    Reference<frame::XModel> xDocModel;
+    xShapeProps->getPropertyValue("Model") >>= xDocModel;
+    CPPUNIT_ASSERT(xDocModel.is());
+
+    uno::Reference<chart::XChartDocument> xChartDoc(xDocModel, uno::UNO_QUERY);
+    return xChartDoc;
+}
+
 uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const char* pDir, const char* pName )
 {
     uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromImpress( pDir, pName );
diff --git a/chart2/qa/extras/data/odg/scatter-plot-labels.odg b/chart2/qa/extras/data/odg/scatter-plot-labels.odg
deleted file mode 100644
index af0dfee..0000000
Binary files a/chart2/qa/extras/data/odg/scatter-plot-labels.odg and /dev/null differ
diff --git a/chart2/qa/extras/data/odt/scatter-plot-labels.odt b/chart2/qa/extras/data/odt/scatter-plot-labels.odt
new file mode 100644
index 0000000..ab8f243
Binary files /dev/null and b/chart2/qa/extras/data/odt/scatter-plot-labels.odt differ
commit 51d1545e0ce8b30eea710501b84853288dd2563b
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jun 11 17:51:14 2014 +0200

    writerfilter: Kill debug_logger.
    
    Does not really log interesting stuff; if anybody wants some kind of logging
    like this, better to use SAL_INFO(), and add it only for really interesting
    stuff.
    
    Change-Id: I11b4caa9660aaf1e70819322b7fc207a544ea3bb

diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
index 353565f..14d5877 100644
--- a/writerfilter/source/filter/ImportFilter.cxx
+++ b/writerfilter/source/filter/ImportFilter.cxx
@@ -81,11 +81,6 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
         OUString sURL = aMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL(), OUString() );
         ::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr();
 
-        writerfilter::TagLogger::Pointer_t debugLogger
-        (writerfilter::TagLogger::getInstance("DEBUG"));
-        debugLogger->setFileName(sURLc);
-        debugLogger->startDocument();
-
         writerfilter::TagLogger::Pointer_t dmapperLogger
         (writerfilter::TagLogger::getInstance("DOMAINMAPPER"));
         dmapperLogger->setFileName(sURLc);
@@ -184,10 +179,9 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
     }
 
     pStream.reset();
-#ifdef DEBUG_IMPORT
 
+#ifdef DEBUG_IMPORT
     dmapperLogger->endDocument();
-    debugLogger->endDocument();
 #endif
 
     return sal_True;
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 5b45c82..aca59c1 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -31,7 +31,6 @@
 #include "OOXMLBinaryObjectReference.hxx"
 #include "OOXMLFastDocumentHandler.hxx"
 #include "OOXMLPropertySetImpl.hxx"
-#include "ooxmlLoggers.hxx"
 
 #include <tools/resmgr.hxx>
 #include <vcl/svapp.hxx>
@@ -48,10 +47,6 @@ namespace writerfilter {
 namespace ooxml
 {
 
-#if OSL_DEBUG_LEVEL > 1
-TagLogger::Pointer_t debug_logger(TagLogger::getInstance("DEBUG"));
-#endif
-
 OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator)
     : mpStream(pStream)
     , mxStatusIndicator(xStatusIndicator)
@@ -284,12 +279,6 @@ writerfilter::Reference<Stream>::Pointer_t
 OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rType,
                                   const sal_Int32 nId)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("getXNoteStream");
-    debug_logger->attribute("id", nId);
-    debug_logger->endElement();
-#endif
-
     OOXMLStream::Pointer_t pStream =
         (OOXMLDocumentFactory::createStream(mpStream, nType));
     // See above, no status indicator for the note stream, either.
@@ -445,10 +434,6 @@ void OOXMLDocumentImpl::resolveFooter(Stream & rStream,
 
 void OOXMLDocumentImpl::resolve(Stream & rStream)
 {
-#ifdef DEBUG_RESOLVE
-    debug_logger->startElement("OOXMLDocumentImpl.resolve");
-#endif
-
     uno::Reference< xml::sax::XFastParser > xParser
         (mpStream->getFastParser());
 
@@ -517,18 +502,11 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
             xParser->parseStream(aParserInput);
         }
         catch (...) {
-#ifdef DEBUG_ELEMENT
-            debug_logger->element("exception");
-#endif
         }
     }
 
     if (mxStatusIndicator.is())
         mxStatusIndicator->end();
-
-#ifdef DEBUG_RESOLVE
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLDocumentImpl::incrementProgress()
diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx
index 1f778c3..834d7a6 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.cxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.cxx
@@ -125,14 +125,6 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
 
     if (pFactory.get() != NULL)
     {
-#ifdef DEBUG_FACTORY
-        debug_logger->startElement("factory.attributes");
-        debug_logger->attribute("define", pFactory->getDefineName(nDefine));
-        char sBuffer[256];
-        snprintf(sBuffer, sizeof(sBuffer), "%08" SAL_PRIxUINT32, nDefine);
-        debug_logger->attribute("define-num", sBuffer);
-#endif
-
         TokenToIdMapPointer pTokenToIdMap = pFactory->getTokenToIdMap(nDefine);
         AttributeToResourceMapPointer pMap = pFactory->getAttributeToResourceMap(nDefine);
 
@@ -142,22 +134,12 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
         for (aIt = pMap->begin(); aIt != aEndIt; ++aIt)
         {
             Id nId = (*pTokenToIdMap)[aIt->first];
-#ifdef DEBUG_FACTORY
-            debug_logger->startElement("factory.attribute");
-            debug_logger->attribute("name", fastTokenToId(aIt->first));
-            debug_logger->attribute("tokenid", (*QNameToString::Instance())(nId));
-            snprintf(sBuffer, sizeof(sBuffer), "%08" SAL_PRIxUINT32, nId);
-            debug_logger->attribute("tokenid-num", sBuffer);
-#endif
             if (Attribs->hasAttribute(aIt->first))
             {
                 switch (aIt->second.m_nResource)
                 {
                 case RT_Boolean:
                     {
-#ifdef DEBUG_FACTORY
-                        debug_logger->element("boolean");
-#endif
                         OUString aValue(Attribs->getValue(aIt->first));
                         OOXMLFastHelper<OOXMLBooleanValue>::newProperty(pHandler, nId, aValue);
 
@@ -167,9 +149,6 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                     break;
                 case RT_String:
                     {
-#ifdef DEBUG_FACTORY
-                        debug_logger->element("string");
-#endif
                         OUString aValue(Attribs->getValue(aIt->first));
                         OOXMLFastHelper<OOXMLStringValue>::newProperty
                             (pHandler, nId, aValue);
@@ -180,9 +159,6 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                     break;
                 case RT_Integer:
                     {
-#ifdef DEBUG_FACTORY
-                        debug_logger->element("integer");
-#endif
                         OUString aValue(Attribs->getValue(aIt->first));
                         OOXMLFastHelper<OOXMLIntegerValue>::newProperty
                             (pHandler, nId, aValue);
@@ -193,9 +169,6 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                     break;
                 case RT_Hex:
                     {
-#ifdef DEBUG_FACTORY
-                        debug_logger->element("hex");
-#endif
                         OUString aValue(Attribs->getValue(aIt->first));
                         OOXMLFastHelper<OOXMLHexValue>::newProperty
                             (pHandler, nId, aValue);
@@ -206,9 +179,6 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                     break;
                 case RT_UniversalMeasure:
                     {
-#ifdef DEBUG_FACTORY
-                        debug_logger->element("universalMeasure");
-#endif
                         OUString aValue(Attribs->getValue(aIt->first));
                         OOXMLFastHelper<OOXMLUniversalMeasureValue>::newProperty(pHandler, nId, aValue);
 
@@ -218,9 +188,6 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                     break;
                 case RT_List:
                     {
-#ifdef DEBUG_FACTORY
-                        debug_logger->startElement("list");
-#endif
                         ListValueMapPointer pListValueMap =
                             pFactory->getListValueMap(aIt->second.m_nRef);
 
@@ -229,37 +196,19 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
                             OUString aValue(Attribs->getValue(aIt->first));
                             sal_uInt32 nValue = (*pListValueMap)[aValue];
 
-#ifdef DEBUG_FACTORY
-                            debug_logger->attribute("value", aValue);
-                            debug_logger->attribute("value-num", nValue);
-#endif
-
                             OOXMLFastHelper<OOXMLIntegerValue>::newProperty
                                 (pHandler, nId, nValue);
 
                             OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(nValue));
                             pFactory->attributeAction(pHandler, aIt->first, pValue);
                         }
-#ifdef DEBUG_FACTORY
-                        debug_logger->endElement();
-#endif
                     }
                     break;
                 default:
-#ifdef DEBUG_FACTORY
-                    debug_logger->element("unknown-attribute-type");
-#endif
                     break;
                 }
             }
-#ifdef DEBUG_FACTORY
-            debug_logger->endElement();
-#endif
         }
-
-#ifdef DEBUG_FACTORY
-        debug_logger->endElement();
-#endif
     }
 }
 
@@ -267,11 +216,6 @@ uno::Reference< xml::sax::XFastContextHandler>
 OOXMLFactory::createFastChildContext(OOXMLFastContextHandler * pHandler,
                                      Token_t Element)
 {
-#ifdef DEBUG_FACTORY
-    debug_logger->startElement("factory.createFastChildContext");
-    debug_logger->attribute("token", fastTokenToId(Element));
-#endif
-
     Id nDefine = pHandler->getDefine();
 
     OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine);
@@ -282,21 +226,12 @@ OOXMLFactory::createFastChildContext(OOXMLFastContextHandler * pHandler,
     if ((Element & 0xffff) < OOXML_FAST_TOKENS_END)
         ret = createFastChildContextFromFactory(pHandler, pFactory, Element);
 
-#ifdef DEBUG_FACTORY
-    debug_logger->endElement();
-#endif
-
     return ret;
 }
 
 void OOXMLFactory::characters(OOXMLFastContextHandler * pHandler,
                               const OUString & rString)
 {
-#ifdef DEBUG_FACTORY
-    debug_logger->startElement("factory.characters");
-    debug_logger->chars(rString);
-#endif
-
     Id nDefine = pHandler->getDefine();
     OOXMLFactory_ns::Pointer_t pFactory = getFactoryForNamespace(nDefine);
 
@@ -304,10 +239,6 @@ void OOXMLFactory::characters(OOXMLFastContextHandler * pHandler,
     {
         pFactory->charactersAction(pHandler, rString);
     }
-
-#ifdef DEBUG_FACTORY
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLFactory::startAction(OOXMLFastContextHandler * pHandler, Token_t /*nToken*/)
@@ -317,13 +248,7 @@ void OOXMLFactory::startAction(OOXMLFastContextHandler * pHandler, Token_t /*nTo
 
     if (pFactory.get() != NULL)
     {
-#ifdef DEBUG_ELEMENT
-        debug_logger->startElement("factory.startAction");
-#endif
         pFactory->startAction(pHandler);
-#ifdef DEBUG_ELEMENT
-        debug_logger->endElement();
-#endif
     }
 }
 
@@ -334,13 +259,7 @@ void OOXMLFactory::endAction(OOXMLFastContextHandler * pHandler, Token_t /*nToke
 
     if (pFactory.get() != NULL)
     {
-#ifdef DEBUG_ELEMENT
-        debug_logger->startElement("factory.endAction");
-#endif
         pFactory->endAction(pHandler);
-#ifdef DEBUG_ELEMENT
-        debug_logger->endElement();
-#endif
     }
 }
 
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index cd71adbb..4fb0d49 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -38,7 +38,6 @@
 #include "OOXMLFastContextHandler.hxx"
 #include "OOXMLFactory.hxx"
 #include "Handler.hxx"
-#include "ooxmlLoggers.hxx"
 
 static const sal_Unicode uCR = 0xd;
 static const sal_Unicode uFtnEdnRef = 0x2;
@@ -219,17 +218,6 @@ void SAL_CALL OOXMLFastContextHandler::startFastElement
  const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.element");
-    string sToken = fastTokenToId(Element);
-    mpParserState->getXPathLogger().startElement(sToken);
-    debug_logger->attribute("token", sToken);
-    debug_logger->attribute("type", getType());
-    debug_logger->attribute("xpath", mpParserState->getXPathLogger().getXPath());
-    debug_logger->startElement("at-start");
-    dumpXml( debug_logger );
-    debug_logger->endElement();
-#endif
     if (oox::getNamespace(Element) == static_cast<sal_Int32>(NS_mce))
         m_bDiscardChildren = prepareMceContext(Element, Attribs);
 
@@ -241,29 +229,15 @@ void SAL_CALL OOXMLFastContextHandler::startFastElement
 }
 
 void SAL_CALL OOXMLFastContextHandler::startUnknownElement
-(const OUString & Namespace, const OUString & Name,
+(const OUString & /*Namespace*/, const OUString & /*Name*/,
  const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
 throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.unknown-element");
-    debug_logger->attribute("namespace", Namespace);
-    debug_logger->attribute("name", Name);
-    mpParserState->getXPathLogger().startElement("unknown");
-#else
-    (void) Namespace;
-    (void) Name;
-#endif
 }
 
 void SAL_CALL OOXMLFastContextHandler::endFastElement(Token_t Element)
 throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    string sToken = fastTokenToId(Element);
-    (void) sToken;
-#endif
-
     if (Element == (NS_mce | OOXML_Choice) || Element == (NS_mce | OOXML_Fallback))
         m_bDiscardChildren = false;
     else if (Element == (NS_mce | OOXML_AlternateContent))
@@ -273,17 +247,8 @@ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
         m_bDiscardChildren = aState.m_bDiscardChildren;
         m_bTookChoice = aState.m_bTookChoice;
     }
-
     else if (!m_bDiscardChildren)
         lcl_endFastElement(Element);
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("at-end");
-    dumpXml( debug_logger );
-    debug_logger->endElement();
-    debug_logger->endElement();
-    mpParserState->getXPathLogger().endElement();
-#endif
 }
 
 void OOXMLFastContextHandler::lcl_startFastElement
@@ -310,10 +275,6 @@ void SAL_CALL OOXMLFastContextHandler::endUnknownElement
 (const OUString & , const OUString & )
 throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-    mpParserState->getXPathLogger().endElement();
-#endif
 }
 
 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
@@ -322,23 +283,12 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
  const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.createFastChildContext");
-    debug_logger->attribute("token", fastTokenToId(Element));
-    debug_logger->attribute("type", getType());
-    debug_logger->attribute("discard-children", OUString::number(m_bDiscardChildren));
-#endif
-
     uno::Reference< xml::sax::XFastContextHandler > xResult;
     if ((Element & 0xffff0000) != NS_mce && !m_bDiscardChildren)
         xResult.set(lcl_createFastChildContext(Element, Attribs));
     else if ((Element & 0xffff0000) == NS_mce)
         xResult = this;
 
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
-
     return xResult;
 }
 
@@ -358,16 +308,6 @@ OOXMLFastContextHandler::createUnknownChildContext
  const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.createUnknownChildContext");
-    debug_logger->attribute("namespace", Namespace);
-    debug_logger->attribute("name", Name);
-    debug_logger->endElement();
-#else
-    (void) Namespace;
-    (void) Name;
-#endif
-
     return uno::Reference< xml::sax::XFastContextHandler >
         (new OOXMLFastContextHandler(*const_cast<const OOXMLFastContextHandler *>(this)));
 }
@@ -430,33 +370,11 @@ void OOXMLFastContextHandler::attributes
 
 void OOXMLFastContextHandler::startAction(Token_t Element)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.startAction");
-#endif
-    lcl_startAction(Element);
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
-}
-
-void OOXMLFastContextHandler::lcl_startAction(Token_t Element)
-{
     OOXMLFactory::getInstance()->startAction(this, Element);
 }
 
 void OOXMLFastContextHandler::endAction(Token_t Element)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.endAction");
-#endif
-    lcl_endAction(Element);
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
-}
-
-void OOXMLFastContextHandler::lcl_endAction(Token_t Element)
-{
     OOXMLFactory::getInstance()->endAction(this, Element);
 }
 
@@ -493,17 +411,6 @@ void OOXMLFastContextHandler::dumpXml( const TagLogger::Pointer_t pLogger ) cons
 
 void OOXMLFastContextHandler::setId(Id rId)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.setId");
-
-    static char sBuffer[256];
-    snprintf(sBuffer, sizeof(sBuffer), "%" SAL_PRIuUINT32, rId);
-
-    debug_logger->attribute("id", std::string(sBuffer));
-    debug_logger->attribute("name", (*QNameToString::Instance())(rId));
-    debug_logger->endElement();
-#endif
-
     mId = rId;
 }
 
@@ -526,10 +433,6 @@ OOXMLParserState::Pointer_t OOXMLFastContextHandler::getParserState() const
 void OOXMLFastContextHandler::setToken(Token_t nToken)
 {
     mnToken = nToken;
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    msTokenString = fastTokenToId(mnToken);
-#endif
 }
 
 Token_t OOXMLFastContextHandler::getToken() const
@@ -551,10 +454,6 @@ OOXMLPropertySet * OOXMLFastContextHandler::getPicturePropSet
 
 void OOXMLFastContextHandler::sendTableDepth() const
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendTableDepth");
-#endif
-
     if (mnTableDepth > 0)
     {
         OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
@@ -575,9 +474,6 @@ void OOXMLFastContextHandler::sendTableDepth() const
 
         mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
     }
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLFastContextHandler::setHandle()
@@ -588,10 +484,6 @@ void OOXMLFastContextHandler::setHandle()
 
 void OOXMLFastContextHandler::startCharacterGroup()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.startCharacterGroup");
-#endif
-
     if (isForwardEvents())
     {
         if (mpParserState->isInCharacterGroup())
@@ -611,10 +503,6 @@ void OOXMLFastContextHandler::startCharacterGroup()
 
 void OOXMLFastContextHandler::endCharacterGroup()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endCharacterGroup");
-#endif
-
     if (isForwardEvents() && mpParserState->isInCharacterGroup())
     {
         mpStream->endCharacterGroup();
@@ -624,10 +512,6 @@ void OOXMLFastContextHandler::endCharacterGroup()
 
 void OOXMLFastContextHandler::startParagraphGroup()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.startParagraphGroup");
-#endif
-
     if (isForwardEvents())
     {
         if (mpParserState->isInParagraphGroup())
@@ -646,10 +530,6 @@ void OOXMLFastContextHandler::startParagraphGroup()
 
 void OOXMLFastContextHandler::endParagraphGroup()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endParagraphGroup");
-#endif
-
     if (isForwardEvents())
     {
         if (mpParserState->isInCharacterGroup())
@@ -665,10 +545,6 @@ void OOXMLFastContextHandler::endParagraphGroup()
 
 void OOXMLFastContextHandler::startSdt()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.startSdt");
-#endif
-
     OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
     OOXMLValue::Pointer_t pVal(new OOXMLIntegerValue(1));
     OOXMLProperty::Pointer_t pProp(new OOXMLPropertyImpl(NS_ooxml::LN_CT_SdtBlock_sdtContent, pVal, OOXMLPropertyImpl::ATTRIBUTE));
@@ -678,10 +554,6 @@ void OOXMLFastContextHandler::startSdt()
 
 void OOXMLFastContextHandler::endSdt()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endSdt");
-#endif
-
     OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
     OOXMLValue::Pointer_t pVal(new OOXMLIntegerValue(1));
     OOXMLProperty::Pointer_t pProp(new OOXMLPropertyImpl(NS_ooxml::LN_CT_SdtBlock_sdtEndContent, pVal, OOXMLPropertyImpl::ATTRIBUTE));
@@ -691,10 +563,6 @@ void OOXMLFastContextHandler::endSdt()
 
 void OOXMLFastContextHandler::startSectionGroup()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.startSectionGroup");
-#endif
-
     if (isForwardEvents())
     {
         if (mpParserState->isInSectionGroup())
@@ -711,10 +579,6 @@ void OOXMLFastContextHandler::startSectionGroup()
 
 void OOXMLFastContextHandler::endSectionGroup()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endSectionGroup");
-#endif
-
     if (isForwardEvents())
     {
         if (mpParserState->isInParagraphGroup())
@@ -751,9 +615,6 @@ OOXMLPropertySet::Pointer_t OOXMLFastContextHandler::getPropertySet() const
 
 void OOXMLFastContextHandler::startField()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.startField");
-#endif
     startCharacterGroup();
     if (isForwardEvents())
         mpStream->text(&cFieldStart, 1);
@@ -762,9 +623,6 @@ void OOXMLFastContextHandler::startField()
 
 void OOXMLFastContextHandler::fieldSeparator()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.fieldSeparator");
-#endif
     startCharacterGroup();
     if (isForwardEvents())
         mpStream->text(&cFieldSep, 1);
@@ -773,9 +631,6 @@ void OOXMLFastContextHandler::fieldSeparator()
 
 void OOXMLFastContextHandler::endField()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endField");
-#endif
     startCharacterGroup();
     if (isForwardEvents())
         mpStream->text(&cFieldEnd, 1);
@@ -784,82 +639,54 @@ void OOXMLFastContextHandler::endField()
 
 void OOXMLFastContextHandler::ftnednref()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.ftnednref");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uFtnEdnRef, 1);
 }
 
 void OOXMLFastContextHandler::ftnednsep()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.ftnednsep");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uFtnEdnSep, 1);
 }
 
 void OOXMLFastContextHandler::ftnedncont()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.ftnedncont");
-#endif
     if (isForwardEvents())
         mpStream->text(&cFtnEdnCont, 1);
 }
 
 void OOXMLFastContextHandler::pgNum()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.pgNum");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uPgNum, 1);
 }
 
 void OOXMLFastContextHandler::tab()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.tab");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uTab, 1);
 }
 
 void OOXMLFastContextHandler::cr()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.cr");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uCR, 1);
 }
 
 void OOXMLFastContextHandler::noBreakHyphen()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.noBreakHyphen");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uNoBreakHyphen, 1);
 }
 
 void OOXMLFastContextHandler::softHyphen()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.softHyphen");
-#endif
     if (isForwardEvents())
         mpStream->utext((const sal_uInt8*)&uSoftHyphen, 1);
 }
 
 void OOXMLFastContextHandler::handleLastParagraphInSection()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.handleLastParagraphInSection");
-#endif
-
     if (mpParserState->isLastParagraphInSection())
     {
         mpParserState->setLastParagraphInSection(false);
@@ -869,9 +696,6 @@ void OOXMLFastContextHandler::handleLastParagraphInSection()
 
 void OOXMLFastContextHandler::endOfParagraph()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endOfParagraph");
-#endif
     if (! mpParserState->isInCharacterGroup())
         startCharacterGroup();
     if (isForwardEvents())
@@ -882,9 +706,6 @@ void OOXMLFastContextHandler::endOfParagraph()
 
 void OOXMLFastContextHandler::startTxbxContent()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.startTxbxContent");
-#endif
 /*
     This usually means there are recursive <w:p> elements, and the ones
     inside and outside of w:txbxContent should not interfere (e.g.
@@ -899,20 +720,12 @@ void OOXMLFastContextHandler::startTxbxContent()
 
 void OOXMLFastContextHandler::endTxbxContent()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.endTxbxContent");
-#endif
     endParagraphGroup();
     mpParserState->endTxbxContent();
 }
 
 void OOXMLFastContextHandler::text(const OUString & sText)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.text");
-    debug_logger->chars(sText);
-    debug_logger->endElement();
-#endif
     if (isForwardEvents())
         mpStream->utext(reinterpret_cast < const sal_uInt8 * >
                         (sText.getStr()),
@@ -931,69 +744,35 @@ void OOXMLFastContextHandler::text(const OUString & sText)
 */
 void OOXMLFastContextHandler::positionOffset(const OUString & sText)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("positionOffset");
-    debug_logger->chars(sText);
-    debug_logger->endElement();
-#endif
     if (isForwardEvents())
         ::writerfilter::dmapper::PositionHandler::setPositionOffset( sText, inPositionV );
 }
 
 void OOXMLFastContextHandler::alignH(const OUString & sText)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("alignH");
-    debug_logger->chars(sText);
-    debug_logger->endElement();
-#endif
     if (isForwardEvents())
         ::writerfilter::dmapper::PositionHandler::setAlignH( sText );
 }
 
 void OOXMLFastContextHandler::alignV(const OUString & sText)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("alignV");
-    debug_logger->chars(sText);
-    debug_logger->endElement();
-#endif
     if (isForwardEvents())
         ::writerfilter::dmapper::PositionHandler::setAlignV( sText );
 }
 
 void OOXMLFastContextHandler::positivePercentage(const OUString& rText)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("positivePercentage");
-    debug_logger->chars(rText);
-    debug_logger->endElement();
-#endif
     if (isForwardEvents())
         mpStream->positivePercentage(rText);
 }
 
 void OOXMLFastContextHandler::propagateCharacterProperties()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.propagateCharacterProperties");
-    debug_logger->propertySet(getPropertySet(),
-            IdToString::Pointer_t(new OOXMLIdToString()));
-    debug_logger->endElement();
-#endif
-
     mpParserState->setCharacterProperties(getPropertySet());
 }
 
 void OOXMLFastContextHandler::propagateCharacterPropertiesAsSet(const Id & rId)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.propagateCharacterPropertiesAsSet");
-    debug_logger->propertySet(getPropertySet(),
-            IdToString::Pointer_t(new OOXMLIdToString()));
-    debug_logger->endElement();
-#endif
-
     OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet()));
     OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySetImpl());
 
@@ -1011,91 +790,44 @@ bool OOXMLFastContextHandler::propagatesProperties() const
 
 void OOXMLFastContextHandler::propagateCellProperties()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.propagateCellProperties");
-#endif
-
     mpParserState->setCellProperties(getPropertySet());
 }
 
 void OOXMLFastContextHandler::propagateRowProperties()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.propagateRowProperties");
-#endif
-
     mpParserState->setRowProperties(getPropertySet());
 }
 
 void OOXMLFastContextHandler::propagateTableProperties()
 {
     OOXMLPropertySet::Pointer_t pProps = getPropertySet();
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.propagateTableProperties");
-    debug_logger->propertySet(getPropertySet(),
-            IdToString::Pointer_t(new OOXMLIdToString()));
-    debug_logger->endElement();
-#endif
 
     mpParserState->setTableProperties(pProps);
 }
 
 void OOXMLFastContextHandler::sendCellProperties()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendCellProperties");
-#endif
-
     mpParserState->resolveCellProperties(*mpStream);
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLFastContextHandler::sendRowProperties()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendRowProperties");
-#endif
-
     mpParserState->resolveRowProperties(*mpStream);
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLFastContextHandler::sendTableProperties()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendTableProperties");
-#endif
-
     mpParserState->resolveTableProperties(*mpStream);
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLFastContextHandler::clearTableProps()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.clearTableProps");
-#endif
-
     mpParserState->setTableProperties(OOXMLPropertySet::Pointer_t
                                      (new OOXMLPropertySetImpl()));
 }
 
 void OOXMLFastContextHandler::sendPropertiesWithId(const Id & rId)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendPropertiesWithId");
-    debug_logger->attribute("id", fastTokenToId(rId));
-#endif
-
     OOXMLValue::Pointer_t pValue(new OOXMLPropertySetValue(getPropertySet()));
     OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySetImpl());
 
@@ -1104,20 +836,10 @@ void OOXMLFastContextHandler::sendPropertiesWithId(const Id & rId)
 
     pPropertySet->add(pProp);
     mpStream->props(pPropertySet);
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->propertySet(getPropertySet(),
-            IdToString::Pointer_t(new OOXMLIdToString()));
-    debug_logger->endElement();
-#endif
 }
 
 void OOXMLFastContextHandler::clearProps()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("contexthandler.clearProps");
-#endif
-
     setPropertySet(OOXMLPropertySet::Pointer_t(new OOXMLPropertySetImpl()));
 }
 
@@ -1149,17 +871,6 @@ OOXMLDocumentImpl* OOXMLFastContextHandler::getDocument()
 
 void OOXMLFastContextHandler::setForwardEvents(bool bForwardEvents)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.setForwardEvents");
-
-    if (bForwardEvents)
-        debug_logger->chars(std::string("true"));
-    else
-        debug_logger->chars(std::string("false"));
-
-    debug_logger->endElement();
-#endif
-
     mpParserState->setForwardEvents(bForwardEvents);
 }
 
@@ -1246,10 +957,6 @@ void OOXMLFastContextHandler::resolvePropertySetAttrs()
 
 void OOXMLFastContextHandler::sendPropertyToParent()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->element("sendPropertyToParent");
-#endif
-
     if (mpParent != NULL)
     {
         OOXMLPropertySet::Pointer_t pProps(mpParent->getPropertySet());
@@ -1266,9 +973,6 @@ void OOXMLFastContextHandler::sendPropertyToParent()
 
 void OOXMLFastContextHandler::sendPropertiesToParent()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendPropertiesToParent");
-#endif
     if (mpParent != NULL)
     {
         OOXMLPropertySet::Pointer_t pParentProps(mpParent->getPropertySet());
@@ -1291,9 +995,6 @@ void OOXMLFastContextHandler::sendPropertiesToParent()
             }
         }
     }
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
 }
 
 uno::Reference< uno::XComponentContext >
@@ -1331,13 +1032,6 @@ void OOXMLFastContextHandlerStream::newProperty(const Id & rId,
 
 void OOXMLFastContextHandlerStream::sendProperty(Id nId)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.sendProperty");
-    debug_logger->attribute("id", (*QNameToString::Instance())(nId));
-    debug_logger->chars(xmlify(getPropertySetAttrs()->toString()));
-    debug_logger->endElement();
-#endif
-
     OOXMLPropertySetEntryToString aHandler(nId);
     getPropertySetAttrs()->resolve(aHandler);
     const OUString & sText = aHandler.getString();
@@ -1354,11 +1048,6 @@ OOXMLFastContextHandlerStream::getPropertySetAttrs() const
 
 void OOXMLFastContextHandlerStream::resolvePropertySetAttrs()
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-        debug_logger->startElement("contexthandler.resolvePropertySetAttrs");
-        debug_logger->chars(mpPropertySetAttrs->toString());
-        debug_logger->endElement();
-#endif
     mpStream->props(mpPropertySetAttrs);
 }
 
@@ -1502,40 +1191,24 @@ void OOXMLFastContextHandlerProperties::handleHdrFtr()
 
 void OOXMLFastContextHandlerProperties::handleComment()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("handleComment");
-#endif
-
     OOXMLCommentHandler aCommentHandler(this);
     getPropertySet()->resolve(aCommentHandler);
 }
 
 void OOXMLFastContextHandlerProperties::handlePicture()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("handlePicture");
-#endif
-
     OOXMLPictureHandler aPictureHandler(this);
     getPropertySet()->resolve(aPictureHandler);
 }
 
 void OOXMLFastContextHandlerProperties::handleBreak()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("handleBreak");
-#endif
-
     OOXMLBreakHandler aBreakHandler(*mpStream);
     getPropertySet()->resolve(aBreakHandler);
 }
 
 void OOXMLFastContextHandlerProperties::handleOLE()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("handleOLE");
-#endif
-
     OOXMLOLEHandler aOLEHandler(this);
     getPropertySet()->resolve(aOLEHandler);
 }
@@ -1549,12 +1222,6 @@ void OOXMLFastContextHandlerProperties::handleFontRel()
 void OOXMLFastContextHandlerProperties::setParent
 (OOXMLFastContextHandler * pParent)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("setParent");
-    debug_logger->chars(std::string("OOXMLFastContextHandlerProperties"));
-    debug_logger->endElement();
-#endif
-
     OOXMLFastContextHandler::setParent(pParent);
 
     if (mpParent->getResource() == STREAM)
@@ -1600,12 +1267,6 @@ void OOXMLFastContextHandlerPropertyTable::lcl_endFastElement
 
     writerfilter::Reference<Table>::Pointer_t pTable(mTable.clone());
 
-#ifdef DEBUG_PROPERTIES
-    debug_logger->startElement("table");
-    debug_logger->attribute("id", (*QNameToString::Instance())(mId));
-    debug_logger->endElement();
-#endif
-
     mpStream->table(mId, pTable);
 
     endAction(Element);
@@ -1627,16 +1288,7 @@ OOXMLFastContextHandlerValue::~OOXMLFastContextHandlerValue()
 
 void OOXMLFastContextHandlerValue::setValue(OOXMLValue::Pointer_t pValue)
 {
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->startElement("contexthandler.setValue");
-    debug_logger->attribute("value", pValue->toString());
-#endif
-
     mpValue = pValue;
-
-#ifdef DEBUG_CONTEXT_HANDLER
-    debug_logger->endElement();
-#endif
 }
 
 OOXMLValue::Pointer_t OOXMLFastContextHandlerValue::getValue() const
@@ -1655,10 +1307,6 @@ throw (uno::RuntimeException, xml::sax::SAXException)
 
 void OOXMLFastContextHandlerValue::setDefaultBooleanValue()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("setDefaultBooleanValue");
-#endif
-
     if (mpValue.get() == NULL)
     {
         OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(true));
@@ -1668,10 +1316,6 @@ void OOXMLFastContextHandlerValue::setDefaultBooleanValue()
 
 void OOXMLFastContextHandlerValue::setDefaultIntegerValue()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("setDefaultIntegerValue");
-#endif
-
     if (mpValue.get() == NULL)
     {
         OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(0));
@@ -1681,10 +1325,6 @@ void OOXMLFastContextHandlerValue::setDefaultIntegerValue()
 
 void OOXMLFastContextHandlerValue::setDefaultHexValue()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("setDefaultHexValue");
-#endif
-
     if (mpValue.get() == NULL)
     {
         OOXMLValue::Pointer_t pValue(new OOXMLHexValue(0));
@@ -1694,10 +1334,6 @@ void OOXMLFastContextHandlerValue::setDefaultHexValue()
 
 void OOXMLFastContextHandlerValue::setDefaultStringValue()
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->element("setDefaultStringValue");
-#endif
-
     if (mpValue.get() == NULL)
     {
         OOXMLValue::Pointer_t pValue(new OOXMLStringValue(OUString()));
@@ -1740,13 +1376,6 @@ void OOXMLFastContextHandlerTable::lcl_endFastElement
     writerfilter::Reference<Table>::Pointer_t pTable(mTable.clone());
     if (isForwardEvents() && mId != 0x0)
     {
-#ifdef DEBUG_PROPERTIES
-        debug_logger->startElement("table");
-        string str = (*QNameToString::Instance())(mId);
-        debug_logger->attribute("id", str);
-        debug_logger->endElement();
-#endif
-
         mpStream->table(mId, pTable);
     }
 }
@@ -1818,23 +1447,11 @@ void OOXMLFastContextHandlerXNote::lcl_endFastElement
 
 void OOXMLFastContextHandlerXNote::checkId(OOXMLValue::Pointer_t pValue)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("checkId");
-    debug_logger->attribute("myId", sal_Int32(pValue->getInt()));
-    debug_logger->attribute("id", getXNoteId());
-    debug_logger->endElement();
-#endif
-
     mnMyXNoteId = sal_Int32(pValue->getInt());
 }
 
 void OOXMLFastContextHandlerXNote::checkType(OOXMLValue::Pointer_t pValue)
 {
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("checkType");
-    debug_logger->attribute("myType", sal_Int32(pValue->getInt()));
-    debug_logger->endElement();
-#endif
     mnMyXNoteType = pValue->getInt();
 }
 
@@ -1883,12 +1500,6 @@ void OOXMLFastContextHandlerTextTableCell::endCell()
             pProps->add(pProp);
         }
 
-#ifdef DEBUG_PROPERTIES
-        debug_logger->startElement("endcell");
-        debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()),
-                IdToString::Pointer_t(new OOXMLIdToString()));
-        debug_logger->endElement();
-#endif
         mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
     }
 }
@@ -1940,13 +1551,6 @@ void OOXMLFastContextHandlerTextTableRow::endRow()
             pProps->add(pProp);
         }
 
-#ifdef DEBUG_PROPERTIES
-        debug_logger->startElement("endrow");
-        debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()),
-                IdToString::Pointer_t(new OOXMLIdToString()));
-        debug_logger->endElement();
-#endif
-
         mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
     }
 
@@ -1996,12 +1600,6 @@ void OOXMLFastContextHandlerTextTableRow::handleGridBefore( OOXMLValue::Pointer_
                 pProps->add(pProp);
             }
 
-    #ifdef DEBUG_PROPERTIES
-            debug_logger->startElement("handlegridbefore");
-            debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()),
-                    IdToString::Pointer_t(new OOXMLIdToString()));
-            debug_logger->endElement();
-    #endif
             mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps));
 
             // fake <w:tcBorders> with no border
@@ -2116,11 +1714,6 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape
     mrShapeContext->setDrawPage(getDocument()->getDrawPage());
     mrShapeContext->setInputStream(getDocument()->getStorageStream());
 
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("setRelationFragmentPath");
-    debug_logger->attribute("path", mpParserState->getTarget());
-    debug_logger->endElement();
-#endif
     mrShapeContext->setRelationFragmentPath
         (mpParserState->getTarget());
 }
@@ -2406,22 +1999,6 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
 
     Id nNameSpace = Element & 0xffff0000;
 
-#ifdef DEBUG_ELEMENT
-    debug_logger->startElement("Wrapper-createChildContext");
-    debug_logger->attribute("token", fastTokenToId(Element));
-
-    const set<Id>::const_iterator aEnd(mMyNamespaces.end());
-    for (set<Id>::const_iterator aIt(mMyNamespaces.begin());
-         aIt != aEnd; ++aIt)
-    {
-        debug_logger->startElement("namespace");
-        debug_logger->attribute("id", fastTokenToId(*aIt));
-        debug_logger->endElement();
-    }
-
-    debug_logger->endElement();
-#endif
-
     bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end();
     bool bInTokens = mMyTokens.find( Element ) != mMyTokens.end( );
 
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index afc685b..0590638 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -243,10 +243,6 @@ protected:
     Id mnDefine;
     Token_t mnToken;
 
-#ifdef DEBUG_CONTEXT_HANDLER
-    string msTokenString;
-#endif
-
     // the stream to send the stream events to.
     Stream * mpStream;
 
@@ -274,10 +270,7 @@ protected:
         throw (uno::RuntimeException, xml::sax::SAXException);
 
     void startAction(Token_t Element);
-    virtual void lcl_startAction(Token_t Element);
     void endAction(Token_t Element);
-    virtual void lcl_endAction(Token_t Element);
-
 
     virtual OOXMLPropertySet * getPicturePropSet
     (const OUString & rId);
diff --git a/writerfilter/source/ooxml/OOXMLFastHelper.hxx b/writerfilter/source/ooxml/OOXMLFastHelper.hxx
index 93281dc..b272683 100644
--- a/writerfilter/source/ooxml/OOXMLFastHelper.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastHelper.hxx
@@ -22,7 +22,7 @@
 #include <iostream>
 #include <resourcemodel/QNameToString.hxx>
 #include "OOXMLFastContextHandler.hxx"
-#include "ooxmlLoggers.hxx"
+
 namespace writerfilter {
 
 namespace ooxml
@@ -52,31 +52,12 @@ uno::Reference<css::xml::sax::XFastContextHandler>
 OOXMLFastHelper<T>::createAndSetParentAndDefine
 (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken, Id nId, Id nDefine)
 {
-#ifdef DEBUG_HELPER
-    debug_logger->startElement("helper.createAndSetParentAndDefine");
-    debug_logger->attribute("context", pHandler->getType());
-    debug_logger->attribute("id", (*QNameToString::Instance())(nId));
-
-    static char buffer[16];
-    snprintf(buffer, sizeof(buffer), "0x%08" SAL_PRIxUINT32, nId);
-
-    debug_logger->attribute("idnum", buffer);
-#endif
-
     OOXMLFastContextHandler * pTmp = new T(pHandler);
 
     pTmp->setToken(nToken);
     pTmp->setId(nId);
     pTmp->setDefine(nDefine);
 
-
-#ifdef DEBUG_HELPER
-    debug_logger->startElement("created");
-    debug_logger->addTag(pTmp->toTag());
-    debug_logger->endElement("created");
-    debug_logger->endElement("helper.createAndSetParentAndDefine");
-#endif
-
     css::uno::Reference<css::xml::sax::XFastContextHandler> aResult(pTmp);
 
     return aResult;
@@ -89,26 +70,7 @@ void OOXMLFastHelper<T>::newProperty(OOXMLFastContextHandler * pHandler,
 {
     OOXMLValue::Pointer_t pVal(new T(rValue));
 
-#ifdef DEBUG_HELPER
-    string aStr = (*QNameToString::Instance())(nId);
-
-    debug_logger->startElement("newProperty-from-string");
-    debug_logger->attribute("name", aStr);
-    debug_logger->attribute
-        ("value",
-         OUStringToOString
-         (rValue, RTL_TEXTENCODING_ASCII_US).getStr());
-
-    if (aStr.empty())
-        debug_logger->element( "unknown-qname" );
-#endif
-
     pHandler->newProperty(nId, pVal);
-
-#ifdef DEBUG_HELPER
-    debug_logger->endElement();
-#endif
-
 }
 
 template <class T>
@@ -118,19 +80,6 @@ void OOXMLFastHelper<T>::newProperty(OOXMLFastContextHandler * pHandler,
 {
     OOXMLValue::Pointer_t pVal(new T(nVal));
 
-#ifdef DEBUG_HELPER
-    string aStr = (*QNameToString::Instance())(nId);
-
-    debug_logger->startElement("helper.newProperty-from-int");
-    debug_logger->attribute("name", aStr);
-    debug_logger->attribute("value", pVal->toString());
-
-    if (aStr.empty())
-        debug_logger->element("unknown-qname");
-
-    debug_logger->endElement();
-#endif
-
     pHandler->newProperty(nId, pVal);
 }
 
diff --git a/writerfilter/source/ooxml/OOXMLParserState.cxx b/writerfilter/source/ooxml/OOXMLParserState.cxx
index e74a81c5..130520d 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.cxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.cxx
@@ -20,7 +20,6 @@
 #include <stdio.h>
 #include <iostream>
 #include "OOXMLParserState.hxx"
-#include "ooxmlLoggers.hxx"
 
 namespace writerfilter {
 namespace ooxml
@@ -118,16 +117,8 @@ void OOXMLParserState::resolveCharacterProperties(Stream & rStream)
 {
     if (mpCharacterProps.get() != NULL)
     {
-#ifdef DEBUG_PROPERTIES
-        debug_logger->startElement("resolveCharacterProperties");
-#endif
-
         rStream.props(mpCharacterProps);
         mpCharacterProps.reset(new OOXMLPropertySetImpl());
-
-#ifdef DEBUG_PROPERTIES
-        debug_logger->endElement();
-#endif
     }
 }
 
diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
index 76fa69b..7fd8934 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
@@ -23,7 +23,6 @@
 #include <resourcemodel/QNameToString.hxx>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <ooxml/OOXMLFastTokens.hxx>
-#include "ooxmlLoggers.hxx"
 #include <ooxml/resourceids.hxx>
 
 namespace writerfilter {
@@ -401,28 +400,16 @@ OOXMLPropertySetImpl::~OOXMLPropertySetImpl()
 
 void OOXMLPropertySetImpl::resolve(Properties & rHandler)
 {
-    size_t nIt = 0;
-
     // The pProp->resolve(rHandler) call below can cause elements to
     // be appended to mProperties. I don't think it can cause elements
     // to be deleted. But let's check with < here just to be safe that
     // the indexing below works.
-    while (nIt < mProperties.size())
+    for (size_t nIt = 0; nIt < mProperties.size(); ++nIt)
     {
         OOXMLProperty::Pointer_t pProp = mProperties[nIt];
 
         if (pProp.get() != NULL)
             pProp->resolve(rHandler);
-#ifdef DEBUG_RESOLVE
-        else
-        {
-            debug_logger->startElement("error");
-            debug_logger->chars(std::string("zero-property"));
-            debug_logger->endElement();
-        }
-#endif
-
-        ++nIt;
     }
 }
 
@@ -455,11 +442,6 @@ string OOXMLPropertySetImpl::getType() const
 
 void OOXMLPropertySetImpl::add(OOXMLProperty::Pointer_t pProperty)
 {
-#ifdef DEBUG_PROPERTY_SET
-    debug_logger->startElement("propertyset.add");
-    debug_logger->chars(pProperty->toString());
-#endif
-

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list