[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/plugins/textshape/commands
From: Ganesh Paramasivam <ganesh () crystalfab ! com>
Date: 2010-04-27 6:10:08
Message-ID: 20100427061008.4DDC4AC8A7 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1119437 by ganeshp:
Enable the tracking and visualization of deletions containing a table
M +33 -0 ChangeTrackedDeleteCommand.cpp
M +35 -3 ShowChangesCommand.cpp
--- trunk/koffice/plugins/textshape/commands/ChangeTrackedDeleteCommand.cpp \
#1119436:1119437 @@ -359,6 +359,25 @@
}
currentList->add(cursor.block(), deletedListItemLevel);
}
+ } else if (tempCursor.currentTable()) {
+ QTextTable *deletedTable = tempCursor.currentTable();
+ int numRows = deletedTable->rows();
+ int numColumns = deletedTable->columns();
+ QTextTable *insertedTable = cursor.insertTable(numRows, numColumns, \
deletedTable->format()); + for (int i=0; i<numRows; i++) {
+ for (int j=0; j<numColumns; j++) {
+ \
tempCursor.setPosition(deletedTable->cellAt(i,j).firstCursorPosition().position()); + \
tempCursor.setPosition(deletedTable->cellAt(i,j).lastCursorPosition().position(), \
QTextCursor::KeepAnchor); + \
insertedTable->cellAt(i,j).setFormat(deletedTable->cellAt(i,j).format().toTableCellFormat());
+ \
cursor.setPosition(insertedTable->cellAt(i,j).firstCursorPosition().position()); + \
cursor.insertFragment(tempCursor.selection()); + }
+ }
+ tempCursor.setPosition(deletedTable->cellAt(numRows-1,numColumns-1).lastCursorPosition().position());
+ currentBlock = tempCursor.block();
+ //Move the cursor outside of table
+ cursor.setPosition(cursor.position() + 1);
+ continue;
} else {
// This block does not contain a list. So no special work here.
if (currentBlock != tempDoc.begin())
@@ -404,6 +423,20 @@
deletedListItem = \
currentBlock.blockFormat().property(KoDeleteChangeMarker::DeletedListItem).toBool(); \
if (currentBlock != tempDoc.begin() && deletedListItem) length += 1; //For the Block \
separator + } else if (tempCursor.currentTable()) {
+ QTextTable *deletedTable = tempCursor.currentTable();
+ int numRows = deletedTable->rows();
+ int numColumns = deletedTable->columns();
+ for (int i=0; i<numRows; i++) {
+ for (int j=0; j<numColumns; j++) {
+ length += 1;
+ length += \
(deletedTable->cellAt(i,j).lastCursorPosition().position() - \
deletedTable->cellAt(i,j).firstCursorPosition().position()); + }
+ }
+ tempCursor.setPosition(deletedTable->cellAt(numRows-1,numColumns-1).lastCursorPosition().position());
+ currentBlock = tempCursor.block();
+ length += 1;
+ continue;
} else {
if (currentBlock != tempDoc.begin())
length += 1; //For the Block Separator
--- trunk/koffice/plugins/textshape/commands/ShowChangesCommand.cpp #1119436:1119437
@@ -177,7 +177,8 @@
QTextCharFormat f;
int deletePosition = element->getDeleteChangeMarker()->position() + 1 - \
numDeletedChars; caret.setPosition(deletePosition);
- caret.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, \
fragmentLength(element->getDeleteData())); + int deletedLength = \
fragmentLength(element->getDeleteData()); + \
caret.setPosition(deletePosition + deletedLength, \
QTextCursor::KeepAnchor);
checkAndRemoveAnchoredShapes(deletePosition, \
fragmentLength(element->getDeleteData())); caret.removeSelectedText();
numDeletedChars += fragmentLength(element->getDeleteData());
@@ -246,6 +247,25 @@
}
currentList->add(cursor.block(), deletedListItemLevel);
}
+ } else if (tempCursor.currentTable()) {
+ QTextTable *deletedTable = tempCursor.currentTable();
+ int numRows = deletedTable->rows();
+ int numColumns = deletedTable->columns();
+ QTextTable *insertedTable = cursor.insertTable(numRows, numColumns, \
deletedTable->format()); + for (int i=0; i<numRows; i++) {
+ for (int j=0; j<numColumns; j++) {
+ \
tempCursor.setPosition(deletedTable->cellAt(i,j).firstCursorPosition().position()); + \
tempCursor.setPosition(deletedTable->cellAt(i,j).lastCursorPosition().position(), \
QTextCursor::KeepAnchor); + \
insertedTable->cellAt(i,j).setFormat(deletedTable->cellAt(i,j).format().toTableCellFormat());
+ \
cursor.setPosition(insertedTable->cellAt(i,j).firstCursorPosition().position()); + \
cursor.insertFragment(tempCursor.selection()); + }
+ }
+ tempCursor.setPosition(deletedTable->cellAt(numRows-1,numColumns-1).lastCursorPosition().position());
+ currentBlock = tempCursor.block();
+ //Move the cursor outside of table
+ cursor.setPosition(cursor.position() + 1);
+ continue;
} else {
// This block does not contain a list. So no special work here.
if (currentBlock != tempDoc.begin())
@@ -273,7 +293,6 @@
if (currentFragment.isValid())
cursor.insertText(currentFragment.text(), \
currentFragment.charFormat()); }
-
}
}
@@ -284,13 +303,26 @@
tempCursor.insertFragment(fragment);
int length = 0;
bool deletedListItem = false;
-
for (QTextBlock currentBlock = tempDoc.begin(); currentBlock != tempDoc.end(); \
currentBlock = currentBlock.next()) { \
tempCursor.setPosition(currentBlock.position()); if (tempCursor.currentList()) {
deletedListItem = \
currentBlock.blockFormat().property(KoDeleteChangeMarker::DeletedListItem).toBool(); \
if (currentBlock != tempDoc.begin() && deletedListItem) length += 1; //For the Block \
separator + } else if (tempCursor.currentTable()) {
+ QTextTable *deletedTable = tempCursor.currentTable();
+ int numRows = deletedTable->rows();
+ int numColumns = deletedTable->columns();
+ for (int i=0; i<numRows; i++) {
+ for (int j=0; j<numColumns; j++) {
+ length += 1;
+ length += \
(deletedTable->cellAt(i,j).lastCursorPosition().position() - \
deletedTable->cellAt(i,j).firstCursorPosition().position()); + }
+ }
+ tempCursor.setPosition(deletedTable->cellAt(numRows-1,numColumns-1).lastCursorPosition().position());
+ currentBlock = tempCursor.block();
+ length += 1;
+ continue;
} else {
if (currentBlock != tempDoc.begin())
length += 1; //For the Block Separator
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic