20#include "KWTextParag.h"
21#include "KWDocument.h"
23#include "KWTextImage.h"
24#include "KWTextFrameSet.h"
25#include "KWVariable.h"
26#include "KWLoadingInfo.h"
28#include <KoVariable.h>
29#include <KoParagCounter.h>
30#include <KoOasisContext.h>
32#include <KoOasisStyles.h>
34#include <tdeglobalsettings.h>
43void KWTextParag::drawFormattingChars( TQPainter &painter, int start, int len,
44 int lastY_pix, int baseLine_pix, int h_pix,
46 KoTextFormat *lastFormat, const TQMemArray<int> &selectionStarts,
47 const TQMemArray<int> &selectionEnds, const TQColorGroup &cg,
48 bool rightToLeft, int line, KoTextZoomHandler* zh,
49 int whichFormattingChars )
51 KWTextFrameSet * textfs = kwTextDocument()->textFrameSet();
54 KWDocument * doc = textfs->kWordDocument();
55 if ( !doc || !doc->viewFormattingChars() )
58 whichFormattingChars = 0;
59 if ( doc->viewFormattingSpace() )
60 whichFormattingChars |= FormattingSpace;
61 if ( doc->viewFormattingBreak() )
62 whichFormattingChars |= FormattingBreak;
63 if ( doc->viewFormattingEndParag() )
64 whichFormattingChars |= FormattingEndParag;
65 if ( doc->viewFormattingTabs() )
66 whichFormattingChars |= FormattingTabs;
68 if ( !whichFormattingChars )
70 if ( start + len == length() && (whichFormattingChars & FormattingBreak) && hardFrameBreakAfter() )
73 TQPen pen( TDEGlobalSettings::linkColor() );
74 painter.setPen( pen );
77 TQString str = i18n( "--- Frame Break ---" );
80 width = lastFormat->screenFontMetrics( zh ).width( str );
81 TQColorGroup cg2( cg );
83 int last = length() - 1;
84 KoTextStringChar &ch = string()->at( last );
85 int x = zh->layoutUnitToPixelX( ch.x );
87 KoTextFormat format( *lastFormat );
88 format.setColor( pen.color() );
89 KoTextParag::drawParagStringInternal(
90 painter, str, 0, str.length(),
92 zh->layoutUnitToPixelY( ch.ascent() ),
93 width, zh->layoutUnitToPixelY( ch.height() ),
94 drawSelections, &format, selectionStarts,
95 selectionEnds, cg2, rightToLeft, line, zh, false );
97 whichFormattingChars &= ~FormattingEndParag;
101 KoTextParag::drawFormattingChars( painter, start, len,
102 lastY_pix, baseLine_pix, h_pix,
104 lastFormat, selectionStarts,
105 selectionEnds, cg, rightToLeft,
106 line, zh, whichFormattingChars );
111 m_layout.pageBreaking = pb;
113 if ( next() && ( pb & KoParagLayout::HardFrameBreakAfter ) )
114 next()->invalidate(0);
123TQDomElement KWTextParag::saveFormat( TQDomDocument & doc, KoTextFormat * curFormat, KoTextFormat * refFormat, int pos, int len )
128 TQDomElement formatElem = doc.createElement( "FORMAT" );
129 formatElem.setAttribute( "id", 1 );
132 formatElem.setAttribute( "pos", pos );
133 formatElem.setAttribute( "len", len );
136 if( !refFormat || curFormat->font().weight() != refFormat->font().weight() )
138 elem = doc.createElement( "WEIGHT" );
139 formatElem.appendChild( elem );
140 elem.setAttribute( "value", curFormat->font().weight() );
142 if( !refFormat || curFormat->color() != refFormat->color() )
144 if ( curFormat->color().isValid() )
146 elem = doc.createElement( "COLOR" );
147 formatElem.appendChild( elem );
148 elem.setAttribute( "red", curFormat->color().red() );
149 elem.setAttribute( "green", curFormat->color().green() );
150 elem.setAttribute( "blue", curFormat->color().blue() );
156 elem = doc.createElement( "COLOR" );
157 formatElem.appendChild( elem );
158 elem.setAttribute( "red", -1 );
159 elem.setAttribute( "green", -1 );
160 elem.setAttribute( "blue", -1 );
164 if( !refFormat || curFormat->font().family() != refFormat->font().family() )
166 elem = doc.createElement( "FONT" );
167 formatElem.appendChild( elem );
168 elem.setAttribute( "name", curFormat->font().family() );
170 if( !refFormat || curFormat->pointSize() != refFormat->pointSize() )
172 elem = doc.createElement( "SIZE" );
173 formatElem.appendChild( elem );
174 elem.setAttribute( "value", curFormat->pointSize() );
176 if( !refFormat || curFormat->font().italic() != refFormat->font().italic() )
178 elem = doc.createElement( "ITALIC" );
179 formatElem.appendChild( elem );
180 elem.setAttribute( "value", static_cast<int>(curFormat->font().italic()) );
183 || curFormat->underlineType() != refFormat->underlineType()
184 || curFormat->textUnderlineColor() !=refFormat->textUnderlineColor()
185 || curFormat->underlineStyle() !=refFormat->underlineStyle()
186 || curFormat->wordByWord() != refFormat->wordByWord())
188 elem = doc.createElement( "UNDERLINE" );
189 formatElem.appendChild( elem );
190 if ( curFormat->doubleUnderline() )
191 elem.setAttribute( "value", "double" );
192 else if ( curFormat->underlineType() == KoTextFormat::U_SIMPLE_BOLD)
193 elem.setAttribute( "value", "single-bold" );
194 else if( curFormat->underlineType()==KoTextFormat::U_WAVE)
195 elem.setAttribute( "value", "wave" );
197 elem.setAttribute( "value", static_cast<int>(curFormat->underline()) );
198 TQString strLineType=KoTextFormat::underlineStyleToString( curFormat->underlineStyle() );
199 elem.setAttribute( "styleline", strLineType );
200 if ( curFormat->textUnderlineColor().isValid() )
201 elem.setAttribute( "underlinecolor", curFormat->textUnderlineColor().name() );
203 elem.setAttribute( "wordbyword" , static_cast<int>(curFormat->wordByWord()));
206 || curFormat->strikeOutType() != refFormat->strikeOutType()
207 || curFormat->strikeOutStyle()!= refFormat->strikeOutStyle()
208 || curFormat->wordByWord() != refFormat->wordByWord())
210 elem = doc.createElement( "STRIKEOUT" );
211 formatElem.appendChild( elem );
212 if ( curFormat->doubleStrikeOut() )
213 elem.setAttribute( "value", "double" );
214 else if ( curFormat->strikeOutType() == KoTextFormat::S_SIMPLE_BOLD)
215 elem.setAttribute( "value", "single-bold" );
217 elem.setAttribute( "value", static_cast<int>(curFormat->strikeOut()) );
218 TQString strLineType=KoTextFormat::strikeOutStyleToString( curFormat->strikeOutStyle() );
219 elem.setAttribute( "styleline", strLineType );
220 elem.setAttribute( "wordbyword" , static_cast<int>(curFormat->wordByWord()));
222 if( !refFormat || (curFormat->vAlign() != refFormat->vAlign())
223 || (curFormat->relativeTextSize() != refFormat->relativeTextSize()))
225 elem = doc.createElement( "VERTALIGN" );
226 formatElem.appendChild( elem );
227 elem.setAttribute( "value", static_cast<int>(curFormat->vAlign()) );
228 if ( curFormat->relativeTextSize()!=0.66)
229 elem.setAttribute( "relativetextsize", curFormat->relativeTextSize() );
231 if( !refFormat || curFormat->textBackgroundColor() != refFormat->textBackgroundColor() )
233 if ( curFormat->textBackgroundColor().isValid())
235 elem = doc.createElement( "TEXTBACKGROUNDCOLOR" );
236 formatElem.appendChild( elem );
237 elem.setAttribute( "red", curFormat->textBackgroundColor().red() );
238 elem.setAttribute( "green", curFormat->textBackgroundColor().green() );
239 elem.setAttribute( "blue", curFormat->textBackgroundColor().blue() );
245 elem = doc.createElement( "TEXTBACKGROUNDCOLOR" );
246 formatElem.appendChild( elem );
247 elem.setAttribute( "red", -1 );
248 elem.setAttribute( "green", -1 );
249 elem.setAttribute( "blue", -1 );
254 ( curFormat->shadowDistanceX() != refFormat->shadowDistanceX()
255 || ( curFormat->shadowDistanceY() != refFormat->shadowDistanceY() )
256 || ( curFormat->shadowColor() != refFormat->shadowColor() ) ) )
258 elem = doc.createElement( "SHADOW" );
259 formatElem.appendChild( elem );
260 elem.setAttribute( "text-shadow", curFormat->shadowAsCss() );
262 if( !refFormat || curFormat->offsetFromBaseLine() != refFormat->offsetFromBaseLine())
264 elem = doc.createElement( "OFFSETFROMBASELINE" );
265 formatElem.appendChild( elem );
266 elem.setAttribute( "value", curFormat->offsetFromBaseLine() );
268 if( !refFormat || curFormat->attributeFont() != refFormat->attributeFont())
270 elem = doc.createElement( "FONTATTRIBUTE" );
271 formatElem.appendChild( elem );
272 elem.setAttribute( "value", KoTextFormat::attributeFontToString(curFormat->attributeFont()) );
274 if( !refFormat || curFormat->language() != refFormat->language())
276 elem = doc.createElement( "LANGUAGE" );
277 formatElem.appendChild( elem );
278 elem.setAttribute( "value", curFormat->language() );
287 save( parentElem, 0, TQMAX( 0, length()-2 ), saveAnchorsFramesets );
292 bool saveAnchorsFramesets )
294 TQDomDocument doc = parentElem.ownerDocument();
295 TQDomElement paragElem = doc.createElement( "PARAGRAPH" );
296 parentElem.appendChild( paragElem );
297 TQDomElement textElem = doc.createElement( "TEXT" );
298 textElem.setAttribute( "xml:space", "preserve");
299 paragElem.appendChild( textElem );
300 if ( partOfTableOfContents() )
301 paragElem.setAttribute( "toc", "true" );
302 TQString text = string()->toString();
303 Q_ASSERT( text.right(1)[0] == ' ' );
304 textElem.appendChild( doc.createTextNode( text.mid( from, to - from + 1 ) ) );
306 TQDomElement formatsElem = doc.createElement( "FORMATS" );
309 KoTextFormat *curFormat = paragraphFormat();
310 for ( int i = from; i <= to; ++i, ++index )
312 KoTextStringChar & ch = string()->at(i);
313 KoTextFormat * newFormat = static_cast<KoTextFormat * >( ch.format() );
316 if ( startPos > -1 && curFormat) {
317 TQDomElement formatElem = saveFormat( doc, curFormat,
318 paragraphFormat(), startPos, index-startPos );
319 if ( !formatElem.firstChild().isNull() )
320 formatsElem.appendChild( formatElem );
323 TQDomElement formatElem = saveFormat( doc, newFormat, paragraphFormat(), index, 1 );
324 formatsElem.appendChild( formatElem );
325 KoTextCustomItem* customItem = ch.customItem();
326 formatElem.setAttribute( "id", customItem->typeId() );
327 customItem->save( formatElem );
329 curFormat = paragraphFormat();
332 if ( saveAnchorsFramesets )
335 if ( dynamic_cast<KWAnchor * >( customItem ) )
336 inlineFs = static_cast<KWAnchor * >( customItem )->frameSet();
344 TQDomElement elem = doc.documentElement();
345 kdDebug() << " saving into " << elem.tagName() << endl;
346 inlineFs-> toXML( elem );
352 if ( newFormat != curFormat )
355 if ( startPos > -1 && curFormat) {
356 TQDomElement formatElem = saveFormat( doc, curFormat, paragraphFormat(), startPos, index-startPos );
357 if ( !formatElem.firstChild().isNull() )
358 formatsElem.appendChild( formatElem );
362 if( newFormat != paragFormat() )
365 curFormat = newFormat;
370 curFormat = paragraphFormat();
375 if ( startPos > -1 && index > startPos && curFormat) {
376 TQDomElement formatElem = saveFormat( doc, curFormat, paragraphFormat(), startPos, index-startPos );
377 if ( !formatElem.firstChild().isNull() )
378 formatsElem.appendChild( formatElem );
381 if (!formatsElem.firstChild().isNull())
382 paragElem.appendChild( formatsElem );
385 TQDomElement layoutElem = doc.createElement( "LAYOUT" );
386 paragElem.appendChild( layoutElem );
389 m_layout.saveParagLayout( layoutElem, resolveAlignment() );
395 TQDomElement paragFormatElement = saveFormat( doc, paragraphFormat(), 0L, 0, to - from + 1 );
396 layoutElem.appendChild( paragFormatElement );
400KoTextFormat KWTextParag::loadFormat( TQDomElement &formatElem, KoTextFormat * refFormat, const TQFont & defaultFont, const TQString & defaultLanguage, bool hyphanation )
404 format.setHyphenation( hyphanation );
409 format.setCollection( 0 );
410 font = format.font();
418 elem = formatElem.namedItem( "FONT" ).toElement();
419 if ( !elem.isNull() )
421 font.setFamily( elem.attribute( "name") );
423 else if ( !refFormat )
427 elem = formatElem.namedItem( "WEIGHT" ).toElement();
428 if ( !elem.isNull() )
429 font.setWeight( elem.attribute( "value" ).toInt() );
430 elem = formatElem.namedItem( "SIZE" ).toElement();
431 if ( !elem.isNull() )
432 font.setPointSize( elem.attribute( "value").toInt() );
433 elem = formatElem.namedItem( "ITALIC" ).toElement();
434 if ( !elem.isNull() )
435 font.setItalic( elem.attribute( "value").toInt() == 1 );
436 elem = formatElem.namedItem( "UNDERLINE" ).toElement();
437 if ( !elem.isNull() ) {
438 TQString value = elem.attribute( "value");
439 if ( value == "0" || value == "1" )
440 format.setUnderlineType( (value.toInt() == 1)?KoTextFormat::U_SIMPLE: KoTextFormat::U_NONE );
441 else if ( value == "single" )
442 format.setUnderlineType ( KoTextFormat::U_SIMPLE);
443 else if ( value == "double" )
444 format.setUnderlineType ( KoTextFormat::U_DOUBLE);
445 else if ( value == "single-bold" )
446 format.setUnderlineType ( KoTextFormat::U_SIMPLE_BOLD);
447 else if( value == "wave")
448 format.setUnderlineType ( KoTextFormat::U_WAVE);
449 if ( elem.hasAttribute( "styleline" ))
451 TQString strLineType = elem.attribute( "styleline");
452 format.setUnderlineStyle( KoTextFormat::stringToUnderlineStyle( strLineType ));
454 if ( elem.hasAttribute( "underlinecolor"))
456 TQColor col( TQColor(elem.attribute( "underlinecolor")));
457 format.setTextUnderlineColor( col );
459 if ( elem.hasAttribute( "wordbyword" ))
460 format.setWordByWord( elem.attribute( "wordbyword").toInt()==1);
462 elem = formatElem.namedItem( "STRIKEOUT" ).toElement();
463 if ( !elem.isNull() )
465 TQString value = elem.attribute( "value");
466 if ( value == "0" || value == "1" )
467 format.setStrikeOutType( (value.toInt() == 1)?KoTextFormat::S_SIMPLE: KoTextFormat::S_NONE );
468 else if ( value == "single" )
469 format.setStrikeOutType ( KoTextFormat::S_SIMPLE);
470 else if ( value == "double" )
471 format.setStrikeOutType ( KoTextFormat::S_DOUBLE);
472 else if ( value == "single-bold" )
473 format.setStrikeOutType ( KoTextFormat::S_SIMPLE_BOLD);
475 if ( elem.hasAttribute( "styleline" ))
477 TQString strLineType = elem.attribute( "styleline");
478 format.setStrikeOutStyle( KoTextFormat::stringToStrikeOutStyle( strLineType ));
480 if ( elem.hasAttribute( "wordbyword" ))
481 format.setWordByWord( elem.attribute( "wordbyword").toInt()==1);
489 format.setFont( font );
491 elem = formatElem.namedItem( "VERTALIGN" ).toElement();
492 if ( !elem.isNull() )
494 format.setVAlign( static_cast<KoTextFormat::VerticalAlignment >( elem.attribute( "value").toInt() ) );
495 if (elem.hasAttribute( "relativetextsize"))
496 format.setRelativeTextSize(elem.attribute( "relativetextsize").toDouble());
498 elem = formatElem.namedItem( "COLOR" ).toElement();
499 if ( !elem.isNull() )
501 int red = elem.attribute( "red").toInt();
502 int green = elem.attribute( "green").toInt();
503 int blue = elem.attribute( "blue").toInt();
504 if ( red == -1 && blue == -1 && green == -1 )
505 format.setColor( TQColor() );
507 format.setColor( TQColor(red,green,blue) );
509 elem = formatElem.namedItem( "TEXTBACKGROUNDCOLOR" ).toElement();
510 if ( !elem.isNull() )
512 int red = elem.attribute( "red").toInt();
513 int green = elem.attribute( "green").toInt();
514 int blue = elem.attribute( "blue").toInt();
515 if ( red == -1 && blue == -1 && green == -1 )
516 format.setTextBackgroundColor( TQColor() );
518 format.setTextBackgroundColor( TQColor(red,green,blue) );
520 elem = formatElem.namedItem( "SHADOW" ).toElement();
521 if ( !elem.isNull() )
523 format.parseShadowFromCss( elem.attribute( "text-shadow" ) );
526 elem = formatElem.namedItem( "SHADOWTEXT" ).toElement();
527 if ( !elem.isNull() && elem.attribute( "value").toInt() && KoParagLayout::shadowCssCompat )
531 format.parseShadowFromCss( *KoParagLayout::shadowCssCompat );
535 elem = formatElem.namedItem( "OFFSETFROMBASELINE" ).toElement();
536 if ( !elem.isNull() )
537 format.setOffsetFromBaseLine( elem.attribute( "value").toInt());
539 elem = formatElem.namedItem( "FONTATTRIBUTE" ).toElement();
540 if ( !elem.isNull() )
541 format.setAttributeFont( KoTextFormat::stringToAttributeFont(elem.attribute( "value")));
543 elem = formatElem.namedItem( "LANGUAGE" ).toElement();
544 if ( !elem.isNull() )
545 format.setLanguage( elem.attribute( "value") );
546 else if ( !refFormat )
547 format.setLanguage( defaultLanguage );
555 TQDomElement layout = attributes.namedItem( "LAYOUT" ).toElement();
556 if ( !layout.isNull() )
558 KWDocument * doc = kwTextDocument()->textFrameSet()->kWordDocument();
560 setParagLayout( paragLayout );
563 KoTextFormat *defaultFormat = style() ? &style()->format() : 0L;
564 TQDomElement formatElem = layout.namedItem( "FORMAT" ).toElement();
565 if ( !formatElem.isNull() )
568 KoTextFormat f = loadFormat( formatElem, defaultFormat, doc->defaultFont(), doc->globalLanguage(), doc->globalHyphenation() );
569 setFormat( document()->formatCollection()->format( &f ) );
574 setFormat( document()->formatCollection()->format( defaultFormat ) );
580 kdWarning(32001) << "No LAYOUT tag in PARAGRAPH, dunno what layout to apply" << endl;
589 TQDomElement element = attributes.namedItem( "TEXT" ).toElement();
590 if ( !element.isNull() )
593 append( element.text() );
595 setFormat( 0, string()->length(), paragFormat(), true );
598 if ( attributes.attribute( "toc" ) == "true" )
599 setPartOfTableOfContents( true );
610 TQValueList<int> removeLenList;
611 TQValueList<int> removePosList;
613 KWDocument * doc = kwTextDocument()->textFrameSet()->kWordDocument();
614 TQDomElement formatsElem = attributes.namedItem( "FORMATS" ).toElement();
615 if ( !formatsElem.isNull() )
617 TQDomElement formatElem = formatsElem.firstChild().toElement();
618 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
620 if ( formatElem.tagName() == "FORMAT" )
622 int index = formatElem.attribute( "pos" ).toInt() + offset;
623 int len = formatElem.attribute( "len" ).toInt();
625 int id = formatElem.attribute( "id" ).toInt();
629 KoTextFormat f = loadFormat( formatElem, paragraphFormat(), doc->defaultFont(),doc->globalLanguage(), doc->globalHyphenation() );
631 setFormat( index, len, document()->formatCollection()->format( &f ) );
641 KoTextStringChar& ch = string()->at(index);
642 if (ch.c.unicode()==1)
644 kdDebug() << "Replacing TQChar(1) (in KWTextParag::loadFormatting)" << endl;
649 kdDebug() << "KWTextParag::loadFormatting insertCustomItem" << endl;
650 paragFormat()->addRef();
651 setCustomItem( index, custom, paragFormat() );
652 custom->load( formatElem );
660 KoTextStringChar& ch = string()->at(index);
664 KoTextFormat f = loadFormat( formatElem, paragraphFormat(), doc->defaultFont(),doc->globalLanguage(), doc->globalHyphenation() );
666 setFormat( index, len, document()->formatCollection()->format( &f ) );
671 TQDomElement varElem = formatElem.namedItem( "VARIABLE" ).toElement();
673 if ( varElem.isNull() )
677 varElem = formatElem;
680 TQDomElement typeElem = varElem.namedItem( "TYPE" ).toElement();
681 if ( typeElem.isNull() )
683 ( oldDoc ? "No <TYPE> in <FORMAT> with id=4, for a variable [old document assumed] !"
684 : "No <TYPE> found in <VARIABLE> tag!" ) << endl;
687 int type = typeElem.attribute( "type" ).toInt();
688 TQString key = typeElem.attribute( "key" );
689 kdDebug() << "KWTextParag::loadFormatting variable type=" << type << " key=" << key << endl;
690 KoVariableFormat * varFormat = key.isEmpty() ? 0 : doc->variableFormatCollection()->format( key.latin1() );
693 if (typeElem.hasAttribute( "correct" ))
694 correct = typeElem.attribute( "correct").toInt();
695 KoVariable * var =doc->variableCollection()->createVariable( type, -1, doc->variableFormatCollection(), varFormat,kwTextDocument(),doc, correct, true , loadFootNote);
698 var->load( varElem );
699 KoTextFormat f = loadFormat( formatElem, paragraphFormat(), doc->defaultFont(),doc->globalLanguage(), doc->globalHyphenation() );
700 setCustomItem( index, var, document()->formatCollection()->format( &f ) );
703 removePosList.append(index+1);
704 removeLenList.append(len-1);
711 Q_ASSERT( len == 1 );
712 TQDomElement anchorElem = formatElem.namedItem( "ANCHOR" ).toElement();
713 if ( !anchorElem.isNull() ) {
714 TQString type = anchorElem.attribute( "type" );
715 if ( type == "grpMgr" || type == "frameset" )
717 TQString framesetName = anchorElem.attribute( "instance" );
719 pos.textfs = kwTextDocument()->textFrameSet();
720 pos.paragId = paragId();
722 doc->addAnchorRequest( framesetName, pos );
725 kdWarning() << "Anchor type not supported: " << type << endl;
728 kdWarning() << "Missing ANCHOR tag" << endl;
732 kdWarning() << "KWTextParag::loadFormatting id=" << id << " not supported" << endl;
738 for( unsigned int i=0; i < removeLenList.count(); i++) {
739 remove(*removePosList.at(i), *removeLenList.at(i));
743void KWTextParag::setParagLayout( const KoParagLayout & layout, int flags, int marginIndex )
745 KoTextParag::setParagLayout( layout, flags, marginIndex );
747 if ( flags & KoParagLayout::PageBreaking )
756 KoParagLayout layout;
764 TQDomElement element = parentElem.namedItem( "NAME" ).toElement();
765 if ( !element.isNull() )
767 TQString styleName = element.attribute( "value" );
768 style = doc->styleCollection()->findStyle( styleName );
771 kdError(32001) << "Cannot find style \"" << styleName << "\" specified in paragraph LAYOUT - using Standard" << endl;
772 style = doc->styleCollection()->findStyle( "Standard" );
778 kdError(32001) << "Missing NAME tag in paragraph LAYOUT - using Standard" << endl;
779 style = doc->styleCollection()->findStyle( "Standard" );
782 layout.style = style;
785 KoParagLayout::loadParagLayout( layout, parentElem, doc->syntaxVersion() );
790void KWTextParag::join( KoTextParag *parag )
792 m_layout.pageBreaking &= ~(KoParagLayout::HardFrameBreakBefore|KoParagLayout::HardFrameBreakAfter);
793 KoTextParag::join( parag );
796void KWTextParag::loadOasis( const TQDomElement& paragElement, KoOasisContext& context, KoStyleCollection *styleCollection, uint& pos )
798 KoTextParag::loadOasis( paragElement, context, styleCollection, pos );
800 KWTextFrameSet* textfs = kwTextDocument()->textFrameSet();
801 if ( textfs->isMainFrameset() && textfs->kWordDocument()->isLoading() )
803 KWDocument * doc = textfs->kWordDocument();
805 const TQString styleName = paragElement.attributeNS( KoXmlNS::text, "style-name", TQString() );
806 if ( !styleName.isEmpty() )
808 const TQDomElement* paragraphStyle = context.oasisStyles().findStyle( styleName, "paragraph" );
809 TQString masterPageName = paragraphStyle ? paragraphStyle->attributeNS( KoXmlNS::style, "master-page-name", TQString() ) : TQString();
813 if ( masterPageName.isEmpty() )
814 masterPageName = "Standard";
815 currentMasterPageRef = masterPageName;
816 context.styleStack().save();
817 context.styleStack().setTypeProperties( "paragraph" );
818 context.addStyles( paragraphStyle, "paragraph" );
820 TQString pageNumber = context.styleStack().attributeNS( KoXmlNS::style, "page-number" );
821 if ( !pageNumber.isEmpty() )
822 doc->variableCollection()->variableSetting()->setStartingPageNumber( pageNumber.toInt() );
823 context.styleStack().restore();
825 doc->loadOasisPageLayout( masterPageName, context );
827 else if ( !masterPageName.isEmpty()
828 && masterPageName != currentMasterPageRef )
832 kdDebug(32001) << "KWTextParag::loadOasis: change of master page detected: from " << currentMasterPageRef << " to " << masterPageName << " -> inserting page break" << endl;
833 currentMasterPageRef = masterPageName;
835 m_layout.pageBreaking |= KoParagLayout::HardFrameBreakBefore;
842void KWTextParag::saveOasis( KoXmlWriter& writer, KoSavingContext& context,
843 int from, int to, bool saveAnchorsFramesets ) const
847 if ( string()->length() == 2 ) {
848 KoTextStringChar &ch = string()->at( 0 );
849 if ( ch.isCustom() && dynamic_cast<KWAnchor* >( ch.customItem() )) {
850 KWFrameSet* fs = static_cast<KWAnchor * >( ch.customItem() )->frameSet();
851 if ( fs-> type() == FT_TABLE ) {
858 KoTextParag::saveOasis( writer, context, from, to, saveAnchorsFramesets );
An anchor is a special character, or 'custom item'.
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
virtual FrameSetType type() const The type of frameset.
virtual TQDomElement toXML(TQDomElement &parentElem, bool saveFrames=true) save to XML - when copying to clipboard
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context, bool saveFrames) const =0 Save to OASIS format.
TQString m_currentMasterPage Current master-page name (OASIS loading).
This is our KoTextDocument reimplementation, to create KWTextParag instead of KoTextParags,...
This class is used by "Insert Picture", i.e.
void load(TQDomElement &attributes) Load (from KWord-1.3 XML) the paragraph.
static KoTextFormat loadFormat(TQDomElement &formatElem, KoTextFormat *refFormat, const TQFont &defaultFont, const TQString &defaultLanguage, bool hyphanation) Public for loading a style (KWord-1.3 XML).
static KoParagLayout loadParagLayout(TQDomElement &parentElem, KWDocument *doc, bool useRefStyle) Load (from KWord-1.3 XML), optionally using styles from document.
static TQDomElement saveFormat(TQDomDocument &doc, KoTextFormat *curFormat, KoTextFormat *refFormat, int pos, int len) Public for saving a style (KWord-1.3 XML).
void save(TQDomElement &parentElem, bool saveAnchorsFramesets=false) Save (to KWord-1.3 XML) the whole paragraph.
void loadLayout(TQDomElement &attributes) Load (from KWord-1.3 XML) and apply paragraph layout.
void setPageBreaking(int pb) The type of page-breaking behaviour.
void loadFormatting(TQDomElement &attributes, int offset=0, bool loadFootNote=true) Load (from KWord-1.3 XML) and apply <FORMAT> tags (used by KWTextParag::load and by KWPasteCommand).
Definition of an anchor's position:
|