Integrating Openoffice -Searching /Replacing string within delimiter

I am trying with an open-office programming.. i load a template which has sections within it.. i can read the contents of the section.. but i failed to search for the contents which are enclosed between the delimiters [...some text.. ].

Pls help me to search the content of the section enclosed within [.*] and to replace it with a new text..

I attach the code which i tried... but its not working.. :-(

Any one pls post the code..

Many thnks..

// For searching string within delimiter

XSearchable xSearchable = (XSearchable) UnoRuntime.queryInterface(XSearchable.class, mxDoc);

XSearchDescriptor xOpenSearchDesc = xSearchable.createSearchDescriptor();

xOpenSearchDesc.setPropertyValue("SearchRegularExpression", new Boolean(true));

xOpenSearchDesc.setPropertyValue("SearchWords",new Boolean(true));

xOpenSearchDesc.setSearchString("[");

XSearchDescriptor xCloseSearchDesc = xSearchable.createSearchDescriptor();

xCloseSearchDesc.setPropertyValue("SearchRegularExpression", new Boolean(true));

xCloseSearchDesc.setPropertyValue("SearchWords",new Boolean(true));

xCloseSearchDesc.setSearchString("]");

XInterface openFinder=(XInterface) xSearchable.findFirst(xOpenSearchDesc);

if(openFinder!=null)

{

XTextRange tr1 = ((XTextRange) UnoRuntime.queryInterface(XTextRange.class, openFinder)).getStart();

XInterface closeFinder=(XInterface) xSearchable.findNext(tr1,xCloseSearchDesc);

if (closeFinder==null)

{

System.out.println("No closing tag!!");

}

else

{

XTextRange tr2 = ((XTextRange) UnoRuntime.queryInterface(XTextRange.class, closeFinder)).getEnd();

//tr1.setString("");

XText xTexts = tr2.getText();

XTextCursor xTextCursor1 =

xTexts. createTextCursorByRange(tr2);

xTextCursor1.gotoRange(tr2,false);

System.out.println("SEARCHING TEST.."+tr2.getString());

}

}

else

System.out.println("String not found!!");

[2068 byte] By [Hema2110a] at [2007-10-3 3:21:23]
# 1
Any body pls reply...
Hema2110a at 2007-7-14 21:13:39 > top of Java-index,Desktop,Deploying...