Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 12336 → Rev 12337

/branches/ScribusUIDStyles/scribus/tabmanager.h
10,7 → 10,8
#include <QDialog>
 
#include "scribusapi.h"
#include "styles/paragraphstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
 
class QVBoxLayout;
class QHBoxLayout;
/branches/ScribusUIDStyles/scribus/styles/charstyle.cpp
105,12 → 105,12
 
 
 
void CharStyle::applyCharStyle(const CharStyle & other)
void CharStyle::applyCharStyle(const CharStyle * other)
{
Style::applyStyle(other);
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (! other.inh_##attr_NAME) \
set##attr_NAME(other.m_##attr_NAME);
if (! other->inh_##attr_NAME) \
set##attr_NAME(other->m_##attr_NAME);
#include "charstyle.attrdefs.cxx"
#undef ATTRDEF
updateFeatures();
117,12 → 117,12
}
 
 
void CharStyle::eraseCharStyle(const CharStyle & other)
void CharStyle::eraseCharStyle(const CharStyle * other)
{
other.validate();
other->validate();
Style::eraseStyle(other);
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (!inh_##attr_NAME && m_##attr_NAME == other.m_##attr_NAME) \
if (!inh_##attr_NAME && m_##attr_NAME == other->m_##attr_NAME) \
reset##attr_NAME();
#include "charstyle.attrdefs.cxx"
#undef ATTRDEF
380,14 → 380,14
 
 
 
void CharStyle::setStyle(const CharStyle& other)
void CharStyle::setStyle(const CharStyle* other)
{
other.validate();
setParent(other.parent());
other->validate();
setParent(other->parent());
m_contextversion = -1;
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
inh_##attr_NAME = other.inh_##attr_NAME; \
m_##attr_NAME = other.m_##attr_NAME;
inh_##attr_NAME = other->inh_##attr_NAME; \
m_##attr_NAME = other->m_##attr_NAME;
#include "charstyle.attrdefs.cxx"
#undef ATTRDEF
updateFeatures();
/branches/ScribusUIDStyles/scribus/styles/style.cpp
27,32 → 27,23
const QString Style::INHERIT_PARENT = "\n";
 
Style::Style()
: m_isDefaultStyle(false), m_name( QUuid::createUuid().toString() ), m_context(NULL), m_contextversion(-1), m_parent(QUuid().toString()), m_shortcut()
: m_isDefaultStyle(false), m_uuid( QUuid::createUuid().toString() ), m_context(NULL), m_contextversion(-1), m_parent(QUuid().toString()), m_shortcut()
{
// QString la(PrefsManager::instance()->guiLanguage());
// m_namesDB[la] = la+"-"+m_name;
m_userName = m_name;
qDebug()<<"STYLE"<<m_name<<m_userName<<m_parent;
m_name = m_uuid;
StylesLibrary::add(m_name,this);
}
 
 
Style::Style(StyleContext* b, QString n, QString lang )
: m_isDefaultStyle(false), m_name( QUuid::createUuid().toString() ), m_userName(n), m_context(b), m_contextversion(-1), m_parent(QUuid().toString()), m_shortcut()
Style::Style( QString n, QString lang )
: m_isDefaultStyle(false), m_uuid( QUuid::createUuid().toString() ), m_name(n), m_parent(QUuid().toString()), m_shortcut()
{
// if(!lang.isEmpty())
// {
// m_namesDB[lang] = n;
// }
// else
// {
// m_namesDB[PrefsManager::instance()->guiLanguage()] = n;
// }
qDebug()<<"STYLE"<<m_name<<m_userName<<m_parent;
StylesLibrary::add(m_name,this);
}
 
Style::Style(const Style& o)
: SaxIO(),
m_isDefaultStyle(o.m_isDefaultStyle),
m_uuid( QUuid::createUuid().toString() ),
m_name(o.m_name),
// m_namesDB(o.m_namesDB),
m_userName(o.m_userName),
61,8 → 52,7
m_parent(o.m_parent),
m_shortcut(o.m_shortcut)
{
update(o.m_context);
qDebug()<<"STYLE (copy)"<<m_name<<m_userName<<m_parent;
StylesLibrary::add(m_uuid,this);
}
 
Style& Style::operator=(const Style& o)
69,19 → 59,19
{ //assert(typeinfo() == o.typeinfo());
m_isDefaultStyle = o.m_isDefaultStyle;
m_name = o.m_name;
m_userName = o.m_userName;
// m_namesDB = o.m_namesDB;
// m_context = o.m_context;
m_contextversion = -1;
m_uuid = o.m_uuid;
m_parent = o.m_parent;
m_shortcut = o.m_shortcut;
update(o.m_context);
qDebug()<<"STYLE (=)"<<m_name<<m_userName<<m_parent;
return *this;
}
 
 
Style::~ Style()
{
StylesLibrary::remove(m_name);
}
 
 
QString Style::displayName(/*const QString& lang*/) const
{
// if ( !hasParent() || !m_context)
240,16 → 230,18
attr["shortcut"] = shortcut();
}
 
void Style::applyStyle(const Style& other)
void Style::applyStyle(const Style* other)
{
if (other.hasParent())
setParent( other.parent() == INHERIT_PARENT? QUuid().toString() :other.parent());
if (other->hasParent())
setParent( other->parent() == INHERIT_PARENT? QUuid().toString() :other->parent());
m_contextversion = -1;
}
 
void Style::eraseStyle(const Style& other)
void Style::eraseStyle(const Style* other)
{
if (other.parent() == parent())
if (other->parent() == parent())
setParent(QUuid().toString());
m_contextversion = -1;
}
 
 
/branches/ScribusUIDStyles/scribus/styles/charstyle.h
134,10 → 134,10
bool equiv(const Style& other) const;
void applyCharStyle(const CharStyle & other);
void eraseCharStyle(const CharStyle & other);
void setStyle(const CharStyle & other);
void erase() { eraseCharStyle(*this); }
void applyCharStyle(const CharStyle * other);
void eraseCharStyle(const CharStyle * other);
void setStyle(const CharStyle * other);
void erase() { eraseCharStyle(this); }
QString asString() const;
/branches/ScribusUIDStyles/scribus/styles/linestyle.cpp
18,23 → 18,23
#include "prefsmanager.h"
 
 
void LineStyle::applyLineStyle(const LineStyle & other)
void LineStyle::applyLineStyle(const LineStyle * other)
{
Style::applyStyle(other);
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (! other.inh_##attr_NAME) \
set##attr_NAME(other.m_##attr_NAME);
if (! other->inh_##attr_NAME) \
set##attr_NAME(other->m_##attr_NAME);
#include "linestyle.attrdefs.cxx"
#undef ATTRDEF
}
 
 
void LineStyle::eraseLineStyle(const LineStyle & other)
void LineStyle::eraseLineStyle(const LineStyle * other)
{
other.validate();
other->validate();
Style::eraseStyle(other);
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (!inh_##attr_NAME && m_##attr_NAME == other.m_##attr_NAME) \
if (!inh_##attr_NAME && m_##attr_NAME == other->m_##attr_NAME) \
reset##attr_NAME();
#include "linestyle.attrdefs.cxx"
#undef ATTRDEF
112,13 → 112,13
}
 
 
void LineStyle::setStyle(const LineStyle& other)
void LineStyle::setStyle(const LineStyle* other)
{
other.validate();
setParent(other.parent());
other->validate();
setParent(other->parent());
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
inh_##attr_NAME = other.inh_##attr_NAME; \
m_##attr_NAME = other.m_##attr_NAME;
inh_##attr_NAME = other->inh_##attr_NAME; \
m_##attr_NAME = other->m_##attr_NAME;
#include "linestyle.attrdefs.cxx"
#undef ATTRDEF
}
/branches/ScribusUIDStyles/scribus/styles/styleslibrary.cpp
0,0 → 1,95
//
// C++ Implementation: styleslibrary
//
// Description:
//
//
// Author: Pierre Marchand, <pierremarc@oep-h.com> (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
 
#include "styleslibrary.h"
 
StylesLibrary *StylesLibrary::instance = 0;
StylesLibrary::StylesLibrary()
{
instance = this;
}
 
StylesLibrary * StylesLibrary::getThis()
{
if(!instance)
instance = new StylesLibrary;
return instance;
}
 
void StylesLibrary::Add(const QString& uuid, Style* style)
{
getThis()->insert(uuid,style);
qDebug()<<"ADD"<<style->displayName()<<getThis()->count();
}
 
void StylesLibrary::Remove(const QString& uuid)
{
qDebug()<<"REMOVE"<<getThis()->value(uuid)<<getThis()->count();
getThis()->remove(uuid);
}
 
Style * StylesLibrary::Style(const QString & uuid)
{
if(getThis()->contains(uuid))
{
return getThis()->value(uuid) ;
}
return 0;
}
 
LineStyle* StylesLibrary::Line(const QString& uuid)
{
if(getThis()->contains(uuid))
{
Style* s( getThis()->value(uuid) );
return reinterpret_cast<LineStyle*>( s );
}
return 0;
}
 
CharStyle* StylesLibrary::Char(const QString& uuid)
{
if(getThis()->contains(uuid))
{
Style* s( getThis()->value(uuid) );
return reinterpret_cast<CharStyle*>( s );
}
return 0;
}
 
ParagraphStyle* StylesLibrary::Paragraph(const QString& uuid)
{
if(getThis()->contains(uuid))
{
Style* s( getThis()->value(uuid) );
return reinterpret_cast<ParagraphStyle*>( s );
}
return 0;
}
 
QString StylesLibrary::Find(const QString& dName)
{
StylesLibrary *sThis(getThis());
for(StylesLibrary::iterator it = sThis->begin() ; it != sThis->end() ; ++it)
{
if(it->displayName() == dName)
return it.key();
}
return QString();
}
 
 
/branches/ScribusUIDStyles/scribus/styles/linestyle.h
18,6 → 18,7
#define LINESTYLE_H
 
#include <QString>
#include "resourcecollection.h"
#include "style.h"
#include "styles/stylecontextproxy.h"
 
63,10 → 64,10
bool equiv(const Style& other) const;
void applyLineStyle(const LineStyle & other);
void eraseLineStyle(const LineStyle & other);
void setStyle(const LineStyle & other);
void erase() { eraseLineStyle(*this); }
void applyLineStyle(const LineStyle * other);
void eraseLineStyle(const LineStyle * other);
void setStyle(const LineStyle * other);
void erase() { eraseLineStyle(this); }
QString asString() const;
/branches/ScribusUIDStyles/scribus/styles/styleslibrary.h
0,0 → 1,43
//
// C++ Interface: styleslibrary
//
// Description:
//
//
// Author: Pierre Marchand, <pierremarc@oep-h.com> (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
 
#ifndef STYLESLIBRARY_H
#define STYLESLIBRARY_H
 
#include "linestyle.h"
#include "charstyle.h"
#include "paragraphstyle.h"
 
/** Because I’m tired running after contexts everywhere, i’ll maintain
a dumb Styles map which can be queried from anywhere to fetch a style
*/
 
class SCRIBUS_API StylesLibrary : private QMap<QString, Style*>
{
static StylesLibrary *instance;
static StylesLibrary* getThis();
StylesLibrary();
~StylesLibrary(){};
public:
static void Add(const QString& uuid, Style* style);
static void Remove(const QString& uuid);
static Style* Style(const QString& uuid);
static LineStyle* Line(const QString& uuid);
static CharStyle* Char(const QString& uuid);
static ParagraphStyle* Paragraph(const QString& uuid);
static QString Find(const QString& dName);
};
 
#endif
/branches/ScribusUIDStyles/scribus/styles/paragraphstyle.cpp
19,13 → 19,16
#include "resourcecollection.h"
#include "desaxe/saxiohelper.h"
#include "desaxe/simple_actions.h"
#include "styleslibrary.h"
 
 
ParagraphStyle::ParagraphStyle() : Style(), cstyleContext(NULL), cstyleContextIsInh(true), cstyle()
ParagraphStyle::ParagraphStyle() : Style(), cstyleContext(NULL), cstyleContextIsInh(true)/*, cstyle()*/
{
setParent("");
cstyleContext.setDefaultStyle( &cstyle );
cstyle.setName( "CSTYLE" + displayName());
CharStyle *csP(new CharStyle);
csP->setName( "CSTYLE" + displayName());
cstyle = csP->uuid();
cstyleContext.setDefaultStyle( csP );
// qDebug(QString("ParagraphStyle() %1 pcontext %2 ccontext %3").arg(reinterpret_cast<uint>(this)).arg(reinterpret_cast<uint>(context())).arg(reinterpret_cast<uint>(defaultStyle()->context())));
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
m_##attr_NAME = attr_DEFAULT; \
37,13 → 40,13
}
 
 
ParagraphStyle::ParagraphStyle(const ParagraphStyle& other) : Style(other), cstyleContext(NULL), cstyleContextIsInh(other.cstyleContextIsInh), cstyle(other.charStyle())
ParagraphStyle::ParagraphStyle(const ParagraphStyle& other) : Style(other), cstyleContext(NULL), cstyleContextIsInh(other.cstyleContextIsInh), cstyle(other.charStyle()->uuid())
{
if (cstyleContextIsInh)
cstyle.setContext(NULL);
else
cstyle.setContext(other.charStyle().context());
cstyleContext.setDefaultStyle( &cstyle );
// if (cstyleContextIsInh)
// cstyle.setContext(NULL);
// else
// cstyle.setContext(other.charStyle().context());
cstyleContext.setDefaultStyle( reinterpret_cast<CharStyle*>(StylesLibrary::style( cstyle )) );
// qDebug(QString("ParagraphStyle(%2) %1").arg(reinterpret_cast<uint>(&other)).arg(reinterpret_cast<uint>(this)));
other.validate();
 
78,7 → 81,7
other.validate();
const ParagraphStyle* oth = dynamic_cast<const ParagraphStyle*> ( & other );
return oth &&
parent() == oth->parent() && cstyle.equiv(oth->charStyle())
parent() == oth->parent() && (cstyle == oth->charStyle()->uuid() )
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
&& (inh_##attr_NAME == oth->inh_##attr_NAME) \
&& (inh_##attr_NAME || m_##attr_NAME == oth->m_##attr_NAME)
111,21 → 114,21
static_cast<Style&>(*this) = static_cast<const Style&>(other);
 
other.validate();
cstyle = other.charStyle();
cstyle = other.charStyle()->uuid() ;
 
// we dont want cstyleContext to point to other's charstyle...
cstyleContext.setDefaultStyle( &cstyle );
if (cstyleContextIsInh)
{
const ParagraphStyle * parent = dynamic_cast<const ParagraphStyle*> ( parentStyle() );
cstyle.setContext(parent ? parent->charStyleContext() : NULL);
}
else
{
cstyle.setContext(other.charStyle().context());
}
// // we dont want cstyleContext to point to other's charstyle...
// cstyleContext.setDefaultStyle( StylesLibrary::Char( cstyle ) );
//
// if (cstyleContextIsInh)
// {
// const ParagraphStyle * parent = dynamic_cast<const ParagraphStyle*> ( parentStyle() );
// cstyle.setContext(parent ? parent->charStyleContext() : NULL);
// }
// else
// {
// cstyle.setContext(other.charStyle().context());
// }
//
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
m_##attr_NAME = other.m_##attr_NAME; \
inh_##attr_NAME = other.inh_##attr_NAME;
146,7 → 149,7
{
if (cstyleContextIsInh) {
const ParagraphStyle * newParent = dynamic_cast<const ParagraphStyle*> ( parentStyle() );
cstyle.setContext(newParent ? newParent->charStyleContext() : NULL);
StylesLibrary::Char( cstyle )->setContext(newParent ? newParent->charStyleContext() : NULL);
}
}
 
160,11 → 163,11
void ParagraphStyle::update(const StyleContext* context)
{
Style::update(context);
assert ( &cstyleContext != cstyle.context());
// assert ( &cstyleContext != cstyle.context());
 
repairImplicitCharStyleInheritance();
assert ( &cstyleContext != cstyle.context());
cstyle.validate();
// assert ( &cstyleContext != cstyle.context());
StylesLibrary::Char(cstyle)->validate();
cstyleContext.invalidate();
 
const ParagraphStyle * oth = dynamic_cast<const ParagraphStyle*> ( parentStyle() );
180,42 → 183,42
 
 
 
void ParagraphStyle::applyStyle(const ParagraphStyle& other)
void ParagraphStyle::applyStyle(const ParagraphStyle* other)
{
Style::applyStyle(other);
cstyle.applyCharStyle(other.charStyle());
StylesLibrary::Char(cstyle)->applyCharStyle(other->charStyle());
cstyleContext.invalidate();
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (! other.inh_##attr_NAME) \
set##attr_NAME(other.m_##attr_NAME);
if (! other->inh_##attr_NAME) \
set##attr_NAME(other->m_##attr_NAME);
#include "paragraphstyle.attrdefs.cxx"
#undef ATTRDEF
}
 
 
void ParagraphStyle::eraseStyle(const ParagraphStyle& other)
void ParagraphStyle::eraseStyle(const ParagraphStyle* other)
{
other.validate();
other->validate();
Style::eraseStyle(other);
cstyle.eraseCharStyle(other.charStyle());
StylesLibrary::Char(cstyle)->eraseCharStyle(other->charStyle());
cstyleContext.invalidate();
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
if (!inh_##attr_NAME && m_##attr_NAME == other.m_##attr_NAME) \
if (!inh_##attr_NAME && m_##attr_NAME == other->m_##attr_NAME) \
reset##attr_NAME();
#include "paragraphstyle.attrdefs.cxx"
#undef ATTRDEF
}
 
void ParagraphStyle::setStyle(const ParagraphStyle & other)
void ParagraphStyle::setStyle(const ParagraphStyle * other)
{
other.validate();
setParent(other.parent());
other->validate();
setParent(other->parent());
m_contextversion = -1;
cstyle.setStyle(other.charStyle());
StylesLibrary::Char(cstyle)->setStyle(other->charStyle());
cstyleContext.invalidate();
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
inh_##attr_NAME = other.inh_##attr_NAME; \
m_##attr_NAME = other.m_##attr_NAME;
inh_##attr_NAME = other->inh_##attr_NAME; \
m_##attr_NAME = other->m_##attr_NAME;
#include "paragraphstyle.attrdefs.cxx"
#undef ATTRDEF
}
225,7 → 228,7
{
for (const Style *sty = parentStyle(); sty != NULL; sty = sty->parentStyle())
lists.collectStyle(sty->uuid());
charStyle().getNamedResources(lists);
charStyle()->getNamedResources(lists);
}
 
 
238,7 → 241,7
setParent(it.value());
repairImplicitCharStyleInheritance();
}
cstyle.replaceNamedResources(newNames);
StylesLibrary::Char(cstyle)->replaceNamedResources(newNames);
}
 
 
277,8 → 280,8
tab.insert("type", toXMLString(tb.tabType));
handler.beginEnd("tabstop", tab);
}
if (charStyle() != CharStyle())
charStyle().saxx(handler);
// if (charStyle() != CharStyle())
// charStyle().saxx(handler);
handler.end(elemtag);
}
 
366,3 → 369,13
Xml_string tabPrefix(Digester::concat(stylePrefix, "tabstop"));
ruleset.addRule(tabPrefix, SetTabStop());
}
 
ParagraphStyle * charStyle()
{
return StylesLibrary::style(cstyle);
}
 
ParagraphStyle * charStyle() const
{
return StylesLibrary::style(cstyle);
}
/branches/ScribusUIDStyles/scribus/styles/paragraphstyle.h
88,15 → 88,15
bool equiv(const Style& other) const;
void applyStyle(const ParagraphStyle& other);
void eraseStyle(const ParagraphStyle& other);
void setStyle(const ParagraphStyle& other);
void erase() { eraseStyle(*this); }
void applyStyle(const ParagraphStyle* other);
void eraseStyle(const ParagraphStyle* other);
void setStyle(const ParagraphStyle* other);
void erase() { eraseStyle(this); }
 
StyleContext* charStyleContext() { return & cstyleContext; }
const StyleContext* charStyleContext() const { return & cstyleContext; }
CharStyle & charStyle() { return cstyle; }
const CharStyle& charStyle() const { return cstyle; }
CharStyle * charStyle() ;
const CharStyle* charStyle() const ;
/** Normally the context for charStyle() is parentStyle()->charStyleContext()
Use this method to break that relation and set charStyle()'s context manually
*/
153,7 → 153,7
// member declarations:
StyleContextProxy cstyleContext;
bool cstyleContextIsInh;
CharStyle cstyle;
QString cstyle;
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
attr_TYPE m_##attr_NAME; \
/branches/ScribusUIDStyles/scribus/styles/CMakeLists.txt
10,11 → 10,12
 
SET(SCRIBUS_STYLES_LIB_SOURCES
style.cpp
stylecontext.cpp
stylecontextproxy.cpp
# stylecontext.cpp
# stylecontextproxy.cpp
linestyle.cpp
charstyle.cpp
paragraphstyle.cpp
styleslibrary.cpp
)
 
QT4_WRAP_CPP(SCRIBUS_STYLES_MOC_SOURCES ${SCRIBUS_STYLES_MOC_CLASSES})
/branches/ScribusUIDStyles/scribus/text/sctext_shared.h
9,8 → 9,9
//#include "text/paragraphlayout.h"
#include "text/frect.h"
#include "style.h"
#include "styles/charstyle.h"
#include "styles/paragraphstyle.h"
// #include "styles/charstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
#include "styles/stylecontextproxy.h"
 
 
/branches/ScribusUIDStyles/scribus/text/storytext.cpp
186,12 → 186,12
if (pos < 0)
pos += length()+1;
CharStyle cstyle(charStyle(pos));
ParagraphStyle pstyle(paragraphStyle(pos));
QString cstyle(charStyle(pos));
QString pstyle(paragraphStyle(pos));
// this style represents all differences between this and other's defaultstyles
ParagraphStyle otherDefault(other.defaultStyle());
otherDefault.eraseStyle(defaultStyle());
QString otherDefault(other.defaultStyle());
StylesLibrary::style( otherDefault )->eraseStyle( StylesLibrary::style( defaultStyle() ) );
int otherStart = onlySelection? other.startOfSelection() : 0;
int otherEnd = onlySelection? other.endOfSelection() : other.length();
524,7 → 524,7
}
 
 
const CharStyle & StoryText::charStyle(int pos) const
const QString & StoryText::charStyle(int pos) const
{
if (pos < 0)
pos += length();
547,7 → 547,7
return dynamic_cast<const CharStyle &> (*that->d->at(pos));
}
 
const ParagraphStyle & StoryText::paragraphStyle(int pos) const
const QString & StoryText::paragraphStyle(int pos) const
{
if (pos < 0)
pos += length();
584,7 → 584,7
return *that->d->at(pos)->parstyle;
}
 
const ParagraphStyle& StoryText::defaultStyle() const
const QString& StoryText::defaultStyle() const
{
assert(d);
return d->defaultStyle;
591,7 → 591,7
}
 
 
void StoryText::setDefaultStyle(const ParagraphStyle& style)
void StoryText::setDefaultStyle(const QString& style)
{
const StyleContext * oldPContext = d->defaultStyle.context();
// const StyleContext * oldCContext = d->defaultStyle.charStyle().context();
608,7 → 608,7
}
 
 
void StoryText::applyCharStyle(int pos, uint len, const CharStyle& style )
void StoryText::applyCharStyle(int pos, uint len, const QString& style )
{
if (pos < 0)
pos += length();
661,7 → 661,7
}
 
 
void StoryText::applyStyle(int pos, const ParagraphStyle& style)
void StoryText::applyStyle(int pos, const QString& style)
{
if (pos < 0)
pos += length();
726,7 → 726,7
}
 
 
void StoryText::setStyle(int pos, const ParagraphStyle& style)
void StoryText::setStyle(int pos, const QString& style)
{
eraseStyle(pos, paragraphStyle(pos));
applyStyle(pos, style);
/branches/ScribusUIDStyles/scribus/text/storytext.h
35,8 → 35,9
#include "text/specialchars.h"
#include "sctextstruct.h"
#include "style.h"
#include "styles/charstyle.h"
#include "styles/paragraphstyle.h"
// #include "styles/charstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
#include "desaxe/saxio.h"
 
#ifdef NLS_CONFORMANCE
126,13 → 127,13
int nextFramePos(int c);
int prevFramePos(int c);
const CharStyle& charStyle(int pos) const;
const ParagraphStyle& paragraphStyle(int pos) const;
const ParagraphStyle& defaultStyle() const;
void setDefaultStyle(const ParagraphStyle& style);
void setCharStyle(int pos, uint len, const CharStyle& style);
void setStyle(int pos, const ParagraphStyle& style);
void applyCharStyle(int pos, uint len, const CharStyle& style);
const QString& charStyle(int pos) const;
const QString& paragraphStyle(int pos) const;
const QString& defaultStyle() const;
void setDefaultStyle(const QString& style);
void setCharStyle(int pos, uint len, const QString& style);
void setStyle(int pos, const QString& style);
void applyCharStyle(int pos, uint len, const QString& style);
void applyStyle(int pos, const ParagraphStyle& style);
void eraseCharStyle(int pos, uint len, const CharStyle& style);
void eraseStyle(int pos, const ParagraphStyle& style);
/branches/ScribusUIDStyles/scribus/style.h
26,7 → 26,6
#include "styles/stylecontext.h"
#include "desaxe/saxio.h"
 
 
/**
* This is the base class for all style-like objects: CharStyles,
* ParagraphStyles, LineStyles, FrameStyles, CellStyles,
40,10 → 39,8
protected:
bool m_isDefaultStyle;
// QMap<QString,QString> m_namesDB; // map< lang , name >
QString m_userName; // transitional
QString m_name; // UUID, yep its bad but avoids revolution.
const StyleContext* m_context;
int m_contextversion;
QString m_name; // transitional
QString m_uuid;
QString m_parent;
QString m_shortcut;
public:
55,13 → 52,13
Style();
 
// if lang is null, which likely will be the rule, we get it from gui language
Style(StyleContext* b, QString n, QString lang = QString() );
Style( QString n, QString lang = QString() );
Style& operator=(const Style& o);
Style(const Style& o);
virtual ~Style(){}
virtual ~Style();
 
// this is an abstract class, so:
77,34 → 74,18
bool isDefaultStyle() const { return m_isDefaultStyle; }
QString uuid() const ; // returns the UUID, at some point has to be changed into uuid()
QString name() const ; // returns the human-readable name
void setName(const QString& n = QString()/*, const QString& lang = QString()*/);
bool hasName(/*const QString& lang = QString()*/) const ;
QString userName() const; // returns the human-readable name
 
virtual QString displayName(/*const QString& lang = QString()*/) const;
QString parent() const ;
void setParent(const QString& p);
bool hasParent() const ;
const Style* parentStyle() const;
static const QString INHERIT_PARENT;
virtual void setContext(const StyleContext* context);
const StyleContext* context() const { return m_context; }
/**
sets a new StyleContext if b is not NULL and then uses the StyleContext
to set all inherited attributes to their valid value.
*/
virtual void update(const StyleContext* b = NULL);
/**
Checks if this Style needs an update
*/
void validate() const;
 
QString shortcut() const { return m_shortcut; }
void setShortcut(const QString &shortcut) { m_shortcut = shortcut; }
 
113,13 → 94,13
have the same parent, and agree on all attributes which are not inherited.
The StyleContext, the name and any inherited attrinutes may be different.
*/
virtual bool equiv(const Style& other) const = 0;
virtual bool equiv(const QString& other) const = 0;
/**
returns true if both Styles are equivalent and have the same name.
Since the context is not tested, this does *not* ensure they will return
the same values for all attributes.
*/
virtual bool operator==(const Style& other) const { return uuid() == other.uuid() && equiv(other); }
virtual bool operator==(const Style& other) const { return uuid() == other.uuid() && equiv(other.uuid()); }
virtual bool operator!=(const Style& other) const { return ! ( (*this) == other ); }
 
/**
130,11 → 111,11
/**
if other has a parent, replace this parent with the other ones
*/
void applyStyle(const Style& other);
void applyStyle(const QString& other);
/**
if other has the same parent, remove this parent
*/
void eraseStyle(const Style& other) ;
void eraseStyle(const QString& other) ;
};
 
 
/branches/ScribusUIDStyles/scribus/smtextstyles.h
10,7 → 10,8
 
#include "styleitem.h"
#include "styles/styleset.h"
#include "styles/paragraphstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
 
class CharStyle;
class ScribusDoc;
/branches/ScribusUIDStyles/scribus/util_text.h
10,8 → 10,9
#include <QString>
 
#include "style.h"
#include "styles/charstyle.h"
#include "styles/paragraphstyle.h"
// #include "styles/charstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
#include "scribusapi.h"
 
class ScribusDoc;
/branches/ScribusUIDStyles/scribus/hruler.h
27,7 → 27,8
#include <QWidget>
 
#include "scribusapi.h"
#include "styles/paragraphstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
 
class PageItem;
 
/branches/ScribusUIDStyles/scribus/fileloader.h
13,9 → 13,10
#include <QList>
 
#include "scribusapi.h"
#include "styles/styleset.h"
#include "styles/paragraphstyle.h"
#include "styles/charstyle.h"
// #include "styles/styleset.h"
// #include "styles/paragraphstyle.h"
// #include "styles/charstyle.h"
#include "styles/styleslibrary.h"
 
class QDomElement;
class QProgressBar;
/branches/ScribusUIDStyles/scribus/sctextstruct.h
24,8 → 24,9
 
#include "scfonts.h"
#include "style.h"
#include "styles/charstyle.h"
#include "styles/paragraphstyle.h"
// #include "styles/charstyle.h"
// #include "styles/paragraphstyle.h"
#include "styles/styleslibrary.h"
 
class PageItem;
 
/branches/ScribusUIDStyles/scribus/plugins/scriptplugin/cmdstyle.cpp
14,8 → 14,9
#include <QList>
 
#include "scribuscore.h"
#include "styles/paragraphstyle.h"
#include "styles/charstyle.h"
// #include "styles/paragraphstyle.h"
// #include "styles/charstyle.h"
#include "styles/styleslibrary.h"
 
/*! 02.01.2007 - 05.01.2007 : Joachim Neu : Create a paragraph style.
Special thanks go to avox for helping me! */