21#include "KoVariable.h"
22#include "KoVariable.moc"
23#include "KoTextZoomHandler.h"
24#include "TimeFormatWidget.h"
25#include "DateFormatWidget.h"
26#include "KoTextCommand.h"
27#include "KoTextObject.h"
28#include "KoTextParag.h"
29#include "KoOasisContext.h"
30#include <KoOasisSettings.h>
32#include <KoDocumentInfo.h>
33#include <KoOasisStyles.h>
34#include <KoXmlWriter.h>
35#include <KoDocument.h>
42#include <kdialogbase.h>
44#include <tdeversion.h>
45#include <tdeinstance.h>
46#include <kcalendarsystem.h>
47#include <tdeaboutdata.h>
49#include <tqstringlist.h>
50#include <tqcombobox.h>
51#include <tqvaluelist.h>
53#include <tqradiobutton.h>
55#include "IsoDuration.h"
57class KoVariableSettings::KoVariableSettingPrivate
60 KoVariableSettingPrivate()
62 m_lastPrintingDate.setTime_t(0);
64 TQDateTime m_lastPrintingDate;
65 TQDateTime m_creationDate;
66 TQDateTime m_modificationDate;
70KoVariableSettings::KoVariableSettings()
72 d =
new KoVariableSettingPrivate;
73 m_startingPageNumber = 1;
75 m_displayComment =
true;
76 m_underlineLink =
true;
77 m_displayFieldCode =
false;
80KoVariableSettings::~KoVariableSettings()
86TQDateTime KoVariableSettings::lastPrintingDate()
const
88 return d->m_lastPrintingDate;
91void KoVariableSettings::setLastPrintingDate(
const TQDateTime & _date)
93 d->m_lastPrintingDate = _date;
96TQDateTime KoVariableSettings::creationDate()
const
98 return d->m_creationDate;
101void KoVariableSettings::setCreationDate(
const TQDateTime & _date )
103 d->m_creationDate = _date;
106TQDateTime KoVariableSettings::modificationDate()
const
108 return d->m_modificationDate;
111void KoVariableSettings::setModificationDate(
const TQDateTime & _date)
113 d->m_modificationDate = _date;
116void KoVariableSettings::saveOasis(
KoXmlWriter &settingsWriter )
const
119 settingsWriter.
addAttribute(
"config:name",
"configuration-variable-settings");
121 settingsWriter.
addConfigItem(
"underlinelink", m_underlineLink);
122 settingsWriter.
addConfigItem(
"displaycomment", m_displayComment);
123 settingsWriter.
addConfigItem(
"displayfieldcode", m_displayFieldCode);
127 if ( d->m_lastPrintingDate.isValid())
128 settingsWriter.
addConfigItem(
"lastPrintingDate", d->m_lastPrintingDate.toString(TQt::ISODate));
130 if ( d->m_creationDate.isValid())
131 settingsWriter.
addConfigItem(
"creationDate", d->m_creationDate.toString(TQt::ISODate));
133 if ( d->m_modificationDate.isValid())
134 settingsWriter.
addConfigItem(
"modificationDate", d->m_modificationDate.toString(TQt::ISODate));
142 if ( !configurationSettings.isNull() )
144 m_displayLink = configurationSettings.parseConfigItemBool(
"displaylink",
true );
145 m_underlineLink = configurationSettings.parseConfigItemBool(
"underlinelink",
true );
146 m_displayComment = configurationSettings.parseConfigItemBool(
"displaycomment",
true );
147 m_displayFieldCode = configurationSettings.parseConfigItemBool(
"displayfieldcode",
false );
149 TQString str = configurationSettings.parseConfigItemString(
"lastPrintingDate" );
150 if ( !str.isEmpty() )
151 d->m_lastPrintingDate = TQDateTime::fromString( str, TQt::ISODate );
153 d->m_lastPrintingDate.setTime_t(0);
155 str = configurationSettings.parseConfigItemString(
"creationDate" );
156 if ( !str.isEmpty() ) {
157 d->m_creationDate = TQDateTime::fromString( str, TQt::ISODate );
160 str = configurationSettings.parseConfigItemString(
"modificationDate" );
161 if ( !str.isEmpty() )
162 d->m_modificationDate = TQDateTime::fromString( str, TQt::ISODate );
168void KoVariableSettings::save( TQDomElement &parentElem )
170 TQDomElement elem = parentElem.ownerDocument().createElement(
"VARIABLESETTINGS" );
171 parentElem.appendChild( elem );
172 if(m_startingPageNumber!=1)
174 elem.setAttribute(
"startingPageNumber", m_startingPageNumber );
176 elem.setAttribute(
"displaylink",(
int)m_displayLink);
177 elem.setAttribute(
"underlinelink",(
int)m_underlineLink);
178 elem.setAttribute(
"displaycomment",(
int)m_displayComment);
179 elem.setAttribute(
"displayfieldcode", (
int)m_displayFieldCode);
181 if ( d->m_lastPrintingDate.isValid())
182 elem.setAttribute(
"lastPrintingDate", d->m_lastPrintingDate.toString(TQt::ISODate));
184 if ( d->m_creationDate.isValid())
185 elem.setAttribute(
"creationDate", d->m_creationDate.toString(TQt::ISODate));
187 if ( d->m_modificationDate.isValid())
188 elem.setAttribute(
"modificationDate", d->m_modificationDate.toString(TQt::ISODate));
191void KoVariableSettings::load( TQDomElement &elem )
193 TQDomElement e = elem.namedItem(
"VARIABLESETTINGS" ).toElement();
196 if(e.hasAttribute(
"startingPageNumber"))
197 m_startingPageNumber = e.attribute(
"startingPageNumber").toInt();
198 if(e.hasAttribute(
"displaylink"))
199 m_displayLink=(bool)e.attribute(
"displaylink").toInt();
200 if(e.hasAttribute(
"underlinelink"))
201 m_underlineLink=(
bool)e.attribute(
"underlinelink").toInt();
202 if(e.hasAttribute(
"displaycomment"))
203 m_displayComment=(
bool)e.attribute(
"displaycomment").toInt();
204 if (e.hasAttribute(
"displayfieldcode"))
205 m_displayFieldCode=(
bool)e.attribute(
"displayfieldcode").toInt();
207 if (e.hasAttribute(
"lastPrintingDate"))
208 d->m_lastPrintingDate = TQDateTime::fromString( e.attribute(
"lastPrintingDate" ), TQt::ISODate );
210 d->m_lastPrintingDate.setTime_t(0);
212 if (e.hasAttribute(
"creationDate")) {
213 d->m_creationDate = TQDateTime::fromString( e.attribute(
"creationDate" ), TQt::ISODate );
216 if (e.hasAttribute(
"modificationDate"))
217 d->m_modificationDate = TQDateTime::fromString( e.attribute(
"modificationDate" ), TQt::ISODate );
227 if ( data.type() != TQVariant::Date && data.type() != TQVariant::DateTime )
229 kdWarning(32500)<<
" Error in KoVariableDateFormat::convert. Value is a "
230 << data.typeName() <<
"(" << data.type() <<
")" << endl;
233 TQDateTime dateTime ( data.toDateTime() );
234 if ( !dateTime.isValid() )
235 return i18n(
"No date set");
237 if (m_strFormat.lower() ==
"locale" || m_strFormat.isEmpty())
238 return TDEGlobal::locale()->formatDate( dateTime.date(),
false );
239 else if ( m_strFormat.lower() ==
"localeshort" )
240 return TDEGlobal::locale()->formatDate( dateTime.date(),
true );
241 else if ( m_strFormat.lower() ==
"localedatetime" )
242 return TDEGlobal::locale()->formatDateTime( dateTime,
false );
243 else if ( m_strFormat.lower() ==
"localedatetimeshort" )
244 return TDEGlobal::locale()->formatDateTime( dateTime,
true );
246 TQString tmp ( dateTime.toString(m_strFormat) );
247 const int month = dateTime.date().month();
248 tmp.replace(
"PPPP", TDEGlobal::locale()->calendar()->monthNamePossessive(month,
false));
249 tmp.replace(
"PPP", TDEGlobal::locale()->calendar()->monthNamePossessive(month,
true));
255 return getKey( m_strFormat );
260 return TQCString(
"DATE") + props.utf8();
265 TQCString params(
key.mid( 4 ) );
266 if ( !params.isEmpty() )
268 if (params[0] ==
'1' || params[0] ==
'0')
269 params = params.mid(1);
270 m_strFormat = TQString::fromUtf8( params );
276TQStringList KoVariableDateFormat::staticFormatPropsList()
278 TQStringList listDateFormat;
279 listDateFormat<<
"locale";
280 listDateFormat<<
"localeshort";
281 listDateFormat<<
"localedatetime";
282 listDateFormat<<
"localedatetimeshort";
283 listDateFormat<<
"dd/MM/yy";
284 listDateFormat<<
"dd/MM/yyyy";
285 listDateFormat<<
"MMM dd,yy";
286 listDateFormat<<
"MMM dd,yyyy";
287 listDateFormat<<
"dd.MMM.yyyy";
288 listDateFormat<<
"MMMM dd, yyyy";
289 listDateFormat<<
"ddd, MMM dd,yy";
290 listDateFormat<<
"dddd, MMM dd,yy";
291 listDateFormat<<
"MM-dd";
292 listDateFormat<<
"yyyy-MM-dd";
293 listDateFormat<<
"dd/yy";
294 listDateFormat<<
"MMMM";
295 listDateFormat<<
"yyyy-MM-dd hh:mm";
296 listDateFormat<<
"dd.MMM.yyyy hh:mm";
297 listDateFormat<<
"MMM dd,yyyy h:mm AP";
298 listDateFormat<<
"yyyy-MM-ddThh:mm:ss";
299 return listDateFormat;
304TQStringList KoVariableDateFormat::staticTranslatedFormatPropsList()
306 TQStringList listDateFormat;
307 listDateFormat<<i18n(
"Locale date format");
308 listDateFormat<<i18n(
"Short locale date format");
309 listDateFormat<<i18n(
"Locale date & time format");
310 listDateFormat<<i18n(
"Short locale date & time format");
311 listDateFormat<<
"dd/MM/yy";
312 listDateFormat<<
"dd/MM/yyyy";
313 listDateFormat<<
"MMM dd,yy";
314 listDateFormat<<
"MMM dd,yyyy";
315 listDateFormat<<
"dd.MMM.yyyy";
316 listDateFormat<<
"MMMM dd, yyyy";
317 listDateFormat<<
"ddd, MMM dd,yy";
318 listDateFormat<<
"dddd, MMM dd,yy";
319 listDateFormat<<
"MM-dd";
320 listDateFormat<<
"yyyy-MM-dd";
321 listDateFormat<<
"dd/yy";
322 listDateFormat<<
"MMMM";
323 listDateFormat<<
"yyyy-MM-dd hh:mm";
324 listDateFormat<<
"dd.MMM.yyyy hh:mm";
325 listDateFormat<<
"MMM dd,yyyy h:mm AP";
326 listDateFormat<<
"yyyy-MM-ddThh:mm:ss";
327 return listDateFormat;
338 TQCString params(
key.mid( 4 ) );
339 if ( !params.isEmpty() )
340 m_strFormat = TQString::fromUtf8(params);
345 if ( time.type() != TQVariant::Time )
347 kdDebug(32500)<<
" Error in KoVariableTimeFormat::convert. Value is a "
348 << time.typeName() <<
"(" << time.type() <<
")" << endl;
352 if( m_strFormat.lower() ==
"locale" || m_strFormat.isEmpty() )
353 return TDEGlobal::locale()->formatTime( time.toTime() );
354 return time.toTime().toString(m_strFormat);
359 return getKey( m_strFormat );
364 return TQCString(
"TIME") + props.utf8();
369TQStringList KoVariableTimeFormat::staticFormatPropsList()
371 TQStringList listTimeFormat;
372 listTimeFormat<<
"locale";
373 listTimeFormat<<
"hh:mm";
374 listTimeFormat<<
"hh:mm:ss";
375 listTimeFormat<<
"hh:mm AP";
376 listTimeFormat<<
"hh:mm:ss AP";
377 listTimeFormat<<
"mm:ss.zzz";
378 return listTimeFormat;
382TQStringList KoVariableTimeFormat::staticTranslatedFormatPropsList()
384 TQStringList listTimeFormat;
385 listTimeFormat<<i18n(
"Locale format");
386 listTimeFormat<<
"hh:mm";
387 listTimeFormat<<
"hh:mm:ss";
388 listTimeFormat<<
"hh:mm AP";
389 listTimeFormat<<
"hh:mm:ss AP";
390 listTimeFormat<<
"mm:ss.zzz";
391 return listTimeFormat;
398 if (
string.type() != TQVariant::String )
400 kdDebug(32500)<<
" Error in KoVariableStringFormat::convert. Value is a " <<
string.typeName() << endl;
404 return string.toString();
409 return getKey( TQString() );
415 return TQCString(
"STRING") + props.utf8();
420TQString KoVariableNumberFormat::convert(
const TQVariant &value )
const
422 if ( value.type() != TQVariant::Int )
424 kdDebug(32500)<<
" Error in KoVariableNumberFormat::convert. Value is a " << value.typeName() << endl;
428 return TQString::number( value.toInt() );
431TQCString KoVariableNumberFormat::key()
const
433 return getKey(TQString());
436TQCString KoVariableNumberFormat::getKey(
const TQString& props )
const
438 return TQCString(
"NUMB") + props.utf8();
443KoVariableFormatCollection::KoVariableFormatCollection()
445 m_dict.setAutoDelete(
true );
454 return createFormat( key );
457KoVariableFormat * KoVariableFormatCollection::createFormat(
const TQCString &key )
459 kdDebug(32500) <<
"KoVariableFormatCollection: creating format for key=" << key << endl;
462 TQCString type = key.left(4);
463 if ( type ==
"DATE" )
465 else if ( type ==
"TIME" )
467 else if ( type ==
"NUMB" )
468 format =
new KoVariableNumberFormat();
469 else if ( type ==
"STRI" )
485 m_variableSettings = _settings;
487 m_formatCollection = formatCollection;
490KoVariableCollection::~KoVariableCollection()
492 delete m_variableSettings;
495void KoVariableCollection::clear()
502void KoVariableCollection::registerVariable(
KoVariable *var )
506 variables.append( var );
509void KoVariableCollection::unregisterVariable(
KoVariable *var )
511 variables.take( variables.findRef( var ) );
514TQValueList<KoVariable *> KoVariableCollection::recalcVariables(
int type)
516 TQValueList<KoVariable *> modifiedVariables;
517 TQPtrListIterator<KoVariable> it( variables );
518 for ( ; it.current() ; ++it )
521 if ( variable->isDeleted() )
523 if ( variable->type() == type || type == VT_ALL )
525 TQVariant oldValue = variable->
varValue();
527 if(variable->height == 0)
529 if ( variable->
varValue() != oldValue )
530 modifiedVariables.append( variable );
531 KoTextParag * parag = variable->paragraph();
535 parag->invalidate( 0 );
536 parag->setChanged(
true );
543 if( !modifiedVariables.isEmpty() )
544 emit repaintVariable();
546 return modifiedVariables;
550void KoVariableCollection::setVariableValue(
const TQString &name,
const TQString &value )
552 varValues[
name ] = value;
555TQString KoVariableCollection::getVariableValue(
const TQString &name )
const
557 if ( !varValues.contains( name ) )
558 return i18n(
"No value" );
559 return varValues[
name ];
562bool KoVariableCollection::customVariableExist(
const TQString &varname)
const
564 return varValues.contains( varname );
567void KoVariableCollection::setVariableSelected(
KoVariable * var)
573TQPtrList<TDEAction> KoVariableCollection::popupActionList()
const
575 TQPtrList<TDEAction> listAction;
577 const TQStringList subTypeList = m_varSelected->
subTypeList();
578 kdDebug() << k_funcinfo <<
"current subtype=" << m_varSelected->subType() << endl;
579 TQStringList::ConstIterator it = subTypeList.begin();
580 for (
int i = 0; it != subTypeList.end() ; ++it, ++i )
582 if ( !(*it).isEmpty() )
587 connect( act, TQ_SIGNAL(activated()),
this, TQ_SLOT(slotChangeSubType()) );
588 if ( i == m_varSelected->subType() )
591 listAction.append( act );
600 for (
int i = 0; it != list.end() ; ++it, ++i )
603 listAction.append(
new TDEActionSeparator() );
605 if ( !(*it).isEmpty() )
608 TQString text = format->
convert( m_varSelected->varValue() );
611 connect( act, TQ_SIGNAL(activated()),
this, TQ_SLOT(slotChangeFormat()) );
612 if ( (*it) == currentFormat )
614 listAction.append( act );
623void KoVariableCollection::slotChangeSubType()
626 int menuNumber = TQCString(act->name()).toInt();
627 int newSubType = m_varSelected->variableSubType(menuNumber);
628 kdDebug(32500) <<
"slotChangeSubType: menuNumber=" << menuNumber <<
" newSubType=" << newSubType << endl;
629 if ( m_varSelected->subType() != newSubType )
632 m_varSelected->subType(), newSubType, m_varSelected );
634 m_varSelected->textDocument()->emitNewCommand(cmd);
638void KoVariableCollection::slotChangeFormat()
641 TQString newFormat = TQString::fromUtf8(act->name());
642 TQString oldFormat = m_varSelected->variableFormat()->formatProperties();
643 if (oldFormat != newFormat )
646 oldFormat, newFormat, m_varSelected );
648 m_varSelected->textDocument()->emitNewCommand(cmd);
654 Q_ASSERT( coll == m_formatCollection );
656 TQStringList stringList;
657 if ( varFormat == 0L )
662 case VT_DATE_VAR_KWORD10:
664 if ( _forceDefaultFormat )
669 if ( result.isNull() )
671 varFormat = coll->
format( result );
676 case VT_TIME_VAR_KWORD10:
678 if ( _forceDefaultFormat )
683 if ( result.isNull() )
685 varFormat = coll->
format( result );
690 varFormat = coll->
format(
"NUMBER" );
697 varFormat = coll->
format(
"STRING" );
700 kdError() <<
"Footnote type not handled in KoVariableCollection: VT_FOOTNOTE" << endl;
703 kdError() <<
" Statistic type not handled in KoVariableCollection: VT_STATISTIC" << endl;
707 Q_ASSERT( varFormat );
708 if ( varFormat == 0L )
711 kdDebug(32500) <<
"Creating variable. Format=" << varFormat->
key() <<
" type=" << type << endl;
715 case VT_DATE_VAR_KWORD10:
716 var =
new KoDateVariable( textdoc, subtype, varFormat,
this, _correct );
719 case VT_TIME_VAR_KWORD10:
720 var =
new KoTimeVariable( textdoc, subtype, varFormat,
this, _correct );
723 kdError() <<
"VT_PGNUM must be handled by the application's reimplementation of KoVariableCollection::createVariable" << endl;
733 var =
new KoMailMergeVariable( textdoc, TQString(), varFormat ,
this);
736 var =
new KoLinkVariable( textdoc,TQString(), TQString(), varFormat ,
this);
739 var =
new KoNoteVariable( textdoc, TQString(), varFormat ,
this);
747KoVariable* KoVariableCollection::loadOasisField( KoTextDocument* textdoc,
const TQDomElement& tag,
KoOasisContext& context )
749 const TQString localName( tag.localName() );
750 const bool isTextNS = tag.namespaceURI() == KoXmlNS::text;
755 if ( localName.endsWith(
"date" ) || localName.endsWith(
"time" ) )
757 TQString dataStyleName = tag.attributeNS( KoXmlNS::style,
"data-style-name", TQString() );
758 TQString dateFormat =
"locale";
759 const KoOasisStyles::DataFormatsMap& map = context.oasisStyles().
dataFormats();
760 KoOasisStyles::DataFormatsMap::const_iterator it = map.find( dataStyleName );
761 if ( it != map.end() )
762 dateFormat = (*it).formatStr;
767 if ( localName ==
"time" )
770 key =
"TIME" + dateFormat;
775 key =
"DATE" + dateFormat;
778 else if (localName ==
"page-number" || localName ==
"page-count" )
783 else if (localName ==
"chapter")
788 else if (localName ==
"file-name")
793 else if (localName ==
"author-name"
794 || localName ==
"author-initials"
795 || localName ==
"subject"
796 || localName ==
"title"
797 || localName ==
"description"
798 || localName ==
"keywords")
803 else if ( localName.startsWith(
"sender-" )
804 && localName !=
"sender-firstname"
805 && localName !=
"sender-lastname"
806 && localName !=
"sender-initials"
812 else if ( localName ==
"variable-set"
813 || localName ==
"user-defined"
814 || localName ==
"user-field-get" )
822 else if ( tag.namespaceURI() == KoXmlNS::office && localName ==
"annotation" )
835 return loadOasisFieldCreateVariable( textdoc, tag, context, key, type );
838KoVariable* KoVariableCollection::loadOasisFieldCreateVariable( KoTextDocument* textdoc,
const TQDomElement& tag,
KoOasisContext& context,
const TQString &key,
int type )
840 KoVariableFormat * varFormat = key.isEmpty() ? 0 : m_formatCollection->format( key.latin1() );
843 KoVariable* var = createVariable( type, -1, m_formatCollection, varFormat, textdoc, context.koDocument(), 0 ,
true );
844 var->loadOasis( tag, context );
851KoVariable::KoVariable( KoTextDocument *textdoc,
KoVariableFormat *varFormat, KoVariableCollection *_varColl)
856 m_varFormat = varFormat;
857 m_varColl->registerVariable(
this );
861KoVariable::~KoVariable()
864 m_varColl->unregisterVariable(
this );
870 return TQStringList();
879 TQString txt =
text();
883 for (
int i = 0 ; i < (int)txt.length() ; ++i )
884 width += fm.width( txt[i] );
887 height = fmt->height();
888 m_ascent = fmt->ascent();
895 KoTextParag * parag = paragraph();
899 parag->invalidate( 0 );
900 parag->setChanged(
true );
905TQString KoVariable::fieldCode()
907 return i18n(
"Variable");
914 if (m_varColl->variableSetting()->displayFieldCode()&&!realValue)
917 str = m_varFormat->
convert( m_varValue );
919 return fmt->displayedString( str);
922void KoVariable::drawCustomItem( TQPainter* p,
int x,
int y,
int wpix,
int hpix,
int ascentpix,
int ,
int ,
int ,
int ,
const TQColorGroup& cg,
bool selected,
int offset,
bool drawingShadow )
927 drawCustomItemHelper( p, x, y, wpix, hpix, ascentpix, cg, selected, offset, fmt, font, fmt->color(), drawingShadow );
930void KoVariable::drawCustomItemHelper( TQPainter* p,
int x,
int y,
int wpix,
int hpix,
int ascentpix,
const TQColorGroup& cg,
bool selected,
int offset,
KoTextFormat* fmt,
const TQFont& font, TQColor textColor,
bool drawingShadow )
939 if ( fmt->textBackgroundColor().isValid() )
940 p->fillRect( x, y, wpix, hpix, fmt->textBackgroundColor() );
944 textColor = fmt->shadowColor();
945 p->setPen( textColor );
949 textColor = cg.color( TQColorGroup::HighlightedText );
950 p->setPen( TQPen( textColor ) );
951 p->fillRect( x, y, wpix, hpix, cg.color( TQColorGroup::Highlight ) );
954 && p->device()->devType() != TQInternal::Printer )
956 textColor = cg.color( TQColorGroup::Highlight );
957 p->setPen( TQPen ( textColor, 0, TQt::DotLine ) );
958 p->drawRect( x, y, wpix, hpix );
961 if ( !textColor.isValid() )
963 p->setPen( TQPen( textColor ) );
968 TQString str =
text();
969 KoTextParag::drawFontEffects( p, fmt, zh, font, textColor, x, ascentpix, wpix, y, hpix, str[0] );
970 int posY = y + ascentpix + offset;
971 if ( fmt->vAlign() == KoTextFormat::AlignSubScript )
972 posY +=p->fontMetrics().height() / 6;
973 if ( fmt->vAlign() != KoTextFormat::AlignSuperScript )
974 posY -= fmt->offsetFromBaseLine();
975 else if ( fmt->offsetFromBaseLine() < 0 )
976 posY -= 2*fmt->offsetFromBaseLine();
984 const int len = str.length();
987 for (
int i = 0; i < len; ++i )
989 const TQChar ch = str[i];
990 p->drawText( x, posY, TQString(ch) );
1003 TQDomElement variableElem = parentElem.ownerDocument().createElement(
"VARIABLE" );
1004 parentElem.appendChild( variableElem );
1005 TQDomElement typeElem = parentElem.ownerDocument().createElement(
"TYPE" );
1006 variableElem.appendChild( typeElem );
1007 typeElem.setAttribute(
"type",
static_cast<int>( type() ) );
1011 typeElem.setAttribute(
"key", m_varFormat->
key().data() );
1012 typeElem.setAttribute(
"text",
text(
true) );
1013 if ( correctValue() != 0)
1014 typeElem.setAttribute(
"correct", correctValue() );
1018void KoVariable::load( TQDomElement & )
1023void KoVariable::loadOasis(
const TQDomElement &,
KoOasisContext& )
1035 m_varFormat = _varFormat;
1039#define addText( text, newFormat ) { \
1040 if ( !text.isEmpty() ) \
1047TQString KoVariable::convertKlocaleToTQDateTimeFormat(
const TQString & _format )
1050 TQString
format( _format );
1054 if (
format.startsWith(
"%Y" ) )
1056 addText(
text, newFormat );
1060 else if (
format.startsWith(
"%y" ) )
1062 addText(
text, newFormat );
1067 else if (
format.startsWith(
"%n" ) )
1069 addText(
text, newFormat );
1073 else if (
format.startsWith(
"%m" ) )
1075 addText(
text, newFormat );
1079 else if (
format.startsWith(
"%e" ) )
1081 addText(
text, newFormat );
1085 else if (
format.startsWith(
"%d" ) )
1087 addText(
text, newFormat );
1091 else if (
format.startsWith(
"%b" ) )
1093 addText(
text, newFormat );
1097 else if (
format.startsWith(
"%B" ) )
1099 addText(
text, newFormat );
1103 else if (
format.startsWith(
"%a" ) )
1105 addText(
text, newFormat );
1110 else if (
format.startsWith(
"%A" ) )
1112 addText(
text, newFormat );
1116 if (
format.startsWith(
"%H" ) )
1119 addText(
text, newFormat );
1123 else if (
format.startsWith(
"%k" ) )
1125 addText(
text, newFormat );
1129 else if (
format.startsWith(
"%I" ) )
1131 addText(
text, newFormat );
1134 else if (
format.startsWith(
"%l" ) )
1136 addText(
text, newFormat );
1139 else if (
format.startsWith(
"%M" ) )
1141 addText(
text, newFormat );
1145 else if (
format.startsWith(
"%S" ) )
1147 addText(
text, newFormat );
1151 else if (
format.startsWith(
"%p" ) )
1154 addText(
text, newFormat );
1165 while (
format.length() > 0 );
1174KoDateVariable::KoDateVariable( KoTextDocument *textdoc,
short int subtype,
KoVariableFormat *_varFormat, KoVariableCollection *_varColl,
int _correctDate)
1175 :
KoVariable( textdoc, _varFormat,_varColl ), m_subtype( subtype ), m_correctDate( _correctDate)
1179TQString KoDateVariable::fieldCode()
1181 if ( m_subtype == VST_DATE_FIX )
1182 return i18n(
"Date (Fixed)");
1183 else if ( m_subtype == VST_DATE_CURRENT)
1184 return i18n(
"Date");
1185 else if ( m_subtype == VST_DATE_LAST_PRINTING)
1186 return i18n(
"Last Printing");
1187 else if ( m_subtype == VST_DATE_CREATE_FILE )
1188 return i18n(
"File Creation");
1189 else if ( m_subtype == VST_DATE_MODIFY_FILE )
1190 return i18n(
"File Modification");
1192 return i18n(
"Date");
1198 TQString oldLanguage;
1199 if ( !fmt->language().isEmpty())
1201 oldLanguage=TDEGlobal::locale()->language();
1202 bool changeLanguage = TDEGlobal::locale()->setLanguage( fmt->language() );
1204 if ( changeLanguage )
1205 TDEGlobal::locale()->setLanguage( oldLanguage );
1213 if ( m_subtype == VST_DATE_CURRENT )
1214 m_varValue = TQDateTime(TQDateTime::currentDateTime().addDays(m_correctDate));
1215 else if ( m_subtype == VST_DATE_LAST_PRINTING )
1216 m_varValue = m_varColl->variableSetting()->lastPrintingDate();
1217 else if ( m_subtype == VST_DATE_CREATE_FILE )
1218 m_varValue = m_varColl->variableSetting()->creationDate();
1219 else if ( m_subtype == VST_DATE_MODIFY_FILE )
1220 m_varValue = m_varColl->variableSetting()->modificationDate();
1224 if ( m_varValue.isNull() )
1225 m_varValue = TQDateTime(TQDateTime::currentDateTime().addDays(m_correctDate));
1232 TQDomElement elem = varElem.ownerDocument().createElement(
"DATE" );
1233 varElem.appendChild( elem );
1235 TQDate date = m_varValue.toDate();
1236 date = date.addDays( -m_correctDate );
1237 elem.setAttribute(
"year", date.year() );
1238 elem.setAttribute(
"month", date.month() );
1239 elem.setAttribute(
"day", date.day() );
1240 elem.setAttribute(
"fix", m_subtype == VST_DATE_FIX );
1241 elem.setAttribute(
"correct", m_correctDate);
1242 elem.setAttribute(
"subtype", m_subtype);
1243 if ( m_varValue.type() == TQVariant::DateTime )
1245 TQTime time = m_varValue.toTime();
1246 elem.setAttribute(
"hour", time.hour() );
1247 elem.setAttribute(
"minute", time.minute() );
1248 elem.setAttribute(
"second", time.second() );
1252void KoDateVariable::load( TQDomElement& elem )
1254 KoVariable::load( elem );
1256 TQDomElement e = elem.namedItem(
"DATE" ).toElement();
1259 const bool fix = e.attribute(
"fix").toInt() == 1;
1260 if ( e.hasAttribute(
"correct"))
1261 m_correctDate = e.attribute(
"correct").toInt();
1264 const int y = e.attribute(
"year").toInt();
1265 const int month = e.attribute(
"month").toInt();
1266 const int d = e.attribute(
"day").toInt();
1267 const int h = e.attribute(
"hour").toInt();
1268 const int min = e.attribute(
"minute").toInt();
1269 const int s = e.attribute(
"second").toInt();
1270 const int ms = e.attribute(
"msecond").toInt();
1271 TQDate date( y, month, d );
1272 date = date.addDays( m_correctDate );
1273 const TQTime time( h, min, s, ms );
1275 m_varValue = TQVariant ( TQDateTime( date, time ) );
1277 m_varValue = TQVariant( date );
1280 m_subtype = fix ? VST_DATE_FIX : VST_DATE_CURRENT;
1281 if ( e.hasAttribute(
"subtype" ))
1282 m_subtype = e.attribute(
"subtype").toInt();
1291 case VST_DATE_CURRENT:
1293 if ( m_subtype == VST_DATE_FIX )
1295 writer.
addAttribute(
"text:date-value", m_varValue.toDate().toString( TQt::ISODate) );
1299 case VST_DATE_LAST_PRINTING:
1302 case VST_DATE_CREATE_FILE:
1305 case VST_DATE_MODIFY_FILE:
1310 bool klocaleFormat =
false;
1311 if ( value.lower() ==
"locale" ||
1313 value.lower() ==
"localeshort" ||
1314 value.lower() ==
"localedatetime" ||
1315 value.lower() ==
"localedatetimeshort" )
1317 if ( value.lower() ==
"locale" || value.isEmpty())
1318 value = TDEGlobal::locale()->dateFormat();
1319 else if ( value.lower() ==
"localeshort" )
1320 value = TDEGlobal::locale()->dateFormatShort();
1321 else if ( value.lower() ==
"localedatetime" )
1322 value = TQString(
"%1 %2" ).arg( TDEGlobal::locale()->dateFormat() ).arg( TDEGlobal::locale()->timeFormat() );
1323 else if ( value.lower() ==
"localedatetimeshort" )
1324 value = TQString(
"%1 %2" ).arg( TDEGlobal::locale()->dateFormatShort() ).arg( TDEGlobal::locale()->timeFormat() );
1325 klocaleFormat =
true;
1327 writer.
addAttribute(
"style:data-style-name", KoOasisStyles::saveOasisDateStyle(context.mainStyles(), value, klocaleFormat ) );
1329 if ( m_correctDate != 0 )
1330 writer.
addAttribute(
"text:date-adjust", daysToISODuration( m_correctDate ) );
1334void KoDateVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
1336 const TQString localName( elem.localName() );
1337 if ( localName ==
"date" )
1340 const TQString dateValue = elem.attributeNS( KoXmlNS::text,
"date-value", TQString());
1342 if ( !dateValue.isEmpty() )
1343 dt = TQDate::fromString(dateValue, TQt::ISODate);
1345 bool fixed = (elem.hasAttributeNS( KoXmlNS::text,
"fixed") && elem.attributeNS( KoXmlNS::text,
"fixed", TQString())==
"true");
1349 m_varValue = TQVariant( dt );
1350 m_subtype = fixed ? VST_DATE_FIX : VST_DATE_CURRENT;
1353 else if ( localName.startsWith(
"print" ) )
1354 m_subtype = VST_DATE_LAST_PRINTING;
1355 else if ( localName.startsWith(
"creation" ) )
1356 m_subtype = VST_DATE_CREATE_FILE;
1357 else if ( localName.startsWith(
"modification" ) )
1358 m_subtype = VST_DATE_MODIFY_FILE;
1359 const TQString adjustStr = elem.attributeNS( KoXmlNS::text,
"date-adjust", TQString() );
1360 if ( !adjustStr.isEmpty() )
1361 m_correctDate = ISODurationToDays( adjustStr );
1364TQStringList KoDateVariable::actionTexts()
1367 lst << i18n(
"Current Date (fixed)" );
1368 lst << i18n(
"Current Date (variable)" );
1369 lst << i18n(
"Date of Last Printing" );
1370 lst << i18n(
"Date of File Creation" );
1371 lst << i18n(
"Date of File Modification" );
1377 return KoDateVariable::actionTexts();
1382 return TQCString(
"DATE") +
"locale";
1388 TQStringList stringList;
1390 DateFormatWidget* widget=
new DateFormatWidget(dialog);
1393 TDEConfig* config = KoGlobal::kofficeConfig();
1394 if( config->hasGroup(
"Date format history") )
1396 TDEConfigGroupSaver cgs( config,
"Date format history");
1397 const int noe=config->readNumEntry(
"Number Of Entries", 5);
1398 for(
int i=0;i<noe;i++)
1402 const TQString tmpString(config->readEntry(
"Last Used"+num));
1403 if(tmpString.startsWith(
"locale"))
1405 else if(stringList.contains(tmpString))
1407 else if(!tmpString.isEmpty())
1409 stringList.append(tmpString);
1415 if(!stringList.isEmpty())
1417 widget->combo1->insertItem(
"---");
1418 widget->combo1->insertStringList(stringList);
1421 TQComboBox *combo= widget->combo1;
1422 combo->setCurrentItem(combo->count() -1);
1423 widget->updateLabel();
1426 if(dialog->exec()==TQDialog::Accepted)
1428 string = widget->resultString().utf8();
1429 correct = widget->correctValue();
1436 config->setGroup(
"Date format history");
1437 stringList.remove(
string);
1438 stringList.prepend(
string);
1439 for(
int i=0;i<=count;i++)
1443 config->writeEntry(
"Last Used"+num, stringList[i]);
1447 return TQCString(
"DATE") + string;
1453KoTimeVariable::KoTimeVariable( KoTextDocument *textdoc,
short int subtype,
KoVariableFormat *varFormat, KoVariableCollection *_varColl,
int _correct)
1454 :
KoVariable( textdoc, varFormat,_varColl ), m_subtype( subtype ), m_correctTime( _correct)
1458TQString KoTimeVariable::fieldCode()
1460 return (m_subtype == VST_TIME_FIX)?i18n(
"Time (Fixed)"):i18n(
"Time");
1467 if ( !fmt->language().isEmpty() )
1469 TQString oldLanguage = TDEGlobal::locale()->language();
1470 bool changeLanguage = TDEGlobal::locale()->setLanguage( fmt->language() );
1472 if ( changeLanguage )
1473 TDEGlobal::locale()->setLanguage( oldLanguage );
1481 if ( m_subtype == VST_TIME_CURRENT )
1482 m_varValue = TQVariant( TQTime(TQTime::currentTime().addSecs(60*m_correctTime)));
1486 if ( m_varValue.toTime().isNull() )
1487 m_varValue = TQVariant( TQTime(TQTime::currentTime().addSecs(60*m_correctTime)));
1495 TQDomElement elem = parentElem.ownerDocument().createElement(
"TIME" );
1496 parentElem.appendChild( elem );
1498 TQTime time = m_varValue.toTime();
1499 time = time.addSecs(-60*m_correctTime);
1500 elem.setAttribute(
"hour", time.hour() );
1501 elem.setAttribute(
"minute", time.minute() );
1502 elem.setAttribute(
"second", time.second() );
1503 elem.setAttribute(
"msecond", time.msec() );
1504 elem.setAttribute(
"fix", m_subtype == VST_TIME_FIX );
1505 elem.setAttribute(
"correct", m_correctTime );
1508void KoTimeVariable::load( TQDomElement& elem )
1510 KoVariable::load( elem );
1512 TQDomElement e = elem.namedItem(
"TIME" ).toElement();
1515 int h = e.attribute(
"hour").toInt();
1516 int m = e.attribute(
"minute").toInt();
1517 int s = e.attribute(
"second").toInt();
1518 int ms = e.attribute(
"msecond").toInt();
1520 if ( e.hasAttribute(
"correct"))
1521 correct=e.attribute(
"correct").toInt();
1522 bool fix =
static_cast<bool>( e.attribute(
"fix").toInt() );
1526 time.setHMS( h, m, s, ms );
1527 time = time.addSecs( 60*m_correctTime );
1528 m_varValue = TQVariant( time);
1531 m_subtype = fix ? VST_TIME_FIX : VST_TIME_CURRENT;
1532 m_correctTime = correct;
1536void KoTimeVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
1538 const TQString localName( elem.localName() );
1539 Q_ASSERT( localName ==
"time" );
1540 if ( localName ==
"time" )
1543 TQDateTime dt(TQDateTime::fromString(elem.attributeNS( KoXmlNS::text,
"time-value", TQString()), TQt::ISODate));
1545 bool fixed = (elem.hasAttributeNS( KoXmlNS::text,
"fixed") && elem.attributeNS( KoXmlNS::text,
"fixed", TQString())==
"true");
1549 m_varValue = TQVariant( dt.time() );
1550 m_subtype = fixed ? VST_TIME_FIX : VST_TIME_CURRENT;
1551 TQString adjustStr = elem.attributeNS( KoXmlNS::text,
"time-adjust", TQString() );
1552 if ( !adjustStr.isEmpty() )
1553 m_correctTime = ISODurationToMinutes( adjustStr );
1560 if ( m_correctTime != 0 ) {
1561 writer.
addAttribute(
"text:time-adjust", minutesToISODuration( m_correctTime ) );
1563 if (m_subtype == VST_TIME_FIX )
1566 writer.
addAttribute(
"text:time-value", m_varValue.toTime().toString( TQt::ISODate ) );
1570 bool klocaleFormat =
false;
1571 if ( value.lower() ==
"locale" )
1573 value = TDEGlobal::locale()->timeFormat();
1574 klocaleFormat =
true;
1576 writer.
addAttribute(
"style:data-style-name", KoOasisStyles::saveOasisTimeStyle(context.mainStyles(), m_varFormat->
formatProperties(), klocaleFormat ) );
1584TQStringList KoTimeVariable::actionTexts()
1587 lst << i18n(
"Current Time (fixed)" );
1588 lst << i18n(
"Current Time (variable)" );
1594 return KoTimeVariable::actionTexts();
1600 TQStringList stringList;
1602 TimeFormatWidget* widget=
new TimeFormatWidget(dialog);
1604 TDEConfig* config = KoGlobal::kofficeConfig();
1606 if( config->hasGroup(
"Time format history") )
1608 TDEConfigGroupSaver cgs( config,
"Time format history" );
1609 const int noe=config->readNumEntry(
"Number Of Entries", 5);
1610 for(
int i=0;i<noe;i++)
1614 TQString tmpString(config->readEntry(
"Last Used"+num));
1615 if(tmpString.startsWith(
"locale"))
1617 else if(stringList.contains(tmpString))
1619 else if(!tmpString.isEmpty())
1621 stringList.append(tmpString);
1626 if(!stringList.isEmpty())
1628 widget->combo1->insertItem(
"---");
1629 widget->combo1->insertStringList(stringList);
1633 TQComboBox *combo= widget->combo1;
1634 combo->setCurrentItem(combo->count() -1);
1636 if(dialog->exec()==TQDialog::Accepted)
1638 string = widget->resultString().utf8();
1639 _correct = widget->correctValue();
1646 config->setGroup(
"Time format history");
1647 stringList.remove(
string);
1648 stringList.prepend(
string);
1649 for(
int i=0;i<=count;i++)
1653 config->writeEntry(
"Last Used"+num, stringList[i]);
1657 return TQCString(
"TIME"+
string );
1662 return TQCString(TQCString(
"TIME")+TQCString(
"locale") );
1669KoCustomVariable::KoCustomVariable( KoTextDocument *textdoc,
const TQString &name,
KoVariableFormat *varFormat, KoVariableCollection *_varColl )
1672 m_varValue = TQVariant( name );
1675TQString KoCustomVariable::fieldCode()
1677 return i18n(
"Custom Variable");
1682 if (m_varColl->variableSetting()->displayFieldCode()&&!realValue)
1692 TQDomElement elem = parentElem.ownerDocument().createElement(
"CUSTOM" );
1693 parentElem.appendChild( elem );
1694 elem.setAttribute(
"name", m_varValue.toString() );
1695 elem.setAttribute(
"value", value() );
1698void KoCustomVariable::load( TQDomElement& elem )
1700 KoVariable::load( elem );
1701 TQDomElement e = elem.namedItem(
"CUSTOM" ).toElement();
1704 m_varValue = TQVariant (e.attribute(
"name" ));
1705 setValue( e.attribute(
"value" ) );
1709void KoCustomVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
1711 const TQString localName( elem.localName() );
1717 if ( localName ==
"variable-set"
1718 || localName ==
"user-defined"
1719 || localName ==
"user-field-get" ) {
1720 m_varValue = elem.attributeNS( KoXmlNS::text,
"name", TQString() );
1721 setValue( elem.text() );
1729 writer.
addAttribute(
"text:name", m_varValue.toString() );
1734TQString KoCustomVariable::value()
const
1736 return m_varColl->getVariableValue( m_varValue.toString() );
1739void KoCustomVariable::setValue(
const TQString &v )
1741 m_varColl->setVariableValue( m_varValue.toString(), v );
1744TQStringList KoCustomVariable::actionTexts()
1746 return TQStringList( i18n(
"Custom..." ) );
1757KoMailMergeVariable::KoMailMergeVariable( KoTextDocument *textdoc,
const TQString &name,
KoVariableFormat *varFormat,KoVariableCollection *_varColl )
1760 m_varValue = TQVariant ( name );
1763TQString KoMailMergeVariable::fieldCode()
1765 return i18n(
"Mail Merge");
1768void KoMailMergeVariable::loadOasis(
const TQDomElement &,
KoOasisContext& )
1775 kdWarning(32500) <<
"Not implemented: OASIS saving of mail merge variables" << endl;
1780void KoMailMergeVariable::saveVariable( TQDomElement& parentElem )
1782 TQDomElement elem = parentElem.ownerDocument().createElement(
"MAILMERGE" );
1783 parentElem.appendChild( elem );
1784 elem.setAttribute(
"name", m_varValue.toString() );
1787void KoMailMergeVariable::load( TQDomElement& elem )
1789 KoVariable::load( elem );
1790 TQDomElement e = elem.namedItem(
"MAILMERGE" ).toElement();
1792 m_varValue = TQVariant( e.attribute(
"name" ) );
1795TQString KoMailMergeVariable::value()
const
1800TQString KoMailMergeVariable::text(
bool )
1803 TQString v = value();
1805 return "<" + v +
">";
1809TQStringList KoMailMergeVariable::actionTexts()
1811 return TQStringList( i18n(
"&Mail Merge..." ) );
1817KoPageVariable::KoPageVariable( KoTextDocument *textdoc,
short int subtype,
KoVariableFormat *varFormat,KoVariableCollection *_varColl )
1818 :
KoVariable( textdoc, varFormat, _varColl ), m_subtype( subtype )
1822TQString KoPageVariable::fieldCode()
1824 if ( m_subtype == VST_PGNUM_CURRENT )
1825 return i18n(
"Page Current Num");
1826 else if ( m_subtype == VST_PGNUM_TOTAL )
1827 return i18n(
"Total Page Num");
1828 else if ( m_subtype == VST_CURRENT_SECTION )
1829 return i18n(
"Current Section");
1830 else if ( m_subtype == VST_PGNUM_PREVIOUS )
1831 return i18n(
"Previous Page Number");
1832 else if ( m_subtype == VST_PGNUM_NEXT )
1833 return i18n(
"Next Page Number");
1836 return i18n(
"Current Section");
1842 TQDomElement pgNumElem = parentElem.ownerDocument().createElement(
"PGNUM" );
1843 parentElem.appendChild( pgNumElem );
1844 pgNumElem.setAttribute(
"subtype", m_subtype );
1845 if ( m_subtype != VST_CURRENT_SECTION )
1846 pgNumElem.setAttribute(
"value", m_varValue.toInt() );
1848 pgNumElem.setAttribute(
"value", m_varValue.toString() );
1851void KoPageVariable::load( TQDomElement& elem )
1853 KoVariable::load( elem );
1854 TQDomElement pgNumElem = elem.namedItem(
"PGNUM" ).toElement();
1855 if (!pgNumElem.isNull())
1857 m_subtype = pgNumElem.attribute(
"subtype").toInt();
1859 if ( m_subtype != VST_CURRENT_SECTION )
1860 m_varValue = TQVariant(pgNumElem.attribute(
"value").toInt());
1862 m_varValue = TQVariant(pgNumElem.attribute(
"value"));
1870 case VST_PGNUM_PREVIOUS:
1871 case VST_PGNUM_NEXT:
1872 case VST_PGNUM_CURRENT:
1875 if ( m_subtype == VST_PGNUM_PREVIOUS )
1879 else if ( m_subtype == VST_PGNUM_NEXT )
1883 else if ( m_subtype == VST_PGNUM_CURRENT )
1891 case VST_CURRENT_SECTION:
1898 case VST_PGNUM_TOTAL:
1908void KoPageVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
1910 const TQString localName( elem.localName() );
1911 if ( localName ==
"page-number" )
1913 m_subtype = VST_PGNUM_CURRENT;
1915 if ( elem.hasAttributeNS( KoXmlNS::text,
"select-page") )
1917 const TQString select = elem.attributeNS( KoXmlNS::text,
"select-page", TQString());
1918 if (select ==
"previous")
1919 m_subtype = VST_PGNUM_PREVIOUS;
1920 else if (select ==
"next")
1921 m_subtype = VST_PGNUM_NEXT;
1924 m_varValue = TQVariant( elem.text().toInt() );
1926 else if ( localName ==
"chapter" )
1928 m_subtype = VST_CURRENT_SECTION;
1929 m_varValue = TQVariant( elem.text() );
1934 else if ( localName ==
"page-count" )
1936 m_subtype = VST_PGNUM_TOTAL;
1937 m_varValue = TQVariant( elem.text() );
1941TQStringList KoPageVariable::actionTexts()
1944 lst << i18n(
"Page Number" );
1945 lst << i18n(
"Number of Pages" );
1946 lst << i18n(
"Section Title" );
1947 lst << i18n(
"Previous Page" );
1948 lst << i18n(
"Next Page" );
1954 return KoPageVariable::actionTexts();
1960 Q_ASSERT( m_varColl );
1962 setVariableFormat((m_subtype == VST_CURRENT_SECTION) ? fc->
format(
"STRING") : fc->
format(
"NUMBER"));
1968KoFieldVariable::KoFieldVariable( KoTextDocument *textdoc,
short int subtype,
KoVariableFormat *varFormat, KoVariableCollection *_varColl ,
KoDocument *_doc )
1969 :
KoVariable( textdoc, varFormat,_varColl ), m_subtype( subtype ), m_doc(_doc)
1973TQString KoFieldVariable::fieldCode()
1975 switch( m_subtype ) {
1977 return i18n(
"Filename");
1979 case VST_DIRECTORYNAME:
1980 return i18n(
"Directory Name");
1982 case VST_PATHFILENAME:
1983 return i18n(
"Path Filename");
1985 case VST_FILENAMEWITHOUTEXTENSION:
1986 return i18n(
"Filename Without Extension");
1988 case VST_AUTHORNAME:
1989 return i18n(
"Author Name");
1992 return i18n(
"Email");
1994 case VST_COMPANYNAME:
1995 return i18n(
"Company Name");
1997 case VST_TELEPHONE_WORK:
1998 return i18n(
"Telephone (work)");
2000 case VST_TELEPHONE_HOME:
2001 return i18n(
"Telephone (home)");
2007 return i18n(
"Country");
2009 case VST_POSTAL_CODE:
2010 return i18n(
"Postal Code");
2013 return i18n(
"City");
2016 return i18n(
"Street");
2018 case VST_AUTHORTITLE:
2019 return i18n(
"Author Title");
2022 return i18n(
"Title");
2025 return i18n(
"Subject");
2028 return i18n(
"Abstract");
2031 return i18n(
"Keywords");
2034 return i18n(
"Initials");
2037 return i18n(
"Field");
2042 if (m_varColl->variableSetting()->displayFieldCode()&&!realValue)
2052 TQDomElement elem = parentElem.ownerDocument().createElement(
"FIELD" );
2053 parentElem.appendChild( elem );
2054 elem.setAttribute(
"subtype", m_subtype );
2055 elem.setAttribute(
"value", m_varValue.toString() );
2058void KoFieldVariable::load( TQDomElement& elem )
2060 KoVariable::load( elem );
2061 TQDomElement e = elem.namedItem(
"FIELD" ).toElement();
2064 m_subtype = e.attribute(
"subtype" ).toInt();
2065 if ( m_subtype == VST_NONE )
2066 kdWarning() <<
"Field subtype of -1 found in the file !" << endl;
2067 m_varValue = TQVariant( e.attribute(
"value" ) );
2069 kdWarning() <<
"FIELD element not found !" << endl;
2072void KoFieldVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
2074 const TQString localName( elem.localName() );
2075 if ( localName ==
"file-name" ) {
2076 const TQString display = elem.attributeNS( KoXmlNS::text,
"display", TQString() );
2077 if (display ==
"path")
2078 m_subtype = VST_DIRECTORYNAME;
2079 else if (display ==
"name")
2080 m_subtype = VST_FILENAMEWITHOUTEXTENSION;
2081 else if (display ==
"name-and-extension")
2082 m_subtype = VST_FILENAME;
2084 m_subtype = VST_PATHFILENAME;
2086 else if ( localName ==
"author-name" )
2087 m_subtype = VST_AUTHORNAME;
2088 else if ( localName ==
"author-initials" )
2089 m_subtype = VST_INITIAL;
2090 else if ( localName ==
"subject" )
2091 m_subtype = VST_SUBJECT;
2092 else if ( localName ==
"title" )
2093 m_subtype = VST_TITLE;
2094 else if ( localName ==
"description" )
2095 m_subtype = VST_ABSTRACT;
2096 else if ( localName ==
"keywords" )
2097 m_subtype = VST_KEYWORDS;
2099 else if ( localName ==
"sender-company" )
2100 m_subtype = VST_COMPANYNAME;
2101 else if ( localName ==
"sender-firstname" )
2103 else if ( localName ==
"sender-lastname" )
2105 else if ( localName ==
"sender-initials" )
2107 else if ( localName ==
"sender-street" )
2108 m_subtype = VST_STREET;
2109 else if ( localName ==
"sender-country" )
2110 m_subtype = VST_COUNTRY;
2111 else if ( localName ==
"sender-postal-code" )
2112 m_subtype = VST_POSTAL_CODE;
2113 else if ( localName ==
"sender-city" )
2114 m_subtype = VST_CITY;
2115 else if ( localName ==
"sender-title" )
2116 m_subtype = VST_AUTHORTITLE;
2117 else if ( localName ==
"sender-position" )
2118 m_subtype = VST_AUTHORPOSITION;
2119 else if ( localName ==
"sender-phone-private" )
2120 m_subtype = VST_TELEPHONE_HOME;
2121 else if ( localName ==
"sender-phone-work" )
2122 m_subtype = VST_TELEPHONE_WORK;
2123 else if ( localName ==
"sender-fax" )
2124 m_subtype = VST_FAX;
2125 else if ( localName ==
"sender-email" )
2126 m_subtype = VST_EMAIL;
2128 m_varValue = TQVariant( elem.text() );
2139 writer.
addAttribute(
"text:display",
"name-and-extension" );
2141 case VST_DIRECTORYNAME:
2145 case VST_AUTHORNAME:
2151 case VST_COMPANYNAME:
2154 case VST_PATHFILENAME:
2158 case VST_FILENAMEWITHOUTEXTENSION:
2160 writer.
addAttribute(
"text:display",
"name-and-extension" );
2162 case VST_TELEPHONE_WORK:
2165 case VST_TELEPHONE_HOME:
2186 case VST_POSTAL_CODE:
2195 case VST_AUTHORTITLE:
2198 case VST_AUTHORPOSITION:
2212 switch( m_subtype ) {
2214 kdWarning() <<
"KoFieldVariable::recalc() called with m_subtype = VST_NONE !" << endl;
2217 value = m_doc->
url().fileName();
2219 case VST_DIRECTORYNAME:
2220 value = m_doc->
url().directory();
2222 case VST_PATHFILENAME:
2223 value=m_doc->
url().path();
2225 case VST_FILENAMEWITHOUTEXTENSION:
2227 TQString file=m_doc->
url().fileName();
2228 int pos=file.findRev(
".");
2230 value=file.mid(0,pos);
2235 case VST_AUTHORNAME:
2237 case VST_COMPANYNAME:
2238 case VST_TELEPHONE_WORK:
2239 case VST_TELEPHONE_HOME:
2242 case VST_POSTAL_CODE:
2245 case VST_AUTHORTITLE:
2246 case VST_AUTHORPOSITION:
2250 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
2252 kdWarning() <<
"Author information not found in documentInfo !" << endl;
2255 if ( m_subtype == VST_AUTHORNAME )
2256 value = authorPage->fullName();
2257 else if ( m_subtype == VST_EMAIL )
2258 value = authorPage->email();
2259 else if ( m_subtype == VST_COMPANYNAME )
2260 value = authorPage->company();
2261 else if ( m_subtype == VST_TELEPHONE_WORK )
2262 value = authorPage->telephoneWork();
2263 else if ( m_subtype == VST_TELEPHONE_HOME )
2264 value = authorPage->telephoneHome();
2265 else if ( m_subtype == VST_FAX )
2266 value = authorPage->fax();
2267 else if ( m_subtype == VST_COUNTRY )
2268 value = authorPage->country();
2269 else if ( m_subtype == VST_POSTAL_CODE )
2270 value = authorPage->postalCode();
2271 else if ( m_subtype == VST_CITY )
2272 value = authorPage->city();
2273 else if ( m_subtype == VST_STREET )
2274 value = authorPage->street();
2275 else if ( m_subtype == VST_AUTHORTITLE )
2276 value = authorPage->title();
2277 else if ( m_subtype == VST_INITIAL )
2278 value = authorPage->initial();
2279 else if ( m_subtype == VST_AUTHORPOSITION )
2280 value = authorPage->position();
2290 KoDocumentInfoAbout * aboutPage =
static_cast<KoDocumentInfoAbout *
>(info->page(
"about" ));
2292 kdWarning() <<
"'About' page not found in documentInfo !" << endl;
2295 if ( m_subtype == VST_TITLE )
2296 value = aboutPage->title();
2297 else if ( m_subtype == VST_SUBJECT )
2298 value = aboutPage->subject();
2299 else if ( m_subtype == VST_KEYWORDS )
2300 value = aboutPage->keywords();
2302 value = aboutPage->abstract();
2308 if (value.isEmpty())
2309 value = m_varValue.toString();
2311 if (value.isEmpty())
2312 value = i18n(
"<None>");
2314 m_varValue = TQVariant( value );
2319TQStringList KoFieldVariable::actionTexts()
2323 lst << i18n(
"Author Name" );
2324 lst << i18n(
"Title" );
2325 lst << i18n(
"Initials" );
2326 lst << i18n(
"Position" );
2327 lst << i18n(
"Company" );
2328 lst << i18n(
"Email" );
2329 lst << i18n(
"Telephone (work)");
2330 lst << i18n(
"Telephone (private)");
2332 lst << i18n(
"Fax");
2333 lst << i18n(
"Street" );
2334 lst << i18n(
"Postal Code" );
2335 lst << i18n(
"City" );
2336 lst << i18n(
"Country");
2338 lst << i18n(
"Document Title" );
2339 lst << i18n(
"Document Abstract" );
2340 lst << i18n(
"Document Subject" );
2341 lst << i18n(
"Document Keywords" );
2343 lst << i18n(
"File Name" );
2344 lst << i18n(
"File Name without Extension" );
2345 lst << i18n(
"Directory Name" );
2346 lst << i18n(
"Directory && File Name" );
2361 case 0: v = VST_AUTHORNAME;
2363 case 1: v = VST_AUTHORTITLE;
2365 case 2: v = VST_INITIAL;
2367 case 3: v = VST_AUTHORPOSITION;
2369 case 4: v = VST_COMPANYNAME;
2371 case 5: v = VST_EMAIL;
2373 case 6: v = VST_TELEPHONE_WORK;
2375 case 7: v = VST_TELEPHONE_HOME;
2377 case 8: v = VST_FAX;
2379 case 9: v = VST_STREET;
2381 case 10: v = VST_POSTAL_CODE;
2383 case 11: v = VST_CITY;
2385 case 12: v = VST_COUNTRY;
2387 case 13: v = VST_TITLE;
2389 case 14: v = VST_ABSTRACT;
2391 case 15: v = VST_SUBJECT;
2393 case 16: v = VST_KEYWORDS;
2395 case 17: v = VST_FILENAME;
2397 case 18: v = VST_FILENAMEWITHOUTEXTENSION;
2399 case 19: v = VST_DIRECTORYNAME;
2401 case 20: v = VST_PATHFILENAME;
2412 return KoFieldVariable::actionTexts();
2418KoLinkVariable::KoLinkVariable( KoTextDocument *textdoc,
const TQString & _linkName,
const TQString & _ulr,
KoVariableFormat *varFormat,KoVariableCollection *_varColl )
2422 m_varValue = TQVariant( _linkName );
2425TQString KoLinkVariable::fieldCode()
2427 return i18n(
"Link");
2430void KoLinkVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
2432 if ( elem.localName() ==
"a" && elem.namespaceURI() == KoXmlNS::text ) {
2433 m_url = elem.attributeNS( KoXmlNS::xlink,
"href", TQString());
2434 m_varValue = TQVariant(elem.text());
2444 writer.
addAttribute(
"office:name", m_varValue.toString() );
2450TQString KoLinkVariable::text(
bool realValue)
2452 if (m_varColl->variableSetting()->displayFieldCode()&&!realValue)
2458void KoLinkVariable::saveVariable( TQDomElement& parentElem )
2460 TQDomElement linkElem = parentElem.ownerDocument().createElement(
"LINK" );
2461 parentElem.appendChild( linkElem );
2462 linkElem.setAttribute(
"linkName", m_varValue.toString() );
2463 linkElem.setAttribute(
"hrefName", m_url );
2466void KoLinkVariable::load( TQDomElement& elem )
2468 KoVariable::load( elem );
2469 TQDomElement linkElem = elem.namedItem(
"LINK" ).toElement();
2470 if (!linkElem.isNull())
2472 m_varValue = TQVariant(linkElem.attribute(
"linkName"));
2473 m_url = linkElem.attribute(
"hrefName");
2477void KoLinkVariable::recalc()
2482TQStringList KoLinkVariable::actionTexts()
2484 return TQStringList( i18n(
"Link..." ) );
2488void KoLinkVariable::drawCustomItem( TQPainter* p,
int x,
int y,
int wpix,
int hpix,
int ascentpix,
int ,
int ,
int ,
int ,
const TQColorGroup& cg,
bool selected,
int offset,
bool drawingShadow )
2493 bool displayLink = m_varColl->variableSetting()->displayLink();
2495 if ( m_varColl->variableSetting()->underlineLink() )
2496 font.setUnderline(
true );
2497 TQColor textColor = displayLink ? cg.color( TQColorGroup::Link ) : fmt->color();
2499 drawCustomItemHelper( p, x, y, wpix, hpix, ascentpix, cg, selected, offset, fmt, font, textColor, drawingShadow );
2506KoNoteVariable::KoNoteVariable( KoTextDocument *textdoc,
const TQString & _note,
KoVariableFormat *varFormat,KoVariableCollection *_varColl )
2508 , m_createdNoteDate( TQDate::currentDate() )
2510 m_varValue = TQVariant( _note );
2513TQString KoNoteVariable::fieldCode()
2515 return i18n(
"Note");
2518TQString KoNoteVariable::createdNote()
const
2520 return TDEGlobal::locale()->formatDate( m_createdNoteDate,
false );
2523void KoNoteVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
2525 const TQString localName = elem.localName();
2527 if ( localName ==
"annotation" && elem.namespaceURI() == KoXmlNS::office )
2530 m_createdNoteDate = TQDate::fromString( date.text(), TQt::ISODate );
2532 for ( ; !text.isNull(); text = text.nextSibling() )
2534 if ( text.isElement() )
2536 TQDomElement t = text.toElement();
2537 note += t.text() +
"\n";
2541 m_varValue = TQVariant( note );
2549 writer.
addTextNode( m_createdNoteDate.toString(TQt::ISODate) );
2551 TQStringList text = TQStringList::split(
"\n", m_varValue.toString() );
2552 for ( TQStringList::Iterator it = text.begin(); it != text.end(); ++it ) {
2560void KoNoteVariable::saveVariable( TQDomElement& parentElem )
2562 TQDomElement linkElem = parentElem.ownerDocument().createElement(
"NOTE" );
2563 parentElem.appendChild( linkElem );
2564 linkElem.setAttribute(
"note", m_varValue.toString() );
2567void KoNoteVariable::load( TQDomElement& elem )
2569 KoVariable::load( elem );
2570 TQDomElement linkElem = elem.namedItem(
"NOTE" ).toElement();
2571 if (!linkElem.isNull())
2573 m_varValue = TQVariant(linkElem.attribute(
"note"));
2577void KoNoteVariable::recalc()
2582TQStringList KoNoteVariable::actionTexts()
2584 return TQStringList( i18n(
"Note..." ) );
2587TQString KoNoteVariable::text(
bool realValue)
2589 if (m_varColl->variableSetting()->displayComment() &&
2590 m_varColl->variableSetting()->displayFieldCode()&&!realValue)
2595 return TQString(
" ");
2599void KoNoteVariable::drawCustomItem( TQPainter* p,
int x,
int y,
int wpix,
int hpix,
int ascentpix,
int cx,
int cy,
int cw,
int ch,
const TQColorGroup& cg,
bool selected,
int offset,
bool drawingShadow )
2601 if ( !m_varColl->variableSetting()->displayComment())
2608 p->setPen( TQPen( fmt->color() ) );
2609 if ( fmt->textBackgroundColor().isValid() )
2610 p->fillRect( x, y, wpix, hpix, fmt->textBackgroundColor() );
2613 p->setPen( TQPen( cg.color( TQColorGroup::HighlightedText ) ) );
2614 p->fillRect( x, y, wpix, hpix, cg.color( TQColorGroup::Highlight ) );
2616 else if ( textDocument() && p->device()->devType() != TQInternal::Printer
2617 && !textDocument()->dontDrawingNoteVariable())
2619 p->fillRect( x, y, wpix, hpix, TQt::yellow);
2620 p->setPen( TQPen( cg.color( TQColorGroup::Highlight ), 0, TQt::DotLine ) );
2621 p->drawRect( x, y, wpix, hpix );
2624 KoVariable::drawCustomItem( p, x, y, wpix, hpix, ascentpix, cx, cy, cw, ch, cg, selected, offset, drawingShadow );
2629void KoPageVariable::setSectionTitle(
const TQString& _title )
2631 TQString title( _title );
2632 if ( title.isEmpty() )
2634 title = i18n(
"<No title>");
2636 m_varValue = TQVariant( title );
2644bool KoStatisticVariable::m_extendedType =
false;
2647KoStatisticVariable::KoStatisticVariable( KoTextDocument *textdoc,
2650 KoVariableCollection *_varColl )
2651 :
KoVariable( textdoc, varFormat, _varColl ),
2652 m_subtype( subtype )
2657TQStringList KoStatisticVariable::actionTexts()
2660 lst << i18n(
"Number of Words" );
2661 lst << i18n(
"Number of Sentences" );
2662 lst << i18n(
"Number of Lines" );
2663 lst << i18n(
"Number of Characters" );
2664 lst << i18n(
"Number of Non-Whitespace Characters" );
2665 lst << i18n(
"Number of Syllables" );
2666 lst << i18n(
"Number of Frames" );
2667 lst << i18n(
"Number of Embedded Objects" );
2668 lst << i18n(
"Number of Pictures" );
2669 if ( m_extendedType )
2670 lst << i18n(
"Number of Tables" );
2675void KoStatisticVariable::setVariableSubType(
short int subtype )
2677 m_subtype = subtype;
2678 Q_ASSERT( m_varColl );
2680 setVariableFormat(fc->
format(
"NUMBER") );
2684TQStringList KoStatisticVariable::subTypeList()
2686 return KoStatisticVariable::actionTexts();
2690void KoStatisticVariable::saveVariable( TQDomElement& varElem )
2692 TQDomElement elem = varElem.ownerDocument().createElement(
"STATISTIC" );
2693 varElem.appendChild( elem );
2695 elem.setAttribute(
"type", TQString::number(m_subtype) );
2696 elem.setAttribute(
"value", TQString::number(m_varValue.toInt()) );
2700void KoStatisticVariable::load( TQDomElement &elem )
2702 KoVariable::load( elem );
2704 TQDomElement e = elem.namedItem(
"STATISTIC" ).toElement();
2705 if ( !e.isNull() ) {
2707 m_subtype = e.attribute(
"type" ).toInt();
2708 m_varValue = e.attribute(
"value" ).toInt();
2713void KoStatisticVariable::loadOasis(
const TQDomElement &elem,
KoOasisContext& )
2715 const TQString localName( elem.localName() );
2716 if ( localName ==
"object-count" )
2718 m_subtype = VST_STATISTIC_NB_EMBEDDED;
2719 m_varValue = TQVariant( elem.text().toInt() );
2721 else if ( localName ==
"table-count" )
2723 m_subtype = VST_STATISTIC_NB_TABLE;
2724 m_varValue = TQVariant( elem.text().toInt() );
2726 else if ( localName ==
"picture-count" )
2728 m_subtype = VST_STATISTIC_NB_PICTURE;
2729 m_varValue = TQVariant( elem.text().toInt() );
2731 else if ( localName ==
"word-count" )
2733 m_subtype = VST_STATISTIC_NB_WORD;
2734 m_varValue = TQVariant( elem.text().toInt() );
2736 else if ( localName ==
"character-count" )
2738 m_subtype = VST_STATISTIC_NB_CHARACTERE;
2739 m_varValue = TQVariant( elem.text().toInt() );
2741 else if ( localName ==
"frame-count" )
2743 m_subtype = VST_STATISTIC_NB_FRAME;
2744 m_varValue = TQVariant( elem.text().toInt() );
2746 else if ( localName ==
"line-count" )
2748 m_subtype = VST_STATISTIC_NB_LINES;
2749 m_varValue = TQVariant( elem.text().toInt() );
2751 else if ( localName ==
"sentence-count" )
2753 m_subtype = VST_STATISTIC_NB_SENTENCE;
2754 m_varValue = TQVariant( elem.text().toInt() );
2756 else if ( localName ==
"non-whitespace-character-count" )
2758 m_subtype = VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE;
2759 m_varValue = TQVariant( elem.text().toInt() );
2761 else if ( localName ==
"syllable-count" )
2763 m_subtype = VST_STATISTIC_NB_SYLLABLE;
2764 m_varValue = TQVariant( elem.text().toInt() );
2773 case VST_STATISTIC_NB_EMBEDDED:
2775 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2778 case VST_STATISTIC_NB_TABLE:
2780 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2783 case VST_STATISTIC_NB_PICTURE:
2785 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2788 case VST_STATISTIC_NB_FRAME:
2791 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2794 case VST_STATISTIC_NB_WORD:
2796 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2799 case VST_STATISTIC_NB_SENTENCE:
2802 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2805 case VST_STATISTIC_NB_CHARACTERE:
2807 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2810 case VST_STATISTIC_NB_LINES:
2813 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2816 case VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE:
2818 writer.
startElement(
"text:non-whitespace-character-count" );
2819 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2822 case VST_STATISTIC_NB_SYLLABLE:
2825 writer.
addTextNode( TQString::number( m_varValue.toInt() ) );
2831TQString KoStatisticVariable::fieldCode()
2833 if ( m_subtype == VST_STATISTIC_NB_FRAME )
2835 return i18n(
"Number of Frames" );
2837 else if( m_subtype == VST_STATISTIC_NB_PICTURE )
2839 return i18n(
"Number of Pictures" );
2841 else if( m_subtype == VST_STATISTIC_NB_TABLE )
2843 return i18n(
"Number of Tables" );
2845 else if( m_subtype == VST_STATISTIC_NB_EMBEDDED )
2847 return i18n(
"Number of Embedded Objects" );
2849 else if( m_subtype == VST_STATISTIC_NB_WORD )
2851 return i18n(
"Number of Words" );
2853 else if( m_subtype == VST_STATISTIC_NB_SENTENCE )
2855 return i18n(
"Number of Sentences" );
2857 else if( m_subtype == VST_STATISTIC_NB_LINES )
2859 return i18n(
"Number of Lines" );
2861 else if ( m_subtype == VST_STATISTIC_NB_CHARACTERE )
2863 return i18n(
"Number of Characters" );
2865 else if ( m_subtype == VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE )
2867 return i18n(
"Number of Non-Whitespace Characters" );
2869 else if ( m_subtype == VST_STATISTIC_NB_SYLLABLE )
2871 return i18n(
"Number of Syllables" );
2874 return i18n(
"Number of Frames" );
void setMainWidget(TQWidget *widget)
Command created when changing the subtype of a variable (turning "fixed date" into "variable date").
A custom variable is a variable whose value is entered by the user.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context) const
Save to Oasis XML.
virtual void saveVariable(TQDomElement &parentElem)
Variable should reimplement this to implement saving.
virtual TQString text(bool realValue=false)
Returns the text to be displayed for this variable It doesn't need to be cached, convert() is fast,...
virtual void recalc()
Reimplemented by KoVariable to recalculate the value.
virtual void recalc()
Reimplemented by KoVariable to recalculate the value.
virtual TQStringList subTypeList()
List of available subtypes (translated). Use variableSubType() to map index to ID.
virtual void saveVariable(TQDomElement &parentElem)
Variable should reimplement this to implement saving.
static TQCString defaultFormat()
Return the default date format for old file.
virtual void resize()
Reimplement this to calculate the item width It is important to start with "if ( m_deleted ) return;"...
static TQCString formatStr(int &correct)
Ask the user and return the date format string with prefix "DATE".
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context) const
Save to Oasis XML.
The KOffice document class.
KoDocumentInfo * documentInfo() const
Any variable that is a string, and whose value is automatically determined - as opposed to custom var...
virtual void recalc()
Reimplemented by KoVariable to recalculate the value.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context) const
Save to Oasis XML.
virtual short int variableSubType(short int menuNumber)
Converts menuNumber to field variable subtype number.
virtual void saveVariable(TQDomElement &parentElem)
Variable should reimplement this to implement saving.
virtual TQStringList subTypeList()
List of available subtypes (translated). Use variableSubType() to map index to ID.
virtual TQString text(bool realValue=false)
Returns the text to be displayed for this variable It doesn't need to be cached, convert() is fast,...
static FieldSubType fieldSubType(short int menuNumber)
Converts menuNumber to field variable subtype number.
Used during loading of Oasis format (and discarded at the end of the loading).
Represents a collection of items (config-item or maps).
Items itemSet(const TQString &itemSetName) const
Returns the toplevel item-set named itemSetName.
const DataFormatsMap & dataFormats() const
Value (date/time/number...) formats found while parsing styles.
virtual void saveVariable(TQDomElement &parentElem)
Variable should reimplement this to implement saving.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context) const
Save to Oasis XML.
virtual void setVariableSubType(short int subtype)
Set this variable's subtype.
virtual TQStringList subTypeList()
List of available subtypes (translated). Use variableSubType() to map index to ID.
Used during saving to Oasis format (and discarded at the end of the saving).
KoTextCustomItem is the base class for custom items (i.e.
KoTextFormat * format() const
The formatting given to this 'special' character Slightly slow (does a linear search in the paragraph...
KoTextDocument * textDocument() const
The text document in which this customitem is.
virtual void recalc()
Reimplemented by KoVariable to recalculate the value.
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
const TQFontMetrics & refFontMetrics() const
TQFont screenFont(const KoTextZoomHandler *zh) const
Returns the font to be used at the zoom & resolution given by 'zh'.
static TQColor defaultTextColor(TQPainter *painter)
Call this when a text color is set to 'invalid', meaning 'whatever the default for the color scheme i...
This class extends KoZoomHandler to add support for WYSIWYG text layouting.
static double ptToLayoutUnitPt(double pt)
Not zoom dependent.
int layoutUnitToPixelX(int lupix) const
The "layout unit pixel" -> "[zoomed] view pixel" conversions.
int pixelToLayoutUnitX(int x) const
The "[zoomed] view pixel" -> "layout unit pixel" conversions.
static TQCString defaultFormat()
Return the default date format for old file.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context) const
Save to Oasis XML.
virtual void saveVariable(TQDomElement &parentElem)
Variable should reimplement this to implement saving.
virtual void recalc()
Reimplemented by KoVariable to recalculate the value.
static TQCString formatStr(int &_correct)
Returns the time format string with prefix "TIME".
virtual TQStringList subTypeList()
List of available subtypes (translated). Use variableSubType() to map index to ID.
virtual void resize()
Reimplement this to calculate the item width It is important to start with "if ( m_deleted ) return;"...
A KoVariable is a custom item, i.e.
virtual void drawCustomItem(TQPainter *p, int x, int y, int wpix, int hpix, int ascentpix, int cx, int cy, int cw, int ch, const TQColorGroup &cg, bool selected, int offset, bool drawingShadow)
All coordinates are in pixels.
virtual TQStringList subTypeList()
List of available subtypes (translated). Use variableSubType() to map index to ID.
TQVariant varValue() const
Return the variable value, as a TQVariant, before format conversion.
void drawCustomItemHelper(TQPainter *p, int x, int y, int wpix, int hpix, int ascentpix, const TQColorGroup &cg, bool selected, int offset, KoTextFormat *fmt, const TQFont &font, TQColor textColor, bool drawingShadow)
Called by drawCustomItem.
virtual TQString text(bool realValue=false)
Returns the text to be displayed for this variable It doesn't need to be cached, convert() is fast,...
virtual void resize()
Reimplement this to calculate the item width It is important to start with "if ( m_deleted ) return;"...
virtual void saveVariable(TQDomElement &parentElem)=0
Variable should reimplement this to implement saving.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context) const
Save to Oasis XML.
virtual void save(TQDomElement &parentElem)
Save the variable.
void recalcAndRepaint()
Ask this variable to recalculate and to repaint itself Only use this if you're working on a single va...
A class for writing out XML (to any TQIODevice), with a special attention on performance.
void addConfigItem(const TQString &configName, const TQString &value)
Special helper for writing config item into settings.xml.
void startElement(const char *tagName, bool indentInside=true)
Start a new element, as a child of the current element.
void addTextNode(const TQString &str)
Overloaded version of addTextNode( const char* ), which is a bit slower because it needs to convert s...
void endElement()
Terminate the current element.
void addAttribute(const char *attrName, const TQString &value)
Overloaded version of addAttribute( const char*, const char* ), which is a bit slower because it need...
virtual void setChecked(bool)
const char * name(StdAction id)
KOFFICECORE_EXPORT TQDomElement namedItemNS(const TQDomNode &node, const char *nsURI, const char *localName)
A namespace-aware version of TQDomNode::namedItem(), which also takes care of casting to a TQDomEleme...