Fix autodetection.

This commit is contained in:
Daniel Kraus 2015-09-04 11:34:14 +02:00
parent ca5028adce
commit 01f7538122
1 changed files with 28 additions and 1 deletions

View File

@ -46,9 +46,23 @@ namespace zaaReloaded2.Importer.ZaaImporter
Paragraph start = null; Paragraph start = null;
Paragraph end = null; Paragraph end = null;
int i = 1; int i = 1;
if (document.Bookmarks.Exists("Labor"))
{
i = GetParagraphIndex(
document,
document.Bookmarks["Labor"].Range.Paragraphs[1]);
}
while (i <= document.Paragraphs.Count) while (i <= document.Paragraphs.Count)
{ {
if (IsLabParagraph(document.Paragraphs[i])) // Expect the first paragraph of a Lauris block to be
// a time stamp. This prevents erroneous detection of
// lines such as "Tel. (09 31) 201-39432; -39126", which
// happen to structurally resemble a paragraph with
// laboratory items.
if (LaurisTimePoint.IsTimeStampLine(
document.Paragraphs[i].Range.Text))
{ {
start = document.Paragraphs[i]; start = document.Paragraphs[i];
break; break;
@ -87,5 +101,18 @@ namespace zaaReloaded2.Importer.ZaaImporter
return (LaurisParagraph.ResemblesLaurisParagraph(text) return (LaurisParagraph.ResemblesLaurisParagraph(text)
|| LaurisTimePoint.IsTimeStampLine(text)); || LaurisTimePoint.IsTimeStampLine(text));
} }
/// <summary>
/// Returns the index of a paragraph.
/// </summary>
/// <remarks>
/// http://word.mvps.org/faqs/macrosvba/GetIndexNoOfPara.htm
/// </remarks>
/// <param name="paragraph">Paragraph whose index to return.</param>
/// <returns>Index of the paragraph.</returns>
private static int GetParagraphIndex(Document document, Paragraph paragraph)
{
return document.Range(0, paragraph.Range.Start).Paragraphs.Count;
}
} }
} }