Author: jghali
Date: Fri Feb  7 14:12:20 2020
New Revision: 23458

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23458
Log:
#16042: Lost frames when opening 1.4.x file

Modified:
    
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp

Modified: 
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23458&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- 
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp  
    (original)
+++ 
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp  
    Fri Feb  7 14:12:20 2020
@@ -202,11 +202,15 @@
        QList<PageItem*> TableItems;
        QList<PageItem*> TableItemsM;
        QList<PageItem*> TableItemsF;
-       QStack< QList<PageItem*> > groupStack;
+       QStack< QList<PageItem*> > groupStackFI;
+       QStack< QList<PageItem*> > groupStackMI;
+       QStack< QList<PageItem*> > groupStackPI;
        QStack< QList<PageItem*> > groupStackF;
        QStack< QList<PageItem*> > groupStackM;
        QStack< QList<PageItem*> > groupStackP;
-       QStack<int> groupStack2;
+       QStack<int> groupStackFI2;
+       QStack<int> groupStackMI2;
+       QStack<int> groupStackPI2;
        
        QScopedPointer<QIODevice> ioDevice(slaReader(fileName));
        if (ioDevice.isNull())
@@ -447,28 +451,60 @@
                                        TableIDM.insert(itemInfo.ownLink, 
itemInfo.item);
                                }
                        }
-                       if (groupStack.count() > 0)
-                       {
-                               groupStack.top().append(itemInfo.item);
-                               while (static_cast<int>(itemInfo.ownNr) == 
groupStack2.top())
+
+                       if ((tagName == "PAGEOBJECT") && (groupStackPI.count() 
> 0))
+                       {
+                               groupStackPI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackPI2.top())
                                {
-                                       if (tagName == "PAGEOBJECT")
-                                               
groupStackP.push(groupStack.pop());
-                                       else if (tagName == "FRAMEOBJECT")
-                                               
groupStackF.push(groupStack.pop());
-                                       else
-                                               
groupStackM.push(groupStack.pop());
-                                       groupStack2.pop();
-                                       if (groupStack2.count() == 0)
+                                       groupStackP.push(groupStackPI.pop());
+                                       groupStackPI2.pop();
+                                       if (groupStackPI2.count() == 0)
                                                break;
                                }
                        }
