basic/source/runtime/methods.cxx | 10 emfio/source/reader/mtftools.cxx | 10 framework/qa/cppunit/data/empty.fodp | 2 framework/qa/cppunit/dispatchtest.cxx | 32 +++ framework/source/uiconfiguration/imagemanagerimpl.cxx | 4 include/vcl/outdevmap.hxx | 10 include/vcl/print.hxx | 4 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx | 42 ++-- libreofficekit/source/gtk/lokdocview.cxx | 18 + sc/inc/refdata.hxx | 6 sc/qa/unit/data/xlsx/129969-min.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 20 + sc/source/core/tool/compiler.cxx | 6 sc/source/core/tool/interpr1.cxx | 2 sc/source/filter/excel/xecontent.cxx | 4 sd/source/ui/view/drviewsj.cxx | 3 sfx2/inc/recentdocsview.hxx | 4 sfx2/inc/unoctitm.hxx | 7 sfx2/source/control/recentdocsview.cxx | 8 sfx2/source/control/unoctitm.cxx | 21 ++ sfx2/source/sidebar/TabBar.cxx | 8 sfx2/source/view/viewprn.cxx | 1 starmath/source/mathmlimport.cxx | 18 - svl/source/items/imageitm.cxx | 2 svl/source/numbers/zforfind.cxx | 19 + svx/source/accessibility/GraphCtlAccessibleContext.cxx | 2 svx/source/dialog/weldeditview.cxx | 13 + sw/source/core/docnode/ndtbl.cxx | 4 sw/source/core/edit/edtab.cxx | 10 sw/source/core/view/viewsh.cxx | 2 sw/source/uibase/config/usrpref.cxx | 2 toolkit/source/awt/vclxtoolkit.cxx | 1 toolkit/source/helper/unowrapper.cxx | 1 vcl/ios/salios.cxx | 147 ++++++++++++++ vcl/osx/salmacos.cxx | 152 +++++++++++++++ vcl/quartz/salgdicommon.cxx | 147 -------------- vcl/source/gdi/print.cxx | 1 vcl/source/gdi/print3.cxx | 11 + vcl/source/outdev/map.cxx | 18 - vcl/unx/gtk3/gtk3gtkinst.cxx | 12 - xmloff/source/transform/ActionMapTypesOASIS.hxx | 2 xmlsecurity/source/helper/ooxmlsecparser.hxx | 4 42 files changed, 541 insertions(+), 249 deletions(-)
New commits: commit 73c20715c10049d6203f4c9f8a279af80dd58dd9 Author: Michael Stahl <[email protected]> AuthorDate: Fri Jul 9 14:25:28 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:02 2021 +0200 toolkit: initialise new VCLXTopWindow properly VCLXToolkit::createSystemChild() doesn't init WindowImpl::mpVCLXWindow and so it can happen that another VCLXTopWindow instance is created later for the same Window. Change-Id: I9ac654dceb15ea619597f2b8d9d1f9282aa1dfc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118684 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit addd7e7835097043efda52594f3a34219dbd1063) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118713 Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index c250a5d2ad5c..8c780efe3117 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -2048,6 +2048,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createSystemChild( con SolarMutexGuard aGuard; pPeer->SetWindow( pChildWindow ); xPeer = pPeer; + pChildWindow->SetWindowPeer(xPeer, pPeer); } return xPeer; commit 0a018ee6376003e255c369922e6a67e11b556cd6 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Dec 11 09:03:51 2020 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:02 2021 +0200 cid#1470585 Dereference null return value Change-Id: If2a3eae843753a06d2f3fa9ac31acc9470cb6982 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107584 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 2c0930f19e269348a2aadc0ffe69ff23d04d7cc1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118616 Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx index b598e4754a70..03e951e2509c 100644 --- a/sw/source/core/edit/edtab.cxx +++ b/sw/source/core/edit/edtab.cxx @@ -148,17 +148,19 @@ bool SwEditShell::TextToTable( const SwInsertTableOptions& rInsTableOpts, bool SwEditShell::TableToText( sal_Unicode cCh ) { SwWait aWait( *GetDoc()->GetDocShell(), true ); - bool bRet = false; SwPaM* pCursor = GetCursor(); const SwTableNode* pTableNd = GetDoc()->IsIdxInTable( pCursor->GetPoint()->nNode ); + if (!pTableNd) + return false; + if( IsTableMode() ) { ClearMark(); pCursor = GetCursor(); } - else if( !pTableNd || pCursor->GetNext() != pCursor ) - return bRet; + else if (pCursor->GetNext() != pCursor) + return false; // TL_CHART2: // tell the charts about the table to be deleted and have them use their own data @@ -177,7 +179,7 @@ bool SwEditShell::TableToText( sal_Unicode cCh ) //Modified for bug #i119954# Application crashed if undo/redo convert nest table to text StartUndo(); - bRet = ConvertTableToText( pTableNd, cCh ); + bool bRet = ConvertTableToText( pTableNd, cCh ); EndUndo(); //End for bug #i119954# pCursor->GetPoint()->nNode = aTabIdx; commit 7f219cef50ba61f97444d6cdb46d32f780156500 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 8 10:04:10 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:01 2021 +0200 return value of PixelToLogic ignored the other uses of SdrObjListPrimitiveHit operate in Logic Position Change-Id: Id6a834a17e6e2252bd4f58d10cd95f7425191203 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118615 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/svx/source/accessibility/GraphCtlAccessibleContext.cxx b/svx/source/accessibility/GraphCtlAccessibleContext.cxx index ffe195b4d990..25a271063bc5 100644 --- a/svx/source/accessibility/GraphCtlAccessibleContext.cxx +++ b/svx/source/accessibility/GraphCtlAccessibleContext.cxx @@ -176,7 +176,7 @@ Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleAt } Point aPnt( rPoint.X, rPoint.Y ); - mpControl->GetDrawingArea()->get_ref_device().PixelToLogic( aPnt ); + aPnt = mpControl->GetDrawingArea()->get_ref_device().PixelToLogic(aPnt); SdrObject* pObj = nullptr; commit a3f0fa79f2ec8ed6fd8c66d1a95e4ababdbc9c0c Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 8 14:15:12 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:01 2021 +0200 Resolves: tdf#143153 null-deref on grouping fit-to-frame obj with another Change-Id: I134d15ac980aa34ff274abd03966cd7948390542 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118628 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/sd/source/ui/view/drviewsj.cxx b/sd/source/ui/view/drviewsj.cxx index 47cbb175ddf4..9eebdbc57c29 100644 --- a/sd/source/ui/view/drviewsj.cxx +++ b/sd/source/ui/view/drviewsj.cxx @@ -271,7 +271,8 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet ) if( SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTLINE_TEXT_AUTOFIT ) ) { const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - const bool bSet = pObj->GetMergedItemSet().GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue() != drawing::TextFitToSizeType_NONE; + const SdrTextFitToSizeTypeItem* pItem = pObj->GetMergedItemSet().GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE); + const bool bSet = pItem && pItem->GetValue() != drawing::TextFitToSizeType_NONE; rSet.Put(SfxBoolItem(SID_OUTLINE_TEXT_AUTOFIT, bSet)); } commit 7734fb9a6fe851291a6664ed84ebf422c1c2273e Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 8 13:48:35 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:01 2021 +0200 tdf#143146 copy functor and arg before calling function that can delete this Change-Id: I4e29fe6fa4119b709e31156afc5c2a5d08cdc072 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118625 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index 48698bb00937..20d7e0e13bb6 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -255,13 +255,17 @@ TabBar::Item::~Item() mrTabBar.GetContainer()->move(mxButton.get(), nullptr); } - IMPL_LINK_NOARG(TabBar::Item, HandleClick, const OString&, void) { + // tdf#143146 copy the functor and arg before calling + // GrabFocusToDocument which may destroy this object + auto aDeckActivationFunctor = maDeckActivationFunctor; + auto sDeckId = msDeckId; + mrTabBar.GrabFocusToDocument(); try { - maDeckActivationFunctor(msDeckId); + aDeckActivationFunctor(sDeckId); } catch(const css::uno::Exception&) {} // workaround for #i123198# commit 3a8303962ea1f15d9eb4ca2b863483c6bdfb1d44 Author: Caolán McNamara <[email protected]> AuthorDate: Sat Mar 20 20:14:43 2021 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:00 2021 +0200 cid#1478187 Resource leak Change-Id: Ib63d25e358f81c428fcbbb502650c37d016b6b44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112821 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit da86cd492c5a04c42086985e17ae84d63bdedd0b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118617 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index c1fcc5542750..156224b57351 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -991,19 +991,28 @@ payloadToRectangle (LOKDocView* pDocView, const char* pPayload) aRet.width = aRet.height = aRet.x = aRet.y = 0; if (!*ppCoordinate) + { + g_strfreev(ppCoordinates); return aRet; + } aRet.x = atoi(*ppCoordinate); if (aRet.x < 0) aRet.x = 0; ++ppCoordinate; if (!*ppCoordinate) + { + g_strfreev(ppCoordinates); return aRet; + } aRet.y = atoi(*ppCoordinate); if (aRet.y < 0) aRet.y = 0; ++ppCoordinate; if (!*ppCoordinate) + { + g_strfreev(ppCoordinates); return aRet; + } long l = atol(*ppCoordinate); if (l > std::numeric_limits<int>::max()) aRet.width = std::numeric_limits<int>::max(); @@ -1013,7 +1022,10 @@ payloadToRectangle (LOKDocView* pDocView, const char* pPayload) aRet.width = priv->m_nDocumentWidthTwips - aRet.x; ++ppCoordinate; if (!*ppCoordinate) + { + g_strfreev(ppCoordinates); return aRet; + } l = atol(*ppCoordinate); if (l > std::numeric_limits<int>::max()) aRet.height = std::numeric_limits<int>::max(); @@ -1021,8 +1033,8 @@ payloadToRectangle (LOKDocView* pDocView, const char* pPayload) aRet.height = l; if (aRet.y + aRet.height > priv->m_nDocumentHeightTwips) aRet.height = priv->m_nDocumentHeightTwips - aRet.y; - g_strfreev(ppCoordinates); + g_strfreev(ppCoordinates); return aRet; } commit 0e50d7d70cdd46afc5ad2ae3cc8ef6e394be05b0 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Dec 1 14:13:50 2020 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:44:00 2021 +0200 cid#1470368 Unchecked dynamic_cast Change-Id: Ie67501aea8df37e894edfecf75e2338709535253 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106986 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 52a69f41e992efa2abc2e2e94414a2547df71329) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118620 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index c00f585d6711..ef34c351b6c0 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2155,7 +2155,7 @@ IsCursorInFieldmarkHidden(SwPaM const& rCursor, sw::FieldmarkMode const eMode) if (*rCursor.GetPoint() < (**iter).GetMarkEnd()) { SwPosition const sepPos(sw::mark::FindFieldSep( - *dynamic_cast<sw::mark::IFieldmark*>(*iter))); + dynamic_cast<sw::mark::IFieldmark&>(**iter))); if (eMode == sw::FieldmarkMode::ShowResult) { if (*rCursor.GetPoint() <= sepPos commit b919e092d7e32658df9339da51991e9f57a4cf95 Author: Caolán McNamara <[email protected]> AuthorDate: Sun Mar 21 14:38:36 2021 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:59 2021 +0200 cid#1474127 Unchecked return value from library Change-Id: I6dac6f24d33ce4557ab94ff08357e597819510d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112839 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 9456a764a98daa2915f6fefac336d8bb5cff531a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118619 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 2a4b90cc8de5..c1fcc5542750 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -2776,10 +2776,10 @@ static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* / return true; if (priv->m_bUnipoll) - g_setenv("SAL_LOK_OPTIONS", "unipoll", FALSE); + (void)g_setenv("SAL_LOK_OPTIONS", "unipoll", FALSE); static const char testingLangs[] = "de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru"; - g_setenv("LOK_ALLOWLIST_LANGUAGES", testingLangs, FALSE); + (void)g_setenv("LOK_ALLOWLIST_LANGUAGES", testingLangs, FALSE); priv->m_pOffice = lok_init_2(priv->m_aLOPath.c_str(), priv->m_aUserProfileURL.empty() ? nullptr : priv->m_aUserProfileURL.c_str()); commit 1d2802191c8e1617fa5c6c41a44c575ac75a3e77 Author: Caolán McNamara <[email protected]> AuthorDate: Sat Mar 20 20:11:25 2021 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:59 2021 +0200 cid#1474277 Resource leak and... cid#1474319 Resource leak cid#1473965 Resource leak cid#1474109 Resource leak cid#1474179 Resource leak Change-Id: I7daba2a0173a7fe7a912c0febf7957667f0fae83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112822 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 4efc4a43ff481661990b304f9599f811db39f7dc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118618 Reviewed-by: Michael Stahl <[email protected]> diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx index fef712ceef0a..be7cd4445536 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx @@ -38,8 +38,8 @@ void btn_clicked(GtkWidget* pButton, gpointer) GtvHelpers::userPromptDialog(GTK_WINDOW(window), "Insert Comment", aEntries); boost::property_tree::ptree aTree; - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string"); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]); + aTree.put(boost::property_tree::ptree::path_type("Text/type", '/'), "string"); + aTree.put(boost::property_tree::ptree::path_type("Text/value", '/'), aEntries["Text"]); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); @@ -191,8 +191,12 @@ static void iterateUnoParams(GtkWidget* pWidget, gpointer userdata) unoParam[i] = gtk_entry_get_text(GTK_ENTRY(pIt->data)); } - pTree->put(boost::property_tree::ptree::path_type(g_strconcat(unoParam[1], "/", "type", nullptr), '/'), unoParam[0]); - pTree->put(boost::property_tree::ptree::path_type(g_strconcat(unoParam[1], "/", "value", nullptr), '/'), unoParam[2]); + gchar* pPath = g_strconcat(unoParam[1], "/", "type", nullptr); + pTree->put(boost::property_tree::ptree::path_type(pPath, '/'), unoParam[0]); + g_free(pPath); + pPath = g_strconcat(unoParam[1], "/", "value", nullptr); + pTree->put(boost::property_tree::ptree::path_type(pPath, '/'), unoParam[2]); + g_free(pPath); } void recentUnoChanged( GtkWidget* pSelector, gpointer /* pItem */ ) @@ -256,11 +260,9 @@ void unoCommandDebugger(GtkWidget* pButton, gpointer /* pItem */) gtk_widget_show_all(pUnoCmdDialog); gint res = gtk_dialog_run (GTK_DIALOG(pUnoCmdDialog)); - switch (res) - { - case GTK_RESPONSE_OK: + if (res == GTK_RESPONSE_OK) { - const gchar* sUnoCmd = g_strconcat(".uno:", gtk_entry_get_text(GTK_ENTRY(pUnoCmdEntry)), nullptr); + gchar* sUnoCmd = g_strconcat(".uno:", gtk_entry_get_text(GTK_ENTRY(pUnoCmdEntry)), nullptr); boost::property_tree::ptree aTree; gtk_container_foreach(GTK_CONTAINER(pUnoParamAreaBox), iterateUnoParams, &aTree); @@ -273,8 +275,8 @@ void unoCommandDebugger(GtkWidget* pButton, gpointer /* pItem */) lok_doc_view_post_command(LOK_DOC_VIEW(window->lokdocview), sUnoCmd, (aArguments.empty() ? nullptr : aArguments.c_str()), false); addToRecentUnoCommands(window, sUnoCmd, aArguments); - } - break; + + g_free(sUnoCmd); } gtk_widget_destroy(pUnoCmdDialog); @@ -649,11 +651,11 @@ void editButtonClicked(GtkWidget* pWidget, gpointer userdata) gchar *commentId = static_cast<gchar*>(g_object_get_data(G_OBJECT(userdata), "id")); boost::property_tree::ptree aTree; - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "string"); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::string(commentId)); + aTree.put(boost::property_tree::ptree::path_type("Id/type", '/'), "string"); + aTree.put(boost::property_tree::ptree::path_type("Id/value", '/'), std::string(commentId)); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string"); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]); + aTree.put(boost::property_tree::ptree::path_type("Text/type", '/'), "string"); + aTree.put(boost::property_tree::ptree::path_type("Text/value", '/'), aEntries["Text"]); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); @@ -673,11 +675,11 @@ void replyButtonClicked(GtkWidget* pWidget, gpointer userdata) gchar *commentId = static_cast<gchar*>(g_object_get_data(G_OBJECT(userdata), "id")); boost::property_tree::ptree aTree; - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "string"); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::string(commentId)); + aTree.put(boost::property_tree::ptree::path_type("Id/type", '/'), "string"); + aTree.put(boost::property_tree::ptree::path_type("Id/value", '/'), std::string(commentId)); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string"); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]); + aTree.put(boost::property_tree::ptree::path_type("Text/type", '/'), "string"); + aTree.put(boost::property_tree::ptree::path_type("Text/value", '/'), aEntries["Text"]); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); @@ -697,8 +699,8 @@ void deleteCommentButtonClicked(GtkWidget* pWidget, gpointer userdata) gchar *commentid = static_cast<gchar*>(g_object_get_data(G_OBJECT(userdata), "id")); boost::property_tree::ptree aTree; - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "string"); - aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::string(commentid)); + aTree.put(boost::property_tree::ptree::path_type("Id/type", '/'), "string"); + aTree.put(boost::property_tree::ptree::path_type("Id/value", '/'), std::string(commentid)); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); commit 90446f3dcd9297f44e7b5fa5f84fa43306a1ea54 Author: dante <[email protected]> AuthorDate: Tue Dec 1 21:00:33 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:58 2021 +0200 Doubled code correction Change-Id: I391cb0f51788034e358889bb4aaf38c3824cac2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107010 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit e8c8af66c4bc63d9761508b4d24f5d1dd4050b79) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118601 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 543a8d02fcb2..2df8e642d925 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -1415,20 +1415,10 @@ void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars) aToken.cMathChar = rChars[0]; SmToken bToken; if( bIsFenced ){ - if( bIsStretchy ) - { - if( isPrefix ) bToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else if( isInfix ) bToken = SmToken( TMLINE, MS_VERTLINE, "mline", TG::NONE, 0 ); - else if( isPostfix ) bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - } - else - { - if( isPrefix ) bToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else if( isInfix ) bToken = SmToken( TMLINE, MS_VERTLINE, "mline", TG::NONE, 0 ); - else if( isPostfix ) bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - } + if( isPrefix ) bToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl( aToken.cMathChar ); + else if( isInfix ) bToken = SmToken( TMLINE, MS_VERTLINE, "mline", TG::NONE, 0 ); + else if( isPostfix ) bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); + else bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); } else bToken = starmathdatabase::Identify_SmXMLOperatorContext_Impl( aToken.cMathChar, bIsStretchy ); if( bToken.eType != TERROR ) aToken = bToken; commit 5a1140e51811a7a80d9123efccbcb140bac74439 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 8 10:55:02 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:58 2021 +0200 SolarMutexGuard::clear called twice where the 2nd call site should undo the 1st since commit 94f8a0e60b7bc5c1176eafe9a36c3f3466bd1408 Date: Thu Mar 20 09:08:10 2014 +0100 Use SolarMutexGuard directly Change-Id: I4b245dd68bf032a1d74fb16b910dc952fd761781 seen with compiler warning of: In member function ‘sal_uInt32 comphelper::SolarMutex::release(bool)’, inlined from ‘void osl::ClearableGuard<T>::clear() [with T = comphelper::SolarMutex]’ at include/osl/mutex.hxx:194:28, inlined from ‘void framework::ImageManagerImpl::reload()’ at framework/source/uiconfiguration/imagemanagerimpl.cxx:1071:25: include/comphelper/solarmutex.hxx:91:22: error: ‘this’ pointer is null [-Werror=nonnull] Change-Id: Ibd074794e4556a6ff34b0dc94099e81e1ae3b349 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118623 Reviewed-by: Stephan Bergmann <[email protected]> Tested-by: Jenkins diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 681ce8a4a7ba..bbed5cc71243 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -929,7 +929,7 @@ void ImageManagerImpl::insertImages( ::sal_Int16 nImageType, const Sequence< OUS // XUIConfigurationPersistence void ImageManagerImpl::reload() { - SolarMutexClearableGuard aGuard; + SolarMutexResettableGuard aGuard; if ( m_bDisposed ) throw DisposedException(); @@ -1068,7 +1068,7 @@ void ImageManagerImpl::reload() implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove ); } - aGuard.clear(); + aGuard.reset(); } } } commit 2d707f94cf2fae7cf7f1c51c663921db8db17a9e Author: Caolán McNamara <[email protected]> AuthorDate: Wed Dec 2 13:31:59 2020 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:58 2021 +0200 cid#1468696 Logically dead code bool bTryXlA1 = (eConv == FormulaGrammar::CONV_A1_XL_A1); if (...) eConv = FormulaGrammar::CONV_XL_R1C1; if (bTryXlA1 || eConv == FormulaGrammar::CONV_OOO) { if (...) { bExternalName = true; eConv = FormulaGrammar::CONV_OOO; } } if (!bExternalName && (bTryXlA1 || eConv != FormulaGrammar::CONV_OOO)) { if (...) { if (eConv == FormulaGrammar::CONV_OOO) { // this condition can only be reached if bTryXlA1 is true // but bTryXlA1 is only true if eConv was originally // CONV_A1_XL_A1. The only things eConv can be changed to // in this function are CONV_XL_R1C1 or CONV_OOO. If it // was changed to CONV_OOO then bExternalName was also // set to true and the block isn't entered if that is true } } } maybe an unconditional assignment of eConv = FormulaGrammar::CONV_XL_A1 is a better solution Change-Id: I45f9947c21662369474048acf2d648733a9b9a6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107076 Tested-by: Jenkins Reviewed-by: Eike Rathke <[email protected]> (cherry picked from commit 22c7ad49679c2abcac4409c93d32b20746b16904) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118602 diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 4204215d8d97..4f2789160a1c 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8241,8 +8241,6 @@ void ScInterpreter::ScIndirect() if (nIndex >= 3 && sRefStr[nIndex-1] == '\'') { bExternalName = true; - if (eConv == FormulaGrammar::CONV_OOO) - eConv = FormulaGrammar::CONV_XL_A1; } } } commit 907643bf1fb5db8104ac5ea6a3e206386890af60 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Dec 2 13:04:27 2020 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:57 2021 +0200 cid#1470369 Uninitialized scalar variable and cid#1470372 Uninitialized scalar variable cid#1470364 Uninitialized scalar variable cid#1470363 Uninitialized scalar variable cid#1470359 Uninitialized scalar variable cid#1470357 Uninitialized scalar variable cid#1470355 Uninitialized scalar variable cid#1470354 Uninitialized scalar variable cid#1470353 Uninitialized scalar variable Change-Id: I4a28f0f375f9108f4c43da7074f85d1fdbb3ebff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107070 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 2a988b1ecddd17f9c851b625d33fbe0c4dfa2325) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118594 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/include/vcl/outdevmap.hxx b/include/vcl/outdevmap.hxx index d4ef27e94e91..467dd688c612 100644 --- a/include/vcl/outdevmap.hxx +++ b/include/vcl/outdevmap.hxx @@ -28,6 +28,16 @@ struct ImplMapRes tools::Long mnMapScNumY; // Scaling factor - numerator in Y direction tools::Long mnMapScDenomX; // Scaling factor - denominator in X direction tools::Long mnMapScDenomY; // Scaling factor - denominator in Y direction + + ImplMapRes() + : mnMapOfsX(0) + , mnMapOfsY(0) + , mnMapScNumX(1) + , mnMapScNumY(1) + , mnMapScDenomX(1) + , mnMapScDenomY(1) + { + } }; #endif // INCLUDED_VCL_OUTDEVMAP_HXX diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 3f478f2fdf88..dc7fca36fa3d 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -1344,17 +1344,11 @@ basegfx::B2DPolyPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolyPolygo return rSource; \ \ ImplMapRes aMapResSource; \ - aMapResSource.mnMapOfsX = 0; \ - aMapResSource.mnMapOfsY = 0; \ - aMapResSource.mnMapScNumX = 1; \ - aMapResSource.mnMapScNumY = 1; \ - aMapResSource.mnMapScDenomX = 1; \ - aMapResSource.mnMapScDenomY = 1; \ - ImplMapRes aMapResDest(aMapResSource); \ + ImplMapRes aMapResDest; \ \ if ( !mbMap || pMapModeSource != &maMapMode ) \ { \ - if ( pMapModeSource->GetMapUnit() == MapUnit::MapRelative ) \ + if ( pMapModeSource->GetMapUnit() == MapUnit::MapRelative ) \ aMapResSource = maMapRes; \ ImplCalcMapResolution( *pMapModeSource, \ mnDPIX, mnDPIY, aMapResSource ); \ @@ -1402,13 +1396,7 @@ static void verifyUnitSourceDest( MapUnit eUnitSource, MapUnit eUnitDest ) #define ENTER4( rMapModeSource, rMapModeDest ) \ ImplMapRes aMapResSource; \ - aMapResSource.mnMapOfsX = 0; \ - aMapResSource.mnMapOfsY = 0; \ - aMapResSource.mnMapScNumX = 1; \ - aMapResSource.mnMapScNumY = 1; \ - aMapResSource.mnMapScDenomX = 1; \ - aMapResSource.mnMapScDenomY = 1; \ - ImplMapRes aMapResDest(aMapResSource); \ + ImplMapRes aMapResDest; \ \ ImplCalcMapResolution( rMapModeSource, 72, 72, aMapResSource ); \ ImplCalcMapResolution( rMapModeDest, 72, 72, aMapResDest ) commit ef3ede9efd2bd265876a630245f1272cdc876756 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Feb 25 15:06:50 2021 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:57 2021 +0200 ofz#31370 Divide-by-zero Change-Id: If581d61b678616f8a80f8ad2d2dea5ecbf10d8fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111557 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit da457f41f8f0a14014ff9f122467f3a26eb1ac20) and... cid#1473321 Division or modulo by float zero and cid#1473322 Division or modulo by float zero where oss-fuzz also found a reproducer as ofz#31370 Divide-by-zero Change-Id: I0facd2e794384515891dbf040f4fe43530478d3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111601 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 28e022c258682dc030668fed7879d9d3f078b720) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118595 Reviewed-by: Michael Stahl <[email protected]> diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 0d918af72dc0..53564c34f82b 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -385,10 +385,13 @@ namespace emfio // calculate measured TextLength const vcl::Font& rFontCandidate(maCurrentMetaFontAction->GetFont()); pTempVirtualDevice->SetFont(rFontCandidate); - const tools::Long nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText)); + tools::Long nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText)); + // on failure, use original length + if (!nMeasuredTextLength) + nMeasuredTextLength = nImportedTextLength; // compare expected and imported TextLengths - if(nImportedTextLength != nMeasuredTextLength) + if (nImportedTextLength != nMeasuredTextLength) { const double fFactorText(static_cast<double>(nImportedTextLength) / static_cast<double>(nMeasuredTextLength)); const double fFactorTextPercent(fabs(1.0 - fFactorText) * 100.0); @@ -417,6 +420,9 @@ namespace emfio rFontCandidate2.SetAverageFontWidth(static_cast<tools::Long>(fCorrectedAverageFontWidth)); pTempVirtualDevice->SetFont(rFontCandidate2); nCorrectedTextLength = pTempVirtualDevice->GetTextWidth(rText); + // on failure, use original length + if (!nCorrectedTextLength) + nCorrectedTextLength = nImportedTextLength; } const double fFactorCorrectedText(static_cast<double>(nImportedTextLength) / static_cast<double>(nCorrectedTextLength)); commit 3b868718553d11e16f0e5c9f2a1651a27ac5bd34 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Apr 1 09:16:12 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:56 2021 +0200 cid#1475790 Uninitialized scalar field this appeared in: commit 0dac6d1f179c286dd7aea2d9ef7c37db8323fa37 Author: Miklos Vajna <[email protected]> Date: Mon Jan 25 15:34:38 2016 +0100 xmlsecurity: implement OOXML stream references and disappeared in: commit cc1d19f7bbaefa5fb22ebd1344112755068b93c9 Author: Michael Stahl <[email protected]> Date: Tue Mar 30 17:37:31 2021 +0200 xmlsecurity: replace OOXMLSecParser implementation Change-Id: Ibaff786612d0f58639471d409dc49d813fb1cb6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113442 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 36e8a0348f7d1ea9f718c3d71514a72990f77a34) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118581 Reviewed-by: Michael Stahl <[email protected]> diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx index ba0e274be6af..4c6d06caaa31 100644 --- a/xmlsecurity/source/helper/ooxmlsecparser.hxx +++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx @@ -77,10 +77,6 @@ private: XSecController* m_pXSecController; css::uno::Reference<css::xml::sax::XDocumentHandler> m_xNextHandler; - /// Last seen <Reference URI="...">. - OUString m_aReferenceURI; - /// Already called addStreamReference() for this reference. - bool m_bReferenceUnresolved; XMLSignatureHelper& m_rXMLSignatureHelper; OUString HandleIdAttr(css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs); commit 28f37f542b8b5ae6a0231b534d59d5bde2594c1f Author: Caolán McNamara <[email protected]> AuthorDate: Wed Jul 7 17:33:06 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:56 2021 +0200 WaE: Wodr type 'ActionMapTypesOOo' violates the C++ ODR Change-Id: If0b83e62e6c9905b1ae391fbed7c43b379dce5db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118506 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/xmloff/source/transform/ActionMapTypesOASIS.hxx b/xmloff/source/transform/ActionMapTypesOASIS.hxx index 8a45d9d1e80c..59ad0fdd2741 100644 --- a/xmloff/source/transform/ActionMapTypesOASIS.hxx +++ b/xmloff/source/transform/ActionMapTypesOASIS.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_XMLOFF_SOURCE_TRANSFORM_ACTIONMAPTYPESOASIS_HXX #define INCLUDED_XMLOFF_SOURCE_TRANSFORM_ACTIONMAPTYPESOASIS_HXX -enum ActionMapTypesOOo +enum ActionMapTypesOasis { PROP_OASIS_GRAPHIC_ATTR_ACTIONS, PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS, commit 66c382d123a5cb2f7ddb64e43d78cf419b3bb9f2 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Dec 1 10:17:18 2020 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:55 2021 +0200 cid#1202935 Uninitialized scalar field Change-Id: Ie95426e6188253dd5f2bd77782f62647d9ddba50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106956 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit ad53629186343f8a111b4bee21721e8b446bd8a2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118582 Reviewed-by: Michael Stahl <[email protected]> diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index e2dba7e1ff53..691a4d323e7e 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -459,6 +459,7 @@ void Printer::ImplInitData() mbPrintFile = false; mbInPrintPage = false; mbNewJobSetup = false; + mbSinglePrintJobs = false; mpInfoPrinter = nullptr; mpPrinter = nullptr; mpDisplayDev = nullptr; commit fbcf3d800ee828a411e5ac33571cf925863f9d78 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Jan 15 09:44:38 2021 +0000 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:55 2021 +0200 cid#1472119 silence Uninitialized scalar field Change-Id: I0a8a12e8bb823fc650212f5cf946ad9139395030 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109327 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit a94aecfdaafc5525be73246d3e8f19fdb714b387) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118583 Reviewed-by: Michael Stahl <[email protected]> diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx index 9b57fe807536..7674794a9a80 100644 --- a/sc/inc/refdata.hxx +++ b/sc/inc/refdata.hxx @@ -124,11 +124,7 @@ struct ScComplexRefData { ScSingleRefData Ref1; ScSingleRefData Ref2; - bool bTrimToData; - - ScComplexRefData() : - bTrimToData(false) - {} + bool bTrimToData = false; void InitFlags() { Ref1.InitFlags(); Ref2.InitFlags(); } commit ed12987f28696b51467507b97702cf50835cc850 Author: dante <[email protected]> AuthorDate: Tue Dec 29 19:58:04 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:54 2021 +0200 Remove warning while building Operator >>= from any does not guarantee initialization, so compiler warns you. Value defaluted at 0. Change-Id: Icecc765be73bb653f0167958e319a1417df6ac86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108485 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> (cherry picked from commit edc7a8a372a689802a583092ff0da0f60b6dbf97) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118584 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/svl/source/items/imageitm.cxx b/svl/source/items/imageitm.cxx index 7a2d528c1fce..2c2a88600cc9 100644 --- a/svl/source/items/imageitm.cxx +++ b/svl/source/items/imageitm.cxx @@ -72,7 +72,7 @@ bool SfxImageItem::PutValue( const css::uno::Any& rVal, sal_uInt8 ) sal_Int16 nVal = sal_Int16(); if ( aSeq[0] >>= nVal ) SetValue( nVal ); - sal_Int16 nTmp; + sal_Int16 nTmp = 0; aSeq[1] >>= nTmp; mnAngle = Degree10(nTmp); aSeq[2] >>= mbMirrored; diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx index 615098813db2..a896acb30c90 100644 --- a/sw/source/uibase/config/usrpref.cxx +++ b/sw/source/uibase/config/usrpref.cxx @@ -233,7 +233,7 @@ void SwContentViewConfig::Load() case 23: m_rParent.SetShowChangesInMargin(bSet); break;// "Display/ShowChangesInMargin" case 24: { - sal_Int32 nSet; + sal_Int32 nSet = 0; pValues[nProp] >>= nSet; m_rParent.SetDefaultAnchor(nSet); } commit 685b615ffd9e46d891a653736d2115f4a32e20d1 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jul 7 13:24:37 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:54 2021 +0200 tdf#140594 Create proper window peer for FORMATTEDFIELD commit 2a694f9e0e7789b4b3b792a9eedd29366fa10c1c Date: Wed May 6 14:08:07 2020 -0400 lok: fix the window type of the formatted field control had introduced the new 'WindowType::FORMATTEDFIELD' and set it for the 'FormattedField' control (instead of using the previous default value set in the 'SpinField' ctor, which is 'WindowType::SPINFIELD'). So far, this type was not explicitly handled when creating the XWindow peer. Handle it just the same as 'WindowType::SPINFIELD' and return a new 'VCLXNumericField', which e.g. makes sure that a "proper" accessible is created and thus alues of a spin field are announced by the NVDA screen reader (again). (See also commit 33cac418db78f64f7fa84b8e65c01c2b02cf17a7 Date: Fri May 29 16:53:59 2020 +0200 tdf#133498 Make native drawing of FormattedField work (again) which had fixed a similar regression elsewhere.) Change-Id: Ie8a4d279a12a1b83a9cf97f1304d84214b3a2a2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118568 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> (cherry picked from commit cdc752fd5e5b3bf97043b9542867d84827614f2c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118503 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index eb37d4137419..34bcdb6d12f4 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -54,6 +54,7 @@ static css::uno::Reference< css::awt::XWindowPeer > CreateXWindow( vcl::Window c case WindowType::METRICBOX: case WindowType::COMBOBOX: return new VCLXComboBox; case WindowType::SPINFIELD: + case WindowType::FORMATTEDFIELD: case WindowType::CURRENCYFIELD: return new VCLXNumericField; case WindowType::DATEFIELD: return new VCLXDateField; case WindowType::MULTILINEEDIT: commit 82bcba9f7fb051392c1de6d599a59835de99750e Author: Eike Rathke <[email protected]> AuthorDate: Mon Jul 5 12:06:27 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:53 2021 +0200 Resolves: tdf#143165 Date input must match separator, D,M,Y not part of Change-Id: Iae464fd0fc6c480b9a16ccb2f8eb635812c6eeff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118408 Reviewed-by: Eike Rathke <[email protected]> Tested-by: Jenkins (cherry picked from commit 89a3caee73c476133af804d9a0a650e72e711d95) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118421 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index edf75a004244..87c64df62c2a 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -1263,6 +1263,17 @@ static bool lcl_IsSignedYearSep( const OUString& rStr, const OUString& rPat, sal } +/** Length of separator usually is 1 but theoretically could be anything. */ +static sal_Int32 lcl_getPatternSeparatorLength( const OUString& rPat, sal_Int32 nPat ) +{ + sal_Int32 nSep = nPat; + sal_Unicode c; + while (nSep < rPat.getLength() && (c = rPat[nSep]) != 'D' && c != 'M' && c != 'Y') + ++nSep; + return nSep - nPat; +} + + bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) { if (nAcceptedDatePattern >= -1) @@ -1383,8 +1394,11 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) bOk = !IsNum[nNext]; if (bOk) { + const sal_Int32 nSepLen = lcl_getPatternSeparatorLength( rPat, nPat); + // Non-numeric input must match separator exactly to be + // accepted as such. const sal_Int32 nLen = sStrArray[nNext].getLength(); - bOk = (rPat.indexOf( sStrArray[nNext], nPat) == nPat); + bOk = (nLen == nSepLen && rPat.indexOf( sStrArray[nNext], nPat) == nPat); if (bOk) { nPat += nLen - 1; @@ -1503,8 +1517,9 @@ bool ImpSvNumberInputScan::SkipDatePatternSeparator( sal_uInt16 nParticle, sal_I default: if (nNext == nParticle) { + const sal_Int32 nSepLen = lcl_getPatternSeparatorLength( rPat, nPat); const sal_Int32 nLen = sStrArray[nNext].getLength(); - bool bOk = (rPat.indexOf( sStrArray[nNext], nPat) == nPat); + bool bOk = (nLen == nSepLen && rPat.indexOf( sStrArray[nNext], nPat) == nPat); if (!bOk) { bOk = lcl_IsSignedYearSep( sStrArray[nNext], rPat, nPat); commit bc08f088402d052933a3a44eed5a96941cfeaa4f Author: Bjoern Michaelsen <[email protected]> AuthorDate: Sun Jul 4 11:58:07 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:53 2021 +0200 tdf#140506: fix repeated table header switching this fixes regression from f899c28f210c6565b7227d7665d449f194d2af8e, which asssumed all frames to be listening to the Notifier of the format. That is not (yet) the case. Change-Id: Ib684842c571823eeb72824196ccfdb1df8179e85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118370 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 25e09087d8e2c5cecca1d548c69a263c7bf8b7ca) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118418 diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index f30ebce4c0f8..cd87b35902ca 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2897,9 +2897,9 @@ void SwDoc::SetRowsToRepeat( SwTable &rTable, sal_uInt16 nSet ) std::make_unique<SwUndoTableHeadline>(rTable, rTable.GetRowsToRepeat(), nSet) ); } + rTable.SetRowsToRepeat(nSet); const SwMsgPoolItem aChg(RES_TBLHEADLINECHG); - rTable.SetRowsToRepeat( nSet ); - rTable.GetFrameFormat()->GetNotifier().Broadcast(sw::LegacyModifyHint(&aChg, &aChg)); + rTable.GetFrameFormat()->CallSwClientNotify(sw::LegacyModifyHint(&aChg, &aChg)); getIDocumentState().SetModified(); } commit 60d24fccf2c2dfc3f2aa547f2cb09d5d09cdd90c Author: Tünde Tóth <[email protected]> AuthorDate: Tue Jun 29 13:58:59 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:43:23 2021 +0200 tdf#140431 XLSX export: fix double file:// prefix Regression from commit: fc58d7d65b9683db7b7632137126680b8483f6c5 (tdf#129969 XLSX export: file URLs need IURI encoding) Change-Id: I5bfb0ef9ba7fe82cd3f4d0e0b3fdcf8f705cba64 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118090 Tested-by: Jenkins Tested-by: László Németh <[email protected]> Reviewed-by: László Németh <[email protected]> (cherry picked from commit 67e2cc17bad3fd7aacb94da47f9024b731434a84) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118293 Tested-by: Gabor Kelemen <[email protected]> Reviewed-by: Gabor Kelemen <[email protected]> (cherry picked from commit 5a47501ec5856f32d652d492e9e144e64642b452) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118299 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/qa/unit/data/xlsx/129969-min.xlsx b/sc/qa/unit/data/xlsx/129969-min.xlsx new file mode 100644 index 000000000000..b6fd8e9e2069 Binary files /dev/null and b/sc/qa/unit/data/xlsx/129969-min.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index f75b81c1a277..60dff1c1a847 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -284,6 +284,8 @@ public: void testCheckboxFormControlXlsxExport(); void testButtonFormControlXlsxExport(); void testInvalidNamedRange(); + void testTdf140431(); + CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -466,6 +468,7 @@ public: CPPUNIT_TEST(testCheckboxFormControlXlsxExport); CPPUNIT_TEST(testButtonFormControlXlsxExport); CPPUNIT_TEST(testInvalidNamedRange); + CPPUNIT_TEST(testTdf140431); CPPUNIT_TEST_SUITE_END(); @@ -5913,6 +5916,23 @@ void ScExportTest::testInvalidNamedRange() CPPUNIT_ASSERT(!xNamedRanges->hasByName("myname")); } +void ScExportTest::testTdf140431() +{ + ScDocShellRef xShell = loadDoc(u"129969-min.", FORMAT_XLSX); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScAddress aPos(0, 2, 0); + const EditTextObject* pEditText = rDoc.GetEditText(aPos); + const SvxFieldData* pData = pEditText->GetFieldData(0, 0, text::textfield::Type::URL); + const SvxURLField* pURLData = static_cast<const SvxURLField*>(pData); + CPPUNIT_ASSERT(pURLData->GetURL().startsWith("file://ndhlis")); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 028ad89241d6..a3cd8dfa9e84 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -392,9 +392,9 @@ XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rU for( int i = 0; i < nLevel; ++i ) msTarget = "../" + msTarget; } - else + else if (rRoot.GetOutput() != EXC_OUTPUT_XML_2007) { - // ooxml expects the file:/// part appended ( or at least + // xls expects the file:/// part appended ( or at least // ms2007 does, ms2010 is more tolerant ) msTarget = "file:///" + msTarget; } commit 0c433d0eaa202a39dc05e8ed15312c1fb9086e8f Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 1 21:12:26 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:29 2021 +0200 tdf#143149 fix crash if app exits while print progress is running dismiss the dialog if its parent goes away, but leave the print job running Change-Id: Ic29ee0300a7d9476ad27a2594a555312e30c74f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118254 Tested-by: Jenkins Reviewed-by: Eike Rathke <[email protected]> diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index ed339266256a..9b5b8e2083c3 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -382,7 +382,7 @@ class VCL_DLLPUBLIC PrinterController std::unique_ptr<ImplPrinterControllerData> mpImplData; protected: - PrinterController(const VclPtr<Printer>&, weld::Window*); + PrinterController(const VclPtr<Printer>&, weld::Window* pDialogParent); public: struct MultiPageSetup { @@ -511,6 +511,8 @@ public: bool isShowDialogs() const; bool isDirectPrint() const; + void dialogsParentClosing(); + // implementation details, not usable outside vcl // don't use outside vcl. Some of these are exported for // the benefit of vcl's plugins. diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 796a505ed8d4..7ec660c7aff6 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -174,6 +174,7 @@ void SfxPrinterController::Notify( SfxBroadcaster& , const SfxHint& rHint ) { EndListening(*mpViewShell); EndListening(*mpObjectShell); + dialogsParentClosing(); mpViewShell = nullptr; mpObjectShell = nullptr; } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 1cc0ce8c1c93..8b00e2d9f85b 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -779,6 +779,17 @@ weld::Window* PrinterController::getWindow() const return mpImplData->mpWindow; } +void PrinterController::dialogsParentClosing() +{ + mpImplData->mpWindow = nullptr; + if (mpImplData->mxProgress) + { + // close the dialog without doing anything, just get rid of it + mpImplData->mxProgress->response(RET_OK); + mpImplData->mxProgress.reset(); + } +} + void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter ) { VclPtr<Printer> xPrinter = mpImplData->mxPrinter; commit 7452a790819fc17d7bad16793be26ac7fc8323b3 Author: Eike Rathke <[email protected]> AuthorDate: Thu Jul 1 15:46:01 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:29 2021 +0200 Resolves: tdf#138432 Use locale's CharClass to parse numeric i18n context Change-Id: I1828f1b6f93228cd517a6a7bd9ae36584bd801a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118226 Reviewed-by: Eike Rathke <[email protected]> Tested-by: Jenkins (cherry picked from commit d703131d063c41b8baca01830c4c9806f99ab7d2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118190 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 7dd0ca5374a7..274205f5734b 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2751,6 +2751,10 @@ Label_MaskStateMachine: cGroupSep != cArrayColSep && cGroupSep != cArrayRowSep && cGroupSep != cDecSep && cGroupSep != cDecSepAlt && cGroupSep != cSheetPrefix && cGroupSep != cSheetSep); + // If a numeric context triggered bi18n then use the default locale's + // CharClass, this may accept group separator as well. + const CharClass* pMyCharClass = (ScGlobal::getCharClassPtr()->isDigit( OUString(pStart[nSrcPos]), 0) ? + ScGlobal::getCharClassPtr() : pCharClass); OUStringBuffer aSymbol; mnRangeOpPosInSymbol = -1; FormulaError nErr = FormulaError::NONE; @@ -2761,7 +2765,7 @@ Label_MaskStateMachine: if ( pStart[nSrcPos] == cSheetPrefix && pStart[nSrcPos+1] == '\'' ) aSymbol.append(pStart[nSrcPos++]); - ParseResult aRes = pConv->parseAnyToken( aFormula, nSrcPos, pCharClass, bGroupSeparator); + ParseResult aRes = pConv->parseAnyToken( aFormula, nSrcPos, pMyCharClass, bGroupSeparator); if ( !aRes.TokenType ) { commit 08640f4c2eb1e008cf51300299cbc41f1a3d5b7f Author: Noel Grandin <[email protected]> AuthorDate: Thu Jun 17 13:38:07 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:28 2021 +0200 fix potential write-after-free in RecentDocsView spotted while running a valgrind session Change-Id: I32c55ae2cc4b2d5abedca24c2f747aaa4183b3d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117382 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> (cherry picked from commit 2176084192dc46a1ef5d6dd79effa5cd5d1dcca2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118256 diff --git a/sfx2/inc/recentdocsview.hxx b/sfx2/inc/recentdocsview.hxx index c8db9bc3c043..a6e2f86a155a 100644 --- a/sfx2/inc/recentdocsview.hxx +++ b/sfx2/inc/recentdocsview.hxx @@ -17,6 +17,7 @@ #include <com/sun/star/util/URL.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +struct ImplSVEvent; namespace com::sun::star::frame { class XDispatch; } namespace sfx2 @@ -92,7 +93,7 @@ private: bool isAcceptedFile(const OUString &rURL) const; - DECL_STATIC_LINK( RecentDocsView, ExecuteHdl_Impl, void*, void ); + DECL_LINK( ExecuteHdl_Impl, void*, void ); tools::Long mnItemMaxSize; size_t mnLastMouseDownItem; @@ -103,6 +104,7 @@ private: OUString maWelcomeLine2; sfx2::LoadRecentFile* mpLoadRecentFile; + ImplSVEvent* m_nExecuteHdlId; }; } // namespace sfx2 diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx index 958785a12394..e74c354bef92 100644 --- a/sfx2/source/control/recentdocsview.cxx +++ b/sfx2/source/control/recentdocsview.cxx @@ -130,6 +130,7 @@ RecentDocsView::RecentDocsView(std::unique_ptr<weld::ScrolledWindow> xWindow, st , maWelcomeLine1(SfxResId(STR_WELCOME_LINE1)) , maWelcomeLine2(SfxResId(STR_WELCOME_LINE2)) , mpLoadRecentFile(nullptr) + , m_nExecuteHdlId(nullptr) { tools::Rectangle aScreen = Application::GetScreenPosSizePixel(Application::GetDisplayBuiltInScreen()); mnItemMaxSize = std::min(aScreen.GetWidth(),aScreen.GetHeight()) > 800 ? 256 : 192; @@ -148,6 +149,8 @@ RecentDocsView::RecentDocsView(std::unique_ptr<weld::ScrolledWindow> xWindow, st RecentDocsView::~RecentDocsView() { + Application::RemoveUserEvent(m_nExecuteHdlId); + m_nExecuteHdlId = nullptr; if (mpLoadRecentFile) { mpLoadRecentFile->pView = nullptr; @@ -401,7 +404,7 @@ void RecentDocsView::PostLoadRecentUsedFile(LoadRecentFile* pLoadRecentFile) { assert(!mpLoadRecentFile); mpLoadRecentFile = pLoadRecentFile; - Application::PostUserEvent(LINK(nullptr, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile); + m_nExecuteHdlId = Application::PostUserEvent(LINK(this, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile); } void RecentDocsView::DispatchedLoadRecentUsedFile() @@ -409,8 +412,9 @@ void RecentDocsView::DispatchedLoadRecentUsedFile() mpLoadRecentFile = nullptr; } -IMPL_STATIC_LINK( RecentDocsView, ExecuteHdl_Impl, void*, p, void ) +IMPL_LINK( RecentDocsView, ExecuteHdl_Impl, void*, p, void ) { + m_nExecuteHdlId = nullptr; LoadRecentFile* pLoadRecentFile = static_cast<LoadRecentFile*>(p); try { commit 5671fad3b07475761c937ffdbb524f5b2273f7d9 Author: Julien Nabet <[email protected]> AuthorDate: Wed Jun 30 22:55:46 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:28 2021 +0200 tdf#143081: fix Basic Replace() function crashes LO 0x00007f19c0aa6e57 in rtl::OUStringBuffer::append(char16_t const*, int) (this=0x7fff100d0748, str=0x6f6f46a u"晦饖香©", len=-1) at include/rtl/ustrbuf.hxx:659 0x00007f19c0c3c8a8 in SbRtl_Replace(StarBASIC*, SbxArray&, bool) (rPar=...) at basic/source/runtime/methods.cxx:1321 see bt here: https://bugs.documentfoundation.org/attachment.cgi?id=173298 Calling xCharClass->toUpper may change words, eg: "Straße" becomes "Strasse" so the length of the word increases. In brief, we want to use the length of aSrcStr not aExpStr Change-Id: Ia291d47a2021efc7dd9162ca5cc72b7940fdd71e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118202 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> (cherry picked from commit 4a0b40f1be9f6773c8ebc5331c257911a76a5cee) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118178 Reviewed-by: Xisco Fauli <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118229 diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 1a598490d68a..ebd48c9cc473 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1276,8 +1276,6 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool) const OUString aExpStr = rPar.Get32(1)->GetOUString(); OUString aFindStr = rPar.Get32(2)->GetOUString(); const OUString aReplaceStr = rPar.Get32(3)->GetOUString(); - const sal_Int32 nExpStrLen = aExpStr.getLength(); - const sal_Int32 nFindStrLen = aFindStr.getLength(); OUString aSrcStr(aExpStr); if (bCaseInsensitive) @@ -1288,10 +1286,12 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool) aSrcStr = xCharClass->toUpper(aSrcStr, 0, aSrcStr.getLength(), rLocale); aFindStr = xCharClass->toUpper(aFindStr, 0, aFindStr.getLength(), rLocale); } + const sal_Int32 nSrcStrLen = aSrcStr.getLength(); + const sal_Int32 nFindStrLen = aFindStr.getLength(); // Note: the result starts from lStartPos, removing everything to the left. See i#94895. - sal_Int32 nPrevPos = std::min(lStartPos - 1, nExpStrLen); - OUStringBuffer sResult(nExpStrLen - nPrevPos); + sal_Int32 nPrevPos = std::min(lStartPos - 1, nSrcStrLen); + OUStringBuffer sResult(nSrcStrLen - nPrevPos); sal_Int32 nCounts = 0; while (lCount == -1 || lCount > nCounts) { @@ -1308,7 +1308,7 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool) break; } } - sResult.append(aExpStr.getStr() + nPrevPos, nExpStrLen - nPrevPos); + sResult.append(aExpStr.getStr() + nPrevPos, nSrcStrLen - nPrevPos); rPar.Get32(0)->PutString(sResult.makeStringAndClear()); } commit 8d7f8273d02597d8d20899a2153339287e38bd56 Author: Michael Stahl <[email protected]> AuthorDate: Wed Jun 30 13:26:59 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:27 2021 +0200 sfx2: try to fix lifecycle of SfxOfficeDispatch This can be created either from the global SfxApplication, or from a SfxViewFrame. Particularly in the latter case, the SfxDispatcher and SfxBindings members are owned by SfxViewFrame, so in case that is destroyed, the SfxOfficeDispatch must clear its pointers. It looks like the member pointers are checked before access already everywhere, so just listen at the SfxViewFrame. Change-Id: If08825734e94dd54e32cb77546684fd583c336ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118162 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 7cbd6d768d282077053c354254315f3dc89bf254) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118195 Tested-by: Jenkins diff --git a/framework/qa/cppunit/data/empty.fodp b/framework/qa/cppunit/data/empty.fodp new file mode 100644 index 000000000000..3c2a4cf2cda5 --- /dev/null +++ b/framework/qa/cppunit/data/empty.fodp @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.presentation"><office:body><office:presentation><draw:page/></office:presentation></office:body></office:document> diff --git a/framework/qa/cppunit/dispatchtest.cxx b/framework/qa/cppunit/dispatchtest.cxx index 0dd6b4cfc33d..2e2efec4693a 100644 --- a/framework/qa/cppunit/dispatchtest.cxx +++ b/framework/qa/cppunit/dispatchtest.cxx @@ -15,6 +15,7 @@ #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> #include <com/sun/star/frame/XInterceptorInfo.hpp> +#include <com/sun/star/util/URLTransformer.hpp> #include <comphelper/processfactory.hxx> #include <rtl/ref.hxx> @@ -201,6 +202,37 @@ CPPUNIT_TEST_FIXTURE(DispatchTest, testInterception) // This was 1: MyInterceptor::queryDispatch() was called for .uno:Italic. CPPUNIT_ASSERT_EQUAL(0, pInterceptor->getUnexpected()); } + +constexpr OUStringLiteral DATA_DIRECTORY = u"/framework/qa/cppunit/data/"; + +CPPUNIT_TEST_FIXTURE(DispatchTest, testSfxOfficeDispatchDispose) +{ + // this test doesn't work with a new document because of aURL.Main check in SfxBaseController::dispatch() + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.fodp", + "com.sun.star.presentation.PresentationDocument"); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + uno::Reference<frame::XController> xController(xModel->getCurrentController()); + CPPUNIT_ASSERT(xController.is()); + uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFrame.is()); + + uno::Reference<util::XURLTransformer> xParser(util::URLTransformer::create(mxComponentContext)); + util::URL url; + url.Complete = xModel->getURL() + "#dummy"; + xParser->parseStrict(url); + + uno::Reference<frame::XDispatch> xDisp(xFrame->queryDispatch(url, "", 0)); + CPPUNIT_ASSERT(xDisp.is()); + + mxComponent->dispose(); + + util::URL urlSlot; + urlSlot.Complete = "slot:5598"; + xParser->parseStrict(urlSlot); + // crashed with UAF + xDisp->dispatch(urlSlot, {}); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sfx2/inc/unoctitm.hxx b/sfx2/inc/unoctitm.hxx index c180150325cc..7f6bf815e1f9 100644 --- a/sfx2/inc/unoctitm.hxx +++ b/sfx2/inc/unoctitm.hxx @@ -25,6 +25,7 @@ #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weakref.hxx> +#include <svl/lstner.hxx> #include <sfx2/ctrlitem.hxx> #include <osl/mutex.hxx> @@ -101,7 +102,9 @@ public: SfxDispatcher* GetDispatcher_Impl(); }; -class SfxDispatchController_Impl : public SfxControllerItem +class SfxDispatchController_Impl + : public SfxControllerItem + , public SfxListener { css::util::URL aDispatchURL; SfxDispatcher* pDispatcher; @@ -126,6 +129,8 @@ public: const css::util::URL& rURL ); virtual ~SfxDispatchController_Impl() override; + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; + static OUString getSlaveCommand( const css::util::URL& rURL ); void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, SfxSlotServer const * pServ ); diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 256ed9f744b3..cad127e1c89d 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -322,6 +322,27 @@ SfxDispatchController_Impl::SfxDispatchController_Impl( BindInternal_Impl( nSlot, pBindings ); pBindings->LEAVEREGISTRATIONS(); } + assert(pDispatcher); + assert(SfxApplication::Get()->GetAppDispatcher_Impl() == pDispatcher + || pDispatcher->GetFrame() != nullptr); + if (pDispatcher->GetFrame()) + { + StartListening(*pDispatcher->GetFrame()); + } + else + { + StartListening(*SfxApplication::Get()); + } +} + +void SfxDispatchController_Impl::Notify(SfxBroadcaster& rBC, SfxHint const& rHint) +{ + if (rHint.GetId() == SfxHintId::Dying) + { // both pBindings and pDispatcher are dead if SfxViewFrame is dead + pBindings = nullptr; + pDispatcher = nullptr; + EndListening(rBC); + } } SfxDispatchController_Impl::~SfxDispatchController_Impl() commit 6c8280e7209a1590a6e5e72fd7d0a99600d0ce7b Author: Caolán McNamara <[email protected]> AuthorDate: Tue Jun 29 11:20:40 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:27 2021 +0200 Related: tdf#143088 return early on notification from frozen editengine processing EE_NOTIFY_PROCESSNOTIFICATIONS from an EditEngine with an UpdateMode mode of false will just to on to cause AccessibleTextHelper_Impl::GetTextForwarder to throw an exception as a Frozen EditEngine is considered Invalid so return early instead Change-Id: I86f9647b7bf839cf3c7cf2f029be8c7c5aeef1f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118071 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index ec606790ac0a..052bd8f4d8f9 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -818,6 +818,19 @@ WeldTextForwarder::~WeldTextForwarder() IMPL_LINK(WeldTextForwarder, NotifyHdl, EENotify&, rNotify, void) { + if (EditEngine* pEditEngine = m_rEditAcc.GetEditEngine()) + { + if (rNotify.eNotificationType == EE_NOTIFY_PROCESSNOTIFICATIONS + && !pEditEngine->GetUpdateMode()) + { + // tdf#143088 an UpdateMode of false will just to on to cause + // AccessibleTextHelper_Impl::GetTextForwarder to throw an + // exception as a Frozen EditEngine is considered Invalid so return + // early instead + return; + } + } + ::std::unique_ptr<SfxHint> aHint = SvxEditSourceHelper::EENotification2Hint(&rNotify); if (aHint) m_rEditSource.GetBroadcaster().Broadcast(*aHint); commit 4f55c5f37a62c2222dd35b17d0959ccf51fb617b Author: Caolán McNamara <[email protected]> AuthorDate: Tue Jun 29 12:13:19 2021 +0100 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:26 2021 +0200 Related: tdf#143088 listen to DefaultWindow for Settings changed having multiple Application::EventListener are expensive while a Window::EventListener is cheap and in this document there are thousands of comments so having thousands of EventListeners is problematic. Change-Id: I64fd12e4bcb8e4fd131effe94e6882e54cfcaf19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118084 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 8a630ee62055..7e691e458d08 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -13853,7 +13853,7 @@ private: GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget); return pThis->signal_scroll(pEvent); } - DECL_LINK(SettingsChangedHdl, VclSimpleEvent&, void); + DECL_LINK(SettingsChangedHdl, VclWindowEvent&, void); public: GtkInstanceDrawingArea(GtkDrawingArea* pDrawingArea, GtkInstanceBuilder* pBuilder, const a11yref& rA11y, bool bTakeOwnership) : GtkInstanceWidget(GTK_WIDGET(pDrawingArea), pBuilder, bTakeOwnership) @@ -13871,7 +13871,7 @@ public: g_object_set_data(G_OBJECT(m_pDrawingArea), "g-lo-GtkInstanceDrawingArea", this); m_xDevice->EnableRTL(get_direction()); - Application::AddEventListener(LINK(this, GtkInstanceDrawingArea, SettingsChangedHdl)); + ImplGetDefaultWindow()->AddEventListener(LINK(this, GtkInstanceDrawingArea, SettingsChangedHdl)); } AtkObject* GetAtkObject(AtkObject* pDefaultAccessible) @@ -14004,7 +14004,7 @@ public: virtual ~GtkInstanceDrawingArea() override { - Application::RemoveEventListener(LINK(this, GtkInstanceDrawingArea, SettingsChangedHdl)); + ImplGetDefaultWindow()->RemoveEventListener(LINK(this, GtkInstanceDrawingArea, SettingsChangedHdl)); g_object_steal_data(G_OBJECT(m_pDrawingArea), "g-lo-GtkInstanceDrawingArea"); if (m_pAccessible) @@ -14036,12 +14036,12 @@ public: } }; -IMPL_LINK(GtkInstanceDrawingArea, SettingsChangedHdl, VclSimpleEvent&, rEvent, void) +IMPL_LINK(GtkInstanceDrawingArea, SettingsChangedHdl, VclWindowEvent&, rEvent, void) { - if (rEvent.GetId() != VclEventId::ApplicationDataChanged) + if (rEvent.GetId() != VclEventId::WindowDataChanged) return; - DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData()); + DataChangedEvent* pData = static_cast<DataChangedEvent*>(rEvent.GetData()); if (pData->GetType() == DataChangedEventType::SETTINGS) signal_style_updated(); } commit c4b615501e9675cbe6d0c467194d0cb2e90b70f3 Author: Thorsten Wagner <[email protected]> AuthorDate: Mon Jun 28 22:36:56 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Sun Jul 11 13:41:26 2021 +0200 tdf#142061 Consider window scaling for XOR drawing on macOS Change-Id: I4261334b6d2d2f34fe3452cc870aba6f88c4069e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118036 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> Tested-by: Adolfo Jayme Barrientos <[email protected]> diff --git a/vcl/ios/salios.cxx b/vcl/ios/salios.cxx index d1552b8b0bbb..4c8c99b4c4a4 100644 --- a/vcl/ios/salios.cxx +++ b/vcl/ios/salios.cxx @@ -331,6 +331,153 @@ void AquaSalGraphics::SetVirDevGraphics(CGLayerHolder const & rLayer, CGContextR SetState(); } +void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth, + CGContextRef xTargetContext, CGLayerRef xTargetLayer ) +{ + SAL_INFO( "vcl.quartz", "XorEmulation::SetTarget() this=" << this << + " (" << nWidth << "x" << nHeight << ") depth=" << nTargetDepth << + " context=" << xTargetContext << " layer=" << xTargetLayer ); + + // prepare to replace old mask+temp context + if( m_xMaskContext ) + { + // cleanup the mask context + CGContextRelease( m_xMaskContext ); + delete[] m_pMaskBuffer; + m_xMaskContext = nullptr; + m_pMaskBuffer = nullptr; + + // cleanup the temp context if needed + if( m_xTempContext ) + { + CGContextRelease( m_xTempContext ); + delete[] m_pTempBuffer; + m_xTempContext = nullptr; + m_pTempBuffer = nullptr; + } + } + + // return early if there is nothing more to do + if( !xTargetContext ) + { + return; + } + // retarget drawing operations to the XOR mask + m_xTargetLayer = xTargetLayer; + m_xTargetContext = xTargetContext; + + // prepare creation of matching CGBitmaps + CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace; + CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst; + int nBitDepth = nTargetDepth; + if( !nBitDepth ) + { + nBitDepth = 32; + } + int nBytesPerRow = 4; + const size_t nBitsPerComponent = (nBitDepth == 16) ? 5 : 8; + if( nBitDepth <= 8 ) + { + aCGColorSpace = GetSalData()->mxGraySpace; + aCGBmpInfo = kCGImageAlphaNone; + nBytesPerRow = 1; + } + nBytesPerRow *= nWidth; + m_nBufferLongs = (nHeight * nBytesPerRow + sizeof(sal_uLong)-1) / sizeof(sal_uLong); + + // create a XorMask context + m_pMaskBuffer = new sal_uLong[ m_nBufferLongs ]; + m_xMaskContext = CGBitmapContextCreate( m_pMaskBuffer, + nWidth, nHeight, + nBitsPerComponent, nBytesPerRow, + aCGColorSpace, aCGBmpInfo ); + SAL_WARN_IF( !m_xMaskContext, "vcl.quartz", "mask context creation failed" ); + + // reset the XOR mask to black + memset( m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong) ); + + // a bitmap context will be needed for manual XORing + // create one unless the target context is a bitmap context + if( nTargetDepth ) + { + m_pTempBuffer = static_cast<sal_uLong*>(CGBitmapContextGetData( m_xTargetContext )); + } + if( !m_pTempBuffer ) + { + // create a bitmap context matching to the target context + m_pTempBuffer = new sal_uLong[ m_nBufferLongs ]; + m_xTempContext = CGBitmapContextCreate( m_pTempBuffer, + nWidth, nHeight, + nBitsPerComponent, nBytesPerRow, + aCGColorSpace, aCGBmpInfo ); + SAL_WARN_IF( !m_xTempContext, "vcl.quartz", "temp context creation failed" ); + } + + // initialize XOR mask context for drawing + CGContextSetFillColorSpace( m_xMaskContext, aCGColorSpace ); + CGContextSetStrokeColorSpace( m_xMaskContext, aCGColorSpace ); + CGContextSetShouldAntialias( m_xMaskContext, false ); + + // improve the XorMask's XOR emulation a little + // NOTE: currently only enabled for monochrome contexts + if( aCGColorSpace == GetSalData()->mxGraySpace ) + { + CGContextSetBlendMode( m_xMaskContext, kCGBlendModeDifference ); + } + // initialize the transformation matrix to the drawing target + const CGAffineTransform aCTM = CGContextGetCTM( xTargetContext ); + CGContextConcatCTM( m_xMaskContext, aCTM ); + if( m_xTempContext ) + { + CGContextConcatCTM( m_xTempContext, aCTM ); + } + // initialize the default XorMask graphics state + CGContextSaveGState( m_xMaskContext ); +} + +bool XorEmulation::UpdateTarget() +{ + SAL_INFO( "vcl.quartz", "XorEmulation::UpdateTarget() this=" << this ); + + if( !IsEnabled() ) + { + return false; + } + // update the temp bitmap buffer if needed + if( m_xTempContext ) + { + SAL_WARN_IF( m_xTargetContext == nullptr, "vcl.quartz", "Target layer is NULL"); + CGContextDrawLayerAtPoint( m_xTempContext, CGPointZero, m_xTargetLayer ); + } + // do a manual XOR with the XorMask + // this approach suffices for simple color manipulations + // and also the complex-clipping-XOR-trick used in metafiles + const sal_uLong* pSrc = m_pMaskBuffer; + sal_uLong* pDst = m_pTempBuffer; + for( int i = m_nBufferLongs; --i >= 0;) + { + *(pDst++) ^= *(pSrc++); + } + // write back the XOR results to the target context + if( m_xTempContext ) + { + CGImageRef xXorImage = CGBitmapContextCreateImage( m_xTempContext ); + const int nWidth = static_cast<int>(CGImageGetWidth( xXorImage )); + const int nHeight = static_cast<int>(CGImageGetHeight( xXorImage )); + // TODO: update minimal changerect + const CGRect aFullRect = CGRectMake(0, 0, nWidth, nHeight); + CGContextDrawImage( m_xTargetContext, aFullRect, xXorImage ); + CGImageRelease( xXorImage ); + } + + // reset the XorMask to black again + // TODO: not needed for last update + memset( m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong) ); + + // TODO: return FALSE if target was not changed + return true; +} + /// From salvd.cxx void AquaSalVirtualDevice::Destroy() diff --git a/vcl/osx/salmacos.cxx b/vcl/osx/salmacos.cxx index 24a4b5b5a4d6..e6573e101b61 100644 --- a/vcl/osx/salmacos.cxx +++ b/vcl/osx/salmacos.cxx @@ -285,6 +285,158 @@ void AquaSalGraphics::SetVirDevGraphics(CGLayerHolder const &rLayer, CGContextRe " (" << mnWidth << "x" << mnHeight << ") fScale=" << fScale << " mnBitmapDepth=" << mnBitmapDepth); } +void XorEmulation::SetTarget(int nWidth, int nHeight, int nTargetDepth, CGContextRef xTargetContext, CGLayerRef xTargetLayer) +{ + SAL_INFO("vcl.quartz", "XorEmulation::SetTarget() this=" << this << + " (" << nWidth << "x" << nHeight << ") depth=" << nTargetDepth << + " context=" << xTargetContext << " layer=" << xTargetLayer); + + // Prepare to replace old mask and temporary context + + if (m_xMaskContext) + { + CGContextRelease(m_xMaskContext); + delete[] m_pMaskBuffer; + m_xMaskContext = nullptr; + m_pMaskBuffer = nullptr; + if (m_xTempContext) + { + CGContextRelease(m_xTempContext); + delete[] m_pTempBuffer; + m_xTempContext = nullptr; + m_pTempBuffer = nullptr; + } + } + + // Return early if there is nothing more to do + + if (!xTargetContext) + return; + + // Retarget drawing operations to the XOR mask + + m_xTargetLayer = xTargetLayer; + m_xTargetContext = xTargetContext; + + // Prepare creation of matching bitmaps + + CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace; + CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst; + int nBitDepth = nTargetDepth; + if (!nBitDepth) + nBitDepth = 32; + int nBytesPerRow = 4; + const size_t nBitsPerComponent = (nBitDepth == 16) ? 5 : 8; + if (nBitDepth <= 8) + { + aCGColorSpace = GetSalData()->mxGraySpace; + aCGBmpInfo = kCGImageAlphaNone; + nBytesPerRow = 1; + } + float fScale = AquaSalGraphics::GetWindowScaling(); + size_t nScaledWidth = nWidth * fScale; + size_t nScaledHeight = nHeight * fScale; + nBytesPerRow *= nScaledWidth; + m_nBufferLongs = (nScaledHeight * nBytesPerRow + sizeof(sal_uLong) - 1) / sizeof(sal_uLong); + + // Create XOR mask context + + m_pMaskBuffer = new sal_uLong[m_nBufferLongs]; + m_xMaskContext = CGBitmapContextCreate(m_pMaskBuffer, nScaledWidth, nScaledHeight, + nBitsPerComponent, nBytesPerRow, aCGColorSpace, aCGBmpInfo); + SAL_WARN_IF(!m_xMaskContext, "vcl.quartz", "mask context creation failed"); + + // Reset XOR mask to black + + memset(m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong)); + + // Create bitmap context for manual XOR unless target context is a bitmap context + + if (nTargetDepth) + m_pTempBuffer = static_cast<sal_uLong*>(CGBitmapContextGetData(m_xTargetContext)); + if (!m_pTempBuffer) + { + m_pTempBuffer = new sal_uLong[m_nBufferLongs]; + m_xTempContext = CGBitmapContextCreate(m_pTempBuffer, nScaledWidth, nScaledHeight, + nBitsPerComponent, nBytesPerRow, aCGColorSpace, aCGBmpInfo); + SAL_WARN_IF(!m_xTempContext, "vcl.quartz", "temp context creation failed"); + } + + // Initialize XOR mask context for drawing + + CGContextSetFillColorSpace(m_xMaskContext, aCGColorSpace); + CGContextSetStrokeColorSpace(m_xMaskContext, aCGColorSpace); + CGContextSetShouldAntialias(m_xMaskContext, false); + + // Improve XOR emulation for monochrome contexts + + if (aCGColorSpace == GetSalData()->mxGraySpace) + CGContextSetBlendMode(m_xMaskContext, kCGBlendModeDifference); + + // Initialize XOR mask transformation matrix and apply scale matrix to consider layer scaling + + const CGAffineTransform aCTM = CGContextGetCTM(xTargetContext); + CGContextConcatCTM(m_xMaskContext, aCTM); + if (m_xTempContext) + { + CGContextConcatCTM( m_xTempContext, aCTM ); + CGContextScaleCTM(m_xTempContext, 1 / fScale, 1 / fScale); + } + CGContextSaveGState(m_xMaskContext); +} + +bool XorEmulation::UpdateTarget() +{ + SAL_INFO("vcl.quartz", "XorEmulation::UpdateTarget() this=" << this); + + if (!IsEnabled()) + return false; + + // Update temporary bitmap buffer + + if (m_xTempContext) + { + SAL_WARN_IF(m_xTargetContext == nullptr, "vcl.quartz", "Target layer is NULL"); + CGContextDrawLayerAtPoint(m_xTempContext, CGPointZero, m_xTargetLayer); + } + + // XOR using XOR mask (sufficient for simple color manipulations as well as for complex XOR clipping used in metafiles) + + const sal_uLong *pSrc = m_pMaskBuffer; + sal_uLong *pDst = m_pTempBuffer; + for (int i = m_nBufferLongs; --i >= 0;) + *(pDst++) ^= *(pSrc++); + + // Write back XOR results to target context + + if (m_xTempContext) + { + CGImageRef xXorImage = CGBitmapContextCreateImage(m_xTempContext); + size_t nWidth = CGImageGetWidth(xXorImage); + size_t nHeight = CGImageGetHeight(xXorImage); + + // Set scale matrix of target context to consider layer scaling and update target context + // TODO: Update minimal change rectangle + + const CGRect aFullRect = CGRectMake(0, 0, nWidth, nHeight); + CGContextSaveGState(m_xTargetContext); + float fScale = AquaSalGraphics::GetWindowScaling(); + CGContextScaleCTM(m_xTargetContext, 1 / fScale, 1 / fScale); + CGContextDrawImage(m_xTargetContext, aFullRect, xXorImage); + CGContextRestoreGState(m_xTargetContext); + CGImageRelease(xXorImage); + } + + // Reset XOR mask to black again + // TODO: Not needed for last update + + memset(m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong)); + + // TODO: Return FALSE if target was not changed + + return true; +} + // From salvd.cxx void AquaSalVirtualDevice::Destroy() diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index bbfe185b73d2..e393659658d6 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -1544,151 +1544,4 @@ XorEmulation::~XorEmulation() SetTarget( 0, 0, 0, nullptr, nullptr ); } -void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth, - CGContextRef xTargetContext, CGLayerRef xTargetLayer ) -{ - SAL_INFO( "vcl.quartz", "XorEmulation::SetTarget() this=" << this << - " (" << nWidth << "x" << nHeight << ") depth=" << nTargetDepth << - " context=" << xTargetContext << " layer=" << xTargetLayer ); - - // prepare to replace old mask+temp context - if( m_xMaskContext ) - { - // cleanup the mask context - CGContextRelease( m_xMaskContext ); - delete[] m_pMaskBuffer; - m_xMaskContext = nullptr; - m_pMaskBuffer = nullptr; - - // cleanup the temp context if needed - if( m_xTempContext ) - { - CGContextRelease( m_xTempContext ); - delete[] m_pTempBuffer; - m_xTempContext = nullptr; - m_pTempBuffer = nullptr; - } - } - - // return early if there is nothing more to do - if( !xTargetContext ) - { - return; - } - // retarget drawing operations to the XOR mask - m_xTargetLayer = xTargetLayer; - m_xTargetContext = xTargetContext; - - // prepare creation of matching CGBitmaps - CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace; - CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst; - int nBitDepth = nTargetDepth; - if( !nBitDepth ) - { - nBitDepth = 32; - } - int nBytesPerRow = 4; - const size_t nBitsPerComponent = (nBitDepth == 16) ? 5 : 8; - if( nBitDepth <= 8 ) - { - aCGColorSpace = GetSalData()->mxGraySpace; - aCGBmpInfo = kCGImageAlphaNone; - nBytesPerRow = 1; - } - nBytesPerRow *= nWidth; - m_nBufferLongs = (nHeight * nBytesPerRow + sizeof(sal_uLong)-1) / sizeof(sal_uLong); - - // create a XorMask context - m_pMaskBuffer = new sal_uLong[ m_nBufferLongs ]; - m_xMaskContext = CGBitmapContextCreate( m_pMaskBuffer, - nWidth, nHeight, - nBitsPerComponent, nBytesPerRow, - aCGColorSpace, aCGBmpInfo ); - SAL_WARN_IF( !m_xMaskContext, "vcl.quartz", "mask context creation failed" ); - - // reset the XOR mask to black - memset( m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong) ); - - // a bitmap context will be needed for manual XORing - // create one unless the target context is a bitmap context - if( nTargetDepth ) - { - m_pTempBuffer = static_cast<sal_uLong*>(CGBitmapContextGetData( m_xTargetContext )); - } - if( !m_pTempBuffer ) - { - // create a bitmap context matching to the target context - m_pTempBuffer = new sal_uLong[ m_nBufferLongs ]; - m_xTempContext = CGBitmapContextCreate( m_pTempBuffer, - nWidth, nHeight, - nBitsPerComponent, nBytesPerRow, - aCGColorSpace, aCGBmpInfo ); - SAL_WARN_IF( !m_xTempContext, "vcl.quartz", "temp context creation failed" ); - } - - // initialize XOR mask context for drawing - CGContextSetFillColorSpace( m_xMaskContext, aCGColorSpace ); - CGContextSetStrokeColorSpace( m_xMaskContext, aCGColorSpace ); - CGContextSetShouldAntialias( m_xMaskContext, false ); - - // improve the XorMask's XOR emulation a little - // NOTE: currently only enabled for monochrome contexts - if( aCGColorSpace == GetSalData()->mxGraySpace ) - { - CGContextSetBlendMode( m_xMaskContext, kCGBlendModeDifference ); - } - // initialize the transformation matrix to the drawing target - const CGAffineTransform aCTM = CGContextGetCTM( xTargetContext ); - CGContextConcatCTM( m_xMaskContext, aCTM ); - if( m_xTempContext ) - { - CGContextConcatCTM( m_xTempContext, aCTM ); - } - // initialize the default XorMask graphics state - CGContextSaveGState( m_xMaskContext ); -} - -bool XorEmulation::UpdateTarget() -{ - SAL_INFO( "vcl.quartz", "XorEmulation::UpdateTarget() this=" << this ); - - if( !IsEnabled() ) - { - return false; - } - // update the temp bitmap buffer if needed - if( m_xTempContext ) - { - SAL_WARN_IF( m_xTargetContext == nullptr, "vcl.quartz", "Target layer is NULL"); - CGContextDrawLayerAtPoint( m_xTempContext, CGPointZero, m_xTargetLayer ); - } - // do a manual XOR with the XorMask - // this approach suffices for simple color manipulations - // and also the complex-clipping-XOR-trick used in metafiles - const sal_uLong* pSrc = m_pMaskBuffer; - sal_uLong* pDst = m_pTempBuffer; - for( int i = m_nBufferLongs; --i >= 0;) - { - *(pDst++) ^= *(pSrc++); - } - // write back the XOR results to the target context - if( m_xTempContext ) - { - CGImageRef xXorImage = CGBitmapContextCreateImage( m_xTempContext ); - const int nWidth = static_cast<int>(CGImageGetWidth( xXorImage )); - const int nHeight = static_cast<int>(CGImageGetHeight( xXorImage )); - // TODO: update minimal changerect - const CGRect aFullRect = CGRectMake(0, 0, nWidth, nHeight); - CGContextDrawImage( m_xTargetContext, aFullRect, xXorImage ); - CGImageRelease( xXorImage ); - } - - // reset the XorMask to black again - // TODO: not needed for last update - memset( m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong) ); - - // TODO: return FALSE if target was not changed - return true; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
