/// ------------------------------------------------------------------------------------ /// <summary> /// Fills the style table and populates the list based on it. /// </summary> /// ------------------------------------------------------------------------------------ private void FillStyleList() { m_styleTable.Clear(); for (int i = 0; i < m_styleSheet.CStyles; i++) { var style = m_styleSheet.get_NthStyleObject(i); if (m_applicableStyleContexts == null || m_applicableStyleContexts.Contains(style.Context)) { m_styleTable.Add(style.Name, new StyleInfo(style)); } } if (m_fCanApplyCharacterStyle && !m_fCanApplyParagraphStyle) { m_styleListHelper.ShowOnlyStylesOfType = StyleType.kstCharacter; } else if (m_fCanApplyParagraphStyle && !m_fCanApplyCharacterStyle) { m_styleListHelper.ShowOnlyStylesOfType = StyleType.kstParagraph; } else if (!m_fCanApplyCharacterStyle && !m_fCanApplyParagraphStyle) { throw new InvalidOperationException("Can't show the Apply Style dialog box if neither character nor paragraph styles can be applied."); } else { m_styleListHelper.ShowOnlyStylesOfType = StyleType.kstLim; } m_styleListHelper.AddStyles(m_styleTable, null); m_styleListHelper.Refresh(); }