+                       else if ((tagName == "FRAMEOBJECT") && 
(groupStackFI.count() > 0))
+                       {
+                               groupStackFI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackFI2.top())
+                               {
+                                       groupStackF.push(groupStackFI.pop());
+                                       groupStackFI2.pop();
+                                       if (groupStackFI2.count() == 0)
+                                               break;
+                               }
+                       }
+                       else if ((tagName == "MASTEROBJECT") && 
(groupStackMI.count() > 0))
+                       {
+                               groupStackMI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackMI2.top())
+                               {
+                                       groupStackM.push(groupStackMI.pop());
+                                       groupStackMI2.pop();
+                                       if (groupStackMI2.count() == 0)
+                                               break;
+                               }
+                       }
+
                        if (itemInfo.isGroupFlag)
                        {
-                               QList<PageItem*> GroupItems;
-                               GroupItems.append(itemInfo.item);
-                               groupStack.push(GroupItems);
-                               groupStack2.push(itemInfo.groupLastItem + 
itemInfo.ownNr);
+                               QList<PageItem*> groupItems;
+                               groupItems.append(itemInfo.item);
+                               if (tagName == "PAGEOBJECT")
+                               {
+                                       groupStackPI.push(groupItems);
+                                       
groupStackPI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else if (tagName == "FRAMEOBJECT")
+                               {
+                                       groupStackFI.push(groupItems);
+                                       
groupStackFI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else
+                               {
+                                       groupStackMI.push(groupItems);
+                                       
groupStackMI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
                        }
                }
                if (tagName == "Pattern")
@@ -2175,7 +2211,7 @@
                if (groupStack.count() > 0)
                {
                        groupStack.top().append(itemInfo.item);
-                       while (static_cast<int>(itemInfo.ownNr) == 
groupStack2.top())
+                       while (itemInfo.ownNr == groupStack2.top())
                        {
                                groupStackP.push(groupStack.pop());
                                groupStack2.pop();
@@ -3145,8 +3181,17 @@
        QString tmp;
        QMap<int,PageItem*> TableID;
        QList<PageItem*> TableItems;
+       QStack< QList<PageItem*> > groupStackFI;
+       QStack< QList<PageItem*> > groupStackMI;
+       QStack< QList<PageItem*> > groupStackPI;
+       QStack< QList<PageItem*> > groupStackF;
+       QStack< QList<PageItem*> > groupStackM;
+       QStack< QList<PageItem*> > groupStackP;
+       QStack<int> groupStackFI2;
+       QStack<int> groupStackMI2;
+       QStack<int> groupStackPI2;
        double pageX = 0, pageY = 0;
-       QMap<int,int> layerTrans;
+       QMap<int, int> layerTrans;
        int maxLayer = 0, maxLevel = 0, a = 0;
 
        layerTrans.clear();
@@ -3382,6 +3427,61 @@
                                        TableItems.append(newItem);
                                        TableID.insert(itemInfo.ownLink, 
newItem);
                                }
+
+                               if ((tagName == "PAGEOBJECT") && 
(groupStackPI.count() > 0))
+                               {
+                                       
groupStackPI.top().append(itemInfo.item);
+                                       while (itemInfo.ownNr == 
groupStackPI2.top())
+                                       {
+                                               
groupStackP.push(groupStackPI.pop());
+                                               groupStackPI2.pop();
+                                               if (groupStackPI2.count() == 0)
+                                                       break;
+                                       }
+                               }
+                               else if ((tagName == "FRAMEOBJECT") && 
(groupStackFI.count() > 0))
+                               {
+                                       
groupStackFI.top().append(itemInfo.item);
+                                       while (itemInfo.ownNr == 
groupStackFI2.top())
+                                       {
+                                               
groupStackF.push(groupStackFI.pop());
+                                               groupStackFI2.pop();
+                                               if (groupStackFI2.count() == 0)
+                                                       break;
+                                       }
+                               }
+                               else if ((tagName == "MASTEROBJECT") && 
(groupStackMI.count() > 0))
+                               {
+                                       
groupStackMI.top().append(itemInfo.item);
+                                       while (itemInfo.ownNr == 
groupStackMI2.top())
+                                       {
+                                               
groupStackM.push(groupStackMI.pop());
+                                               groupStackMI2.pop();
+                                               if (groupStackMI2.count() == 0)
+                                                       break;
+                                       }
+                               }
+
+                               if (itemInfo.isGroupFlag)
+                               {
+                                       QList<PageItem*> groupItems;
+                                       groupItems.append(itemInfo.item);
+                                       if (tagName == "PAGEOBJECT")
+                                       {
+                                               groupStackPI.push(groupItems);
+                                               
groupStackPI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                                       }
+                                       else if (tagName == "FRAMEOBJECT")
+                                       {
+                                               groupStackFI.push(groupItems);
+                                               
groupStackFI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                                       }
+                                       else
+                                       {
+                                               groupStackMI.push(groupItems);
+                                               
groupStackMI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                                       }
+                               }
                        }
                }
        }
@@ -3472,6 +3572,99 @@
                }
        }
 
