This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch odf-1.3
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/odf-1.3 by this push:
new 561c6157b8 Allow the DatabaseField parameter to DCOUNT and DCOUNTA
functions to be optional. This is required in ODF 1.3
561c6157b8 is described below
commit 561c6157b86908803ccecf18699e7b5dfaba10b2
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Mon Jan 22 07:31:44 2024 +0200
Allow the DatabaseField parameter to DCOUNT and DCOUNTA functions to be
optional.
This is required in ODF 1.3
Patch by: me
---
.../helpcontent2/source/text/scalc/01/04060101.xhp | 9 ++-
main/sc/source/core/tool/interpr1.cxx | 90 ++++++++++++----------
2 files changed, 53 insertions(+), 46 deletions(-)
diff --git a/main/helpcontent2/source/text/scalc/01/04060101.xhp
b/main/helpcontent2/source/text/scalc/01/04060101.xhp
index df2b00e89f..7245002845 100644
--- a/main/helpcontent2/source/text/scalc/01/04060101.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060101.xhp
@@ -505,7 +505,7 @@ oldref="88">DCOUNT</paragraph>
<paragraph xml-lang="en-US" id="hd_id3156099" role="heading" level="3" l10n="U"
oldref="90">Syntax</paragraph>
<paragraph xml-lang="en-US" id="par_id3153218" role="code" l10n="U"
oldref="91">DCOUNT(Database; DatabaseField; SearchCriteria)</paragraph>
-<paragraph xml-lang="en-US" id="par_id3153273" role="paragraph" l10n="U"
oldref="187">For the DatabaseField parameter you can enter a cell to specify
the column, or enter the number 0 for the entire database. The parameter cannot
be empty. <embedvar href="text/scalc/01/04060101.xhp#quotes"/>
+<paragraph xml-lang="en-US" id="par_id3153273" role="paragraph" l10n="U"
oldref="187">If the DatabaseField parameter is present, it should specify the
column in which to count the numerical values. If it is absent or set to the
number 0, it doesn't count any column's values, and just returns the number of
rows matching the criteria. <embedvar href="text/scalc/01/04060101.xhp#quotes"/>
</paragraph>
<paragraph xml-lang="en-US" id="hd_id3154743" role="heading" level="3" l10n="U"
oldref="92">Example</paragraph>
@@ -528,10 +528,11 @@ oldref="97">DCOUNTA</paragraph>
<paragraph xml-lang="en-US" id="hd_id3143228" role="heading" level="3" l10n="U"
oldref="99">Syntax</paragraph>
<paragraph xml-lang="en-US" id="par_id3146893" role="code" l10n="U"
oldref="100">DCOUNTA(Database; DatabaseField; SearchCriteria)</paragraph>
-<embed href="text/scalc/01/04060101.xhp#quotes"/>
+<paragraph xml-lang="en-US" id="par_id3156112" role="paragraph" l10n="U"
oldref="101">If the DatabaseField parameter is present, it should specify the
column in which to count the alphanumerical values. If it is absent or set to
the number 0, it doesn't count any column's values, and just returns the number
of rows matching the criteria. <embedvar
href="text/scalc/01/04060101.xhp#quotes"/>
+</paragraph>
<paragraph xml-lang="en-US" id="hd_id3149751" role="heading" level="3" l10n="U"
-oldref="101">Example</paragraph>
-<paragraph xml-lang="en-US" id="par_id3153982" role="paragraph" l10n="CHG"
oldref="102">In the example above (scroll up, please), you can search for the
number of children whose name starts with an E or a subsequent letter. Edit the
formula in B16 to read <item
type="input">=DCOUNTA(A1:E10;"Name";A13:E14)</item>. Delete the old search
criteria and enter <item type="input">>=E</item> under Name in field A14.
The result is 5. If you now delete all number values for Greta in row 8, the r
[...]
+oldref="102">Example</paragraph>
+<paragraph xml-lang="en-US" id="par_id3153982" role="paragraph" l10n="CHG"
oldref="103">In the example above (scroll up, please), you can search for the
number of children whose name starts with an E or a subsequent letter. Edit the
formula in B16 to read <item
type="input">=DCOUNTA(A1:E10;"Name";A13:E14)</item>. Delete the old search
criteria and enter <item type="input">>=E</item> under Name in field A14.
The result is 5. If you now delete all number values for Greta in row 8, the r
[...]
</section>
<section id="Section3">
<bookmark xml-lang="en-US" branch="index" id="bm_id3147256">
diff --git a/main/sc/source/core/tool/interpr1.cxx
b/main/sc/source/core/tool/interpr1.cxx
index e3fe37449f..f1e058c93d 100644
--- a/main/sc/source/core/tool/interpr1.cxx
+++ b/main/sc/source/core/tool/interpr1.cxx
@@ -6521,7 +6521,8 @@ ScDBQueryParamBase* ScInterpreter::GetDBParams( sal_Bool&
rMissingField )
bAllowMissingField = sal_True;
rMissingField = sal_False;
}
- if ( GetByte() == 3 )
+ sal_uInt8 nParamCount = GetByte();
+ if ( (bAllowMissingField && nParamCount == 2) || nParamCount == 3 )
{
// First, get the query criteria range.
::std::auto_ptr<ScDBRangeBase> pQueryRef( PopDoubleRef() );
@@ -6533,54 +6534,59 @@ ScDBQueryParamBase* ScInterpreter::GetDBParams(
sal_Bool& rMissingField )
String aStr;
ScRange aMissingRange;
sal_Bool bRangeFake = sal_False;
- switch (GetStackType())
+ if (nParamCount == 3)
{
- case svDouble :
- nVal = ::rtl::math::approxFloor( GetDouble() );
- if ( bAllowMissingField && nVal == 0.0 )
- rMissingField = sal_True; // fake missing parameter
- break;
- case svString :
- bByVal = sal_False;
- aStr = GetString();
- break;
- case svSingleRef :
- {
- ScAddress aAdr;
- PopSingleRef( aAdr );
- ScBaseCell* pCell = GetCell( aAdr );
- if (HasCellValueData(pCell))
- nVal = GetCellValue( aAdr, pCell );
+ switch (GetStackType())
+ {
+ case svDouble :
+ nVal = ::rtl::math::approxFloor( GetDouble() );
+ if ( bAllowMissingField && nVal == 0.0 )
+ rMissingField = sal_True; // fake missing parameter
+ break;
+ case svString :
+ bByVal = sal_False;
+ aStr = GetString();
+ break;
+ case svSingleRef :
+ {
+ ScAddress aAdr;
+ PopSingleRef( aAdr );
+ ScBaseCell* pCell = GetCell( aAdr );
+ if (HasCellValueData(pCell))
+ nVal = GetCellValue( aAdr, pCell );
+ else
+ {
+ bByVal = sal_False;
+ GetCellString(aStr, pCell);
+ }
+ }
+ break;
+ case svDoubleRef :
+ if ( bAllowMissingField )
+ { // fake missing parameter for old SO compatibility
+ bRangeFake = sal_True;
+ PopDoubleRef( aMissingRange );
+ }
else
{
- bByVal = sal_False;
- GetCellString(aStr, pCell);
+ PopError();
+ SetError( errIllegalParameter );
}
- }
- break;
- case svDoubleRef :
- if ( bAllowMissingField )
- { // fake missing parameter for old SO compatibility
- bRangeFake = sal_True;
- PopDoubleRef( aMissingRange );
- }
- else
- {
+ break;
+ case svMissing :
+ PopError();
+ if ( bAllowMissingField )
+ rMissingField = sal_True;
+ else
+ SetError( errIllegalParameter );
+ break;
+ default:
PopError();
SetError( errIllegalParameter );
- }
- break;
- case svMissing :
- PopError();
- if ( bAllowMissingField )
- rMissingField = sal_True;
- else
- SetError( errIllegalParameter );
- break;
- default:
- PopError();
- SetError( errIllegalParameter );
+ }
}
+ else
+ rMissingField = sal_True;
auto_ptr<ScDBRangeBase> pDBRef( PopDoubleRef() );