Commit Graph

408 Commits

Author SHA1 Message Date
2554efabb6 use comphelper::containerToSequence
in chart2, we remove a local equivalent of the method

Change-Id: I25129a3d1ea1dd724eb9cd38a57be37a78b3d100
2015-11-19 09:33:29 +02:00
87686af6b8 loplugin:nullptr (automatic rewrite)
Change-Id: I7a5fda2606f42e2736ad0618f2d8bcc5ba4028fb
2015-11-10 10:31:33 +01:00
59b072e22b yyyyy
Change-Id: I9a947beefd2dfe21da8239e841ea3fb416bd1548
2015-11-04 14:10:44 +02:00
3bc5df7f32 UNO: no need to use OUString constructor when calling createInstance
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-30 08:59:59 +00:00
644487a115 loplugin:unusedmethods
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-27 08:20:43 +00:00
147cb6a2ae Bump python to 3.5
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-25 08:29:39 +00:00
8d80b5be02 com::sun::star->css in package,pyuno
Change-Id: I7b7b0e7fea2d1a2b9f6f5501ad5e0b8c1b4a17b9
2015-10-23 15:14:45 +02:00
b36963c0a6 Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY code
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-10-12 17:52:29 +02:00
f1e6e9e7ff fix build by moving python-related includes below others
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-10-09 21:02:02 +00:00
34180700b2 loplugin:removeunusedmethods, remove unused stuff
Change-Id: I35456b2a3ad2a84a1d045f09cdfb29e4c19b8350
2015-09-29 15:08:43 +02:00
ee7da352b8 Resolves: tdf#88206 replace cppu::WeakImplHelper* etc.
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-09-15 06:19:28 +00:00
f5eeaaac7c loplugin:stringconstant: OUStringBuffer: appendAscii -> append
Change-Id: I98058ff0653a3aab3399735271d04b16a05a3684
2015-08-31 08:02:45 +02:00
7e318570dc tdf#39440 reduce scope of local variables
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-22 13:04:12 +00:00
2387c2a46e Give PyUNO structs/exceptions their own separate type
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-30 05:55:32 +00:00
9c5a217681 Tweak introspection/invocation to be more useful to PyUNO
- 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-27 07:40:34 +00:00
3458a25202 Fix PyUNO object hash to use the correct pointer
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-25 02:17:28 +00:00
a781abe326 Make PyUNO objects hashable
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-21 06:56:42 +00:00
7799d0749a coverity#1309066 Uncaught exception
Change-Id: If02a62e814051bb2d75a683877f8d17ec9201993
2015-07-02 11:39:32 +01:00
33776d143f PyUNO: Allow import of constant group by name
Change-Id: I0ea809a888187624261182552cf7fa0a9c96c648
2015-07-01 13:14:25 +08:00
3a6ec53eee Fix compilation with Python 2.7
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-07-01 04:18:48 +00:00
a1a7aa93a3 coverity#1308526 Uncaught exception
Change-Id: Ie0266c7e8ab5980dc25ce14edd42b3f599f71245
2015-06-28 17:55:54 +01:00
ce75e5b931 loplugin:implicitboolconversion
Change-Id: If495a415d4263d1932c03a31d07a517218533847
2015-06-26 14:10:03 +02:00
8811c41abc loplugin:cstylecast
Change-Id: I5f0bceb240a492c7c010b4356bc8efafdd83bf24
2015-06-26 14:07:54 +02:00
2a807ca137 loplugin:passstuffbyref
Change-Id: I66410932347b4f65c4b24b5316009ecffc8aef06
2015-06-26 14:06:45 +02:00
c44021f754 loplugin:salbool
Change-Id: I4875b12807aed36f758d81c731e2ac52a3a606e4
2015-06-26 14:05:44 +02:00
e29a7ff187 loplugin:salbool
Change-Id: I9975a87f6df2b7a79c376130864e9eb54bc3452b
2015-06-26 14:04:43 +02:00
7f9a65862b loplugin:loopvartoosmall
Change-Id: I19d801444e4d1db5576b5742c60fc138384d3b70
2015-06-26 14:03:46 +02:00
63e81af351 loplugin:stringconstant: handle OUString+=OUString(literal)
Change-Id: Id2efd6f38390bb73620cf40121430c4226024103
2015-06-26 13:55:33 +02:00
af8143bc40 Make PyUNO provide more Pythonic behaviour
- 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::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::container::XIndexAccess
com::sun::container::XIndexReplace
com::sun::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::container::XNameAccess
com::sun::container::XNameReplace
com::sun::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::container::XEnumerationAccess
- Objects provide Python iterable semantics
    for val in obj: ...         # Implicit iterator
    itr = iter(obj)             # Named iterator

