]> source.dussan.org Git - poi.git/commitdiff
make code more similar between default case and indexed case
authorJaven O'Neal <onealj@apache.org>
Wed, 19 Oct 2016 06:44:09 +0000 (06:44 +0000)
committerJaven O'Neal <onealj@apache.org>
Wed, 19 Oct 2016 06:44:09 +0000 (06:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765536 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java

index 5d66b30bf6c9b4cc31d482f2217c4e8371f0a1cd..a321faf8f4848bcd5ab6bd3faa997b49d2d24a35 100644 (file)
@@ -559,9 +559,10 @@ public class POIXMLDocumentPart {
         OPCPackage pkg = packagePart.getPackage();
         
         try {
-            if (descriptor.getDefaultFileName().equals(descriptor.getFileName(9999))) {
+            String name = descriptor.getDefaultFileName();
+            if (name.equals(descriptor.getFileName(9999))) {
                 // Non-index based, check if default is free
-                PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getDefaultFileName());
+                PackagePartName ppName = PackagingURIHelper.createPartName(name);
                 if (pkg.containPart(ppName)) {
                     // Default name already taken, not index based, nothing free
                     return -1;
@@ -575,8 +576,9 @@ public class POIXMLDocumentPart {
             int idx = minIdx;
             if (minIdx < 0) idx = 1;
             while (idx < 1000) {
-                String name = descriptor.getFileName(idx);
-                if (!pkg.containPart(PackagingURIHelper.createPartName(name))) {
+                name = descriptor.getFileName(idx);
+                PackagePartName ppName = PackagingURIHelper.createPartName(name);
+                if (!pkg.containPart(ppName)) {
                     return idx;
                 }
                 idx++;