On Thu, 28 Nov 2013 16:02:06 +0000
Caolán McNamara <caol...@redhat.com> wrote:

> So now UniString is gone we have the chance to make use of OUString for
> >= 64k paragraphs (#i17171#) but we basically have to decide what to do
> with places that currently return STRING_LEN/STRING_MAXLEN in xub_Strlen
> (unsigned short). Do we want to return -1 or SAL_MAX_INT32 as the
> replacement. -1 is "nice" but there is so much code in existence that
> expects the error/boundary condition return value to be > any valid
> number that I reckon SAL_MAX_INT32 might be safer as the default.
> 
> For a concrete place see OutputDevice::GetTextBreak where STRING_LEN is
> returned for the boundary case. See also grepping for STRING_LEN in sw
> and think mass search/replace STRING_LEN SAL_MAX_INT32 :-)
> 
> For reference, I attach the trivial patches to remove the 16bit length
> limits in writer that stop anything larger that 0xFFFF entering it which
> are the final bits to be applied once everything else is done.
> 
> C.

I'm (slowly) working on this in sw and, from what I 've seen up to now, 
sometimes STRING_LEN/STRING_MAXLEN are used just as an upper bound for some 
following code, while sometimes they report an error condition.
Even if I really would like this conversion process being completed quickly, I 
can't see a mass search/replace as a safe solution. Deciding the right value to 
be used on a case by case basis is also difficult since it involves looking at 
a lot of (sometimes obscure) code but it has two advantages:
* finally separating error from boundary conditions
* incremental work should be easier to debug/fix
If a mass replacement is chosen as the way to go, I would suggest to choose 
SAL_MAX_INT32.

Cheers
Matteo

PS: in some code also sal_uInt32 was used as an "extentended" xub_StrLen: I was 
planning to ask on the ML for hints about a class that does that and then 
interfaces with OUStrings, sadly I can't remember its name at this moment.

PPS: in order to further improve code clarity and maintainability, I was also 
thinking about introducing a

class OUString
{
[...]
static sal_Int32 maxLength() {return SAL_MAX_INT32;}
};

I can provide a patch, in case this is seen as a good idea.
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to