Re: Commit: Re: PATCH - DefaultPageSize


Subject: Re: Commit: Re: PATCH - DefaultPageSize
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Fri Dec 08 2000 - 03:23:49 CST


On Thu, 7 Dec 2000, Daniel Thompson wrote:

> > This is nice work already. Now apart from the internationalization, the
> > other issue is that Abi doesn't resize on the fly when you change paper
> > sizes. You have to log out or open a new view to see the new page size.
>
> My view is that ultimately the default page size should only affect
> document *creation*. I think existing documents should have their own paper
> size embedded in them and this can be changed through the (unimplemented)
> Page Setup dialog.

This makes sense. However if you have a blank document you might expect it
to change to the new paper size.
>
> > Do you think you should pop up a message dialog to let the user
> > know that the changes will be reflected on the next window they open?
>
> Assuming I start working on with the Page Setup dialog soon I don't think
> this will be necessary.
>

I'm really looking forward to this.

> Page Setup *will* require the current view to be changed on the fly. Does
> anyone have any idea how hard this will be? Can I just destroy the view
> and regenerate it with the new paper size?
>

I don't think you need to nuke the whole view. Here's what I would try.

First off you have to invent a document attribute tht describes the
page size. At present there are none defined so you will have to invent
their names (like page-width page-height, orientation ) and store them as
protected member variables in the pd_Document class. These should be
written out and restored from the abiword xml file. Copy the code used by
the list implementation to do this. You should record the names of your
attributes in src/text/ptbl/xp/pt_Types.h

Once again use the list import/export code as a guide for how to read and
write these sizes into the abi document file. Look at the code in
src/text/ptbl/xp/pd_Document.cpp, src/wp/impexp/xp/ie_imp_AbiWord_1.cpp .

Do you remeber my post about the abi frame work? when changing the page
size you don't need to change anything in the piece table description of
the document. You do have to recreate a new layout structure from the
piecetable data though.

Now you have to reformat the current layouts.

 To do this loop over all the active frames of the document and remove all
the lines and pages associated with each layout.

You remove all the lines in the DocLayout with a nested series of
fl_BlockLayout::collapse() calls on all the blocks in the document.
Copy how a format() on a doclayout is implemented through all
the layout subclasses. Just use a collapse() instead of a format(). Now
delete all the columns with a series of
calls through all the DocSectionLayouts(). Just copy the code in the
DocSectionLayout destructor. Finally remove all pages by looping through
the vector of pages in the fl_DocLayout class. See the destructor in
fl_Doclayout to see how this is done.

After the layout information is gone (lines,columns and pages), Remove the
top and left rulers. Then redraw them with your new page size.

Then to refill everything just do a formatAll() in fl_DocLayout on your
document with the altered page sizes and hey presto you've changed the
page size on the fly. It won't even change your cursor position.

OK that was the difficult but nice way to change page sizes on the fly.

The quick and dirty way is after changing the page sizes in the
pd_Document class, just destroy every frame containing the document and
then recreate them.

Much easier but not as nice.

Good Luck!

PS I didn't get a chance to internationalize your patch.



This archive was generated by hypermail 2b25 : Fri Dec 08 2000 - 03:24:33 CST