Commit Graph
1257 Commits
Author SHA1 Message Date
Mike Kaganski b280efcb9b Drop some uses Sequence::getConstArray
Replace by operator[], begin() and end(), which don't have overhead
since commit 2484de6728 (Remove non-
const Sequence::begin()/end() in internal code, 2021-10-15)
and commit fb3c04bd19 (Drop non-const
Sequence::operator[] in internal code, 2021-11-05).

Change-Id: I221470b3439bb0dc6e7705b0d99deb3cd2063484
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195176
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-12-07 12:54:23 +01:00
Mike Kaganski 7f198b27f4 Drop class utl::MediaDescriptor, and use comphelper::SequenceAsHashMap
utl::MediaDescriptor was just a SequenceAsHashMap with a few added
methods. It made it more difficult to assign a SequenceAsHashMap to
MediaDescriptor, without real upsides. In many places, the class was
used not as media descriptor, but just as helper to create sequences.

This change puts the string constants and the former methods into a
namespace utl::MediaDescriptor.

It would be also good to drop comphelper::NamedValueCollection, which
is basically a twin of comphelper::SequenceAsHashMap (TODO).

Change-Id: Ia9b69c5a2ad153ecc654944c419c1880252ed86e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195163
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-12-06 18:18:32 +01:00
Karthik Godha 258face115 tdf#169539: PPT->PPTX Draw OLE object data loss
Draw OLE objects are skipped during the export of PPTX.

Change-Id: I21c328a3e322de9fc3d4a18030e53894e7fa2514
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194216
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
(cherry picked from commit f6b22383258d6ecd93193240b60d6124791d8699)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195047
Tested-by: Jenkins
2025-12-05 14:13:21 +01:00
Noel Grandin c7cc5167c5 fixes for --disable-pdfimport build
Change-Id: I9fa7dcf45409c02a1d5d9a30b1c85f3946755136
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191505
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2025-09-25 17:44:46 +02:00
Gabor Kelemen 3ea68d1b8d tdf#146619 Run IWYU on e...
embeddedobj/ emfio/ extensions/ eventattacher/

Change-Id: I7a86b19d1c5ff3859cb5f97a4ef74cf8e01de3b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190909
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-09-23 16:24:45 +02:00
Mike Kaganski a255b04d8d Shorten some names ending with _ASCII
Whatever that was intended to mean: if that meant that the constants
were encoded that way, these are UTF-16 already; is that meant that
they only contained characters in that range, that is unimportant.

Change-Id: I5463f1fca0d552a93d3c9d487ed9912c9e1a989e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191240
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-09-20 19:35:12 +02:00
Noel Grandin d35a23cbda EmbeddedUpdate should not use the css namespace
that is for the UNO API stuff, using it just makes the code harder to read

Change-Id: I01ac7672aa993842a889cdb8bcc05137efc80ee0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190938
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-09-15 13:34:35 +02:00
Noel Grandin 6d0e5ddede remove BitmapEx
all use-sites have been converted to Bitmap

Change-Id: I1a8842217a266eef100bd387ab013b004e532256
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190618
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2025-09-05 19:45:45 +02:00
Noel Grandin 15cc32ad4e BitmapEx->Bitmap in VCLBitmapCreator
now that Bitmap supports transparency.

This code is not part of the build, so not tested.

Change-Id: I22201f5aede3bc8f720a4b4721c6711dfc1ddf41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190461
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2025-09-01 10:43:10 +02:00
Caolán McNamara 72e538b9bd tainted_data_return is deprecated
in favour of taint_source, lets drop them all first

Change-Id: I9c4e5c143fcbd6de9491360c993a8ea1b89a726e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189820
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-08-17 15:33:16 +02:00
Gabor Kelemen 8d736f84a0 Remove IWYU exceptions about comphelper/scopeguard.hxx
Noticed that newer versions of IWYU no longer give a false warning
about this, so just drop them

Change-Id: Ic45a8fab10965dc5d0a5432fc36e48db187834c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187143
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-07-01 20:54:16 +02:00
Noel Grandin 03caa7db14 tdf#167073 Extension MRI does not start
revert
    commit 39f2c62847
    simplify TaskCreatorService
and
    commit 96b6d13c9a.
    [API CHANGE] no need for TaskCreatorService to be exposed via UNO

I missed that this service is in use.

Change-Id: I97b01668f7ba313335f9fbd8cf0e398dfc1b5ca0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186643
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-06-18 15:26:32 +02:00
Noel Grandin 39f2c62847 simplify TaskCreatorService
now that it is no longer an UNO service, we can simplify it,
and returning a more explicit type.

Change-Id: Ibd0f56e04ac26f09b57dc295febcf26202f16a2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186495
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2025-06-14 19:34:10 +02:00
Noel Grandin 96b6d13c9a [API CHANGE] no need for TaskCreatorService to be exposed via UNO
This is a purely internal usage thing.

Change-Id: I8d13d21c791bc88a2fc288fb97f7877eecab3e73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186494
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-06-14 19:34:01 +02:00
Gabor Kelemen 924ab1962e Remove obsolete fw declarations from embeddedobj/ extensions/
found with bin/find-unneeded-includes --fwdecl

Change-Id: I029145e0f04b1ed90bb0d16c871891bca85b39a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183885
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-04-17 00:22:52 +02:00
Devashish Gupta 797292f65b tdf#42982 Improve UNO API error reporting
Change-Id: Icba16d0ec6782c1d135c693cb840c6a2116c0fa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183163
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-03-27 05:25:43 +01:00
varshneydevansh 2a20616d09 Move Windows error helpers to comphelper namespace
Previously, WindowsErrorString and WindowsErrorStringFromHRESULT were
defined in an anonymous namespace in windowserrorstring.hxx, which:
1. Made them unavailable to other translation units
2. Violate ODR by creating separate copies in each TU
3. Require workarounds to access them

Changes:
- Move functions to proper comphelper namespace
- Keep implementations inline as they're simple utilities
- Preserve all existing functionality
- Update all call sites to use comphelper:: prefix

This change enables proper use of these utilities across LibreOffice
while maintaining current behavior and performance characteristics.

Introduced in this commit:

    commit 94cdcaa4d8
    Author: Tor Lillqvist <tml@collabora.com>
    Date:   Thu Aug 13 13:22:28 2015 +0300

        Add a globally usable WindowsErrorString function

Change-Id: I34df1c2b1f30c6204f107ca4792131d692203880
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183332
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-03-26 15:11:33 +01:00
Akshay Kumar Dubey 12d487285b tdf#42982 Improve UNO API error reporting
Change-Id: I35b815e45debc479d20c956fd07a188d0251853d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181293
Tested-by: Jenkins
Reviewed-by: Hossein   <hossein@libreoffice.org>
2025-02-19 08:29:06 +01:00
Manish Bera 117d31400c tdf#162563 Remove Java applet code and references from embeddedobj
Change-Id: If3e7ab1cb45c988f3f39fc2f73377c77dc9972f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178873
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2024-12-26 12:14:07 +01:00
Caolán McNamara 836d73a651 consider VndSunStarExpand an exotic protocol
and generally don't bother with it when fetching data
from urls

