source/text/sbasic/shared/03/sf_dictionary.xhp |  190 ++++++++++++++++---------
 1 file changed, 124 insertions(+), 66 deletions(-)

New commits:
commit 3a202a242eacd1bb7739686cc4803950cbe3d24f
Author:     Rafael Lima <rafael.palma.l...@gmail.com>
AuthorDate: Mon Jan 11 22:39:06 2021 +0100
Commit:     Olivier Hallot <olivier.hal...@libreoffice.org>
CommitDate: Mon Jan 11 23:15:44 2021 +0100

    Update SF_Dictionary Help page
    
    Improves text and adds new examples.
    
    Change-Id: I17fca5debf0a0f4f952a3d624ba2a64cf1d596eb
    Reviewed-on: https://gerrit.libreoffice.org/c/help/+/109112
    Tested-by: Jenkins
    Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org>

diff --git a/source/text/sbasic/shared/03/sf_dictionary.xhp 
b/source/text/sbasic/shared/03/sf_dictionary.xhp
index 35c56ec0e..e540d9c73 100644
--- a/source/text/sbasic/shared/03/sf_dictionary.xhp
+++ b/source/text/sbasic/shared/03/sf_dictionary.xhp
@@ -37,11 +37,11 @@
   <br/>Additionally its items contain only primitive Basic data types such as 
dates, text, numbers, and the like.</paragraph>
 
   <h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2>
-
+  <paragraph role="paragraph" id="par_id821610388789467">The following example 
creates <literal>myDict</literal> as an empty dictionary.</paragraph>
   <bascode>
     <paragraph role="bascode" localize="false" 
id="bas_id851582897798335">GlobalScope.BasicLibraries.loadLibrary("ScriptForge")</paragraph>
     <paragraph role="bascode" localize="false" id="bas_id371582885621964">Dim 
myDict As Variant</paragraph>
-    <paragraph role="bascode" localize="false" id="bas_id201582885621287">    
myDict = CreateScriptService("Dictionary")</paragraph>
+    <paragraph role="bascode" localize="false" 
id="bas_id201582885621287">myDict = 
CreateScriptService("Dictionary")</paragraph>
   </bascode>
 
   <paragraph role="paragraph" id="par_id71158288562139" xml-lang="en-US">It is 
recommended to free resources after use:</paragraph>
@@ -76,7 +76,7 @@
             <paragraph id="par_id371582885195525" role="tablecontent" 
localize="false">Long</paragraph>
         </tablecell>
         <tablecell>
-            <paragraph id="par_id881582885195976" role="tablecontent" 
xml-lang="en-US">The actual number of entries in the dictionary</paragraph>
+            <paragraph id="par_id881582885195976" role="tablecontent" 
xml-lang="en-US">The number of entries in the dictionary</paragraph>
         </tablecell>
     </tablerow>
     <tablerow>
@@ -90,7 +90,7 @@
             <paragraph id="par_id131582886030297" role="tablecontent" 
xml-lang="en-US">Array of Variants</paragraph>
         </tablecell>
         <tablecell>
-            <paragraph id="par_id471582886030489" role="tablecontent" 
xml-lang="en-US">The list of items as a one dimension array</paragraph>
+            <paragraph id="par_id471582886030489" role="tablecontent" 
xml-lang="en-US">The list of items as a one dimensional array</paragraph>
         </tablecell>
     </tablerow>
     <tablerow>
@@ -104,21 +104,21 @@
             <paragraph id="par_id271582886791111" role="tablecontent" 
xml-lang="en-US">Array of Strings</paragraph>
         </tablecell>
         <tablecell>
-            <paragraph id="par_id16158288679167" role="tablecontent" 
xml-lang="en-US">The list of keys as a one dimension array</paragraph>
+            <paragraph id="par_id16158288679167" role="tablecontent" 
xml-lang="en-US">The list of keys as a one dimensional array</paragraph>
         </tablecell>
     </tablerow>
     </table>
 
-    <paragraph role="tip" id="par_id461582886731495" xml-lang="en-US">The Keys 
and Items properties return their respective contents, using an identical 
ordering.
-    <br/>The order is unrelated to the creation sequence.</paragraph>
+    <paragraph role="tip" id="par_id461582886731495" xml-lang="en-US">The 
<literal>Keys</literal> and <literal>Items</literal> properties return their 
respective contents, using an identical ordering. The order is unrelated to the 
creation sequence.</paragraph>
 
     <h3 id="hd_id691582887572811" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
+    <paragraph role="paragraph" id="par_id931610389113917">The following 
example uses the <literal>Keys</literal> property to iterate over all keys in 
the dictionary <literal>myDict</literal>.</paragraph>
     <bascode>
     <paragraph role="bascode" localize="false" id="bas_id211582887012398">Dim 
a As Variant, b As String</paragraph>
-    <paragraph role="bascode" localize="false" id="bas_id351582887179042">    
a = myDict.Keys</paragraph>
-    <paragraph role="bascode" localize="false" id="bas_id251582887187534">    
For Each b In a</paragraph>
-    <paragraph role="bascode" localize="false" id="bas_id121582887198799">     
   ' ...</paragraph>
-    <paragraph role="bascode" localize="false" id="bas_id571606473148931">    
Next b</paragraph>
+    <paragraph role="bascode" localize="false" id="bas_id351582887179042">a = 
myDict.Keys</paragraph>
+    <paragraph role="bascode" localize="false" id="bas_id251582887187534">For 
Each b In a</paragraph>
+    <paragraph role="bascode" localize="false" id="bas_id121582887198799">    
MsgBox(myDict.Item(b))</paragraph>
+    <paragraph role="bascode" localize="false" id="bas_id571606473148931">Next 
b</paragraph>
     </bascode>
 
     <table id="tab_id891606472825856">
@@ -129,13 +129,13 @@
     </tablerow>
     <tablerow>
        <tablecell><paragraph id="par_id381606472825856" role="tablecontent">
-           <link href="text/sbasic/shared/03/sf_dictionary.xhp#Add" name="Add 
method">Add</link><br/><br/>
+           <link href="text/sbasic/shared/03/sf_dictionary.xhp#Add" name="Add 
method">Add</link><br/>
            <link href="text/sbasic/shared/03/sf_dictionary.xhp#ConvertToArray" 
name="ConvertToArray method">ConvertToArray</link><br/>
            <link href="text/sbasic/shared/03/sf_dictionary.xhp#ConvertToJson" 
name="ConvertToJson method">ConvertToJson</link><br/>
            <link 
href="text/sbasic/shared/03/sf_dictionary.xhp#ConvertToPropertyValues" 
name="ConvertToPropertyValues method">ConvertToPropertyValues</link>
        </paragraph></tablecell>
        <tablecell><paragraph id="par_id451606472825856" role="tablecontent">
-           <link href="text/sbasic/shared/03/sf_dictionary.xhp#Exists" 
name="Exists method">Exists</link><br/><br/>
+           <link href="text/sbasic/shared/03/sf_dictionary.xhp#Exists" 
name="Exists method">Exists</link><br/>
            <link href="text/sbasic/shared/03/sf_dictionary.xhp#ImportFromJson" 
name="ImportFromJson method">ImportFromJson</link><br/>
            <link 
href="text/sbasic/shared/03/sf_dictionary.xhp#ImportFromPropertyValues" 
name="ImportFromPropertyValues method">ImportFromPropertyValues</link><br/>
            <link href="text/sbasic/shared/03/sf_dictionary.xhp#Item" 
name="Item method">Item</link>
@@ -155,19 +155,20 @@
         <bookmark_value>Dictionary service;Add</bookmark_value>
       </bookmark>
       <h2 id="hd_id831582887670029" localize="false">Add</h2>
-        <paragraph role="paragraph" id="par_id831582887670029">Add a new 
key-item pair into the dictionary. Returns <literal>True</literal> if 
successful.</paragraph>
+        <paragraph role="paragraph" id="par_id831582887670029">Adds a new 
key-item pair into the dictionary. Returns <literal>True</literal> if 
successful.</paragraph>
         <h3 id="hd_id451582887670029" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id731582887670029">myDict.Add(Key As String, Item As Variant) As 
Boolean</paragraph>
         </bascode>
         <h3 id="hd_id821582887670030" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-          <paragraph role="paragraph" 
id="par_id341582887670030"><emph>Key</emph> : Not case-sensitive. Must not yet 
exist in the dictionary, otherwise a <literal>DUPLICATEKEYERROR</literal> error 
is generated. Spaces only generate a <literal>INVALIDKEYERROR</literal> 
error.</paragraph>
-          <paragraph role="paragraph" 
id="par_id401582887670030"><emph>Item</emph> : Any value, including an array, a 
Basic object, a UNO object, a dictionary, ...</paragraph>
+          <paragraph role="paragraph" 
id="par_id341582887670030"><emph>Key</emph> : String value used to identify the 
Item. The key is not case-sensitive.</paragraph>
+          <paragraph role="paragraph" 
id="par_id401582887670030"><emph>Item</emph> : Any value, including an array, a 
Basic object, a UNO object, a dictionary, etc.</paragraph>
         <h3 id="hd_id461582887670030" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id191582887670030">Dim NewValue As Variant</paragraph>
-          <paragraph role="bascode" localize="false" 
id="bas_id391582887670030">    myDict.Add("NewKey", NewValue)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id391582887670030">myDict.Add("NewKey", NewValue)</paragraph>
        </bascode>
+    <warning id="par_id1001610391308765">Every key must be unique in the same 
dictionary. If the key already exists in the dictionary, a 
<literal>DUPLICATEKEYERROR</literal> will be raised. Keys that are made of 
space characters will raise a <literal>INVALIDKEYERROR</literal> 
error.</warning>
     </section>
 
     <section id="ConvertToArray">
