[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 159 commits - basic/qa basic/source bin/lo-all-static-libs canvas/source comphelper/source config_host.mk.in configure.ac connectivity/source cui/source dbaccess/source desktop/inc desktop/Library_sofficeapp.mk desktop/qa desktop/source distro-configs/Jenkins download.lst editeng/source emfio/qa extensions/source external/boost external/iODBC external/libwebp external/Module_external.mk external/pdfium external/python3 external/unixODBC filter/Configuration_filter.mk filter/qa filter/source icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_dark_svg icon-themes/breeze_svg include/comphelper include/editeng include/sal include/sfx2 include/svl include/svtools include/svx include/tools include/vcl javaunohelper/source Makefile.fetch officecfg/registry oovbaapi/ooo readlicense_oo/license RepositoryExternal.mk sc/inc sc/Library_sc.mk scp2/source sc/qa sc/source sdext/source sd/inc sd/Library_sd.mk sd/qa sd/sdi sd/source s d/uiconfig sfx2/inc sfx2/source sfx2/uiconfig shell/source solenv/clang-format solenv/flatpak-manifest.in solenv/gdb solenv/sanitizers svl/source svtools/inc svtools/source svtools/uiconfig svx/inc svx/Library_svx.mk svx/sdi svx/source svx/uiconfig svx/UIConfig_svx.mk sw/inc sw/Library_sw.mk sw/qa sw/sdi sw/source sw/uiconfig tools/source translations ucb/source UnoControls/inc UnoControls/source vcl/CppunitTest_vcl_filters_test.mk vcl/Executable_webpfuzzer.mk vcl/inc vcl/jsdialog vcl/Library_vcl.mk vcl/Module_vcl.mk vcl/qa vcl/source vcl/unx vcl/win vcl/workben wizards/source writerfilter/qa writerfilter/source xmloff/qa xmloff/source xmlsecurity/inc xmlsecurity/source

Mon, 14 Feb 2022 03:43:02 -0800

Rebased ref, commits from common ancestor:
commit 5c982b3c9ebf50c3f814705363b2381877bed859
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Wed Feb 9 12:31:49 2022 +0530
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:34 2022 +0100

    lokCalcRTL: global RTL: fix chart edit mode rendering
    
    If global RTL flag is set, vcl-window X offset of chart window is
    mirrored w.r.t parent window rectangle. This has to be undone to get the
    correct chart bounding box in negative X document coordinates so that
    the offset calculations for tile rendering remains the same for RTL
    documents irrespective of the system/global RTL setting.
    
    Conflicts:
            include/sfx2/lokcharthelper.hxx
            sfx2/source/view/lokcharthelper.cxx
    
    Change-Id: I3e1666681af4e7ab1257bcc88d44bbdb053a7d47
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129704
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    (cherry picked from commit 4fd2a14c6ee68f0574766ec7ec3dca35debe9d20)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129778
    Tested-by: Jenkins
    Reviewed-by: Dennis Francis <dennis.fran...@collabora.com>

diff --git a/include/sfx2/lokcharthelper.hxx b/include/sfx2/lokcharthelper.hxx
index a05868866ef4..c93c4d2b8459 100644
--- a/include/sfx2/lokcharthelper.hxx
+++ b/include/sfx2/lokcharthelper.hxx
@@ -29,11 +29,13 @@ private:
     css::uno::Reference<css::frame::XController> mxController;
     css::uno::Reference<css::frame::XDispatch> mxDispatcher;
     VclPtr<vcl::Window> mpWindow;
+    bool mbNegativeX;
 
 public:
-    LokChartHelper(SfxViewShell* pViewShell)
+    LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false)
         : mpViewShell(pViewShell)
         , mpWindow(nullptr)
+        , mbNegativeX(bNegativeX)
     {}
 
     css::uno::Reference<css::frame::XController>& GetXController();
@@ -43,7 +45,7 @@ public:
     void Invalidate();
 
     bool Hit(const Point& aPos);
-    static bool HitAny(const Point& aPos);
+    static bool HitAny(const Point& aPos, bool bNegativeX = false);
     void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& 
rTileRect);
     static void PaintAllChartsOnTile(VirtualDevice& rDevice,
                                      int nOutputWidth, int nOutputHeight,
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 39019044a7f2..6a0c084388f5 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -725,11 +725,11 @@ void ScModelObj::postMouseEvent(int nType, int nX, int 
nY, int nCount, int nButt
     // check if user hit a chart which is being edited by him
     ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
     SCTAB nTab = pViewData->GetTabNo();
-    LokChartHelper aChartHelper(pTabViewShell);
     const ScDocument& rDoc = pDocShell->GetDocument();
     // In LOK RTL mode draw/svx operates in negative X coordinates
     // But the coordinates from client is always positive, so negate nX for 
draw.
     bool bDrawNegativeX = rDoc.IsNegativePage(nTab);
+    LokChartHelper aChartHelper(pTabViewShell, bDrawNegativeX);
     int nDrawX = bDrawNegativeX ? -nX : nX;
     if (aChartHelper.postMouseEvent(nType, nDrawX, nY,
                                     nCount, nButtons, nModifier,
@@ -745,7 +745,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, 
int nCount, int nButt
     // and, if so, skip current mouse event
     if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
     {
-        if (LokChartHelper::HitAny(aPointTwipDraw))
+        if (LokChartHelper::HitAny(aPointTwipDraw, bDrawNegativeX))
             return;
     }
 
diff --git a/sfx2/source/view/lokcharthelper.cxx 
b/sfx2/source/view/lokcharthelper.cxx
index 21ae981fa50b..ebd0ba14c0fc 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -141,7 +141,17 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
                     const auto nYNum = p.first * scaleY.GetDenominator();
                     const auto nYDen = p.second * scaleY.GetNumerator();
 
-                    Point aOffset = 
pWindow->GetOffsetPixelFrom(*pRootWin).scale(nXNum, nXDen, nYNum, nYDen);
+                    Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin);
+                    if (mbNegativeX && AllSettings::GetLayoutRTL())
+                    {
+                        // If global RTL flag is set, vcl-window X offset of 
chart window is
+                        // mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+                        aOffset.setX(pRootWin->GetOutOffXPixel() + 
pRootWin->GetSizePixel().Width()
+                            - pWindow->GetOutOffXPixel() - 
pWindow->GetSizePixel().Width());
+
+                    }
+
+                    aOffset = aOffset.scale(nXNum, nXDen, nYNum, nYDen);
                     Size aSize = pWindow->GetSizePixel().scale(nXNum, nXDen, 
nYNum, nYDen);
                     aBBox = tools::Rectangle(aOffset, aSize);
                 }
@@ -172,7 +182,7 @@ bool LokChartHelper::Hit(const Point& aPos)
     return false;
 }
 
