void TestStoryText::removeCharStyle() { StoryText story; story.insertChars(0, QString("0123456789") + SpecialChars::PARSEP + QString("abcdefghijklmnopqrstuvwxyz") + SpecialChars::PARSEP + QString("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); QCOMPARE(story.nrOfRuns(), 3u); CharStyle cs; cs.setFontSize(10); story.applyCharStyle(5 + 26 + 1, 26 + 1, cs); story.removeChars(11, 26+1); QCOMPARE(story.nrOfRuns(), 3u); QCOMPARE(story.startOfRun(0), 0); QCOMPARE(story.endOfRun(0), 11); QCOMPARE(story.startOfRun(1), 11); QCOMPARE(story.endOfRun(1), 5 + 26 + 1); QCOMPARE(story.startOfRun(2), 5 + 26 + 1); QCOMPARE(story.endOfRun(2), 11 + 26); }
void gtAction:: setCharStyleAttributes(gtFont *font, CharStyle& style) { int flags = font->getFlags(); style.erase(); if ((flags & gtFont::familyWasSet) || (flags & gtFont::weightWasSet) || (flags & gtFont::slantWasSet)) style.setFont(validateFont(font)); if (flags & gtFont::sizeWasSet) style.setFontSize(font->getSize()); if (flags & gtFont::effectWasSet) style.setFeatures(static_cast<StyleFlag>(font->getEffectsValue()).featureList()); if (flags & gtFont::fillColorWasSet) style.setFillColor(parseColor(font->getColor())); if (flags & gtFont::fillShadeWasSet) style.setFillShade(font->getShade()); if (flags & gtFont::strokeColorWasSet) style.setStrokeColor(parseColor(font->getStrokeColor())); if (flags & gtFont::strokeShadeWasSet) style.setStrokeShade(font->getStrokeShade()); if (flags & gtFont::hscaleWasSet) style.setScaleH(font->getHscale()); if (flags & gtFont::kerningWasSet) style.setTracking(font->getKerning()); }
/*! 03.01.2007 - 05.01.2007 : Joachim Neu : Create a char style. Special thanks go to avox for helping me! */ PyObject *scribus_createcharstyle(PyObject* /* self */, PyObject* args, PyObject* keywords) { char* keywordargs[] = { const_cast<char*>("name"), const_cast<char*>("font"), const_cast<char*>("fontsize"), const_cast<char*>("features"), const_cast<char*>("fillcolor"), const_cast<char*>("fillshade"), const_cast<char*>("strokecolor"), const_cast<char*>("strokeshade"), const_cast<char*>("baselineoffset"), const_cast<char*>("shadowxoffset"), const_cast<char*>("shadowyoffset"), const_cast<char*>("outlinewidth"), const_cast<char*>("underlineoffset"), const_cast<char*>("underlinewidth"), const_cast<char*>("strikethruoffset"), const_cast<char*>("strikethruwidth"), const_cast<char*>("scaleh"), const_cast<char*>("scalev"), const_cast<char*>("tracking"), const_cast<char*>("language"), NULL}; char *Name = const_cast<char*>(""), *Font = const_cast<char*>("Times"), *Features = const_cast<char*>("inherit"), *FillColor = const_cast<char*>("Black"), *StrokeColor = const_cast<char*>("Black"), *Language = const_cast<char*>(""); double FontSize = 200, FillShade = 1, StrokeShade = 1, ScaleH = 1, ScaleV = 1, BaselineOffset = 0, ShadowXOffset = 0, ShadowYOffset = 0, OutlineWidth = 0, UnderlineOffset = 0, UnderlineWidth = 0, StrikethruOffset = 0, StrikethruWidth = 0, Tracking = 0; if (!PyArg_ParseTupleAndKeywords(args, keywords, "es|esdesesdesddddddddddddes", keywordargs, "utf-8", &Name, "utf-8", &Font, &FontSize, "utf-8", &Features, "utf-8", &FillColor, &FillShade, "utf-8", &StrokeColor, &StrokeShade, &BaselineOffset, &ShadowXOffset, &ShadowYOffset, &OutlineWidth, &UnderlineOffset, &UnderlineWidth, &StrikethruOffset, &StrikethruWidth, &ScaleH, &ScaleV, &Tracking, "utf-8", &Language)) return NULL; if(!checkHaveDocument()) return NULL; if(Name == EMPTY_STRING) { PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty char style name.","python error").toLocal8Bit().constData()); return NULL; } QStringList FeaturesList = QString(Features).split(QString(",")); CharStyle TmpCharStyle; TmpCharStyle.setName(Name); TmpCharStyle.setFont((*ScCore->primaryMainWindow()->doc->AllFonts)[QString(Font)]); TmpCharStyle.setFontSize(FontSize * 10); TmpCharStyle.setFeatures(FeaturesList); TmpCharStyle.setFillColor(QString(FillColor)); TmpCharStyle.setFillShade(FillShade * 100); TmpCharStyle.setStrokeColor(QString(StrokeColor)); TmpCharStyle.setStrokeShade(StrokeShade * 100); TmpCharStyle.setBaselineOffset(BaselineOffset); TmpCharStyle.setShadowXOffset(ShadowXOffset); TmpCharStyle.setShadowYOffset(ShadowYOffset); TmpCharStyle.setOutlineWidth(OutlineWidth); TmpCharStyle.setUnderlineOffset(UnderlineOffset); TmpCharStyle.setUnderlineWidth(UnderlineWidth); TmpCharStyle.setStrikethruOffset(StrikethruOffset); TmpCharStyle.setStrikethruWidth(StrikethruWidth); TmpCharStyle.setScaleH(ScaleH * 1000); TmpCharStyle.setScaleV(ScaleV * 1000); TmpCharStyle.setTracking(Tracking); TmpCharStyle.setLanguage(QString(Language)); StyleSet<CharStyle> TmpStyleSet; TmpStyleSet.create(TmpCharStyle); ScCore->primaryMainWindow()->doc->redefineCharStyles(TmpStyleSet, false); // PV - refresh the Style Manager window. // I thought that this can work but it doesn't: // ScCore->primaryMainWindow()->styleMgr()->reloadStyleView(); // So the brute force setDoc is called... ScCore->primaryMainWindow()->styleMgr()->setDoc(ScCore->primaryMainWindow()->doc); Py_RETURN_NONE; }