From ec0bd3953041ec6ca62100aeb63b901913869be3 Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Thu, 5 Jul 2001 22:35:22 +0000 Subject: [PATCH] Fixed Join Table Cells bug 86009, r=mjudge, sr=sfraser git-svn-id: svn://10.0.0.236/trunk@98727 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsTableEditor.cpp | 46 +++++-------------- .../editor/libeditor/html/nsTableEditor.cpp | 46 +++++-------------- 2 files changed, 22 insertions(+), 70 deletions(-) diff --git a/mozilla/editor/base/nsTableEditor.cpp b/mozilla/editor/base/nsTableEditor.cpp index 1d2a58cbfad..23988f3901c 100644 --- a/mozilla/editor/base/nsTableEditor.cpp +++ b/mozilla/editor/base/nsTableEditor.cpp @@ -3120,47 +3120,23 @@ nsHTMLEditor::GetFirstSelectedCellInTable(nsIDOMElement **aCell, PRInt32 *aRowIn if (NS_FAILED(res)) return res; if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND; - PRInt32 startRowIndex, startColIndex; - res = GetCellIndexes(cell, startRowIndex, startColIndex); - if(NS_FAILED(res)) return res; + *aCell = cell.get(); + NS_ADDREF(*aCell); - // Start with first cell selected - nsCOMPtr firstCell = cell; - PRInt32 firstRowIndex = startRowIndex; - PRInt32 firstColIndex = startColIndex; - - while (cell) + // Also return the row and/or column if requested + if (aRowIndex || aColIndex) { - res = GetNextSelectedCell(getter_AddRefs(cell), nsnull); - if (NS_FAILED(res)) return res; - if (cell) - { - res = GetCellIndexes(cell, startRowIndex, startColIndex); - if(NS_FAILED(res)) return res; - // Find the topmost row - if (startRowIndex <= firstRowIndex) - { - // Then save the left-most cell in that row - if (startRowIndex < firstRowIndex || - startColIndex < firstColIndex) - { - firstCell = cell; - firstRowIndex = startRowIndex; - firstColIndex = startColIndex; - } - } - } - } - if (NS_SUCCEEDED(res)) - { - *aCell = firstCell.get(); - NS_ADDREF(*aCell); + PRInt32 startRowIndex, startColIndex; + res = GetCellIndexes(cell, startRowIndex, startColIndex); + if(NS_FAILED(res)) return res; if (aRowIndex) - *aRowIndex = firstRowIndex; + *aRowIndex = startRowIndex; + if (aColIndex) - *aColIndex = firstColIndex; + *aColIndex = startColIndex; } + return res; } diff --git a/mozilla/editor/libeditor/html/nsTableEditor.cpp b/mozilla/editor/libeditor/html/nsTableEditor.cpp index 1d2a58cbfad..23988f3901c 100644 --- a/mozilla/editor/libeditor/html/nsTableEditor.cpp +++ b/mozilla/editor/libeditor/html/nsTableEditor.cpp @@ -3120,47 +3120,23 @@ nsHTMLEditor::GetFirstSelectedCellInTable(nsIDOMElement **aCell, PRInt32 *aRowIn if (NS_FAILED(res)) return res; if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND; - PRInt32 startRowIndex, startColIndex; - res = GetCellIndexes(cell, startRowIndex, startColIndex); - if(NS_FAILED(res)) return res; + *aCell = cell.get(); + NS_ADDREF(*aCell); - // Start with first cell selected - nsCOMPtr firstCell = cell; - PRInt32 firstRowIndex = startRowIndex; - PRInt32 firstColIndex = startColIndex; - - while (cell) + // Also return the row and/or column if requested + if (aRowIndex || aColIndex) { - res = GetNextSelectedCell(getter_AddRefs(cell), nsnull); - if (NS_FAILED(res)) return res; - if (cell) - { - res = GetCellIndexes(cell, startRowIndex, startColIndex); - if(NS_FAILED(res)) return res; - // Find the topmost row - if (startRowIndex <= firstRowIndex) - { - // Then save the left-most cell in that row - if (startRowIndex < firstRowIndex || - startColIndex < firstColIndex) - { - firstCell = cell; - firstRowIndex = startRowIndex; - firstColIndex = startColIndex; - } - } - } - } - if (NS_SUCCEEDED(res)) - { - *aCell = firstCell.get(); - NS_ADDREF(*aCell); + PRInt32 startRowIndex, startColIndex; + res = GetCellIndexes(cell, startRowIndex, startColIndex); + if(NS_FAILED(res)) return res; if (aRowIndex) - *aRowIndex = firstRowIndex; + *aRowIndex = startRowIndex; + if (aColIndex) - *aColIndex = firstColIndex; + *aColIndex = startColIndex; } + return res; }