svx/source/svdraw/svdograf.cxx | 40 ++++++++++++++++++++++--------------- xmloff/source/draw/shapeexport.cxx | 4 +-- 2 files changed, 26 insertions(+), 18 deletions(-)
New commits: commit ed498b64c7b49a57546c05188035b5ac825f0193 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Oct 9 19:57:39 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 10 09:28:46 2025 +0200 we can use GetMimeTypeForXGraphic directly Change-Id: I6b198cf2d4802f787ba4527dc78dd4668b863fa1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192132 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 1a2a1a145e6f..b4af3d21cab1 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -86,6 +86,7 @@ #include <comphelper/classids.hxx> #include <comphelper/memorystream.hxx> +#include <comphelper/graphicmimetype.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -250,8 +251,7 @@ uno::Reference<lang::XComponent> XMLShapeExport::checkForPDFShapeReplacement(con uno::Reference<graphic::XGraphic> xGraphic; xPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; - OUString sOutMimeType; - GetExport().GetGraphicMimeTypeFromStream(xGraphic, sOutMimeType); + OUString sOutMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic); if (sOutMimeType != "application/pdf") return nullptr; commit 0c809263b3f93e9ad23df47ecc48d1ddae2ba0f8 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Oct 9 19:50:11 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 10 09:28:39 2025 +0200 create drawing document directly and work directly with the view-less models's SdrPage Change-Id: I32432ad0479d8d1faa3646d2059e2a7e8b56e26f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192131 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index cb0417a942c5..c7e9e03d6470 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -60,8 +60,7 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> -#include <com/sun/star/frame/XDesktop2.hpp> -#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/frame/XLoadable.hpp> #include <vcl/filter/PDFiumLibrary.hxx> #include <svdpdf.hxx> #include <svx/unoapi.hxx> @@ -380,18 +379,15 @@ css::uno::Reference<css::lang::XComponent> SdrGrafObj::GetReplacementGraphicMode // Create an empty Draw component. uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDesktop2> xDesktop = css::frame::Desktop::create(xContext); - if (!xDesktop) - return nullptr; - uno::Reference<lang::XComponent> xComponent = xDesktop->loadComponentFromURL(u"private:factory/sdraw"_ustr, u"_default"_ustr, 0, {}); - uno::Reference<frame::XModel> xModel(xComponent, uno::UNO_QUERY); + uno::Reference<frame::XModel> xModel(xContext->getServiceManager()->createInstanceWithContext(u"com.sun.star.drawing.DrawingDocument"_ustr, xContext), + uno::UNO_QUERY); if (!xModel) return nullptr; + uno::Reference<css::frame::XLoadable> xModelLoad(xModel, uno::UNO_QUERY); + if (xModelLoad) + xModelLoad->initNew(); uno::Reference<frame::XController> xController(xModel->getCurrentController()); - SfxViewShell* pViewShell = SfxViewShell::Get(xController); - if (!pViewShell) - return nullptr; - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xModel, uno::UNO_QUERY); if (!xDrawPagesSupplier) return nullptr; uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages(); @@ -412,30 +408,25 @@ css::uno::Reference<css::lang::XComponent> SdrGrafObj::GetReplacementGraphicMode aFilter.DoImport(*pSdrPage, 0, rGraphic.getPageNumber(), nullptr); } - if (SdrView* pView = pViewShell->GetDrawView()) - { - if (SdrPageView* pPV = pView->GetSdrPageView()) - { - // Group shapes together, including invisible objects - - rtl::Reference<SdrObject> xGrp(new SdrObjGroup(rSdrModel)); - SdrObjList* pDstList = xGrp->GetSubList(); + // Group shapes together, including invisible objects + size_t nSrcObjCount = pSdrPage->GetObjCount(); + if (!nSrcObjCount) + return xModel; - SdrObjList* pSrcList = pPV->GetObjList(); - size_t i = pSrcList->GetObjCount(); - while (i > 0) - { - --i; - rtl::Reference<SdrObject> xObj(pSrcList->GetObj(i)); - pSrcList->RemoveObject(i); - pDstList->InsertObject(xObj.get(), 0); - } + rtl::Reference<SdrObject> xGrp(new SdrObjGroup(rSdrModel)); + SdrObjList* pDstList = xGrp->GetSubList(); - pSrcList->InsertObject(xGrp.get(), 0); - } + while (nSrcObjCount > 0) + { + --nSrcObjCount; + rtl::Reference<SdrObject> xObj(pSdrPage->GetObj(nSrcObjCount)); + pSdrPage->RemoveObject(nSrcObjCount); + pDstList->InsertObject(xObj.get(), 0); } - return xComponent; + pSdrPage->InsertObject(xGrp.get(), 0); + + return xModel; } void SdrGrafObj::NbcSetGraphic(const Graphic& rGraphic) commit e3f3b22cf46ba1d0ae2384f399b5f988c5c1fba2 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Oct 1 16:37:12 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 10 09:28:32 2025 +0200 include any invisible objects in group Change-Id: I2e7a145b16817129e130fb2217eecfd1cbbfc573 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191747 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit 4f5ed06e55a711b0e6182c57f1daf059ced03a27) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192130 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 4d0489b663ef..cb0417a942c5 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -35,6 +35,7 @@ #include <svx/svdhdl.hxx> #include <svx/svdmodel.hxx> #include <svx/svdpage.hxx> +#include <svx/svdpagv.hxx> #include <svx/svdview.hxx> #include <svx/svdograf.hxx> #include <svx/svdogrp.hxx> @@ -413,9 +414,25 @@ css::uno::Reference<css::lang::XComponent> SdrGrafObj::GetReplacementGraphicMode if (SdrView* pView = pViewShell->GetDrawView()) { - // Group shapes together - pView->MarkAllObj(); - pView->GroupMarked(); + if (SdrPageView* pPV = pView->GetSdrPageView()) + { + // Group shapes together, including invisible objects + + rtl::Reference<SdrObject> xGrp(new SdrObjGroup(rSdrModel)); + SdrObjList* pDstList = xGrp->GetSubList(); + + SdrObjList* pSrcList = pPV->GetObjList(); + size_t i = pSrcList->GetObjCount(); + while (i > 0) + { + --i; + rtl::Reference<SdrObject> xObj(pSrcList->GetObj(i)); + pSrcList->RemoveObject(i); + pDstList->InsertObject(xObj.get(), 0); + } + + pSrcList->InsertObject(xGrp.get(), 0); + } } return xComponent;
