continue;\r
}\r
\r
+ int tSize = 0;\r
+\r
aSize = annotations[a].annotations.length;\r
if(insert)\r
temp = new Annotation[aSize + command.number];\r
{\r
if(command.position<aSize)\r
{\r
- if (aSize - command.number + command.position > 0)\r
- temp = new Annotation[aSize - command.number + command.position];\r
+ if(command.position+command.number>aSize)\r
+ tSize = aSize;\r
else\r
- temp = new Annotation[aSize];\r
+ tSize = aSize - command.number + command.position;\r
}\r
else\r
- temp = new Annotation[aSize];\r
+ tSize = aSize;\r
+\r
+ if(tSize<0)\r
+ tSize = aSize;\r
+\r
+ temp = new Annotation[tSize];\r
+\r
}\r
\r
if(insert)\r
aSize - command.position);\r
}\r
else\r
- temp = annotations[a].annotations;\r
+ {\r
+ if (command.deletedAnnotations != null\r
+ &&\r
+ command.deletedAnnotations.containsKey(annotations[a].annotationId))\r
+ {\r
+ Annotation[] restore = (Annotation[])\r
+ command.deletedAnnotations.get(annotations[a].annotationId);\r
+\r
+ temp = new Annotation[annotations[a].annotations.length+\r
+ restore.length];\r
+ System.arraycopy(annotations[a].annotations,\r
+ 0,temp,0,\r
+ annotations[a].annotations.length);\r
+ System.arraycopy(restore,0,temp,annotations[a].annotations.length,restore.length);\r
+ }\r
+ else\r
+ temp = annotations[a].annotations;\r
+ }\r
}\r
else\r
{\r
- if(command.position < aSize && aSize - command.number+command.position>0)\r
+ if(tSize!=aSize)\r
{\r
System.arraycopy(annotations[a].annotations,\r
0, temp, 0, command.position);\r
aSize - command.position - command.number);\r
}\r
else\r
- temp = annotations[a].annotations;\r
+ {\r
+ int dSize = aSize - command.position;\r
+\r
+ if(dSize>0)\r
+ {\r
+ Annotation[] deleted = new Annotation[command.number];\r
+ System.arraycopy(annotations[a].annotations,\r
+ command.position, deleted, 0, dSize);\r
+\r
+ command.deletedAnnotations.put(annotations[a].annotationId,\r
+ deleted);\r
+\r
+ tSize = Math.min(annotations[a].annotations.length, command.position);\r
+ temp = new Annotation[tSize];\r
+ System.arraycopy(annotations[a].annotations,\r
+ 0, temp, 0, tSize);\r
+ }\r
+ else\r
+ temp = annotations[a].annotations;\r
+ }\r
}\r
\r
annotations[a].annotations = temp;\r