Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfaure2016-04-22 16:15:14 +0000
committertfaure2016-04-22 16:15:14 +0000
commita2a35653c74f4883a2068a7b23fdc6522f40243a (patch)
treec4fb546810bfb1d5c2f4c3b40a96eb35c05e6474
parentbb149fe072b0ee8c50d1bd6eb149103b32dbad58 (diff)
downloadorg.eclipse.gendoc-a2a35653c74f4883a2068a7b23fdc6522f40243a.tar.gz
org.eclipse.gendoc-a2a35653c74f4883a2068a7b23fdc6522f40243a.tar.xz
org.eclipse.gendoc-a2a35653c74f4883a2068a7b23fdc6522f40243a.zip
Bug 492264 : empty images generation
when an open tag and a close tag for wpc:bg exists the string is now searched and replace by the reference of the picture Change-Id: I717c2ab4fab11262a14b95f831d35049a8718537 Signed-off-by: tfaure <tristan.faure@atos.net>
-rw-r--r--plugins/org.eclipse.gendoc.services.docx/src/org/eclipse/gendoc/services/docx/DOCXImageService.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/org.eclipse.gendoc.services.docx/src/org/eclipse/gendoc/services/docx/DOCXImageService.java b/plugins/org.eclipse.gendoc.services.docx/src/org/eclipse/gendoc/services/docx/DOCXImageService.java
index 897b276..77347aa 100644
--- a/plugins/org.eclipse.gendoc.services.docx/src/org/eclipse/gendoc/services/docx/DOCXImageService.java
+++ b/plugins/org.eclipse.gendoc.services.docx/src/org/eclipse/gendoc/services/docx/DOCXImageService.java
@@ -17,11 +17,13 @@ package org.eclipse.gendoc.services.docx;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.gendoc.documents.AbstractImageService;
import org.eclipse.gendoc.documents.ImageDimension;
import org.eclipse.gendoc.services.GendocServices;
import org.eclipse.gendoc.services.IGendocDiagnostician;
+import org.eclipse.gendoc.services.ILogger;
import org.eclipse.gendoc.services.exception.AdditionalResourceException;
import org.eclipse.gendoc.tags.ITag;
import org.eclipse.gendoc.tags.handlers.impl.RegisteredTags;
@@ -63,7 +65,24 @@ public class DOCXImageService extends AbstractImageService
Matcher mDraw = pDraw.matcher(newTagContent);
if (mDraw.find())
{
- newTagContent = new StringBuffer(newTagContent.toString().replaceAll("(<wpc:bg/>)", toInsertDraw));
+ // determines if there are wpc:bg
+ if (newTagContent.toString().contains("(<wpc:bg/>)")){
+ newTagContent = new StringBuffer(newTagContent.toString().replaceAll("(<wpc:bg/>)", toInsertDraw));
+ }
+ else {
+ // in some cases the wordprocessor or the user fills some properties of the wpc tag and the document
+ // does not contain <wpc:bg/>
+ Pattern openWpcTag = Pattern.compile("<wpc:bg>.*</wpc:bg>", Pattern.MULTILINE | Pattern.DOTALL);
+ Matcher matcherOpenWpcTag = openWpcTag.matcher(newTagContent.toString());
+ if (matcherOpenWpcTag.find()){
+ newTagContent = new StringBuffer(matcherOpenWpcTag.replaceAll(toInsertDraw));
+ }
+ else {
+ ILogger logger = GendocServices.getDefault().getService(ILogger.class);
+ String tagIdDocx = tag.getAttributes().get(RegisteredTags.ID);
+ logger.log("The execution of tag with id '"+ tagIdDocx +"' is maybe erroneous : problems with insertion\n\tcould not replace <wpc:bg>\n" + newTagContent.toString(), IStatus.WARNING);
+ }
+ }
}
// Manage size for Office 2010 embedded image definition
@@ -72,7 +91,7 @@ public class DOCXImageService extends AbstractImageService
}
catch (AdditionalResourceException e)
{
- IGendocDiagnostician diagnostician =(IGendocDiagnostician)GendocServices.getDefault().getService(IGendocDiagnostician.class);
+ IGendocDiagnostician diagnostician = (IGendocDiagnostician)GendocServices.getDefault().getService(IGendocDiagnostician.class);
String tagIdDocx = tag.getAttributes().get(RegisteredTags.ID);
if (null == tagIdDocx)

Back to the top