-bool LokChartHelper::HitAny(const Point& aPos)
+bool LokChartHelper::HitAny(const Point& aPos, bool bNegativeX)
 {
     SfxViewShell* pCurView = SfxViewShell::Current();
     int nPartForCurView = pCurView ? pCurView->getPart() : -1;
@@ -181,7 +191,7 @@ bool LokChartHelper::HitAny(const Point& aPos)
     {
         if (pViewShell->GetDocId() == pCurView->GetDocId() && 
pViewShell->getPart() == nPartForCurView)
         {
-            LokChartHelper aChartHelper(pViewShell);
+            LokChartHelper aChartHelper(pViewShell, bNegativeX);
             if (aChartHelper.Hit(aPos))
                 return true;
         }
@@ -267,7 +277,7 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& 
rDevice,
     {
         if (pCurView && pViewShell->GetDocId() == pCurView->GetDocId() && 
pViewShell->getPart() == nPartForCurView)
         {
-            LokChartHelper aChartHelper(pViewShell);
+            LokChartHelper aChartHelper(pViewShell, bNegativeX);
             aChartHelper.PaintTile(rDevice, aTileRect);
         }
         pViewShell = SfxViewShell::GetNext(*pViewShell);
commit 6099409099fefa2d7dba117df2dc0a3df979137a
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Mon Feb 7 12:05:03 2022 +0000
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:34 2022 +0100

    boost / gettext warning improvement.
    
    std::runtime_exception of:
            "Invalid or unsupported charset:UTF-8 or UTF-8"
    
    is less useful than it could be when spat out from the boost gettext
    impl. Survive for the next (and probably more useful) exception.
    
    Change-Id: Ibeb60b4a34f09f47051844c3e8048f38618d0e05
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129566
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/external/boost/UnpackedTarball_boost.mk 
b/external/boost/UnpackedTarball_boost.mk
index 838c495c5161..5ffb4197468c 100644
--- a/external/boost/UnpackedTarball_boost.mk
+++ b/external/boost/UnpackedTarball_boost.mk
@@ -16,6 +16,7 @@ boost_patches += boost.6142.warnings.patch.1
 boost_patches += boost.utility.Wundef.warnings.patch
 
 boost_patches += boost.noiconv.patch
+boost_patches += boost.between.warning.patch
 
 boost_patches += rtti.patch.0
 
diff --git a/external/boost/boost.between.warning.patch 
b/external/boost/boost.between.warning.patch
new file mode 100644
index 000000000000..bb4535708549
--- /dev/null
+++ b/external/boost/boost.between.warning.patch
@@ -0,0 +1,13 @@
+diff -ru boost.orig/boost/libs/locale/src/encoding/codepage.cpp 
boost/boost/libs/locale/src/encoding/codepage.cpp
+--- foo/misc/boost.orig/libs/locale/src/encoding/codepage.cpp
++++ foo/misc/boost/libs/locale/src/encoding/codepage.cpp
+@@ -58,6 +58,9 @@
+                         return cvt->convert(begin,end);
+                     #endif
+                     #endif
++                  // ensures we get a sensible warning in boost's gettext 
results about a real mismatch.
++                  if (to_charset && from_charset && !strcmp(to_charset, 
from_charset))
++                          return std::string(begin, end - begin);
+                     throw invalid_charset_error(std::string(to_charset) + " 
or " + from_charset);
+                 }
+ 
commit da715f1f6827cbb42a6cba755a8e8bd009a21eb8
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Tue Jan 18 17:04:15 2022 +0000
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:34 2022 +0100

    lok: avoid duplicate emission of statechanged: messages.
    
    We tend to get many of these per keystroke, with the same state.
    
    Change-Id: I9d759f54aee8d6dabcef094997e8f352dd608ec3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128539
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 636cf8ef9863..288fa8ebfcc0 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -87,6 +87,7 @@ namespace desktop {
         static tools::Rectangle SanitizedRectangle(const tools::Rectangle& 
rect);
     };
 
+    /// One instance of this per view, handles flushing callbacks
     class DESKTOP_DLLPUBLIC CallbackFlushHandler final : public Idle, public 
SfxLokCallbackInterface
     {
     public:
@@ -191,6 +192,7 @@ namespace desktop {
         queue_type1 m_queue1;
         queue_type2 m_queue2;
         std::map<int, std::string> m_states;
+        std::unordered_map<std::string, std::string> m_lastStateChange;
         std::unordered_map<int, std::unordered_map<int, std::string>> 
m_viewStates;
 
         // For some types only the last message matters (see isUpdatedType()) 
or only the last message
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 906faf3520ca..b365f90d14b9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1345,6 +1345,7 @@ void CallbackFlushHandler::TimeoutIdle::Invoke()
     mHandler->Invoke();
 }
 
+// One of these is created per view to handle events cf. doc_registerCallback
 CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, 
LibreOfficeKitCallback pCallback, void* pData)
     : Idle( "lokit idle callback" ),
       m_pDocument(pDocument),
@@ -2140,22 +2141,52 @@ void CallbackFlushHandler::Invoke()
         const auto& payload = it2->getPayload();
         const int viewId = lcl_isViewCallbackType(type) ? it2->getViewId() : 
-1;
 
+        SAL_INFO("lok", "processing event: [" << type << ',' << viewId << "]: 
[" << payload << "].");
+
+        // common code-path for events on this view:
         if (viewId == -1)
         {
-            const auto stateIt = m_states.find(type);
-            if (stateIt != m_states.end())
+            size_t idx;
+            // key-value pairs
+            if (type == LOK_CALLBACK_STATE_CHANGED &&
+                (idx = payload.find('=')) != std::string::npos)
             {
-                // If the state didn't change, it's safe to ignore.
-                if (stateIt->second == payload)
+                std::string key = payload.substr(0, idx);
+                std::string value = payload.substr(idx+1);
+                const auto stateIt = m_lastStateChange.find(key);
+                if (stateIt != m_lastStateChange.end())
                 {
-                    SAL_INFO("lok", "Skipping duplicate [" << type << "]: [" 
<< payload << "].");
-                    continue;
+                    // If the value didn't change, it's safe to ignore.
+                    if (stateIt->second == value)
+                    {
+                        SAL_INFO("lok", "Skipping new state duplicate: [" << 
type << "]: [" << payload << "].");
+                        continue;
+                    }
+                    SAL_INFO("lok", "Replacing a state element [" << type << 
"]: [" << payload << "].");
+                    stateIt->second = value;
+                }
+                else
+                {
+                    SAL_INFO("lok", "Inserted a new state element: [" << type 
<< "]: [" << payload << "]");
+                    m_lastStateChange.emplace(key, value);
+                }
+            }
+            else
+            {
+                const auto stateIt = m_states.find(type);
+                if (stateIt != m_states.end())
+                {
+                    // If the state didn't change, it's safe to ignore.
+                    if (stateIt->second == payload)
+                    {
+                        SAL_INFO("lok", "Skipping duplicate [" << type << "]: 
[" << payload << "].");
+                        continue;
+                    }
+                    stateIt->second = payload;
                 }
-
-                stateIt->second = payload;
             }
         }
-        else
+        else // less common path for events relating to other views
         {
             const auto statesIt = m_viewStates.find(viewId);
             if (statesIt != m_viewStates.end())
commit 7e3b931de13a0b0f1d264feffb8a2609d5370cea
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Fri Dec 24 15:25:30 2021 -0400
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:33 2022 +0100

    lok: add 'dropdown' dialog type
    
    The position of the dropdwon is absolute to screen so
    add this type so we can transform correct position on the client side.
    
    Change-Id: I9e2faeb532e313a1a4043d4044f71ada2e7225a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127439
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129459
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcas...@collabora.com>

diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 5ac275290df3..80ab426aa98d 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -685,7 +685,10 @@ void FloatingWindow::StateChanged( StateChangedType nType )
                 // we are a toplevel window, let's so far pretend to be a
                 // dialog - but maybe we'll need a separate type for this
                 // later
-                aItems.emplace_back("type", "dialog");
+                if (mbInPopupMode)
+                    aItems.emplace_back("type", "dropdown");
+                else
+                    aItems.emplace_back("type", "dialog");
                 aItems.emplace_back("position", 
mpImplData->maLOKTwipsPos.toString()); // twips
             }
             else
commit 68dc37c50180e62f55337faf1a121db6822daf74
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Thu Feb 3 23:32:40 2022 +0530
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:33 2022 +0100

    Added master slide handling in getPart* functions of SdXImpressDocument
    
    There was no option to get the master slide info from SdXImpressDocument
    
    Change-Id: Ic42a4c541c406a50ec26ec2113174ab25675a074
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129423
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129480
    Tested-by: Jenkins

diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index 7557aa1a247a..4db38965efe0 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -3612,7 +3612,7 @@ SfxBoolItem MasterSlidesPanel SID_MASTER_SLIDES_PANEL
     GroupId = SfxGroupId::Modify;
 ]
 
-SfxVoidItem SlideMasterPage SID_SLIDE_MASTER_MODE
+SfxBoolItem SlideMasterPage SID_SLIDE_MASTER_MODE
 ()
 [
     AutoUpdate = FALSE,
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 62545ec2f0c4..cf88666f69bc 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -236,6 +236,7 @@ public:
     virtual OUString getPartName( int nPart ) override;
     virtual OUString getPartHash( int nPart ) override;
     virtual VclPtr<vcl::Window> getDocWindow() override;
+    bool isMasterViewMode();
 
     virtual void setPartMode( int nPartMode ) override;
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 5e6e374c3f80..a3ef3367534c 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -46,6 +46,7 @@
 #include <unomodel.hxx>
 #include "unopool.hxx"
 #include <sfx2/lokhelper.hxx>
+#include <sfx2/dispatch.hxx>
 #include <vcl/svapp.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
@@ -127,6 +128,8 @@
 #include <tools/UnitConversion.hxx>
 #include <svx/ColorSets.hxx>
 
+#include <app.hrc>
+
 using namespace ::cppu;
 using namespace ::com::sun::star;
 using namespace ::sd;
@@ -2323,11 +2326,12 @@ void SdXImpressDocument::setPart( int nPart, bool 
bAllowChangeFocus )
 
 int SdXImpressDocument::getParts()
 {
-    // TODO: master pages?
-    // Read: drviews1.cxx
     if (!mpDoc)
         return 0;
 
+    if (isMasterViewMode())
+        return mpDoc->GetMasterSdPageCount(PageKind::Standard);
+
     return mpDoc->GetSdPageCount(PageKind::Standard);
 }
 
@@ -2340,9 +2344,14 @@ int SdXImpressDocument::getPart()
     return pViewSh->GetViewShellBase().getPart();
 }
 
-OUString SdXImpressDocument::getPartName( int nPart )
+OUString SdXImpressDocument::getPartName(int nPart)
 {
-    SdPage* pPage = mpDoc->GetSdPage( nPart, PageKind::Standard );
+    SdPage* pPage;
+    if (isMasterViewMode())
+        pPage = mpDoc->GetMasterSdPage(nPart, PageKind::Standard);
+    else
+        pPage = mpDoc->GetSdPage(nPart, PageKind::Standard);
+
     if (!pPage)
     {
         SAL_WARN("sd", "DrawViewShell not available!");
@@ -2352,9 +2361,14 @@ OUString SdXImpressDocument::getPartName( int nPart )
     return pPage->GetName();
 }
 
-OUString SdXImpressDocument::getPartHash( int nPart )
+OUString SdXImpressDocument::getPartHash(int nPart)
 {
-    SdPage* pPage = mpDoc->GetSdPage( nPart, PageKind::Standard );
+    SdPage* pPage;
+    if (isMasterViewMode())
+        pPage = mpDoc->GetMasterSdPage(nPart, PageKind::Standard);
+    else
+        pPage = mpDoc->GetSdPage(nPart, PageKind::Standard);
+
     if (!pPage)
     {
         SAL_WARN("sd", "DrawViewShell not available!");
@@ -2364,6 +2378,23 @@ OUString SdXImpressDocument::getPartHash( int nPart )
     return OUString::number(pPage->GetHashCode());
 }
 
+bool SdXImpressDocument::isMasterViewMode()
+{
+    DrawViewShell* pViewSh = GetViewShell();
+    if (!pViewSh)
+        return false;
+
+    if (pViewSh->GetDispatcher())
+    {
+        const SfxPoolItem* xItem = nullptr;
+        pViewSh->GetDispatcher()->QueryState(SID_SLIDE_MASTER_MODE, xItem);
+        const SfxBoolItem* isMasterViewMode = dynamic_cast<const 
SfxBoolItem*>(xItem);
+        if (isMasterViewMode && isMasterViewMode->GetValue())
+            return true;
+    }
+    return false;
+}
+
 VclPtr<vcl::Window> SdXImpressDocument::getDocWindow()
 {
     SolarMutexGuard aGuard;
commit 0653220aefe111f68530adeef419491423981d4d
Author:     Szymon Kłos <eszka...@gmail.com>
AuthorDate: Mon Jan 31 14:25:43 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:33 2022 +0100

    Use unique id for FN_UNO_TRANSFORMED_GRAPHIC
    
    Change-Id: I1425fbbe843534adba8b87f9c7b23461cc6049c2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129375
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129489
    Tested-by: Jenkins

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 342f41cb949a..ef4e79e7225c 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -632,7 +632,7 @@
 #define FN_UNO_VISIBLE_AREA_WIDTH           (FN_EXTRA2 + 125)
 #define FN_UNO_VISIBLE_AREA_HEIGHT          (FN_EXTRA2 + 126)
 
-#define FN_UNO_TRANSFORMED_GRAPHIC          (FN_EXTRA2 + 125)
+#define FN_UNO_TRANSFORMED_GRAPHIC          (FN_EXTRA2 + 127)
 
 // Area: Help
 // Region: Traveling & Selection
commit e1647ea7d55cc4e19ba404b1d407cc123745bbef
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Feb 2 10:47:22 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:33 2022 +0100

    speed up bitmap rotation
    
    (*) use more cache-dense temporary arrays
    (*) use float instead of double - I cannot see a difference in results
    (*) tools::Long->sal_Int32, we don't need more than 32-bits for x/y
        coordinates
    
    Change-Id: I81a1da573735f183a7d2a117f6170cf373433e4d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129324
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/source/bitmap/bitmappaint.cxx 
b/vcl/source/bitmap/bitmappaint.cxx
index 034fd5738a2a..954820c761cc 100644
--- a/vcl/source/bitmap/bitmappaint.cxx
+++ b/vcl/source/bitmap/bitmappaint.cxx
@@ -367,45 +367,41 @@ bool Bitmap::Rotate(Degree10 nAngle10, const Color& 
rFillColor)
                     const double fSinAngle = sin(toRadians(nAngle10));
                     const double fXMin = aNewBound.Left();
                     const double fYMin = aNewBound.Top();
-                    const tools::Long nWidth = aSizePix.Width();
-                    const tools::Long nHeight = aSizePix.Height();
-                    const tools::Long nNewWidth = aNewSizePix.Width();
-                    const tools::Long nNewHeight = aNewSizePix.Height();
-                    tools::Long nX;
-                    tools::Long nY;
-                    tools::Long nRotX;
-                    tools::Long nRotY;
-                    std::unique_ptr<long[]> pCosX(new long[nNewWidth]);
-                    std::unique_ptr<long[]> pSinX(new long[nNewWidth]);
-                    std::unique_ptr<long[]> pCosY(new long[nNewHeight]);
-                    std::unique_ptr<long[]> pSinY(new long[nNewHeight]);
-
-                    for (nX = 0; nX < nNewWidth; nX++)
+                    const sal_Int32 nWidth = aSizePix.Width();
+                    const sal_Int32 nHeight = aSizePix.Height();
+                    const sal_Int32 nNewWidth = aNewSizePix.Width();
+                    const sal_Int32 nNewHeight = aNewSizePix.Height();
+                    // we store alternating values of cos/sin. We do this 
instead of
+                    // separate arrays to improve cache hit.
+                    std::unique_ptr<sal_Int32[]> pCosSinX(new 
sal_Int32[nNewWidth * 2]);
+                    std::unique_ptr<sal_Int32[]> pCosSinY(new 
sal_Int32[nNewHeight * 2]);
+
+                    for (sal_Int32 nIdx = 0, nX = 0; nX < nNewWidth; nX++)
                     {
-                        const double fTmp = (fXMin + nX) * 64.;
+                        const float fTmp = (fXMin + nX) * 64;
 
-                        pCosX[nX] = FRound(fCosAngle * fTmp);
-                        pSinX[nX] = FRound(fSinAngle * fTmp);
+                        pCosSinX[nIdx++] = std::round(fCosAngle * fTmp);
+                        pCosSinX[nIdx++] = std::round(fSinAngle * fTmp);
                     }
 
-                    for (nY = 0; nY < nNewHeight; nY++)
+                    for (sal_Int32 nIdx = 0, nY = 0; nY < nNewHeight; nY++)
                     {
-                        const double fTmp = (fYMin + nY) * 64.;
+                        const float fTmp = (fYMin + nY) * 64;
 
-                        pCosY[nY] = FRound(fCosAngle * fTmp);
-                        pSinY[nY] = FRound(fSinAngle * fTmp);
+                        pCosSinY[nIdx++] = std::round(fCosAngle * fTmp);
+                        pCosSinY[nIdx++] = std::round(fSinAngle * fTmp);
                     }
 
-                    for (nY = 0; nY < nNewHeight; nY++)
+                    for (sal_Int32 nCosSinYIdx = 0, nY = 0; nY < nNewHeight; 
nY++)
                     {
-                        tools::Long nSinY = pSinY[nY];
-                        tools::Long nCosY = pCosY[nY];
+                        sal_Int32 nSinY = pCosSinY[nCosSinYIdx++];
+                        sal_Int32 nCosY = pCosSinY[nCosSinYIdx++];
                         Scanline pScanline = pWriteAcc->GetScanline(nY);
 
-                        for (nX = 0; nX < nNewWidth; nX++)
+                        for (sal_Int32 nCosSinXIdx = 0, nX = 0; nX < 
nNewWidth; nX++)
                         {
-                            nRotX = (pCosX[nX] - nSinY) >> 6;
-                            nRotY = (pSinX[nX] + nCosY) >> 6;
+                            sal_Int32 nRotX = (pCosSinX[nCosSinXIdx++] - 
nSinY) >> 6;
+                            sal_Int32 nRotY = (pCosSinX[nCosSinXIdx++] + 
nCosY) >> 6;
 
                             if ((nRotX > -1) && (nRotX < nWidth) && (nRotY > 
-1)
                                 && (nRotY < nHeight))
commit d1b20ba96b583edfef27071c19d04dbc748c70e7
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Dec 7 14:42:47 2021 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:33 2022 +0100

    disable ScPosWnd completely in LOK mode
    
    366e328dc7f36061971c549c2d33d365026b65ca already mostly disabled it,
    but the instance was still created, and it sets up listening that
    results in ScPosWnd::FillRangeNames() getting called on every
    SfxLokHelper::setView(), which forms the major cost of the view
    switching.
    
    Change-Id: Ic16da4bdfb678d53a79da57e9bbdcb7fc59c576d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126481
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 9029f23e5f95..def5e37791d9 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -161,7 +161,7 @@ static VclPtr<ScInputBarGroup> lcl_chooseRuntimeImpl( 
vcl::Window* pParent, cons
 ScInputWindow::ScInputWindow( vcl::Window* pParent, const SfxBindings* pBind ) 
:
         // With WB_CLIPCHILDREN otherwise we get flickering
         ToolBox         ( pParent, WinBits(WB_CLIPCHILDREN | WB_BORDER | 
WB_NOSHADOW) ),
-        aWndPos         ( VclPtr<ScPosWnd>::Create(this) ),
+        aWndPos         ( !comphelper::LibreOfficeKit::isActive() ? 
VclPtr<ScPosWnd>::Create(this) : nullptr ),
         mxTextWindow    ( lcl_chooseRuntimeImpl( this, pBind ) ),
         pInputHdl       ( nullptr ),
         mpViewShell     ( nullptr ),
@@ -589,7 +589,8 @@ void ScInputWindow::SetFuncString( const OUString& rString, 
bool bDoEdit )
 
 void ScInputWindow::SetPosString( const OUString& rStr )
 {
-    aWndPos->SetPos( rStr );
+    if (!comphelper::LibreOfficeKit::isActive())
+        aWndPos->SetPos( rStr );
 }
 
 void ScInputWindow::SetTextString( const OUString& rString )
@@ -648,7 +649,8 @@ void ScInputWindow::SetSumAssignMode()
 
 void ScInputWindow::SetFormulaMode( bool bSet )
 {
-    aWndPos->SetFormulaMode(bSet);
+    if (!comphelper::LibreOfficeKit::isActive())
+        aWndPos->SetFormulaMode(bSet);
     mxTextWindow->SetFormulaMode(bSet);
 }
 
@@ -713,7 +715,8 @@ void ScInputWindow::SwitchToTextWin()
 
 void ScInputWindow::PosGrabFocus()
 {
-    aWndPos->GrabFocus();
+    if (!comphelper::LibreOfficeKit::isActive())
+        aWndPos->GrabFocus();
 }
 
 void ScInputWindow::EnableButtons( bool bEnable )
commit 4e21d9d6126c22bbc35a9f94e45d0542a6855b9c
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Jan 26 08:38:59 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:33 2022 +0100

    desktop lok, export options: allow passing through a JSON string as-is
    
    setFormatSpecificFilterData() sets useful defaults, but the PDF export
    code has the (sane) behavior of preferring FilterData over
    FilterOptions, so in case we explicitly got a JSON string in
    FilterOptions to in fact set FilterData, then leave FilterData empty.
    
    Change-Id: I20e8094bf431782fe0f5d68e3ec630e1274e30c7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128970
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/desktop/qa/data/3page.odg b/desktop/qa/data/3page.odg
new file mode 100644
index 000000000000..1fad913e0493
Binary files /dev/null and b/desktop/qa/data/3page.odg differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index c1b1cc34cbf9..1504c2f040fe 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -62,6 +62,7 @@
 #include <cppunit/TestAssert.h>
 #include <vcl/BitmapTools.hxx>
 #include <vcl/pngwrite.hxx>
+#include <vcl/filter/PDFiumLibrary.hxx>
 
 #if USE_TLS_NSS
 #include <nss.h>
@@ -159,6 +160,7 @@ public:
     void testSearchAllNotificationsCalc();
     void testPaintTile();
     void testSaveAs();
+    void testSaveAsJsonOptions();
     void testSaveAsCalc();
     void testPasteWriter();
     void testPasteWriterJPEG();
@@ -225,6 +227,7 @@ public:
     CPPUNIT_TEST(testSearchAllNotificationsCalc);
     CPPUNIT_TEST(testPaintTile);
     CPPUNIT_TEST(testSaveAs);
+    CPPUNIT_TEST(testSaveAsJsonOptions);
     CPPUNIT_TEST(testSaveAsCalc);
     CPPUNIT_TEST(testPasteWriter);
     CPPUNIT_TEST(testPasteWriterJPEG);
@@ -675,6 +678,32 @@ void DesktopLOKTest::testSaveAs()
     CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
 }
 
+void DesktopLOKTest::testSaveAsJsonOptions()
+{
+    // Given a document with 3 pages:
+    LibLODocument_Impl* pDocument = loadDoc("3page.odg");
+
+    // When exporting that document to PDF, skipping the first page:
+    utl::TempFile aTempFile;
+    aTempFile.EnableKillingFile();
+    OString aOptions("{\"PageRange\":{\"type\":\"string\",\"value\":\"2-\"}}");
+    CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "pdf", aOptions.getStr()));
+
+    // Then make sure the resulting PDF has 2 pages:
+    SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ);
+    SvMemoryStream aMemory;
+    aMemory.WriteStream(aFile);
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+        = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize());
+    CPPUNIT_ASSERT(pPdfDocument);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 2
+    // - Actual  : 3
+    // i.e. FilterOptions was ignored.
+    CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+}
+
 void DesktopLOKTest::testSaveAsCalc()
 {
     LibLODocument_Impl* pDocument = loadDoc("search.ods");
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7c5648a11a6d..906faf3520ca 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2873,7 +2873,12 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, 
const char* sUrl, const cha
 
         comphelper::SequenceAsHashMap aFilterDataMap;
 
-        setFormatSpecificFilterData(sFormat, aFilterDataMap);
+        // If filter options is JSON string, then make sure aFilterDataMap 
stays empty, otherwise we
+        // would ignore the filter options.
+        if (!aFilterOptions.startsWith("{"))
+        {
+            setFormatSpecificFilterData(sFormat, aFilterDataMap);
+        }
 
         if (!watermarkText.isEmpty())
             aFilterDataMap["TiledWatermark"] <<= watermarkText;
commit 3a95a42c2b1ac5852a76c986ea54a3aff2fe99c6
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Jan 24 08:28:21 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:32 2022 +0100

    PDF export: allow setting filter data keys from the cmdline
    
    Follow-up improvement to commit 3eb9eb9906c9 (lok: add pdf version
    option for export, 2021-11-15), possibilities are endless.
    
    For example, to skip the first page of a Draw document:
    
    soffice --convert-to 
'pdf:draw_pdf_Export:{"PageRange":{"type":"string","value":"2-"}}' test.odg
    
    Add watermark:
    
    soffice --convert-to 
'pdf:draw_pdf_Export:{"TiledWatermark":{"type":"string","value":"draft"}}' 
test.odg
    
    Encrypt:
    
    soffice --convert-to 
'pdf:draw_pdf_Export:{"EncryptFile":{"type":"boolean","value":"true"},"DocumentOpenPassword":{"type":"string","value":"secret"}}'
 test.odg
    
    Version 1.5 (instead of the default 1.6):
    
    soffice --convert-to 
'pdf:draw_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"15"}}' test.odg
    
    The cost of the verbose syntax is probably smaller than the benefit of
    having this 1:1 mapping from string to PropertyValues.
    
    Change-Id: I2093a3a787a9578dd02a154593b7a020f4a0ba31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128849
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx
index 6d1a793a7158..d7fc558d198e 100644
--- a/filter/source/pdf/pdffilter.cxx
+++ b/filter/source/pdf/pdffilter.cxx
@@ -30,6 +30,9 @@
 
 #include <com/sun/star/io/XOutputStream.hpp>
 
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
+
 using namespace ::com::sun::star::io;
 
 PDFFilter::PDFFilter( const Reference< XComponentContext > &rxContext ) :
@@ -47,6 +50,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& 
rDescriptor )
 {
     Reference< XOutputStream >  xOStm;
     Sequence< PropertyValue >   aFilterData;
+    OUString aFilterOptions;
     sal_Int32                   nLength = rDescriptor.getLength();
     const PropertyValue*        pValue = rDescriptor.getConstArray();
     bool                        bIsRedactMode = false;
@@ -60,6 +64,8 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& 
rDescriptor )
             pValue[ i ].Value >>= xOStm;
         else if ( pValue[ i ].Name == "FilterData" )
             pValue[ i ].Value >>= aFilterData;
+        else if ( pValue[ i ].Name == "FilterOptions" )
+            pValue[ i ].Value >>= aFilterOptions;
         else if ( pValue[ i ].Name == "StatusIndicator" )
             pValue[ i ].Value >>= xStatusIndicator;
         else if ( pValue[i].Name == "InteractionHandler" )
@@ -72,6 +78,13 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& 
rDescriptor )
             pValue[i].Value >>= bIsRedactMode;
     }
 
+    if (!aFilterData.hasElements() && !aFilterOptions.isEmpty())
+    {
+        // Allow setting filter data keys from the cmdline.
+        std::vector<PropertyValue> aData = 
comphelper::JsonToPropertyValues(aFilterOptions.toUtf8());
+        aFilterData = comphelper::containerToSequence(aData);
+    }
+
     /* we don't get FilterData if we are exporting directly
        to pdf, but we have to use the last user settings (especially for the 
CompressMode) */
     if ( !aFilterData.hasElements() )
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 4050c8a5d7e9..7312078b1896 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1992,6 +1992,25 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testLinkWrongPagePartial)
     CPPUNIT_ASSERT(!pPdfPage2->hasLinks());
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testPageRange)
+{
+    // Given a document with 3 pages:
+    // When exporting that document to PDF, skipping the first page:
+    aMediaDescriptor["FilterName"] <<= OUString("draw_pdf_Export");
+    aMediaDescriptor["FilterOptions"]
+        <<= OUString("{\"PageRange\":{\"type\":\"string\",\"value\":\"2-\"}}");
+    saveAsPDF(u"link-wrong-page-partial.odg");
+
+    // Then make sure the resulting PDF has 2 pages:
+    std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport();
+    CPPUNIT_ASSERT(pPdfDocument);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 2
+    // - Actual  : 3
+    // i.e. FilterOptions was ignored.
+    CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testLargePage)
 {
     // Import the bugdoc and export as PDF.
commit 1335259c7eb7362e4f7bb78e77b6110f08f1305e
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Jan 20 21:02:35 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:32 2022 +0100

    comphelper: move JsonToPropertyValues() from desktop/
    
    Because filter/ code will need this in a bit, and that can't depend on
    desktop/.
    
    Change-Id: I07f0f8ef30942a2d11388c6721c7f277e117bfba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128709
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/comphelper/source/misc/sequenceashashmap.cxx 
b/comphelper/source/misc/sequenceashashmap.cxx
index eb78e60c55d2..c6ac57326935 100644
--- a/comphelper/source/misc/sequenceashashmap.cxx
+++ b/comphelper/source/misc/sequenceashashmap.cxx
@@ -19,11 +19,82 @@
 
 #include <sal/config.h>
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/reflection/XIdlField.hpp>
+#include <com/sun/star/reflection/theCoreReflection.hpp>
 #include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <sal/log.hxx>
+
+using namespace com::sun::star;
 
+namespace
+{
+uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree)
+{
+    uno::Any aAny;
+    uno::Any aValue;
+    sal_Int32 nFields;
+    uno::Reference<reflection::XIdlField> aField;
+    boost::property_tree::ptree aNodeNull, aNodeValue, aNodeField;
+    const std::string& rType = aTree.get<std::string>("type", "");
+    const std::string& rValue = aTree.get<std::string>("value", "");
+    uno::Sequence<uno::Reference<reflection::XIdlField>> aFields;
+    uno::Reference<reflection::XIdlClass> xIdlClass
+        = 
css::reflection::theCoreReflection::get(comphelper::getProcessComponentContext())
+              ->forName(OUString::fromUtf8(rType.c_str()));
+    if (xIdlClass.is())
+    {
+        uno::TypeClass aTypeClass = xIdlClass->getTypeClass();
+        xIdlClass->createObject(aAny);
+        aFields = xIdlClass->getFields();
+        nFields = aFields.getLength();
+        aNodeValue = aTree.get_child("value", aNodeNull);
+        if (nFields > 0 && aNodeValue != aNodeNull)
+        {
+            for (sal_Int32 itField = 0; itField < nFields; ++itField)
+            {
+                aField = aFields[itField];
+                aNodeField = 
aNodeValue.get_child(aField->getName().toUtf8().getStr(), aNodeNull);
+                if (aNodeField != aNodeNull)
+                {
+                    aValue = jsonToUnoAny(aNodeField);
+                    aField->set(aAny, aValue);
+                }
+            }
+        }
+        else if (!rValue.empty())
+        {
+            if (aTypeClass == uno::TypeClass_VOID)
+                aAny.clear();
+            else if (aTypeClass == uno::TypeClass_BYTE)
+                aAny <<= 
static_cast<sal_Int8>(OString(rValue.c_str()).toInt32());
+            else if (aTypeClass == uno::TypeClass_BOOLEAN)
+                aAny <<= OString(rValue.c_str()).toBoolean();
+            else if (aTypeClass == uno::TypeClass_SHORT)
+                aAny <<= 
static_cast<sal_Int16>(OString(rValue.c_str()).toInt32());
+            else if (aTypeClass == uno::TypeClass_UNSIGNED_SHORT)
+                aAny <<= 
static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32());
+            else if (aTypeClass == uno::TypeClass_LONG)
+                aAny <<= OString(rValue.c_str()).toInt32();
+            else if (aTypeClass == uno::TypeClass_UNSIGNED_LONG)
+                aAny <<= 
static_cast<sal_uInt32>(OString(rValue.c_str()).toInt32());
+            else if (aTypeClass == uno::TypeClass_FLOAT)
+                aAny <<= OString(rValue.c_str()).toFloat();
+            else if (aTypeClass == uno::TypeClass_DOUBLE)
+                aAny <<= OString(rValue.c_str()).toDouble();
+            else if (aTypeClass == uno::TypeClass_STRING)
+                aAny <<= OUString::fromUtf8(rValue.c_str());
+        }
+    }
+    return aAny;
+}
+}
 
 namespace comphelper{
 
@@ -234,6 +305,72 @@ void SequenceAsHashMap::update(const SequenceAsHashMap& 
rUpdate)
     }
 }
 
+std::vector<css::beans::PropertyValue> JsonToPropertyValues(const OString& 
rJson)
+{
+    std::vector<beans::PropertyValue> aArguments;
+    boost::property_tree::ptree aTree, aNodeNull, aNodeValue;
+    std::stringstream aStream(rJson.getStr());
+    boost::property_tree::read_json(aStream, aTree);
+
+    for (const auto& rPair : aTree)
+    {
+        const std::string& rType = rPair.second.get<std::string>("type", "");
+        const std::string& rValue = rPair.second.get<std::string>("value", "");
+
+        beans::PropertyValue aValue;
+        aValue.Name = OUString::fromUtf8(rPair.first.c_str());
+        if (rType == "string")
+            aValue.Value <<= OUString::fromUtf8(rValue.c_str());
+        else if (rType == "boolean")
+            aValue.Value <<= OString(rValue.c_str()).toBoolean();
+        else if (rType == "float")
+            aValue.Value <<= OString(rValue.c_str()).toFloat();
+        else if (rType == "long")
+            aValue.Value <<= OString(rValue.c_str()).toInt32();
+        else if (rType == "short")
+            aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32());
+        else if (rType == "unsigned short")
+            aValue.Value <<= sal_uInt16(OString(rValue.c_str()).toUInt32());
+        else if (rType == "int64")
+            aValue.Value <<= OString(rValue.c_str()).toInt64();
+        else if (rType == "int32")
+            aValue.Value <<= OString(rValue.c_str()).toInt32();
+        else if (rType == "int16")
+            aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32());
+        else if (rType == "uint64")
+            aValue.Value <<= OString(rValue.c_str()).toUInt64();
+        else if (rType == "uint32")
+            aValue.Value <<= OString(rValue.c_str()).toUInt32();
+        else if (rType == "uint16")
+            aValue.Value <<= sal_uInt16(OString(rValue.c_str()).toUInt32());
+        else if (rType == "[]byte")
+        {
+            aNodeValue = rPair.second.get_child("value", aNodeNull);
+            if (aNodeValue != aNodeNull && aNodeValue.size() == 0)
+            {
+                uno::Sequence<sal_Int8> aSeqByte(reinterpret_cast<const 
sal_Int8*>(rValue.c_str()),
+                                                 rValue.size());
+                aValue.Value <<= aSeqByte;
+            }
+        }
+        else if (rType == "[]any")
+        {
+            aNodeValue = rPair.second.get_child("value", aNodeNull);
+            if (aNodeValue != aNodeNull && !aNodeValue.empty())
+            {
+                uno::Sequence<uno::Any> aSeq(aNodeValue.size());
+                std::transform(aNodeValue.begin(), aNodeValue.end(), 
aSeq.getArray(),
+                               [](const auto& rSeqPair) { return 
jsonToUnoAny(rSeqPair.second); });
+                aValue.Value <<= aSeq;
+            }
+        }
+        else
+            SAL_WARN("comphelper", "JsonToPropertyValues: unhandled type '" << 
rType << "'");
+        aArguments.push_back(aValue);
+    }
+    return aArguments;
+}
+
 } // namespace comphelper
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c4daa2614ea6..7c5648a11a6d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -77,9 +77,6 @@
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/reflection/theCoreReflection.hpp>
-#include <com/sun/star/reflection/XIdlClass.hpp>
-#include <com/sun/star/reflection/XIdlReflection.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/util/URLTransformer.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
@@ -374,130 +371,12 @@ static OUString getAbsoluteURL(const char* pURL)
     return OUString();
 }
 
