[Libreoffice-commits] core.git: 7 commits - include/unotools offapi/com officecfg/registry sc/inc sc/source

Eike Rathke erack at redhat.com
Fri Feb 19 23:40:19 UTC 2016


 include/unotools/textsearch.hxx                           |   30 ++++++++++++++
 offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl |   16 +++++++
 officecfg/registry/schema/org/openoffice/Office/Calc.xcs  |    8 +++
 sc/inc/docoptio.hxx                                       |    6 ++
 sc/inc/optuno.hxx                                         |    1 
 sc/inc/unonames.hxx                                       |    2 
 sc/source/core/tool/docoptio.cxx                          |   13 +++++-
 sc/source/filter/xml/XMLCalculationSettingsContext.cxx    |    6 +-
 sc/source/filter/xml/xmlexprt.cxx                         |   10 +++-
 sc/source/ui/unoobj/docuno.cxx                            |    2 
 sc/source/ui/unoobj/optuno.cxx                            |    7 +++
 11 files changed, 96 insertions(+), 5 deletions(-)

New commits:
commit ef02de2698d90fd874bddf3146165cbe85487bc5
Author: Eike Rathke <erack at redhat.com>
Date:   Sat Feb 20 00:36:03 2016 +0100

    write ODF table:use-wildcards to calculation settings, tdf#72196
    
    Change-Id: I36d23c891b9ba85f0b0352d2314f092d7e9113eb

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 508f8c2..bcff585 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3749,6 +3749,9 @@ void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreads
         bool bLookUpLabels (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_LOOKUPLABELS) ));
         bool bMatchWholeCell (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_MATCHWHOLE) ));
         bool bUseRegularExpressions (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_REGEXENABLED) ));
+        bool bUseWildcards (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_WILDCARDSENABLED) ));
+        if (bUseWildcards && bUseRegularExpressions)
+            bUseRegularExpressions = false;     // mutually exclusive, wildcards take precedence
         bool bIsIterationEnabled (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_ITERENABLED) ));
         sal_uInt16 nYear2000 (pDoc ? pDoc->GetDocOptions().GetYear2000() : 0);
         sal_Int32 nIterationCount(100);
@@ -3758,8 +3761,9 @@ void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreads
         util::Date aNullDate;
         xPropertySet->getPropertyValue( SC_UNO_NULLDATE ) >>= aNullDate;
         if (bCalcAsShown || bIgnoreCase || !bLookUpLabels || !bMatchWholeCell || !bUseRegularExpressions ||
-            bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001) ||
-            aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 || nYear2000 != 1930)
+                bUseWildcards ||
+                bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001) ||
+                aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 || nYear2000 != 1930)
         {
             if (bIgnoreCase)
                 AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_FALSE);
@@ -3771,6 +3775,8 @@ void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreads
                 AddAttribute(XML_NAMESPACE_TABLE, XML_AUTOMATIC_FIND_LABELS, XML_FALSE);
             if (!bUseRegularExpressions)
                 AddAttribute(XML_NAMESPACE_TABLE, XML_USE_REGULAR_EXPRESSIONS, XML_FALSE);
