Commits

Eike Rathke [er]  committed 60cc87a

calcdatatables: DataTable styles undo move

  • Participants
  • Parent commits 9cfef8a

Comments (0)

Files changed (4)

File sc/inc/datatablestyle.hxx

 
                                     /// Find all that are entirely covered by rRange.
         void                        FindInRange( ScDataTableMap & o_rDataTables, const ScRange& rRange ) const;
+
+                                    /// For Ref-Undo
+        bool                        operator==( const ScDataTableFormatList& rList ) const;
 };
 
 #endif

File sc/source/core/data/datatablestyle.cxx

 }
 
 
+bool ScDataTableFormatList::operator==( const ScDataTableFormatList& rList ) const
+{
+    size_t nCount = Count();
+    bool bEqual = (nCount == rList.Count());
+    for (size_t i=0; i<nCount && bEqual; i++)       // entries are sorted
+        if (!(*this)[i]->Equals( *rList[i]))
+            bEqual = false;
+
+    return bEqual;
+}
+
+
 const ScDataTableFormat* ScDataTableFormatList::GetFormat( sal_uInt32 nKey ) const
 {
     /* TODO: binary search */

File sc/source/ui/inc/refundo.hxx

 class ScDPCollection;
 class ScChartCollection;
 class ScConditionalFormatList;
+class ScDataTableFormatList;
 class ScDetOpList;
 class ScChartListenerCollection;
 class ScAreaLinkSaveCollection;
 	ScPrintRangeSaver*			pPrintRanges;
 	ScDPCollection*				pDPCollection;
 	ScConditionalFormatList*	pCondFormList;
+    ScDataTableFormatList*      pDataTableFormatList;
 	ScDetOpList*				pDetOpList;
 	ScChartListenerCollection*	pChartListenerCollection;
 	ScAreaLinkSaveCollection*	pAreaLinks;

File sc/source/ui/undo/refundo.cxx

 #include "dpobject.hxx"
 #include "areasave.hxx"
 #include "unoreflist.hxx"
+#include "datatablestyle.hxx"
 
 // -----------------------------------------------------------------------
 
 	ScConditionalFormatList* pOldCond = pDoc->GetCondFormList();
 	pCondFormList = pOldCond ? new ScConditionalFormatList(*pOldCond) : NULL;
 
+    ScDataTableFormatList* pOldDTab = pDoc->GetDataTableFormatList();
+    pDataTableFormatList = pOldDTab ? new ScDataTableFormatList(*pOldDTab) : NULL;
+
 	ScDetOpList* pOldDetOp = pDoc->GetDetOpList();
 	pDetOpList = pOldDetOp ? new ScDetOpList(*pOldDetOp) : 0;
 
 	delete pPrintRanges;
 	delete pDPCollection;
 	delete pCondFormList;
+	delete pDataTableFormatList;
 	delete pDetOpList;
 	delete pChartListenerCollection;
 	delete pAreaLinks;
 			DELETEZ(pCondFormList);
 	}
 
+    if (pDataTableFormatList)
+    {
+        ScDataTableFormatList* pNewDTab = pDoc->GetDataTableFormatList();
+        if ( pNewDTab && *pDataTableFormatList == *pNewDTab )
+            DELETEZ(pDataTableFormatList);
+    }
+
 	if (pDetOpList)
 	{
 		ScDetOpList* pNewDetOp = pDoc->GetDetOpList();
 
 	if (pCondFormList)
 		pDoc->SetCondFormList( new ScConditionalFormatList(*pCondFormList) );
+    if (pDataTableFormatList)
+        pDoc->SetDataTableFormatList( *pDataTableFormatList);
 	if (pDetOpList)
 		pDoc->SetDetOpList( new ScDetOpList(*pDetOpList) );