Index: ap_Dialog_Styles.cpp =================================================================== --- ap_Dialog_Styles.cpp (revision 29473) +++ ap_Dialog_Styles.cpp (working copy) @@ -1010,7 +1010,45 @@ FREEP(props); } +void AP_Dialog_Styles::cullCharStyle() +{ + const static gchar * extraFields[] = {"text-align", "text-indent", "margin-left", "margin-right", + "margin-top", "margin-bottom", "line-height","tabstops","start-value","list-delim", + "list-decimal","list-style","field-font","field-color", "keep-together","keep-with-next", + "orphans","widows","dom-dir","text-indent","default-tab-interval",NULL}; + const gchar **p=extraFields; + while (*p) { + if (m_vecAllProps.getItemCount() <= 2) break; // UGLY hack to prevent empty styles + removeVecProp(*p++); + } +} + +void AP_Dialog_Styles::cullDerivedStyle() +{ + const gchar *base=getAttsVal("basedon"); + if (!base) return; + PD_Style *pStyle; + if (!getLDoc()->getStyle(base,&pStyle)) + return; + if (!pStyle) return; + + const gchar *pVal, *pOwnVal; + + for(int i=0; igetProperty((const gchar *) m_vecAllProps.getNthItem(i), + pVal)) continue; + if (!pVal) continue; + pOwnVal=(const gchar *) m_vecAllProps.getNthItem(i+1); + if (pOwnVal && !strcmpi(pVal,pOwnVal)) { + m_vecAllProps.deleteNthItem(i+1); + m_vecAllProps.deleteNthItem(i); + i-=2; + } + } +} + /*! * Take the current style description and use it to define a new style * in the main document. @@ -1019,6 +1057,14 @@ { UT_DEBUGMSG(("DOM: new style %s\n", szName)); + cullDerivedStyle(); + + const gchar *type=getAttsVal("type"); + + if (*type=='C') { + cullCharStyle(); + } + const gchar ** props = NULL; UT_uint32 i = 0; if(m_vecAllProps.getItemCount() <= 0) @@ -1078,6 +1124,8 @@ */ bool AP_Dialog_Styles::applyModifiedStyleToDoc(void) { + cullDerivedStyle(); + const gchar ** props = NULL; UT_uint32 i = 0; if(m_vecAllProps.getItemCount() <= 0) Index: ap_Dialog_Styles.h =================================================================== --- ap_Dialog_Styles.h (revision 29473) +++ ap_Dialog_Styles.h (working copy) @@ -113,6 +113,9 @@ UT_GenericVector m_vecAllAttribs; private: + void cullCharStyle(); + void cullDerivedStyle(); + XAP_Frame * m_pFrame; FV_View * m_pView; PD_Document * m_pDoc;