Commit Graph

355 Commits

Author SHA1 Message Date
Stephan Bergmann
ac6dc5751e loplugin:salbool: Automatic rewrite of sal_False/True
Change-Id: I886fa2cc662072ad746d3828ba66bbd368121de8
2016-04-20 17:25:46 +02:00
Jochen Nitschke
150ac9cf05 clean-up: unused using declarations and includes
Searched source for using declarations.
Checked if those symbols reappear in the source file,
even in comments or dead code but not in #include statements.
If they don't reappear, remove the declaration.
Remove includes whose symbol got removed.

Change-Id: Ibb77163f63c1120070e9518e3dc0a78c6c59fab0
Reviewed-on: https://gerrit.libreoffice.org/24148
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2016-04-18 07:25:24 +00:00
Noel Grandin
62633dfe02 clang-tidy performance-unnecessary-value-param in various
Change-Id: I7168d44dab8e6a8e37bb7920d744ff32f5e52907
Reviewed-on: https://gerrit.libreoffice.org/24019
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-04-14 11:37:19 +00:00
Noel Grandin
b8eb294651 loplugin:passstuffbyref in various
Change-Id: I80070c83204e531c2f599f8a56193d6ffe0e5022
2016-04-14 10:24:47 +02:00
Jochen Nitschke
4c7ec9f112 cleanup: remove unused com/sun/star/uno includes
Sequence.h(xx), Any.h(xx) and Type.h(xx)
and remove unused using-declarations from these files.

Add a few missing includes provided by them.

Change-Id: I6b91b6d1fdf9d0496dd546c0aab9bdcc6831a5d4
Reviewed-on: https://gerrit.libreoffice.org/23805
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-04-12 06:38:26 +00:00
tymyjan
bfb9612226 tdf#97499 Fixed containers parameters clearing #3
Change-Id: I1c105de7e1df251533179fba77e3797ef1c4e2d4
Reviewed-on: https://gerrit.libreoffice.org/23752
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-04-04 05:46:34 +00:00
Jochen Nitschke
f7a75a66fa cleanup: remove unused Reference.h(xx) includes
and unused using-declarations from Reference.h

Change-Id: I297a7ae6044fa329d245ecf08fd5c4cb930f5b19
Reviewed-on: https://gerrit.libreoffice.org/23735
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
2016-04-02 19:01:24 +00:00
Wastack
eea3f508c3 tdf#97966 Drop 'static' keywords
Including no keywords from extern "C" blocks

Change-Id: I87f2ed75888b51ec9e0cb75566bf7c2351b479b4
Reviewed-on: https://gerrit.libreoffice.org/23675
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-04-01 06:46:02 +00:00
Tomáš Chvátal
a4c1704127 Fix python2 build of pyuno with older py2 versions
SyntaxError: ('invalid syntax', ('//usr/lib64/libreoffice/program//uno.py',
368, 77, "            return _ConstantGroup({c.Name.split('.')[-1]:
c.ConstantValue for c in td.Constants})\n"))

Change-Id: Ie87c21fbfd83fc4d6f918eb55128db235c2220a8
Reviewed-on: https://gerrit.libreoffice.org/22863
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-03-04 11:45:14 +00:00
Rico Tzschichholz
e14bd2d684 pyuno: Fix build with python 2.7
Adjust conditionals to properly respect python 2.7.1+

Change-Id: I32d21a071e054100294e418af5358305eac69944
Reviewed-on: https://gerrit.libreoffice.org/22231
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
2016-02-09 12:45:25 +00:00
Chris Sherlock
a238b1f8d3 Remove excess newlines
A ridiculously fast way of doing this is:

for i in $(pcregrep -l -M -r --include='.*[hc]xx$' \
  --exclude-dir=workdir --exclude-dir=instdir '^
{3,}' .)
do
    perl -0777 -i -pe 's/^
{3,}/

/gm' $i
done

Change-Id: Iebb93eccbee9e4fc5c4380474ba595858a27ac2c
Reviewed-on: https://gerrit.libreoffice.org/22224
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2016-02-09 08:18:05 +00:00
Andrea Gelmini
64d624b651 Fix typos
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-10 14:17:20 +00:00
Tomáš Chvátal
5c4bfb4071 Pyuno add compat for python 2.6
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-06 22:01:02 +00:00
Andrzej Hunt
9d0b06e9f7 new loplugin rangedforcopy - use reference in range based for
Inspired by 6e6ae98037

Change-Id: Ia0f264d3a6bbf076aa5080e3398683e50bc6ef01
Reviewed-on: https://gerrit.libreoffice.org/20190
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-01-05 11:06:52 +00:00
Noel Grandin
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
Stephan Bergmann
87686af6b8 loplugin:nullptr (automatic rewrite)
Change-Id: I7a5fda2606f42e2736ad0618f2d8bcc5ba4028fb
2015-11-10 10:31:33 +01:00
Noel Grandin
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
Noel Grandin
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
David Ostrovsky
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
Noel Grandin
8d80b5be02 com::sun::star->css in package,pyuno
Change-Id: I7b7b0e7fea2d1a2b9f6f5501ad5e0b8c1b4a17b9
2015-10-23 15:14:45 +02:00
Stephan Bergmann
b36963c0a6 Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY code
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-10-12 17:52:29 +02:00
Douglas Mencken
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
Noel Grandin
34180700b2 loplugin:removeunusedmethods, remove unused stuff
Change-Id: I35456b2a3ad2a84a1d045f09cdfb29e4c19b8350
2015-09-29 15:08:43 +02:00
Takeshi Abe
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
Stephan Bergmann
f5eeaaac7c loplugin:stringconstant: OUStringBuffer: appendAscii -> append
Change-Id: I98058ff0653a3aab3399735271d04b16a05a3684
2015-08-31 08:02:45 +02:00
Michael Weghorn
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
Matthew J. Francis
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
Matthew J. Francis
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
Matthew J. Francis
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
Matthew J. Francis
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
Caolán McNamara
7799d0749a coverity#1309066 Uncaught exception
Change-Id: If02a62e814051bb2d75a683877f8d17ec9201993
2015-07-02 11:39:32 +01:00
Matthew J. Francis
33776d143f PyUNO: Allow import of constant group by name
Change-Id: I0ea809a888187624261182552cf7fa0a9c96c648
2015-07-01 13:14:25 +08:00
Matthew J. Francis
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
Caolán McNamara
a1a7aa93a3 coverity#1308526 Uncaught exception
Change-Id: Ie0266c7e8ab5980dc25ce14edd42b3f599f71245
2015-06-28 17:55:54 +01:00
Stephan Bergmann
ce75e5b931 loplugin:implicitboolconversion
Change-Id: If495a415d4263d1932c03a31d07a517218533847
2015-06-26 14:10:03 +02:00
Stephan Bergmann
8811c41abc loplugin:cstylecast
Change-Id: I5f0bceb240a492c7c010b4356bc8efafdd83bf24
2015-06-26 14:07:54 +02:00
Stephan Bergmann
2a807ca137 loplugin:passstuffbyref
Change-Id: I66410932347b4f65c4b24b5316009ecffc8aef06
2015-06-26 14:06:45 +02:00
Stephan Bergmann
c44021f754 loplugin:salbool
Change-Id: I4875b12807aed36f758d81c731e2ac52a3a606e4
2015-06-26 14:05:44 +02:00
Stephan Bergmann
e29a7ff187 loplugin:salbool
Change-Id: I9975a87f6df2b7a79c376130864e9eb54bc3452b
2015-06-26 14:04:43 +02:00
Stephan Bergmann
7f9a65862b loplugin:loopvartoosmall
Change-Id: I19d801444e4d1db5576b5742c60fc138384d3b70
2015-06-26 14:03:46 +02:00
Stephan Bergmann
63e81af351 loplugin:stringconstant: handle OUString+=OUString(literal)
Change-Id: Id2efd6f38390bb73620cf40121430c4226024103
2015-06-26 13:55:33 +02:00
Matthew J. Francis
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
Julien Nabet
ad84b40b08 Typo: pyhton->python
Change-Id: I16d99991b8b88753c593a5a1ab9e32a8e0264514
2015-06-14 01:15:14 +02:00
Julien Nabet
3754474cde Typos
Change-Id: I21c352a63d668c174eef212dbfbe6346c678ce4d
2015-06-13 09:13:52 +02:00
Julien Nabet
22009c987b Typo: Adapater->Adapter
Change-Id: I696c0693dc7a69dc3a4b8df0c4e8571414d5b9a6
2015-06-12 23:57:33 +02:00
Michael Stahl
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
Stephan Bergmann
5782f69c0c loplugin:cstylecast: deal with remaining pointer casts
Change-Id: Iffa346c16a6775b206c8f8613eee9e7201e3badb
2015-06-08 16:27:02 +02:00
Noel Grandin
6ef9f7e202 loplugin:loopvartoosmall
Change-Id: Ib4def3435eab4625645c5afe3b151f9f430564ac
2015-06-02 12:09:56 +02:00
Stephan Bergmann
10fe9ed22b loplugin:cstylecast: nop between pointer types of exactly same spelling
Change-Id: I0968c4b37b97bb89ebc8b873c78a96431245f480
2015-05-11 12:50:14 +02:00
Stephan Bergmann
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