summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-11-16Bump version to 5.0-10cp-5.0-10Andras Timar
Change-Id: I9f0e693aa48ed6a1ace8b9cdfd1b1db2f3379215
2015-11-16bump png to 1.5.24 CVE-2015-7981 + CVE-2015-8126Caolán McNamara
Change-Id: Ice54f6c89eb2a2492d2b55a3f4edb13df4192446 Reviewed-on: https://gerrit.libreoffice.org/19985 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 055c248e1573cc7cd7988b28f8bb0bf64bf0d6c8)
2015-11-16Resolves: tdf#94069 call setVisible when setDesignMode is calledCaolán McNamara
void UnoControl::setDesignMode calls setVisible on the XWindow so it seems sensible that FmXGridPeer::setDesignMode should also do so. The desirable side effect is that moving the window in design mode then is moving a un-shown window so nothing is invalidated so the paint loop doesn't happen. Change-Id: Ic5a4ba62590372bec15a29b993b73d6dfb94a8a9 (cherry picked from commit a7816853bad55ada597092c16ba9a0a761e067d0) Reviewed-on: https://gerrit.libreoffice.org/19906 Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit a08a5ff76b78f828367467a0a1610d2f7e63ad75)
2015-11-16Resolves: tdf#95321 tables in headers/footers with wrong contentCaolán McNamara
Change-Id: I937ed893dfd9919bf48b8fd38a1b83c524200532 (cherry picked from commit 6128c10f550924c2b75f18b6c6220cc1770adba4) Reviewed-on: https://gerrit.libreoffice.org/19911 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 82c0f2eb67f8fda9981fe83ebab3d658b6ec85fd)
2015-11-16tdf#85232 WPG import: fix handling of line shapesMiklos Vajna
The missing convertMm100ToTwip() calls mispositioned the line shapes inside the groupshape in case of using drawingML inside DOCX files. (cherry picked from commit 11129d89b152db54c86bb2bda58c24b8abb6c5a8) Conflicts: sw/qa/extras/ooxmlimport/ooxmlimport.cxx Change-Id: I0c9d652de43d779f9073a8bfe22866ce4f31d0fa Reviewed-on: https://gerrit.libreoffice.org/19946 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit ca8cdb9afc886f3013a7c1d8707d4c5bef70a1c5)
2015-11-16tdf#95551 - fix image map crash.Michael Meeks
Remove listener we add, and don't crash on callback for disposed dialog. Reviewed-on: https://gerrit.libreoffice.org/19936 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 45c6d948fbac77a8a6926f56579a4ceba981288f) Conflicts: svx/source/dialog/imapdlg.cxx Change-Id: Ia6a1bddd212cb28a0331469e8e87324346d02841
2015-11-16svx: loplugin:badstaticsMichael Stahl
(cherry picked from commit d5016b013672056f89f908b6cde38183fad145bb) Change-Id: Ief31d8153fdbf91cdd29df5ac7801bd88a98542e Reviewed-on: https://gerrit.libreoffice.org/19955 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit d11d0915730f5eefda3f610a9e2c549a39cf655d)
2015-11-16Bogus assertStephan Bergmann
implementation can indeed be empty when cppu::writeSharedLibComponentInfo calls getEnvironmentFromModule(mod, curEnv, "", ""), which in the final if-branch calls getEnvironment with implementation = "". Happens when adding desktop/qa's test-active.oxt. Regression introduced with ae3a0c8da50b36db395984637f5ad74d3b4887bc "Add .component <implementation constructor='...' feature." (cherry picked from commit 97464be9808c0d349be8b84fea6973527496bf26) Conflicts: cppuhelper/source/shlib.cxx Change-Id: Ia70958e4aa18d378ff35063bdf6187f6e073b765 Reviewed-on: https://gerrit.libreoffice.org/19956 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 2466c85c001761da6979e0e1b3a0b15d4b2bdd32)
2015-11-16coverity#1338592 Explicit null dereferencedCaolán McNamara
Change-Id: Ief5c2effbddebe29fc7a4d38ed0af4fed72de40e (cherry picked from commit e08fbe4c592b25fb88828157ff054431ac8e2d8b) Reviewed-on: https://gerrit.libreoffice.org/19915 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit b453342413fddbc808c39f5edd8b19ed49fff05d)
2015-11-16Resolves: tdf#93847 gtk3: paint blocking is unnecessary and harmfulCaolán McNamara
for gtk3. Probably also a fairly dumb idea for gtk2, but with the extra unblocking opportunities it probably just "works out ok" in that model. Change-Id: I3d4716c691fc84a5e68c210fee51f9e31cfacc02 (cherry picked from commit f9dfd0129ce0b0e21e3f57488ff513794dbbaae5) Reviewed-on: https://gerrit.libreoffice.org/19929 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit 11d0bacd7441ee206163b62dce33fc28a25f99dc)
2015-11-16Resolves: tdf#93317 Modified Document Dialog misses focus on Gtk3Caolán McNamara
Change-Id: I16ddac82a76a1e665797e4be192d3642f2660d9f (cherry picked from commit 82abd23f3ee1900b7579e5a0afa23581d5836f01) Reviewed-on: https://gerrit.libreoffice.org/19933 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit 5a1d267a1ed7557db3fe4c73bc0749c885f0ebef)
2015-11-16Resolves: tdf#95021 crash on closing macro dialog editorCaolán McNamara
VclPtr related, dialog dtor is never called, so timer is never stopped and timer refers to deleted parent data (cherry picked from commit 0943adb2f7ec319891c11889b40c9a69f0d1027e) Change-Id: I804ba082817802c0017e61c6b86c5d3694995ea8 Reviewed-on: https://gerrit.libreoffice.org/19926 Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com> Tested-by: Maxim Monastirsky <momonasmon@gmail.com> (cherry picked from commit 33df62efe3c94b87b765f8334c8b614eb896338b)
2015-11-16tdf#95761 All Hotkeys with CTRL+ALT+ not workedJuergen Funk
The problem was always masked out the combination ALT+CTRL, this only needed when press the ALTGR key, but the other ALT-Key (left side) is valid. Change-Id: I8a6f953f519627418fb48ee8d1d68b3cbf797250 Reviewed-on: https://gerrit.libreoffice.org/19923 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-on: https://gerrit.libreoffice.org/19932 (cherry picked from commit 0ff2015b429f7b5847f8b2eaab498416ef043642)
2015-11-16tdf#75256 sifr updates: callout shapesMatthias Freund
Change-Id: Id584edf091aebd95bb71d7efd2df6fdaa511c837 Reviewed-on: https://gerrit.libreoffice.org/19875 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit 131a1962beb53d4945f7edf2cdb94fff0154bdc9) Reviewed-on: https://gerrit.libreoffice.org/19920 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit ec0da57d9cc93b2bfaaa5b6b2d47c3850b3a814e)
2015-11-16tdf#89088 DOCX import: fix missing text due to throwing ShapeContextHandlerMiklos Vajna
Regression from commit 866a4436d3cfac1ff42d7996250bf96fb703aeaa (oox: handle textboxes in ShapeContextHandler::endFastElement(), 2014-06-04), the problem was that code in ShapeContextHandler::endFastElement() assumed that all the XShape implementation it may see provides a TextBox UNO property (which is specific to Writer) of type bool, but this is not true. Fix the problem by assuming false in case it has an other type. Testcase can be a simple "does it load" one, as in the meantime exceptions such as trying to read a bool from an uno::Any make the DOCX XFilter::filter() implementation return false, unlike in the originally reported LibreOffice 4.4 version that just silently discarded the remaining content of the document. Change-Id: I81781a7ec28d085ceee50d386b8eda023f83c29f (cherry picked from commit 4cae3689d4d78fabe6529c9df03c438b1e9d1611) Reviewed-on: https://gerrit.libreoffice.org/19905 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 2c43db1ecfd9621f4eb6775a4f682d00987692f4)
2015-11-16tdf#95481 catch out-of-range access in vcl bitmapArmin Le Grand
blendBitmap24 assumes bitmap is 2 lines high for doing interpolation. For bitmaps of height 1, really nothing to interpolate there. Fix cornercase by 'blending' between the very same line instead. Reviewed-on: https://gerrit.libreoffice.org/19863 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Cherry-picked from 99e3ab6effa9356a1a444160e60ed8df099b15a3 Change-Id: I9b94000aa563e525d0bb2418346ad2c86af26df8 Reviewed-on: https://gerrit.libreoffice.org/19888 Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de> Tested-by: Katarina Behrens <Katarina.Behrens@cib.de> (cherry picked from commit 5a86268e5dabaa5c02cf912e3793ce0f44c03a0b)
2015-11-16sc lok: use client zoom for ViewRowColumnHeadersAndrzej Hunt
Change-Id: I85000851f82ea7cdc4b536683adbc8570de9af7e (cherry picked from commit 396b5f411f7ecc7d600efdc0bb2381a7d1ed6d88)
2015-11-16LOK: calc formula callback + formula bar implementation in gtkMihai Varga
We need the callback to be able implement the formula bar Change-Id: I1c78ab0b9ed9304c0465a9993a7101f8efb91052 Conflicts: include/LibreOfficeKit/LibreOfficeKitEnums.h libreofficekit/source/gtk/lokdocview.cxx Conflicts: libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx libreofficekit/source/gtk/lokdocview.cxx
2015-11-16LOK: setClientZoom() - sets the client zoom levelMihai Varga
We need to know the client's view level to correctly handle the mouse events in calc. PaintTile() set a zoom level that corresponds to the requested tiles and previously postMouseEvent would call SetZoom(1,1). Now we can make use of knowing the client's view level and call SetZoom() with the correct parameters Change-Id: I34b5afcdcc06a671a8ac92c03e87404e42adf4cd Conflicts: sc/source/ui/unoobj/docuno.cxx Conflicts: libreofficekit/source/gtk/lokdocview.cxx libreofficekit/source/gtk/tilebuffer.hxx
2015-11-16SwPostItField::dumpAsXml: survive 0 mpTextMiklos Vajna
And no need to copy it to be able to dump it. Change-Id: I5c0782c489a5d7c24173a81cc82efd195c4aa56e (cherry picked from commit 44c7272fc543947792ae8195341b8867d81e3925)
2015-11-16CppunitTest_desktop_lib: add Writer comments textcaseMiklos Vajna
Fails without e.g. the last hunk of commit 1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3 (sw lok: forward key events to annotation window if necessary, 2015-11-12). Change-Id: I7f39530881f6141fea956b751aa57eb2bdcadcb2 (cherry picked from commit 1118689e70ed49604ded6e1ae83a22bdc995b2fb)
2015-11-16CppunitTest_sw_tiledrendering: replace various ifdefs with a single conditionMiklos Vajna
LOK is Linux-only at the moment, don't bother with disabling each and every unit test on Mac/Windows for now. Change-Id: I2ff1ed47251c16ec6a8d43138789480d95ea720e (cherry picked from commit 18dfcbb11a05b7e702dc2161df9db8386a7ca34b)
2015-11-16sw lok comments: implement mouse move and mouse upMiklos Vajna
As long as we don't tweak the map mode of the comment widgets permanently we also have to disable the selection engine's timer, as that would emit events without the correct map mode: so disable that for the LOK case for now. (cherry picked from commit b3dc0d7c72c2bb997bfceaeaf25dc9153ceca244) Conflicts: sw/inc/SidebarWin.hxx sw/source/uibase/docvw/SidebarTxtControl.hxx Change-Id: If377ff2f064c30feb473f153f9d5b29b8ace7113
2015-11-16sw lok comments: fix cursor position of a newly created sidebar windowMiklos Vajna
With this, pressing ctrl-alt-c to create a new comment has the correct cursor position. Change-Id: Icb8d708dab015d8ffa9bcfe28de66238a75b50bc (cherry picked from commit d78432e9a077725046419902c542ce4e5f515705)
2015-11-16sw lok comments: fix callback of newly created outliner viewsMiklos Vajna
SwPostItMgr::registerLibreOfficeKitCallback() already took care of informing existing outliners, this commit gives a callback to newly registered ones as well. (cherry picked from commit dacc616f7020d045a1cfdb3806436e06046dae10) Conflicts: sw/inc/drawdoc.hxx sw/source/core/draw/drawdoc.cxx Change-Id: I660dcb54231a9d404bf80b4284003d119dae6a5c
2015-11-16sw lok comments: implement setTextSelection() APIMiklos Vajna
So that it's possible to drag the text selection start/end handles in comment text when there is an existing selection. (cherry picked from commit e320d070bb0d4dd0ceb696f2c7cc5afb7c4273c3) Conflicts: sw/source/uibase/docvw/SidebarWin.cxx Change-Id: I3acc4770928d4f385f0ca09a2484a9e112409907
2015-11-16sw lok comments: emit invalidation events in SidebarTextControlMiklos Vajna
With this, newly typed characters show up instantly in comments, not only after changing the zoom level. (cherry picked from commit 4cbbaf571d3982eccd7f7267df3185b3d321d0da) Conflicts: sw/source/uibase/docvw/SidebarTxtControl.hxx Change-Id: I1470db1ec03cc415917375f1f95434cf0944e559
2015-11-16sw lok comments: fix position of blinking cursor after mouse clickMiklos Vajna
LOK always works in absolute twips (origo being the top left corner of SwEditWin), so not only the callbacks have to translate relative twips to absolute ones, but the opposite have to be done for mouse event coordinates. With this, clicking at a random position inside a comment places the blinking cursor at a reasonable position, not always at 0,0. (cherry picked from commit 57972554b58a680f47a05f4d6711c99106f80523) Conflicts: sw/source/uibase/docvw/SidebarWin.cxx Change-Id: Ic8d20f177acd9e1908acf17698c53a1470bd4aec
2015-11-16sw lok: disable comment menu button for nowMiklos Vajna
Change-Id: Ic052544b2835181652732b8de9eaf79572a9db6e (cherry picked from commit 022c716fc89c7315a7c454c01e2fe70d5aece289)
2015-11-16editeng lok: respect origin of map mode for TEXT_SELECTIONMiklos Vajna
With this, selections of Writer comment text show up at the correct position, not at the top left corner of the window. Change-Id: If865503d9a02a27730e382d65c42c706dd533a93 (cherry picked from commit 22e97c130868fe7d7529cfcfb2a240f775bd8916)
2015-11-16sw lok: fix blinking cursor position of commentsMiklos Vajna
With this, it is possible to click inside a comment (and get a blinking cursor inside a comment), and also possible to use the arrow keys to native around and still get correct blinking cursor position. (cherry picked from commit 5fb91dfd804cd6f3d585bb4113b9a68083ac71ee) Conflicts: sw/inc/SidebarWin.hxx sw/source/uibase/docvw/SidebarTxtControl.hxx sw/source/uibase/docvw/SidebarWin.cxx Change-Id: I29eb1e60e4e571151f0b18bec8cf765ea09af09f
2015-11-16editeng lok: respect origin of map mode for INVALIDATE_VISIBLE_CURSORMiklos Vajna
Writer comments are separate widgets, but we want to have coordinates in absolutes twips, so give Writer a chance to inform us about the delta. For now only do this in case the map unit is twips, as Impress sets the origin already. Change-Id: Idf340944165e44b0888c00965d6be7798712ff76 (cherry picked from commit e988ab84f1c32519bfca758086c749ba98a5a85f)
2015-11-16sw: don't show main cursor when editing a postitMiklos Vajna
This is primarily for tiled editing that doesn't know about multiple cursors, so if both the postit cursor and the main cursor is shown for a short period of time, then the main one is hidden, then gtktiledviewer still shows the main one. OTOH if we can avoid showing the cursor in general just to hide it a bit later in general, let's not do that. With this, the "cursor is shown at the comment anchor, not inside the anchor when clicking on the postit" bug disappears. Change-Id: I2383292c5f84604dc8b126510b0797b8426920ae (cherry picked from commit 1c482cb54b4dab4c5b549ecd2395104f042e4101)
2015-11-16sw lok: forward key events to annotation window if necessaryMiklos Vajna
And to allow proper reaction by the annotation windows, inform them when a LOK callback is registered. With this, it's possible to modify the contents of annotations via LOK. (cherry picked from commit 1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3) Conflicts: sw/inc/PostItMgr.hxx sw/inc/SidebarWin.hxx sw/source/core/view/viewsh.cxx sw/source/uibase/docvw/SidebarTxtControl.hxx sw/source/uibase/docvw/edtwin.cxx Change-Id: I4489941512197880940e20cbaeb0b47a7a6f26fc
2015-11-16sw lok: route SwEditWin::MouseButtonDown to SidebarTextControl if necessaryMiklos Vajna
LOK sends all mouse events to SwEditWin, so add initial hit testing in its mouse handler to forward the mouse events to the right VCL widget. (cherry picked from commit b7ecf6279ef3343f12fce776862c027bfeff6617) Conflicts: sw/inc/PostItMgr.hxx sw/source/uibase/docvw/SidebarWin.cxx sw/source/uibase/docvw/edtwin.cxx Change-Id: I67e8e19f47156261fd7c7eafd4e63f743e0c4ce9
2015-11-16sw lok: fix sidebarwindows::SwSidebarWin pixel positionMiklos Vajna
So SwSidebarWin member functions don't get twip values when they call GetPosPixel(). Change-Id: Ied4ff7f49d0320766b045d78f731900af92d37ef (cherry picked from commit c4ef30ea916752ba5a057b49960a60a55f70c84c)
2015-11-16This PixelToLogic() call can be conditional in SwSidebarWin::SetPosAndSize()Miklos Vajna
It is only needed when tiled rendering. (cherry picked from commit 88f4866803fc766503292252cb36af4a70ea98fd) Conflicts: sw/source/uibase/docvw/SidebarWin.cxx Change-Id: Ie1668f5f3d4d17abc212e2262a6c155dcb855d2e
2015-11-16sw lok: fix length of the line overlay above the notesMiklos Vajna
With this, e.g. a line above a note (with width of 180 px) is also 180 px, not 12 px. (cherry picked from commit 096408073c2de484cba3736d13b57d22b7f48775) Change-Id: I7c4eeda1bc904242dc298013411b9671ba0f2149
2015-11-16sw lok: fix width of the notes sidebarMiklos Vajna
The map mode is in general disabled during tiled rendering, so mouse positions can be sent in using twips, but here we have to temporarily enable it, otherwise the width will be returned always in pixels. With this, the gray background of the sidebar has the proper width, not e.g. fifteenth of the expected value (using default zoom). Change-Id: I4380ee0ba6bcda97cf71735161dbdc826e7a2532 (cherry picked from commit 6c3dbdbccbcccf914360dac1167599c5b89446a8)
2015-11-16sw: allow doc model xml dump creation while editing comment textMiklos Vajna
Change-Id: Ie682cfe97b8c48bc66575b89875ca617dbb8ab4e (cherry picked from commit b3b9f2c5b4dde4c5ea9736f8ceda4cdb98036b0b)
2015-11-16sw doc model xml dump: show comment textMiklos Vajna
(cherry picked from commit 9b504ad3ae9f71ea02df2ab6f2c2fbd59d38ae9a) Conflicts: sw/inc/docufld.hxx Change-Id: If15ca89f2b7c54441f076eb233c4e1414dac25c0
2015-11-16sc lok annotations: paint range and anchor overlayMiklos Vajna
Change-Id: I16e51e074704026a45471e7a08c3b96846d44053 (cherry picked from commit 5f68759810496ff3fadf5a883203449772c7392f)
2015-11-16sw lok annotations: disable the scrollbar for nowMiklos Vajna
Change-Id: I7493eaab55c23c79ca0878c34a97dfb4af857260 (cherry picked from commit 8fc6aafcb4769271bc7b208e9b9b430b875b6104)
2015-11-16sw lok annotations: paint all child windowMiklos Vajna
And use map modes to get the painting to the correct position instead of manually adjusting each and every Paint() method. (cherry picked from commit 177e375d2e63f1c3db9f5ab41e4281af740625fb) Conflicts: sw/source/uibase/docvw/SidebarTxtControl.cxx sw/source/uibase/docvw/SidebarTxtControl.hxx Change-Id: I66798321b8bbf2c7968d6ac1edebb1f8df60bce8
2015-11-16sw tiled rendering: initial annotation supportMiklos Vajna
(cherry picked from commit d54aaea33bf2dab86c0ead4bd142c593d017f930) Conflicts: sw/inc/PostItMgr.hxx sw/inc/SidebarWin.hxx sw/source/uibase/docvw/SidebarTxtControl.cxx sw/source/uibase/docvw/SidebarTxtControl.hxx sw/source/uibase/docvw/SidebarWin.cxx Change-Id: I4fcb05f8a58965341cf44a1b7e2367b5cbff981d
2015-11-16tdf#38395 enable smart apostrophe replacement by defaultLászló Németh
Unicode apostrophe is mandatory for French, English, etc. typography, and it is a default option in all modern word processors. The fix enables single quote AutoCorrect replacement for all languages. Change-Id: I2964242ecd1cc839bf27e9a3d772f5cab95d8db0 (cherry picked from commit e6fade1ce133039d28369751b77ac8faff6e40cb)
2015-11-13android: Fixes to AndroidManifestTomaž Vajngerl
Change-Id: I661b3de74066831f22757b587e8b367913030573 (cherry picked from commit 613ef01748bd155653954f1effe00e395ba38a3b)
2015-11-13android: add source of icons to READMETomaž Vajngerl
Change-Id: Iad3ad138a9a7164d10ab6e51e22032ad115d08a5 (cherry picked from commit e4130895577106f0b7eb5530d4e1754794f53547)
2015-11-13android: don't set text color in about dialogTomaž Vajngerl
Change-Id: Iea5df81bb2f85376dc67e1cca63d5586a834e1b0 (cherry picked from commit 7b3f6dd1685bec33aae79c95584b461fdb72e879)
2015-11-13android: remove old unused action buttons (bold, italic,...)Tomaž Vajngerl
Change-Id: I68d87af8ec2662208776d3b202d412145c86d9b2 (cherry picked from commit cb5fa33f0060df7649c6db8bc55be71d1e873def)