summaryrefslogtreecommitdiff
path: root/pyuno
AgeCommit message (Collapse)Author
2016-01-10Fix typosAndrea Gelmini
Change-Id: I9a5940027423ff0791fa7da0b79b617412ce6b86 Reviewed-on: https://gerrit.libreoffice.org/21209 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-07configure: hard-code /usr/bin/{sort,find} for CygwinMichael Stahl
... to avoid calling C:/Windows/system32/{sort,find}.exe, if those happen to be first in PATH. On a Windows 7 system, the other conflicts appear to be harmless, we don't use "more", "expand", "timeout", "whoami". Change-Id: Iceefeb7ee6725291b04c0eba465991bb1df96b57 Reviewed-on: https://gerrit.libreoffice.org/21175 Tested-by: Jenkins <ci@libreoffice.org> Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
2016-01-06Pyuno add compat for python 2.6Tomáš Chvátal
Change-Id: I3e40a8006278b094d494820e6f47628c6579e78a Reviewed-on: https://gerrit.libreoffice.org/20883 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
2016-01-05new loplugin rangedforcopy - use reference in range based forAndrzej Hunt
Inspired by 6e6ae9803796b120e95f6e89575e03c5fd0ed3c2 Change-Id: Ia0f264d3a6bbf076aa5080e3398683e50bc6ef01 Reviewed-on: https://gerrit.libreoffice.org/20190 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2015-11-19use comphelper::containerToSequenceNoel Grandin
in chart2, we remove a local equivalent of the method Change-Id: I25129a3d1ea1dd724eb9cd38a57be37a78b3d100
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
Change-Id: I7a5fda2606f42e2736ad0618f2d8bcc5ba4028fb
2015-11-04yyyyyNoel Grandin
Change-Id: I9a947beefd2dfe21da8239e841ea3fb416bd1548
2015-10-30UNO: no need to use OUString constructor when calling createInstanceNoel Grandin
Change-Id: I37da28539b94706574116d0fff5f008aabfb5526 Reviewed-on: https://gerrit.libreoffice.org/19682 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2015-10-27loplugin:unusedmethodsNoel Grandin
Change-Id: I161cd52606c11b6008f5d8b1d8ee391692f91861 Reviewed-on: https://gerrit.libreoffice.org/19231 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-10-25Bump python to 3.5David Ostrovsky
3.5 release is needed for MSVC 14.0 (aka VS 2015) support. Python 3.5 removed build toolchain support for MSVC 2013. Because we still need to support it, we duplicate the Python directory in externals and copy old patches and dispatch to this directory for MSVC 2013. Once the support for MSVC 2013 is dropped on master, this directory can be removed again. Change-Id: Idf7bc351239582f583ecbdb53c923cbdcf968089 Reviewed-on: https://gerrit.libreoffice.org/17352 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2015-10-23com::sun::star->css in package,pyunoNoel Grandin
Change-Id: I7b7b0e7fea2d1a2b9f6f5501ad5e0b8c1b4a17b9
2015-10-12Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY codeStephan Bergmann
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-10-12Replace "SAL_DELETED_FUNCTION" with "= delete" in LIBO_INTERNAL_ONLY codeStephan Bergmann
Change-Id: I328ac7a95ccc87732efae48b567a0556865928f3
2015-10-09fix build by moving python-related includes below othersDouglas Mencken
This fixes build errors like "macro (...) passed 2 arguments, but takes just 1" The reason is a conflict between tolower() etc. as a set of functions from <ios> and a hacky fix in Python's include pyport.h which tries to undefine tolower() and then redefine it Change-Id: I82e5ac19b70912d09d5e3a34c93eddc08cec9260 Reviewed-on: https://gerrit.libreoffice.org/19082 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2015-09-29loplugin:removeunusedmethods, remove unused stuffNoel Grandin
Change-Id: I35456b2a3ad2a84a1d045f09cdfb29e4c19b8350
2015-09-15Resolves: tdf#88206 replace cppu::WeakImplHelper* etc.Takeshi Abe
with the variadic variants. Change-Id: I7154f9472f02fdf47d27ba715db55bb1ec669a8a Reviewed-on: https://gerrit.libreoffice.org/18580 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-08-31loplugin:stringconstant: OUStringBuffer: appendAscii -> appendStephan Bergmann
Change-Id: I98058ff0653a3aab3399735271d04b16a05a3684
2015-08-22tdf#39440 reduce scope of local variablesMichael Weghorn
This addresses some cppcheck warnings. Change-Id: Ie492fb9c106b37c3fe7b0105236ad6315f4f159e Reviewed-on: https://gerrit.libreoffice.org/17921 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2015-08-18configure, pyuno: stop claiming our python 3.3.5 is 3.3.3Michael Stahl
... and adapt makefiles to automatically rebuild everything that depends on PYTHON_VERSION. Change-Id: If468183e59463503051c2a1526a905dbee9bf4cb Reviewed-on: https://gerrit.libreoffice.org/17818 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
2015-07-30Give PyUNO structs/exceptions their own separate typeMatthew J. Francis
Change-Id: Ie4c42c623fae1cf39c2e4c643825c9655cd28daa Reviewed-on: https://gerrit.libreoffice.org/17410 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Matthew Francis <mjay.francis@gmail.com>
2015-07-27Tweak introspection/invocation to be more useful to PyUNOMatthew J. Francis
- Make introspection/invocation handle XNameReplace and XIndexReplace - Make introspection handle XUnoTunnel - Adapt PyUNO to take advantage of the additionally handled interfaces Change-Id: Ie848d10fd2c31cad76fcc3a746262a490a2c9ae1 Reviewed-on: https://gerrit.libreoffice.org/17314 Reviewed-by: Matthew Francis <mjay.francis@gmail.com> Tested-by: Matthew Francis <mjay.francis@gmail.com>
2015-07-25Fix PyUNO object hash to use the correct pointerMatthew J. Francis
Change-Id: Id93cba88eaf0dca0784051507809bc849d046a03 Reviewed-on: https://gerrit.libreoffice.org/17337 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Matthew Francis <mjay.francis@gmail.com>
2015-07-21Make PyUNO objects hashableMatthew J. Francis
This allows them to be used as set members and dict keys Change-Id: I10bd71788be6b508c6f491a27a8841e599e47e3a Reviewed-on: https://gerrit.libreoffice.org/17248 Reviewed-by: Matthew Francis <mjay.francis@gmail.com> Tested-by: Matthew Francis <mjay.francis@gmail.com>
2015-07-02loplugin:unusedmethods bridges,ucbhelper,io,pyunoNoel Grandin
Change-Id: I483deb33b9d861af679d4a36e13585345401e10d Reviewed-on: https://gerrit.libreoffice.org/16681 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2015-07-02coverity#1309066 Uncaught exceptionCaolán McNamara
Change-Id: If02a62e814051bb2d75a683877f8d17ec9201993
2015-07-01PyUNO: Allow import of constant group by nameMatthew J. Francis
Change-Id: I0ea809a888187624261182552cf7fa0a9c96c648
2015-07-01Fix compilation with Python 2.7Matthew J. Francis
Change-Id: I0dd118f0215e06fec0cccff9b46d80f13bd802cc Reviewed-on: https://gerrit.libreoffice.org/16620 Reviewed-by: Matthew Francis <mjay.francis@gmail.com> Tested-by: Matthew Francis <mjay.francis@gmail.com>
2015-06-28coverity#1308526 Uncaught exceptionCaolán McNamara
Change-Id: Ie0266c7e8ab5980dc25ce14edd42b3f599f71245
2015-06-26loplugin:implicitboolconversionStephan Bergmann
Change-Id: If495a415d4263d1932c03a31d07a517218533847
2015-06-26loplugin:cstylecastStephan Bergmann
Change-Id: I5f0bceb240a492c7c010b4356bc8efafdd83bf24
2015-06-26loplugin:passstuffbyrefStephan Bergmann
Change-Id: I66410932347b4f65c4b24b5316009ecffc8aef06
2015-06-26loplugin:salboolStephan Bergmann
Change-Id: I4875b12807aed36f758d81c731e2ac52a3a606e4
2015-06-26loplugin:salboolStephan Bergmann
Change-Id: I9975a87f6df2b7a79c376130864e9eb54bc3452b
2015-06-26loplugin:loopvartoosmallStephan Bergmann
Change-Id: I19d801444e4d1db5576b5742c60fc138384d3b70
2015-06-26loplugin:stringconstant: handle OUString+=OUString(literal)Stephan Bergmann
Change-Id: Id2efd6f38390bb73620cf40121430c4226024103
2015-06-26Make PyUNO provide more Pythonic behaviourMatthew J. Francis
- Simplifies working with UNO objects by giving the behaviour of Python lists, dicts and iterators to objects which implement UNO container interfaces - Applies a custom behaviour to allow objects which implement com::sun::star::table::XCellRange to yield cells and cell ranges by subscript - When UNO container objects are addressed in the new style, eliminates the requirement to manually construct Any objects for contained elements which are typed sequences - Allows lists and iterators to be passed wherever a UNO method accepts a sequence - Relaxes the requirements for initialising UNO structs to allow some members to be skipped when all initialisers are passed by name 1. Collection interfaces ======================== Objects which implement core UNO collection interfaces are made to behave in a way that is more natural for Python code. com::sun::star::container::XIndexAccess com::sun::star::container::XIndexReplace com::sun::star::container::XIndexContainer - Objects provide Python list access semantics num = len(obj) # Number of elements val = obj[0] # Access by index val1,val2 = obj[2:4] # Access by slice val1,val2 = obj[0:3:2] # Access by extended slice if val in obj: ... # Test value presence for val in obj: ... # Implicit iterator (values) itr = iter(obj) # Named iterator (values) obj[0] = val # Replace by index obj[2:4] = val1,val2 # Replace by slice obj[0:3:2] = val1,val2 # Replace by extended slice obj[2:3] = val1,val2 # Insert/replace by slice obj[2:2] = (val,) # Insert by slice obj[2:4] = (val,) # Replace/delete by slice obj[2:3] = () # Delete by slice (implicit) del obj[0] # Delete by index del obj[2:4] # Delete by slice com::sun::star::container::XNameAccess com::sun::star::container::XNameReplace com::sun::star::container::XNameContainer - Objects provide Python dict access semantics num = len(obj) # Number of keys val = obj[key] # Access by key if key in obj: ... # Test key presence for key in obj: ... # Implicit iterator (keys) itr = iter(obj) # Named iterator (keys) obj[key] = val # Replace by key obj[key] = val # Insert by key del obj[key] # Delete by key com::sun::star::container::XEnumerationAccess - Objects provide Python iterable semantics for val in obj: ... # Implicit iterator itr = iter(obj) # Named iterator com::sun::star::container::XEnumeration - Objects provide Python iterator semantics for val in itr: ... # Iteration of named iterator if val in itr: ... # Test value presence Objects which implement both XIndex* and XName* are supported, and respond to both integer and string keys. However, iterating over such an object will return the keys (like a Python dict) rather than the values (like a Python list). 2. Cell ranges ============== A custom behaviour is applied to objects which implement com::sun::star::table::XCellRange to allow their cells and cell ranges to be addressed by subscript, in the style of a Python list or dict (read-only). This is applicable to Calc spreadsheet sheets, Writer text tables and cell ranges created upon these. cell = cellrange[0,0] # Access cell by indices rng = cellrange[0,1:2] # Access cell range by index,slice rng = cellrange[1:2,0] # Access cell range by slice,index rng = cellrange[0:1,2:3] # Access cell range by slices rng = cellrange['A1:B2'] # Access cell range by descriptor rng = cellrange['Name'] # Access cell range by name Note that the indices used are in Python/C order, and differ from the arguments to methods provided by XCellRange. - The statement cellrange[r,c], which returns the cell from row r and column c, is equivalent to calling XCellRange::getCellByPosition(c,r) - The statement cellrange[t:b,l:r], which returns a cell range covering rows t to b(non-inclusive) and columns l to r(non- inclusive), is equivalent to calling XCellRange::getCellRangeByPosition(l,t,r-1,b-1). In contrast to the handling of objects implementing XIndex*, extended slice syntax is not supported. Negative indices (from-end addresses) are supported only for objects which also implement com::sun::star::table::XColumnRowRange (currently Calc spreadsheet sheets and cell ranges created upon these). For such objects, the following syntax is also available: rng = cellrange[0] # Access cell range by row index rng = cellrange[0,:] # Access cell range by row index rng = cellrange[:,0] # Access cell range by column index 3. Elimination of explicit Any ============================== PyUNO has not previously been able to cope with certain method arguments which are typed as Any but require a sequence of specific type to be passed. This is a particular issue for container interfaces such as XIndexContainer and XNameContainer. The existing solution to dealing with such methods is to use a special method to pass an explicitly typed Any, giving code such as: index = doc.createInstance("com.sun.star.text.ContentIndex"); ... uno.invoke( index.LevelParagraphStyles , "replaceByIndex", (0, uno.Any("[]string", ('Caption',))) ) The new Pythonic container access is able to correctly infer the expected type of the sequences required by these arguments. In the new style, the above call to .replaceByIndex() can instead be written: index.LevelParagraphStyles[0] = ('Caption',) 4. List and iterator arguments ============================== Wherever a UNO API expects a sequence, a Python list or iterator can now be passed. This enables the use of list comprehensions and generator expressions for method calls and property assignments. Example: tbl = doc.createInstance('com.sun.star.text.TextTable') tbl.initialize(10,10) # ... insert table ... # Assign numbers 0..99 to the cells using a generator expression tbl.Data = ((y for y in range(10*x,10*x + 10)) for x in range(10)) 5. Tolerant struct initialisation ================================= Previously, a UNO struct could be created fully uninitialised, or by passing a combination of positional and/or named arguments to its constructor. However, if any arguments were passed, all members were required to be initialised or an exception was thrown. This requirement is relaxed such that when all arguments passed to a struct constructor are by name, some may be omitted. The existing requirement that all members must be explicitly initialised when some constructor arguments are unnamed (positional) is not affected. Example: from com.sun.star.beans import PropertyValue prop = PropertyValue(Name='foo', Value='bar') Change-Id: Id29bff10a18099b1a00af1abee1a6c1bc58b3978 Reviewed-on: https://gerrit.libreoffice.org/16272 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Matthew Francis <mjay.francis@gmail.com>
2015-06-14Typo: pyhton->pythonJulien Nabet
Change-Id: I16d99991b8b88753c593a5a1ab9e32a8e0264514
2015-06-13TyposJulien Nabet
Change-Id: I21c352a63d668c174eef212dbfbe6346c678ce4d
2015-06-12Typo: Adapater->AdapterJulien Nabet
Change-Id: I696c0693dc7a69dc3a4b8df0c4e8571414d5b9a6
2015-06-10pyuno: remove obsolete LC_NUMERIC to "C" mangling codeMichael Stahl
The CPython changelog says for version 2.4: - Python no longer relies on the LC_NUMERIC locale setting to be the "C" locale; as a result, it no longer tries to prevent changing the LC_NUMERIC category. Change-Id: I6d63c4dedca48c99bf81135d69285d9116a19740
2015-06-08loplugin:cstylecast: deal with remaining pointer castsStephan Bergmann
Change-Id: Iffa346c16a6775b206c8f8613eee9e7201e3badb
2015-06-02loplugin:loopvartoosmallNoel Grandin
Change-Id: Ib4def3435eab4625645c5afe3b151f9f430564ac
2015-05-11loplugin:cstylecast: nop between pointer types of exactly same spellingStephan Bergmann
Change-Id: I0968c4b37b97bb89ebc8b873c78a96431245f480
2015-04-08A UNO Any can't contain an AnyStephan Bergmann
...and css::uno::makeAny<css::uno::Any>() was never meant to be used. Introduce css::uno::toAny for the (template-code) cases that shall return an Any for both Any and non-Any inputs. Change-Id: Ifa977d73f1da71b2fedde7e8140b19497c4a0257
2015-04-01Replace remaining getCppuType et al with cppu::UnoTypeStephan Bergmann
Change-Id: Id848d14133fee5104e79ba0683cbaf942598faa7
2015-03-29Clean up remaining C-style casts among void pointersStephan Bergmann
Change-Id: I1b49c020d597b569e330482f4dbf20c15ccdae3f
2015-03-28Clean up C-style casts from pointers to voidStephan Bergmann
Change-Id: I3676d56e65dd2d5b36882073c63e571a79819fee
2015-03-26WaE: redundant const_cast on lhs of pointer comparison expressionTor Lillqvist
Change-Id: Idd06653813e3f4863a5186eb6dce074227c25579
2015-03-26const_cast: convert some C-style casts and remove some redundant onesStephan Bergmann
Change-Id: I71ebd11d850304772535cfb873086176d301172a
2015-03-19We require MSVC2013 (_MSC_VER == 1800) nowTor Lillqvist
Change-Id: Ice8504041f22e00f2e5010813d9dff1d2987c8d6