Bug 140836 - Calc Advanced Filter does not work correctly when copying criteria range fields (BASIC code)
Summary: Calc Advanced Filter does not work correctly when copying criteria range fiel...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.1.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-06 04:42 UTC by Igor
Modified: 2021-07-19 16:49 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Explains the error in detail (312.87 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-03-06 04:46 UTC, Igor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor 2021-03-06 04:42:34 UTC
Description:
BASIC: When the numeric criterion as string value is applied, the leading zero is lost. Looking ahead: FilterFields(0).StringValue = "01", but after copying the structure from critera range, we get .StringValue = "1" (see example attached).

<pseudocode>

 ' Update filter fields.
 oFields = oCriteriaRange _
  .createFilterDescriptorByObject(oDBRange.ReferredCells).FilterFields

 ' #ERROR! after copying the structure
 oDescriptor.FilterFields = oFields  'the leading zero is lost

When applying the advanced (standard) filter manually, everything works correctly. The REGEX function, of course, also works correctly.

Steps to Reproduce:
1. Download the example.
2. Run the code.
3. It doesn't work correctly.

Actual Results:
The leading zero is lost

Expected Results:
If the numeric criterion as a string contains a leading zero, then the representation of the value should not change.


Reproducible: Always


User Profile Reset: No



Additional Info:
https://bugs.documentfoundation.org/show_bug.cgi?id=140613
Comment 1 Igor 2021-03-06 04:46:30 UTC
Created attachment 170260 [details]
Explains the error in detail

Duplicates the post:
https://bugs.documentfoundation.org/show_bug.cgi?id=140613
Comment 2 Mike Kaganski 2021-03-06 06:02:54 UTC
Repro using Version: 7.1.1.2 (x64) / LibreOffice Community
Build ID: fe0b08f4af1bacafe4c7ecc87ce55bb426164676
CPU threads: 12; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: CL.

Steps:
1. In attachment 170260 [details] (opened with macros enabled), go to Sheet2
2. Ctrl+Click the "ResetDatabaseRange" hyperlink in L1
3. Ctrl+Click the "RefreshDBRange" hyperlink in L2

=> the "Database" DB range is updated, with non-matching rows filtered out.
Expected: rows 7 to 19 hidden
Actual: only row 19 is hidden

The code that is discussed is lines 41-42 in the "Sub RefreshDBRange()" of the document macros .

Code pointer: ScTable::CreateQueryParam in sc/source/core/data/table3.cxx, which uses pFormatter->IsNumberFormat to determine the type of query, irrespective of the cell format (explicitly textual).

No idea if changing this could result in problems. Eike?
Comment 3 Igor 2021-03-06 13:08:41 UTC
Mike, thank you for your participation and help
Comment 4 Mike Kaganski 2021-07-19 16:49:52 UTC
Not a bug: see tdf#143438 for missing documentation issue.