Source Code (Use browser search to find items of interest.)

Class Index

kword'KWFormatCollection (./koffice/kword/formatcollection.h:34)

class KWFormatCollection
{
public:
    KWFormatCollection( KWordDocument *_doc );
    ~KWFormatCollection();

    KWFormat *getFormat( const KWFormat &_format );
    void removeFormat( KWFormat *_format );

    QString generateKey( KWFormat *_format )
    { return generateKey( *_format ); }

protected:
    QString generateKey( const KWFormat &_format );
    KWFormat *findFormat( QString _key );
    KWFormat *insertFormat( QString _key, const KWFormat &_format );

    QDict<KWFormat> formats;
    KWordDocument *doc;
};

kword'KWFormatCollection::KWFormatCollection() (./koffice/kword/formatcollection.cc:32)

KWFormatCollection::KWFormatCollection( KWordDocument *_doc )
    : formats( 1999, true )
{
    formats.setAutoDelete( true );
    doc = _doc;
}

/*================================================================*/

kword'KWFormatCollection::~KWFormatCollection() (./koffice/kword/formatcollection.cc:40)

KWFormatCollection::~KWFormatCollection()
{
    formats.clear();
}

/*================================================================*/

kword'KWFormatCollection::getFormat() (./koffice/kword/formatcollection.cc:46)

KWFormat *KWFormatCollection::getFormat( const KWFormat &_format )
{
    QString key = generateKey( _format );

    KWFormat *format = findFormat( key );
    if ( format )
    {
        format->incRef();
        return format;
    }
    else
        return insertFormat( key, _format );
}

/*================================================================*/

kword'KWFormatCollection::removeFormat() (./koffice/kword/formatcollection.cc:61)

void KWFormatCollection::removeFormat( KWFormat *_format )
{
    QString key = generateKey( *_format );

    formats.remove( key );
}

/*================================================================*/

kword'KWFormatCollection::generateKey() (./koffice/kword/formatcollection.cc:69)

QString KWFormatCollection::generateKey( const KWFormat &_format )
{
    QString key;

    // Key: BIU-Fontname-Fontsize-red-gree-blue
    // e.g. B**-Times-12-255-40-32
    key.sprintf( "%c%c%c-%s-%d-%d-%d-%d-%d",
                 ( _format.getWeight() == QFont::Bold ? 'B' : '*' ),
                 ( _format.getItalic() == 1 ? 'I' : '*' ),
                 ( _format.getUnderline() == 1 ? 'U' : '*' ),
                 _format.getUserFont()->getFontName().data(),
                 _format.getPTFontSize(), _format.getColor().red(),
                 _format.getColor().green(), _format.getColor().blue(),
                 _format.getVertAlign() );

    return key;
}

/*================================================================*/

kword'KWFormatCollection::findFormat() (./koffice/kword/formatcollection.cc:88)

KWFormat *KWFormatCollection::findFormat( QString _key )
{
    return formats.find( _key.data() );
}

/*================================================================*/

kword'KWFormatCollection::insertFormat() (./koffice/kword/formatcollection.cc:94)

KWFormat *KWFormatCollection::insertFormat( QString _key, const KWFormat &_format )
{
    KWFormat *format = new KWFormat( doc, _format );

    formats.insert( _key.data(), format );
    format->incRef();

    return format;
}