Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 3675 → Rev 3676

/branches/Version13x/Scribus/scribus/fileloader.cpp
2598,11 → 2598,11
}
//Calculate the canvas size
FPoint mincp, maxcp;
if (!is12doc)
{
FPoint mincp, maxcp;
ScApp->doc->canvasMinMax(mincp, maxcp);
FPoint maximumCanvas = FPoint(QMAX(maxcp.x(), maximumX), QMAX(maxcp.y(), maximumY));
FPoint maximumCanvas(QMAX(maxcp.x(), maximumX), QMAX(maxcp.y(), maximumY));
ScApp->view->adjustCanvas(mincp, maximumCanvas);
}
/branches/Version13x/Scribus/scribus/undomanager.h
517,6 → 517,7
static QString Polygon;
static QString BezierCurve;
static QString Polyline;
static QString PathText;
static QString ConvertTo;
static QString ImportSVG;
static QString ImportEPS;
/branches/Version13x/Scribus/scribus/scribusdoc.cpp
2676,16 → 2676,18
return -1.0;
}
 
PageItem* ScribusDoc::convertItemTo(PageItem *currItem, PageItem::ItemType newType)
PageItem* ScribusDoc::convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem)
{
//Item to convert is null, return
Q_ASSERT(currItem!=NULL);
if (currItem==NULL)
return false;
//Dont attempt a Line conversion
if (currItem->itemType()==PageItem::Line || newType==PageItem::Line)
return false;
 
//Take the item to convert from the docs Items list
PageItem *oldItem = Items.take(currItem->ItemNr);
//Create a new item from the old one
PageItem *newItem;
switch (newType)
{
2706,6 → 2708,10
newItem = new PageItem_PolyLine(*oldItem);
break;
case PageItem::PathText:
if (secondaryItem==NULL)
return false;
if (UndoManager::undoEnabled())
undoManager->beginTransaction(currentPage->getUName(), 0, Um::PathText, "", Um::ITextFrame);
newItem = new PageItem_PathText(*oldItem);
break;
default:
2713,8 → 2719,16
break;
}
Q_ASSERT(newItem!=NULL);
//If the new item is null, return. If converting Text to Path, start a transaction
//as the old bezier will be deleted
if (newItem==NULL)
{
if (newType==PageItem::PathText && UndoManager::undoEnabled())
undoManager->cancelTransaction();
return false;
}
//Do new item type specific adjustments to the new item. Some of this may move when new
//constructors are built into the item classes
switch (newType)
{
case PageItem::ImageFrame:
2734,6 → 2748,13
newItem->Frame = false;
newItem->ClipEdited = true;
newItem->FrameType = 3;
if(oldItem->itemType()==PageItem::PolyLine)
{
newItem->PoLine.addPoint(newItem->PoLine.point(newItem->PoLine.size()-2));
newItem->PoLine.addPoint(newItem->PoLine.point(newItem->PoLine.size()-3));
newItem->PoLine.addPoint(newItem->PoLine.point(0));
newItem->PoLine.addPoint(newItem->PoLine.point(0));
}
newItem->Clip = FlattenPath(newItem->PoLine, newItem->Segments);
newItem->ContourLine = newItem->PoLine.copy();
break;
2744,16 → 2765,33
ScApp->view->AdjustItemSize(newItem);
break;
case PageItem::PathText:
newItem->Frame = false;
newItem->ClipEdited = true;
newItem->convertTo(PageItem::PathText);
{
newItem->convertTo(PageItem::PathText);
newItem->Frame = false;
newItem->ClipEdited = true;
newItem->PoLine = secondaryItem->PoLine.copy();
newItem->Pwidth = secondaryItem->Pwidth;
newItem->setLineColor(secondaryItem->lineColor());
newItem->PLineArt = secondaryItem->PLineArt;
newItem->PLineEnd = secondaryItem->PLineEnd;
newItem->PLineJoin = secondaryItem->PLineJoin;
/* if (!Doc->loading)
emit UpdtObj(Doc->currentPage->pageNr(), b->ItemNr); */
//FIXME: Stop using the view here
ScApp->view->UpdatePolyClip(newItem);
ScApp->view->AdjustItemSize(newItem);
double dx = secondaryItem->Xpos - newItem->Xpos;
double dy = secondaryItem->Ypos - newItem->Ypos;
ScApp->view->MoveItem(dx, dy, newItem);
newItem->Rot = secondaryItem->Rot;
newItem->FrameType = 3;
}
break;
default:
newItem=NULL;
break;
}
//Insert the new item into the docs items list
Items.append(newItem);
newItem->ItemNr = Items.count()-1;
//<<At some point we HAVE to stop this!
2762,6 → 2800,7
else
DocItems = Items;
//>>
//Create the undo action for the new item
if (UndoManager::undoEnabled())
{
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >("Convert Item");
2773,7 → 2812,18
target = Pages.at(newItem->OwnPage);
undoManager->action(target, is);
}
 
//If converting text to path, delete the bezier and close the undo transaction
if (newType==PageItem::PathText)
{
//FIXME: Stop using the view here
ScApp->view->SelectItem(secondaryItem);
ScApp->view->DeleteItem();
ScApp->view->updateContents();
ScApp->view->Deselect(true);
if (UndoManager::undoEnabled())
undoManager->commit();
}
return newItem;
}
 
