Commit Graph

47 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
Tor Lillqvist
a251fe4d48 We require MSVC2013 (_MSC_VER == 1800) now
Change-Id: Ice8504041f22e00f2e5010813d9dff1d2987c8d6
2015-03-19 10:57:17 +02:00
Caolán McNamara
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
Noel Grandin
0e507ae031 various: remove SAL_THROW macro
Change-Id: I9464179a736b91f5bc32eb5e5e89b3b4e3da3494
2014-06-05 08:17:52 +02:00
Thomas Arnhold
2bd7767d01 Resolves fdo#70681: fixincludeguards.pl: all that's left
Change-Id: I3e51a62710bb46c8255fd228d41d9300c90a1fb5
Reviewed-on: https://gerrit.libreoffice.org/9360
Reviewed-by: Thomas Arnhold <thomas@arnhold.org>
Tested-by: Thomas Arnhold <thomas@arnhold.org>
2014-05-15 12:50:46 +00:00
Noel Grandin
e5d0a9ad78 pyuno: sal_Bool->bool
Change-Id: I071c8984cd86b523d8ebae04b5fb2bdc1ac1a5b1
2014-05-08 11:48:14 +02:00
Caolán McNamara
d69b30a84d coverity#1019376 Resource leak
Change-Id: Ifa9c5a7b3aa0d219e09fa3081e66d870a508a84d
2014-04-02 15:51:15 +01:00
Stephan Bergmann
70cc2b191b First batch of adding SAL_OVERRRIDE to overriding function declarations
...mostly done with a rewriting Clang plugin, with just some manual tweaking
necessary to fix poor macro usage.

Change-Id: I71fa20213e86be10de332ece0aa273239df7b61a
2014-03-26 16:39:26 +01:00
Stephan Bergmann
5e21a413c7 cppuhelper: retrofit std::exception into overriding exception specs
Change-Id: I56e32131b7991ee9948ce46765632eb823d463b3
2014-02-26 18:22:20 +01:00
Alexander Wilms
3a35e28628 Remove visual noise from pyuno
Change-Id: I27f5edf45d5968879436e2466f953576651ed8ae
Reviewed-on: https://gerrit.libreoffice.org/8290
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2014-02-26 09:21:35 -06:00
Stephan Bergmann
cedba3ffd8 Use bool
Change-Id: I4c05c602ecdd77d07e8106387270bf01718e975b
2014-01-10 17:11:44 +01:00
David Bolen
1be8e912ba fdo#50470: Restore pyuno object method introspection in Python 3
Switch to __dir__ entry point for introspection as Python 3 dropped support
for __members__/__methods__.  This is backwards compatible to Python 2.6.

Module initialization adjusted to complete type setup (needed for tp_dict)
via PyType_Ready.

Change-Id: Ie1f7b9dd4279242de89d009eb7acdc8c786dab8f
Reviewed-on: https://gerrit.libreoffice.org/5375
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
2013-08-13 11:34:52 +00:00
Herbert Dürr
28a4496c76 Resolves: #i120788# remove unused members from PyUNO_callable_Internals
Patch by: Tsutomu Uchino <hanya.runo@gmail.com>

(cherry picked from commit 5e2c3fd88906494965979bd20ca852391bee3bac)

Conflicts:
	pyuno/source/module/pyuno_impl.hxx

Change-Id: If73d5f7b799f04b79b5cc71d2d44c797851b18d0
2013-07-12 11:45:05 +01:00
Luboš Luňák
1946794ae0 mass removal of rtl:: prefixes for O(U)String*
Modules sal, salhelper, cppu, cppuhelper, codemaker (selectively) and odk
have kept them, in order not to break external API (the automatic using declaration
is LO-internal).

Change-Id: I588fc9e0c45b914f824f91c0376980621d730f09
2013-04-07 14:23:11 +02:00
Tor Lillqvist
43df436f60 WaE: Fix needed with MSVS 2010, too
Change-Id: I1d1da64b14139c1d90ac07685f3fe88e99253815
2012-12-25 10:55:29 +02:00
Tor Lillqvist
781548472b VS2012 WaE: C4211: nonstandard extension used : redefined extern to static
Some screwup with hypot(). As a workaround, include <math.h> early.

Change-Id: Ic8c6abc45f8502097c6b6b619108d50ea3c22392
2012-12-21 18:39:28 +02:00
Michael Stahl
af2b7fac27 pyuno: fix handling of "str", "unicode", "bytes" types:
Replace currrent wrappers of Python 2 only PyString_* functions with
better abstractions that handle default "str" (PyStr_*) or byte strings
("str"/"bytes" depending on version, PyStrBytes_*) and adjust all
invocations to work on appropriate string types.
Fixes obvious "attributes typeName and/or value of uno.Enum are not
strings" exceptions with Python 3.

