Exemple #1
0
 public DocumentController(IHostingEnvironment hostingEnvironment,
                           IDocumentService documentService,
                           IBookmarkService bookmarkService,
                           ITableUtil tableUtil,
                           ITextUtil textUtil,
                           DocumentMapper documentMapper,
                           BookmarkMapper bookmarkMapper,
                           IDocumentCore documentCore,
                           IWordBookmarkParser bookmarkParser)
 {
     _hostingEnvironment = hostingEnvironment;
     _documentService    = documentService;
     _bookmarkService    = bookmarkService;
     _tableUtil          = tableUtil;
     _textUtil           = textUtil;
     _documentMapper     = documentMapper;
     _bookmarkMapper     = bookmarkMapper;
     _documentCore       = documentCore;
     _bookmarkParser     = bookmarkParser;
 }
        public static void GetExtentInfo(this ITextUtil textUtil, int startIndex, int length, out int startLine, out int startLineOffset, out int endLine, out int endLineOffset)
        {
            textUtil.Reset();
            int    lineNumber = 0, charCount = 0, lineCharCount = 0;
            string line;

            while (textUtil.TryReadLine(out line) && charCount < startIndex)
            {
                ++lineNumber;
                charCount    += line.Length;
                lineCharCount = line.Length;
            }

            //We passed the line we want to be on, so back up
            int positionAtEndOfPreviousLine = charCount - lineCharCount;

            startLine       = lineNumber - 1;
            startLineOffset = startIndex - positionAtEndOfPreviousLine;


            while (textUtil.TryReadLine(out line) && charCount < startIndex + length)
            {
                ++lineNumber;
                charCount    += line.Length;
                lineCharCount = line.Length;
            }

            if (line != null)
            {
                positionAtEndOfPreviousLine = charCount - lineCharCount;
                endLineOffset = startIndex + length - positionAtEndOfPreviousLine;
            }
            else
            {
                endLineOffset = lineCharCount;
            }

            endLine = lineNumber - 1;
        }
 public static bool Replace(this ITextUtil util, Range range, string text)
 {
     //Deletes the current bindings elements and move it to the top of the file
     return(util.Delete(range) && util.Insert(range, text, false));
 }