[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Simple KWord patch for frames extending beyond the page
From:       Michael Fair <michael () daclubhouse ! net>
Date:       2003-10-15 19:31:01
[Download RAW message or body]

The attached patch makes a simple change to the way Rects are translated 
from normalToView coordinates in KWViewMode.h for KWord.

The original code mapped the topLeft point, and then mapped the bottomRIght
points of the rect separately and used the resulting rect from the two mapped 
points as the new rect.  This causes a problem if the two points aren't 
calculated to be on the same page and the pages are laid out horizontally not 
vertically (as in Preview Mode).

This patch maps the topLeft point same as the original, but instead of mapping 
the bottomRight directly, it subtracts the bottomRight from the topLeft to 
get the width/height, maps that width/height as a point into the view 
coordinates, and then adds the result to the mapped topLeft point.

This makes the new equation do something closer to:
QRect( topLeft, topLeft + (width/height in View coordinate units) )

This only makes a difference for the case where because of the frame's size 
the bottomRight point would be beyond the bottom of the page.

This patch makes absolutely no attempt to resize or relocate the frame so that 
it actually fits on the page merely prevents it from rendering horridly.

-- Michael --

PS The patch also removes a trailing space from a comment.

["kwviewmode.h.diff" (text/x-diff)]

Index: kword/kwviewmode.h
===================================================================
RCS file: /home/kde/koffice/kword/kwviewmode.h,v
retrieving revision 1.24
diff -u -3 -p -r1.24 kwviewmode.h
--- kword/kwviewmode.h	14 Jul 2002 09:42:56 -0000	1.24
+++ kword/kwviewmode.h	15 Oct 2003 19:04:43 -0000
@@ -55,7 +55,10 @@ public:
 
     /** Normal coord -> view coord */
     QRect normalToView( const QRect & nRect )
-    { return QRect( normalToView( nRect.topLeft() ), normalToView( nRect.bottomRight() ) ); }
+    {
+        QPoint viewTopleft = normalToView( nRect.topLeft() );
+	return QRect( viewTopLeft,
+	    viewTopLeft  + normalToView( nRect.bottomRight() - nRect.topLeft() ) ); }
 
     /** View coord -> normal coord */
     virtual QPoint viewToNormal( const QPoint & vPoint ) = 0;
@@ -112,7 +115,7 @@ public:
     /** Return the name of the viewmode, used for loading/saving. */
     virtual const QString type() = 0;
 
-    /** Answers the question if argument frameset has to be drawn as a text-mode 
+    /** Answers the question if argument frameset has to be drawn as a text-mode
      *  text area if true, or if false as a frame with its own contents. */
     virtual bool isTextModeFrameset(KWFrameSet *) const { return false; }
 


_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic