Subversion Repositories Scribus

Rev

Rev 12337 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12337 pierre 1
//
2
// C++ Implementation: styleslibrary
3
//
4
// Description: 
5
//
6
//
7
// Author: Pierre Marchand, <pierremarc@oep-h.com> (C) 2008
8
//
9
// Copyright: See COPYING file that comes with this distribution
10
//
11
//
12
 
13
#include "styleslibrary.h"
14
 
12340 pierre 15
#include <QDebug>
16
 
12337 pierre 17
StylesLibrary *StylesLibrary::instance = 0;
18
StylesLibrary::StylesLibrary()
19
{
20
        instance = this;
21
}
22
 
23
StylesLibrary * StylesLibrary::getThis()
24
{
25
        if(!instance)
26
                instance = new StylesLibrary;
27
        return instance;
28
}
29
 
30
void StylesLibrary::Add(const QString& uuid, Style* style)
31
{
32
        getThis()->insert(uuid,style);
12340 pierre 33
        qDebug()<<"ADD"<<style->name()<<getThis()->count();
12337 pierre 34
}
35
 
36
void StylesLibrary::Remove(const QString& uuid)
37
{
38
        qDebug()<<"REMOVE"<<getThis()->value(uuid)<<getThis()->count();
39
        getThis()->remove(uuid);
40
 
41
}
42
 
12340 pierre 43
Style * StylesLibrary::BaseStyle(const QString & uuid)
12337 pierre 44
{
45
        if(getThis()->contains(uuid))
46
        {
47
                return getThis()->value(uuid) ;
48
        }
49
 
50
        return 0;
51
}
52
 
53
LineStyle* StylesLibrary::Line(const QString& uuid)
54
{
55
        if(getThis()->contains(uuid))
56
        {
57
                Style* s( getThis()->value(uuid) );
58
                return reinterpret_cast<LineStyle*>( s );
59
        }
60
 
61
        return 0;
62
}
63
 
64
CharStyle* StylesLibrary::Char(const QString& uuid)
65
{
66
        if(getThis()->contains(uuid))
67
        {
68
                Style* s( getThis()->value(uuid) );
69
                return reinterpret_cast<CharStyle*>( s );
70
        }
71
 
72
        return 0;
73
}
74
 
75
ParagraphStyle* StylesLibrary::Paragraph(const QString& uuid)
76
{
77
        if(getThis()->contains(uuid))
78
        {
79
                Style* s( getThis()->value(uuid) );
80
                return reinterpret_cast<ParagraphStyle*>( s );
81
        }
82
 
83
        return 0;
84
}
85
 
86
QString StylesLibrary::Find(const QString& dName)
87
{
88
        StylesLibrary *sThis(getThis());
89
        for(StylesLibrary::iterator it = sThis->begin() ; it != sThis->end() ; ++it)
90
        {
12340 pierre 91
                if((*it)->name() == dName)
12337 pierre 92
                        return it.key();
93
        }
94
        return QString();
95
}
96
 
97
 
12340 pierre 98
int StylesLibrary::Count()
99
{
100
        return getThis()->count();
101
}