Change-Id: I51a2601c6fb7d6c32f9e2d1286ee0d3b05b370b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176645
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-11-19 20:20:03 +01:00
Xisco Fauli a38a22c7e5 UnoApiTest: rename load to loadFromURL and use it everywhere
Change-Id: Ie67eebec74f783fa0c29acfb23bb83bc582812b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175724
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2024-10-29 09:11:37 +01:00
Caolán McNamara 7bbe74b2be cid#1555789 COPY_INSTEAD_OF_MOVE
and

cid#1556865 COPY_INSTEAD_OF_MOVE
cid#1556871 COPY_INSTEAD_OF_MOVE
cid#1556939 COPY_INSTEAD_OF_MOVE
cid#1556951 COPY_INSTEAD_OF_MOVE
cid#1556964 COPY_INSTEAD_OF_MOVE
cid#1556966 COPY_INSTEAD_OF_MOVE
cid#1556968 COPY_INSTEAD_OF_MOVE
cid#1556971 COPY_INSTEAD_OF_MOVE
cid#1556989 COPY_INSTEAD_OF_MOVE
cid#1557001 COPY_INSTEAD_OF_MOVE
cid#1557011 COPY_INSTEAD_OF_MOVE
cid#1557032 COPY_INSTEAD_OF_MOVE
cid#1557038 COPY_INSTEAD_OF_MOVE
cid#1557041 COPY_INSTEAD_OF_MOVE
cid#1557055 COPY_INSTEAD_OF_MOVE
cid#1557056 COPY_INSTEAD_OF_MOVE
cid#1557057 COPY_INSTEAD_OF_MOVE
cid#1557065 COPY_INSTEAD_OF_MOVE
cid#1557068 COPY_INSTEAD_OF_MOVE
cid#1557087 COPY_INSTEAD_OF_MOVE
cid#1557090 COPY_INSTEAD_OF_MOVE
cid#1557093 COPY_INSTEAD_OF_MOVE
cid#1557113 COPY_INSTEAD_OF_MOVE
cid#1557122 COPY_INSTEAD_OF_MOVE
cid#1557126 COPY_INSTEAD_OF_MOVE
cid#1557145 COPY_INSTEAD_OF_MOVE
cid#1557151 COPY_INSTEAD_OF_MOVE
cid#1557152 COPY_INSTEAD_OF_MOVE
cid#1557197 COPY_INSTEAD_OF_MOVE
cid#1557216 COPY_INSTEAD_OF_MOVE
cid#1557245 COPY_INSTEAD_OF_MOVE
cid#1557272 COPY_INSTEAD_OF_MOVE
cid#1557310 COPY_INSTEAD_OF_MOVE
cid#1557314 COPY_INSTEAD_OF_MOVE
cid#1557318 COPY_INSTEAD_OF_MOVE
cid#1557333 COPY_INSTEAD_OF_MOVE
cid#1557340 COPY_INSTEAD_OF_MOVE
cid#1557358 COPY_INSTEAD_OF_MOVE
cid#1557359 COPY_INSTEAD_OF_MOVE
cid#1557365 COPY_INSTEAD_OF_MOVE
cid#1557367 COPY_INSTEAD_OF_MOVE
cid#1557395 COPY_INSTEAD_OF_MOVE
cid#1557418 COPY_INSTEAD_OF_MOVE
cid#1557488 COPY_INSTEAD_OF_MOVE
cid#1557493 COPY_INSTEAD_OF_MOVE
cid#1557506 COPY_INSTEAD_OF_MOVE
cid#1557514 COPY_INSTEAD_OF_MOVE
cid#1557528 COPY_INSTEAD_OF_MOVE
cid#1557534 COPY_INSTEAD_OF_MOVE
cid#1557537 COPY_INSTEAD_OF_MOVE
cid#1557562 COPY_INSTEAD_OF_MOVE
cid#1557563 COPY_INSTEAD_OF_MOVE
cid#1557592 COPY_INSTEAD_OF_MOVE
cid#1557608 COPY_INSTEAD_OF_MOVE
cid#1557615 COPY_INSTEAD_OF_MOVE
cid#1557619 COPY_INSTEAD_OF_MOVE
cid#1557637 COPY_INSTEAD_OF_MOVE
cid#1557648 COPY_INSTEAD_OF_MOVE
cid#1557712 COPY_INSTEAD_OF_MOVE
cid#1557750 COPY_INSTEAD_OF_MOVE
cid#1557762 COPY_INSTEAD_OF_MOVE
cid#1557765 COPY_INSTEAD_OF_MOVE

Change-Id: I10db1910627e04a26e25836c05ad5c2707abd18b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175696
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-10-27 20:19:12 +01:00
Caolán McNamara 7cf8cffcb8 cid#1633347 COPY_INSTEAD_OF_MOVE
and

cid#1633346 COPY_INSTEAD_OF_MOVE
cid#1633344 COPY_INSTEAD_OF_MOVE
cid#1633343 COPY_INSTEAD_OF_MOVE
cid#1633340 COPY_INSTEAD_OF_MOVE
cid#1608137 COPY_INSTEAD_OF_MOVE
cid#1608131 COPY_INSTEAD_OF_MOVE
cid#1607860 COPY_INSTEAD_OF_MOVE
cid#1607432 COPY_INSTEAD_OF_MOVE
cid#1607394 COPY_INSTEAD_OF_MOVE
cid#1607310 COPY_INSTEAD_OF_MOVE
cid#1607156 COPY_INSTEAD_OF_MOVE
cid#1607093 COPY_INSTEAD_OF_MOVE
cid#1607090 COPY_INSTEAD_OF_MOVE
cid#1607039 COPY_INSTEAD_OF_MOVE
cid#1606709 COPY_INSTEAD_OF_MOVE
cid#1558053 COPY_INSTEAD_OF_MOVE
cid#1558052 COPY_INSTEAD_OF_MOVE
cid#1558042 COPY_INSTEAD_OF_MOVE
cid#1558038 COPY_INSTEAD_OF_MOVE
cid#1558037 COPY_INSTEAD_OF_MOVE
cid#1558034 COPY_INSTEAD_OF_MOVE
cid#1558031 COPY_INSTEAD_OF_MOVE
cid#1558027 COPY_INSTEAD_OF_MOVE
cid#1557994 COPY_INSTEAD_OF_MOVE
cid#1557977 COPY_INSTEAD_OF_MOVE
cid#1557970 COPY_INSTEAD_OF_MOVE
cid#1557966 COPY_INSTEAD_OF_MOVE
cid#1557957 COPY_INSTEAD_OF_MOVE
cid#1557954 COPY_INSTEAD_OF_MOVE
cid#1557941 COPY_INSTEAD_OF_MOVE
cid#1557933 COPY_INSTEAD_OF_MOVE
cid#1557918 COPY_INSTEAD_OF_MOVE
cid#1557907 COPY_INSTEAD_OF_MOVE
cid#1557890 COPY_INSTEAD_OF_MOVE
cid#1557883 COPY_INSTEAD_OF_MOVE
cid#1557881 COPY_INSTEAD_OF_MOVE
cid#1557861 COPY_INSTEAD_OF_MOVE
cid#1557842 COPY_INSTEAD_OF_MOVE
cid#1557840 COPY_INSTEAD_OF_MOVE
cid#1557830 COPY_INSTEAD_OF_MOVE
cid#1557830 COPY_INSTEAD_OF_MOVE