+       while (groupStackP.count() > 0)
+       {
+               bool isTableIt = false;
+               QList<PageItem*> gpL = groupStackP.pop();
+               PageItem* gItem = gpL.takeFirst();
+               for (int id = 0; id < gpL.count(); id++)
+               {
+                       PageItem* cItem = gpL.at(id);
+                       isTableIt = cItem->isTableItem;
+                       cItem->gXpos = cItem->xPos() - gItem->xPos();
+                       cItem->gYpos = cItem->yPos() - gItem->yPos();
+                       cItem->Parent = gItem;
+                       if (gItem->rotation() != 0)
+                       {
+                               QTransform ma;
+                               ma.rotate(-gItem->rotation());
+                               FPoint n = FPoint(cItem->gXpos, cItem->gYpos);
+                               cItem->gXpos = ma.m11() * n.x() + ma.m21() * 
n.y() + ma.dx();
+                               cItem->gYpos = ma.m22() * n.y() + ma.m12() * 
n.x() + ma.dy();
+                               cItem->setRotation(cItem->rotation() - 
gItem->rotation());
+                               cItem->oldRot = cItem->rotation();
+                       }
+                       m_Doc->DocItems.removeOne(cItem);
+               }
+               bool converted = false;
+               if (isTableIt)
+                       converted = convertOldTable(m_Doc, gItem, gpL, 
&groupStackP, &m_Doc->DocItems);
+               if (!converted)
+                       gItem->groupItemList = gpL;
+       }
+
+       while (groupStackF.count() > 0)
+       {
+               bool isTableIt = false;
+               QList<PageItem*> gpL = groupStackF.pop();
+               PageItem* gItem = gpL.takeFirst();
+               for (int id = 0; id < gpL.count(); id++)
+               {
+                       PageItem* cItem = gpL.at(id);
+                       isTableIt = cItem->isTableItem;
+                       cItem->gXpos = cItem->xPos() - gItem->xPos();
+                       cItem->gYpos = cItem->yPos() - gItem->yPos();
+                       cItem->Parent = gItem;
+                       if (gItem->rotation() != 0)
+                       {
+                               QTransform ma;
+                               ma.rotate(-gItem->rotation());
+                               FPoint n = FPoint(cItem->gXpos, cItem->gYpos);
+                               cItem->gXpos = ma.m11() * n.x() + ma.m21() * 
n.y() + ma.dx();
+                               cItem->gYpos = ma.m22() * n.y() + ma.m12() * 
n.x() + ma.dy();
+                               cItem->setRotation(cItem->rotation() - 
gItem->rotation());
+                               cItem->oldRot = cItem->rotation();
+                       }
+                       m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem));
+               }
+               bool converted = false;
+               if (isTableIt)
+                       converted = convertOldTable(m_Doc, gItem, gpL, 
&groupStackF, nullptr);
+               if (!converted)
+                       gItem->groupItemList = gpL;
+       }
+
+       while (groupStackM.count() > 0)
+       {
+               bool isTableIt = false;
+               QList<PageItem*> gpL = groupStackM.pop();
+               PageItem* gItem = gpL.takeFirst();
+               for (int id = 0; id < gpL.count(); id++)
+               {
+                       PageItem* cItem = gpL.at(id);
+                       isTableIt = cItem->isTableItem;
+                       cItem->gXpos = cItem->xPos() - gItem->xPos();
+                       cItem->gYpos = cItem->yPos() - gItem->yPos();
+                       cItem->Parent = gItem;
+                       if (gItem->rotation() != 0)
+                       {
+                               QTransform ma;
+                               ma.rotate(-gItem->rotation());
+                               FPoint n = FPoint(cItem->gXpos, cItem->gYpos);
+                               cItem->gXpos = ma.m11() * n.x() + ma.m21() * 
n.y() + ma.dx();
+                               cItem->gYpos = ma.m22() * n.y() + ma.m12() * 
n.x() + ma.dy();
+                               cItem->setRotation(cItem->rotation() - 
gItem->rotation());
+                               cItem->oldRot = cItem->rotation();
+                       }
+                       m_Doc->MasterItems.removeOne(cItem);
+               }
+               bool converted = false;
+               if (isTableIt)
+                       converted = convertOldTable(m_Doc, gItem, gpL, 
&groupStackM, &m_Doc->MasterItems);
+               if (!converted)
+                       gItem->groupItemList = gpL;
+       }
+
        // reestablish first/lastAuto
        m_Doc->FirstAuto = m_Doc->LastAuto;
        if (m_Doc->LastAuto)

Modified: 
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23458&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- 
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp  
    (original)
+++ 
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp  
    Fri Feb  7 14:12:20 2020
@@ -205,11 +205,15 @@
        QMap<int,PageItem*> TableIDF;
        QMap<int,PageItem*> TableIDM;
        QMap<int,PageItem*> WeldID;
-       QStack< QList<PageItem*> > groupStack;
+       QStack< QList<PageItem*> > groupStackFI;
+       QStack< QList<PageItem*> > groupStackMI;
+       QStack< QList<PageItem*> > groupStackPI;
        QStack< QList<PageItem*> > groupStackF;
        QStack< QList<PageItem*> > groupStackM;
        QStack< QList<PageItem*> > groupStackP;