@@ -176,29 +177,40 @@
         <bookmark_value>Dictionary service;ConvertToArray</bookmark_value>
       </bookmark>
       <h2 id="hd_id211582888424104" localize="false">ConvertToArray</h2>
-        <paragraph role="paragraph" id="par_id81582888424104">Store the 
content of the dictionary in a two-columns zero-based array. The key is stored 
in the first column, the item is stored in the second column.
-        <br />The resulting array is empty when the dictionary is 
empty.</paragraph>
+        <paragraph role="paragraph" id="par_id81582888424104">Stores the 
contents of the dictionary in a two-columns zero-based array. The keys are 
stored in the first column and the items are stored in the second 
column.</paragraph>
+        <paragraph role="paragraph" id="par_id341610391565678">If the 
dictionary is empty, this method will return an empty 
<literal>Array</literal>.</paragraph>
         <h3 id="hd_id201582888424104" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id251582888424105">myDict.ConvertToArray() As Variant</paragraph>
         </bascode>
+      <h3 id="hd_id461582887670031" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
+      <bascode>
+        <paragraph role="bascode" localize="false" 
id="bas_id651610391840491">Dim myDict as Variant</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id381610391862148">myDict = 
CreateScriptService("Dictionary")</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id61610391873262">myDict.Add("a", 1)</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id351610391876967">myDict.Add("b", 2)</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id491610391880959">myDict.Add("c", 3)</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id521610391883264">Dim arr as Variant</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id361610391885584">arr = myDict.ConvertToArray()</paragraph>
+        <paragraph role="bascode" localize="false" 
id="bas_id911610391888240">'(("a", 1), ("b", 2), ("c", 3))</paragraph>
+      </bascode>
     </section>
-
+  
     <section id="ConvertToJson">
         <comment> ConvertToJson 
---------------------------------------------------------------------------------------------------------------------
 </comment>
         <bookmark xml-lang="en-US" localize="false" branch="index" 
id="bm_id631601296836318">
             <bookmark_value>Dictionary service;ConvertToJson</bookmark_value>
         </bookmark>
         <h2 id="hd_id851601296836224" localize="false">ConvertToJson</h2>
-        <paragraph role="paragraph" id="par_id831601296836981">Convert the 
content of the dictionary to <link href="https://en.wikipedia.org/wiki/JSON"; 
name="JSON text">JSON (JavaScript Object Notation)</link> text.</paragraph>
+        <paragraph role="paragraph" id="par_id831601296836981">Converts the 
contents of a dictionary to <link href="https://en.wikipedia.org/wiki/JSON"; 
name="JSON text">JSON (JavaScript Object Notation)</link> text.</paragraph>
         <h3 id="hd_id261601297024828" xml-lang="en-US">Limitations</h3>
-        <paragraph role="paragraph" id="par_id401601297178073" 
xml-lang="en-US">Allowed data types are: <literal>String</literal>, 
<literal>Boolean</literal>, numbers, <literal>Null</literal> and 
<literal>Empty</literal>. Arrays containing items of those types are allowed, 
whatever their dimensions. Dates are converted into strings but not within 
arrays where they are forbidden. Other data types are converted to their string 
representation (cfr. SF_String.Represent).</paragraph>
+        <paragraph role="paragraph" id="par_id401601297178073" 
xml-lang="en-US">This method supports the following data types: 
<literal>String</literal>, <literal>Boolean</literal>, numbers, 
<literal>Null</literal> and <literal>Empty</literal>. Arrays containing items 
of those types are also allowed, whatever their dimensions. Dates are converted 
into strings, however they cannot be used inside Arrays. Other data types are 
converted to their string representation using the 
<literal>SF_String.Represent</literal> service.</paragraph>
         <h3 id="hd_id551601296836572" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
             <paragraph role="bascode" localize="false" 
id="bas_id491601296836271">myDict.ConvertToJson([Indent As Variant]) As 
String</paragraph>
         </bascode>
         <h3 id="hd_id1001601296836123" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-      <paragraph role="paragraph" id="par_id8816012968362"><emph>Indent</emph> 
: When <literal>Indent</literal> is a positive number or a text, JSON array 
elements and object members are pretty-printed with that indent level. A 
negative <literal>Indent</literal> value solely insert new lines. 
<literal>Indent</literal> default value "" selects the most compact 
representation. Using a positive integer for <literal>Indent</literal> indents 
that many spaces per level. When <literal>Indent</literal> is a string, such as 
<literal>Chr(9)</literal> or <literal>Tab(1)</literal>, the tab sign is used to 
indent each level.</paragraph>
+      <paragraph role="paragraph" id="par_id8816012968362"><emph>Indent</emph> 
: When <literal>Indent</literal> is a positive number or a text, JSON array 
elements and object members are pretty-printed with that indentation level. A 
negative <literal>Indent</literal> value will add new lines with no identation. 
<literal>Indent</literal> default value "" selects the most compact 
representation. Using a positive integer for <literal>Indent</literal> indents 
that many spaces per level. When <literal>Indent</literal> is a string, such as 
<literal>Chr(9)</literal> or <literal>Tab(1)</literal>, the Tab character is 
used to indent each level.</paragraph>
         <h3 id="hd_id19160129683665" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
             <paragraph role="bascode" localize="false" 