Change-Id: If5ee3396eafdb8b338d9e6cf0705be6e2b431fd5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175577
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-10-25 10:48:12 +02:00
Mike Kaganski f2808f9165 Avoid deadlock
As seen in the following call stacks:

Main thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  emboleobj!osl::Mutex::acquire+0x9 [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  emboleobj!osl::ClearableGuard<osl::Mutex>::{ctor}+0xd [libre-office-git-repo\include\osl\mutex.hxx @ 182]
  emboleobj!osl::ResettableGuard<osl::Mutex>::{ctor}+0xd [libre-office-git-repo\include\osl\mutex.hxx @ 236]
  emboleobj!OleEmbeddedObject::getStatus+0x72 [libre-office-git-repo\embeddedobj\source\msole\oleembed.cxx @ 1133]
  sfxlo!SfxViewShell::CheckIPClient_Impl+0x42 [libre-office-git-repo\sfx2\source\view\viewsh.cxx @ 3563]
  sfxlo!SfxInPlaceClient_Impl::TimerHdl+0x40 [libre-office-git-repo\sfx2\source\view\ipclient.cxx @ 628]
  sfxlo!SfxInPlaceClient_Impl::LinkStubTimerHdl+0x53 [libre-office-git-repo\sfx2\source\view\ipclient.cxx @ 624]
  vcllo!Scheduler::CallbackTaskScheduling+0x130e [libre-office-git-repo\vcl\source\app\scheduler.cxx @ 511]
  vclplug_winlo!WinSalTimer::ImplHandleElapsedTimer+0x2e [libre-office-git-repo\vcl\win\app\saltimer.cxx @ 167]
  vclplug_winlo!ImplSalYield+0x14f [libre-office-git-repo\vcl\win\app\salinst.cxx @ 525]
  vclplug_winlo!WinSalInstance::DoYield+0xad [libre-office-git-repo\vcl\win\app\salinst.cxx @ 581]
  vcllo!ImplYield+0x367 [libre-office-git-repo\vcl\source\app\svapp.cxx @ 393]
  vcllo!Application::Execute+0xfa [libre-office-git-repo\vcl\source\app\svapp.cxx @ 369]
  sofficeapp!desktop::Desktop::Main+0x173f [libre-office-git-repo\desktop\source\app\app.cxx @ 1605]
  vcllo!ImplSVMain+0xda [libre-office-git-repo\vcl\source\app\svmain.cxx @ 229]
  sofficeapp!soffice_main+0xf3 [libre-office-git-repo\desktop\source\app\sofficemain.cxx @ 94]

Request thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  vclplug_winlo!osl::Mutex::acquire+0xa [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  vclplug_winlo!SalYieldMutex::doAcquire+0x91 [libre-office-git-repo\vcl\win\app\salinst.cxx @ 148]
  emboleobj!SolarMutexReleaser::{dtor}+0xc [libre-office-git-repo\include\vcl\svapp.hxx @ 1425]
  emboleobj!OleComponent::StoreOwnTmpIfNecessary+0x1d3 [libre-office-git-repo\embeddedobj\source\msole\olecomponent.cxx @ 1365]
  emboleobj!OleEmbeddedObject::StoreObjectToStream+0x2f [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1032]
  emboleobj!OleEmbeddedObject::StoreToLocation_Impl+0x3cc [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1169]
  emboleobj!OleEmbeddedObject::storeAsEntry+0x152 [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1523]
  comphelper!comphelper::EmbeddedObjectContainer::StoreEmbeddedObject+0x490 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 501]
  comphelper!comphelper::EmbeddedObjectContainer::InsertEmbeddedObject+0x6f [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 518]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x388 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 945]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x46 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 831]
  swlo!SwOLENode::SavePersistentData+0x20b [libre-office-git-repo\sw\source\core\ole\ndole.cxx @ 403]
  swlo!SwNodes::ChgNode+0x411 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 214]
  swlo!SwNodes::MoveNodes+0x18e6 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 868]
  swlo!SwUndoSaveContent::MoveToUndoNds+0x1c1 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 784]
  swlo!SwUndoSaveSection::SaveSection+0x559 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1325]
  swlo!SwUndoSaveSection::SaveSection+0x55 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1278]
  swlo!SwUndoFlyBase::DelFly+0x127 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 232]
  swlo!SwUndoDelLayFormat::SwUndoDelLayFormat+0x64 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 429]
  swlo!std::make_unique+0x22 [C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\memory @ 3382]
  swlo!sw::DocumentLayoutManager::DelLayoutFormat+0x283 [libre-office-git-repo\sw\source\core\doc\DocumentLayoutManager.cxx @ 242]
  swlo!SwTextNode::DestroyAttr+0x82 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1204]
  swlo!SwTextNode::EraseText+0x18f [libre-office-git-repo\sw\source\core\txtnode\ndtxt.cxx @ 2813]
  swlo!SwTextNode::DeleteAttributes+0x115 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1863]
  swlo!SwXFrame::dispose+0xdb [libre-office-git-repo\sw\source\core\unocore\unoframe.cxx @ 2692]
  mscx_uno!`anonymous namespace'::cpp_call+0x710 [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 214]
  mscx_uno!unoInterfaceProxyDispatch+0x2fa [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 430]
  binaryurplo!binaryurp::IncomingRequest::execute_throw+0x635 [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 239]
  binaryurplo!binaryurp::IncomingRequest::execute+0xbf [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 79]
  binaryurplo!request+0x1c [libre-office-git-repo\binaryurp\source\reader.cxx @ 84]
  cppu3!cppu_threadpool::JobQueue::enter+0x21e [libre-office-git-repo\cppu\source\threadpool\jobqueue.cxx @ 101]
  cppu3!cppu_threadpool::ORequestThread::run+0xa0 [libre-office-git-repo\cppu\source\threadpool\thread.cxx @ 169]

where the call to OleComponent::StoreOwnTmpIfNecessary from
OleEmbeddedObject::StoreObjectToStream was made with m_aMutex
held; and that mutex was attempted to be locked from the main
thread, holding solar mutex.

Change-Id: I1914188728cdaa9cdf22d216ec71f733d7780692
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175117
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-10-18 11:14:16 +02:00
Mike Kaganski 7122fcf862 Avoid deadlock because of recursive lock
As seen in the following call stacks:

Main thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  emboleobj!osl::Mutex::acquire+0x9 [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  emboleobj!osl::Guard<osl::Mutex>::{ctor}+0x9 [libre-office-git-repo\include\osl\mutex.hxx @ 144]
  emboleobj!OleEmbeddedObject::getCurrentState+0x68 [libre-office-git-repo\embeddedobj\source\msole\oleembed.cxx @ 643]
  sfxlo!SfxInPlaceClient::IsObjectUIActive+0x23 [libre-office-git-repo\sfx2\source\view\ipclient.cxx @ 847]
  sfxlo!SfxViewShell::GetUIActiveClient+0x5b [libre-office-git-repo\sfx2\source\view\viewsh.cxx @ 2521]
  sfxlo!SfxDispatcher::FindServer_+0x282 [libre-office-git-repo\sfx2\source\control\dispatch.cxx @ 1627]
  sfxlo!SfxDispatcher::GetShellAndSlot_Impl+0x2f [libre-office-git-repo\sfx2\source\control\dispatch.cxx @ 703]
  sfxlo!SfxDispatcher::QueryState+0x5b [libre-office-git-repo\sfx2\source\control\dispatch.cxx @ 1979]
  swlo!SwView::CheckReadonlyState+0x64 [libre-office-git-repo\sw\source\uibase\uiview\view.cxx @ 627]
  swlo!SwView::TimeoutHdl+0x76 [libre-office-git-repo\sw\source\uibase\uiview\view.cxx @ 608]
  vcllo!Scheduler::CallbackTaskScheduling+0x130e [libre-office-git-repo\vcl\source\app\scheduler.cxx @ 511]
  vclplug_winlo!WinSalTimer::ImplHandleElapsedTimer+0x2e [libre-office-git-repo\vcl\win\app\saltimer.cxx @ 167]
  vclplug_winlo!ImplSalYield+0x14f [libre-office-git-repo\vcl\win\app\salinst.cxx @ 525]
  vclplug_winlo!WinSalInstance::DoYield+0xad [libre-office-git-repo\vcl\win\app\salinst.cxx @ 581]
  vcllo!ImplYield+0x367 [libre-office-git-repo\vcl\source\app\svapp.cxx @ 393]
  vcllo!Application::Execute+0xfa [libre-office-git-repo\vcl\source\app\svapp.cxx @ 369]
  sofficeapp!desktop::Desktop::Main+0x173f [libre-office-git-repo\desktop\source\app\app.cxx @ 1605]
  vcllo!ImplSVMain+0xda [libre-office-git-repo\vcl\source\app\svmain.cxx @ 229]
  sofficeapp!soffice_main+0xf3 [libre-office-git-repo\desktop\source\app\sofficemain.cxx @ 94]

Request thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  vclplug_winlo!osl::Mutex::acquire+0xa [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  vclplug_winlo!SalYieldMutex::doAcquire+0x91 [libre-office-git-repo\vcl\win\app\salinst.cxx @ 148]
  emboleobj!SolarMutexReleaser::{dtor}+0xc [libre-office-git-repo\include\vcl\svapp.hxx @ 1425]
  emboleobj!OleComponent::GetExtent+0x102 [libre-office-git-repo\embeddedobj\source\msole\olecomponent.cxx @ 1134]
  emboleobj!OleEmbeddedObject::getVisualAreaSize+0x23f [libre-office-git-repo\embeddedobj\source\msole\olevisual.cxx @ 227]
  emboleobj!OleEmbeddedObject::saveCompleted+0x406 [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1603]
  comphelper!comphelper::EmbeddedObjectContainer::StoreEmbeddedObject+0x49b [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 501]
  comphelper!comphelper::EmbeddedObjectContainer::InsertEmbeddedObject+0x6f [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 518]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x388 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 945]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x46 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 831]
  swlo!SwOLENode::SavePersistentData+0x20b [libre-office-git-repo\sw\source\core\ole\ndole.cxx @ 403]
  swlo!SwNodes::ChgNode+0x411 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 214]
  swlo!SwNodes::MoveNodes+0x18e6 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 868]
  swlo!SwUndoSaveContent::MoveToUndoNds+0x1c1 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 784]
  swlo!SwUndoSaveSection::SaveSection+0x559 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1325]
  swlo!SwUndoSaveSection::SaveSection+0x55 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1278]
  swlo!SwUndoFlyBase::DelFly+0x127 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 232]
  swlo!SwUndoDelLayFormat::SwUndoDelLayFormat+0x64 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 429]
  swlo!std::make_unique+0x22 [C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\memory @ 3382]
  swlo!sw::DocumentLayoutManager::DelLayoutFormat+0x283 [libre-office-git-repo\sw\source\core\doc\DocumentLayoutManager.cxx @ 242]
  swlo!SwTextNode::DestroyAttr+0x82 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1204]
  swlo!SwTextNode::EraseText+0x18f [libre-office-git-repo\sw\source\core\txtnode\ndtxt.cxx @ 2813]
  swlo!SwTextNode::DeleteAttributes+0x115 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1863]
  swlo!SwXFrame::dispose+0xdb [libre-office-git-repo\sw\source\core\unocore\unoframe.cxx @ 2692]
  mscx_uno!`anonymous namespace'::cpp_call+0x710 [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 214]
  mscx_uno!unoInterfaceProxyDispatch+0x2fa [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 430]
  binaryurplo!binaryurp::IncomingRequest::execute_throw+0x635 [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 239]
  binaryurplo!binaryurp::IncomingRequest::execute+0xbf [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 79]
  binaryurplo!request+0x1c [libre-office-git-repo\binaryurp\source\reader.cxx @ 84]
  cppu3!cppu_threadpool::JobQueue::enter+0x21e [libre-office-git-repo\cppu\source\threadpool\jobqueue.cxx @ 101]
  cppu3!cppu_threadpool::ORequestThread::run+0xa0 [libre-office-git-repo\cppu\source\threadpool\thread.cxx @ 169]

