~ubuntu-branches/ubuntu/wily/scribus/wily-proposed

« back to all changes in this revision

Viewing changes to scribus/scribusdoc.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <sstream>
28
28
 
29
29
#include <QByteArray>
30
 
 #include <QDebug>
 
30
#include <QDebug>
31
31
#include <QEventLoop>
32
32
#include <QFile>
33
33
#include <QList>
128
128
                }
129
129
        }
130
130
        
131
 
        void changed(Page* pg)
 
131
        void changed(Page* pg, bool /*layout*/)
132
132
        {
133
133
                QRectF pagebox(pg->xOffset(), pg->yOffset(), pg->width(), pg->height());
134
134
                doc->invalidateRegion(pagebox);
141
141
                m_docChangeNeeded = true;
142
142
        }
143
143
        
144
 
        void changed(PageItem* it)
 
144
        void changed(PageItem* it, bool layout)
145
145
        {
146
146
                it->invalidateLayout();
 
147
                if (layout)
 
148
                        it->layout();
147
149
                doc->regionsChanged()->update(it->getBoundingRect());
148
150
                if (m_updateEnabled <= 0)
149
151
                {
918
920
        return false;
919
921
}
920
922
 
 
923
QList<int> ScribusDoc::getSortedStyleList()
 
924
{
 
925
        QList<int> retList;
 
926
        for (int ff = 0; ff < docParagraphStyles.count(); ++ff)
 
927
        {
 
928
                if (docParagraphStyles[ff].parent().isEmpty())
 
929
                {
 
930
                        if (!retList.contains(ff))
 
931
                                retList.append(ff);
 
932
                        continue;
 
933
                }
 
934
 
 
935
                QList<int> retList2;
 
936
                QString name = docParagraphStyles[ff].name();
 
937
                QString par  = docParagraphStyles[ff].parent();
 
938
                retList2.prepend(ff);
 
939
                while ((!par.isEmpty()) && (par != name))
 
940
                {
 
941
                        int pp = docParagraphStyles.find(par);
 
942
                        if ((pp >= 0) && (!retList2.contains(pp)))
 
943
                                retList2.prepend(pp);
 
944
                        par = (pp >= 0) ? docParagraphStyles[pp].parent() : QString();
 
945
                }
 
946
                for (int r = 0; r < retList2.count(); ++r)
 
947
                {
 
948
                        if (!retList.contains(retList2[r]))
 
949
                                retList.append(retList2[r]);
 
950
                }
 
951
        }
 
952
        return retList;
 
953
}
 
954
 
 
955
QList<int> ScribusDoc::getSortedCharStyleList()
 
956
{
 
957
        QList<int> retList;
 
958
        for (int ff = 0; ff < docCharStyles.count(); ++ff)
 
959
        {
 
960
                if (docCharStyles[ff].parent().isEmpty())
 
961
                {
 
962
                        if (!retList.contains(ff))
 
963
                                retList.append(ff);
 
964
                        continue;
 
965
                }
 
966
 
 
967
                QList<int> retList2;
 
968
                QString name = docCharStyles[ff].name();
 
969
                QString par  = docCharStyles[ff].parent();
 
970
                retList2.prepend(ff);
 
971
                while ((!par.isEmpty()) && (par != name))
 
972
                {
 
973
                        int pp = docCharStyles.find(par);
 
974
                        if ((pp >= 0) && (!retList2.contains(pp)))
 
975
                                retList2.prepend(pp);
 
976
                        par = (pp >= 0) ? docCharStyles[pp].parent() : QString();
 
977
                }
 
978
                for (int r = 0; r < retList2.count(); ++r)
 
979
                {
 
980
                        if (!retList.contains(retList2[r]))
 
981
                                retList.append(retList2[r]);
 
982
                }
 
983
        }
 
984
        return retList;
 
985
}
921
986
 
922
987
void ScribusDoc::replaceStyles(const QMap<QString,QString>& newNameForOld)
923
988
{
1361
1426
                }
1362
1427
                else if (ss->contains("OLD_MASTERPAGE"))
1363
1428
                        restoreMasterPageApplying(ss, isUndo);
1364
 
                else if (ss->contains("COPY_PAGE"))
1365
 
                        restorePageCopy(ss, isUndo);
 
1429
                else if (ss->contains("PAGE_COPY"))
 
1430
                        restoreCopyPage(ss, isUndo);
 
1431
                else if (ss->contains("PAGE_MOVE"))
 
1432
                        restoreMovePage(ss, isUndo);
1366
1433
                else if (ss->contains("PAGE_CHANGEPROPS"))
1367
1434
                {
1368
1435
                        if (isUndo)
1879
1946
        setCurrentPage(Pages->at(pageNumber!=0?0:1));
1880
1947
        Page* page = Pages->takeAt(pageNumber);
1881
1948
        delete page;
1882
 
        changed();
1883
 
}
1884
 
 
1885
 
 
1886
 
void ScribusDoc::movePage(const int from, const int to, const int ziel, const int art)
1887
 
{
1888
 
        QList<Page*> Buf;
1889
 
        int zz = ziel;
1890
 
        Buf.clear();
1891
 
        for (int a = from; a < to; ++a)
1892
 
        {
1893
 
                Buf.append(Pages->takeAt(from));
1894
 
                if (a <= zz)
1895
 
                        --zz;
1896
 
        }
1897
 
        int bufCount=Buf.count();
1898
 
        switch (art)
1899
 
        {
1900
 
                case 0:
1901
 
                        for (int b = 0; b < bufCount; ++b)
1902
 
                                Pages->insert(zz++, Buf.at(b));
1903
 
                        break;
1904
 
                case 1:
1905
 
                        for (int b = 0; b < bufCount; ++b)
1906
 
                                Pages->insert(++zz, Buf.at(b));
1907
 
                        break;
1908
 
                case 2:
1909
 
                        for (int b = 0; b < bufCount; ++b)
1910
 
                                Pages->append(Buf.at(b));
1911
 
                        break;
1912
 
        }
1913
 
        changed();
 
1949
        reformPages();
 
1950
        changed();
 
1951
}
 
1952
 
 
1953
 
 
1954
void ScribusDoc::movePage(const int fromPage, const int toPage, const int dest, const int position)
 
1955
{
 
1956
        QList<Page*> pageList;
 
1957
        int numPages = dest;
 
1958
        for (int i = fromPage; i < toPage; ++i)
 
1959
        {
 
1960
                pageList.append(Pages->takeAt(fromPage));
 
1961
                if (i <= numPages)
 
1962
                        --numPages;
 
1963
        }
 
1964
        int pageListCount=pageList.count();
 
1965
        switch (position)
 
1966
        {
 
1967
                case 0: //Before Page
 
1968
                        for (int j = 0; j < pageListCount; ++j)
 
1969
                                Pages->insert(numPages++, pageList.at(j));
 
1970
                        break;
 
1971
                case 1: //After Page
 
1972
                        for (int j = 0; j < pageListCount; ++j)
 
1973
                                Pages->insert(++numPages, pageList.at(j));
 
1974
                        break;
 
1975
                case 2: //To End
 
1976
                        for (int j = 0; j < pageListCount; ++j)
 
1977
                                Pages->append(pageList.at(j));
 
1978
                        break;
 
1979
        }
 
1980
 
 
1981
        if (UndoManager::undoEnabled())
 
1982
        {
 
1983
                SimpleState *ss = new SimpleState(Um::MovePage, "", Um::IDocument);
 
1984
                ss->set("PAGE_MOVE", "page_move");
 
1985
                ss->set("PAGE_MOVE_FROM", fromPage);
 
1986
                ss->set("PAGE_MOVE_TO", toPage);
 
1987
                ss->set("PAGE_MOVE_DEST", dest);
 
1988
                ss->set("PAGE_MOVE_NEWPOS", position);
 
1989
                undoManager->action(this, ss, DocName, Um::IDocument);
 
1990
        }
 
1991
        reformPages();
 
1992
        if (m_View && m_ScMW )
 
1993
        {
 
1994
                m_View->reformPagesView();
 
1995
                m_ScMW->updateGUIAfterPagesChanged();
 
1996
        }
 
1997
        changed();
 
1998
}
 
1999
 
 
2000
void ScribusDoc::restoreMovePage(SimpleState *state, bool isUndo)
 
2001
{
 
2002
        int fromPage = state->getInt("PAGE_MOVE_FROM");
 
2003
        int toPage = state->getInt("PAGE_MOVE_TO");
 
2004
        int position = state->getInt("PAGE_MOVE_NEWPOS");
 
2005
        int dest = state->getInt("PAGE_MOVE_DEST");
 
2006
 
 
2007
        if (isUndo)
 
2008
        {
 
2009
                int newPageDest=fromPage;
 
2010
                int newPageFrom=0;
 
2011
                int newPageTo  =0;
 
2012
                int newPosition=0;
 
2013
                int pagesMoved=toPage-fromPage;
 
2014
                switch (position)
 
2015
                {
 
2016
                        case 0: //Before Page
 
2017
                                newPageFrom=dest-pagesMoved;
 
2018
                                break;
 
2019
                        case 1: //After Page
 
2020
                                newPageFrom=dest-pagesMoved+1;
 
2021
                                break;
 
2022
                        case 2: //To End
 
2023
                                newPageFrom=Pages->count()-pagesMoved;
 
2024
                                break;
 
2025
                }
 
2026
                newPageTo=newPageFrom+pagesMoved;
 
2027
                movePage(newPageFrom, newPageTo, newPageDest, newPosition);
 
2028
        }
 
2029
        else
 
2030
                movePage(fromPage, toPage, dest, position);
1914
2031
}
1915
2032
 
1916
2033
 
3018
3135
        QChar chstr;
3019
3136
        if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
3020
3137
        {
 
3138
                /* May be needed for fixing #10371 completely
 
3139
                if (it->isAnnotation())
 
3140
                {
 
3141
                        int annotType  = it->annotation().Type();
 
3142
                        bool mustEmbed = ((annotType >= 2) && (annotType <= 6) && (annotType != 4));
 
3143
                        if (mustEmbed && (!Really.contains(it->itemText.defaultStyle().charStyle().font().replacementName())))
 
3144
                        {
 
3145
                                Really.insert(it->itemText.defaultStyle().charStyle().font().replacementName(), QMap<uint, FPointArray>());
 
3146
                        }
 
3147
                }*/
3021
3148
                for (int e = 0; e < it->itemText.length(); ++e)
3022
3149
                {
3023
3150
                        if (! Really.contains(it->itemText.charStyle(e).font().replacementName()) )
3066
3193
                        }
3067
3194
                        if ((chr == 30) || (chr == 23))
3068
3195
                        {
3069
 
                                /* CB Removed forced loading of 0-9 for section based numbering
3070
 
                                for (uint numco = 0x30; numco < 0x3A; ++numco)
3071
 
                                {
3072
 
                                        if (it->itemText.charStyle(e)->cfont->CharWidth.contains(numco))
3073
 
                                        {
3074
 
                                                gly = it->itemText.charStyle(e)->cfont->GlyphArray[numco].Outlines.copy();
3075
 
                                                it->itemText.charStyle(e)->cfont->RealGlyphs.insert(numco, gly);
3076
 
                                        }
3077
 
                                }*/
3078
3196
                                //Our page number collection string
3079
3197
                                QString pageNumberText(QString::null);
3080
3198
                                if (chr == 30)
3081
3199
                                {
3082
 
                                        //If not on a master page just get the page number for the page and the text
3083
 
                                        if (lc!=0)
 
3200
                                        if (e > 0 && it->itemText.text(e-1) == SpecialChars::PAGENUMBER)
 
3201
                                                pageNumberText=SpecialChars::ZWNBSPACE;
 
3202
                                        else if (lc!=0) //If not on a master page just get the page number for the page and the text
3084
3203
                                                pageNumberText=getSectionPageNumberForPageIndex(it->OwnPage);
3085
3204
                                        else
3086
3205
                                        {
3361
3480
}
3362
3481
 
3363
3482
 
3364
 
void ScribusDoc::restorePageCopy(SimpleState *state, bool isUndo)
 
3483
void ScribusDoc::restoreCopyPage(SimpleState *state, bool isUndo)
3365
3484
{
3366
3485
        int pnum = state->getInt("PAGE_NUM");
3367
3486
        int extPage = state->getInt("EXISTING_PAGE");
3377
3496
                        destLocation=DocPages.count();
3378
3497
                for (int i = 0; i < copyCount; ++i)
3379
3498
                {
3380
 
                        m_ScMW->DeletePage(destLocation, destLocation);
 
3499
                        m_ScMW->deletePage(destLocation, destLocation);
3381
3500
                        if (whereTo == 2)
3382
3501
                                --destLocation;
3383
3502
                }
4097
4216
        if (!reload)
4098
4217
        {
4099
4218
                QFileInfo fi(pageItem->Pfile);
4100
 
                ScCore->fileWatcher->addDir(fi.absolutePath());
 
4219
                //#9845, why are we tracking dir changes when we are tracking the file itself
 
4220
                //ScCore->fileWatcher->addDir(fi.absolutePath());
4101
4221
                ScCore->fileWatcher->addFile(pageItem->Pfile);
4102
4222
        }
4103
4223
        if (!isLoading())
4308
4428
        }
4309
4429
}
4310
4430
 
 
4431
void  ScribusDoc::fixItemPageOwner()
 
4432
{
 
4433
        int pageNr;
 
4434
        Page* page;
 
4435
        PageItem* currItem;
 
4436
        MarginStruct pageBleeds;
 
4437
 
 
4438
        for (int i = 0; i < Items->count(); ++i)
 
4439
        {
 
4440
                currItem = Items->at(i);
 
4441
                pageNr = currItem->OwnPage;
 
4442
 
 
4443
                // TODO check group owner
 
4444
                if (currItem->Groups.count() != 0)
 
4445
                        continue;
 
4446
 
 
4447
                // If item has a valid page, check that
 
4448
                // specified page effectively contain the item
 
4449
                if (pageNr >= 0 && pageNr < Pages->count())
 
4450
                {
 
4451
                        page = Pages->at(pageNr);
 
4452
                        getBleeds(page, pageBleeds);
 
4453
                        double x1 = page->xOffset() - pageBleeds.Left;
 
4454
                        double y1 = page->yOffset() - pageBleeds.Top;
 
4455
                        double w1 = page->width()   + pageBleeds.Left + pageBleeds.Right;
 
4456
                        double h1 = page->height()  + pageBleeds.Bottom + pageBleeds.Top;
 
4457
                        double x2 = currItem->BoundingX;
 
4458
                        double y2 = currItem->BoundingY;
 
4459
                        double w2 = currItem->BoundingW;
 
4460
                        double h2 = currItem->BoundingH;
 
4461
                        if (( qMax(x1, x2) <= qMin(x1 + w1, x2 + w2) && qMax(y1, y2) <= qMin(y1 + h1, y2 + h2)))
 
4462
                        {
 
4463
                                continue;
 
4464
                        }
 
4465
                }
 
4466
 
 
4467
                // If no or page owner is incorrect, recompute page owner
 
4468
                currItem->OwnPage = OnPage(currItem);
 
4469
        }
 
4470
 
 
4471
        // #10379: Scribus crash when opening .sla document
 
4472
        // OwnPage is not meaningful for inline frame
 
4473
        for (int i = 0; i < FrameItems.count(); ++i)
 
4474
        {
 
4475
                currItem = FrameItems.at(i);
 
4476
                currItem->OwnPage = -1;
 
4477
        }
 
4478
}
 
4479
 
4311
4480
 
4312
4481
struct oldPageVar
4313
4482
{
4422
4591
                for (uint ite = 0; ite < docItemsCount; ++ite)
4423
4592
                {
4424
4593
                        PageItem *item = Items->at(ite);
4425
 
                        if (item->OwnPage < 0)
 
4594
                        if ((item->OwnPage < 0) || (!moveObjects))
4426
4595
                        {
4427
4596
                                if (item->Groups.count() != 0)
4428
4597
                                        GroupOnPage(item);
4431
4600
                        }
4432
4601
                        else
4433
4602
                        {
4434
 
                                if (moveObjects)
4435
 
                                {
4436
 
                                        oldPg = pageTable[item->OwnPage];
4437
 
                                        item->moveBy(-oldPg.oldXO + Pages->at(oldPg.newPg)->xOffset(), -oldPg.oldYO + Pages->at(oldPg.newPg)->yOffset());
4438
 
                                        item->OwnPage = static_cast<int>(oldPg.newPg);
4439
 
                                }
4440
 
                                else
4441
 
                                {
4442
 
                                        if (item->Groups.count() != 0)
4443
 
                                                GroupOnPage(item);
4444
 
                                        else
4445
 
                                                item->OwnPage = OnPage(item);
4446
 
                                }
 
4603
                                oldPg = pageTable[item->OwnPage];
 
4604
                                item->moveBy(-oldPg.oldXO + Pages->at(oldPg.newPg)->xOffset(), -oldPg.oldYO + Pages->at(oldPg.newPg)->yOffset());
 
4605
                                item->OwnPage = static_cast<int>(oldPg.newPg);
4447
4606
                        }
4448
4607
                        item->setRedrawBounding();
4449
4608
                }
4767
4926
bool ScribusDoc::itemNameExists(const QString checkItemName)
4768
4927
{
4769
4928
        bool found = false;
4770
 
        uint docItemCount=Items->count();
 
4929
        uint docItemCount = Items->count();
4771
4930
        for (uint i = 0; i < docItemCount; ++i)
4772
4931
        {
4773
4932
                if (checkItemName == Items->at(i)->itemName())
4971
5130
{
4972
5131
        UndoTransaction copyTransaction(undoManager->beginTransaction(getUName(), Um::IDocument, Um::CopyPage, "", Um::ICreate));
4973
5132
        SimpleState *ss = new SimpleState(Um::Copy, "", Um::ICreate);
4974
 
        ss->set("COPY_PAGE", "copy_page");
 
5133
        ss->set("PAGE_COPY", "page_copy");
4975
5134
        ss->set("PAGE_NUM", pageNumberToCopy);
4976
5135
        ss->set("EXISTING_PAGE", existingPage);
4977
5136
        ss->set("WHERE_TO", whereToInsert);
5070
5229
                                destination->initialMargins.Right = from->initialMargins.Right;
5071
5230
                        }
5072
5231
                }
 
5232
                reformPages();
5073
5233
                // FIXME: stop using m_View
5074
 
                m_View->reformPages();
 
5234
                if (m_View)
 
5235
                        m_View->reformPagesView();
5075
5236
                if (itemBuffer.count() > 0)
5076
5237
                {
5077
5238
                        int lcount = 0;
5323
5484
                for (uint c = 0; c < docSelectionCount; ++c)
5324
5485
                {
5325
5486
                        currItem = m_Selection->itemAt(c);
5326
 
                        if (((currItem->isSingleSel) && (currItem->isGroupControl)) || ((currItem->isSingleSel) && (currItem->isTableItem)))
 
5487
                        if ((currItem->isSingleSel) && ((currItem->Groups.count() > 0) || (currItem->isTableItem)))
5327
5488
                                return false;
5328
5489
                        ObjOrder.insert(currItem->ItemNr, c);
5329
5490
                        int d = Items->indexOf(currItem);
5352
5513
                for (uint c = 0; c < docSelectionCount; ++c)
5353
5514
                {
5354
5515
                        currItem = m_Selection->itemAt(c);
5355
 
                        if (((currItem->isSingleSel) && (currItem->isGroupControl)) || ((currItem->isSingleSel) && (currItem->isTableItem)))
 
5516
                        if ((currItem->isSingleSel) && ((currItem->Groups.count() > 0) || (currItem->isTableItem)))
5356
5517
                                return false;
5357
5518
                        ObjOrder.insert(currItem->ItemNr, c);
5358
5519
                        int d = Items->indexOf(currItem);
6030
6191
                                start = currItem->itemText.startOfSelection();
6031
6192
                                stop = currItem->itemText.endOfSelection();
6032
6193
                                if (start >= stop)
6033
 
                                        start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
 
6194
                                        start = stop = currItem->itemText.normalizedCursorPosition();
6034
6195
                        }
6035
6196
                        for (int pos=start; pos < stop; ++pos)
6036
6197
                        {
6084
6245
                                start = currItem->itemText.startOfSelection();
6085
6246
                                stop = currItem->itemText.endOfSelection();
6086
6247
                                if (start >= stop)
6087
 
                                        start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
 
6248
                                        start = stop = currItem->itemText.normalizedCursorPosition();
6088
6249
                        }
6089
6250
                        for (int pos=start; pos < stop; ++pos)
6090
6251
                        {
6148
6309
                                start = currItem->itemText.startOfSelection();
6149
6310
                                stop = currItem->itemText.endOfSelection();
6150
6311
                                if (start >= stop)
6151
 
                                        start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
 
6312
                                        start = stop = currItem->itemText.normalizedCursorPosition();
6152
6313
                        }
6153
6314
                        for (int pos=start; pos < stop; ++pos)
6154
6315
                        {
6203
6364
                                }
6204
6365
                                else
6205
6366
                                {
6206
 
                                        start = qMax(currItem->firstInFrame(), currItem->CPos);
6207
 
                                        length = (start + 1) < currItem->itemText.length()? 1 : 0;
 
6367
                                        start = qMax(currItem->firstInFrame(), currItem->itemText.cursorPosition());
 
6368
//9876                                  length = (start + 1) < currItem->itemText.length()? 1 : 0;
 
6369
                                        length = start < currItem->itemText.length() ? 1 : 0;
6208
6370
                                }
6209
6371
                        }
6210
6372
                        currItem->itemText.applyCharStyle(start, qMax(0, length), newStyle);
6262
6424
                                }
6263
6425
                                else
6264
6426
                                {
6265
 
                                        start = qMax(currItem->firstInFrame(), currItem->CPos);
6266
 
                                        length = (start + 1) < currItem->itemText.length()? 1 : 0;
 
6427
                                        start = qMax(currItem->firstInFrame(), currItem->itemText.cursorPosition());
 
6428
//9876                                  length = (start + 1) < currItem->itemText.length()? 1 : 0;
 
6429
                                        length = start < currItem->itemText.length()? 1 : 0;
6267
6430
                                }
6268
6431
                        }
6269
6432
                        currItem->itemText.setCharStyle(start, length, newStyle);
6320
6483
                                }
6321
6484
                                else
6322
6485
                                {
6323
 
                                        start = qMax(currItem->firstInFrame(), currItem->CPos);
6324
 
                                        length = (start + 1) < currItem->itemText.length()? 1 : 0;
 
6486
                                        start = qMax(currItem->firstInFrame(), currItem->itemText.cursorPosition());
 
6487
//9876                                  length = (start + 1) < currItem->itemText.length()? 1 : 0;
 
6488
                                        length = start < currItem->itemText.length() ? 1 : 0;
6325
6489
                                }
6326
6490
                        }
6327
6491
                        QString lastParent;
6614
6778
//CB Same as RecalcPicturesRes apart from the name checking, which should be able to be removed
6615
6779
void ScribusDoc::updatePict(QString name)
6616
6780
{
 
6781
        bool updated=false;
6617
6782
        for (int a = 0; a < DocItems.count(); ++a)
6618
6783
        {
6619
6784
                PageItem *currItem = DocItems.at(a);
6625
6790
                        currItem->setImageFlippedH(fho);
6626
6791
                        currItem->setImageFlippedV(fvo);
6627
6792
                        currItem->AdjustPictScale();
 
6793
                        updated=true;
6628
6794
                }
6629
6795
        }
6630
6796
        for (int a = 0; a < MasterItems.count(); ++a)
6638
6804
                        currItem->setImageFlippedH(fho);
6639
6805
                        currItem->setImageFlippedV(fvo);
6640
6806
                        currItem->AdjustPictScale();
 
6807
                        updated=true;
6641
6808
                }
6642
6809
        }
