Allow the DatabaseField parameter to DCOUNT and DCOUNTA functions to be optional.
This is required in ODF 1.3

Patch by: me
diff --git a/main/helpcontent2/source/text/scalc/01/04060101.xhp b/main/helpcontent2/source/text/scalc/01/04060101.xhp
index df2b00e..7245002 100644
--- a/main/helpcontent2/source/text/scalc/01/04060101.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060101.xhp
@@ -505,7 +505,7 @@
 <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 @@
 <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">&gt;=E</item> under Name in field A14. The result is 5. If you now delete all number values for Greta in row 8, the result changes to 4. Row 8 is no longer included in the count because it does not contain any values. The name Greta is text, not a value. Note that the DatabaseField parameter must point to a column that can contain values.<comment>see i25407</comment></paragraph>
+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">&gt;=E</item> under Name in field A14. The result is 5. If you now delete all number values for Greta in row 8, the result changes to 4. Row 8 is no longer included in the count because it does not contain any values. The name Greta is text, not a value. Note that the DatabaseField parameter must point to a column that can contain values.<comment>see i25407</comment></paragraph>
 </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 e3fe374..f1e058c 100644
--- a/main/sc/source/core/tool/interpr1.cxx
+++ b/main/sc/source/core/tool/interpr1.cxx
@@ -6521,7 +6521,8 @@
         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 @@
         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() );