-       QStack<int> groupStack2;
+       QStack<int> groupStackFI2;
+       QStack<int> groupStackMI2;
+       QStack<int> groupStackPI2;
 
 
        itemRemap.clear();
@@ -357,28 +361,60 @@
                                        }
                                }
                        }
-                       if (groupStack.count() > 0)
-                       {
-                               groupStack.top().append(itemInfo.item);
-                               while (static_cast<int>(itemInfo.ownNr) == 
groupStack2.top())
-                               {
-                                       if ((tagName == "PAGEOBJECT") || 
(tagName == "ITEM"))
-                                               
groupStackP.push(groupStack.pop());
-                                       else if (tagName == "FRAMEOBJECT")
-                                               
groupStackF.push(groupStack.pop());
-                                       else
-                                               
groupStackM.push(groupStack.pop());
-                                       groupStack2.pop();
-                                       if (groupStack2.count() == 0)
+
+                       if ((tagName == "PAGEOBJECT") && (groupStackPI.count() 
> 0))
+                       {
+                               groupStackPI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackPI2.top())
+                               {
+                                       groupStackP.push(groupStackPI.pop());
+                                       groupStackPI2.pop();
+                                       if (groupStackPI2.count() == 0)
                                                break;
                                }
                        }
+                       else if ((tagName == "FRAMEOBJECT") && 
(groupStackFI.count() > 0))
+                       {
+                               groupStackFI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackFI2.top())
+                               {
+                                       groupStackF.push(groupStackFI.pop());
+                                       groupStackFI2.pop();
+                                       if (groupStackFI2.count() == 0)
+                                               break;
+                               }
+                       }
+                       else if ((tagName == "MASTEROBJECT") && 
(groupStackMI.count() > 0))
+                       {
+                               groupStackMI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackMI2.top())
+                               {
+                                       groupStackM.push(groupStackMI.pop());
+                                       groupStackMI2.pop();
+                                       if (groupStackMI2.count() == 0)
+                                               break;
+                               }
+                       }
+
                        if (itemInfo.isGroupFlag)
                        {
-                               QList<PageItem*> GroupItems;
-                               GroupItems.append(itemInfo.item);
-                               groupStack.push(GroupItems);
-                               groupStack2.push(itemInfo.groupLastItem + 
itemInfo.ownNr);
+                               QList<PageItem*> groupItems;
+                               groupItems.append(itemInfo.item);
+                               if (tagName == "PAGEOBJECT")
+                               {
+                                       groupStackPI.push(groupItems);
+                                       
groupStackPI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else if (tagName == "FRAMEOBJECT")
+                               {
+                                       groupStackFI.push(groupItems);
+                                       
groupStackFI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else
+                               {
+                                       groupStackMI.push(groupItems);
+                                       
groupStackMI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
                        }
                }
                if (tagName == "Pattern")
@@ -697,11 +733,15 @@
        QList<PageItem*> TableItemsF;
        QMap<int,PageItem*> WeldID;
        QList<PageItem*> WeldItems;
-       QStack< QList<PageItem*> > groupStack;
+       QStack< QList<PageItem*> > groupStackFI;
+       QStack< QList<PageItem*> > groupStackMI;
+       QStack< QList<PageItem*> > groupStackPI;
        QStack< QList<PageItem*> > groupStackF;
        QStack< QList<PageItem*> > groupStackM;
        QStack< QList<PageItem*> > groupStackP;
-       QStack<int> groupStack2;
+       QStack<int> groupStackFI2;
+       QStack<int> groupStackMI2;
+       QStack<int> groupStackPI2;
 
        QByteArray docBytes("");
        loadRawText(fileName, docBytes);
@@ -858,28 +898,60 @@
                                        WeldID.insert(itemInfo.ownWeld, 
itemInfo.item);
                                }
                        }
