summaryrefslogtreecommitdiff
path: root/pyuno/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 20:22:48 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-22 07:43:35 +0100
commit494b3e69fd4bef0af19627cf31da98da376019d0 (patch)
treef0c9f434cfcc5775c45c79e8dba93453ec0ac8d0 /pyuno/source
parent968b64d054eb164cee9fb92b6bf7dd93f478bf24 (diff)
loplugin:flatten in package..reportdesign
Change-Id: I2da242fcb59709ebdd0819ec04d051d794da71e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127277 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'pyuno/source')
-rw-r--r--pyuno/source/module/pyuno.cxx36
-rw-r--r--pyuno/source/module/pyuno_module.cxx45
2 files changed, 39 insertions, 42 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index cdd5e417feeb..c3de37b82a88 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -739,32 +739,30 @@ static PyObject* lcl_getitem_slice( PyUNO const *me, PyObject *pKey )
nLen = xIndexAccess->getCount();
}
- if ( xIndexAccess.is() )
+ if ( !xIndexAccess )
+ return nullptr;
+
+ sal_Int32 nStart = 0, nStop = 0, nStep = 0, nSliceLength = 0;
+ int nSuccess = lcl_PySlice_GetIndicesEx(pKey, nLen, &nStart, &nStop, &nStep, &nSliceLength);
+ if ( nSuccess == -1 && PyErr_Occurred() )
+ return nullptr;
+
+ PyRef rTuple( PyTuple_New( nSliceLength ), SAL_NO_ACQUIRE, NOT_NULL );
+ sal_Int32 nCur, i;
+ for ( nCur = nStart, i = 0; i < nSliceLength; nCur += nStep, i++ )
{
- sal_Int32 nStart = 0, nStop = 0, nStep = 0, nSliceLength = 0;
- int nSuccess = lcl_PySlice_GetIndicesEx(pKey, nLen, &nStart, &nStop, &nStep, &nSliceLength);
- if ( nSuccess == -1 && PyErr_Occurred() )
- return nullptr;
+ Any aRet;
- PyRef rTuple( PyTuple_New( nSliceLength ), SAL_NO_ACQUIRE, NOT_NULL );
- sal_Int32 nCur, i;
- for ( nCur = nStart, i = 0; i < nSliceLength; nCur += nStep, i++ )
{
- Any aRet;
-
- {
- PyThreadDetach antiguard;
+ PyThreadDetach antiguard;
- aRet = xIndexAccess->getByIndex( nCur );
- }
- PyRef rRet = runtime.any2PyObject( aRet );
- PyTuple_SetItem( rTuple.get(), i, rRet.getAcquired() );
+ aRet = xIndexAccess->getByIndex( nCur );
}
-
- return rTuple.getAcquired();
+ PyRef rRet = runtime.any2PyObject( aRet );
+ PyTuple_SetItem( rTuple.get(), i, rRet.getAcquired() );
}
- return nullptr;
+ return rTuple.getAcquired();
}
static PyObject* lcl_getitem_string( PyUNO const *me, PyObject *pKey, Runtime const & runtime )
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx
index a5167ef09919..81a8b7919db9 100644
--- a/pyuno/source/module/pyuno_module.cxx
+++ b/pyuno/source/module/pyuno_module.cxx
@@ -708,31 +708,30 @@ static PyObject * fileUrlToSystemPath(
static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args )
{
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 2 )
- {
- OUString ouPath = pyString2ustring( PyTuple_GetItem( args , 0 ) );
- OUString ouRel = pyString2ustring( PyTuple_GetItem( args, 1 ) );
- OUString ret;
- oslFileError e = osl_getAbsoluteFileURL( ouPath.pData, ouRel.pData, &(ret.pData) );
- if( e != osl_File_E_None )
- {
- OUString buf =
- "Couldn't absolutize " +
- ouRel +
- " using root " +
- ouPath +
- " for reason (" +
- OUString::number(static_cast<sal_Int32>(e) ) +
- ")";
+ if( !PyTuple_Check( args ) || PyTuple_Size( args ) != 2 )
+ return nullptr;
- PyErr_SetString(
- PyExc_OSError,
- OUStringToOString(buf,osl_getThreadTextEncoding()).getStr());
- return nullptr;
- }
- return ustring2PyUnicode( ret ).getAcquired();
+ OUString ouPath = pyString2ustring( PyTuple_GetItem( args , 0 ) );
+ OUString ouRel = pyString2ustring( PyTuple_GetItem( args, 1 ) );
+ OUString ret;
+ oslFileError e = osl_getAbsoluteFileURL( ouPath.pData, ouRel.pData, &(ret.pData) );
+ if( e != osl_File_E_None )
+ {
+ OUString buf =
+ "Couldn't absolutize " +
+ ouRel +
+ " using root " +
+ ouPath +
+ " for reason (" +
+ OUString::number(static_cast<sal_Int32>(e) ) +
+ ")";
+
+ PyErr_SetString(
+ PyExc_OSError,
+ OUStringToOString(buf,osl_getThreadTextEncoding()).getStr());
+ return nullptr;
}
- return nullptr;
+ return ustring2PyUnicode( ret ).getAcquired();
}
static PyObject * invoke(SAL_UNUSED_PARAMETER PyObject *, PyObject *args)