Bonjour, je suis coincé ...
j'ai un document ouvert dans lequel je recherche des balises. ces balises
signifient que la phrase qui la contient doit être mise à la verticale.
mon prgramme (ci-dessous) recherche la balise mais ne met à la verticale que
le texte de remplacement...
comment sélectionner la phrase entière pour lui attribuer la propriété de
texte vertical ?
XTextDocument xTextDoc =
(com.sun.star.text.XTextDocument)UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
xWriterComponent);
//***********************************************************
// RECHERCHE LA BALISE [VERT] ET RETOURNE LE TEXTE ASSOCIE
//***********************************************************
// ajuster la propriété
short rotation = 900;
short noRotation = 0;
// Create textdocument
XTextCursor xTextCursor = null;
XText xText = (XText)xTextDoc.getText();
xTextCursor = (XTextCursor) xText.createTextCursor();
//recherche la balise [VERT]
XSearchable xSearch = (XSearchable)
UnoRuntime.queryInterface(XSearchable.class, xWriterComponent);
XSearchDescriptor xSearchDesc =
xSearch.createSearchDescriptor();
xSearchDesc.setSearchString("[VERT]");
Object result = xSearch.findFirst(xSearchDesc);
while (result != null)
{
XPropertySet xCPS =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, result);
xCPS.setPropertyValue("CharRotation", new Short (rotation));
result = xSearch.findNext(result, xSearchDesc);
}
//***************************************************************
//RECHERCHE ET REMPLACE LA BALISE [VERT]
//***************************************************************
XReplaceable xReplaceable = (XReplaceable)
UnoRuntime.queryInterface(XReplaceable.class, xWriterComponent);
XReplaceDescriptor xRepDesc =
xReplaceable.createReplaceDescriptor();
// set a string to search for
xRepDesc.setSearchString("[VERT]");
// set the string to be inserted
xRepDesc.setReplaceString("test");
// create an array of one property value for a CharWeight
property
PropertyValue[] aReplaceArgs = new PropertyValue[1];
aReplaceArgs[0] = new PropertyValue();
aReplaceArgs[0].Name = "CharWeight";
aReplaceArgs[0].Value = new Float
(com.sun.star.awt.FontWeight.BOLD);
// set our sequence with one property value as ReplaceAttribute
XPropertyReplace xPropRepl = (XPropertyReplace)
UnoRuntime.queryInterface(XPropertyReplace.class, xRepDesc);
xPropRepl.setReplaceAttributes(aReplaceArgs);
// replace
int nResult = xReplaceable.replaceAll(xRepDesc);
merci par avance...
_________________________________________________________________
Retrouvez tout en un clin d'oeil avec la barre d'outil MSN Search !
http://desktop.msn.fr/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]