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

List:       koffice-devel
Subject:    Re: Tables on multiple pages
From:       Thomas Zander <zander () kde ! org>
Date:       2008-06-26 21:41:52
Message-ID: 200806262341.52535.zander () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Thursday 26. June 2008 14:17:17 Stefan Nikolaus wrote:
> Hi,
>
> I want to support multiple pages for the Table Shape, specifically for
> usage in KWord.

Brilliant! :)

> The logic for splitting the table into pages is basically the same as for
> printing a sheet in KSpread. The TableShape should become a
> KoShapeContainer consisting of several shapes, one for each page. Each
> shape has its own position in the document. So, does this already suffice
> to break the table onto different pages?

Yes, it does. This is basically the same as what KWord (textshape) does.
One thing, I'm not sure why you need to make it a KoShapeContainer. As far as 
I can tell you can use normal shapes.
The solution the text shape uses is that there are a set of textshapes which 
all have the same userData (KoShape::setUserData()) and that userdata is 
basically the model that combines them all.

So, if you *just* want to have multiple shapes on multiple pages this would 
suffice.  But naturally you want to have multiple shapes on multiple pages 
*inside* a text flow. :)

This is a bit harder.

> KWord supports different layouts for each page. How can these be queried
> from outside? Do you have to go over the parent container of the inlined
> shape and use its dimension or how should one handle it?

Let me give you an overview, the answer to the above question will naturally 
flow from that.
The embedding of a table shape in a text flow requires you to use a 
KoTextAnchor to connect your table shape to the text shape.
  "This class is the object that is positioned in the text to be an anchor for 
a shape.  An anchor is the connection between the text-shape and the so 
called 'anchored-shape', where the anchored shape can be any kind of shape.  
This textanchor then connects the anchored-shape to the text flow so the 
anchored shape can be repositioned on the canvas if new text is inserted or 
removed before the anchor character."  (see rest of API docs of KoTextAnchor)

The solution that I suggest is that you inherit from the KoTextAnchor and 
reimplement the virtual methods updatePosition and resize using the parent 
shape (the text shape) as the base size for cutting up the table and for 
determining the wanted sizes.

At this point, using the multiple shapes and the private text anchor class 
will take care of doing the in-text layout and splitting of the table for 
you.

The part where I can't really see a solution for right now is how to insert 
this construction in a text flow.  Let me explain;
We need a way to insert a new instance of the spreadsheet shape-plugin and we 
need a way to insert our new textAnchor class in the text flow too.
So something like;
  KoShape * sheet = new SpreadSheet()
  KoInlineObject *a = new SheetAnchor(sheet);
  KoTextSelectionHandler *handler = qobject_cast<KoTextSelectionHandler*> 
(canvas()->toolProxy()->selection());
  handler->insertInlineObject(a);

Now, the problem here is where to put the SheetAnchor class.  The sheetAnchor 
class needs to use the SpreadSheet API (to do splitting and to create new 
shapes for a next page).  So it could very well go into the kspread shape 
plugin.
But then where do we write the above code? You can't create a new class thats 
stored in the spreadsheet plugin from kotext...

Some solutions I see;
* We used to have a KoInlineObject registry which now got rewritten to be a 
KoVariableRegistry.  The solution would be to get the inline-object registry 
back and since the SheetAnchor would inherit from that (indirectly) we could 
write code in kotext that uses the registry to create the SheetAnchor.
The sheetanchor is in the same plugin as the sheetShape so it can create one 
of those at will.

* hmm, not really a solution; *move everything to kofficelibs* :P  Sorry, no 
creative ideas at this time...

Ok, I hope I didn't overwhelm you, and I hope its reasonably clear.  Just 
re-read it after getting into kotext, some concepts are a bit new and weird, 
I guess.

Anyway, good luck!
-- 
Thomas Zander

["signature.asc" (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://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