Add replace by range

This commit is contained in:
Mauricio Baeza 2020-12-02 18:31:33 -06:00
parent fea2a3ae43
commit 59e471c5f7
2 changed files with 17 additions and 13 deletions

View File

@ -279,19 +279,6 @@ class LOCellRange(object):
def auto_format(self, value):
self.obj.autoFormat(value)
def replace(self, options):
descriptor = self.obj.Spreadsheet.createReplaceDescriptor()
descriptor.setSearchString(options['Search'])
descriptor.setReplaceString(options['Replace'])
descriptor.SearchCaseSensitive = options.get('CaseSensitive', False)
descriptor.SearchWords = options.get('Words', False)
if hasattr(descriptor, 'SearchRegularExpression'):
descriptor.SearchRegularExpression = options.get('RegularExpression', False)
if hasattr(descriptor, 'SearchType') and 'Type' in options:
descriptor.SearchType = options['Type']
found = self.obj.replaceAll(descriptor)
return found
@property
def validation(self):
return self.obj.Validation

View File

@ -2050,6 +2050,10 @@ class LOCalcSheet(object):
def search_descriptor(self):
return self.obj.createSearchDescriptor()
@property
def replace_descriptor(self):
return self.obj.createReplaceDescriptor()
def activate(self):
self.doc.activate(self.obj)
return
@ -2418,6 +2422,19 @@ class LOCalcRange(object):
return rangos
def replace(self, options):
descriptor = self.sheet.replace_descriptor
descriptor.setSearchString(options['Search'])
descriptor.setReplaceString(options['Replace'])
descriptor.SearchCaseSensitive = options.get('CaseSensitive', False)
descriptor.SearchWords = options.get('Words', False)
if hasattr(descriptor, 'SearchRegularExpression'):
descriptor.SearchRegularExpression = options.get('RegularExpression', False)
if hasattr(descriptor, 'SearchType') and 'Type' in options:
descriptor.SearchType = options['Type']
count = self.obj.replaceAll(descriptor)
return count
def in_range(self, rango):
if isinstance(rango, LOCalcRange):
address = rango.range_address