64af5b
From 952553d3998a1d6fbb0d197f81b769438a48a372 Mon Sep 17 00:00:00 2001
64af5b
From: Stephan Bergmann <sbergman@redhat.com>
64af5b
Date: Fri, 7 Jun 2019 09:28:12 +0200
64af5b
Subject: [PATCH] More uses of referer URL with SvxBrushItem
64af5b
64af5b
Reviewed-on: https://gerrit.libreoffice.org/73643
64af5b
Tested-by: Jenkins
64af5b
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
64af5b
(cherry picked from commit b518882de8213ef71a8003f95fbdf7689069c06d)
64af5b
Conflicts:
64af5b
	sw/source/core/text/porfld.cxx
64af5b
	sw/source/core/unocore/unosett.cxx
64af5b
64af5b
Change-Id: I04b524784df4ef453d8b1feec13b62f183a17e23
64af5b
Reviewed-on: https://gerrit.libreoffice.org/73860
64af5b
Tested-by: Jenkins
64af5b
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
64af5b
---
64af5b
 sw/inc/unosett.hxx                                |  2 +-
64af5b
 sw/source/core/text/porfld.cxx                    |  4 ++--
64af5b
 sw/source/core/text/porfld.hxx                    |  1 +
64af5b
 sw/source/core/text/txtfld.cxx                    | 12 +++++++++++-
64af5b
 sw/source/core/unocore/unosett.cxx                | 15 ++++++++++++---
64af5b
 .../uibase/config/StoredChapterNumbering.cxx      |  2 +-
64af5b
 6 files changed, 28 insertions(+), 8 deletions(-)
64af5b
64af5b
diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx
64af5b
index 295eb06..185b5bc 100644
64af5b
--- a/sw/inc/unosett.hxx
64af5b
+++ b/sw/inc/unosett.hxx
64af5b
@@ -210,7 +210,7 @@ public:
64af5b
 
64af5b
     static css::uno::Sequence<css::beans::PropertyValue> GetPropertiesForNumFormat(
64af5b
             const SwNumFormat& rFormat, OUString const& rCharFormatName,
64af5b
-            OUString const* pHeadingStyleName);
64af5b
+            OUString const* pHeadingStyleName, OUString const & referer);
64af5b
     static void SetPropertiesToNumFormat(
64af5b
             SwNumFormat & aFormat,
64af5b
             OUString & rCharStyleName,
64af5b
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
64af5b
index 7771658..b29cee3 100644
64af5b
--- a/sw/source/core/text/porfld.cxx
64af5b
+++ b/sw/source/core/text/porfld.cxx
64af5b
@@ -755,7 +755,7 @@ SwBulletPortion::SwBulletPortion( const sal_Unicode cBullet,
64af5b
 
64af5b
 SwGrfNumPortion::SwGrfNumPortion(
64af5b
         const OUString& rGraphicFollowedBy,
64af5b
-        const SvxBrushItem* pGrfBrush,
64af5b
+        const SvxBrushItem* pGrfBrush, OUString const & referer,
64af5b
         const SwFormatVertOrient* pGrfOrient, const Size& rGrfSize,
64af5b
         const bool bLft, const bool bCntr, const sal_uInt16 nMinDst,
64af5b
         const bool bLabelAlignmentPosAndSpaceModeActive ) :
64af5b
@@ -769,7 +769,7 @@ SwGrfNumPortion::SwGrfNumPortion(
64af5b
     if( pGrfBrush )
64af5b
     {
64af5b
         *pBrush = *pGrfBrush;
64af5b
-        const Graphic* pGraph = pGrfBrush->GetGraphic();
64af5b
+        const Graphic* pGraph = pGrfBrush->GetGraphic(referer);
64af5b
         if( pGraph )
64af5b
             SetAnimated( pGraph->IsAnimated() );
64af5b
         else
64af5b
diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx
64af5b
index 38fc089..4ecf25e 100644
64af5b
--- a/sw/source/core/text/porfld.hxx
64af5b
+++ b/sw/source/core/text/porfld.hxx
64af5b
@@ -168,6 +168,7 @@ class SwGrfNumPortion : public SwNumberPortion
64af5b
 public:
64af5b
     SwGrfNumPortion( const OUString& rGraphicFollowedBy,
64af5b
                      const SvxBrushItem* pGrfBrush,
64af5b
+                     OUString const & referer,
64af5b
                      const SwFormatVertOrient* pGrfOrient,
64af5b
                      const Size& rGrfSize,
64af5b
                      const bool bLeft,
64af5b
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
64af5b
index 6b2b938..14e3968 100644
64af5b
--- a/sw/source/core/text/txtfld.cxx
64af5b
+++ b/sw/source/core/text/txtfld.cxx
64af5b
@@ -52,6 +52,7 @@
64af5b
 #include <flddat.hxx>
64af5b
 #include <fmtautofmt.hxx>
64af5b
 #include <IDocumentSettingAccess.hxx>
64af5b
+#include <sfx2/docfile.hxx>
64af5b
 #include <svl/itemiter.hxx>
64af5b
 
64af5b
 static bool lcl_IsInBody( SwFrame const *pFrame )
64af5b
@@ -478,8 +479,17 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
64af5b
 
64af5b
         if( SVX_NUM_BITMAP == rNumFormat.GetNumberingType() )
64af5b
         {
64af5b
+            OUString referer;
64af5b
+            if (auto const sh1 = rInf.GetVsh()) {
64af5b
+                if (auto const doc = sh1->GetDoc()) {
64af5b
+                    auto const sh2 = doc->GetPersist();
64af5b
+                    if (sh2 != nullptr && sh2->HasName()) {
64af5b
+                        referer = sh2->GetMedium()->GetName();
64af5b
+                    }
64af5b
+                }
64af5b
+            }
64af5b
             pRet = new SwGrfNumPortion( pTextNd->GetLabelFollowedBy(),
64af5b
-                                        rNumFormat.GetBrush(),
64af5b
+                                        rNumFormat.GetBrush(), referer,
64af5b
                                         rNumFormat.GetGraphicOrientation(),
64af5b
                                         rNumFormat.GetGraphicSize(),
64af5b
                                         bLeft, bCenter, nMinDist,
64af5b
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
64af5b
index f7376b9..44cd118 100644
64af5b
--- a/sw/source/core/unocore/unosett.cxx
64af5b
+++ b/sw/source/core/unocore/unosett.cxx
64af5b
@@ -55,6 +55,7 @@
64af5b
 #include <o3tl/any.hxx>
64af5b
 #include <o3tl/enumarray.hxx>
64af5b
 #include <vcl/font.hxx>
64af5b
+#include <sfx2/docfile.hxx>
64af5b
 #include <editeng/flstitem.hxx>
64af5b
 #include <vcl/metric.hxx>
64af5b
 #include <svtools/ctrltool.hxx>
64af5b
@@ -1316,13 +1317,21 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex(
64af5b
         SwStyleNameMapper::FillProgName(sValue, aUString, SwGetPoolIdFromName::TxtColl);
64af5b
     }
64af5b
 
64af5b
-    return GetPropertiesForNumFormat(rFormat, CharStyleName, (pDocShell) ? & aUString : nullptr);
64af5b
+    OUString referer;
64af5b
+    if (pDoc != nullptr) {
64af5b
+        auto const sh = pDoc->GetPersist();
64af5b
+        if (sh != nullptr && sh->HasName()) {
64af5b
+            referer = sh->GetMedium()->GetName();
64af5b
+        }
64af5b
+    }
64af5b
+    return GetPropertiesForNumFormat(
64af5b
+        rFormat, CharStyleName, (pDocShell) ? & aUString : nullptr, referer);
64af5b
 
64af5b
 }
64af5b
 
64af5b
 uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat(
64af5b
         const SwNumFormat& rFormat, OUString const& rCharFormatName,
64af5b
-        OUString const*const pHeadingStyleName)
64af5b
+        OUString const*const pHeadingStyleName, OUString const & referer)
64af5b
 {
64af5b
     bool bChapterNum = pHeadingStyleName != nullptr;
64af5b
 
64af5b
@@ -1454,7 +1463,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat
64af5b
             //graphicbitmap
64af5b
             const Graphic* pGraphic = nullptr;
64af5b
             if(pBrush )
64af5b
-                pGraphic = pBrush->GetGraphic();
64af5b
+                pGraphic = pBrush->GetGraphic(referer);
64af5b
             if(pGraphic)
64af5b
             {
64af5b
                 uno::Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( pGraphic->GetBitmapEx() );
64af5b
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx
64af5b
index c575863..b972ec5 100644
64af5b
--- a/sw/source/uibase/config/StoredChapterNumbering.cxx
64af5b
+++ b/sw/source/uibase/config/StoredChapterNumbering.cxx
64af5b
@@ -129,7 +129,7 @@ public:
64af5b
         OUString dummy; // pass in empty HeadingStyleName - can't import anyway
64af5b
         uno::Sequence<beans::PropertyValue> const ret(
64af5b
             SwXNumberingRules::GetPropertiesForNumFormat(
64af5b
-                *pNumFormat, *pCharStyleName, &dummy));
64af5b
+                *pNumFormat, *pCharStyleName, &dummy, ""));
64af5b
         return uno::makeAny(ret);
64af5b
     }
64af5b
 
64af5b
-- 
64af5b
2.20.1
64af5b