Hi, On Wed, Jun 20, 2012 at 8:16 AM, julien2412 <[email protected]> wrote: > Hello, > > By looking in the last fix commits, I sometimes "opengrok" to see if the > same kind of initial problem solved by the fix could be found. > > Then I read this code : > 71 // query the attribute descriptions > 72 void SwAttrSet::GetPresentation( > 73 SfxItemPresentation ePres, > 74 SfxMapUnit eCoreMetric, > 75 SfxMapUnit ePresMetric, > 76 String &rText ) const > 77 { > 78 static sal_Char const sKomma[] = ", "; > 79 > 80 rText.Erase(); > 81 String aStr; > 82 if( Count() ) > 83 { > 84 SfxItemIter aIter( *this ); > 85 const IntlWrapper rInt( > ::comphelper::getProcessServiceFactory(), > 86 GetAppLanguage() ); > 87 while( sal_True ) > 88 { > 89 aIter.GetCurItem()->GetPresentation( ePres, eCoreMetric, > 90 ePresMetric, aStr, > 91 &rInt ); > 92 if( rText.Len() && aStr.Len() ) > 93 rText += String::CreateFromAscii(sKomma); > 94 rText += aStr; > 95 if( aIter.IsAtEnd() ) > 96 break; > 97 aIter.NextItem(); > 98 } > 99 } > 100 } > if "rText" variable is completely cleared at the beginning (line 80), what's > the use of "rText.Len() &&..." (line 92) (and therefore line 93 and 78) ?
As far as I can see by just looking at this snippet of code this is needed because rText would be ", ... , ... , ..." instead of "... , ... , ..." if you omit rText.Len() from the if statement. In other words.. the rText.Len() is to ensure you don't write comma at the beginning of rText. > Julien > > -- > View this message in context: > http://nabble.documentfoundation.org/Question-about-function-SwAttrSet-GetPresentation-sw-source-ui-utlui-attrdesc-cxx-tp3991205.html > Sent from the Dev mailing list archive at Nabble.com. > _______________________________________________ > LibreOffice mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/libreoffice Regards, Tomaž _______________________________________________ LibreOffice mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice
