示例#1
0
void RightPaneWidget::onDeleteText()
{
    TRACE1(m_twTexts->count());
    if (!m_twTexts->count())
        return;
    int textIndex = m_twTexts->currentIndex();
    emit deleteText(textIndex);
}
示例#2
0
QMenu* ConsoleWidget::createEditMenu()
{
  QMenu* menu = new QMenu(tr("&Edit"));

  QAction* action = menu->addAction(QIcon(":/Icons/arrow_undo.png"), tr("&Undo"));
  action->setShortcut(QKeySequence(QKeySequence::Undo));
  action->setStatusTip(tr("Undo the last action"));
  action->setEnabled(canUndo);
  connect(action, SIGNAL(triggered()), this, SLOT(undo()));
  connect(this, SIGNAL(undoAvailable(bool)), action, SLOT(setEnabled(bool)));

  action = menu->addAction(QIcon(":/Icons/arrow_redo.png"), tr("&Redo"));
  action->setShortcut(QKeySequence(QKeySequence::Redo));
  action->setStatusTip(tr("Redo the previously undone action"));
  action->setEnabled(canRedo);
  connect(action, SIGNAL(triggered()), this, SLOT(redo()));
  connect(this, SIGNAL(redoAvailable(bool)), action, SLOT(setEnabled(bool)));

  menu->addSeparator();

  action = menu->addAction(QIcon(":/Icons/cut.png"), tr("Cu&t"));
  action->setShortcut(QKeySequence(QKeySequence::Cut));
  action->setStatusTip(tr("Cut the current selection's contents to the clipboard"));
  action->setEnabled(canCopy);
  connect(action, SIGNAL(triggered()), this, SLOT(cut()));
  connect(this, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));

  action = menu->addAction(QIcon(":/Icons/page_copy.png"), tr("&Copy"));
  action->setShortcut(QKeySequence(QKeySequence::Copy));
  action->setStatusTip(tr("Copy the current selection's contents to the clipboard"));
  action->setEnabled(canCopy);
  connect(action, SIGNAL(triggered()), this, SLOT(copy()));
  connect(this, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));

  action = menu->addAction(QIcon(":/Icons/page_paste.png"), tr("&Paste"));
  action->setShortcut(QKeySequence(QKeySequence::Paste));
  action->setStatusTip(tr("Paste the clipboard's contents into the current selection"));
  action->setEnabled(canPaste());
  connect(action, SIGNAL(triggered()), this, SLOT(paste()));
  connect(this, SIGNAL(pasteAvailable(bool)), action, SLOT(setEnabled(bool)));

  action = menu->addAction(tr("&Delete"));
  action->setShortcut(QKeySequence(QKeySequence::Delete));
  action->setStatusTip(tr("Delete the currently selected content"));
  action->setEnabled(canCopy);
  connect(action, SIGNAL(triggered()), this, SLOT(deleteText()));
  connect(this, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));

  menu->addSeparator();

  action = menu->addAction(tr("Select &All"));
  action->setShortcut(QKeySequence(QKeySequence::SelectAll));
  action->setStatusTip(tr("Select the whole text"));
  connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));

  return menu;
}
示例#3
0
void QAccessibleSimpleEditableTextInterface::cutText(int startOffset, int endOffset)
{
#ifdef QT_NO_CLIPBOARD
    Q_UNUSED(startOffset);
    Q_UNUSED(endOffset);
#else
    QString sub = textForRange(iface, startOffset, endOffset);
    deleteText(startOffset, endOffset);
    QApplication::clipboard()->setText(sub);
#endif
}
示例#4
0
void SidePanel::draw(sf::RenderWindow* window,sf::Font* font) {
	sf::RectangleShape bg(sf::Vector2f(290,600));
	bg.setFillColor(sf::Color(200,200,115));
	bg.setPosition(710,0);
	window->draw(bg);

	std::string dateString = Calendar::months[dateShown->tm_mon];
	dateString += " ";
	dateString += std::to_string(dateShown->tm_mday);
	dateString += ", ";
	dateString += std::to_string(dateShown->tm_year + 1900);
	sf::Text dateText(dateString,*font,20);
	dateText.setPosition(716,-2);
	dateText.setColor(sf::Color(0,0,0));
	window->draw(dateText);

	DisplayShift::draw(window,font);

	sf::RectangleShape bottomline(sf::Vector2f(290,5));
	bottomline.setFillColor(sf::Color(100,100,55));
	bottomline.setPosition(710,560);
	window->draw(bottomline);
	sf::RectangleShape newButton(sf::Vector2f(82,20));
	newButton.setPosition(720,570);
	newButton.setFillColor(sf::Color(255,255,80));
	window->draw(newButton);
	sf::RectangleShape editButton(newButton);
	editButton.move(94,0);
	window->draw(editButton);
	sf::RectangleShape deleteButton(editButton);
	deleteButton.move(94,0);
	window->draw(deleteButton);

	sf::Text newText("New", *font, 20);
	newText.setPosition(726,568);
	newText.setColor(sf::Color());
	window->draw(newText);
	sf::Text editText(newText);
	editText.setString("Edit");
	editText.move(94,0);
	window->draw(editText);
	sf::Text deleteText(editText);
	deleteText.setString("Delete");
	deleteText.move(94,0);
	window->draw(deleteText);
}
示例#5
0
bool FontManager::makeText(const std::string& textID, const std::string& textString,
						   int size, const vec2f& position,
						   const sf::Color& color, const sf::Text::Style& style,
						   const bool& center_origin) {
	if (texts.count(textID) != 0)
		deleteText(textID);
	sf::Text text;
	text.setFont(globalFont);
	text.setString(textString);
	text.setCharacterSize(size);
	text.setColor(color);
	text.setStyle(style);
	if (center_origin)
		text.setOrigin(text.getLocalBounds().width/2,
					   text.getLocalBounds().height/2);
	text.setOrigin(text.getOrigin().x + text.getLocalBounds().left, //deviation restored
				   text.getOrigin().y + text.getLocalBounds().top); //deviation restored
	text.setPosition(sf::Vector2f(position.x,position.y));
	texts[textID] = text;
	return true;
}
示例#6
0
void Transcribe::guiReady(QObject* root) {
  m_main_window = qobject_cast<QWindow*>(root);
  m_text_area = m_main_window->findChild<QObject*>("text_area");

  // Set the icon, which, strangely enough, cannot be done from QML
  m_main_window->setIcon(QIcon("://window_icon"));

#ifndef Q_OS_ANDROID
  // Restore window state
  QSettings settings;
  settings.beginGroup(CFG_GROUP_SCREEN);
  if (settings.value(CFG_SCREEN_IS_MAXIMIZED, false).toBool()) {
    m_main_window->setVisibility(QWindow::Maximized);
  } else {
    m_main_window->resize(settings.value(CFG_SCREEN_SIZE,
                                         QSize(640, 480)).toSize());
    m_main_window->setPosition(settings.value(CFG_SCREEN_POS,
                                              QPoint(200, 200)).toPoint());
    settings.endGroup();\
  }
#endif

  // Install the key filter and connect its signals
  KeyCatcher* catcher = new KeyCatcher(root);
  connect(catcher,        SIGNAL(keyTyped()),
          &m_keeper,      SLOT(keyTyped()));
  connect(catcher,        SIGNAL(saveFile()),
          this,           SLOT(saveText()));
  connect(catcher,        SIGNAL(seekAudio(int)),
          m_player.get(), SLOT(skipSeconds(int)));
  connect(catcher,        SIGNAL(togglePlayPause()),
          m_player.get(), SLOT(togglePlayPause()));
  connect(catcher,        SIGNAL(togglePlayPause(bool)),
          m_player.get(), SLOT(togglePlayPause(bool)));
  connect(catcher,        SIGNAL(boost(bool)),
          m_player.get(), SLOT(boost(bool)));
  root->installEventFilter(catcher);
#ifdef Q_OS_ANDROID
  // On Android, we might connect the signals when using the virtual keyboard
  // in addition to the signals from the physical keyboard.
  connect(qApp->inputMethod(), SIGNAL(visibleChanged()),
          this,                SLOT(connectVirtualKeyboard()));
  connectVirtualKeyboard();
#endif

  // Connect GUI events to their callbacks
  connect(m_main_window,  SIGNAL(audioPositionChanged(int)),
          m_player.get(), SLOT(setPosition(int)));
  connect(m_main_window,  SIGNAL(playingStateChanged(bool)),
          m_player.get(), SLOT(togglePlayPause(bool)));
  connect(m_main_window,  SIGNAL(seekAudio(int)),
          m_player.get(), SLOT(skipSeconds(int)));
  connect(m_main_window,  SIGNAL(boostAudio(bool)),
          m_player.get(), SLOT(boost(bool)));
  connect(m_main_window, SIGNAL(saveText()),
          this,          SLOT(saveText()));
#ifdef Q_OS_ANDROID
  connect(m_main_window, SIGNAL(shareText()),
          this,          SLOT(shareText()));
  connect(m_main_window, SIGNAL(deleteText()),
          this,          SLOT(deleteText()));
#endif
  connect(m_main_window, SIGNAL(pickFiles()),
          this,          SLOT(pickFiles()));
  connect(m_main_window, SIGNAL(historySelected(int)),
          this,          SLOT(restoreHistory(int)));
  connect(m_main_window, SIGNAL(signalQuit()),
          this,          SLOT(close()));
  connect(m_main_window, SIGNAL(numWordsDirty()),
          this,          SLOT(countWords()));
}
SimpleRichTextEdit::SimpleRichTextEdit(QWidget *parent)
	: KTextEdit(parent)
{
	enableFindReplace(false);
	setCheckSpellingEnabled(true);

	setAutoFormatting(KTextEdit::AutoNone);
	setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

	QTextDocument *textDocument = document();

	QTextOption textOption;
	textOption.setAlignment(Qt::AlignCenter);
	textOption.setWrapMode(QTextOption::NoWrap);
	textDocument->setDefaultTextOption(textOption);

	QFont defaultFont = font();
	defaultFont.setPointSize(defaultFont.pointSize() + 2);
	textDocument->setDefaultFont(defaultFont);

	QString styleSheet("p {" "   display: block;" "   white-space: pre;" "   margin-top: 0px;" "   margin-bottom: 0px;" "}");
	textDocument->setDefaultStyleSheet(styleSheet);

	setTextInteractionFlags(Qt::TextEditorInteraction);

	m_actions[Undo] = new QAction(this);
	m_actions[Undo]->setIcon(QIcon::fromTheme("edit-undo"));
	m_actions[Undo]->setText(i18n("Undo"));
	m_actions[Undo]->setShortcuts(KStandardShortcut::undo());
	connect(m_actions[Undo], SIGNAL(triggered()), this, SLOT(undo()));

	m_actions[Redo] = new QAction(this);
	m_actions[Redo]->setIcon(QIcon::fromTheme("edit-redo"));
	m_actions[Redo]->setText(i18n("Redo"));
	m_actions[Redo]->setShortcuts(KStandardShortcut::redo());
	connect(m_actions[Redo], SIGNAL(triggered()), this, SLOT(redo()));

	m_actions[Cut] = new QAction(this);
	m_actions[Cut]->setIcon(QIcon::fromTheme("edit-cut"));
	m_actions[Cut]->setText(i18n("Cut"));
	m_actions[Cut]->setShortcuts(KStandardShortcut::cut());
	connect(m_actions[Cut], SIGNAL(triggered()), this, SLOT(cut()));

	m_actions[Copy] = new QAction(this);
	m_actions[Copy]->setIcon(QIcon::fromTheme("edit-copy"));
	m_actions[Copy]->setText(i18n("Copy"));
	m_actions[Copy]->setShortcuts(KStandardShortcut::copy());
	connect(m_actions[Copy], SIGNAL(triggered()), this, SLOT(copy()));

#if !defined(QT_NO_CLIPBOARD)
	m_actions[Paste] = new QAction(this);
	m_actions[Paste]->setIcon(QIcon::fromTheme("edit-paste"));
	m_actions[Paste]->setText(i18n("Paste"));
	m_actions[Paste]->setShortcuts(KStandardShortcut::paste());
	connect(m_actions[Paste], SIGNAL(triggered()), this, SLOT(paste()));
#endif

	m_actions[Delete] = new QAction(this);
	m_actions[Delete]->setIcon(QIcon::fromTheme("edit-delete"));
	m_actions[Delete]->setText(i18n("Delete"));
	m_actions[Delete]->setShortcut(QKeySequence::Delete);
	connect(m_actions[Delete], SIGNAL(triggered()), this, SLOT(deleteText()));

	m_actions[Clear] = new QAction(this);
	m_actions[Clear]->setIcon(QIcon::fromTheme("edit-clear"));
	m_actions[Clear]->setText(i18nc("@action:inmenu Clear all text", "Clear"));
	connect(m_actions[Clear], SIGNAL(triggered()), this, SLOT(undoableClear()));

	m_actions[SelectAll] = new QAction(this);
	m_actions[SelectAll]->setIcon(QIcon::fromTheme("edit-select-all"));
	m_actions[SelectAll]->setText(i18n("Select All"));
	m_actions[SelectAll]->setShortcut(QKeySequence::SelectAll);
	connect(m_actions[SelectAll], SIGNAL(triggered()), this, SLOT(selectAll()));

	m_actions[ToggleBold] = new QAction(this);
	m_actions[ToggleBold]->setIcon(QIcon::fromTheme("format-text-bold"));
	m_actions[ToggleBold]->setText(i18nc("@action:inmenu Toggle bold style", "Bold"));
	m_actions[ToggleBold]->setShortcut(QKeySequence("Ctrl+B"));
	connect(m_actions[ToggleBold], SIGNAL(triggered()), this, SLOT(toggleFontBold()));

	m_actions[ToggleItalic] = new QAction(this);
	m_actions[ToggleItalic]->setIcon(QIcon::fromTheme("format-text-italic"));
	m_actions[ToggleItalic]->setText(i18nc("@action:inmenu Toggle italic style", "Italic"));
	m_actions[ToggleItalic]->setShortcut(QKeySequence("Ctrl+I"));
	connect(m_actions[ToggleItalic], SIGNAL(triggered()), this, SLOT(toggleFontItalic()));

	m_actions[ToggleUnderline] = new QAction(this);
	m_actions[ToggleUnderline]->setIcon(QIcon::fromTheme("format-text-underline"));
	m_actions[ToggleUnderline]->setText(i18nc("@action:inmenu Toggle underline style", "Underline"));
	m_actions[ToggleUnderline]->setShortcut(QKeySequence("Ctrl+U"));
	connect(m_actions[ToggleUnderline], SIGNAL(triggered()), this, SLOT(toggleFontUnderline()));

	m_actions[ToggleStrikeOut] = new QAction(this);
	m_actions[ToggleStrikeOut]->setIcon(QIcon::fromTheme("format-text-strikethrough"));
	m_actions[ToggleStrikeOut]->setText(i18nc("@action:inmenu Toggle strike through style", "Strike Through"));
	m_actions[ToggleStrikeOut]->setShortcut(QKeySequence("Ctrl+T"));
	connect(m_actions[ToggleStrikeOut], SIGNAL(triggered()), this, SLOT(toggleFontStrikeOut()));

	m_actions[ChangeTextColor] = new QAction(this);
	m_actions[ChangeTextColor]->setIcon(QIcon::fromTheme("format-text-color"));
	m_actions[ChangeTextColor]->setText(i18nc("@action:inmenu Change Text Color", "Text Color"));
	m_actions[ChangeTextColor]->setShortcut(QKeySequence("Ctrl+Shift+C"));
	connect(m_actions[ChangeTextColor], SIGNAL(triggered()), this, SLOT(changeTextColor()));

	m_actions[CheckSpelling] = new QAction(this);
	m_actions[CheckSpelling]->setIcon(QIcon::fromTheme("tools-check-spelling"));
	m_actions[CheckSpelling]->setText(i18n("Check Spelling..."));
	connect(m_actions[CheckSpelling], SIGNAL(triggered()), this, SLOT(checkSpelling()));

	m_actions[ToggleAutoSpellChecking] = new QAction(this);
	m_actions[ToggleAutoSpellChecking]->setText(i18n("Auto Spell Check"));
	m_actions[ToggleAutoSpellChecking]->setCheckable(true);
	connect(m_actions[ToggleAutoSpellChecking], SIGNAL(triggered()), this, SLOT(toggleAutoSpellChecking()));

	m_actions[AllowTabulations] = new QAction(this);
	m_actions[AllowTabulations]->setText(i18n("Allow Tabulations"));
	connect(m_actions[AllowTabulations], SIGNAL(triggered()), this, SLOT(toggleTabChangesFocus()));

	QMenu *menu = createStandardContextMenu();
	menu->setParent(this);
	QList<QAction *> actions = menu->actions();
	m_insertUnicodeControlCharMenu = 0;
	for(QList<QAction *>::ConstIterator it = actions.constBegin(), end = actions.constEnd(); it != end; ++it) {
		if((*it)->menu()) {
			// this depends on Qt private implementation but at least is guaranteed
			// to behave reasonably if that implementation changes in the future.
			if(!strcmp((*it)->menu()->metaObject()->className(), "QUnicodeControlCharacterMenu")) {
				m_insertUnicodeControlCharMenu = (*it)->menu();
				break;
			}
		}
	}
}
示例#8
0
文件: tip.cpp 项目: qanny/tools
void tipClass::initconnects() {
    connect(addbtn, SIGNAL(clicked()), this, SLOT(addText()));

    connect(deletebtn, SIGNAL(clicked()), this, SLOT(deleteText()));
}
示例#9
0
QMenu* EditorWidget::createPopupMenu()
{
  QMenu* menu = new QMenu(tr("&Edit"));

  if(!undoAct)
  {
    undoAct = new QAction(QIcon(":/icons/arrow_undo.png"), tr("&Undo"), this);
    undoAct->setShortcut(QKeySequence(QKeySequence::Undo));
    undoAct->setStatusTip(tr("Undo the last action"));
    undoAct->setEnabled(canUndo);
    connect(undoAct, SIGNAL(triggered()), textEdit, SLOT(undo()));
  }
  menu->addAction(undoAct);

  if(!redoAct)
  {
    redoAct = new QAction(QIcon(":/icons/arrow_redo.png"), tr("&Redo"), this);
    redoAct->setShortcut(QKeySequence(QKeySequence::Redo));
    redoAct->setStatusTip(tr("Redo the previously undone action"));
    redoAct->setEnabled(canRedo);
    connect(redoAct, SIGNAL(triggered()), textEdit, SLOT(redo()));
  }
  menu->addAction(redoAct);
  menu->addSeparator();

  if(!cutAct)
  {
    cutAct = new QAction(QIcon(":/icons/cut.png"), tr("Cu&t"), this);
    cutAct->setShortcut(QKeySequence(QKeySequence::Cut));
    cutAct->setStatusTip(tr("Cut the current selection's contents to the clipboard"));
    cutAct->setEnabled(canCopy);
    connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
  }
  menu->addAction(cutAct);

  if(!copyAct)
  {
    copyAct = new QAction(QIcon(":/icons/page_copy.png"), tr("&Copy"), this);
    copyAct->setShortcut(QKeySequence(QKeySequence::Copy));
    copyAct->setStatusTip(tr("Copy the current selection's contents to the clipboard"));
    copyAct->setEnabled(canCopy);
    connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
  }
  menu->addAction(copyAct);

  if(!pasteAct)
  {
    pasteAct = new QAction(QIcon(":/icons/page_paste.png"), tr("&Paste"), this);
    pasteAct->setShortcut(QKeySequence(QKeySequence::Paste));
    pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current selection"));
    connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
  }
  pasteAct->setEnabled(textEdit->canPaste());
  menu->addAction(pasteAct);

  if(!deleteAct)
  {
    deleteAct = new QAction(tr("&Delete"), this);
    deleteAct->setShortcut(QKeySequence(QKeySequence::Delete));
    deleteAct->setStatusTip(tr("Delete the currently selected content"));
    deleteAct->setEnabled(canCopy);
    connect(deleteAct, SIGNAL(triggered()), this, SLOT(deleteText()));
  }
  menu->addAction(deleteAct);
  menu->addSeparator();

  QAction* action = menu->addAction(tr("Select &All"));
  action->setShortcut(QKeySequence(QKeySequence::SelectAll));
  action->setStatusTip(tr("Select the whole document"));
  connect(action, SIGNAL(triggered()), textEdit, SLOT(selectAll()));

  return menu;
}
示例#10
0
/*
Given a specification for a document and a view, this function will run the
single-edit tests for that document/view.

The document is represented by a descriptor array in which each descriptor is a paragraph.

The view is represented simply by the TInt aTopOfBand argument, which tells us how
many paragraphs to lose from the top of the band. So if it is zero, then we just initialise
the doc and don't scroll at all; if it is 1 we scroll down until 1 paragraph is removed from
the top of the band, and so on. Currently it's basically only ever set to 1 or 0, and is thus
used as a boolean "top_of_doc!=top_of_band"

So, given the document/view. the function will retrieve the list of useful positions to test,
and then test:
- increasing font size
- deleting
- inserting text
- inserting various other things
...making use of various helper functions to do so
*/
void RunSingleEditTestsOnDocumentL(CRichText& aRichText, CBandMaintainer& aMaintainer,
	CBandValidator& aValidator, const MDesCArray& aTextContents, TInt aTopOfBand)
	{
	TDocumentSpec docSpec(aTextContents, aTopOfBand);
	docSpec.SetupDocumentL(aRichText, aMaintainer);


	RArray<TInt> positions;
	CleanupClosePushL(positions);

	RArray<TTmLineInfo> lines;
	CleanupClosePushL(lines);

	if(KSelectEditPointsFromWholeBand)
		{
		GetLinesInBandL(aMaintainer.TmLayoutUnderTest(), lines);
		}
	else
		{
		GetVisibleLinesL(aMaintainer.LayoutUnderTest(), lines);
		}

	PositionsToTestL(lines, positions);

	output->WriteDocumentAttributesL(aMaintainer.ViewUnderTest());
	output->WriteDocumentPositionsL(positions);

	test.Start(_L("Reformatting: change font"));
	TReformatText changeFont(aMaintainer, aRichText, aValidator, EChangeFont, testEnv->Device());
	ExecuteTestL(aRichText, aMaintainer, changeFont, docSpec, positions);

	test.Next(_L("Reformatting: decrease font"));
	TReformatText decreaseFont(aMaintainer, aRichText, aValidator, EDecreaseFontSize, testEnv->Device());
	ExecuteTestL(aRichText, aMaintainer, decreaseFont, docSpec, positions);

	test.Next(_L("Reformatting: make bold"));
	TReformatText makeBold(aMaintainer, aRichText, aValidator, EMakeBold, testEnv->Device());
	ExecuteTestL(aRichText, aMaintainer, makeBold, docSpec, positions);

	test.Next(_L("Reformatting: increase font"));
	TReformatText increaseFont(aMaintainer, aRichText, aValidator, EIncreaseFontSize, testEnv->Device());
	ExecuteTestL(aRichText, aMaintainer, increaseFont, docSpec, positions);

	test.Next(_L("Deleting"));
	TDeleteText deleteText(aMaintainer, aRichText, aValidator);
	ExecuteTestL(aRichText, aMaintainer, deleteText, docSpec, positions);

	test.Next(_L("Inserting a space"));
	InsertTextL(aRichText, aMaintainer, aValidator, docSpec, KSpace, positions);

	test.Next(_L("Inserting several spaces"));
	InsertTextL(aRichText, aMaintainer, aValidator, docSpec, KSpaces, positions);

	test.Next(_L("Inserting less than a line of text"));
	InsertTextL(aRichText, aMaintainer, aValidator, docSpec, KEnglishLessThanALine_1, positions);

	test.Next(_L("Inserting multi-line text"));
	InsertTextL(aRichText, aMaintainer, aValidator, docSpec, KEnglishMoreThanALine_1, positions);

	test.Next(_L("Inserting RLO marker"));
	InsertTextL(aRichText, aMaintainer, aValidator, docSpec, KRLO, positions);

	test.Next(_L("Inserting paragraph delimiter"));
	InsertTextL(aRichText, aMaintainer, aValidator, docSpec, KParagraphDelimiter, positions);

	test.End();

	CleanupStack::PopAndDestroy(2);
	}
