923
QList<int> ScribusDoc::getSortedStyleList()
926
for (int ff = 0; ff < docParagraphStyles.count(); ++ff)
928
if (docParagraphStyles[ff].parent().isEmpty())
930
if (!retList.contains(ff))
936
QString name = docParagraphStyles[ff].name();
937
QString par = docParagraphStyles[ff].parent();
938
retList2.prepend(ff);
939
while ((!par.isEmpty()) && (par != name))
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();
946
for (int r = 0; r < retList2.count(); ++r)
948
if (!retList.contains(retList2[r]))
949
retList.append(retList2[r]);
955
QList<int> ScribusDoc::getSortedCharStyleList()
958
for (int ff = 0; ff < docCharStyles.count(); ++ff)
960
if (docCharStyles[ff].parent().isEmpty())
962
if (!retList.contains(ff))
968
QString name = docCharStyles[ff].name();
969
QString par = docCharStyles[ff].parent();
970
retList2.prepend(ff);
971
while ((!par.isEmpty()) && (par != name))
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();
978
for (int r = 0; r < retList2.count(); ++r)
980
if (!retList.contains(retList2[r]))
981
retList.append(retList2[r]);
922
987
void ScribusDoc::replaceStyles(const QMap<QString,QString>& newNameForOld)
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"))
1879
1946
setCurrentPage(Pages->at(pageNumber!=0?0:1));
1880
1947
Page* page = Pages->takeAt(pageNumber);
1886
void ScribusDoc::movePage(const int from, const int to, const int ziel, const int art)
1891
for (int a = from; a < to; ++a)
1893
Buf.append(Pages->takeAt(from));
1897
int bufCount=Buf.count();
1901
for (int b = 0; b < bufCount; ++b)
1902
Pages->insert(zz++, Buf.at(b));
1905
for (int b = 0; b < bufCount; ++b)
1906
Pages->insert(++zz, Buf.at(b));
1909
for (int b = 0; b < bufCount; ++b)
1910
Pages->append(Buf.at(b));
1954
void ScribusDoc::movePage(const int fromPage, const int toPage, const int dest, const int position)
1956
QList<Page*> pageList;
1957
int numPages = dest;
1958
for (int i = fromPage; i < toPage; ++i)
1960
pageList.append(Pages->takeAt(fromPage));
1964
int pageListCount=pageList.count();
1967
case 0: //Before Page
1968
for (int j = 0; j < pageListCount; ++j)
1969
Pages->insert(numPages++, pageList.at(j));
1971
case 1: //After Page
1972
for (int j = 0; j < pageListCount; ++j)
1973
Pages->insert(++numPages, pageList.at(j));
1976
for (int j = 0; j < pageListCount; ++j)
1977
Pages->append(pageList.at(j));
1981
if (UndoManager::undoEnabled())
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);
1992
if (m_View && m_ScMW )
1994
m_View->reformPagesView();
1995
m_ScMW->updateGUIAfterPagesChanged();
2000
void ScribusDoc::restoreMovePage(SimpleState *state, bool isUndo)
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");
2009
int newPageDest=fromPage;
2013
int pagesMoved=toPage-fromPage;
2016
case 0: //Before Page
2017
newPageFrom=dest-pagesMoved;
2019
case 1: //After Page
2020
newPageFrom=dest-pagesMoved+1;
2023
newPageFrom=Pages->count()-pagesMoved;
2026
newPageTo=newPageFrom+pagesMoved;
2027
movePage(newPageFrom, newPageTo, newPageDest, newPosition);
2030
movePage(fromPage, toPage, dest, position);
3019
3136
if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
3138
/* May be needed for fixing #10371 completely
3139
if (it->isAnnotation())
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())))
3145
Really.insert(it->itemText.defaultStyle().charStyle().font().replacementName(), QMap<uint, FPointArray>());
3021
3148
for (int e = 0; e < it->itemText.length(); ++e)
3023
3150
if (! Really.contains(it->itemText.charStyle(e).font().replacementName()) )
3067
3194
if ((chr == 30) || (chr == 23))
3069
/* CB Removed forced loading of 0-9 for section based numbering
3070
for (uint numco = 0x30; numco < 0x3A; ++numco)
3072
if (it->itemText.charStyle(e)->cfont->CharWidth.contains(numco))
3074
gly = it->itemText.charStyle(e)->cfont->GlyphArray[numco].Outlines.copy();
3075
it->itemText.charStyle(e)->cfont->RealGlyphs.insert(numco, gly);
3078
3196
//Our page number collection string
3079
3197
QString pageNumberText(QString::null);
3082
//If not on a master page just get the page number for the page and the text
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);
4431
void ScribusDoc::fixItemPageOwner()
4436
MarginStruct pageBleeds;
4438
for (int i = 0; i < Items->count(); ++i)
4440
currItem = Items->at(i);
4441
pageNr = currItem->OwnPage;
4443
// TODO check group owner
4444
if (currItem->Groups.count() != 0)
4447
// If item has a valid page, check that
4448
// specified page effectively contain the item
4449
if (pageNr >= 0 && pageNr < Pages->count())
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)))
4467
// If no or page owner is incorrect, recompute page owner
4468
currItem->OwnPage = OnPage(currItem);
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)
4475
currItem = FrameItems.at(i);
4476
currItem->OwnPage = -1;
4312
4481
struct oldPageVar
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);
4442
if (item->Groups.count() != 0)
4445
item->OwnPage = OnPage(item);
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);
4448
4607
item->setRedrawBounding();
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);
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;
6210
6372
currItem->itemText.applyCharStyle(start, qMax(0, length), newStyle);
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;
6269
6432
currItem->itemText.setCharStyle(start, length, newStyle);
6668
6836
currItem->setImageFlippedH(fho);
6669
6837
currItem->setImageFlippedV(fvo);
6670
6838
currItem->AdjustPictScale();
6673
6842
PageItem *ite = pa.items.at(0);
6674
6843
docPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items);
6676
regionsChanged()->update(QRectF());
6847
regionsChanged()->update(QRectF());
6680
6852
void ScribusDoc::updatePictDir(QString name)
6682
6855
for (int a = 0; a < DocItems.count(); ++a)
6684
6857
PageItem *currItem = DocItems.at(a);
6964
7148
currItem->PictureIsAvailable = false;
6965
7149
currItem->pixm = ScImage();
6968
7153
PageItem *ite = pa.items.at(0);
6969
7154
docPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items);
6971
regionsChanged()->update(QRectF());
7158
regionsChanged()->update(QRectF());
6976
7163
void ScribusDoc::updatePic()
6978
7165
//TODO? Getting the pointer with m_Selection->itemAt(i) over and over again in the loop
7784
void ScribusDoc::itemSelection_SetItemTextReversed(bool reversed)
7786
uint selectedItemCount = m_Selection->count();
7787
if (selectedItemCount != 0)
7789
UndoTransaction *activeTransaction = NULL;
7790
if (UndoManager::undoEnabled())
7791
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
7792
for (uint i = 0; i < selectedItemCount; ++i)
7794
PageItem *currItem = m_Selection->itemAt(i);
7795
currItem->setImageFlippedH(reversed);
7796
currItem->setReversed(reversed);
7798
if (activeTransaction)
7800
activeTransaction->commit(Um::Selection,
7805
delete activeTransaction;
7806
activeTransaction = NULL;
7808
regionsChanged()->update(QRectF());
7597
7814
void ScribusDoc::itemSelection_SetItemFillTransparency(double t)
7599
7816
uint selectedItemCount=m_Selection->count();
10489
10709
void ScribusDoc::itemSelection_SplitItems(Selection* /*customSelection*/)
10491
10711
PageItem *bb;
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)
10498
if (currItem->PoLine.point(a).x() > 900000)
10715
PageItem *currItem = m_Selection->itemAt(i);
10716
if (!currItem->isPolygon() || currItem->Segments.count() <= 0)
10719
uint EndInd = currItem->PoLine.size();
10720
for (uint a = EndInd-1; a > 0; --a)
10501
bb = new PageItem_Polygon(*currItem);
10503
bb->ItemNr = Items->count()-1;
10504
bb->convertTo(PageItem::Polygon);
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;
10514
EndInd = StartInd - 4;
10722
if (currItem->PoLine.point(a).x() > 900000)
10725
bb = new PageItem_Polygon(*currItem);
10727
bb->ItemNr = Items->count()-1;
10728
bb->convertTo(PageItem::Polygon);
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;
10738
EndInd = StartInd - 4;
10741
currItem->PoLine.resize(StartInd-4);
10742
AdjustItemSize(currItem);
10743
currItem->ContourLine = currItem->PoLine.copy();
10744
currItem->ClipEdited = true;
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);