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 if(! m_frameset) return;
00344
00345
00346
00347
00348 writer.startElement( "text:note" );
00349 writer.addAttribute( "text:id",m_frameset->name() );
00350 writer.addAttribute( "text:note-class", m_noteType == FootNote ? "footnote" : "endnote" );
00351
00352 writer.startElement( "text:note-citation" );
00353 if ( m_numberingType == Auto )
00354 writer.addTextNode( QString( "%1" ).arg( m_numDisplay ) );
00355 else
00356 {
00357 writer.addAttribute( "text:label", m_varValue.toString() );
00358 writer.addTextNode(m_varValue.toString() );
00359 }
00360 writer.endElement();
00361
00362 writer.startElement( "text:note-body" );
00363
00364 m_frameset->saveOasisContent( writer, context );
00365 writer.endElement();
00366
00367 writer.endElement();
00368 }
00369
00370 void KWFootNoteVariable::saveVariable( QDomElement &parentElem )
00371 {
00372 QDomElement footnoteElem = parentElem.ownerDocument().createElement( "FOOTNOTE" );
00373 parentElem.appendChild( footnoteElem );
00374
00375 if ( m_numberingType == Auto )
00376 footnoteElem.setAttribute( "value", m_numDisplay );
00377 else
00378 footnoteElem.setAttribute( "value", m_varValue.toString() );
00379 footnoteElem.setAttribute( "notetype", m_noteType == FootNote ? "footnote" : "endnote" );
00380 footnoteElem.setAttribute( "numberingtype", m_numberingType == Auto ? "auto" : "manual" );
00381 Q_ASSERT( m_frameset );
00382 if( m_frameset )
00383 footnoteElem.setAttribute( "frameset", m_frameset->name() );
00384 }
00385
00386 void KWFootNoteVariable::load( QDomElement &elem )
00387 {
00388 KoVariable::load( elem );
00389 QDomElement footnoteElem = elem.namedItem( "FOOTNOTE" ).toElement();
00390 if (!footnoteElem.isNull())
00391 {
00392
00393 QString str = footnoteElem.attribute("notetype").lower();
00394 if ( str == "footnote" )
00395 m_noteType = FootNote;
00396 else if ( str == "endnote" )
00397 m_noteType = EndNote;
00398 else
00399 kdWarning() << "Unknown footnote type: '" << str << "'" << endl;
00400
00401 str = footnoteElem.attribute("numberingtype").lower();
00402 if ( str == "auto" )
00403 m_numberingType = Auto;
00404 else if ( str == "manual")
00405 m_numberingType = Manual;
00406 else
00407 kdWarning() << "Unknown footnote numbering: '" << str << "'" << endl;
00408
00409 if ( m_numberingType == Auto )
00410 {
00411 m_numDisplay = footnoteElem.attribute("value").toInt();
00412 formatedNote();
00413 }
00414 else
00415 m_varValue = QVariant(footnoteElem.attribute("value"));
00416
00417 str = footnoteElem.attribute("frameset");
00418 m_doc->addFootNoteRequest( str, this );
00419 }
00420 }
00421
00422 void KWFootNoteVariable::formatedNote()
00423 {
00424 if ( m_numberingType == Auto )
00425 {
00426 m_varValue = QVariant(applyStyle());
00427 }
00428 }
00429
00430 QString KWFootNoteVariable::applyStyle()
00431 {
00432 KWVariableSettings* settings = static_cast<KWVariableSettings*>(m_varColl->variableSetting());
00433 KoParagCounter tmpCounter = (m_noteType == FootNote) ? settings->footNoteCounter() : settings->endNoteCounter();
00434
00435 QString tmp;
00436 int val = m_numDisplay + tmpCounter.startNumber()-1;
00437 Q_ASSERT( val >= 0 );
00438 if ( val < 0 )
00439 return i18n("ERROR");
00440 switch ( tmpCounter.style() )
00441 {
00442 case KoParagCounter::STYLE_NUM:
00443 tmp.setNum( val );
00444 break;
00445 case KoParagCounter::STYLE_ALPHAB_L:
00446 tmp=KoParagCounter::makeAlphaLowerNumber( val );
00447 break;
00448 case KoParagCounter::STYLE_ALPHAB_U:
00449 tmp=KoParagCounter::makeAlphaUpperNumber( val );
00450 break;
00451 case KoParagCounter::STYLE_ROM_NUM_L:
00452 tmp = KoParagCounter::makeRomanNumber( val ).lower();
00453 break;
00454 case KoParagCounter::STYLE_ROM_NUM_U:
00455 tmp = KoParagCounter::makeRomanNumber( val ).upper();
00456 break;
00457 case KoParagCounter::STYLE_CUSTOMBULLET:
00458
00459 tmp = tmpCounter.customBulletCharacter();
00460 break;
00461 default:
00462 tmp.setNum( val );
00463 break;
00464 }
00465
00466 tmp.prepend( tmpCounter.prefix() );
00467 tmp.append( tmpCounter.suffix() );
00468 return tmp;
00469 }
00470
00471 QString KWFootNoteVariable::text(bool realValue)
00472 {
00473 if (m_varColl->variableSetting()->displayFieldCode()&& !realValue)
00474 return fieldCode();
00475 return m_varFormat->convert( m_varValue );
00476 }
00477
00478 void KWFootNoteVariable::setNumDisplay( int val )
00479 {
00480 m_numDisplay = val;
00481 if ( val != -1 )
00482 formatedNote();
00483 }
00484
00485 QString KWFootNoteVariable::fieldCode()
00486 {
00487 return (noteType()==FootNote) ?i18n("Footnote"):i18n("Endnote");
00488 }
00489
00490 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 )
00491 {
00492 KoTextFormat * fmt = format();
00493 KoTextZoomHandler * zh = textDocument()->paintingZoomHandler();
00494
00495
00496 QFont font( fmt->screenFont( zh ) );
00497 int pointSize = ( ( font.pointSize() * 2 ) / 3 );
00498 font.setPointSize( pointSize );
00499
00500 int offset = _offset;
00501 if ( offset == 0 )
00502 {
00503 int h = zh->layoutUnitToPixelY( height );
00504 offset = -( h - QFontMetrics(font).height() );
00505 }
00506
00507 QColor textColor( fmt->color() );
00508 drawCustomItemHelper( p, x, y, wpix, hpix, ascentpix, cg, selected, offset, fmt, font, textColor, drawingShadow );
00509 }
00510
00511 void KWFootNoteVariable::finalize()
00512 {
00513 Q_ASSERT( m_frameset );
00514 if (!m_frameset )
00515 return;
00516 Q_ASSERT( !m_frameset->isDeleted() );
00517 if ( m_frameset->isDeleted() )
00518 return;
00519
00520
00521
00522 int pageNum = this->pageNum();
00523 if ( pageNum == -1 )
00524 return;
00525
00526 KWFrame* footNoteFrame = m_frameset->frame( 0 );
00527 int framePage = footNoteFrame->pageNumber();
00528 if ( framePage != pageNum )
00529 {
00530
00531 KWTextFrameSet * fs = static_cast<KWTextDocument *>(textDocument())->textFrameSet();
00532 fs->textObject()->abortFormatting();
00533
00534
00535
00536 m_doc->delayedRecalcFrames( QMIN( pageNum, framePage ) );
00537 m_doc->delayedRepaintAllViews();
00538 }
00539 }
00540
00541 void KWFootNoteVariable::resize()
00542 {
00543 if ( m_deleted )
00544 return;
00545 KoTextFormat *fmt = format();
00546 QFont font( fmt->refFont() );
00547 if ( fmt->vAlign() == KoTextFormat::AlignNormal )
00548 {
00549 int pointSize = ( ( font.pointSize() * 2 ) / 3 );
00550 font.setPointSize( pointSize );
00551 }
00552 QFontMetrics fm( font );
00553 QString txt = text();
00554 width = 0;
00555 for ( int i = 0 ; i < (int)txt.length() ; ++i )
00556 width += fm.charWidth( txt, i );
00557
00558 width = qRound( KoTextZoomHandler::ptToLayoutUnitPt( width ) );
00559 height = fmt->height();
00560 m_ascent = fmt->ascent();
00561
00562 }
00563
00564 void KWFootNoteVariable::setDeleted( bool del )
00565 {
00566 kdDebug() << "KWFootNoteVariable::setDeleted " << del << endl;
00567 if ( del )
00568 {
00569 Q_ASSERT( m_frameset );
00570 if ( m_frameset ) {
00571 m_frameset->deleteAllFrames();
00572 m_frameset->setVisible( false );
00573 }
00574 }
00575 else
00576 {
00577 Q_ASSERT( m_frameset );
00578 if ( m_frameset ) {
00579 kdDebug() << "Making frameset " << m_frameset << " visible" << endl;
00580 m_frameset->setVisible( true );
00581 if ( m_frameset->isDeleted() )
00582 m_frameset->createInitialFrame( 0 );
00583 Q_ASSERT( m_frameset->isVisible() );
00584 }
00585 }
00586
00587
00588
00589
00590
00591
00592
00593 KWTextFrameSet * textfs = static_cast<KWTextDocument *>(textDocument())->textFrameSet();
00594 textfs->renumberFootNotes();
00595
00596 m_doc->recalcFrames();
00597
00598 if (!del)
00599 m_frameset->layout();
00600 KoVariable::setDeleted( del );
00601
00602 m_doc->delayedRepaintAllViews();
00603 }
00604
00605 int KWFootNoteVariable::pageNum() const
00606 {
00607 int page = m_doc->pageManager()->pageNumber(varY());
00608 Q_ASSERT( page <= m_doc->lastPage() );
00609 return page;
00610 }
00611
00612 double KWFootNoteVariable::varY() const
00613 {
00614
00615 int paragy = paragraph()->rect().y();
00616 KWTextFrameSet * fs = static_cast<KWTextDocument *>(textDocument())->textFrameSet();
00617 if ( !fs->hasFramesInPageArray() )
00618 {
00619 kdDebug(32001) << "KWFootNoteVariable::varY too early, no updateFrames yet" << endl;
00620 return 0;
00621 }
00622
00623
00624
00625
00626
00627
00628 KoPoint dPoint;
00629
00630 KWFrame* containingFrame = fs->internalToDocument( QPoint( x(), paragy + y() + height ), dPoint );
00631 if ( containingFrame )
00632 {
00633
00634 double varY = dPoint.y();
00635
00636
00637 return varY;
00638 } else
00639 {
00640
00641
00642 return 0;
00643 }
00644 }
00645
00646
00647 KWStatisticVariable::KWStatisticVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc )
00648 : KoStatisticVariable( textdoc, subtype, varFormat, _varColl ),
00649 m_doc(doc)
00650 {
00651 }
00652
00653 void KWStatisticVariable::recalc()
00654 {
00655 int nb = 0;
00656 ulong charsWithSpace = 0L;
00657 ulong charsWithoutSpace = 0L;
00658 ulong words = 0L;
00659 ulong sentences = 0L;
00660 ulong lines = 0L;
00661 ulong syllables = 0L;
00662 bool frameInfo = ( m_subtype == VST_STATISTIC_NB_WORD ||
00663 m_subtype == VST_STATISTIC_NB_SENTENCE ||
00664 m_subtype == VST_STATISTIC_NB_LINES ||
00665 m_subtype == VST_STATISTIC_NB_CHARACTERE);
00666 QPtrListIterator<KWFrameSet> framesetIt( m_doc->framesetsIterator() );
00667
00668 for ( framesetIt.toFirst(); framesetIt.current(); ++framesetIt )
00669 {
00670 KWFrameSet *frameSet = framesetIt.current();
00671 if ( frameSet->isVisible() )
00672 {
00673 if ( m_subtype == VST_STATISTIC_NB_FRAME )
00674 {
00675 ++nb;
00676 }
00677 else if( m_subtype == VST_STATISTIC_NB_PICTURE && frameSet->type() == FT_PICTURE )
00678 {
00679 ++nb;
00680 }
00681 else if( m_subtype == VST_STATISTIC_NB_TABLE && frameSet->type() == FT_TABLE )
00682 {
00683 ++nb;
00684 }
00685 else if( m_subtype == VST_STATISTIC_NB_EMBEDDED && frameSet->type() == FT_PART )
00686 {
00687 ++nb;
00688 }
00689 if ( frameInfo
00690 && (frameSet->frameSetInfo() == KWFrameSet::FI_FOOTNOTE || frameSet->frameSetInfo() == KWFrameSet::FI_BODY)
00691 && frameSet->isVisible() )
00692 {
00693 frameSet->statistics( 0L, charsWithSpace, charsWithoutSpace,
00694 words, sentences, syllables, lines, false );
00695 }
00696 }
00697 if ( frameInfo )
00698 {
00699 if( m_subtype == VST_STATISTIC_NB_WORD )
00700 {
00701 nb = words;
00702 }
00703 else if( m_subtype == VST_STATISTIC_NB_SENTENCE )
00704 {
00705 nb = sentences;
00706 }
00707 else if( m_subtype == VST_STATISTIC_NB_LINES )
00708 {
00709 nb = lines;
00710 }
00711 else if ( m_subtype == VST_STATISTIC_NB_CHARACTERE )
00712 {
00713 nb = charsWithSpace;
00714 }
00715 else if ( m_subtype == VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE )
00716 {
00717 nb = charsWithoutSpace;
00718 }
00719 else if ( m_subtype == VST_STATISTIC_NB_SYLLABLE )
00720 {
00721 nb = syllables;
00722 }
00723 else
00724 nb = 0;
00725 }
00726 }
00727 m_varValue = QVariant(nb);
00728 resize();
00729 if ( width == -1 )
00730 width = 0;
00731 }
00732
00733 QString KWStatisticVariable::text(bool realValue)
00734 {
00735 if ( m_varColl->variableSetting()->displayFieldCode() && !realValue )
00736 return fieldCode();
00737 else
00738 return m_varFormat->convert( m_varValue );
00739 }