id="bas_id671601298281962">myDict.Add("p0", 12.5)</paragraph>
@@ -206,7 +218,8 @@
             <paragraph role="bascode" localize="false" 
id="bas_id201601298295976">myDict.Add("p2", DateSerial(2020,9,28))</paragraph>
             <paragraph role="bascode" localize="false" 
id="bas_id951601298323286">myDict.Add("p3", True)</paragraph>
             <paragraph role="bascode" localize="false" 
id="bas_id731601298329491">myDict.Add("p4", Array(1,2,3))</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id451601298336500">MsgBox a.ConvertToJson()    '    {"p0": 12.5, "p1": 
"a string \u00e0\u00e9\"\u00ea", "p2": "2020-09-28", "p3": true, "p4": [1, 2, 
3]}</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id451601298336500">MsgBox a.ConvertToJson()    </paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id511610392557702">'{"p0": 12.5, "p1": "a string \u00e0\u00e9\"\u00ea", 
"p2": "2020-09-28", "p3": true, "p4": [1, 2, 3]}</paragraph>
         </bascode>
     </section>
 
@@ -216,15 +229,25 @@
         <bookmark_value>Dictionary 
service;ConvertToPropertyValues</bookmark_value>
       </bookmark>
       <h2 id="hd_id421582889470909" 
localize="false">ConvertToPropertyValues</h2>
-        <paragraph role="paragraph" id="par_id151582889470596">Store the 
content of the dictionary in an array of <literal>PropertyValues</literal>.
-        <br />Each entry in the array is a 
<literal>com.sun.star.beans.PropertyValue</literal>. The key is stored in 
<literal>Name</literal>, the item is stored in <literal>Value</literal>.
-        <br />If one of the items has a type <literal>Date</literal>, it is 
converted to a <literal>com.sun.star.util.DateTime</literal> structure.
-        <br />If one of the items is an empty array, it is converted to 
<literal>Null</literal>.
-        <br />The resulting array is empty when the dictionary is 
empty.</paragraph>
+        <paragraph role="paragraph" id="par_id151582889470596">Store the 
content of the dictionary in an array of 
<literal>PropertyValues</literal>.</paragraph>
+        <paragraph role="paragraph" id="par_id231610392665049">Each entry in 
the array is a <literal>com.sun.star.beans.PropertyValue</literal>. The key is 
stored in <literal>Name</literal>, the item is stored in 
<literal>Value</literal>.</paragraph>
+        <paragraph role="paragraph" id="par_id341610392705367">If one of the 
items has a type <literal>Date</literal>, it is converted to a 
<literal>com.sun.star.util.DateTime</literal> structure. If one of the items is 
an empty array, it is converted to <literal>Null</literal>. The resulting array 
is empty when the dictionary is empty.</paragraph>
         <h3 id="hd_id841582889470464" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id191582889470444">myDict.ConvertToPropertyValues() As 
Variant</paragraph>
         </bascode>
+        <h3 id="hd_id461582887670032" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
+        <bascode>
+          <paragraph role="bascode" localize="false" 
id="bas_id81610393124521">Dim myDict as Variant</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id971610393127816">myDict = 
CreateScriptService("Dictionary")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id531610393130289">'Adds some properties to the dictonary</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id711610393132877">myDict.Add("Color", "Blue")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id681610393135354">myDict.Add("Width", 20)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id571610393137959">'Converts to an Array of PropertyValue 
objects</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id351610393140357">Dim prop as Variant</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id101610393142717">prop = myDict.ConvertToPropertyValues()</paragraph>
+        </bascode>
+        <tip id="par_id421610393306916">Many services and methods in the UNO 
library take in parameters represented using the 
<literal>PropertyValue</literal> struct, which is part of the LibreOffice 
API.</tip>
     </section>
 
     <section id="Exists">
@@ -233,18 +256,24 @@
         <bookmark_value>Dictionary service;Exists</bookmark_value>
       </bookmark>
       <h2 id="hd_id461582889812915" localize="false">Exists</h2>
-        <paragraph role="paragraph" id="par_id841582889812916">Determine if a 
key exists in the dictionary.</paragraph>
+        <paragraph role="paragraph" id="par_id841582889812916">Determines if a 
key exists in the dictionary.</paragraph>
         <h3 id="hd_id601582889812916" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id311582889812917">myDict.Exists(Key As String) As Boolean</paragraph>
         </bascode>
         <h3 id="hd_id661582889812917" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-          <paragraph role="paragraph" 