Change-Id: I255dcb1bc198fd7f6a62b83b957901521071a480
2012-11-25 16:06:40 +01:00
Michael Meeks
1d3e6bb6c4 re-base on ALv2 code. Removing:
a patch contributed by Pedro Giffuni to handle FreeBSD issues
    that are unlikely to be an issue with a two-layer LibreOffice.
    http://svn.apache.org/viewvc?view=revision&revision=1180509
2012-07-02 16:52:50 +01:00
Alexander Bergmann
99b2adf721 Removed unused code 2012-02-10 14:20:52 +00:00
Alexander Bergmann
0439af27e1 Code cleanup: ( () ) replaced by (()) 2012-01-26 17:41:07 +00:00
Stephan Bergmann
7c704c78d3 Removed some unused parameters; added SAL_UNUSED_PARAMETER.
SAL_UNUSED_PARAMETER (expanding to __attribute__ ((unused)) for GCC)
is used to annotate legitimately unused parameters, so that static
analysis tools can tell legitimately unused parameters from truly
unnecessary ones.  To that end, some patches for external modules
are also added, that are only applied when compiling with GCC and
add necessary __attribute__ ((unused)) in headers.
2012-01-21 15:21:16 +01:00
Joseph Powers
966b75157f PyVarObject_HEAD_INIT() isn't defined in Python 2.5-
Mac OS X is still being compiled vs 2.3
2011-05-07 17:41:06 -07:00
Andreas Becker
a09ce46818 Port PyUno to support Python 3 2011-05-07 20:35:03 +01:00
Fridrich Strba
030633cd53 moving the rest of ure repository to boost unordered containers 2011-02-04 00:28:23 +01:00
Sebastian Spaeth
a715e1b3d0 Add vim/emacs modelines to all source files
Fixes #fdo30794
Based on bin/add-modelines script (originally posted in mail
1286706307.1871.1399280959@webmail.messagingengine.com)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-10-14 17:04:31 +02:00
Jens-Heiner Rechtien
7c80db2eb3 changefileheader2: #i109125#: change source file copyright notice from Sun Microsystems to Oracle; remove CVS style keywords (RCSfile, Revision) 2010-02-12 15:01:35 +01:00
Rüdiger Timm
6267704651 INTEGRATION: CWS changefileheader (1.6.54); FILE MERGED
2008/03/31 07:24:58 rt 1.6.54.1: #i87441# Change license header to LPGL v3.
2008-04-11 09:35:32 +00:00
Jens-Heiner Rechtien
c79d6a2782 INTEGRATION: CWS warnings01 (1.3.44); FILE MERGED
2006/04/20 14:46:09 sb 1.3.44.5: #i53898# Made code warning-free again after resync to SRC680m162.
2006/04/07 21:24:23 sb 1.3.44.4: RESYNC: (1.4-1.5); FILE MERGED
2006/03/01 10:01:16 sb 1.3.44.3: #i53898# Made code waring-free.
2005/09/23 02:08:50 sb 1.3.44.2: RESYNC: (1.3-1.4); FILE MERGED
2005/09/09 15:31:19 sb 1.3.44.1: #i53898# Made code warning-free.
2006-06-20 04:03:59 +00:00
Oliver Bolte
b9a3ce0386 INTEGRATION: CWS pyunofixes2 (1.3.40); FILE MERGED
2006/01/07 21:35:15 jbu 1.3.40.3: RESYNC: (1.3-1.4); FILE MERGED
2005/09/09 18:51:58 jbu 1.3.40.2: #i54416# removed now obsolete PYUNO_DEBUG macro
2005/09/09 18:43:07 jbu 1.3.40.1: #i54416#,#i47270# added logging support for pyuno + refcounting bug for __members__ variable fixed
2006-03-22 09:49:43 +00:00
Rüdiger Timm
6f477c90de INTEGRATION: CWS ooo19126 (1.3.42); FILE MERGED
2005/09/05 18:39:21 rt 1.3.42.1: #i54170# Change license header: remove SISSL
2005-09-08 15:52:59 +00:00
Jens-Heiner Rechtien
37e9825d0d INTEGRATION: CWS geordi2q14 (1.2.34); FILE MERGED
2004/01/29 18:09:56 hr 1.2.34.1: #111934#: merge CWS ooo111fix2
2004-02-02 18:30:27 +00:00
Jörg Budischewski
4640b548a7 #i12504# added conversion mode 2003-05-24 22:28:33 +00:00
Jörg Budischewski
e80bdbafeb initial checkin for the pyuno-0.9.2 release 2003-03-23 11:12:59 +00:00