Files
odfstudio/sw/source/core/inc/FillBitmapLinkTracker.hxx
T
Caolán McNamara 928a715ddf register writer XATTR_FILLBITMAP URLs as SvBaseLinks via SwFormat...
...and SwContentNode

rather than digging around via pool ItemSurrogates for these writer
elements

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4222cc9aeda1335252f48c4242edfc5fc71a60f0
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/3471
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit d8a09afac6108d7ba23b253ed83b564af8a31c55)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208082
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-25 01:47:59 +02:00

63 lines
2.1 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*/
#ifndef INCLUDED_SW_SOURCE_CORE_INC_FILLBITMAPLINKTRACKER_HXX
#define INCLUDED_SW_SOURCE_CORE_INC_FILLBITMAPLINKTRACKER_HXX
#include <rtl/ustring.hxx>
#include <tools/ref.hxx>
#include <map>
#include <string_view>
class SwContentNode;
class SwDoc;
class SwFormat;
namespace sfx2
{
class SvBaseLink;
}
namespace sw
{
// Owns one sfx2::SvBaseLink per SwFormat or SwContentNode that currently
// holds a deferred XFillBitmapItem URL. Links are registered as soon as
// the deferred item is set.
//
// When the graphic resolves, DataChanged calls SetFormatAttr / SetAttr on the
// host with the fetched graphic. Each link also listens to its host's notifier
// and self-deregisters on Dying so a link never outlives its host.
class FillBitmapLinkTracker final
{
public:
explicit FillBitmapLinkTracker(SwDoc& rDoc);
~FillBitmapLinkTracker();
// Called by SwFormat::SwClientNotify / SwContentNode::SwClientNotify
// when XATTR_FILLBITMAP changes in the host's own attribute set, and
// from the link itself on host-Dying to drop the stale entry. rNewURL
// is the deferred origin URL of the new item, or empty when the item
// is absent, already resolved, or the host is going away.
void onFillBitmapURLChanged(SwFormat& rFormat, std::u16string_view rNewURL);
void onFillBitmapURLChanged(SwContentNode& rNode, std::u16string_view rNewURL);
private:
template <typename Host>
void onURLChangedImpl(std::map<Host*, tools::SvRef<sfx2::SvBaseLink>>& rMap, Host& rHost,
std::u16string_view rNewURL);
SwDoc& m_rDoc;
std::map<SwFormat*, tools::SvRef<sfx2::SvBaseLink>> m_aLinks;
std::map<SwContentNode*, tools::SvRef<sfx2::SvBaseLink>> m_aNodeLinks;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */