Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 8265 → Rev 8266

/branches/Version13x/Scribus/scribus/styles/charstyle.cpp
12,6 → 12,8
#include "scfonts.h"
#include "style.h"
#include "desaxe/saxiohelper.h"
#include "desaxe/simple_actions.h"
#include "prefsmanager.h"
 
StyleFlag& StyleFlag::operator&= (const StyleFlag& right){
int result = static_cast<int>(value) & static_cast<int>(right.value);
97,23 → 99,6
}
 
 
void CharStyle::saxx(SaxHandler& handler) const
{
Xml_attr att;
if (!name().isEmpty())
att.insert("name", name());
if (!parent().isEmpty())
att.insert("parent", parent());
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (!inh_##attr_NAME) \
att.insert(# attr_NAME, toXMLString(m_##attr_NAME));
#include "charstyle.attrdefs.cxx"
#undef ATTRDEF
handler.begin("charstyle", att);
handler.end("charstyle");
}
 
 
void CharStyle::applyCharStyle(const CharStyle & other)
{
Style::applyStyle(other);
259,3 → 244,57
}
*/
 
 
Xml_string toXMLString(StyleFlag val)
{
return toXMLString(static_cast<unsigned int>(val & ScStyle_UserStyles));
}
 
 
void CharStyle::saxx(SaxHandler& handler, Xml_string elemtag) const
{
Xml_attr att;
if (!name().isEmpty())
att.insert("name", name());
if (!parent().isEmpty())
att.insert("parent", parent());
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (!inh_##attr_NAME) \
att.insert(# attr_NAME, toXMLString(m_##attr_NAME));
#include "charstyle.attrdefs.cxx"
#undef ATTRDEF
handler.beginEnd(elemtag, att);
}
 
 
 
template<>
StyleFlag parse(Xml_string str)
{
return StyleFlag(parseInt(str));
}
 
template<>
ScFace parse(Xml_string str)
{
// FIXME: enable font substitution here
return PrefsManager::instance()->appPrefs.AvailFonts[str];
}
 
 
using namespace desaxe;
 
 
const Xml_string CharStyle::saxxDefaultElem("charstyle");
 
void CharStyle::desaxeRules(Xml_string prefixPattern, Digester& ruleset, Xml_string elemtag)
{
Xml_string stylePrefix(Digester::concat(prefixPattern, elemtag));
ruleset.addRule(stylePrefix, Factory<CharStyle>());
ruleset.addRule(stylePrefix, SetAttributeWithConversion<CharStyle, const QString&>( & CharStyle::setName, "name", &parse<const QString&>));
ruleset.addRule(stylePrefix, SetAttributeWithConversion<CharStyle, const QString&>( & CharStyle::setParent, "parent", &parse<const QString&>));
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
ruleset.addRule(stylePrefix, SetAttributeWithConversion<CharStyle, attr_TYPE> ( & CharStyle::set##attr_NAME, # attr_NAME, &parse<attr_TYPE> ));
#include "charstyle.attrdefs.cxx"
#undef ATTRDEF
}