20#include "KoParagLayout.h"
21#include "KoRichText.h"
22#include "KoParagCounter.h"
23#include "KoStyleCollection.h"
24#include "KoOasisContext.h"
25#include <KoXmlWriter.h>
28#include <KoGenStyles.h>
39TQString* KoParagLayout::shadowCssCompat = 0L;
42KoParagLayout::KoParagLayout()
50 for ( int i = 0 ; i < 5 ; ++i )
52 pageBreaking = layout.pageBreaking;
53 leftBorder = layout.leftBorder;
54 rightBorder = layout.rightBorder;
55 topBorder = layout.topBorder;
56 bottomBorder = layout.bottomBorder;
57 joinBorder = layout.joinBorder;
63 lineSpacing = layout.lineSpacing;
64 lineSpacingType = layout.lineSpacingType;
66 direction = layout.direction;
67 setTabList( layout.tabList() );
75 for ( int i = 0 ; i < 5 ; ++i )
81 if ( pageBreaking != layout.pageBreaking )
82 flags |= PageBreaking;
83 if ( leftBorder != layout.leftBorder
84 || rightBorder != layout.rightBorder
85 || topBorder != layout.topBorder
86 || bottomBorder != layout.bottomBorder
87 || joinBorder != layout.joinBorder )
95 flags |= BulletNumber;
98 flags |= BulletNumber;
101 if ( counter && counter->numbering() != KoParagCounter::NUM_NONE )
102 flags |= BulletNumber;
104 if ( lineSpacing != layout.lineSpacing
105 || lineSpacingType != layout.lineSpacingType )
106 flags |= LineSpacing;
109 if ( m_tabList != layout.m_tabList )
113 flags |= BackgroundColor;
120void KoParagLayout::initialise()
123 for ( int i = 0 ; i < 5 ; ++i )
125 lineSpacingType = LS_SINGLE;
128 leftBorder.setPenWidth( 0);
129 rightBorder.setPenWidth( 0);
130 topBorder.setPenWidth( 0);
131 bottomBorder.setPenWidth( 0);
135 direction = TQChar::DirON;
139KoParagLayout::~KoParagLayout()
154 KoTabulatorList tabList;
155 TQDomElement element = parentElem.firstChild().toElement();
156 for ( ; !element.isNull() ; element = element.nextSibling().toElement() )
158 if ( element.tagName() == "TABULATOR" )
161 tab. type = static_cast<KoTabulators >( getAttribute( element, "type", T_LEFT ) );
162 tab. ptPos = getAttribute( element, "ptpos", 0.0 );
163 tab. filling = static_cast<KoTabulatorFilling >( getAttribute( element, "filling", TF_BLANK ) );
164 tab. ptWidth = getAttribute( element, "width", 0.5 );
165 TQString alignCharStr = element.attribute( "alignchar");
166 if ( alignCharStr.isEmpty() )
167 tab. alignChar = TDEGlobal::locale()->decimalSymbol()[0];
170 tabList.append( tab );
173 qHeapSort( tabList );
174 layout.setTabList( tabList );
176 element = parentElem.namedItem( "FLOW" ).toElement();
177 if ( !element.isNull() )
179 TQString flow = element.attribute( "align" );
180 if ( !flow.isEmpty() )
182 layout. alignment = flow== "right" ? TQt::AlignRight :
183 flow== "center" ? TQt::AlignHCenter :
184 flow== "justify" ? TQt::AlignJustify :
185 flow== "left" ? TQt::AlignLeft : TQt::AlignAuto;
187 TQString dir = element.attribute( "dir" );
188 if ( !dir.isEmpty() ) {
190 layout.direction = TQChar::DirL;
191 else if ( dir == "R" )
192 layout.direction = TQChar::DirR;
194 kdWarning() << "Unexpected value for paragraph direction: " << dir << endl;
197 flow = element.attribute( "value" );
198 static const int flow2align[] = { TQt::AlignAuto, TQt::AlignRight, TQt::AlignHCenter, TQt::AlignJustify };
199 if ( !flow.isEmpty() && flow.toInt() < 4 )
200 layout. alignment = flow2align[flow.toInt()];
204 if ( docVersion < 2 )
206 element = parentElem.namedItem( "OHEAD" ).toElement();
207 if ( !element.isNull() )
208 layout. margins[TQStyleSheetItem::MarginTop] = getAttribute( element, "pt", 0.0 );
210 element = parentElem.namedItem( "OFOOT" ).toElement();
211 if ( !element.isNull() )
212 layout. margins[TQStyleSheetItem::MarginBottom] = getAttribute( element, "pt", 0.0 );
214 element = parentElem.namedItem( "IFIRST" ).toElement();
215 if ( !element.isNull() )
216 layout. margins[TQStyleSheetItem::MarginFirstLine] = getAttribute( element, "pt", 0.0 );
218 element = parentElem.namedItem( "ILEFT" ).toElement();
219 if ( !element.isNull() )
220 layout. margins[TQStyleSheetItem::MarginLeft] = getAttribute( element, "pt", 0.0 );
224 element = parentElem.namedItem( "INDENTS" ).toElement();
225 if ( !element.isNull() )
227 layout. margins[TQStyleSheetItem::MarginFirstLine] = getAttribute( element, "first", 0.0 );
228 layout. margins[TQStyleSheetItem::MarginLeft] = getAttribute( element, "left", 0.0 );
229 layout. margins[TQStyleSheetItem::MarginRight] = getAttribute( element, "right", 0.0 );
231 element = parentElem.namedItem( "OFFSETS" ).toElement();
232 if ( !element.isNull() )
234 layout. margins[TQStyleSheetItem::MarginTop] = getAttribute( element, "before", 0.0 );
235 layout. margins[TQStyleSheetItem::MarginBottom] = getAttribute( element, "after", 0.0 );
238 if ( docVersion < 2 )
240 element = parentElem.namedItem( "LINESPACE" ).toElement();
241 if ( !element.isNull() )
243 layout.lineSpacingType = KoParagLayout::LS_CUSTOM;
244 layout.lineSpacing = getAttribute( element, "pt", 0.0 );
248 element = parentElem.namedItem( "LINESPACING" ).toElement();
249 if ( !element.isNull() )
252 if ( element.hasAttribute( "value" ))
254 TQString value = element.attribute( "value" );
255 if ( value == "oneandhalf" )
257 layout.lineSpacingType = KoParagLayout::LS_ONEANDHALF;
258 layout.lineSpacing = 0;
260 else if ( value == "double" )
262 layout.lineSpacingType = KoParagLayout::LS_DOUBLE;
263 layout.lineSpacing = 0;
267 layout.lineSpacingType = KoParagLayout::LS_CUSTOM;
268 layout.lineSpacing = value.toDouble();
273 TQString type = element.attribute( "type" );
274 if ( type == "oneandhalf" )
276 layout.lineSpacingType = KoParagLayout::LS_ONEANDHALF;
277 layout.lineSpacing = 0;
279 else if ( type == "double" )
281 layout.lineSpacingType = KoParagLayout::LS_DOUBLE;
282 layout.lineSpacing = 0;
284 else if ( type == "custom" )
286 layout.lineSpacingType = KoParagLayout::LS_CUSTOM;
287 layout.lineSpacing = element.attribute( "spacingvalue" ).toDouble();
289 else if ( type == "atleast" )
291 layout.lineSpacingType = KoParagLayout::LS_AT_LEAST;
292 layout.lineSpacing = element.attribute( "spacingvalue" ).toDouble();
294 else if ( type == "multiple" )
296 layout.lineSpacingType = KoParagLayout::LS_MULTIPLE;
297 layout.lineSpacing = element.attribute( "spacingvalue" ).toDouble();
299 else if ( type == "fixed" )
301 layout.lineSpacingType = KoParagLayout::LS_FIXED;
302 layout.lineSpacing = element.attribute( "spacingvalue" ).toDouble();
304 else if ( type == "single" )
305 layout.lineSpacingType = KoParagLayout::LS_SINGLE;
309 int pageBreaking = 0;
310 element = parentElem.namedItem( "PAGEBREAKING" ).toElement();
311 if ( !element.isNull() )
313 if ( element.attribute( "linesTogether" ) == "true" )
314 pageBreaking |= KoParagLayout::KeepLinesTogether;
315 if ( element.attribute( "hardFrameBreak" ) == "true" )
316 pageBreaking |= KoParagLayout::HardFrameBreakBefore;
317 if ( element.attribute( "hardFrameBreakAfter" ) == "true" )
318 pageBreaking |= KoParagLayout::HardFrameBreakAfter;
320 if ( docVersion < 2 )
322 element = parentElem.namedItem( "HARDBRK" ).toElement();
323 if ( !element.isNull() )
324 pageBreaking |= KoParagLayout::HardFrameBreakBefore;
326 layout.pageBreaking = pageBreaking;
328 element = parentElem.namedItem( "LEFTBORDER" ).toElement();
329 if ( !element.isNull() )
330 layout.leftBorder = KoBorder::loadBorder( element );
332 layout.leftBorder.setPenWidth(0);
334 element = parentElem.namedItem( "RIGHTBORDER" ).toElement();
335 if ( !element.isNull() )
336 layout.rightBorder = KoBorder::loadBorder( element );
338 layout.rightBorder.setPenWidth(0);
340 element = parentElem.namedItem( "TOPBORDER" ).toElement();
341 if ( !element.isNull() )
342 layout.topBorder = KoBorder::loadBorder( element );
344 layout.topBorder.setPenWidth(0);
346 element = parentElem.namedItem( "BOTTOMBORDER" ).toElement();
347 if ( !element.isNull() )
348 layout.bottomBorder = KoBorder::loadBorder( element );
350 layout.bottomBorder.setPenWidth(0);
352 element = parentElem.namedItem( "COUNTER" ).toElement();
353 if ( !element.isNull() )
360 element = parentElem.namedItem( "SHADOW" ).toElement();
361 if ( !element.isNull() && element.hasAttribute( "direction") )
363 int shadowDistance = element.attribute( "distance").toInt();
364 int shadowDirection = element.attribute( "direction").toInt();
366 if ( element.hasAttribute( "red") )
368 int r = element.attribute( "red").toInt();
369 int g = element.attribute( "green").toInt();
370 int b = element.attribute( "blue").toInt();
371 shadowColor.setRgb( r, g, b );
375 switch ( shadowDirection )
380 distanceX = - shadowDistance;
385 distanceX = shadowDistance;
388 switch ( shadowDirection )
393 distanceY = - shadowDistance;
398 distanceY = shadowDistance;
401 if ( !shadowCssCompat )
402 shadowCssCompat = new TQString;
404 kdDebug(32500) << "setting shadow compat to " << ( *shadowCssCompat ) << endl;
408 delete shadowCssCompat;
409 shadowCssCompat = 0L;
417 str == "left" ? TQt::AlignLeft :
418 str == "right" ? TQt::AlignRight :
419 str == "start" ? TQt::AlignLeft :
420 str == "end" ? TQt::AlignRight :
421 str == "center" ? TQt::AlignHCenter :
422 str == "justify" ? TQt::AlignJustify :
423 str == "start" ? TQt::AlignAuto
430 return alignment == TQt::AlignLeft ? "left" :
432 alignment == TQt::AlignHCenter ? "center" :
433 alignment == TQt::AlignJustify ? "justify" :
439 context.styleStack().setTypeProperties( "paragraph" );
444 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "text-align" ) ) {
445 TQCString align = context.styleStack().attributeNS( KoXmlNS::fo, "text-align" ).latin1();
449 if ( context.styleStack().hasAttributeNS( KoXmlNS::style, "writing-mode" ) ) {
451 TQString writingMode = context.styleStack().attributeNS( KoXmlNS::style, "writing-mode" );
452 layout.direction = ( writingMode== "rl-tb" || writingMode== "rl" ) ? TQChar::DirR : TQChar::DirL;
456 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "margin-left" ) ||
457 context.styleStack().hasAttributeNS( KoXmlNS::fo, "margin-right" ) ) {
458 layout. margins[TQStyleSheetItem::MarginLeft] = KoUnit::parseValue( context.styleStack().attributeNS( KoXmlNS::fo, "margin-left" ) );
459 layout. margins[TQStyleSheetItem::MarginRight] = KoUnit::parseValue( context.styleStack().attributeNS( KoXmlNS::fo, "margin-right" ) );
462 if ( context.styleStack().attributeNS( KoXmlNS::style, "auto-text-indent") == "true" )
467 else if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "text-indent") )
468 first = KoUnit::parseValue( context.styleStack().attributeNS( KoXmlNS::fo, "text-indent") );
470 layout. margins[TQStyleSheetItem::MarginFirstLine] = first;
474 if( context.styleStack().hasAttributeNS( KoXmlNS::fo, "margin-top") ||
475 context.styleStack().hasAttributeNS( KoXmlNS::fo, "margin-bottom")) {
476 layout. margins[TQStyleSheetItem::MarginTop] = KoUnit::parseValue( context.styleStack().attributeNS( KoXmlNS::fo, "margin-top" ) );
477 layout. margins[TQStyleSheetItem::MarginBottom] = KoUnit::parseValue( context.styleStack().attributeNS( KoXmlNS::fo, "margin-bottom" ) );
481 if( context.styleStack().hasAttributeNS( KoXmlNS::fo, "line-height") ) {
483 TQString value = context.styleStack().attributeNS( KoXmlNS::fo, "line-height" );
484 if ( value != "normal" ) {
485 if ( value == "100%" )
486 layout.lineSpacingType = KoParagLayout::LS_SINGLE;
487 else if( value== "150%")
488 layout.lineSpacingType = KoParagLayout::LS_ONEANDHALF;
489 else if( value== "200%")
490 layout.lineSpacingType = KoParagLayout::LS_DOUBLE;
491 else if ( value.find( '%') > -1 )
493 value = value.remove( '%' );
494 double percent = value.toDouble();
495 layout.lineSpacingType = KoParagLayout::LS_MULTIPLE;
496 layout.lineSpacing = percent / 100.0;
497 kdDebug(33001) << "line-height =" << percent << ", " << layout.lineSpacing << ", " << percent/100 << endl;
501 layout.lineSpacingType = KoParagLayout::LS_FIXED;
507 else if ( context.styleStack().hasAttributeNS( KoXmlNS::style, "line-height-at-least") )
509 TQString value = context.styleStack().attributeNS( KoXmlNS::style, "line-height-at-least" );
515 layout.lineSpacingType = KoParagLayout::LS_AT_LEAST;
519 else if ( context.styleStack().hasAttributeNS( KoXmlNS::style, "line-spacing") )
521 double value = KoUnit::parseValue( context.styleStack().attributeNS( KoXmlNS::style, "line-spacing" ) );
524 layout.lineSpacingType = KoParagLayout::LS_CUSTOM;
525 layout.lineSpacing = value;
530 KoTabulatorList tabList;
531 if ( context.styleStack().hasChildNodeNS( KoXmlNS::style, "tab-stops" ) ) {
532 TQDomElement tabStops = context.styleStack().childNodeNS( KoXmlNS::style, "tab-stops" );
534 TQDomElement tabStop;
535 forEachElement( tabStop, tabStops )
537 Q_ASSERT( tabStop.localName() == "tab-stop" );
538 const TQString type = tabStop.attributeNS( KoXmlNS::style, "type", TQString() );
543 tab. ptPos += layout. margins[TQStyleSheetItem::MarginLeft];
544 if ( type == "center" )
546 else if ( type == "right" )
548 else if ( type == "char" ) {
549 TQString delimiterChar = tabStop.attributeNS( KoXmlNS::style, "char", TQString() );
550 if ( !delimiterChar.isEmpty() )
552 tab. type = T_DEC_PNT;
560 if ( tabStop.attributeNS( KoXmlNS::style, "leader-type", TQString() ) == "single" )
562 TQString leaderStyle = tabStop.attributeNS( KoXmlNS::style, "leader-style", TQString() );
563 if ( leaderStyle == "solid" )
565 else if ( leaderStyle == "dotted" )
567 else if ( leaderStyle == "dash" )
569 else if ( leaderStyle == "dot-dash" )
571 else if ( leaderStyle == "dot-dot-dash" )
577 TQString leaderChar = tabStop.attributeNS( KoXmlNS::style, "leader-text", TQString() );
578 if ( !leaderChar.isEmpty() )
580 TQChar ch = leaderChar[0];
581 switch (ch.latin1()) {
593 tabList.append( tab );
596 qHeapSort( tabList );
597 layout.setTabList( tabList );
599 layout.joinBorder = !( context.styleStack().attributeNS( KoXmlNS::style, "join-border") == "false" );
602 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "border", "left") )
603 layout.leftBorder.loadFoBorder( context.styleStack().attributeNS( KoXmlNS::fo, "border", "left") );
605 layout.leftBorder.setPenWidth(0);
606 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "border", "right") )
607 layout.rightBorder.loadFoBorder( context.styleStack().attributeNS( KoXmlNS::fo, "border", "right") );
609 layout.rightBorder.setPenWidth(0);
610 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "border", "top") )
611 layout.topBorder.loadFoBorder( context.styleStack().attributeNS( KoXmlNS::fo, "border", "top") );
613 layout.topBorder.setPenWidth(0);
614 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "border", "bottom") )
615 layout.bottomBorder.loadFoBorder( context.styleStack().attributeNS( KoXmlNS::fo, "border", "bottom") );
617 layout.bottomBorder.setPenWidth(0);
621 int pageBreaking = 0;
622 if( context.styleStack().hasAttributeNS( KoXmlNS::fo, "break-before") ||
623 context.styleStack().hasAttributeNS( KoXmlNS::fo, "break-after") ||
624 context.styleStack().hasAttributeNS( KoXmlNS::fo, "keep-together") ||
625 context.styleStack().hasAttributeNS( KoXmlNS::style, "keep-with-next") ||
626 context.styleStack().hasAttributeNS( KoXmlNS::fo, "keep-with-next") )
628 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "break-before") ) {
630 if ( context.styleStack().attributeNS( KoXmlNS::fo, "break-before" ) != "auto" )
631 pageBreaking |= KoParagLayout::HardFrameBreakBefore;
633 else if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "break-after") ) {
635 if ( context.styleStack().attributeNS( KoXmlNS::fo, "break-after" ) != "auto" )
636 pageBreaking |= KoParagLayout::HardFrameBreakAfter;
639 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "keep-together" ) ) {
640 if ( context.styleStack().attributeNS( KoXmlNS::fo, "keep-together" ) != "auto" )
641 pageBreaking |= KoParagLayout::KeepLinesTogether;
643 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "keep-with-next" ) ) {
645 TQString val = context.styleStack().attributeNS( KoXmlNS::fo, "keep-with-next" );
646 if ( val == "true" || val == "always" )
647 pageBreaking |= KoParagLayout::KeepWithNext;
650 layout.pageBreaking = pageBreaking;
654 if ( context.styleStack().hasAttributeNS( KoXmlNS::fo, "background-color" ) ) {
655 TQString bgColor = context.styleStack().attributeNS( KoXmlNS::fo, "background-color");
656 if (bgColor != "transparent")
663 const KoParagLayout& layout = * this;
664 TQDomDocument doc = parentElem.ownerDocument();
665 TQDomElement element = doc.createElement( "NAME" );
666 parentElem.appendChild( element );
668 element.setAttribute( "value", layout.style-> displayName() );
672 element = doc.createElement( "FLOW" );
673 parentElem.appendChild( element );
675 element.setAttribute( "align", alignment==TQt::AlignRight ? "right" :
676 alignment==TQt::AlignHCenter ? "center" :
677 alignment==TQt::AlignJustify ? "justify" :
678 alignment==TQt::AlignAuto ? "auto" : "left" );
680 if ( static_cast<TQChar::Direction >(layout.direction) == TQChar::DirR )
681 element.setAttribute( "dir", "R" );
683 if ( static_cast<TQChar::Direction >(layout.direction) == TQChar::DirL )
684 element.setAttribute( "dir", "L" );
686 if ( layout. margins[TQStyleSheetItem::MarginFirstLine] != 0 ||
687 layout. margins[TQStyleSheetItem::MarginLeft] != 0 ||
688 layout. margins[TQStyleSheetItem::MarginRight] != 0 )
690 element = doc.createElement( "INDENTS" );
691 parentElem.appendChild( element );
692 if ( layout. margins[TQStyleSheetItem::MarginFirstLine] != 0 )
693 element.setAttribute( "first", layout. margins[TQStyleSheetItem::MarginFirstLine] );
694 if ( layout. margins[TQStyleSheetItem::MarginLeft] != 0 )
695 element.setAttribute( "left", layout. margins[TQStyleSheetItem::MarginLeft] );
696 if ( layout. margins[TQStyleSheetItem::MarginRight] != 0 )
697 element.setAttribute( "right", layout. margins[TQStyleSheetItem::MarginRight] );
700 if ( layout. margins[TQStyleSheetItem::MarginTop] != 0 ||
701 layout. margins[TQStyleSheetItem::MarginBottom] != 0 )
703 element = doc.createElement( "OFFSETS" );
704 parentElem.appendChild( element );
705 if ( layout. margins[TQStyleSheetItem::MarginTop] != 0 )
706 element.setAttribute( "before", layout. margins[TQStyleSheetItem::MarginTop] );
707 if ( layout. margins[TQStyleSheetItem::MarginBottom] != 0 )
708 element.setAttribute( "after", layout. margins[TQStyleSheetItem::MarginBottom] );
710 if ( layout.lineSpacingType != LS_SINGLE )
712 element = doc.createElement( "LINESPACING" );
713 parentElem.appendChild( element );
714 if ( layout.lineSpacingType == KoParagLayout::LS_ONEANDHALF ) {
715 element.setAttribute( "type", "oneandhalf" );
716 element.setAttribute( "value", "oneandhalf" );
718 else if ( layout.lineSpacingType == KoParagLayout::LS_DOUBLE ) {
719 element.setAttribute( "type", "double" );
720 element.setAttribute( "value", "double" );
722 else if ( layout.lineSpacingType == KoParagLayout::LS_CUSTOM )
724 element.setAttribute( "type", "custom" );
725 element.setAttribute( "spacingvalue", layout.lineSpacing);
726 element.setAttribute( "value", layout.lineSpacing );
728 else if ( layout.lineSpacingType == KoParagLayout::LS_AT_LEAST )
730 element.setAttribute( "type", "atleast" );
731 element.setAttribute( "spacingvalue", layout.lineSpacing);
733 else if ( layout.lineSpacingType == KoParagLayout::LS_MULTIPLE )
735 element.setAttribute( "type", "multiple" );
736 element.setAttribute( "spacingvalue", layout.lineSpacing);
738 else if ( layout.lineSpacingType == KoParagLayout::LS_FIXED )
740 element.setAttribute( "type", "fixed" );
741 element.setAttribute( "spacingvalue", layout.lineSpacing);
744 kdDebug()<< " error in lineSpacing Type\n";
747 if ( layout.pageBreaking != 0 )
749 element = doc.createElement( "PAGEBREAKING" );
750 parentElem.appendChild( element );
751 if ( layout.pageBreaking & KoParagLayout::KeepLinesTogether )
752 element.setAttribute( "linesTogether", "true" );
753 if ( layout.pageBreaking & KoParagLayout::HardFrameBreakBefore )
754 element.setAttribute( "hardFrameBreak", "true" );
755 if ( layout.pageBreaking & KoParagLayout::HardFrameBreakAfter )
756 element.setAttribute( "hardFrameBreakAfter", "true" );
759 if ( layout.leftBorder.penWidth() > 0 )
761 element = doc.createElement( "LEFTBORDER" );
762 parentElem.appendChild( element );
763 layout.leftBorder.save( element );
765 if ( layout.rightBorder.penWidth() > 0 )
767 element = doc.createElement( "RIGHTBORDER" );
768 parentElem.appendChild( element );
769 layout.rightBorder.save( element );
771 if ( layout.topBorder.penWidth() > 0 )
773 element = doc.createElement( "TOPBORDER" );
774 parentElem.appendChild( element );
775 layout.topBorder.save( element );
777 if ( layout.bottomBorder.penWidth() > 0 )
779 element = doc.createElement( "BOTTOMBORDER" );
780 parentElem.appendChild( element );
781 layout.bottomBorder.save( element );
785 element = doc.createElement( "COUNTER" );
786 parentElem.appendChild( element );
791 KoTabulatorList tabList = layout.tabList();
792 KoTabulatorList::ConstIterator it = tabList.begin();
793 for ( ; it != tabList.end() ; it++ )
795 element = doc.createElement( "TABULATOR" );
796 parentElem.appendChild( element );
797 element.setAttribute( "type", (*it).type );
798 element.setAttribute( "ptpos", (*it).ptPos );
799 element.setAttribute( "filling", (*it).filling );
800 if ( (*it).filling != TF_BLANK )
801 element.setAttribute( "width", TQString::number( (*it).ptWidth, 'g', DBL_DIG ) );
802 if ( (*it).type == T_DEC_PNT && !(*it).alignChar.isNull() )
803 element.setAttribute( "alignchar", TQString((*it).alignChar) );
812 if ( !savingStyle || (TQChar::Direction) direction != TQChar::DirON )
813 gs. addProperty( "style:writing-mode", (TQChar::Direction)direction == TQChar::DirR ? "rl-tb" : "lr-tb" );
820 switch ( lineSpacingType ) {
821 case KoParagLayout::LS_SINGLE:
824 case KoParagLayout::LS_ONEANDHALF:
827 case KoParagLayout::LS_DOUBLE:
830 case KoParagLayout::LS_MULTIPLE:
831 gs. addProperty( "fo:line-height", TQString::number( lineSpacing * 100.0 ) + '%' );
833 case KoParagLayout::LS_FIXED:
836 case KoParagLayout::LS_CUSTOM:
839 case KoParagLayout::LS_AT_LEAST:
840 gs. addPropertyPt( "style:line-height-at-least", lineSpacing );
845 buffer.open( IO_WriteOnly );
848 KoTabulatorList::ConstIterator it = m_tabList.begin();
849 for ( ; it != m_tabList.end() ; it++ )
853 double pos = (*it).ptPos - margins[TQStyleSheetItem::MarginLeft];
856 switch ( (*it).type ) {
868 if ( !(*it).alignChar.isNull() )
869 tabsWriter. addAttribute( "style:char", TQString( (*it).alignChar ) );
874 switch( (*it).filling ) {
879 tabsWriter. addAttribute( "style:leader-type", "single" );
880 tabsWriter. addAttribute( "style:leader-style", "solid" );
885 tabsWriter. addAttribute( "style:leader-type", "single" );
886 tabsWriter. addAttribute( "style:leader-style", "dotted" );
891 tabsWriter. addAttribute( "style:leader-type", "single" );
892 tabsWriter. addAttribute( "style:leader-style", "dash" );
897 tabsWriter. addAttribute( "style:leader-type", "single" );
898 tabsWriter. addAttribute( "style:leader-style", "dot-dash" );
902 case TF_DASH_DOT_DOT:
903 tabsWriter. addAttribute( "style:leader-type", "single" );
904 tabsWriter. addAttribute( "style:leader-style", "dot-dot-dash" );
909 if ( (*it).filling != TF_BLANK )
916 TQString elementContents = TQString::fromUtf8( buffer.buffer(), buffer.buffer().size() );
921 bool fourBordersEqual = leftBorder.penWidth() > 0 &&
922 leftBorder == rightBorder && rightBorder == topBorder && topBorder == bottomBorder;
923 if ( fourBordersEqual ) {
924 gs. addProperty( "fo:border", leftBorder.saveFoBorder() );
926 if ( leftBorder.penWidth() > 0 )
927 gs. addProperty( "fo:border-left", leftBorder.saveFoBorder() );
928 if ( rightBorder.penWidth() > 0 )
929 gs. addProperty( "fo:border-right", rightBorder.saveFoBorder() );
930 if ( topBorder.penWidth() > 0 )
931 gs. addProperty( "fo:border-top", topBorder.saveFoBorder() );
932 if ( bottomBorder.penWidth() > 0 )
933 gs. addProperty( "fo:border-bottom", bottomBorder.saveFoBorder() );
936 if ( pageBreaking & KoParagLayout::HardFrameBreakBefore )
937 gs. addProperty( "fo:break-before", context.hasColumns() ? "column" : "page" );
938 else if ( pageBreaking & KoParagLayout::HardFrameBreakAfter )
939 gs. addProperty( "fo:break-after", context.hasColumns() ? "column" : "page" );
940 if ( pageBreaking & KoParagLayout::KeepLinesTogether )
942 if ( pageBreaking & KoParagLayout::KeepWithNext )
void addChildElement(const TQString &elementName, const TQString &elementContents) Add a child element to the style properties.
void addProperty(const TQString &propName, const TQString &propValue, PropertyType type=DefaultType) Add a property to the style.
void addPropertyPt(const TQString &propName, double propValue, PropertyType type=DefaultType) Add a property which represents a distance, measured in pt The number is written out with the highest...
Used during loading of Oasis format (and discarded at the end of the loading).
This is the structure associated with a paragraph (KoTextParag), to define the bullet or numbering of...
void load(TQDomElement &element) KOffice-1.3 loading code.
Numbering numbering() const Numbering type and style.
void save(TQDomElement &element) KOffice-1.3 saving code.
static void loadOasisParagLayout(KoParagLayout &layout, KoOasisContext &context) Load this parag layout from Oasis XML.
void saveOasis(KoGenStyle &gs, KoSavingContext &context, bool savingStyle) const Save this parag layout to Oasis XML.
static void loadParagLayout(KoParagLayout &layout, const TQDomElement &parentElem, int docVersion=2) Load this parag layout from XML.
static TQt::AlignmentFlags loadOasisAlignment(const TQCString &str) Convert an alignment string into an alignment flag (load).
TQColor backgroundColor The background color of the paragraph.
int compare(const KoParagLayout &layout) const Return a set of flags showing the differences between this and 'layout'.
void operator=(const KoParagLayout &) Assignment operator for KoParagLayout.
double margins[5] left, right, top, bottom, firstLineSpacing - in pt
static TQCString saveOasisAlignment(TQt::AlignmentFlags alignment) Convert an alignment flag into an alignment string (save).
KoParagCounter * counter can be 0 if no counter set
char alignment Alignment flag (AlignAuto/AlignLeft/AlignRight/AlignJustify).
void saveParagLayout(TQDomElement &parentElem, int alignment) const Save this parag layout to XML.
Used during saving to Oasis format (and discarded at the end of the saving).
TQString shadowAsCss() const Return css string for the shadow, used when saving.
static double parseValue(TQString value, double defaultVal=0.0) parse common KOffice and OO values, like "10cm", "5mm" to pt
TQString displayName() const The user-visible name (e.g. translated, or set by the user).
A class for writing out XML (to any TQIODevice), with a special attention on performance.
void startElement(const char *tagName, bool indentInside=true) Start a new element, as a child of the current element.
void addAttributePt(const char *attrName, double value) Add an attribute which represents a distance, measured in pt The number is written out with the highe...
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...
Struct: KoTabulator Defines the position of a tabulation (in pt), and its type.
KoTabulators type Type of tab (left/center/right/decimalpoint).
KoTabulatorFilling filling Type of tab filling.
double ptPos Position of the tab in pt.
TQChar alignChar Alignment character.
double ptWidth Width of the tab filling line.
|