Subversion Repositories Scribus

Rev

Go to most recent revision | Details | 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
 
15
StylesLibrary *StylesLibrary::instance = 0;
16
StylesLibrary::StylesLibrary()
17
{
18
        instance = this;
19
}
20
 
21
StylesLibrary * StylesLibrary::getThis()
22
{
23
        if(!instance)
24
                instance = new StylesLibrary;
25
        return instance;
26
}
27
 
28
void StylesLibrary::Add(const QString& uuid, Style* style)
29
{
30
        getThis()->insert(uuid,style);
31
        qDebug()<<"ADD"<<style->displayName()<<getThis()->count();
32
}
33
 
34
void StylesLibrary::Remove(const QString& uuid)
35
{
36
        qDebug()<<"REMOVE"<<getThis()->value(uuid)<<getThis()->count();
37
        getThis()->remove(uuid);
38
 
39
}
40
 
41
Style * StylesLibrary::Style(const QString & uuid)
42
{
43
        if(getThis()->contains(uuid))
44
        {
45
                return getThis()->value(uuid) ;
46
        }
47
 
48
        return 0;
49
}
50
 
51
LineStyle* StylesLibrary::Line(const QString& uuid)
52
{
53
        if(getThis()->contains(uuid))
54
        {
55
                Style* s( getThis()->value(uuid) );
56
                return reinterpret_cast<LineStyle*>( s );
57
        }
58
 
59
        return 0;
60
}
61
 
62
CharStyle* StylesLibrary::Char(const QString& uuid)
63
{
64
        if(getThis()->contains(uuid))
65
        {
66
                Style* s( getThis()->value(uuid) );
67
                return reinterpret_cast<CharStyle*>( s );
68
        }
69
 
70
        return 0;
71
}
72
 
73
ParagraphStyle* StylesLibrary::Paragraph(const QString& uuid)
74
{
75
        if(getThis()->contains(uuid))
76
        {
77
                Style* s( getThis()->value(uuid) );
78
                return reinterpret_cast<ParagraphStyle*>( s );
79
        }
80
 
81
        return 0;
82
}
83
 
84
QString StylesLibrary::Find(const QString& dName)
85
{
86
        StylesLibrary *sThis(getThis());
87
        for(StylesLibrary::iterator it = sThis->begin() ; it != sThis->end() ; ++it)
88
        {
89
                if(it->displayName() == dName)
90
                        return it.key();
91
        }
92
        return QString();
93
}
94
 
95