-static uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree)
-{
-    uno::Any aAny;
-    uno::Any aValue;
-    sal_Int32 nFields;
-    uno::Reference< reflection::XIdlField > aField;
-    boost::property_tree::ptree aNodeNull, aNodeValue, aNodeField;
-    const std::string& rType = aTree.get<std::string>("type", "");
-    const std::string& rValue = aTree.get<std::string>("value", "");
-    uno::Sequence< uno::Reference< reflection::XIdlField > > aFields;
-    uno::Reference< reflection:: XIdlClass > xIdlClass =
-        
css::reflection::theCoreReflection::get(comphelper::getProcessComponentContext())->forName(OUString::fromUtf8(rType.c_str()));
-    if (xIdlClass.is())
-    {
-        uno::TypeClass aTypeClass = xIdlClass->getTypeClass();
-        xIdlClass->createObject(aAny);
-        aFields = xIdlClass->getFields();
-        nFields = aFields.getLength();
-        aNodeValue = aTree.get_child("value", aNodeNull);
-        if (nFields > 0 && aNodeValue != aNodeNull)
-        {
-            for (sal_Int32 itField = 0; itField < nFields; ++itField)
-            {
-                aField = aFields[itField];
-                aNodeField = 
aNodeValue.get_child(aField->getName().toUtf8().getStr(), aNodeNull);
-                if (aNodeField != aNodeNull)
-                {
-                    aValue = jsonToUnoAny(aNodeField);
-                    aField->set(aAny, aValue);
-                }
-            }
-        }
-        else if (!rValue.empty())
-        {
-            if (aTypeClass == uno::TypeClass_VOID)
-                aAny.clear();
-            else if (aTypeClass == uno::TypeClass_BYTE)
-                aAny <<= 
static_cast<sal_Int8>(OString(rValue.c_str()).toInt32());
-            else if (aTypeClass == uno::TypeClass_BOOLEAN)
-                aAny <<= OString(rValue.c_str()).toBoolean();
-            else if (aTypeClass == uno::TypeClass_SHORT)
-                aAny <<= 
static_cast<sal_Int16>(OString(rValue.c_str()).toInt32());
-            else if (aTypeClass == uno::TypeClass_UNSIGNED_SHORT)
-                aAny <<= 
static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32());
-            else if (aTypeClass == uno::TypeClass_LONG)
-                aAny <<= OString(rValue.c_str()).toInt32();
-            else if (aTypeClass == uno::TypeClass_UNSIGNED_LONG)
-                aAny <<= 
static_cast<sal_uInt32>(OString(rValue.c_str()).toInt32());
-            else if (aTypeClass == uno::TypeClass_FLOAT)
-                aAny <<= OString(rValue.c_str()).toFloat();
-            else if (aTypeClass == uno::TypeClass_DOUBLE)
-                aAny <<= OString(rValue.c_str()).toDouble();
-            else if (aTypeClass == uno::TypeClass_STRING)
-                aAny <<= OUString::fromUtf8(rValue.c_str());
-        }
-    }
-    return aAny;
-}
-
 std::vector<beans::PropertyValue> desktop::jsonToPropertyValuesVector(const 
char* pJSON)
 {
     std::vector<beans::PropertyValue> aArguments;
     if (pJSON && pJSON[0] != '\0')
     {
-        boost::property_tree::ptree aTree, aNodeNull, aNodeValue;
-        std::stringstream aStream(pJSON);
-        boost::property_tree::read_json(aStream, aTree);
-
-        for (const auto& rPair : aTree)
-        {
-            const std::string& rType = rPair.second.get<std::string>("type", 
"");
-            const std::string& rValue = rPair.second.get<std::string>("value", 
"");
-
-            beans::PropertyValue aValue;
-            aValue.Name = OUString::fromUtf8(rPair.first.c_str());
-            if (rType == "string")
-                aValue.Value <<= OUString::fromUtf8(rValue.c_str());
-            else if (rType == "boolean")
-                aValue.Value <<= OString(rValue.c_str()).toBoolean();
-            else if (rType == "float")
-                aValue.Value <<= OString(rValue.c_str()).toFloat();
-            else if (rType == "long")
-                aValue.Value <<= OString(rValue.c_str()).toInt32();
-            else if (rType == "short")
-                aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32());
-            else if (rType == "unsigned short")
-                aValue.Value <<= 
sal_uInt16(OString(rValue.c_str()).toUInt32());
-            else if (rType == "int64")
-                aValue.Value <<= OString(rValue.c_str()).toInt64();
-            else if (rType == "int32")
-                aValue.Value <<= OString(rValue.c_str()).toInt32();
-            else if (rType == "int16")
-                aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32());
-            else if (rType == "uint64")
-                aValue.Value <<= OString(rValue.c_str()).toUInt64();
-            else if (rType == "uint32")
-                aValue.Value <<= OString(rValue.c_str()).toUInt32();
-            else if (rType == "uint16")
-                aValue.Value <<= 
sal_uInt16(OString(rValue.c_str()).toUInt32());
-            else if (rType == "[]byte")
-            {
-                aNodeValue = rPair.second.get_child("value", aNodeNull);
-                if (aNodeValue != aNodeNull && aNodeValue.size() == 0)
-                {
-                    uno::Sequence< sal_Int8 > aSeqByte(reinterpret_cast<const 
sal_Int8*>(rValue.c_str()), rValue.size());
-                    aValue.Value <<= aSeqByte;
-                }
-            }
-            else if (rType == "[]any")
-            {
-                aNodeValue = rPair.second.get_child("value", aNodeNull);
-                if (aNodeValue != aNodeNull && !aNodeValue.empty())
-                {
-                    uno::Sequence< uno::Any > aSeq(aNodeValue.size());
-                    std::transform(aNodeValue.begin(), aNodeValue.end(), 
aSeq.getArray(),
-                                   [](const auto& rSeqPair)
-                                   { return jsonToUnoAny(rSeqPair.second); });
-                    aValue.Value <<= aSeq;
-                }
-            }
-            else
-                SAL_WARN("desktop.lib", "jsonToPropertyValuesVector: unhandled 
type '"<<rType<<"'");
-            aArguments.push_back(aValue);
-        }
+        aArguments = comphelper::JsonToPropertyValues(pJSON);
     }
     return aArguments;
 }
