Buenas,
Lo que quiero decir es que con la prueba que me pasaste(aplicaFormato.odt), no funciona como la brocha:
Las pruebas que hago son:
- Poner el cursos sobre un texto, por ejemplo "leyes".
Pulsar el botón "Crear estilo"
Y al texto leyes se le cambia el estilo, poniendo fondo amarillo.
La brocha no funciona así, funciona:
- Poner el cursos sobre un texto, por ejemplo "leyes".
Pulsar el botón "Crear estilo"
Al texto "leyes" no le hace nada
Seleccionar otro texto
Se le aplica el formato que tiene leyes sobre este nuevo texto.
En cuanto a mi desarrollo, adjunto código fuente:
Código: Seleccionar todo
JButton buttonPincelCopiar;
JButton buttonPincelPegar;
this.buttonPincelCopiar = (JButton)CreadorButton.crearBoton( CreadorButton.TIPO_JBUTTON, true, WeboUI.ICONO_FORMATPAINTBRUSH, null, null, null);
this.buttonPincelPegar = (JButton)CreadorButton.crearBoton( CreadorButton.TIPO_JBUTTON, true, WeboUI.ICONO_FORMATPAINTBRUSH, null, null, null);
this.buttonPincelCopiar.setToolTipText("Copiar formato");
this.buttonPincelCopiar.setEnabled( this.oODocumentoMostrado.getOOConfig().isEdicionPermitida() );
this.buttonPincelPegar.setToolTipText("Pegar formato");
this.buttonPincelPegar.setEnabled( this.oODocumentoMostrado.getOOConfig().isEdicionPermitida() );
this.buttonPincelCopiar.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
OODocumentShow.this.soloCopiarFormato();
}
});
this.buttonPincelPegar.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
OODocumentShow.this.pegarFormato();
}
});
Código: Seleccionar todo
private void pegarFormato()
{
try
{
System.out.println("pegarFormato método............");
this.oODocumentoMostrado.pegarFormato();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog( this.frame,
"Error al copiar",
"WebOffice: Error copiando",
JOptionPane.ERROR_MESSAGE);
System.out.println("· [ Error ] Error al copiar");
ex.printStackTrace();
}
}
private void soloCopiarFormato()
{
try
{
System.out.println("solocopiar método............");
this.oODocumentoMostrado.copiarFormato();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog( this.frame,
"Error al copiar",
"WebOffice: Error copiando",
JOptionPane.ERROR_MESSAGE);
System.out.println("· [ Error ] Error al copiar");
ex.printStackTrace();
}
}
Código: Seleccionar todo
public void copiarFormato() throws OOException
{
System.out.println("copiarFormato en OODOocument.java");
OODocumentEdition oODocumentEdition = new OODocumentEdition();
oODocumentEdition.setDocument(this.xTextDocument);
oODocumentEdition.setCursor(this.xTextCursor);
oODocumentEdition.copiarFormato(this.oODocumentShow.getDispatchHelper(),this.oODocumentShow.getDispatchProvider());
}
public void pegarFormato() throws OOException
{
System.out.println("copyFormat en OODOocument.java");
OODocumentEdition oODocumentEdition = new OODocumentEdition();
oODocumentEdition.setDocument(this.xTextDocument);
oODocumentEdition.setCursor(this.xTextCursor);
oODocumentEdition.pegarFormato(this.oODocumentShow.getDispatchHelper(),this.oODocumentShow.getDispatchProvider());
}
Código: Seleccionar todo
public void copiarFormato(XDispatchHelper xDispatchHelper, XDispatchProvider xDispatchProvider) throws OOException
{
PropertyValue[] args = new PropertyValue[2];
System.out.println("creando propiedades");
args[0] = new PropertyValue();
System.out.println("creada propiedades"+args[0]);
args[0].Name = "Param";
args[0].Value = "miEstilo";
args[1] = new PropertyValue();
args[1].Name = "Family";
args[1].Value =1;
xDispatchHelper.executeDispatch(xDispatchProvider,".uno:StyleNewByExample", "", 0, args);
}
public void pegarFormato(XDispatchHelper xDispatchHelper, XDispatchProvider xDispatchProvider) throws OOException
{
PropertyValue[] args = new PropertyValue[2];
args[0] = new PropertyValue();
args[0].Name = "Template";
args[0].Value ="miEstilo";
args[1] = new PropertyValue();
args[1].Name = "Family";
args[1].Value ="1";
xDispatchHelper.executeDispatch(xDispatchProvider, ".uno:StyleUpdateByExample", "", 0, args);
}
Probando con este código, a veces se entera del estilo, pero lo aplica raro.
Podrías indicarme cómo haces las pruebas? Igual estoy haciendo algo mal...
Saludos.