-                       if (groupStack.count() > 0)
-                       {
-                               groupStack.top().append(itemInfo.item);
-                               while (static_cast<int>(itemInfo.ownNr) == 
groupStack2.top())
-                               {
-                                       if (tagName == "PAGEOBJECT")
-                                               
groupStackP.push(groupStack.pop());
-                                       else if (tagName == "FRAMEOBJECT")
-                                               
groupStackF.push(groupStack.pop());
-                                       else
-                                               
groupStackM.push(groupStack.pop());
-                                       groupStack2.pop();
-                                       if (groupStack2.count() == 0)
+
+                       if ((tagName == "PAGEOBJECT") && (groupStackPI.count() 
> 0))
+                       {
+                               groupStackPI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackPI2.top())
+                               {
+                                       groupStackP.push(groupStackPI.pop());
+                                       groupStackPI2.pop();
+                                       if (groupStackPI2.count() == 0)
                                                break;
                                }
                        }
+                       else if ((tagName == "FRAMEOBJECT") && 
(groupStackFI.count() > 0))
+                       {
+                               groupStackFI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackFI2.top())
+                               {
+                                       groupStackF.push(groupStackFI.pop());
+                                       groupStackFI2.pop();
+                                       if (groupStackFI2.count() == 0)
+                                               break;
+                               }
+                       }
+                       else if ((tagName == "MASTEROBJECT") && 
(groupStackMI.count() > 0))
+                       {
+                               groupStackMI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackMI2.top())
+                               {
+                                       groupStackM.push(groupStackMI.pop());
+                                       groupStackMI2.pop();
+                                       if (groupStackMI2.count() == 0)
+                                               break;
+                               }
+                       }
+
                        if (itemInfo.isGroupFlag)
                        {
-                               QList<PageItem*> GroupItems;
-                               GroupItems.append(itemInfo.item);
-                               groupStack.push(GroupItems);
-                               groupStack2.push(itemInfo.groupLastItem + 
itemInfo.ownNr);
+                               QList<PageItem*> groupItems;
+                               groupItems.append(itemInfo.item);
+                               if (tagName == "PAGEOBJECT")
+                               {
+                                       groupStackPI.push(groupItems);
+                                       
groupStackPI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else if (tagName == "FRAMEOBJECT")
+                               {
+                                       groupStackFI.push(groupItems);
+                                       
groupStackFI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else
+                               {
+                                       groupStackMI.push(groupItems);
+                                       
groupStackMI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
                        }
                }
                if (tagName == "Pattern")
@@ -1231,11 +1303,15 @@
        QList<PageItem*> TableItemsF;
        QMap<int,PageItem*> WeldID;
        QList<PageItem*> WeldItems;
-       QStack< QList<PageItem*> > groupStack;
+       QStack< QList<PageItem*> > groupStackFI;
+       QStack< QList<PageItem*> > groupStackMI;
+       QStack< QList<PageItem*> > groupStackPI;
        QStack< QList<PageItem*> > groupStackF;
        QStack< QList<PageItem*> > groupStackM;
        QStack< QList<PageItem*> > groupStackP;
-       QStack<int> groupStack2;
+       QStack<int> groupStackFI2;
+       QStack<int> groupStackMI2;
+       QStack<int> groupStackPI2;
        
        markeredItemsMap.clear();
        markeredMarksMap.clear();
@@ -1524,28 +1600,60 @@
                                        WeldID.insert(itemInfo.ownWeld, 
itemInfo.item);
                                }
                        }
