27#include <KoGenStyles.h>
28#include <KoOasisStyles.h>
29#include <KoStyleStack.h>
30#include <KoXmlWriter.h>
33#include "kspread_util.h"
34#include "kspread_doc.h"
36#include "kspread_style.h"
40static uint calculateValue( TQPen
const & pen )
42 uint n = pen.color().red() + pen.color().green() + pen.color().blue();
44 n += 1000 * pen.width();
45 n += 10000 * (uint) pen.style();
55 m_alignX( Format::Undefined ),
56 m_alignY( Format::Middle ),
57 m_floatFormat( Format::OnlyNegSigned ),
58 m_floatColor( Format::AllBlack ),
59 m_formatType( Generic_format ),
61 m_bgColor( TQt::white ),
62 m_backGroundBrush( TQt::red, TQt::NoBrush ),
68 TQFont f( KoGlobal::defaultFont() );
70 m_fontSize = f.pointSize();
72 TQPen pen( TQt::black, 1, TQt::NoPen );
82 m_leftPenValue = calculateValue( pen );
83 m_topPenValue = calculateValue( pen );
84 m_rightPenValue = calculateValue( pen );
85 m_bottomPenValue = calculateValue( pen );
91 : m_parent( ( style->m_type == BUILTIN || style->m_type == CUSTOM ) ? (
CustomStyle *) style : 0 ),
94 m_featuresSet( ( style->m_type == BUILTIN || style->m_type == CUSTOM ) ? 0 : style->m_featuresSet ),
95 m_alignX( style->m_alignX ),
96 m_alignY( style->m_alignY ),
97 m_floatFormat( style->m_floatFormat ),
98 m_floatColor( style->m_floatColor ),
99 m_formatType( style->m_formatType ),
100 m_fontFamily( style->m_fontFamily ),
101 m_fontFlags( style->m_fontFlags ),
102 m_fontSize( style->m_fontSize ),
103 m_textPen( style->m_textPen ),
104 m_bgColor( style->m_bgColor ),
105 m_rightBorderPen( style->m_rightBorderPen ),
106 m_bottomBorderPen( style->m_bottomBorderPen ),
107 m_leftBorderPen( style->m_leftBorderPen ),
108 m_topBorderPen( style->m_topBorderPen ),
109 m_fallDiagonalPen( style->m_fallDiagonalPen ),
110 m_goUpDiagonalPen( style->m_goUpDiagonalPen ),
111 m_backGroundBrush( style->m_backGroundBrush ),
112 m_rotateAngle( style->m_rotateAngle ),
113 m_indent( style->m_indent ),
114 m_strFormat( style->m_strFormat ),
115 m_precision( style->m_precision ),
116 m_prefix( style->m_prefix ),
117 m_postfix( style->m_postfix ),
118 m_currency( style->m_currency ),
119 m_properties( style->m_properties )
132 if ( m_featuresSet != style.m_featuresSet )
134 if ( m_type != style.m_type )
140 ( m_featuresSet & SAngle ) && ( m_rotateAngle != style.m_rotateAngle ) ||
156 ( m_featuresSet & SFloatFormat ) && ( m_floatFormat != style.m_floatFormat ) ||
158 ( m_featuresSet & SFormatType ) && ( m_formatType != style.m_formatType ) ||
163 ( m_featuresSet & SFontFlag ) && ( m_fontFlags != style.m_fontFlags ) ||
164 ( m_featuresSet & SFontSize ) && ( m_fontSize != style.m_fontSize ) ||
171 if ( ( m_featuresSet & SDontPrintText ) && ( differingProperties & PDontPrintText ) ||
172 ( m_featuresSet & SCustomFormat ) && ( differingProperties & PCustomFormat ) ||
173 ( m_featuresSet & SNotProtected ) && ( differingProperties & PNotProtected ) ||
174 ( m_featuresSet & SHideAll ) && ( differingProperties & PHideAll ) ||
175 ( m_featuresSet & SHideFormula ) && ( differingProperties & PHideFormula ) ||
176 ( m_featuresSet & SMultiRow ) && ( differingProperties & PMultiRow ) ||
177 ( m_featuresSet & SVerticalText ) && ( differingProperties & PVerticalText ) )
184void Style::loadOasisStyle( KoOasisStyles& oasisStyles,
const TQDomElement & element )
187 KoStyleStack styleStack;
188 styleStack.push( element );
189 styleStack.setTypeProperties(
"table-cell" );
190 loadOasisTableCellProperties( oasisStyles, styleStack );
191 styleStack.setTypeProperties(
"text" );
192 loadOasisTextProperties( oasisStyles, styleStack );
193 styleStack.setTypeProperties(
"paragraph" );
194 loadOasisParagraphProperties( oasisStyles, styleStack );
196 loadOasisDataStyle( oasisStyles, element );
199void Style::loadOasisDataStyle( KoOasisStyles& oasisStyles,
const TQDomElement& element )
202 if ( element.hasAttributeNS( KoXmlNS::style,
"data-style-name" ) )
209 const TQString styleName = element.attributeNS( KoXmlNS::style,
"data-style-name", TQString() );
210 if ( oasisStyles.dataFormats().contains(styleName) )
212 const KoOasisStyles::NumericStyleFormat dataStyle = oasisStyles.dataFormats()[styleName];
214 TQString tmp = dataStyle.prefix;
215 if ( !tmp.isEmpty() )
218 m_featuresSet |= SPrefix;
220 tmp = dataStyle.suffix;
221 if ( !tmp.isEmpty() )
224 m_featuresSet |= SPostfix;
227 switch (dataStyle.type)
229 case KoOasisStyles::NumericStyleFormat::Number:
230 m_formatType = Number_format;
231 m_featuresSet |= SFormatType;
233 case KoOasisStyles::NumericStyleFormat::Scientific:
234 m_formatType = Scientific_format;
235 m_featuresSet |= SFormatType;
237 case KoOasisStyles::NumericStyleFormat::Currency:
238 kdDebug() <<
" currency-symbol: " << dataStyle.currencySymbol << endl;
239 if (!dataStyle.currencySymbol.isEmpty())
241 Currency currency(dataStyle.currencySymbol);
243 m_currency.symbol = currency.getDisplayCode();
245 m_formatType = Money_format;
246 m_featuresSet |= SFormatType;
248 case KoOasisStyles::NumericStyleFormat::Percentage:
249 m_formatType = Percentage_format;
250 m_featuresSet |= SFormatType;
252 case KoOasisStyles::NumericStyleFormat::Fraction:
255 tmp = dataStyle.formatStr;
256 if ( !tmp.isEmpty() )
258 m_formatType = Style::fractionType( tmp );
259 m_featuresSet |= SFormatType;
262 case KoOasisStyles::NumericStyleFormat::Date:
265 tmp = dataStyle.formatStr;
266 if ( !tmp.isEmpty() )
268 m_formatType = Style::dateType( tmp );
269 m_featuresSet |= SFormatType;
272 case KoOasisStyles::NumericStyleFormat::Time:
275 tmp = dataStyle.formatStr;
276 if ( !tmp.isEmpty() )
278 m_formatType = Style::timeType( tmp );
279 m_featuresSet |= SFormatType;
282 case KoOasisStyles::NumericStyleFormat::Boolean:
283 m_formatType = Number_format;
284 m_featuresSet |= SFormatType;
286 case KoOasisStyles::NumericStyleFormat::Text:
287 m_formatType = Text_format;
288 m_featuresSet |= SFormatType;
292 if (dataStyle.precision > -1)
295 m_featuresSet |= SPrecision;
301void Style::loadOasisParagraphProperties( KoOasisStyles& oasisStyles,
const KoStyleStack& styleStack )
303 Q_UNUSED( oasisStyles );
304 kdDebug() <<
"\t paragraph-properties" << endl;
305 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"text-align" ) )
307 TQString str = styleStack.attributeNS( KoXmlNS::fo,
"text-align" );
308 if ( str ==
"center" )
310 else if ( str ==
"end" )
312 else if ( str ==
"start" )
316 m_featuresSet |= SAlignX;
317 kdDebug() <<
"\t\t text-align: " << str << endl;
321void Style::loadOasisTableCellProperties( KoOasisStyles& oasisStyles,
const KoStyleStack& styleStack )
324 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"vertical-align" ) )
328 str = styleStack.attributeNS( KoXmlNS::style,
"vertical-align" );
329 if ( str ==
"bottom" )
331 else if ( str ==
"top" )
333 else if ( str ==
"middle" )
337 m_featuresSet |= SAlignY;
339 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"background-color" ) )
341 m_bgColor = TQColor( styleStack.attributeNS( KoXmlNS::fo,
"background-color" ) );
343 m_featuresSet |= SBackgroundColor;
346 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"wrap-option" )&&( styleStack.attributeNS( KoXmlNS::fo,
"wrap-option" )==
"wrap" ) )
348 setProperty( PMultiRow );
349 m_featuresSet |= SMultiRow;
351 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"cell-protect" ) )
353 str = styleStack.attributeNS( KoXmlNS::style,
"cell-protect" );
354 if ( str==
"hidden-and-protected" )
356 setProperty( PHideAll );
357 m_featuresSet |= SHideAll;
359 else if ( str ==
"protected formula-hidden" )
361 setProperty( PHideFormula );
362 m_featuresSet |= SHideFormula;
364 else if ( str ==
"protected" )
366 setProperty( PNotProtected );
367 m_featuresSet |= SNotProtected;
369 else if ( str ==
"formula-hidden" )
373 setNotProtected(
true );
374 setHideFormula(
true );
379 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"print-content" ) && ( styleStack.attributeNS( KoXmlNS::style,
"print-content" )==
"false" ) )
381 setProperty( PDontPrintText );
382 m_featuresSet |= SDontPrintText;
385 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"direction" ) && ( styleStack.attributeNS( KoXmlNS::style,
"direction" )==
"ttb" ) )
387 setProperty( PVerticalText );
388 m_featuresSet |= SVerticalText;
391 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"rotation-angle" ) )
394 int a = styleStack.attributeNS( KoXmlNS::style,
"rotation-angle" ).toInt( &ok );
395 kdDebug()<<
" rotation-angle :"<<a<<endl;
398 m_rotateAngle= ( -a );
399 m_featuresSet |= SAngle;
402 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"margin-left" ) )
405 setIndent( KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo,
"margin-left" ),0.0 ) );
406 m_featuresSet |= SIndent;
408 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"border" ) )
410 str=styleStack.attributeNS( KoXmlNS::fo,
"border" );
411 TQPen pen = convertOasisStringToPen( str );
412 m_featuresSet |= SLeftBorder;
413 m_featuresSet |= SRightBorder;
414 m_featuresSet |= STopBorder;
415 m_featuresSet |= SBottomBorder;
421 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"border-left" ) )
423 str=styleStack.attributeNS( KoXmlNS::fo,
"border-left" );
425 m_featuresSet |= SLeftBorder;
427 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"border-right" ) )
429 str=styleStack.attributeNS( KoXmlNS::fo,
"border-right" );
431 m_featuresSet |= SRightBorder;
433 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"border-top" ) )
435 str=styleStack.attributeNS( KoXmlNS::fo,
"border-top" );
437 m_featuresSet |= STopBorder;
439 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"border-bottom" ) )
441 str=styleStack.attributeNS( KoXmlNS::fo,
"border-bottom" );
443 m_featuresSet |= SBottomBorder;
445 if (styleStack.hasAttributeNS( KoXmlNS::style,
"diagonal-tl-br" ) )
447 str=styleStack.attributeNS( KoXmlNS::style,
"diagonal-tl-br" );
449 m_featuresSet |= SFallDiagonal;
451 if (styleStack.hasAttributeNS( KoXmlNS::style,
"diagonal-bl-tr" ) )
453 str=styleStack.attributeNS( KoXmlNS::style,
"diagonal-bl-tr" );
455 m_featuresSet |= SGoUpDiagonal;
458 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"style-name" ) )
460 kdDebug()<<
" style name :"<<styleStack.attributeNS( KoXmlNS::draw,
"style-name" )<<endl;
462 const TQDomElement * style = oasisStyles.findStyle( styleStack.attributeNS( KoXmlNS::draw,
"style-name" ),
"graphic" );
463 kdDebug()<<
" style :"<<style<<endl;
466 KoStyleStack drawStyleStack;
467 drawStyleStack.push( *style );
468 drawStyleStack.setTypeProperties(
"graphic" );
469 if ( drawStyleStack.hasAttributeNS( KoXmlNS::draw,
"fill" ) )
471 const TQString fill = drawStyleStack.attributeNS( KoXmlNS::draw,
"fill" );
472 kdDebug()<<
" load object gradient fill type :"<<fill<<endl;
474 if ( fill ==
"solid" || fill ==
"hatch" )
476 kdDebug()<<
" Style ******************************************************\n";
477 m_backGroundBrush=KoOasisStyles::loadOasisFillStyle( drawStyleStack, fill, oasisStyles );
478 m_featuresSet |= SBackgroundBrush;
481 kdDebug()<<
" fill style not supported into kspread : "<<fill<<endl;
487void Style::loadOasisTextProperties( KoOasisStyles& oasisStyles,
const KoStyleStack& styleStack )
489 Q_UNUSED( oasisStyles );
495 kdDebug() <<
"\t text-properties" << endl;
496 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"font-family" ) )
498 m_fontFamily = styleStack.attributeNS( KoXmlNS::fo,
"font-family" );
499 m_featuresSet |= SFontFamily;
500 m_featuresSet |= SFont;
501 kdDebug() <<
"\t\t fo:font-family: " <<
m_fontFamily << endl;
503 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"font-size" ) )
505 m_fontSize = (int) KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo,
"font-size" ), 10.0 );
506 m_featuresSet |= SFontSize;
507 m_featuresSet |= SFont;
508 kdDebug() <<
"\t\t fo:font-size: " << m_fontSize << endl;
510 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"font-style" ) )
512 if ( styleStack.attributeNS( KoXmlNS::fo,
"font-style" ) ==
"italic" )
514 m_fontFlags |= FItalic;
515 m_featuresSet |= SFontFlag;
516 m_featuresSet |= SFont;
517 kdDebug() <<
"\t\t fo:font-style: " <<
"italic" << endl;
520 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"font-weight" ) )
522 if ( styleStack.attributeNS( KoXmlNS::fo,
"font-weight" ) ==
"bold" )
524 m_fontFlags |= FBold;
525 m_featuresSet |= SFontFlag;
526 m_featuresSet |= SFont;
527 kdDebug() <<
"\t\t fo:font-weight: " <<
"bold" << endl;
530 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"text-underline-style" ) )
532 if ( styleStack.attributeNS( KoXmlNS::style,
"text-underline-style" ) !=
"none" )
534 m_fontFlags |= FUnderline;
535 m_featuresSet |= SFontFlag;
536 m_featuresSet |= SFont;
537 kdDebug() <<
"\t\t style:text-underline-style: " <<
"solid (actually: !none)" << endl;
540 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"text-underline-width" ) )
544 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"text-underline-color" ) )
548 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"color" ) )
550 TQColor color = TQColor( styleStack.attributeNS( KoXmlNS::fo,
"color" ) );
551 if ( color.isValid() )
553 m_featuresSet |= STextPen;
555 kdDebug() <<
"\t\t fo:color: " << TQString(color.name()) << endl;
558 if ( styleStack.hasAttributeNS( KoXmlNS::style,
"text-line-through-style" ) )
560 if ( styleStack.attributeNS( KoXmlNS::style,
"text-line-through-style" ) !=
"none"
563 m_fontFlags |= FStrike;
564 m_featuresSet |= SFontFlag;
565 m_featuresSet |= SFont;
566 kdDebug() <<
"\t\t text-line-through-style: " <<
"solid (actually: !none)" << endl;
571static TQString convertDateFormat(
const TQString& date )
573 TQString result = date;
574 result.replace(
"%Y",
"yyyy" );
575 result.replace(
"%y",
"yy" );
576 result.replace(
"%n",
"M" );
577 result.replace(
"%m",
"MM" );
578 result.replace(
"%e",
"d" );
579 result.replace(
"%d",
"dd" );
580 result.replace(
"%b",
"MMM" );
581 result.replace(
"%B",
"MMMM" );
582 result.replace(
"%a",
"ddd" );
583 result.replace(
"%A",
"dddd" );
587FormatType Style::dateType(
const TQString &_format )
589 const TQString dateFormatShort = convertDateFormat( TDEGlobal::locale()->dateFormatShort() );
590 const TQString dateFormat = convertDateFormat( TDEGlobal::locale()->dateFormat() );
592 if ( _format ==
"dd-MMM-yy" )
594 else if ( _format ==
"dd-MMM-yyyy" )
596 else if ( _format ==
"d-MM" )
598 else if ( _format ==
"dd-MM" )
600 else if ( _format ==
"dd/MM/yy" )
602 else if ( _format ==
"dd/MM/yyyy" )
604 else if ( _format ==
"MMM-yy" )
606 else if ( _format ==
"MMMM-yyyy" )
608 else if ( _format ==
"MMMMM-yy" )
609 return date_format10;
610 else if ( _format ==
"dd/MMM" )
611 return date_format11;
612 else if ( _format ==
"dd/MM" )
613 return date_format12;
614 else if ( _format ==
"dd/MMM/yyyy" )
615 return date_format13;
616 else if ( _format ==
"yyyy/MMM/dd" )
617 return date_format14;
618 else if ( _format ==
"yyyy-MMM-dd" )
619 return date_format15;
620 else if ( _format ==
"yyyy/MM/dd" )
621 return date_format16;
622 else if ( _format ==
"d MMMM yyyy" )
623 return date_format17;
624 else if ( _format ==
"MM/dd/yyyy" )
625 return date_format18;
626 else if ( _format ==
"MM/dd/yy" )
627 return date_format19;
628 else if ( _format ==
"MMM/dd/yy" )
629 return date_format20;
630 else if ( _format ==
"MMM/dd/yyyy" )
631 return date_format21;
632 else if ( _format ==
"MMM-yyyy" )
633 return date_format22;
634 else if ( _format ==
"yyyy" )
635 return date_format23;
636 else if ( _format ==
"yy" )
637 return date_format24;
638 else if ( _format ==
"yyyy/MM/dd" )
639 return date_format25;
640 else if ( _format ==
"yyyy/MMM/dd" )
641 return date_format26;
642 else if ( _format == dateFormatShort )
643 return ShortDate_format;
644 else if ( _format == dateFormat )
645 return TextDate_format;
647 return ShortDate_format;
650FormatType Style::timeType(
const TQString &_format )
652 if ( _format ==
"h:mm AP" )
654 else if ( _format ==
"h:mm:ss AP" )
656 else if ( _format ==
"hh \\h mm \\m\\i\\n ss \\s" )
658 else if ( _format ==
"hh:mm" )
660 else if ( _format ==
"hh:mm:ss" )
662 else if ( _format ==
"m:ss" )
664 else if ( _format ==
"h:mm:ss" )
666 else if ( _format ==
"h:mm" )
672FormatType Style::fractionType(
const TQString &_format )
674 if ( _format ==
"# ?/2" )
675 return fraction_half;
676 else if ( _format ==
"# ?/4" )
677 return fraction_quarter;
678 else if ( _format ==
"# ?/8" )
679 return fraction_eighth;
680 else if ( _format ==
"# ?/16" )
681 return fraction_sixteenth;
682 else if ( _format ==
"# ?/10" )
683 return fraction_tenth;
684 else if ( _format ==
"# ?/100" )
685 return fraction_hundredth;
686 else if ( _format ==
"# ?/?" )
687 return fraction_one_digit;
688 else if ( _format ==
"# \?\?/\?\?" )
689 return fraction_two_digits;
690 else if ( _format ==
"# \?\?\?/\?\?\?" )
691 return fraction_three_digits;
693 return fraction_half;
698 const TQString &_prefix,
const TQString &_postfix,
699 int _precision,
const TQString& symbol )
707 styleName = saveOasisStyleNumericNumber( mainStyles, _style, _precision, _prefix, _postfix );
711 styleName = saveOasisStyleNumericText( mainStyles, _style, _precision, _prefix, _postfix );
712 valueType =
"string";
715 styleName = saveOasisStyleNumericMoney( mainStyles, _style,symbol, _precision, _prefix, _postfix );
716 valueType =
"currency";
718 case Percentage_format:
719 styleName = saveOasisStyleNumericPercentage( mainStyles, _style, _precision, _prefix, _postfix );
720 valueType =
"percentage";
722 case Scientific_format:
723 styleName = saveOasisStyleNumericScientific( mainStyles, _style, _prefix, _postfix, _precision );
726 case ShortDate_format:
727 case TextDate_format:
728 styleName = saveOasisStyleNumericDate( mainStyles, _style, _prefix, _postfix );
732 case SecondeTime_format:
741 styleName = saveOasisStyleNumericTime( mainStyles, _style, _prefix, _postfix );
745 case fraction_quarter:
746 case fraction_eighth:
747 case fraction_sixteenth:
749 case fraction_hundredth:
750 case fraction_one_digit:
751 case fraction_two_digits:
752 case fraction_three_digits:
753 styleName = saveOasisStyleNumericFraction( mainStyles,_style, _prefix, _postfix );
782 styleName = saveOasisStyleNumericDate( mainStyles, _style, _prefix, _postfix );
786 styleName = saveOasisStyleNumericCustom( mainStyles, _style, _prefix, _postfix );
790 if (_precision > -1 || !_prefix.isEmpty() || !_postfix.isEmpty())
792 styleName = saveOasisStyleNumericNumber( mainStyles, _style, _precision, _prefix, _postfix );
797 if ( !styleName.isEmpty() )
799 style.addAttribute(
"style:data-style-name", styleName );
804TQString Style::saveOasisStyleNumericNumber( KoGenStyles& mainStyles, FormatType ,
int _precision,
805 const TQString &_prefix,
const TQString &_suffix )
808 if ( _precision == -1 )
813 for (
int i = 0; i <_precision; i++ )
819 return KoOasisStyles::saveOasisNumberStyle( mainStyles, format, _prefix, _suffix );
822TQString Style::saveOasisStyleNumericText( KoGenStyles& , FormatType ,
int ,
823 const TQString &,
const TQString & )
828TQString Style::saveOasisStyleNumericMoney( KoGenStyles& mainStyles, FormatType ,
829 const TQString& symbol,
int _precision,
830 const TQString &_prefix,
const TQString &_suffix )
833 if ( _precision == -1 )
838 for (
int i = 0; i <_precision; i++ )
844 return KoOasisStyles::saveOasisCurrencyStyle( mainStyles, format, symbol, _prefix, _suffix );
847TQString Style::saveOasisStyleNumericPercentage( KoGenStyles&mainStyles, FormatType ,
849 const TQString &_prefix,
const TQString &_suffix )
857 if ( _precision == -1 )
862 for (
int i = 0; i <_precision; i++ )
868 return KoOasisStyles::saveOasisPercentageStyle( mainStyles, format, _prefix, _suffix );
872TQString Style::saveOasisStyleNumericScientific( KoGenStyles&mainStyles, FormatType ,
873 const TQString &_prefix,
const TQString _suffix,
int _precision )
879 if ( _precision == -1 )
884 for (
int i = 0; i <_precision; i++ )
888 format =
"0."+tmp+
"E+00";
890 return KoOasisStyles::saveOasisScientificStyle( mainStyles, format, _prefix, _suffix );
893TQString Style::saveOasisStyleNumericDate( KoGenStyles&mainStyles, FormatType _style,
894 const TQString &_prefix,
const TQString &_suffix )
901 case ShortDate_format:
902 format = TDEGlobal::locale()->dateFormatShort();
905 case TextDate_format:
906 format = TDEGlobal::locale()->dateFormat();
910 format =
"dd-MMM-yy";
913 format =
"dd-MMM-yyyy";
925 format =
"dd/MM/yyyy";
934 format =
"MMMM-yyyy";
946 format =
"dd/MMM/yyyy";
949 format =
"yyyy/MMM/dd";
952 format =
"yyyy-MMM-dd";
955 format =
"yyyy/MM/dd";
958 format =
"d MMMM yyyy";
961 format =
"MM/dd/yyyy";
967 format =
"MMM/dd/yy";
970 format =
"MMM/dd/yyyy";
982 format =
"yyyy/MM/dd";
985 format =
"yyyy/MMM/dd";
988 kdDebug()<<
"this date format is not defined ! :"<<_style<<endl;
991 return KoOasisStyles::saveOasisDateStyle( mainStyles, format, locale, _prefix, _suffix );
994TQString Style::saveOasisStyleNumericCustom( KoGenStyles& , FormatType ,
995 const TQString &,
const TQString & )
1014TQString Style::saveOasisStyleNumericTime( KoGenStyles& mainStyles, FormatType _style,
1015 const TQString &_prefix,
const TQString &_suffix )
1026 bool locale =
false;
1031 format =
"hh:mm:ss";
1033 case SecondeTime_format:
1040 format =
"h:mm:ss AP";
1043 format =
"hh \\h mm \\m\\i\\n ss \\s";
1049 format =
"hh:mm:ss";
1061 kdDebug()<<
"time format not defined :"<<_style<<endl;
1064 return KoOasisStyles::saveOasisTimeStyle( mainStyles, format, locale, _prefix, _suffix );
1068TQString Style::saveOasisStyleNumericFraction( KoGenStyles &mainStyles, FormatType _style,
1069 const TQString &_prefix,
const TQString _suffix )
1080 case fraction_quarter:
1083 case fraction_eighth:
1086 case fraction_sixteenth:
1089 case fraction_tenth:
1092 case fraction_hundredth:
1095 case fraction_one_digit:
1098 case fraction_two_digits:
1099 format =
"# \?\?/\?\?";
1101 case fraction_three_digits:
1102 format =
"# \?\?\?/\?\?\?";
1105 kdDebug()<<
" fraction format not defined :"<<_style<<endl;
1109 return KoOasisStyles::saveOasisFractionStyle( mainStyles, format, _prefix, _suffix );
1116 if (style.type() == 0)
1117 style = KoGenStyle( Doc::STYLE_CELL_AUTO,
"table-cell" );
1135 if ( m_parent && (m_parent->type() !=
BUILTIN || m_parent->name() !=
"Default") )
1137 style.addAttribute(
"style:parent-style-name", m_parent->name() );
1139 if ( featureSet( SAlignX ) && alignX() != Format::Undefined )
1144 case Format::Center:
1153 case Format::Undefined:
1156 if ( !value.isEmpty() )
1158 style.addProperty(
"style:text-align-source",
"fix" );
1159 style.addProperty(
"fo:text-align", value, KoGenStyle::ParagraphType );
1163 if ( featureSet( SAlignY ) )
1171 case Format::Middle:
1174 case Format::Bottom:
1177 case Format::UndefinedY:
1181 if (!value.isEmpty())
1182 style.addProperty(
"style:vertical-align", value );
1185 if ( featureSet( SBackgroundColor ) &&
m_bgColor != TQColor() &&
m_bgColor.isValid() )
1188 if ( featureSet( SMultiRow ) && hasProperty( PMultiRow ) )
1189 style.addProperty(
"fo:wrap-option",
"wrap" );
1191 if ( featureSet( SVerticalText ) && hasProperty( PVerticalText ) )
1193 style.addProperty(
"style:direction",
"ttb" );
1194 style.addProperty(
"style:rotation-angle",
"0" );
1195 style.addProperty(
"style:rotation-align",
"none" );
1198 if ( featureSet( SFloatFormat ) )
1199 format.setAttribute(
"float", (
int) m_floatFormat );
1201 if ( featureSet( SFloatColor ) )
1202 format.setAttribute(
"floatcolor", (
int)
m_floatColor );
1204 if ( featureSet( SCustomFormat ) && !strFormat().isEmpty() )
1207 if ( featureSet( SFormatType ) && formatType() == Format::Money )
1209 format.setAttribute(
"type", (
int)
m_currency.type );
1210 format.setAttribute(
"symbol",
m_currency.symbol );
1213 if ( featureSet( SAngle ) && m_rotateAngle != 0 )
1215 style.addProperty(
"style:rotation-align",
"none" );
1216 style.addProperty(
"style:rotation-angle", TQString::number( -1.0 *m_rotateAngle ) );
1219 if ( featureSet( SIndent ) &&
m_indent != 0.0 )
1221 style.addPropertyPt(
"fo:margin-left",
m_indent, KoGenStyle::ParagraphType );
1227 if ( featureSet( SDontPrintText ) && hasProperty( PDontPrintText ) )
1228 style.addProperty(
"style:print-content",
"false");
1231 bool hideAll =
false;
1232 bool hideFormula =
false;
1233 bool isNotProtected =
false;
1235 if ( featureSet( SNotProtected ) && hasProperty( PNotProtected ) )
1236 isNotProtected =
true;
1238 if ( featureSet( SHideAll ) && hasProperty( PHideAll ) )
1241 if ( featureSet( SHideFormula ) && hasProperty( PHideFormula ) )
1245 style.addProperty(
"style:cell-protect",
"hidden-and-protected" );
1248 if ( isNotProtected && !hideFormula )
1249 style.addProperty(
"style:cell-protect",
"none" );
1250 else if ( isNotProtected && hideFormula )
1251 style.addProperty(
"style:cell-protect",
"formula-hidden" );
1252 else if ( hideFormula )
1253 style.addProperty(
"style:cell-protect",
"protected formula-hidden" );
1254 else if ( featureSet( SNotProtected ) && !hasProperty( PNotProtected ) )
1256 style.addProperty(
"style:cell-protect",
"protected" );
1267 if ( featureSet( SLeftBorder ) && featureSet( SRightBorder ) &&
1268 featureSet( STopBorder ) && featureSet( SBottomBorder ) &&
1274 style.addProperty(
"fo:border", convertOasisPenToString(
m_leftBorderPen ) );
1278 if ( featureSet( SLeftBorder ) && (
m_leftBorderPen.style() != TQt::NoPen ) )
1279 style.addProperty(
"fo:border-left", convertOasisPenToString(
m_leftBorderPen ) );
1281 if ( featureSet( SRightBorder ) && (
m_rightBorderPen.style() != TQt::NoPen ) )
1282 style.addProperty(
"fo:border-right", convertOasisPenToString(
m_rightBorderPen ) );
1284 if ( featureSet( STopBorder ) && (
m_topBorderPen.style() != TQt::NoPen ) )
1285 style.addProperty(
"fo:border-top", convertOasisPenToString(
m_topBorderPen ) );
1287 if ( featureSet( SBottomBorder ) && (
m_bottomBorderPen.style() != TQt::NoPen ) )
1288 style.addProperty(
"fo:border-bottom", convertOasisPenToString(
m_bottomBorderPen ) );
1290 if ( featureSet( SFallDiagonal ) && (
m_fallDiagonalPen.style() != TQt::NoPen ) )
1292 style.addProperty(
"style:diagonal-tl-br", convertOasisPenToString(
m_fallDiagonalPen ) );
1294 if ( featureSet( SGoUpDiagonal ) && (
m_goUpDiagonalPen.style() != TQt::NoPen ) )
1296 style.addProperty(
"style:diagonal-bl-tr", convertOasisPenToString(
m_goUpDiagonalPen ) );
1300 if ( featureSet( SFontFamily ) )
1302 style.addProperty(
"fo:font-family",
m_fontFamily, KoGenStyle::TextType );
1304 if ( featureSet( SFontSize ) )
1306 style.addPropertyPt(
"fo:font-size",m_fontSize, KoGenStyle::TextType );
1309 if ( featureSet( SFontFlag ) && m_fontFlags & (uint) FBold )
1310 style.addProperty(
"fo:font-weight",
"bold", KoGenStyle::TextType );
1312 if ( featureSet( SFontFlag ) && m_fontFlags & (uint) FItalic )
1313 style.addProperty(
"fo:font-style",
"italic", KoGenStyle::TextType );
1315 if ( featureSet( SFontFlag ) && m_fontFlags & (uint) FUnderline )
1318 style.addProperty(
"style:text-underline-style",
"solid", KoGenStyle::TextType );
1320 style.addProperty(
"style:text-underline-width",
"auto", KoGenStyle::TextType );
1321 style.addProperty(
"style:text-underline-color",
"font-color", KoGenStyle::TextType );
1324 if ( featureSet( SFontFlag ) && m_fontFlags & (uint) FStrike )
1325 style.addProperty(
"style:text-line-through-style",
"solid", KoGenStyle::TextType );
1327 if ( featureSet( STextPen ) &&
m_textPen.color().isValid() )
1334 if ( featureSet( SBackgroundBrush ) && (
m_backGroundBrush.style() != TQt::NoBrush) )
1337 if ( !tmp.isEmpty() )
1338 style.addProperty(
"draw:style-name", tmp );
1343 int _precision = -1;
1344 if ( featureSet( SPrefix ) && !prefix().isEmpty() )
1346 if ( featureSet( SPostfix ) && !postfix().isEmpty() )
1348 if ( featureSet( SPrecision ) &&
m_precision != -1 )
1352 if ( featureSet( SFormatType ) && m_formatType == Money_format )
1354 symbol = Currency::getCurrencyCode(
m_currency.type);
1358 _prefix, _postfix, _precision,
1360 if ( !numericStyle.isEmpty() )
1361 style.addAttribute(
"style:data-style-name", numericStyle );
1364TQString Style::saveOasisBackgroundStyle( KoGenStyles &mainStyles,
const TQBrush &brush )
1366 KoGenStyle styleobjectauto = KoGenStyle( KoGenStyle::STYLE_GRAPHICAUTO,
"graphic" );
1367 KoOasisStyles::saveOasisFillStyle( styleobjectauto, mainStyles, brush );
1368 return mainStyles.lookup( styleobjectauto,
"gr" );
1371void Style::saveXML( TQDomDocument & doc, TQDomElement & format )
const
1373 if ( featureSet( SAlignX ) && alignX() != Format::Undefined )
1374 format.setAttribute(
"alignX", (
int)
m_alignX );
1376 if ( featureSet( SAlignY ) && alignY() != Format::Middle )
1377 format.setAttribute(
"alignY", (
int)
m_alignY );
1379 if ( featureSet( SBackgroundColor ) &&
m_bgColor != TQColor() &&
m_bgColor.isValid() )
1380 format.setAttribute(
"bgcolor",
m_bgColor.name() );
1382 if ( featureSet( SMultiRow ) && hasProperty( PMultiRow ) )
1383 format.setAttribute(
"multirow",
"yes" );
1385 if ( featureSet( SVerticalText ) && hasProperty( PVerticalText ) )
1386 format.setAttribute(
"verticaltext",
"yes" );
1388 if ( featureSet( SPrecision ) )
1391 if ( featureSet( SPrefix ) && !prefix().isEmpty() )
1392 format.setAttribute(
"prefix",
m_prefix );
1394 if ( featureSet( SPostfix ) && !postfix().isEmpty() )
1395 format.setAttribute(
"postfix",
m_postfix );
1397 if ( featureSet( SFloatFormat ) )
1398 format.setAttribute(
"float", (
int) m_floatFormat );
1400 if ( featureSet( SFloatColor ) )
1401 format.setAttribute(
"floatcolor", (
int)
m_floatColor );
1403 if ( featureSet( SFormatType ) )
1404 format.setAttribute(
"format",(
int) m_formatType );
1406 if ( featureSet( SCustomFormat ) && !strFormat().isEmpty() )
1409 if ( featureSet( SFormatType ) && formatType() == Money_format )
1411 format.setAttribute(
"type", (
int)
m_currency.type );
1412 format.setAttribute(
"symbol",
m_currency.symbol );
1415 if ( featureSet( SAngle ) )
1416 format.setAttribute(
"angle", m_rotateAngle );
1418 if ( featureSet( SIndent ) )
1419 format.setAttribute(
"indent",
m_indent );
1421 if ( featureSet( SDontPrintText ) && hasProperty( PDontPrintText ) )
1422 format.setAttribute(
"dontprinttext",
"yes" );
1424 if ( featureSet( SNotProtected ) && hasProperty( PNotProtected ) )
1425 format.setAttribute(
"noprotection",
"yes" );
1427 if ( featureSet( SHideAll ) && hasProperty( PHideAll ) )
1428 format.setAttribute(
"hideall",
"yes" );
1430 if ( featureSet( SHideFormula ) && hasProperty( PHideFormula ) )
1431 format.setAttribute(
"hideformula",
"yes" );
1433 if ( featureSet( SFontFamily ) )
1435 if ( featureSet( SFontSize ) )
1436 format.setAttribute(
"font-size", m_fontSize );
1437 if ( featureSet( SFontFlag ) )
1438 format.setAttribute(
"font-flags", m_fontFlags );
1443 if ( featureSet( STextPen ) &&
m_textPen.color().isValid() )
1444 format.appendChild( util_createElement(
"pen",
m_textPen, doc ) );
1446 if ( featureSet( SBackgroundBrush ) )
1452 if ( featureSet( SLeftBorder ) )
1454 TQDomElement left = doc.createElement(
"left-border" );
1455 left.appendChild( util_createElement(
"pen",
m_leftBorderPen, doc ) );
1456 format.appendChild( left );
1459 if ( featureSet( STopBorder ) )
1461 TQDomElement top = doc.createElement(
"top-border" );
1462 top.appendChild( util_createElement(
"pen",
m_topBorderPen, doc ) );
1463 format.appendChild( top );
1466 if ( featureSet( SRightBorder ) )
1468 TQDomElement right = doc.createElement(
"right-border" );
1470 format.appendChild( right );
1473 if ( featureSet( SBottomBorder ) )
1475 TQDomElement bottom = doc.createElement(
"bottom-border" );
1477 format.appendChild( bottom );
1480 if ( featureSet( SFallDiagonal ) )
1482 TQDomElement fallDiagonal = doc.createElement(
"fall-diagonal" );
1483 fallDiagonal.appendChild( util_createElement(
"pen",
m_fallDiagonalPen, doc ) );
1484 format.appendChild( fallDiagonal );
1487 if ( featureSet( SGoUpDiagonal ) )
1489 TQDomElement goUpDiagonal = doc.createElement(
"up-diagonal" );
1490 goUpDiagonal.appendChild( util_createElement(
"pen",
m_goUpDiagonalPen, doc ) );
1491 format.appendChild( goUpDiagonal );
1495bool Style::loadXML( TQDomElement & format )
1498 if ( format.hasAttribute(
"type" ) )
1500 m_type = (
StyleType) format.attribute(
"type" ).toInt( &ok );
1505 if ( format.hasAttribute(
"alignX" ) )
1507 Format::Align a = (Format::Align) format.attribute(
"alignX" ).toInt( &ok );
1510 if ( (
unsigned int) a >= 1 || (
unsigned int) a <= 4 )
1513 m_featuresSet |= SAlignX;
1516 if ( format.hasAttribute(
"alignY" ) )
1518 Format::AlignY a = (Format::AlignY) format.attribute(
"alignY" ).toInt( &ok );
1521 if ( (
unsigned int) a >= 1 || (
unsigned int) a < 4 )
1524 m_featuresSet |= SAlignY;
1528 if ( format.hasAttribute(
"bgcolor" ) )
1530 m_bgColor = TQColor( format.attribute(
"bgcolor" ) );
1533 m_featuresSet |= SBackgroundColor;
1536 if ( format.hasAttribute(
"multirow" ) )
1538 setProperty( PMultiRow );
1539 m_featuresSet |= SMultiRow;
1542 if ( format.hasAttribute(
"verticaltext" ) )
1544 setProperty( PVerticalText );
1545 m_featuresSet |= SVerticalText;
1548 if ( format.hasAttribute(
"precision" ) )
1550 int i = format.attribute(
"precision" ).toInt( &ok );
1553 kdDebug(36001) <<
"Value out of range Cell::precision=" << i << endl;
1557 m_featuresSet |= SPrecision;
1560 if ( format.hasAttribute(
"float" ) )
1562 Format::FloatFormat a = (Format::FloatFormat)format.attribute(
"float" ).toInt( &ok );
1565 if ( (
unsigned int) a >= 1 || (
unsigned int) a <= 3 )
1568 m_featuresSet |= SFloatFormat;
1572 if ( format.hasAttribute(
"floatcolor" ) )
1574 Format::FloatColor a = (Format::FloatColor) format.attribute(
"floatcolor" ).toInt( &ok );
1575 if ( !ok )
return false;
1576 if ( (
unsigned int) a >= 1 || (
unsigned int) a <= 2 )
1579 m_featuresSet |= SFloatColor;
1583 if ( format.hasAttribute(
"format" ) )
1585 int fo = format.attribute(
"format" ).toInt( &ok );
1588 m_formatType = ( FormatType ) fo;
1589 m_featuresSet |= SFormatType;
1591 if ( format.hasAttribute(
"custom" ) )
1594 m_featuresSet |= SCustomFormat;
1596 if ( m_formatType == Money_format )
1598 if ( format.hasAttribute(
"type" ) )
1600 m_currency.type = format.attribute(
"type" ).toInt( &ok );
1604 if ( format.hasAttribute(
"symbol" ) )
1606 m_currency.symbol = format.attribute(
"symbol" );
1608 m_featuresSet |= SFormatType;
1610 if ( format.hasAttribute(
"angle" ) )
1612 m_rotateAngle = format.attribute(
"angle" ).toInt( &ok );
1615 m_featuresSet |= SAngle;
1617 if ( format.hasAttribute(
"indent" ) )
1619 m_indent = format.attribute(
"indent" ).toDouble( &ok );
1622 m_featuresSet |= SIndent;
1624 if ( format.hasAttribute(
"dontprinttext" ) )
1626 setProperty( PDontPrintText );
1627 m_featuresSet |= SDontPrintText;
1630 if ( format.hasAttribute(
"noprotection" ) )
1632 setProperty( PNotProtected );
1633 m_featuresSet |= SNotProtected;
1636 if ( format.hasAttribute(
"hideall" ) )
1638 setProperty( PHideAll );
1639 m_featuresSet |= SHideAll;
1642 if ( format.hasAttribute(
"hideformula" ) )
1644 setProperty( PHideFormula );
1645 m_featuresSet |= SHideFormula;
1649 TQDomElement font = format.namedItem(
"font" ).toElement();
1650 if ( !font.isNull() )
1652 TQFont f( util_toFont( font ) );
1654 m_fontSize = f.pointSize();
1656 m_fontFlags |= FItalic;
1658 m_fontFlags |= FBold;
1659 if ( f.underline() )
1660 m_fontFlags |= FUnderline;
1661 if ( f.strikeOut() )
1662 m_fontFlags |= FStrike;
1664 m_featuresSet |= SFont;
1665 m_featuresSet |= SFontFamily;
1666 m_featuresSet |= SFontFlag;
1667 m_featuresSet |= SFontSize;
1670 if ( format.hasAttribute(
"font-family" ) )
1673 m_featuresSet |= SFont;
1674 m_featuresSet |= SFontFamily;
1676 if ( format.hasAttribute(
"font-size" ) )
1678 m_fontSize = format.attribute(
"font-size" ).toInt( &ok );
1681 m_featuresSet |= SFont;
1682 m_featuresSet |= SFontSize;
1685 if ( format.hasAttribute(
"font-flags" ) )
1687 m_fontFlags = format.attribute(
"font-flags" ).toInt( &ok );
1690 m_featuresSet |= SFont;
1691 m_featuresSet |= SFontFlag;
1694 if ( format.hasAttribute(
"brushcolor" ) )
1702 if ( format.hasAttribute(
"brushstyle" ) )
1704 m_backGroundBrush.setStyle( (TQt::BrushStyle) format.attribute(
"brushstyle" ).toInt( &ok ) );
1709 m_featuresSet |= SBackgroundBrush;
1712 TQDomElement pen = format.namedItem(
"pen" ).toElement();
1713 if ( !pen.isNull() )
1717 m_featuresSet |= STextPen;
1720 TQDomElement left = format.namedItem(
"left-border" ).toElement();
1721 if ( !left.isNull() )
1723 TQDomElement pen = left.namedItem(
"pen" ).toElement();
1724 if ( !pen.isNull() )
1728 m_featuresSet |= SLeftBorder;
1732 TQDomElement top = format.namedItem(
"top-border" ).toElement();
1733 if ( !top.isNull() )
1735 TQDomElement pen = top.namedItem(
"pen" ).toElement();
1736 if ( !pen.isNull() )
1740 m_featuresSet |= STopBorder;
1744 TQDomElement right = format.namedItem(
"right-border" ).toElement();
1745 if ( !right.isNull() )
1747 TQDomElement pen = right.namedItem(
"pen" ).toElement();
1748 if ( !pen.isNull() )
1752 m_featuresSet |= SRightBorder;
1756 TQDomElement bottom = format.namedItem(
"bottom-border" ).toElement();
1757 if ( !bottom.isNull() )
1759 TQDomElement pen = bottom.namedItem(
"pen" ).toElement();
1760 if ( !pen.isNull() )
1764 m_featuresSet |= SBottomBorder;
1768 TQDomElement fallDiagonal = format.namedItem(
"fall-diagonal" ).toElement();
1769 if ( !fallDiagonal.isNull() )
1771 TQDomElement pen = fallDiagonal.namedItem(
"pen" ).toElement();
1772 if ( !pen.isNull() )
1776 m_featuresSet |= SFallDiagonal;
1780 TQDomElement goUpDiagonal = format.namedItem(
"up-diagonal" ).toElement();
1781 if ( !goUpDiagonal.isNull() )
1783 TQDomElement pen = goUpDiagonal.namedItem(
"pen" ).toElement();
1784 if ( !pen.isNull() )
1788 m_featuresSet |= SGoUpDiagonal;
1792 if ( format.hasAttribute(
"prefix" ) )
1794 m_prefix = format.attribute(
"prefix" );
1795 m_featuresSet |= SPrefix;
1797 if ( format.hasAttribute(
"postfix" ) )
1799 m_postfix = format.attribute(
"postfix" );
1800 m_featuresSet |= SPostfix;
1810 m_parentName = m_parent->name();
1825 if ( m_usageCount < 1 )
1836bool Style::hasProperty( Properties p )
const
1841 case PDontPrintText:
1863 kdWarning() <<
"Unhandled property" << endl;
1867 return ( !m_parent || featureSet( f ) ? (
m_properties & (uint) p ) : m_parent->hasProperty( p ) );
1870bool Style::hasFeature( FlagsSet f,
bool withoutParent )
const
1872 bool b = ( m_featuresSet & (uint) f );
1875 if ( m_parent && !withoutParent )
1876 b = ( m_parent->hasFeature( f, withoutParent ) ? true : b );
1881void Style::clearFeature( FlagsSet f )
1883 m_featuresSet &= ~(uint)f;
1886TQFont Style::font()
const
1888 TQString family = fontFamily();
1889 int size = fontSize();
1890 uint ff = fontFlags();
1892 TQFont f( family, size );
1893 if ( ff & (uint) FBold )
1895 if ( ff & (uint) FItalic )
1896 f.setItalic(
true );
1897 if ( ff & (uint) FUnderline )
1898 f.setUnderline(
true );
1899 if ( ff & (uint) FStrike )
1900 f.setStrikeOut(
true );
1905TQString
const & Style::fontFamily()
const
1907 return ( !m_parent || featureSet( SFontFamily ) ?
m_fontFamily : m_parent->fontFamily() );
1910uint Style::fontFlags()
const
1912 return ( !m_parent || featureSet( SFontFlag ) ? m_fontFlags : m_parent->fontFlags() );
1915int Style::fontSize()
const
1917 return ( !m_parent || featureSet( SFontSize ) ? m_fontSize : m_parent->fontSize() );
1920TQPen
const & Style::pen()
const
1922 return ( !m_parent || featureSet( STextPen ) ?
m_textPen : m_parent->pen() );
1925TQColor
const & Style::bgColor()
const
1927 return ( !m_parent || featureSet( SBackgroundColor ) ?
m_bgColor : m_parent->bgColor() );
1930TQPen
const & Style::rightBorderPen()
const
1932 return ( !m_parent || featureSet( SRightBorder ) ?
m_rightBorderPen : m_parent->rightBorderPen() );
1935TQPen
const & Style::bottomBorderPen()
const
1937 return ( !m_parent || featureSet( SBottomBorder ) ?
m_bottomBorderPen : m_parent->bottomBorderPen() );
1940TQPen
const & Style::leftBorderPen()
const
1942 return ( !m_parent || featureSet( SLeftBorder ) ?
m_leftBorderPen : m_parent->leftBorderPen() );
1945TQPen
const & Style::topBorderPen()
const
1947 return ( !m_parent || featureSet( STopBorder ) ?
m_topBorderPen : m_parent->topBorderPen() );
1950TQPen
const & Style::fallDiagonalPen()
const
1952 return ( !m_parent || featureSet( SFallDiagonal ) ?
m_fallDiagonalPen : m_parent->fallDiagonalPen() );
1955TQPen
const & Style::goUpDiagonalPen()
const
1957 return ( !m_parent || featureSet( SGoUpDiagonal ) ?
m_goUpDiagonalPen : m_parent->goUpDiagonalPen() );
1960int Style::precision()
const
1962 return ( !m_parent || featureSet( SPrecision ) ?
m_precision : m_parent->precision() );
1965int Style::rotateAngle()
const
1967 return ( !m_parent || featureSet( SAngle ) ? m_rotateAngle : m_parent->rotateAngle() );
1970double Style::indent()
const
1972 return ( !m_parent || featureSet( SIndent ) ?
m_indent : m_parent->indent() );
1975TQBrush
const & Style::backGroundBrush()
const
1977 return ( !m_parent || featureSet( SBackgroundBrush ) ?
m_backGroundBrush : m_parent->backGroundBrush() );
1980Format::Align Style::alignX()
const
1982 return ( !m_parent || featureSet( SAlignX ) ?
m_alignX : m_parent->alignX() );
1985Format::AlignY Style::alignY()
const
1987 return ( !m_parent || featureSet( SAlignY ) ?
m_alignY : m_parent->alignY() );
1990Format::FloatFormat Style::floatFormat()
const
1992 return ( !m_parent || featureSet( SFloatFormat ) ? m_floatFormat : m_parent->floatFormat() );
1995Format::FloatColor Style::floatColor()
const
1997 return ( !m_parent || featureSet( SFloatColor ) ?
m_floatColor : m_parent->floatColor() );
2000FormatType Style::formatType()
const
2002 return ( !m_parent || featureSet( SFormatType ) ? m_formatType : m_parent->formatType() );
2005Format::Currency
const & Style::currency()
const
2007 return ( !m_parent || featureSet( SFormatType ) ?
m_currency : m_parent->currency() );
2010TQString
const & Style::strFormat()
const
2012 return ( !m_parent || featureSet( SCustomFormat ) ?
m_strFormat : m_parent->strFormat() );
2015TQString
const & Style::prefix()
const
2017 return ( !m_parent || featureSet( SPrefix ) ?
m_prefix : m_parent->prefix() );
2020TQString
const & Style::postfix()
const
2022 return ( !m_parent || featureSet( SPostfix ) ?
m_postfix : m_parent->postfix() );
2027Style * Style::setAlignX( Format::Align alignX )
2029 if ( m_type !=
AUTO || m_usageCount > 1 )
2033 style->m_featuresSet |= SAlignX;
2038 m_featuresSet |= SAlignX;
2042Style * Style::setAlignY( Format::AlignY alignY )
2044 if ( m_type !=
AUTO || m_usageCount > 1 )
2048 style->m_featuresSet |= SAlignY;
2053 m_featuresSet |= SAlignY;
2057Style * Style::setFont( TQFont
const & f )
2059 if ( m_type !=
AUTO || m_usageCount > 1 )
2065 style->m_featuresSet |= SFont;
2066 style->m_featuresSet |= SFontFamily;
2068 if ( style->m_fontSize != f.pointSize() )
2070 style->m_fontSize = f.pointSize();
2071 style->m_featuresSet |= SFont;
2072 style->m_featuresSet |= SFontSize;
2074 if ( f.italic() != (m_fontFlags & (uint) FItalic ) )
2077 style->m_fontFlags |= FItalic;
2079 style->m_fontFlags &= ~(uint) FItalic;
2080 style->m_featuresSet |= SFont;
2081 style->m_featuresSet |= SFontFlag;
2083 if ( f.bold() != (m_fontFlags & (uint) FBold ) )
2086 style->m_fontFlags |= FBold;
2088 style->m_fontFlags &= ~(uint) FBold;
2089 style->m_featuresSet |= SFont;
2090 style->m_featuresSet |= SFontFlag;
2092 if ( f.underline() != (m_fontFlags & (uint) FUnderline ) )
2094 if ( f.underline() )
2095 style->m_fontFlags |= FUnderline;
2097 style->m_fontFlags &= ~(uint) FUnderline;
2098 style->m_featuresSet |= SFont;
2099 style->m_featuresSet |= SFontFlag;
2101 if ( f.strikeOut() != (m_fontFlags & (uint) FStrike ) )
2103 if ( f.strikeOut() )
2104 style->m_fontFlags |= FStrike;
2106 style->m_fontFlags &= ~(uint) FStrike;
2107 style->m_featuresSet |= SFont;
2108 style->m_featuresSet |= SFontFlag;
2117 m_featuresSet |= SFont;
2118 m_featuresSet |= SFontFamily;
2120 if ( m_fontSize != f.pointSize() )
2122 m_fontSize = f.pointSize();
2123 m_featuresSet |= SFont;
2124 m_featuresSet |= SFontSize;
2126 if ( f.italic() != (m_fontFlags & (uint) FItalic ) )
2129 m_fontFlags |= FItalic;
2131 m_fontFlags &= ~(uint) FItalic;
2132 m_featuresSet |= SFont;
2133 m_featuresSet |= SFontFlag;
2135 if ( f.bold() != (m_fontFlags & (uint) FBold ) )
2138 m_fontFlags |= FBold;
2140 m_fontFlags &= ~(uint) FBold;
2141 m_featuresSet |= SFont;
2142 m_featuresSet |= SFontFlag;
2144 if ( f.underline() != (m_fontFlags & (uint) FUnderline ) )
2146 if ( f.underline() )
2147 m_fontFlags |= FUnderline;
2149 m_fontFlags &= ~(uint) FUnderline;
2150 m_featuresSet |= SFont;
2151 m_featuresSet |= SFontFlag;
2153 if ( f.strikeOut() != (m_fontFlags & (uint) FStrike ) )
2155 if ( f.strikeOut() )
2156 m_fontFlags |= FStrike;
2158 m_fontFlags &= ~(uint) FStrike;
2159 m_featuresSet |= SFont;
2160 m_featuresSet |= SFontFlag;
2166Style * Style::setFontFamily( TQString
const & fam )
2168 if ( m_type !=
AUTO || m_usageCount > 1 )
2174 style->m_featuresSet |= SFontFamily;
2175 style->m_featuresSet |= SFont;
2182 m_featuresSet |= SFont;
2183 m_featuresSet |= SFontFamily;
2187Style * Style::setFontFlags( uint flags )
2189 if ( m_type !=
AUTO || m_usageCount > 1 )
2191 if ( m_fontFlags != flags )
2194 style->m_fontFlags = flags;
2195 style->m_featuresSet |= SFontFlag;
2196 style->m_featuresSet |= SFont;
2202 m_fontFlags = flags;
2203 m_featuresSet |= SFont;
2204 m_featuresSet |= SFontFlag;
2208Style * Style::setFontSize(
int size )
2210 if ( m_type !=
AUTO || m_usageCount > 1 )
2212 if ( m_fontSize != size )
2215 style->m_fontSize = size;
2216 style->m_featuresSet |= SFontSize;
2217 style->m_featuresSet |= SFont;
2224 m_featuresSet |= SFont;
2225 m_featuresSet |= SFontSize;
2229Style * Style::setPen( TQPen
const & pen )
2231 if ( m_type !=
AUTO || m_usageCount > 1 )
2235 if ( style->
m_textPen.style() != TQt::NoPen )
2236 style->m_featuresSet |= STextPen;
2242 m_featuresSet |= STextPen;
2246Style * Style::setBgColor( TQColor
const & color )
2248 if ( m_type !=
AUTO || m_usageCount > 1 )
2253 style->m_featuresSet |= SBackgroundColor;
2259 m_featuresSet |= SBackgroundColor;
2263Style * Style::setRightBorderPen( TQPen
const & pen )
2265 if ( m_type !=
AUTO || m_usageCount > 1 )
2269 style->m_rightPenValue = calculateValue( pen );
2271 style->m_featuresSet |= SRightBorder;
2276 m_rightPenValue = calculateValue( pen );
2278 m_featuresSet |= SRightBorder;
2282Style * Style::setBottomBorderPen( TQPen
const & pen )
2284 if ( m_type !=
AUTO || m_usageCount > 1 )
2288 style->m_bottomPenValue = calculateValue( pen );
2290 style->m_featuresSet |= SBottomBorder;
2295 m_bottomPenValue = calculateValue( pen );
2297 m_featuresSet |= SBottomBorder;
2301Style * Style::setLeftBorderPen( TQPen
const & pen )
2303 if ( m_type !=
AUTO || m_usageCount > 1 )
2307 style->m_leftPenValue = calculateValue( pen );
2309 style->m_featuresSet |= SLeftBorder;
2314 m_leftPenValue = calculateValue( pen );
2316 m_featuresSet |= SLeftBorder;
2320Style * Style::setTopBorderPen( TQPen
const & pen )
2322 if ( m_type !=
AUTO || m_usageCount > 1 )
2326 style->m_topPenValue = calculateValue( pen );
2328 style->m_featuresSet |= STopBorder;
2333 m_topPenValue = calculateValue( pen );
2335 m_featuresSet |= STopBorder;
2339Style * Style::setFallDiagonalPen( TQPen
const & pen )
2341 if ( m_type !=
AUTO || m_usageCount > 1 )
2346 style->m_featuresSet |= SFallDiagonal;
2352 m_featuresSet |= SFallDiagonal;
2356Style * Style::setGoUpDiagonalPen( TQPen
const & pen )
2358 if ( m_type !=
AUTO || m_usageCount > 1 )
2363 style->m_featuresSet |= SGoUpDiagonal;
2369 m_featuresSet |= SGoUpDiagonal;
2373Style * Style::setRotateAngle(
int angle )
2375 if ( m_type !=
AUTO || m_usageCount > 1 )
2378 style->m_rotateAngle = angle;
2379 style->m_featuresSet |= SAngle;
2383 m_rotateAngle = angle;
2384 m_featuresSet |= SAngle;
2388Style * Style::setIndent(
double indent )
2390 if ( m_type !=
AUTO || m_usageCount > 1 )
2394 style->m_featuresSet |= SIndent;
2399 m_featuresSet |= SIndent;
2403Style * Style::setBackGroundBrush( TQBrush
const & brush )
2405 if ( m_type !=
AUTO || m_usageCount > 1 )
2410 style->m_featuresSet |= SBackgroundBrush;
2416 m_featuresSet |= SBackgroundBrush;
2420Style * Style::setFloatFormat( Format::FloatFormat format )
2422 if ( m_type !=
AUTO || m_usageCount > 1 )
2425 style->m_floatFormat = format;
2426 style->m_featuresSet |= SFloatFormat;
2430 m_floatFormat = format;
2431 m_featuresSet |= SFloatFormat;
2435Style * Style::setFloatColor( Format::FloatColor color )
2437 if ( m_type !=
AUTO || m_usageCount > 1 )
2441 style->m_featuresSet |= SFloatColor;
2446 m_featuresSet |= SFloatColor;
2450Style * Style::setStrFormat( TQString
const & strFormat )
2452 if ( m_type !=
AUTO || m_usageCount > 1 )
2456 style->m_featuresSet |= SCustomFormat;
2461 m_featuresSet |= SCustomFormat;
2465Style * Style::setPrecision(
int precision )
2467 if ( m_type !=
AUTO || m_usageCount > 1 )
2471 style->m_featuresSet |= SPrecision;
2476 m_featuresSet |= SPrecision;
2480Style * Style::setPrefix( TQString
const & prefix )
2482 if ( m_type !=
AUTO || m_usageCount > 1 )
2486 style->m_featuresSet |= SPrefix;
2491 m_featuresSet |= SPrefix;
2495Style * Style::setPostfix( TQString
const & postfix )
2497 if ( m_type !=
AUTO || m_usageCount > 1 )
2501 style->m_featuresSet |= SPostfix;
2506 m_featuresSet |= SPostfix;
2510Style * Style::setCurrency( Format::Currency
const & currency )
2512 if ( m_type !=
AUTO || m_usageCount > 1 )
2516 style->m_featuresSet |= SFormatType;
2521 m_featuresSet |= SFormatType;
2525Style * Style::setProperty( Properties p )
2527 if ( m_type !=
AUTO || m_usageCount > 1 )
2533 case PDontPrintText:
2534 style->m_featuresSet |= SDontPrintText;
2537 style->m_featuresSet |= SCustomFormat;
2540 style->m_featuresSet |= SNotProtected;
2543 style->m_featuresSet |= SHideAll;
2546 style->m_featuresSet |= SHideFormula;
2549 style->m_featuresSet |= SMultiRow;
2552 style->m_featuresSet |= SVerticalText;
2555 kdWarning() <<
"Unhandled property" << endl;
2563 case PDontPrintText:
2564 m_featuresSet |= SDontPrintText;
2567 m_featuresSet |= SCustomFormat;
2570 m_featuresSet |= SNotProtected;
2573 m_featuresSet |= SHideAll;
2576 m_featuresSet |= SHideFormula;
2579 m_featuresSet |= SMultiRow;
2582 m_featuresSet |= SVerticalText;
2585 kdWarning() <<
"Unhandled property" << endl;
2590Style * Style::clearProperty( Properties p )
2592 if ( m_type !=
AUTO || m_usageCount > 1 )
2598 case PDontPrintText:
2599 style->m_featuresSet |= SDontPrintText;
2602 style->m_featuresSet |= SCustomFormat;
2605 style->m_featuresSet |= SNotProtected;
2608 style->m_featuresSet |= SHideAll;
2611 style->m_featuresSet |= SHideFormula;
2614 style->m_featuresSet |= SMultiRow;
2617 style->m_featuresSet |= SVerticalText;
2620 kdWarning() <<
"Unhandled property" << endl;
2628 case PDontPrintText:
2629 m_featuresSet |= SDontPrintText;
2632 m_featuresSet |= SCustomFormat;
2635 m_featuresSet |= SNotProtected;
2638 m_featuresSet |= SHideAll;
2641 m_featuresSet |= SHideFormula;
2644 m_featuresSet |= SMultiRow;
2647 m_featuresSet |= SVerticalText;
2650 kdWarning() <<
"Unhandled property" << endl;
2656Style * Style::setFormatType( FormatType format )
2658 if ( m_type !=
AUTO || m_usageCount > 1 )
2661 style->m_formatType = format;
2662 style->m_featuresSet |= SFormatType;
2666 m_formatType = format;
2667 m_featuresSet |= SFormatType;
2673 static TQMap<TQRgb , TQString> map;
2675 TQRgb rgb = color.rgb();
2677 if (!map.contains( rgb ))
2679 map[rgb] = color.name();
2694CustomStyle::CustomStyle()
2702CustomStyle::CustomStyle(
Style * parent, TQString
const & name )
2710 if ( parent->hasProperty( PDontPrintText ) )
2711 addProperty( PDontPrintText );
2712 if ( parent->hasProperty( PCustomFormat ) )
2713 addProperty( PCustomFormat );
2714 if ( parent->hasProperty( PNotProtected ) )
2715 addProperty( PNotProtected );
2716 if ( parent->hasProperty( PHideAll ) )
2717 addProperty( PHideAll );
2718 if ( parent->hasProperty( PHideFormula ) )
2719 addProperty( PHideFormula );
2720 if ( parent->hasProperty( PMultiRow ) )
2721 addProperty( PMultiRow );
2722 if ( parent->hasProperty( PVerticalText ) )
2723 addProperty( PVerticalText );
2725 changeAlignX( parent->alignX() );
2726 changeAlignY( parent->alignY() );
2727 changeFloatFormat( parent->floatFormat() );
2728 changeFloatColor( parent->floatColor() );
2729 changeFormatType( parent->formatType() );
2730 changeFontFamily( parent->fontFamily() );
2731 changeFontSize( parent->fontSize() );
2732 changeFontFlags( parent->fontFlags() );
2733 changePen( parent->pen() );
2734 changeBgColor( parent->bgColor() );
2735 changeRightBorderPen( parent->rightBorderPen() );
2736 changeBottomBorderPen( parent->bottomBorderPen() );
2737 changeLeftBorderPen( parent->leftBorderPen() );
2738 changeTopBorderPen( parent->topBorderPen() );
2739 changeFallBorderPen( parent->fallDiagonalPen() );
2740 changeGoUpBorderPen( parent->goUpDiagonalPen() );
2741 changeBackGroundBrush( parent->backGroundBrush() );
2742 changeRotateAngle( parent->rotateAngle() );
2743 changeIndent( parent->indent() );
2744 changeStrFormat( parent->strFormat() );
2745 changePrecision( parent->precision() );
2746 changePrefix( parent->prefix() );
2747 changePostfix( parent->postfix() );
2748 changeCurrency( parent->currency() );
2751CustomStyle::CustomStyle( TQString
const & name,
CustomStyle * parent )
2757 m_parentName = m_parent->name();
2760CustomStyle::~CustomStyle()
2772 if ( style.type() == 0 )
2773 style = KoGenStyle( Doc::STYLE_CELL_USER,
"table-cell" );
2775 if ( m_name.isEmpty() )
2779 if( type() !=
BUILTIN || m_name !=
"Default" )
2780 style.addAttribute(
"style:display-name", m_name );
2786 if ( style.type() == Doc::STYLE_CELL_AUTO )
2789 if( ( m_type ==
BUILTIN ) && ( m_name ==
"Default" ) )
2791 style.setDefaultStyle(
true);
2793 return mainStyles.lookup( style,
"Default", KoGenStyles::DontForceNumbering );
2797 return mainStyles.lookup( style,
"custom-style" );
2803 if ( style.hasAttributeNS( KoXmlNS::style,
"parent-style-name" ) )
2804 m_parentName = style.attributeNS( KoXmlNS::style,
"parent-style-name", TQString() );
2805 else if ( m_name !=
"Default" )
2806 m_parentName =
"Default";
2810 Style::loadOasisStyle( oasisStyles, style );
2813void CustomStyle::save( TQDomDocument & doc, TQDomElement & styles )
2815 if ( m_name.isEmpty() )
2818 TQDomElement style( doc.createElement(
"style" ) );
2819 style.setAttribute(
"type", (
int) m_type );
2821 style.setAttribute(
"parent", m_parent->name() );
2822 style.setAttribute(
"name", m_name );
2824 TQDomElement format( doc.createElement(
"format" ) );
2825 saveXML( doc, format );
2826 style.appendChild( format );
2828 styles.appendChild( style );
2831bool CustomStyle::loadXML( TQDomElement
const & style, TQString
const & name )
2835 if ( style.hasAttribute(
"parent" ) )
2836 m_parentName = style.attribute(
"parent" );
2838 if ( !style.hasAttribute(
"type" ) )
2842 m_type = (
StyleType) style.attribute(
"type" ).toInt( &ok );
2846 TQDomElement f( style.namedItem(
"format" ).toElement() );
2848 if ( !Style::loadXML( f ) )
2854void CustomStyle::setName( TQString
const & name )
2859void CustomStyle::refreshParentName()
2862 m_parentName = m_parent->name();
2865bool CustomStyle::definesAll()
const
2867 if ( !( m_featuresSet & (uint) SAlignX ) )
2869 if ( !( m_featuresSet & (uint) SAlignY ) )
2871 if ( !( m_featuresSet & (uint) SPrefix ) )
2873 if ( !( m_featuresSet & (uint) SPostfix ) )
2875 if ( !( m_featuresSet & (uint) SLeftBorder ) )
2877 if ( !( m_featuresSet & (uint) SRightBorder ) )
2879 if ( !( m_featuresSet & (uint) STopBorder ) )
2881 if ( !( m_featuresSet & (uint) SBottomBorder ) )
2883 if ( !( m_featuresSet & (uint) SFallDiagonal ) )
2885 if ( !( m_featuresSet & (uint) SGoUpDiagonal ) )
2887 if ( !( m_featuresSet & (uint) SBackgroundBrush ) )
2889 if ( !( m_featuresSet & (uint) SFontFamily ) )
2891 if ( !( m_featuresSet & (uint) SFontSize ) )
2893 if ( !( m_featuresSet & (uint) SFontFlag ) )
2895 if ( !( m_featuresSet & (uint) STextPen ) )
2897 if ( !( m_featuresSet & (uint) SBackgroundColor ) )
2899 if ( !( m_featuresSet & (uint) SFloatFormat ) )
2901 if ( !( m_featuresSet & (uint) SFloatColor ) )
2903 if ( !( m_featuresSet & (uint) SMultiRow ) )
2905 if ( !( m_featuresSet & (uint) SVerticalText ) )
2907 if ( !( m_featuresSet & (uint) SPrecision ) )
2909 if ( !( m_featuresSet & (uint) SFormatType ) )
2911 if ( !( m_featuresSet & (uint) SAngle ) )
2913 if ( !( m_featuresSet & (uint) SIndent ) )
2915 if ( !( m_featuresSet & (uint) SDontPrintText ) )
2917 if ( !( m_featuresSet & (uint) SCustomFormat ) )
2919 if ( !( m_featuresSet & (uint) SNotProtected ) )
2921 if ( !( m_featuresSet & (uint) SHideAll ) )
2923 if ( !( m_featuresSet & (uint) SHideFormula ) )
2929void CustomStyle::changeAlignX( Format::Align alignX )
2932 m_featuresSet |= SAlignX;
2935void CustomStyle::changeAlignY( Format::AlignY alignY )
2938 m_featuresSet |= SAlignY;
2941void CustomStyle::changeFont( TQFont
const & f )
2946 m_featuresSet |= SFontFamily;
2947 m_featuresSet |= SFont;
2949 if ( m_fontSize != f.pointSize() )
2951 m_fontSize = f.pointSize();
2952 m_featuresSet |= SFont;
2953 m_featuresSet |= SFontSize;
2956 if ( f.italic() != (m_fontFlags & (uint) FItalic ) )
2959 m_fontFlags |= FItalic;
2961 m_fontFlags &= ~(uint) FItalic;
2962 m_featuresSet |= SFont;
2963 m_featuresSet |= SFontFlag;
2965 if ( f.bold() != (m_fontFlags & (uint) FBold ) )
2968 m_fontFlags |= FBold;
2970 m_fontFlags &= ~(uint) FBold;
2971 m_featuresSet |= SFont;
2972 m_featuresSet |= SFontFlag;
2974 if ( f.underline() != (m_fontFlags & (uint) FUnderline ) )
2976 if ( f.underline() )
2977 m_fontFlags |= FUnderline;
2979 m_fontFlags &= ~(uint) FUnderline;
2980 m_featuresSet |= SFont;
2981 m_featuresSet |= SFontFlag;
2983 if ( f.strikeOut() != (m_fontFlags & (uint) FStrike ) )
2985 if ( f.strikeOut() )
2986 m_fontFlags |= FStrike;
2988 m_fontFlags &= ~(uint) FStrike;
2989 m_featuresSet |= SFont;
2990 m_featuresSet |= SFontFlag;
2994void CustomStyle::changeFontFamily( TQString
const & fam )
2999 m_featuresSet |= SFont;
3000 m_featuresSet |= SFontFamily;
3004void CustomStyle::changeFontSize(
int size )
3006 if ( m_fontSize != size )
3009 m_featuresSet |= SFont;
3010 m_featuresSet |= SFontSize;
3014void CustomStyle::changeFontFlags( uint flags )
3016 if ( m_fontFlags != flags )
3018 m_fontFlags = flags;
3019 m_featuresSet |= SFont;
3020 m_featuresSet |= SFontFlag;
3024void CustomStyle::changeTextColor( TQColor
const & color )
3027 m_featuresSet |= STextPen;
3030void CustomStyle::changePen( TQPen
const & pen )
3033 m_featuresSet |= STextPen;
3036void CustomStyle::changeBgColor( TQColor
const & color )
3039 m_featuresSet |= SBackgroundColor;
3042void CustomStyle::changeRightBorderPen( TQPen
const & pen )
3045 m_rightPenValue = calculateValue( pen );
3046 m_featuresSet |= SRightBorder;
3049void CustomStyle::changeBottomBorderPen( TQPen
const & pen )
3052 m_bottomPenValue = calculateValue( pen );
3053 m_featuresSet |= SBottomBorder;
3056void CustomStyle::changeLeftBorderPen( TQPen
const & pen )
3059 m_leftPenValue = calculateValue( pen );
3060 m_featuresSet |= SLeftBorder;
3063void CustomStyle::changeTopBorderPen( TQPen
const & pen )
3066 m_topPenValue = calculateValue( pen );
3067 m_featuresSet |= STopBorder;
3070void CustomStyle::changeFallBorderPen( TQPen
const & pen )
3073 m_featuresSet |= SFallDiagonal;
3076void CustomStyle::changeGoUpBorderPen( TQPen
const & pen )
3079 m_featuresSet |= SGoUpDiagonal;
3082void CustomStyle::changeRotateAngle(
int angle )
3084 m_rotateAngle = angle;
3085 m_featuresSet |= SAngle;
3088void CustomStyle::changeIndent(
double indent )
3091 m_featuresSet |= SIndent;
3094void CustomStyle::changeBackGroundBrush( TQBrush
const & brush )
3097 m_featuresSet |= SBackgroundBrush;
3100void CustomStyle::changeFloatFormat( Format::FloatFormat format )
3102 m_floatFormat = format;
3103 m_featuresSet |= SFloatFormat;
3106void CustomStyle::changeFloatColor( Format::FloatColor color )
3109 m_featuresSet |= SFloatColor;
3112void CustomStyle::changeFormatType( FormatType format )
3114 m_formatType = format;
3115 m_featuresSet |= SFormatType;
3118void CustomStyle::changeStrFormat( TQString
const & strFormat )
3121 m_featuresSet |= SCustomFormat;
3124void CustomStyle::changePrecision(
int precision )
3127 m_featuresSet |= SPrecision;
3130void CustomStyle::changePrefix( TQString
const & prefix )
3133 m_featuresSet |= SPrefix;
3136void CustomStyle::changePostfix( TQString
const & postfix )
3139 m_featuresSet |= SPostfix;
3142void CustomStyle::changeCurrency( Format::Currency
const & currency )
3147void CustomStyle::addProperty( Properties p )
3152 case PDontPrintText:
3153 m_featuresSet |= SDontPrintText;
3156 m_featuresSet |= SCustomFormat;
3159 m_featuresSet |= SNotProtected;
3162 m_featuresSet |= SHideAll;
3165 m_featuresSet |= SHideFormula;
3168 m_featuresSet |= SMultiRow;
3171 m_featuresSet |= SVerticalText;
3174 kdWarning() <<
"Unhandled property" << endl;
3178void CustomStyle::removeProperty( Properties p )
3183 case PDontPrintText:
3184 m_featuresSet &= SDontPrintText;
3187 m_featuresSet &= SCustomFormat;
3190 m_featuresSet &= SNotProtected;
3193 m_featuresSet &= SHideAll;
3196 m_featuresSet &= SHideFormula;
3199 m_featuresSet &= SMultiRow;
3202 m_featuresSet &= SVerticalText;
3205 kdWarning() <<
"Unhandled property" << endl;
3209bool CustomStyle::operator==(
const CustomStyle& other )
const
3211 if ( m_name != other.m_name )
Built-in or custom style defined in StyleManager dialog.
void loadOasis(KoOasisStyles &oasisStyles, const TQDomElement &style, const TQString &name)
Loads the style properties from style .
virtual TQString saveOasis(KoGenStyle &style, KoGenStyles &mainStyles)
The Style class represents a cell style.
TQBrush m_backGroundBrush
The brush used to draw the background.
TQPen m_fallDiagonalPen
The pen used to draw the diagonal.
TQString m_postfix
The postfix of a numeric value ( for example "DM" ) May be empty.
TQString m_strFormat
Format of the content, e.g.
double m_indent
Give indent.
TQPen m_bottomBorderPen
The pen used to draw the bottom border.
uint m_properties
Stores information like: DonPrint, DontShowFormula, Protected...
TQString m_fontFamily
The font used to draw the text.
void addRef()
Marks this style as used.
bool operator==(const Style &style) const
Returns true if both styles have the same properties.
bool release()
Releases this style.
TQPen m_topBorderPen
The pen used to draw the top border.
virtual TQString saveOasis(KoGenStyle &style, KoGenStyles &mainStyles)
Saves an OASIS automatic style.
TQPen m_rightBorderPen
The pen used to draw the right border.
Format::FloatColor m_floatColor
The color format of a floating point value.
Format::Currency m_currency
Currency information: about which currency from which country.
Format::AlignY m_alignY
Aligment of the text at top middle or bottom.
TQPen m_textPen
The pen used to draw the text.
virtual ~Style()
Destructor.
@ BUILTIN
built-in style (the default style)
@ AUTO
automatically generated on cell format changes
@ CUSTOM
custom style (defined in the StyleManager dialog)
Format::Align m_alignX
Alignment of the text.
TQString m_prefix
The prefix of a numeric value ( for example "$" ) May be empty.
static TQString colorName(const TQColor &color)
Returns the name of a colour.
void saveOasisStyle(KoGenStyle &style, KoGenStyles &mainStyles)
Helper function for saveOasis Does the real work by determining the used attributes.
int m_precision
The precision of the floating point representation If precision is -1, this means that no precision i...
static TQString saveOasisStyleNumeric(KoGenStyle &style, KoGenStyles &mainStyles, FormatType _style, const TQString &_prefix, const TQString &_postfix, int _precision, const TQString &symbol)
TQColor m_bgColor
The background color.
TQPen m_goUpDiagonalPen
The pen used to draw the the diagonal which go up.
TQPen m_leftBorderPen
The pen used to draw the left border.