diff --git a/include/comphelper/propertysequence.hxx 
b/include/comphelper/propertysequence.hxx
index 2c143aa9ed7a..e788f56f428f 100644
--- a/include/comphelper/propertysequence.hxx
+++ b/include/comphelper/propertysequence.hxx
@@ -13,10 +13,14 @@
 #include <utility>
 #include <algorithm>
 #include <initializer_list>
+#include <vector>
+
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 #include <com/sun/star/beans/PropertyValue.hpp>
 
+#include <comphelper/comphelperdllapi.h>
+
 namespace comphelper
 {
     /// Init list for property sequences.
@@ -48,6 +52,8 @@ namespace comphelper
                        });
         return vResult;
     }
+
+    COMPHELPER_DLLPUBLIC std::vector<css::beans::PropertyValue> 
JsonToPropertyValues(const OString& rJson);
 }   // namespace comphelper
 
 
commit 4dd761b6a7e76bd1f6a13a44a0cb020b8312c773
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Mon Jan 31 20:27:54 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:32 2022 +0100

    fix the orientation combobox in the print dialog
    
    Changing the orientation value to anything else than 'Automatic'
    didn't do anything by default. This was because by default
    neither isPaperSizeFromUser() nor getPapersizeFromSetup()
    were set, so PrintDialog::setPaperOrientation() did nothing.
    It looks to me like 8cbdc6a068ad88fc43a98bd0f88 that introduced it
    was rather broken (not just this bug, but also e.g. the ugly
    modifying of the paper sizes by non-const reference from a const
    function). In fact this whole stuff still looks broken to me, why
    does it change paper size instead of just setting the orientation?
    It seems like the orientation gets reset, or maybe the setting
    was just a band-aid. I don't know how to fix that all though.
    
    Change-Id: If5fdf4c47e06f2b0797d27126d21b3451b8334cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129239
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 83f4170c241c..e656cf80cc45 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -470,10 +470,8 @@ public:
     VCL_DLLPRIVATE    void              setReversePrint( bool i_bReverse );
     VCL_DLLPRIVATE    void              setPapersizeFromSetup( bool 
i_bPapersizeFromSetup );
     VCL_DLLPRIVATE    bool              getPapersizeFromSetup() const;
-    VCL_DLLPRIVATE    Size&             getPaperSizeSetup() const;
     VCL_DLLPRIVATE    void              setPaperSizeFromUser( Size i_aUserSize 
);
-    VCL_DLLPRIVATE    Size&             getPaperSizeFromUser() const;
-    VCL_DLLPRIVATE    bool              isPaperSizeFromUser() const;
+    VCL_DLLPRIVATE    void              setOrientationFromUser( Orientation 
eOrientation, bool set );
                       void              setPrinterModified( bool 
i_bPapersizeFromSetup );
                       bool              getPrinterModified() const;
     VCL_DLLPRIVATE    void              pushPropertiesToPrinter();
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 21aab3667d4e..5b96417476e0 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -231,10 +231,9 @@ namespace vcl
         void setupPaperSidesBox();
         void storeToSettings();
         void readFromSettings();
-        void setPaperOrientation( Orientation eOrientation );
+        void setPaperOrientation( Orientation eOrientation, bool fromUser );
         void updateOrientationBox( bool bAutomatic = true );
         bool hasOrientationChanged() const;
-        void checkPaperSize( Size& rPaperSize );
         void setPreviewText();
         void updatePrinterText();
         void checkControlDependencies();
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index f33d59820caa..aecc43e15e33 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -158,6 +158,7 @@ public:
     bool                                                        
mbReversePageOrder;
     bool                                                        
mbPapersizeFromSetup;
     bool                                                        
mbPapersizeFromUser;
+    bool                                                        
mbOrientationFromUser;
     bool                                                        
mbPrinterModified;
     css::view::PrintableState                                   meJobState;
 
@@ -171,6 +172,8 @@ public:
     Size                                                        
maDefaultPageSize;
     // set by user through print dialog
     Size                                                        maUserPageSize;
+    // set by user through print dialog
+    Orientation                                                 
meUserOrientation;
     // set by user through printer properties subdialog of printer settings 
dialog
     sal_Int32                                                   
mnDefaultPaperBin;
     // Set by user through printer properties subdialog of print dialog.
@@ -197,6 +200,7 @@ public:
         mbReversePageOrder( false ),
         mbPapersizeFromSetup( false ),
         mbPapersizeFromUser( false ),
+        mbOrientationFromUser( false ),
         mbPrinterModified( false ),
         meJobState( css::view::PrintableState_JOB_STARTED ),
         mnDefaultPaperBin( -1 ),
@@ -212,15 +216,27 @@ public:
         }
     }
 
-    const Size& getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const
+    Size getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const
     {
+        Size size;
         if ( mbPapersizeFromUser )
-            return maUserPageSize;
-        if( mbPapersizeFromSetup )
-            return maDefaultPageSize;
-        if( maMultiPage.nRows * maMultiPage.nColumns > 1 && ! bNoNUP )
-            return maMultiPage.aPaperSize;
-        return i_rPageSize;
+            size = maUserPageSize;
+        else if( mbPapersizeFromSetup )
+            size =  maDefaultPageSize;
+        else if( maMultiPage.nRows * maMultiPage.nColumns > 1 && ! bNoNUP )
+            size = maMultiPage.aPaperSize;
+        else
+            size = i_rPageSize;
+        if(mbOrientationFromUser)
+        {
+            if ( (meUserOrientation == Orientation::Portrait && size.Width() > 
size.Height()) ||
+                 (meUserOrientation == Orientation::Landscape && size.Width() 
< size.Height()) )
+            {
+                // coverity[swapped-arguments : FALSE] - this is in the 
correct order
+                size = Size( size.Height(), size.Width() );
+            }
+        }
+        return size;
     }
     PrinterController::PageSize modifyJobSetup( const css::uno::Sequence< 
css::beans::PropertyValue >& i_rProps );
     void resetPaperToLastConfigured();
@@ -824,6 +840,7 @@ void PrinterController::setPrinter( const VclPtr<Printer>& 
i_rPrinter )
     }
 
     mpImplData->mbPapersizeFromUser = false;
+    mpImplData->mbOrientationFromUser = false;
     mpImplData->mxPrinter->Pop();
     mpImplData->mnFixedPaperBin = -1;
 }
@@ -1407,7 +1424,10 @@ void PrinterController::setPapersizeFromSetup( bool 
i_bPapersizeFromSetup )
     mpImplData->mbPapersizeFromSetup = i_bPapersizeFromSetup;
     mpImplData->mxPrinter->SetPrinterSettingsPreferred( i_bPapersizeFromSetup 
);
     if ( i_bPapersizeFromSetup )
-        mpImplData->mbPapersizeFromUser = !i_bPapersizeFromSetup;
+    {
+        mpImplData->mbPapersizeFromUser = false;
+        mpImplData->mbOrientationFromUser = false;
+    }
 }
 
 bool PrinterController::getPapersizeFromSetup() const
@@ -1415,11 +1435,6 @@ bool PrinterController::getPapersizeFromSetup() const
     return mpImplData->mbPapersizeFromSetup;
 }
 
-Size& PrinterController::getPaperSizeSetup() const
-{
-    return mpImplData->maDefaultPageSize;
-}
-
 void PrinterController::setPaperSizeFromUser( Size i_aUserSize )
 {
     mpImplData->mbPapersizeFromUser = true;
@@ -1429,14 +1444,10 @@ void PrinterController::setPaperSizeFromUser( Size 
i_aUserSize )
     mpImplData->maUserPageSize = i_aUserSize;
 }
 
