[Libreoffice] [PATCH] Remove unnecessary parameter to IDocumentStatistics::UpdateDocStat
Arnaud Versini
arnaud.versini at gmail.com
Sun Aug 21 11:41:35 PDT 2011
Hi,
New version of the patch. I have added a method :
IDocumentStatistic::GetUpdatedDocStat wich check state before returning. I
left some UpdateDocStat but I will continue it later.
Sorry for the first patch.
2011/8/19 Caolán McNamara <caolanm at redhat.com>
> On Wed, 2011-08-17 at 21:04 +0200, Arnaud Versini wrote:
> > Hi
> >
> > This patch remove unnecessary parameter SwDocStat& rStat to the method
> > IDocumentStatistics::UpdateDocStat and also limit copy of SwDocStat
> > during file saving and statistic dialog.
>
> There's a bug in the last hunk anyway,
>
> {
> SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());
> if(aStat.bModified)
> - pDocShell->GetDoc()->UpdateDocStat( aStat );
> + pDocShell->GetDoc()->UpdateDocStat();
>
> i.e. the "aStat" is a copy so after the UpdateDocStat is called, it's an
> unchanged copy, not a reference to an updated SwDocStat like it used to
> be, so a line or two later nValue = aStat.nChar will be wrong.
>
> Is there a specific problem you're trying to fix here ?
>
This is only for refactoring, I've seen some things to change when I have
patched fdo#36931.
>
> Looking through the DocStat stuff it looks a bit messy. Seems of it
> appears to want to give access to the document statistics for a fast
> query by some code that the stats need to be updated, and by other code
> just to get the stats. And some bits fail to check for bModified and
> force an update and some do. And the awesome rtf filter const_casts the
> document doc stat and updates it directly.
>
This rtf filter will be replaced with GSoC?
>
> If we want to refactor this then I suggest...
>
> a) move "bModified" out of the SwDocStat and add something like bool
> areStatsStale/statsNeedUpdating to IDocumentStatistics instead to query
> this fact
>
I will do this for shells I think
> b) have IDocumentStatistics::GetDocStat always return updated document
> stats instead of having to get them, find out if they are stale and
> update them if they are.
>
Done with a new method
>
> That would probably avoid the problems of needing to directly call
> UpdateDocStat for the general case where someone just wants to get
> up-to-date stats, but allow any special cases of calling UpdateDocStat
> when areStatsStale is true in order to force update of fields that
> display the doc stats.
>
> C.
>
> Thanks
--
Arnaud Versini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110821/3939872b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Remove-unecessary-parameter-to-IDocumentStatistics-U.patch
Type: text/x-patch
Size: 17217 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110821/3939872b/attachment-0001.bin>
More information about the LibreOffice
mailing list