23#include "KWFrameSet.h"
24#include "KWFrameList.h"
25#include "KWDocument.h"
26#include "KWPageManager.h"
27#include "KWTextFrameSet.h"
28#include "KWViewMode.h"
31#include <KoOasisContext.h>
33#include <KoXmlWriter.h>
34#include <KoStyleStack.h>
47int ZOrderedFrameList::compareItems(TQPtrCollection::Item a, TQPtrCollection::Item b)
49 int za = ((KWFrame *)a)->zOrder();
50 int zb = ((KWFrame *)b)->zOrder();
51 if (za == zb) return 0;
52 if (za < zb) return -1;
65 copySettings( frame );
71 : KoRect( left, top, width, height ),
74 m_sheetSide( AnySide ),
76 m_runAroundSide( RA_BIGGEST ),
77 m_frameBehavior( AutoExtendFrame ),
78 m_newFrameBehavior( ( fs && fs->type() == FT_TEXT ) ? Reconnect : NoFollowup ),
80 m_drawFootNoteLine( false ),
81 m_runAroundLeft( 1.0 ),
82 m_runAroundRight( 1.0 ),
83 m_runAroundTop( 1.0 ),
84 m_runAroundBottom( 1.0 ),
89 m_minFrameHeight( 0.01 ),
92 m_backgroundColor( (fs && (fs->type() == FT_PICTURE || fs->type() == FT_PART)) ? TQBrush( TQColor(), TQt::NoBrush) : TQBrush( TQColor() ) ),
93 m_borderLeft( TQColor(), KoBorder::SOLID, 0 ),
94 m_borderRight( TQColor(), KoBorder::SOLID, 0 ),
95 m_borderTop( TQColor(), KoBorder::SOLID, 0 ),
96 m_borderBottom( TQColor(), KoBorder::SOLID, 0 ),
110void KWFrame::setBackgroundColor( const TQBrush &color )
112 m_backgroundColor = color;
118 Q_ASSERT( m_frameSet );
120 kdDebug() << k_funcinfo << this << " has no frameset!" << endl;
123 if( !m_frameSet->pageManager() ) {
124 kdWarning() << k_funcinfo << this << " is not a frame that is in use; misses a pageManager!" << endl;
140void KWFrame::copySettings( KWFrame *frm)
143 setRect(frm->x(), frm->y(), frm->width(), frm->height());
145 setSheetSide(frm->sheetSide());
146 setRunAround(frm->runAround());
147 setRunAroundSide(frm->runAroundSide());
148 setFrameBehavior(frm->frameBehavior());
149 setNewFrameBehavior(frm->newFrameBehavior());
150 setRunAroundGap(frm->runAroundLeft(), frm->runAroundRight(), frm->runAroundTop(), frm->runAroundBottom());
159 m_drawFootNoteLine = false;
160 setBackgroundColor( frm->backgroundColor() );
162 setRightBorder(frm->rightBorder());
163 setTopBorder(frm->topBorder());
164 setBottomBorder(frm->bottomBorder());
173void KWFrame::updateRulerHandles(){
178 KWDocument *doc = frameSet()->kWordDocument();
180 doc->updateRulerFrameStartEnd();
187 KWDocument *doc = m_frameSet->kWordDocument();
188 TQRect outerRect( doc->zoomRect( * this ) );
189 if ( viewMode && !m_frameSet->groupmanager() ) {
191 KWFrame* settingsFrame = m_frameSet->settingsFrame( this );
192 outerRect.rLeft() -= KoBorder::zoomWidthX( settingsFrame-> leftBorder().width(), doc, minBorder );
193 outerRect.rTop() -= KoBorder::zoomWidthY( settingsFrame->topBorder().width(), doc, minBorder );
194 outerRect.rRight() += KoBorder::zoomWidthX( settingsFrame->rightBorder().width(), doc, minBorder );
195 outerRect.rBottom() += KoBorder::zoomWidthY( settingsFrame->bottomBorder().width(), doc, minBorder );
203 KWDocument *doc = m_frameSet->kWordDocument();
204 KWFrame* settingsFrame = m_frameSet->settingsFrame( this );
205 outerRect.rLeft() -= KoBorder::zoomWidthX( settingsFrame-> leftBorder().width(), doc, 1 ) / doc->zoomedResolutionX();
206 outerRect.rTop() -= KoBorder::zoomWidthY( settingsFrame->topBorder().width(), doc, 1 ) / doc->zoomedResolutionY();
207 outerRect.rRight() += KoBorder::zoomWidthX( settingsFrame->rightBorder().width(), doc, 1 ) / doc->zoomedResolutionX();
208 outerRect.rBottom() += KoBorder::zoomWidthY( settingsFrame->bottomBorder().width(), doc, 1 ) / doc->zoomedResolutionY();
215 raRect.rLeft() -= m_runAroundLeft;
216 raRect.rRight() += m_runAroundRight;
217 raRect.rTop() -= m_runAroundTop;
218 raRect.rBottom() += m_runAroundBottom;
226 frameElem.setAttribute( "left", TQString::number( left(), 'g', DBL_DIG ) );
227 frameElem.setAttribute( "top", TQString::number( top(), 'g', DBL_DIG ) );
228 frameElem.setAttribute( "right", TQString::number( right(), 'g', DBL_DIG ) );
229 frameElem.setAttribute( "bottom", TQString::number( bottom(), 'g', DBL_DIG ) );
231 frameElem.setAttribute( "min-height", TQString::number( minimumFrameHeight(), 'g', DBL_DIG ) );
233 if ( !m_frameSet->isHeaderOrFooter() && !m_frameSet->isMainFrameset() )
235 if(runAround()!=RA_NO)
237 frameElem.setAttribute( "runaround", static_cast<int>( runAround() ) );
238 if (runAround() == RA_BOUNDINGRECT)
240 if (runAroundSide()==RA_LEFT)
241 frameElem.setAttribute( "runaroundSide", "left" );
242 else if (runAroundSide()==RA_RIGHT)
243 frameElem.setAttribute( "runaroundSide", "right" );
245 frameElem.setAttribute( "runaroundSide", "biggest" );
248 if(runAroundLeft()!=0 || runAroundRight()!=0 || runAroundTop()!=0 || runAroundBottom()!=0) {
249 frameElem.setAttribute( "runaroundLeft", m_runAroundLeft );
250 frameElem.setAttribute( "runaroundRight", m_runAroundRight );
251 frameElem.setAttribute( "runaroundTop", m_runAroundTop );
252 frameElem.setAttribute( "runaroundBottom", m_runAroundBottom );
254 double runAroundGap = TQMAX( TQMAX( m_runAroundLeft, m_runAroundRight ), TQMAX( m_runAroundTop, m_runAroundBottom ) );
255 frameElem.setAttribute( "runaroundGap", runAroundGap );
260 frameElem.setAttribute( "lWidth", leftBorder().penWidth() );
264 frameElem.setAttribute( "lRed", leftBorder().color.red() );
265 frameElem.setAttribute( "lGreen", leftBorder().color.green() );
266 frameElem.setAttribute( "lBlue", leftBorder().color.blue() );
268 if( leftBorder().getStyle() != KoBorder::SOLID)
269 frameElem.setAttribute( "lStyle", static_cast<int>( leftBorder().getStyle()) );
271 if(rightBorder().penWidth()!=0)
272 frameElem.setAttribute( "rWidth", rightBorder().penWidth() );
274 if(rightBorder().color.isValid())
276 frameElem.setAttribute( "rRed", rightBorder().color.red() );
277 frameElem.setAttribute( "rGreen", rightBorder().color.green() );
278 frameElem.setAttribute( "rBlue", rightBorder().color.blue() );
280 if(rightBorder().getStyle() != KoBorder::SOLID)
281 frameElem.setAttribute( "rStyle", static_cast<int>( rightBorder().getStyle() ) );
283 if(topBorder().penWidth()!=0)
284 frameElem.setAttribute( "tWidth", topBorder().penWidth() );
286 if(topBorder().color.isValid())
288 frameElem.setAttribute( "tRed", topBorder().color.red() );
289 frameElem.setAttribute( "tGreen", topBorder().color.green() );
290 frameElem.setAttribute( "tBlue", topBorder().color.blue() );
292 if(topBorder().getStyle() != KoBorder::SOLID)
293 frameElem.setAttribute( "tStyle", static_cast<int>( topBorder().getStyle() ) );
295 if(bottomBorder().penWidth()!=0) {
296 frameElem.setAttribute( "bWidth", bottomBorder().penWidth() );
298 if(bottomBorder().color.isValid()) {
299 frameElem.setAttribute( "bRed", bottomBorder().color.red() );
300 frameElem.setAttribute( "bGreen", bottomBorder().color.green() );
301 frameElem.setAttribute( "bBlue", bottomBorder().color.blue() );
303 if(bottomBorder().getStyle() != KoBorder::SOLID)
304 frameElem.setAttribute( "bStyle", static_cast<int>( bottomBorder().getStyle() ) );
306 if(backgroundColor().color().isValid())
308 frameElem.setAttribute( "bkRed", backgroundColor().color().red() );
309 frameElem.setAttribute( "bkGreen", backgroundColor().color().green() );
310 frameElem.setAttribute( "bkBlue", backgroundColor().color().blue() );
311 frameElem.setAttribute( "bkStyle", ( int)backgroundColor().style ());
314 frameElem.setAttribute( "bleftpt", paddingLeft() );
320 frameElem.setAttribute( "btoppt", paddingTop() );
325 if(frameBehavior()!=AutoCreateNewFrame)
326 frameElem.setAttribute( "autoCreateNewFrame", static_cast<int>( frameBehavior()) );
329 frameElem.setAttribute( "newFrameBehavior", static_cast<int>( newFrameBehavior()) );
332 frameElem.setAttribute( "copy", static_cast<int>( m_bCopy ) );
334 if(sheetSide()!= AnySide)
335 frameElem.setAttribute( "sheetSide", static_cast<int>( sheetSide()) );
337 frameElem.setAttribute( "z-index", zOrder() );
342 m_minFrameHeight = KWDocument::getAttribute( frameElem, "min-height", 0.0 );
343 m_runAround = static_cast<RunAround>( KWDocument::getAttribute( frameElem, "runaround", RA_NO ) );
344 TQString str = frameElem.attribute( "runaroundSide" );
346 m_runAroundSide = RA_LEFT;
347 else if ( str == "right" )
348 m_runAroundSide = RA_RIGHT;
350 m_runAroundSide = RA_BIGGEST;
352 double runAroundGap = ( frameElem.hasAttribute( "runaroundGap" ) )
353 ? frameElem.attribute( "runaroundGap" ).toDouble()
354 : frameElem.attribute( "runaGapPT" ).toDouble();
355 setRunAroundGap( KWDocument::getAttribute( frameElem, "runaroundLeft", runAroundGap ),
356 KWDocument::getAttribute( frameElem, "runaroundRight", runAroundGap ),
357 KWDocument::getAttribute( frameElem, "runaroundTop", runAroundGap ),
358 KWDocument::getAttribute( frameElem, "runaroundBottom", runAroundGap ) );
360 m_sheetSide = static_cast<SheetSide>( KWDocument::getAttribute( frameElem, "sheetSide", AnySide ) );
361 m_frameBehavior = static_cast<FrameBehavior>( KWDocument::getAttribute( frameElem, "autoCreateNewFrame", AutoCreateNewFrame ) );
365 defaultValue = static_cast<NewFrameBehavior>( KWDocument::getAttribute( frameElem, "newFrameBehaviour", defaultValue ) );
366 m_newFrameBehavior = static_cast<NewFrameBehavior>( KWDocument::getAttribute( frameElem, "newFrameBehavior", defaultValue ) );
368 m_newFrameBehavior = NoFollowup;
371 l.setPenWidth( KWDocument::getAttribute( frameElem, "lWidth", 0.0 ));
372 r.setPenWidth(KWDocument::getAttribute( frameElem, "rWidth", 0.0 ));
373 t.setPenWidth(KWDocument::getAttribute( frameElem, "tWidth", 0.0 ));
374 b.setPenWidth(KWDocument::getAttribute( frameElem, "bWidth", 0.0 ));
375 if ( frameElem.hasAttribute( "lRed") )
377 KWDocument::getAttribute( frameElem, "lRed", 0 ),
378 KWDocument::getAttribute( frameElem, "lGreen", 0 ),
379 KWDocument::getAttribute( frameElem, "lBlue", 0 ) );
380 if ( frameElem.hasAttribute( "rRed") )
382 KWDocument::getAttribute( frameElem, "rRed", 0 ),
383 KWDocument::getAttribute( frameElem, "rGreen", 0 ),
384 KWDocument::getAttribute( frameElem, "rBlue", 0 ) );
385 if ( frameElem.hasAttribute( "tRed") )
387 KWDocument::getAttribute( frameElem, "tRed", 0 ),
388 KWDocument::getAttribute( frameElem, "tGreen", 0 ),
389 KWDocument::getAttribute( frameElem, "tBlue", 0 ) );
390 if ( frameElem.hasAttribute( "bRed") )
392 KWDocument::getAttribute( frameElem, "bRed", 0 ),
393 KWDocument::getAttribute( frameElem, "bGreen", 0 ),
394 KWDocument::getAttribute( frameElem, "bBlue", 0 ) );
395 l.setStyle( static_cast<KoBorder::BorderStyle >( KWDocument::getAttribute( frameElem, "lStyle", KoBorder::SOLID ) ));
396 r.setStyle( static_cast<KoBorder::BorderStyle >( KWDocument::getAttribute( frameElem, "rStyle", KoBorder::SOLID ) ));
397 t.setStyle( static_cast<KoBorder::BorderStyle >( KWDocument::getAttribute( frameElem, "tStyle", KoBorder::SOLID ) ));
398 b.setStyle( static_cast<KoBorder::BorderStyle >( KWDocument::getAttribute( frameElem, "bStyle", KoBorder::SOLID ) ));
400 if ( frameElem.hasAttribute( "bkRed") )
402 KWDocument::getAttribute( frameElem, "bkRed", 0 ),
403 KWDocument::getAttribute( frameElem, "bkGreen", 0 ),
404 KWDocument::getAttribute( frameElem, "bkBlue", 0 ) );
406 if ( syntaxVersion < 2 )
408 if(c==l.color && l.penWidth()==1 && l.getStyle()==0 )
410 if(c==r.color && r.penWidth()==1 && r.getStyle()==0)
412 if(c==t.color && t.penWidth()==1 && t.getStyle()==0 )
414 if(c==b.color && b.penWidth()==1 && b.getStyle()==0 )
421 m_backgroundColor = TQBrush( c );
424 if( frameElem.hasAttribute( "bkStyle"))
425 m_backgroundColor.setStyle ( static_cast<TQt::BrushStyle >(KWDocument::getAttribute( frameElem, "bkStyle", TQt::SolidPattern )));
427 m_paddingLeft = frameElem.attribute( "bleftpt" ).toDouble();
428 m_paddingRight = frameElem.attribute( "brightpt" ).toDouble();
429 m_paddingTop = frameElem.attribute( "btoppt" ).toDouble();
430 m_paddingBottom = frameElem.attribute( "bbottompt" ).toDouble();
431 m_bCopy = KWDocument::getAttribute( frameElem, "copy", frameSet->isHeaderOrFooter() );
432 m_zOrder = frameElem.attribute( "z-index" ).toInt();
437void KWFrame::loadBorderProperties( KoStyleStack& styleStack )
440 m_paddingLeft = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "padding", "left" ) );
441 m_paddingRight = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "padding", "right" ) );
442 m_paddingTop = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "padding", "top" ) );
443 m_paddingBottom = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "padding", "bottom" ) );
446 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "background-color" ) ) {
447 TQString color = styleStack.attributeNS( KoXmlNS::fo, "background-color" );
448 if ( color == "transparent" )
449 m_backgroundColor = TQBrush( TQColor(), TQt::NoBrush );
452 m_backgroundColor = TQBrush( TQColor( color ) );
456 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "background-transparency" ) ) {
457 TQString transp = styleStack.attributeNS( KoXmlNS::fo, "background-transparency" );
458 if ( transp == "100%" )
459 m_backgroundColor.setStyle( TQt::NoBrush );
465 m_borderLeft.loadFoBorder( styleStack.attributeNS( KoXmlNS::fo, "border", "left") );
466 m_borderRight.loadFoBorder( styleStack.attributeNS( KoXmlNS::fo, "border", "right") );
467 m_borderTop.loadFoBorder( styleStack.attributeNS( KoXmlNS::fo, "border", "top") );
468 m_borderBottom.loadFoBorder( styleStack.attributeNS( KoXmlNS::fo, "border", "bottom") );
473void KWFrame::loadCommonOasisProperties( KoOasisContext& context, KWFrameSet* frameSet, const char* typeProperties )
475 KoStyleStack& styleStack = context.styleStack();
476 styleStack.setTypeProperties( typeProperties );
478 loadBorderProperties( styleStack );
483 if ( styleStack.hasAttributeNS( KoXmlNS::draw, "fill-color" ) ) {
484 TQString color = styleStack.attributeNS( KoXmlNS::draw, "fill-color" );
485 if ( color == "transparent" )
486 m_backgroundColor = TQBrush( TQColor(), TQt::NoBrush );
489 m_backgroundColor = TQBrush( TQColor( color ) );
495 m_runAroundLeft = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin", "left" ) );
496 m_runAroundRight = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin", "right" ) );
497 m_runAroundTop = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin", "top" ) );
498 m_runAroundBottom = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin", "bottom" ) );
501 m_runAroundLeft = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-left" ) );
502 m_runAroundRight = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-right" ) );
503 m_runAroundTop = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-top" ) );
504 m_runAroundBottom = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-bottom" ) );
508 const TQCString frameBehaviorOnNewPage = styleStack.attributeNS( KoXmlNS::koffice, "frame-behavior-on-new-page" ).latin1();
509 if ( frameBehaviorOnNewPage == "followup" )
510 m_newFrameBehavior = Reconnect;
511 else if ( frameBehaviorOnNewPage == "copy" )
512 m_newFrameBehavior = Copy;
513 else if ( frameBehaviorOnNewPage == "none" )
514 m_newFrameBehavior = NoFollowup;
516 m_newFrameBehavior = frameSet->isHeaderOrFooter() ? Copy : NoFollowup;
517 if ( !frameBehaviorOnNewPage.isEmpty() )
518 kdWarning(32001) << "Unknown value for koffice:frame-behavior-on-new-page: " << frameBehaviorOnNewPage << endl;
522 m_newFrameBehavior = NoFollowup;
526 const TQCString oowrap = styleStack.attributeNS( KoXmlNS::style, "wrap" ).latin1();
527 if ( oowrap == "none" )
528 runAround = KWFrame::RA_SKIP;
529 else if ( oowrap == "left" )
530 runAroundSide = KWFrame::RA_LEFT;
531 else if ( oowrap == "right" )
532 runAroundSide= KWFrame::RA_RIGHT;
533 else if ( oowrap == "run-through" )
534 runAround = KWFrame::RA_NO;
540 setRunAround( runAround );
541 setRunAroundSide( runAroundSide );
544void KWFrame::startOasisFrame( KoXmlWriter &writer, KoGenStyles& mainStyles, const TQString& name, const TQString& lastFrameName ) const
546 writer.startElement( "draw:frame" );
547 writer.addAttribute( "draw:name", name );
548 writer.addAttribute( "draw:style-name", saveOasisFrameStyle( mainStyles ) );
554 writer.addAttributePt( "svg:x", left() );
555 writer.addAttributePt( "svg:y", yInPage );
556 writer.addAttribute( "text:anchor-type", "page" );
557 writer.addAttribute( "text:anchor-page-number", pgNum );
558 writer.addAttribute( "draw:z-index", zOrder() );
560 writer.addAttributePt( "svg:width", width() );
561 writer.addAttributePt( "svg:height", height() );
563 writer.addAttribute( "draw:copy-of", lastFrameName );
568void KWFrame::saveBorderProperties( KoGenStyle& frameStyle ) const
572 if ( m_backgroundColor.style() == TQt::NoBrush )
573 frameStyle.addProperty( "fo:background-color", "transparent" );
574 else if ( m_backgroundColor.color().isValid() )
575 frameStyle.addProperty( "fo:background-color", m_backgroundColor.color().name() );
578 if ( ( m_borderLeft == m_borderRight )
579 && ( m_borderLeft == m_borderTop )
580 && ( m_borderLeft == m_borderBottom ) )
582 frameStyle.addProperty( "fo:border", m_borderLeft.saveFoBorder() );
586 frameStyle.addProperty( "fo:border-left", m_borderLeft.saveFoBorder() );
587 frameStyle.addProperty( "fo:border-right", m_borderRight.saveFoBorder() );
588 frameStyle.addProperty( "fo:border-top", m_borderTop.saveFoBorder() );
589 frameStyle.addProperty( "fo:border-bottom", m_borderBottom.saveFoBorder() );
592 if ( m_paddingLeft != 0 && ( ( m_paddingLeft == m_paddingRight )
593 && ( m_paddingLeft == m_paddingTop )
594 && ( m_paddingLeft == m_paddingBottom ) ) )
595 frameStyle.addPropertyPt( "fo:padding", m_paddingLeft );
598 if ( m_paddingLeft != 0 )
599 frameStyle.addPropertyPt( "fo:padding-left", m_paddingLeft );
600 if ( m_paddingRight != 0 )
601 frameStyle.addPropertyPt( "fo:padding-right", m_paddingRight );
602 if ( m_paddingTop != 0 )
603 frameStyle.addPropertyPt( "fo:padding-top", m_paddingTop );
604 if ( m_paddingBottom != 0 )
605 frameStyle.addPropertyPt( "fo:padding-bottom", m_paddingBottom );
609void KWFrame::saveMarginAttributes( KoXmlWriter &writer ) const
611 if ( m_runAroundLeft != 0 )
612 writer.addAttributePt( "fo:margin-left", m_runAroundLeft );
613 if ( m_runAroundRight != 0 )
614 writer.addAttributePt( "fo:margin-right", m_runAroundRight );
615 if ( m_runAroundTop != 0 )
616 writer.addAttributePt( "fo:margin-top", m_runAroundTop );
617 if ( m_runAroundBottom != 0 )
618 writer.addAttributePt( "fo:margin-bottom", m_runAroundBottom );
621void KWFrame::saveMarginProperties( KoGenStyle& frameStyle ) const
624 if ( m_runAroundLeft != 0 && ( ( m_runAroundLeft == m_runAroundRight )
625 && ( m_runAroundLeft == m_runAroundTop )
626 && ( m_runAroundLeft == m_runAroundBottom ) ) )
627 frameStyle.addPropertyPt( "fo:margin", m_runAroundLeft );
631 if ( m_runAroundLeft != 0 )
632 frameStyle.addPropertyPt( "fo:margin-left", m_runAroundLeft );
633 if ( m_runAroundRight != 0 )
634 frameStyle.addPropertyPt( "fo:margin-right", m_runAroundRight );
635 if ( m_runAroundTop != 0 )
636 frameStyle.addPropertyPt( "fo:margin-top", m_runAroundTop );
637 if ( m_runAroundBottom != 0 )
638 frameStyle.addPropertyPt( "fo:margin-bottom", m_runAroundBottom );
644TQString KWFrame::saveOasisFrameStyle( KoGenStyles& mainStyles ) const
646 KoGenStyle frameStyle( KWDocument::STYLE_FRAME_AUTO, "graphic" );
652 if ( !protect.isEmpty() )
656 if ( !protect.isEmpty() )
657 frameStyle.addProperty( "style:protect", protect );
661 frameStyle.addProperty( "style:horizontal-rel", "page" );
662 frameStyle.addProperty( "style:vertical-rel", "page" );
663 frameStyle.addProperty( "style:horizontal-pos", "from-left" );
664 frameStyle.addProperty( "style:vertical-pos", "from-top" );
669 if ( m_backgroundColor.style() == TQt::NoBrush )
670 frameStyle.addProperty( "draw:fill-color", "transparent" );
671 else if ( m_backgroundColor.color().isValid() )
672 frameStyle.addProperty( "draw:fill-color", m_backgroundColor.color().name() );
674 saveBorderProperties( frameStyle );
675 saveMarginProperties( frameStyle );
677 if ( runAround() == KWFrame::RA_SKIP )
678 frameStyle.addProperty( "style:wrap", "none" );
679 else if ( runAround() == KWFrame::RA_NO )
680 frameStyle.addProperty( "style:wrap", "run-through" );
683 if ( runAroundSide() == KWFrame::RA_LEFT )
684 frameStyle.addProperty( "style:wrap", "left" );
685 else if ( runAroundSide() == KWFrame::RA_RIGHT )
686 frameStyle.addProperty( "style:wrap", "right" );
687 else if ( runAroundSide() == KWFrame::RA_BIGGEST )
688 frameStyle.addProperty( "style:wrap", "biggest" );
694 if ( m_newFrameBehavior != defaultNfb ) {
695 const char* value = "none";
696 if ( m_newFrameBehavior == Reconnect )
698 else if ( m_newFrameBehavior == Copy )
700 else if ( m_newFrameBehavior == NoFollowup )
702 frameStyle.addProperty( "koffice:frame-behavior-on-new-page", value );
706 const char* frameBehav = 0;
707 if ( m_frameBehavior == KWFrame::Ignore )
709 else if ( m_frameBehavior == KWFrame::AutoCreateNewFrame )
710 frameBehav = "auto-create-new-frame";
713 frameStyle.addProperty( "style:overflow-behavior", frameBehav );
715 return mainStyles.lookup( frameStyle, "fr" );
723KoRect KWFrame::innerRect() const
725 KoRect inner( this->normalize());
727 inner.setWidth( innerWidth() );
728 inner.setHeight( innerHeight() );
732double KWFrame::innerWidth() const
734 return KMAX( 0.0, width() - m_paddingLeft - m_paddingRight );
737double KWFrame::innerHeight() const
739 return KMAX( 0.0, height() - m_paddingTop - m_paddingBottom );
742void KWFrame::setFramePadding( double left, double top, double right, double bottom)
744 m_paddingLeft = left;
746 m_paddingRight = right;
747 m_paddingBottom = bottom;
752 return f1->zOrder() < f2->zOrder();
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
KWTextFrameSet * anchorFrameset() const Return the frameset in which our anchor is - assuming isFloating().
bool isFrameAtPos(const KWFrame *frame, const TQPoint &nPoint, bool borderOfFrameOnly=false) const Return if the point is on the frame.
This class represents a single frame.
bool frameAtPos(const TQPoint &nPoint, bool borderOfFrameOnly=false) const Return if the point is on the frame.
NewFrameBehavior What happens on new page (create a new frame and reconnect, no followup, make copy).
TQRect outerRect(KWViewMode *viewMode) const Return the zoomed rectangle for this frame, including the border - for drawing.
double minimumFrameHeight(void) const
KWFrameSet * frameSet() const Data stucture methods.
double paddingTop() const get top padding
double paddingBottom() const get bottom padding
void setPaddingLeft(double b) set left padding (distance between frame contents and frame border)
void setMinimumFrameHeight(double h) The property minimum frame height is used to make the automatic frame shrinking code stop.
static bool compareFrameZOrder(KWFrame *f1, KWFrame *f2) This is a method used to sort a list using the STL sorting methods.
virtual ~KWFrame() Destructor.
void setPaddingRight(double b) set right padding
FrameBehavior what should happen when the frame is full
void setZOrder(int z) The z-order of the frame, relative to the other frames on the same page.
void save(TQDomElement &frameElem) create XML to describe yourself
RunAround Runaround types RA_NO = No run around, all text is just printed.
void setPaddingBottom(double b) set bottom padding
double paddingLeft() const get left padding
bool isCopy() const Drawing property: if isCopy, this frame is a copy of the previous frame in the frameset.
double paddingRight() const get right padding
void setPaddingTop(double b) set top padding
int pageNumber() const The page on which this frame is.
const KoBorder & leftBorder() const All borders can be custom drawn with their own colors etc.
KoRect outerKoRect() const Return the unzoomed rectangle, including the border, for the frames-on-top list.
void startOasisFrame(KoXmlWriter &xmlWriter, KoGenStyles &mainStyles, const TQString &name, const TQString &lastFrameName=TQString()) const Write out a draw:frame element and its style.
void load(TQDomElement &frameElem, KWFrameSet *frameSet, int syntaxVersion) read attributes from XML.
RunAroundSide Runaround side - only meaningful when RA_BOUNDINGRECT is used.
KoRect runAroundRect() const Return the rectangle for this frame including the border and the runaround gap.
KWFrame(KWFrameSet *fs, double left, double top, double width, double height, RunAround ra=RA_BOUNDINGRECT) Constructor.
KWFrame * getCopy() returns a copy of self
SheetSide This frame will only be copied to: AnySide, OddSide or EvenSide.
void frameBordersChanged() Marks a frame to have changed position/borders.
double topOfPage(int pageNumber) const Return the y-offset in this document of the top of page with pageNumber Note that pageNumber is NOT a...
int pageNumber(const KoRect *rect) const return pageNumber of frame, pagenumbers for a normal document start at 1.
virtual void invalidate() Invalidate all paragraphs (causes a re-flow of the text upon next redraw).
Abstract base class for KWCanvas's view modes.
bool drawFrameBorders() const Should we see frame borders?
|