r17355 by fschmid - Tables: second part of making table cell text really editable, allow copy & paste of text
scribus-commit
scribus-commit at lists.scribus.net
Sun Mar 4 18:58:35 UTC 2012
Author: fschmid
Date: Sun Mar 4 18:58:35 2012
New Revision: 17355
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17355
Log:
Tables: second part of making table cell text really editable, allow copy & paste of text
Modified:
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17355&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Mar 4 18:58:35 2012
@@ -4896,28 +4896,36 @@
}
}
currItem = doc->m_Selection->itemAt(0);
- if (doc->appMode == modeEdit)
- {
- if ((currItem->itemText.length() == 0) || (!currItem->HasSel))
- return;
- StoryText itemText(doc);
- itemText.setDefaultStyle(currItem->itemText.defaultStyle());
- itemText.insert(0, currItem->itemText, true);
-
- std::ostringstream xmlString;
- SaxXML xmlStream(xmlString);
- xmlStream.beginDoc();
- itemText.saxx(xmlStream, "SCRIBUSTEXT");
- xmlStream.endDoc();
- std::string xml(xmlString.str());
-
- ScTextMimeData* mimeData = new ScTextMimeData();
- mimeData->setScribusText (QByteArray(xml.c_str(), xml.length()));
- mimeData->setText( itemText.text(0, itemText.length()) ) ;
- QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
-
- dynamic_cast<PageItem_TextFrame*>(currItem)->deleteSelectedTextFromFrame();
- currItem->update();
+ if (((doc->appMode == modeEdit) || (doc->appMode == modeEditTable)) && (currItem->isTextFrame() || currItem->isTable()))
+ {
+ PageItem_TextFrame *cItem;
+ if (doc->appMode == modeEditTable)
+ cItem = currItem->asTable()->activeCell().textFrame();
+ else
+ cItem = currItem->asTextFrame();
+ if (cItem->HasSel)
+ {
+ if ((cItem->itemText.length() == 0) || (!cItem->HasSel))
+ return;
+ StoryText itemText(doc);
+ itemText.setDefaultStyle(cItem->itemText.defaultStyle());
+ itemText.insert(0, cItem->itemText, true);
+ std::ostringstream xmlString;
+ SaxXML xmlStream(xmlString);
+ xmlStream.beginDoc();
+ itemText.saxx(xmlStream, "SCRIBUSTEXT");
+ xmlStream.endDoc();
+ std::string xml(xmlString.str());
+ ScTextMimeData* mimeData = new ScTextMimeData();
+ mimeData->setScribusText (QByteArray(xml.c_str(), xml.length()));
+ mimeData->setText( itemText.text(0, itemText.length()) ) ;
+ QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
+ cItem->deleteSelectedTextFromFrame();
+ if (doc->appMode == modeEditTable)
+ currItem->asTable()->update();
+ else
+ cItem->update();
+ }
}
else
{
@@ -4963,25 +4971,30 @@
if ((HaveDoc) && (doc->m_Selection->count() != 0))
{
PageItem *currItem = doc->m_Selection->itemAt(0);
- if ((doc->appMode == modeEdit) && (currItem->HasSel))
- {
- StoryText itemText(doc);
- itemText.setDefaultStyle(currItem->itemText.defaultStyle());
- itemText.insert(0, currItem->itemText, true);
-
- BufferI = itemText.text(0, itemText.length());
-
- std::ostringstream xmlString;
- SaxXML xmlStream(xmlString);
- xmlStream.beginDoc();
- itemText.saxx(xmlStream, "SCRIBUSTEXT");
- xmlStream.endDoc();
- std::string xml(xmlString.str());
-
- ScTextMimeData* mimeData = new ScTextMimeData();
- mimeData->setScribusText( QByteArray(xml.c_str(), xml.length()) );
- mimeData->setText( itemText.text(0, itemText.length()) );
- QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
+ if (((doc->appMode == modeEdit) || (doc->appMode == modeEditTable)) && (currItem->isTextFrame() || currItem->isTable()))
+ {
+ PageItem_TextFrame *cItem;
+ if (doc->appMode == modeEditTable)
+ cItem = currItem->asTable()->activeCell().textFrame();
+ else
+ cItem = currItem->asTextFrame();
+ if (cItem->HasSel)
+ {
+ StoryText itemText(doc);
+ itemText.setDefaultStyle(cItem->itemText.defaultStyle());
+ itemText.insert(0, cItem->itemText, true);
+ BufferI = itemText.text(0, itemText.length());
+ std::ostringstream xmlString;
+ SaxXML xmlStream(xmlString);
+ xmlStream.beginDoc();
+ itemText.saxx(xmlStream, "SCRIBUSTEXT");
+ xmlStream.endDoc();
+ std::string xml(xmlString.str());
+ ScTextMimeData* mimeData = new ScTextMimeData();
+ mimeData->setScribusText( QByteArray(xml.c_str(), xml.length()) );
+ mimeData->setText( itemText.text(0, itemText.length()) );
+ QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
+ }
}
else
{
@@ -5024,10 +5037,13 @@
if (UndoManager::undoEnabled())
activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste));
PageItem* selItem = doc->m_Selection->itemAt(0);
- bool isTextFrame = (dynamic_cast<PageItem_TextFrame*>(selItem) != NULL);
- if (doc->appMode == modeEdit && isTextFrame)
- {
- PageItem_TextFrame *currItem = dynamic_cast<PageItem_TextFrame*>(doc->m_Selection->itemAt(0));
+ if (((doc->appMode == modeEdit) || (doc->appMode == modeEditTable)) && (selItem->isTextFrame() || selItem->isTable()))
+ {
+ PageItem_TextFrame *currItem;
+ if (doc->appMode == modeEditTable)
+ currItem = selItem->asTable()->activeCell().textFrame();
+ else
+ currItem = selItem->asTextFrame();
assert(currItem != NULL);
if (currItem->HasSel)
currItem->deleteSelectedTextFromFrame();
@@ -5088,7 +5104,6 @@
{
doc->m_Selection->addItem(doc->Items->at(as));
}
- doc->m_Selection->delaySignalsOff();
if (isGroup)
doc->GroupCounter++;
doc->m_Selection->setGroupRect();
@@ -5122,6 +5137,7 @@
outlinePalette->BuildTree();
currItem->itemText.insertObject(currItem3);
undoManager->setUndoEnabled(true);
+ doc->m_Selection->delaySignalsOff();
}
else
{
@@ -5131,7 +5147,11 @@
text = text.replace('\n', SpecialChars::PARSEP);
currItem->itemText.insertChars(text, true);
}
- currItem->update();
+ if (doc->appMode == modeEditTable)
+ selItem->asTable()->update();
+ else
+ currItem->update();
+ view->DrawNew();
}
else
{
Modified: trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17355&path=/trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp Sun Mar 4 18:58:35 2012
@@ -91,31 +91,33 @@
if (item && m_doc.isNull())
setDoc(item->doc());
-
- m_item = item;
-
- disconnectSignals();
- enableFromSelection();
-
- if (m_item)
- {
- PageItem_TextFrame *i2;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- else
- i2 = m_item->asTextFrame();
- if (i2 != 0)
- revertButton->setChecked(i2->reversed());
- if (m_item->asTextFrame() || m_item->asPathText() || m_item->asTable())
- {
- ParagraphStyle parStyle = m_item->itemText.defaultStyle();
- if (m_doc->appMode == modeEdit)
- m_item->currentTextProps(parStyle);
- else if (m_doc->appMode == modeEditTable)
- m_item->asTable()->activeCell().textFrame()->currentTextProps(parStyle);
- updateStyle(parStyle);
- }
- connectSignals();
+ if (item == NULL)
+ return;
+ if (item->isTable() || item->isTextFrame())
+ {
+ m_item = item;
+ disconnectSignals();
+ enableFromSelection();
+ if (m_item)
+ {
+ PageItem_TextFrame *i2;
+ if (m_doc->appMode == modeEditTable)
+ i2 = m_item->asTable()->activeCell().textFrame();
+ else
+ i2 = m_item->asTextFrame();
+ if (i2 != 0)
+ revertButton->setChecked(i2->reversed());
+ if (m_item->asTextFrame() || m_item->asPathText() || m_item->asTable())
+ {
+ ParagraphStyle parStyle = m_item->itemText.defaultStyle();
+ if (m_doc->appMode == modeEdit)
+ m_item->currentTextProps(parStyle);
+ else if (m_doc->appMode == modeEditTable)
+ m_item->asTable()->activeCell().textFrame()->currentTextProps(parStyle);
+ updateStyle(parStyle);
+ }
+ connectSignals();
+ }
}
}
More information about the scribus-commit
mailing list