Ajustes na formatação das listas(ol e ul)

parent ef4723f8
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java/mprj/doerj/caderno/util/CadernoUtil.java=UTF-8
encoding/build.gradle=UTF-8 encoding/build.gradle=UTF-8
...@@ -73,6 +73,8 @@ ...@@ -73,6 +73,8 @@
</div> </div>
<liferay-ui:error key="erroDataNula" message="Uma data deve ser selecionada." /> <liferay-ui:error key="erroDataNula" message="Uma data deve ser selecionada." />
</div> </div>
<input type="checkbox" name="delimitador" id="delimitador" label="" />
<span style="font-weight: bold;">Inserir delimitador entre as matrias.</span>
<aui:button-row> <aui:button-row>
<aui:button type="reset" id="limparFormDO" name="limparFormDO" value="Limpar" /> <aui:button type="reset" id="limparFormDO" name="limparFormDO" value="Limpar" />
<aui:button type="submit" id="enviarFormDO" name="enviarFormDO" value="Gerar Caderno"/> <aui:button type="submit" id="enviarFormDO" name="enviarFormDO" value="Gerar Caderno"/>
......
package mprj.doerj.caderno.application.model;
public class Lista {
private Long posicaoOl;
private Long ilvl;
public Long getPosicaoOl() {
return posicaoOl;
}
public void setPosicaoOl(Long posicaoOl) {
this.posicaoOl = posicaoOl;
}
public Long getIlvl() {
return ilvl;
}
public void setIlvl(Long ilvl) {
this.ilvl = ilvl;
}
}
...@@ -132,6 +132,7 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet { ...@@ -132,6 +132,7 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet {
String dataDivulgacao = ParamUtil.getString(actionRequest, "dataP"); String dataDivulgacao = ParamUtil.getString(actionRequest, "dataP");
String idStatus = ParamUtil.getString(actionRequest, "situacao"); String idStatus = ParamUtil.getString(actionRequest, "situacao");
String delimitador = ParamUtil.getString(actionRequest, "delimitador");
JSONArray listaConteudos = new JSONArray(); JSONArray listaConteudos = new JSONArray();
RestServices rest = new RestServices(); RestServices rest = new RestServices();
...@@ -142,7 +143,7 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet { ...@@ -142,7 +143,7 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet {
if(!mensagensDeErro(listaConteudos, dataDivulgacao, actionRequest)){ if(!mensagensDeErro(listaConteudos, dataDivulgacao, actionRequest)){
GeraCaderno caderno = new GeraCaderno(); GeraCaderno caderno = new GeraCaderno();
caderno.processaCaderno(actionRequest, actionResponse,listaConteudos,dataDivulgacao); caderno.processaCaderno(actionRequest, actionResponse,listaConteudos,dataDivulgacao,delimitador);
//SessionMessages.add(actionRequest, "sucessoMessage"); //SessionMessages.add(actionRequest, "sucessoMessage");
......
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ import java.util.List;
import org.docx4j.openpackaging.exceptions.Docx4JException; import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart; import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart;
import org.docx4j.wml.CTLanguage;
import org.docx4j.wml.HpsMeasure; import org.docx4j.wml.HpsMeasure;
import org.docx4j.wml.RFonts; import org.docx4j.wml.RFonts;
import org.docx4j.wml.RPr; import org.docx4j.wml.RPr;
...@@ -30,14 +31,14 @@ public class Estilos { ...@@ -30,14 +31,14 @@ public class Estilos {
"Hello World! This title is now in Arial."); "Hello World! This title is now in Arial.");
wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Subtitle", wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Subtitle",
"Subtitle, this subtitle is now Arial too"); "Subtitle, this subtitle is now Arial too");
wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading1", wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("TituloDoeMPRJ",
"As is Heading1"); "As is Heading1");
wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading2", wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("SubtituloDOe-MPRJ",
"Heading2 is now Arial, no longer bold and has an underline " + "Heading2 is now Arial, no longer bold and has an underline " +
"and fontsize 12"); "and fontsize 12");
wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading3", wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading3",
"Heading3 is now Arial"); "Heading3 is now Arial");
wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Normal", wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("CorpoDoeMPRJ-Materia",
"And normal text has changed to Arial and fontsize 10"); "And normal text has changed to Arial and fontsize 10");
wordMLPackage.save(new java.io.File("C:/Users/diogo.souza/Documents/Caderno DO/HelloWord12.docx") ); wordMLPackage.save(new java.io.File("C:/Users/diogo.souza/Documents/Caderno DO/HelloWord12.docx") );
...@@ -61,11 +62,11 @@ public class Estilos { ...@@ -61,11 +62,11 @@ public class Estilos {
List<Style> stylesList = styles.getStyle(); List<Style> stylesList = styles.getStyle();
for (Style style : stylesList) { for (Style style : stylesList) {
if (style.getStyleId().equals("Normal")) { if (style.getStyleId().equals("CorpoDoeMPRJ-Materia")) {
alterNormalStyle(style); alterNormalStyle(style);
} else if (style.getStyleId().equals("Heading2")) { } else if (style.getStyleId().equals("SubtituloDOe-MPRJ")) {
alterHeading2Style(style); alterHeading2Style(style);
} else if (style.getStyleId().equals("Heading1") || } else if (style.getStyleId().equals("TituloDoeMPRJ") ||
style.getStyleId().equals("Heading3") || style.getStyleId().equals("Heading3") ||
style.getStyleId().equals("Title") || style.getStyleId().equals("Title") ||
style.getStyleId().equals("Subtitle")) { style.getStyleId().equals("Subtitle")) {
...@@ -108,6 +109,9 @@ public class Estilos { ...@@ -108,6 +109,9 @@ public class Estilos {
RPr rpr = new RPr(); RPr rpr = new RPr();
changeFontToSpranq(rpr); changeFontToSpranq(rpr);
changeFontSize(rpr, 20); changeFontSize(rpr, 20);
CTLanguage lang = new CTLanguage();
lang.setVal("pt-BR");
rpr.setLang(lang);
style.setRPr(rpr); style.setRPr(rpr);
} }
......
package mprj.doerj.caderno.util; package mprj.doerj.caderno.util;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ContentTypes; import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.PortalUtil; import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.util.WebKeys;
...@@ -16,7 +12,9 @@ import java.io.IOException; ...@@ -16,7 +12,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import javax.portlet.ActionRequest; import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse; import javax.portlet.ActionResponse;
...@@ -27,17 +25,23 @@ import javax.servlet.http.HttpServletResponse; ...@@ -27,17 +25,23 @@ import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.docx4j.XmlUtils;
import org.docx4j.convert.in.xhtml.FormattingOption;
import org.docx4j.convert.in.xhtml.XHTMLImporterImpl;
import org.docx4j.openpackaging.exceptions.Docx4JException; import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart; import org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import mprj.doerj.caderno.application.model.Lista;
public class GeraCaderno { public class GeraCaderno {
public void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao) throws Docx4JException, JAXBException, IOException, ParseException, PortalException{ public void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao,String delimitador) throws Docx4JException, JAXBException, IOException, ParseException, PortalException{
...@@ -53,6 +57,7 @@ public class GeraCaderno { ...@@ -53,6 +57,7 @@ public class GeraCaderno {
String conteudo=""; String conteudo="";
String orgao=""; String orgao="";
String titulo=""; String titulo="";
String idMateria="";
PortletPreferences prefs = actionRequest.getPreferences(); PortletPreferences prefs = actionRequest.getPreferences();
CadernoUtil util = new CadernoUtil(); CadernoUtil util = new CadernoUtil();
MainDocumentPart currentDocumentPart = null; MainDocumentPart currentDocumentPart = null;
...@@ -89,9 +94,9 @@ public class GeraCaderno { ...@@ -89,9 +94,9 @@ public class GeraCaderno {
//Cria o hash map com as variveis para substuio dos dados dos cabealhos e expediente //Cria o hash map com as variveis para substuio dos dados dos cabealhos e expediente
HashMap<String, String> variables = new HashMap<String, String>(); HashMap<String, String> variables = new HashMap<String, String>();
variables.put("edicao", edicao); variables.put("edi", edicao);
variables.put("disponibilizacao", disponibilizacao); variables.put("dis", disponibilizacao);
variables.put("publicacao", publicacao); variables.put("pub", publicacao);
String PGJ = prefs.getValue("PGJConfig", ""); String PGJ = prefs.getValue("PGJConfig", "");
variables.put("PGJ", PGJ); variables.put("PGJ", PGJ);
...@@ -175,12 +180,12 @@ public class GeraCaderno { ...@@ -175,12 +180,12 @@ public class GeraCaderno {
mainPart.variableReplace(variables); mainPart.variableReplace(variables);
Estilos estilo = new Estilos(); // Estilos estilo = new Estilos();
estilo.alterStyleSheet(acumuladoPackage); //estilo.alterStyleSheet(acumuladoPackage);
WordprocessingMLPackage firstPagePackage = WordprocessingMLPackage.createPackage(); WordprocessingMLPackage firstPagePackage = WordprocessingMLPackage.createPackage();
boolean firstPage=true; boolean firstPage=true;
List<Lista> listaOls = new ArrayList<Lista>();
//faz a leitura da listagem de todos os contedos recebidos pelo servio Rest //faz a leitura da listagem de todos os contedos recebidos pelo servio Rest
for(int i=0;i<listaConteudos.length();i++){ for(int i=0;i<listaConteudos.length();i++){
...@@ -195,13 +200,15 @@ public class GeraCaderno { ...@@ -195,13 +200,15 @@ public class GeraCaderno {
titulo = obj.get("NOME").toString(); titulo = obj.get("NOME").toString();
titulo = util.tratarString(titulo,"titulo"); titulo = util.tratarString(titulo,"titulo");
conteudo = obj.get("CONTEUDO").toString(); conteudo = obj.get("CONTEUDO").toString();
idMateria=obj.get("IDMATERIA").toString();
conteudo=util.tratarString(conteudo,"conteudo"); conteudo=util.tratarString(conteudo,"conteudo");
conteudo=util.tratarLista(conteudo);
wordCurrentPackage = util.ConverterHTML(conteudo,orgao,titulo,actionRequest); //listaOls.addAll(util.retornarOls(conteudo));
wordCurrentPackage = util.ConverterHTML(conteudo,orgao,titulo,idMateria,delimitador,actionRequest);
currentDocumentPart = wordCurrentPackage.getMainDocumentPart(); currentDocumentPart = wordCurrentPackage.getMainDocumentPart();
acumuladoPackage.getMainDocumentPart().getContent().addAll(currentDocumentPart.getContent()); acumuladoPackage.getMainDocumentPart().getContent().addAll(currentDocumentPart.getContent());
wordCurrentPackage = null; wordCurrentPackage = null;
...@@ -211,15 +218,24 @@ public class GeraCaderno { ...@@ -211,15 +218,24 @@ public class GeraCaderno {
MainDocumentPart acumuladoDocumentPart = acumuladoPackage.getMainDocumentPart(); MainDocumentPart acumuladoDocumentPart = acumuladoPackage.getMainDocumentPart();
estilo.alterStyleSheet(templatePackage); // estilo.alterStyleSheet(templatePackage);
/*XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(templatePackage);
XHTMLImporter.setParagraphFormatting(FormattingOption.CLASS_PLUS_OTHER);*/
templatePackage.getMainDocumentPart().getContent().addAll(acumuladoDocumentPart.getContent()); templatePackage.getMainDocumentPart().getContent().addAll(acumuladoDocumentPart.getContent());
util.ORGAO=""; util.ORGAO="";
util.TITULO=""; util.TITULO="";
//File exportFile = new File("C:/Users/diogo.souza/Documents/Caderno DO/testeDoc4JNovo.docx"); //File exportFile = new File("C:/Users/diogo.souza/Documents/Caderno DO/testeDoc4JNovo.docx");
String dataNomeArquivo = dataDivulgacao.replace("/", "-"); String dataNomeArquivo = dataDivulgacao.replace("/", "-");
String nomeArquivo="caderno_doerj_" + dataNomeArquivo + ".docx";
String nomeArquivo="";
if (delimitador.equals("on")) {
nomeArquivo="caderno_doerj_" + dataNomeArquivo + "_materia_delimitada.docx";
}else {
nomeArquivo="caderno_doerj_" + dataNomeArquivo + ".docx";
}
// InputStream nomeArquivoInputStream = getClass().getResourceAsStream("/META-INF/resources/template/"+nomeArquivo); // InputStream nomeArquivoInputStream = getClass().getResourceAsStream("/META-INF/resources/template/"+nomeArquivo);
// File exportFile = new File(nomeArquivoInputStream.toString()); // File exportFile = new File(nomeArquivoInputStream.toString());
...@@ -228,11 +244,20 @@ public class GeraCaderno { ...@@ -228,11 +244,20 @@ public class GeraCaderno {
File exportFile = File.createTempFile("caderno_doerj_tmp_", ".docx"); File exportFile = File.createTempFile("caderno_doerj_tmp_", ".docx");
try { try {
CadernoUtil caderno = new CadernoUtil();
//templatePackage = caderno.formatarListas(templatePackage,listaOls);
//acumuladoPackage = caderno.formatarListas(acumuladoPackage,listaOls);
//NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
//templatePackage.getMainDocumentPart().addTargetPart(ndp);
//ndp.getInd(String.valueOf(10),String.valueOf(0));
//ndp.unmarshalDefaultNumbering();
//ndp.restart(1, 0, 1);
System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true));
templatePackage.save(exportFile); templatePackage.save(exportFile);
//acumuladoPackage.save(exportFile);
PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse); PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse);
HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse); HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse);
...@@ -259,11 +284,23 @@ public class GeraCaderno { ...@@ -259,11 +284,23 @@ public class GeraCaderno {
} }
} }
catch (Exception e) {
e.printStackTrace();
exportFile.delete();
CadernoUtil caderno = new CadernoUtil();
caderno.QTD_LISTAS=0L;
}
finally { finally {
exportFile.delete(); exportFile.delete();
CadernoUtil caderno = new CadernoUtil();
caderno.QTD_LISTAS=0L;
} }
} }
} }
...@@ -73,6 +73,8 @@ ...@@ -73,6 +73,8 @@
</div> </div>
<liferay-ui:error key="erroDataNula" message="Uma data deve ser selecionada." /> <liferay-ui:error key="erroDataNula" message="Uma data deve ser selecionada." />
</div> </div>
<input type="checkbox" name="delimitador" id="delimitador" label="" />
<span style="font-weight: bold;">Inserir delimitador entre as matrias.</span>
<aui:button-row> <aui:button-row>
<aui:button type="reset" id="limparFormDO" name="limparFormDO" value="Limpar" /> <aui:button type="reset" id="limparFormDO" name="limparFormDO" value="Limpar" />
<aui:button type="submit" id="enviarFormDO" name="enviarFormDO" value="Gerar Caderno"/> <aui:button type="submit" id="enviarFormDO" name="enviarFormDO" value="Gerar Caderno"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment