Beispiel #1
0
void Prefs_Printer::restoreDefaults(struct ApplicationPrefs *prefsData)
{
	int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
	unitChange(docUnitIndex);
	double unitRatio = unitGetRatioFromIndex(docUnitIndex);

	QString Pcap;
	QString printerName;
	QStringList printerNames = PrinterUtil::getPrinterNames();
	int numPrinters = printerNames.count();
	for( int i = 0; i < numPrinters; i++)
	{
		printerName = printerNames[i];
		destinationComboBox->addItem(printerName);
	}

	destinationComboBox->addItem( tr("File"));

	PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options");

	QString selectedDest = prefs->get("CurrentPrn", "");
	int prnIndex = destinationComboBox->findText(selectedDest);
	if ((prnIndex > -1) && (prnIndex < destinationComboBox->count()))
		destinationComboBox->setCurrentIndex(prnIndex);
	useAltPrinterCmdCheckBox->setChecked(prefs->getBool("OtherCom", false));
	selOtherComm();
	altPrinterCmdLineEdit->setText(prefs->get("Command", ""));
	bool iccInUse = prefs->getBool("ICCinUse", false);
	bool psPrinter = PrinterUtil::isPostscriptPrinter(destinationComboBox->currentText());
	applyICCProfilesCheckBox->setChecked( psPrinter ? iccInUse : false );
	applyICCProfilesCheckBox->setEnabled( psPrinter );
	outputComboBox->setCurrentIndex(prefs->getInt("Separations", 0));
	postscriptPrintToColorComboBox->setCurrentIndex(prefs->getInt("PrintColor", 0));
	postscriptLevelComboBox->setCurrentIndex(prefs->getInt("PSLevel", 3)-1);
	pageMirrorHorizontallyCheckBox->setChecked(prefs->getBool("MirrorH", false));
	pageMirrorVerticallyCheckBox->setChecked(prefs->getBool("MirrorV", false));
	setMediaSizeCheckBox->setChecked(prefs->getBool("doDev", false));
	applyUnderColorRemovalCheckBox->setChecked(prefs->getBool("DoGCR", false));
	clipToPrinterMarginsCheckBox->setChecked(prefs->getBool("Clip", false));
	convertSpotsToProcessCheckBox->setChecked(!prefs->getBool("doSpot", true));
	MarginStruct bleeds;
	bleeds.set(prefs->getDouble("BleedTop",0.0),
			   prefs->getDouble("BleedBottom", 0.0),
			   prefs->getDouble("BleedRight", 0.0),
			   prefs->getDouble("BleedLeft", 0.0));
	bleedsWidget->setup(bleeds, 0, docUnitIndex, false, false);
	bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
	bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
	markLengthSpinBox->setValue(prefs->getDouble("markLength", 20.0) * unitRatio);
	markOffsetSpinBox->setValue(prefs->getDouble("markOffset", 0.0) * unitRatio);
	cropMarksCheckBox->setChecked(prefs->getBool("cropMarks", false));
	bleedMarksCheckBox->setChecked(prefs->getBool("bleedMarks", false));
	registrationMarksCheckBox->setChecked(prefs->getBool("registrationMarks", false));
	colorBarsCheckBox->setChecked(prefs->getBool("colorMarks", false));
	includePDFAnnotationsCheckBox->setChecked(prefs->getBool("includePDFMarks", true));
}
Beispiel #2
0
void Hyphenator::slotHyphenate(PageItem* it)
{
	if (!(it->asTextFrame()) || (it->itemText.length() == 0))
		return;
	m_doc->DoDrawing = false;

	QString text = "";

	int startC = 0;
	if (it->itemText.selectionLength() > 0)
	{
		startC = it->itemText.startOfSelection();
		text = it->itemText.text(startC, it->itemText.selectionLength());
	}
	else {
		text = it->itemText.text(0, it->itemText.length());
	}

	rememberedWords.clear();
	qApp->setOverrideCursor(QCursor(Qt::WaitCursor));

	BreakIterator* bi = StoryText::getWordIterator();
	bi->setText((const UChar*) text.utf16());
	int pos = bi->first();
	while (pos != BreakIterator::DONE)
	{
		int firstC = pos;
		pos = bi->next();
		int lastC = pos;
		int countC = lastC - firstC;

		const CharStyle& style = it->itemText.charStyle(firstC);
		if (countC > 0 && countC > style.hyphenWordMin() - 1)
		{
			QString word = text.mid(firstC, countC);
			QString wordLower = QLocale(style.language()).toLower(word);
			if (wordLower.contains(SpecialChars::SHYPHEN))
				break;

			bool ok = loadDict(style.language());
			if (!ok)
				continue;

			QByteArray te = m_codec->fromUnicode(wordLower);
			char *buffer = static_cast<char*>(malloc(te.length() + 5));
			if (buffer == nullptr)
				break;

			char **rep = nullptr;
			int *pos = nullptr;
			int *cut = nullptr;
			// TODO: support non-standard hyphenation, see hnj_hyphen_hyphenate2 docs
			if (!hnj_hyphen_hyphenate2(m_hdict, te.data(), te.length(), buffer, nullptr, &rep, &pos, &cut))
			{
	  			int i = 0;
				buffer[te.length()] = '\0';
				bool hasHyphen = false;
				for (i = 1; i < wordLower.length()-1; ++i)
				{
					if(buffer[i] & 1)
					{
						hasHyphen = true;
						break;
					}
				}
				QString outs = "";
				QString input = "";
				outs += word[0];
				for (i = 1; i < wordLower.length()-1; ++i)
				{
					outs += word[i];
					if(buffer[i] & 1)
						outs += "-";
				}
				outs += word.rightRef(1);
				input = outs;
				if (!ignoredWords.contains(word))
				{
					if (!hasHyphen)
						it->itemText.hyphenateWord(startC + firstC, wordLower.length(), nullptr);
					else if (m_automatic)
					{
						if (specialWords.contains(word))
						{
							outs = specialWords.value(word);
							uint ii = 1;
							for (i = 1; i < outs.length()-1; ++i)
							{
								QChar cht = outs[i];
								if (cht == '-')
									buffer[ii-1] = 1;
								else
								{
									buffer[ii] = 0;
									++ii;
								}
							}
						}
						it->itemText.hyphenateWord(startC + firstC, wordLower.length(), buffer);
					}
					else
					{
						if (specialWords.contains(word))
						{
							outs = specialWords.value(word);
							uint ii = 1;
							for (i = 1; i < outs.length()-1; ++i)
							{
								QChar cht = outs[i];
								if (cht == '-')
									buffer[ii-1] = 1;
								else
								{
									buffer[ii] = 0;
									++ii;
								}
							}
						}
						if (rememberedWords.contains(input))
						{
							outs = rememberedWords.value(input);
							uint ii = 1;
							for (i = 1; i < outs.length()-1; ++i)
							{
								QChar cht = outs[i];
								if (cht == '-')
									buffer[ii-1] = 1;
								else
								{
									buffer[ii] = 0;
									++ii;
								}
							}
							it->itemText.hyphenateWord(firstC, wordLower.length(), buffer);
						}
						else
						{
							qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
							PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("hyhpen_options");
							int xpos = prefs->getInt("Xposition", -9999);
							int ypos = prefs->getInt("Yposition", -9999);
							HyAsk *dia = new HyAsk((QWidget*)parent(), outs);
							if ((xpos != -9999) && (ypos != -9999))
								dia->move(xpos, ypos);
							qApp->processEvents();
							if (dia->exec())
							{
								outs = dia->Wort->text();
								uint ii = 1;
								for (i = 1; i < outs.length()-1; ++i)
								{
									QChar cht = outs[i];
									if (cht == '-')
										buffer[ii-1] = 1;
									else
									{
										buffer[ii] = 0;
										++ii;
									}
								}
								if (!rememberedWords.contains(input))
									rememberedWords.insert(input, outs);
								if (dia->addToIgnoreList->isChecked())
								{
									if (!ignoredWords.contains(word))
										ignoredWords.insert(word);
								}
								if (dia->addToExceptionList->isChecked())
								{
									if (!specialWords.contains(word))
										specialWords.insert(word, outs);
								}
								it->itemText.hyphenateWord(firstC, wordLower.length(), buffer);
							}
							else
							{
								free(buffer);
								buffer = nullptr;
								prefs->set("Xposition", dia->xpos);
								prefs->set("Yposition", dia->ypos);
								delete dia;
								break;
							}
							prefs->set("Xposition", dia->xpos);
							prefs->set("Yposition", dia->ypos);
							delete dia;
							qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
						}
					}
				}
			}
			free(buffer);
			if (rep)
			{
				for (int i = 0; i < te.length() - 1; ++i)
					free(rep[i]);
			}
			free(rep);
			free(pos);
			free(cut);
		}
	}
	qApp->restoreOverrideCursor();
	m_doc->DoDrawing = true;
	rememberedWords.clear();
}
Beispiel #3
0
bool CreateMode::doOneClick(FPoint& startPoint, FPoint& endPoint)
{
	bool doCreate = false;
	double xSize, ySize;
	int  originPoint = 0;
	
	if (QApplication::keyboardModifiers() & Qt::ControlModifier)
		return true;

	PrefsContext* sizes = PrefsManager::instance()->prefsFile->getContext("ObjectSize");
	bool doRemember     = sizes->getBool("Remember", true);

	int lmode = (createObjectMode == modeDrawLine) ? 1 : 0;
	if (lmode == 0)
	{
		xSize = sizes->getDouble("defWidth", 100.0);
		ySize = sizes->getDouble("defHeight", 100.0);
		originPoint = sizes->getInt("Origin", 0);
	}
	else
	{
		xSize = sizes->getDouble("defLength", 100.0);
		ySize = sizes->getDouble("defAngle", 0.0);
		originPoint = sizes->getInt("OriginL", 0);
	}
	//#12577 Remove one click dialog
	//#12577 OneClick *dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, doRemember, originPoint, lmode);
	//#12577 if (dia->exec())
	{
		//#12577 doRemember = dia->checkRemember->isChecked();
		if (lmode == 0)
		{
			//#12577 xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex());
			//#12577 ySize = dia->spinHeight->value() / unitGetRatioFromIndex(m_doc->unitIndex());
			//#12577 originPoint = dia->RotationGroup->checkedId();
			if (doRemember)
			{
				sizes->set("defWidth", xSize);
				sizes->set("defHeight", ySize);
				sizes->set("Origin", originPoint);
			}
			endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize);
			switch (originPoint)
			{
				case 0:
					break;
				case 1:
					startPoint.setX(startPoint.x() - xSize);
					endPoint.setX(endPoint.x() - xSize);
					break;
				case 2:
					startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0);
					endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0);
					break;
				case 3:
					startPoint.setY(startPoint.y() - ySize);
					endPoint.setY(endPoint.y() - ySize);
					break;
				case 4:
					startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize);
					endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize);
					break;
			}
		}
		else
		{
			FPoint oldStart = startPoint;
			//#12577 xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex());
			//#12577 ySize = dia->spinHeight->value();
			//#12577 originPoint = dia->RotationGroup->checkedId();
			if (doRemember)
			{
				sizes->set("defLength", xSize);
				sizes->set("defAngle", ySize);
				sizes->set("OriginL", originPoint);
			}
			double angle = -ySize * M_PI / 180.0;
			switch (originPoint)
			{
				case 0:
					endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle));
					break;
				case 1:
					startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle));
					endPoint   = oldStart;
					break;
				case 2:
					startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle));
					endPoint   = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle));
					break;
			}
		}
		sizes->set("Remember", doRemember);
		doCreate = true;
	}
	//delete dia;
	return doCreate;
}
Beispiel #4
0
void Hyphenator::slotHyphenate(PageItem* it)
{
	if ((!m_usable) || !(it->asTextFrame()) || (it->itemText.length() == 0))
		return;
	m_doc->DoDrawing = false;

	const char *word;
	char *buffer;
	const int BORDER = 2;
	QString text = "";
	QString buf;
	QByteArray te;

	int startC = 0;
	if (it->itemText.lengthOfSelection() > 0)
	{
		startC = it->itemText.startOfSelection();
		text = it->itemText.text(startC, it->itemText.lengthOfSelection());
	}
	else {
		text = it->itemText.text(0, it->itemText.length());
	}
	int firstC = 0;
	int lastC = 0;
	int Ccount = 0;
	QString found = "";
	QString found2 = "";
	rememberedWords.clear();
	//uint maxC = it->itemText.length() - 1;
	qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
	QRegExp wordBoundary("\\w");
	QRegExp whiteSpace("\\s|\\W|\\d|\\n|\\r|\\t");
	while ((firstC+Ccount < signed(text.length())) && (firstC != -1) && 
			(lastC < signed(text.length())))
	{
		firstC = text.indexOf(wordBoundary, firstC+Ccount);
		if (firstC < 0)
			break;
		if (firstC > 0 && text.at(firstC-1) == SpecialChars::SHYPHEN)
		{
			Ccount = 1;
			continue;
		}
		lastC = text.indexOf(whiteSpace, firstC);
		if (lastC < 0)
			lastC = signed(text.length());
		Ccount = lastC - firstC;
		if (lastC < signed(text.length()) && text.at(lastC) == SpecialChars::SHYPHEN)
		{
			++Ccount;
			continue;
		}
		if (Ccount > MinWordLen-1)
		{
			found = text.mid(firstC, Ccount).toLower();
			found2 = text.mid(firstC, Ccount);
			if (found.contains(SpecialChars::SHYPHEN))
				break;

			NewDict(it->itemText.charStyle(firstC).language());

  			te = m_codec->fromUnicode( found );
			word = te.data();
			int wordlen = strlen(word);
			buffer = static_cast<char*>(malloc(wordlen+BORDER+3));
			if (buffer == NULL)
				break;
			char ** rep = NULL;
			int * pos = NULL;
			int * cut = NULL;
			if (!hnj_hyphen_hyphenate2(m_hdict, word, wordlen, buffer, NULL, &rep, &pos, &cut))
			{
	  			int i = 0;
  				buffer[wordlen] = '\0';
				bool hasHyphen = false;
				for (i = 1; i < found.length()-1; ++i)
				{
					if(buffer[i] & 1)
					{
						hasHyphen = true;
						break;
					}
				}
				QString outs = "";
				QString input = "";
				outs += found2[0];
				for (i = 1; i < found.length()-1; ++i)
				{
					outs += found2[i];
					if(buffer[i] & 1)
						outs += "-";
				}
				outs += found2.right(1);
				input = outs;
				if (!ignoredWords.contains(found2))
				{
					if (!hasHyphen)
						it->itemText.hyphenateWord(startC + firstC, found.length(), NULL);
					else if (Automatic)
					{
						if (specialWords.contains(found2))
						{
							outs = specialWords.value(found2);
							uint ii = 1;
							for (i = 1; i < outs.length()-1; ++i)
							{
								QChar cht = outs[i];
								if (cht == '-')
									buffer[ii-1] = 1;
								else
								{
									buffer[ii] = 0;
									++ii;
								}
							}
						}
						it->itemText.hyphenateWord(startC + firstC, found.length(), buffer);
					}
					else
					{
						if (specialWords.contains(found2))
						{
							outs = specialWords.value(found2);
							uint ii = 1;
							for (i = 1; i < outs.length()-1; ++i)
							{
								QChar cht = outs[i];
								if (cht == '-')
									buffer[ii-1] = 1;
								else
								{
									buffer[ii] = 0;
									++ii;
								}
							}
						}
						if (rememberedWords.contains(input))
						{
							outs = rememberedWords.value(input);
							uint ii = 1;
							for (i = 1; i < outs.length()-1; ++i)
							{
								QChar cht = outs[i];
								if (cht == '-')
									buffer[ii-1] = 1;
								else
								{
									buffer[ii] = 0;
									++ii;
								}
							}
							it->itemText.hyphenateWord(firstC, found.length(), buffer);
						}
						else
						{
							qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
							PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("hyhpen_options");
							int xpos = prefs->getInt("Xposition", -9999);
							int ypos = prefs->getInt("Yposition", -9999);
							HyAsk *dia = new HyAsk((QWidget*)parent(), outs);
							if ((xpos != -9999) && (ypos != -9999))
								dia->move(xpos, ypos);
							qApp->processEvents();
							if (dia->exec())
							{
								outs = dia->Wort->text();
								uint ii = 1;
								for (i = 1; i < outs.length()-1; ++i)
								{
									QChar cht = outs[i];
									if (cht == '-')
										buffer[ii-1] = 1;
									else
									{
										buffer[ii] = 0;
										++ii;
									}
								}
								if (!rememberedWords.contains(input))
									rememberedWords.insert(input, outs);
								if (dia->addToIgnoreList->isChecked())
								{
									if (!ignoredWords.contains(found2))
										ignoredWords.insert(found2);
								}
								if (dia->addToExceptionList->isChecked())
								{
									if (!specialWords.contains(found2))
										specialWords.insert(found2, outs);
								}
								it->itemText.hyphenateWord(firstC, found.length(), buffer);
							}
							else
							{
								free(buffer);
								buffer = NULL;
								prefs->set("Xposition", dia->xpos);
								prefs->set("Yposition", dia->ypos);
								delete dia;
								break;
							}
							prefs->set("Xposition", dia->xpos);
							prefs->set("Yposition", dia->ypos);
							delete dia;
							qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
						}
					}
				}
			}
			free(buffer);
			if (rep)
			{
				for (int i = 0; i < wordlen - 1; ++i)
					if (rep[i])
						free(rep[i]);
				free(rep);
			}
			if (pos) free(pos);
			if (cut) free(cut);
			buffer = NULL;
			rep = NULL;
			pos = NULL;
			cut = NULL;
		}
		if (Ccount == 0)
			Ccount++;
	}
	qApp->restoreOverrideCursor();
	m_doc->DoDrawing = true;
	rememberedWords.clear();
}