-Size& PrinterController::getPaperSizeFromUser() const
-{
-    return mpImplData->maUserPageSize;
-}
-
-bool PrinterController::isPaperSizeFromUser() const
+void PrinterController::setOrientationFromUser( Orientation eOrientation, bool 
set )
 {
-    return mpImplData->mbPapersizeFromUser;
+    mpImplData->mbOrientationFromUser = set;
+    mpImplData->meUserOrientation = eOrientation;
 }
 
 void PrinterController::setPrinterModified( bool i_bPrinterModified )
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 46cb72752bbf..8387d8a4c760 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -1025,35 +1025,12 @@ bool PrintDialog::hasOrientationChanged() const
         || (nOrientation == ORIENTATION_PORTRAIT && eOrientation == 
Orientation::Landscape);
 }
 
-// make sure paper size matches paper orientation
-void PrintDialog::checkPaperSize( Size& rPaperSize )
-{
-    Orientation eOrientation = maPController->getPrinter()->GetOrientation();
-    if ( (eOrientation == Orientation::Portrait && rPaperSize.Width() > 
rPaperSize.Height()) ||
-         (eOrientation == Orientation::Landscape && rPaperSize.Width() < 
rPaperSize.Height()) )
-    {
-        // coverity[swapped-arguments : FALSE] - this is in the correct order
-        rPaperSize = Size( rPaperSize.Height(), rPaperSize.Width() );
-    }
-}
-
 // Always use this function to set paper orientation to make sure everything 
behaves well
-void PrintDialog::setPaperOrientation( Orientation eOrientation )
+void PrintDialog::setPaperOrientation( Orientation eOrientation, bool fromUser 
)
 {
     VclPtr<Printer> aPrt( maPController->getPrinter() );
     aPrt->SetOrientation( eOrientation );
-
-    // check if it's necessary to swap width and height of paper
-    if ( maPController->isPaperSizeFromUser() )
-    {
-        Size& aPaperSize = maPController->getPaperSizeFromUser();
-        checkPaperSize( aPaperSize );
-    }
-    else if ( maPController->getPapersizeFromSetup() )
-    {
-        Size& aPaperSize = maPController->getPaperSizeSetup();
-        checkPaperSize( aPaperSize );
-    }
+    maPController->setOrientationFromUser( eOrientation, fromUser );
 }
 
 void PrintDialog::checkControlDependencies()
@@ -1174,12 +1151,12 @@ void PrintDialog::updateNup( bool i_bMayUseCache )
         if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on 
landscape
         {
             aMPS.aPaperSize = maNupLandscapeSize;
-            setPaperOrientation( Orientation::Landscape );
+            setPaperOrientation( Orientation::Landscape, false );
         }
         else
         {
             aMPS.aPaperSize = maNupPortraitSize;
-            setPaperOrientation( Orientation::Portrait );
+            setPaperOrientation( Orientation::Portrait, false );
         }
     }
 
@@ -2000,7 +1977,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, 
void )
     {
         int nOrientation = mxOrientationBox->get_active();
         if ( nOrientation != ORIENTATION_AUTOMATIC )
-            setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ) 
);
+            setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ), 
true );
 
         updateNup( false );
     }
@@ -2026,9 +2003,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, 
void )
         else
             aPrt->SetPaper( mePaper );
 
-        Size aPaperSize( aInfo.getWidth(), aInfo.getHeight() );
-        checkPaperSize( aPaperSize );
-        maPController->setPaperSizeFromUser( aPaperSize );
+        maPController->setPaperSizeFromUser( Size( aInfo.getWidth(), 
aInfo.getHeight() ) );
 
         maUpdatePreviewIdle.Start();
     }