6643
6810
        for (int a = 0; a <FrameItems.count(); ++a)
6651
6818
                        currItem->setImageFlippedH(fho);
6652
6819
                        currItem->setImageFlippedV(fvo);
6653
6820
                        currItem->AdjustPictScale();
 
6821
                        updated=true;
6654
6822
                }
6655
6823
        }
6656
6824
        QStringList patterns = docPatterns.keys();
6668
6836
                                currItem->setImageFlippedH(fho);
6669
6837
                                currItem->setImageFlippedV(fvo);
6670
6838
                                currItem->AdjustPictScale();
 
6839
                                updated=true;
6671
6840
                        }
6672
6841
                }
6673
6842
                PageItem *ite = pa.items.at(0);
6674
6843
                docPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items);
6675
6844
        }
6676
 
        regionsChanged()->update(QRectF());
6677
 
        changed();
 
6845
        if (updated)
 
6846
        {
 
6847
                regionsChanged()->update(QRectF());
 
6848
                changed();
 
6849
        }
6678
6850
}
6679
6851
 
6680
6852
void ScribusDoc::updatePictDir(QString name)
6681
6853
{
 
6854
        bool updated=false;
6682
6855
        for (int a = 0; a < DocItems.count(); ++a)
6683
6856
        {
6684
6857
                PageItem *currItem = DocItems.at(a);
6698
6871
                                                currItem->setImageFlippedV(fvo);
6699
6872
                                                currItem->AdjustPictScale();
6700
6873
                                                ScCore->fileWatcher->addFile(currItem->Pfile);
 
6874
                                                updated=true;
6701
6875
                                        }
6702
6876
                                }
