summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorHenning Brinkmann <hbrinkm@openoffice.org>2010-01-22 13:09:54 +0100
committerHenning Brinkmann <hbrinkm@openoffice.org>2010-01-22 13:09:54 +0100
commitf3460df24abfdf44d89e542382515f7195fae1da (patch)
tree61fd0d45a48c2cc849a3589ab4cd493901c9a17f /sw
parent3c310fe22faf95f1eb7870f795b890bcb7e68569 (diff)
writerfilter07: SwNodes::ExpandTableRanges not needed. Correct node range for each table cell in convertToTable
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ndarr.hxx3
-rw-r--r--sw/source/core/docnode/ndtbl.cxx39
-rw-r--r--sw/source/core/unocore/unotext.cxx18
3 files changed, 33 insertions, 27 deletions
diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index 74bdfd6c480f..489de9b47d0f 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -282,8 +282,7 @@ public:
SwTxtFmtColl* pTxtColl,
SwUndoTxtToTbl* pUndo = 0 );
- SwNodeRange ExpandRangeForTableBox(const SwNodeRange & rRange);
- TableRanges_t ExpandTableRanges(const TableRanges_t & rRanges);
+ SwNodeRange * ExpandRangeForTableBox(const SwNodeRange & rRange);
//create a table from a vector of NodeRanges - API support
SwTableNode* TextToTable( const TableRanges_t& rTableNodes,
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index a843d5032826..8b1523c58ac8 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1269,8 +1269,11 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
return pNdTbl;
}
-SwNodeRange SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
+SwNodeRange * SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
{
+ SwNodeRange * pResult = NULL;
+ bool bChanged = false;
+
SwNodeIndex aNewStart = rRange.aStart;
SwNodeIndex aNewEnd = rRange.aEnd;
@@ -1288,7 +1291,10 @@ SwNodeRange SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
aIndex = *pEndNode;
if (aIndex > aNewEnd)
+ {
aNewEnd = aIndex;
+ bChanged = true;
+ }
}
else if (rNode.IsEndNode())
{
@@ -1296,7 +1302,10 @@ SwNodeRange SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
SwNodeIndex aStartIndex = *pStartNode;
if (aStartIndex < aNewStart)
+ {
aNewStart = aStartIndex;
+ bChanged = true;
+ }
}
if (aIndex < aEndIndex)
@@ -1310,36 +1319,16 @@ SwNodeRange SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
SwNodeIndex aStartIndex(*pStartNode);
aNewStart = aStartIndex;
aNewEnd = aIndex;
+ bChanged = true;
++aIndex;
pNode = &aIndex.GetNode();
}
- return SwNodeRange(aNewStart, aNewEnd);
-}
-
-SwNodes::TableRanges_t SwNodes::ExpandTableRanges
-(const SwNodes::TableRanges_t & rTableRanges)
-{
- TableRanges_t aResult;
-
- TableRanges_t::const_iterator aRowEndIter = rTableRanges.end();
- for (TableRanges_t::const_iterator aRowIter = rTableRanges.begin();
- aRowIter != aRowEndIter; ++aRowIter)
- {
- NodeRanges_t aRowRanges;
- NodeRanges_t::const_iterator aCellEndIter = aRowIter->end();
- for (NodeRanges_t::const_iterator aCellIter = aRowIter->begin();
- aCellIter != aCellEndIter; ++aCellIter)
- {
- SwNodeRange aRange = ExpandRangeForTableBox(*aCellIter);
- aRowRanges.push_back(aRange);
- }
-
- aResult.push_back(aRowRanges);
- }
+ if (bChanged)
+ pResult = new SwNodeRange(aNewStart, aNewEnd);
- return aResult;
+ return pResult;
}
/*-- 18.05.2006 08:23:28---------------------------------------------------
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index ee1055b276c9..249409ed6e90 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1824,6 +1824,24 @@ uno::Reference< text::XTextTable > SwXText::convertToTable(
if(!SwXTextRange::XTextRangeToSwPaM(aStartCellPam, xStartRange) ||
!SwXTextRange::XTextRangeToSwPaM(aEndCellPam, xEndRange) )
throw lang::IllegalArgumentException();
+
+ SwNodeRange aTmpRange( aStartCellPam.Start()->nNode, aEndCellPam.End()->nNode);
+ SwNodeRange * pCorrectedRange = pDoc->GetNodes().ExpandRangeForTableBox(aTmpRange);
+
+ if (pCorrectedRange != NULL)
+ {
+ SwPaM aNewStartPaM(pCorrectedRange->aStart, 0);
+ aStartCellPam = aNewStartPaM;
+
+ xub_StrLen nEndLen = 0;
+ SwTxtNode * pTxtNode = pCorrectedRange->aEnd.GetNode().GetTxtNode();
+ if (pTxtNode != NULL)
+ nEndLen = pTxtNode->Len();
+
+ SwPaM aNewEndPaM(pCorrectedRange->aEnd, nEndLen);
+ aEndCellPam = aNewEndPaM;
+ }
+
/** check the nodes between start and end
it is allowed to have pairs of StartNode/EndNodes
*/