commit 8ad4edf43f7e143967590dac02ca72d843f9ae11
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Jan 13 15:59:49 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Feb 14 12:09:32 2022 +0100

    support for the WebP image format (tdf#114532)
    
    This commit implements a WebP reader and writer for both lossless
    and lossy WebP, export dialog options for selecting lossless/lossy
    and quality for lossy, and various internal support for the format.
    
    Since writing WebP to e.g. ODT documents would make those images
    unreadable by previous versions with no WebP support, support
    for that is explicitly disabled in GraphicFilter, to be enabled
    somewhen later.
    
    Change-Id: I9b10f6da6faa78a0bb74415a92e9f163c14685f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128920
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/Makefile.fetch b/Makefile.fetch
index 407d7d1ab985..87f423971455 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -163,6 +163,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk 
$(SRCDIR)/download.lst $(S
                $(call fetch_Optional,LIBNUMBERTEXT,LIBNUMBERTEXT_TARBALL) \
                $(call fetch_Optional,LIBPNG,LIBPNG_TARBALL) \
                $(call fetch_Optional,LIBTOMMATH,LIBTOMMATH_TARBALL) \
+               $(call fetch_Optional,LIBWEBP,LIBWEBP_TARBALL) \
                $(call fetch_Optional,LIBXML2,LIBXML_TARBALL) \
                $(call fetch_Optional,XMLSEC,XMLSEC_TARBALL) \
                $(call fetch_Optional,LIBXSLT,LIBXSLT_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index c374a72847a7..9044f574bc81 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -2734,6 +2734,57 @@ endef
 endif # !SYSTEM_LIBPNG
 
 
+ifneq ($(SYSTEM_LIBWEBP),)
+
+define gb_LinkTarget__use_libwebp
+$(call gb_LinkTarget_set_include,$(1),\
+       $$(INCLUDE) \
+       $(LIBWEBP_CFLAGS) \
+)
+
+$(call gb_LinkTarget_add_libs,$(1),\
+       $(LIBWEBP_LIBS) \
+)
+
+endef
+
+gb_ExternalProject__use_libwebp :=
+
+else # !SYSTEM_LIBWEBP
+
+define gb_LinkTarget__use_libwebp
+$(call gb_LinkTarget_set_include,$(1),\
+       $(LIBWEBP_CFLAGS) \
+       $$(INCLUDE) \
+)
+
+$(call gb_LinkTarget_set_include,$(1),\
+       -I$(call gb_UnpackedTarball_get_dir,libwebp)/src \
+       $$(INCLUDE) \
+)
+ifeq ($(OS),WNT)
+$(call gb_LinkTarget_add_libs,$(1),\
+       $(call 
gb_UnpackedTarball_get_dir,libwebp)/output/lib/libwebp$(gb_StaticLibrary_PLAINEXT)
 \
+)
+else
+$(call gb_LinkTarget_add_libs,$(1),\
+       -L$(call gb_UnpackedTarball_get_dir,libwebp)/src/.libs -lwebp \
+)
+endif
+$(call gb_LinkTarget_use_external_project,$(1),libwebp)
+
+endef
+
+define gb_ExternalProject__use_libwebp
+$(call gb_ExternalProject_use_external_project,$(1),\
+       libwebp \
+)
+
+endef
+
+endif # !SYSTEM_LIBWEBP
+
+
 ifneq ($(SYSTEM_CURL),)
 
 define gb_LinkTarget__use_curl
diff --git a/bin/lo-all-static-libs b/bin/lo-all-static-libs
index 11230c695248..fbe6d7010624 100755
--- a/bin/lo-all-static-libs
+++ b/bin/lo-all-static-libs
@@ -123,6 +123,7 @@ echo $INSTDIR/$LIBO_LIB_FOLDER/lib*.a \
      $WORKDIR/UnpackedTarball/liborcus/src/*/.libs/*.a \
      $WORKDIR/UnpackedTarball/librevenge/src/*/.libs/*.a \
      $WORKDIR/UnpackedTarball/libvisio/src/lib/.libs/*.a \
+     $WORKDIR/UnpackedTarball/libwebp/src/.libs/*.a \
      $WORKDIR/UnpackedTarball/libwp?/src/lib/.libs/*.a \
      $WORKDIR/UnpackedTarball/raptor/src/.libs/*.a \
      $WORKDIR/UnpackedTarball/rasqal/src/.libs/*.a \
diff --git a/config_host.mk.in b/config_host.mk.in
index b16826ba1088..f7f42ed45235 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -405,6 +405,8 @@ export LIBSERIALIZER_JAR=@LIBSERIALIZER_JAR@
 export LIBTOMMATH_CFLAGS=@LIBTOMMATH_CFLAGS@
 export LIBTOMMATH_LIBS=@LIBTOMMATH_LIBS@
 export LIBTOOL=@LIBTOOL@
+export LIBWEBP_CFLAGS=$(gb_SPACE)@LIBWEBP_CFLAGS@
+export LIBWEBP_LIBS=$(gb_SPACE)@LIBWEBP_LIBS@
 export LIBXML_CFLAGS=$(gb_SPACE)@LIBXML_CFLAGS@
 export LIBXML_JAR=@LIBXML_JAR@
 export LIBXML_LIBS=$(gb_SPACE)@LIBXML_LIBS@
@@ -633,6 +635,7 @@ export SYSTEM_LIBNUMBERTEXT_DATA=@SYSTEM_LIBNUMBERTEXT_DATA@
 export SYSTEM_LIBORCUS=@SYSTEM_LIBORCUS@
 export SYSTEM_LIBPNG=@SYSTEM_LIBPNG@
 export SYSTEM_LIBTOMMATH=@SYSTEM_LIBTOMMATH@
+export SYSTEM_LIBWEBP=@SYSTEM_LIBWEBP@
 export SYSTEM_LIBXML=@SYSTEM_LIBXML@
 export SYSTEM_LIBXML_FOR_BUILD=@SYSTEM_LIBXML_FOR_BUILD@
 export SYSTEM_LIBXSLT=@SYSTEM_LIBXSLT@
diff --git a/configure.ac b/configure.ac
index 633311f0b9f9..5326327f0e52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13530,6 +13530,12 @@ dnl 
===================================================================
 
 
libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng],["-I${WORKDIR}/UnpackedTarball/libpng"],["-L${WORKDIR}/LinkTarget/StaticLibrary
 -llibpng"])
 
+dnl ===================================================================
+dnl Test whether to build libwebp or rely on the system version
+dnl ===================================================================
+
+libo_CHECK_SYSTEM_MODULE([libwebp],[LIBWEBP],[libwebp])
+
 dnl ===================================================================
 dnl Check for runtime JVM search path
 dnl ===================================================================
diff --git a/download.lst b/download.lst
index 851a1188080e..86dddcb13d4d 100644
--- a/download.lst
+++ b/download.lst
@@ -186,6 +186,8 @@ export LIBNUMBERTEXT_SHA256SUM := 
db9060d208501bd7bc06300a55d8489d29dd560ee0fbbd
 export LIBNUMBERTEXT_TARBALL := libnumbertext-1.0.8.tar.xz
 export LIBTOMMATH_SHA256SUM := 
083daa92d8ee6f4af96a6143b12d7fc8fe1a547e14f862304f7281f8f7347483
 export LIBTOMMATH_TARBALL := ltm-1.0.zip
+export LIBWEBP_SHA256SUM := 
808b98d2f5b84e9b27fdef6c5372dac769c3bda4502febbfa5031bd3c4d7d018
+export LIBWEBP_TARBALL := libwebp-1.2.1.tar.gz
 export XMLSEC_SHA256SUM := 
26041d35a20a245ed5a2fb9ee075f10825664d274220cb5190340fa87a4d0931
 export XMLSEC_TARBALL := xmlsec1-1.2.33.tar.gz
 export LIBXML_SHA256SUM := 
c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92
diff --git a/external/Module_external.mk b/external/Module_external.mk
index fcb6fd6c310f..4e1a04ccc317 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -63,6 +63,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
        $(call gb_Helper_optional,LIBLANGTAG,liblangtag) \
        $(call gb_Helper_optional,LIBNUMBERTEXT,libnumbertext) \
        $(call gb_Helper_optional,LIBPNG,libpng) \
+       $(call gb_Helper_optional,LIBWEBP,libwebp) \
        $(call gb_Helper_optional,LIBXML2,libxml2) \
        $(call gb_Helper_optional,LIBXSLT,libxslt) \
        $(call gb_Helper_optional,LPSOLVE,lpsolve) \
diff --git a/external/libwebp/ExternalProject_libwebp.mk 
b/external/libwebp/ExternalProject_libwebp.mk
new file mode 100644
index 000000000000..beb7a39e7b64
--- /dev/null
+++ b/external/libwebp/ExternalProject_libwebp.mk
@@ -0,0 +1,52 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,libwebp))
+
+$(eval $(call gb_ExternalProject_register_targets,libwebp,\
+       build \
+))
+
+ifeq ($(COM),MSC)
+$(eval $(call gb_ExternalProject_use_nmake,libwebp,build))
+
+$(call gb_ExternalProject_get_state_target,libwebp,build):
+       $(call gb_Trace_StartRange,libwebp,EXTERNAL)
+       $(call gb_ExternalProject_run,build,\
+               nmake -nologo -f Makefile.vc CFG=release-static RTLIBCFG=static 
OBJDIR=output \
+       )
+       $(call gb_Trace_EndRange,libwebp,EXTERNAL)
+else
+$(eval $(call gb_ExternalProject_use_autoconf,libwebp,build))
+
+$(call gb_ExternalProject_get_state_target,libwebp,build) :
+       $(call gb_Trace_StartRange,libwebp,EXTERNAL)
+       $(call gb_ExternalProject_run,build,\
+               export PKG_CONFIG="" \
+               && MAKE=$(MAKE) $(gb_RUN_CONFIGURE) ./configure \
+                       --enable-static \
+                       --with-pic \
+                       --disable-shared \
+                       --disable-gl \
+                       --disable-sdl \
+                       --disable-png \
+                       --disable-jpeg \
+                       --disable-tiff \
+                       --disable-gif \
+                       --disable-wic \
+                       $(if 
$(verbose),--disable-silent-rules,--enable-silent-rules) \
+                       CXXFLAGS="$(gb_CXXFLAGS) $(if 
$(ENABLE_OPTIMIZED),$(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS))" \
+                       CPPFLAGS="$(CPPFLAGS) $(BOOST_CPPFLAGS)" \
+                       $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) 
--host=$(HOST_PLATFORM)) \
+               && $(MAKE) \
+       )
+       $(call gb_Trace_EndRange,libwebp,EXTERNAL)
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libwebp/Makefile b/external/libwebp/Makefile
new file mode 100644
index 000000000000..e4968cf85fb6
--- /dev/null
+++ b/external/libwebp/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libwebp/Makefile.vc.patch 
b/external/libwebp/Makefile.vc.patch
new file mode 100644
index 000000000000..653998319b82
--- /dev/null
+++ b/external/libwebp/Makefile.vc.patch
@@ -0,0 +1,145 @@
+--- Makefile.vc.sav    2021-07-30 00:55:37.000000000 +0200
++++ Makefile.vc        2022-01-25 17:35:30.206117700 +0100
+@@ -7,11 +7,11 @@
+ LIBWEBPDEMUX_BASENAME = libwebpdemux
+ 
+ !IFNDEF ARCH
+-!IF ! [ cl 2>&1 | find "x86" > NUL ]
++!IF ! [ $(CC) 2>&1 | grep -q "x86" > NUL ]
+ ARCH = x86
+-!ELSE IF ! [ cl 2>&1 | find "x64" > NUL ]
++!ELSE IF ! [ $(CC) 2>&1 | grep -q "x64" > NUL ]
+ ARCH = x64
+-!ELSE IF ! [ cl 2>&1 | find "ARM" > NUL ]
++!ELSE IF ! [ $(CC) 2>&1 | grep -q "ARM" > NUL ]
+ ARCH = ARM
+ !ELSE
+ !ERROR Unable to auto-detect toolchain architecture! \
+@@ -27,8 +27,8 @@
+ ## Nothing more to do below this line!
+ 
+ NOLOGO     = /nologo
+-CCNODBG    = cl.exe $(NOLOGO) /O2 /DNDEBUG
+-CCDEBUG    = cl.exe $(NOLOGO) /Od /Zi /D_DEBUG /RTC1
++CCNODBG    = $(CC) $(NOLOGO) /O2 /DNDEBUG
++CCDEBUG    = $(CC) $(NOLOGO) /Od /Zi /D_DEBUG /RTC1
+ CFLAGS     = /I. /Isrc $(NOLOGO) /W3 /EHsc /c
+ CFLAGS     = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN
+ LDFLAGS    = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE
+@@ -67,7 +67,7 @@
+ RTLIB   = /MD
+ RTLIBD  = /MDd
+ !ENDIF
+-DIRBASE = $(OUTDIR)\$(CFG)\$(ARCH)
++DIRBASE = $(OUTDIR)
+ DIROBJ = $(DIRBASE)\obj
+ DIRLIB = $(DIRBASE)\lib
+ DIRINC = $(DIRBASE)\include
+@@ -86,10 +86,10 @@
+ 
+ # Target configuration
+ !IF "$(CFG)" == "release-static"
+-CC             = $(CCNODBG)
++CC_             = $(CCNODBG)
+ STATICLIBBUILD = TRUE
+ !ELSE IF "$(CFG)" == "debug-static"
+-CC             = $(CCDEBUG)
++CC_             = $(CCDEBUG)
+ RTLIB          = $(RTLIBD)
+ STATICLIBBUILD = TRUE
+ LIBWEBPDECODER_BASENAME = $(LIBWEBPDECODER_BASENAME)_debug
+@@ -97,11 +97,11 @@
+ LIBWEBPMUX_BASENAME = $(LIBWEBPMUX_BASENAME)_debug
+ LIBWEBPDEMUX_BASENAME = $(LIBWEBPDEMUX_BASENAME)_debug
+ !ELSE IF "$(CFG)" == "release-dynamic"
+-CC        = $(CCNODBG)
++CC_        = $(CCNODBG)
+ RC        = $(RCNODBG)
+ DLLBUILD  = TRUE
+ !ELSE IF "$(CFG)" == "debug-dynamic"
+-CC        = $(CCDEBUG)
++CC_        = $(CCDEBUG)
+ RC        = $(RCDEBUG)
+ RTLIB     = $(RTLIBD)
+ DLLBUILD  = TRUE
+@@ -112,7 +112,7 @@
+ !ENDIF
+ 
+ !IF "$(STATICLIBBUILD)" == "TRUE"
+-CC     = $(CC) $(RTLIB)
++CC_     = $(CC_) $(RTLIB)
+ CFGSET = TRUE
+ LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME).lib
+ LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME).lib
+@@ -120,7 +120,7 @@
+ LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME).lib
+ !ELSE IF "$(DLLBUILD)" == "TRUE"
+ DLLINC = webp_dll.h
+-CC     = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL
++CC_     = $(CC_) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL
+ LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib
+ LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib
+ LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib
+@@ -421,7 +421,7 @@
+     $(DIROBJ)\$(DLLINC)
+ 
+ {$(DIROBJ)}.c{$(DIROBJ)}.obj:
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@  $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@  $<
+ 
+ {src}.rc{$(DIROBJ)}.res:
+       $(RC) /fo$@ $<
+@@ -461,39 +461,39 @@
+ # File-specific flag builds. Note batch rules take precedence over wildcards,
+ # so for now name each file individually.
+ $(DIROBJ)\examples\anim_diff.obj: examples\anim_diff.c
+-      $(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
++      $(CC_) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
+         /Fo$(DIROBJ)\examples\ examples\$(@B).c
+ $(DIROBJ)\examples\anim_dump.obj: examples\anim_dump.c
+-      $(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
++      $(CC_) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
+         /Fo$(DIROBJ)\examples\ examples\$(@B).c
+ $(DIROBJ)\examples\anim_util.obj: examples\anim_util.c
+-      $(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
++      $(CC_) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
+         /Fo$(DIROBJ)\examples\ examples\$(@B).c
+ $(DIROBJ)\examples\gif2webp.obj: examples\gif2webp.c
+-      $(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
++      $(CC_) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
+         /Fo$(DIROBJ)\examples\ examples\$(@B).c
+ $(DIROBJ)\examples\gifdec.obj: examples\gifdec.c
+-      $(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
++      $(CC_) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
+         /Fo$(DIROBJ)\examples\ examples\$(@B).c
+ # Batch rules
+ {examples}.c{$(DIROBJ)\examples}.obj::
+-      $(CC) $(CFLAGS) /Fd$(DIROBJ)\examples\ /Fo$(DIROBJ)\examples\ $<
++      $(CC_) $(CFLAGS) /Fd$(DIROBJ)\examples\ /Fo$(DIROBJ)\examples\ $<
+ {extras}.c{$(DIROBJ)\extras}.obj::
+-      $(CC) $(CFLAGS) /Fd$(DIROBJ)\extras\ /Fo$(DIROBJ)\extras\ $<
++      $(CC_) $(CFLAGS) /Fd$(DIROBJ)\extras\ /Fo$(DIROBJ)\extras\ $<
+ {imageio}.c{$(DIROBJ)\imageio}.obj::
+-      $(CC) $(CFLAGS) /Fd$(DIROBJ)\imageio\ /Fo$(DIROBJ)\imageio\ $<
++      $(CC_) $(CFLAGS) /Fd$(DIROBJ)\imageio\ /Fo$(DIROBJ)\imageio\ $<
+ {src\dec}.c{$(DIROBJ)\dec}.obj::
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\dec\ $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\dec\ $<
+ {src\demux}.c{$(DIROBJ)\demux}.obj::
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\demux\ $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\demux\ $<
+ {src\dsp}.c{$(DIROBJ)\dsp}.obj::
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\dsp\ $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\dsp\ $<
+ {src\enc}.c{$(DIROBJ)\enc}.obj::
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\enc\ $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\enc\ $<
+ {src\mux}.c{$(DIROBJ)\mux}.obj::
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\mux\ $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\mux\ $<
+ {src\utils}.c{$(DIROBJ)\utils}.obj::
+-      $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\utils\ $<
++      $(CC_) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\utils\ $<
+ 
+ LNKLIBS     = ole32.lib windowscodecs.lib shlwapi.lib
+ !IF "$(UNICODE)" == "1"
diff --git a/external/libwebp/Module_libwebp.mk 
b/external/libwebp/Module_libwebp.mk
new file mode 100644
index 000000000000..b89056ac3d35
--- /dev/null
+++ b/external/libwebp/Module_libwebp.mk
@@ -0,0 +1,17 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,libwebp))
+
+$(eval $(call gb_Module_add_targets,libwebp,\
+       ExternalProject_libwebp \
+       UnpackedTarball_libwebp \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libwebp/README b/external/libwebp/README
new file mode 100644
index 000000000000..1308c278baca
--- /dev/null
+++ b/external/libwebp/README
@@ -0,0 +1 @@
+libwebp is a library to encode and decode images in WebP format, from 
[https://developers.google.com/speed/webp/]
diff --git a/external/libwebp/UnpackedTarball_libwebp.mk 
b/external/libwebp/UnpackedTarball_libwebp.mk
new file mode 100644
index 000000000000..67f797157717
--- /dev/null
+++ b/external/libwebp/UnpackedTarball_libwebp.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,libwebp))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,libwebp,$(LIBWEBP_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libwebp,0))
+
+$(eval $(call gb_UnpackedTarball_add_patches,libwebp,\
+       external/libwebp/Makefile.vc.patch \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index dfeacc6a542c..a58b8396c551 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -442,6 +442,7 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_web_filters.xc
        writer_web_pdf_Export\
        writer_web_png_Export\
        writer_web_jpg_Export\
+       writer_web_webp_Export\
        writerweb8_writer_template\
        writerweb8_writer \
 ))
@@ -715,6 +716,7 @@ $(eval $(call 
filter_Configuration_add_types,fcfg_langpack,fcfg_drawgraphics_typ
        svm_StarView_Metafile \
        tga_Truevision_TARGA \
        tif_Tag_Image_File \
+       webp_WebP \
        wmf_MS_Windows_Metafile \
        xbm_X_Consortium \
        xpm_XPM \
@@ -742,6 +744,7 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f
        SVM___StarView_Metafile \
        TGA___Truevision_TARGA \
        TIF___Tag_Image_File \
+       WEBP___WebP \
        WMF___MS_Windows_Metafile \
        XBM___X_Consortium \
        XPM \
@@ -757,6 +760,7 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f
        draw_png_Export \
        draw_svg_Export \
        draw_tif_Export \
+       draw_webp_Export \
        draw_wmf_Export \
 ))
 
@@ -781,6 +785,7 @@ $(eval $(call 
filter_Configuration_add_types,fcfg_langpack,fcfg_impressgraphics_
        svm_StarView_Metafile \
        tif_Tag_Image_File \
        wmf_MS_Windows_Metafile \
+       webp_WebP \
        xpm_XPM \
 ))
 
@@ -795,6 +800,7 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_impressgraphic
        impress_png_Export \
        impress_svg_Export \
        impress_tif_Export \
+       impress_webp_Export \
        impress_wmf_Export \
 ))
 
@@ -809,6 +815,7 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_writergraphics
        writer_jpg_Export \
        writer_png_Export \
        writer_svg_Export \
+       writer_webp_Export \
 ))
 
 # fcfg_calcgraphics
@@ -821,6 +828,7 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_calcgraphics_f
        calc_jpg_Export \
        calc_png_Export \
        calc_svg_Export \
+       calc_webp_Export \
 ))
 
 # fcfg_internalgraphics
@@ -848,6 +856,7 @@ $(eval $(call 
filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics
        svm_StarView_Metafile \
        tga_Truevision_TARGA \
        tif_Tag_Image_File \
+       webp_WebP \
        wmf_MS_Windows_Metafile \
        xbm_X_Consortium \
        xpm_XPM \
@@ -887,11 +896,13 @@ $(eval $(call 
filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_inter
        tga_Import \
        tif_Export \
        tif_Import \
+       webp_Export \
+       webp_Import \
        wmf_Export \
        wmf_Import \
        xbm_Import \
        xpm_Import \
-        mov_Import \
+       mov_Import \
 ))
 
 # fcfg_xslt
diff --git a/filter/qa/complex/filter/detection/typeDetection/files.csv 
b/filter/qa/complex/filter/detection/typeDetection/files.csv
index b882ea1179ca..8e558590b4e7 100644
--- a/filter/qa/complex/filter/detection/typeDetection/files.csv
+++ b/filter/qa/complex/filter/detection/typeDetection/files.csv
@@ -111,6 +111,7 @@ 
ppm;Graphics/pic.ppm;ppm_Portable_Pixelmap;ppm_Portable_Pixelmap
 ras;Graphics/pic.ras;ras_Sun_Rasterfile;ras_Sun_Rasterfile
 svm;Graphics/pic.svm;svm_StarView_Metafile;svm_StarView_Metafile:generic_Text
 tif;Graphics/pic.tif;tif_Tag_Image_File;tif_Tag_Image_File:generic_Text
+webp;Graphics/pic.webp;webp_WebP;webp_WebP
 
wmf;Graphics/pic.wmf;wmf_MS_Windows_Metafile;wmf_MS_Windows_Metafile:generic_Text
 
 
diff --git a/filter/source/config/cache/typedetection.cxx 
b/filter/source/config/cache/typedetection.cxx
index ac4d9aed9f2a..b91ac31566af 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -232,6 +232,7 @@ int getFlatTypeRank(const OUString& rType)
         "pcd_Photo_CD_Base",
         "pcd_Photo_CD_Base4",
         "pcd_Photo_CD_Base16",
+        "webp_WebP",
         "impress_CGM_Computer_Graphics_Metafile", // There is binary and ascii 
variants ?
         "draw_WordPerfect_Graphics",
         "draw_Visio_Document",
diff --git a/filter/source/config/fragments/filters/WEBP___WebP.xcu 
b/filter/source/config/fragments/filters/WEBP___WebP.xcu
new file mode 100644
index 000000000000..9c650e3de42e
--- /dev/null
+++ b/filter/source/config/fragments/filters/WEBP___WebP.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="WEBP - WebP" oor:op="replace">
+        <prop oor:name="Flags"><value>IMPORT ALIEN</value></prop>
+        <prop oor:name="UIComponent"/>
+        <prop oor:name="FilterService"/>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop 
oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/filters/calc_webp_Export.xcu 
b/filter/source/config/fragments/filters/calc_webp_Export.xcu
new file mode 100644
index 000000000000..a6e5d18a3347
--- /dev/null
+++ b/filter/source/config/fragments/filters/calc_webp_Export.xcu
@@ -0,0 +1,20 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+    <node oor:name="calc_webp_Export" oor:op="replace">
+        <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER 
SUPPORTSSELECTION</value></prop>
+        <prop 
oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+        <prop 
oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop 
oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/filters/draw_webp_Export.xcu 
b/filter/source/config/fragments/filters/draw_webp_Export.xcu
new file mode 100644
index 000000000000..e6da69197a61
--- /dev/null
+++ b/filter/source/config/fragments/filters/draw_webp_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="draw_webp_Export" oor:op="replace">
+        <prop oor:name="Flags"><value>EXPORT ALIEN 
SUPPORTSSELECTION</value></prop>
+        <prop 
oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+        <prop oor:name="FilterService"/>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop 
oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/filters/impress_webp_Export.xcu 
b/filter/source/config/fragments/filters/impress_webp_Export.xcu
new file mode 100644
index 000000000000..00284a272cba
--- /dev/null
+++ b/filter/source/config/fragments/filters/impress_webp_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="impress_webp_Export" oor:op="replace">
+        <prop oor:name="Flags"><value>EXPORT ALIEN 
SUPPORTSSELECTION</value></prop>
+        <prop 
oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+        <prop oor:name="FilterService"/>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop 
oor:name="DocumentService"><value>com.sun.star.presentation.PresentationDocument</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/filters/writer_web_webp_Export.xcu 
b/filter/source/config/fragments/filters/writer_web_webp_Export.xcu
new file mode 100644
index 000000000000..5273bb72228b
--- /dev/null
+++ b/filter/source/config/fragments/filters/writer_web_webp_Export.xcu
@@ -0,0 +1,21 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+    <node oor:name="writer_web_webp_Export" oor:op="replace">
+        <prop oor:name="Flags"><value>EXPORT ALIEN 
3RDPARTYFILTER</value></prop>
+        <prop 
oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+        <prop 
oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop 
oor:name="DocumentService"><value>com.sun.star.text.WebDocument</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/filters/writer_webp_Export.xcu 
b/filter/source/config/fragments/filters/writer_webp_Export.xcu
new file mode 100644
index 000000000000..ceb56a8c035f
--- /dev/null
+++ b/filter/source/config/fragments/filters/writer_webp_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="writer_webp_Export" oor:op="replace">
+        <prop oor:name="Flags"><value>EXPORT ALIEN 
3RDPARTYFILTER</value></prop>
+        <prop 
oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+        <prop 
oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop 
oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+    </node>
diff --git 
a/filter/source/config/fragments/internalgraphicfilters/webp_Export.xcu 
b/filter/source/config/fragments/internalgraphicfilters/webp_Export.xcu
new file mode 100644
index 000000000000..70ff15429734
--- /dev/null
+++ b/filter/source/config/fragments/internalgraphicfilters/webp_Export.xcu
@@ -0,0 +1,27 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="webp_Export" oor:op="replace"  >
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="FormatName"><value>SVEWEBP</value></prop>
+        <prop oor:name="RealFilterName"/>
+        <prop 
oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="Flags"><value>EXPORT</value></prop>
+    </node>
diff --git 
a/filter/source/config/fragments/internalgraphicfilters/webp_Import.xcu 
b/filter/source/config/fragments/internalgraphicfilters/webp_Import.xcu
new file mode 100644
index 000000000000..cdce5c9e4047
--- /dev/null
+++ b/filter/source/config/fragments/internalgraphicfilters/webp_Import.xcu
@@ -0,0 +1,27 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="webp_Import" oor:op="replace"  >
+        <prop oor:name="Type"><value>webp_WebP</value></prop>
+        <prop oor:name="FormatName"><value>SVIWEBP</value></prop>
+        <prop oor:name="RealFilterName"><value>WEBP - WebP</value></prop>
+        <prop oor:name="UIComponent"/>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="Flags"><value>IMPORT</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/types/webp_WebP.xcu 
b/filter/source/config/fragments/types/webp_WebP.xcu
new file mode 100644
index 000000000000..e58984fbedc7
--- /dev/null
+++ b/filter/source/config/fragments/types/webp_WebP.xcu
@@ -0,0 +1,29 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="webp_WebP" oor:op="replace" >
+        <prop 
oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
+        <prop oor:name="URLPattern"/>
+        <prop oor:name="Extensions"><value>webp</value></prop>
+        <prop oor:name="MediaType"><value>image/webp</value></prop>
+        <prop oor:name="Preferred"><value>false</value></prop>
+        <prop oor:name="PreferredFilter"><value>WEBP - WebP</value></prop>
+        <prop oor:name="UIName">
+            <value>WEBP - WebP Image</value>
+        </prop>
+        <prop oor:name="ClipboardFormat"/>
+    </node>
diff --git a/icon-themes/breeze/res/sx03223.png 
b/icon-themes/breeze/res/sx03223.png
new file mode 100644
index 000000000000..82e6f7b14f31
Binary files /dev/null and b/icon-themes/breeze/res/sx03223.png differ
diff --git a/icon-themes/breeze_dark/res/sx03223.png 
b/icon-themes/breeze_dark/res/sx03223.png
new file mode 100644
index 000000000000..82e6f7b14f31
Binary files /dev/null and b/icon-themes/breeze_dark/res/sx03223.png differ
diff --git a/icon-themes/breeze_dark_svg/res/sx03223.svg 
b/icon-themes/breeze_dark_svg/res/sx03223.svg
new file mode 100644
index 000000000000..576860153fb7
--- /dev/null
+++ b/icon-themes/breeze_dark_svg/res/sx03223.svg
@@ -0,0 +1 @@

... etc. - the rest is truncated

Reply via email to