~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to plugins/textshape/commands/ShowChangesCommand.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
                container = dynamic_cast<KoShapeContainer *>((lay->shapes()).at(0));
156
156
 
157
157
            if (container) {
158
 
                container->addChild(anchor->shape()); 
 
158
                container->addShape(anchor->shape());
159
159
                QUndoCommand *shapeCommand = m_canvas->shapeController()->addShapeDirect(anchor->shape());
160
160
                shapeCommand->redo();
161
161
                m_shapeCommands.push_front(shapeCommand);
177
177
            QTextCharFormat f;
178
178
            int deletePosition = element->getDeleteChangeMarker()->position() + 1 - numDeletedChars;
179
179
            caret.setPosition(deletePosition);
180
 
            caret.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, fragmentLength(element->getDeleteData()));
 
180
            int deletedLength = fragmentLength(element->getDeleteData());
 
181
            caret.setPosition(deletePosition + deletedLength, QTextCursor::KeepAnchor);
181
182
            checkAndRemoveAnchoredShapes(deletePosition, fragmentLength(element->getDeleteData()));
182
183
            caret.removeSelectedText();
183
184
            numDeletedChars += fragmentLength(element->getDeleteData());
246
247
                } 
247
248
                currentList->add(cursor.block(), deletedListItemLevel);
248
249
            }
 
250
        } else if (tempCursor.currentTable()) {
 
251
            QTextTable *deletedTable = tempCursor.currentTable();
 
252
            int numRows = deletedTable->rows();
 
253
            int numColumns = deletedTable->columns();
 
254
            QTextTable *insertedTable = cursor.insertTable(numRows, numColumns, deletedTable->format());
 
255
            for (int i=0; i<numRows; i++) {
 
256
                for (int j=0; j<numColumns; j++) {
 
257
                    tempCursor.setPosition(deletedTable->cellAt(i,j).firstCursorPosition().position());
 
258
                    tempCursor.setPosition(deletedTable->cellAt(i,j).lastCursorPosition().position(), QTextCursor::KeepAnchor);
 
259
                    insertedTable->cellAt(i,j).setFormat(deletedTable->cellAt(i,j).format().toTableCellFormat());
 
260
                    cursor.setPosition(insertedTable->cellAt(i,j).firstCursorPosition().position());
 
261
                    cursor.insertFragment(tempCursor.selection());
 
262
                }
 
263
            }
 
264
            tempCursor.setPosition(deletedTable->cellAt(numRows-1,numColumns-1).lastCursorPosition().position());
 
265
            currentBlock = tempCursor.block();
 
266
            //Move the cursor outside of table
 
267
            cursor.setPosition(cursor.position() + 1);
 
268
            continue;
249
269
        } else {
250
270
            // This block does not contain a list. So no special work here. 
251
271
            if (currentBlock != tempDoc.begin())
273
293
            if (currentFragment.isValid())
274
294
                cursor.insertText(currentFragment.text(), currentFragment.charFormat());
275
295
        }
276
 
        
277
296
    }
278
297
}
279
298
 
284
303
    tempCursor.insertFragment(fragment);
285
304
    int length = 0;
286
305
    bool deletedListItem = false;
287
 
    
288
306
    for (QTextBlock currentBlock = tempDoc.begin(); currentBlock != tempDoc.end(); currentBlock = currentBlock.next()) {
289
307
        tempCursor.setPosition(currentBlock.position());
290
308
        if (tempCursor.currentList()) {
291
309
            deletedListItem = currentBlock.blockFormat().property(KoDeleteChangeMarker::DeletedListItem).toBool();
292
310
            if (currentBlock != tempDoc.begin() && deletedListItem)
293
311
                length += 1; //For the Block separator
 
312
        } else if (tempCursor.currentTable()) {
 
313
            QTextTable *deletedTable = tempCursor.currentTable();
 
314
            int numRows = deletedTable->rows();
 
315
            int numColumns = deletedTable->columns();
 
316
            for (int i=0; i<numRows; i++) {
 
317
                for (int j=0; j<numColumns; j++) {
 
318
                    length += 1;
 
319
                    length += (deletedTable->cellAt(i,j).lastCursorPosition().position() - deletedTable->cellAt(i,j).firstCursorPosition().position());
 
320
                }
 
321
            }
 
322
            tempCursor.setPosition(deletedTable->cellAt(numRows-1,numColumns-1).lastCursorPosition().position());
 
323
            currentBlock = tempCursor.block();
 
324
            length += 1;
 
325
            continue;
294
326
        } else {
295
327
            if (currentBlock != tempDoc.begin())
296
328
                length += 1; //For the Block Separator