+            if (bUseWildcards)
+                AddAttribute(XML_NAMESPACE_TABLE, XML_USE_WILDCARDS, XML_TRUE);
             if (nYear2000 != 1930)
             {
                 OUStringBuffer sBuffer;
commit 20fec9becf33e51a1d3ae8afcd52e4d65b343b7a
Author: Eike Rathke <erack at redhat.com>
Date:   Sat Feb 20 00:33:01 2016 +0100

    import Wildcards at ScXMLCalculationSettingsContext, tdf#72196
    
    Change-Id: Ic0031052a488581ad8627375993c275bc635ed8a

diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index 836d530..4110b5e 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -131,8 +131,10 @@ void ScXMLCalculationSettingsContext::EndElement()
             xPropertySet->setPropertyValue( SC_UNO_IGNORECASE, uno::makeAny(bIgnoreCase) );
             xPropertySet->setPropertyValue( SC_UNO_LOOKUPLABELS, uno::makeAny(bLookUpLabels) );
             xPropertySet->setPropertyValue( SC_UNO_MATCHWHOLE, uno::makeAny(bMatchWholeCell) );
-            xPropertySet->setPropertyValue( SC_UNO_REGEXENABLED,
-                    uno::makeAny(eSearchType == utl::SearchParam::SRCH_REGEXP) );
+            bool bWildcards, bRegex;
+            utl::SearchParam::ConvertToBool( eSearchType, bWildcards, bRegex);
+            xPropertySet->setPropertyValue( SC_UNO_REGEXENABLED, uno::makeAny(bRegex) );
+            xPropertySet->setPropertyValue( SC_UNO_WILDCARDSENABLED, uno::makeAny(bWildcards) );
             xPropertySet->setPropertyValue( SC_UNO_ITERENABLED, uno::makeAny(bIsIterationEnabled) );
             xPropertySet->setPropertyValue( SC_UNO_ITERCOUNT, uno::makeAny(nIterationCount) );
             xPropertySet->setPropertyValue( SC_UNO_ITEREPSILON, uno::makeAny(fIterationEpsilon) );
commit 9f0fa7e5316509d73e3384a3b23b61a8a2d27f7c
Author: Eike Rathke <erack at redhat.com>
Date:   Sat Feb 20 00:23:31 2016 +0100

    add Wildcards UNO API implementation, tdf#72196
    
    Change-Id: I3dbca9661b55596484ac77f92243fd463fa01ec9

diff --git a/sc/inc/optuno.hxx b/sc/inc/optuno.hxx
index d2d2bce..b75fb3c 100644
--- a/sc/inc/optuno.hxx
+++ b/sc/inc/optuno.hxx
@@ -35,6 +35,7 @@
 #define PROP_UNO_SPELLONLINE    10
 #define PROP_UNO_STANDARDDEC    11
 #define PROP_UNO_REGEXENABLED   12
+#define PROP_UNO_WILDCARDSENABLED 13
 
 class ScDocOptionsHelper
 {
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 5939895..c031789 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -278,6 +278,7 @@
 #define SC_UNONAME_ISUSER           "IsUserDefined"
 #define SC_UNONAME_ISNATIVE         "IsNative"
 #define SC_UNONAME_REGEXP           "RegularExpressions"
+#define SC_UNONAME_WILDCARDS        "Wildcards"
 #define SC_UNONAME_SAVEOUT          "SaveOutputPosition"
 #define SC_UNONAME_SKIPDUP          "SkipDuplicates"
 #define SC_UNONAME_SRCOBJ           "SourceObject"
@@ -498,6 +499,7 @@
 #define SC_UNO_SPELLONLINE              "SpellOnline"
 #define SC_UNO_STANDARDDEC              "StandardDecimals"
 #define SC_UNO_REGEXENABLED             "RegularExpressions"
+#define SC_UNO_WILDCARDSENABLED         "Wildcards"
 #define SC_UNO_BASICLIBRARIES           "BasicLibraries"
 #define SC_UNO_DIALOGLIBRARIES          "DialogLibraries"
 #define SC_UNO_RUNTIMEUID               "RuntimeUID"
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 7620b63..cdb8682 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -158,6 +158,7 @@ static const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
         {OUString(SC_UNO_SPELLONLINE),             PROP_UNO_SPELLONLINE, cppu::UnoType<bool>::get(),                          0, 0},
         {OUString(SC_UNO_STANDARDDEC),             PROP_UNO_STANDARDDEC, cppu::UnoType<sal_Int16>::get(),                    0, 0},
         {OUString(SC_UNO_REGEXENABLED),            PROP_UNO_REGEXENABLED, cppu::UnoType<bool>::get(),                         0, 0},
+        {OUString(SC_UNO_WILDCARDSENABLED),        PROP_UNO_WILDCARDSENABLED, cppu::UnoType<bool>::get(),                         0, 0},
         {OUString(SC_UNO_RUNTIMEUID),              0, cppu::UnoType<OUString>::get(),                  beans::PropertyAttribute::READONLY, 0},
         {OUString(SC_UNO_HASVALIDSIGNATURES),      0, cppu::UnoType<bool>::get(),                                             beans::PropertyAttribute::READONLY, 0},
         {OUString(SC_UNO_ISLOADED),                0, cppu::UnoType<bool>::get(),                                             0, 0},
@@ -2102,6 +2103,7 @@ void SAL_CALL ScModelObj::setPropertyValue(
             // done...
             if ( aString == SC_UNO_IGNORECASE ||
                  aString == SC_UNONAME_REGEXP ||
+                 aString == SC_UNONAME_WILDCARDS ||
                  aString == SC_UNO_LOOKUPLABELS )
                 bHardRecalc = false;
         }
diff --git a/sc/source/ui/unoobj/optuno.cxx b/sc/source/ui/unoobj/optuno.cxx
index b158b0e..a78d618 100644
--- a/sc/source/ui/unoobj/optuno.cxx
+++ b/sc/source/ui/unoobj/optuno.cxx
@@ -44,6 +44,7 @@ const SfxItemPropertyMapEntry* ScDocOptionsHelper::GetPropertyMap()
         {OUString(SC_UNO_SPELLONLINE),  PROP_UNO_SPELLONLINE ,  cppu::UnoType<bool>::get(),          0, 0},
         {OUString(SC_UNO_STANDARDDEC),  PROP_UNO_STANDARDDEC ,  cppu::UnoType<sal_Int16>::get(),    0, 0},
         {OUString(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED,  cppu::UnoType<bool>::get(),          0, 0},
+        {OUString(SC_UNO_WILDCARDSENABLED), PROP_UNO_WILDCARDSENABLED, cppu::UnoType<bool>::get(),  0, 0},
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
     return aMap;
@@ -116,6 +117,9 @@ bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions,
         case PROP_UNO_REGEXENABLED:
             rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
         break;
+        case PROP_UNO_WILDCARDSENABLED:
+            rOptions.SetFormulaWildcardsEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+        break;
         default:;
     }
     return true;
@@ -173,6 +177,9 @@ uno::Any ScDocOptionsHelper::getPropertyValue(
         case PROP_UNO_REGEXENABLED:
             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaRegexEnabled() );
         break;
+        case PROP_UNO_WILDCARDSENABLED:
+            ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaWildcardsEnabled() );
+        break;
         default:;
     }
     return aRet;
