25 ScriptForge libraries are an extensible and robust collection of macro scripting resources
for LibreOffice
26 to be invoked
from user Basic
or Python macros. Users familiar
with other BASIC macro variants often face hard
27 times to dig into the extensive LibreOffice Application Programming Interface even
for the simplest operations.
28 By collecting most-demanded document operations
in a set of easy to use, easy to read routines, users can now
29 program document macros
with much less hassle
and get quicker results.
31 ScriptForge abundant methods are organized
in reusable modules that cleanly isolate Basic/Python programming
32 language constructs
from ODF document content accesses
and user interface(UI) features.
34 The scriptforge.py module
35 - implements a protocol between Python (user) scripts
and the ScriptForge Basic library
36 - contains the interfaces (classes
and attributes) to be used
in Python user scripts
37 to run the services implemented
in the standard libraries shipped
with LibreOffice
41 When Python
and LibreOffice run
in the same process (usual case): either
42 from scriptforge
import *
43 from scriptforge
import CreateScriptService
45 When Python
and LibreOffice are started
in separate processes,
46 LibreOffice being started
from console ... (example
for Linux
with port = 2021)
47 ./soffice --accept=
'socket,host=localhost,port=2021;urp;'
48 then use next statement:
49 from scriptforge
import *
50 from scriptforge
import CreateScriptService, ScriptForge
53 Specific documentation about the use of ScriptForge
from Python scripts:
54 https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_intro.html?DbPAR=BASIC
64class _Singleton(type):
66 A Singleton metaclass design pattern
67 Credits: « Python in a Nutshell » by Alex Martelli, O
'Reilly
83 The ScriptForge (singleton) class encapsulates the
core of the
ScriptForge run-time
84 - Bridge
with the LibreOffice process
85 - Implementation of the inter-language protocol
with the Basic libraries
86 - Identification of the available services interfaces
87 - Dispatching of services
88 - Coexistence
with UNO
90 It embeds the Service
class that manages the protocol with Basic
98 componentcontext =
None
100 SCRIPTFORGEINITDONE =
False
105 library =
'ScriptForge'
109 basicdispatcher =
'@application#ScriptForge.SF_PythonHelper._PythonDispatcher'
111 pythonhelpermodule =
'ScriptForgeHelper.py'
114 V_EMPTY, V_NULL, V_INTEGER, V_LONG, V_SINGLE, V_DOUBLE = 0, 1, 2, 3, 4, 5
115 V_CURRENCY, V_DATE, V_STRING, V_OBJECT, V_BOOLEAN = 6, 7, 8, 9, 11
116 V_VARIANT, V_ARRAY, V_ERROR, V_UNO = 12, 8192, -1, 16
118 objMODULE, objCLASS, objUNO = 1, 2, 3
120 cstSymEmpty, cstSymNull, cstSymMissing =
'+++EMPTY+++',
'+++NULL+++',
'+++MISSING+++'
122 servicesmodules = dict([(
'ScriptForge.Array', 0),
123 (
'ScriptForge.Exception', 1),
124 (
'ScriptForge.FileSystem', 2),
125 (
'ScriptForge.Platform', 3),
126 (
'ScriptForge.Region', 4),
127 (
'ScriptForge.Services', 5),
128 (
'ScriptForge.Session', 6),
129 (
'ScriptForge.String', 7),
130 (
'ScriptForge.UI', 8)])
134 Because singleton, constructor is executed only once
while Python active
135 Arguments are mandatory when Python
and LibreOffice run
in separate processes
136 :param hostname: probably
'localhost'
137 :param port: port number
139 ScriptForge.hostname = hostname
140 ScriptForge.port = port
146 ScriptForge.serviceslist = dict((cls.servicename, cls)
for cls
in SFServices.__subclasses__())
147 ScriptForge.servicesdispatcher =
None
151 ScriptForge.SetAttributeSynonyms()
153 ScriptForge.SCRIPTFORGEINITDONE =
True
158 Called by the ScriptForge class constructor to establish the connection with
159 the requested LibreOffice instance
160 The default arguments are
for the usual interactive mode
162 :param hostname: probably
'localhost' or ''
163 :param port: port number
or 0
164 :
return: the derived component context
166 if len(hostname) > 0
and port > 0:
168 resolver = ctx.ServiceManager.createInstanceWithContext(
169 'com.sun.star.bridge.UnoUrlResolver', ctx)
171 conn =
'socket,host=%s,port=%d' % (hostname, port)
172 url =
'uno:%s;urp;StarOffice.ComponentContext' % conn
173 ctx = resolver.resolve(url)
176 'Connection to LibreOffice failed (host = ' + hostname +
', port = ' + str(port) +
')')
178 elif len(hostname) == 0
and port == 0:
181 raise SystemExit(
'The creation of the ScriptForge() instance got invalid arguments: '
182 +
'(host = ' + hostname +
', port = ' + str(port) +
')')
187 Returns the general script provider
189 servicemanager = context.ServiceManager
190 masterscript = servicemanager.createInstanceWithContext(
191 'com.sun.star.script.provider.MasterScriptProviderFactory', context)
192 return masterscript.createScriptProvider(
"")
197 Create a UNO object corresponding with the given Python
or Basic script
198 The execution
is done
with the invoke() method applied on the created object
199 Implicit scope: Either
200 "application" a shared library (BASIC)
201 "share" a library of LibreOffice Macros (PYTHON)
202 :param script: Either
204 [@] means that the targeted method accepts ParamArray arguments (Basic only)
206 :
return: the value returned by the invoked script,
or an error
if the script was
not found
216 elif len(script) > 0:
224 scope, script = script.split(
'#')
225 if '.py$' in script.lower():
232 scope, script = script.split(
'#')
233 uri =
'vnd.sun.star.script:{0}?language=Python&location={1}'.format(script, scope)
236 scope =
'application'
238 if len(script.split(
'.')) < 3:
240 uri =
'vnd.sun.star.script:{0}{1}?language=Basic&location={2}'.format(lib, script, scope)
242 fullscript = (
'@' if paramarray
else '') + scope +
':' + script
247 'The script \'{0}\' could not be located in your LibreOffice installation'.format(script))
258 scriptreturn = xscript.invoke(args[0], (), ())
260 scriptreturn = xscript.invoke(args, (), ())
263 return scriptreturn[0]
268 Execute a given Basic script and interpret its result
269 This method has
as counterpart the ScriptForge.SF_PythonHelper._PythonDispatcher() Basic method
270 :param basicobject: a Service subclass
271 :param flags: see the vb*
and flg* constants
in the SFServices
class
272 :param method: the name of the method
or property to invoke,
as a string
273 :param args: the arguments of the method. Symbolic cst* constants may be necessary
274 :
return: The invoked Basic counterpart script (
with InvokeSimpleScript()) will
return a tuple
275 [0] The returned value - scalar, object reference
or a tuple
276 [1] The Basic VarType() of the returned value
277 Null, Empty
and Nothing have different vartypes but
return all
None to Python
278 Additionally, when [0]
is a tuple:
279 [2] Number of dimensions
in Basic
280 Additionally, when [0]
is a UNO
or Basic object:
281 [2] Module (1), Class instance (2)
or UNO (3)
282 [3] The object
's ObjectType
283 [4] The object's ServiceName
284 [5] The object's name
285 When an error occurs Python receives None as a scalar. This determines the occurrence of a failure
286 The method returns either
287 - the 0th element of the tuple when scalar, tuple
or UNO object
288 - a new Service() object
or one of its subclasses otherwise
291 script = ScriptForge.basicdispatcher
292 cstNoArgs =
'+++NOARGS+++'
293 cstValue, cstVarType, cstDims, cstClass, cstType, cstService, cstName = 0, 1, 2, 2, 3, 4, 5
299 args = (basicobject,) + (flags,) + (method,) + (cstNoArgs,)
301 args = (basicobject,) + (flags,) + (method,) + args
306 if not isinstance(returntuple, (tuple, list)):
307 raise RuntimeError(
"The execution of the method '" + method +
"' failed. Execution stops.")
310 if returntuple[cstVarType] == ScriptForge.V_OBJECT
and len(returntuple) > cstClass:
311 if returntuple[cstClass] == ScriptForge.objUNO:
315 servname = returntuple[cstService]
316 if servname
not in cls.serviceslist:
318 raise RuntimeError(
"The service '" + servname +
"' is not available in Python. Execution stops.")
319 subcls = cls.serviceslist[servname]
320 if subcls
is not None:
321 return subcls(returntuple[cstValue], returntuple[cstType], returntuple[cstClass],
322 returntuple[cstName])
323 elif returntuple[cstVarType] >= ScriptForge.V_ARRAY:
327 elif returntuple[cstVarType] == ScriptForge.V_DATE:
328 dat = SFScriptForge.SF_Basic.CDateFromUnoDateTime(returntuple[cstValue])
332 return returntuple[cstValue]
337 A synonym of an attribute is either the lowercase
or the camelCase form of its original ProperCase name.
338 In every subclass of SFServices:
339 1) Fill the propertysynonyms dictionary
with the synonyms of the properties listed
in serviceproperties
341 serviceproperties = dict(ConfigFolder =
False, InstallFolder =
False)
342 propertysynonyms = dict(configfolder =
'ConfigFolder', installfolder =
'InstallFolder',
343 configFolder =
'ConfigFolder', installFolder =
'InstallFolder')
344 2) Define new method attributes synonyms of the original methods
348 copyFile, copyfile = CopyFile, CopyFile
352 return key[0].lower() + key[1:]
354 for cls
in SFServices.__subclasses__():
356 if hasattr(cls,
'serviceproperties'):
357 dico = cls.serviceproperties
358 dicosyn = dict(zip(map(str.lower, dico.keys()), dico.keys()))
359 cc = dict(zip(map(camelCase, dico.keys()), dico.keys()))
361 setattr(cls,
'propertysynonyms', dicosyn)
363 methods = [method
for method
in dir(cls)
if not method.startswith(
'_')]
364 for method
in methods:
365 func = getattr(cls, method)
369 setattr(cls, lc, func)
370 cc = camelCase(method)
372 setattr(cls, cc, func)
378 Convert a dictionary passed as argument to a list alternating keys
and values
380 dict(A =
'a', B = 2) =>
'A',
'a',
'B', 2
382 return [v
for p
in zip(list(kwargs.keys()), list(kwargs.values()))
for v
in p]
391 Generic implementation of a parent Service class
392 Every service must subclass this
class to be recognized as a valid service
393 A service instance
is created by the CreateScriptService method
394 It can have a mirror
in the Basic world
or be totally defined
in Python
396 Every subclass must initialize 3
class properties:
397 servicename (e.g.
'ScriptForge.FileSystem',
'ScriptForge.Basic')
398 servicesynonyms (e.g.
'FileSystem',
'Basic')
399 serviceimplementation: either
'python' or 'basic'
400 This
is sufficient to register the service
in the Python world
402 The communication
with Basic
is managed by 2
ScriptForge() methods:
403 InvokeSimpleScript(): low level invocation of a Basic script. This script must be located
404 in a usual Basic module. The result
is passed
as-
is
405 InvokeBasicService(): the result comes back encapsulated
with additional info
406 The result
is interpreted
in the method
407 The invoked script can be a property
or a method of a Basic
class or usual module
408 It
is up to every service method to determine which method to use
410 For Basic services only:
411 Each instance
is identified by its
412 - object reference: the real Basic object embedded
as a UNO wrapper object
413 - object type (
'SF_String',
'DICTIONARY', ...)
414 -
class module: 1
for usual modules, 2
for class modules
415 - name (form, control, ... name) - may be blank
417 The role of the
SFServices() superclass
is mainly to propose a generic properties management
418 Properties are got
and set following next strategy:
419 1. Property names are controlled strictly (
'Value' or 'value',
not 'VALUE')
420 2. Getting a property value
for the first time
is always done via a Basic call
421 3. Next occurrences are fetched
from the Python dictionary of the instance
if the property
422 is read-only, otherwise via a Basic call
423 4. Read-only properties may be modified
or deleted exceptionally by the
class
424 when self.
internal ==
True. The latter must immediately be reset after use
426 Each subclass must define its interface
with the user scripts:
428 Property names are proper-cased
429 Conventionally, camel-cased
and lower-cased synonyms are supported where relevant
430 a dictionary named
'serviceproperties' with keys = (proper-cased) property names
and value = boolean
431 True = editable,
False = read-only
432 a list named
'localProperties' reserved to properties
for internal use
433 e.g. oDlg.Controls()
is a method that uses
'_Controls' to hold the list of available controls
435 forceGetProperty =
False
436 read-only serviceproperties are buffered
in Python after their 1st get request to Basic
437 Otherwise set it to
True to force a recomputation at each property getter invocation
438 If there
is a need to handle a specific property
in a specific manner:
440 def myProperty(self):
443 a usual
def: statement
444 def myMethod(self, arg1, arg2 = ''):
445 return self.Execute(self.
vbMethod,
'myMethod', arg1, arg2)
446 Method names are proper-cased, arguments are lower-cased
447 Conventionally, camel-cased
and lower-cased homonyms are supported where relevant
448 All arguments must be present
and initialized before the call to Basic,
if any
451 vbGet, vbLet, vbMethod, vbSet = 2, 4, 1, 8
461 moduleClass, moduleStandard = 2, 1
464 forceGetProperty =
False
466 propertysynonyms = {}
469 internal_attributes = (
'objectreference',
'objecttype',
'name',
'internal',
'servicename',
470 'serviceimplementation',
'classmodule',
'EXEC',
'SIMPLEEXEC')
472 SIMPLEEXEC = ScriptForge.InvokeSimpleScript
473 EXEC = ScriptForge.InvokeBasicService
475 def __init__(self, reference = -1, objtype = None, classmodule = 0, name = ''):
477 Trivial initialization of internal properties
478 If the subclass has its own __init()__ method, a call to this one should be its first statement.
479 Afterwards localProperties should be filled with the list of its own properties
490 Executed for EVERY property reference
if name
not yet
in the instance dict
491 At the 1st get, the property value
is always got
from Basic
492 Due to the use of lower/camelcase synonyms, it
is called
for each variant of the same property
493 The method manages itself the buffering
in __dict__ based on the official ProperCase property name
498 if name
in (
'serviceproperties',
'localProperties',
'internal_attributes',
'propertysynonyms',
501 elif name
in self.serviceproperties:
502 if self.
forceGetProperty is False and self.serviceproperties[name]
is False:
503 if name
in self.__dict__:
504 return self.__dict__[name]
508 self.__dict__[name] = prop
513 return super(SFServices, self).__getattribute__(name)
517 Executed for EVERY property assignment, including
in __init__() !!
518 Setting a property requires
for serviceproperties() to be executed
in Basic
519 Management of __dict__
is automatically done
in the final usual object.__setattr__ method
522 if name
in (
'serviceproperties',
'localProperties',
'internal_attributes',
'propertysynonyms',
532 elif self.serviceproperties[name]
is True:
536 raise AttributeError(
537 "type object '" + self.
objecttype +
"' has no editable property '" + name +
"'")
539 raise AttributeError(
"type object '" + self.
objecttype +
"' has no property '" + name +
"'")
540 object.__setattr__(self, name, value)
556 if len(methodname) > 0:
561 Get the given property from the Basic world
565 calltype = self.
vbGet + (self.
flgUno if propertyname[0] ==
'X' else 0)
573 return list(self.serviceproperties)
589 Set the given property to a new value in the Basic world
593 if isinstance(value, datetime.datetime):
594 value = SFScriptForge.SF_Basic.CDateToUnoDateTime(value)
596 if repr(type(value)) ==
"<class 'pyuno'>":
612 Provides a collection of methods for manipulating
and transforming arrays of one dimension (vectors)
613 and arrays of two dimensions (matrices). This includes set operations, sorting,
614 importing to
and exporting
from text files.
615 The Python version of the service provides a single method: ImportFromCSVFile
618 serviceimplementation =
'basic'
619 servicename =
'ScriptForge.Array'
620 servicesynonyms = (
'array',
'scriptforge.array')
621 serviceproperties = dict()
625 Difference with the Basic version: dates are returned
in their iso format,
626 not as any of the datetime objects.
629 filename, delimiter, dateformat)
636 This service proposes a collection of Basic methods to be executed in a Python context
637 simulating the exact syntax
and behaviour of the identical Basic builtin method.
639 SF_Basic.MsgBox(
'This has to be displayed in a message box')
641 The signatures of Basic builtin functions are derived
from
642 core/basic/source/runtime/stdobj.cxx
644 Detailed user documentation:
645 https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_basic.html?DbPAR=BASIC
648 serviceimplementation =
'python'
649 servicename =
'ScriptForge.Basic'
650 servicesynonyms = (
'basic',
'scriptforge.basic')
652 module =
'SF_PythonHelper'
654 MB_ABORTRETRYIGNORE, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3 = 2, 128, 256, 512
655 MB_ICONEXCLAMATION, MB_ICONINFORMATION, MB_ICONQUESTION, MB_ICONSTOP = 48, 64, 32, 16
656 MB_OK, MB_OKCANCEL, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL = 0, 1, 5, 4, 3
657 IDABORT, IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY, IDYES = 3, 2, 5, 7, 1, 4, 6
667 Converts a UNO date/time representation to a datetime.datetime Python native object
668 :param unodate: com.sun.star.util.DateTime, com.sun.star.util.Date or com.sun.star.util.Time
669 :
return: the equivalent datetime.datetime
671 date = datetime.datetime(1899, 12, 30, 0, 0, 0, 0)
672 datetype = repr(type(unodate))
673 if 'com.sun.star.util.DateTime' in datetype:
674 if 1900 <= unodate.Year <= datetime.MAXYEAR:
675 date = datetime.datetime(unodate.Year, unodate.Month, unodate.Day, unodate.Hours,
676 unodate.Minutes, unodate.Seconds, int(unodate.NanoSeconds / 1000))
677 elif 'com.sun.star.util.Date' in datetype:
678 if 1900 <= unodate.Year <= datetime.MAXYEAR:
679 date = datetime.datetime(unodate.Year, unodate.Month, unodate.Day)
680 elif 'com.sun.star.util.Time' in datetype:
681 date = datetime.datetime(unodate.Hours, unodate.Minutes, unodate.Seconds,
682 int(unodate.NanoSeconds / 1000))
690 Converts a date representation into the ccom.sun.star.util.DateTime date format
691 Acceptable boundaries: year >= 1900 and <= 32767
692 :param date: datetime.datetime, datetime.date, datetime.time, float (time.time)
or time.struct_time
693 :
return: a com.sun.star.util.DateTime
696 unodate.Year, unodate.Month, unodate.Day, unodate.Hours, unodate.Minutes, unodate.Seconds, \
697 unodate.NanoSeconds, unodate.IsUTC = \
698 1899, 12, 30, 0, 0, 0, 0,
False
700 if isinstance(date, float):
701 date = time.localtime(date)
702 if isinstance(date, time.struct_time):
703 if 1900 <= date[0] <= 32767:
704 unodate.Year, unodate.Month, unodate.Day, unodate.Hours, unodate.Minutes, unodate.Seconds = \
707 unodate.Hours, unodate.Minutes, unodate.Seconds = date[3:3]
708 elif isinstance(date, (datetime.datetime, datetime.date, datetime.time)):
709 if isinstance(date, (datetime.datetime, datetime.date)):
710 if 1900 <= date.year <= 32767:
711 unodate.Year, unodate.Month, unodate.Day = date.year, date.month, date.day
712 if isinstance(date, (datetime.datetime, datetime.time)):
713 unodate.Hours, unodate.Minutes, unodate.Seconds, unodate.NanoSeconds = \
714 date.hour, date.minute, date.second, date.microsecond * 1000
737 if isinstance(date, datetime.datetime):
743 def DateDiff(cls, interval, date1, date2, firstdayofweek = 1, firstweekofyear = 1):
744 if isinstance(date1, datetime.datetime):
746 if isinstance(date2, datetime.datetime):
748 return cls.
SIMPLEEXEC(cls.
module +
'.PyDateDiff', interval, date1, date2, firstdayofweek, firstweekofyear)
751 def DatePart(cls, interval, date, firstdayofweek = 1, firstweekofyear = 1):
752 if isinstance(date, datetime.datetime):
754 return cls.
SIMPLEEXEC(cls.
module +
'.PyDatePart', interval, date, firstdayofweek, firstweekofyear)
758 if isinstance(string, datetime.datetime):
759 string = string.isoformat()
764 def Format(cls, expression, format = ''):
765 if isinstance(expression, datetime.datetime):
771 return ScriptForge.componentcontext
788 return ScriptForge.InvokeSimpleScript(SFScriptForge.SF_Basic.module +
'.PyGlobalScope',
'Basic')
792 return ScriptForge.InvokeSimpleScript(SFScriptForge.SF_Basic.module +
'.PyGlobalScope',
'Dialog')
795 def InputBox(cls, prompt, title = '', default = '', xpostwips = -1, ypostwips = -1):
796 if xpostwips < 0
or ypostwips < 0:
798 return cls.
SIMPLEEXEC(cls.
module +
'.PyInputBox', prompt, title, default, xpostwips, ypostwips)
801 def MsgBox(cls, prompt, buttons = 0, title = ''):
806 return datetime.datetime.now()
809 def RGB(cls, red, green, blue):
810 return int(
'%02x%02x%02x' % (red, green, blue), 16)
814 ctx = ScriptForge.componentcontext
817 smgr = ctx.getServiceManager()
818 DESK =
'com.sun.star.frame.Desktop'
819 desktop = smgr.createInstanceWithContext(DESK, ctx)
822 starDesktop, stardesktop = StarDesktop, StarDesktop
827 When the current component is the Basic IDE, the ThisComponent object returns
828 in Basic the component owning the currently run user script.
829 Above behaviour cannot be reproduced
in Python.
830 :
return: the current component
or None when
not a document
835 impl = comp.ImplementationName
836 if impl
in (
'com.sun.star.comp.basic.BasicIDE',
'com.sun.star.comp.sfx2.BackingComp'):
840 thisComponent, thiscomponent = ThisComponent, ThisComponent
845 When the current component is the Basic IDE, the ThisDatabaseDocument object returns
846 in Basic the database owning the currently run user script.
847 Above behaviour cannot be reproduced
in Python.
848 :
return: the current Base (main) component
or None when
not a Base document
or one of its subcomponents
856 if sess.HasUnoProperty(comp,
'ImplementationName'):
857 impl = comp.ImplementationName
858 if sess.HasUnoProperty(comp,
'Identifier'):
859 ident = comp.Identifier
861 targetimpl =
'com.sun.star.comp.dba.ODatabaseDocument'
862 if impl == targetimpl:
865 if impl ==
'SwXTextDocument' and ident ==
'com.sun.star.sdb.FormDesign' \
866 or impl ==
'org.openoffice.comp.dbu.ODatasourceBrowser' \
867 or impl
in (
'org.openoffice.comp.dbu.OTableDesign',
'org.openoffice.comp.dbu.OQuertDesign') \
868 or impl ==
'SwXTextDocument' and ident ==
'com.sun.star.sdb.TextReportDesign' \
869 or impl ==
'org.openoffice.comp.dbu.ORelationDesign':
870 db = comp.ScriptContainer
871 if sess.HasUnoProperty(db,
'ImplementationName'):
872 if db.ImplementationName == targetimpl:
876 thisDatabaseDocument, thisdatabasedocument = ThisDatabaseDocument, ThisDatabaseDocument
879 def Xray(cls, unoobject = None):
880 return cls.
SIMPLEEXEC(
'XrayTool._main.xray', unoobject)
887 The service adds to a Python dict instance the interfaces for conversion to
and from
888 a list of UNO PropertyValues
891 dico = dict(A = 1, B = 2, C = 3)
895 propval = myDict.ConvertToPropertyValues()
897 dico = dict(A = 1, B = 2, C = 3)
902 propval = myDict.ConvertToPropertyValues()
905 serviceimplementation =
'python'
906 servicename =
'ScriptForge.Dictionary'
907 servicesynonyms = (
'dictionary',
'scriptforge.dictionary')
910 SFServices.__init__(self)
917 Store the content of the dictionary in an array of PropertyValues.
918 Each entry
in the array
is a com.sun.star.beans.PropertyValue.
919 he key
is stored
in Name, the value
is stored
in Value.
921 If one of the items has a type datetime, it
is converted to a com.sun.star.util.DateTime structure.
922 If one of the items
is an empty list, it
is converted to
None.
924 The resulting array
is empty when the dictionary
is empty.
927 for key
in iter(self):
930 if isinstance(value, dict):
932 elif isinstance(value, (tuple, list)):
936 for i
in range(len(value)):
937 if isinstance(value[i], dict):
940 elif isinstance(value, (datetime.datetime, datetime.date, datetime.time)):
941 item = SFScriptForge.SF_Basic.CDateToUnoDateTime(value)
950 Inserts the contents of an array of PropertyValue objects into the current dictionary.
951 PropertyValue Names are used as keys
in the dictionary, whereas Values contain the corresponding values.
952 Date-type values are converted to datetime.datetime instances.
953 :param propertyvalues: a list.tuple containing com.sun.star.beans.PropertyValue objects
954 :param overwrite: When
True, entries
with same name may exist
in the dictionary
and their values
955 are overwritten. When
False (default), repeated keys are
not overwritten.
956 :
return:
True when successful
959 for pv
in iter(propertyvalues):
961 if overwrite
is True or key
not in self:
963 if 'com.sun.star.util.DateTime' in repr(type(item)):
964 item = datetime.datetime(item.Year, item.Month, item.Day,
965 item.Hours, item.Minutes, item.Seconds, int(item.NanoSeconds / 1000))
966 elif 'com.sun.star.util.Date' in repr(type(item)):
967 item = datetime.datetime(item.Year, item.Month, item.Day)
968 elif 'com.sun.star.util.Time' in repr(type(item)):
969 item = datetime.datetime(item.Hours, item.Minutes, item.Seconds, int(item.NanoSeconds / 1000))
970 result.append((key, item))
979 The Exception service is a collection of methods
for code debugging
and error handling.
981 The Exception service console stores events, variable values
and information about errors.
982 Use the console when the Python shell
is not available,
for example
in Calc user defined functions (UDF)
983 or during events processing.
984 Use
DebugPrint() method to aggregate additional user data of any type.
986 Console entries can be dumped to a text file
or visualized
in a dialogue.
989 serviceimplementation =
'basic'
990 servicename =
'ScriptForge.Exception'
991 servicesynonyms = (
'exception',
'scriptforge.exception')
992 serviceproperties = dict()
1007 param =
'\n'.join(list(map(
lambda a: a.strip(
"'")
if isinstance(a, str)
else repr(a), args)))
1009 return bas.MsgBox(param, bas.MB_OK + bas.MB_ICONINFORMATION,
'DebugDisplay')
1014 param =
'\t'.join(list(map(
lambda a: a.strip(
"'")
if isinstance(a, str)
else repr(a),
1015 args))).expandtabs(tabsize = 4)
1021 Open an APSO python shell window - Thanks to its authors Hanya/Tsutomu Uchino/Hubert Lambert
1022 :param variables: Typical use
1023 PythonShell.({**globals(), **locals()})
1024 to push the global and local dictionaries to the shell window
1026 if variables
is None:
1027 variables = locals()
1029 ctx = ScriptForge.componentcontext
1030 ext = ctx.getByName(
'/singletons/com.sun.star.deployment.PackageInformationProvider')
1031 apso =
'apso.python.script.organizer'
1032 if len(ext.getPackageLocation(apso)) > 0:
1035 if ScriptForge.port > 0:
1039 ctx.ServiceManager.createInstance(
'apso.python.script.organizer.impl')
1041 from apso_utils
import console
1042 kwargs = {
'loc': variables}
1043 kwargs[
'loc'].setdefault(
'XSCRIPTCONTEXT', uno)
1047 SFScriptForge.SF_Basic.GetGuiType()
1050 cls.
_RaiseFatal(
'SF_Exception.PythonShell',
'variables=None',
'PYTHONSHELLERROR')
1055 Generate a run-time error caused by an anomaly in a user script detected by ScriptForge
1056 The message
is logged
in the console. The execution
is STOPPED
1057 For INTERNAL USE only
1062 return cls.
SIMPLEEXEC(
'@SF_Exception.RaiseFatal', (errorcode, *args))
1067 Wrapper of RaiseFatal(). Includes method and syntax of the failed Python routine
1068 to simulate the exact behaviour of the Basic
RaiseFatal() method
1069 For INTERNAL USE only
1071 ScriptForge.InvokeSimpleScript('ScriptForge.SF_Utils._EnterFunction', sub, subargs)
1073 raise RuntimeError(
"The execution of the method '" + sub.split(
'.')[-1] +
"' failed. Execution stops.")
1080 The "FileSystem" service includes common file
and folder handling routines.
1083 serviceimplementation =
'basic'
1084 servicename =
'ScriptForge.FileSystem'
1085 servicesynonyms = (
'filesystem',
'scriptforge.filesystem')
1086 serviceproperties = dict(FileNaming =
True, ConfigFolder =
False, ExtensionsFolder =
False, HomeFolder =
False,
1087 InstallFolder =
False, TemplatesFolder =
False, TemporaryFolder =
False,
1088 UserTemplatesFolder =
False)
1090 forceGetProperty =
True
1092 ForReading, ForWriting, ForAppending = 1, 2, 8
1098 py = ScriptForge.pythonhelpermodule +
'$' +
'_SF_FileSystem__CompareFiles'
1102 return self.
SIMPLEEXEC(py, file1, file2, comparecontents)
1106 def CopyFile(self, source, destination, overwrite = True):
1116 return self.
ExecMethod(self.
vbMethod,
'CreateTextFile', filename, overwrite, encoding)
1130 def Files(self, foldername, filter = '', includesubfolders = False):
1131 return self.
ExecMethod(self.
vbMethod,
'Files', foldername, filter, includesubfolders)
1143 py = ScriptForge.pythonhelpermodule +
'$' +
'_SF_FileSystem__GetFilelen'
1163 py = ScriptForge.pythonhelpermodule +
'$' +
'_SF_FileSystem__HashFile'
1166 return self.
SIMPLEEXEC(py, file, algorithm.lower())
1179 def OpenTextFile(self, filename, iomode = 1, create = False, encoding = 'UTF-8'):
1180 return self.
ExecMethod(self.
vbMethod,
'OpenTextFile', filename, iomode, create, encoding)
1182 def PickFile(self, defaultfile = ScriptForge.cstSymEmpty, mode = 'OPEN', filter = ''):
1185 def PickFolder(self, defaultfolder = ScriptForge.cstSymEmpty, freetext = ''):
1188 def SubFolders(self, foldername, filter = '', includesubfolders = False):
1189 return self.
ExecMethod(self.
vbMethod,
'SubFolders', foldername, filter, includesubfolders)
1194 return cls.
SIMPLEEXEC(
'ScriptForge.SF_FileSystem._ConvertFromUrl', filename)
1201 This service provides a number of methods related to the translation of strings
1202 with minimal impact on the program
's source code.
1203 The methods provided by the L10N service can be used mainly to:
1204 Create POT files that can be used as templates
for translation of all strings
in the program.
1205 Get translated strings at runtime
for the language defined
in the Locale property.
1208 serviceimplementation =
'basic'
1209 servicename =
'ScriptForge.L10N'
1210 servicesynonyms = (
'l10n',
'scriptforge.l10n')
1211 serviceproperties = dict(Folder =
False, Languages =
False, Locale =
False)
1215 locale2 = '', encoding2 = 'UTF-8'):
1217 Transform positional and keyword arguments into positional only
1219 return foldername, locale, encoding, locale2, encoding2
1221 def AddText(self, context = '', msgid = '', comment = ''):
1241 The 'Platform' service implements a collection of properties about the actual execution environment
1243 the hardware platform
1244 the operating system
1245 the LibreOffice version
1247 All those properties are read-only.
1248 The implementation
is mainly based on the
'platform' module of the Python standard library
1251 serviceimplementation =
'basic'
1252 servicename =
'ScriptForge.Platform'
1253 servicesynonyms = (
'platform',
'scriptforge.platform')
1254 serviceproperties = dict(Architecture =
False, ComputerName =
False, CPUCount =
False, CurrentUser =
False,
1255 Extensions =
False, FilterNames =
False, Fonts =
False, FormatLocale =
False,
1256 Locale =
False, Machine =
False, OfficeLocale =
False, OfficeVersion =
False,
1257 OSName =
False, OSPlatform =
False, OSRelease =
False, OSVersion =
False,
1258 Printers =
False, Processor =
False, PythonVersion =
False, SystemLocale =
False,
1261 py = ScriptForge.pythonhelpermodule +
'$' +
'_SF_Platform'
1313 dico.ImportFromPropertyValues(props, overwrite =
True)
1321 The "Region" service gathers a collection of functions about languages, countries
and timezones
1324 - Numbers
and dates formatting
1326 - Timezones conversions
1327 - Numbers transformed to text
1330 serviceimplementation =
'basic'
1331 servicename =
'ScriptForge.Region'
1332 servicesynonyms = (
'region',
'scriptforge.region')
1333 serviceproperties = dict()
1367 return self.
GetProperty(
'MonthAbbrevNames', region)
1373 return self.
GetProperty(
'MonthNarrowNames', region)
1376 return self.
GetProperty(
'ThousandSeparator', region)
1383 if isinstance(localdatetime, datetime.datetime):
1384 localdatetime = SFScriptForge.SF_Basic.CDateToUnoDateTime(localdatetime)
1388 if isinstance(utcdatetime, datetime.datetime):
1389 utcdatetime = SFScriptForge.SF_Basic.CDateToUnoDateTime(utcdatetime)
1391 utcdatetime, timezone, locale)
1392 return SFScriptForge.SF_Basic.CDateFromUnoDateTime(localdate)
1401 if isinstance(localdatetime, datetime.datetime):
1402 localdatetime = SFScriptForge.SF_Basic.CDateToUnoDateTime(localdatetime)
1405 return SFScriptForge.SF_Basic.CDateFromUnoDateTime(utcdate)
1409 return SFScriptForge.SF_Basic.CDateFromUnoDateTime(now)
1416 The Session service gathers various general-purpose methods about:
1418 - the invocation of external scripts or programs
1421 serviceimplementation =
'basic'
1422 servicename =
'ScriptForge.Session'
1423 servicesynonyms = (
'session',
'scriptforge.session')
1424 serviceproperties = dict()
1427 SCRIPTISEMBEDDED =
'document'
1428 SCRIPTISAPPLICATION =
'application'
1429 SCRIPTISPERSONAL =
'user'
1430 SCRIPTISPERSOXT =
'user:uno_packages'
1431 SCRIPTISSHARED =
'share'
1432 SCRIPTISSHAROXT =
'share:uno_packages'
1433 SCRIPTISOXT =
'uno_packages'
1437 if scope
is None or scope ==
'':
1440 args = (scope,) + (script,) + (
None,)
1442 args = (scope,) + (script,) + args
1444 return cls.
SIMPLEEXEC(
'@SF_Session.ExecuteBasicScript', args)
1450 args = (calcfunction,) + (
None,)
1452 args = (calcfunction,) + args
1454 return cls.
SIMPLEEXEC(
'@SF_Session.ExecuteCalcFunction', args)
1458 return cls.
SIMPLEEXEC(scope +
'#' + script, *args)
1468 py = ScriptForge.pythonhelpermodule +
'$' +
'_SF_Session__OpenURLInBrowser'
1474 def SendMail(self, recipient, cc = '', bcc = '', subject = '', body = '', filenames = '', editmessage = True):
1475 return self.
ExecMethod(self.
vbMethod,
'SendMail', recipient, cc, bcc, subject, body, filenames, editmessage)
1494 Focus on string manipulation, regular expressions, encodings and hashing algorithms.
1495 The methods implemented
in Basic that are redundant
with Python builtin functions
1499 serviceimplementation =
'basic'
1500 servicename =
'ScriptForge.String'
1501 servicesynonyms = (
'string',
'scriptforge.string')
1502 serviceproperties = dict()
1506 py = ScriptForge.pythonhelpermodule +
'$' +
'_SF_String__HashStr'
1507 return cls.
SIMPLEEXEC(py, inputstr, algorithm.lower())
1509 def IsADate(self, inputstr, dateformat = 'YYYY-MM-DD'):
1515 def IsFileName(self, inputstr, osname = ScriptForge.cstSymEmpty):
1524 def IsLike(self, inputstr, pattern, casesensitive = False):
1533 def SplitNotQuoted(self, inputstr, delimiter = ' ', occurrences = 0, quotechar = '"'):
1534 return self.
ExecMethod(self.
vbMethod,
'SplitNotQuoted', inputstr, delimiter, occurrences, quotechar)
1536 def Wrap(self, inputstr, width = 70, tabsize = 8):
1544 The TextStream service is used to sequentially read
from and write to files opened
or created
1545 using the ScriptForge.FileSystem service..
1548 serviceimplementation =
'basic'
1549 servicename =
'ScriptForge.TextStream'
1550 servicesynonyms = ()
1551 serviceproperties = dict(AtEndOfStream =
False, Encoding =
False, FileName =
False, IOMode =
False,
1552 Line =
False, NewLine =
True)
1558 atEndOfStream, atendofstream = AtEndOfStream, AtEndOfStream
1589 The "Timer" service measures the amount of time it takes to run user scripts.
1592 serviceimplementation =
'basic'
1593 servicename =
'ScriptForge.Timer'
1594 servicesynonyms = (
'timer',
'scriptforge.timer')
1595 serviceproperties = dict(Duration =
False, IsStarted =
False, IsSuspended =
False,
1596 SuspendDuration =
False, TotalDuration =
False)
1598 forceGetProperty =
True
1603 Transform positional and keyword arguments into positional only
1627 Singleton class for the identification and the manipulation of the
1628 different windows composing the whole LibreOffice application:
1630 - Windows moving
and resizing
1631 - Statusbar settings
1632 - Creation of new windows
1633 - Access to the underlying
"documents"
1636 serviceimplementation =
'basic'
1637 servicename =
'ScriptForge.UI'
1638 servicesynonyms = (
'ui',
'scriptforge.ui')
1639 serviceproperties = dict(ActiveWindow =
False, Height =
False, Width =
False, X =
False, Y =
False)
1642 MACROEXECALWAYS, MACROEXECNEVER, MACROEXECNORMAL = 2, 1, 0
1643 BASEDOCUMENT, CALCDOCUMENT, DRAWDOCUMENT, IMPRESSDOCUMENT, MATHDOCUMENT, WRITERDOCUMENT = \
1644 'Base',
'Calc',
'Draw',
'Impress',
'Math',
'Writer'
1650 activeWindow, activewindow = ActiveWindow, ActiveWindow
1655 def CreateBaseDocument(self, filename, embeddeddatabase = 'HSQLDB', registrationname = '', calcfilename = ''):
1656 return self.
ExecMethod(self.
vbMethod,
'CreateBaseDocument', filename, embeddeddatabase, registrationname,
1660 return self.
ExecMethod(self.
vbMethod,
'CreateDocument', documenttype, templatefile, hidden)
1674 def OpenBaseDocument(self, filename = '', registrationname = '', macroexecution = MACROEXECNORMAL):
1675 return self.
ExecMethod(self.
vbMethod,
'OpenBaseDocument', filename, registrationname, macroexecution)
1677 def OpenDocument(self, filename, password = '', readonly = False, hidden = False,
1678 macroexecution = MACROEXECNORMAL, filtername = '', filteroptions = ''):
1679 return self.
ExecMethod(self.
vbMethod,
'OpenDocument', filename, password, readonly, hidden,
1680 macroexecution, filtername, filteroptions)
1682 def Resize(self, left = -1, top = -1, width = -1, height = -1):
1686 params = tuple(list(args) + ScriptForge.unpack_args(kwargs))
1687 if len(params) == 0:
1688 params = (command,) + (
None,)
1690 params = (command,) + params
1691 return self.
SIMPLEEXEC(
'@SF_UI.RunCommand', params)
1699 ScriptForge.componentcontext)
1710 The SFDatabases class manages databases embedded in or connected to Base documents
1719 Each instance of the current class represents a single database, with essentially its tables, queries
1721 The exchanges
with the database are done
in SQL only.
1722 To make them more readable, use optionally square brackets to surround table/query/field names
1723 instead of the (RDBMS-dependent) normal surrounding character.
1724 SQL statements may be run
in direct
or indirect mode. In direct mode the statement
is transferred literally
1725 without syntax checking nor review to the database engine.
1728 serviceimplementation =
'basic'
1729 servicename =
'SFDatabases.Database'
1730 servicesynonyms = (
'database',
'sfdatabases.database')
1731 serviceproperties = dict(Queries =
False, Tables =
False, XConnection =
False, XMetaData =
False)
1734 def ReviewServiceArgs(cls, filename = '', registrationname = '', readonly = True, user = '', password = ''):
1736 Transform positional and keyword arguments into positional only
1738 return filename, registrationname, readonly, user, password
1743 def DAvg(self, expression, tablename, criteria = ''):
1746 def DCount(self, expression, tablename, criteria = ''):
1749 def DLookup(self, expression, tablename, criteria = '', orderclause = ''):
1750 return self.
ExecMethod(self.
vbMethod,
'DLookup', expression, tablename, criteria, orderclause)
1752 def DMax(self, expression, tablename, criteria = ''):
1755 def DMin(self, expression, tablename, criteria = ''):
1758 def DSum(self, expression, tablename, criteria = ''):
1761 def GetRows(self, sqlcommand, directsql = False, header = False, maxrows = 0):
1776 def RunSql(self, sqlcommand, directsql = False):
1784 A datasheet is the visual representation of tabular data produced by a database.
1785 A datasheet may be opened automatically by script code at any moment.
1786 The Base document owning the data may
or may
not be opened.
1787 Any SELECT SQL statement may trigger the datasheet display.
1790 serviceimplementation =
'basic'
1791 servicename =
'SFDatabases.Datasheet'
1792 servicesynonyms = (
'datasheet',
'sfdatabases.datasheet')
1793 serviceproperties = dict(ColumnHeaders =
False, CurrentColumn =
False, CurrentRow =
False,
1794 DatabaseFileName =
False, Filter =
True, LastRow =
False, OrderBy =
True,
1795 ParentDatabase =
False, Source =
False, SourceType =
False, XComponent =
False,
1796 XControlModel =
False, XTabControllerModel =
False)
1804 def CreateMenu(self, menuheader, before = '', submenuchar = '>'):
1828 The SFDialogs class manages dialogs defined with the Basic IDE
1837 Each instance of the current class represents a single dialog box displayed to the user.
1838 The dialog box must have been designed
and defined
with the Basic IDE previously.
1839 From a Python script, a dialog box can be displayed
in modal
or in non-modal modes.
1841 In modal mode, the box
is displayed
and the execution of the macro process
is suspended
1842 until one of the OK
or Cancel buttons
is pressed. In the meantime, other user actions
1843 executed on the box can trigger specific actions.
1845 In non-modal mode, the floating dialog remains displayed until the dialog
is terminated
1846 by code (
Terminate())
or until the LibreOffice application stops.
1849 serviceimplementation =
'basic'
1850 servicename =
'SFDialogs.Dialog'
1851 servicesynonyms = (
'dialog',
'sfdialogs.dialog')
1852 serviceproperties = dict(Caption =
True, Height =
True, Modal =
False, Name =
False,
1853 OnFocusGained =
True, OnFocusLost =
True, OnKeyPressed =
True,
1854 OnKeyReleased =
True, OnMouseDragged =
True, OnMouseEntered =
True,
1855 OnMouseExited =
True, OnMouseMoved =
True, OnMousePressed =
True,
1856 OnMouseReleased =
True,
1857 Page =
True, Visible =
True, Width =
True, XDialogModel =
False, XDialogView =
False)
1859 OKBUTTON, CANCELBUTTON = 1, 0
1864 Transform positional and keyword arguments into positional only
1865 Add the XComponentContext
as last argument
1867 return container, library, dialogname, ScriptForge.componentcontext
1873 def Center(self, parent = ScriptForge.cstSymMissing):
1876 parentobj = parent.objectreference
if isinstance(parent, parentclasses)
else parent
1880 return self.
ExecMethod(self.
vbMethod,
'CloneControl', sourcename, controlname, left, top)
1886 return self.
ExecMethod(self.
vbMethod,
'CreateButton', controlname, place, toggle, push)
1889 return self.
ExecMethod(self.
vbMethod,
'CreateCheckBox', controlname, place, multiline)
1891 def CreateComboBox(self, controlname, place, border = '3D', dropdown = True, linecount = 5):
1892 return self.
ExecMethod(self.
vbMethod,
'CreateComboBox', controlname, place, border, dropdown, linecount)
1895 maxvalue = +1000000, increment = 1, accuracy = 2):
1896 return self.
ExecMethod(self.
vbMethod,
'CreateCurrencyField', controlname, place, border, spinbutton,
1897 minvalue, maxvalue, increment, accuracy)
1900 mindate = datetime.datetime(1900, 1, 1, 0, 0, 0, 0),
1901 maxdate = datetime.datetime(2200, 12, 31, 0, 0, 0, 0)):
1902 if isinstance(mindate, datetime.datetime):
1903 mindate = SFScriptForge.SF_Basic.CDateToUnoDateTime(mindate)
1904 if isinstance(maxdate, datetime.datetime):
1905 maxdate = SFScriptForge.SF_Basic.CDateToUnoDateTime(maxdate)
1907 dropdown, mindate, maxdate)
1910 return self.
ExecMethod(self.
vbMethod,
'CreateFileControl', controlname, place, border)
1913 return self.
ExecMethod(self.
vbMethod,
'CreateFixedLine', controlname, place, orientation)
1915 def CreateFixedText(self, controlname, place, border = 'NONE', multiline = False, align = 'LEFT',
1916 verticalalign = 'TOP'):
1917 return self.
ExecMethod(self.
vbMethod,
'CreateFixedText', controlname, place, border, multiline, align,
1921 minvalue = -1000000, maxvalue = +1000000):
1922 return self.
ExecMethod(self.
vbMethod,
'CreateFormattedField', controlname, place, border, spinbutton,
1928 def CreateHyperlink(self, controlname, place, border = 'NONE', multiline = False, align = 'LEFT',
1929 verticalalign = 'TOP'):
1930 return self.
ExecMethod(self.
vbMethod,
'CreateHyperlink', controlname, place, border, multiline, align,
1934 return self.
ExecMethod(self.
vbMethod,
'CreateImageControl', controlname, place, border, scale)
1936 def CreateListBox(self, controlname, place, border = '3D', dropdown = True, linecount = 5,
1937 multiselect = False):
1938 return self.
ExecMethod(self.
vbMethod,
'CreateListBox', controlname, place, border, dropdown,
1939 linecount, multiselect)
1942 minvalue = -1000000, maxvalue = +1000000, increment = 1, accuracy = 2):
1943 return self.
ExecMethod(self.
vbMethod,
'CreateNumericField', controlname, place, border, spinbutton,
1944 minvalue, maxvalue, increment, accuracy)
1947 return self.
ExecMethod(self.
vbMethod,
'CreatePatternField', controlname, place, border,
1948 editmask, literalmask)
1951 return self.
ExecMethod(self.
vbMethod,
'CreateProgressBar', controlname, place, border, minvalue, maxvalue)
1954 return self.
ExecMethod(self.
vbMethod,
'CreateRadioButton', controlname, place, multiline)
1956 def CreateScrollBar(self, controlname, place, orientation, border = '3D', minvalue = 0, maxvalue = 100):
1957 return self.
ExecMethod(self.
vbMethod,
'CreateScrollBar', controlname, place, orientation, border,
1961 scrollbars = 'None', gridlines = False):
1962 return self.
ExecMethod(self.
vbMethod,
'CreateTableControl', controlname, place, border,
1963 rowheaders, columnheaders, scrollbars, gridlines)
1966 maximumlength = 0, passwordcharacter = ''):
1968 multiline, maximumlength, passwordcharacter)
1971 mintime = datetime.datetime(1899, 12, 30, 0, 0, 0, 0),
1972 maxtime = datetime.datetime(1899, 12, 30, 23, 59, 59, 0)):
1973 if isinstance(mintime, datetime.datetime):
1974 mintime = SFScriptForge.SF_Basic.CDateToUnoDateTime(mintime)
1975 if isinstance(maxtime, datetime.datetime):
1976 maxtime = SFScriptForge.SF_Basic.CDateToUnoDateTime(maxtime)
1981 return self.
ExecMethod(self.
vbMethod,
'CreateTreeControl', controlname, place, border)
1996 def Resize(self, left = -99999, top = -99999, width = -1, height = -1):
1999 def SetPageManager(self, pilotcontrols = '', tabcontrols = '', wizardcontrols = '', lastpage = 0):
2000 return self.
ExecMethod(self.
vbMethod,
'SetPageManager', pilotcontrols, tabcontrols, wizardcontrols,
2011 Pseudo service never returned from the Basic world. A SF_Dialog instance
is returned instead.
2012 Main purpose: manage the arguments of
CreateScriptService()
for the creation of a dialog
from scratch
2015 serviceimplementation =
'basic'
2016 servicename =
'SFDialogs.NewDialog'
2017 servicesynonyms = (
'newdialog',
'sfdialogs.newdialog')
2018 serviceproperties = dict()
2023 Transform positional and keyword arguments into positional only
2024 Add the XComponentContext
as last argument
2026 outsideprocess = len(ScriptForge.hostname) > 0 and ScriptForge.port > 0
2028 return dialogname, place, ScriptForge.componentcontext
2030 return dialogname, place
2037 Each instance of the current class represents a single control within a dialog box.
2038 The focus
is clearly set on getting
and setting the values displayed by the controls of the dialog box,
2039 not on their formatting.
2040 A special attention
is given to controls
with type TreeControl.
2043 serviceimplementation =
'basic'
2044 servicename =
'SFDialogs.DialogControl'
2045 servicesynonyms = ()
2046 serviceproperties = dict(Border =
True, Cancel =
True, Caption =
True, ControlType =
False, CurrentNode =
True,
2047 Default =
True, Enabled =
True, Format =
True, Height =
True, ListCount =
False,
2048 ListIndex =
True, Locked =
True, MultiSelect =
True, Name =
False,
2049 OnActionPerformed =
True, OnAdjustmentValueChanged =
True, OnFocusGained =
True,
2050 OnFocusLost =
True, OnItemStateChanged =
True, OnKeyPressed =
True,
2051 OnKeyReleased =
True, OnMouseDragged =
True, OnMouseEntered =
True,
2052 OnMouseExited =
True, OnMouseMoved =
True, OnMousePressed =
True,
2053 OnMouseReleased =
True, OnNodeExpanded =
True, OnNodeSelected =
True,
2054 OnTextChanged =
True, Page =
True, Parent =
False, Picture =
True,
2055 RootNode =
False, RowSource =
True, TabIndex =
True, Text =
False, TipText =
True,
2056 TripleState =
True, URL =
True, Value =
True, Visible =
True, Width =
True,
2057 X =
True, Y =
True, XControlModel =
False, XControlView =
False,
2058 XGridColumnModel =
False, XGridDataModel =
False, XTreeDataModel =
False)
2069 def AddSubNode(self, parentnode, displayvalue, datavalue = ScriptForge.cstSymEmpty):
2072 def AddSubTree(self, parentnode, flattree, withdatavalue = False):
2073 return self.
ExecMethod(self.
vbMethod,
'AddSubTree', parentnode, flattree, withdatavalue)
2075 def CreateRoot(self, displayvalue, datavalue = ScriptForge.cstSymEmpty):
2078 def FindNode(self, displayvalue, datavalue = ScriptForge.cstSymEmpty, casesensitive = False):
2081 def Resize(self, left = -99999, top = -99999, width = -1, height = -1):
2087 def SetTableData(self, dataarray, widths = (1,), alignments =
'', rowheaderwidth = 10):
2100 The SFDocuments class gathers a number of classes, methods and
properties making easy
2101 managing
and manipulating LibreOffice documents
2110 The methods and properties are generic
for all types of documents: they are combined
in the
2111 current SF_Document
class
2112 - saving, closing documents
2113 - accessing their standard
or custom properties
2114 Specific properties
and methods are implemented
in the concerned subclass(es) SF_Calc, SF_Base, ...
2117 serviceimplementation =
'basic'
2118 servicename =
'SFDocuments.Document'
2119 servicesynonyms = (
'document',
'sfdocuments.document')
2120 serviceproperties = dict(Description =
True, DocumentType =
False, ExportFilters =
False, FileSystem =
False,
2121 ImportFilters =
False, IsBase =
False, IsCalc =
False, IsDraw =
False,
2122 IsFormDocument =
False, IsImpress =
False, IsMath =
False, IsWriter =
False,
2123 Keywords =
True, Readonly =
False, Subject =
True, Title =
True, XComponent =
False)
2125 forceGetProperty =
True
2130 Transform positional and keyword arguments into positional only
2140 def CreateMenu(self, menuheader, before = '', submenuchar = '>'):
2143 def Echo(self, echoon = True, hourglass = False):
2146 def ExportAsPDF(self, filename, overwrite = False, pages = '', password = '', watermark = ''):
2147 return self.
ExecMethod(self.
vbMethod,
'ExportAsPDF', filename, overwrite, pages, password, watermark)
2156 params = tuple([command] + list(args) + ScriptForge.unpack_args(kwargs))
2162 def SaveAs(self, filename, overwrite = False, password = '', filtername = '', filteroptions = ''):
2163 return self.
ExecMethod(self.
vbMethod,
'SaveAs', filename, overwrite, password, filtername, filteroptions)
2165 def SaveCopyAs(self, filename, overwrite = False, password = '', filtername = '', filteroptions = ''):
2167 password, filtername, filteroptions)
2169 def SetPrinter(self, printer = '', orientation = '', paperformat = ''):
2170 return self.
ExecMethod(self.
vbMethod,
'SetPrinter', printer, orientation, paperformat)
2180 The SF_Base module is provided mainly to block parent properties that are NOT applicable to Base documents
2181 In addition, it provides methods to identify form documents
and access their internal forms
2182 (read more elsewhere (the
"SFDocuments.Form" service) about this subject)
2185 serviceimplementation =
'basic'
2186 servicename =
'SFDocuments.Base'
2187 servicesynonyms = (
'base',
'scriptforge.base')
2188 serviceproperties = dict(DocumentType =
False, FileSystem =
False, IsBase =
False, IsCalc =
False,
2189 IsDraw =
False, IsFormDocument =
False, IsImpress =
False, IsMath =
False,
2190 IsWriter =
False, XComponent =
False)
2195 Transform positional and keyword arguments into positional only
2208 def Forms(self, formdocument, form = ''):
2226 def PrintOut(self, formdocument, pages = '', copies = 1):
2229 def SetPrinter(self, formdocument = '', printer = '', orientation = '', paperformat = ''):
2230 return self.
ExecMethod(self.
vbMethod,
'SetPrinter', formdocument, printer, orientation, paperformat)
2237 The SF_Calc module is focused on :
2238 - management (copy, insert, move, ...) of sheets within a Calc document
2239 - exchange of data between Basic data structures
and Calc ranges of values
2242 serviceimplementation =
'basic'
2243 servicename =
'SFDocuments.Calc'
2244 servicesynonyms = (
'calc',
'sfdocuments.calc')
2245 serviceproperties = dict(CurrentSelection =
True, Sheets =
False,
2246 Description =
True, DocumentType =
False, ExportFilters =
False, FileSystem =
False,
2247 ImportFilters =
False, IsBase =
False, IsCalc =
False, IsDraw =
False,
2248 IsFormDocument =
False, IsImpress =
False, IsMath =
False, IsWriter =
False,
2249 Keywords =
True, Readonly =
False, Subject =
True, Title =
True, XComponent =
False)
2251 forceGetProperty =
True
2256 Transform positional and keyword arguments into positional only
2307 def A1Style(self, row1, column1, row2 = 0, column2 = 0, sheetname = '~'):
2308 return self.
ExecMethod(self.
vbMethod,
'A1Style', row1, column1, row2, column2, sheetname)
2316 def ClearAll(self, range, filterformula = '', filterscope = ''):
2320 return self.
ExecMethod(self.
vbMethod,
'ClearFormats', range, filterformula, filterscope)
2323 return self.
ExecMethod(self.
vbMethod,
'ClearValues', range, filterformula, filterscope)
2325 def CompactLeft(self, range, wholecolumn = False, filterformula = ''):
2326 return self.
ExecMethod(self.
vbMethod,
'CompactLeft', range, wholecolumn, filterformula)
2328 def CompactUp(self, range, wholerow = False, filterformula = ''):
2331 def CopySheet(self, sheetname, newname, beforesheet = 32768):
2338 filename, sheet, newname, beforesheet)
2350 def CreateChart(self, chartname, sheetname, range, columnheader = False, rowheader = False):
2351 return self.
ExecMethod(self.
vbMethod,
'CreateChart', chartname, sheetname, range, columnheader, rowheader)
2353 def CreatePivotTable(self, pivottablename, sourcerange, targetcell, datafields = ScriptForge.cstSymEmpty,
2354 rowfields = ScriptForge.cstSymEmpty, columnfields = ScriptForge.cstSymEmpty,
2355 filterbutton = True, rowtotals = True, columntotals = True):
2356 return self.
ExecMethod(self.
vbMethod,
'CreatePivotTable', pivottablename, sourcerange, targetcell,
2357 datafields, rowfields, columnfields, filterbutton, rowtotals, columntotals)
2375 return self.
ExecMethod(self.
vbMethod,
'ExportRangeToFile', range, filename, imagetype, overwrite)
2390 return self.
ExecMethod(self.
vbMethod,
'ImportFromCSVFile', filename, destinationcell, filteroptions)
2392 def ImportFromDatabase(self, filename = '', registrationname = '', destinationcell = '', sqlcommand = '',
2394 return self.
ExecMethod(self.
vbMethod,
'ImportFromDatabase', filename, registrationname,
2395 destinationcell, sqlcommand, directsql)
2406 def Offset(self, range, rows = 0, columns = 0, height = ScriptForge.cstSymEmpty,
2407 width = ScriptForge.cstSymEmpty):
2410 def OpenRangeSelector(self, title = '', selection = '~', singlecell = False, closeafterselect = True):
2411 return self.
ExecMethod(self.
vbMethod,
'OpenRangeSelector', title, selection, singlecell, closeafterselect)
2413 def Printf(self, inputstr, range, tokencharacter = '%'):
2416 def PrintOut(self, sheetname = '~', pages = '', copies = 1):
2419 def RemoveDuplicates(self, range, columns = 1, header = False, casesensitive = False, mode = 'COMPACT'):
2420 return self.
ExecMethod(self.
vbMethod,
'RemoveDuplicates', range, columns, header, casesensitive, mode)
2431 def SetCellStyle(self, targetrange, style, filterformula = '', filterscope = ''):
2432 return self.
ExecMethod(self.
vbMethod,
'SetCellStyle', targetrange, style, filterformula, filterscope)
2443 def ShiftLeft(self, range, wholecolumn = False, columns = 0):
2449 def ShiftUp(self, range, wholerow = False, rows = 0):
2452 def SortRange(self, range, sortkeys, sortorder = 'ASC', destinationcell = ScriptForge.cstSymEmpty,
2453 containsheader = False, casesensitive = False, sortcolumns = False):
2454 return self.
ExecMethod(self.
vbMethod,
'SortRange', range, sortkeys, sortorder, destinationcell,
2455 containsheader, casesensitive, sortcolumns)
2462 The SF_CalcReference class has as unique role to hold sheet and range references.
2463 They are implemented
in Basic
as Type ... End Type data structures
2466 serviceimplementation =
'basic'
2467 servicename =
'SFDocuments.CalcReference'
2468 servicesynonyms = ()
2469 serviceproperties = dict()
2476 The SF_Chart module is focused on the description of chart documents
2477 stored
in Calc sheets.
2478 With this service, many chart types
and chart characteristics available
2479 in the user interface can be read
or modified.
2482 serviceimplementation =
'basic'
2483 servicename =
'SFDocuments.Chart'
2484 servicesynonyms = ()
2485 serviceproperties = dict(ChartType =
True, Deep =
True, Dim3D =
True, Exploded =
True, Filled =
True,
2486 Legend =
True, Percent =
True, Stacked =
True, Title =
True,
2487 XChartObj =
False, XDiagram =
False, XShape =
False, XTableChart =
False,
2488 XTitle =
True, YTitle =
True)
2490 def Resize(self, xpos = -1, ypos = -1, width = -1, height = -1):
2494 return self.
ExecMethod(self.
vbMethod,
'ExportToFile', filename, imagetype, overwrite)
2501 Management of forms defined in LibreOffice documents. Supported types are Base, Calc
and Writer documents.
2502 It includes the management of subforms
2503 Each instance of the current
class represents a single form or a single subform
2504 A form may optionally be (understand
"is often") linked to a data source manageable
with
2505 the SFDatabases.Database service. The current service offers rapid access to that service.
2508 serviceimplementation =
'basic'
2509 servicename =
'SFDocuments.Form'
2510 servicesynonyms = ()
2511 serviceproperties = dict(AllowDeletes =
True, AllowInserts =
True, AllowUpdates =
True, BaseForm =
False,
2512 Bookmark =
True, CurrentRecord =
True, Filter =
True, LinkChildFields =
False,
2513 LinkParentFields =
False, Name =
False,
2514 OnApproveCursorMove =
True, OnApproveParameter =
True, OnApproveReset =
True,
2515 OnApproveRowChange =
True, OnApproveSubmit =
True, OnConfirmDelete =
True,
2516 OnCursorMoved =
True, OnErrorOccurred =
True, OnLoaded =
True, OnReloaded =
True,
2517 OnReloading =
True, OnResetted =
True, OnRowChanged =
True, OnUnloaded =
True,
2519 OrderBy =
True, Parent =
False, RecordSource =
True, XForm =
False)
2559 Manage the controls belonging to a form or subform stored
in a document.
2560 Each instance of the current
class represents a single control within a form, a subform or a tablecontrol.
2561 A prerequisite
is that all controls within the same form, subform
or tablecontrol must have
2565 serviceimplementation =
'basic'
2566 servicename =
'SFDocuments.FormControl'
2567 servicesynonyms = ()
2568 serviceproperties = dict(Action =
True, Caption =
True, ControlSource =
False, ControlType =
False,
2569 Default =
True, DefaultValue =
True, Enabled =
True, Format =
True,
2570 ListCount =
False, ListIndex =
True, ListSource =
True, ListSourceType =
True,
2571 Locked =
True, MultiSelect =
True, Name =
False,
2572 OnActionPerformed =
True, OnAdjustmentValueChanged =
True,
2573 OnApproveAction =
True, OnApproveReset =
True, OnApproveUpdate =
True,
2574 OnChanged =
True, OnErrorOccurred =
True, OnFocusGained =
True, OnFocusLost =
True,
2575 OnItemStateChanged =
True, OnKeyPressed =
True, OnKeyReleased =
True,
2576 OnMouseDragged =
True, OnMouseEntered =
True, OnMouseExited =
True,
2577 OnMouseMoved =
True, OnMousePressed =
True, OnMouseReleased =
True, OnResetted =
True,
2578 OnTextChanged =
True, OnUpdated =
True, Parent =
False, Picture =
True,
2579 Required =
True, Text =
False, TipText =
True, TripleState =
True, Value =
True,
2580 Visible =
True, XControlModel =
False, XControlView =
False)
2593 The orchestration of Base form documents (aka Base Forms, but this is confusing)
2594 and the identification of
and the access to their controls.
2595 Form documents are always contained
in a Base document.
2596 They should
not be confused
with Writer documents containing forms,
2597 even
if it
is easy to convert the former to the latter.
2600 serviceimplementation =
'basic'
2601 servicename =
'SFDocuments.FormDocument'
2602 servicesynonyms = (
'formdocument',
'sfdocuments.formdocument')
2603 serviceproperties = dict(DocumentType =
False, FileSystem =
False, IsBase =
False, IsCalc =
False,
2604 IsDraw =
False, IsFormDocument =
False, IsImpress =
False, IsMath =
False,
2605 IsWriter =
False, Readonly =
False, XComponent =
False)
2610 Transform positional and keyword arguments into positional only
2623 def PrintOut(self, pages = '', copies = 1, printbackground = True, printblankpages = False,
2624 printevenpages = True, printoddpages = True, printimages = True):
2625 return self.
ExecMethod(self.
vbMethod,
'PrintOut', pages, copies, printbackground, printblankpages,
2626 printevenpages, printoddpages, printimages)
2633 The SF_Writer module is focused on :
2637 serviceimplementation =
'basic'
2638 servicename =
'SFDocuments.Writer'
2639 servicesynonyms = (
'writer',
'sfdocuments.writer')
2640 serviceproperties = dict(Description =
True, DocumentType =
False, ExportFilters =
False, FileSystem =
False,
2641 ImportFilters =
False, IsBase =
False, IsCalc =
False, IsDraw =
False,
2642 IsFormDocument =
False, IsImpress =
False, IsMath =
False, IsWriter =
False,
2643 Keywords =
True, Readonly =
False, Subject =
True, Title =
True, XComponent =
False)
2645 forceGetProperty =
True
2650 Transform positional and keyword arguments into positional only
2657 def PrintOut(self, pages = '', copies = 1, printbackground = True, printblankpages = False,
2658 printevenpages = True, printoddpages = True, printimages = True):
2659 return self.
ExecMethod(self.
vbMethod,
'PrintOut', pages, copies, printbackground, printblankpages,
2660 printevenpages, printoddpages, printimages)
2668 The SFWidgets class manages toolbars and popup menus
2677 Display a menu in the menubar of a document
or a form document.
2678 After use, the menu will
not be saved neither
in the application settings, nor
in the document.
2679 The menu will be displayed,
as usual, when its header
in the menubar
is clicked.
2680 When one of its items
is selected, there are 3 alternative options:
2681 - a UNO command (like
".uno:About")
is triggered
2682 - a user script
is run receiving a standard argument defined
in this service
2683 - one of above combined
with a toggle of the status of the item
2684 The menu
is described
from top to bottom. Each menu item receives a numeric
and a string identifier.
2687 serviceimplementation =
'basic'
2688 servicename =
'SFWidgets.Menu'
2689 servicesynonyms = (
'menu',
'sfwidgets.menu')
2690 serviceproperties = dict(ShortcutCharacter =
False, SubmenuCharacter =
False)
2692 def AddCheckBox(self, menuitem, name = '', status = False, icon = '', tooltip = '',
2693 command = '', script = ''):
2694 return self.
ExecMethod(self.
vbMethod,
'AddCheckBox', menuitem, name, status, icon, tooltip,
2697 def AddItem(self, menuitem, name = '', icon = '', tooltip = '', command = '', script = ''):
2698 return self.
ExecMethod(self.
vbMethod,
'AddItem', menuitem, name, icon, tooltip, command, script)
2700 def AddRadioButton(self, menuitem, name = '', status = False, icon = '', tooltip = '',
2701 command = '', script = ''):
2702 return self.
ExecMethod(self.
vbMethod,
'AddRadioButton', menuitem, name, status, icon, tooltip,
2710 Display a popup menu anywhere and any time.
2711 A popup menu
is usually triggered by a mouse action (typically a right-click) on a dialog, a form
2712 or one of their controls. In this case the menu will be displayed below the clicked area.
2713 When triggered by other events, including
in the normal flow of a user script, the script should
2714 provide the coordinates of the topleft edge of the menu versus the actual component.
2715 The menu
is described
from top to bottom. Each menu item receives a numeric
and a string identifier.
2716 The execute() method returns the item selected by the user.
2719 serviceimplementation =
'basic'
2720 servicename =
'SFWidgets.PopupMenu'
2721 servicesynonyms = (
'popupmenu',
'sfwidgets.popupmenu')
2722 serviceproperties = dict(ShortcutCharacter =
False, SubmenuCharacter =
False)
2727 Transform positional and keyword arguments into positional only
2729 return event, x, y, submenuchar
2731 def AddCheckBox(self, menuitem, name = '', status = False, icon = '', tooltip = ''):
2732 return self.
ExecMethod(self.
vbMethod,
'AddCheckBox', menuitem, name, status, icon, tooltip)
2734 def AddItem(self, menuitem, name = '', icon = '', tooltip = ''):
2737 def AddRadioButton(self, menuitem, name = '', status = False, icon = '', tooltip = ''):
2738 return self.
ExecMethod(self.
vbMethod,
'AddRadioButton', menuitem, name, status, icon, tooltip)
2748 Each component has its own set of toolbars, depending on the component type
2749 (Calc, Writer, Basic IDE, ...).
2750 In the context of the actual class, a toolbar
is presumed defined statically:
2751 - either by the application
2752 -
or by a customization done by the user.
2755 serviceimplementation =
'basic'
2756 servicename =
'SFWidgets.Toolbar'
2757 servicesynonyms = (
'toolbar',
'sfwidgets.toolbar')
2758 serviceproperties = dict(BuiltIn =
False, Docked =
False, HasGlobalScope =
False, Name =
False,
2759 ResourceURL =
False, Visible =
True, XUIElement =
False)
2769 A toolbar consists in a series of graphical controls to trigger actions.
2770 The
"Toolbar" service gives access to the
"ToolbarButton" service to manage
2771 the individual buttons belonging to the toolbar.
2774 serviceimplementation =
'basic'
2775 servicename =
'SFWidgets.ToolbarButton'
2776 servicesynonyms = (
'toolbarbutton',
'sfwidgets.toolbarbutton')
2777 serviceproperties = dict(Caption =
False, Height =
False, Index =
False, OnClick =
True, Parent =
False,
2778 TipText =
True, Visible =
True, Width =
False, X =
False, Y =
False)
2789 A service being the name of a collection of properties and methods,
2790 this method returns either
2791 - the Python object mirror of the Basic object implementing the requested service
2792 - the Python object implementing the service itself
2794 A service may be designated by its official name, stored
in its class.servicename
2795 or by one of its synonyms stored
in its class.servicesynonyms list
2796 If the service
is not identified, the service creation
is delegated to Basic, that might
raise an error
2797 if still
not identified there
2799 :param service: the name of the service
as a string
'library.service' - cased exactly
2800 or one of its synonyms
2801 :param args: the arguments to
pass to the service constructor
2802 :
return: the service
as a Python object
2807 if ScriptForge.SCRIPTFORGEINITDONE
is False:
2810 def ResolveSynonyms(servicename):
2812 Synonyms within service names implemented in Python
or predefined are resolved here
2813 :param servicename: The short name of the service
2814 :
return: The official service name
if found, the argument otherwise
2816 for cls
in SFServices.__subclasses__():
2817 if servicename.lower()
in cls.servicesynonyms:
2818 return cls.servicename
2823 scriptservice = ResolveSynonyms(service)
2824 if scriptservice
in ScriptForge.serviceslist:
2825 serv = ScriptForge.serviceslist[scriptservice]
2827 if serv.serviceimplementation ==
'python':
2830 elif scriptservice
in ScriptForge.servicesmodules:
2831 return serv(ScriptForge.servicesmodules[scriptservice], classmodule = SFServices.moduleStandard)
2836 if serv
is not None:
2837 if hasattr(serv,
'ReviewServiceArgs'):
2839 args = serv.ReviewServiceArgs(*args, **kwargs)
2842 serv = ScriptForge.InvokeBasicService(
'SF_Services', SFServices.vbMethod,
'CreateScriptService', service)
2844 serv = ScriptForge.InvokeBasicService(
'SF_Services', SFServices.vbMethod,
'CreateScriptService',
2849createScriptService, createscriptservice = CreateScriptService, CreateScriptService
2855g_exportedScripts = ()
def DLookup(self, expression, tablename, criteria='', orderclause='')
def RunSql(self, sqlcommand, directsql=False)
def DMax(self, expression, tablename, criteria='')
def OpenFormDocument(self, formdocument)
def DAvg(self, expression, tablename, criteria='')
def DCount(self, expression, tablename, criteria='')
def OpenTable(self, tablename)
def DSum(self, expression, tablename, criteria='')
def ReviewServiceArgs(cls, filename='', registrationname='', readonly=True, user='', password='')
def DMin(self, expression, tablename, criteria='')
def OpenQuery(self, queryname)
def GetRows(self, sqlcommand, directsql=False, header=False, maxrows=0)
def OpenSql(self, sql, directsql=False)
def GetValue(self, column=0)
def CreateMenu(self, menuheader, before='', submenuchar='>')
def Toolbars(self, toolbarname='')
def GetText(self, column=0)
def RemoveMenu(self, menuheader)
def GoToCell(self, row=0, column=0)
def CreateRoot(self, displayvalue, datavalue=ScriptForge.cstSymEmpty)
def SetTableData(self, dataarray, widths=(1,), alignments='', rowheaderwidth=10)
def WriteLine(self, line='')
def AddSubTree(self, parentnode, flattree, withdatavalue=False)
def FindNode(self, displayvalue, datavalue=ScriptForge.cstSymEmpty, casesensitive=False)
def Resize(self, left=-99999, top=-99999, width=-1, height=-1)
def AddSubNode(self, parentnode, displayvalue, datavalue=ScriptForge.cstSymEmpty)
def SetPageManager(self, pilotcontrols='', tabcontrols='', wizardcontrols='', lastpage=0)
def CreateFileControl(self, controlname, place, border='3D')
def CreateNumericField(self, controlname, place, border='3D', spinbutton=False, minvalue=-1000000, maxvalue=+1000000, increment=1, accuracy=2)
def CreateTimeField(self, controlname, place, border='3D', mintime=datetime.datetime(1899, 12, 30, 0, 0, 0, 0), maxtime=datetime.datetime(1899, 12, 30, 23, 59, 59, 0))
def CreateFixedText(self, controlname, place, border='NONE', multiline=False, align='LEFT', verticalalign='TOP')
def Execute(self, modal=True)
def CreateFormattedField(self, controlname, place, border='3D', spinbutton=False, minvalue=-1000000, maxvalue=+1000000)
def CreateListBox(self, controlname, place, border='3D', dropdown=True, linecount=5, multiselect=False)
def OrderTabs(self, tabslist, start=1, increment=1)
def Center(self, parent=ScriptForge.cstSymMissing)
def CreateDateField(self, controlname, place, border='3D', dropdown=True, mindate=datetime.datetime(1900, 1, 1, 0, 0, 0, 0), maxdate=datetime.datetime(2200, 12, 31, 0, 0, 0, 0))
def CreateRadioButton(self, controlname, place, multiline=False)
def CreateTreeControl(self, controlname, place, border='3D')
def CreateTextField(self, controlname, place, border='3D', multiline=False, maximumlength=0, passwordcharacter='')
def CloneControl(self, sourcename, controlname, left=1, top=1)
def EndExecute(self, returnvalue)
def CreateButton(self, controlname, place, toggle=False, push='')
def GetTextsFromL10N(self, l10n)
def Resize(self, left=-99999, top=-99999, width=-1, height=-1)
def ReviewServiceArgs(cls, container='', library='Standard', dialogname='')
def CreateTableControl(self, controlname, place, border='3D', rowheaders=True, columnheaders=True, scrollbars='None', gridlines=False)
def CreateGroupBox(self, controlname, place)
def CreatePatternField(self, controlname, place, border='3D', editmask='', literalmask='')
def CreateCheckBox(self, controlname, place, multiline=False)
def CreateScrollBar(self, controlname, place, orientation, border='3D', minvalue=0, maxvalue=100)
def Controls(self, controlname='')
def CreateFixedLine(self, controlname, place, orientation)
def CreateCurrencyField(self, controlname, place, border='3D', spinbutton=False, minvalue=-1000000, maxvalue=+1000000, increment=1, accuracy=2)
def CreateImageControl(self, controlname, place, border='3D', scale='FITTOSIZE')
def CreateProgressBar(self, controlname, place, border='3D', minvalue=0, maxvalue=100)
def CreateComboBox(self, controlname, place, border='3D', dropdown=True, linecount=5)
def CreateHyperlink(self, controlname, place, border='NONE', multiline=False, align='LEFT', verticalalign='TOP')
def ReviewServiceArgs(cls, dialogname='', place=(0, 0, 0, 0))
def SetPrinter(self, formdocument='', printer='', orientation='', paperformat='')
def OpenTable(self, tablename)
def IsLoaded(self, formdocument)
def GetDatabase(self, user='', password='')
def PrintOut(self, formdocument, pages='', copies=1)
def ReviewServiceArgs(cls, windowname='')
def Forms(self, formdocument, form='')
def CloseDocument(self, saveask=True)
def OpenFormDocument(self, formdocument, designmode=False)
def CloseFormDocument(self, formdocument)
def OpenQuery(self, queryname)
def SetCellStyle(self, targetrange, style, filterformula='', filterscope='')
def ImportFromCSVFile(self, filename, destinationcell, filteroptions=ScriptForge.cstSymEmpty)
def XCellRange(self, rangename)
def FirstColumn(self, rangename)
def ShiftDown(self, range, wholerow=False, rows=0)
def InsertSheet(self, sheetname, beforesheet=32768)
def ShiftRight(self, range, wholecolumn=False, columns=0)
def MoveRange(self, source, destination)
def RemoveDuplicates(self, range, columns=1, header=False, casesensitive=False, mode='COMPACT')
def Activate(self, sheetname='')
def Width(self, rangename)
def RemoveSheet(self, sheetname)
def GetFormula(self, range)
def CompactUp(self, range, wholerow=False, filterformula='')
def Region(self, rangename)
def ReviewServiceArgs(cls, windowname='')
def ClearValues(self, range, filterformula='', filterscope='')
def Height(self, rangename)
def MoveSheet(self, sheetname, beforesheet=32768)
def CopyToCell(self, sourcerange, destinationcell)
def Charts(self, sheetname, chartname='')
def LastCell(self, rangename)
def GetColumnName(self, columnnumber)
def XSpreadsheet(self, sheetname)
def CopySheet(self, sheetname, newname, beforesheet=32768)
def ExportRangeToFile(self, range, filename, imagetype='pdf', overwrite=False)
def Offset(self, range, rows=0, columns=0, height=ScriptForge.cstSymEmpty, width=ScriptForge.cstSymEmpty)
def A1Style(self, row1, column1, row2=0, column2=0, sheetname='~')
def ClearAll(self, range, filterformula='', filterscope='')
def CopyToRange(self, sourcerange, destinationrange)
def CompactLeft(self, range, wholecolumn=False, filterformula='')
def ShiftLeft(self, range, wholecolumn=False, columns=0)
def Printf(self, inputstr, range, tokencharacter='%')
def LastRow(self, rangename)
def RenameSheet(self, sheetname, newname)
def CreateChart(self, chartname, sheetname, range, columnheader=False, rowheader=False)
def FirstCell(self, rangename)
def ClearFormats(self, range, filterformula='', filterscope='')
def Range(self, rangename)
def PrintOut(self, sheetname='~', pages='', copies=1)
def Sheet(self, sheetname)
def SheetName(self, rangename)
def XSheetCellCursor(self, rangename)
def SetArray(self, targetcell, value)
def Forms(self, sheetname, form='')
def SetValue(self, targetrange, value)
def SetFormula(self, targetrange, formula)
def ShiftUp(self, range, wholerow=False, rows=0)
def CreatePivotTable(self, pivottablename, sourcerange, targetcell, datafields=ScriptForge.cstSymEmpty, rowfields=ScriptForge.cstSymEmpty, columnfields=ScriptForge.cstSymEmpty, filterbutton=True, rowtotals=True, columntotals=True)
def LastColumn(self, rangename)
def FirstRow(self, rangename)
def CopySheetFromFile(self, filename, sheetname, newname, beforesheet=32768)
def SortRange(self, range, sortkeys, sortorder='ASC', destinationcell=ScriptForge.cstSymEmpty, containsheader=False, casesensitive=False, sortcolumns=False)
def ImportFromDatabase(self, filename='', registrationname='', destinationcell='', sqlcommand='', directsql=False)
def GetValue(self, range)
def OpenRangeSelector(self, title='', selection='~', singlecell=False, closeafterselect=True)
def Resize(self, xpos=-1, ypos=-1, width=-1, height=-1)
def ExportToFile(self, filename, imagetype='png', overwrite=False)
def SetPrinter(self, printer='', orientation='', paperformat='')
def Toolbars(self, toolbarname='')
def RunCommand(self, command, *args, **kwargs)
def RemoveMenu(self, menuheader)
def ExportAsPDF(self, filename, overwrite=False, pages='', password='', watermark='')
def SaveCopyAs(self, filename, overwrite=False, password='', filtername='', filteroptions='')
def SaveAs(self, filename, overwrite=False, password='', filtername='', filteroptions='')
def PrintOut(self, pages='', copies=1)
def CloseDocument(self, saveask=True)
def CreateMenu(self, menuheader, before='', submenuchar='>')
def Echo(self, echoon=True, hourglass=False)
def ReviewServiceArgs(cls, windowname='')
def ReviewServiceArgs(cls, windowname='')
def PrintOut(self, pages='', copies=1, printbackground=True, printblankpages=False, printevenpages=True, printoddpages=True, printimages=True)
def ImportFromCSVFile(self, filename, delimiter=',', dateformat='')
def DateValue(cls, string)
def DateDiff(cls, interval, date1, date2, firstdayofweek=1, firstweekofyear=1)
def CDateToUnoDateTime(date)
def GetPathSeparator(cls)
def MsgBox(cls, prompt, buttons=0, title='')
def CreateUnoService(cls, servicename)
def InputBox(cls, prompt, title='', default='', xpostwips=-1, ypostwips=-1)
def Format(cls, expression, format='')
def Xray(cls, unoobject=None)
def RGB(cls, red, green, blue)
def CreateUnoStruct(cls, unostructure)
def CDateFromUnoDateTime(unodate)
def DateAdd(cls, interval, number, date)
def ConvertFromUrl(cls, url)
def CDate(cls, datevalue)
def ConvertToUrl(cls, systempath)
def ThisDatabaseDocument(self)
def GetDefaultContext(cls)
def DatePart(cls, interval, date, firstdayofweek=1, firstweekofyear=1)
def ConvertToPropertyValues(self)
def ImportFromPropertyValues(self, propertyvalues, overwrite=False)
def __init__(self, dic=None)
def Console(self, modal=True)
def DebugPrint(self, *args)
def PythonShell(cls, variables=None)
def _RaiseFatal(cls, sub, subargs, errorcode, *args)
def ConsoleClear(self, keep=0)
def ConsoleToFile(self, filename)
def RaiseFatal(cls, errorcode, *args)
def DebugDisplay(self, *args)
def GetTempName(self, extension='')
def FolderExists(self, foldername)
def DeleteFolder(self, foldername)
def HashFile(self, filename, algorithm)
def CopyFile(self, source, destination, overwrite=True)
def GetName(self, filename)
def MoveFolder(self, source, destination)
def Files(self, foldername, filter='', includesubfolders=False)
def _ConvertFromUrl(cls, filename)
def Normalize(self, filename)
def ExtensionFolder(self, extension)
def GetFileLen(self, filename)
def FileExists(self, filename)
def GetFileModified(self, filename)
def SubFolders(self, foldername, filter='', includesubfolders=False)
def BuildPath(self, foldername, name)
def CopyFolder(self, source, destination, overwrite=True)
def GetBaseName(self, filename)
def GetParentFolderName(self, filename)
def CompareFiles(self, filename1, filename2, comparecontents=False)
def DeleteFile(self, filename)
def PickFile(self, defaultfile=ScriptForge.cstSymEmpty, mode='OPEN', filter='')
def CreateTextFile(self, filename, overwrite=True, encoding='UTF-8')
def MoveFile(self, source, destination)
def GetExtension(self, filename)
def CreateFolder(self, foldername)
def PickFolder(self, defaultfolder=ScriptForge.cstSymEmpty, freetext='')
def OpenTextFile(self, filename, iomode=1, create=False, encoding='UTF-8')
def AddText(self, context='', msgid='', comment='')
def AddTextsFromDialog(self, dialog)
def ReviewServiceArgs(cls, foldername='', locale='', encoding='UTF-8', locale2='', encoding2='UTF-8')
def GetText(self, msgid, *args)
def ExportToPOTFile(self, filename, header='', encoding='UTF-8')
def TimeSeparator(self, region='')
def UTCDateTime(self, localdatetime, timezone, locale='')
def ThousandSeparator(self, region='')
def MonthNames(self, region='')
def Country(self, region='')
def LocalDateTime(self, utcdatetime, timezone, locale='')
def DayNames(self, region='')
def DayNarrowNames(self, region='')
def DecimalPoint(self, region='')
def Currency(self, region='')
def UTCNow(self, timezone, locale='')
def DatePatterns(self, region='')
def DayAbbrevNames(self, region='')
def MonthNarrowNames(self, region='')
def TimeZoneOffset(self, timezone, locale='')
def Number2Text(self, number, locale='')
def Language(self, region='')
def MonthAbbrevNames(self, region='')
def DateSeparator(self, region='')
def DSTOffset(self, localdatetime, timezone, locale='')
def ListSeparator(self, region='')
def ExecutePythonScript(cls, scope='', script='', *args)
def SendMail(self, recipient, cc='', bcc='', subject='', body='', filenames='', editmessage=True)
def ExecuteBasicScript(cls, scope='', script='', *args)
def HasUnoMethod(self, unoobject, methodname)
def UnoObjectType(self, unoobject)
def HasUnoProperty(self, unoobject, propertyname)
def UnoProperties(self, unoobject)
def ExecuteCalcFunction(cls, calcfunction, *args)
def OpenURLInBrowser(cls, url)
def RunApplication(self, command, parameters)
string SCRIPTISAPPLICATION
def WebService(self, uri)
def UnoMethods(self, unoobject)
def IsSheetName(self, inputstr)
def IsIPv4(self, inputstr)
def IsFileName(self, inputstr, osname=ScriptForge.cstSymEmpty)
def IsADate(self, inputstr, dateformat='YYYY-MM-DD')
def SplitNotQuoted(self, inputstr, delimiter=' ', occurrences=0, quotechar='"')
def IsIBAN(self, inputstr)
def IsEmail(self, inputstr)
def IsLike(self, inputstr, pattern, casesensitive=False)
def Wrap(self, inputstr, width=70, tabsize=8)
def HashStr(cls, inputstr, algorithm)
def IsUrl(self, inputstr)
def WriteBlankLines(self, lines)
def WriteLine(self, line)
def ReviewServiceArgs(cls, start=False)
def ShowProgressBar(self, title='', text='', percentage=-1)
def Resize(self, left=-1, top=-1, width=-1, height=-1)
def Maximize(self, windowname='')
def OpenBaseDocument(self, filename='', registrationname='', macroexecution=MACROEXECNORMAL)
def CreateBaseDocument(self, filename, embeddeddatabase='HSQLDB', registrationname='', calcfilename='')
def RunCommand(self, command, *args, **kwargs)
def SetStatusbar(self, text='', percentage=-1)
def CreateDocument(self, documenttype='', templatefile='', hidden=False)
def WindowExists(self, windowname)
def Activate(self, windowname='')
def GetDocument(self, windowname='')
def Minimize(self, windowname='')
def OpenDocument(self, filename, password='', readonly=False, hidden=False, macroexecution=MACROEXECNORMAL, filtername='', filteroptions='')
def __init__(self, reference=-1, objtype=None, classmodule=0, name='')
def __setattr__(self, name, value)
def GetProperty(self, propertyname, arg=None)
dictionary propertysynonyms
def SetProperty(self, propertyname, value)
def basicproperties(self)
def __getattr__(self, name)
def ExecMethod(self, flags=0, methodname='', *args)
tuple internal_attributes
def __init__(self, hostname='', port=0)
def InvokeBasicService(cls, basicobject, flags, method, *args)
def ScriptProvider(cls, context=None)
def ConnectToLOProcess(cls, hostname='', port=0)
string pythonhelpermodule
def InvokeSimpleScript(cls, script, *args)
def SetAttributeSynonyms()
def __call__(cls, *args, **kwargs)
def CreateScriptService(service, *args, **kwargs)
def getComponentContext()
def createUnoStruct(typeName, *args, **kwargs)