示例#11
0
/**
@SYMTestCaseID SYSLIB-FORMA-UT-1900
@SYMTestCaseDesc This function will run tests to check if the bidirectional state is being
maintained correctly. Documents containing a mix of different directionality are created and
specific edits which are of interest for each document are performed. These edits are location
specific and will depend on the bidirectional state of surrounding text.
@SYMTestPriority High
@SYMTestActions Edits are performed:
changing the base directionality of a paragraph
changing the directionality of text above the edit position
changing the directionality of neutral characters before and after edit position
changing the directionality of mirrored characters such as parenthesis
changing text directinality by adding explicit embedding
@SYMTestExpectedResults The test must not fail or panic .
@SYMDEF DEF092140, DEF092139
*/
void RunBidirectionalTestL(CRichText& aRichText, CBandMaintainer& aMaintainer, CBandValidator& aValidator)
	{

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//set up paragraph of just LTR text
	aRichText.InsertL(0, KBleak2);
	aMaintainer.InitialiseViewL();
	User::After(3000000);

//change paragraph base directionality by inserting a RLM marker at the beginning of the paragraph
	TInsertText insertRLM(aMaintainer, aRichText, aValidator, KRLM());
	insertRLM.ExecuteL(0, 1);
	User::After(3000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//set up paragraph of LLL-RRR-LLL-NNN-RRR-LLL
	aRichText.InsertL(0, KEnglishLongWords_1);
	aRichText.InsertL(aRichText.DocumentLength(), KArabicLessThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_1);
	aRichText.InsertL(aRichText.DocumentLength(), KPuncs);
	aRichText.InsertL(aRichText.DocumentLength(), KArabicLessThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KBleak2);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();
	User::After(1000000);

//delete the second run of LTR changing the directionality of the neutrals
	TDeleteText deleteText(aMaintainer, aRichText, aValidator);
	TInt editPos = KEnglishLongWords_1().Length()+KArabicLessThanALine().Length();
	deleteText.ExecuteL(editPos,KEnglishLessThanALine_1().Length());
	User::After(1000000);

//delete the second run of RTL characters to check if neutral directionality is maintained
	editPos = KEnglishLongWords_1().Length()+KArabicLessThanALine().Length()+KPuncs().Length();
	deleteText.ExecuteL(editPos,KArabicLessThanALine().Length());
	User::After(1000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//set up band to be a paragraph of numbers followed by LTR i.e. EN-EN-EN-LLL
	aRichText.InsertL(aRichText.DocumentLength(), KNumbers);
	aRichText.InsertL(aRichText.DocumentLength(), KBleak2);
	aMaintainer.InitialiseViewL();
	User::After(3000000);

//edit to change directionality of numbers above the edit by inserting RTL text before the LTR
//This RLM works perfectly
	TInsertText insertArabic(aMaintainer, aRichText, aValidator, KArabicMoreThanALine());
	insertArabic.ExecuteL(KNumbers().Length(), KArabicMoreThanALine().Length());
	User::After(3000000);

//undo previous edit text will return to previous directionality
	deleteText.ExecuteL(KNumbers().Length(),KArabicMoreThanALine().Length());
	User::After(10000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

// Document containing RRRRR ( LLLL ) LLLL
	aRichText.InsertL(0, KArabicMoreThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KOpenBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_1);
	aRichText.InsertL(aRichText.DocumentLength(), KCloseBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_2);
	aRichText.InsertL(aRichText.DocumentLength(), KOpenBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_4);
	aRichText.InsertL(aRichText.DocumentLength(), KCloseBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

// Insert LTR after RTL test Doc should now be RRRR LLLL ( LLLL ) LLLL
	TInsertText insertEnglish(aMaintainer, aRichText, aValidator, KEnglishLessThanALine_3());
	insertEnglish.ExecuteL(KArabicMoreThanALine().Length(), KEnglishLessThanALine_3().Length());
// The brackets are now being displayed correctly
// BUT is the neutral English text meant to be displayed as RTL as initially inserted (no RLM)??
	User::After(10000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

// Just an arabic RTL sentence.
	aRichText.InsertL(0, KArabicMoreThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

// Test formatting when inserting RTL enclosed in parenthesis
	TInsertText insertArabBrackets(aMaintainer, aRichText, aValidator, KArabicInParenthesis());
	insertArabBrackets.ExecuteL(KArabicMoreThanALine().Length(), KArabicInParenthesis().Length());
	User::After(1000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

// Just an arabic RTL sentence.
	aRichText.InsertL(0, KArabicMoreThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

// Test formatting when inserting open parenthesis
	TInsertText insertOpen(aMaintainer, aRichText, aValidator, KOpenBracket());
	insertOpen.ExecuteL(KArabicMoreThanALine().Length(), KOpenBracket().Length());
	User::After(1000000);

// Test formatting when inserting RTL after opening parenthesis
	TInsertText insertArabicLessLine(aMaintainer, aRichText, aValidator, KArabicLessThanALine());
	insertArabicLessLine.ExecuteL(aRichText.DocumentLength()-1, KArabicLessThanALine().Length());
	User::After(1000000);

// Test formatting when inserting closing parenthesis after RTL text
	TInsertText insertClose(aMaintainer, aRichText, aValidator, KCloseBracket());
	insertClose.ExecuteL(aRichText.DocumentLength()-1, KOpenBracket().Length());
// This is now being displayed correctly
	User::After(10000000);

// Insert RTL text after parenthesis
	insertArabicLessLine.ExecuteL(aRichText.DocumentLength()-1, KArabicLessThanALine().Length());
// This is now being displayed correctly
	User::After(10000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//Explicit Embedding testing
	aRichText.InsertL(0, KEnglishShortParagraph);
	aRichText.InsertL(aRichText.DocumentLength(), KRLE);
	aRichText.InsertL(aRichText.DocumentLength(), KFirstWordArabic);
	aRichText.InsertL(aRichText.DocumentLength(), KFirstWord);
	aRichText.InsertL(aRichText.DocumentLength(), KSecondWordArabic);
	aRichText.InsertL(aRichText.DocumentLength(), KSecondWord);
	aRichText.InsertL(aRichText.DocumentLength(), KThirdWordArabic);
	aRichText.InsertL(aRichText.DocumentLength(), KPDF);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishMoreThanALine_1);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

	User::After(1000000);
	editPos=KEnglishShortParagraph().Length()+1;
//	TInsertText insertText2(aMaintainer, aRichText, aValidator, KEnglishLessThanALine_1());
	insertEnglish.ExecuteL(editPos,KEnglishLessThanALine_3().Length());
	User::After(1000000);
	}