Пример #1
0
        private static void CacheItem(
            int numberingInstanceId,
            ParagraphStateCache cache,
            List <int> vector,
            NumberItem item)
        {
            var targetedIdentationLevel = item.IndentationLevel;
            var currentIndentationLevel = vector.Count - 1;

            if (targetedIdentationLevel <= currentIndentationLevel)
            {
                vector[targetedIdentationLevel]++;
                if (targetedIdentationLevel < currentIndentationLevel)
                {
                    vector.RemoveRange(targetedIdentationLevel + 1, vector.Count - targetedIdentationLevel - 1);
                }
            }
            else
            {
                while (vector.Count <= item.IndentationLevel)
                {
                    vector.Add(0);
                }
            }

            var itemVector = new int[vector.Count];

            vector.CopyTo(itemVector);

            cache.Add(item.Paragraph, new ParagraphState
            {
                Indentations        = itemVector,
                NumberingInstanceId = numberingInstanceId
            });
        }
Пример #2
0
        public ParagraphStateCache Create()
        {
            var cache = new ParagraphStateCache();

            CacheNumberLists(cache);
            return(cache);
        }
Пример #3
0
 private void Initialize()
 {
     try
     {
         _nconfCache  = new ConfigCache(_numbering, _styles, new ConfigFactory());
         _pstateCache = new ParagraphStateCacheFactory(_styles, _body).Create();
     }
     catch { }
 }
Пример #4
0
 private void Initialize()
 {
     try
     {
         _nconfCache = new ConfigCache(_numbering, _styles, new ConfigFactory());
         var fac = new ParagraphStateCacheFactory
         {
             Body = _body,
             Styles = _styles,
             Numbering = _numbering
         };
         _pstateCache = fac.Create();
     }
     catch { }
 }
Пример #5
0
        private void CacheNumberLists(ParagraphStateCache cache)
        {
            foreach (var numberList in NumberLists)
            {
                //  Parallel.ForEach(NumberLists, numberList =>
                //{
                var vector = new List <int>();

                foreach (var item in numberList.Items)
                {
                    CacheItem(numberList.NumberingInstanceId, cache, vector, item);
                }
                //});
            }
        }