/branches/Version13x/Scribus/scribus/scribusdoc.h
375,7 → 375,7
/**
* @brief Item type conversion functions
*/
PageItem* convertItemTo(PageItem *, PageItem::ItemType);
PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
/**
* @brief The page number of the current page
/branches/Version13x/Scribus/scribus/scribusview.cpp
7252,9 → 7252,8
SelectItem(Doc->Items.at(nr), draw, single);
}
 
void ScribusView::SelectItem(PageItem *pi, bool draw, bool single)
void ScribusView::SelectItem(PageItem *currItem, bool draw, bool single)
{
PageItem *currItem = pi;
if (!currItem->Select)
{
if (single)
8254,85 → 8253,6
}
}
 
void ScribusView::ToPicFrame()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::ImageFrame);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToPolyFrame()
{
PageItem *currItem = new PageItem_Polygon(*SelItem.at(0));
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::Polygon);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToTextFrame()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::TextFrame);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToBezierFrame()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::PolyLine);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::Bezier2Poly()
{
PageItem *currItem = SelItem.at(0);
currItem->convertTo(PageItem::Polygon);
currItem->Frame = false;
currItem->ClipEdited = true;
currItem->FrameType = 3;
currItem->PoLine.addPoint(currItem->PoLine.point(currItem->PoLine.size()-2));
currItem->PoLine.addPoint(currItem->PoLine.point(currItem->PoLine.size()-3));
currItem->PoLine.addPoint(currItem->PoLine.point(0));
currItem->PoLine.addPoint(currItem->PoLine.point(0));
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
currItem->ContourLine = currItem->PoLine.copy();
RefreshItem(currItem);
emit HaveSel(currItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), currItem->ItemNr);
EmitValues(currItem);
emit DocChanged();
}
 
void ScribusView::ClearItem()
{
if (SelItem.count() != 0)
11394,42 → 11314,120
}
}
 
void ScribusView::ToPicFrame()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::ImageFrame);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToPolyFrame()
{
PageItem *currItem = new PageItem_Polygon(*SelItem.at(0));
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::Polygon);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToTextFrame()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::TextFrame);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToBezierFrame()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::PolyLine);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::Bezier2Poly()
{
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::Polygon);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
/*
currItem->convertTo(PageItem::Polygon);
currItem->Frame = false;
currItem->ClipEdited = true;
currItem->FrameType = 3;
currItem->PoLine.addPoint(currItem->PoLine.point(currItem->PoLine.size()-2));
currItem->PoLine.addPoint(currItem->PoLine.point(currItem->PoLine.size()-3));
currItem->PoLine.addPoint(currItem->PoLine.point(0));
currItem->PoLine.addPoint(currItem->PoLine.point(0));
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
currItem->ContourLine = currItem->PoLine.copy();
RefreshItem(currItem);
emit HaveSel(currItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), currItem->ItemNr);
EmitValues(currItem);
emit DocChanged();
*/
}
 
void ScribusView::ToPathText()
{
if (SelItem.count() > 1)
{
PageItem* oldItem=SelItem.at(0);
PageItem *bb;
if (oldItem->asTextFrame())
bb = SelItem.at(1);
PageItem* currItem=SelItem.at(0);
PageItem *polyLineItem;
if (currItem->asTextFrame())
polyLineItem = SelItem.at(1);
else
{
bb = SelItem.at(0);
oldItem = SelItem.at(1);
polyLineItem = SelItem.at(0);
currItem = SelItem.at(1);
}
if (!bb->asPolyLine())
if (!polyLineItem->asPolyLine())
return;
PageItem* currItem = new PageItem_PathText(*oldItem);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::PathText);
newItem->PoLine = bb->PoLine.copy();
newItem->Pwidth = bb->Pwidth;
newItem->setLineColor(bb->lineColor());
newItem->PLineArt = bb->PLineArt;
newItem->PLineEnd = bb->PLineEnd;
newItem->PLineJoin = bb->PLineJoin;
/* if (!Doc->loading)
emit UpdtObj(Doc->currentPage->pageNr(), b->ItemNr); */
UpdatePolyClip(newItem);
AdjustItemSize(newItem);
double dx = bb->Xpos - newItem->Xpos;
double dy = bb->Ypos - newItem->Ypos;
MoveItem(dx, dy, newItem);
newItem->Rot = bb->Rot;
newItem->FrameType = 3;
Deselect(true);
SelectItemNr(bb->ItemNr);
DeleteItem();
updateContents();
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::PathText, polyLineItem);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
}
 
/branches/Version13x/Scribus/scribus/undomanager.cpp
758,6 → 758,7
UndoManager::Polygon = tr("Polygon");
UndoManager::BezierCurve = tr("Bezier curve");
UndoManager::Polyline = tr("Polyline");
UndoManager::PathText = tr("Text on a Path");
UndoManager::ConvertTo = tr("Convert to");
UndoManager::ImportSVG = tr("Import SVG image");
UndoManager::ImportEPS = tr("Import EPS image");
982,7 → 983,7
QString UndoManager::SetFont = "";
QString UndoManager::SetFontSize = "";
QString UndoManager::SetFontWidth = "";
QString UndoManager::SetFontHeight = "";
QString UndoManager::SetFontHeight = "";
QString UndoManager::SetFontFill = "";
QString UndoManager::SetFontStroke = "";
QString UndoManager::SetFontFillShade = "";
998,6 → 999,7
QString UndoManager::Polygon = "";
QString UndoManager::BezierCurve = "";
QString UndoManager::Polyline = "";
QString UndoManager::PathText = "";
QString UndoManager::ConvertTo = "";
QString UndoManager::ImportSVG = "";
QString UndoManager::ImportEPS = "";