id="par_id971582889812917"><emph>Key</emph> : The key to check.</paragraph>
+          <paragraph role="paragraph" 
id="par_id971582889812917"><emph>Key</emph> : The key to be looked up in the 
dictionary.</paragraph>
         <h3 id="hd_id231582889812918" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
-          <paragraph role="bascode" localize="false" 
id="bas_id741582889812919">If Not myDict.Exists("newkey") Then</paragraph>
-          <paragraph role="bascode" id="bas_id471582889812919">    ' You may 
add it safely to the dictionary</paragraph>
-          <paragraph role="bascode" 
id="bas_id811606485130666">EndIf</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id741582889812919">Dim myDict as Variant</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id471582889812919">myDict = 
CreateScriptService("Dictionary")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id811606485130666">'Adds some properties to the dictonary</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id391610393640781">myDict.Add("Color", "Blue")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id891610393643755">myDict.Add("Width", 20)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id531610393646186">'(...)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id491610393648822">If Not myDict.Exists("Size") Then</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id681610393651551">   MsgBox "You have to provide a Size 
value"</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id581610393654335">End If</paragraph>
         </bascode>
     </section>
 
@@ -254,27 +283,27 @@
             <bookmark_value>Dictionary service;ImportFromJson</bookmark_value>
         </bookmark>
         <h2 id="hd_id81601391980848" localize="false">ImportFromJson</h2>
-        <paragraph role="paragraph" id="par_id791601391980978">Add the content 
of a <link href="https://en.wikipedia.org/wiki/JSON"; name="JSON text">JSON 
(JavaScript Object Notation)</link> text into the current dictionary. Returns 
<literal>True</literal> if successful.</paragraph>
+        <paragraph role="paragraph" id="par_id791601391980978">Adds the 
content of a <link href="https://en.wikipedia.org/wiki/JSON"; name="JSON 
text">JSON (JavaScript Object Notation)</link> string into the current 
dictionary. Returns <literal>True</literal> if successful.</paragraph>
         <h3 id="hd_id961601392113644" xml-lang="en-US">Limitations</h3>
         <paragraph role="paragraph" id="par_id481601392181131" 
xml-lang="en-US">The JSON string may contain numbers, text, booleans, null 
values and arrays containing those types. It must not contain JSON objects 
namely sub-dictionaries.</paragraph>
-        <paragraph role="paragraph" id="par_id511601392205908" 
xml-lang="en-US">An attempt is made to convert text to date if the item fits 
one of these patterns: YYYY-MM-DD, HH:MM:SS or YYYY-MM-DD HH:MM:SS.</paragraph>
+        <paragraph role="paragraph" id="par_id511601392205908" 
xml-lang="en-US">An attempt is made to convert text to date if the item matches 
one of these patterns: YYYY-MM-DD, HH:MM:SS or YYYY-MM-DD HH:MM:SS.</paragraph>
         <h3 id="hd_id301601391980982" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
             <paragraph role="bascode" localize="false" 
id="bas_id401601391980113">myDict.ImportFromJson(InputStr As String, [Overwrite 
As Boolean]) As Boolean</paragraph>
         </bascode>
         <h3 id="hd_id871601391980130" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
         <paragraph role="paragraph" 
id="par_id69160139198061"><emph>InputStr</emph> : The string to 
import.</paragraph>
-        <paragraph role="paragraph" 
id="par_id201601391980268"><emph>Overwrite</emph> : when 
<literal>True</literal>, entries with same name may exist in the dictionary and 
their values are overwritten. When <literal>False</literal> (default), synonyms 
raise an error. Note that dictionary keys are not case-sensitive while names 
are case-sensitive in JSON strings.</paragraph>
+        <paragraph role="paragraph" 
id="par_id201601391980268"><emph>Overwrite</emph> : When 
<literal>True</literal>, entries with same name may exist in the dictionary and 
their values are overwritten. When <literal>False</literal> (default), repeated 
keys will raise an error. Beware that dictionary keys are not case-sensitive 
while names are case-sensitive in JSON strings.</paragraph>
         <h3 id="hd_id141601391980338" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
             <paragraph role="bascode" localize="false" 
