diff options
Diffstat (limited to 'sw/source/core/unocore/unotbl.cxx')
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index bf1df93d5d16..b7098710802b 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -494,6 +494,40 @@ String lcl_GetCellName( sal_Int32 nColumn, sal_Int32 nRow ) return sCellName; } +/** Find the top left or bottom right corner box in given table. + Consider nested lines when finding the box. + + @param i_pTable the table + + @param i_bTopLeft if true, find top left box, otherwise find bottom + right box + */ + +const SwTableBox* lcl_FindCornerTableBox(const SwTableLines& rTableLines, const bool i_bTopLeft) +{ + bool bFirst = true; + const SwTableBox* pBox = 0; + do + { + const SwTableLines& rLines(bFirst ? rTableLines : pBox->GetTabLines()); + bFirst = false; + OSL_ASSERT(rLines.Count() != 0); + if (rLines.Count() != 0) + { + const SwTableLine* pLine(rLines[i_bTopLeft ? 0 : rLines.Count() - 1]); + OSL_ASSERT(pLine); + const SwTableBoxes& rBoxes(pLine->GetTabBoxes()); + OSL_ASSERT(rBoxes.Count() != 0); + pBox = rBoxes[i_bTopLeft ? 0 : rBoxes.Count() - 1]; + OSL_ASSERT(pBox); + } + else + { + pBox = 0; + } + } while (pBox && !pBox->GetSttNd()); + return pBox; +} /* -----------------21.11.05 14:46------------------- @@ -3318,7 +3352,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, // hier muessen die Actions aufgehoben werden UnoActionRemoveContext aRemoveContext(pDoc); - SwTableBox* pTLBox = rLines[0]->GetTabBoxes()[0]; + const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true); const SwStartNode* pSttNd = pTLBox->GetSttNd(); SwPosition aPos(*pSttNd); // Cursor in die obere linke Zelle des Ranges setzen @@ -3326,9 +3360,9 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, pUnoCrsr->Move( fnMoveForward, fnGoNode ); pUnoCrsr->SetRemainInSection( sal_False ); - SwTableLine* pLastLine = rLines[rLines.Count() - 1]; - SwTableBoxes &rBoxes = pLastLine->GetTabBoxes(); - const SwTableBox* pBRBox = rBoxes[rBoxes.Count() -1]; + + + const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false); pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); @@ -3514,7 +3548,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be // hier muessen die Actions aufgehoben werden UnoActionRemoveContext aRemoveContext(pDoc); - SwTableBox* pTLBox = rLines[0]->GetTabBoxes()[0]; + const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true); const SwStartNode* pSttNd = pTLBox->GetSttNd(); SwPosition aPos(*pSttNd); // Cursor in die obere linke Zelle des Ranges setzen @@ -3522,11 +3556,11 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be pUnoCrsr->Move( fnMoveForward, fnGoNode ); pUnoCrsr->SetRemainInSection( sal_False ); - SwTableLine* pLastLine = rLines[rLines.Count() - 1]; - SwTableBoxes &rBoxes = pLastLine->GetTabBoxes(); - const SwTableBox* pBRBox = rBoxes[rBoxes.Count() -1]; + const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false); pUnoCrsr->SetMark(); - pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); + const SwStartNode* pLastNd = pBRBox->GetSttNd(); + pUnoCrsr->GetPoint()->nNode = *pLastNd; + pUnoCrsr->Move( fnMoveForward, fnGoNode ); SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); @@ -4448,41 +4482,6 @@ void SwXCellRange::GetDataSequence( pDblSeq->realloc( nDtaCnt ); } -/*-- 04.06.04 11:42:47--------------------------------------------------- - - -----------------------------------------------------------------------*/ - -SwUnoCrsr * lcl_CreateCursor( SwFrmFmt &rTblFmt, - SwTableBox *pStartBox, // should be top-left cell of cell range - SwTableBox *pEndBox ) // should be bottom right-cell cell range -{ - // create a *new* UNO cursor spanning the cell range defined by - // the start and end box. Both boxes must be belong to the same table! - - SwUnoCrsr *pUnoCrsr = 0; - if (pStartBox && pEndBox) - { - // hier muessen die Actions aufgehoben werden um - // (zB dem Layout zu ermglichen die Tabelle zu formatieren, da - // sonst kein Tabellen Cursor aufgespannt werden kann.) - UnoActionRemoveContext aRemoveContext(rTblFmt.GetDoc()); - - // set point of cursor to top left box of range - const SwStartNode* pSttNd = pStartBox->GetSttNd(); - SwPosition aPos(*pSttNd); - pUnoCrsr = rTblFmt.GetDoc()->CreateUnoCrsr(aPos, sal_True); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); - pUnoCrsr->SetRemainInSection( sal_False ); - pUnoCrsr->SetMark(); - pUnoCrsr->GetPoint()->nNode = *pEndBox->GetSttNd(); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr *pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); - pCrsr->MakeBoxSels(); - } - return pUnoCrsr; -} - - /*-- 29.04.02 11:42:47--------------------------------------------------- -----------------------------------------------------------------------*/ |