6703
6877
                        }
6722
6896
                                                currItem->setImageFlippedV(fvo);
6723
6897
                                                currItem->AdjustPictScale();
6724
6898
                                                ScCore->fileWatcher->addFile(currItem->Pfile);
 
6899
                                                updated=true;
6725
6900
                                        }
6726
6901
                                }
6727
6902
                        }
6746
6921
                                                currItem->setImageFlippedV(fvo);
6747
6922
                                                currItem->AdjustPictScale();
6748
6923
                                                ScCore->fileWatcher->addFile(currItem->Pfile);
 
6924
                                                updated=true;
6749
6925
                                        }
6750
6926
                                }
6751
6927
                        }
6774
6950
                                                        currItem->setImageFlippedV(fvo);
6775
6951
                                                        currItem->AdjustPictScale();
6776
6952
                                                        ScCore->fileWatcher->addFile(currItem->Pfile);
 
6953
                                                        updated=true;
6777
6954
                                                }
6778
6955
                                        }
6779
6956
                                }
6782
6959
                PageItem *ite = pa.items.at(0);
6783
6960
                docPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items);
6784
6961
        }
6785
 
        regionsChanged()->update(QRectF());
6786
 
        changed();
 
6962
        if (updated)
 
6963
        {
 
6964
                regionsChanged()->update(QRectF());
 
6965
                changed();
 
6966
        }