com::sun::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::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::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-26 09:41:11 +00:00
ad84b40b08 Typo: pyhton->python
Change-Id: I16d99991b8b88753c593a5a1ab9e32a8e0264514
2015-06-14 01:15:14 +02:00
3754474cde Typos
Change-Id: I21c352a63d668c174eef212dbfbe6346c678ce4d
2015-06-13 09:13:52 +02:00
22009c987b Typo: Adapater->Adapter
Change-Id: I696c0693dc7a69dc3a4b8df0c4e8571414d5b9a6
2015-06-12 23:57:33 +02:00
1ee5e1a17c pyuno: remove obsolete LC_NUMERIC to "C" mangling code
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-10 14:38:27 +02:00
5782f69c0c loplugin:cstylecast: deal with remaining pointer casts
Change-Id: Iffa346c16a6775b206c8f8613eee9e7201e3badb
2015-06-08 16:27:02 +02:00
6ef9f7e202 loplugin:loopvartoosmall
Change-Id: Ib4def3435eab4625645c5afe3b151f9f430564ac
2015-06-02 12:09:56 +02:00
10fe9ed22b loplugin:cstylecast: nop between pointer types of exactly same spelling
Change-Id: I0968c4b37b97bb89ebc8b873c78a96431245f480
2015-05-11 12:50:14 +02:00
9222f5d065 A UNO Any can't contain an Any
...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-08 17:45:08 +02:00
714f4db8d3 Replace remaining getCppuType et al with cppu::UnoType
Change-Id: Id848d14133fee5104e79ba0683cbaf942598faa7
2015-04-01 08:40:15 +02:00
0bd502af47 Clean up remaining C-style casts among void pointers
Change-Id: I1b49c020d597b569e330482f4dbf20c15ccdae3f
2015-03-29 09:17:47 +02:00
8375ac0186 Clean up C-style casts from pointers to void
Change-Id: I3676d56e65dd2d5b36882073c63e571a79819fee
2015-03-28 19:09:23 +01:00
9bd2b842a5 const_cast: convert some C-style casts and remove some redundant ones
Change-Id: I71ebd11d850304772535cfb873086176d301172a
2015-03-26 15:33:33 +01:00
a251fe4d48 We require MSVC2013 (_MSC_VER == 1800) now
Change-Id: Ice8504041f22e00f2e5010813d9dff1d2987c8d6
2015-03-19 10:57:17 +02:00
e557b160fd pyuno, scripting: remove executable bits from python, js, bsh files
Change-Id: Id108693d84fbca7764614e126ee1b3b045baec17
2015-03-02 13:26:28 +01:00
7b83298667 Some more loplugin:cstylecast: pyuno
Change-Id: I80c9fdb45c9f58ac3cd1b0fab2631b903194e268
2015-01-20 09:06:50 +01:00
5484475fc1 include algorithm
Change-Id: I55abf17a1da2616ca2b1303747ca8cc7e402634e
2015-01-02 17:03:55 +00:00
fd1372ba8b boost::unordered_map->std::unordered_map
you can get debug stl this way

Change-Id: Ia70a3e7c7c452390e8bee34975d296c9318e4a19
2015-01-02 16:14:36 +00:00
3dfcc045dd pyuno: Use appropriate OUString functions on string constants
Change-Id: Ib507da6fc85d8bc81fd48108a98ef96d188643ac
2014-12-12 12:21:47 +01:00
8eb37e74ff pyuno: move "officehelper.py" from scripting to pyuno
... because at least in Fedora packages with system python it's a pain
to use officehelper.bootstrap() because unlike pyuno it is not installed
in the standard python directories but in libreoffice/program.

You might think that bootstrap() is not appropriate functionality for a
UNO langauge binding, but then why does ::cppu::bootstrap() exist?

Change-Id: I5fd4b344a811c087d32fb6304e55105ab3cb137e
Reviewed-on: https://gerrit.libreoffice.org/12968
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
2014-12-02 13:47:26 +00:00
2ad716f406 Revert "pyuno: set up fake command line in getComponentContext()"
This reverts commit 2386a92c1e6e8ec263edb4dc4fdcfeaa4673ce1f and its follow-ups
1acaa577b67158c060d2f57414f7aea86504a489 "sal: add special handling of argc==0
to osl_setCommandArgs()" and 01f27b5e5d428cc3c4aeabdcbbb8204494fbd435 "sal: fix
osl_setCommandArgs() on WNT."

The situation that osl_getCommandArgCount is called without a prior call to
osl_setCommandArgs should be considered as harmless and can legitimately not
only happen in the pyuno case discussed in the reverted commits, but also in
case binary UNO is bootstrapped from within a Java process, as happens in
test-javanative in ure/source/uretest/Makefile.

Change-Id: I2829db390e37dfe5daeda33a4c0659b7d35e565a
2014-11-25 23:22:13 +01:00
15b4ab8d19 cppuhelper: clean up public headers with include-what-you-use
Change-Id: I41ba46831f24b2960a1fe982b74a2b623e682e0b
2014-11-18 18:51:49 +01:00