commit 91dd7a67d1b64d56fc00b19db102731a91f220f7
Author: Eike Rathke <erack at redhat.com>
Date:   Sat Feb 20 00:14:54 2016 +0100

    add FormulaWildcardsEnabled to ScDocOptions, tdf#72196
    
    Currently as raw bool values matching the configuration values.
    Will need a precedence handling.
    
    Change-Id: I1a65b4dc0af54bd39474a2ca329bee1ea0337a9f

diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index 4b17935..cd7effa 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -46,6 +46,7 @@ class SC_DLLPUBLIC ScDocOptions
     bool       bDoAutoSpell;            ///< auto-spelling
     bool       bLookUpColRowNames;      ///< determine column-/row titles automagically
     bool       bFormulaRegexEnabled;    ///< regular expressions in formulas enabled
+    bool       bFormulaWildcardsEnabled;///< wildcards in formulas enabled
     bool       bWriteCalcConfig;        ///< (subset of) Calc config will be written to user's profile
 public:
                 ScDocOptions();
@@ -92,6 +93,9 @@ public:
     void    SetFormulaRegexEnabled( bool bVal ) { bFormulaRegexEnabled = bVal; }
     bool    IsFormulaRegexEnabled() const       { return bFormulaRegexEnabled; }
 
+    void    SetFormulaWildcardsEnabled( bool bVal ) { bFormulaWildcardsEnabled = bVal; }
+    bool    IsFormulaWildcardsEnabled() const       { return bFormulaWildcardsEnabled; }
+
     void    SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; }
     bool    IsWriteCalcConfig() const       { return bWriteCalcConfig; }
 };