6787
6967
}
6788
6968
 
6789
6969
//CB Same as updatePict apart from the name checking, this should be able to be removed
6925
7105
 
6926
7106
void ScribusDoc::removePict(QString name)
6927
7107
{
 
7108
        bool updated=false;
6928
7109
        for (int a = 0; a < DocItems.count(); ++a)
6929
7110
        {
6930
7111
                PageItem *currItem = DocItems.at(a);
6932
7113
                {
6933
7114
                        currItem->PictureIsAvailable = false;
6934
7115
                        currItem->pixm = ScImage();
 
7116
                        updated=true;
6935
7117
                }
6936
7118
        }
6937
7119
        for (int a = 0; a < MasterItems.count(); ++a)
6941
7123
                {
6942
7124
                        currItem->PictureIsAvailable = false;
6943
7125
                        currItem->pixm = ScImage();
 
7126
                        updated=true;
6944
7127
                }
6945
7128
        }
6946
7129
        for (int a = 0; a < FrameItems.count(); ++a)
6950
7133
                {
6951
7134
                        currItem->PictureIsAvailable = false;
6952
7135
                        currItem->pixm = ScImage();
 
7136
                        updated=true;
6953
7137
                }
6954
7138
        }
6955
7139
        QStringList patterns = docPatterns.keys();