id="bas_id411601393205207">Dim s As String</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id891601393212562">    s = "{'firstName': 'John','lastName': 
'Smith','isAlive': true,'age': 66, 'birth':  '1954-09-28 20:15:00'" 
_</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id221601393220997">        &amp; ",'address': {'streetAddress': '21 2nd 
Street','city': 'New York','state': 'NY','postalCode': '10021-3100'}" 
_</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id931601393226582">        &amp; ",'phoneNumbers': [{'type': 
'home','number': '212 555-1234'},{'type': 'office','number': '646 555-4567'}]" 
_</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id671601393233042">        &amp; ",'children': 
['Q','M','G','T'],'spouse': null}"</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id131601393240390">    s = Replace(s, "'", """")</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id351601393248554">    myDict.ImportFromJson(s, OverWrite := 
True)</paragraph>
-            <paragraph role="bascode" id="bas_id521601393254694">        '    
The (sub)-dictionaries "address" and "phoneNumbers(0) and (1) are reduced to 
Empty.</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id891601393212562">s = "{'firstName': 'John','lastName': 
'Smith','isAlive': true,'age': 66, 'birth':  '1954-09-28 20:15:00'" 
_</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id221601393220997">    &amp; ",'address': {'streetAddress': '21 2nd 
Street','city': 'New York','state': 'NY','postalCode': '10021-3100'}" 
_</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id931601393226582">    &amp; ",'phoneNumbers': [{'type': 
'home','number': '212 555-1234'},{'type': 'office','number': '646 555-4567'}]" 
_</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id671601393233042">    &amp; ",'children': ['Q','M','G','T'],'spouse': 
null}"</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id131601393240390">s = Replace(s, "'", """")</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id351601393248554">myDict.ImportFromJson(s, OverWrite := 
True)</paragraph>
+            <paragraph role="bascode" id="bas_id521601393254694">'The 
(sub)-dictionaries "address" and "phoneNumbers" (0) and (1) are imported as 
Empty values.</paragraph>
         </bascode>
     </section>
 
@@ -284,19 +313,20 @@
             <bookmark_value>Dictionary 
service;ImportFromPropertyValues</bookmark_value>
         </bookmark>
         <h2 id="hd_id71588941968955" 
localize="false">ImportFromPropertyValues</h2>
-        <paragraph role="paragraph" id="par_id651588941968228">Insert the 
content of an array of <literal>PropertyValues</literal> into the current 
dictionary. Names contain the new keys, values contain the new items. Returns 
<literal>True</literal> if successful.</paragraph>
+        <paragraph role="paragraph" id="par_id651588941968228">Inserts the 
contents of an array of <literal>PropertyValue</literal> objects into the 
current dictionary. <literal>PropertyValue</literal> Names are used as Keys in 
the dictionary, whereas Values contain the corresponding values. Returns 
<literal>True</literal> if successful.</paragraph>
         <h3 id="hd_id82158894196854" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
             <paragraph role="bascode" localize="false" 
id="bas_id961588941968180">myDict.ImportFromPropertyValues(PropertyValues As 
Variant [, Overwrite As Boolean]) As Boolean</paragraph>
         </bascode>
         <h3 id="hd_id271588941968528" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-        <paragraph role="paragraph" 
id="par_id751588941968522"><emph>PropertyValues</emph> : a zero-based 1 
dimension array. Each entry is a UNO object of type 
<literal>com.sun.star.beans.PropertyValue</literal>. The argument may also be a 
single item.</paragraph>
-        <paragraph role="paragraph" 
id="par_id21588941968131"><emph>Overwrite</emph> : when 
<literal>True</literal>, entries with same name may exist in the dictionary and 
their values are overwritten. When <literal>False</literal> (default), synonyms 
raise an error. Note that dictionary keys are not case-sensitive while names 
are case-sensitive in sets of property values.</paragraph>
+        <paragraph role="paragraph" 
id="par_id751588941968522"><emph>PropertyValues</emph> : A zero-based 1 
dimensional array containing 
<literal>com.sun.star.beans.PropertyValue</literal> objects. This parameter may 
also be a single <literal>PropertyValue</literal> object not contained in an 
Array.</paragraph>
+        <paragraph role="paragraph" 
id="par_id21588941968131"><emph>Overwrite</emph> : When 
<literal>True</literal>, entries with same name may exist in the dictionary and 
their values are overwritten. When <literal>False</literal> (default), repeated 
keys will raise an error. Note that dictionary keys are not case-sensitive, 
whereas names are case-sensitive in sets of property values.</paragraph>
         <h3 id="hd_id501588941968965" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
             <paragraph role="bascode" localize="false" 
id="bas_id951588941968987">Dim vProp As New 
com.sun.star.beans.PropertyValue</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id831588943409828">    vProp.Name = "prop"     :     vProp.Value = 
CDateToUnoDateTime(Now)</paragraph>
-            <paragraph role="bascode" localize="false" 
id="bas_id771588941968883">    myDict.ImportFromPropertyValues(vProp, Overwrite 
:= True)</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id831588943409828">vProp.Name = "prop"</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id891610395011237">vProp.Value = CDateToUnoDateTime(Now)</paragraph>
+            <paragraph role="bascode" localize="false" 
id="bas_id771588941968883">myDict.ImportFromPropertyValues(vProp, Overwrite := 
True)</paragraph>
         </bascode>
     </section>
 
@@ -306,16 +336,25 @@
         <bookmark_value>Dictionary service;Item</bookmark_value>
       </bookmark>
       <h2 id="hd_id301582098366573" localize="false">Item</h2>
-        <paragraph role="paragraph" id="par_id891582890366737">Retrieve an 
existing dictionary entry based on its key. Returns the value of the item if 
successful, otherwise <literal>Empty</literal>.</paragraph>
+        <paragraph role="paragraph" id="par_id891582890366737">Retrieves an 
existing dictionary entry based on its key. Returns the value of the item if 
successful, otherwise returns <literal>Empty</literal>.</paragraph>
         <h3 id="hd_id731582900366531" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id71588290366664">myDict.Item(Key As String) As Variant</paragraph>
         </bascode>
         <h3 id="hd_id751782890366698" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-          <paragraph role="paragraph" 
id="par_id551582890399669"><emph>Key</emph> : Not case-sensitive. Must exist in 
the dictionary, otherwise a <literal>UNKNOWNKEYERROR</literal> error is 
generated.</paragraph>
+          <paragraph role="paragraph" 
id="par_id551582890399669"><emph>Key</emph> : Not case-sensitive. Must exist in 
the dictionary, otherwise a <literal>UNKNOWNKEYERROR</literal> error is 
raised.</paragraph>
         <h3 id="hd_id81583890366375" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
+        <paragraph role="paragraph" id="par_id181610395933967">The following 
example iterates over all keys in the dictionary and uses the 
<literal>Item</literal> method to access their values.</paragraph>
         <bascode>
-          <paragraph role="bascode" localize="false" 
id="bas_id371528890366702">myDict.Item("Key")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id371528890366702">Dim myDict as Variant, k as Variant, allKeys as 
Variant</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id661610395517565">myDict = 
CreateScriptService("Dictionary")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id181610395523430">myDict.Add("key1", 100)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id621610395527679">myDict.Add("key2", 200)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id871610395530158">myDict.Add("key3", 300)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id891610395534807">allKeys = myDict.Keys</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id71610395537640">For Each k in allKeys</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id411610395540304">   MsgBox(myDict.Item(k))</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id931610395543522">Next k</paragraph>
        </bascode>
     </section>
 
@@ -325,16 +364,21 @@
         <bookmark_value>Dictionary service;Remove</bookmark_value>
       </bookmark>
       <h2 id="hd_id301582890366573" localize="false">Remove</h2>
-        <paragraph role="paragraph" id="par_id891582890388737">Remove an 
existing dictionary entry based on its key. Returns <literal>True</literal> if 
successful.</paragraph>
+        <paragraph role="paragraph" id="par_id891582890388737">Removes an 
existing dictionary entry based on its key. Returns <literal>True</literal> if 
successful.</paragraph>
         <h3 id="hd_id731582890366531" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id71582890366664">myDict.Remove(Key As String) As Boolean</paragraph>
         </bascode>
         <h3 id="hd_id771582890366698" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-          <paragraph role="paragraph" 
id="par_id551582890366999"><emph>Key</emph> : Not case-sensitive. Must exist in 
the dictionary, otherwise a <literal>UNKNOWNKEYERROR</literal> error is 
generated.</paragraph>
+          <paragraph role="paragraph" 
id="par_id551582890366999"><emph>Key</emph> : Not case-sensitive. Must exist in 
the dictionary, otherwise an <literal>UNKNOWNKEYERROR</literal> error is 
raised.</paragraph>
         <h3 id="hd_id81582890366375" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
-          <paragraph role="bascode" localize="false" 
id="bas_id371582890366702">myDict.Remove("OldKey")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id56158289627581">myDict.Add("key1", 100)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id651610399290742">myDict.Add("key2", 200)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id741610399296091">myDict.Add("key3", 300)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id591610399299316">MsgBox(myDict.Count) 'Prints "3"</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id661610399302807">myDict.Remove("key2")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id671610399305808">MsgBox(myDict.Count) 'Prints "2"</paragraph>
        </bascode>
     </section>
 
@@ -344,10 +388,19 @@
         <bookmark_value>Dictionary service;RemoveAll</bookmark_value>
       </bookmark>
       <h2 id="hd_id911582896275637" localize="false">RemoveAll</h2>
-        <paragraph role="paragraph" id="par_id921582896275624">Remove all the 
entries from the dictionary. Returns <literal>True</literal> if 
successful.</paragraph>
+        <paragraph role="paragraph" id="par_id921582896275624">Removes all the 
entries from the dictionary. Returns <literal>True</literal> if 
successful.</paragraph>
         <h3 id="hd_id161582896275448" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
-          <paragraph role="bascode" localize="false" 
id="bas_id56158289627581">myDict.RemoveAll() As Boolean</paragraph>
+          <paragraph role="bascode"  localize="false" 
id="bas_id561610400492690">myDict.RemoveAll() As Boolean</paragraph>
+        </bascode>
+        <h3 id="hd_id81582890366376" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
+        <bascode>
+          <paragraph role="bascode" localize="false" 
id="bas_id56158289627580">myDict.Add("key1", 100)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id651610399290743">myDict.Add("key2", 200)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id741610399296092">myDict.Add("key3", 300)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id591610399299317">MsgBox(myDict.Count) 'Prints "3"</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id661610399302808">myDict.RemoveAll()</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id671610399305809">MsgBox(myDict.Count) 'Prints "0"</paragraph>
         </bascode>
     </section>
 
@@ -357,18 +410,20 @@
         <bookmark_value>Dictionary service;ReplaceItem</bookmark_value>
       </bookmark>
       <h2 id="hd_id801582895615477" localize="false">ReplaceItem</h2>
-        <paragraph role="paragraph" id="par_id281582895615444">Replace an 
existing item value based on its key. Returns <literal>True</literal> if 
successful.</paragraph>
+        <paragraph role="paragraph" id="par_id281582895615444">Replaces an 
existing item value based on its key. Returns <literal>True</literal> if 
successful.</paragraph>
         <h3 id="hd_id66158289561569" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id51582895615226">myDict.ReplaceItem(Key As String, Value As Variant) 
As Boolean</paragraph>
         </bascode>
         <h3 id="hd_id521582895615249" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-          <paragraph role="paragraph" 
id="par_id991582895615535"><emph>Key</emph> : Not case-sensitive. Must exist in 
the dictionary, otherwise a <literal>UNKNOWNKEYERROR</literal> error is 
generated.</paragraph>
-          <paragraph role="paragraph" 
id="par_id721582895615186"><emph>Value</emph> : The new value of the item part 
of the dictionary entry.</paragraph>
+          <paragraph role="paragraph" 
id="par_id991582895615535"><emph>Key</emph> : String value representing the key 
whose value will be replaced. Not case-sensitive. If the key does not exist in 
the dictionary, a <literal>UNKNOWNKEYERROR</literal> error is 
raised.</paragraph>
+          <paragraph role="paragraph" 
id="par_id721582895615186"><emph>Value</emph> : The new value of the item 
referred to with the Key parameter.</paragraph>
         <h3 id="hd_id781582895615372" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
-          <paragraph role="bascode" localize="false" 
id="bas_id581582895615680">Dim NewValue As Variant</paragraph>
-          <paragraph role="bascode" localize="false" 
id="bas_id351582895615555">    myDict.ReplaceItem("ExistingKey", 
NewValue)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id581582895615680">myDict.Add("a", 1)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id351582895615555">MsgBox(myDict.Item("a")) 'Prints "1"</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id361610399892402">myDict.ReplaceItem("a", 100)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id411610399896001">MsgBox(myDict.Item("a")) ' Prints "100"</paragraph>
        </bascode>
     </section>
 
@@ -378,17 +433,20 @@
         <bookmark_value>Dictionary service;ReplaceKey</bookmark_value>
       </bookmark>
       <h2 id="hd_id231582896597839" localize="false">ReplaceKey</h2>
-        <paragraph role="paragraph" id="par_id571582896597766">Replace an 
existing key with a new value. The item part is left unchanged. Returns 
<literal>True</literal> if successful.</paragraph>
+        <paragraph role="paragraph" id="par_id571582896597766">Replaces an 
existing key in the dictionary by a new key. The item value is left unchanged. 
Returns <literal>True</literal> if successful.</paragraph>
         <h3 id="hd_id441582896597550" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
         <bascode>
           <paragraph role="bascode" localize="false" 
id="bas_id351582896597447">myDict.ReplaceKey(Key As String, Value As String) As 
Boolean</paragraph>
         </bascode>
         <h3 id="hd_id791582896597306" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
-          <paragraph role="paragraph" 
id="par_id911582896597619"><emph>Key</emph> : Not case-sensitive. Must exist in 
the dictionary, otherwise a <literal>UNKNOWNKEYERROR</literal> error is 
generated.</paragraph>
-          <paragraph role="paragraph" 
id="par_id531582896597989"><emph>Value</emph> : Not case-sensitive. Must not 
exist in the dictionary, otherwise a <literal>DUPLICATEKEYERROR</literal> error 
is generated.</paragraph>
+          <paragraph role="paragraph" 
id="par_id911582896597619"><emph>Key</emph> : String value representing the key 
to be be replaced. Not case-sensitive. If the key does not exist in the 
dictionary, a <literal>UNKNOWNKEYERROR</literal> error is raised.</paragraph>
+          <paragraph role="paragraph" 
id="par_id531582896597989"><emph>Value</emph> : String value for the new key. 
Not case-sensitive. If the new key already exists in the dictionary, a 
<literal>DUPLICATEKEYERROR</literal> error is raised.</paragraph>
         <h3 id="hd_id931582896597782" localize="false"><embedvar 
href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
         <bascode>
-          <paragraph role="bascode" localize="false" 
id="bas_id521582896597313"> myDict.ReplaceKey("OldKey", "NewKey")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id521582896597313">myDict.Add("oldKey", 100)</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id961610400326541">MsgBox(myDict.Item("oldKey")) 'Prints 
"100"</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id631610400329115">myDict.ReplaceKey("oldKey", "newKey")</paragraph>
+          <paragraph role="bascode" localize="false" 
id="bas_id761610400331545">MsgBox(myDict.Item("newKey")) ' Prints 
"100"</paragraph>
        </bascode>
     </section>
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to