@@ -113,6 +117,7 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
     bDoAutoSpell        = rCpy.bDoAutoSpell;
     bLookUpColRowNames  = rCpy.bLookUpColRowNames;
     bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
+    bFormulaWildcardsEnabled = rCpy.bFormulaWildcardsEnabled;
     bWriteCalcConfig    = rCpy.bWriteCalcConfig;
 
     return *this;
@@ -136,6 +141,7 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
             &&  rOpt.bDoAutoSpell           == bDoAutoSpell
             &&  rOpt.bLookUpColRowNames     == bLookUpColRowNames
             &&  rOpt.bFormulaRegexEnabled   == bFormulaRegexEnabled
+            &&  rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled
             &&  rOpt.bWriteCalcConfig       == bWriteCalcConfig
             );
 }
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index e688752..8b9bcaa 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -71,6 +71,7 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
             bDoAutoSpell( rCpy.bDoAutoSpell ),
             bLookUpColRowNames( rCpy.bLookUpColRowNames ),
             bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled ),
+            bFormulaWildcardsEnabled( rCpy.bFormulaWildcardsEnabled ),
             bWriteCalcConfig( rCpy.bWriteCalcConfig )
 {
 }
@@ -96,6 +97,7 @@ void ScDocOptions::ResetDocOptions()
     bDoAutoSpell        = false;
     bLookUpColRowNames  = true;
     bFormulaRegexEnabled= true;
+    bFormulaWildcardsEnabled= false;
     bWriteCalcConfig    = true;
 }
 
@@ -147,7 +149,8 @@ SfxPoolItem* ScTpCalcItem::Clone( SfxItemPool * ) const
 #define SCCALCOPT_SEARCHCRIT        9
 #define SCCALCOPT_FINDLABEL         10
 #define SCCALCOPT_REGEX             11
-#define SCCALCOPT_COUNT             12
+#define SCCALCOPT_WILDCARDS         12
+#define SCCALCOPT_COUNT             13
 
 #define CFGPATH_DOCLAYOUT   "Office.Calc/Layout/Other"
 
@@ -170,6 +173,7 @@ Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
         "Other/SearchCriteria",             // SCCALCOPT_SEARCHCRIT
         "Other/FindLabel",                  // SCCALCOPT_FINDLABEL
         "Other/RegularExpressions",         // SCCALCOPT_REGEX
+        "Other/Wildcards",                  // SCCALCOPT_WILDCARDS
     };
     Sequence<OUString> aNames(SCCALCOPT_COUNT);
     OUString* pNames = aNames.getArray();
@@ -262,6 +266,9 @@ ScDocCfg::ScDocCfg() :
                     case SCCALCOPT_REGEX :
                         SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
                         break;
+                    case SCCALCOPT_WILDCARDS :
+                        SetFormulaWildcardsEnabled( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                        break;
                 }
             }
         }
@@ -345,6 +352,10 @@ IMPL_LINK_NOARG_TYPED(ScDocCfg, CalcCommitHdl, ScLinkConfigItem&, void)
                 break;
             case SCCALCOPT_REGEX :
                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsFormulaRegexEnabled() );
+                break;
+            case SCCALCOPT_WILDCARDS :
+                ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsFormulaWildcardsEnabled() );
+                break;
         }
     }
     aCalcItem.PutProperties(aNames, aValues);
commit ec3bc95a1cc8283867d2d4df4aa1268588ccaedf
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 19 22:22:27 2016 +0100

    add Wildcards configuration option, tdf#72196
    
    Currently defaulted to false to not interfere with RegularExpressions
    true default, we should switch RegularExpressions to false and Wildcards
    to true instead.
    
    Change-Id: I06dd2fd074089629f19a06f3eb65413bdca5d9e0

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 8e1200e..e2006aa 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1308,6 +1308,14 @@
           </info>
           <value>true</value>
         </prop>
