summaryrefslogtreecommitdiff
path: root/embeddedobj
AgeCommit message (Collapse)AuthorFilesLines
2021-11-12coverity: annotate with markup so they will stay silencedCaolán McNamara1-0/+1
Change-Id: I8ac0ae4cd64d8171eebd98d89d1fe954280987b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125072 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-10-30Prepare for removal of non-const operator[] from Sequence in embeddedobjMike Kaganski13-249/+203
Change-Id: I19432a1e506526fdc1cd98625d9cfff12ea2f973 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124361 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-24tdf#42982: improve UNO API error reporting4k5h1t1-2/+2
Change-Id: I9300b4e6eb9ee3ff2b9bfd32efdf0c8ceedc9d3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124113 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
2021-10-16Fix a forgotten return of the valueMike Kaganski1-2/+1
... ever since its introduction in commit 5ea5c0afebd272d5f44e6524c0f67b5317639919 Change-Id: Ic2f082db43c961185921137c6b64b2e1abef28e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123704 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-16Use sal::systools::COMReference and drop ComSmartMike Kaganski1-169/+37
Change-Id: Ic6e0c87f607264629cdec1fdcd0c3144d8fbf8e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123695 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-16Fix the copypaste errorMike Kaganski1-1/+1
... ever since commit 6eea9416a3a5be2d2f6aab6c58ab4e6d4b085ea8 Change-Id: Ic3f6f6876d398cd48cd480518d99a516cea95a31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123636 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-10-15Remove non-const Sequence::begin()/end() in internal codeMike Kaganski1-1/+1
... to avoid hidden cost of multiple COW checks, because they call getArray() internally. This obsoletes [loplugin:sequenceloop]. Also rename toNonConstRange to asNonConstRange, to reflect that the result is a view of the sequence, not an independent object. TODO: also drop non-const operator[], but introduce operator[] in SequenceRange. Change-Id: Idd5fd7a3400fe65274d2a6343025e2ef8911635d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123518 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-09-30Extended loplugin:referencecasting/redundantcast (clang-cl): embeddedobjStephan Bergmann2-4/+2
Change-Id: I345b6535df2df4770191dc1aae0ca024b747a50a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122887 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-09-29embeddedobj: add a status indicator for the Further objects dialogMiklos Vajna1-0/+25
Inserting a large file can take a while, and we do it on the main thread, so the UI is frozen during the operation. Create the progressbar in cui, which is allowed to link against sfx2/ and then pass it down to embeddedobj/. Similarly for the label of the progressbar, again because cui is allowed to link against svx/. Change-Id: I53fec4e14df647b140647d9ff5a3a37c0aa9e72e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122825 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2021-09-15Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 4Mike Kaganski1-1/+2
- Change implementations of getSomething to use getSomethingImpl Or where that's impossible, use getSomething_cast to unify this and reduce number of places where we reinterpret_cast. All static methods getting tunnel ids were renamed to getUnoTunnelId, to comply with the convention used in <comphelper/servicehelper.hxx>. TODO (in separate commits): - Revise uses of getSomething to use getFromUnoTunnel Change-Id: Ifde9e214b52e5df678de71fcc32d2199c82e85cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122100 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-08-31clang-tidy:readability-redundant-member-initNoel Grandin1-2/+0
Change-Id: Icaef0cca9ca7bce76a7eb7ecd54c492f9ffcaad6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121376 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-23loplugin:referencecasting look through more clang TypesNoel Grandin1-20/+7
Note that because of where the fix resides, loplugin:redundantcast also notices a few more things. Change-Id: I0b66047fadfff2c5ceafcbd3eab085de00d861a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120865 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-10embeddedobj: implement XServiceInfo in the various embedded obj implementationsMiklos Vajna8-2/+128
This gives UNO clients a reliable way to detect e.g. OSpecialEmbeddedObject, where it's expected that double-clicking on the object doesn't do anything. Change-Id: I595453490b157b64214cd7359da1e3a3c959191d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120274 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2021-08-08create comphelper:OMultiTypeInterfaceContainerHelperVar2 and use itNoel Grandin1-3/+3
based on OInterfaceContainerHelper2 which is considerably faster than the original OInterfaceContainerHelper Change-Id: Ia8cdbc5ef877a7af3d9193e1bb2faf1595c15470 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120165 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-08-07create comphelper::OMultiTypeInterfaceContainerHelper2 and use itNoel Grandin10-62/+60
based on OInterfaceContainerHelper2 which is considerably faster than the original OInterfaceContainerHelper Change-Id: I9c8b6d0e5382018824bf7188a26343703abf2d51 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120161 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-14sfx2: handle OnMainThread=true in SfxOfficeDispatch::dispatch()Miklos Vajna1-1/+7
This is needed when an out of process Java UNO client registers their command dispatch interceptor, Windows OleInitialize() has been called already on the main thread and then dispatching e.g. uno:Paste (which would interact with OLE) would call OLE functions on a thread, which would fail with RPC_E_CHANGED_MODE. In other words, a situation similar to commit 22aa6508e0a65e65a6f9410b498fe4fd6c236639 (framework: allow dispatching a command on the main thread, 2019-01-29), but that one was for DispatchHelper, this one is for XDispatch implementations. Change-Id: If5a80fe36962e014e781d2a8c156055f127e69a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118886 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2021-07-09loplugin:indentation (clang-cl)Stephan Bergmann1-6/+6
Change-Id: Iae559ca8bee9650c01167a4d1b918e18cbf03c28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118660 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-06-08Simplify Sequences initializations (desktop/e*/filter/forms/formula/fpicker)Julien Nabet3-11/+11
includes removing of unused TOKEN_SEP Change-Id: Ic72d9d94bd8d07232699ee4d948f3b203d524491 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116833 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-06-01loplugin:stringview (clang-cl)Stephan Bergmann1-1/+1
Change-Id: Id1f8f24fec638efcdf5a04ca7253e6f401afd2fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116548 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-19loplugin:external (clang-cl)Stephan Bergmann1-0/+3
Change-Id: I0bd38acd8c562f4478831f278e7cfda54268849d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115747 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-18loplugin:logexceptionnicely (clang-cl)Stephan Bergmann1-6/+6
Change-Id: I56a944dbc13d4f2d4ce5b691789e6144a3e13945 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115746 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-07embeddedobj: handle getting the visible area on a threadMiklos Vajna8-3/+247
The Windows OLE2 implementation of the embedded object interface assumes that the same thread is used for loading and saving the embedded objects. This means that in case the main thread is used for loading (e.g. from remote UNO, but with OnMainThead=true), but a thread is used for storing (without an explicit OnMainThead=true), then the underlying win32 API call failed and we returned a fixed size in EmbeddedObjectRef::GetSize(). Fix the problem by explicitly checking for RPC_E_WRONG_THREAD and adding error handling for that case. Change-Id: Icf1e7722d33a809fa671d1505b2a0155af040c71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115236 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2021-05-05loplugin:constmethodNoel Grandin1-1/+1
Change-Id: I7913fd8144d521b8293ac43036d0fad82e457cd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115145 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-02throw() -> noexcept, part 2/3: Automatic loplugin:noexcept rewriteStephan Bergmann4-6/+6
Change-Id: I076f16d0536b534abf0ced4d76051eadb4c0e033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-04-23embeddedobj: fix lost native data when updating it via OLE fails, take 2Miklos Vajna1-0/+16
How to reproduce the problem: 1) Create an ODT file which has an OLE object, where the native data is an OLE2 container, containing a Package stream, containing a DOCX file 2) Install some external application on Windows which registers itself as a handler for the DOCX CSLID [ this is where writing a testcase for this bug is challenging ]. 3) Open this document via Java, using URP. Load the document with Hidden=true and OnMainThread=true. 4) Save the document using XStorable.store(). Expected result: the native data is there. Actual result: the native data is sometimes missing (0 bytes). The root cause is that GetUserClassID() Win32 API call in OleComponent::StoreOwnTmpIfNecessary() fails in some cases, and re-trying a few times after a small sleep doesn't help. Handle this error better by doing what OleEmbeddedObject::SwitchOwnPersistence(XStorage, OUString) already does: discard the old native data only if we have non-empty new native data. A result of the above was that an export to reqif-xhtml (sw HTML export with FilterOptions set to xhtmlns=reqif-xhtml) wrote empty \objdata. Change-Id: I59611601cf09597e9f7727db5bd6d7426fe17b75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114537 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2021-04-08embeddedobj: fix lost native data when updating it via OLE failsMiklos Vajna2-0/+18
How to reproduce the problem: 1) Create an ODT file which has an OLE object, where the native data is an OLE2 container, containing a Package stream, containing a DOCX file. 2) Install some external application on Windows which registers itself as a handler for the DOCX CSLID [ this is where writing a testcase for this bug is challenging ]. 3) Open this document via Java, using URP. Load the document with Hidden=true and OnMainThread=true. 4) Dispatch .uno:UpdateAll 5) Save the document using XStorable.store() Expected result: the native data is there. Actual result: the native data is sometimes missing (0 bytes). Typically happens at least once if you perform the steps 4 times in a row. The root cause is that GetUserClassID() Win32 API fails in some cases, and re-trying a few times after a small sleep doesn't help. Handle this error better by detecting this situation in OleEmbeddedObject::SwitchOwnPersistence() and reusing the old native data, similar to how svt::EmbeddedObjectRef::GetReplacement() updates the preview image in a transactional way (only delete the old one when we have a one one). Finally, detect a broken OLE2 preview during reqif export, this way the reqif export result's embedded object is editable in Word, while \objdata was simply empty previously. Change-Id: I4dd34ebe6ad892a14cdcfb82acc82d9edf790fb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113814 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2021-04-08tdf#141529 sync linked OLE save(s) with hosting file save(s)Armin Le Grand (Allotropia)5-28/+141
Before deactivating a linked OLE saved it and overwrote the original, even when not saving the hosting document at all. This is not intuitive from user perspective and may lead to unexpected data loss (of the OLE content). Reported case was especially about closing the hosted document without saving in the understandable believe that that way the changed OLE will not be changed on external medium. Added mechanism for linked OLE to hold data in a hidden local temp file, synching/writing back on hosting file save. Most complicated was adapting the 'break link' case and ensuring other cases to work, but looks good now from my POV Change-Id: I7f63d667820b2d9725abc598a9dd7360be1f8d5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113793 Tested-by: Armin Le Grand <Armin.Le.Grand@me.com> Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2021-04-08Fix typosAndrea Gelmini1-1/+1
Change-Id: I41f5c964a289a88b3f6fc637797fe77d17aaab38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113737 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
2021-04-07Updated README.md files to represent current code / use Markdown formatHossein1-1/+3
Previously, all of the README files have been renamed to README.md and now, the contents of these files were changed to use Markdown format. Other than format inconsistency, some README.md files lacked information about modules, or were out of date. By using LibreOffice / OpenOffice wiki and other documentation websites, these files were updated. Now every README.md file has a title, and some description. The top-level README.md file is changed to add links to the modules. The result of processing the Markdown format README.md files can be seen at: https://docs.libreoffice.org/ Change-Id: Ic3b0c3c064a2498d6a435253b041df010cd7797a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113424 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
2021-04-07tdf#141528 ensure that reset of linked state is executedArmin Le Grand (Allotropia)1-2/+13
Take m_xDocHolder->GetComponent() and xModif->setModified inside the local try..catch expression to ensure that the reset of the linked state below (m_bIsLink and .clear()) is executed Change-Id: I52d49569a43fd2c23dd997c7217f7552cbdcfb82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113722 Tested-by: Armin Le Grand <Armin.Le.Grand@me.com> Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2021-03-25const OUString -> const OUStringLiteralMike Kaganski1-1/+1
Mostly automated rewrite Change-Id: Ie020a083f898bc126b8fb039d4ecb2e687172da1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112965 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-24Using .md extension/Markdown syntax for modules READMEHossein1-0/+0
Renaming all README files for all top level modules to README.md, applying no content change at this stage to be able to track history of the files. These files should be edited to use correct Markdown syntax later. Change-Id: I542fa3f3d32072156f16eaad2211a397cc212665 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112977 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2021-03-20use unique_ptr in OCommonEmbeddedObjectNoel Grandin2-18/+15
Change-Id: I2258838cbbe242dbe31500ecd6f29c315a335b71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112743 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-03-10Drop 'static_cast<cppu::OWeakObject*>' syntactic noiseMike Kaganski4-5/+5
... where the object is created in-place, and its type is known Change-Id: Ifabfcf2f3ad0d60152f14e8d970c1faa42115288 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112256 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-03loplugin:refcounting (clang-cl)Stephan Bergmann5-25/+19
Change-Id: Ifa54eed0a772b658d266e9e42be5f5232e7a6b79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111812 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-16loplugin:referencecasting in editeng..frameworkNoel1-1/+1
Change-Id: Ia3375011ecd0a65afed0f131f477fc1542603fde Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110948 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-02-02tdf#140079 Claim support for the OleEmbeddedObject::doVerb -9 fallbackCaolán McNamara1-1/+6
So in SfxViewFrame::GetState_Impl in case SID_OBJECT hasVerbs is not empty, so that the doVerb attempt with -9 fallback is attempted Change-Id: If32c50fedbc2a269ac277061c76a63514d320bb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110316 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-01-12loplugin:stringview (clang-cl)Stephan Bergmann1-1/+6
Change-Id: I64177842c3f77a5ae43574a18f389b64f61bc868 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109176 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-01-12tdf#42982: Improve UNO API error reportingBayram Çiçek1-1/+1
Change-Id: I78c6fed4e94f1ebfc772db4dec9955da7230bc3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109071 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
2021-01-07tdf#42982 Improved UNO API error reportinghomeboy4451-4/+4
Change-Id: I450ea0b1a19381c47370633d124c2ba906415987 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108356 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
2021-01-05tdf#96505 : Get rid of cargo cult long integer literalsumutbayramoglu1-1/+1
Change-Id: I7b269fb5bafceba071ebe649a696ef61301c4018 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107366 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-12-29loplugin:stringviewparam: operator +Stephan Bergmann4-8/+12
Change-Id: I044dd21b63d7eb03224675584fa143009c6b6008 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108418 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-19make *String(string_view) constructors explicitNoel Grandin1-1/+1
to make it more obvious when we are constructing heap OUStrings code and potentially inadvertently throwing away performance. And fix a handful of places so revealed. Change-Id: I0cf390f78026f8a670aaab53424cd31510633051 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107923 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-12-01OSL_FAIL.*exception -> TOOLS_WARN_EXCEPTIONNoel1-1/+2
Change-Id: I6800e23ead2767d245d5da71d2d40e0f8a6d7e1f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106859 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-11-25Remove unused OleComponent::SetHostName aContName parameterStephan Bergmann3-4/+3
Unused ever since the code was introduced in 5ea5c0afebd272d5f44e6524c0f67b5317639919 "#112923# embedded object for MS OLE". (The accompanying // TODO: use aContName and aEmbDocName in m_pOleObject->SetHostNames() comment was removed when a307ad7ae029a0a62404996a63954e7026001ce3 "OLE: show title of parent document in MSO" started to use the aEmbDocName parameter, which had previously been unused too.) Change-Id: I0fbb20dbf526a3fdbdc4a3e76e64fa80e8460480 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106571 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
2020-11-24loplugin:stringviewparam extend to comparison operatorsNoel1-3/+3
which means that some call sites have to change to use unicode string literals i.e. u"foo" instead of "foo" Change-Id: Ie51c3adf56d343dd1d1710777f9d2a43ee66221c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106125 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-11-13tdf#123936 Formatting files in module embeddedobj with clang-formatPhilipp Hofer2-11/+11
Change-Id: If177567a6e5ac934dec11a4b873005f563d77689 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105664 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-11-12tdf#42949 Fix new IWYU warnings in directories [e-f]*Gabor Kelemen7-6/+4
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I963aa5fb892a0be36212fd0587b69f217f017947 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105469 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2020-10-02Use the new single-instance="true" attribute in embeddedobjStephan Bergmann7-22/+21
Change-Id: Icead3bb5715a08bc2a2dfbb16c074d1b19e316a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103855 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-09-16Turn OUStringLiteral into a consteval'ed, static-refcound rtl_uStringStephan Bergmann1-1/+5
...from which an OUString can cheaply be instantiated. This is the OUString equivalent of 4b9e440c51be3e40326bc90c33ae69885bfb51e4 "Turn OStringLiteral into a consteval'ed, static-refcound rtl_String". Most remarks about that commit apply here too (this commit is just substantially bigger and a bit more complicated because there were so much more uses of OUStringLiteral than of OStringLiteral): The one downside is that OUStringLiteral now needs to be a template abstracting over the string length. But any uses for which that is a problem (e.g., as the element type of a container that would no longer be homogeneous, or in the signature of a function that shall not be turned into a template for one reason or another) can be replaced with std::u16string_view, without loss of efficiency compared to the original OUStringLiteral, and without loss of expressivity. The new OUStringLiteral ctor code would probably not be very efficient if it were ever executed at runtime, but it is intended to be only executed at compile time. Where available, C++20 "consteval" is used to statically ensure that. The intended use of the new OUStringLiteral is in all cases where an object that shall itself not be an OUString (e.g., because it shall be a global static variable for which the OUString ctor/dtor would be detrimental at library load/unload) must be converted to an OUString instance in at least one place. Other string literal abstractions could use std::u16string_view (or just plain char16_t const[N]), but interestingly OUStringLiteral might be more efficient than constexpr std::u16string_view even for such cases, as it should not need any relocations at library load time. For now, no existing uses of OUStringLiteral have been changed to some other abstraction (unless technically necessary as discussed above), and no additional places that would benefit from OUStringLiteral have been changed to use it. Global constexpr OUStringLiteral variables defined in an included file would be somewhat suboptimal, as each translation unit that uses them would create its own, unshared instance. The envisioned solution is to turn them into static data members of some class (and there may be a loplugin coming to find and fix affected places). Another approach that has been taken here in a few cases where such variables were only used in one .cxx anyway is to move their definitions from the .hxx into that one .cxx (in turn causing some files to become empty and get removed completely)---which also silenced some GCC -Werror=unused-variable if a variable from a .hxx was not used in some .cxx including it. To keep individual commits reasonably manageable, some consumers of OUStringLiteral in rtl/ustrbuf.hxx and rtl/ustring.hxx are left in a somewhat odd state for now, where they don't take advantage of OUStringLiteral's equivalence to rtl_uString, but just keep extracting its contents and copy it elsewhere. In follow-up commits, those consumers should be changed appropriately, making them treat OUStringLiteral like an rtl_uString or dropping the OUStringLiteral overload in favor of an existing (and cheap to use now) OUString overload, etc. In a similar vein, comparison operators between OUString and std::u16string_view have been added to the existing plethora of comparison operator overloads. It would be nice to eventually consolidate them, esp. with the overloads taking OUStringLiteral and/or char16_t const[N] string literals, but that appears tricky to get right without introducing new ambiguities. Also, a handful of places across the code base use comparisons between OUString and OUStringNumber, which are now ambiguous (converting the OUStringNumber to either OUString or std::u16string_view). For simplicity, those few places have manually been fixed for now by adding explicit conversion to std::u16string_view. Also some compilerplugins code needed to be adapted, and some of the compilerplugins/test cases have become irrelevant (and have been removed), as the tested code would no longer compile in the first place. sal/qa/rtl/strings/test_oustring_concat.cxx documents a workaround for GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96878> "Failed class template argument deduction in unevaluated, parenthesized context". That place, as well as uses of OUStringLiteral in extensions/source/abpilot/fieldmappingimpl.cxx and i18npool/source/localedata/localedata.cxx, which have been replaced with OUString::Concat (and which is arguably a better choice, anyway), also caused failures with at least Clang 5.0.2 (but would not have caused failures with at least recent Clang 12 trunk, so appear to be bugs in Clang that have meanwhile been fixed). Change-Id: I34174462a28f2000cfeb2d219ffd533a767920b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102222 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>