/* This file is part of the KDE project Copyright (C) 2001 Shaheed Haque This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KoParagCounter.h" #include "KoTextParag.h" #include "KoTextZoomHandler.h" #include "KoTextFormat.h" #include "KoTextDocument.h" #include "KoOasisContext.h" #include #include #include #include #include #include static KoTextParag * const INVALID_PARAG = (KoTextParag *)-1; KoParagCounter::KoParagCounter() { m_numbering = NUM_NONE; m_style = STYLE_NONE; m_depth = 0; m_startNumber = 1; m_displayLevels = 1; m_restartCounter = false; m_customBulletChar = QChar( '-' ); m_customBulletFont = QString::null; m_align = Qt::AlignAuto; invalidate(); } bool KoParagCounter::operator==( const KoParagCounter & c2 ) const { // ## This is kinda wrong. Unused fields (depending on the counter style) shouldn't be compared. return (m_numbering==c2.m_numbering && m_style==c2.m_style && m_depth==c2.m_depth && m_startNumber==c2.m_startNumber && m_displayLevels==c2.m_displayLevels && m_restartCounter==c2.m_restartCounter && m_prefix==c2.m_prefix && m_suffix==c2.m_suffix && m_customBulletChar==c2.m_customBulletChar && m_customBulletFont==c2.m_customBulletFont && m_align==c2.m_align && m_custom==c2.m_custom); } QString KoParagCounter::custom() const { return m_custom; } QChar KoParagCounter::customBulletCharacter() const { return m_customBulletChar; } QString KoParagCounter::customBulletFont() const { return m_customBulletFont; } unsigned int KoParagCounter::depth() const { return m_depth; } void KoParagCounter::invalidate() { m_cache.number = -1; m_cache.text = QString::null; m_cache.width = -1; m_cache.parent = INVALID_PARAG; m_cache.counterFormat = 0; } bool KoParagCounter::isBullet( Style style ) // static { switch ( style ) { case STYLE_DISCBULLET: case STYLE_SQUAREBULLET: case STYLE_BOXBULLET: case STYLE_CIRCLEBULLET: case STYLE_CUSTOMBULLET: return true; default: return false; } } bool KoParagCounter::isBullet() const { return isBullet( m_style ); } void KoParagCounter::load( QDomElement & element ) { m_numbering = static_cast( element.attribute("numberingtype", "2").toInt() ); m_style = static_cast