diff options
author | jphillips | 2010-08-25 18:15:44 +0000 |
---|---|---|
committer | jphillips | 2010-08-25 18:15:44 +0000 |
commit | 325ca9a9e2b5ac30342695352cae719dbe58619a (patch) | |
tree | 483b3fdb469f791ca3c5bc37b75886353e239568 | |
parent | 7cb4d7e3258dfefc99ce031e7871dec6e6bf415e (diff) | |
download | org.eclipse.osee-325ca9a9e2b5ac30342695352cae719dbe58619a.tar.gz org.eclipse.osee-325ca9a9e2b5ac30342695352cae719dbe58619a.tar.xz org.eclipse.osee-325ca9a9e2b5ac30342695352cae719dbe58619a.zip |
Fixed issues with bookmark link
3 files changed, 16 insertions, 6 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/word/WordUtilTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/word/WordUtilTest.java index c3f95bb1cb5..2a1d563d474 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/word/WordUtilTest.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/word/WordUtilTest.java @@ -25,7 +25,7 @@ public class WordUtilTest { bookmark = WordUtil.reassignBookMarkID(bookmark); assertEquals( "The bookmark IDs have been reset", - "more content><aml:annotation aml:id=\"10546168\" w:type=\"Word.Bookmark.Start\"/><aml:annotation aml:id=\"1000\" w:type=\"Word.Bookmark.End\"/><Some more content> <aml:annotation aml:id=\"133334\" w:type=\"Word.Bookmark.Start\"/>aml:id=\"1001\" w:type=\"Word.Bookmark.End", + "more content><aml:annotation aml:id=\"1000\" w:type=\"Word.Bookmark.Start\"/><aml:annotation aml:id=\"1000\" w:type=\"Word.Bookmark.End\"/><Some more content> <aml:annotation aml:id=\"1001\" w:type=\"Word.Bookmark.Start\"/>aml:id=\"1001\" w:type=\"Word.Bookmark.End", bookmark); } } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkBuilder.java index 1c54a93b021..3cd20649fc7 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkBuilder.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/linking/OseeLinkBuilder.java @@ -65,7 +65,7 @@ public class OseeLinkBuilder { Random random = new Random(); int idNumber = getValidNumber(random.nextInt(19580427), random); - return String.format(WORDML_BOOKMARK_FORMAT, idNumber, source.getGuid(), idNumber); + return String.format(WORDML_BOOKMARK_FORMAT, 0, source.getGuid(), 0); } private int getValidNumber(int number, Random random) { diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/word/WordUtil.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/word/WordUtil.java index b9d512ee38c..11d5b2a2964 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/word/WordUtil.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/word/WordUtil.java @@ -57,8 +57,10 @@ public class WordUtil { private static final String SELECT_WORD_VALUES = "SELECT attr.content, attr.gamma_id FROM osee_attribute attr, osee_txs txs WHERE attr.art_id=? AND attr.attr_type_id=? AND attr.gamma_id = txs.gamma_id AND txs.branch_id=? ORDER BY attr.gamma_id DESC"; private static final Matcher binIdMatcher = Pattern.compile("wordml://(.+?)[.]").matcher(""); - private static final Matcher bookMarkIdMatcher = + private static final Matcher bookMarkIdEndMatcher = Pattern.compile("aml:id=\"(\\d+)\" w:type=\"Word.Bookmark.End").matcher("");// + private static final Matcher bookMarkIdStartMatcher = Pattern.compile( + "aml:id=\"(\\d+)\" w:type=\"Word.Bookmark.Start").matcher("");// private static final Pattern tagKiller = Pattern.compile("<.*?>", Pattern.DOTALL | Pattern.MULTILINE); private static final Pattern paragraphPattern = Pattern.compile("<w:p( .*?)?>"); private static int bookMarkId = 1000; @@ -75,11 +77,19 @@ public class WordUtil { ChangeSet changeSet = new ChangeSet(content); boolean atLeastOneMatch = false; String toReturn = content; - bookMarkIdMatcher.reset(content); + bookMarkIdEndMatcher.reset(content); + bookMarkIdStartMatcher.reset(content); - while (bookMarkIdMatcher.find()) { + while (bookMarkIdStartMatcher.find()) { atLeastOneMatch = true; - changeSet.replace(bookMarkIdMatcher.start(1), bookMarkIdMatcher.end(1), String.valueOf(bookMarkId++)); + int newId = bookMarkId++; + changeSet.replace(bookMarkIdStartMatcher.start(1), bookMarkIdStartMatcher.end(1), String.valueOf(newId)); + + if (bookMarkIdEndMatcher.find(bookMarkIdStartMatcher.end(1))) { + changeSet.replace(bookMarkIdEndMatcher.start(1), bookMarkIdEndMatcher.end(1), String.valueOf(newId)); + } else { + System.err.println("Error"); + } } if (atLeastOneMatch) { toReturn = changeSet.toString(); |