Custom formats

Nov 2, 2015 at 8:45 AM
if you change the below function, the custom formats will work
public static UInt32Value GetNumberingFormatIndex(this NumberingFormat numberingFormat, Stylesheet styleSheet)
        {
            // adding a custom numbering format does not appear to work.
            // stick with the predefined ones

            string outerXML = numberingFormat.OuterXml;
            bool hasNumFmtID = numberingFormat.NumberFormatId != null;

            UInt32Value index = 164U;
            UInt32Value maxNumFmtID = 0;

            foreach (NumberingFormat f in styleSheet.NumberingFormats.ToList())
            {
                if (f.OuterXml.Equals(outerXML))
                    return f.NumberFormatId.Value;

                if (hasNumFmtID && f.NumberFormatId.Value == numberingFormat.NumberFormatId.Value)
                    return f.NumberFormatId.Value;

                if (f.FormatCode.Value == numberingFormat.FormatCode.Value)
                    return f.NumberFormatId.Value;

                maxNumFmtID = Math.Max(maxNumFmtID, f.NumberFormatId);
                index++;
            }

            if (!hasNumFmtID)
                numberingFormat.NumberFormatId = Math.Max(maxNumFmtID, 163U) + 1;

            styleSheet.NumberingFormats.Append(numberingFormat);
           // styleSheet.Save();
            UInt32Value result = styleSheet.NumberingFormats.Count.Value;
            styleSheet.NumberingFormats.Count++;

            return numberingFormat.NumberFormatId;
        }