Hi Bjoern,<br><br><div class="gmail_quote">2012/11/30 Bjoern Michaelsen <span dir="ltr"><<a href="mailto:bjoern.michaelsen@canonical.com" target="_blank">bjoern.michaelsen@canonical.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Yes, there are quite a few evil cornercases lurking there. Before changing<br>
those conditionals, I think it is a good idea to just add assertions that make<br>
sure these assumptions are kept consistent all the time. A start would be to<br>
check that when an item is put in the set, to check:<br>
- If it has a non-zero Which-Id<br>
- and is not a SfxVoidItem<br>
any client code that does something different (even explicitly putting a<br>
SfxVoidItem), is abusing the API and should be fixed by making it call<br>
DisableItem instead). Once you are sure that is cleaned up, one can carefully<br>
go on about changing the conditions. Some care is still needed as in theory,<br>
someone might have e.g. put a non-zero, non-SfxVoidItem and later set the<br>
WhichId on the item to 0.<br></blockquote><div> <br>after a break I found sometime to hack :)<br>There is one place where SfxVoidItem is used instead of DisableItem function.:<br><a href="http://opengrok.libreoffice.org/xref/core/editeng/source/editeng/eerdll.cxx#150">http://opengrok.libreoffice.org/xref/core/editeng/source/editeng/eerdll.cxx#150</a><br>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">SfxPoolItem** GlobalEditData::GetDefItems()<br>{<br>    if ( !ppDefItems )<br>    {<br>        ppDefItems = new SfxPoolItem*[EDITITEMCOUNT];<br>
<br>        // Paragraph attributes:<br>        SvxNumRule aTmpNumRule( 0, 0, sal_False );<br><br>        ppDefItems[0]  = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );<br>        ppDefItems[1]  = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS );<br>
        ppDefItems[2]  = new SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, sal_False );<br>        ppDefItems[3]  = new SfxBoolItem( EE_PARA_FORBIDDENRULES, sal_True );<br>...<br>        ppDefItems[17] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD, EE_PARA_VER_JUST );<br>
<br>        // Character attributes:<br>        ppDefItems[18] = new SvxColorItem( Color( COL_AUTO ), EE_CHAR_COLOR );<br>        ppDefItems[19] = new SvxFontItem( EE_CHAR_FONTINFO );<br> ...</blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
        ppDefItems[38] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL );<br>        ppDefItems[39] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK );<br>        ppDefItems[40] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL );<br>
        ppDefItems[41] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK );<br>        ppDefItems[42] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL );<br>        ppDefItems[43] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK );<br>
        ppDefItems[44] = new SvxCharReliefItem( RELIEF_NONE, EE_CHAR_RELIEF );<br>        ppDefItems[45] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY );<br>        ppDefItems[46] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS );<br>
        ppDefItems[47] = new SvxOverlineItem( UNDERLINE_NONE, EE_CHAR_OVERLINE );<br><br>        // Features<br>        ppDefItems[48] = new SfxVoidItem( EE_FEATURE_TAB );<br>        ppDefItems[49] = new SfxVoidItem( EE_FEATURE_LINEBR );<br>
        ppDefItems[50] = new SvxCharSetColorItem( Color( COL_RED ), RTL_TEXTENCODING_DONTKNOW, EE_FEATURE_NOTCONV );<br>        ppDefItems[51] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );<br><br>        DBG_ASSERT( EDITITEMCOUNT == 52, "ITEMCOUNT geaendert, DefItems nicht angepasst!" );<br>
<br>        // Init DefFonts:<br>        GetDefaultFonts( *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START],<br>                         *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START],<br>                         *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START] );<br>
    }<br><br>    return ppDefItems;<br>}<br></blockquote><div>What about this? Changing to SvxColorItem crashes CppunitTest_sw_subsequent_odfexport on <br>Program received signal SIGSEGV, Segmentation fault.<br>0x45c4f134 in CharAttribList::InsertAttrib (this=0x8676b60, pAttrib=0x0) at /home/maciej/programowanie/libreoffice/libo-working/editeng/source/editeng/editdoc.cxx:2661<br>
2661        const sal_uInt16 nStart = pAttrib->GetStart(); // may be better for Comp.Opt.<br>#0  0x45c4f134 in CharAttribList::InsertAttrib (this=0x8676b60, pAttrib=0x0) at /home/maciej/programowanie/libreoffice/libo-working/editeng/source/editeng/editdoc.cxx:2661<br>
#1  0x45c4e7d3 in EditDoc::InsertAttrib (this=0x86766a0, rPoolItem=..., pNode=0x8676b40, nStart=0, nEnd=0) at /home/maciej/programowanie/libreoffice/libo-working/editeng/source/editeng/editdoc.cxx:2473<br>#2  0x45c4e9fb in EditDoc::InsertAttrib (this=0x86766a0, pNode=0x8676b40, nStart=0, nEnd=0, rPoolItem=...) at /home/maciej/programowanie/libreoffice/libo-working/editeng/source/editeng/editdoc.cxx:2515<br>
#3  0x45d07e44 in ImpEditEngine::SetAttribs (this=0x8676630, aSel=..., rSet=..., nSpecial=1 '\001') at /home/maciej/programowanie/libreoffice/libo-working/editeng/source/editeng/impedit5.cxx:551<br><br>because based on ItemState it should be disabled and never go beyond #3. This shows that Item EE_CHAR_RUBI_DUMMY (4036) is by default disabled, and never explicitly with DisableItem function.<br>
<br>Thanks in advance for any help/advice<br><br>Best Regards,<br>    Maciek<br></div></div></div>