summaryrefslogtreecommitdiff
path: root/scripting
AgeCommit message (Collapse)AuthorFilesLines
2019-11-09tdf#80731: Only check closing parenthesis when in IDEMike Kaganski1-4/+2
This reinstates the fix by Pierre Lepage, which was reverted in 351dead74b4c213b13102f81b5ae9bb47ad8ca39, and makes sure it only has effect when the compilation is started from IDE. The idea is that the IDE is used primarily for development, and that's a good opportunity to detect any error in the code. When the code is compiled from outside of the IDE (like running an extension), the error is tolerated to allow users run the legacy code having this error. Hopefully this is enough for tdf#106529. This re-uses comphelper's NoEnableJavaInteractionContext class, which is converted into general-purpose SetFlagContext class to avoid code duplication. Change-Id: Ie290019cb190b8d1d590699ec13bd63eac478d09 Reviewed-on: https://gerrit.libreoffice.org/81616 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-11-08Respect DisableMacrosExecution option in javascript editorSamuel Mehrbrodt3-51/+64
Change-Id: I44c2d3a706a99839369bd4aff2abbb675e430926 Reviewed-on: https://gerrit.libreoffice.org/82286 Tested-by: Jenkins Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de>
2019-11-08Respect DisableMacrosExecution option in beanshell editorSamuel Mehrbrodt1-0/+29
Change-Id: I0713b3d1ab45519aef25b5bd3d912baf2252d37b Reviewed-on: https://gerrit.libreoffice.org/82262 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-11-06Check if scripting disabled for each dispatch callSamuel Mehrbrodt1-1/+4
Not only when initializing. This way, changing the property during runtime has an effect. Change-Id: Iba5f00996f0079fc4bafb5d373f34c6fd86c7959 Reviewed-on: https://gerrit.libreoffice.org/82078 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-11-05Fix option to disable macrosSamuel Mehrbrodt2-1/+6
so that it indeeds disables any macro execution. Before, you could still add macros to the toolbar and execute them from there (and probably many more places). Now, if this option is set, any macro will no longer be executed. This includes Javascript, Beanshell and Python scripts Change-Id: Icfa845e836782c8e1b670a67694f79a60ad74fad Reviewed-on: https://gerrit.libreoffice.org/82052 Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de>
2019-10-31Fix StringAdd::isCompileTimeConstantStephan Bergmann1-10/+5
...to find StringLiteral on the RHS of +=. Which revealed that the VisitCompoundStmt/checkForCompoundAssign logic needed to be fixed, too, so that s += side_effect(); s += "literal"; s += side_effect(); only gets combined to s += side_effect() + "literal"; s += side_effect(); and not all the way to s += side_effect() + "literal" + side_effect(); Change-Id: I432e3458b933a7d0ad6141c747b675cc8b0f0ba4 Reviewed-on: https://gerrit.libreoffice.org/81804 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-17Remaining loplugin:bufferaddStephan Bergmann1-4/+1
...that had been missing because the plugin didn't implement postRun, so it didn't report anything when run as part of the shared plugin. (But did report the expected warnings when run as a standalone plugin during CompilerTest_compilerplugins_clang.) Most fixes are straightforward. A noteworthy one is PreparedStatement::setBytes in connectivity/source/drivers/postgresql/pq_preparedstatement.cxx: The old preallocation of a 20 character OStringBuffer might have prevented buf.append( reinterpret_cast<char *>(escapedString), len -1 ); from potentially throwing std::bad_alloc, which would have caused escapedString to be leaked. Even though that 20-character preallocation was likely just random junk and not meant to address the potential leak, lets address it now. Change-Id: Ib506332d061684a22a74e5e39e591539fd2c4900 Reviewed-on: https://gerrit.libreoffice.org/80925 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-16loplugin:stringadd look through a couple more known-good methodsNoel Grandin1-8/+8
Change-Id: Ifbdb3e41eae665f7dcaf5301aaba2b6e4662cf48 Reviewed-on: https://gerrit.libreoffice.org/80855 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-01loplugin:stringadd in scNoel Grandin2-9/+4
Change-Id: Idab16f785ca5e8954f8e50132938f6329106c927 Reviewed-on: https://gerrit.libreoffice.org/79891 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-09-29Fix typosAndrea Gelmini1-3/+3
Change-Id: I8a93a6ed49661ddfae390a0302fca1fab5c95f14 Reviewed-on: https://gerrit.libreoffice.org/79795 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
2019-09-26loplugin:constmethod in scNoel Grandin4-5/+5
Change-Id: I78c4fb4acf21756f91582caee5e30e3ad1fc2ae4 Reviewed-on: https://gerrit.libreoffice.org/79543 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-09-06Fixing "...."Andrea Gelmini1-2/+2
Change-Id: I3424e17cfdfb563fdc5882942031deafae8689fe Reviewed-on: https://gerrit.libreoffice.org/78678 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-08-31Fix typosAndrea Gelmini1-1/+1
Change-Id: Iac08e415f84741ecdb151788776ee15e7364fae1 Reviewed-on: https://gerrit.libreoffice.org/77762 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
2019-08-26loplugin:returnconstval in variousNoel Grandin2-2/+2
Change-Id: Ib5d293417b1faeb7ef63a8df99fc1ba644989cdc Reviewed-on: https://gerrit.libreoffice.org/78079 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-20loplugin:constvars in sccomp..sdNoel Grandin3-5/+6
Change-Id: Ic4b2a1d23da80a5b0976692f490c29a7169be3ef Reviewed-on: https://gerrit.libreoffice.org/77793 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-19Improve check for absolute URIStephan Bergmann1-1/+1
Change-Id: I4dee44832107f72f8f3fb68554428dc1e646c346 Reviewed-on: https://gerrit.libreoffice.org/77706 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-17tdf#88205 Adapt uses of css::uno::Sequence to use initializer_list ctorJulien Nabet5-28/+12
in scaddins, scripting Change-Id: I92e6380f535aec12c1f1c5c51d8b544c8a7d9611 Reviewed-on: https://gerrit.libreoffice.org/77650 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-08-16member 'Context' of struct type 'uno.Exception' not given a valueCaolán McNamara1-6/+7
Change-Id: Ie80f729e5c1dbf3214f9532dcb935b239bac7997 Reviewed-on: https://gerrit.libreoffice.org/77566 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-16AttributeError on getMessageCaolán McNamara1-1/+1
Change-Id: If0bd315fe605b850ec397eb2267b08ad8039355c Reviewed-on: https://gerrit.libreoffice.org/77565 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-16an absolute uri is invalid inputCaolán McNamara1-0/+5
Change-Id: I392be4282be8ed67e3451b28d2c9f22acd4c87fc Reviewed-on: https://gerrit.libreoffice.org/77564 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-15loplugin:sequenceloop in scaddins..scriptingNoel Grandin5-9/+9
Change-Id: I25044332e107b630b257e48d95ee9272145ed344 Reviewed-on: https://gerrit.libreoffice.org/77524 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-14revert part of 'warn on load when a document binds an event to a macro'Caolán McNamara1-23/+33
i.e. commit b3edf85e0fe6ca03dc26e1bf531be82193bc9627 Author: Caolán McNamara <caolanm@redhat.com> Date: Wed Aug 7 17:37:11 2019 +0100 because then extensions that add a entry to menus results in menu entries that cannot run in the start center where there is no document. If allowed when there is no document, it would still result in the odd behaviour that such menu entries would not work in a document which contained macros or macro-calls if permission was denied to run them Add a similar check instead to SfxEvents_Impl::Execute Change-Id: I8084ab2dc66bb95e2562a3dba188c721d44a5676 Reviewed-on: https://gerrit.libreoffice.org/77465 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-13warn on load when a document binds an event to a macroCaolán McNamara1-33/+22
a) treat shared/Scripts equivalently to document scripts This doesn't automatically warn/block running those scripts when used in a freshly loaded document on its own however because DocumentMacroMode::checkMacrosOnLoading will see at... if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() ) that the document contains no macros and flip the allow macros flag to true so that potentially new uses of macros added by the user during the edit are allowed to run b) so, add an additional flag to indicate existence of use of macros in a document c) for odf import, set it when a script:event-listener tag is encountered d) for html import when registerScriptEvents or SwFormatINetFormat::SetMacroTable is called e) for doc import when Read_F_Macro or StoreMacroCmds is called as well for good measure f) for xls import when registerScriptEvent or ScMacroInfo::SetMacro is called g) for oox import when VbaProject::attachMacros is called Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b Reviewed-on: https://gerrit.libreoffice.org/77131 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-13construct final url from parsed outputCaolán McNamara1-2/+10
Change-Id: Ifd733625a439685ad307603eb2b00bf463eb9ca9 Reviewed-on: https://gerrit.libreoffice.org/77373 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-12Fix typosAndrea Gelmini1-1/+1
Change-Id: I3e6b96f4ea341130e98ee54ed8c124209b05d343 Reviewed-on: https://gerrit.libreoffice.org/77291 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-08-11Fixed typoMatthias Seidel1-1/+1
(cherry picked from commit 1f21ba2f2a1bc287cd869b0a03eac6e8a90eb21f) Change-Id: I286d0e6b04d6505f0728d6f84d34239be060dc27 Reviewed-on: https://gerrit.libreoffice.org/77268 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-08Related tdf#116767: Call URLClassLoader.closeStephan Bergmann2-43/+52
...which required the return type of com.sun.star.script.framework.provider.ClassLoaderFactory.getURLClassLoader to be changed. (In theory, there could be 3rd-party scripting providers that hook into the framework and are affected by that incompatible change, but, practically, chances should be low.) Change-Id: I083c398726aaf62df7286d6da86b9d2056a5a8c1 Reviewed-on: https://gerrit.libreoffice.org/77146 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-08Remove unused NoSuitableClassLoaderExceptionStephan Bergmann2-43/+0
It was introduced with 980aa9b06ca521363ae4175f349becd4cdd501aa "#i19331#" (or at least moved to its current place there, with older traces lost to history), but its only actual use in the code has since been removed with 8087d5389f8d1133f119a9e6db88f91229831b61 "Java new cannot return null". (In theory, there could be 3rd-party scripting providers that hook into the framework and use that class, but, practically, chances should be low.) Change-Id: I8586fccf120c93391308ede547bbeec6fabf2743 Reviewed-on: https://gerrit.libreoffice.org/77142 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-08Remove odd catch of ArrayStoreExceptionStephan Bergmann1-17/+4
...(which is a RuntimeException) around a call of com.sun.star.script.framework.provider.ClassLoaderFactory.getURLClassLoader. The catch block was introduced in 3076ea9dc6677dcf0f65c53c8f205d870dc27d53 "INTEGRATION: CWS scriptingf2 (1.2.2); FILE MERGED", for no apparent reason. It was introduced along with catch blocks for MalformedURLException and NoSuitableClassLoaderException, but which have already been removed with 616b3ad50404f35d84708b3feeb8c66f2f23f1b1 "java: remove exceptions from throws clauses that are not". Change-Id: I8d2890aed1b0f50fe817002cb6f1610c550568f1 Reviewed-on: https://gerrit.libreoffice.org/77140 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-06Properly obtain locationStephan Bergmann1-2/+7
Change-Id: I9fb0d883a3623394343cd54ef61e5610544198c8 Reviewed-on: https://gerrit.libreoffice.org/77019 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-06keep name percent-encodedStephan Bergmann1-1/+3
Change-Id: I470c4b24192c3e3c9b556a9bbb3b084359e0033b Reviewed-on: https://gerrit.libreoffice.org/76892 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-07-31Improved loplugin:stringconstant (now that GCC 7 supports it): scriptingStephan Bergmann9-22/+22
Change-Id: I60519d5f0663ab244468f10cbc79a8fc80771726 Reviewed-on: https://gerrit.libreoffice.org/76651 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-07-30Simplify Sequence iterations in scaddins, sccomp, scriptingArkadiy Illarionov10-106/+68
Use range-based loops, STL and comphelper functions Change-Id: I836422a1c81a3dc9585687ed2e506eb59bb4ec91 Reviewed-on: https://gerrit.libreoffice.org/76484 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
2019-07-23cid#1448376 SIC: Inner class could be made staticCaolán McNamara1-1/+1
Change-Id: Id9923031c1fe91ba71dfe8d68cbe23b72e9637b5 Reviewed-on: https://gerrit.libreoffice.org/76143 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-07-20cid#1448526 RANGE: Range checksCaolán McNamara1-1/+1
Change-Id: I3b9d9c648151b2a5b9cc6a015b88a59fa7ec4e53 Reviewed-on: https://gerrit.libreoffice.org/76003 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-07-20loplugin:referencecasting in scriptingNoel Grandin6-23/+18
Change-Id: I056ae11c6cda0a1550a8fe363b069359feafcd59 Reviewed-on: https://gerrit.libreoffice.org/75996 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-07-19tdf#123587 Beanshell editor: Show current file name as window titleAndreas Heinisch2-1/+10
Change-Id: I7a817d19cfadc46b1f35a4e42e5a6177c1910a4b Reviewed-on: https://gerrit.libreoffice.org/75869 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-07-09tdf#125355 Beanshell Editor: Corrected indentation when Enter is pressedAndreas Heinisch1-0/+26
Change-Id: Ife96256da02c4b21e2649040c53b7d16f236e3a0 Reviewed-on: https://gerrit.libreoffice.org/73371 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-07-03cid#1448470: perf inefficient map iteratorJulien Nabet1-6/+3
Change-Id: If7dd6455ca02d6c78ac997bd9c2924863db1d906 Reviewed-on: https://gerrit.libreoffice.org/75059 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-06-25improve loplugin:simplifyconstructNoel Grandin3-18/+3
Change-Id: If863d28c6db470faa0d22273020888d4219e069e Reviewed-on: https://gerrit.libreoffice.org/74559 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-06-21simplify some getSupportedServiceNamesNoel Grandin1-7/+4
Change-Id: I81195505d6006b6587f7b98c1545919083f0e588 Reviewed-on: https://gerrit.libreoffice.org/74497 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-06-17loplugin:logexceptionnicely in scripting..sdextNoel Grandin5-16/+17
Change-Id: Ib08f41bb0bed494e7ed00f5bae92eae2b8e80d93 Reviewed-on: https://gerrit.libreoffice.org/74113 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-06-12scripting: copy python/InsertText.py to the Scripts directoryAshod Nakashian1-0/+1
Change-Id: I55e367f8fc3bbd2aa65ca9cdef2e97a3dfa3d117 Reviewed-on: https://gerrit.libreoffice.org/68762 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/73486 Tested-by: Jenkins Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2019-06-05python: add sample python script to insert/replace textAshod Nakashian1-0/+61
Change-Id: Idde3cd22ecc1f1bd34f7519acedc85584ed2deaf Reviewed-on: https://gerrit.libreoffice.org/58160 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/73477 Tested-by: Jenkins
2019-05-21tdf#97635 Added unindentation using shift-tab (mimicked eclipse behavior)Andreas Heinisch1-2/+2
Restored java 6 compatibility Change-Id: I550920457874b9261bdde07040aad8f7b67773d8 Reviewed-on: https://gerrit.libreoffice.org/72671 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-05-20tdf#97635 Added unindentation using shift-tab (mimicked eclipse's behavior)Andreas Heinisch1-5/+8
Moved shift+tab check to the keyPressed function to provide continuous insertion and compiled tab-pattern only once Change-Id: Iffe847fea07295075dc1a280f0697e8c798e8d6f Reviewed-on: https://gerrit.libreoffice.org/72580 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-05-16tdf#97635 Added unindentation using shift-tab (mimicked eclipse behavior)Andreas Heinisch1-0/+22
Change-Id: Iaf64451c92f3465751032dde9c283141e548b3ca Reviewed-on: https://gerrit.libreoffice.org/72228 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-05-13fix wrong SET/QUERY flags passed to uno::ReferenceNoel Grandin6-10/+10
By creating deleted methods for the wrong calls. Avoids the compiler needing to construct a temporary Change-Id: I3b8c648d6bb22d22827bf74f21ea5a2a17fc0f6a Reviewed-on: https://gerrit.libreoffice.org/72103 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-12Use hasElements to check Sequence emptiness in sax..sdextArkadiy Illarionov4-8/+8
Similar to clang-tidy readability-container-size-empty Change-Id: If6a567708d3c59355d54933fad23c85195846624 Reviewed-on: https://gerrit.libreoffice.org/71763 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-10an uno -> a unoCaolán McNamara4-7/+7
Change-Id: I538db88f8477dd2d2ad25c372928fec6c11d979d Reviewed-on: https://gerrit.libreoffice.org/72105 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>