[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Calligra] f4f2dec: Adding stub functions for the implementation of th
From:       Ganesh Paramasivam <ganesh () crystalfab ! com>
Date:       2010-12-09 11:34:29
Message-ID: 20101209113429.E9258A60AE () git ! kde ! org
[Download RAW message or body]

commit f4f2decb4fcda38cc3e95270aac8673f2af73dba
branch words-change_tracking-ganeshp
Author: Ganesh Paramasivam <ganesh@crystalfab.com>
Date:   Thu Dec 9 17:03:07 2010 +0530

    Adding stub functions for the implementation of the different scenarios that \
result in complex deletes. These will be filled in incrementally going forward

diff --git a/libs/kotext/opendocument/KoTextWriter.cpp \
b/libs/kotext/opendocument/KoTextWriter.cpp index 9d53aa0..d5db860 100644
--- a/libs/kotext/opendocument/KoTextWriter.cpp
+++ b/libs/kotext/opendocument/KoTextWriter.cpp
@@ -149,6 +149,12 @@ public:
     QBuffer generatedXmlBuffer;
 
     void postProcessTagTypeChangeXml();
+    void generateFinalXml(QString &outputXml, const KoXmlElement &element);
+    void handleParagraphWithHeaderMerge(QString &outputXml, const KoXmlElement \
&element); +    void handleParagraphWithListItemMerge(QString &outputXml, const \
KoXmlElement &element); +    void handleListItemWithParagraphMerge(QString \
&outputXml, const KoXmlElement &element); +    void handleListWithListMerge(QString \
&outputXml, const KoXmlElement &element); +    void \
handleListItemWithListItemMerge(QString &outputXml, const KoXmlElement &element);  };
 
 void KoTextWriter::Private::saveChange(QTextCharFormat format)
@@ -863,7 +869,7 @@ QTextBlock& KoTextWriter::Private::saveList(QTextBlock &block, \
QHash<QTextList *  int topListLevel = KoList::level(block);
 
     bool closeTagChangeRegion = false;
-    if ((level == 1) && (tagTypeChangeRegionOpened)) {
+    if ((level == 1) && (tagTypeChangeRegionOpened) && !headingLevel) {
         QTextBlock listBlock = block;
         do {
             if (listBlock.blockNumber() == tagTypeChangeEndBlockNumber) {
@@ -983,6 +989,8 @@ void KoTextWriter::Private::writeBlocks(QTextDocument *document, \
int from, int t  while (block.isValid() && ((to == -1) || (block.position() <= to))) \
{  QTextCursor cursor(block);
         QTextFrame *cursorFrame = cursor.currentFrame();
+        int blockOutlineLevel = \
block.blockFormat().property(KoParagraphStyle::OutlineLevel).toInt(); +
         if (cursorFrame != currentFrame && \
cursorFrame->format().hasProperty(KoText::TableOfContents)) {  int frameBegin = \
cursorFrame->firstPosition();  int frameEnd = cursorFrame->lastPosition();
@@ -1008,7 +1016,7 @@ void KoTextWriter::Private::writeBlocks(QTextDocument \
*document, int from, int t  continue;
         }
 
-        if (!tagTypeChangeRegionOpened && !cursor.currentTable() && \
!cursor.currentList()) { +        if (!tagTypeChangeRegionOpened && \
!cursor.currentTable() && (!cursor.currentList() || blockOutlineLevel)) {  \
tagTypeChangeEndBlockNumber = checkForTagTypeChanges(block);  if \
(tagTypeChangeEndBlockNumber != -1) {  tagTypeChangeRegionOpened = true;
@@ -1018,7 +1026,7 @@ void KoTextWriter::Private::writeBlocks(QTextDocument \
*document, int from, int t  
         saveParagraph(block, from, to);
 
-        if (tagTypeChangeRegionOpened && (block.blockNumber() == \
tagTypeChangeEndBlockNumber) && !cursor.currentList()) { +        if \
(tagTypeChangeRegionOpened && (block.blockNumber() == tagTypeChangeEndBlockNumber) && \
(!cursor.currentList() || blockOutlineLevel)) {  closeTagTypeChangeRegion();
         }
 
@@ -1157,10 +1165,64 @@ void KoTextWriter::Private::postProcessTagTypeChangeXml()
 
     bool ok = doc.setContent(&reader, &errorMsg, &errorLine, &errorColumn);
     if (ok) {
-        qDebug() << "*************XML parsed successfully.....";
+        //Generate the final XML output and save it
+        QString outputXml;
+        generateFinalXml(outputXml, doc.documentElement());
     } 
 }
 
+void KoTextWriter::Private::generateFinalXml(QString &outputXml, const KoXmlElement \
&element) +{
+    QString firstChild = element.firstChild().toElement().localName();
+    QString secondChild = \
element.firstChild().nextSibling().toElement().localName(); +
+    if ((firstChild == "p") && (secondChild == "h")) {
+        handleParagraphWithHeaderMerge(outputXml, element);
+    } else if ((firstChild == "h") && (secondChild == "p")) {
+        handleParagraphWithHeaderMerge(outputXml, element);
+    } else if ((firstChild == "p") && (secondChild == "list")) {
+        handleParagraphWithListItemMerge(outputXml, element);
+    } else if ((firstChild == "h") && (secondChild == "list")) {
+        handleParagraphWithListItemMerge(outputXml, element);
+    } else if ((firstChild == "list") && (secondChild == "p")) {
+        handleListItemWithParagraphMerge(outputXml, element);
+    } else if ((firstChild == "list") && (secondChild == "h")) {
+        handleListItemWithParagraphMerge(outputXml, element);
+    } else if ((firstChild == "list") && (secondChild == "list")) {
+        handleListWithListMerge(outputXml, element);
+    } else if ((firstChild == "list") && (secondChild == "")) {
+        handleListItemWithListItemMerge(outputXml, element);
+    } else {
+        //Not Possible
+    }
+
+}
+
+void KoTextWriter::Private::handleParagraphWithHeaderMerge(QString &outputXml, const \
KoXmlElement &element) +{
+    qDebug() << "*************handleParaWithHMerge*************";
+}
+
+void KoTextWriter::Private::handleParagraphWithListItemMerge(QString &outputXml, \
const KoXmlElement &element) +{
+    qDebug() << "*************handlePWithListItemMerge***********";
+}
+
+void KoTextWriter::Private::handleListItemWithParagraphMerge(QString &outputXml, \
const KoXmlElement &element) +{
+    qDebug() << "*************handleListItemWithParaMerge**********";
+}
+
+void KoTextWriter::Private::handleListWithListMerge(QString &outputXml, const \
KoXmlElement &element) +{
+    qDebug() << "*************handleListWithListMerge***************";
+}
+
+void KoTextWriter::Private::handleListItemWithListItemMerge(QString &outputXml, \
const KoXmlElement &element) +{
+    qDebug() << "*************handleListItemWithListItemMerge*********";
+}
+
 void KoTextWriter::write(QTextDocument *document, int from, int to)
 { 
     d->document = document;  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic