b1bd9f
From 5d0796bc14c43fa6c3e1417046e241db89306fed Mon Sep 17 00:00:00 2001
b1bd9f
From: Stephan Bergmann <sbergman@redhat.com>
b1bd9f
Date: Fri, 7 Jun 2019 09:28:12 +0200
b1bd9f
Subject: [PATCH] More uses of referer URL with SvxBrushItem
b1bd9f
b1bd9f
Reviewed-on: https://gerrit.libreoffice.org/73643
b1bd9f
Tested-by: Jenkins
b1bd9f
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
b1bd9f
(cherry picked from commit b518882de8213ef71a8003f95fbdf7689069c06d)
b1bd9f
Conflicts:
b1bd9f
	sw/source/core/text/porfld.cxx
b1bd9f
	sw/source/core/unocore/unosett.cxx
b1bd9f
b1bd9f
Change-Id: I04b524784df4ef453d8b1feec13b62f183a17e23
b1bd9f
Reviewed-on: https://gerrit.libreoffice.org/73860
b1bd9f
Tested-by: Jenkins
b1bd9f
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
b1bd9f
---
b1bd9f
 sw/inc/unosett.hxx                                |  2 +-
b1bd9f
 sw/source/core/text/porfld.cxx                    |  4 ++--
b1bd9f
 sw/source/core/text/porfld.hxx                    |  1 +
b1bd9f
 sw/source/core/text/txtfld.cxx                    | 12 +++++++++++-
b1bd9f
 sw/source/core/unocore/unosett.cxx                | 15 ++++++++++++---
b1bd9f
 .../uibase/config/StoredChapterNumbering.cxx      |  2 +-
b1bd9f
 6 files changed, 28 insertions(+), 8 deletions(-)
b1bd9f
b1bd9f
diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx
b1bd9f
index 6386f4f..e90797e 100644
b1bd9f
--- a/sw/inc/unosett.hxx
b1bd9f
+++ b/sw/inc/unosett.hxx
b1bd9f
@@ -208,7 +208,7 @@ public:
b1bd9f
 
b1bd9f
     static css::uno::Sequence<css::beans::PropertyValue> GetPropertiesForNumFormat(
b1bd9f
             const SwNumFormat& rFormat, OUString const& rCharFormatName,
b1bd9f
-            OUString const* pHeadingStyleName);
b1bd9f
+            OUString const* pHeadingStyleName, OUString const & referer);
b1bd9f
     static void SetPropertiesToNumFormat(
b1bd9f
             SwNumFormat & aFormat,
b1bd9f
             OUString & rCharStyleName,
b1bd9f
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
b1bd9f
index 4f24e63..ba60112 100644
b1bd9f
--- a/sw/source/core/text/porfld.cxx
b1bd9f
+++ b/sw/source/core/text/porfld.cxx
b1bd9f
@@ -756,7 +756,7 @@ SwBulletPortion::SwBulletPortion( const sal_Unicode cBullet,
b1bd9f
 SwGrfNumPortion::SwGrfNumPortion(
b1bd9f
         SwFrame*,
b1bd9f
         const OUString& rGraphicFollowedBy,
b1bd9f
-        const SvxBrushItem* pGrfBrush,
b1bd9f
+        const SvxBrushItem* pGrfBrush, OUString const & referer,
b1bd9f
         const SwFormatVertOrient* pGrfOrient, const Size& rGrfSize,
b1bd9f
         const bool bLft, const bool bCntr, const sal_uInt16 nMinDst,
b1bd9f
         const bool bLabelAlignmentPosAndSpaceModeActive ) :
b1bd9f
@@ -770,7 +770,7 @@ SwGrfNumPortion::SwGrfNumPortion(
b1bd9f
     if( pGrfBrush )
b1bd9f
     {
b1bd9f
         *pBrush = *pGrfBrush;
b1bd9f
-        const Graphic* pGraph = pGrfBrush->GetGraphic();
b1bd9f
+        const Graphic* pGraph = pGrfBrush->GetGraphic(referer);
b1bd9f
         if( pGraph )
b1bd9f
             SetAnimated( pGraph->IsAnimated() );
b1bd9f
         else
b1bd9f
diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx
b1bd9f
index 740c2d9..d648a0f 100644
b1bd9f
--- a/sw/source/core/text/porfld.hxx
b1bd9f
+++ b/sw/source/core/text/porfld.hxx
b1bd9f
@@ -170,6 +170,7 @@ public:
b1bd9f
     SwGrfNumPortion( SwFrame *pFrame,
b1bd9f
                      const OUString& rGraphicFollowedBy,
b1bd9f
                      const SvxBrushItem* pGrfBrush,
b1bd9f
+                     OUString const & referer,
b1bd9f
                      const SwFormatVertOrient* pGrfOrient,
b1bd9f
                      const Size& rGrfSize,
b1bd9f
                      const bool bLeft,
b1bd9f
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
b1bd9f
index 239e2a3..b6f2c5e 100644
b1bd9f
--- a/sw/source/core/text/txtfld.cxx
b1bd9f
+++ b/sw/source/core/text/txtfld.cxx
b1bd9f
@@ -52,6 +52,7 @@
b1bd9f
 #include "flddat.hxx"
b1bd9f
 #include "fmtautofmt.hxx"
b1bd9f
 #include <IDocumentSettingAccess.hxx>
b1bd9f
+#include <sfx2/docfile.hxx>
b1bd9f
 #include <svl/itemiter.hxx>
b1bd9f
 
b1bd9f
 static bool lcl_IsInBody( SwFrame *pFrame )
b1bd9f
@@ -478,9 +479,18 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
b1bd9f
 
b1bd9f
         if( SVX_NUM_BITMAP == rNumFormat.GetNumberingType() )
b1bd9f
         {
b1bd9f
+            OUString referer;
b1bd9f
+            if (auto const sh1 = rInf.GetVsh()) {
b1bd9f
+                if (auto const doc = sh1->GetDoc()) {
b1bd9f
+                    auto const sh2 = doc->GetPersist();
b1bd9f
+                    if (sh2 != nullptr && sh2->HasName()) {
b1bd9f
+                        referer = sh2->GetMedium()->GetName();
b1bd9f
+                    }
b1bd9f
+                }
b1bd9f
+            }
b1bd9f
             pRet = new SwGrfNumPortion( const_cast<SwTextFrame*>(GetTextFrame()),
b1bd9f
                                         pTextNd->GetLabelFollowedBy(),
b1bd9f
-                                        rNumFormat.GetBrush(),
b1bd9f
+                                        rNumFormat.GetBrush(), referer,
b1bd9f
                                         rNumFormat.GetGraphicOrientation(),
b1bd9f
                                         rNumFormat.GetGraphicSize(),
b1bd9f
                                         bLeft, bCenter, nMinDist,
b1bd9f
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
b1bd9f
index 716ab9d..13dc05f 100644
b1bd9f
--- a/sw/source/core/unocore/unosett.cxx
b1bd9f
+++ b/sw/source/core/unocore/unosett.cxx
b1bd9f
@@ -53,6 +53,7 @@
b1bd9f
 #include <com/sun/star/style/VerticalAlignment.hpp>
b1bd9f
 #include <o3tl/any.hxx>
b1bd9f
 #include <vcl/font.hxx>
b1bd9f
+#include <sfx2/docfile.hxx>
b1bd9f
 #include <editeng/flstitem.hxx>
b1bd9f
 #include <vcl/metric.hxx>
b1bd9f
 #include <svtools/ctrltool.hxx>
b1bd9f
@@ -1342,13 +1343,21 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex(
b1bd9f
         SwStyleNameMapper::FillProgName(sValue, aUString, SwGetPoolIdFromName::TxtColl, true);
b1bd9f
     }
b1bd9f
 
b1bd9f
-    return GetPropertiesForNumFormat(rFormat, CharStyleName, (pDocShell) ? & aUString : nullptr);
b1bd9f
+    OUString referer;
b1bd9f
+    if (pDoc != nullptr) {
b1bd9f
+        auto const sh = pDoc->GetPersist();
b1bd9f
+        if (sh != nullptr && sh->HasName()) {
b1bd9f
+            referer = sh->GetMedium()->GetName();
b1bd9f
+        }
b1bd9f
+    }
b1bd9f
+    return GetPropertiesForNumFormat(
b1bd9f
+        rFormat, CharStyleName, (pDocShell) ? & aUString : nullptr, referer);
b1bd9f
 
b1bd9f
 }
b1bd9f
 
b1bd9f
 uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat(
b1bd9f
         const SwNumFormat& rFormat, OUString const& rCharFormatName,
b1bd9f
-        OUString const*const pHeadingStyleName)
b1bd9f
+        OUString const*const pHeadingStyleName, OUString const & referer)
b1bd9f
 {
b1bd9f
     bool bChapterNum = pHeadingStyleName != nullptr;
b1bd9f
 
b1bd9f
@@ -1480,7 +1489,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat
b1bd9f
             //graphicbitmap
b1bd9f
             const Graphic* pGraphic = nullptr;
b1bd9f
             if(pBrush )
b1bd9f
-                pGraphic = pBrush->GetGraphic();
b1bd9f
+                pGraphic = pBrush->GetGraphic(referer);
b1bd9f
             if(pGraphic)
b1bd9f
             {
b1bd9f
                 uno::Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( pGraphic->GetBitmapEx() );
b1bd9f
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx
b1bd9f
index 2464878..a56aeeb 100644
b1bd9f
--- a/sw/source/uibase/config/StoredChapterNumbering.cxx
b1bd9f
+++ b/sw/source/uibase/config/StoredChapterNumbering.cxx
b1bd9f
@@ -135,7 +135,7 @@ public:
b1bd9f
         OUString dummy; // pass in empty HeadingStyleName - can't import anyway
b1bd9f
         uno::Sequence<beans::PropertyValue> const ret(
b1bd9f
             SwXNumberingRules::GetPropertiesForNumFormat(
b1bd9f
-                *pNumFormat, *pCharStyleName, &dummy));
b1bd9f
+                *pNumFormat, *pCharStyleName, &dummy, ""));
b1bd9f
         return uno::makeAny(ret);
b1bd9f
     }
b1bd9f
 
b1bd9f
-- 
b1bd9f
2.20.1
b1bd9f