As seen, the request thread has OleEmbeddedObject::saveCompleted
and OleEmbeddedObject::getVisualAreaSize on the stack; both acquire
OleEmbeddedObject's mutex; but only getVisualAreaSize releases it
for the call of OleComponent::GetExtent. The latter releases solar
mutex, at which time, the main thread (locking the solar mutex)
attempts to call OleEmbeddedObject::getCurrentState, which needs
the object's mutex, which is still locked in the request thread.

Avoid this, by passing the lock object to the implementation of
getVisualAreaSize from saveCompleted.

Change-Id: Ie44a20a8c89000e0e951e024c2bfde93cf2cc3f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174891
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-10-14 21:18:05 +02:00
Mike Kaganski a6a6921123 Use good old string literals in assertXPath and friends
These are only sent to an external API expecting char*-like strings,
or for comparison. Having every assertXPath having three of _[ou]str
is too much syntactic noise, making the unit tests almost unreadable.

Change-Id: Ic004a36ea75e7bfe0b96f405c40f926a957b51cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174416
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-10-05 10:06:44 +02:00
Mike Kaganski 47d8d0cbe7 Avoid deadlock
Seen when running an external Java code, with these call stacks:

Main thread:

 win32u.dll!NtUserMsgWaitForMultipleObjectsEx()
 sal3.dll!osl_waitCondition(void * Condition, const TimeValue * pTimeout)
 [Inline Frame] vclplug_winlo.dll!osl::Condition::wait(const TimeValue *)
 vclplug_winlo.dll!SalYieldMutex::doAcquire(unsigned long nLockCount)
 [Inline Frame] emboleobj.dll!SolarMutexReleaser::{dtor}()
 emboleobj.dll!OleComponent::getTransferData(const com::sun::star::datatransfer::DataFlavor & aFlavor)
 emboleobj.dll!OleEmbeddedObject::getPreferredVisualRepresentation(__int64 nAspect)
 comphelper.dll!comphelper::EmbeddedObjectContainer::GetGraphicReplacementStream(__int64 nViewAspect, const com::sun::star::uno::Reference<com::sun::star::embed::XEmbeddedObject> & xObj, rtl::OUString * pMediaType)
 [Inline Frame] svtlo.dll!svt::EmbeddedObjectRef::GetGraphicReplacementStream(__int64)
 svtlo.dll!svt::EmbeddedObjectRef::GetGraphicStream(bool bUpdate)
 svtlo.dll!svt::EmbeddedObjectRef::GetReplacement(bool bUpdate)
 svtlo.dll!svt::EmbeddedObjectRef::UpdateReplacement(bool bUpdateOle)
 swlo.dll!SwWrtShell::CalcAndSetScale(svt::EmbeddedObjectRef & xObj, const SwRect * pFlyPrtRect, const SwRect * pFlyFrameRect, const bool bNoTextFramePrtAreaChanged)
 swlo.dll!SwContentNotify::ImplDestroy()
 swlo.dll!SwContentNotify::~SwContentNotify()
 swlo.dll!SwNoTextFrame::MakeAll(OutputDevice * pRenderContext)
 swlo.dll!SwFrame::OptPrepareMake()
 [Inline Frame] swlo.dll!SwFrame::OptCalc()
 swlo.dll!SwLayAction::FormatContent_(const SwContentFrame * pContent, const SwPageFrame * pPage)
 swlo.dll!SwLayAction::FormatFlyContent(const SwFlyFrame * pFly)
 swlo.dll!SwObjectFormatter::FormatObj_(SwAnchoredObject & _rAnchoredObj)
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject & _rAnchoredObj, const bool _bCheckForMovedFwd)
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame * _pMasterTextFrame)
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObjs()
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame(SwFrame & _rAnchorFrame, const SwPageFrame & _rPageFrame, SwLayAction * _pLayAction)
 swlo.dll!SwLayAction::FormatContent(SwPageFrame * pPage)
 swlo.dll!SwLayAction::InternalAction(OutputDevice * pRenderContext)
 [Inline Frame] swlo.dll!SwLayAction::Action(OutputDevice * pRenderContext)
 swlo.dll!SwLayIdle::SwLayIdle(SwRootFrame * pRt, SwViewShellImp * pI)
 swlo.dll!SwViewShell::LayoutIdle()
 swlo.dll!sw::DocumentTimerManager::DoIdleJobs(Timer * __formal)
 vcllo.dll!Scheduler::CallbackTaskScheduling()
 vclplug_winlo.dll!WinSalTimer::ImplHandleElapsedTimer()
 vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents)
 vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
 vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents)
 vcllo.dll!Application::Execute()
 sofficeapp.dll!desktop::Desktop::Main()
 vcllo.dll!ImplSVMain()
 sofficeapp.dll!soffice_main()
 [Inline Frame] soffice.bin!sal_main()
 soffice.bin!main(int argc, char * * argv)
 [Inline Frame] soffice.bin!invoke_main()
 soffice.bin!__scrt_common_main_seh()
 kernel32.dll!BaseThreadInitThunk()
 ntdll.dll!RtlUserThreadStart()

