Hello:

I was wondering if someone might be able to shed some light on attribute
searching.  I want to search and replace based on a character style.
However I must be missing something .... in the code below, option 1 does
not work but option 2 does work.  The documentation states that "Any
properties contained in the services com.sun.star.style.CharacterProperties,
com.sun.star.style.CharacterPropertiesAsian and
com.sun.star.style.ParagraphProperties can be used for an attribute
search".  This is in Ooo 2.0.4.

Any thoughts on why opt1 does not work?


                       XReplaceable xRepl = (XReplaceable)
UnoRuntime.queryInterface(XReplaceable.class, _xDoc);
                       XReplaceDescriptor replDesc =
xRepl.createReplaceDescriptor();

                       XPropertyReplace replProp =
(XPropertyReplace)UnoRuntime.queryInterface(XPropertyReplace.class,
replDesc);

                       PropertyValue[] aSearchArgs = new PropertyValue[1];
                       aSearchArgs[0] = new PropertyValue();
//opt1                        aSearchArgs[0].Name = "CharStyleName";
//opt2                        aSearchArgs[0].Name = "CharSrikeout";
                       aSearchArgs[0].Value = new String("Test1");

                       PropertyValue[] aReplArgs = new PropertyValue[1];
                       aReplArgs[0] = new PropertyValue();
                       aReplArgs[0].Name = "CharStyleName";
                       aReplArgs[0].Value = new String("Test2");


                       replProp.setSearchAttributes(aSearchArgs);
                       replProp.setReplaceAttributes(aReplArgs);


//opt1                        replProp.setValueSearch(true);
//opt2                        replProp.setValueSearch(false);


                       XInterface xSearchInterface = (XInterface)
xRepl.findFirst(replDesc);

                       while(xSearchInterface != null){
                            XTextRange xSearchTextRange = (
com.sun.star.text.XTextRange)
                               UnoRuntime.queryInterface(
                                   com.sun.star.text.XTextRange.class,
xSearchInterface);
                            xSearchInterface = (XInterface)
xRepl.findNext(xSearchInterface,
replDesc);
                            System.out.println("found text: " +
xSearchTextRange.getString());
                       }

Reply via email to