Class WriteSearchReplace
- class ooodev.write.search.write_search_replace.WriteSearchReplace(doc, desc)[source]
Bases:
WriteDocPropPartial
,PropertyReplaceComp
,LoInstPropsPartial
Represents a writer search.
New in version 0.30.0.
- Parameters:
doc (WriteDoc) –
desc (XPropertyReplace) –
- __init__(doc, desc)[source]
Constructor
- Parameters:
doc (WriteDoc) – doc that owns this component.
desc (com.sun.star.util.XPropertyReplace) –
- Return type:
None
- add_event_property_change(name, cb)
Adds a listener for an event.
Event is invoked when property is changed.
The callback
EventArgs.event_data
will contain acom.sun.star.beans.PropertyChangeEvent
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_event_property_change_events_disposing(name, cb)
Adds a listener for an event.
Event is invoked when the property listener is about to be disposed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.lang.EventObject
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_event_vetoable_change(name, cb)
Adds a listener for an event.
Event is invoked when property is changed.
The callback
EventArgs.event_data
will contain acom.sun.star.beans.PropertyChangeEvent
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_event_vetoable_change_events_disposing(name, cb)
Adds a listener for an event.
Event is invoked when the property listener is about to be disposed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.lang.EventObject
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_property_change_listener(name, listener)
Adds a listener for property changes.
- Parameters:
name (str) – The name of the property.
listener (Any) – The listener to be added.
- Return type:
None
- add_vetoable_change_listener(name, listener)
Adds a listener for vetoable changes.
- Parameters:
name (str) – The name of the property.
listener (Any) – The listener to be added.
- Return type:
None
- find_all()[source]
Searches the contained texts for all occurrences of whatever is specified.
- Returns:
The found occurrences.
- Return type:
WriteTextRanges | None
- find_first()[source]
Finds the first occurrence of the search string.
- Returns:
XInterface or None.
- Return type:
XInterface | None
- find_next(start)[source]
Finds the first occurrence of the search string.
- Parameters:
start (XInterface | ComponentT) – Start position. Any object that supports
XInterface
or an object that has a Component that supportsXInterface
.- Returns:
XInterface or None.
- Return type:
XInterface | None
- get_property_set_info()
Returns the property set info.
- Returns:
The property set info.
- Return type:
XPropertySetInfo
- get_property_value(name)
Returns the value of a property.
- Parameters:
name (str) – The name of the property.
- Returns:
The value of the property.
- Return type:
Any
- get_replace_attributes()
Gets the properties to replace the found occurrences.
- Return type:
Tuple
[PropertyValue
,...
]
- get_replace_string()
Gets the string which replaces the found occurrences.
- Return type:
str
- get_search_attributes()
Get the search attributes.
- Return type:
Tuple
[PropertyValue
,...
]
- get_search_string()
Gets the string of characters to look for.
- Return type:
str
- get_value_search()
provides the information if specific property values are searched, or just the existence of the specified properties.
- Return type:
bool
- remove_event_property_change(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_event_property_change_events_disposing(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_event_vetoable_change(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_event_vetoable_change_events_disposing(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_property_change_listener(name, listener)
Removes a listener for property changes.
- Parameters:
name (str) – The name of the property.
listener (Any) – The listener to be removed.
- Return type:
None
- remove_vetoable_change_listener(name, listener)
Removes a listener for vetoable changes.
- Parameters:
name (str) – The name of the property.
listener (Any) – The listener to be removed.
- Return type:
None
- replace_all()[source]
Replaces all occurrences of old_words with new_words.
old_words
andnew_words
must be the same length.- Parameters:
old_words (Sequence[str]) – Sequence of words to be replaced. Can be a sequence of regular expressions if
search_regular_expression
is True.new_words (Sequence[str]) – Sequence of words to replace with.
- Returns:
The number of replacements.
- Return type:
int
- replace_words(old_words, new_words)[source]
Replaces all occurrences of old_words with new_words.
old_words
andnew_words
must be the same length.- Parameters:
old_words (Sequence[str]) – Sequence of words to be replaced. Can be a sequence of regular expressions if
search_regular_expression
is True.new_words (Sequence[str]) – Sequence of words to replace with.
- Returns:
The number of replacements.
- Return type:
int
- set_property_value(name, value)
Sets the value of a property.
- Parameters:
name (str) – The name of the property.
value (Any) – The value of the property.
- Return type:
None
- set_replace_attributes(*attribs)
Sets the properties to replace the found occurrences.
- Raises:
com.sun.star.beans.UnknownPropertyException –
UnknownPropertyException
com.sun.star.lang.IllegalArgumentException –
IllegalArgumentException
- Return type:
None
- Parameters:
attribs (PropertyValue) –
- set_replace_string(replacement)
Sets the string which replaces the found occurrences.
- Return type:
None
- Parameters:
replacement (str) –
- set_search_attributes(*attribs)
Sets the properties to search for.
- Raises:
com.sun.star.beans.UnknownPropertyException –
UnknownPropertyException
com.sun.star.lang.IllegalArgumentException –
IllegalArgumentException
- Return type:
None
- Parameters:
attribs (PropertyValue) –
- set_search_string(string)
Sets the string of characters to look for.
- Return type:
None
- Parameters:
string (str) –
- set_value_search(value_search)
Sets if specific property values are searched, or just the existence of the specified properties.
- Return type:
None
- Parameters:
value_search (bool) –
- property component: com.sun.star.util.ReplaceDescriptor
ReplaceDescriptor Component
- Return type:
ReplaceDescriptor
- property office_doc: OfficeDocumentT
Office Document.
- Return type:
- property replace_str: str
Gets/Set replace string.
- Returns:
Replace string.
- Return type:
str
- property search_backwards: bool
If
True
, the search is done backwards in the document.- Return type:
bool
- property search_case_sensitive: bool
If
True
, the case of the letters is important for the match.- Return type:
bool
- property search_regular_expression: bool
If
True
, the search string is evaluated as a regular expression.search_regular_expression
,search_wildcard
andsearch_similarity
are mutually exclusive, only one can beTrue
at the same time.- Return type:
bool
- property search_similarity: bool
Gets/Sets - If
True
, a similarity search is performed.In the case of a similarity search, the following properties specify the kind of similarity:
search_regular_expression
,search_wildcard
andsearch_similarity
are mutually exclusive, only one can beTrue
at the same time.- Return type:
bool
- property search_similarity_add: int
Gets/Sets the number of characters that must be added to match the search pattern.
- Return type:
int
- property search_similarity_exchange: int
Gets/Sets - This property specifies the number of characters that must be replaced to match the search pattern.
- Return type:
int
- property search_similarity_relax: bool
Gets/Sets If
True
, all similarity rules are applied together.In the case of a relaxed similarity search, the following properties are applied together:
- Return type:
bool
- property search_similarity_remove: int
Gets/Sets - This property specifies the number of characters that may be ignored to match the search pattern.
- Return type:
int
- property search_str: str
Gets/Set search string.
- Returns:
Search string.
- Return type:
str
- property search_styles: bool
Gets/Sets If
True
, it is searched for positions where the paragraph style with the name of the search pattern is applied.- Return type:
bool
- property search_wildcard: bool | None
Gets/Sets - If
True
, the search string is evaluated as a wildcard pattern.Wildcards are
*
(asterisk) for any sequence of characters, including an empty sequence, and?
(question mark) for exactly one character. Escape character is\
(U+005C REVERSE SOLIDUS) aka backslash, it escapes the special meaning of a question mark, asterisk or escape character that follows immediately after the escape character.search_regular_expression
,search_wildcard
andsearch_similarity
are mutually exclusive, only one can beTrue
at the same time.optional
- Returns:
True
if the search string is evaluated as a wildcard pattern, otherwiseFalse
. If the property is not supported,None
is returned.- Return type:
bool | None
- property search_words: bool
If
True
, only complete words will be found.- Return type:
bool