Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

I was trying to debug a problem where the email-field doesn't show the correct color when imported (pptx).
I have attached a sample debug file.

qsort seems to change the order of the elements even if the elements are sorted. (Technically though it is correct), our way of applying color attributes goes out of order. For the field it should have been _FIELD data followed by EE_CHAR_COLOR, but then because of the qsort this gets reversed.

I have attached a work-around patch, this affects only 3.5 branch and on windows (I haven't tested 3.6+ on windows as yet, the code is different though).

Please let me know if there is a better way to solve this problem rather than a work-around...
If not, please review+push this, thanks!

Thanks & Regards,
Muthu Subramanian
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 0161eaa0..2aa21300c 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1994,6 +2058,16 @@ void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib )
         aAttribs.Insert( pAttrib, nCount );
 }
 
+static bool isAlreadySorted( CharAttribArray &rAttribs )
+{
+       bool bSorted = true;
+       sal_uInt16 nCount = rAttribs.Count();
+       for( sal_uInt16 i = 1; i < nCount && bSorted; i++ )
+                       if( rAttribs.GetObject( i - 1 )->GetStart() > rAttribs.GetObject( i 
)->GetStart() )
+                                bSorted = false;
+       return bSorted;
+}
+
 void CharAttribList::ResortAttribs()
 {
     if ( Count() )
@@ -2001,7 +2075,8 @@ void CharAttribList::ResortAttribs()
 #if defined __SUNPRO_CC
 #pragma disable_warn
 #endif
-        qsort( (void*)aAttribs.GetData(), aAttribs.Count(), sizeof( EditCharAttrib* ), 
CompareStart );
+               if( !isAlreadySorted( aAttribs ) )
+                       qsort( (void*)aAttribs.GetData(), aAttribs.Count(), sizeof( EditCharAttrib* 
), CompareStart );
 #if defined __SUNPRO_CC
 #pragma enable_warn
 #endif

Attachment: email3-1-1.pptx
Description: MS-Powerpoint 2007 presentation


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.