Bugzilla – Attachment 140105 Details for
Bug 115983
findAll and replaceAll methods have an unexpected behavior when they are called from the com.sun.star.sheet.SheetCellRanges service.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
A piece of code that reproduce the problem.
cellranges_replace.py (text/x-python), 1.86 KB, created by
vatairethibault
on 2018-02-24 00:07:57 UTC
(
hide
)
Description:
A piece of code that reproduce the problem.
Filename:
MIME Type:
Creator:
vatairethibault
Created:
2018-02-24 00:07:57 UTC
Size:
1.86 KB
patch
obsolete
>from com.sun.star.frame.FrameSearchFlag import CREATE > >def replace(event=None): > > #open a new calc document and fill two ranges spreaded on two differents sheets with the value to search > cdoc = XSCRIPTCONTEXT.getDesktop().loadComponentFromURL('private:factory/scalc', '_blank', CREATE, ()) > snames = ('asheet', 'anothersheet') > cdoc.Sheets.getByIndex(0).Name = snames[1] > cdoc.Sheets.insertNewByName(snames[0], 0) > svalue = 'old' > for aname in snames: > asheet = cdoc.Sheets.getByName(aname) > arange = asheet.getCellRangeByName('A1:D4') > for acol in range(0, arange.Columns.Count): > for arow in range(0, arange.Rows.Count): > arange.getCellByPosition(acol, arow).String = svalue > arange = asheet.getCellRangeByName('E5:H8') > for acol in range(0, arange.Columns.Count): > for arow in range(0, arange.Rows.Count): > arange.getCellByPosition(acol, arow).String = svalue > > #add ranges to the collection > ranges = cdoc.createInstance('com.sun.star.sheet.SheetCellRanges') > ranges.addRangeAddress(cdoc.Sheets.getByName(snames[0]).getCellRangeByName('B2:C3').RangeAddress, False) > ranges.addRangeAddress(cdoc.Sheets.getByName(snames[1]).getCellRangeByName('F6:G7').RangeAddress, False) > print('target collection : {0}'.format(ranges.AbsoluteName)) > > #search and replace > sdesc = ranges.createSearchDescriptor() > sdesc.SearchString = svalue > sdesc.ReplaceString = 'new' > findres = ranges.findAll(sdesc) > renum = findres.createEnumeration() > ccnt = 0 > while (renum.hasMoreElements()): > arange = renum.nextElement() > ccnt += (arange.Columns.Count * arange.Rows.Count) > > print('findAll collection : {0}'.format(findres.AbsoluteName)) > print('findAll count : {0}'.format(ccnt)) > print('replaceAll count : {0}'.format(ranges.replaceAll(sdesc))) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 115983
: 140105 |
140528