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

List:       kde-commits
Subject:    koffice
From:       Thomas Zander <zander () kde ! org>
Date:       2010-12-18 9:44:01
Message-ID: 20101218094401.07CA03E1F5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1207473 by zander:

Fix numbering of headers.

The problem was manyfold. At loading the different headings were not put
into the same KoList. At layout other lists interfered if they were
interspersed between the headings.

 M  +16 -0     libs/kotext/KoList.cpp  
 M  +9 -1      plugins/textshape/ListItemsHelper.cpp  


--- trunk/koffice/libs/kotext/KoList.cpp #1207472:1207473
@@ -69,9 +69,24 @@
         return list;
     }
 
+    //the block was already another list but with a different style - remove block from list
     if (list)
         list->remove(block);
 
+    // Ok, so we are now ready to add the block to another list, but which other list?
+    // For headers we always want to continue from any previous header
+    // For normal lists we either want to continue an adjecent list or create a new one
+    if (block.blockFormat().hasProperty(KoParagraphStyle::OutlineLevel)) {
+        for (QTextBlock b = block.previous();b.isValid(); b = b.previous()) {
+            list = document.list(b);
+            if (list && *list->style() == *style) {
+                break;
+            }
+        }
+        if (!list || *list->style() != *style) {
+            list = new KoList(block.document(), style);
+        }
+    } else {
     list = document.list(block.previous());
     if (!list || *list->style() != *style) {
         list = document.list(block.next());
@@ -79,6 +94,7 @@
             list = new KoList(block.document(), style);
         }
     }
+    }
     list->add(block, level);
     return list;
 }
--- trunk/koffice/plugins/textshape/ListItemsHelper.cpp #1207472:1207473
@@ -284,12 +284,16 @@
         if (paragIndex > 0)
             index = paragIndex;
 
+        //check if this is the first of this level meaning we should start from startvalue
         QTextBlock b = tb.previous();
         for (;b.isValid(); b = b.previous()) {
             if (b.textList() == m_textList)
                 break; // all fine
             if (b.textList() == 0)
                 continue;
+            QTextListFormat otherFormat = b.textList()->format();
+            if (otherFormat.style() != format.style())
+                continue; // uninteresting for us
             if (b.textList()->format().intProperty(KoListStyle::Level) < level) {
                 index = startValue;
                 break;
@@ -304,6 +308,8 @@
                 if (b.textList() == 0)
                     continue;
                 QTextListFormat lf = b.textList()->format();
+                if (lf.style() != format.style())
+                    continue; // uninteresting for us
                 const int otherLevel  = lf.intProperty(KoListStyle::Level);
                 if (checkLevel <= otherLevel)
                     continue;
@@ -433,7 +439,9 @@
         while (nb.isValid() && nb.textList() == 0)
             nb = nb.next();
         if (nb.isValid()) {
-            if (nb.textList()->format().intProperty(KoListStyle::Level) > level) {
+            QTextListFormat lf = nb.textList()->format();
+            if ((lf.style() == format.style())
+              && nb.textList()->format().intProperty(KoListStyle::Level) > level) {
                 // this is a sublist
                 // have to remember to recalculate this list after the current level is done
                 // cant do it right away since the sublist's prefix text is dependant on this level
[prev in list] [next in list] [prev in thread] [next in thread] 

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