6963
7147
                        {
6964
7148
                                currItem->PictureIsAvailable = false;
6965
7149
                                currItem->pixm = ScImage();
 
7150
                                updated=true;
6966
7151
                        }
6967
7152
                }
6968
7153
                PageItem *ite = pa.items.at(0);
6969
7154
                docPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items);
6970
7155
        }
6971
 
        regionsChanged()->update(QRectF());
6972
 
        changed();
 
7156
        if (updated)
 
7157
        {
 
7158
                regionsChanged()->update(QRectF());
 
7159
                changed();
 
7160
        }
6973
7161
}
6974
7162
 
6975
 
 
6976
7163
void ScribusDoc::updatePic()
6977
7164
{
6978
7165
//TODO? Getting the pointer with m_Selection->itemAt(i) over and over again in the loop 
7594
7781
}
7595
7782
 
7596
7783
 
 
7784
void ScribusDoc::itemSelection_SetItemTextReversed(bool reversed)
 
7785
{
 
7786
        uint selectedItemCount = m_Selection->count();
 
7787
        if (selectedItemCount != 0)
 
7788
        {
 
7789
                UndoTransaction *activeTransaction = NULL;
 
7790
                if (UndoManager::undoEnabled())
 
7791
                        activeTransaction = new UndoTransaction(undoManager->beginTransaction());
 
7792
                for (uint i = 0; i < selectedItemCount; ++i)
 
7793
                {
 
7794
                        PageItem *currItem = m_Selection->itemAt(i);
 
7795
                        currItem->setImageFlippedH(reversed);
 
7796
                        currItem->setReversed(reversed);
 
7797
                }
 
7798
                if (activeTransaction)
 
7799
                {
 
7800
                        activeTransaction->commit(Um::Selection,
 
7801
                                                                          Um::IGroup,
 
7802
                                                                          Um::FlipH,
 
7803
                                                                          0,
 
7804
                                                                          Um::IFlipH);
 
7805
                        delete activeTransaction;
 
7806
                        activeTransaction = NULL;
 
7807
                }
 
7808
                regionsChanged()->update(QRectF());
 
7809
                changed();
 
7810
        }
 
7811
}
 
