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

List:       koffice-devel
Subject:    Re: Berlin Sprint Action List Update
From:       Thomas Zander <zander () kde ! org>
Date:       2007-11-09 7:49:02
Message-ID: 200711090849.08583.zander () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi Sebastian, thanks for thinking along :)

On Thursday 08 November 2007 20:59:58 Sebastian Sauer wrote:
> Thomas Zander wrote:
> > On Monday 05 November 2007 15:46:07 Boudewijn Rempt wrote:
> >> * all apps need the style manager, because now everyone crashes when
> >> a new style is added, except KWord. It is a document-wide resource,
> >> so KoCanvasResourceProvider is not the right place. Maybe
> >> KoDocument?
> >
> > There are two things;
> > a) it needs to be stored document wide
>
> sounds like the most logical way imho :)

Sure, if an app wants this, he can :)
If Krita doesn't care about text styles, or if kchart doesn't care it can 
avoid having an instance and avoid linking to kotext.
I don't know; their maintainers are in a better position to judge :)

 > Storing it in the KoDocument is not going to be a good idea as that
> > means it needs to link to libKoText. And it doesn't help anyway since
> > the code to add shapes is not there anyway so point (b) can't be
> > fulfilled here.
>
> it doesn't need to link to kotext. Using a QVariant as container could
> pretty much do the job and only those that actualy need to work with
> it, need to link to it.

Ehm, that only answers one little part of the linking question. A void 
pointer would do as well for that case...
You still need to (1) create a new instance and you still need to (2) add 
the stylemanager to the newly created and loaded shapes.
Naturally you need code to do that.  And those 6 lines of code is what 
Thorsten is concerned about duplicating.

> > So, my solution is a little added code to the text-plugin.  It will
> > automatically create a styleManager for each text-shape that doesn't
> > have one. Allowing the text shape to have styles.
> > This, however, will not share the textstyles among all shapes in that
> > document.  If an application wants that, he has to add the code in
> > his document.
>
> and what happens if we need to share a KoStyleManager instance like
> e.g. we need for the header+footer within KWord (see
> KWOpenDocumentLoader::loadHeaderFooter ) 

KWord has its own instance in the document, so this has and will keep on 
working.

> or e.g. if we have 2 
> text-shapes within kspread or for nested shapes?

KSpread doesn't link to kotext, so I didn't add the stylemanager instance 
I have a patch, I'll attach it.  Really, just 6 lines of code.
This means that when there are two shapes is kspread they will have 
different stylemanagers.

> what is for sure dirty aka not optimal since 
> everybody who likes to pass an own KoStyleManager to the loading code
> needs atm to create an own KoTextLoadingContext-instance and have to
> use that one as KoShapeLoadingContext

Yeah, that gives the problem that Thorsten mailed about this morning, that 
it "doesn't work" for him...
Not sure what the proper solution here is, but I believe we should move 
the styleManager ownership from the loader to the document after loading.
-- 
Thomas Zander

["doc.diff" (text/x-diff)]

--- Doc.cpp	2007-11-08 19:26:41.000000000 +0100
+++ Doc.cpp~	2007-11-09 08:46:05.000000000 +0100
@@ -68,6 +68,9 @@
 #include <KoShapeManager.h>
 #include <KoShapeRegistry.h>
 #include <KoStoreDevice.h>
+#include <KoStyleManager.h>
+#include <KoTextShapeData.h>
+#include <KoTextDocumentLayout.h>
 #include <KoXmlNS.h>
 #include <KoXmlWriter.h>
 #include <KoZoomHandler.h>
@@ -202,6 +205,7 @@
   // The precision used for decimal numbers, if the default cell style's
   // precision is set to arbitrary.
   int precision;
+  KoStyleManager *textStyleManager;
 };
 
 /*****************************************************************************
@@ -282,6 +286,7 @@
   d->refYear = 1930;
   d->refDate = QDate( 1899, 12, 30 );
   d->precision = 8;
+  d->textStyleManager = new KoStyleManager(this);
 
     // Init chart shape factory with KSpread's specific configuration panels.
     QList<KoShapeConfigFactory*> panels = ChartDialog::panels( this );
@@ -437,6 +442,14 @@
 {
     if ( !shape )
         return;
+
+    KoTextShapeData *data = qobject_cast<KoTextShapeData*> (shape->userData());
+    if (data) { // its a text shape.
+        KoTextDocumentLayout *lay = dynamic_cast<KoTextDocumentLayout*> \
(data->document()->documentLayout()); +        if(lay)
+            lay->setStyleManager(d->textStyleManager);
+    }
+
     KoShape* parent = shape;
     SheetShapeContainer* shapeContainer = 0;
     while ( !shapeContainer && ( parent = parent->parent() ) )


[Attachment #8 (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