00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KWVariable.h"
00021
00022 #include "KWTextFrameSet.h"
00023 #include "KWTextDocument.h"
00024 #include "KWMailMergeDataBase.h"
00025 #include "KWDocument.h"
00026 #include "KWCommand.h"
00027 #include "KWViewMode.h"
00028 #include "KWPageManager.h"
00029
00030 #include <KoVariable.h>
00031 #include <KoXmlWriter.h>
00032 #include <KoXmlNS.h>
00033 #include <KoDom.h>
00034
00035 #include <klocale.h>
00036 #include <kdebug.h>
00037
00038 KWVariableSettings::KWVariableSettings() : KoVariableSettings()
00039 {
00040 m_footNoteCounter.setSuffix( QString::null );
00041 m_endNoteCounter.setSuffix( QString::null );
00042
00043 m_endNoteCounter.setStyle( KoParagCounter::STYLE_ROM_NUM_L );
00044 }
00045
00046 void KWVariableSettings::changeFootNoteCounter( KoParagCounter _c )
00047 {
00048 m_footNoteCounter = _c;
00049 }
00050
00051 void KWVariableSettings::changeEndNoteCounter( KoParagCounter _c )
00052 {
00053 m_endNoteCounter = _c;
00054 }
00055
00056 void KWVariableSettings::saveNoteConfiguration( KoXmlWriter& writer ) const
00057 {
00058 writer.startElement( "text:notes-configuration" );
00059 writer.addAttribute( "text:note-class", "footnote" );
00060
00061 m_footNoteCounter.saveOasisListLevel( writer, false );
00062 writer.addAttribute( "text:footnotes-position", "page" );
00063 writer.addAttribute( "text:start-numbering-at", "document" );
00064 writer.endElement();
00065 writer.startElement( "text:notes-configuration" );
00066 writer.addAttribute( "text:note-class", "endnote" );
00067
00068 m_endNoteCounter.saveOasisListLevel( writer, false );
00069 writer.addAttribute( "text:start-numbering-at", "document" );
00070 writer.endElement();
00071 }
00072
00073 void KWVariableSettings::loadNoteConfiguration( const QDomElement& parent )
00074 {
00075 QDomElement e;
00076 forEachElement( e, parent )
00077 {
00078 if ( e.localName() == "notes-configuration" && e.namespaceURI() == KoXmlNS::text )
00079 {
00080 const QString noteClass = e.attributeNS( KoXmlNS::text, "note-class", QString::null );
00081 if ( noteClass == "footnote" ) {
00082 m_footNoteCounter.loadOasisListStyle( e, QDomElement(), QDomElement(), -1, true, false, 1, false );
00083 m_footNoteCounter.setNumbering( KoParagCounter::NUM_FOOTNOTE );
00084 m_footNoteCounter.setRestartCounter( false );
00085 }
00086 else if ( noteClass == "endnote" ) {
00087 m_endNoteCounter.loadOasisListStyle( e, QDomElement(), QDomElement(), -1, true, false, 1, false );
00088 m_endNoteCounter.setNumbering( KoParagCounter::NUM_FOOTNOTE );
00089 m_endNoteCounter.setRestartCounter( false );
00090 }
00091 }
00092 }
00093 }
00094
00095 void KWVariableSettings::save( QDomElement &parentElem )
00096 {
00097 KoVariableSettings::save( parentElem );
00098 QDomDocument doc = parentElem.ownerDocument();
00099 QDomElement footNoteSettingElem = doc.createElement( "FOOTNOTESETTING" );
00100 parentElem.appendChild( footNoteSettingElem );
00101 m_footNoteCounter.save( footNoteSettingElem );
00102 QDomElement endNoteSettingElem = doc.createElement( "ENDNOTESETTING" );
00103 parentElem.appendChild( endNoteSettingElem );
00104 m_endNoteCounter.save( endNoteSettingElem );
00105 }
00106
00107 void KWVariableSettings::load( QDomElement &elem )
00108 {
00109 KoVariableSettings::load( elem );
00110 QDomElement footNoteSettings = elem.namedItem( "FOOTNOTESETTING" ).toElement();
00111 if ( !footNoteSettings.isNull() )
00112 m_footNoteCounter.load( footNoteSettings );
00113 QDomElement endNoteSettings = elem.namedItem( "ENDNOTESETTING" ).toElement();
00114 if ( !endNoteSettings.isNull() )
00115 m_endNoteCounter.load( endNoteSettings );
00116 }
00117
00118 KWVariableCollection::KWVariableCollection(KWVariableSettings *_setting, KoVariableFormatCollection* coll)
00119 : KoVariableCollection(_setting, coll)
00120 {
00121 }
00122
00123 KoVariable* KWVariableCollection::loadOasisField( KoTextDocument* textdoc, const QDomElement& tag, KoOasisContext& context )
00124 {
00125 const QString localName( tag.localName() );
00126 const bool isTextNS = tag.namespaceURI() == KoXmlNS::text;
00127 if ( isTextNS )
00128 {
00129
00130 if ( localName == "note" )
00131 {
00132 QString key = "STRING";
00133 int type = VT_FOOTNOTE;
00134 return loadOasisFieldCreateVariable( textdoc, tag, context, key, type );
00135 }
00136 else if ( localName == "table-count" ||
00137 localName == "object-count" ||
00138 localName == "picture-count" ||
00139 localName == "paragraph-count" ||
00140 localName == "word-count" ||
00141 localName == "character-count" ||
00142 localName == "sentence-count" ||
00143 localName == "line-count" ||
00144 localName == "frame-count" ||
00145 localName == "non-whitespace-character-count" ||
00146 localName == "syllable-count")
00147 {
00148 QString key = "NUMBER";
00149 int type = VT_STATISTIC;
00150 return loadOasisFieldCreateVariable( textdoc, tag, context, key, type );
00151 }
00152 else
00153 return KoVariableCollection::loadOasisField( textdoc, tag, context );
00154 }
00155 else
00156 return KoVariableCollection::loadOasisField( textdoc, tag, context );
00157 }
00158
00159 KoVariable *KWVariableCollection::createVariable( int type, short int subtype, KoVariableFormatCollection * coll, KoVariableFormat *varFormat,KoTextDocument *textdoc, KoDocument * doc, int _correct,bool _forceDefaultFormat, bool loadFootNote )
00160 {
00161 KWDocument *m_doc = static_cast<KWDocument *>(doc);
00162 KoVariable * var = 0L;
00163 switch(type) {
00164 case VT_PGNUM:
00165 if ( !varFormat )
00166 varFormat = (subtype == KoPageVariable::VST_CURRENT_SECTION) ? coll->format("STRING") : coll->format("NUMBER");
00167 var = new KWPgNumVariable( textdoc, subtype, varFormat, this, m_doc );
00168 break;
00169 case VT_MAILMERGE:
00170 var = new KWMailMergeVariable( textdoc, QString::null, coll->format("STRING"), this, m_doc );
00171 break;
00172 case VT_FOOTNOTE:
00173 if ( !loadFootNote )
00174 return 0L;
00175 if ( !varFormat )
00176 varFormat = coll->format("STRING");
00177 var = new KWFootNoteVariable( textdoc, varFormat, this, m_doc );
00178 break;
00179 case VT_STATISTIC:
00180 if ( !varFormat )
00181 varFormat = coll->format("NUMBER");
00182 var = new KWStatisticVariable( textdoc, subtype, varFormat, this, m_doc );
00183 break;
00184 default:
00185 return KoVariableCollection::createVariable( type, subtype, coll, varFormat, textdoc, doc, _correct, _forceDefaultFormat );
00186 }
00187 return var;
00188 }
00189
00190
00191
00192
00193 KWPgNumVariable::KWPgNumVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat ,KoVariableCollection *_varColl, KWDocument *doc )
00194 : KoPageVariable( textdoc, subtype, varFormat ,_varColl ), m_doc(doc)
00195 {
00196 }
00197
00198 void KWPgNumVariable::recalc()
00199 {
00200 if ( !m_doc->layoutViewMode()->hasPages() )
00201 {
00202
00203
00204 resize();
00205 return;
00206 }
00207
00208 if ( m_subtype == VST_PGNUM_TOTAL )
00209 {
00210 m_varValue = QVariant(m_doc->pageCount()+m_varColl->variableSetting()->startingPageNumber()-1);
00211 resize();
00212 }
00213
00214
00215 if ( width == -1 )
00216 width = 0;
00217 }
00218
00219 QString KWPgNumVariable::text(bool realValue)
00220 {
00221 if (m_varColl->variableSetting()->displayFieldCode()&& !realValue)
00222 return fieldCode();
00223
00224 else if ( m_subtype != VST_CURRENT_SECTION && !m_doc->layoutViewMode()->hasPages() && !realValue)
00225 return fieldCode();
00226 else
00227 return m_varFormat->convert( m_varValue );
00228 }
00229
00230
00231
00232
00233 KWMailMergeVariable::KWMailMergeVariable( KoTextDocument *textdoc, const QString &name, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc )
00234 : KoMailMergeVariable( textdoc, name, varFormat,_varColl ), m_doc(doc)
00235 {
00236 }
00237
00238 QString KWMailMergeVariable::value() const
00239 {
00240 return m_doc->mailMergeDataBase()->getValue( m_varValue.toString() );
00241 }
00242
00243 QString KWMailMergeVariable::text(bool realValue)
00244 {
00245 if (m_varColl->variableSetting()->displayFieldCode()&& !realValue)
00246 return fieldCode();
00247
00248 QString v = value();
00249 if ( m_doc->mailMergeDataBase()->isSampleRecord() )
00250 return "<" + v + ">";
00251 return v;
00252 }
00253
00254 void KWMailMergeVariable::recalc()
00255 {
00256 resize();
00257 }
00258
00260
00261 KWFootNoteVariable::KWFootNoteVariable( KoTextDocument *textdoc, KoVariableFormat *varFormat, KoVariableCollection *varColl, KWDocument *doc )
00262 : KoVariable( textdoc, varFormat, varColl ),
00263 m_doc(doc),
00264 m_frameset( 0L ),
00265 m_numberingType( Auto ),
00266 m_num( -1 ),
00267 m_numDisplay( -1 )
00268 {
00269 m_varValue = QVariant( QString::null );
00270 }
00271
00272 void KWFootNoteVariable::setNumberingType( Numbering _type )
00273 {
00274 m_numberingType = _type;
00275
00276 setVariableFormat(m_doc->variableFormatCollection()->format("STRING"));
00277 }
00278
00279 void KWFootNoteVariable::loadOasis( const QDomElement& footNoteTag, KoOasisContext& context )
00280 {
00281
00282
00283 const QString id = footNoteTag.attributeNS( KoXmlNS::text, "id", QString::null );
00284
00285 if ( footNoteTag.hasAttributeNS( KoXmlNS::text, "note-class" ) )
00286 {
00287 const QString str = footNoteTag.attributeNS( KoXmlNS::text, "note-class", QString::null );
00288 if ( str == "footnote" )
00289 m_noteType = FootNote;
00290 else if ( str == "endnote" )
00291 m_noteType = EndNote;
00292 else {
00293 kdWarning()<<" Unknown footnote type: '" << str << "'" << endl;
00294 m_noteType = FootNote;
00295 }
00296 }
00297
00298 QDomElement element;
00299 QDomElement bodyElement;
00300 forEachElement( element, footNoteTag )
00301 {
00302 if ( element.namespaceURI() != KoXmlNS::text )
00303 continue;
00304
00305 const QString localName = element.localName();
00306 if( localName == "note-citation" )
00307 {
00308 if ( element.hasAttributeNS( KoXmlNS::text, "label" ) )
00309 m_numberingType = Manual;
00310 else
00311 m_numberingType = Auto;
00312 if ( m_numberingType == Auto )
00313 {
00314
00315 m_numDisplay = element.text().toInt();
00316 formatedNote();
00317 }
00318 else
00319 {
00320
00321 m_varValue = QVariant( element.text() );
00322 }
00323 } else if ( localName == "note-body" ) {
00324 bodyElement = element;
00325 }
00326 }
00327 Q_ASSERT( !bodyElement.isNull() );
00328
00329 Q_ASSERT( !m_frameset );
00330 m_frameset = new KWFootNoteFrameSet( m_doc, id );
00331 m_frameset->setFrameSetInfo( KWFrameSet::FI_FOOTNOTE );
00332
00333 m_frameset->setFootNoteVariable( this );
00334 m_frameset->createInitialFrame( 0 );
00335 m_doc->addFrameSet( m_frameset );
00336
00337
00338 m_frameset->loadOasisContent( bodyElement, context );
00339 }
00340
00341 void KWFootNoteVariable::saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const
00342 {
00343
00344
00345
00346 writer.startElement( "text:note" );
00347 writer.addAttribute( "text:id",m_frameset->name() );
00348 writer.addAttribute( "text:note-class", m_noteType == FootNote ? "footnote" : "endnote" );
00349
00350 writer.startElement( "text:note-citation" );
00351 if ( m_numberingType == Auto )
00352 writer.addTextNode( QString( "%1" ).arg( m_numDisplay ) );
00353 else
00354 {
00355 writer.addAttribute( "text:label", m_varValue.toString() );
00356 writer.addTextNode(m_varValue.toString() );
00357 }
00358 writer.endElement();
00359
00360 writer.startElement( "text:note-body" );
00361
00362 m_frameset->saveOasisContent( writer, context );
00363 writer.endElement();
00364
00365 writer.endElement();
00366 }
00367
00368 void KWFootNoteVariable::saveVariable( QDomElement &parentElem )
00369 {
00370 QDomElement footnoteElem = parentElem.ownerDocument().createElement( "FOOTNOTE" );
00371 parentElem.appendChild( footnoteElem );
00372
00373 if ( m_numberingType == Auto )
00374 footnoteElem.setAttribute( "value", m_numDisplay );
00375 else
00376 footnoteElem.setAttribute( "value", m_varValue.toString() );
00377 footnoteElem.setAttribute( "notetype", m_noteType == FootNote ? "footnote" : "endnote" );
00378 footnoteElem.setAttribute( "numberingtype", m_numberingType == Auto ? "auto" : "manual" );
00379 Q_ASSERT( m_frameset );
00380 if( m_frameset )
00381 footnoteElem.setAttribute( "frameset", m_frameset->name() );
00382 }
00383
00384 void KWFootNoteVariable::load( QDomElement &elem )
00385 {
00386 KoVariable::load( elem );
00387 QDomElement footnoteElem = elem.namedItem( "FOOTNOTE" ).toElement();
00388 if (!footnoteElem.isNull())
00389 {
00390
00391 QString str = footnoteElem.attribute("notetype").lower();
00392 if ( str == "footnote" )
00393 m_noteType = FootNote;
00394 else if ( str == "endnote" )
00395 m_noteType = EndNote;
00396 else
00397 kdWarning() << "Unknown footnote type: '" << str << "'" << endl;
00398
00399 str = footnoteElem.attribute("numberingtype").lower();
00400 if ( str == "auto" )
00401 m_numberingType = Auto;
00402 else if ( str == "manual")
00403 m_numberingType = Manual;
00404 else
00405 kdWarning() << "Unknown footnote numbering: '" << str << "'" << endl;
00406
00407 if ( m_numberingType == Auto )
00408 {
00409 m_numDisplay = footnoteElem.attribute("value").toInt();
00410 formatedNote();
00411 }
00412 else
00413 m_varValue = QVariant(footnoteElem.attribute("value"));
00414
00415 str = footnoteElem.attribute("frameset");
00416 m_doc->addFootNoteRequest( str, this );
00417 }
00418 }
00419
00420 void KWFootNoteVariable::formatedNote()
00421 {
00422 if ( m_numberingType == Auto )
00423 {
00424 m_varValue = QVariant(applyStyle());
00425 }
00426 }
00427
00428 QString KWFootNoteVariable::applyStyle()
00429 {
00430 KWVariableSettings* settings = static_cast<KWVariableSettings*>(m_varColl->variableSetting());
00431 KoParagCounter tmpCounter = (m_noteType == FootNote) ? settings->footNoteCounter() : settings->endNoteCounter();
00432
00433 QString tmp;
00434 int val = m_numDisplay + tmpCounter.startNumber()-1;
00435 Q_ASSERT( val >= 0 );
00436 if ( val < 0 )
00437 return i18n("ERROR");
00438 switch ( tmpCounter.style() )
00439 {
00440 case KoParagCounter::STYLE_NUM:
00441 tmp.setNum( val );
00442 break;
00443 case KoParagCounter::STYLE_ALPHAB_L:
00444 tmp=KoParagCounter::makeAlphaLowerNumber( val );
00445 break;
00446 case KoParagCounter::STYLE_ALPHAB_U:
00447 tmp=KoParagCounter::makeAlphaUpperNumber( val );
00448 break;
00449 case KoParagCounter::STYLE_ROM_NUM_L:
00450 tmp = KoParagCounter::makeRomanNumber( val ).lower();
00451 break;
00452 case KoParagCounter::STYLE_ROM_NUM_U:
00453 tmp = KoParagCounter::makeRomanNumber( val ).upper();
00454 break;
00455 case KoParagCounter::STYLE_CUSTOMBULLET:
00456
00457 tmp = tmpCounter.customBulletCharacter();
00458 break;
00459 default:
00460 tmp.setNum( val );
00461 break;
00462 }
00463
00464 tmp.prepend( tmpCounter.prefix() );
00465 tmp.append( tmpCounter.suffix() );
00466 return tmp;
00467 }
00468
00469 QString KWFootNoteVariable::text(bool realValue)
00470 {
00471 if (m_varColl->variableSetting()->displayFieldCode()&& !realValue)
00472 return fieldCode();
00473 return m_varFormat->convert( m_varValue );
00474 }
00475
00476 void KWFootNoteVariable::setNumDisplay( int val )
00477 {
00478 m_numDisplay = val;
00479 if ( val != -1 )
00480 formatedNote();
00481 }
00482
00483 QString KWFootNoteVariable::fieldCode()
00484 {
00485 return (noteType()==FootNote) ?i18n("Footnote"):i18n("Endnote");
00486 }
00487
00488 void KWFootNoteVariable::drawCustomItem( QPainter* p, int x, int y, int wpix, int hpix, int ascentpix, int , int , int , int , const QColorGroup& cg, bool selected, int _offset, bool drawingShadow )
00489 {
00490 KoTextFormat * fmt = format();
00491 KoTextZoomHandler * zh = textDocument()->paintingZoomHandler();
00492
00493
00494 QFont font( fmt->screenFont( zh ) );
00495 int pointSize = ( ( font.pointSize() * 2 ) / 3 );
00496 font.setPointSize( pointSize );
00497
00498 int offset = _offset;
00499 if ( offset == 0 )
00500 {
00501 int h = zh->layoutUnitToPixelY( height );
00502 offset = -( h - QFontMetrics(font).height() );
00503 }
00504
00505 QColor textColor( fmt->color() );
00506 drawCustomItemHelper( p, x, y, wpix, hpix, ascentpix, cg, selected, offset, fmt, font, textColor, drawingShadow );
00507 }
00508
00509 void KWFootNoteVariable::finalize()
00510 {
00511 Q_ASSERT( m_frameset );
00512 if (!m_frameset )
00513 return;
00514 Q_ASSERT( !m_frameset->isDeleted() );
00515 if ( m_frameset->isDeleted() )
00516 return;
00517
00518
00519
00520 int pageNum = this->pageNum();
00521 if ( pageNum == -1 )
00522 return;
00523
00524 KWFrame* footNoteFrame = m_frameset->frame( 0 );
00525 int framePage = footNoteFrame->pageNumber();
00526 if ( framePage != pageNum )
00527 {
00528
00529 KWTextFrameSet * fs = static_cast<KWTextDocument *>(textDocument())->textFrameSet();
00530 fs->textObject()->abortFormatting();
00531
00532
00533
00534 m_doc->delayedRecalcFrames( QMIN( pageNum, framePage ) );
00535 m_doc->delayedRepaintAllViews();
00536 }
00537 }
00538
00539 void KWFootNoteVariable::resize()
00540 {
00541 if ( m_deleted )
00542 return;
00543 KoTextFormat *fmt = format();
00544 QFont font( fmt->refFont() );
00545 if ( fmt->vAlign() == KoTextFormat::AlignNormal )
00546 {
00547 int pointSize = ( ( font.pointSize() * 2 ) / 3 );
00548 font.setPointSize( pointSize );
00549 }
00550 QFontMetrics fm( font );
00551 QString txt = text();
00552 width = 0;
00553 for ( int i = 0 ; i < (int)txt.length() ; ++i )
00554 width += fm.charWidth( txt, i );
00555
00556 width = qRound( KoTextZoomHandler::ptToLayoutUnitPt( width ) );
00557 height = fmt->height();
00558 m_ascent = fmt->ascent();
00559
00560 }
00561
00562 void KWFootNoteVariable::setDeleted( bool del )
00563 {
00564 kdDebug() << "KWFootNoteVariable::setDeleted " << del << endl;
00565 if ( del )
00566 {
00567 Q_ASSERT( m_frameset );
00568 if ( m_frameset ) {
00569 m_frameset->deleteAllFrames();
00570 m_frameset->setVisible( false );
00571 }
00572 }
00573 else
00574 {
00575 Q_ASSERT( m_frameset );
00576 if ( m_frameset ) {
00577 kdDebug() << "Making frameset " << m_frameset << " visible" << endl;
00578 m_frameset->setVisible( true );
00579 if ( m_frameset->isDeleted() )
00580 m_frameset->createInitialFrame( 0 );
00581 Q_ASSERT( m_frameset->isVisible() );
00582 }
00583 }
00584
00585
00586
00587
00588
00589
00590
00591 KWTextFrameSet * textfs = static_cast<KWTextDocument *>(textDocument())->textFrameSet();
00592 textfs->renumberFootNotes();
00593
00594 m_doc->recalcFrames();
00595
00596 if (!del)
00597 m_frameset->layout();
00598 KoVariable::setDeleted( del );
00599
00600 m_doc->delayedRepaintAllViews();
00601 }
00602
00603 int KWFootNoteVariable::pageNum() const
00604 {
00605 int page = m_doc->pageManager()->pageNumber(varY());
00606 Q_ASSERT( page <= m_doc->lastPage() );
00607 return page;
00608 }
00609
00610 double KWFootNoteVariable::varY() const
00611 {
00612
00613 int paragy = paragraph()->rect().y();
00614 KWTextFrameSet * fs = static_cast<KWTextDocument *>(textDocument())->textFrameSet();
00615 if ( !fs->hasFramesInPageArray() )
00616 {
00617 kdDebug(32001) << "KWFootNoteVariable::varY too early, no updateFrames yet" << endl;
00618 return 0;
00619 }
00620
00621
00622
00623
00624
00625
00626 KoPoint dPoint;
00627
00628 KWFrame* containingFrame = fs->internalToDocument( QPoint( x(), paragy + y() + height ), dPoint );
00629 if ( containingFrame )
00630 {
00631
00632 double varY = dPoint.y();
00633
00634
00635 return varY;
00636 } else
00637 {
00638
00639
00640 return 0;
00641 }
00642 }
00643
00644
00645 KWStatisticVariable::KWStatisticVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc )
00646 : KoStatisticVariable( textdoc, subtype, varFormat, _varColl ),
00647 m_doc(doc)
00648 {
00649 }
00650
00651 void KWStatisticVariable::recalc()
00652 {
00653 int nb = 0;
00654 ulong charsWithSpace = 0L;
00655 ulong charsWithoutSpace = 0L;
00656 ulong words = 0L;
00657 ulong sentences = 0L;
00658 ulong lines = 0L;
00659 ulong syllables = 0L;
00660 bool frameInfo = ( m_subtype == VST_STATISTIC_NB_WORD ||
00661 m_subtype == VST_STATISTIC_NB_SENTENCE ||
00662 m_subtype == VST_STATISTIC_NB_LINES ||
00663 m_subtype == VST_STATISTIC_NB_CHARACTERE);
00664 QPtrListIterator<KWFrameSet> framesetIt( m_doc->framesetsIterator() );
00665
00666 for ( framesetIt.toFirst(); framesetIt.current(); ++framesetIt )
00667 {
00668 KWFrameSet *frameSet = framesetIt.current();
00669 if ( frameSet->isVisible() )
00670 {
00671 if ( m_subtype == VST_STATISTIC_NB_FRAME )
00672 {
00673 ++nb;
00674 }
00675 else if( m_subtype == VST_STATISTIC_NB_PICTURE && frameSet->type() == FT_PICTURE )
00676 {
00677 ++nb;
00678 }
00679 else if( m_subtype == VST_STATISTIC_NB_TABLE && frameSet->type() == FT_TABLE )
00680 {
00681 ++nb;
00682 }
00683 else if( m_subtype == VST_STATISTIC_NB_EMBEDDED && frameSet->type() == FT_PART )
00684 {
00685 ++nb;
00686 }
00687 if ( frameInfo
00688 && (frameSet->frameSetInfo() == KWFrameSet::FI_FOOTNOTE || frameSet->frameSetInfo() == KWFrameSet::FI_BODY)
00689 && frameSet->isVisible() )
00690 {
00691 frameSet->statistics( 0L, charsWithSpace, charsWithoutSpace,
00692 words, sentences, syllables, lines, false );
00693 }
00694 }
00695 if ( frameInfo )
00696 {
00697 if( m_subtype == VST_STATISTIC_NB_WORD )
00698 {
00699 nb = words;
00700 }
00701 else if( m_subtype == VST_STATISTIC_NB_SENTENCE )
00702 {
00703 nb = sentences;
00704 }
00705 else if( m_subtype == VST_STATISTIC_NB_LINES )
00706 {
00707 nb = lines;
00708 }
00709 else if ( m_subtype == VST_STATISTIC_NB_CHARACTERE )
00710 {
00711 nb = charsWithSpace;
00712 }
00713 else if ( m_subtype == VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE )
00714 {
00715 nb = charsWithoutSpace;
00716 }
00717 else if ( m_subtype == VST_STATISTIC_NB_SYLLABLE )
00718 {
00719 nb = syllables;
00720 }
00721 else
00722 nb = 0;
00723 }
00724 }
00725 m_varValue = QVariant(nb);
00726 resize();
00727 if ( width == -1 )
00728 width = 0;
00729 }
00730
00731 QString KWStatisticVariable::text(bool realValue)
00732 {
00733 if ( m_varColl->variableSetting()->displayFieldCode() && !realValue )
00734 return fieldCode();
00735 else
00736 return m_varFormat->convert( m_varValue );
00737 }