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

List:       koffice-devel
Subject:    Re: koffice/kword/plugins/scripting
From:       Thomas Zander <zander () kde ! org>
Date:       2007-02-04 9:28:10
Message-ID: 200702041028.11258.zander () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Saturday 03 February 2007 23:11, Sebastian Sauer wrote:
> SVN commit 629851 by sebsauer:
>
> doc says createVariable can return NULL.

Reading your usage, I see my docs and implementation of the manager can be 
improved :)

Its concepts are highly confusing, I admit.

The variable manager manages 2 things;
the name/value pairs. (which are just QStrings)
and the KoVariable instances that _have_ to be inserted into a text document 
to have any use.
Your code here doesn't use the KoVariable instance, and thus the call 
to 'createVariable' is not the correct one.  Just a manager.setValue() would 
be enough.


>  M  +3 -3      TextDocument.h
>
>
> --- trunk/koffice/kword/plugins/scripting/TextDocument.h #629850:629851
> @@ -118,9 +118,9 @@
>              /** Add a new variable. */
>              bool addVariable(const QString& variablename, const QString&
> value) { KoVariableManager* manager = variableManager();
> -                if( ! manager ) return false;
> -                KoVariable* v = manager->createVariable(variablename);
> -                v->setValue(value);
> +                KoVariable* variable = manager ?
> manager->createVariable(variablename) : 0; +                if( ! variable
> ) return false;
> +                variable->setValue(value);
>                  return true;
>              }
>              /** Remove an existing variable. */

-- 
Thomas Zander

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