7812
 
 
7813
 
7597
7814
void ScribusDoc::itemSelection_SetItemFillTransparency(double t)
7598
7815
{
7599
7816
        uint selectedItemCount=m_Selection->count();
8065
8282
        changed();
8066
8283
        m_ScMW->HaveNewSel(m_Selection->itemAt(0)->itemType());
8067
8284
        for (int i = 0; i < m_Selection->count(); ++i)
 
8285
        {
8068
8286
                setRedrawBounding(m_Selection->itemAt(i));
 
8287
                m_Selection->itemAt(i)->invalidateLayout();
 
8288
        }
8069
8289
        m_alignTransaction->commit(); // commit and send the action to the UndoManager
8070
8290
        delete m_alignTransaction;
8071
8291
        m_alignTransaction = NULL;
10489
10709
void ScribusDoc::itemSelection_SplitItems(Selection* /*customSelection*/)
10490
10710
{
10491
10711
        PageItem *bb;
10492
 
        uint StartInd = 0;
10493
10712
        m_Selection->delaySignalsOn();
10494
 
        PageItem *currItem = m_Selection->itemAt(0);
10495
 
        uint EndInd = currItem->PoLine.size();
10496
 
        for (uint a = EndInd-1; a > 0; --a)
 
10713
        for (int i = 0; i < m_Selection->count(); ++i)
10497
10714
        {
10498
 
                if (currItem->PoLine.point(a).x() > 900000)
 
10715
                PageItem *currItem = m_Selection->itemAt(i);
 
10716
                if (!currItem->isPolygon() || currItem->Segments.count() <= 0)
 
10717
                        continue;
 
10718
                uint StartInd = 0;
 
10719
                uint EndInd = currItem->PoLine.size();
 
10720
                for (uint a = EndInd-1; a > 0; --a)
10499
10721
                {
10500
 
                        StartInd = a + 1;
10501
 
                        bb = new PageItem_Polygon(*currItem);
10502
 
                        Items->append(bb);
10503
 
                        bb->ItemNr = Items->count()-1;
10504
 
                        bb->convertTo(PageItem::Polygon);
10505
 
                        bb->Frame = false;
10506
 
                        bb->FrameType = 3;
10507
 
                        bb->PoLine.resize(0);
10508
 
                        bb->PoLine.putPoints(0, EndInd - StartInd, currItem->PoLine, StartInd);
10509
 
                        bb->setRotation(currItem->rotation());
10510
 
                        AdjustItemSize(bb);
10511
 
                        bb->ContourLine = bb->PoLine.copy();
10512
 
                        bb->ClipEdited = true;
10513
 
                        a -= 3;
10514
 
                        EndInd = StartInd - 4;
 
10722
                        if (currItem->PoLine.point(a).x() > 900000)
 
10723
                        {
 
10724
                                StartInd = a + 1;
 
10725
                                bb = new PageItem_Polygon(*currItem);
 
10726
                                Items->append(bb);
 
10727
                                bb->ItemNr = Items->count()-1;
 
10728
                                bb->convertTo(PageItem::Polygon);
 
10729
                                bb->Frame = false;
 
10730
                                bb->FrameType = 3;
 
10731
                                bb->PoLine.resize(0);
 
10732
                                bb->PoLine.putPoints(0, EndInd - StartInd, currItem->PoLine, StartInd);
 
10733
                                bb->setRotation(currItem->rotation());
 
10734
                                AdjustItemSize(bb);
 
10735
                                bb->ContourLine = bb->PoLine.copy();
 
10736
                                bb->ClipEdited = true;
 
10737
                                a -= 3;
 
10738
                                EndInd = StartInd - 4;
 
10739
                        }
10515
10740
                }
 
10741
                currItem->PoLine.resize(StartInd-4);
 
10742
                AdjustItemSize(currItem);
 
10743
                currItem->ContourLine = currItem->PoLine.copy();
 
10744
                currItem->ClipEdited = true;
10516
10745
        }
10517
 
        currItem->PoLine.resize(StartInd-4);
10518
 
        AdjustItemSize(currItem);
10519
 
        currItem->ContourLine = currItem->PoLine.copy();
10520
 
        currItem->ClipEdited = true;
10521
10746
        m_Selection->delaySignalsOff();
10522
10747
        //FIXME: stop using m_View
10523
10748
        m_View->Deselect(true);