Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 19355 → Rev 19356

/trunk/Scribus/scribus/scribusdoc.cpp
1841,10 → 1841,12
changeLayerName(ss->getInt("ACTIVE"), name);
layersUndo=true;
}
else if (ss->contains("MASTERPAGE_ADD"))
restoreAddMasterPage(ss, isUndo);
else if (ss->contains("MASTERPAGE_RENAME"))
restoreMasterPageRenaming(ss, isUndo);
else if (ss->contains("OLD_MASTERPAGE"))
restoreMasterPageApplying(ss, isUndo);
else if (ss->contains("MASTERPAGE_ADD"))
restoreAddMasterPage(ss, isUndo);
else if (ss->contains("PAGE_COPY"))
restoreCopyPage(ss, isUndo);
else if (ss->contains("PAGE_MOVE"))
2326,7 → 2328,9
QString pageName = ss->get("MASTERPAGE_NAME");
int pageNr = ss->getInt("MASTERPAGE_NBR");
 
bool oldMPMode = masterPageMode();
bool oldMPMode = masterPageMode();
ScPage* oldPage = currentPage();
 
setMasterPageMode(true);
if (isUndo)
{
2347,6 → 2351,8
delete tmp;
}
setMasterPageMode(oldMPMode);
if (!oldMPMode)
setCurrentPage(oldPage);
scMW()->pagePalette->updateMasterPageList();
m_View->reformPages();
}
2666,33 → 2672,40
bool ScribusDoc::renameMasterPage(const QString& oldPageName, const QString& newPageName)
{
Q_ASSERT(oldPageName!=CommonStrings::masterPageNormal && oldPageName!=CommonStrings::trMasterPageNormal);
if (MasterNames.contains(oldPageName) && !MasterNames.contains(newPageName))
if (!MasterNames.contains(oldPageName) || MasterNames.contains(newPageName))
return false;
 
//Rename our master page lists
int number = MasterNames[oldPageName];
MasterNames.insert(newPageName, number);
MasterNames.remove(oldPageName);
Q_ASSERT(MasterPages.at(number)->pageName()==oldPageName);
MasterPages.at(number)->setPageName(newPageName);
//Update any pages that were linking to our old name
ScPage* docPage=NULL;
for (int i=0; i < DocPages.count(); ++i )
{
//Rename our master page lists
int number=MasterNames[oldPageName];
MasterNames.insert(newPageName, number);
MasterNames.remove(oldPageName);
Q_ASSERT(MasterPages.at(number)->pageName()==oldPageName);
MasterPages.at(number)->setPageName(newPageName);
//Update any pages that were linking to our old name
ScPage* docPage=NULL;
for (int i=0; i < DocPages.count(); ++i )
{
docPage=DocPages[i];
if (docPage->MPageNam == oldPageName)
docPage->MPageNam = newPageName;
}
//Update any items that were linking to our old name
uint masterItemsCount=MasterItems.count();
for (uint i = 0; i < masterItemsCount; ++i)
{
if (MasterItems.at(i)->OnMasterPage == oldPageName)
MasterItems.at(i)->OnMasterPage = newPageName;
}
changed();
return true;
docPage=DocPages[i];
if (docPage->MPageNam == oldPageName)
docPage->MPageNam = newPageName;
}
return false;
//Update any items that were linking to our old name
uint masterItemsCount=MasterItems.count();
for (uint i = 0; i < masterItemsCount; ++i)
{
if (MasterItems.at(i)->OnMasterPage == oldPageName)
MasterItems.at(i)->OnMasterPage = newPageName;
}
changed();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::RenameMasterPage, "", Um::IDocument);
ss->set("MASTERPAGE_RENAME", "masterpage_rename");
ss->set("OLD_MASTERPAGE", oldPageName);
ss->set("NEW_MASTERPAGE", newPageName);
undoManager->action(this, ss);
}
return true;
}
 
 
4876,6 → 4889,16
scMW()->pagePalette->rebuildPages();
}
 
void ScribusDoc::restoreMasterPageRenaming(SimpleState *state, bool isUndo)
{
QString oldName = state->get("OLD_MASTERPAGE");
QString newName = state->get("NEW_MASTERPAGE");
if (isUndo)
renameMasterPage(newName, oldName);
else
renameMasterPage(oldName, newName);
scMW()->pagePalette->updateMasterPageList();
}
 
void ScribusDoc::restoreCopyPage(SimpleState *state, bool isUndo)
{
/trunk/Scribus/scribus/scribusdoc.h
739,6 → 739,7
* @brief Undo function for applying a master page
*/
void restoreMasterPageApplying(SimpleState *state, bool isUndo);
void restoreMasterPageRenaming(SimpleState *state, bool isUndo);
void restoreCopyPage(SimpleState *state, bool isUndo);
void restoreMovePage(SimpleState *state, bool isUndo);
void restoreAddMasterPage(SimpleState *state, bool isUndo);
/trunk/Scribus/scribus/undomanager.cpp
870,6 → 870,8
UndoManager::DelMasterPage = tr("Del master page");
UndoManager::ImportMasterPage = tr("Import master page");
UndoManager::DuplicateMasterPage= tr("Duplicate master page");
UndoManager::ApplyMasterPage = tr("Apply Master Page");
UndoManager::RenameMasterPage = tr("Rename Master Page");
UndoManager::UniteItem = tr("Combine Polygons");
UndoManager::SplitItem = tr("Split Polygons");
UndoManager::Resize = tr("Resize");
912,7 → 914,6
UndoManager::Delete = tr("Delete");
UndoManager::Rename = tr("Rename");
UndoManager::FromTo = tr("From %1\nto %2");
UndoManager::ApplyMasterPage = tr("Apply Master Page");
UndoManager::Paste = tr("Paste");
UndoManager::Cut = tr("Cut");
UndoManager::RoundCorner = tr("Change round corner");
1162,6 → 1163,8
QString UndoManager::ImportMasterPage = "";
QString UndoManager::DuplicateMasterPage= "";
QString UndoManager::DelMasterPage = "";
QString UndoManager::ApplyMasterPage = "";
QString UndoManager::RenameMasterPage = "";
QString UndoManager::Resize = "";
QString UndoManager::Rotate = "";
QString UndoManager::MoveFromTo = "";
1208,7 → 1211,6
QString UndoManager::Delete = "";
QString UndoManager::Rename = "";
QString UndoManager::FromTo = "";
QString UndoManager::ApplyMasterPage = "";
QString UndoManager::Paste = "";
QString UndoManager::Cut = "";
QString UndoManager::Transparency = "";
/trunk/Scribus/scribus/undomanager.h
467,6 → 467,8
static QString DelMasterPage;
static QString ImportMasterPage;
static QString DuplicateMasterPage;
static QString ApplyMasterPage;
static QString RenameMasterPage;
static QString Resize;
static QString Rotate;
static QString MoveFromTo;
503,7 → 505,6
static QString Rename;
static QString FromTo;
static QString Mode;
static QString ApplyMasterPage;
static QString Paste;
static QString Cut;
static QString Transparency;