21#include "KWTextFrameSet.h"
22#include "KWTableFrameSet.h"
23#include "KWDocument.h"
25#include "KWViewMode.h"
29#include "KWFormulaFrameSet.h"
30#include "KWBgSpellCheck.h"
31#include "KWordTextFrameSetIface.h"
32#include "KWordTextFrameSetEditIface.h"
33#include "KWordFootNoteFrameSetIface.h"
34#include "KWordFrameSetIface.h"
35#include "KWLoadingInfo.h"
36#include "KWInsertTOCCommand.h"
37#include "KWMailMergeDataBase.h"
38#include "KoTextBookmark.h"
39#include "KWVariable.h"
40#include "KWOasisSaver.h"
41#include "KWFrameList.h"
42#include "KWPageManager.h"
45#include <KoParagCounter.h>
46#include <KoCustomVariablesDia.h>
47#include <KoAutoFormat.h>
48#include <KoTextObject.h>
49#include <KoTextCommand.h>
50#include <KoTextFormatter.h>
51#include <KoChangeCaseDia.h>
53#include <KoXmlWriter.h>
54#include <KoOasisContext.h>
59#include <tdemessagebox.h>
62#include <tqclipboard.h>
63#include <tqdragobject.h>
66#include <tqprogressdialog.h>
70#include <tqapplication.h>
87class KWTextFormatter :
public KoTextFormatter
91 virtual ~KWTextFormatter() {}
93 virtual int formatVertically( KoTextDocument*, KoTextParag* parag )
95 return m_textfs->formatVertically( parag, parag->rect() );
97 virtual void postFormat( KoTextParag* parag )
99 m_textfs->fixParagWidth(
static_cast<KWTextParag *
>( parag ) );
109 if (
name.isEmpty() )
110 m_name = _doc->generateFramesetName( i18n(
"Text Frameset %1" ) );
114 TQObject::setName( m_name.utf8() );
121 m_name = tag.attributeNS( KoXmlNS::draw,
"name", TQString() );
122 if ( doc->frameSetByName( m_name ) )
123 m_name = doc->generateFramesetName( m_name +
" %1" );
133 TQObject::setName( m_name.utf8() );
134 m_currentViewMode = 0L;
135 m_currentDrawnFrame = 0L;
136 m_lastTextDocHeight = 0;
140void KWTextFrameSet::init()
142 m_currentViewMode = 0L;
143 m_currentDrawnFrame = 0L;
144 m_lastTextDocHeight = 0;
147 new KoTextFormatCollection( m_doc->defaultFont(), TQColor(),
148 m_doc->globalLanguage(),
149 m_doc->globalHyphenation() ),
150 new KWTextFormatter(
this ) );
151 textdoc->setFlow(
this );
152 textdoc->setPageBreakEnabled(
true );
153 if ( m_doc->tabStopValue() != -1 )
154 textdoc->setTabStops( m_doc->ptToLayoutUnitPixX( m_doc->tabStopValue() ));
156 m_textobj =
new KoTextObject( textdoc, m_doc->styleCollection()->findStyle(
"Standard" ),
157 this, (m_name+
"-textobj").utf8() );
158 m_doc->backSpeller()->registerNewTextObject( m_textobj );
159 connect( m_textobj, TQ_SIGNAL( availableHeightNeeded() ),
160 TQ_SLOT( slotAvailableHeightNeeded() ) );
161 connect( m_textobj, TQ_SIGNAL( afterFormatting(
int, KoTextParag*,
bool* ) ),
162 TQ_SLOT( slotAfterFormatting(
int, KoTextParag*,
bool* ) ) );
167 connect( m_textobj, TQ_SIGNAL( newCommand( KCommand * ) ),
168 TQ_SLOT( slotNewCommand( KCommand * ) ) );
170 TQ_SLOT( slotRepaintChanged() ) );
171 connect( m_textobj, TQ_SIGNAL( paragraphDeleted( KoTextParag*) ),
172 TQ_SLOT( slotParagraphDeleted(KoTextParag*) ));
174 connect( m_textobj, TQ_SIGNAL( paragraphCreated( KoTextParag*) ),
175 TQ_SLOT( slotParagraphCreated(KoTextParag*) ));
176 connect( m_textobj, TQ_SIGNAL( paragraphModified( KoTextParag*,
int,
int,
int) ),
177 TQ_SLOT( slotParagraphModified(KoTextParag*,
int,
int,
int) ));
180void KWTextFrameSet::slotParagraphModified(KoTextParag* _parag,
int _type,
int start,
int length)
182 kWordDocument()->paragraphModified(_parag, _type, start, length);
185void KWTextFrameSet::slotParagraphCreated(KoTextParag* )
190void KWTextFrameSet::slotParagraphDeleted(KoTextParag*_parag)
192 kWordDocument()->paragraphDeleted( _parag,
this);
195KWordFrameSetIface* KWTextFrameSet::dcopObject()
198 m_dcop =
new KWordTextFrameSetIface(
this );
208KoTextDocument * KWTextFrameSet::textDocument()
const
210 return m_textobj->textDocument();
218void KWTextFrameSet::slotAvailableHeightNeeded()
221 kdDebug() <<
"KWTextFrameSet::slotAvailableHeightNeeded " <<
name() << endl;
228 kdDebug() <<
"KWTextFrameSet::documentToInternal dPoint:" << dPoint.x() <<
"," << dPoint.y() << endl;
230 if ( !m_doc->layoutViewMode()->hasFrames() ) {
231 iPoint = TQPoint( m_doc->ptToLayoutUnitPixX( dPoint.x() ),
232 m_doc->ptToLayoutUnitPixY( dPoint.y() ) );
233 return m_frames.getFirst();
236 int pageNum = m_doc->pageManager()->pageNumber(dPoint);
237 TQPtrListIterator<KWFrame> frameIt(
framesInPage( pageNum ) );
238 for ( ; frameIt.current(); ++frameIt )
240 KWFrame *theFrame = frameIt.current();
241 if ( theFrame->contains( dPoint ) )
243 iPoint.setX( m_doc->ptToLayoutUnitPixX( dPoint.x() - theFrame->innerRect().x() ) );
244 iPoint.setY( m_doc->ptToLayoutUnitPixY( dPoint.y() - theFrame->innerRect().y() + theFrame->internalY() ) );
246 kdDebug() <<
"documentToInternal: returning " << iPoint.x() <<
"," << iPoint.y()
247 <<
" internalY=" << theFrame->internalY() <<
" because frame=" << theFrame
248 <<
" contains dPoint:" << dPoint.x() <<
"," << dPoint.y() << endl;
259 iPoint = m_doc->ptToLayoutUnitPix( dPoint );
263KWFrame * KWTextFrameSet::documentToInternalMouseSelection(
const KoPoint &dPoint, TQPoint &iPoint, RelativePosition& relPos,
KWViewMode *viewMode )
const
266 kdDebug() <<
"KWTextFrameSet::documentToInternalMouseSelection dPoint:" << dPoint.x() <<
"," << dPoint.y() << endl;
269 relPos = InsideFrame;
270 iPoint = TQPoint( m_doc->ptToLayoutUnitPixX( dPoint.x() ),
271 m_doc->ptToLayoutUnitPixY( dPoint.y() ) );
272 return m_frames.getFirst();
276 int pageNum = m_doc->pageManager()->pageNumber(dPoint);
277 TQPtrListIterator<KWFrame> frameIt(
framesInPage( pageNum ) );
278 for ( ; frameIt.current(); ++frameIt )
280 KWFrame *theFrame = frameIt.current();
281 if ( theFrame->contains( dPoint ) )
283 iPoint.setX( m_doc->ptToLayoutUnitPixX( dPoint.x() - theFrame->innerRect().x() ) );
284 iPoint.setY( m_doc->ptToLayoutUnitPixY( dPoint.y() - theFrame->innerRect().y() + theFrame->internalY() ) );
286 kdDebug() <<
"documentToInternal: returning InsideFrame " << iPoint.x() <<
"," << iPoint.y()
287 <<
" internalY=" << theFrame->internalY() <<
" because frame=" << theFrame
288 <<
" contains dPoint:" << dPoint.x() <<
"," << dPoint.y() << endl;
290 relPos = InsideFrame;
295 for ( ; frameIt.current(); ++frameIt )
297 KWFrame *theFrame = frameIt.current();
298 KoRect openLeftRect( theFrame->innerRect() );
301 kdDebug() <<
"documentToInternal: openLeftRect=" << openLeftRect << endl;
303 if ( openLeftRect.contains( dPoint ) )
306 iPoint.setX( m_doc->ptToLayoutUnitPixX(theFrame->innerRect().left() ));
307 iPoint.setY( m_doc->ptToLayoutUnitPixY( dPoint.y() - theFrame->top() + theFrame->internalY() ) );
309 kdDebug() <<
"documentToInternal: returning LeftOfFrame " << iPoint.x() <<
"," << iPoint.y()
310 <<
" internalY=" << theFrame->internalY() <<
" because openLeftRect=" << openLeftRect
311 <<
" contains dPoint:" << dPoint.x() <<
"," << dPoint.y() << endl;
313 relPos = LeftOfFrame;
316 KoRect openTopRect( KoPoint( 0, 0 ), theFrame->innerRect().bottomRight() );
318 kdDebug() <<
"documentToInternal: openTopRect=" << openTopRect << endl;
320 if ( openTopRect.contains( dPoint ) )
323 iPoint.setX( m_doc->ptToLayoutUnitPixX( dPoint.x() - theFrame->innerRect().left() ) );
324 iPoint.setY( m_doc->ptToLayoutUnitPixY( theFrame->internalY() ) );
326 kdDebug() <<
"documentToInternal: returning " << iPoint.x() <<
"," << iPoint.y()
327 <<
" internalY=" << theFrame->internalY() <<
" because openTopRect=" << openTopRect
328 <<
" contains dPoint:" << dPoint.x() <<
"," << dPoint.y() << endl;
339 KWFrame *theFrame = m_frames.getLast();
340 iPoint.setX( m_doc->ptToLayoutUnitPixX( theFrame->innerWidth() ) );
341 iPoint.setY( m_doc->ptToLayoutUnitPixY( theFrame->innerHeight() ) );
343 kdDebug() <<
"documentToInternal: returning AtEnd " << iPoint.x() <<
"," << iPoint.y()
344 <<
" because we are under all frames of the last page" << endl;
351 TQPtrListIterator<KWFrame> frameIt(
framesInPage( pageNum + 1 ) );
352 if ( frameIt.current() )
355 KWFrame *theFrame = frameIt.current();
356 KoRect openTopRect( theFrame->innerRect() );
357 openTopRect.setTop( 0 );
358 if ( openTopRect.contains( dPoint ) )
359 iPoint.setX( m_doc->ptToLayoutUnitPixX( dPoint.x() - theFrame->left() ) );
362 iPoint.setY( m_doc->ptToLayoutUnitPixY( theFrame->internalY() ) );
364 kdDebug() <<
"documentToInternal: returning TopOfFrame " << iPoint.x() <<
"," << iPoint.y()
365 <<
" because we are under all frames of page " << pageNum << endl;
373 iPoint = m_doc->ptToLayoutUnitPix( dPoint );
375 kdDebug() <<
"documentToInternal: returning not found for " << iPoint.x() <<
"," << iPoint.y() << endl;
383 kdDebug() <<
"KWTextFrameSet::internalToDocumentWithHint hintDPoint: " << hintDPoint.x() <<
"," << hintDPoint.y() << endl;
385 if ( !m_doc->layoutViewMode()->hasFrames() ) {
386 dPoint = m_doc->layoutUnitPtToPt( m_doc->pixelToPt( iPoint ) );
387 return m_frames.getFirst();
391 for ( ; frameIt.current(); ++frameIt )
393 KWFrame *theFrame = frameIt.current();
394 TQRect r( 0, m_doc->ptToLayoutUnitPixY( theFrame->internalY() ), m_doc->ptToLayoutUnitPixX( theFrame->innerWidth() )+1, m_doc->ptToLayoutUnitPixY( theFrame->innerHeight() )+1 );
396 kdDebug() <<
"ITD: r=" << r <<
" iPoint=" << iPoint.x() <<
"," << iPoint.y() << endl;
399 if ( r.contains( iPoint ) )
403 kdDebug() <<
"copy: " << theFrame->
isCopy() <<
" hintDPoint.y()=" << hintDPoint.y() <<
" dPoint.y()=" << dPoint.y() << endl;
407 if ( hintDPoint.isNull() || hintDPoint.y() <= dPoint.y() )
410 lastFrame = theFrame;
412 else if ( lastFrame )
421 kdDebug(32002) <<
"KWTextFrameSet::internalToDocumentWithHint " << iPoint.x() <<
"," << iPoint.y()
422 <<
" not in any frame of " << (
void*)
this << endl;
424 dPoint = m_doc->layoutUnitPtToPt( m_doc->pixelToPt( iPoint ) );
432 if ( m_doc->layoutViewMode()->hasFrames() )
433 Q_ASSERT( theFrame );
435 return KoPoint( relPoint.x() + theFrame->innerRect().x(),
436 relPoint.y() - theFrame->internalY() + theFrame->innerRect().y() );
449 if ( !
isVisible() || m_frames.isEmpty() )
452 int num = currentPgNum + direction;
453 int pages = m_doc->pageCount();
454 for ( ; num >= 0 && num < pages ; num += direction )
462 TQPtrListIterator<KWFrame> frameIt(
framesInPage( num ) );
463 return TQPoint( 0, m_doc->ptToLayoutUnitPixY( frameIt.current()->internalY() ) + 2 );
467 return TQPoint( 0, m_doc->ptToLayoutUnitPixY( m_frames.getFirst()->internalY() ) + 2 );
470 KWFrame * theFrame = m_frames.getLast();
471 return TQPoint( 0, m_doc->ptToLayoutUnitPixY( theFrame->internalY() + theFrame->innerHeight() ) );
476 bool onlyChanged,
bool resetChanged,
480 m_currentViewMode = viewMode;
484 if ( isMainFrameset() && viewMode->
hasFrames() )
490 if ( m_doc->footNoteSeparatorLineWidth() ==0.0)
493 int pages = m_doc->pageCount();
494 KWPage *page = m_doc->pageManager()->page(m_doc->pageManager()->startPage());
497 double width = pageWidth * m_doc->footNoteSeparatorLineLength() / 100.0;
498 int numColumns = m_doc->numColumns();
499 for (
int pageNum = 0; pageNum < pages; pageNum++ )
503 uint frameNum = pageNum * numColumns ;
508 if (
frame->drawFootNoteLine() )
510 double y =
frame->bottomLeft().y() + m_doc->headerFooterInfo().ptFootNoteBodySpacing / 2;
511 KoRect rect( left, y, width, 0 );
512 switch( m_doc->footNoteSeparatorLinePosition())
517 rect = KoRect( pageWidth/2.0+left-width/2.0, y,width,0);
520 rect = KoRect( pageWidth+left-width, y,width,0);
524 TQRect flatRect = viewMode->
normalToView( m_doc->zoomRect( rect ) );
526 flatRect.setBottom( flatRect.top() + 1 );
527 if ( flatRect.intersects( crect ) ) {
529 TQPen pen( KoTextFormat::defaultTextColor( p ),
530 KoBorder::zoomWidthY( m_doc->footNoteSeparatorLineWidth(), m_doc, 1 ) );
531 switch( m_doc->footNoteSeparatorLineType())
534 pen.setStyle( TQt::SolidLine );
537 pen.setStyle( TQt::DashLine );
540 pen.setStyle( TQt::DotLine );
543 pen.setStyle( TQt::DashDotLine );
545 case SLT_DASH_DOT_DOT:
546 pen.setStyle( TQt::DashDotDotLine );
550 p->drawLine( flatRect.left(), flatRect.top(), flatRect.right(), flatRect.top() );
562 const TQPoint& translationOffset,
563 KWFrame *settingsFrame,
const TQColorGroup &cg,
bool onlyChanged,
bool resetChanged,
570 drawUnderlyingFrames &= theFrame->isTransparent();
572 KWFrameSet::drawFrame( theFrame, painter, fcrect, crect, translationOffset,
settingsFrame, cg, onlyChanged, resetChanged, edit, viewMode, drawUnderlyingFrames );
576 const TQColorGroup &cg,
bool onlyChanged,
bool resetChanged,
579 Q_ASSERT( r.isValid() );
584 m_currentDrawnFrame = theFrame;
589 TQPtrListIterator<KoTextCustomItem> cit( textDocument()->allCustomItems() );
590 for ( ; cit.current() ; ++cit )
593 if ( var && !var->isDeleted() )
595 TQSize oldSize( var->width, var->height );
596 const int pageNumberOffset = kWordDocument()->variableCollection()->variableSetting()->startingPageNumber() - 1;
597 switch ( var->subType() )
599 case KWPgNumVariable::VST_PGNUM_CURRENT:
602 var->setPgNum( theFrame->
pageNumber() + pageNumberOffset );
604 case KWPgNumVariable::VST_CURRENT_SECTION:
605 var->setSectionTitle( kWordDocument()->sectionTitle( theFrame->
pageNumber() ) );
607 case KWPgNumVariable::VST_PGNUM_PREVIOUS:
608 var->setPgNum( TQMAX(theFrame->
pageNumber()-1,0) + pageNumberOffset );
610 case KWPgNumVariable::VST_PGNUM_NEXT:
611 var->setPgNum( theFrame->
pageNumber() + 1 + pageNumberOffset );
616 TQSize newSize( var->width, var->height );
617 if ( oldSize != newSize )
618 var->paragraph()->invalidate( 0 );
619 var->paragraph()->setChanged(
true );
625 uint drawingFlags = 0;
627 drawingFlags |= KoTextDocument::DrawSelections;
629 drawingFlags |= KoTextDocument::TransparentBackground;
630 if ( m_doc->backgroundSpellCheckEnabled() )
631 drawingFlags |= KoTextDocument::DrawMisspelledLine;
632 if ( m_doc->viewFormattingChars() )
633 drawingFlags |= KoTextDocument::DrawFormattingChars;
636 KoTextParag * lastFormatted = textDocument()->drawWYSIWYG(
637 painter, r.x(), r.y(), r.width(), r.height(),
639 onlyChanged,
false, cursor, resetChanged, drawingFlags );
644 if ( onlyChanged && resetChanged )
648 KoTextParag * lastDrawn = lastFormatted->prev();
649 if ( lastFormatted == textDocument()->lastParag() && ( !lastDrawn || m_doc->layoutUnitToPixelY( lastDrawn->rect().bottom() ) < r.bottom() ) )
650 lastDrawn = lastFormatted;
653 if ( lastDrawn && m_doc->layoutUnitToPixelY( lastDrawn->rect().bottom() ) > r.bottom() )
656 lastDrawn->setChanged(
true );
666 if ( ( !lastFormatted || lastFormatted == textDocument()->lastParag() )
670 int docHeight = textDocument()->lastParag()->pixelRect(m_doc).bottom() + 1;
674 TQRect blank( 0, docHeight, availSize.width(), availSize.height() - docHeight );
676 painter->fillRect( blank, cg.brush( TQColorGroup::Base ) );
680 m_currentDrawnFrame = 0L;
683void KWTextFrameSet::drawCursor( TQPainter *p, KoTextCursor *cursor,
bool cursorVisible,
KWCanvas *canvas,
KWFrame *theFrame )
686 m_currentViewMode = canvas->viewMode();
687 bool hasFrames = m_currentViewMode->
hasFrames();
688 m_currentDrawnFrame = theFrame;
690 TQRect normalFrameRect;
692 normalFrameRect = m_doc->zoomRect( theFrame->innerRect() );
694 normalFrameRect = TQRect( TQPoint(0, 0), m_currentViewMode->
contentsSize() );
696 KoTextParag* parag = cursor->parag();
697 TQPoint topLeft = parag->rect().topLeft();
700 int cursorHeight = m_doc->layoutUnitToPixelY( topLeft.y(), parag->lineHeightOfChar( cursor->index(), 0, &lineY ) );
701 TQPoint iPoint( topLeft.x() + cursor->x(),
702 topLeft.y() + lineY );
705 kdDebug() <<
"KWTextFrameSet::drawCursor topLeft=" << topLeft.x() <<
"," << topLeft.y()
706 <<
" x=" << cursor->x() <<
" y=" << lineY << endl;
707 kdDebug() <<
"KWTextFrameSet::drawCursor iPoint=" << iPoint.x() <<
"," << iPoint.y()
708 <<
" cursorHeight=" << cursorHeight << endl;
711 KoPoint hintDPoint = theFrame ? theFrame->innerRect().topLeft() : KoPoint();
715 kdDebug() <<
" dPoint(doc, pts)=" << dPoint.x() <<
"," << dPoint.y() << endl;
716 TQPoint debugPt = m_doc->zoomPoint( dPoint );
717 kdDebug() <<
" zoomed dPoint(doc, pixels)=" << debugPt.x() <<
"," << debugPt.y() << endl;
719 TQPoint vPoint = m_currentViewMode->
normalToView( m_doc->zoomPoint( dPoint ) );
721 kdDebug() <<
" vPoint(view, pixels)=" << vPoint.x() <<
"," << vPoint.y() << endl;
724 iPoint = m_doc->layoutUnitToPixel( iPoint );
732 TQRect clip( vPoint.x() - 5, vPoint.y(), 10, cursorHeight );
735 kdDebug() <<
" clip(view, before intersect)=" << clip << endl;
738 TQRect viewFrameRect = m_currentViewMode->
normalToView( normalFrameRect );
739 clip &= viewFrameRect;
741 kdDebug() <<
"KWTextFrameSet::drawCursor normalFrameRect=" << normalFrameRect
742 <<
" clip(view, after intersect)=" << clip << endl;
749 reg &= p->xForm( viewFrameRect );
752 if ( !hasFrames || !reg.isEmpty() )
760 TQColorGroup cg = TQApplication::palette().active();
764 p->setClipRegion( reg );
767 int translationX = viewFrameRect.left();
768 int translationY = viewFrameRect.top() - m_doc->zoomItY( theFrame->internalY() );
770 kdDebug() <<
" translating Y by viewFrameRect.top()-internalY in pixelY= " << viewFrameRect.top() <<
"-" << m_doc->zoomItY( theFrame->internalY() ) <<
"=" << viewFrameRect.top() - m_doc->zoomItY( theFrame->internalY() ) << endl;
772 p->translate( translationX, translationY );
773 p->setBrushOrigin( p->brushOrigin().x() + translationX, p->brushOrigin().y() + translationY );
778 TQBrush bgBrush( settings->backgroundColor() );
779 bgBrush.setColor( KWDocument::resolveBgColor( bgBrush.color(), p ) );
780 cg.setBrush( TQColorGroup::Base, bgBrush );
782 TQColor background = bgBrush.color();
783 cg.setColor(TQColorGroup::Text, TQColor( 255 - background.red(),
784 255 - background.green(), 255 - background.blue()) );
790 uint drawingFlags = KoTextDocument::DrawSelections;
791 if ( m_doc->backgroundSpellCheckEnabled() )
792 drawingFlags |= KoTextDocument::DrawMisspelledLine;
793 if ( m_doc->viewFormattingChars() )
794 drawingFlags |= KoTextDocument::DrawFormattingChars;
797 bool wasChanged = parag->hasChanged();
798 int oldLineChanged = parag->lineChanged();
800 parag->lineStartOfChar( cursor->index(), 0, &line );
801 parag->setChanged(
false );
802 parag->setLineChanged( line );
804 textDocument()->drawParagWYSIWYG(
806 TQMAX(0, iPoint.x() - 5),
807 iPoint.y(), clip.width(), clip.height(),
809 cursorVisible, cursor,
false , drawingFlags );
812 parag->setLineChanged( oldLineChanged );
814 parag->setChanged(
false );
819 TQPoint ximPoint = vPoint;
820 canvas->setXimPosition( ximPoint.x(), ximPoint.y(),
821 0, cursorHeight - parag->lineSpacing( line ) );
824 m_currentDrawnFrame = 0L;
831 m_textobj->formatMore( 2 );
837 m_textobj->setLastFormattedParag( textDocument()->firstParag() );
838 textDocument()->invalidate();
841void KWTextFrameSet::slotRepaintChanged()
846int KWTextFrameSet::paragraphs()
849 KoTextParag * parag = textDocument()->firstParag();
850 for ( ; parag ; parag = parag->next() )
855int KWTextFrameSet::paragraphsSelected()
858 KoTextParag *parag = textDocument()->firstParag();
859 for ( ; parag ; parag = parag->next() ) {
860 if ( parag->hasSelection( KoTextDocument::Standard ) )
868 ulong & sentences, ulong & syllables, ulong & lines,
bool selected )
870 return m_textobj->statistics( progress, charsWithSpace, charsWithoutSpace, words, sentences, syllables, lines, selected );
874#define kdDebugBody(area) if ( frameSetInfo() == FI_BODY ) kdDebug(area)
876TQValueList<KWFrame*> KWTextFrameSet::framesFromTo(
int y1,
int y2 )
const
878 TQValueList<KWFrame*> framesList;
883 framesList.append( firstFrame );
884 uint frameIndex =
const_cast<KWTextFrameSet *
>(
this)->m_frames.findRef( firstFrame );
885 while ( ++frameIndex < m_frames.count() ) {
887 if ( f->internalY() > y2 )
889 framesList.append( f );
901void KWTextFrameSet::getMargins(
int yp,
int h,
int reqMinWidth,
902 int* marginLeft,
int* marginRight,
int* pageWidth,
904 int* breakBegin,
int* breakEnd, KoTextParag* parag )
910 int paragLeftMargin = parag ? parag->leftMargin() : 0;
911 if ( parag && !parag->string()->isRightToLeft() && parag->firstLineMargin() > 0 )
912 paragLeftMargin += parag->firstLineMargin();
914 kdDebugBody(32002) <<
" KWTextFrameSet " <<
this <<
"(" <<
name() <<
") getMargins yp=" << yp
915 <<
" h=" << h <<
" called by "
916 << (marginLeft && marginRight ?
"adjustMargins" :
"formatVertically")
917 <<
" paragLeftMargin=" << paragLeftMargin
920 if (breakBegin) assert(breakEnd);
921 if (breakEnd) assert(breakBegin);
923 if ( marginLeft ) { assert( marginRight ); assert( pageWidth ); }
929 TQValueList<KWFrame*> textFrames = framesFromTo( yp, yp + h );
930 if (textFrames.isEmpty())
933 kdDebug(32002) <<
" getMargins: internalToDocument returned no text frames for y1=" << yp <<
" y2=" << yp + h <<
" ->aborting with 0 margins" << endl;
938 if ( !m_frames.isEmpty() && m_frames.last()->frameBehavior() == KWFrame::AutoExtendFrame )
940 textFrames.append( m_frames.last() );
957 kdDebugBody(32002) <<
" getMargins: internalToDocument returned " << textFrames.count() <<
" frames holding this paragraph" << endl;
969 int to = m_doc->ptToLayoutUnitPixX( textFrames.first()->innerWidth() );
975 kdDebugBody(32002) <<
" getMargins: looking for frames between " << yp <<
" and " << yp+h <<
" (internal coords)" << endl;
977 if ( m_doc->layoutViewMode()->shouldAdjustMargins() )
981 for ( TQValueList<KWFrame*>::const_iterator txtit = textFrames.begin(), txtend = textFrames.end() ; txtit != txtend ; ++txtit ) {
983 Q_ASSERT( theFrame->frameStack() );
984 TQValueList<KWFrame*> onTop = theFrame->frameStack()->
framesOnTop();
985 for (TQValueListIterator<KWFrame*> fIt = onTop.begin(); from < to && fIt != onTop.end(); ++fIt )
987 if ( (*fIt)->runAround() == KWFrame::RA_BOUNDINGRECT )
989 KoRect rectOnTop = theFrame->intersect( (*fIt)->runAroundRect() );
991 kdDebugBody(32002) <<
" getMargins found frame on top " << (*fIt)->frameSet()->name() <<
" with rect-on-top at (normal coords) " << rectOnTop << endl;
993 TQPoint iTop, iBottom;
996 iTop.y() <= yp + h &&
1000 kdDebugBody(32002) <<
" in internal coords: " << TQRect(iTop,iBottom) << endl;
1003 if ( TQMAX( yp, iTop.y() ) <= TQMIN( yp+h, iBottom.y() ) )
1006 kdDebugBody(32002) <<
" getMargins iTop=" << iTop.x() <<
"," << iTop.y()
1007 <<
" iBottom=" << iBottom.x() <<
"," << iBottom.y() << endl;
1009 int availLeft = TQMAX( 0, iTop.x() - from );
1010 int availRight = TQMAX( 0, to - iBottom.x() );
1012 kdDebugBody(32002) <<
" getMargins availLeft=" << availLeft
1013 <<
" availRight=" << availRight << endl;
1015 bool chooseLeft =
false;
1016 switch ( (*fIt)->runAroundSide() ) {
1017 case KWFrame::RA_LEFT:
1020 case KWFrame::RA_RIGHT:
1022 case KWFrame::RA_BIGGEST:
1023 chooseLeft = ( availLeft > availRight );
1028 to = TQMIN( to, from + availLeft - 1 );
1031 from = TQMAX( from, to - availRight + 1 );
1034 kdDebugBody(32002) <<
" getMargins from=" << from <<
" to=" << to << endl;
1037 if ( to - from < reqMinWidth + paragLeftMargin )
1040 kdDebugBody(32002) <<
" smaller than minimum=" << m_doc->ptToLayoutUnitPixX( 15 ) + paragLeftMargin << endl;
1045 if ( breakEnd && from == to )
1050 *breakBegin = iTop.y();
1051 *breakEnd = iBottom.y();
1055 *breakBegin = TQMIN( *breakBegin, iTop.y() );
1056 *breakEnd = TQMAX( *breakEnd, iBottom.y() );
1059 kdDebugBody(32002) <<
" getMargins iBottom.y=" << iBottom.y()
1060 <<
" breakBegin=" << *breakBegin
1061 <<
" breakEnd=" << *breakEnd << endl;
1074 kdDebugBody(32002) <<
" getMargins done. from=" << from <<
" to=" << to << endl;
1082 *marginLeft += from;
1086 kdDebug(32002) <<
" getMargins " <<
name()
1087 <<
" page width=" << *pageWidth
1088 <<
" to=" << to << endl;
1090 *marginRight += *pageWidth - to;
1098 kdDebugBody(32002) <<
"KWTextFrameSet::adjustMargins called for paragraph " << (parag?parag->paragId():-1) << endl;
1101 getMargins( yp, h, reqMinWidth, &leftMargin, &rightMargin, &pageWidth, &validHeight, 0L, 0L, parag );
1103 kdDebugBody(32002) <<
"KWTextFrameSet::adjustMargins(yp=" << yp <<
" h=" << h <<
" reqMinWidth=" << reqMinWidth <<
" returning"
1104 <<
" leftMargin=" << leftMargin <<
" rightMargin=" << rightMargin
1105 <<
" valid from " << yp <<
" to " << yp+validHeight << endl;
1110bool KWTextFrameSet::checkVerticalBreak(
int & yp,
int & hp, KoTextParag * parag,
bool linesTogether,
int breakBegin,
int breakEnd )
1116 if ( TQMAX( yp, breakBegin ) <= TQMIN( yp+hp, breakEnd ) )
1118 if ( !parag || linesTogether )
1120#ifdef DEBUG_FORMATVERTICALLY
1121 kdDebug(32002) <<
"checkVerticalBreak ADJUSTING yp=" << yp <<
" hp=" << hp
1122 <<
" breakEnd+2 [new value for yp]=" << breakEnd+2 << endl;
1129 TQMap<int, KoTextParagLineStart*>& lineStarts = parag->lineStartList();
1130#ifdef DEBUG_FORMATVERTICALLY
1131 kdDebug(32002) <<
"checkVerticalBreak parag " << parag->paragId()
1132 <<
". lineStarts has " << lineStarts.count()
1133 <<
" items" << endl;
1137 TQMap<int, KoTextParagLineStart*>::Iterator it = lineStarts.begin();
1138 for ( ; it != lineStarts.end() ; ++it, ++line )
1140 KoTextParagLineStart * ls = it.data();
1142 int y = parag->rect().y() + ls->y;
1143#ifdef DEBUG_FORMATVERTICALLY
1144 kdDebug(32002) <<
"checkVerticalBreak parag " << parag->paragId()
1145 <<
" line " << line <<
" ls->y=" << ls->y
1146 <<
" ls->h=" << ls->h <<
" y=" << y
1147 <<
" breakBegin=" << breakBegin
1148 <<
" breakEnd=" << breakEnd << endl;
1152 if ( TQMAX( y, breakBegin ) <= TQMIN( y + ls->h, breakEnd ) )
1156#ifdef DEBUG_FORMATVERTICALLY
1157 kdDebug(32002) <<
"checkVerticalBreak parag " << parag->paragId()
1158 <<
" BREAKING first line -> parag break" << endl;
1163 dy = breakEnd + 1 - y;
1164 ls->y = breakEnd + 1 - parag->rect().y();
1165#ifdef DEBUG_FORMATVERTICALLY
1166 kdDebug(32002) <<
"checkVerticalBreak parag " << parag->paragId()
1167 <<
" BREAKING at line " << line <<
" dy=" << dy <<
" Setting ls->y to " << ls->y <<
", y=" << breakEnd << endl;
1174#ifdef DEBUG_FORMATVERTICALLY
1176 kdDebug(32002) <<
" moving down to position ls->y=" << ls->y << endl;
1180 parag->setMovedDown(
true );
1181 parag->setHeight( hp + dy );
1182#ifdef DEBUG_FORMATVERTICALLY
1183 kdDebug(32002) <<
"Paragraph height set to " << hp+dy << endl;
1196 if ( !m_doc->layoutViewMode()->shouldFormatVertically() )
1201#ifdef DEBUG_FORMATVERTICALLY
1202 kdDebugBody(32002) <<
"KWTextFrameSet::formatVertically called for paragraph " << (parag?parag->paragId():-1) << endl;
1205 int yp = paragRect.y();
1206 int hp = paragRect.height();
1219 bool linesTogether = parag ? parag->linesTogether() :
true;
1220 bool hardFrameBreak = parag ? parag->hardFrameBreakBefore() :
false;
1221 if ( !hardFrameBreak && parag && parag->prev() )
1222 hardFrameBreak =
static_cast<KWTextParag *
>(parag->prev())->hardFrameBreakAfter();
1224#ifdef DEBUG_FORMATVERTICALLY
1225 kdDebugBody(32002) <<
"KWTextFrameSet::formatVertically parag=" << parag
1226 <<
" linesTogether=" << linesTogether <<
" hardFrameBreak=" << hardFrameBreak
1228 <<
" hp=" << hp << endl;
1231 int totalHeight = 0;
1233 for ( ; frameIt.current(); ++frameIt )
1235 int frameHeight = kWordDocument()->ptToLayoutUnitPixY( frameIt.current()->innerHeight() );
1236 int bottom = totalHeight + frameHeight;
1239 bool check = frameIt.atLast() && frameIt.current()->frameBehavior() == KWFrame::AutoCreateNewFrame;
1244 TQPtrListIterator<KWFrame> nextFrame( frameIt );
1245 while ( !check && !nextFrame.atLast() )
1248 if ( !nextFrame.current()->isCopy() )
1255 if ( hardFrameBreak && yp > totalHeight && yp < bottom && !parag->wasMovedDown() )
1261#ifdef DEBUG_FORMATVERTICALLY
1262 kdDebug(32002) <<
"KWTextFrameSet::formatVertically -> HARD FRAME BREAK" << endl;
1263 kdDebug(32002) <<
"KWTextFrameSet::formatVertically yp now " << yp << endl;
1268#ifdef DEBUG_FORMATVERTICALLY
1269 kdDebug(32002) <<
" formatVertically: frameHeight=" << frameHeight <<
" bottom=" << bottom << endl;
1272 if ( hp < frameHeight || ( parag && parag->lineStartList().count() > 1 ) )
1275 (void) checkVerticalBreak( yp, hp, parag, linesTogether, bottom, bottom );
1280 if ( yp+hp < bottom )
1282 totalHeight = bottom;
1285#ifdef DEBUG_FORMATVERTICALLY
1286 kdDebug(32002) <<
" formatVertically: now looking at RA_SKIP" << endl;
1293 for ( ; frameIt.current(); ++frameIt )
1295 Q_ASSERT( frameIt.current()->frameStack() );
1296 TQValueList<KWFrame*> onTop = frameIt.current()->frameStack()->framesOnTop();
1297 for (TQValueListIterator<KWFrame*> fIt = onTop.begin(); fIt != onTop.end(); ++fIt )
1299 if ( (*fIt)->runAround() == KWFrame::RA_SKIP )
1301 KoRect rectOnTop = frameIt.current()->intersect( (*fIt)->runAroundRect() );
1302 TQPoint iTop, iBottom;
1304 iTop.y() <= yp + hp &&
1306 checkVerticalBreak( yp, hp, parag, linesTogether,
1307 iTop.y(), iBottom.y() ) )
1309 kdDebug(32002) <<
"KWTextFrameSet::formatVertically breaking around RA_SKIP frame yp="<<yp<<
" hp=" << hp << endl;
1322 int reqMinWidth = parag ? parag->string()->at( 0 ).width : 0;
1323 getMargins( yp, hp, reqMinWidth, 0L, 0L, 0L, 0L, &breakBegin, &breakEnd, parag );
1326 kdDebug(32002) <<
"KWTextFrameSet("<<
name()<<
")::formatVertically no-space case. breakBegin=" << breakBegin
1327 <<
" breakEnd=" << breakEnd <<
" hp=" << hp << endl;
1328 Q_ASSERT( breakBegin <= breakEnd );
1329 if ( checkVerticalBreak( yp, hp, parag, linesTogether, breakBegin, breakEnd ) )
1332 kdWarning(32002) <<
"checkVerticalBreak didn't find it" << endl;
1339 if ( hp != oldHeight )
1340 parag->setHeight( hp );
1342 TQRect r = parag->rect();
1343 r.moveBy( 0, yp - oldY );
1344 parag->setRect( r );
1345 parag->setMovedDown(
true );
1348#ifdef DEBUG_FORMATVERTICALLY
1349 kdDebug() <<
"KWTextFrameSet::formatVertically returning " << ( yp + hp ) - ( oldY + oldHeight ) << endl;
1351 return ( yp + hp ) - ( oldY + oldHeight );
1358 TQRect r( 0, y, w, h );
1365 if ( parag && m_doc->viewFormattingChars() && parag->rect().width() < textDocument()->width() )
1367 if ( parag->hardFrameBreakAfter() )
1369 KoTextFormat * lastFormat = parag->at( parag->length() - 1 )->format();
1370 const TQFontMetrics& refFontMetrics = lastFormat->refFontMetrics();
1372 TQString str = i18n(
"--- Frame Break ---" );
1373 int width = refFontMetrics.width( str );
1374 parag->setWidth( TQMIN( parag->rect().width() + width, textDocument()->width() ) );
1377 parag->fixParagWidth(
true );
1383 textDocument()->takeFlow();
1394 bool operator < (
const FrameStruct & t )
const {
1395 return compare(frame, t.frame) < 0;
1397 bool operator <= (
const FrameStruct & t )
const {
1398 return compare(frame, t.frame) <= 0;
1400 bool operator > (
const FrameStruct & t )
const {
1401 return compare(frame, t.frame) > 0;
1409 int compare (
const KWFrame *frameOne,
const KWFrame *frameTwo)
const {
1413 if( (pageOne == -1) ^ (pageTwo == -1)) {
1418 if ( pageOne > pageTwo )
return 4;
1419 if ( pageOne < pageTwo )
return -4;
1421 double centerX = frameOne->left() + (frameOne->width() /2);
1423 if ( centerX > frameTwo->right())
return 3;
1424 if ( centerX < frameTwo->left())
return -3;
1427 double centerY = frameOne->top() + (frameOne->height() /2);
1428 if ( centerY > frameTwo->bottom() )
return 2;
1429 if ( centerY < frameTwo->top() )
return -2;
1432 if (frameOne->top() > frameTwo->top())
return 1;
1442 m_textobj->setVisible(
false);
1445 m_textobj->setVisible(
true);
1453 TQValueList<FrameStruct> sortedFrames;
1457 for ( ; frameIter.current(); ++frameIter )
1461 width = TQMAX( width, m_doc->ptToLayoutUnitPixX( frameIter.current()->innerWidth()));
1465 str.frame = frameIter.current();
1466 sortedFrames.append( str );
1469 if ( width != textDocument()->width() )
1473 textDocument()->setWidth( width + 1 );
1478 qHeapSort( sortedFrames );
1481 m_frames.setAutoDelete(
false );
1484 TQValueList<FrameStruct>::Iterator it = sortedFrames.begin();
1485 for ( ; it != sortedFrames.end() ; ++it )
1486 m_frames.append( (*it).frame );
1489 double availHeight = 0;
1490 double internalYpt = 0;
1491 double lastRealFrameHeight = 0;
1492 bool firstFrame =
true;
1494 TQPtrListIterator<KWFrame> frameIt( m_frames );
1495 for ( ; frameIt.current(); ++frameIt )
1497 KWFrame* theFrame = frameIt.current();
1499 if ( !theFrame->
isCopy() )
1500 internalYpt += lastRealFrameHeight;
1505 if ( !theFrame->
isCopy() || firstFrame )
1507 lastRealFrameHeight = theFrame->innerHeight();
1508 availHeight += lastRealFrameHeight;
1513 m_textobj->setAvailableHeight( m_doc->ptToLayoutUnitPixY( availHeight ) );
1516 m_frames.setAutoDelete(
true );
1523 return m_textobj->availableHeight();
1529 kdDebug() <<
name() <<
" ITD called for relPoint=" << relPoint.x() <<
"," << relPoint.y() << endl;
1531 if ( !m_doc->layoutViewMode()->hasFrames() ) {
1533 return m_frames.getFirst();
1541 double internalY = 0.0;
1544 while ( n1 <= n2 ) {
1548 kdDebug() <<
"ITD: begin. mid=" << mid << endl;
1556 internalY = theFrame->internalY();
1558 kdDebug() <<
"ITD: relPoint.y=" << relPoint.y() <<
" internalY=" << internalY << endl;
1560 res = relPoint.y() - internalY;
1562 kdDebug() <<
"ITD: res=" << res << endl;
1568 double height = theFrame->innerHeight();
1570 kdDebug() <<
"ITD: height=" << height <<
" -> the bottom is at " << internalY+height << endl;
1572 if ( relPoint.y() < internalY + height )
1575 kdDebug() <<
"ITD: found a match " << mid << endl;
1589 kdDebug() <<
"ITD: End of loop. n1=" << n1 <<
" n2=" << n2 << endl;
1599 kdDebug() <<
"ITD: Setting mid to n2=" << mid << endl;
1604 kdDebug(32002) <<
"KWTextFrameSet::internalToDocument " << relPoint.x() <<
"," << relPoint.y()
1605 <<
" before any frame of " << (
void*)
this << endl;
1614 while ( mid - 1 >= 0 )
1621 kdDebug() <<
"KWTextFrameSet::internalToDocument going back to page " << mid <<
" - frame: " << theFrame->internalY() << endl;
1623 if ( theFrame->internalY() == internalY )
1632 for ( ; frameIt.current(); ++frameIt )
1634 KWFrame *theFrame = frameIt.current();
1635 KoRect relRect( 0, theFrame->internalY(), theFrame->innerWidth(), theFrame->innerHeight() );
1637 kdDebug() <<
"KWTextFrameSet::internalToDocument frame's relative rect:" << relRect << endl;
1639 if ( relRect.contains( relPoint ) )
1646 kdDebug(32002) <<
"KWTextFrameSet::internalToDocument " << relPoint.x() <<
"," << relPoint.y()
1647 <<
" not in any frame of " << (
void*)
this <<
" (looked on page " << result <<
")" << endl;
1656 KoPoint relPoint = m_doc->layoutUnitPtToPt( m_doc->pixelToPt( iPoint ) );
1661void KWTextFrameSet::printDebug()
1663 KWFrameSet::printDebug();
1666 kdDebug() <<
"KoTextDocument width = " << textDocument()->width() <<
" height = " << textDocument()->height() << endl;
1669 TQPtrListIterator<KoTextCustomItem> cit( textDocument()->allCustomItems() );
1670 for ( ; cit.current() ; ++cit )
1674 kdDebug() <<
"Inline framesets: " << anc->
frameSet()->
name() << endl;
1679TQDomElement KWTextFrameSet::saveInternal( TQDomElement &parentElem,
bool saveFrames,
bool saveAnchorsFramesets )
1681 if ( m_frames.isEmpty() )
1682 return TQDomElement();
1684 TQDomElement framesetElem = parentElem.ownerDocument().createElement(
"FRAMESET" );
1685 parentElem.appendChild( framesetElem );
1687 if ( m_groupmanager ) {
1688 framesetElem.setAttribute(
"grpMgr", m_groupmanager->
name() );
1691 framesetElem.setAttribute(
"row", cell->firstRow() );
1692 framesetElem.setAttribute(
"col", cell->firstColumn() );
1693 framesetElem.setAttribute(
"rows", cell->rowSpan() );
1694 framesetElem.setAttribute(
"cols", cell->columnSpan() );
1696 if ( protectContent() )
1697 framesetElem.setAttribute(
"protectContent",
static_cast<int>(protectContent()));
1704 start->
save( framesetElem, saveAnchorsFramesets );
1705 start =
static_cast<KWTextParag *
>( start->next() );
1708 return framesetElem;
1713 context.styleStack().
save();
1714 context.fillStyleStack( frameTag, KoXmlNS::draw,
"style-name",
"graphic" );
1719 bool hasMinHeight = tag.hasAttributeNS( KoXmlNS::fo,
"min-height" );
1720 if ( hasMinHeight ) {
1721 double height = KoUnit::parseValue( tag.attributeNS( KoXmlNS::fo,
"min-height", TQString() ) );
1723 if ( height >
frame->height() || !tag.hasAttributeNS( KoXmlNS::fo,
"height" ) )
1724 frame->setHeight( height );
1728 const TQString overflowBehavior = context.styleStack().attributeNS( KoXmlNS::style,
"overflow-behavior" );
1730 frame->setFrameBehavior( KWFrame::AutoExtendFrame );
1731 else if ( overflowBehavior ==
"auto-create-new-frame" )
1733 frame->setFrameBehavior( KWFrame::AutoCreateNewFrame );
1734 frame->setNewFrameBehavior( KWFrame::Reconnect );
1736 else if ( overflowBehavior.isEmpty() || overflowBehavior ==
"clip" )
1737 frame->setFrameBehavior( KWFrame::Ignore );
1739 kdWarning(32001) <<
"Unknown value for style:overflow-behavior: " << overflowBehavior << endl;
1741 context.styleStack().restore();
1748 return m_textobj->loadOasisContent( bodyElem, context, m_doc->styleCollection() );
1758static void finishTOC( KoXmlWriter& writer )
1760 writer.endElement();
1761 writer.endElement();
1768 TQMap<const KoTextParag*, KoTextBookmarkList> bookmarksPerParagraph;
1769 if ( m_doc->bookmarkList() )
1770 bookmarksPerParagraph = m_doc->bookmarkList()->bookmarksPerParagraph();
1775 KoTextParag* parag = textDocument()->firstParag();
1778 bool tocParag = parag->partOfTableOfContents();
1779 if ( tocParag != inTOC ) {
1781 writer.startElement(
"text:table-of-content" );
1782 writer.addAttribute(
"text:name",
"Table Of Contents" );
1783 writer.addAttribute(
"text:protected",
"false" );
1784 writer.startElement(
"text:table-of-content-source" );
1788 writer.endElement();
1789 writer.startElement(
"text:index-body" );
1790 writer.startElement(
"text:index-title" );
1791 writer.addAttribute(
"text:name",
"Table Of Contents Heading" );
1793 finishTOC( writer );
1798 KoSavingContext::BookmarkPositions bookmarkStarts, bookmarkEnds;
1799 TQMap<const KoTextParag*, KoTextBookmarkList>::const_iterator bkit = bookmarksPerParagraph.find( parag );
1800 if ( bkit != bookmarksPerParagraph.end() ) {
1802 const KoTextBookmarkList& bookmarks = *bkit;
1803 for ( KoTextBookmarkList::const_iterator it = bookmarks.begin(); it != bookmarks.end(); ++it )
1805 const KoTextBookmark& bk = *it;
1806 if ( bk.startParag() == parag )
1807 bookmarkStarts.append( KoSavingContext::BookmarkPosition(
1808 bk.bookmarkName(), bk.bookmarkStartIndex(),
1810 if ( bk.endParag() == parag && !bk.isSimple() )
1811 bookmarkEnds.append( KoSavingContext::BookmarkPosition( bk.bookmarkName(),
1812 bk.bookmarkEndIndex(),
false ) );
1814 qHeapSort( bookmarkStarts );
1815 qHeapSort( bookmarkEnds );
1818 context.setBookmarkPositions( bookmarkStarts, bookmarkEnds );
1821 parag->saveOasis( writer, context, 0, parag->lastCharPos() );
1823 if ( tocParag && !inTOC )
1824 writer.endElement();
1827 parag = parag->next();
1830 finishTOC( writer );
1837 TQString lastFrameName =
name();
1840 TQString nextFrameName =
name() +
"-";
1842 writer.startElement(
"draw:text-box" );
1843 if (
frame->frameBehavior() == KWFrame::AutoExtendFrame )
1845 if ( m_frames.count() > 1 && saveFrames )
1846 writer.addAttribute(
"draw:chain-next-name", nextFrameName +
"2" );
1848 writer.endElement();
1849 writer.endElement();
1854 int frameNumber = 2;
1857 for ( ; frameIter.current(); ++frameIter, ++frameNumber )
1859 const TQString frameName = nextFrameName + TQString::number( frameNumber );
1860 frameIter.current()->startOasisFrame( writer, context.mainStyles(), frameName, lastFrameName );
1861 lastFrameName = frameName;
1862 writer.startElement(
"draw:text-box" );
1863 if (
frame->frameBehavior() == KWFrame::AutoExtendFrame )
1865 if ( frameNumber < (
int)m_frames.count() )
1866 writer.addAttribute(
"draw:chain-next-name", nextFrameName + TQString::number( frameNumber+1 ) );
1868 writer.endElement();
1869 writer.endElement();
1877 if ( attributes.hasAttribute(
"protectContent"))
1878 setProtectContent((
bool)attributes.attribute(
"protectContent" ).toInt());
1880 textDocument()->clear(
false);
1881 m_textobj->setLastFormattedParag( 0L );
1885 TQDomElement paragraph = attributes.firstChild().toElement();
1886 for ( ; !paragraph.isNull() ; paragraph = paragraph.nextSibling().toElement() )
1888 if ( paragraph.tagName() ==
"PARAGRAPH" )
1891 parag->
load( paragraph );
1892 if ( !lastParagraph )
1893 textDocument()->setFirstParag( parag );
1894 lastParagraph = parag;
1895 m_doc->progressItemLoaded();
1899 if ( !lastParagraph )
1902 textDocument()->clear(
true );
1903 static_cast<KWTextParag *
>( textDocument()->firstParag() )->setStyle( m_doc->styleCollection()->findStyle(
"Standard" ) );
1906 textDocument()->setLastParag( lastParagraph );
1908 m_textobj->setLastFormattedParag( textDocument()->firstParag() );
1915 m_textobj->formatMore( 0 );
1930 TQPtrListIterator<KoTextCustomItem> cit( textDocument()->allCustomItems() );
1931 for ( ; cit.current() ; ++cit )
1939void KWTextFrameSet::addTextFrameSets( TQPtrList<KWTextFrameSet> & lst,
bool onlyReadWrite )
1941 if (!
textObject()->protectContent() || !onlyReadWrite)
1945void KWTextFrameSet::slotNewCommand( KCommand *cmd )
1947 m_doc->addCommand( cmd );
1954 m_textobj->ensureFormatted( parag, emitAfterFormatting );
1957bool KWTextFrameSet::slotAfterFormattingNeedMoreSpace(
int bottom, KoTextParag *lastFormatted )
1960#ifdef DEBUG_FORMAT_MORE
1962 kdDebug(32002) <<
"slotAfterFormatting We need more space in " <<
name()
1963 <<
" bottom=" << bottom + lastFormatted->rect().height()
1964 <<
" availHeight=" << availHeight << endl;
1966 kdDebug(32002) <<
"slotAfterFormatting We need more space in " <<
name()
1967 <<
" bottom2=" << bottom <<
" availHeight=" << availHeight << endl;
1969 if ( m_frames.isEmpty() )
1971 kdWarning(32002) <<
"slotAfterFormatting no more space, but no frame !" << endl;
1976 if ( frmBehavior == KWFrame::AutoExtendFrame && isProtectSize())
1977 frmBehavior = KWFrame::Ignore;
1978 if ( frmBehavior == KWFrame::AutoCreateNewFrame )
1982 if ( availHeight < minHeight )
1983 frmBehavior = KWFrame::Ignore;
1986 int difference = ( bottom + 2 ) - availHeight;
1987#ifdef DEBUG_FORMAT_MORE
1988 kdDebug(32002) <<
"AutoExtendFrame bottom=" << bottom <<
" availHeight=" << availHeight
1989 <<
" => difference = " << difference << endl;
1991 if( lastFormatted && bottom + lastFormatted->rect().height() > availHeight ) {
1992#ifdef DEBUG_FORMAT_MORE
1993 kdDebug(32002) <<
" next will be off -> adding " << lastFormatted->rect().height() << endl;
1995 difference += lastFormatted->rect().height();
1998 switch ( frmBehavior ) {
1999 case KWFrame::AutoExtendFrame:
2001 if(difference > 0) {
2004 double wantedPosition = 0;
2007 if ( theFrame->
frameSet()->isAFooter() || theFrame->
frameSet()->isFootNote() )
2011 double maxFooterSize = footerHeaderSizeMax( theFrame );
2012 double diffPt = m_doc->layoutUnitPtToPt( m_doc->pixelYToPt( difference ) );
2013 wantedPosition = theFrame->top() - diffPt;
2014#ifdef DEBUG_FORMAT_MORE
2015 kdDebug() <<
" diffPt=" << diffPt <<
" -> wantedPosition=" << wantedPosition << endl;
2017 if ( wantedPosition < 0 )
2019 m_textobj->setLastFormattedParag( 0 );
2023 if ( wantedPosition != theFrame->top() &&
2024 ( theFrame->
frameSet()->isFootEndNote() ||
2025 theFrame->bottom() - maxFooterSize <= wantedPosition ) )
2027 theFrame->setTop( wantedPosition );
2028#ifdef DEBUG_FORMAT_MORE
2029 kdDebug() <<
" ok: frame=" << *theFrame <<
" bottom=" << theFrame->bottom() <<
" height=" << theFrame->height() << endl;
2031 frameResized( theFrame,
true );
2035 kdDebug() <<
"slotAfterFormatting didn't manage to get more space for footer/footnote, aborting" << endl;
2040 wantedPosition = m_doc->layoutUnitPtToPt( m_doc->pixelYToPt( difference ) ) + theFrame->bottom();
2041 KWPage *page = m_doc->pageManager()->page( theFrame );
2046 pageBottom = theFrame->bottom();
2047 double newPosition = TQMIN( wantedPosition, pageBottom );
2048 kdDebug(32002) <<
"wantedPosition=" << wantedPosition <<
" pageBottom=" << pageBottom
2049 <<
" -> newPosition=" << newPosition << endl;
2051 if ( theFrame->
frameSet()->isAHeader() )
2053 double maxHeaderSize=footerHeaderSizeMax( theFrame );
2054 newPosition = TQMIN( newPosition, maxHeaderSize + theFrame->top() );
2057 newPosition = TQMAX( newPosition, theFrame->top() );
2058 kdDebug(32002) <<
"newPosition=" << newPosition << endl;
2060 bool resized =
false;
2063#ifdef DEBUG_FORMAT_MORE
2064 kdDebug(32002) <<
"is table cell; just setting new minFrameHeight, to " << newPosition - theFrame->top() << endl;
2066 double newMinFrameHeight = newPosition - theFrame->top();
2071 table->
recalcCols(cell->firstColumn(), cell->firstRow());
2072 table->recalcRows(cell->firstColumn(), cell->firstRow());
2079 theFrame->setBottom(newPosition);
2080 frameResized( theFrame,
false );
2087 double maxFooterSize = footerHeaderSizeMax( theFrame );
2088 double diffPt = m_doc->layoutUnitPtToPt( m_doc->pixelYToPt( difference ) );
2089 wantedPosition = theFrame->top() - diffPt;
2090 if ( wantedPosition < 0 )
2092 m_textobj->setLastFormattedParag( 0 );
2096 if ( wantedPosition != theFrame->top() &&
2097 ( theFrame->
frameSet()->isFootEndNote() ||
2098 theFrame->bottom() - maxFooterSize <= wantedPosition ) )
2100 theFrame->setTop( wantedPosition );
2101 frameResized( theFrame,
true );
2106 m_doc->delayedRepaintAllViews();
2110 resized = TQABS( theFrame->bottom() - newPosition ) > 1E-10;
2111#ifdef DEBUG_FORMAT_MORE
2112 kdDebug() <<
" bottom=" << theFrame->bottom() <<
" new position:" << newPosition <<
" wantedPosition=" << wantedPosition <<
" resized=" << resized << endl;
2117#ifdef DEBUG_FORMAT_MORE
2118 kdDebug(32002) <<
"slotAfterFormatting changing bottom from " << theFrame->bottom() <<
" to " << newPosition << endl;
2120 theFrame->setBottom(newPosition);
2121 frameResized( theFrame,
false );
2125 if(newPosition < wantedPosition &&
2126 (theFrame->newFrameBehavior() == KWFrame::Reconnect
2127 && !theFrame->
frameSet()->isEndNote()))
2129 wantedPosition = wantedPosition - newPosition + theFrame->top() + page->
height();
2130#ifdef DEBUG_FORMAT_MORE
2131 kdDebug(32002) <<
"Not enough room in this page -> creating new one, with a reconnect frame" << endl;
2132 kdDebug(32002) <<
"new wantedPosition=" << wantedPosition << endl;
2137 else if(newPosition < wantedPosition && (theFrame->newFrameBehavior() == KWFrame::NoFollowup)) {
2138 if ( theFrame->
frameSet()->isEndNote() )
2139 m_doc->delayedRecalcFrames( theFrame->
pageNumber() );
2141 m_textobj->setLastFormattedParag( 0 );
2151 case KWFrame::AutoCreateNewFrame:
2154 return createNewPageAndNewFrame( lastFormatted, difference );
2157 case KWFrame::Ignore:
2158#ifdef DEBUG_FORMAT_MORE
2159 kdDebug(32002) <<
"slotAfterFormatting frame behaviour is Ignore" << endl;
2161 m_textobj->setLastFormattedParag( 0 );
2164 kdWarning() <<
"NEVERREACHED" << endl;
2169void KWTextFrameSet::slotAfterFormattingTooMuchSpace(
int bottom )
2174 int difference = availHeight - ( bottom + 2 );
2175#ifdef DEBUG_FORMAT_MORE
2176 kdDebug(32002) <<
"slotAfterFormatting less text than space (AutoExtendFrame). Frameset " <<
name() <<
" availHeight=" << availHeight <<
" bottom=" << bottom <<
" ->difference=" << difference << endl;
2180#ifdef DEBUG_FORMAT_MORE
2181 kdDebug(32002) <<
" frame is " << *theFrame <<
" footer:" << ( theFrame->
frameSet()->isAFooter() || theFrame->
frameSet()->isFootEndNote() ) << endl;
2183 if ( theFrame->
frameSet()->isAFooter() || theFrame->
frameSet()->isFootEndNote() )
2185 double wantedPosition = theFrame->top() + m_doc->layoutUnitPtToPt( m_doc->pixelYToPt( difference ) );
2186 Q_ASSERT( wantedPosition < theFrame->bottom() );
2187 if ( wantedPosition != theFrame->top() )
2189#ifdef DEBUG_FORMAT_MORE
2190 kdDebug() <<
" top= " << theFrame->top() <<
" setTop " << wantedPosition << endl;
2192 theFrame->setTop( wantedPosition );
2193#ifdef DEBUG_FORMAT_MORE
2194 kdDebug() <<
" -> the frame is now " << *theFrame << endl;
2196 frameResized( theFrame,
true );
2201 double wantedPosition = theFrame->bottom() - m_doc->layoutUnitPtToPt( m_doc->pixelYToPt( difference ) );
2202#ifdef DEBUG_FORMAT_MORE
2203 kdDebug() <<
"slotAfterFormatting wantedPosition=" << wantedPosition <<
" top+minheight=" << theFrame->top() + s_minFrameHeight << endl;
2205 wantedPosition = TQMAX( wantedPosition, theFrame->top() + s_minFrameHeight );
2207 if ( wantedPosition != theFrame->bottom()) {
2215#ifdef DEBUG_FORMAT_MORE
2216 kdDebug(32002) <<
"is table cell; only setting new minFrameHeight to " << theFrame->
minimumFrameHeight() <<
", recalcrows will do the rest" << endl;
2219 table->
recalcCols(cell->firstColumn(), cell->firstRow());
2220 table->recalcRows(cell->firstColumn(), cell->firstRow());
2227 theFrame->setBottom(wantedPosition);
2228 frameResized( theFrame,
false );
2233 double wantedPosition = theFrame->top() + m_doc->layoutUnitPtToPt( m_doc->pixelYToPt( difference ) );
2234 Q_ASSERT( wantedPosition < theFrame->bottom() );
2235 if ( wantedPosition != theFrame->top() )
2237 theFrame->setTop( wantedPosition );
2238 frameResized( theFrame,
true );
2241 m_doc->delayedRepaintAllViews();
2246 wantedPosition = TQMAX( wantedPosition, theFrame->top() + theFrame->
minimumFrameHeight() );
2247 if ( wantedPosition != theFrame->bottom()) {
2248#ifdef DEBUG_FORMAT_MORE
2249 kdDebug() <<
" the frame was " << *theFrame << endl;
2250 kdDebug() <<
"setBottom " << wantedPosition << endl;
2252 theFrame->setBottom( wantedPosition );
2253#ifdef DEBUG_FORMAT_MORE
2254 kdDebug() <<
" -> the frame is now " << *theFrame << endl;
2256 frameResized( theFrame,
true );
2262void KWTextFrameSet::slotAfterFormatting(
int bottom, KoTextParag *lastFormatted,
bool* abort )
2265 if ( ( bottom > availHeight ) ||
2266 ( lastFormatted && bottom + lastFormatted->rect().height() > availHeight ) )
2268 *abort = slotAfterFormattingNeedMoreSpace( bottom, lastFormatted );
2272 else if ( m_frames.count() > 1 && !lastFormatted &&
frameSetInfo() == KWFrameSet::FI_BODY
2273 && bottom < availHeight - m_doc->ptToLayoutUnitPixY( m_frames.last()->innerHeight() ) )
2275#ifdef DEBUG_FORMAT_MORE
2276 kdDebug(32002) <<
"slotAfterFormatting too much space (bottom=" << bottom <<
", availHeight=" << availHeight <<
") , trying to remove last frame" << endl;
2280 if(m_frames.last()->frameBehavior() == KWFrame::AutoExtendFrame
2281 && m_frames.last()->minimumFrameHeight() < 1E-10 ) {
2283 m_doc->frameChanged( 0L );
2285 if ( m_doc->processingType() == KWDocument::WP ) {
2286 bool removed = m_doc->tryRemovingPages();
2289 m_doc->afterRemovePages();
2294 else if ( !lastFormatted && bottom + 2 < availHeight &&
2295 (m_frames.last()->frameBehavior() == KWFrame::AutoExtendFrame&& !isProtectSize()) )
2297 slotAfterFormattingTooMuchSpace( bottom );
2301 if ( m_doc->processingType() == KWDocument::WP
2302 &&
this == m_doc->frameSet( 0 ) )
2304 if ( m_lastTextDocHeight != textDocument()->height() )
2306 m_lastTextDocHeight = textDocument()->height();
2315bool KWTextFrameSet::createNewPageAndNewFrame( KoTextParag* lastFormatted,
int )
2317 KWFrame* lastFrame = m_frames.last();
2319 if ( !lastFrame || lastFrame->newFrameBehavior() != KWFrame::Reconnect ) {
2320 kdDebug(32002) <<
name() <<
" : frame is AutoCreateNewFrame but not Reconnect !?!? Aborting." << endl;
2321 m_textobj->setLastFormattedParag( 0 );
2326 kdDebug(32002) <<
"createNewPageAndNewFrame creating new frame in frameset " <<
name() << endl;
2328 uint oldCount = m_frames.count();
2329 int lastPageNumber = m_doc->pageManager()->lastPageNumber();
2330 kdDebug(32002) <<
" last frame=" << lastFrame <<
" pagenum=" << lastFrame->
pageNumber() <<
" lastPageNumber=" << lastPageNumber <<
" m_frames count=" << oldCount << endl;
2333 if ( lastFrame->
pageNumber() == lastPageNumber )
2338 int heightWeWillGet = 0;
2339 if(isMainFrameset())
2340 heightWeWillGet += m_doc->ptToLayoutUnitPixY( m_frames.last()->height() );
2342 TQPtrList<KWFrame> framesToCopy = m_doc->framesToCopyOnNewPage( lastPageNumber );
2343 TQPtrListIterator<KWFrame> frameIt( framesToCopy );
2344 for ( ; frameIt.current(); ++frameIt )
2345 if (frameIt.current()->frameSet() ==
this &&
2346 frameIt.current()->newFrameBehavior()==KWFrame::Reconnect)
2347 heightWeWillGet += m_doc->ptToLayoutUnitPixY( frameIt.current()->height() );
2355 KoTextParag* parag = lastFormatted ? lastFormatted : textDocument()->lastParag();
2359 int paragHeight = parag->rect().height();
2360 kdDebug(32002) <<
"height we will get in the new page:" << heightWeWillGet <<
" parag " << parag <<
" height:" << paragHeight << endl;
2361 if ( heightWeWillGet < paragHeight && !m_groupmanager )
2363 kdDebug(32002) <<
"not enough height on the new page, not worth it" << endl;
2364 m_textobj->setLastFormattedParag( 0 );
2368 KWPage *page = m_doc->appendPage();
2369 if ( !m_doc->isLoading() )
2370 m_doc->afterInsertPage( page->
pageNumber() );
2371 kdDebug(32002) <<
"now frames count=" << m_frames.count() << endl;
2376 if ( m_frames.count() == oldCount )
2378 Q_ASSERT( !isMainFrameset() );
2380 kdDebug(32002) <<
"createNewPageAndNewFrame creating frame on page " << lastFrame->
pageNumber()+1 << endl;
2382 frm->moveBy( 0, m_doc->pageManager()->page(frm)->height() );
2387 Q_ASSERT(
frame(0) &&
frame(0)->frameStack());
2394 if ( lastFormatted )
2395 lastFormatted = lastFormatted->prev();
2397 lastFormatted = textDocument()->lastParag();
2399 if ( lastFormatted )
2401 m_textobj->setLastFormattedParag( lastFormatted );
2402 lastFormatted->invalidate( 0 );
2408 m_doc->delayedRepaintAllViews();
2412double KWTextFrameSet::footNoteSize(
KWFrame *theFrame )
2416 TQPtrListIterator<KWFrameSet> fit = m_doc->framesetsIterator();
2417 for ( ; fit.current() ; ++fit )
2419 if((fit.current()->isFootNote() || fit.current()->isEndNote()) &&
2420 fit.current()->isVisible())
2422 KWFrame * frm=fit.current()->frame( 0 );
2424 tmp += frm->innerHeight()+m_doc->ptFootnoteBodySpacing();
2431double KWTextFrameSet::footerHeaderSizeMax(
KWFrame *theFrame )
2433 KWPage *page = m_doc->pageManager()->page(theFrame);
2438 bool header=theFrame->
frameSet()->isAHeader();
2439 if( header ? m_doc->isHeaderVisible():m_doc->isFooterVisible() )
2441 TQPtrListIterator<KWFrameSet> fit = m_doc->framesetsIterator();
2442 for ( ; fit.current() ; ++fit )
2444 bool state = header ? fit.current()->isAFooter():fit.current()->isAHeader();
2445 if(fit.current()->isVisible() && state)
2447 KWFrame * frm=fit.current()->frame( 0 );
2450 return (tmp-frm->innerHeight()-footNoteSize( theFrame ));
2455 if (theFrame->
frameSet()->isHeaderOrFooter())
2456 return (tmp-footNoteSize( theFrame ));
2461void KWTextFrameSet::frameResized(
KWFrame *theFrame,
bool invalidateLayout )
2463 kdDebug(32002) <<
"KWTextFrameSet::frameResized " << theFrame <<
" " << *theFrame <<
" invalidateLayout=" << invalidateLayout << endl;
2464 if ( theFrame->height() < 0 )
2468 Q_ASSERT( fs ==
this );
2470 Q_ASSERT(
frame(0) &&
frame(0)->frameStack());
2473 theFrame->updateRulerHandles();
2479 if ( fs->isMainFrameset() || fs->isEndNote() )
2480 m_doc->delayedRecalcFrames( theFrame->
pageNumber() );
2483 m_doc->recalcFrames( theFrame->
pageNumber(), -1 );
2488 if ( invalidateLayout )
2489 m_doc->invalidate(
this);
2492 m_doc->delayedRepaintAllViews();
2497 KoTextParag * lastParag = textDocument()->lastParag();
2502 if ( !lastParag->isValid() )
2504 int bottom = lastParag->rect().top() + lastParag->rect().height();
2506 if ( theFrame->
frameSet() ==
this )
2508 kdDebug() <<
"KWTextFrameSet::isFrameEmpty text bottom=(LU) " << bottom <<
" theFrame=" << theFrame <<
" " << *theFrame <<
" its internalY(LU)=" << m_doc->ptToLayoutUnitPixY( theFrame->internalY() ) << endl;
2509 return bottom < m_doc->ptToLayoutUnitPixY( theFrame->internalY() );
2512 kdWarning() <<
"KWTextFrameSet::isFrameEmpty called for frame " << theFrame <<
" which isn't a child of ours!" << endl;
2514 kdDebug() <<
"(this is " <<
name() <<
" and the frame belongs to " << theFrame->
frameSet()->
name() <<
")" << endl;
2520 kdDebug() <<
"KWTextFrameSet(" <<
name() <<
")::canRemovePage " << num << endl;
2524 kdDebug() <<
"No frame on that page. Number of frames: " <<
frameCount() << endl;
2528 TQPtrListIterator<KWFrame> frameIt(
framesInPage( num ) );
2529 for ( ; frameIt.current(); ++frameIt )
2531 KWFrame * theFrame = frameIt.current();
2532 kdDebug() <<
"canRemovePage: looking at " << theFrame <<
" pageNum=" << theFrame->
pageNumber() << endl;
2534 Q_ASSERT( theFrame->
frameSet() ==
this );
2536 kdDebug() <<
"KWTextFrameSet(" <<
name() <<
")::canRemovePage"
2537 <<
" found a frame on page " << num <<
" empty:" << isEmpty << endl;
2539 bool isCopy = theFrame->
isCopy() && frameIt.current() != m_frames.first();
2540 if ( !isCopy && !isEmpty )
2548 KWFrame *frm = m_frames.at( num );
2549 kdDebug() <<
"KWTextFrameSet(" <<
name() <<
")::deleteFrame " << frm <<
" (" << num <<
")" << endl;
2560#ifdef DEBUG_VIEWAREA
2561 kdDebug(32002) <<
"KWTextFrameSet::updateViewArea " << (
void*)w <<
" " << w->name()
2562 <<
" nPointBottom=" << nPointBottom.x() <<
"," << nPointBottom.y()
2563 <<
" availHeight=" << ah <<
" textDocument()->height()=" << textDocument()->height() << endl;
2567 int maxPage = m_doc->pageManager()->pageNumber(m_doc->unzoomItY( nPointBottom.y() ));
2574 TQPtrListIterator<KWFrame> frameIt(
framesInPage( maxPage ) );
2575 for ( ; frameIt.current(); ++frameIt )
2577 maxY = TQMAX( maxY, m_doc->ptToLayoutUnitPixY( frameIt.current()->internalY() + frameIt.current()->innerHeight() ) );
2580#ifdef DEBUG_VIEWAREA
2581 kdDebug(32002) <<
"KWTextFrameSet (" <<
name() <<
")::updateViewArea maxY now " << maxY << endl;
2583 m_textobj->setViewArea( w, maxY );
2584 m_textobj->formatMore( 2 );
2587KCommand * KWTextFrameSet::setPageBreakingCommand( KoTextCursor * cursor,
int pageBreaking )
2589 if ( !textDocument()->
hasSelection( KoTextDocument::Standard ) &&
2590 static_cast<KWTextParag *
>(cursor->parag())->pageBreaking() == pageBreaking )
2593 m_textobj->emitHideCursor();
2595 m_textobj->storeParagUndoRedoInfo( cursor );
2597 if ( !textDocument()->
hasSelection( KoTextDocument::Standard ) ) {
2600 m_textobj->setLastFormattedParag( cursor->parag() );
2604 KoTextParag *start = textDocument()->selectionStart( KoTextDocument::Standard );
2605 KoTextParag *end = textDocument()->selectionEnd( KoTextDocument::Standard );
2606 m_textobj->setLastFormattedParag( start );
2607 for ( ; start && start != end->next() ; start = start->next() )
2608 static_cast<KWTextParag *
>(start)->setPageBreaking( pageBreaking );
2611 m_textobj->formatMore( 2 );
2613 KoTextObject::UndoRedoInfo & undoRedoInfo = m_textobj->undoRedoInfoStruct();
2614 undoRedoInfo.newParagLayout.pageBreaking = pageBreaking;
2615 KoTextParagCommand *cmd =
new KoTextParagCommand(
2616 textDocument(), undoRedoInfo.id, undoRedoInfo.eid,
2617 undoRedoInfo.oldParagLayouts, undoRedoInfo.newParagLayout,
2618 KoParagLayout::PageBreaking );
2619 textDocument()->addCommand( cmd );
2620 undoRedoInfo.clear();
2621 m_textobj->emitShowCursor();
2622 m_textobj->emitUpdateUI(
true );
2623 m_textobj->emitEnsureCursorVisible();
2625 return new KoTextCommand( m_textobj, i18n(
"Change Paragraph Attribute") );
2628KCommand * KWTextFrameSet::pasteOasis( KoTextCursor * cursor,
const TQByteArray & data,
bool removeSelected )
2630 if (protectContent() )
2633 kdDebug(32001) <<
"KWTextFrameSet::pasteOasis data:" << data.size() <<
" bytes" << endl;
2634 KMacroCommand * macroCmd =
new KMacroCommand( i18n(
"Paste") );
2635 if ( removeSelected && textDocument()->
hasSelection( KoTextDocument::Standard ) )
2636 macroCmd->addCommand( m_textobj->removeSelectedTextCommand( cursor, KoTextDocument::Standard ) );
2637 m_textobj->emitHideCursor();
2638 m_textobj->setLastFormattedParag( cursor->parag()->prev() ?
2639 cursor->parag()->prev() : cursor->parag() );
2642 textDocument()->addCommand( cmd );
2644 macroCmd->addCommand(
new KoTextCommand( m_textobj, TQString() ) );
2646 *cursor = *( cmd->execute( cursor ) );
2653 m_textobj->emitEnsureCursorVisible();
2654 m_textobj->emitUpdateUI(
true );
2655 m_textobj->emitShowCursor();
2656 m_textobj->selectionChangedNotify();
2660void KWTextFrameSet::insertTOC( KoTextCursor * cursor )
2662 m_textobj->emitHideCursor();
2663 KMacroCommand * macroCmd =
new KMacroCommand( i18n(
"Insert Table of Contents") );
2667 KoTextCursor *cur= KWInsertTOCCommand::removeTOC(
this, cursor, macroCmd );
2671 KoTextDocCommand * cmd =
new KWInsertTOCCommand(
this,cur ? cur->parag(): cursor->parag() );
2672 textDocument()->addCommand( cmd );
2673 macroCmd->addCommand(
new KoTextCommand( m_textobj, TQString() ) );
2674 *cursor = *( cmd->execute( cursor ) );
2676 m_textobj->setLastFormattedParag( textDocument()->firstParag() );
2677 m_textobj->formatMore( 2 );
2679 m_textobj->emitEnsureCursorVisible();
2680 m_textobj->emitUpdateUI(
true );
2681 m_textobj->emitShowCursor();
2683 m_doc->addCommand( macroCmd );
2686KNamedCommand* KWTextFrameSet::insertFrameBreakCommand( KoTextCursor *cursor )
2688 KMacroCommand* macroCmd =
new KMacroCommand( TQString() );
2689 macroCmd->addCommand( m_textobj->insertParagraphCommand( cursor ) );
2693 cursor->setParag( parag );
2694 cursor->setIndex( parag->length() - 1 );
2696 macroCmd->addCommand( setPageBreakingCommand( cursor, parag->pageBreaking() | KoParagLayout::HardFrameBreakAfter ) );
2697 Q_ASSERT( parag->next() );
2698 if ( parag->next() ) {
2699 cursor->setParag( parag->next() );
2700 cursor->setIndex( 0 );
2705void KWTextFrameSet::insertFrameBreak( KoTextCursor *cursor )
2707 clearUndoRedoInfo();
2708 m_textobj->emitHideCursor();
2709 KNamedCommand* cmd = insertFrameBreakCommand( cursor );
2710 cmd->setName( i18n(
"Insert Break After Paragraph" ) );
2711 m_doc->addCommand( cmd );
2713 m_textobj->setLastFormattedParag( cursor->parag() );
2714 m_textobj->formatMore( 2 );
2716 m_textobj->emitEnsureCursorVisible();
2717 m_textobj->emitUpdateUI(
true );
2718 m_textobj->emitShowCursor();
2721TQRect KWTextFrameSet::paragRect( KoTextParag * parag )
const
2730 TQPoint topLeft = m_doc->zoomPoint( p );
2732 TQPoint bottomRight = m_doc->zoomPoint( p );
2733 return TQRect( topLeft, bottomRight );
2736void KWTextFrameSet::findPosition(
const KoPoint &dPoint, KoTextParag * & parag,
int & index )
2738 KoTextCursor cursor( textDocument() );
2743 cursor.place( iPoint, textDocument()->firstParag() );
2744 parag = cursor.parag();
2745 index = cursor.index();
2750 parag = textDocument()->lastParag();
2752 index = parag->length() - 1;
2758 TQPtrListIterator<KWFrame> frameIt(
framesInPage( pageNum ) );
2759 if ( !frameIt.current() )
2763 double topPt = frameIt.current()->internalY();
2764 double bottomPt = topPt + frameIt.current()->height();
2766 for ( ; frameIt.current(); ++frameIt )
2768 double y = frameIt.current()->internalY();
2769 topPt = TQMIN( topPt, y );
2770 bottomPt = TQMAX( bottomPt, y + frameIt.current()->height() );
2773 topLU = m_doc->ptToLayoutUnitPixY( topPt );
2774 bottomLU = m_doc->ptToLayoutUnitPixY( bottomPt );
2780 KoTextParag* parag = textDocument()->firstParag();
2781 for ( ; parag ; parag = parag->next() )
2783 if ( parag->rect().bottom() >= yLU )
2789KCommand * KWTextFrameSet::deleteAnchoredFrame(
KWAnchor * anchor )
2791 kdDebug() <<
"KWTextFrameSet::deleteAnchoredFrame anchor->index=" << anchor->index() << endl;
2793 KoTextCursor c( textDocument() );
2794 c.setParag( anchor->paragraph() );
2795 c.setIndex( anchor->index() );
2797 textDocument()->setSelectionStart( KoTextDocument::Temp, &c );
2798 c.setIndex( anchor->index() + 1 );
2799 textDocument()->setSelectionEnd( KoTextDocument::Temp, &c );
2800 KCommand *cmd = m_textobj->removeSelectedTextCommand( &c, KoTextDocument::Temp );
2802 m_doc->repaintAllViews();
2808 return m_textobj->hasSelection();
2813 return m_textobj->selectedText();
2816TQString KWTextFrameSet::toPlainText()
const
2818 return m_textobj->textDocument()->plainText();
2824 Q_ASSERT( m_textobj->isVisible() );
2826 m_textobj->highlightPortion( parag, index, length, repaint );
2831 TQRect expose = canvas->viewMode()->
normalToView( paragRect( parag ) );
2832 canvas->ensureVisible( (expose.left()+expose.right()) / 2,
2833 (expose.top()+expose.bottom()) / 2,
2834 (expose.right()-expose.left()) / 2,
2835 (expose.bottom()-expose.top()) / 2);
2838 TQRect globalRect( expose );
2839 globalRect.moveTopLeft( canvas->mapToGlobal( globalRect.topLeft() ) );
2840 KDialog::avoidArea( dialog, globalRect );
2845void KWTextFrameSet::removeHighlight(
bool repaint )
2847 m_textobj->removeHighlight( repaint );
2850void KWTextFrameSet::clearUndoRedoInfo()
2852 m_textobj->clearUndoRedoInfo();
2857 m_textobj->applyStyleChange( changed );
2863 return m_textobj->currentFormat();
2866KCommand *KWTextFrameSet::setChangeCaseOfTextCommand(KoChangeCaseDia::TypeOfCase _type)
2868 KoTextDocument *textdoc = m_textobj->textDocument();
2869 textdoc->selectAll( KoTextDocument::Standard );
2870 KoTextCursor *cursor =
new KoTextCursor( textDocument() );
2871 KCommand* cmd = m_textobj->changeCaseOfText(cursor, _type);
2872 textdoc->removeSelection( KoTextDocument::Standard );
2880 m_textobj->textDocument()->selectAll( KoTextDocument::Temp );
2881 KCommand *cmd = m_textobj->setFormatCommand( 0L, 0L, newFormat, flags, zoomFont, KoTextDocument::Temp );
2882 m_textobj->textDocument()->removeSelection( KoTextDocument::Temp );
2888 return m_textobj->currentParagLayoutFormat();
2891bool KWTextFrameSet::rtl()
const
2893 return m_textobj->rtl();
2899 return m_textobj->setParagLayoutFormatCommand(newLayout, flags, marginIndex);
2902class KWFootNoteVarList :
public TQPtrList< KWFootNoteVariable >
2905 virtual int compareItems(TQPtrCollection::Item a, TQPtrCollection::Item b)
2909 if ( vara->paragraph() == varb->paragraph() ) {
2912 int indexa = vara->index();
2913 int indexb = varb->index();
2914 return indexa < indexb ? -1 : indexa == indexb ? 0 : 1;
2916 if ( vara->paragraph()->paragId() < varb->paragraph()->paragId() )
2924 KWFootNoteVarList lst;
2925 TQPtrListIterator<KoTextCustomItem> cit( textDocument()->allCustomItems() );
2926 for ( ; cit.current() ; ++cit )
2929 if (fnv && !fnv->isDeleted() && (fnv->
frameSet() && !fnv->
frameSet()->isDeleted()))
2933 short int footNoteVarNumber = 0;
2934 short int endNoteVarNumber = 0;
2935 short int footNoteNumDisplay = 1;
2936 short int endNoteNumDisplay = 1;
2937 bool needRepaint =
false;
2938 TQPtrListIterator< KWFootNoteVariable > vit( lst );
2941 TQValueList<int> addedNums;
2942 for ( ; vit.current() ; ++vit )
2945 if ( var->numberingType()==KWFootNoteVariable::Manual )
2947 uint
const num = var->text().toUInt();
2949 addedNums.append( num );
2953 for ( vit.toFirst() ; vit.current() ; )
2956 bool endNote = var->noteType() == EndNote;
2957 short int & varNumber = endNote ? endNoteVarNumber : footNoteVarNumber;
2958 short int & numDisplay = endNote ? endNoteNumDisplay : footNoteNumDisplay;
2960 bool changed =
false;
2961 if ( varNumber != var->num() || var->numberingType()==KWFootNoteVariable::Manual )
2964 var->setNum( varNumber );
2966 if ( var->numberingType()==KWFootNoteVariable::Auto )
2968 if ( addedNums.contains( numDisplay ) != 0 )
2973 if ( numDisplay != var->numDisplay() )
2976 var->setNumDisplay( numDisplay );
2984 TQString fsName = endNote ? i18n(
"Endnote %1") : i18n(
"Footnote %1");
2985 if ( var->numberingType()== KWFootNoteVariable::Manual)
2986 var->
frameSet()->setName( m_doc->generateFramesetName(fsName));
2988 var->
frameSet()->setName( fsName.arg( var->text() ) );
2989 var->
frameSet()->setCounterText( var->text() );
2992 var->paragraph()->invalidate(0);
2993 var->paragraph()->setChanged(
true );
2998 if ( needRepaint && repaint )
2999 m_doc->slotRepaintChanged(
this );
3002KoTextDocCommand *KWTextFrameSet::deleteTextCommand( KoTextDocument *textdoc,
int id,
int index,
const TQMemArray<KoTextStringChar> & str,
const CustomItemsMap & customItemsMap,
const TQValueList<KoParagLayout> & oldParagLayouts )
3004 return new KWTextDeleteCommand( textdoc,
id, index, str, customItemsMap, oldParagLayouts );
3009 const KoTextCursor c1 = textDocument()->selectionStartCursor(KoTextDocument::Standard );
3010 const KoTextCursor c2 = textDocument()->selectionEndCursor( KoTextDocument::Standard );
3011 if ( c1.parag() == c2.parag() )
3012 return TQByteArray();
3016 TQMap<TQString, const KoTextParag*> sortMap;
3017 sortMap.insert( c1.parag()->toString(0), c1.parag() );
3019 const KoTextParag *p = c1.parag()->next();
3020 while ( p && p != c2.parag() ) {
3021 sortMap.insert( p->toString(0), p );
3024 sortMap.insert( c2.parag()->toString(0), c2.parag());
3026 typedef TQValueList<const KoTextParag *> ParagList;
3027 ParagList sortedParags = sortMap.values();
3028 if (
type == KW_SORTDECREASE )
3032 for ( ParagList::const_iterator it = sortedParags.begin(),
3033 end = sortedParags.end();
3034 it != end ; ++it ) {
3035 newList.prepend( *it );
3037 sortedParags = newList;
3042 if ( !oasisSaver.
finish() )
3043 return TQByteArray();
3044 return oasisSaver.
data();
3053 kdDebug() <<
"KWTextFrameSetEdit::insertFootNote " << endl;
3054 KWDocument * doc = m_doc;
3056 var->setNoteType( noteType );
3057 var->setNumberingType( numType );
3058 if ( numType == KWFootNoteVariable::Manual )
3059 var->setManualString( manualString );
3062 KWFootNoteFrameSet *fs =
new KWFootNoteFrameSet( doc, i18n(
"Footnotes" ) );
3063 fs->setFrameSetInfo( KWFrameSet::FI_FOOTNOTE );
3065 doc->addFrameSet( fs );
3068 var->setFrameSet( fs );
3069 fs->setFootNoteVariable( var );
3074KoVariable* KWTextFrameSet::variableUnderMouse(
const KoPoint& dPoint )
3078 return textObject()->variableAtPoint( iPoint );
3082KoLinkVariable* KWTextFrameSet::linkVariableUnderMouse(
const KoPoint& dPoint )
3087 KoLinkVariable* linkVariable =
dynamic_cast<KoLinkVariable *
>(
textObject()->variableAtPoint( iPoint ) );
3088 return linkVariable;
3096 : KoTextView( fs->textObject() ),
KWFrameSetEdit( fs, canvas ), m_rtl( false )
3098 setBackSpeller( fs->kWordDocument()->backSpeller() );
3100 KoTextView::setReadWrite( fs->kWordDocument()->isReadWrite() );
3102 connect( textobj, TQ_SIGNAL( selectionChanged(
bool) ), canvas, TQ_SIGNAL( selectionChanged(
bool) ) );
3104 connect( textView(), TQ_SIGNAL( cut() ), TQ_SLOT( cut() ) );
3105 connect( textView(), TQ_SIGNAL( copy() ), TQ_SLOT( copy() ) );
3106 connect( textView(), TQ_SIGNAL( paste() ), TQ_SLOT( paste() ) );
3107 updateUI(
true,
true );
3109 if( canvas->gui() && canvas->gui()->getHorzRuler())
3111 if ( !textobj->protectContent() )
3112 canvas->gui()->getHorzRuler()->changeFlags(KoRuler::F_INDENTS | KoRuler::F_TABS);
3114 canvas->gui()->getHorzRuler()->changeFlags(0);
3117 setOverwriteMode( canvas->overwriteMode() );
3120KWTextFrameSetEdit::~KWTextFrameSetEdit()
3126KoTextViewIface* KWTextFrameSetEdit::dcopObject()
3129 dcop =
new KWordTextFrameSetEditIface(
this );
3136 disconnect( textView()->textObject(), TQ_SIGNAL( selectionChanged(
bool) ), m_canvas, TQ_SIGNAL( selectionChanged(
bool) ) );
3137 textView()->terminate(removeSelection);
3140void KWTextFrameSetEdit::slotFrameDeleted(
KWFrame *frm )
3146void KWTextFrameSetEdit::paste()
3148 TQMimeSource *data = TQApplication::clipboard()->data();
3149 int provides = KWView::checkClipboard( data );
3150 pasteData( data, provides,
false );
3153void KWTextFrameSetEdit::pasteData( TQMimeSource* data,
int provides,
bool drop )
3155 if ( provides & KWView::ProvidesOasis )
3157 KCommand* cmd = pasteOasisCommand( data );
3159 frameSet()->kWordDocument()->addCommand(cmd);
3161 else if ( provides & KWView::ProvidesPlainText )
3165 const TQString text = TQApplication::clipboard()->text();
3166 const bool removeSelected = !drop;
3167 if ( !text.isEmpty() )
3168 textObject()->pasteText( cursor(), text, currentFormat(), removeSelected );
3171 kdWarning(32002) <<
"Unhandled case in KWTextFrameSetEdit::pasteData: provides=" << provides << endl;
3174 KWFootNoteFrameSet *footNote =
dynamic_cast<KWFootNoteFrameSet *
>(textFrameSet());
3177 KoParagCounter *counter = footNote->textDocument()->firstParag()->counter();
3178 if ( !counter || ( counter->numbering() != KoParagCounter::NUM_FOOTNOTE ) )
3179 footNote->setCounterText( footNote->footNoteVariable()->text() );
3180 frameSet()->kWordDocument()->slotRepaintChanged( frameSet() );
3184KCommand* KWTextFrameSetEdit::pasteOasisCommand( TQMimeSource* data )
3187 TQCString returnedTypeMime = KoTextObject::providesOasis( data );
3188 if ( !returnedTypeMime.isEmpty() )
3190 TQByteArray arr = data->encodedData( returnedTypeMime );
3191 Q_ASSERT( !arr.isEmpty() );
3193 return textFrameSet()->pasteOasis( cursor(), arr,
true );
3198void KWTextFrameSetEdit::cut()
3200 if ( textDocument()->hasSelection( KoTextDocument::Standard ) ) {
3202 textObject()->removeSelectedText( cursor() );
3206void KWTextFrameSetEdit::copy()
3208 if ( textDocument()->hasSelection( KoTextDocument::Standard ) ) {
3209 TQDragObject *drag = newDrag( 0 );
3210 TQApplication::clipboard()->setData( drag );
3214bool KWTextFrameSetEdit::doIgnoreDoubleSpace(KoTextParag * parag,
3215 int index,TQChar ch )
3217 if( textFrameSet()->kWordDocument()->allowAutoFormat())
3219 KoAutoFormat * autoFormat = textFrameSet()->kWordDocument()->autoFormat();
3222 return autoFormat->doIgnoreDoubleSpace( parag, index,ch );
3230void KWTextFrameSetEdit::doAutoFormat( KoTextCursor* cursor, KoTextParag *parag,
int index, TQChar ch )
3232 if( textFrameSet()->kWordDocument()->allowAutoFormat() )
3234 KoAutoFormat * autoFormat = textFrameSet()->kWordDocument()->autoFormat();
3236 autoFormat->doAutoFormat( cursor, parag, index, ch, textObject());
3240bool KWTextFrameSetEdit::doCompletion( KoTextCursor* cursor, KoTextParag *parag,
int index )
3242 if( textFrameSet()->kWordDocument()->allowAutoFormat() )
3244 KoAutoFormat * autoFormat = textFrameSet()->kWordDocument()->autoFormat();
3246 return autoFormat->doCompletion( cursor, parag, index, textObject());
3251bool KWTextFrameSetEdit::doToolTipCompletion( KoTextCursor* cursor, KoTextParag *parag,
int index,
int keyPressed )
3253 if( textFrameSet()->kWordDocument()->allowAutoFormat() )
3255 KoAutoFormat * autoFormat = textFrameSet()->kWordDocument()->autoFormat();
3257 return autoFormat->doToolTipCompletion( cursor, parag, index, textObject(), keyPressed);
3262void KWTextFrameSetEdit::showToolTipBox(KoTextParag *parag,
int index, TQWidget *widget,
const TQPoint &pos)
3264 if( textFrameSet()->kWordDocument()->allowAutoFormat() )
3266 KoAutoFormat * autoFormat = textFrameSet()->kWordDocument()->autoFormat();
3268 autoFormat->showToolTipBox(parag, index, widget, pos);
3272void KWTextFrameSetEdit::removeToolTipCompletion()
3274 if( textFrameSet()->kWordDocument()->allowAutoFormat() )
3276 KoAutoFormat * autoFormat = textFrameSet()->kWordDocument()->autoFormat();
3278 autoFormat->removeToolTipCompletion();
3282void KWTextFrameSetEdit::textIncreaseIndent()
3284 kdDebug(32001) <<
"Increasing list" << endl;
3285 m_canvas->gui()->getView()->textIncreaseIndent();
3288bool KWTextFrameSetEdit::textDecreaseIndent()
3290 if (currentLeftMargin()>0)
3292 kdDebug(32001) <<
"Decreasing list" << endl;
3293 m_canvas->gui()->getView()->textDecreaseIndent();
3300void KWTextFrameSetEdit::startDrag()
3302 textView()->dragStarted();
3303 m_canvas->dragStarted();
3304 TQDragObject *drag = newDrag( m_canvas->viewport() );
3305 if ( !frameSet()->kWordDocument()->isReadWrite() )
3308 bool move = ( drag->drag() );
3312 if ( TQDragObject::target() != m_canvas && TQDragObject::target() != m_canvas->viewport() ) {
3318 textObject()->removeSelectedText( cursor() );
3325TQDragObject * KWTextFrameSetEdit::newDrag( TQWidget * parent )
3328 return fs->kWordDocument()->dragSelected( parent, fs );
3331void KWTextFrameSetEdit::ensureCursorVisible()
3334 KoTextParag * parag = cursor()->parag();
3335 int idx = cursor()->index();
3337 KoTextStringChar *chr = parag->at( idx );
3338 int cursorHeight = parag->lineHeightOfChar( idx );
3339 int x = parag->rect().x() + cursor()->x();
3341 int y = 0;
int dummy;
3342 parag->lineHeightOfChar( idx, &dummy, &y );
3343 y += parag->rect().y();
3346 KoTextStringChar *chrLeft = idx > 0 ? chr-1 : chr;
3348 int areaLeft = chr->rightToLeft ? chr->width : chrLeft->width;
3349 int areaRight = chr->rightToLeft ? chrLeft->width : chr->width;
3359 m_canvas->gui()->getView()->updatePageInfo();
3361 TQPoint cursorPos = textFrameSet()->kWordDocument()->zoomPoint( pt );
3362 cursorPos = m_canvas->viewMode()->
normalToView( cursorPos );
3363 areaLeft = textFrameSet()->kWordDocument()->layoutUnitToPixelX( areaLeft ) + 1;
3364 areaRight = textFrameSet()->kWordDocument()->layoutUnitToPixelX( areaRight ) + 1;
3365 cursorHeight = textFrameSet()->kWordDocument()->layoutUnitToPixelY( cursorHeight );
3368 m_canvas->ensureVisible( cursorPos.x() - areaLeft, cursorPos.y() + cursorHeight / 2, areaLeft + areaRight, cursorHeight / 2 + 2 );
3371bool KWTextFrameSetEdit::enterCustomItem( KoTextCustomItem* customItem,
bool fromRight )
3376 if ( frameSet->
type() == FT_FORMULA || frameSet->
type() == FT_TEXT ) {
3382 m_canvas->editFrameSet( frameSet );
3387 if ( frameSet->
type() == FT_FORMULA )
3388 static_cast<KWFormulaFrameSetEdit*
>( edit )->moveEnd();
3393 if ( frameSet->
type() == FT_FORMULA )
3397 static_cast<KWFormulaFrameSet*
>( frameSet )->setChanged();
3406void KWTextFrameSetEdit::keyPressEvent( TQKeyEvent* e )
3409 if ( !( e->state() & ControlButton ) && !( e->state() & ShiftButton ) )
3411 if (e->state() != TQt::NoButton)
3412 removeToolTipCompletion();
3413 switch ( e->key() ) {
3415 KoTextCursor* cursor = textView()->cursor();
3416 KoTextParag* parag = cursor->parag();
3417 int index = cursor->index();
3419 KoTextStringChar* ch = parag->at( index-1 );
3420 if ( ch->isCustom() ) {
3421 KoTextCustomItem* customItem = ch->customItem();
3422 if ( enterCustomItem( customItem,
true ) ) {
3428 if ( index == 0 && !parag->prev() )
3434 KoTextCursor* cursor = textView()->cursor();
3435 KoTextParag* parag = cursor->parag();
3436 int index = cursor->index();
3437 if ( index < parag->length() - 1 ) {
3438 KoTextStringChar* ch = parag->at( index );
3439 if ( ch->isCustom() ) {
3440 KoTextCustomItem* customItem = ch->customItem();
3441 if ( enterCustomItem( customItem,
false ) ) {
3446 }
else if ( !parag->next() )
3454 TQPoint pos = textFrameSet()->cursorPos( cursor(), m_canvas,
m_currentFrame );
3455 textView()->handleKeyPressEvent( e, m_canvas, pos );
3458void KWTextFrameSetEdit::keyReleaseEvent( TQKeyEvent* e )
3460 textView()->handleKeyReleaseEvent( e );
3463void KWTextFrameSetEdit::imStartEvent( TQIMEvent* e )
3465 textView()->handleImStartEvent( e );
3468void KWTextFrameSetEdit::imComposeEvent( TQIMEvent* e )
3470 textView()->handleImComposeEvent( e );
3473void KWTextFrameSetEdit::imEndEvent( TQIMEvent* e )
3475 textView()->handleImEndEvent( e );
3478void KWTextFrameSetEdit::mousePressEvent( TQMouseEvent *e,
const TQPoint &,
const KoPoint & dPoint )
3480 if ( dPoint.x() < 0 || dPoint.y() < 0 )
3483 textFrameSet()->
textObject()->clearUndoRedoInfo();
3489 KWFrame * theFrame = textFrameSet()->documentToInternalMouseSelection( dPoint, iPoint, relPos, m_canvas->viewMode() );
3493 m_canvas->gui()->getView()->updatePageInfo();
3500 bool addParag = textView()->handleMousePressEvent( e, iPoint, relPos != KWTextFrameSet::LeftOfFrame, frameSet()->kWordDocument()->insertDirectCursor() );
3504 if ( relPos == KWTextFrameSet::LeftOfFrame )
3505 textView()->selectParagUnderCursor( *textView()->cursor() );
3507 frameSet()->kWordDocument()->setModified(
true );
3511 if ( e->button() != TQt::LeftButton )
3513 KoVariable* var = variable();
3519 footNoteVar->
frameSet()->startEditing( m_canvas );
3525void KWTextFrameSetEdit::mouseMoveEvent( TQMouseEvent * e,
const TQPoint & nPoint,
const KoPoint & )
3527 if ( textView()->maybeStartDrag( e ) )
3529 if ( nPoint.x() < 0 || nPoint.y() < 0 )
3533 KoPoint dPoint = frameSet()->kWordDocument()->unzoomPoint( nPoint );
3535 if ( nPoint.y() > 0 && textFrameSet()->documentToInternalMouseSelection( dPoint, iPoint, relPos , m_canvas->viewMode()) )
3537 if ( relPos == KWTextFrameSet::LeftOfFrame )
3538 textView()->extendParagraphSelection( iPoint );
3540 textView()->handleMouseMoveEvent( e, iPoint );
3548 KWDocument* doc = fs->kWordDocument();
3549 if ( doc->variableCollection()->variableSetting()->displayLink() ) {
3551 const TQString url = variable->url();
3552 if( url.startsWith(
"bkm://") )
3554 const KoTextBookmark* bookmark = doc->bookmarkByName(url.mid(6) );
3557 cursor()->setParag( bookmark->startParag() );
3558 ensureCursorVisible();
3562 KoTextView::openLink( variable );
3570 KoLinkVariable* v = linkVariable();
3575void KWTextFrameSetEdit::mouseReleaseEvent( TQMouseEvent *,
const TQPoint &,
const KoPoint & )
3577 textView()->handleMouseReleaseEvent();
3580void KWTextFrameSetEdit::mouseDoubleClickEvent( TQMouseEvent *e,
const TQPoint &,
const KoPoint & )
3582 textView()->handleMouseDoubleClickEvent( e, TQPoint() );
3585void KWTextFrameSetEdit::dragEnterEvent( TQDragEnterEvent * e )
3587 int provides = KWView::checkClipboard( e );
3588 if ( !frameSet()->kWordDocument()->isReadWrite() || provides == 0 )
3596void KWTextFrameSetEdit::dragMoveEvent( TQDragMoveEvent * e,
const TQPoint &nPoint,
const KoPoint & )
3598 int provides = KWView::checkClipboard( e );
3599 if ( !frameSet()->kWordDocument()->isReadWrite() || provides == 0 )
3606 if ( provides & ( KWView::ProvidesOasis | KWView::ProvidesPlainText | KWView::ProvidesFormula ) )
3609 KoPoint dPoint = frameSet()->kWordDocument()->unzoomPoint( nPoint );
3610 if ( textFrameSet()->documentToInternal( dPoint, iPoint ) )
3612 textObject()->emitHideCursor();
3613 placeCursor( iPoint );
3614 textObject()->emitShowCursor();
3620void KWTextFrameSetEdit::dragLeaveEvent( TQDragLeaveEvent * )
3624void KWTextFrameSetEdit::dropEvent( TQDropEvent * e,
const TQPoint & nPoint,
const KoPoint &, KWView* view )
3626 int provides = KWView::checkClipboard( e );
3627 if ( frameSet()->kWordDocument()->isReadWrite() && provides )
3630 KoTextCursor dropCursor( textDocument() );
3632 KoPoint dPoint = frameSet()->kWordDocument()->unzoomPoint( nPoint );
3633 if ( !textFrameSet()->documentToInternal( dPoint, dropPoint ) )
3636 dropCursor.place( dropPoint, textDocument()->firstParag() );
3637 kdDebug(32001) <<
"KWTextFrameSetEdit::dropEvent dropCursor at parag=" << dropCursor.parag()->paragId() <<
" index=" << dropCursor.index() << endl;
3639 if ( ( e->source() == m_canvas ||
3640 e->source() == m_canvas->viewport() ) &&
3641 e->action() == TQDropEvent::Move &&
3643 textDocument()->hasSelection( KoTextDocument::Standard ) ) {
3645 KCommand *cmd = textView()->prepareDropMove( dropCursor );
3648 KMacroCommand* macroCmd =
new KMacroCommand( i18n(
"Move Text" ) );
3649 macroCmd->addCommand(cmd);
3651 cmd = pasteOasisCommand( e );
3653 macroCmd->addCommand(cmd);
3656 textFrameSet()->
layout();
3657 frameSet()->kWordDocument()->addCommand( macroCmd );
3663 textDocument()->removeSelection( KoTextDocument::Standard );
3664 textObject()->selectionChangedNotify();
3668 view->pasteData( e,
true );
3672void KWTextFrameSetEdit::focusInEvent()
3674 textView()->focusInEvent();
3677void KWTextFrameSetEdit::focusOutEvent()
3679 textView()->focusOutEvent();
3682void KWTextFrameSetEdit::selectAll()
3684 textObject()->selectAll(
true );
3687void KWTextFrameSetEdit::drawCursor(
bool visible )
3690 kdDebug() <<
"KWTextFrameSetEdit::drawCursor " << visible << endl;
3692 KoTextView::drawCursor( visible );
3693 if ( !cursor()->parag() )
3696 if ( !cursor()->parag()->isValid() )
3699 if ( !frameSet()->kWordDocument()->isReadWrite() )
3704 TQPainter p( m_canvas->viewport() );
3705 p.translate( -m_canvas->contentsX(), -m_canvas->contentsY() );
3706 p.setBrushOrigin( -m_canvas->contentsX(), -m_canvas->contentsY() );
3708 textFrameSet()->drawCursor( &p, cursor(), visible, m_canvas,
m_currentFrame );
3711bool KWTextFrameSetEdit::pgUpKeyPressed()
3713 TQRect crect( m_canvas->contentsX(), m_canvas->contentsY(),
3714 m_canvas->visibleWidth(), m_canvas->visibleHeight() );
3718 int h = frameSet()->kWordDocument()->pixelToLayoutUnitY( (
int)( (
double)crect.height() * 0.9 ) );
3719 KoTextParag *s = textView()->cursor()->parag();
3720 KoTextParag* oldParag = s;
3721 int y = s->rect().y();
3723 if ( y - s->rect().y() >= h )
3729 s = textDocument()->firstParag();
3731 textView()->cursor()->setParag( s );
3732 textView()->cursor()->setIndex( 0 );
3733 if ( s == oldParag )
3735 m_canvas->viewportScroll(
true );
3741bool KWTextFrameSetEdit::pgDownKeyPressed()
3743 TQRect crect( m_canvas->contentsX(), m_canvas->contentsY(),
3744 m_canvas->visibleWidth(), m_canvas->visibleHeight() );
3747 int h = frameSet()->kWordDocument()->pixelToLayoutUnitY( (
int)( (
double)crect.height() * 0.9 ) );
3749 KoTextCursor *cursor = textView()->cursor();
3750 KoTextParag *s = cursor->parag();
3751 KoTextParag* oldParag = s;
3752 int y = s->rect().y();
3754 if ( s->rect().y() - y >= h )
3760 s = textDocument()->lastParag();
3761 cursor->setParag( s );
3762 cursor->setIndex( s->length() - 1 );
3764 cursor->setParag( s );
3765 cursor->setIndex( 0 );
3767 if ( s == oldParag )
3769 m_canvas->viewportScroll(
false );
3775void KWTextFrameSetEdit::ctrlPgUpKeyPressed()
3780 if ( !iPoint.isNull() )
3781 placeCursor( iPoint );
3785void KWTextFrameSetEdit::ctrlPgDownKeyPressed()
3790 if ( !iPoint.isNull() )
3791 placeCursor( iPoint );
3795void KWTextFrameSetEdit::setCursor( KoTextParag* parag,
int index )
3797 cursor()->setParag( parag );
3798 cursor()->setIndex( index );
3801void KWTextFrameSetEdit::insertExpression(
const TQString &_c)
3803 if(textObject()->hasSelection() )
3804 frameSet()->kWordDocument()->addCommand(textObject()->replaceSelectionCommand(
3805 cursor(), _c, i18n(
"Insert Expression")));
3807 textObject()->insert( cursor(), currentFormat(), _c, i18n(
"Insert Expression") );
3810void KWTextFrameSetEdit::insertFloatingFrameSet(
KWFrameSet * fs,
const TQString & commandName )
3812 textObject()->clearUndoRedoInfo();
3813 CustomItemsMap customItemsMap;
3814 TQString placeHolders;
3816 int frameNumber = 0;
3818 int insertFlags = KoTextObject::DoNotRemoveSelected;
3821 if ( frameNumber == 0 && anchor->ownLine() && cursor()->index() > 0 )
3823 kdDebug() <<
"ownline -> prepending \\n" << endl;
3824 placeHolders += TQChar(
'\n');
3826 insertFlags |= KoTextObject::CheckNewLine;
3828 placeHolders += KoTextObject::customItemChar();
3829 customItemsMap.insert( index, anchor );
3832 textObject()->insert( cursor(), currentFormat(), placeHolders,
3833 commandName, KoTextDocument::Standard, insertFlags,
3837void KWTextFrameSetEdit::insertLink(
const TQString &_linkName,
const TQString & hrefName)
3839 KWDocument * doc = frameSet()->kWordDocument();
3840 KoVariable * var =
new KoLinkVariable( textFrameSet()->textDocument(), _linkName, hrefName, doc->variableFormatCollection()->format(
"STRING" ), doc->variableCollection() );
3841 insertVariable( var );
3844void KWTextFrameSetEdit::insertComment(
const TQString &_comment)
3846 KWDocument * doc = frameSet()->kWordDocument();
3847 KoVariable * var =
new KoNoteVariable( textFrameSet()->textDocument(), _comment, doc->variableFormatCollection()->format(
"STRING" ), doc->variableCollection() );
3848 insertVariable( var );
3852void KWTextFrameSetEdit::insertCustomVariable(
const TQString &name)
3854 KWDocument * doc = frameSet()->kWordDocument();
3855 KoVariable * var =
new KoCustomVariable( textFrameSet()->textDocument(), name, doc->variableFormatCollection()->format(
"STRING" ), doc->variableCollection());
3856 insertVariable( var );
3859void KWTextFrameSetEdit::insertFootNote( NoteType noteType, KWFootNoteVariable::Numbering numType,
const TQString &manualString )
3861 KWFootNoteFrameSet *fs = textFrameSet()->
insertFootNote( noteType, numType, manualString );
3867 fs->createInitialFrame( pageNum );
3869 insertVariable( var );
3875 textFrameSet()->kWordDocument()->recalcFrames( pageNum, -1 );
3881 fs->startEditing( m_canvas );
3885void KWTextFrameSetEdit::insertVariable(
int type,
int subtype )
3887 kdDebug() <<
"KWTextFrameSetEdit::insertVariable " << type << endl;
3888 KWDocument * doc = frameSet()->kWordDocument();
3890 KoVariable * var = 0L;
3891 bool refreshCustomMenu =
false;
3892 if ( type == VT_CUSTOM )
3894 KoCustomVarDialog dia( m_canvas );
3895 if ( dia.exec() == TQDialog::Accepted )
3897 KoCustomVariable *v =
new KoCustomVariable( textFrameSet()->textDocument(), dia.name(), doc->variableFormatCollection()->format(
"STRING" ),doc->variableCollection() );
3898 v->setValue( dia.value() );
3900 refreshCustomMenu =
true;
3903 else if ( type == VT_MAILMERGE )
3905 KWMailMergeVariableInsertDia dia( m_canvas, doc->mailMergeDataBase() );
3906 if ( dia.exec() == TQDialog::Accepted )
3908 var =
new KWMailMergeVariable( textFrameSet()->textDocument(), dia.getName(), doc->variableFormatCollection()->format(
"STRING" ),doc->variableCollection(),doc );
3912 var = doc->variableCollection()->createVariable( type, subtype, doc->variableFormatCollection(), 0L, textFrameSet()->textDocument(), doc, 0);
3914 insertVariable( var, 0L , refreshCustomMenu);
3917void KWTextFrameSetEdit::insertVariable( KoVariable *var, KoTextFormat *format ,
bool refreshCustomMenu )
3921 CustomItemsMap customItemsMap;
3922 customItemsMap.insert( 0, var );
3924 format = currentFormat();
3925 kdDebug() <<
"KWTextFrameSetEdit::insertVariable inserting into paragraph" << endl;
3927 kdDebug() <<
"KWTextFrameSetEdit::insertVariable format=" << format << endl;
3929 textObject()->insert( cursor(), format, KoTextObject::customItemChar(),
3930 i18n(
"Insert Variable"),
3931 KoTextDocument::Standard,
3932 KoTextObject::DoNotRemoveSelected,
3934 frameSet()->kWordDocument()->slotRepaintChanged( frameSet() );
3935 if ( var->type()==VT_CUSTOM && refreshCustomMenu)
3936 frameSet()->kWordDocument()->refreshMenuCustomVariable();
3940void KWTextFrameSetEdit::insertWPPage()
3943 textfs->clearUndoRedoInfo();
3944 KoTextObject* textobj = textObject();
3945 KWDocument * doc = frameSet()->kWordDocument();
3946 int pages = doc->pageCount();
3947 int columns = doc->numColumns();
3950 KMacroCommand* macroCmd =
new KMacroCommand( i18n(
"Insert Page") );
3952 macroCmd->addCommand( textfs->insertFrameBreakCommand( cursor() ) );
3953 textobj->setLastFormattedParag( cursor()->parag() );
3954 textobj->formatMore( 2 );
3955 }
while ( pages == doc->pageCount() && ++inserted <= columns );
3956 if ( pages == doc->pageCount() )
3957 kdWarning(32002) << k_funcinfo <<
" didn't manage to insert a new page! inserted=" << inserted <<
" columns=" << columns <<
" pages=" << pages << endl;
3959 doc->addCommand( macroCmd );
3961 textfs->slotRepaintChanged();
3962 textobj->emitEnsureCursorVisible();
3963 textobj->emitUpdateUI(
true );
3964 textobj->emitShowCursor();
3968 if(type == KoBorder::LeftBorder)
3969 return m_paragLayout.leftBorder;
3970 if(type == KoBorder::RightBorder)
3971 return m_paragLayout.rightBorder;
3972 if(type == KoBorder::TopBorder)
3973 return m_paragLayout.topBorder;
3974 return m_paragLayout.bottomBorder;
3978void KWTextFrameSetEdit::updateUI(
bool updateFormat,
bool force )
3981 KoTextView::updateUI( updateFormat, force );
3986 if ( m_paragLayout.alignment != parag->resolveAlignment() || force ) {
3987 m_paragLayout.alignment = parag->resolveAlignment();
3988 m_canvas->gui()->getView()->showAlign( m_paragLayout.alignment );
3992 if ( !m_paragLayout.counter )
3993 m_paragLayout.counter =
new KoParagCounter;
3994 KoParagCounter::Style cstyle = m_paragLayout.counter->style();
3995 if ( parag->counter() )
3996 *m_paragLayout.counter = *parag->counter();
3999 m_paragLayout.counter->setNumbering( KoParagCounter::NUM_NONE );
4000 m_paragLayout.counter->setStyle( KoParagCounter::STYLE_NONE );
4002 if ( m_paragLayout.counter->style() != cstyle || force )
4003 m_canvas->gui()->getView()->showCounter( * m_paragLayout.counter );
4005 if(m_paragLayout.leftBorder!=parag->leftBorder() ||
4006 m_paragLayout.rightBorder!=parag->rightBorder() ||
4007 m_paragLayout.topBorder!=parag->topBorder() ||
4008 m_paragLayout.bottomBorder!=parag->bottomBorder() || force )
4010 m_paragLayout.leftBorder = parag->leftBorder();
4011 m_paragLayout.rightBorder = parag->rightBorder();
4012 m_paragLayout.topBorder = parag->topBorder();
4013 m_paragLayout.bottomBorder = parag->bottomBorder();
4014 m_canvas->gui()->getView()->updateBorderButtons( m_paragLayout.leftBorder, m_paragLayout.rightBorder, m_paragLayout.topBorder, m_paragLayout.bottomBorder );
4017 if ( !parag->style() )
4018 kdWarning() <<
"Paragraph " << parag->paragId() <<
" has no style" << endl;
4019 else if ( m_paragLayout.style != parag->style() || force )
4021 m_paragLayout.style = parag->style();
4022 m_canvas->gui()->getView()->showStyle( m_paragLayout.style->name() );
4025 if( m_paragLayout.margins[TQStyleSheetItem::MarginLeft] != parag->margin(TQStyleSheetItem::MarginLeft)
4026 || m_paragLayout.margins[TQStyleSheetItem::MarginFirstLine] != parag->margin(TQStyleSheetItem::MarginFirstLine)
4027 || m_paragLayout.margins[TQStyleSheetItem::MarginRight] != parag->margin(TQStyleSheetItem::MarginRight)
4028 || parag->string()->isRightToLeft() != m_rtl
4031 m_paragLayout.margins[TQStyleSheetItem::MarginFirstLine] = parag->margin(TQStyleSheetItem::MarginFirstLine);
4032 m_paragLayout.margins[TQStyleSheetItem::MarginLeft] = parag->margin(TQStyleSheetItem::MarginLeft);
4033 m_paragLayout.margins[TQStyleSheetItem::MarginRight] = parag->margin(TQStyleSheetItem::MarginRight);
4034 if ( m_rtl != parag->string()->isRightToLeft() && parag->counter() )
4036 parag->counter()->invalidate();
4037 parag->setChanged(
true );
4039 m_rtl = parag->string()->isRightToLeft();
4040 m_canvas->gui()->getView()->showRulerIndent( m_paragLayout.margins[TQStyleSheetItem::MarginLeft], m_paragLayout.margins[TQStyleSheetItem::MarginFirstLine], m_paragLayout.margins[TQStyleSheetItem::MarginRight], m_rtl );
4042 if( m_paragLayout.tabList() != parag->tabList() || force)
4044 m_paragLayout.setTabList( parag->tabList() );
4045 KoRuler * hr = m_canvas->gui()->getHorzRuler();
4047 hr->setTabList( parag->tabList() );
4049 if( m_paragLayout.lineSpacingType != parag->paragLayout().lineSpacingType || force)
4051 m_paragLayout.lineSpacingType = parag->paragLayout().lineSpacingType;
4052 m_canvas->gui()->getView()->showSpacing( m_paragLayout.lineSpacingType );
4059void KWTextFrameSetEdit::showFormat( KoTextFormat *format )
4061 m_canvas->gui()->getView()->showFormat( *format );
4064TQPoint KWTextFrameSet::cursorPos( KoTextCursor *cursor,
KWCanvas* canvas,
KWFrame* currentFrame )
4068 KoTextParag* parag = cursor->parag();
4069 const TQPoint topLeft = parag->rect().topLeft();
4071 parag->lineHeightOfChar( cursor->index(), 0, &lineY );
4073 TQPoint iPoint( topLeft.x() + cursor->x() + parag->at( cursor->index() )->width, topLeft.y() + lineY );
4077 KoPoint hintDPoint = currentFrame ? currentFrame->innerRect().topLeft() : KoPoint();
4080 vPoint = viewMode->
normalToView( m_doc->zoomPoint( dPoint ) );
4081 vPoint.rx() -= canvas->contentsX();
4082 vPoint.ry() -= canvas->contentsY();
4089bool KWFootNoteFrameSet::isFootNote()
const
4091 if ( !m_footNoteVar ) {
4092 kdWarning() << k_funcinfo <<
" called too early? No footnote var." << endl;
4095 return ( m_footNoteVar->noteType() == FootNote );
4098bool KWFootNoteFrameSet::isEndNote()
const
4100 if ( !m_footNoteVar ) {
4101 kdWarning() << k_funcinfo <<
" called too early? No footnote var." << endl;
4104 return ( m_footNoteVar->noteType() == EndNote );
4109void KWFootNoteFrameSet::createInitialFrame(
int pageNum )
4111 KWFrame *frame =
new KWFrame(
this, 0, m_doc->pageManager()->topOfPage(pageNum) + 1, 20, 20 );
4112 frame->setFrameBehavior(KWFrame::AutoExtendFrame);
4113 frame->setNewFrameBehavior(KWFrame::NoFollowup);
4117void KWFootNoteFrameSet::startEditing(
KWCanvas* canvas )
4119 canvas->editFrameSet(
this );
4124 textedit->ensureCursorVisible();
4129 m_footNoteVar = var;
4132void KWFootNoteFrameSet::setCounterText(
const TQString& text )
4134 KoTextParag* parag = textDocument()->firstParag();
4137 KoParagCounter counter;
4138 counter.setNumbering( KoParagCounter::NUM_FOOTNOTE );
4139 counter.setPrefix( text );
4140 counter.setSuffix( TQString() );
4141 parag->setCounter( counter );
4145KWordFrameSetIface* KWFootNoteFrameSet::dcopObject()
4148 m_dcop =
new KWFootNoteFrameSetIface(
this );
4153#include "KWTextFrameSet.moc"
An anchor is a special character, or 'custom item'.
KWFrameSet * frameSet() const
The frameset that will provide the content to display in this anchor object.
Class: KWCanvas This class is responsible for the rendering of the frames to the screen as well as th...
void editTextFrameSet(KWFrameSet *fs, KoTextParag *parag, int index)
Starting editing fs if we're not yet doing it.
void repaintChanged(KWFrameSet *fs, bool resetChanged)
Only repaint the frameset fs.
void update()
Update the z-ordering around the frame we host the framelist for.
TQValueList< KWFrame * > framesOnTop() const
Fetches the frames on top of the frame this frameList is for.
This object is created to edit a particular frameset in a particular view The view's canvas creates i...
bool exitLeft()
Called if the cursor tries to leave the frameset at its beginning.
bool exitRight()
Called if the cursor tries to leave the frameset at its end.
KWFrame * m_currentFrame
The Frameset-Edit implementation is responsible for updating that one (to the frame where the current...
virtual KWFrameSetEdit * currentTextEdit()
Return the current most-low-level text edit object.
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
void repaintChanged(KWFrameSet *frameset)
Emitted when something has changed in this frameset, so that all views repaint it.
virtual void setVisible(bool v)
set the visibility of the frameset.
virtual void deleteFrame(unsigned int num, bool remove=true, bool recalc=true)
Delete a frame from the set of frames this frameSet has.
static KWFrame * settingsFrame(const KWFrame *frame)
Returns the original frame that the param frame is a copy off, or the frame itself.
virtual FrameSetType type() const
The type of frameset.
@ SortFrames
kwtextframeset only
int m_firstPage
always equal to m_framesInPage[0].first()->pageNumber() :)
const TQPtrList< KWFrame > & frameIterator() const
Iterator over the child frames.
virtual void finalize()
Called once the frameset has been completely loaded or constructed.
virtual void drawContents(TQPainter *painter, const TQRect &crect, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode, KWFrameViewManager *frameViewManager)
Paint this frameset.
void setAnchored(KWTextFrameSet *textfs, KoTextParag *parag, int index, bool placeHolderExists=false, bool repaint=true)
Make this frameset anchored, with the anchor at paragId,index in the text frameset textfs.
bool isDeleted() const
True if the frameset was deleted (but not destroyed, since it's in the undo/redo)
TQPtrVector< TQPtrList< KWFrame > > m_framesInPage
This array provides a direct access to the frames on page N.
virtual void drawFrame(KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQRect &crect, const TQPoint &translationOffset, KWFrame *settingsFrame, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode, bool drawUnderlyingFrames)
Draw a particular frame of this frameset.
virtual KWAnchor * createAnchor(KoTextDocument *txt, int frameNum)
Create an anchor for the floating frame identified by frameNum.
unsigned int frameCount() const
Get number of child frames.
virtual void load(TQDomElement &framesetElem, bool loadFrames=true)
load from XML - when loading
bool isFloating() const
Return true if this frameset is floating (inline), false if it's fixed.
virtual void updateFrames(int flags=0xff)
Called when our frames change, or when another frameset's frames change.
void saveCommon(TQDomElement &parentElem, bool saveFrames)
save the common attributes for the frameset
KWTableFrameSet * groupmanager() const
returns the groupManager this frameset belongs to.
KWTextFrameSet * anchorFrameset() const
Return the frameset in which our anchor is - assuming isFloating()
KWFrame * frame(unsigned int _num) const
get a frame by number
TQString name() const
get/set frameset name. For tables in particular, this must be unique
TQRegion frameClipRegion(TQPainter *painter, KWFrame *frame, const TQRect &crect, KWViewMode *viewMode)
Determine the clipping rectangle for drawing the contents of frame with painter in the rectangle deli...
const TQPtrList< KWFrame > & framesInPage(int pageNum) const
Return list of frames in page pageNum.
Info frameSetInfo() const
Returns the type of TextFrameSet this is.
bool isVisible(KWViewMode *viewMode=0L) const
Returns true if the frameset is visible.
Class that knows about all the (visible) frames in the document and will act as a manager between the...
This class represents a single frame.
double minimumFrameHeight(void) const
KWFrameSet * frameSet() const
Data stucture methods.
double paddingTop() const
get top padding
double paddingBottom() const
get bottom padding
void setMinimumFrameHeight(double h)
The property minimum frame height is used to make the automatic frame shrinking code stop.
FrameBehavior
what should happen when the frame is full
void save(TQDomElement &frameElem)
create XML to describe yourself
void setInternalY(double y)
The "internal Y" is the offset (in pt) of the real frame showed in this one ("real" means "the last t...
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.
int pageNumber() const
The page on which this frame is.
void startOasisFrame(KoXmlWriter &xmlWriter, KoGenStyles &mainStyles, const TQString &name, const TQString &lastFrameName=TQString()) const
Write out a draw:frame element and its style.
KWFrame * getCopy()
returns a copy of self
Command created when pasting oasis-formatted text.
This is used to save a bunch of paragraphs into a oasis store in memory, as some features do (e....
TQByteArray data() const
Return the entire ZIP store as a byte array.
bool finish()
You MUST call this after saving the paragraphs and before calling data() Return true on success.
void saveParagraphs(const TQValueList< const KoTextParag * > ¶graphs)
Save a list of paragraphs.
This class represents a printed page of the document.
double height() const
return the height of this page (in pt)
double leftMargin() const
return the width of the margin at left (in pt);
int pageNumber() const
returns the number of this page as it will be shown to the user.
double topMargin() const
return the height of the margin at top (in pt);
double bottomMargin() const
return the height of the margin at bottom (in pt);
double width() const
return the width of this page (in pt)
double rightMargin() const
return the width of the margin at left (in pt);
double offsetInDocument() const
All Pages are in a document-wide coordinate system that simply puts every page under the next page an...
"current page number" and "number of pages" variables
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...
void recalcCols(uint column, uint row)
resize and position all cells
This is our KoTextDocument reimplementation, to create KWTextParag instead of KoTextParags,...
Object that is created to edit a Text frame set (KWTextFrameSet).
KoBorder border(KoBorder::BorderType type)
Return the requested border of the paragraph that the cursor currently is in.
virtual void terminate(bool removeselection=true)
Called before destruction, when terminating edition - use to e.g.
void openLink()
Called by KWView when using the action.
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.
KWFrame * internalToDocumentWithHint(const TQPoint &iPoint, KoPoint &dPoint, const KoPoint &hintDPoint) const
Same as internalToDocument, but goes directly to the normal coords (zoomed) since this method is used...
TQPoint moveToPage(int currentPgNum, short int direction) const
Implementation of Ctrl+PageUp/PageDown Returns a point in layout units (for placing the cursor)
virtual KWFrameSetEdit * createFrameSetEdit(KWCanvas *canvas)
Create a framesetedit object to edit this frameset in canvas.
virtual FrameSetType type() const
The type of frameset.
bool hasSelection() const
return true if some text is selected
TQByteArray sortText(SortType type) const
Sort selected paragraphs Return a complete OASIS store, ready for "pasting".
void frameDeleted(KWFrame *frame)
Tell the Edit object that this frame got deleted.
KoTextObject * textObject() const
Return the contained text object.
virtual void updateFrames(int flags=0xff)
reshuffle frames so text is always displayed from top-left down and then right.
KoPoint internalToDocumentKnowingFrame(const KoPoint &relPoint, KWFrame *theFrame) const
A variant of internalToDocument, when the frame is already known.
KWFrame * internalToDocument(const KoPoint &relPoint, KoPoint &dPoint) const
Convert the in the internal qtextdoc coordinates (in layout units) into a point in the document coord...
KWTextFrameSet(KWDocument *_doc, const TQString &name)
Cnstructor.
virtual int adjustFlow(int y, int w, int h)
reimplemented from KoTextParag, adjusts y and returns the shift.
void ensureFormatted(KoTextParag *parag, bool emitAfterFormatting=true)
Make sure this paragraph is formatted If formatting happens, the afterFormatting signal will only be ...
virtual KoTextFormat * currentFormat() const
Let KoTextFormatInterface access the current format.
KWFrame * loadOasisTextFrame(const TQDomElement &frameTag, const TQDomElement &tag, KoOasisContext &context)
Load a frame and add it to this frameset - called by KWOasisLoader.
virtual bool canRemovePage(int num)
Return true if page num can be removed, as far as this frameset is concerned.
void setInlineFramesVisible(bool)
Show or hide all inline frames that are inside this frameset.
KWFrame * loadOasis(const TQDomElement &frame, const TQDomElement &bodyElem, KoOasisContext &context)
Load a complete textbox (frame and text)
virtual void layout()
Invalidate all paragraphs and start re-formatting.
bool isFrameEmpty(KWFrame *frame)
Return true if the last frame is empty.
virtual void load(TQDomElement &attributes, bool loadFrames=true)
load from XML - when loading
RelativePosition
used by documentToInternalMouseSelection()
void mainTextHeightChanged()
Tell the text viewmode that the height of the text might have changed.
virtual int availableHeight() const
Return the available height in pixels (sum of all frames' height, with zoom applied) Used to know if ...
void loadOasisContent(const TQDomElement &bodyElem, KoOasisContext &context)
Load the contents of a frame (i.e. the text)
virtual KCommand * setParagLayoutFormatCommand(KoParagLayout *newLayout, int flags, int marginIndex=-1)
Let KoTextFormatInterface set a modified current parag layout.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context, bool saveFrames) const
Save a complete textbox (frame and text)
virtual const KoParagLayout * currentParagLayoutFormat() const
Let KoTextFormatInterface access the current parag layout.
virtual void invalidate()
Invalidate all paragraphs (causes a re-flow of the text upon next redraw)
virtual void deleteFrame(unsigned int num, bool remove=true, bool recalc=true)
Delete a frame from the set of frames this frameSet has.
KWFrame * documentToInternal(const KoPoint &dPoint, TQPoint &iPoint) const
Convert the dPoint in the normal coordinate system (and in pt) into a point (iPoint) in the internal ...
KoTextParag * paragAtLUPos(int yLU) const
Find the parag at the given Y position (in LU)
virtual void adjustMargins(int yp, int h, int reqMinWidth, int &leftMargin, int &rightMargin, int &pageWidth, KoTextParag *parag)
reimplemented from KoTextFlow, implements flowing around frames etc.
int formatVertically(KoTextParag *parag, const TQRect &rect)
Called by KWTextFormatter.
virtual void drawFrameContents(KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode)
Implement this one instead of drawFrame to benefit from double-buffering AND transparency handling (p...
void saveOasisContent(KoXmlWriter &writer, KoSavingContext &context) const
Save the contents of a frame (i.e. the text)
virtual KCommand * setFormatCommand(const KoTextFormat *newFormat, int flags, bool zoomFont=false)
Let KoTextFormatInterface set the modified format.
virtual void drawFrame(KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQRect &crect, const TQPoint &translationOffset, KWFrame *settingsFrame, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode, bool drawUnderlyingFrames)
Draw a particular frame of this frameset.
void fixParagWidth(KWTextParag *parag)
Called by KWTextFormatter::postFormat()
bool minMaxInternalOnPage(int pageNum, int &topLU, int &bottomLU) const
Return the min and max LU coordinates for the text in the given page, if the frameset has any frames ...
KWFootNoteFrameSet * insertFootNote(NoteType noteType, KWFootNoteVariable::Numbering numType, const TQString &manualString)
Insert a footnote (var and frameset).
virtual void drawContents(TQPainter *painter, const TQRect &crect, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode, KWFrameViewManager *frameViewManager)
Paint this frameset.
virtual void finalize()
Called once the frameset has been completely loaded or constructed.
virtual void setVisible(bool v)
set the visibility of the frameset.
~KWTextFrameSet()
Destructor.
void updateViewArea(TQWidget *w, KWViewMode *viewMode, const TQPoint &nPointBottom)
Views notify the KWTextFrameSet of which area of the text they're looking at, so that formatMore() en...
TQString selectedText() const
returns the selected text [without formatting] if hasSelection()
void renumberFootNotes(bool repaint=true)
(Assuming this==main frameset), recalc the foot note numbers
void highlightPortion(KoTextParag *parag, int index, int length, KWCanvas *canvas, bool repaint=true, KDialogBase *dialog=0)
Highlighting support (for search/replace, spellchecking etc.)
virtual bool statistics(TQProgressDialog *progress, ulong &charsWithSpace, ulong &charsWithoutSpace, ulong &words, ulong &sentences, ulong &syllables, ulong &lines, bool selected)
Calculate statistics for this frameset.
void applyStyleChange(KoStyleChangeDefMap changed)
Update the paragraph that use the given style, after this style was changed.
This class extends KoTextParag for KWord-specific formatting stuff, custom items, loading and saving.
void load(TQDomElement &attributes)
Load (from KWord-1.3 XML) the paragraph.
void save(TQDomElement &parentElem, bool saveAnchorsFramesets=false)
Save (to KWord-1.3 XML) the whole paragraph.
void setPageBreaking(int pb)
The type of page-breaking behaviour.
The 'edit only one text frameset' view mode.
static const int OFFSET
hardcoded distance from the left side this viewmode starts its rendering
Abstract base class for KWCanvas's view modes.
virtual bool hasFrames()
Does this viewmode know anything about frames?
virtual TQSize availableSizeForText(KWTextFrameSet *textfs)
Size (in pixels) of the total area available for text in a given textframeset This is used by KWTextF...
virtual TQPoint normalToView(const TQPoint &nPoint)=0
Normal coord -> view coord.
virtual bool drawSelections()
Should selected text be drawn as such?
virtual TQSize contentsSize()=0
Size of the contents area, in pixels.
virtual TQPoint viewToNormal(const TQPoint &vPoint)=0
View coord -> normal coord.
virtual bool drawFrameBackground()
Should frame background be drawn? Usually yes, but not for embedded docs with transparent=true.