-                       if (groupStack.count() > 0)
-                       {
-                               groupStack.top().append(itemInfo.item);
-                               while (static_cast<int>(itemInfo.ownNr) == 
groupStack2.top())
-                               {
-                                       if (tagName == "PAGEOBJECT")
-                                               
groupStackP.push(groupStack.pop());
-                                       else if (tagName == "FRAMEOBJECT")
-                                               
groupStackF.push(groupStack.pop());
-                                       else
-                                               
groupStackM.push(groupStack.pop());
-                                       groupStack2.pop();
-                                       if (groupStack2.count() == 0)
+
+                       if ((tagName == "PAGEOBJECT") && (groupStackPI.count() 
> 0))
+                       {
+                               groupStackPI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackPI2.top())
+                               {
+                                       groupStackP.push(groupStackPI.pop());
+                                       groupStackPI2.pop();
+                                       if (groupStackPI2.count() == 0)
                                                break;
                                }
                        }
+                       else if ((tagName == "FRAMEOBJECT") && 
(groupStackFI.count() > 0))
+                       {
+                               groupStackFI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackFI2.top())
+                               {
+                                       groupStackF.push(groupStackFI.pop());
+                                       groupStackFI2.pop();
+                                       if (groupStackFI2.count() == 0)
+                                               break;
+                               }
+                       }
+                       else if ((tagName == "MASTEROBJECT") && 
(groupStackMI.count() > 0))
+                       {
+                               groupStackMI.top().append(itemInfo.item);
+                               while (itemInfo.ownNr == groupStackMI2.top())
+                               {
+                                       groupStackM.push(groupStackMI.pop());
+                                       groupStackMI2.pop();
+                                       if (groupStackMI2.count() == 0)
+                                               break;
+                               }
+                       }
+
                        if (itemInfo.isGroupFlag)
                        {
-                               QList<PageItem*> GroupItems;
-                               GroupItems.append(itemInfo.item);
-                               groupStack.push(GroupItems);
-                               groupStack2.push(itemInfo.groupLastItem + 
itemInfo.ownNr);
+                               QList<PageItem*> groupItems;
+                               groupItems.append(itemInfo.item);
+                               if (tagName == "PAGEOBJECT")
+                               {
+                                       groupStackPI.push(groupItems);
+                                       
groupStackPI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else if (tagName == "FRAMEOBJECT")
+                               {
+                                       groupStackFI.push(groupItems);
+                                       
groupStackFI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
+                               else
+                               {
+                                       groupStackMI.push(groupItems);
+                                       
groupStackMI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                               }
                        }
                }
                if (tagName == "Pattern")
@@ -4305,7 +4413,7 @@
                if (groupStack.count() > 0)
                {
                        groupStack.top().append(itemInfo.item);
-                       while (static_cast<int>(itemInfo.ownNr) == 
groupStack2.top())
+                       while (itemInfo.ownNr == groupStack2.top())
                        {
                                groupStackP.push(groupStack.pop());
                                groupStack2.pop();
@@ -5993,10 +6101,15 @@
        QList<PageItem*> TableItems;
        QMap<int,PageItem*> WeldID;
        QList<PageItem*> WeldItems;
-       QStack< QList<PageItem*> > groupStack;
+       QStack< QList<PageItem*> > groupStackFI;
+       QStack< QList<PageItem*> > groupStackMI;
+       QStack< QList<PageItem*> > groupStackPI;
        QStack< QList<PageItem*> > groupStackF;
+       QStack< QList<PageItem*> > groupStackM;
        QStack< QList<PageItem*> > groupStackP;
-       QStack<int> groupStack2;
+       QStack<int> groupStackFI2;
+       QStack<int> groupStackMI2;
+       QStack<int> groupStackPI2;
        double pageX = 0, pageY = 0;
        QMap<int,int> layerTrans;
        int maxLayer = 0, maxLevel = 0, a = 0;
@@ -6267,7 +6380,6 @@
                        }
                        else
                        {
-
                                ItemInfo itemInfo;
                                QString masterPageName = Mpage ? 
renamedPageName : QString();
                                success = readObject(m_Doc, reader, itemInfo, 
fileDir, true, masterPageName);
@@ -6316,28 +6428,60 @@
                                                WeldID.insert(itemInfo.ownWeld, 
itemInfo.item);
                                        }
                                }
-                               if (groupStack.count() > 0)
-                               {
-                                       groupStack.top().append(itemInfo.item);
-                                       while (static_cast<int>(itemInfo.ownNr) 
== groupStack2.top())
+
+                               if ((tagName == "PAGEOBJECT") && 
(groupStackPI.count() > 0))
+                               {
+                                       
groupStackPI.top().append(itemInfo.item);
+                                       while (itemInfo.ownNr == 
groupStackPI2.top())
                                        {
-                                               if (tagName == "PAGEOBJECT")
-                                                       
groupStackP.push(groupStack.pop());
-                                               else if (tagName == 
"FRAMEOBJECT")
-                                                       
groupStackF.push(groupStack.pop());
-                                               else
-                                                       groupStack.pop();
-                                               groupStack2.pop();
-                                               if (groupStack2.count() == 0)
+                                               
groupStackP.push(groupStackPI.pop());
+                                               groupStackPI2.pop();
+                                               if (groupStackPI2.count() == 0)
                                                        break;
                                        }
                                }
+                               else if ((tagName == "FRAMEOBJECT") && 
(groupStackFI.count() > 0))
+                               {
+                                       
groupStackFI.top().append(itemInfo.item);
+                                       while (itemInfo.ownNr == 
groupStackFI2.top())
+                                       {
+                                               
groupStackF.push(groupStackFI.pop());
+                                               groupStackFI2.pop();
+                                               if (groupStackFI2.count() == 0)
+                                                       break;
+                                       }
+                               }
+                               else if ((tagName == "MASTEROBJECT") && 
(groupStackMI.count() > 0))
+                               {
+                                       
groupStackMI.top().append(itemInfo.item);
+                                       while (itemInfo.ownNr == 
groupStackMI2.top())
+                                       {
+                                               
groupStackM.push(groupStackMI.pop());
+                                               groupStackMI2.pop();
+                                               if (groupStackMI2.count() == 0)
+                                                       break;
+                                       }
+                               }
+
                                if (itemInfo.isGroupFlag)
                                {
-                                       QList<PageItem*> GroupItems;
-                                       GroupItems.append(itemInfo.item);
-                                       groupStack.push(GroupItems);
-                                       groupStack2.push(itemInfo.groupLastItem 
+ itemInfo.ownNr);
+                                       QList<PageItem*> groupItems;
+                                       groupItems.append(itemInfo.item);
+                                       if (tagName == "PAGEOBJECT")
+                                       {
+                                               groupStackPI.push(groupItems);
+                                               
groupStackPI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                                       }
+                                       else if (tagName == "FRAMEOBJECT")
+                                       {
+                                               groupStackFI.push(groupItems);
+                                               
groupStackFI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                                       }
+                                       else
+                                       {
+                                               groupStackMI.push(groupItems);
+                                               
groupStackMI2.push(itemInfo.groupLastItem + itemInfo.ownNr);
+                                       }
                                }
                        }
                }