Request thread:

 ntdll.dll!NtWaitForAlertByThreadId()
 ntdll.dll!RtlpWaitOnCriticalSection()
 ntdll.dll!RtlpEnterCriticalSectionContended()
 ntdll.dll!RtlEnterCriticalSection()
 sal3.dll!osl_acquireMutex(_oslMutexImpl * Mutex)
 [Inline Frame] emboleobj.dll!osl::Mutex::acquire()
 [Inline Frame] emboleobj.dll!osl::Guard<osl::Mutex>::{ctor}(osl::Mutex &)
 emboleobj.dll!OleComponent::addModifyListener(const com::sun::star::uno::Reference<com::sun::star::util::XModifyListener> & xListener)
 svtlo.dll!svt::`anonymous namespace'::EmbedEventListener_Impl::Create(svt::EmbeddedObjectRef * p)
 svtlo.dll!svt::EmbeddedObjectRef::EmbeddedObjectRef(const com::sun::star::uno::Reference<com::sun::star::embed::XEmbeddedObject> & xObj, __int64 nAspect)
 swlo.dll!SwXFrame::getPropertyValue(const rtl::OUString & rPropertyName)
 mscx_uno.dll!`anonymous namespace'::cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, _typelib_TypeDescriptionReference * pReturnTypeRef, long nParams, _typelib_MethodParameter * pParams, void * pUnoReturn, void * * pUnoArgs, _uno_Any * * ppUnoExc)
 mscx_uno.dll!unoInterfaceProxyDispatch(_uno_Interface * pUnoI, const _typelib_TypeDescription * pMemberTD, void * pReturn, void * * pArgs, _uno_Any * * ppException)
 binaryurplo.dll!binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny * returnValue, std::vector<binaryurp::BinaryAny,std::allocator<binaryurp::BinaryAny>> * outArguments)
 binaryurplo.dll!binaryurp::IncomingRequest::execute()
 binaryurplo.dll!request(void * pThreadSpecificData)
 cppu3.dll!cppu_threadpool::JobQueue::enter(const void * nDisposeId, bool bReturnWhenNoJob)
 cppu3.dll!cppu_threadpool::ORequestThread::run()
 cppu3.dll!threadFunc(void * param)
 sal3.dll!oslWorkerWrapperFunction(void * pData)
 ucrtbase.dll!thread_start<unsigned int (__cdecl*)(void *),1>()
 kernel32.dll!BaseThreadInitThunk()
 ntdll.dll!RtlUserThreadStart()

Change-Id: I54d3fd91d8bbf4f52eee2f498c91e06ebc82d836
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172864
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-09-04 16:56:07 +02:00
Mike Kaganski 6084a2904d Make OleEmbeddedObject locking stricter
This is an attempt to reduce areas that execute with mutex unlocked
because the called code may deadlock. Also, this copies objects on
stack before unlocking, using lambdas' own variables.

I hope that it somewhat improves reliability. OTOH, this runs more
code with lock active, has a potential of new deadlocks, so risky.

