Skip to content

Commit

Permalink
Fix some issues with editing the first footnote in a document
Browse files Browse the repository at this point in the history
I think this happened for documents with one or more in-text citation
and a footnote located at the end of the document
  • Loading branch information
simonster committed Apr 21, 2014
1 parent 1e34187 commit 27d8b24
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions build/zoteroWinWordIntegration/zoteroWinWordDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ NS_IMETHODIMP zoteroWinWordDocument::CursorInField(const char *fieldType, zotero
CFields rangeFields = selection.get_Fields();
long selectionStart = selection.get_Start();
long selectionEnd = selection.get_End();
long selectionStoryType = selection.get_StoryType();

long rangeFieldCount = rangeFields.get_Count();
if(!rangeFieldCount) {
Expand All @@ -240,33 +241,19 @@ NS_IMETHODIMP zoteroWinWordDocument::CursorInField(const char *fieldType, zotero
rangeEnd = rangeEnd.GoToNext(7); // go to next field

// might only be one field in the entire doc
long rangeStartIndex = range.get_Start();
long rangeEndIndex = rangeEnd.get_Start();
if(range.get_Start() == rangeEndIndex) {
long storyType = range.get_StoryType();
if(storyType == 2) {
CFootnotes notes = selectionRange.get_Footnotes();
long nNotes = notes.get_Count();
CFootnote startNote = notes.Item(1);
CFootnote endNote = notes.Item(nNotes);
range = startNote.get_Range();
range = range.get_Duplicate();
rangeEnd = endNote.get_Range();
rangeEndIndex = rangeEnd.get_End();
} else if(storyType == 3) {
CEndnotes notes = selectionRange.get_Endnotes();
long nNotes = notes.get_Count();
CEndnote startNote = notes.Item(1);
CEndnote endNote = notes.Item(nNotes);
range = startNote.get_Range();
range = range.get_Duplicate();
rangeEnd = endNote.get_Range();
rangeEndIndex = rangeEnd.get_End();
} else {
range = range.GoToPrevious(3); // move a line back
if(rangeStartIndex == selectionStart ||
rangeEndIndex == selectionEnd) {
CStoryRanges storyRanges = comDoc.get_StoryRanges();
CRange storyRange = storyRanges.Item(selectionStoryType);
range = storyRange.get_Duplicate();
if(rangeStartIndex != selectionStart) {
range.put_Start(rangeStartIndex);
}
if(rangeEndIndex == selectionEnd) {
rangeEndIndex = range.get_End();
}
}
if(rangeEndIndex < selectionEnd) {
rangeEndIndex = selectionEnd; // span at least to selection end
}

// make range span from previous field to next field
Expand Down Expand Up @@ -296,10 +283,11 @@ NS_IMETHODIMP zoteroWinWordDocument::CursorInField(const char *fieldType, zotero
long testFieldEnd = testFieldResult.get_End();

// if there is no overlap, continue
if((testFieldStart > selectionStart && testFieldEnd > selectionEnd
&& testFieldStart > selectionEnd && testFieldEnd > selectionEnd)
|| (testFieldStart < selectionStart && testFieldEnd < selectionEnd
&& testFieldStart < selectionEnd && testFieldEnd < selectionEnd)) continue;
if(testFieldCode.get_StoryType() != selectionStoryType ||
(testFieldStart > selectionStart && testFieldEnd > selectionEnd &&
testFieldStart > selectionEnd && testFieldEnd > selectionEnd) ||
(testFieldStart < selectionStart && testFieldEnd < selectionEnd &&
testFieldStart < selectionEnd && testFieldEnd < selectionEnd)) continue;

// otherwise, check for an appropriate code
if(testFieldCodeText.Find(FIELD_PREFIX) != -1
Expand Down
Binary file modified components-26.0/zoteroWinWordIntegration.dll
Binary file not shown.
Binary file modified components-27.0/zoteroWinWordIntegration.dll
Binary file not shown.
Binary file modified components-28.0/zoteroWinWordIntegration.dll
100644 → 100755
Binary file not shown.

0 comments on commit 27d8b24

Please sign in to comment.