@@ -6534,7 +6678,6 @@
                        gItem->groupItemList = gpL;
        }
 
-
        while (groupStackF.count() > 0)
        {
                bool isTableIt = false;
@@ -6562,6 +6705,37 @@
                bool converted = false;
                if (isTableIt)
                        converted = convertOldTable(m_Doc, gItem, gpL, 
&groupStackF, nullptr);
+               if (!converted)
+                       gItem->groupItemList = gpL;
+       }
+
+       while (groupStackM.count() > 0)
+       {
+               bool isTableIt = false;
+               QList<PageItem*> gpL = groupStackM.pop();
+               PageItem* gItem = gpL.takeFirst();
+               for (int id = 0; id < gpL.count(); id++)
+               {
+                       PageItem* cItem = gpL.at(id);
+                       isTableIt = cItem->isTableItem;
+                       cItem->gXpos = cItem->xPos() - gItem->xPos();
+                       cItem->gYpos = cItem->yPos() - gItem->yPos();
+                       cItem->Parent = gItem;
+                       if (gItem->rotation() != 0)
+                       {
+                               QTransform ma;
+                               ma.rotate(-gItem->rotation());
+                               FPoint n = FPoint(cItem->gXpos, cItem->gYpos);
+                               cItem->gXpos = ma.m11() * n.x() + ma.m21() * 
n.y() + ma.dx();
+                               cItem->gYpos = ma.m22() * n.y() + ma.m12() * 
n.x() + ma.dy();
+                               cItem->setRotation(cItem->rotation() - 
gItem->rotation());
+                               cItem->oldRot = cItem->rotation();
+                       }
+                       m_Doc->MasterItems.removeOne(cItem);
+               }
+               bool converted = false;
+               if (isTableIt)
+                       converted = convertOldTable(m_Doc, gItem, gpL, 
&groupStackM, &m_Doc->MasterItems);
                if (!converted)
                        gItem->groupItemList = gpL;
        }


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to