Fix autodetection.
This commit is contained in:
parent
ca5028adce
commit
01f7538122
@ -46,9 +46,23 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
Paragraph start = null;
|
||||
Paragraph end = null;
|
||||
int i = 1;
|
||||
|
||||
if (document.Bookmarks.Exists("Labor"))
|
||||
{
|
||||
i = GetParagraphIndex(
|
||||
document,
|
||||
document.Bookmarks["Labor"].Range.Paragraphs[1]);
|
||||
}
|
||||
|
||||
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];
|
||||
break;
|
||||
@ -87,5 +101,18 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
return (LaurisParagraph.ResemblesLaurisParagraph(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user