+        <prop oor:name="Wildcards" oor:type="xs:boolean" oor:nillable="false">
+          <!-- UIHints: Tools - Options  Spreadsheet  Calculate  [Check box] Enable wildcards in formulas -->
+          <info>
+            <desc>Specifies whether the calculation uses wildcards in formulas, e.g. for functions which look up sheet contents.</desc>
+            <label>Enable wildcards in formulas</label>
+          </info>
+          <value>false</value>
+        </prop>
         <prop oor:name="FormulaSyntax" oor:type="xs:int">
           <!-- UIHints: Tools - Options  Spreadsheet  Calculate -->
           <!-- This node is deprecated, but we still need to keep it for migration purposes. -->
commit da6d813222e81470fac38282d1cebd1f858ba925
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 19 13:41:47 2016 +0100

    add [optional, property] boolean Wildcards, tdf#72196
    
    Change-Id: I7105bdeafe6a1b8bf24e88f7a00d5eb3d23df15a

diff --git a/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl b/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
index dca11f4..bdb784e4 100644
--- a/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
+++ b/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
@@ -124,6 +124,10 @@ published service SpreadsheetDocumentSettings
 
     /** specifies whether regular expressions in formulas are enabled,
         e.g., for functions which look up spreadsheet contents.
+
+        <p>RegularExpressions and Wildcards are mutually exclusive, only
+        one can have the value `TRUE`. Internally, if both are true then
+        Wildcards takes precedence over RegularExpressions.</p>
      */
     [property] boolean RegularExpressions;
 
@@ -208,6 +212,18 @@ published service SpreadsheetDocumentSettings
      */
     [readonly,optional, property] boolean IsRecordChangesProtected;
 
+
+    /** specifies whether wildcards in formulas are enabled,
+        e.g., for functions which look up spreadsheet contents.
+
+        <p>Wildcards and RegularExpressions are mutually exclusive, only
+        one can have the value `TRUE`. Internally, if both are true then
+        Wildcards takes precedence over RegularExpressions.</p>
+
+        @since LibreOffice 5.2
+     */
+    [optional, property] boolean Wildcards;
+
 };
 
 
commit fb3f66c20f79f178ba0f53b850ed0af0d1c5b2ff
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 19 12:33:47 2016 +0100

    add ConvertToSearchType() ConvertToBool(), tdf#72196
    
    Change-Id: Iaab31cd6afe5cedccd4f79b142aa1ecee8a6e8d4

diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index 7ddfbf0..67c440a 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -49,6 +49,36 @@ class UNOTOOLS_DLLPUBLIC SearchParam
 public:
     enum SearchType{ SRCH_NORMAL, SRCH_REGEXP, SRCH_LEVDIST, SRCH_WILDCARD };
 
+    /** Convert configuration and document boolean settings to SearchType.
+        If bWildcard is true it takes precedence over bRegExp.
+     */
+    static SearchType ConvertToSearchType( bool bWildcard, bool bRegExp )
+    {
+        return bWildcard ? SRCH_WILDCARD : (bRegExp ? SRCH_REGEXP : SRCH_NORMAL);
+    }
+
+    /** Convert SearchType to configuration and document boolean settings.
+     */
+    static void ConvertToBool( const SearchType eSearchType, bool& rbWildcard, bool& rbRegExp )
+    {
+        switch (eSearchType)
+        {
+            case SRCH_WILDCARD:
+                rbWildcard = true;
+                rbRegExp = false;
+                break;
+            case SRCH_REGEXP:
+                rbWildcard = false;
+                rbRegExp = true;
+                break;
+            default:
+                // SRCH_LEVDIST is not a persistent setting.
+                rbWildcard = false;
+                rbRegExp = false;
+                break;
+        }
+    }
+
 private:
     OUString sSrchStr;            // the search string
     OUString sReplaceStr;         // the replace string


More information about the Libreoffice-commits mailing list