Change-Id: I558b7f5f18f63622fed3a9c3978327d0d76fe90d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172237
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-22 12:06:43 +02:00
Mike Kaganski 53ac9e0f3c Make OleEmbeddedObject::GetRidOfComponent safer when releasing lock
Thanks Michael Stahl for the useful advise - see
https://gerrit.libreoffice.org/c/core/+/171996/comment/4dc20148_5ec861ad/

Change-Id: I16e1876a81a52f291ede49572f012c15d4cd9a6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172233
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-22 08:22:49 +02:00
Mike Kaganski 29f59dad0e Unlock the mutex to avoid deadlock
The request thread was calling OleComponent::CloseObject, which executed
on main thread; OleEmbeddedObject::m_aMutex as locked by request thread:

 emboleobj.dll!OleComponent::CloseObject() Line 1004
 emboleobj.dll!OleComponent::Dispose() Line 451
 emboleobj.dll!OleComponent::close(unsigned char bDeliverOwnership) Line 1513
 emboleobj.dll!OleEmbeddedObject::GetRidOfComponent() Line 235
 emboleobj.dll!OleEmbeddedObject::Dispose() Line 269
 emboleobj.dll!OleEmbeddedObject::close(unsigned char bDeliverOwnership) Line 498
 comphelper.dll!comphelper::EmbeddedObjectContainer::CloseEmbeddedObjects() Line 208
 sfxlo.dll!SfxObjectShell::~SfxObjectShell() Line 322
 swlo.dll!SwDocShell::~SwDocShell() Line 380
 swlo.dll!SwDocShell::`vector deleting destructor'(unsigned int)
 cppuhelper3MSC.dll!cppu::OWeakObject::release() Line 229
 sfxlo.dll!rtl::Reference<SfxObjectShell>::~Reference<SfxObjectShell>() Line 126
 sfxlo.dll!IMPL_SfxBaseModel_DataContainer::~IMPL_SfxBaseModel_DataContainer() Line 265
 sfxlo.dll!IMPL_SfxBaseModel_DataContainer::`scalar deleting destructor'(unsigned int)
 sfxlo.dll!std::_Destroy_in_place<IMPL_SfxBaseModel_DataContainer>(IMPL_SfxBaseModel_DataContainer & _Obj) Line 293
 sfxlo.dll!std::_Ref_count_obj2<IMPL_SfxBaseModel_DataContainer>::_Destroy() Line 2113
 sfxlo.dll!std::_Ref_count_base::_Decref() Line 1164
 sfxlo.dll!std::_Ptr_base<IMPL_SfxBaseModel_DataContainer>::_Decref() Line 1380
 sfxlo.dll!std::shared_ptr<IMPL_SfxBaseModel_DataContainer>::~shared_ptr<IMPL_SfxBaseModel_DataContainer>() Line 1685
 sfxlo.dll!std::shared_ptr<IMPL_SfxBaseModel_DataContainer>::reset() Line 1732
 sfxlo.dll!SfxBaseModel::dispose() Line 794
 swlo.dll!SwXTextDocument::dispose() Line 561
 sfxlo.dll!SfxBaseModel::close(unsigned char bDeliverOwnership) Line 1523
 swlo.dll!SwXTextDocument::close(unsigned char bDeliverOwnership) Line 574
 sfxlo.dll!SfxBaseModel::dispose() Line 745
 swlo.dll!SwXTextDocument::dispose() Line 561
 mscx_uno.dll!`anonymous namespace'::cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, _typelib_TypeDescriptionReference * pReturnTypeRef, long nParams, _typelib_MethodParameter * pParams, void * pUnoReturn, void * * pUnoArgs, _uno_Any * * ppUnoExc) Line 214
 mscx_uno.dll!unoInterfaceProxyDispatch(_uno_Interface * pUnoI, const _typelib_TypeDescription * pMemberTD, void * pReturn, void * * pArgs, _uno_Any * * ppException) Line 430
 binaryurplo.dll!binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny * returnValue, std::vector<binaryurp::BinaryAny,std::allocator<binaryurp::BinaryAny>> * outArguments) Line 239
 binaryurplo.dll!binaryurp::IncomingRequest::execute() Line 79
 binaryurplo.dll!request(void * pThreadSpecificData) Line 84
 cppu3.dll!cppu_threadpool::JobQueue::enter(const void * nDisposeId, bool bReturnWhenNoJob) Line 101
 cppu3.dll!cppu_threadpool::ORequestThread::run() Line 165
 cppu3.dll!threadFunc(void * param) Line 190
 sal3.dll!oslWorkerWrapperFunction(void * pData) Line 67

Main thread was acquiring OleEmbeddedObject::m_aMutex, which deadlocked:

 sal3.dll!osl_acquireMutex(_oslMutexImpl * Mutex) Line 65
 emboleobj.dll!osl::Mutex::acquire() Line 63
 emboleobj.dll!osl::ResettableGuard<osl::Mutex>::reset() Line 250
 emboleobj.dll!OleEmbeddedObject::setVisualAreaSize(__int64 nAspect, const com::sun::star::awt::Size & aSize) Line 148
 swlo.dll!SwWrtShell::CalcAndSetScale(svt::EmbeddedObjectRef & xObj, const SwRect * pFlyPrtRect, const SwRect * pFlyFrameRect, const bool bNoTextFramePrtAreaChanged) Line 777
 swlo.dll!SwContentNotify::ImplDestroy() Line 926
 swlo.dll!SwContentNotify::~SwContentNotify() Line 1037
 swlo.dll!SwNoTextFrame::MakeAll(OutputDevice * pRenderContext) Line 584
 swlo.dll!SwFrame::OptPrepareMake() Line 412
 swlo.dll!SwFrame::OptCalc() Line 1110
 swlo.dll!SwLayAction::FormatContent_(const SwContentFrame * pContent, const SwPageFrame * pPage) Line 1960
 swlo.dll!SwLayAction::FormatFlyContent(const SwFlyFrame * pFly) Line 1985
 swlo.dll!SwObjectFormatter::FormatObj_(SwAnchoredObject & _rAnchoredObj) Line 312
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject & _rAnchoredObj, const bool _bCheckForMovedFwd) Line 133
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame * _pMasterTextFrame) Line 414
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObjs() Line 348
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame(SwFrame & _rAnchorFrame, const SwPageFrame & _rPageFrame, SwLayAction * _pLayAction) Line 160
 swlo.dll!SwLayAction::FormatContent(SwPageFrame * pPage) Line 1793
 swlo.dll!SwLayAction::InternalAction(OutputDevice * pRenderContext) Line 605
 swlo.dll!SwLayAction::Action(OutputDevice * pRenderContext) Line 389
 swlo.dll!SwLayIdle::SwLayIdle(SwRootFrame * pRt, SwViewShellImp * pI) Line 2363
 swlo.dll!SwViewShell::LayoutIdle() Line 827
 swlo.dll!sw::DocumentTimerManager::DoIdleJobs(Timer * __formal) Line 176
 swlo.dll!sw::DocumentTimerManager::LinkStubDoIdleJobs(void * instance, Timer * data) Line 156
 vcllo.dll!Link<Timer *,void>::Call(Timer * data) Line 111
 vcllo.dll!Timer::Invoke() Line 75
 vcllo.dll!Scheduler::CallbackTaskScheduling() Line 509
 vcllo.dll!SalTimer::CallCallback() Line 53
 vclplug_winlo.dll!WinSalTimer::ImplHandleElapsedTimer() Line 169
 vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 525
 vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 581
 vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 385
 vcllo.dll!Application::Yield() Line 473
 vcllo.dll!Application::Execute() Line 361
 sofficeapp.dll!desktop::Desktop::Main() Line 1652
 vcllo.dll!ImplSVMain() Line 229
 vcllo.dll!SVMain() Line 262
 sofficeapp.dll!soffice_main() Line 110
 soffice.bin!sal_main() Line 51
 soffice.bin!main(int argc, char * * argv) Line 49
 soffice.bin!invoke_main() Line 79
 soffice.bin!__scrt_common_main_seh() Line 288
 soffice.bin!__scrt_common_main() Line 331
 soffice.bin!mainCRTStartup(void * __formal) Line 17

Change-Id: Iaf5133c488d4f26f43530ea19584e99cce12d81e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171855
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-14 14:44:14 +02:00
Caolán McNamara d33d592801 cid#1554791 COPY_INSTEAD_OF_MOVE
and

cid#1554819 COPY_INSTEAD_OF_MOVE
cid#1554837 COPY_INSTEAD_OF_MOVE
cid#1554881 COPY_INSTEAD_OF_MOVE
cid#1554882 COPY_INSTEAD_OF_MOVE
cid#1554884 COPY_INSTEAD_OF_MOVE
cid#1554891 COPY_INSTEAD_OF_MOVE
cid#1554892 COPY_INSTEAD_OF_MOVE
cid#1554897 COPY_INSTEAD_OF_MOVE
cid#1554904 COPY_INSTEAD_OF_MOVE
cid#1554918 COPY_INSTEAD_OF_MOVE
cid#1554928 COPY_INSTEAD_OF_MOVE
cid#1554931 COPY_INSTEAD_OF_MOVE
cid#1554944 COPY_INSTEAD_OF_MOVE
cid#1554945 COPY_INSTEAD_OF_MOVE
cid#1554959 COPY_INSTEAD_OF_MOVE
cid#1554960 COPY_INSTEAD_OF_MOVE
cid#1554963 COPY_INSTEAD_OF_MOVE
cid#1554966 COPY_INSTEAD_OF_MOVE
cid#1554969 COPY_INSTEAD_OF_MOVE
cid#1554973 COPY_INSTEAD_OF_MOVE
cid#1555011 COPY_INSTEAD_OF_MOVE
cid#1555012 COPY_INSTEAD_OF_MOVE
cid#1555015 COPY_INSTEAD_OF_MOVE
cid#1555044 COPY_INSTEAD_OF_MOVE
cid#1555051 COPY_INSTEAD_OF_MOVE
cid#1555055 COPY_INSTEAD_OF_MOVE
cid#1555063 COPY_INSTEAD_OF_MOVE
cid#1555068 COPY_INSTEAD_OF_MOVE
cid#1555073 COPY_INSTEAD_OF_MOVE
cid#1555074 COPY_INSTEAD_OF_MOVE
cid#1555078 COPY_INSTEAD_OF_MOVE
cid#1555080 COPY_INSTEAD_OF_MOVE
cid#1555091 COPY_INSTEAD_OF_MOVE
cid#1555099 COPY_INSTEAD_OF_MOVE
cid#1555101 COPY_INSTEAD_OF_MOVE
cid#1555121 COPY_INSTEAD_OF_MOVE
cid#1610739 COPY_INSTEAD_OF_MOVE
cid#1608424 COPY_INSTEAD_OF_MOVE
cid#1608059 COPY_INSTEAD_OF_MOVE
cid#1607952 COPY_INSTEAD_OF_MOVE
cid#1607653 COPY_INSTEAD_OF_MOVE
cid#1607614 COPY_INSTEAD_OF_MOVE
cid#1607592 COPY_INSTEAD_OF_MOVE

Change-Id: Ie9f922a9fe1b8001dfab31e2741fe8bd5558e442
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170802
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-07-20 23:03:28 +02:00
Gabor Kelemen e1a351ca19 Remove now unneeded osl/diagnose.h
followup to commit 57c228803e

Change-Id: Iebfb23bb65e2bf898bf27f367cc9641f47a14cf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167998
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
2024-07-20 10:20:31 +02:00
Caolán McNamara a6a95c0ce4 cid#1608568 COPY_INSTEAD_OF_MOVE
Change-Id: I7509b0033855c66324d655b66bef9cc14f5e8074
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169980
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-07-04 12:58:23 +02:00
Mike Kaganski d32153d321 Make sure to clear the guard around OleEmbeddedObject::changeState
The method itself clears its own guard; the caller still holding the
guard results in hangs seen in some Java code.

See also commit e2bfc34d14 (Reimplement
OleComponentNative_Impl to use IGlobalInterfaceTablem 2024-03-11).

Change-Id: Ib22e71e7500ccceb946f7b1d6606f8f61ae2afe8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169315
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-06-21 08:57:08 +02:00
Noel Grandin ddf32ef202 loplugin:ostr in embeddedobj
Change-Id: I644042d0ca6041174a8e11f780c546bcf7d4571a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167282
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-08 08:15:07 +02:00
Mike Kaganski 466156f14d Use osl::ResettableMutexGuardScopedReleaser instead of ad-hoc guards
Change-Id: I2aa09655c207d3647650b5e38011a600bd221699
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165777
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-04-04 13:21:14 +02:00
Mike Kaganski 328416e015 This assert was wrong
In commit e2bfc34d14 (Reimplement
OleComponentNative_Impl to use IGlobalInterfaceTable, 2024-03-11),
I added the assert in a false assumption that RunObject may only
be called once. Indeed, this is not so. Thus just make sure to not
try to register it second time.

Change-Id: I36fc4f3939bd0061e462659749bba8e4bd3075ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165299
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-26 17:14:40 +01:00
Mike Kaganski f0c32a4de8 Replace some matchAsciiL (and wrong lengths) with match
Change-Id: I6d0b5fa249cb466230183e11fc96a89fad69d45d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165310
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-26 15:54:26 +01:00
Mike Kaganski fb94c8f64a Relax SolarMutexReleaser precondition to not require SolarMutex lock
As discussed on https://gerrit.libreoffice.org/c/core/+/164843/2#message-8873d3d119de7206b33bc824f5809b8b1d3d97da,
it is impossible at times to know in advance, if a specific code, that
must not be guarded by SolarMutex (e.g., calling to other threads, which
might need to grab the mutex), will itself be guarded by SolarMutex.
Before this change, a required pre-requisite for SolarMutexReleaser use
was existing lock of SolarMutex; otherwise, an attempt to release it
would call abort(). Thus, in some places we had to grab the mutex prior
to releasing it, and that itself introduced more potential for deadlock.

Now the SolarMutexReleaser is safe to use without the lock, in which
case, it will do nothing.

Change-Id: I8759c2f6ed448598b3be4d6c5109804b5e7523ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165262
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-25 06:27:32 +01:00
Mike Kaganski ec0e9bee23 Pass m_pOleComponent to lambda by copy
Both m_pOleComponent and the copy are rtl::Reference, so the copy
will ensure the lifetime of the object.
See https://gerrit.libreoffice.org/c/core/+/164986/2#message-5dd187741df3242f47d1037a1f9c9b0fd9bb1f8e

Change-Id: I092281ce41786682b269ba048f102877117391f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165013
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-20 04:41:36 +01:00
Mike Kaganski 0c9f650136 Release the mutex when calling the OLE method
... which may need to be executed on a different thread.

Change-Id: Id9e4b86fd3eafa49139b21e3817aa1ee8aff3dba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164986
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-19 06:20:41 +01:00
Mike Kaganski 3e0a2239e9 Introduce a guard to delay processing of idles
In a following scenario, there could be a crash:

1. Platform: a Windows system with MS Word installed.
2. LibreOffice is run in a listener mode;
3. A Java program opens a Writer document in a visible mode, with an
   embedded Word OLE object;
4. It adds some text; then resizes the OLE object; then removes the
   OLE object.

Word OLE objects have OLEMISC_RECOMPOSEONRESIZE flag [1]; this means,
that every re-layout of the document with this object must ask the
OLE server to re-layout the object content. So, the request thread
changes the document text, which triggers idle re-layout or redraw;
the idles start executing immediately in the idle main thread, with
solar mutex locked; then the request thread starts the OLE object
removal operation. The ongoing relayout in main thread would at some
stage need to execute a call to the OLE object, which temporarily
releases the solar mutex (this makes impossible using solar mutex to
synchronize the order of operations in this scenario). Other mutexes
guarding OLE object (in OleEmbeddedObject, and in OleComponent) are
also released for the duration of the call. Thus, the removal that
happens in the request thread proceeds, and the node containing the
OLE object is destroyed, while the main thread (processing exactly
this node) is waiting for the OLE server response, then for mutexes,
to proceed. After that, the main thread would attempt to access the
destroyed node object.

This change introduces a scheduler guard (a RAII object), that sets
a flag to not process idle events during the lifetime of the guard.
In its constructor, it also makes sure, that current pending idle
events are finished. This would make sure that guarded code started
from other threads would not race with idles potentially accessing
the model that is currently in transient state.

[1] https://learn.microsoft.com/en-us/windows/win32/api/oleidl/ne-oleidl-olemisc

Change-Id: I2ef0601ccd8b5872588a88493d1f43e39022dbed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164753
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-13 13:47:53 +01:00
Andrea Gelmini 8b83bd661b Fix typo
Change-Id: I26617232049c6218b99d00e1f69adad42e8249ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164668
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2024-03-11 19:33:19 +01:00
Andrea Gelmini 83c2a63223 Fix typo
Change-Id: I9d09cb02d5fed17d48f0bc42ac41cf8bad3b66b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164667
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-11 18:57:32 +01:00
Andrea Gelmini ea1d09b039 Fix typo
Change-Id: Idc184c5155fa69888561fed5709da36c330d1c2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164666
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-11 18:56:34 +01:00
Mike Kaganski a00f608e6a Drop old "SvGlobalName order" compatibility hack
It was added in commit 7afe74c37e
(INTEGRATION: CWS os54 (1.21.10); FILE MERGED, 2005-03-11) for
issue #i30510# related to "StampIt". Hopefully now, after almost
20 years, the hack is not needed anymore.

Change-Id: Id39765b9d2c51fd487c48ce06382c068bab08959
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164459
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-11 04:45:23 +01:00
Mike Kaganski e2bfc34d14 Reimplement OleComponentNative_Impl to use IGlobalInterfaceTable
... to make sure that object methods are called in correct apartment

The user-visible problem was, that running a Java code that connects
to LibreOffice, and opening a document with an embedded OLE object
(it was Word object in a specific case, which needs activation at
opening stage, because these objects have OLEMISC_RECOMPOSEONRESIZE
flag), using loadComponentFromURL with "OnMainThread" set to true,
then closing the document, resulted in a hang after several hundreds
iterations. This was caused by Word process, that was started in
background to serve the COM calls, wasn't closed properly, and kept
all the objects in memory, until OOM.

The reason why it wasn't closed was failed call to IOleObject::Close
in OleComponent::CloseObject, which returned RPC_E_WRONG_THREAD,
because the activation of the OLE object happened in the main thread
(because of "OnMainThread"), which is STA, but closing happened in
the handler thread (belonging to MTA).

Similar problems previously were addressed in commits
2dc3a6c273 (framework: allow loading a
component on the main thread, 2018-12-20),
6002014ce0 (framework: allow loading a
component on the main thread, using XDesktop, 2021-04-28),
d5cd62164d (embeddedobj: handle getting
the visible area on a thread, 2021-05-07).
These changes tried different workarounds for the same problem, when
a COM object instantiated in one apartment is later manipulated from
another, which fails. First two handled the case when the document
is loaded from a non-UI thread, and then manipulated with the UI; to
handle that, they introduced flags that delegated opening the file
to the main (UI) thread. The last change tried to handle the reverse
problem of the OLE object instantiated in the main thread was saved
in a handler thread, which again failed; the workaround was, again,
to try to delegate the second attempt to the main thread.

But basically all methods can fail in such circumstations, as shown
in this problem's case. The "OnMainThread" flag must be passed to
fileopen functions explicitly. Also, the workarounds only work by
passing everything to STA, and don't target a case when the calls
must be passed from STA to MTA.

Since Windows 2000, there is IGlobalInterfaceTable, which goal is
to solve this problem. It allows to use an intermediate object,
which can transparently delegate all calls to the correct thread.

This change re-implements how OLE objects are referenced from
OleComponentNative_Impl, using the said IGlobalInterfaceTable.
This should hopefully obsolete the previous workarounds, which
nevertheless are kept for now.

Change-Id: Ia1c590e547ed24a2c7389283aed6cc3d8ea024b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164457
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-11 04:39:58 +01:00
varshneydevansh cc695e180b tdf#42982: Improve UNO API error reporting
Change-Id: I2eead2d6907cf49d9a8525065d33c3ef43207660
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161779
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2024-03-10 23:40:21 +01:00
Sarper Akdemir cb685f603e tdf#158375: make it possible to hot disable embedded objects
Do not require a reload of the current document for the
embedded objects to be disabled.

Also make sure the existing active embedded objects are
disabled when DisableActiveContent is enabled via options
dialog.

Change-Id: I5a8f302af0cac64575c3e5ec6dbe71ec50a15442
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164367
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
2024-03-07 12:30:15 +01:00
Mike Kaganski 957552bee4 Drop some reinterpret_casts
Change-Id: I5bcfe37adbf1f142950a1a2679f22333c711735e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164456
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-06 15:21:31 +01:00