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